From 7f53cbeca711af1b99bc3d6851ecdbb05eda32f3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 20 Jan 2023 09:58:59 +0000 Subject: [PATCH] Fix types --- .../server/src/api/controllers/row/ExternalRequest.ts | 3 ++- packages/server/src/api/controllers/table/external.ts | 5 +++-- packages/server/src/constants/index.ts | 6 ------ .../server/src/db/defaultData/datasource_bb_default.ts | 8 ++------ packages/server/src/db/linkedRows/LinkController.ts | 3 ++- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 6085921423..4581724910 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -10,6 +10,7 @@ import { FieldSchema, Row, Table, + RelationshipTypes, } from "@budibase/types" import { breakRowIdField, @@ -18,7 +19,7 @@ import { convertRowId, } from "../../../integrations/utils" import { getDatasourceAndQuery } from "./utils" -import { FieldTypes, RelationshipTypes } from "../../../constants" +import { FieldTypes } from "../../../constants" import { breakExternalTableId, isSQL } from "../../../integrations/utils" import { processObjectSync } from "@budibase/string-templates" import { cloneDeep } from "lodash/fp" diff --git a/packages/server/src/api/controllers/table/external.ts b/packages/server/src/api/controllers/table/external.ts index dbe09f59c1..835aba0450 100644 --- a/packages/server/src/api/controllers/table/external.ts +++ b/packages/server/src/api/controllers/table/external.ts @@ -8,7 +8,7 @@ import { foreignKeyStructure, hasTypeChanged, } from "./utils" -import { FieldTypes, RelationshipTypes } from "../../../constants" +import { FieldTypes } from "../../../constants" import { makeExternalQuery } from "../../../integrations/base/query" import { handleRequest } from "../row/external" import { events, context } from "@budibase/backend-core" @@ -22,6 +22,7 @@ import { FieldSchema, BBContext, TableRequest, + RelationshipTypes, } from "@budibase/types" import sdk from "../../../sdk" const { cloneDeep } = require("lodash/fp") @@ -146,7 +147,7 @@ function generateLinkSchema( column: FieldSchema, table: Table, relatedTable: Table, - type: string + type: RelationshipTypes ) { if (!table.primary || !relatedTable.primary) { throw new Error("Unable to generate link schema, no primary keys") diff --git a/packages/server/src/constants/index.ts b/packages/server/src/constants/index.ts index ef933769b1..ded3a91b19 100644 --- a/packages/server/src/constants/index.ts +++ b/packages/server/src/constants/index.ts @@ -38,12 +38,6 @@ export const SwitchableTypes = CanSwitchTypes.reduce((prev, current) => prev ? prev.concat(current) : current ) -export enum RelationshipTypes { - ONE_TO_MANY = "one-to-many", - MANY_TO_ONE = "many-to-one", - MANY_TO_MANY = "many-to-many", -} - export enum FormulaTypes { STATIC = "static", DYNAMIC = "dynamic", diff --git a/packages/server/src/db/defaultData/datasource_bb_default.ts b/packages/server/src/db/defaultData/datasource_bb_default.ts index 81d0488cda..516783ed31 100644 --- a/packages/server/src/db/defaultData/datasource_bb_default.ts +++ b/packages/server/src/db/defaultData/datasource_bb_default.ts @@ -1,8 +1,4 @@ -import { - FieldTypes, - AutoFieldSubTypes, - RelationshipTypes, -} from "../../constants" +import { FieldTypes, AutoFieldSubTypes } from "../../constants" import { importToRows } from "../../api/controllers/table/utils" import { cloneDeep } from "lodash/fp" import LinkDocument from "../linkedRows/LinkDocument" @@ -11,7 +7,7 @@ import { employeeImport } from "./employeeImport" import { jobsImport } from "./jobsImport" import { expensesImport } from "./expensesImport" import { db as dbCore } from "@budibase/backend-core" -import { Table, Row } from "@budibase/types" +import { Table, Row, RelationshipTypes } from "@budibase/types" export const DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs" export const DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory" diff --git a/packages/server/src/db/linkedRows/LinkController.ts b/packages/server/src/db/linkedRows/LinkController.ts index 765efb9c8f..4a154b8f19 100644 --- a/packages/server/src/db/linkedRows/LinkController.ts +++ b/packages/server/src/db/linkedRows/LinkController.ts @@ -1,13 +1,14 @@ import { IncludeDocs, getLinkDocuments } from "./linkUtils" import { InternalTables, getUserMetadataParams } from "../utils" import Sentry from "@sentry/node" -import { FieldTypes, RelationshipTypes } from "../../constants" +import { FieldTypes } from "../../constants" import { context } from "@budibase/backend-core" import LinkDocument from "./LinkDocument" import { Database, FieldSchema, LinkDocumentValue, + RelationshipTypes, Row, Table, } from "@budibase/types"