diff --git a/packages/builder/src/components/backend/DataTable/formula.js b/packages/builder/src/components/backend/DataTable/formula.js index f5ff3caec4..e3da4249bc 100644 --- a/packages/builder/src/components/backend/DataTable/formula.js +++ b/packages/builder/src/components/backend/DataTable/formula.js @@ -1,3 +1,4 @@ +import { FieldType } from "@budibase/types" import { FIELDS } from "constants/backend" import { tables } from "stores/builder" import { get as svelteGet } from "svelte/store" @@ -5,14 +6,12 @@ import { get as svelteGet } from "svelte/store" // currently supported level of relationship depth (server side) const MAX_DEPTH = 1 -//https://github.com/Budibase/budibase/issues/3030 -const internalType = "internal" - const TYPES_TO_SKIP = [ - FIELDS.FORMULA.type, - FIELDS.LONGFORM.type, - FIELDS.ATTACHMENT.type, - internalType, + FieldType.FORMULA, + FieldType.LONGFORM, + FieldType.ATTACHMENT, + //https://github.com/Budibase/budibase/issues/3030 + FieldType.INTERNAL, ] export function getBindings({ @@ -26,7 +25,7 @@ export function getBindings({ return bindings } for (let [column, schema] of Object.entries(table.schema)) { - const isRelationship = schema.type === FIELDS.LINK.type + const isRelationship = schema.type === FieldType.LINK // skip relationships after a certain depth and types which // can't bind to if ( diff --git a/packages/builder/src/components/backend/TableNavigator/utils.js b/packages/builder/src/components/backend/TableNavigator/utils.js index b7e46042be..ae7aaa0f0a 100644 --- a/packages/builder/src/components/backend/TableNavigator/utils.js +++ b/packages/builder/src/components/backend/TableNavigator/utils.js @@ -12,7 +12,7 @@ const getDefaultSchema = rows => { newSchema[column] = { name: column, type: "string", - constraints: FIELDS["STRING"].constraints, + constraints: FIELDS.STRING.constraints, } }) }) diff --git a/packages/builder/src/helpers/schemaGenerator.js b/packages/builder/src/helpers/schemaGenerator.js index 33115fc997..eb044496f6 100644 --- a/packages/builder/src/helpers/schemaGenerator.js +++ b/packages/builder/src/helpers/schemaGenerator.js @@ -1,17 +1,17 @@ -import { FIELDS } from "constants/backend" +import { FieldType } from "@budibase/types" function baseConversion(type) { if (type === "string") { return { - type: FIELDS.STRING.type, + type: FieldType.STRING, } } else if (type === "boolean") { return { - type: FIELDS.BOOLEAN.type, + type: FieldType.BOOLEAN, } } else if (type === "number") { return { - type: FIELDS.NUMBER.type, + type: FieldType.NUMBER, } } } @@ -31,7 +31,7 @@ function recurse(schemaLevel = {}, objectLevel) { const schema = recurse(schemaLevel[key], value[0]) if (schema) { schemaLevel[key] = { - type: FIELDS.ARRAY.type, + type: FieldType.ARRAY, schema, } } @@ -45,7 +45,7 @@ function recurse(schemaLevel = {}, objectLevel) { } } if (!schemaLevel.type) { - return { type: FIELDS.JSON.type, schema: schemaLevel } + return { type: FieldType.JSON, schema: schemaLevel } } else { return schemaLevel } diff --git a/packages/builder/src/helpers/utils.js b/packages/builder/src/helpers/utils.js index 6bb333f3c4..a1f9b34e3d 100644 --- a/packages/builder/src/helpers/utils.js +++ b/packages/builder/src/helpers/utils.js @@ -1,3 +1,4 @@ +import { FieldType } from "@budibase/types" import { ActionStepID } from "constants/backend/automations" import { TableNames } from "constants" import { @@ -20,20 +21,20 @@ export function buildAutoColumn(tableName, name, subtype) { switch (subtype) { case AUTO_COLUMN_SUB_TYPES.UPDATED_BY: case AUTO_COLUMN_SUB_TYPES.CREATED_BY: - type = FIELDS.LINK.type + type = FieldType.LINK constraints = FIELDS.LINK.constraints break case AUTO_COLUMN_SUB_TYPES.AUTO_ID: - type = FIELDS.NUMBER.type + type = FieldType.NUMBER constraints = FIELDS.NUMBER.constraints break case AUTO_COLUMN_SUB_TYPES.UPDATED_AT: case AUTO_COLUMN_SUB_TYPES.CREATED_AT: - type = FIELDS.DATETIME.type + type = FieldType.DATETIME constraints = FIELDS.DATETIME.constraints break default: - type = FIELDS.STRING.type + type = FieldType.STRING constraints = FIELDS.STRING.constraints break } diff --git a/packages/builder/src/stores/builder/tables.js b/packages/builder/src/stores/builder/tables.js index f86b37ab85..0163281480 100644 --- a/packages/builder/src/stores/builder/tables.js +++ b/packages/builder/src/stores/builder/tables.js @@ -1,7 +1,8 @@ +import { FieldType } from "@budibase/types" import { get, writable, derived } from "svelte/store" import { cloneDeep } from "lodash/fp" import { API } from "api" -import { SWITCHABLE_TYPES, FIELDS } from "constants/backend" +import { SWITCHABLE_TYPES } from "constants/backend" export function createTablesStore() { const store = writable({ @@ -83,14 +84,14 @@ export function createTablesStore() { // make sure tables up to date (related) let newTableIds = [] for (let column of Object.values(updatedTable?.schema || {})) { - if (column.type === FIELDS.LINK.type) { + if (column.type === FieldType.LINK) { newTableIds.push(column.tableId) } } let oldTableIds = [] for (let column of Object.values(oldTable?.schema || {})) { - if (column.type === FIELDS.LINK.type) { + if (column.type === FieldType.LINK) { oldTableIds.push(column.tableId) } }