Files
flipper/desktop/plugins/databases/ClientProtocol.js
Michael Bolin 8658fca4dd Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:52 -07:00

102 lines
2.1 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import type {PluginClient, Value} from 'flipper';
type ClientCall<Params, Response> = Params => Promise<Response>;
type DatabaseListRequest = {};
type DatabaseListResponse = Array<{
id: number,
name: string,
tables: Array<string>,
}>;
type QueryTableRequest = {
databaseId: number,
table: string,
order?: string,
reverse: boolean,
start: number,
count: number,
};
type QueryTableResponse = {
columns: Array<string>,
values: Array<Array<Value>>,
start: number,
count: number,
total: number,
};
type GetTableStructureRequest = {
databaseId: number,
table: string,
};
type GetTableStructureResponse = {
structureColumns: Array<string>,
structureValues: Array<Array<Value>>,
indexesColumns: Array<string>,
indexesValues: Array<Array<Value>>,
definition: string,
};
type ExecuteSqlRequest = {
databaseId: number,
value: string,
};
type ExecuteSqlResponse = {
type: string,
columns: Array<string>,
values: Array<Array<Value>>,
insertedId: number,
affectedCount: number,
};
type GetTableInfoRequest = {
databaseId: number,
table: string,
};
type GetTableInfoResponse = {
definition: string,
};
export class DatabaseClient {
client: PluginClient;
constructor(pluginClient: PluginClient) {
this.client = pluginClient;
}
getDatabases: ClientCall<
DatabaseListRequest,
DatabaseListResponse,
> = params => this.client.call('databaseList', {});
getTableData: ClientCall<QueryTableRequest, QueryTableResponse> = params =>
this.client.call('getTableData', params);
getTableStructure: ClientCall<
GetTableStructureRequest,
GetTableStructureResponse,
> = params => this.client.call('getTableStructure', params);
getExecution: ClientCall<ExecuteSqlRequest, ExecuteSqlResponse> = params =>
this.client.call('execute', params);
getTableInfo: ClientCall<
GetTableInfoRequest,
GetTableInfoResponse,
> = params => this.client.call('getTableInfo', params);
}