From ce1ddb44585703ba7822ec50ade07e5d07998230 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 21 Nov 2022 15:53:47 +0000 Subject: [PATCH] Import refactoring and some review updates. --- packages/backend-core/src/constants.js | 1 - packages/backend-core/src/constants.ts | 1 - .../[application]/data/datasource/bb_internal/index.svelte | 2 +- .../datasource/datasource_internal_bb_default/index.svelte | 2 +- packages/server/src/api/controllers/datasource.js | 6 +++--- packages/server/src/db/defaultData/datasource_bb_default.js | 4 ++-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/src/constants.js b/packages/backend-core/src/constants.js index 8d291a055c..7fda17f6f2 100644 --- a/packages/backend-core/src/constants.js +++ b/packages/backend-core/src/constants.js @@ -42,4 +42,3 @@ exports.Config = { exports.MAX_VALID_DATE = new Date(2147483647000) exports.DEFAULT_TENANT_ID = "default" -exports.BUDIBASE_DATASOURCE_TYPE = "budibase" diff --git a/packages/backend-core/src/constants.ts b/packages/backend-core/src/constants.ts index 8db01365b8..61b3cea1f6 100644 --- a/packages/backend-core/src/constants.ts +++ b/packages/backend-core/src/constants.ts @@ -42,4 +42,3 @@ export enum Config { export const MAX_VALID_DATE = new Date(2147483647000) export const DEFAULT_TENANT_ID = "default" -export const BUDIBASE_DATASOURCE_TYPE = "budibase" diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/index.svelte index 0627ac5d03..7188295073 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/bb_internal/index.svelte @@ -7,7 +7,7 @@ let modal - let internalTablesBySourceId = $tables.list.filter( + $: internalTablesBySourceId = $tables.list.filter( table => table.type !== "external" && $datasources.selected === table.sourceId ) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/index.svelte index b19f0d15c5..540ca20bc1 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/index.svelte @@ -6,7 +6,7 @@ import { goto } from "@roxi/routify" let modal - let internalTablesBySourceId = $tables.list.filter( + $: internalTablesBySourceId = $tables.list.filter( table => table.type !== "external" && $datasources.selected === table.sourceId ) diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 1bcfb3c423..80bd263d87 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -13,7 +13,7 @@ const { getDatasourceAndQuery } = require("./row/utils") const { invalidateDynamicVariables } = require("../../threads/utils") const { getAppDB } = require("@budibase/backend-core/context") const { events } = require("@budibase/backend-core") -const { BUDIBASE_DATASOURCE_TYPE } = require("@budibase/backend-core/constants") +const { db: dbCore } = require("@budibase/backend-core") exports.fetch = async function (ctx) { // Get internal tables @@ -52,7 +52,7 @@ exports.fetch = async function (ctx) { delete datasource.config.auth } - if (datasource.type === BUDIBASE_DATASOURCE_TYPE) { + if (datasource.type === dbCore.BUDIBASE_DATASOURCE_TYPE) { datasource.entities = internal[datasource._id] } } @@ -244,7 +244,7 @@ exports.destroy = async function (ctx) { const datasource = await db.get(datasourceId) // Delete all queries for the datasource - if (datasource.type === BUDIBASE_DATASOURCE_TYPE) { + if (datasource.type === dbCore.BUDIBASE_DATASOURCE_TYPE) { await destroyInternalTablesBySourceId(datasourceId) } else { const queries = await db.allDocs(getQueryParams(datasourceId, null)) diff --git a/packages/server/src/db/defaultData/datasource_bb_default.js b/packages/server/src/db/defaultData/datasource_bb_default.js index 7038b58fd7..f12ee2c97d 100644 --- a/packages/server/src/db/defaultData/datasource_bb_default.js +++ b/packages/server/src/db/defaultData/datasource_bb_default.js @@ -10,7 +10,7 @@ const { inventoryImport } = require("./inventoryImport") const { employeeImport } = require("./employeeImport") const { jobsImport } = require("./jobsImport") const { expensesImport } = require("./expensesImport") -const { BUDIBASE_DATASOURCE_TYPE } = require("@budibase/backend-core/constants") +const { db: dbCore } = require("@budibase/backend-core") exports.DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs" exports.DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory" @@ -19,7 +19,7 @@ exports.DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee" exports.DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default" exports.DEFAULT_BB_DATASOURCE = { _id: this.DEFAULT_BB_DATASOURCE_ID, - type: BUDIBASE_DATASOURCE_TYPE, + type: dbCore.BUDIBASE_DATASOURCE_TYPE, name: "Sample Data", source: "BUDIBASE", config: {},