Import refactoring and some review updates.

This commit is contained in:
Dean 2022-11-21 15:53:47 +00:00
parent 7fe99448f7
commit ce1ddb4458
6 changed files with 7 additions and 9 deletions

View File

@ -42,4 +42,3 @@ exports.Config = {
exports.MAX_VALID_DATE = new Date(2147483647000) exports.MAX_VALID_DATE = new Date(2147483647000)
exports.DEFAULT_TENANT_ID = "default" exports.DEFAULT_TENANT_ID = "default"
exports.BUDIBASE_DATASOURCE_TYPE = "budibase"

View File

@ -42,4 +42,3 @@ export enum Config {
export const MAX_VALID_DATE = new Date(2147483647000) export const MAX_VALID_DATE = new Date(2147483647000)
export const DEFAULT_TENANT_ID = "default" export const DEFAULT_TENANT_ID = "default"
export const BUDIBASE_DATASOURCE_TYPE = "budibase"

View File

@ -7,7 +7,7 @@
let modal let modal
let internalTablesBySourceId = $tables.list.filter( $: internalTablesBySourceId = $tables.list.filter(
table => table =>
table.type !== "external" && $datasources.selected === table.sourceId table.type !== "external" && $datasources.selected === table.sourceId
) )

View File

@ -6,7 +6,7 @@
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
let modal let modal
let internalTablesBySourceId = $tables.list.filter( $: internalTablesBySourceId = $tables.list.filter(
table => table =>
table.type !== "external" && $datasources.selected === table.sourceId table.type !== "external" && $datasources.selected === table.sourceId
) )

View File

@ -13,7 +13,7 @@ const { getDatasourceAndQuery } = require("./row/utils")
const { invalidateDynamicVariables } = require("../../threads/utils") const { invalidateDynamicVariables } = require("../../threads/utils")
const { getAppDB } = require("@budibase/backend-core/context") const { getAppDB } = require("@budibase/backend-core/context")
const { events } = require("@budibase/backend-core") 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) { exports.fetch = async function (ctx) {
// Get internal tables // Get internal tables
@ -52,7 +52,7 @@ exports.fetch = async function (ctx) {
delete datasource.config.auth delete datasource.config.auth
} }
if (datasource.type === BUDIBASE_DATASOURCE_TYPE) { if (datasource.type === dbCore.BUDIBASE_DATASOURCE_TYPE) {
datasource.entities = internal[datasource._id] datasource.entities = internal[datasource._id]
} }
} }
@ -244,7 +244,7 @@ exports.destroy = async function (ctx) {
const datasource = await db.get(datasourceId) const datasource = await db.get(datasourceId)
// Delete all queries for the datasource // Delete all queries for the datasource
if (datasource.type === BUDIBASE_DATASOURCE_TYPE) { if (datasource.type === dbCore.BUDIBASE_DATASOURCE_TYPE) {
await destroyInternalTablesBySourceId(datasourceId) await destroyInternalTablesBySourceId(datasourceId)
} else { } else {
const queries = await db.allDocs(getQueryParams(datasourceId, null)) const queries = await db.allDocs(getQueryParams(datasourceId, null))

View File

@ -10,7 +10,7 @@ const { inventoryImport } = require("./inventoryImport")
const { employeeImport } = require("./employeeImport") const { employeeImport } = require("./employeeImport")
const { jobsImport } = require("./jobsImport") const { jobsImport } = require("./jobsImport")
const { expensesImport } = require("./expensesImport") 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_JOBS_TABLE_ID = "ta_bb_jobs"
exports.DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory" 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 = "datasource_internal_bb_default"
exports.DEFAULT_BB_DATASOURCE = { exports.DEFAULT_BB_DATASOURCE = {
_id: this.DEFAULT_BB_DATASOURCE_ID, _id: this.DEFAULT_BB_DATASOURCE_ID,
type: BUDIBASE_DATASOURCE_TYPE, type: dbCore.BUDIBASE_DATASOURCE_TYPE,
name: "Sample Data", name: "Sample Data",
source: "BUDIBASE", source: "BUDIBASE",
config: {}, config: {},