* Add s3 support for generate CRUD - Dropdown enhancement to open options on initial load - Hide column selection option for s3 * Refactor the prop name * Add useS3BucketList hook WIP * Dropdown enchancement & Fix small issues * Add fetch all sheets query * Add Query to get all S3 buckets * Fix dropdown open issue * Remove defaultIsOpen prop from dropdown * Resolve comments - Remove debugger - mockSheetUrl -> getSheetUrl * Add S3 cypress test * Fix cypress test yml config * Fix generate page cypress test
106 lines
2.6 KiB
TypeScript
106 lines
2.6 KiB
TypeScript
import { DEFAULT_TEST_DATA_SOURCE_TIMEOUT_MS } from "constants/ApiConstants";
|
|
import API from "api/Api";
|
|
import { GenericApiResponse } from "./ApiResponses";
|
|
import { AxiosPromise } from "axios";
|
|
|
|
import { DatasourceAuthentication, Datasource } from "entities/Datasource";
|
|
export interface CreateDatasourceConfig {
|
|
name: string;
|
|
pluginId: string;
|
|
datasourceConfiguration: {
|
|
url: string;
|
|
databaseName?: string;
|
|
authentication?: DatasourceAuthentication;
|
|
};
|
|
//Passed for logging purposes.
|
|
appName?: string;
|
|
}
|
|
|
|
export interface EmbeddedRestDatasourceRequest {
|
|
datasourceConfiguration: { url: string };
|
|
invalids: Array<string>;
|
|
isValid: boolean;
|
|
name: string;
|
|
organizationId: string;
|
|
pluginId: string;
|
|
}
|
|
|
|
type executeQueryData = Array<{ key?: string; value?: string }>;
|
|
|
|
export interface executeDatasourceQueryRequest {
|
|
datasourceId: string;
|
|
data: executeQueryData;
|
|
}
|
|
|
|
class DatasourcesApi extends API {
|
|
static url = "v1/datasources";
|
|
|
|
static fetchDatasources(
|
|
orgId: string,
|
|
): AxiosPromise<GenericApiResponse<Datasource[]>> {
|
|
return API.get(DatasourcesApi.url + `?organizationId=${orgId}`);
|
|
}
|
|
|
|
static createDatasource(datasourceConfig: Partial<Datasource>): Promise<any> {
|
|
return API.post(DatasourcesApi.url, datasourceConfig);
|
|
}
|
|
|
|
static testDatasource(datasourceConfig: Partial<Datasource>): Promise<any> {
|
|
return API.post(`${DatasourcesApi.url}/test`, datasourceConfig, undefined, {
|
|
timeout: DEFAULT_TEST_DATA_SOURCE_TIMEOUT_MS,
|
|
});
|
|
}
|
|
|
|
static updateDatasource(
|
|
datasourceConfig: Partial<Datasource>,
|
|
id: string,
|
|
): Promise<any> {
|
|
return API.put(DatasourcesApi.url + `/${id}`, datasourceConfig);
|
|
}
|
|
|
|
static deleteDatasource(id: string): Promise<any> {
|
|
return API.delete(DatasourcesApi.url + `/${id}`);
|
|
}
|
|
|
|
static fetchDatasourceStructure(
|
|
id: string,
|
|
ignoreCache = false,
|
|
): Promise<any> {
|
|
return API.get(
|
|
DatasourcesApi.url + `/${id}/structure?ignoreCache=${ignoreCache}`,
|
|
);
|
|
}
|
|
|
|
static fetchMockDatasources(): AxiosPromise<
|
|
GenericApiResponse<Datasource[]>
|
|
> {
|
|
return API.get(DatasourcesApi.url + "/mocks");
|
|
}
|
|
|
|
static addMockDbToDatasources(
|
|
name: string,
|
|
organizationId: string,
|
|
pluginId: string,
|
|
packageName: string,
|
|
): Promise<any> {
|
|
return API.post(DatasourcesApi.url + `/mocks`, {
|
|
name,
|
|
organizationId,
|
|
pluginId,
|
|
packageName,
|
|
});
|
|
}
|
|
|
|
static executeDatasourceQuery({
|
|
data,
|
|
datasourceId,
|
|
}: executeDatasourceQueryRequest) {
|
|
return API.put(
|
|
DatasourcesApi.url + `/datasource-query` + `/${datasourceId}`,
|
|
data,
|
|
);
|
|
}
|
|
}
|
|
|
|
export default DatasourcesApi;
|