Databases plugin migrated to Sandy functional API

Summary: Converted Databases plugin to Sandy functional API

Reviewed By: mweststrate

Differential Revision: D27999205

fbshipit-source-id: e9d2c7aa5858b9da3c1672efbb558fb6b1077b6b
This commit is contained in:
Anton Nikolaev
2021-04-27 09:30:11 -07:00
committed by Facebook GitHub Bot
parent 140cf38ffd
commit c2a07e7638
3 changed files with 852 additions and 1092 deletions

View File

@@ -7,9 +7,7 @@
* @format
*/
import {PluginClient, Value} from 'flipper';
type ClientCall<Params, Response> = (arg: Params) => Promise<Response>;
import {Value} from 'flipper';
type DatabaseListRequest = {};
@@ -71,28 +69,14 @@ type GetTableInfoResponse = {
definition: string;
};
export class DatabaseClient {
client: PluginClient;
export type Methods = {
databaseList(params: DatabaseListRequest): Promise<DatabaseListResponse>;
getTableData(params: QueryTableRequest): Promise<QueryTableResponse>;
getTableStructure(
params: GetTableStructureRequest,
): Promise<GetTableStructureResponse>;
execute(params: ExecuteSqlRequest): Promise<ExecuteSqlResponse>;
getTableInfo(params: GetTableInfoRequest): Promise<GetTableInfoResponse>;
};
constructor(pluginClient: PluginClient) {
this.client = pluginClient;
}
getDatabases: ClientCall<DatabaseListRequest, DatabaseListResponse> = () =>
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);
}
export type Events = {};