From f3d5e2b4a05a87945d48c0371a5ce4f804cf1dd0 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Mon, 26 Jun 2023 13:44:23 +0100 Subject: [PATCH] remove builderstore/datasource --- .../builder/src/builderStore/datasource.js | 54 ------------------- .../PlusConfigForm.svelte | 4 +- 2 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 packages/builder/src/builderStore/datasource.js diff --git a/packages/builder/src/builderStore/datasource.js b/packages/builder/src/builderStore/datasource.js deleted file mode 100644 index 219ff7eb8f..0000000000 --- a/packages/builder/src/builderStore/datasource.js +++ /dev/null @@ -1,54 +0,0 @@ -import { datasources, tables } from "../stores/backend" -import { IntegrationNames } from "../constants/backend" -import { get } from "svelte/store" -import cloneDeep from "lodash/cloneDeepWith" -import { API } from "api" - -function prepareData(config) { - let datasource = {} - let existingTypeCount = get(datasources).list.filter( - ds => ds.source === config.type - ).length - - let baseName = IntegrationNames[config.type] || config.name - let name = - existingTypeCount === 0 ? baseName : `${baseName}-${existingTypeCount + 1}` - - datasource.type = "datasource" - datasource.source = config.type - datasource.config = config.config - datasource.name = name - datasource.plus = config.plus - - return datasource -} - -export async function saveDatasource(config, { skipFetch, tablesFilter } = {}) { - const datasource = prepareData(config) - // Create datasource - const fetchSchema = !skipFetch && datasource.plus - const resp = await datasources.save(datasource, { fetchSchema, tablesFilter }) - - // update the tables incase datasource plus - await tables.fetch() - await datasources.select(resp._id) - return resp -} - -export async function createRestDatasource(integration) { - const config = cloneDeep(integration) - return saveDatasource(config) -} - -export async function validateDatasourceConfig(config) { - const datasource = prepareData(config) - return await API.validateDatasource(datasource) -} - -export async function getDatasourceInfo(config) { - let datasource = config - if (!config._id) { - datasource = prepareData(config) - } - return await API.fetchInfoForDatasource(datasource) -} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte index 576366173a..36fb34143a 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte @@ -16,7 +16,6 @@ import ArrayRenderer from "components/common/renderers/ArrayRenderer.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte" import { goto } from "@roxi/routify" - import { getDatasourceInfo } from "builderStore/datasource" export let datasource export let save @@ -170,8 +169,7 @@