diff --git a/packages/pro b/packages/pro index d68b4f40f8..8baf8586ec 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit d68b4f40f85dba3184da8b9d63ef2cd66d4a8ef2 +Subproject commit 8baf8586ec078951230c8466d5f13f9b6d5ed055 diff --git a/packages/server/src/api/controllers/row/alias.ts b/packages/server/src/api/controllers/row/alias.ts index 1d586c54fd..60c207c8ce 100644 --- a/packages/server/src/api/controllers/row/alias.ts +++ b/packages/server/src/api/controllers/row/alias.ts @@ -23,6 +23,12 @@ const DISABLED_WRITE_CLIENTS: SqlClient[] = [ SqlClient.ORACLE, ] +const DISABLED_OPERATIONS: Operation[] = [ + Operation.CREATE_TABLE, + Operation.UPDATE_TABLE, + Operation.DELETE_TABLE, +] + class CharSequence { static alphabet = "abcdefghijklmnopqrstuvwxyz" counters: number[] @@ -59,13 +65,18 @@ export default class AliasTables { } isAliasingEnabled(json: QueryJson, datasource: Datasource) { + const operation = json.endpoint.operation const fieldLength = json.resource?.fields?.length - if (!fieldLength || fieldLength <= 0) { + if ( + !fieldLength || + fieldLength <= 0 || + DISABLED_OPERATIONS.includes(operation) + ) { return false } try { const sqlClient = getSQLClient(datasource) - const isWrite = WRITE_OPERATIONS.includes(json.endpoint.operation) + const isWrite = WRITE_OPERATIONS.includes(operation) const isDisabledClient = DISABLED_WRITE_CLIENTS.includes(sqlClient) if (isWrite && isDisabledClient) { return false diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index 0061c37ba0..7f89a5cac2 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -19,6 +19,7 @@ import env from "../../../environment" import { type App } from "@budibase/types" import tk from "timekeeper" import * as uuid from "uuid" +import { structures } from "@budibase/backend-core/tests" describe("/applications", () => { let config = setup.getConfig() @@ -356,7 +357,7 @@ describe("/applications", () => { it("should reject an unknown app id with a 404", async () => { await config.api.application.duplicateApp( - app.appId.slice(0, -1) + "a", + structures.db.id(), { name: "to-dupe 123", url: "/to-dupe-123", diff --git a/packages/shared-core/jest.config.ts b/packages/shared-core/jest.config.ts new file mode 100644 index 0000000000..5c7c870b58 --- /dev/null +++ b/packages/shared-core/jest.config.ts @@ -0,0 +1,10 @@ +export default { + preset: "ts-jest", + testEnvironment: "node", + transform: { + "^.+\\.ts?$": "@swc/jest", + }, + moduleNameMapper: { + "@budibase/types": "/../types/src", + }, +} diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 777896a7f7..c024d1b819 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -11,7 +11,9 @@ "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", - "check:types": "tsc -p tsconfig.json --noEmit --paths null" + "check:types": "tsc -p tsconfig.json --noEmit --paths null", + "test": "jest", + "test:watch": "yarn test --watchAll" }, "dependencies": { "@budibase/types": "0.0.0", @@ -20,29 +22,5 @@ "devDependencies": { "rimraf": "3.0.2", "typescript": "5.2.2" - }, - "nx": { - "targets": { - "build": { - "dependsOn": [ - { - "projects": [ - "@budibase/types" - ], - "target": "build" - } - ] - }, - "dev": { - "dependsOn": [ - { - "projects": [ - "@budibase/types" - ], - "target": "build" - } - ] - } - } } } diff --git a/packages/shared-core/src/tests/cron.test.ts b/packages/shared-core/src/tests/cron.test.ts index d56165b2b8..3945acb565 100644 --- a/packages/shared-core/src/tests/cron.test.ts +++ b/packages/shared-core/src/tests/cron.test.ts @@ -1,4 +1,3 @@ -import { expect, describe, it } from "vitest" import { cron } from "../helpers" describe("check valid and invalid crons", () => { diff --git a/packages/shared-core/src/tests/filters.test.ts b/packages/shared-core/src/tests/filters.test.ts index de969562af..e74e37d681 100644 --- a/packages/shared-core/src/tests/filters.test.ts +++ b/packages/shared-core/src/tests/filters.test.ts @@ -5,7 +5,6 @@ import { SearchFilter, } from "@budibase/types" import { buildLuceneQuery, runLuceneQuery } from "../filters" -import { expect, describe, it, test } from "vitest" describe("runLuceneQuery", () => { const docs = [ @@ -194,7 +193,7 @@ describe("runLuceneQuery", () => { expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3]) }) - test.each([[523, 259], "523,259"])( + it.each([[523, 259], "523,259"])( "should return rows with matches on numeric oneOf filter", input => { const query = buildQuery({ @@ -209,7 +208,7 @@ describe("runLuceneQuery", () => { } ) - test.each([ + it.each([ [false, []], [true, [1, 2, 3]], ])("should return %s if allOr is %s ", (allOr, expectedResult) => { diff --git a/packages/shared-core/tsconfig.build.json b/packages/shared-core/tsconfig.build.json index 8a7f0ea216..13e298d71c 100644 --- a/packages/shared-core/tsconfig.build.json +++ b/packages/shared-core/tsconfig.build.json @@ -18,13 +18,6 @@ }, "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" }, - "include": ["**/*.js", "**/*.ts"], - "exclude": [ - "node_modules", - "dist", - "**/*.spec.ts", - "**/*.spec.js", - "__mocks__", - "src/tests" - ] + "include": ["src/**/*"], + "exclude": ["**/*.spec.ts", "**/*.spec.js", "__mocks__", "src/tests"] } diff --git a/packages/shared-core/tsconfig.json b/packages/shared-core/tsconfig.json index 5e3d49c8b9..ad028931e4 100644 --- a/packages/shared-core/tsconfig.json +++ b/packages/shared-core/tsconfig.json @@ -1,9 +1,8 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "baseUrl": "..", - "rootDir": "src", - "composite": true + "composite": true, + "types": ["node", "jest"] }, "exclude": ["node_modules", "dist"] } diff --git a/packages/types/package.json b/packages/types/package.json index f4c7b13344..67b923ed54 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "description": "Budibase types", "main": "dist/index.js", - "types": "dist/index.d.ts", + "types": "src/index.ts", "author": "Budibase", "license": "GPL-3.0", "scripts": { diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index 5a1f30eb62..12c86bd9ba 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -7,7 +7,7 @@ import { ViewTemplateOpts, } from "../" import { Writable } from "stream" -import PouchDB from "pouchdb-find" +import type PouchDB from "pouchdb-find" export enum SearchIndex { ROWS = "rows", diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index a2fd5207b4..ad5356c2dc 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "baseUrl": ".", - "rootDir": "./src", "composite": true }, "exclude": ["node_modules", "dist"] diff --git a/packages/worker/scripts/test.sh b/packages/worker/scripts/test.sh index 17b3ee17f4..4191674538 100644 --- a/packages/worker/scripts/test.sh +++ b/packages/worker/scripts/test.sh @@ -4,10 +4,10 @@ set -e if [[ -n $CI ]] then # Running in ci, where resources are limited - echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" - jest --coverage --maxWorkers=2 --forceExit --bail $@ + echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" + jest --coverage --maxWorkers=2 --forceExit --bail $@ else # --maxWorkers performs better in development - echo "jest --coverage --maxWorkers=2 --forceExit $@" - jest --coverage --maxWorkers=2 --forceExit $@ + echo "jest --coverage --detectOpenHandles $@" + jest --coverage --detectOpenHandles $@ fi \ No newline at end of file diff --git a/packages/worker/src/sdk/auth/tests/auth.spec.ts b/packages/worker/src/sdk/auth/tests/auth.spec.ts index e9f348f7c7..894a3e6eca 100644 --- a/packages/worker/src/sdk/auth/tests/auth.spec.ts +++ b/packages/worker/src/sdk/auth/tests/auth.spec.ts @@ -6,6 +6,8 @@ import { TestConfiguration } from "../../../tests" describe("auth", () => { const config = new TestConfiguration() + afterAll(config.afterAll) + describe("resetUpdate", () => { it("providing a valid code will update the password", async () => { await context.doInTenant(structures.tenant.id(), async () => {