From d23a34687f954dc87752cb1b43866f0f9ab0149d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 17 May 2024 16:32:38 +0100 Subject: [PATCH 1/3] Quick fix for the CLI - the disabling of pino logging being part of the index means it doesn't run until after TS imports - moving it to be first import/ran before all else. --- packages/cli/src/environment.ts | 1 + packages/cli/src/index.ts | 3 ++- packages/cli/start.sh | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/environment.ts b/packages/cli/src/environment.ts index 9d017f99b2..51f6e9b972 100644 --- a/packages/cli/src/environment.ts +++ b/packages/cli/src/environment.ts @@ -1,3 +1,4 @@ +process.env.DISABLE_PINO_LOGGER = "1" process.env.NO_JS = "1" process.env.JS_BCRYPT = "1" process.env.DISABLE_JWT_WARNING = "1" diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 86a6d2b7b3..23a2447ad6 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node -process.env.DISABLE_PINO_LOGGER = "1" +// have to import this before anything else +import "./init" import "./environment" import { getCommands } from "./options" import { Command } from "commander" diff --git a/packages/cli/start.sh b/packages/cli/start.sh index 9650f0bbfa..ae39f73753 100755 --- a/packages/cli/start.sh +++ b/packages/cli/start.sh @@ -1,3 +1,3 @@ #!/bin/bash dir="$(dirname -- "$(readlink -f "${BASH_SOURCE}")")" -${dir}/node_modules/ts-node/dist/bin.js ${dir}/src/index.ts $@ +${dir}/../../node_modules/ts-node/dist/bin.js ${dir}/src/index.ts $@ From 5d1c23373f347a1a137624e27b77856294b85ef0 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 17 May 2024 16:32:55 +0100 Subject: [PATCH 2/3] removing init import. --- packages/cli/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 23a2447ad6..317ccea974 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node // have to import this before anything else -import "./init" import "./environment" import { getCommands } from "./options" import { Command } from "commander" From c1ce6be9b9817d1e0081a635972311f033730f81 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 17 May 2024 17:17:57 +0100 Subject: [PATCH 3/3] Disallowing arrays for single types (attachment and user). --- packages/server/src/sdk/app/rows/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/rows/utils.ts b/packages/server/src/sdk/app/rows/utils.ts index a9df4f89cd..777ebff655 100644 --- a/packages/server/src/sdk/app/rows/utils.ts +++ b/packages/server/src/sdk/app/rows/utils.ts @@ -14,7 +14,7 @@ import { makeExternalQuery } from "../../../integrations/base/query" import { Format } from "../../../api/controllers/view/exporters" import sdk from "../.." import { isRelationshipColumn } from "../../../db/utils" -import { SqlClient, isSQL } from "../../../integrations/utils" +import { isSQL, SqlClient } from "../../../integrations/utils" const SQL_CLIENT_SOURCE_MAP: Record = { [SourceName.POSTGRES]: SqlClient.POSTGRES, @@ -144,6 +144,10 @@ export async function validate({ throw new Error("Unable to fetch table for validation") } const errors: Record = {} + const disallowArrayTypes = [ + FieldType.ATTACHMENT_SINGLE, + FieldType.BB_REFERENCE_SINGLE, + ] for (let fieldName of Object.keys(fetchedTable.schema)) { const column = fetchedTable.schema[fieldName] const constraints = cloneDeep(column.constraints) @@ -160,6 +164,10 @@ export async function validate({ if (type === FieldType.OPTIONS && constraints?.inclusion) { constraints.inclusion.push(null as any, "") } + + if (disallowArrayTypes.includes(type) && Array.isArray(row[fieldName])) { + errors[fieldName] = `Cannot accept arrays` + } let res // Validate.js doesn't seem to handle array