From aff286807ce2bdfc394c63a40323a4320a2c2426 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 27 Jul 2023 10:00:56 +0100 Subject: [PATCH 001/123] fail pipeline if unreleased changes in master --- .../workflows/check_unreleased_changes.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/check_unreleased_changes.yml diff --git a/.github/workflows/check_unreleased_changes.yml b/.github/workflows/check_unreleased_changes.yml new file mode 100644 index 0000000000..2312990c3c --- /dev/null +++ b/.github/workflows/check_unreleased_changes.yml @@ -0,0 +1,29 @@ +name: Check for Unreleased Changes + +on: + pull_request: + branches: + - master + +jobs: + check_unreleased: + runs-on: ubuntu-latest + steps: + - name: Check for unreleased changes + env: + REPO: "Budibase/budibase" + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + RELEASE_TIMESTAMP=$(curl -s -H "Authorization: token $TOKEN" \ + "https://api.github.com/repos/$REPO/releases/latest" | \ + jq -r .published_at) + COMMIT_TIMESTAMP=$(curl -s -H "Authorization: token $TOKEN" \ + "https://api.github.com/repos/$REPO/commits/master" | \ + jq -r .commit.committer.date) + RELEASE_SECONDS=$(date --date="$RELEASE_TIMESTAMP" "+%s") + COMMIT_SECONDS=$(date --date="$COMMIT_TIMESTAMP" "+%s") + if (( COMMIT_SECONDS > RELEASE_SECONDS )); then + echo "There are unreleased changes. Please release these changes before merging." + exit 1 + fi + echo "No unreleased changes detected." From c11706440dc0ff82adf1041a6901ad70a5e914dd Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 27 Jul 2023 10:27:19 +0100 Subject: [PATCH 002/123] change pipeline name to match filename --- .github/workflows/check_unreleased_changes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_unreleased_changes.yml b/.github/workflows/check_unreleased_changes.yml index 2312990c3c..d558330545 100644 --- a/.github/workflows/check_unreleased_changes.yml +++ b/.github/workflows/check_unreleased_changes.yml @@ -1,4 +1,4 @@ -name: Check for Unreleased Changes +name: check_unreleased_changes on: pull_request: From 546c16f1180bffb3e1f7a42ccd964642d8aaa233 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Jul 2023 17:20:42 +0200 Subject: [PATCH 003/123] Update local tools --- .nvmrc | 2 +- .tool-versions | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.nvmrc b/.nvmrc index 835d07c442..7950a44576 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.20.1 +v18.17.0 diff --git a/.tool-versions b/.tool-versions index 9f2ea77b14..a909d60941 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -nodejs 14.21.3 +nodejs 18.17.0 python 3.10.0 -yarn 1.22.19 \ No newline at end of file +yarn 1.22.19 From d8c2499c15d5e5d1db8444dbe8069cba08836b35 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Jul 2023 17:46:57 +0200 Subject: [PATCH 004/123] Fix automation issues --- packages/server/src/automations/tests/automation.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/automations/tests/automation.spec.ts b/packages/server/src/automations/tests/automation.spec.ts index 67ff6d40ec..0cdc69c5ac 100644 --- a/packages/server/src/automations/tests/automation.spec.ts +++ b/packages/server/src/automations/tests/automation.spec.ts @@ -33,7 +33,7 @@ describe("Run through some parts of the automations system", () => { setup.afterAll() }) - it("should be able to init in builder", async () => { + it.only("should be able to init in builder", async () => { const automation: Automation = { ...basicAutomation(), appId: config.appId, From 5e59d735332b288ff86b51dcd7399e6c7efe2e24 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 24 Jul 2023 17:48:10 +0200 Subject: [PATCH 005/123] Change actions to use node 18 --- .github/workflows/budibase_ci.yml | 24 +++++++++++------------ .github/workflows/release-develop.yml | 2 +- .github/workflows/release-master.yml | 2 +- .github/workflows/release-selfhost.yml | 4 ++-- .github/workflows/release-singleimage.yml | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 9509a22e99..661fcb170b 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -33,10 +33,10 @@ jobs: uses: actions/checkout@v3 if: github.repository != github.event.pull_request.head.repo.full_name - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn - run: yarn lint @@ -54,10 +54,10 @@ jobs: uses: actions/checkout@v3 if: github.repository != github.event.pull_request.head.repo.full_name - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn # Run build all the projects @@ -78,10 +78,10 @@ jobs: uses: actions/checkout@v3 if: github.repository != github.event.pull_request.head.repo.full_name - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro @@ -104,10 +104,10 @@ jobs: uses: actions/checkout@v3 if: github.repository != github.event.pull_request.head.repo.full_name - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn - run: yarn test --scope=@budibase/worker --scope=@budibase/server @@ -127,10 +127,10 @@ jobs: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn - run: yarn test --scope=@budibase/pro @@ -148,10 +148,10 @@ jobs: uses: actions/checkout@v3 if: github.repository != github.event.pull_request.head.repo.full_name - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x cache: "yarn" - run: yarn - run: yarn build diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index 61cb283e28..bd727b7865 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -44,7 +44,7 @@ jobs: - uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 18.x - run: yarn install --frozen-lockfile - name: Update versions diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index 7f8b8f1d55..db2723cdfe 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -36,7 +36,7 @@ jobs: - uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 18.x - run: yarn install --frozen-lockfile - name: Update versions diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index 39ee812726..ddfe202465 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -28,10 +28,10 @@ jobs: exit 1 fi - - name: Use Node.js 14.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 18.x - name: Get the latest budibase release version id: version diff --git a/.github/workflows/release-singleimage.yml b/.github/workflows/release-singleimage.yml index 5b75c20d29..25be68feb0 100644 --- a/.github/workflows/release-singleimage.yml +++ b/.github/workflows/release-singleimage.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [14.x] + node-version: [18.x] steps: - name: Fail if not a tag run: | From e2ac7e3463a165ac9ecfc58fcc500ce5112b3d7a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 25 Jul 2023 10:44:53 +0200 Subject: [PATCH 006/123] Fix minio usage --- .../backend-core/tests/core/utilities/testContainerUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-core/tests/core/utilities/testContainerUtils.ts b/packages/backend-core/tests/core/utilities/testContainerUtils.ts index f6c702f7ef..06bd91392e 100644 --- a/packages/backend-core/tests/core/utilities/testContainerUtils.ts +++ b/packages/backend-core/tests/core/utilities/testContainerUtils.ts @@ -80,7 +80,7 @@ function getRedisConfig() { export function setupEnv(...envs: any[]) { const couch = getCouchConfig(), - minio = getCouchConfig(), + minio = getMinioConfig(), redis = getRedisConfig() const configs = [ { key: "COUCH_DB_PORT", value: couch.port }, From f7cae98a963dad0b3469332ef9151bbd98fe87b0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 10:00:10 +0200 Subject: [PATCH 007/123] Change node engine --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a392aeee78..358c027026 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "@budibase/types": "0.0.0" }, "engines": { - "node": ">=14.0.0 <15.0.0" + "node": ">=18.0.0 <19.0.0" }, "dependencies": {} } From c7b0960bb3063013c08f516ec3b90b09d8b77d39 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 11:30:44 +0200 Subject: [PATCH 008/123] Make use of workerIdleMemoryLimit --- packages/server/jest.config.ts | 1 + packages/worker/jest.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index f36864f999..b43bd742c0 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,6 +16,7 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, + workerIdleMemoryLimit: "40%", } // add pro sources if they exist diff --git a/packages/worker/jest.config.ts b/packages/worker/jest.config.ts index 0a640766f4..f03f8006cc 100644 --- a/packages/worker/jest.config.ts +++ b/packages/worker/jest.config.ts @@ -16,6 +16,7 @@ const config: Config.InitialOptions = { "@budibase/types": "/../types/src", "@budibase/shared-core": ["/../shared-core/src"], }, + workerIdleMemoryLimit: "40%", } // add pro sources if they exist From 225d498909580f6b8912e99f3d0402b5a0d6c424 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 16:02:03 +0200 Subject: [PATCH 009/123] Run with concurrency 1 --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 661fcb170b..bdb2e640b5 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -110,7 +110,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn - - run: yarn test --scope=@budibase/worker --scope=@budibase/server + - run: yarn test --concurrency=1 --scope=@budibase/worker --scope=@budibase/server - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos From 5dc36238667104cd9745defe5f048ac6da5c3dbe Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 16:03:53 +0200 Subject: [PATCH 010/123] Remove workerIdleMemoryLimit from worker --- packages/worker/jest.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/worker/jest.config.ts b/packages/worker/jest.config.ts index f03f8006cc..0a640766f4 100644 --- a/packages/worker/jest.config.ts +++ b/packages/worker/jest.config.ts @@ -16,7 +16,6 @@ const config: Config.InitialOptions = { "@budibase/types": "/../types/src", "@budibase/shared-core": ["/../shared-core/src"], }, - workerIdleMemoryLimit: "40%", } // add pro sources if they exist From e71ec971a093b6c1d40d4571da80e623230ab400 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 16:04:19 +0200 Subject: [PATCH 011/123] workerIdleMemoryLimit server at 50% --- packages/server/jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index b43bd742c0..a683be8150 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,7 +16,7 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, - workerIdleMemoryLimit: "40%", + workerIdleMemoryLimit: "50%", } // add pro sources if they exist From c2a5a37c487e1961d4d132c158d159db5aecfb1f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 16:23:56 +0200 Subject: [PATCH 012/123] Split tests --- .github/workflows/budibase_ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index bdb2e640b5..d12e632fd4 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -110,7 +110,12 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn - - run: yarn test --concurrency=1 --scope=@budibase/worker --scope=@budibase/server + - name: Test worker + run: yarn test --scope=@budibase/worker + - name: Test server + env: + NODE_OPTIONS: "--max_old_space_size=4096" + run: yarn test --scope=@budibase/server - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos From 0f75660808d0206e3f40299f3310be49acd5cd73 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 16:47:09 +0200 Subject: [PATCH 013/123] Attempt different commands --- .github/workflows/budibase_ci.yml | 8 ++------ packages/server/scripts/test.sh | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index d12e632fd4..5dc3ba1222 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -110,12 +110,8 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn - - name: Test worker - run: yarn test --scope=@budibase/worker - - name: Test server - env: - NODE_OPTIONS: "--max_old_space_size=4096" - run: yarn test --scope=@budibase/server + - name: Test worker and server + run: yarn test --concurrency=1 --scope=@budibase/worker --scope=@budibase/server - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index f3f679c4da..4aad5b3c7c 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -5,8 +5,9 @@ if [[ -n $CI ]] then # --runInBand performs better in ci where resources are limited export NODE_OPTIONS="--max-old-space-size=4096" - echo "jest --coverage --runInBand --forceExit" - jest --coverage --runInBand --forceExit + node ../../node_modules/jest/bin/jest.js --version + echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js" + node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js else # --maxWorkers performs better in development echo "jest --coverage --maxWorkers=2 --forceExit" From f82c10782fb3da16e8022433d0dc440e686dbdef Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 17:14:34 +0200 Subject: [PATCH 014/123] Log heap usage --- packages/server/jest.config.ts | 1 - packages/server/scripts/test.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index a683be8150..f36864f999 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,7 +16,6 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, - workerIdleMemoryLimit: "50%", } // add pro sources if they exist diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 4aad5b3c7c..19f3fb33d7 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -7,7 +7,7 @@ then export NODE_OPTIONS="--max-old-space-size=4096" node ../../node_modules/jest/bin/jest.js --version echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js" - node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js + node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --logHeapUsage else # --maxWorkers performs better in development echo "jest --coverage --maxWorkers=2 --forceExit" From 2e1903f95577275e102dfbf26de80e683541f9fb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 17:40:44 +0200 Subject: [PATCH 015/123] Log --- packages/server/scripts/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 19f3fb33d7..3adc5abbd0 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -6,7 +6,7 @@ then # --runInBand performs better in ci where resources are limited export NODE_OPTIONS="--max-old-space-size=4096" node ../../node_modules/jest/bin/jest.js --version - echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js" + echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --logHeapUsage" node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --logHeapUsage else # --maxWorkers performs better in development From 42b14fe712aa04124f3c65acef66bfa05db34630 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 17:45:47 +0200 Subject: [PATCH 016/123] Add workerIdleMemoryLimit --- packages/server/jest.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index f36864f999..f12e2e46c7 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,6 +16,7 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, + workerIdleMemoryLimit: 0.2, } // add pro sources if they exist From e5ceaf8ffd75f3cec86373671504ccd7e8d71aef Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 18:03:13 +0200 Subject: [PATCH 017/123] Add 2gb limit --- packages/server/jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index f12e2e46c7..87e2ef4d0a 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,7 +16,7 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, - workerIdleMemoryLimit: 0.2, + workerIdleMemoryLimit: "2GB", } // add pro sources if they exist From 800f5c5095e2eeca639414d1293b311293e112cd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 18:11:34 +0200 Subject: [PATCH 018/123] Use --frozen-lock --- .github/workflows/budibase_ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 5dc3ba1222..6c9fb1c253 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -38,7 +38,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile - run: yarn lint build: @@ -59,7 +59,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile # Run build all the projects - run: yarn build # Check the types of the projects built via esbuild @@ -83,7 +83,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro - uses: codecov/codecov-action@v3 with: @@ -109,7 +109,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile - name: Test worker and server run: yarn test --concurrency=1 --scope=@budibase/worker --scope=@budibase/server - uses: codecov/codecov-action@v3 @@ -133,7 +133,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile - run: yarn test --scope=@budibase/pro integration-test: @@ -154,7 +154,7 @@ jobs: with: node-version: 18.x cache: "yarn" - - run: yarn + - run: yarn --frozen-lockfile - run: yarn build - name: Run tests run: | From 712732f79589353ffed3817207c25980fa9c17e8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 18:37:13 +0200 Subject: [PATCH 019/123] Run in band? --- packages/server/scripts/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 3adc5abbd0..5d0c793846 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -6,8 +6,8 @@ then # --runInBand performs better in ci where resources are limited export NODE_OPTIONS="--max-old-space-size=4096" node ../../node_modules/jest/bin/jest.js --version - echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --logHeapUsage" - node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --logHeapUsage + echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage" + node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage else # --maxWorkers performs better in development echo "jest --coverage --maxWorkers=2 --forceExit" From a0be6029b3bd8a7524f5c07ef10ed5b5c278ba6e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 21:10:28 +0200 Subject: [PATCH 020/123] Remove concurrency --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 6c9fb1c253..9e2d0b3fbe 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -111,7 +111,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Test worker and server - run: yarn test --concurrency=1 --scope=@budibase/worker --scope=@budibase/server + run: yarn test --scope=@budibase/worker --scope=@budibase/server - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos From e2758d3da18c90f062d7749c86cfaa320914e7bb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 27 Jul 2023 21:12:26 +0200 Subject: [PATCH 021/123] Remove it.only( --- packages/server/src/automations/tests/automation.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/automations/tests/automation.spec.ts b/packages/server/src/automations/tests/automation.spec.ts index 0cdc69c5ac..67ff6d40ec 100644 --- a/packages/server/src/automations/tests/automation.spec.ts +++ b/packages/server/src/automations/tests/automation.spec.ts @@ -33,7 +33,7 @@ describe("Run through some parts of the automations system", () => { setup.afterAll() }) - it.only("should be able to init in builder", async () => { + it("should be able to init in builder", async () => { const automation: Automation = { ...basicAutomation(), appId: config.appId, From 51a1d1c183664809022461a66d72e6fed4fe8f06 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 28 Jul 2023 10:59:12 +0200 Subject: [PATCH 022/123] Add force exists --- packages/server/scripts/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 5d0c793846..353995f8bb 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -6,8 +6,8 @@ then # --runInBand performs better in ci where resources are limited export NODE_OPTIONS="--max-old-space-size=4096" node ../../node_modules/jest/bin/jest.js --version - echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage" - node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage + echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage --forceExit" + node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage --forceExit else # --maxWorkers performs better in development echo "jest --coverage --maxWorkers=2 --forceExit" From d5533c00d609a73847d06d25f4396c42abc69ae6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 28 Jul 2023 12:53:52 +0200 Subject: [PATCH 023/123] Fix workerIdleMemoryLimit usage --- packages/server/jest.config.ts | 1 - packages/server/scripts/test.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index 87e2ef4d0a..f36864f999 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,7 +16,6 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", }, - workerIdleMemoryLimit: "2GB", } // add pro sources if they exist diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 353995f8bb..a2c6f2cdf2 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -6,8 +6,8 @@ then # --runInBand performs better in ci where resources are limited export NODE_OPTIONS="--max-old-space-size=4096" node ../../node_modules/jest/bin/jest.js --version - echo "node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage --forceExit" - node --expose-gc --no-compilation-cache ../../node_modules/jest/bin/jest.js --runInBand --logHeapUsage --forceExit + echo "jest --coverage --maxWorkers=2 --forceExit" + jest --coverage --maxWorkers=2 --forceExit --workerIdleMemoryLimit=2000MB else # --maxWorkers performs better in development echo "jest --coverage --maxWorkers=2 --forceExit" From 52078d6fd7475c8a17e6d2ebdb537d3dd70b2d4f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 28 Jul 2023 17:52:24 +0200 Subject: [PATCH 024/123] Don't modify production pipelines --- .github/workflows/release-master.yml | 2 +- .github/workflows/release-selfhost.yml | 4 ++-- .github/workflows/release-singleimage.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index db2723cdfe..7f8b8f1d55 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -36,7 +36,7 @@ jobs: - uses: actions/setup-node@v1 with: - node-version: 18.x + node-version: 14.x - run: yarn install --frozen-lockfile - name: Update versions diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index ddfe202465..39ee812726 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -28,10 +28,10 @@ jobs: exit 1 fi - - name: Use Node.js 18.x + - name: Use Node.js 14.x uses: actions/setup-node@v1 with: - node-version: 18.x + node-version: 14.x - name: Get the latest budibase release version id: version diff --git a/.github/workflows/release-singleimage.yml b/.github/workflows/release-singleimage.yml index 25be68feb0..5b75c20d29 100644 --- a/.github/workflows/release-singleimage.yml +++ b/.github/workflows/release-singleimage.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x] + node-version: [14.x] steps: - name: Fail if not a tag run: | From b69943c074de1514726e01ac3d1f045d8fc1429e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 2 Aug 2023 15:13:43 +0200 Subject: [PATCH 025/123] Move tests --- .../server/src/api/routes/tests/row.spec.ts | 497 +++++++++--------- 1 file changed, 251 insertions(+), 246 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index b986ffb945..012ed537ee 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -813,252 +813,6 @@ describe("/rows", () => { }) }) - describe("view search", () => { - function userTable(): Table { - return { - name: "user", - type: "user", - schema: { - name: { - type: FieldType.STRING, - name: "name", - constraints: { type: "string" }, - }, - age: { - type: FieldType.NUMBER, - name: "age", - constraints: {}, - }, - }, - } - } - - it("returns table rows from view", async () => { - const table = await config.createTable(userTable()) - const rows = [] - for (let i = 0; i < 10; i++) { - rows.push(await config.createRow({ tableId: table._id })) - } - - const createViewResponse = await config.api.viewV2.create() - const response = await config.api.viewV2.search(createViewResponse.id) - - expect(response.body.rows).toHaveLength(10) - expect(response.body).toEqual({ - rows: expect.arrayContaining(rows.map(expect.objectContaining)), - }) - }) - - it("searching respects the view filters", async () => { - const table = await config.createTable(userTable()) - const expectedRows = [] - for (let i = 0; i < 10; i++) - await config.createRow({ - tableId: table._id, - name: generator.name(), - age: generator.integer({ min: 10, max: 30 }), - }) - - for (let i = 0; i < 5; i++) - expectedRows.push( - await config.createRow({ - tableId: table._id, - name: generator.name(), - age: 40, - }) - ) - - const createViewResponse = await config.api.viewV2.create({ - query: { equal: { age: 40 } }, - }) - - const response = await config.api.viewV2.search(createViewResponse.id) - - expect(response.body.rows).toHaveLength(5) - expect(response.body).toEqual({ - rows: expect.arrayContaining(expectedRows.map(expect.objectContaining)), - }) - }) - - const sortTestOptions: [ - { - field: string - order?: SortOrder - type?: SortType - }, - string[] - ][] = [ - [ - { - field: "name", - order: SortOrder.ASCENDING, - type: SortType.STRING, - }, - ["Alice", "Bob", "Charly", "Danny"], - ], - [ - { - field: "name", - }, - ["Alice", "Bob", "Charly", "Danny"], - ], - [ - { - field: "name", - order: SortOrder.DESCENDING, - }, - ["Danny", "Charly", "Bob", "Alice"], - ], - [ - { - field: "name", - order: SortOrder.DESCENDING, - type: SortType.STRING, - }, - ["Danny", "Charly", "Bob", "Alice"], - ], - [ - { - field: "age", - order: SortOrder.ASCENDING, - type: SortType.number, - }, - ["Danny", "Alice", "Charly", "Bob"], - ], - [ - { - field: "age", - order: SortOrder.ASCENDING, - }, - ["Danny", "Alice", "Charly", "Bob"], - ], - [ - { - field: "age", - order: SortOrder.DESCENDING, - }, - ["Bob", "Charly", "Alice", "Danny"], - ], - [ - { - field: "age", - order: SortOrder.DESCENDING, - type: SortType.number, - }, - ["Bob", "Charly", "Alice", "Danny"], - ], - ] - - it.each(sortTestOptions)( - "allow sorting (%s)", - async (sortParams, expected) => { - await config.createTable(userTable()) - const users = [ - { name: "Alice", age: 25 }, - { name: "Bob", age: 30 }, - { name: "Charly", age: 27 }, - { name: "Danny", age: 15 }, - ] - for (const user of users) { - await config.createRow({ - tableId: config.table!._id, - ...user, - }) - } - - const createViewResponse = await config.api.viewV2.create({ - sort: sortParams, - }) - - const response = await config.api.viewV2.search(createViewResponse.id) - - expect(response.body.rows).toHaveLength(4) - expect(response.body).toEqual({ - rows: expected.map(name => expect.objectContaining({ name })), - }) - } - ) - - it.each(sortTestOptions)( - "allow override the default view sorting (%s)", - async (sortParams, expected) => { - await config.createTable(userTable()) - const users = [ - { name: "Alice", age: 25 }, - { name: "Bob", age: 30 }, - { name: "Charly", age: 27 }, - { name: "Danny", age: 15 }, - ] - for (const user of users) { - await config.createRow({ - tableId: config.table!._id, - ...user, - }) - } - - const createViewResponse = await config.api.viewV2.create({ - sort: { - field: "name", - order: SortOrder.ASCENDING, - type: SortType.STRING, - }, - }) - - const response = await config.api.viewV2.search(createViewResponse.id, { - sort: { - column: sortParams.field, - order: sortParams.order, - type: sortParams.type, - }, - }) - - expect(response.body.rows).toHaveLength(4) - expect(response.body).toEqual({ - rows: expected.map(name => expect.objectContaining({ name })), - }) - } - ) - - it("when schema is defined, defined columns and row attributes are returned", async () => { - const table = await config.createTable(userTable()) - const rows = [] - for (let i = 0; i < 10; i++) { - rows.push( - await config.createRow({ - tableId: table._id, - name: generator.name(), - age: generator.age(), - }) - ) - } - - const view = await config.api.viewV2.create({ - schema: { name: {} }, - }) - const response = await config.api.viewV2.search(view.id) - - expect(response.body.rows).toHaveLength(10) - expect(response.body.rows).toEqual( - expect.arrayContaining( - rows.map(r => ({ - ...expectAnyInternalColsAttributes, - _viewId: view.id, - name: r.name, - })) - ) - ) - }) - - it("views without data can be returned", async () => { - const table = await config.createTable(userTable()) - - const createViewResponse = await config.api.viewV2.create() - const response = await config.api.viewV2.search(createViewResponse.id) - - expect(response.body.rows).toHaveLength(0) - }) - }) - describe("view 2.0", () => { function userTable(): Table { return { @@ -1261,5 +1015,256 @@ describe("/rows", () => { await config.api.row.get(tableId, rows[1]._id!, { expectStatus: 200 }) }) }) + + describe("view search", () => { + function userTable(): Table { + return { + name: "user", + type: "user", + schema: { + name: { + type: FieldType.STRING, + name: "name", + constraints: { type: "string" }, + }, + age: { + type: FieldType.NUMBER, + name: "age", + constraints: {}, + }, + }, + } + } + + it("returns table rows from view", async () => { + const table = await config.createTable(userTable()) + const rows = [] + for (let i = 0; i < 10; i++) { + rows.push(await config.createRow({ tableId: table._id })) + } + + const createViewResponse = await config.api.viewV2.create() + const response = await config.api.viewV2.search(createViewResponse.id) + + expect(response.body.rows).toHaveLength(10) + expect(response.body).toEqual({ + rows: expect.arrayContaining(rows.map(expect.objectContaining)), + }) + }) + + it("searching respects the view filters", async () => { + const table = await config.createTable(userTable()) + const expectedRows = [] + for (let i = 0; i < 10; i++) + await config.createRow({ + tableId: table._id, + name: generator.name(), + age: generator.integer({ min: 10, max: 30 }), + }) + + for (let i = 0; i < 5; i++) + expectedRows.push( + await config.createRow({ + tableId: table._id, + name: generator.name(), + age: 40, + }) + ) + + const createViewResponse = await config.api.viewV2.create({ + query: { equal: { age: 40 } }, + }) + + const response = await config.api.viewV2.search(createViewResponse.id) + + expect(response.body.rows).toHaveLength(5) + expect(response.body).toEqual({ + rows: expect.arrayContaining( + expectedRows.map(expect.objectContaining) + ), + }) + }) + + const sortTestOptions: [ + { + field: string + order?: SortOrder + type?: SortType + }, + string[] + ][] = [ + [ + { + field: "name", + order: SortOrder.ASCENDING, + type: SortType.STRING, + }, + ["Alice", "Bob", "Charly", "Danny"], + ], + [ + { + field: "name", + }, + ["Alice", "Bob", "Charly", "Danny"], + ], + [ + { + field: "name", + order: SortOrder.DESCENDING, + }, + ["Danny", "Charly", "Bob", "Alice"], + ], + [ + { + field: "name", + order: SortOrder.DESCENDING, + type: SortType.STRING, + }, + ["Danny", "Charly", "Bob", "Alice"], + ], + [ + { + field: "age", + order: SortOrder.ASCENDING, + type: SortType.number, + }, + ["Danny", "Alice", "Charly", "Bob"], + ], + [ + { + field: "age", + order: SortOrder.ASCENDING, + }, + ["Danny", "Alice", "Charly", "Bob"], + ], + [ + { + field: "age", + order: SortOrder.DESCENDING, + }, + ["Bob", "Charly", "Alice", "Danny"], + ], + [ + { + field: "age", + order: SortOrder.DESCENDING, + type: SortType.number, + }, + ["Bob", "Charly", "Alice", "Danny"], + ], + ] + + it.each(sortTestOptions)( + "allow sorting (%s)", + async (sortParams, expected) => { + await config.createTable(userTable()) + const users = [ + { name: "Alice", age: 25 }, + { name: "Bob", age: 30 }, + { name: "Charly", age: 27 }, + { name: "Danny", age: 15 }, + ] + for (const user of users) { + await config.createRow({ + tableId: config.table!._id, + ...user, + }) + } + + const createViewResponse = await config.api.viewV2.create({ + sort: sortParams, + }) + + const response = await config.api.viewV2.search(createViewResponse.id) + + expect(response.body.rows).toHaveLength(4) + expect(response.body).toEqual({ + rows: expected.map(name => expect.objectContaining({ name })), + }) + } + ) + + it.each(sortTestOptions)( + "allow override the default view sorting (%s)", + async (sortParams, expected) => { + await config.createTable(userTable()) + const users = [ + { name: "Alice", age: 25 }, + { name: "Bob", age: 30 }, + { name: "Charly", age: 27 }, + { name: "Danny", age: 15 }, + ] + for (const user of users) { + await config.createRow({ + tableId: config.table!._id, + ...user, + }) + } + + const createViewResponse = await config.api.viewV2.create({ + sort: { + field: "name", + order: SortOrder.ASCENDING, + type: SortType.STRING, + }, + }) + + const response = await config.api.viewV2.search( + createViewResponse.id, + { + sort: { + column: sortParams.field, + order: sortParams.order, + type: sortParams.type, + }, + } + ) + + expect(response.body.rows).toHaveLength(4) + expect(response.body).toEqual({ + rows: expected.map(name => expect.objectContaining({ name })), + }) + } + ) + + it("when schema is defined, defined columns and row attributes are returned", async () => { + const table = await config.createTable(userTable()) + const rows = [] + for (let i = 0; i < 10; i++) { + rows.push( + await config.createRow({ + tableId: table._id, + name: generator.name(), + age: generator.age(), + }) + ) + } + + const view = await config.api.viewV2.create({ + schema: { name: {} }, + }) + const response = await config.api.viewV2.search(view.id) + + expect(response.body.rows).toHaveLength(10) + expect(response.body.rows).toEqual( + expect.arrayContaining( + rows.map(r => ({ + ...expectAnyInternalColsAttributes, + _viewId: view.id, + name: r.name, + })) + ) + ) + }) + + it("views without data can be returned", async () => { + const table = await config.createTable(userTable()) + + const createViewResponse = await config.api.viewV2.create() + const response = await config.api.viewV2.search(createViewResponse.id) + + expect(response.body.rows).toHaveLength(0) + }) + }) }) }) From d28120de3a75f89fd9a547eb4d1970240f1387d0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 3 Aug 2023 04:58:37 +0200 Subject: [PATCH 026/123] Make search a post request --- .../server/src/api/controllers/row/views.ts | 44 ++++--------------- packages/server/src/api/routes/row.ts | 2 +- .../server/src/tests/utilities/api/viewV2.ts | 28 ++---------- packages/types/src/api/web/app/rows.ts | 9 ++++ 4 files changed, 23 insertions(+), 60 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index c38b7fe56e..963576fff3 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -1,14 +1,8 @@ import { quotas } from "@budibase/pro" -import { - UserCtx, - SearchResponse, - SortOrder, - SortType, - ViewV2, -} from "@budibase/types" +import { UserCtx, SearchResponse, ViewV2, SearchRequest } from "@budibase/types" import sdk from "../../../sdk" -export async function searchView(ctx: UserCtx) { +export async function searchView(ctx: UserCtx) { const { viewId } = ctx.params const view = await sdk.views.get(viewId) @@ -35,7 +29,7 @@ export async function searchView(ctx: UserCtx) { tableId: view.tableId, query: view.query || {}, fields: viewFields, - ...getSortOptions(ctx, view), + ...getSortOptions(ctx.request.body, view), }), { datasourceId: view.tableId, @@ -46,32 +40,12 @@ export async function searchView(ctx: UserCtx) { ctx.body = result } -function getSortOptions( - ctx: UserCtx, - view: ViewV2 -): - | { - sort: string - sortOrder?: SortOrder - sortType?: SortType - } - | undefined { - const { sort_column, sort_order, sort_type } = ctx.query - if (Array.isArray(sort_column)) { - ctx.throw(400, "sort_column cannot be an array") - } - if (Array.isArray(sort_order)) { - ctx.throw(400, "sort_order cannot be an array") - } - if (Array.isArray(sort_type)) { - ctx.throw(400, "sort_type cannot be an array") - } - - if (sort_column) { +function getSortOptions(request: SearchRequest, view: ViewV2) { + if (request.sort?.column) { return { - sort: sort_column, - sortOrder: sort_order as SortOrder, - sortType: sort_type as SortType, + sort: request.sort.column, + sortOrder: request.sort.order, + sortType: request.sort.type, } } if (view.sort) { @@ -82,5 +56,5 @@ function getSortOptions( } } - return + return undefined } diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index ac0cd2b4a4..cb1bab3361 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -269,7 +269,7 @@ router ) router - .get( + .post( "/api/v2/views/:viewId/search", authorized(PermissionType.VIEW, PermissionLevel.READ), rowController.views.searchView diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index 5ad2b2d3d7..0622fb823c 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -1,13 +1,12 @@ import { CreateViewRequest, - SortOrder, - SortType, UpdateViewRequest, DeleteRowRequest, PatchRowRequest, PatchRowResponse, Row, ViewV2, + SearchRequest, } from "@budibase/types" import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" @@ -81,31 +80,12 @@ export class ViewV2API extends TestAPI { search = async ( viewId: string, - options?: { - sort: { - column: string - order?: SortOrder - type?: SortType - } - }, + params?: SearchRequest, { expectStatus } = { expectStatus: 200 } ) => { - const qs: [string, any][] = [] - if (options?.sort.column) { - qs.push(["sort_column", options.sort.column]) - } - if (options?.sort.order) { - qs.push(["sort_order", options.sort.order]) - } - if (options?.sort.type) { - qs.push(["sort_type", options.sort.type]) - } - let url = `/api/v2/views/${viewId}/search` - if (qs.length) { - url += "?" + qs.map(q => q.join("=")).join("&") - } return this.request - .get(url) + .post(`/api/v2/views/${viewId}/search`) + .send(params) .set(this.config.defaultHeaders()) .expect("Content-Type", /json/) .expect(expectStatus) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index fedb8ec146..e5bbdb8645 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,4 +1,5 @@ import { Row } from "../../../documents" +import { SortOrder, SortType } from "../pagination" export interface PatchRowRequest extends Row { _id: string @@ -8,6 +9,14 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} +export interface SearchRequest { + sort?: { + column: string + order?: SortOrder + type?: SortType + } +} + export interface SearchResponse { rows: any[] } From a91ce15c9bf4ad33106da760e96a4e177cdc807c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 3 Aug 2023 05:14:50 +0200 Subject: [PATCH 027/123] Move interface SearchParams to types --- packages/server/src/sdk/app/rows/search.ts | 16 +--------------- packages/types/src/sdk/index.ts | 1 + packages/types/src/sdk/row.ts | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 packages/types/src/sdk/row.ts diff --git a/packages/server/src/sdk/app/rows/search.ts b/packages/server/src/sdk/app/rows/search.ts index a523d828f3..4861f473ea 100644 --- a/packages/server/src/sdk/app/rows/search.ts +++ b/packages/server/src/sdk/app/rows/search.ts @@ -1,23 +1,9 @@ -import { SearchFilters, SortOrder, SortType } from "@budibase/types" +import { SearchFilters, SearchParams } from "@budibase/types" import { isExternalTable } from "../../../integrations/utils" import * as internal from "./search/internal" import * as external from "./search/external" import { Format } from "../../../api/controllers/view/exporters" -export interface SearchParams { - tableId: string - paginate?: boolean - query: SearchFilters - bookmark?: string - limit?: number - sort?: string - sortOrder?: SortOrder - sortType?: SortType - version?: string - disableEscaping?: boolean - fields?: string[] -} - export interface ViewParams { calculation: string group: string diff --git a/packages/types/src/sdk/index.ts b/packages/types/src/sdk/index.ts index e4b5778ed9..0eab2ba556 100644 --- a/packages/types/src/sdk/index.ts +++ b/packages/types/src/sdk/index.ts @@ -19,3 +19,4 @@ export * from "./user" export * from "./cli" export * from "./websocket" export * from "./permissions" +export * from "./row" diff --git a/packages/types/src/sdk/row.ts b/packages/types/src/sdk/row.ts new file mode 100644 index 0000000000..7e4b89e0f7 --- /dev/null +++ b/packages/types/src/sdk/row.ts @@ -0,0 +1,16 @@ +import { SortOrder, SortType } from "../api" +import { SearchFilters } from "./search" + +export interface SearchParams { + tableId: string + paginate?: boolean + query: SearchFilters + bookmark?: string + limit?: number + sort?: string + sortOrder?: SortOrder + sortType?: SortType + version?: string + disableEscaping?: boolean + fields?: string[] +} From cb59a2fc9bdeb7d2724a83dd71589d88086eb798 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 3 Aug 2023 05:16:10 +0200 Subject: [PATCH 028/123] Type search request --- packages/server/src/api/controllers/row/index.ts | 7 +++++-- packages/server/src/api/controllers/row/views.ts | 4 ++-- packages/types/src/api/web/app/rows.ts | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 7f6f494621..695e626630 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -11,6 +11,9 @@ import { Row, PatchRowRequest, PatchRowResponse, + SearchRowResponse, + SearchRowRequest, + SearchParams, } from "@budibase/types" import * as utils from "./utils" import { gridSocket } from "../../../websockets" @@ -197,10 +200,10 @@ export async function destroy(ctx: UserCtx) { ctx.body = response } -export async function search(ctx: any) { +export async function search(ctx: Ctx) { const tableId = utils.getTableId(ctx) - const searchParams = { + const searchParams: SearchParams = { ...ctx.request.body, tableId, } diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index c38b7fe56e..2af95f444e 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -1,14 +1,14 @@ import { quotas } from "@budibase/pro" import { UserCtx, - SearchResponse, + SearchRowResponse, SortOrder, SortType, ViewV2, } from "@budibase/types" import sdk from "../../../sdk" -export async function searchView(ctx: UserCtx) { +export async function searchView(ctx: UserCtx) { const { viewId } = ctx.params const view = await sdk.views.get(viewId) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index fedb8ec146..493cff09bc 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,3 +1,4 @@ +import { SearchParams } from "../../../sdk" import { Row } from "../../../documents" export interface PatchRowRequest extends Row { @@ -8,6 +9,8 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} -export interface SearchResponse { +export interface SearchRowRequest extends SearchParams {} + +export interface SearchRowResponse { rows: any[] } From 464ba92b47bf2dbacc383078d3c315022737ea11 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 3 Aug 2023 14:32:03 +0300 Subject: [PATCH 029/123] Fix tests --- packages/server/src/api/routes/tests/row.spec.ts | 8 +++----- packages/server/src/tests/utilities/api/viewV2.ts | 4 ++-- packages/types/src/api/web/app/rows.ts | 5 ++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 012ed537ee..3061cf6356 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1212,11 +1212,9 @@ describe("/rows", () => { const response = await config.api.viewV2.search( createViewResponse.id, { - sort: { - column: sortParams.field, - order: sortParams.order, - type: sortParams.type, - }, + sort: sortParams.field, + sortOrder: sortParams.order, + sortType: sortParams.type, } ) diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index 0622fb823c..813d2ebfd1 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -6,7 +6,7 @@ import { PatchRowResponse, Row, ViewV2, - SearchRequest, + SearchViewRowRequest, } from "@budibase/types" import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" @@ -80,7 +80,7 @@ export class ViewV2API extends TestAPI { search = async ( viewId: string, - params?: SearchRequest, + params?: SearchViewRowRequest, { expectStatus } = { expectStatus: 200 } ) => { return this.request diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 493cff09bc..39e856b297 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -9,7 +9,10 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} -export interface SearchRowRequest extends SearchParams {} +export interface SearchRowRequest extends Omit {} + +export interface SearchViewRowRequest + extends Pick {} export interface SearchRowResponse { rows: any[] From 8c61359b9d940b6f4eaa6d4840d7f53c2e199066 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 3 Aug 2023 17:23:15 +0100 Subject: [PATCH 030/123] Allow user specified type casting in MySQL queries --- .vscode/launch.json | 72 ++++++++----------- packages/server/package.json | 2 +- .../server/src/api/controllers/query/index.ts | 4 +- .../tests/{filter.spec.js => filter.spec.ts} | 23 +++--- packages/server/src/integrations/mysql.ts | 11 ++- packages/server/src/threads/definitions.ts | 6 ++ packages/server/src/threads/query.ts | 31 +++++++- 7 files changed, 94 insertions(+), 55 deletions(-) rename packages/server/src/automations/tests/{filter.spec.js => filter.spec.ts} (76%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8cb49d5825..6c0089bb6b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,42 +1,32 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Budibase Server", - "type": "node", - "request": "launch", - "runtimeArgs": [ - "--nolazy", - "-r", - "ts-node/register/transpile-only" - ], - "args": [ - "${workspaceFolder}/packages/server/src/index.ts" - ], - "cwd": "${workspaceFolder}/packages/server" - }, - { - "name": "Budibase Worker", - "type": "node", - "request": "launch", - "runtimeArgs": [ - "--nolazy", - "-r", - "ts-node/register/transpile-only" - ], - "args": [ - "${workspaceFolder}/packages/worker/src/index.ts" - ], - "cwd": "${workspaceFolder}/packages/worker" - }, - ], - "compounds": [ - { - "name": "Start Budibase", - "configurations": ["Budibase Server", "Budibase Worker"] - } - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Budibase Server", + "type": "node", + "request": "launch", + "runtimeVersion": "14.20.1", + "runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], + "args": ["${workspaceFolder}/packages/server/src/index.ts"], + "cwd": "${workspaceFolder}/packages/server" + }, + { + "name": "Budibase Worker", + "type": "node", + "request": "launch", + "runtimeVersion": "14.20.1", + "runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], + "args": ["${workspaceFolder}/packages/worker/src/index.ts"], + "cwd": "${workspaceFolder}/packages/worker" + } + ], + "compounds": [ + { + "name": "Start Budibase", + "configurations": ["Budibase Server", "Budibase Worker"] + } + ] +} diff --git a/packages/server/package.json b/packages/server/package.json index e112c1f572..aedab54a81 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -100,7 +100,7 @@ "memorystream": "0.3.1", "mongodb": "5.7", "mssql": "9.1.1", - "mysql2": "2.3.3", + "mysql2": "3.5.2", "node-fetch": "2.6.7", "object-sizeof": "2.6.1", "open": "8.4.0", diff --git a/packages/server/src/api/controllers/query/index.ts b/packages/server/src/api/controllers/query/index.ts index c32e17bd92..8e13041bf4 100644 --- a/packages/server/src/api/controllers/query/index.ts +++ b/packages/server/src/api/controllers/query/index.ts @@ -120,7 +120,7 @@ export async function preview(ctx: any) { const query = ctx.request.body // preview may not have a queryId as it hasn't been saved, but if it does // this stops dynamic variables from calling the same query - const { fields, parameters, queryVerb, transformer, queryId } = query + const { fields, parameters, queryVerb, transformer, queryId, schema } = query const authConfigCtx: any = getAuthConfig(ctx) @@ -133,6 +133,7 @@ export async function preview(ctx: any) { parameters, transformer, queryId, + schema, // have to pass down to the thread runner - can't put into context now environmentVariables: envVars, ctx: { @@ -228,6 +229,7 @@ async function execute( user: ctx.user, auth: { ...authConfigCtx }, }, + schema: query.schema, } const runFn = () => Runner.run(inputs) diff --git a/packages/server/src/automations/tests/filter.spec.js b/packages/server/src/automations/tests/filter.spec.ts similarity index 76% rename from packages/server/src/automations/tests/filter.spec.js rename to packages/server/src/automations/tests/filter.spec.ts index 5fa5e0e202..c2c5d13e2d 100644 --- a/packages/server/src/automations/tests/filter.spec.js +++ b/packages/server/src/automations/tests/filter.spec.ts @@ -1,11 +1,18 @@ -const setup = require("./utilities") -const { FilterConditions } = require("../steps/filter") +import * as setup from "./utilities" +import { FilterConditions } from "../steps/filter" describe("test the filter logic", () => { - async function checkFilter(field, condition, value, pass = true) { - let res = await setup.runStep(setup.actions.FILTER.stepId, - { field, condition, value } - ) + async function checkFilter( + field: any, + condition: string, + value: any, + pass = true + ) { + let res = await setup.runStep(setup.actions.FILTER.stepId, { + field, + condition, + value, + }) expect(res.result).toEqual(pass) expect(res.success).toEqual(true) } @@ -36,9 +43,9 @@ describe("test the filter logic", () => { it("check date coercion", async () => { await checkFilter( - (new Date()).toISOString(), + new Date().toISOString(), FilterConditions.GREATER_THAN, - (new Date(-10000)).toISOString(), + new Date(-10000).toISOString(), true ) }) diff --git a/packages/server/src/integrations/mysql.ts b/packages/server/src/integrations/mysql.ts index a01f6b71f9..cb71a78013 100644 --- a/packages/server/src/integrations/mysql.ts +++ b/packages/server/src/integrations/mysql.ts @@ -148,7 +148,9 @@ class MySQLIntegration extends Sql implements DatasourcePlus { this.config = { ...config, multipleStatements: true, - typeCast: function (field: any, next: any) { + } + if (!this.config.typeCast) { + this.config.typeCast = function (field: any, next: any) { if ( field.type == "DATETIME" || field.type === "DATE" || @@ -161,7 +163,7 @@ class MySQLIntegration extends Sql implements DatasourcePlus { return field.buffer()?.[0] } return next() - }, + } } } @@ -204,7 +206,10 @@ class MySQLIntegration extends Sql implements DatasourcePlus { async internalQuery( query: SqlQuery, - opts: { connect?: boolean; disableCoercion?: boolean } = { + opts: { + connect?: boolean + disableCoercion?: boolean + } = { connect: true, disableCoercion: false, } diff --git a/packages/server/src/threads/definitions.ts b/packages/server/src/threads/definitions.ts index 21e7ce0b69..dd0891d34a 100644 --- a/packages/server/src/threads/definitions.ts +++ b/packages/server/src/threads/definitions.ts @@ -11,6 +11,12 @@ export interface QueryEvent { queryId: string environmentVariables?: Record ctx?: any + schema?: { + [key: string]: { + name: string + type: string + } + } } export interface QueryVariable { diff --git a/packages/server/src/threads/query.ts b/packages/server/src/threads/query.ts index 9901ddffa6..d3949f7e25 100644 --- a/packages/server/src/threads/query.ts +++ b/packages/server/src/threads/query.ts @@ -8,6 +8,7 @@ import { context, cache, auth } from "@budibase/backend-core" import { getGlobalIDFromUserMetadataID } from "../db/utils" import sdk from "../sdk" import { cloneDeep } from "lodash/fp" +import { SourceName } from "@budibase/types" import { isSQL } from "../integrations/utils" import { interpolateSQL } from "../integrations/queries/sql" @@ -27,6 +28,7 @@ class QueryRunner { hasRerun: boolean hasRefreshedOAuth: boolean hasDynamicVariables: boolean + schema: any constructor(input: QueryEvent, flags = { noRecursiveQuery: false }) { this.datasource = input.datasource @@ -36,6 +38,7 @@ class QueryRunner { this.pagination = input.pagination this.transformer = input.transformer this.queryId = input.queryId + this.schema = input.schema this.noRecursiveQuery = flags.noRecursiveQuery this.cachedVariables = [] // Additional context items for enrichment @@ -50,7 +53,7 @@ class QueryRunner { } async execute(): Promise { - let { datasource, fields, queryVerb, transformer } = this + let { datasource, fields, queryVerb, transformer, schema } = this let datasourceClone = cloneDeep(datasource) let fieldsClone = cloneDeep(fields) @@ -67,6 +70,32 @@ class QueryRunner { datasourceClone.config.authConfigs = updatedConfigs } + if (datasource.source === SourceName.MYSQL && schema) { + datasourceClone.config.typeCast = function (field: any, next: any) { + if (schema[field.name]?.name === field.name) { + if (["LONGLONG", "NEWDECIMAL", "DECIMAL"].includes(field.type)) { + if (schema[field.name]?.type === "number") { + const value = field.string() + return value ? Number(value) : null + } else { + return field.string() + } + } + } + if ( + field.type == "DATETIME" || + field.type === "DATE" || + field.type === "TIMESTAMP" + ) { + return field.string() + } + if (field.type === "BIT" && field.length === 1) { + return field.buffer()?.[0] + } + return next() + } + } + const integration = new Integration(datasourceClone.config) // pre-query, make sure datasource variables are added to parameters From 057761fdd902c8455e15b99316be39e0f973b358 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 3 Aug 2023 18:13:51 +0100 Subject: [PATCH 031/123] Update filters types with schemaFields --- .../controls/FilterEditor/FilterDrawer.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index e8bbb8a354..25a03a93de 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -17,7 +17,7 @@ import { generate } from "shortid" import { LuceneUtils, Constants } from "@budibase/frontend-core" import { getFields } from "helpers/searchFields" - import { createEventDispatcher } from "svelte" + import { createEventDispatcher, onMount } from "svelte" export let schemaFields export let filters = [] @@ -64,6 +64,15 @@ }) } + onMount(() => { + parseFilters(filters) + rawFilters.forEach(filter => { + filter.type = + schemaFields.find(field => field.name === filter.field)?.type || + filter.type + }) + }) + // Add field key prefixes and a special metadata filter object to indicate // whether to use the "match all" or "match any" behaviour const enrichFilters = (rawFilters, matchAny) => { From 20f71fadd32fb7f92e8e6ae972ccbf79707e509a Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 3 Aug 2023 18:52:55 +0100 Subject: [PATCH 032/123] Refactor --- packages/server/src/integrations/mysql.ts | 63 +++++++++++++++++------ packages/server/src/threads/query.ts | 29 ++--------- packages/types/src/sdk/datasources.ts | 6 +++ 3 files changed, 56 insertions(+), 42 deletions(-) diff --git a/packages/server/src/integrations/mysql.ts b/packages/server/src/integrations/mysql.ts index cb71a78013..b88162c59a 100644 --- a/packages/server/src/integrations/mysql.ts +++ b/packages/server/src/integrations/mysql.ts @@ -93,6 +93,21 @@ const SCHEMA: Integration = { }, } +const defaultTypeCasting = function (field: any, next: any) { + if ( + field.type == "DATETIME" || + field.type === "DATE" || + field.type === "TIMESTAMP" || + field.type === "LONGLONG" + ) { + return field.string() + } + if (field.type === "BIT" && field.length === 1) { + return field.buffer()?.[0] + } + return next() +} + export function bindingTypeCoerce(bindings: any[]) { for (let i = 0; i < bindings.length; i++) { const binding = bindings[i] @@ -147,24 +162,9 @@ class MySQLIntegration extends Sql implements DatasourcePlus { delete config.rejectUnauthorized this.config = { ...config, + typeCast: defaultTypeCasting, multipleStatements: true, } - if (!this.config.typeCast) { - this.config.typeCast = function (field: any, next: any) { - if ( - field.type == "DATETIME" || - field.type === "DATE" || - field.type === "TIMESTAMP" || - field.type === "LONGLONG" - ) { - return field.string() - } - if (field.type === "BIT" && field.length === 1) { - return field.buffer()?.[0] - } - return next() - } - } } async testConnection() { @@ -196,6 +196,37 @@ class MySQLIntegration extends Sql implements DatasourcePlus { return `concat(${parts.join(", ")})` } + defineTypeCastingFromSchema(schema: { + [key: string]: { name: string; type: string } + }): void { + if (!schema) { + return + } + this.config.typeCast = function (field: any, next: any) { + if (schema[field.name]?.name === field.name) { + if (["LONGLONG", "NEWDECIMAL", "DECIMAL"].includes(field.type)) { + if (schema[field.name]?.type === "number") { + const value = field.string() + return value ? Number(value) : null + } else { + return field.string() + } + } + } + if ( + field.type == "DATETIME" || + field.type === "DATE" || + field.type === "TIMESTAMP" + ) { + return field.string() + } + if (field.type === "BIT" && field.length === 1) { + return field.buffer()?.[0] + } + return next() + } + } + async connect() { this.client = await mysql.createConnection(this.config) } diff --git a/packages/server/src/threads/query.ts b/packages/server/src/threads/query.ts index d3949f7e25..37720c66ba 100644 --- a/packages/server/src/threads/query.ts +++ b/packages/server/src/threads/query.ts @@ -70,34 +70,11 @@ class QueryRunner { datasourceClone.config.authConfigs = updatedConfigs } - if (datasource.source === SourceName.MYSQL && schema) { - datasourceClone.config.typeCast = function (field: any, next: any) { - if (schema[field.name]?.name === field.name) { - if (["LONGLONG", "NEWDECIMAL", "DECIMAL"].includes(field.type)) { - if (schema[field.name]?.type === "number") { - const value = field.string() - return value ? Number(value) : null - } else { - return field.string() - } - } - } - if ( - field.type == "DATETIME" || - field.type === "DATE" || - field.type === "TIMESTAMP" - ) { - return field.string() - } - if (field.type === "BIT" && field.length === 1) { - return field.buffer()?.[0] - } - return next() - } - } - const integration = new Integration(datasourceClone.config) + // define the type casting from the schema + integration.defineTypeCastingFromSchema?.(schema) + // pre-query, make sure datasource variables are added to parameters const parameters = await this.addDatasourceVariables() diff --git a/packages/types/src/sdk/datasources.ts b/packages/types/src/sdk/datasources.ts index 2391f6e878..d6a0d4a7c8 100644 --- a/packages/types/src/sdk/datasources.ts +++ b/packages/types/src/sdk/datasources.ts @@ -166,6 +166,12 @@ export interface IntegrationBase { delete?(query: any): Promise testConnection?(): Promise getExternalSchema?(): Promise + defineTypeCastingFromSchema?(schema: { + [key: string]: { + name: string + type: string + } + }): void } export interface DatasourcePlus extends IntegrationBase { From d3470dfcb06ed8ce69e0a3fa3c25d6f163ddeffa Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Aug 2023 12:00:25 +0300 Subject: [PATCH 033/123] Fix imports --- packages/server/src/sdk/app/rows/search/external.ts | 3 ++- packages/server/src/sdk/app/rows/search/internal.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search/external.ts b/packages/server/src/sdk/app/rows/search/external.ts index 159f3d84fd..447d1d7d16 100644 --- a/packages/server/src/sdk/app/rows/search/external.ts +++ b/packages/server/src/sdk/app/rows/search/external.ts @@ -6,6 +6,7 @@ import { IncludeRelationship, Row, SearchFilters, + SearchParams, } from "@budibase/types" import * as exporters from "../../../../api/controllers/view/exporters" import sdk from "../../../../sdk" @@ -13,7 +14,7 @@ import { handleRequest } from "../../../../api/controllers/row/external" import { breakExternalTableId } from "../../../../integrations/utils" import { cleanExportRows } from "../utils" import { utils } from "@budibase/shared-core" -import { ExportRowsParams, ExportRowsResult, SearchParams } from "../search" +import { ExportRowsParams, ExportRowsResult } from "../search" import { HTTPError, db } from "@budibase/backend-core" import pick from "lodash/pick" diff --git a/packages/server/src/sdk/app/rows/search/internal.ts b/packages/server/src/sdk/app/rows/search/internal.ts index e7f0aadfd6..dfc5b7dcab 100644 --- a/packages/server/src/sdk/app/rows/search/internal.ts +++ b/packages/server/src/sdk/app/rows/search/internal.ts @@ -12,7 +12,7 @@ import { } from "../../../../db/utils" import { getGlobalUsersFromMetadata } from "../../../../utilities/global" import { outputProcessing } from "../../../../utilities/rowProcessor" -import { Database, Row, Table } from "@budibase/types" +import { Database, Row, Table, SearchParams } from "@budibase/types" import { cleanExportRows } from "../utils" import { Format, @@ -28,7 +28,7 @@ import { getFromMemoryDoc, } from "../../../../api/controllers/view/utils" import sdk from "../../../../sdk" -import { ExportRowsParams, ExportRowsResult, SearchParams } from "../search" +import { ExportRowsParams, ExportRowsResult } from "../search" import pick from "lodash/pick" export async function search(options: SearchParams) { From 4d74a6615fc383599066adec12b078e48c391a98 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Aug 2023 18:22:33 +0300 Subject: [PATCH 034/123] Fix types --- .../src/sdk/app/rows/search/tests/external.spec.ts | 11 +++++++++-- .../src/sdk/app/rows/search/tests/internal.spec.ts | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search/tests/external.spec.ts b/packages/server/src/sdk/app/rows/search/tests/external.spec.ts index b24557fd4f..b3bddfbc97 100644 --- a/packages/server/src/sdk/app/rows/search/tests/external.spec.ts +++ b/packages/server/src/sdk/app/rows/search/tests/external.spec.ts @@ -1,8 +1,15 @@ import { GenericContainer } from "testcontainers" -import { Datasource, FieldType, Row, SourceName, Table } from "@budibase/types" +import { + Datasource, + FieldType, + Row, + SourceName, + Table, + SearchParams, +} from "@budibase/types" + import TestConfiguration from "../../../../../tests/utilities/TestConfiguration" -import { SearchParams } from "../../search" import { search } from "../external" import { expectAnyExternalColsAttributes, diff --git a/packages/server/src/sdk/app/rows/search/tests/internal.spec.ts b/packages/server/src/sdk/app/rows/search/tests/internal.spec.ts index a58c368cea..b3e98a1149 100644 --- a/packages/server/src/sdk/app/rows/search/tests/internal.spec.ts +++ b/packages/server/src/sdk/app/rows/search/tests/internal.spec.ts @@ -1,6 +1,5 @@ -import { FieldType, Row, Table } from "@budibase/types" +import { FieldType, Row, Table, SearchParams } from "@budibase/types" import TestConfiguration from "../../../../../tests/utilities/TestConfiguration" -import { SearchParams } from "../../search" import { search } from "../internal" import { expectAnyInternalColsAttributes, From 4f08f900ed79f92b9ba5441c99a0a67d8cd10e6a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Aug 2023 18:38:07 +0300 Subject: [PATCH 035/123] Type view search --- .../server/src/api/controllers/row/views.ts | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index b8a407399c..629515417b 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -2,13 +2,15 @@ import { quotas } from "@budibase/pro" import { UserCtx, ViewV2, - SearchRowRequest, SearchRowResponse, + SearchViewRowRequest, + RequiredKeys, + SearchParams, } from "@budibase/types" import sdk from "../../../sdk" export async function searchView( - ctx: UserCtx + ctx: UserCtx ) { const { viewId } = ctx.params @@ -30,24 +32,24 @@ export async function searchView( undefined ctx.status = 200 - const result = await quotas.addQuery( - () => - sdk.rows.search({ - tableId: view.tableId, - query: view.query || {}, - fields: viewFields, - ...getSortOptions(ctx.request.body, view), - }), - { - datasourceId: view.tableId, - } - ) + + const searchOptions: RequiredKeys & + RequiredKeys> = { + tableId: view.tableId, + query: view.query || {}, + fields: viewFields, + ...getSortOptions(ctx.request.body, view), + } + + const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), { + datasourceId: view.tableId, + }) result.rows.forEach(r => (r._viewId = view.id)) ctx.body = result } -function getSortOptions(request: SearchRowRequest, view: ViewV2) { +function getSortOptions(request: SearchViewRowRequest, view: ViewV2) { if (request.sort) { return { sort: request.sort, @@ -63,5 +65,9 @@ function getSortOptions(request: SearchRowRequest, view: ViewV2) { } } - return undefined + return { + sort: undefined, + sortOrder: undefined, + sortType: undefined, + } } From 250505a19b5ed74f18757e02dd50e6810dc9f155 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Aug 2023 18:41:49 +0300 Subject: [PATCH 036/123] Add limit on request --- packages/server/src/api/controllers/row/views.ts | 1 + packages/server/src/api/routes/tests/row.spec.ts | 16 ++++++++++++++++ packages/types/src/api/web/app/rows.ts | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 629515417b..9ac052c1e9 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -39,6 +39,7 @@ export async function searchView( query: view.query || {}, fields: viewFields, ...getSortOptions(ctx.request.body, view), + limit: ctx.request.body.limit, } const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), { diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 3061cf6356..2f81a78950 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1263,6 +1263,22 @@ describe("/rows", () => { expect(response.body.rows).toHaveLength(0) }) + + it("returns table rows from view", async () => { + const table = await config.createTable(userTable()) + const rows = [] + for (let i = 0; i < 10; i++) { + rows.push(await config.createRow({ tableId: table._id })) + } + const limit = generator.integer({ min: 1, max: 8 }) + + const createViewResponse = await config.api.viewV2.create() + const response = await config.api.viewV2.search(createViewResponse.id, { + limit, + }) + + expect(response.body.rows).toHaveLength(limit) + }) }) }) }) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 39e856b297..e95afa6e59 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -12,7 +12,7 @@ export interface PatchRowResponse extends Row {} export interface SearchRowRequest extends Omit {} export interface SearchViewRowRequest - extends Pick {} + extends Pick {} export interface SearchRowResponse { rows: any[] From a1d85a831c7118c62918722d3923fc4255945f59 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 4 Aug 2023 16:58:40 +0100 Subject: [PATCH 037/123] Some quick modifications to allow the views to go through the standard row CRUD, the view search is still separate for now however this may change. --- packages/server/src/api/routes/row.ts | 91 +------------------ .../server/src/api/routes/tests/row.spec.ts | 17 ---- packages/server/src/db/utils.ts | 12 ++- packages/server/src/middleware/noViewData.ts | 9 -- .../src/middleware/tests/noViewData.spec.ts | 83 ----------------- .../server/src/middleware/trimViewRowInfo.ts | 14 +-- packages/server/src/sdk/app/views/index.ts | 7 +- packages/types/src/documents/document.ts | 1 + packages/types/src/sdk/permissions.ts | 1 - 9 files changed, 25 insertions(+), 210 deletions(-) delete mode 100644 packages/server/src/middleware/noViewData.ts delete mode 100644 packages/server/src/middleware/tests/noViewData.spec.ts diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index ac0cd2b4a4..3227df98ed 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -4,9 +4,7 @@ import authorized from "../../middleware/authorized" import { paramResource, paramSubResource } from "../../middleware/resourceId" import { permissions } from "@budibase/backend-core" import { internalSearchValidator } from "./utils/validators" -import noViewData from "../../middleware/noViewData" import trimViewRowInfo from "../../middleware/trimViewRowInfo" -import * as utils from "../../db/utils" const { PermissionType, PermissionLevel } = permissions const router: Router = new Router() @@ -177,7 +175,7 @@ router "/api/:tableId/rows", paramResource("tableId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), - noViewData, + trimViewRowInfo, rowController.save ) /** @@ -192,7 +190,7 @@ router "/api/:tableId/rows", paramResource("tableId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), - noViewData, + trimViewRowInfo, rowController.patch ) /** @@ -245,6 +243,7 @@ router "/api/:tableId/rows", paramResource("tableId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), + trimViewRowInfo, rowController.destroy ) @@ -267,92 +266,10 @@ router authorized(PermissionType.TABLE, PermissionLevel.WRITE), rowController.exportRows ) - -router .get( "/api/v2/views/:viewId/search", - authorized(PermissionType.VIEW, PermissionLevel.READ), + authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.views.searchView ) - /** - * @api {post} /api/:tableId/rows Creates a new row - * @apiName Creates a new row - * @apiGroup rows - * @apiPermission table write access - * @apiDescription This API will create a new row based on the supplied body. If the - * body includes an "_id" field then it will update an existing row if the field - * links to one. Please note that "_id", "_rev" and "tableId" are fields that are - * already used by Budibase tables and cannot be used for columns. - * - * @apiParam {string} tableId The ID of the table to save a row to. - * - * @apiParam (Body) {string} [_id] If the row exists already then an ID for the row must be provided. - * @apiParam (Body) {string} [_rev] If working with an existing row for an internal table its revision - * must also be provided. - * @apiParam (Body) {string} _viewId The ID of the view should be specified in the row body itself. - * @apiParam (Body) {string} tableId The ID of the table should also be specified in the row body itself. - * @apiParam (Body) {any} [any] Any field supplied in the body will be assessed to see if it matches - * a column in the specified table. All other fields will be dropped and not stored. - * - * @apiSuccess {string} _id The ID of the row that was just saved, if it was just created this - * is the rows new ID. - * @apiSuccess {string} [_rev] If saving to an internal table a revision will also be returned. - * @apiSuccess {object} body The contents of the row that was saved will be returned as well. - */ - .post( - "/api/v2/views/:viewId/rows", - paramResource("viewId"), - authorized(PermissionType.VIEW, PermissionLevel.WRITE), - trimViewRowInfo, - rowController.save - ) - /** - * @api {patch} /api/v2/views/:viewId/rows/:rowId Updates a row - * @apiName Update a row - * @apiGroup rows - * @apiPermission table write access - * @apiDescription This endpoint is identical to the row creation endpoint but instead it will - * error if an _id isn't provided, it will only function for existing rows. - */ - .patch( - "/api/v2/views/:viewId/rows/:rowId", - paramResource("viewId"), - authorized(PermissionType.VIEW, PermissionLevel.WRITE), - trimViewRowInfo, - rowController.patch - ) - /** - * @api {delete} /api/v2/views/:viewId/rows Delete rows for a view - * @apiName Delete rows for a view - * @apiGroup rows - * @apiPermission table write access - * @apiDescription This endpoint can delete a single row, or delete them in a bulk - * fashion. - * - * @apiParam {string} tableId The ID of the table the row is to be deleted from. - * - * @apiParam (Body) {object[]} [rows] If bulk deletion is desired then provide the rows in this - * key of the request body that are to be deleted. - * @apiParam (Body) {string} [_id] If deleting a single row then provide its ID in this field. - * @apiParam (Body) {string} [_rev] If deleting a single row from an internal table then provide its - * revision here. - * - * @apiSuccess {object[]|object} body If deleting bulk then the response body will be an array - * of the deleted rows, if deleting a single row then the body will contain a "row" property which - * is the deleted row. - */ - .delete( - "/api/v2/views/:viewId/rows", - paramResource("viewId"), - authorized(PermissionType.VIEW, PermissionLevel.WRITE), - // This is required as the implementation relies on the table id - (ctx, next) => { - ctx.params.tableId = utils.extractViewInfoFromID( - ctx.params.viewId - ).tableId - return next() - }, - rowController.destroy - ) export default router diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index b986ffb945..86c41b8503 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -24,7 +24,6 @@ import { structures, } from "@budibase/backend-core/tests" import trimViewRowInfoMiddleware from "../../../middleware/trimViewRowInfo" -import noViewDataMiddleware from "../../../middleware/noViewData" import router from "../row" describe("/rows", () => { @@ -406,14 +405,6 @@ describe("/rows", () => { "Table row endpoints cannot contain view info" ) }) - - it("should setup the noViewData middleware", async () => { - const route = router.stack.find( - r => r.methods.includes("POST") && r.path === "/api/:tableId/rows" - ) - expect(route).toBeDefined() - expect(route?.stack).toContainEqual(noViewDataMiddleware) - }) }) describe("patch", () => { @@ -482,14 +473,6 @@ describe("/rows", () => { "Table row endpoints cannot contain view info" ) }) - - it("should setup the noViewData middleware", async () => { - const route = router.stack.find( - r => r.methods.includes("PATCH") && r.path === "/api/:tableId/rows" - ) - expect(route).toBeDefined() - expect(route?.stack).toContainEqual(noViewDataMiddleware) - }) }) describe("destroy", () => { diff --git a/packages/server/src/db/utils.ts b/packages/server/src/db/utils.ts index dda14a9187..e8dc3b3f6c 100644 --- a/packages/server/src/db/utils.ts +++ b/packages/server/src/db/utils.ts @@ -284,10 +284,20 @@ export function getMultiIDParams(ids: string[]) { * @returns {string} The new view ID which the view doc can be stored under. */ export function generateViewID(tableId: string) { - return `${tableId}${SEPARATOR}${newid()}` + return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}${newid()}` +} + +export function isViewID(viewId: string) { + return viewId?.split(SEPARATOR)[0] === DocumentType.VIEW } export function extractViewInfoFromID(viewId: string) { + if (!isViewID(viewId)) { + throw new Error("Unable to extract table ID, is not a view ID") + } + const split = viewId.split(SEPARATOR) + split.shift() + viewId = split.join(SEPARATOR) const regex = new RegExp(`^(?.+)${SEPARATOR}([^${SEPARATOR}]+)$`) const res = regex.exec(viewId) return { diff --git a/packages/server/src/middleware/noViewData.ts b/packages/server/src/middleware/noViewData.ts deleted file mode 100644 index 809424b6bf..0000000000 --- a/packages/server/src/middleware/noViewData.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Ctx, Row } from "@budibase/types" - -export default async (ctx: Ctx, next: any) => { - if (ctx.request.body._viewId) { - return ctx.throw(400, "Table row endpoints cannot contain view info") - } - - return next() -} diff --git a/packages/server/src/middleware/tests/noViewData.spec.ts b/packages/server/src/middleware/tests/noViewData.spec.ts deleted file mode 100644 index 54b0ca8ff8..0000000000 --- a/packages/server/src/middleware/tests/noViewData.spec.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { generator } from "@budibase/backend-core/tests" -import { BBRequest, FieldType, Row, Table } from "@budibase/types" -import { Next } from "koa" -import * as utils from "../../db/utils" -import noViewDataMiddleware from "../noViewData" - -class TestConfiguration { - next: Next - throw: jest.Mock<(status: number, message: string) => never> - middleware: typeof noViewDataMiddleware - params: Record - request?: Pick, "body"> - - constructor() { - this.next = jest.fn() - this.throw = jest.fn() - this.params = {} - - this.middleware = noViewDataMiddleware - } - - executeMiddleware(ctxRequestBody: Row) { - this.request = { - body: ctxRequestBody, - } - return this.middleware( - { - request: this.request as any, - throw: this.throw as any, - params: this.params, - } as any, - this.next - ) - } - - afterEach() { - jest.clearAllMocks() - } -} - -describe("noViewData middleware", () => { - let config: TestConfiguration - - beforeEach(() => { - config = new TestConfiguration() - }) - - afterEach(() => { - config.afterEach() - }) - - const getRandomData = () => ({ - _id: generator.guid(), - name: generator.name(), - age: generator.age(), - address: generator.address(), - }) - - it("it should pass without view id data", async () => { - const data = getRandomData() - await config.executeMiddleware({ - ...data, - }) - - expect(config.next).toBeCalledTimes(1) - expect(config.throw).not.toBeCalled() - }) - - it("it should throw an error if _viewid is provided", async () => { - const data = getRandomData() - await config.executeMiddleware({ - _viewId: generator.guid(), - ...data, - }) - - expect(config.throw).toBeCalledTimes(1) - expect(config.throw).toBeCalledWith( - 400, - "Table row endpoints cannot contain view info" - ) - expect(config.next).not.toBeCalled() - }) -}) diff --git a/packages/server/src/middleware/trimViewRowInfo.ts b/packages/server/src/middleware/trimViewRowInfo.ts index 2e3ded27f5..763552c3d7 100644 --- a/packages/server/src/middleware/trimViewRowInfo.ts +++ b/packages/server/src/middleware/trimViewRowInfo.ts @@ -7,15 +7,15 @@ import { Next } from "koa" export default async (ctx: Ctx, next: Next) => { const { body } = ctx.request const { _viewId: viewId } = body - if (!viewId) { - return ctx.throw(400, "_viewId is required") + + const possibleViewId = ctx.params.tableId + + // nothing to do, it is not a view (just a table ID) + if (!viewId || !utils.isViewID(possibleViewId)) { + return next() } - if (!ctx.params.viewId) { - return ctx.throw(400, "viewId path is required") - } - - const { tableId } = utils.extractViewInfoFromID(ctx.params.viewId) + const { tableId } = utils.extractViewInfoFromID(possibleViewId) const { _viewId, ...trimmedView } = await trimViewFields( viewId, tableId, diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 7e75f22060..637caa06ee 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -1,17 +1,14 @@ -import { HTTPError, context } from "@budibase/backend-core" +import { context, HTTPError } from "@budibase/backend-core" import { FieldSchema, TableSchema, View, ViewV2 } from "@budibase/types" import sdk from "../../../sdk" import * as utils from "../../../db/utils" -import merge from "lodash/merge" export async function get(viewId: string): Promise { const { tableId } = utils.extractViewInfoFromID(viewId) const table = await sdk.tables.getTable(tableId) const views = Object.values(table.views!) - const view = views.find(v => isV2(v) && v.id === viewId) as ViewV2 | undefined - - return view + return views.find(v => isV2(v) && v.id === viewId) as ViewV2 | undefined } export async function create( diff --git a/packages/types/src/documents/document.ts b/packages/types/src/documents/document.ts index 6ba318269b..164aa79ac9 100644 --- a/packages/types/src/documents/document.ts +++ b/packages/types/src/documents/document.ts @@ -37,6 +37,7 @@ export enum DocumentType { USER_FLAG = "flag", AUTOMATION_METADATA = "meta_au", AUDIT_LOG = "al", + VIEW = "view", } export interface Document { diff --git a/packages/types/src/sdk/permissions.ts b/packages/types/src/sdk/permissions.ts index 9e51e4c7b4..9fe1970e44 100644 --- a/packages/types/src/sdk/permissions.ts +++ b/packages/types/src/sdk/permissions.ts @@ -14,6 +14,5 @@ export enum PermissionType { WEBHOOK = "webhook", BUILDER = "builder", GLOBAL_BUILDER = "globalBuilder", - VIEW = "view", QUERY = "query", } From 497943930ea4e68ad0a879a0002e0e0abdc264a0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 09:22:39 +0300 Subject: [PATCH 038/123] Rename --- packages/server/src/api/routes/tests/row.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 2f81a78950..8f7c6741be 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1264,7 +1264,7 @@ describe("/rows", () => { expect(response.body.rows).toHaveLength(0) }) - it("returns table rows from view", async () => { + it("respects the limit parameter", async () => { const table = await config.createTable(userTable()) const rows = [] for (let i = 0; i < 10; i++) { From 39d099b443b179ad6b371df4d95a84ef4ac6eb21 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 10:49:04 +0300 Subject: [PATCH 039/123] Handle and test pagination --- .../server/src/api/controllers/row/views.ts | 8 ++- .../server/src/api/routes/tests/row.spec.ts | 57 +++++++++++++++++++ packages/types/src/api/web/app/rows.ts | 5 +- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 9ac052c1e9..204cb6b4bc 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -33,13 +33,17 @@ export async function searchView( ctx.status = 200 + const { body } = ctx.request + const searchOptions: RequiredKeys & RequiredKeys> = { tableId: view.tableId, query: view.query || {}, fields: viewFields, - ...getSortOptions(ctx.request.body, view), - limit: ctx.request.body.limit, + ...getSortOptions(body, view), + limit: body.limit, + bookmark: body.bookmark, + paginate: body.paginate, } const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), { diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 8f7c6741be..b9f584706e 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1279,6 +1279,63 @@ describe("/rows", () => { expect(response.body.rows).toHaveLength(limit) }) + + it("can handle pagination", async () => { + const table = await config.createTable(userTable()) + const rows = [] + for (let i = 0; i < 10; i++) { + rows.push(await config.createRow({ tableId: table._id })) + } + // rows.sort((a, b) => (a._id! > b._id! ? 1 : -1)) + + const createViewResponse = await config.api.viewV2.create() + const allRows = (await config.api.viewV2.search(createViewResponse.id)) + .body.rows + + const firstPageResponse = await config.api.viewV2.search( + createViewResponse.id, + { + paginate: true, + limit: 4, + } + ) + expect(firstPageResponse.body).toEqual({ + rows: expect.arrayContaining(allRows.slice(0, 4)), + totalRows: 10, + hasNextPage: true, + bookmark: expect.any(String), + }) + + const secondPageResponse = await config.api.viewV2.search( + createViewResponse.id, + { + paginate: true, + limit: 4, + bookmark: firstPageResponse.body.bookmark, + } + ) + expect(secondPageResponse.body).toEqual({ + rows: expect.arrayContaining(allRows.slice(4, 8)), + totalRows: 10, + hasNextPage: true, + bookmark: expect.any(String), + }) + + const lastPageResponse = await config.api.viewV2.search( + createViewResponse.id, + { + paginate: true, + limit: 4, + bookmark: secondPageResponse.body.bookmark, + } + ) + expect(lastPageResponse.body).toEqual({ + rows: expect.arrayContaining(allRows.slice(8)), + totalRows: 10, + hasNextPage: false, + bookmark: expect.any(String), + }) + }) }) }) }) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index e95afa6e59..f1890ef777 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -12,7 +12,10 @@ export interface PatchRowResponse extends Row {} export interface SearchRowRequest extends Omit {} export interface SearchViewRowRequest - extends Pick {} + extends Pick< + SearchRowRequest, + "sort" | "sortOrder" | "sortType" | "limit" | "bookmark" | "paginate" + > {} export interface SearchRowResponse { rows: any[] From 74287370dff0508c3fcee59455cbfc5a587b1f11 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 11:18:36 +0300 Subject: [PATCH 040/123] Move filter types to types --- packages/shared-core/src/filters.ts | 78 +++++----------------- packages/types/src/api/web/index.ts | 1 + packages/types/src/api/web/searchFilter.ts | 49 ++++++++++++++ 3 files changed, 66 insertions(+), 62 deletions(-) create mode 100644 packages/types/src/api/web/searchFilter.ts diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 54e0df92df..6602762160 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -1,4 +1,12 @@ -import { Datasource, FieldType, SortDirection, SortType } from "@budibase/types" +import { + Datasource, + FieldType, + SearchFilter, + SearchQuery, + SearchQueryFields, + SortDirection, + SortType, +} from "@budibase/types" import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants" import { deepGet } from "./helpers" @@ -73,13 +81,13 @@ export const NoEmptyFilterStrings = [ OperatorOptions.NotEquals.value, OperatorOptions.Contains.value, OperatorOptions.NotContains.value, -] as (keyof QueryFields)[] +] as (keyof SearchQueryFields)[] /** * Removes any fields that contain empty strings that would cause inconsistent * behaviour with how backend tables are filtered (no value means no filter). */ -const cleanupQuery = (query: Query) => { +const cleanupQuery = (query: SearchQuery) => { if (!query) { return query } @@ -110,66 +118,12 @@ const removeKeyNumbering = (key: string) => { } } -type Filter = { - operator: keyof Query - field: string - type: any - value: any - externalType: keyof typeof SqlNumberTypeRangeMap -} - -type Query = QueryFields & QueryConfig -type QueryFields = { - string?: { - [key: string]: string - } - fuzzy?: { - [key: string]: string - } - range?: { - [key: string]: { - high: number | string - low: number | string - } - } - equal?: { - [key: string]: any - } - notEqual?: { - [key: string]: any - } - empty?: { - [key: string]: any - } - notEmpty?: { - [key: string]: any - } - oneOf?: { - [key: string]: any[] - } - contains?: { - [key: string]: any[] - } - notContains?: { - [key: string]: any[] - } - containsAny?: { - [key: string]: any[] - } -} - -type QueryConfig = { - allOr?: boolean -} - -type QueryFieldsType = keyof QueryFields - /** * Builds a lucene JSON query from the filter structure generated in the builder * @param filter the builder filter structure */ -export const buildLuceneQuery = (filter: Filter[]) => { - let query: Query = { +export const buildLuceneQuery = (filter: SearchFilter[]) => { + let query: SearchQuery = { string: {}, fuzzy: {}, range: {}, @@ -275,7 +229,7 @@ export const buildLuceneQuery = (filter: Filter[]) => { * @param docs the data * @param query the JSON lucene query */ -export const runLuceneQuery = (docs: any[], query?: Query) => { +export const runLuceneQuery = (docs: any[], query?: SearchQuery) => { if (!docs || !Array.isArray(docs)) { return [] } @@ -289,7 +243,7 @@ export const runLuceneQuery = (docs: any[], query?: Query) => { // Iterates over a set of filters and evaluates a fail function against a doc const match = ( - type: QueryFieldsType, + type: keyof SearchQueryFields, failFn: (docValue: any, testValue: any) => boolean ) => (doc: any) => { @@ -456,7 +410,7 @@ export const luceneLimit = (docs: any[], limit: string) => { return docs.slice(0, numLimit) } -export const hasFilters = (query?: Query) => { +export const hasFilters = (query?: SearchQuery) => { if (!query) { return false } diff --git a/packages/types/src/api/web/index.ts b/packages/types/src/api/web/index.ts index 0e0527eb7f..cba1e04f9a 100644 --- a/packages/types/src/api/web/index.ts +++ b/packages/types/src/api/web/index.ts @@ -8,3 +8,4 @@ export * from "./system" export * from "./app" export * from "./global" export * from "./pagination" +export * from "./searchFilter" diff --git a/packages/types/src/api/web/searchFilter.ts b/packages/types/src/api/web/searchFilter.ts new file mode 100644 index 0000000000..4dc00453d3 --- /dev/null +++ b/packages/types/src/api/web/searchFilter.ts @@ -0,0 +1,49 @@ +export type SearchFilter = { + operator: keyof SearchQuery + field: string + type: any + value: any + externalType: "integer" | "int" | "smallint" | "mediumint" +} + +export type SearchQuery = { + allOr?: boolean + string?: { + [key: string]: string + } + fuzzy?: { + [key: string]: string + } + range?: { + [key: string]: { + high: number | string + low: number | string + } + } + equal?: { + [key: string]: any + } + notEqual?: { + [key: string]: any + } + empty?: { + [key: string]: any + } + notEmpty?: { + [key: string]: any + } + oneOf?: { + [key: string]: any[] + } + contains?: { + [key: string]: any[] + } + notContains?: { + [key: string]: any[] + } + containsAny?: { + [key: string]: any[] + } +} + +export type SearchQueryFields = Omit From 77568af7048cfdd569b9afe30dc83195d43fd21b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 13:14:18 +0300 Subject: [PATCH 041/123] Change filter query to store the expected shape --- packages/server/src/api/controllers/row/views.ts | 4 +++- packages/server/src/api/routes/tests/row.spec.ts | 9 ++++++++- packages/shared-core/src/filters.ts | 8 ++++++-- packages/types/src/api/web/searchFilter.ts | 6 ++++-- packages/types/src/documents/app/view.ts | 7 +++---- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index c38b7fe56e..9d6e38b1ec 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -6,6 +6,7 @@ import { SortType, ViewV2, } from "@budibase/types" +import { dataFilters } from "@budibase/shared-core" import sdk from "../../../sdk" export async function searchView(ctx: UserCtx) { @@ -29,11 +30,12 @@ export async function searchView(ctx: UserCtx) { undefined ctx.status = 200 + const query = dataFilters.buildLuceneQuery(view.query || []) const result = await quotas.addQuery( () => sdk.rows.search({ tableId: view.tableId, - query: view.query || {}, + query, fields: viewFields, ...getSortOptions(ctx, view), }), diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index b986ffb945..230aaa54cf 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -869,7 +869,14 @@ describe("/rows", () => { ) const createViewResponse = await config.api.viewV2.create({ - query: { equal: { age: 40 } }, + query: [ + { + operator: "equal", + field: "age", + value: "40", + type: FieldType.NUMBER, + }, + ], }) const response = await config.api.viewV2.search(createViewResponse.id) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 6602762160..8739db1b40 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -181,9 +181,13 @@ export const buildLuceneQuery = (filter: SearchFilter[]) => { } if (operator.startsWith("range") && query.range) { const minint = - SqlNumberTypeRangeMap[externalType]?.min || Number.MIN_SAFE_INTEGER + SqlNumberTypeRangeMap[ + externalType as keyof typeof SqlNumberTypeRangeMap + ]?.min || Number.MIN_SAFE_INTEGER const maxint = - SqlNumberTypeRangeMap[externalType]?.max || Number.MAX_SAFE_INTEGER + SqlNumberTypeRangeMap[ + externalType as keyof typeof SqlNumberTypeRangeMap + ]?.max || Number.MAX_SAFE_INTEGER if (!query.range[field]) { query.range[field] = { low: type === "number" ? minint : "0000-00-00T00:00:00.000Z", diff --git a/packages/types/src/api/web/searchFilter.ts b/packages/types/src/api/web/searchFilter.ts index 4dc00453d3..1b5948e50c 100644 --- a/packages/types/src/api/web/searchFilter.ts +++ b/packages/types/src/api/web/searchFilter.ts @@ -1,9 +1,11 @@ +import { FieldType } from "../../documents" + export type SearchFilter = { operator: keyof SearchQuery field: string - type: any + type?: FieldType value: any - externalType: "integer" | "int" | "smallint" | "mediumint" + externalType?: string } export type SearchQuery = { diff --git a/packages/types/src/documents/app/view.ts b/packages/types/src/documents/app/view.ts index 3fe8b4a500..204b995337 100644 --- a/packages/types/src/documents/app/view.ts +++ b/packages/types/src/documents/app/view.ts @@ -1,6 +1,5 @@ -import { SortOrder, SortType } from "../../api" -import { SearchFilters } from "../../sdk" -import { TableSchema, UIFieldMetadata } from "./table" +import { SearchFilter, SortOrder, SortType } from "../../api" +import { UIFieldMetadata } from "./table" export interface View { name: string @@ -20,7 +19,7 @@ export interface ViewV2 { name: string primaryDisplay?: string tableId: string - query?: SearchFilters + query?: SearchFilter[] sort?: { field: string order?: SortOrder From c60a54bd23df677644f735594216f33cefdd1e90 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 13:50:48 +0300 Subject: [PATCH 042/123] Fix checks --- .github/workflows/budibase_ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 9da52f8bc0..f57a729ba9 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -25,13 +25,13 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.repository != 'Budibase/budibase' + if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -46,13 +46,13 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.repository != 'Budibase/budibase' + if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -70,13 +70,13 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.repository != 'Budibase/budibase' + if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -96,13 +96,13 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.repository != 'Budibase/budibase' + if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -119,7 +119,7 @@ jobs: test-pro: runs-on: ubuntu-latest - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 @@ -140,13 +140,13 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.repository != 'Budibase/budibase' + if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -166,7 +166,7 @@ jobs: check-pro-submodule: runs-on: ubuntu-latest - if: github.repository == 'Budibase/budibase' + if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 From be3912904e2f88577889b29464f9f14585b571a7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 13:56:57 +0300 Subject: [PATCH 043/123] Fix yaml --- .github/workflows/budibase_ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index f57a729ba9..60401099bc 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -46,7 +46,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -70,7 +70,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -96,7 +96,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -119,7 +119,7 @@ jobs: test-pro: runs-on: ubuntu-latest - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 @@ -140,7 +140,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -166,7 +166,7 @@ jobs: check-pro-submodule: runs-on: ubuntu-latest - if: github.event_name = "pull_request" && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 From b5e7755948a8c98bf14de75c070a66e4dc1ebd47 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 13:59:59 +0300 Subject: [PATCH 044/123] Attempt yaml --- .github/workflows/budibase_ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 60401099bc..9730487684 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -46,7 +46,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -70,7 +70,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -96,7 +96,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -119,7 +119,7 @@ jobs: test-pro: runs-on: ubuntu-latest - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 @@ -140,7 +140,7 @@ jobs: steps: - name: Checkout repo and submodules uses: actions/checkout@v3 - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} @@ -166,7 +166,7 @@ jobs: check-pro-submodule: runs-on: ubuntu-latest - if: github.event_name = 'pull_request' && github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' steps: - name: Checkout repo and submodules uses: actions/checkout@v3 From 02f28442d69238affa0cc356351db0aab75fe980 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 14:05:44 +0300 Subject: [PATCH 045/123] Fix double checkout --- .github/workflows/budibase_ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 9730487684..e060db8370 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -31,7 +31,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -52,7 +52,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -76,7 +76,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -102,7 +102,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 @@ -146,7 +146,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Checkout repo only uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' - name: Use Node.js 14.x uses: actions/setup-node@v3 From c6fba3a82787483229b78f661478f2f2383595ae Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 14:16:23 +0300 Subject: [PATCH 046/123] Fix types --- .../server/src/api/routes/tests/viewV2.spec.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index fc97e657c5..e30bc2c0b1 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -62,7 +62,7 @@ describe("/v2/views", () => { name: generator.name(), tableId: config.table!._id!, primaryDisplay: generator.word(), - query: { allOr: false, equal: { field: "value" } }, + query: [{ operator: "equal", field: "field", value: "value" }], sort: { field: "fieldToSort", order: SortOrder.DESCENDING, @@ -190,7 +190,7 @@ describe("/v2/views", () => { const tableId = config.table!._id! await config.api.viewV2.update({ ...view, - query: { equal: { newField: "thatValue" } }, + query: [{ operator: "equal", field: "newField", value: "thatValue" }], }) expect(await config.api.table.get(tableId)).toEqual({ @@ -198,7 +198,9 @@ describe("/v2/views", () => { views: { [view.name]: { ...view, - query: { equal: { newField: "thatValue" } }, + query: [ + { operator: "equal", field: "newField", value: "thatValue" }, + ], schema: expect.anything(), }, }, @@ -216,7 +218,13 @@ describe("/v2/views", () => { tableId, name: view.name, primaryDisplay: generator.word(), - query: { equal: { [generator.word()]: generator.word() } }, + query: [ + { + operator: "equal", + field: generator.word(), + value: generator.word(), + }, + ], sort: { field: generator.word(), order: SortOrder.DESCENDING, @@ -285,7 +293,7 @@ describe("/v2/views", () => { { ...view, tableId: generator.guid(), - query: { equal: { newField: "thatValue" } }, + query: [{ operator: "equal", field: "newField", value: "thatValue" }], }, { expectStatus: 404 } ) From 4bcffd553b6c74ab187fd88fbbf5ceee8c5e1e46 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 11:26:25 +0000 Subject: [PATCH 047/123] Bump version to 2.8.32-alpha.2 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 238a2a2192..f72055b174 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.1", + "version": "2.8.32-alpha.2", "npmClient": "yarn", "packages": [ "packages/*" From d956738cd456d5da03c56f9a54cd22602d72cdc5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 7 Aug 2023 12:28:17 +0100 Subject: [PATCH 048/123] Reverting pro reference to develop. --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index 3495feff36..cf3bef2aad 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 3495feff36b73ab9abf2cc45df39900e79d38e27 +Subproject commit cf3bef2aad9c739111b306fd0712397adc363f81 From 0247a6c4cc54fcb59a08f3a877c5fbf68b69a4ac Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 11:29:58 +0000 Subject: [PATCH 049/123] Bump version to 2.8.32-alpha.3 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index f72055b174..4ad0562b73 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.2", + "version": "2.8.32-alpha.3", "npmClient": "yarn", "packages": [ "packages/*" From 768016ce2e234c3be3e5e83ab67458469d391a10 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 14:36:47 +0300 Subject: [PATCH 050/123] Update docs --- docs/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 2fb4c36fa8..70f198a84c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -90,7 +90,7 @@ Component libraries are collections of components as well as the definition of t #### 1. Prerequisites -- NodeJS version `14.x.x` +- NodeJS version `18.x.x` - Python version `3.x` ### Using asdf (recommended) From f6c042ae341e9f24849b8332d6d0c1d4aa082284 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 14:37:57 +0300 Subject: [PATCH 051/123] Remove hardcoded target in esbuild --- scripts/build.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build.js b/scripts/build.js index b93ae1bbe6..2ca41b5f7d 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -43,7 +43,6 @@ function runBuild(entry, outfile) { TsconfigPathsPlugin({ tsconfig: tsconfigPathPluginContent }), nodeExternalsPlugin(), ], - target: "node14", preserveSymlinks: true, loader: { ".svelte": "copy", From 12d6911ae390ce6a566862984a3d4c64876db484 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 14:38:16 +0300 Subject: [PATCH 052/123] Update docker images to 18.x --- hosting/single/Dockerfile | 2 +- packages/server/Dockerfile | 2 +- packages/worker/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hosting/single/Dockerfile b/hosting/single/Dockerfile index e43e5ad10c..6fc1f96d28 100644 --- a/hosting/single/Dockerfile +++ b/hosting/single/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-slim as build +FROM node:18-slim as build # install node-gyp dependencies RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends apt-utils cron g++ make python diff --git a/packages/server/Dockerfile b/packages/server/Dockerfile index a526538b71..61f064ecfb 100644 --- a/packages/server/Dockerfile +++ b/packages/server/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-slim +FROM node:18-slim LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh" LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh" diff --git a/packages/worker/Dockerfile b/packages/worker/Dockerfile index dd98f3b7f8..4230ee86f8 100644 --- a/packages/worker/Dockerfile +++ b/packages/worker/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine +FROM node:18-alpine LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh" LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh" From cb25a0d23a9180b37a8eec54abc905255c81febe Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 11:53:41 +0000 Subject: [PATCH 053/123] Bump version to 2.8.32-alpha.4 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 4ad0562b73..f687e46b24 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.3", + "version": "2.8.32-alpha.4", "npmClient": "yarn", "packages": [ "packages/*" From 3eb31c7a8140b3b63d4aa84214024d519feff25a Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 12:28:09 +0000 Subject: [PATCH 054/123] Bump version to 2.8.32-alpha.5 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index f687e46b24..a3162b37c3 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.4", + "version": "2.8.32-alpha.5", "npmClient": "yarn", "packages": [ "packages/*" From 4d2fef6b199aa0b4ecdb9cfc70d26deb1c6ebc6d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 15:33:50 +0300 Subject: [PATCH 055/123] Fix types after merge --- packages/server/src/api/routes/tests/row.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index b9f584706e..3284d25de8 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1072,7 +1072,7 @@ describe("/rows", () => { ) const createViewResponse = await config.api.viewV2.create({ - query: { equal: { age: 40 } }, + query: [{ operator: "equal", field: "age", value: 40 }], }) const response = await config.api.viewV2.search(createViewResponse.id) From 206be7e8a1daf7f3174ce9711e3427c6e1d29f18 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 7 Aug 2023 15:36:56 +0300 Subject: [PATCH 056/123] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index cf3bef2aad..ecee8071eb 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit cf3bef2aad9c739111b306fd0712397adc363f81 +Subproject commit ecee8071ebe0f98a5bb19646954e373264be210d From 1f49db1347b60154af604ad6803fe43846242ebb Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 13:41:18 +0000 Subject: [PATCH 057/123] Bump version to 2.8.32-alpha.6 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index a3162b37c3..8be4ff3061 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.5", + "version": "2.8.32-alpha.6", "npmClient": "yarn", "packages": [ "packages/*" From 0049cc74bbc7a10f0b6dc5627530b28cd159419f Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 13:56:12 +0000 Subject: [PATCH 058/123] Bump version to 2.8.32-alpha.7 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 8be4ff3061..dc7cabb9fa 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.32-alpha.6", + "version": "2.8.32-alpha.7", "npmClient": "yarn", "packages": [ "packages/*" From 41a904126817d1f72014dc44c88e8c093ab927af Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 7 Aug 2023 16:36:28 +0100 Subject: [PATCH 059/123] PR fixes. --- packages/backend-core/src/security/permissions.ts | 4 ---- packages/server/src/api/routes/row.ts | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/backend-core/src/security/permissions.ts b/packages/backend-core/src/security/permissions.ts index 70dae57ae6..aa0b20a30c 100644 --- a/packages/backend-core/src/security/permissions.ts +++ b/packages/backend-core/src/security/permissions.ts @@ -78,7 +78,6 @@ export const BUILTIN_PERMISSIONS = { permissions: [ new Permission(PermissionType.QUERY, PermissionLevel.READ), new Permission(PermissionType.TABLE, PermissionLevel.READ), - new Permission(PermissionType.VIEW, PermissionLevel.READ), ], }, WRITE: { @@ -87,7 +86,6 @@ export const BUILTIN_PERMISSIONS = { permissions: [ new Permission(PermissionType.QUERY, PermissionLevel.WRITE), new Permission(PermissionType.TABLE, PermissionLevel.WRITE), - new Permission(PermissionType.VIEW, PermissionLevel.READ), new Permission(PermissionType.AUTOMATION, PermissionLevel.EXECUTE), ], }, @@ -98,7 +96,6 @@ export const BUILTIN_PERMISSIONS = { new Permission(PermissionType.TABLE, PermissionLevel.WRITE), new Permission(PermissionType.USER, PermissionLevel.READ), new Permission(PermissionType.AUTOMATION, PermissionLevel.EXECUTE), - new Permission(PermissionType.VIEW, PermissionLevel.READ), new Permission(PermissionType.WEBHOOK, PermissionLevel.READ), ], }, @@ -109,7 +106,6 @@ export const BUILTIN_PERMISSIONS = { new Permission(PermissionType.TABLE, PermissionLevel.ADMIN), new Permission(PermissionType.USER, PermissionLevel.ADMIN), new Permission(PermissionType.AUTOMATION, PermissionLevel.ADMIN), - new Permission(PermissionType.VIEW, PermissionLevel.ADMIN), new Permission(PermissionType.WEBHOOK, PermissionLevel.READ), new Permission(PermissionType.QUERY, PermissionLevel.ADMIN), ], diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index 55906c2ffe..1fd45e0e92 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -267,11 +267,10 @@ router rowController.exportRows ) -router - .post( - "/api/v2/views/:viewId/search", - authorized(PermissionType.TABLE, PermissionLevel.READ), - rowController.views.searchView - ) +router.post( + "/api/v2/views/:viewId/search", + authorized(PermissionType.TABLE, PermissionLevel.READ), + rowController.views.searchView +) export default router From 4c2e3a54893db23f7c8f0524e079004e7cbf4415 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 7 Aug 2023 16:49:13 +0100 Subject: [PATCH 060/123] Updating last remaining view perms to table perms. --- packages/server/src/api/routes/view.ts | 2 +- packages/server/src/utilities/security.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/routes/view.ts b/packages/server/src/api/routes/view.ts index 18c58134b4..07e31fc701 100644 --- a/packages/server/src/api/routes/view.ts +++ b/packages/server/src/api/routes/view.ts @@ -34,7 +34,7 @@ router "/api/views/:viewName", paramResource("viewName"), authorized( - permissions.PermissionType.VIEW, + permissions.PermissionType.TABLE, permissions.PermissionLevel.READ ), rowController.fetchView diff --git a/packages/server/src/utilities/security.ts b/packages/server/src/utilities/security.ts index 694dff4360..54e19007f1 100644 --- a/packages/server/src/utilities/security.ts +++ b/packages/server/src/utilities/security.ts @@ -14,6 +14,7 @@ export function getPermissionType(resourceId: string) { switch (docType) { case DocumentType.TABLE: case DocumentType.ROW: + case DocumentType.VIEW: return permissions.PermissionType.TABLE case DocumentType.AUTOMATION: return permissions.PermissionType.AUTOMATION @@ -22,9 +23,6 @@ export function getPermissionType(resourceId: string) { case DocumentType.QUERY: case DocumentType.DATASOURCE: return permissions.PermissionType.QUERY - default: - // views don't have an ID, will end up here - return permissions.PermissionType.VIEW } } From 07a28fc284c4f1b26730d4bcf74d0a96faa84e99 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 7 Aug 2023 20:33:14 +0000 Subject: [PATCH 061/123] Bump version to 2.9.8-alpha.0 --- lerna.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index 0d412b0cbc..9640694d79 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.9.7", + "version": "2.9.8-alpha.0", "npmClient": "yarn", "packages": [ "packages/*" @@ -19,4 +19,4 @@ "loadEnvFiles": false } } -} +} \ No newline at end of file From 51f086030012f74d08f73879ccde797db097d531 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 8 Aug 2023 08:12:18 +0000 Subject: [PATCH 062/123] Bump version to 2.9.8-alpha.1 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 9640694d79..0d8ae345e8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.9.8-alpha.0", + "version": "2.9.8-alpha.1", "npmClient": "yarn", "packages": [ "packages/*" From b925a347d2ffdcd7144c7dfcad62fcd9f3deeb1a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:35:04 +0300 Subject: [PATCH 063/123] Remove fetch-depth --- .github/workflows/budibase_ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 08fc2fe0b8..683f8cbfe8 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -173,7 +173,6 @@ jobs: uses: actions/checkout@v3 with: submodules: true - fetch-depth: 0 token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - name: Check pro commit From a882e3341f4927f467b36e436fb017261cf11147 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:43:31 +0300 Subject: [PATCH 064/123] Add since flag --- .github/workflows/budibase_ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 683f8cbfe8..135fa035f5 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,6 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + NX_BASE_BRANCH: ${{ github.base_ref || "origin/master"}} jobs: lint: @@ -61,9 +62,9 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile # Run build all the projects - - run: yarn build + - run: yarn build --since=${{ NX_BASE_BRANCH }} # Check the types of the projects built via esbuild - - run: yarn check:types + - run: yarn check:types --since=${{ NX_BASE_BRANCH }} test-libraries: runs-on: ubuntu-latest @@ -84,7 +85,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro + - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos @@ -111,7 +112,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Test worker and server - run: yarn test --scope=@budibase/worker --scope=@budibase/server + run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos @@ -134,7 +135,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --scope=@budibase/pro + - run: yarn test --scope=@budibase/pro --since=${{ NX_BASE_BRANCH }} integration-test: runs-on: ubuntu-latest From 19b3def9b855355b7c31df1a8808eabf19b49d05 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:45:59 +0300 Subject: [PATCH 065/123] Fix env --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 135fa035f5..b12b371f24 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: ${{ github.base_ref || "origin/master"}} + NX_BASE_BRANCH: ${{ github.base_ref || origin/master}} jobs: lint: From 3e7da2bfd10b9cdb495a1d632196f756209d7d44 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:47:10 +0300 Subject: [PATCH 066/123] Fix --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index b12b371f24..3218f69ff6 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: ${{ github.base_ref || origin/master}} + NX_BASE_BRANCH: ${{ github.base_ref || 'origin/master'}} jobs: lint: From 49bc467eb982686af6cd014e8d31dd9908148da6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:48:16 +0300 Subject: [PATCH 067/123] Prefix env --- .github/workflows/budibase_ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 3218f69ff6..ea00c9438a 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -62,9 +62,9 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile # Run build all the projects - - run: yarn build --since=${{ NX_BASE_BRANCH }} + - run: yarn build --since=${{ env.NX_BASE_BRANCH }} # Check the types of the projects built via esbuild - - run: yarn check:types --since=${{ NX_BASE_BRANCH }} + - run: yarn check:types --since=${{ env.NX_BASE_BRANCH }} test-libraries: runs-on: ubuntu-latest @@ -85,7 +85,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ NX_BASE_BRANCH }} + - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos @@ -112,7 +112,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Test worker and server - run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ NX_BASE_BRANCH }} + run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos @@ -135,7 +135,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --scope=@budibase/pro --since=${{ NX_BASE_BRANCH }} + - run: yarn test --scope=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} integration-test: runs-on: ubuntu-latest From d5d5c21ef80afcb09fd9eee992d1adf5bb1cef88 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:56:44 +0300 Subject: [PATCH 068/123] Change build to run in lerna --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4294e83883..4e4befb5f2 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "preinstall": "node scripts/syncProPackage.js", "setup": "git config submodule.recurse true && git submodule update && node ./hosting/scripts/setup.js && yarn && yarn build && yarn dev", "bootstrap": "./scripts/link-dependencies.sh && echo '***BOOTSTRAP ONLY REQUIRED FOR USE WITH ACCOUNT PORTAL***'", - "build": "yarn nx run-many -t=build", + "build": "lerna run build --stream", "build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput", "check:types": "lerna run check:types", "backend:bootstrap": "./scripts/scopeBackend.sh && yarn run bootstrap", From 987ee1b8b27b612f66ba165291311e002df503b9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 11:58:29 +0300 Subject: [PATCH 069/123] Prefix NX_BASE_BRANCH --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index ea00c9438a..693d81372d 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: ${{ github.base_ref || 'origin/master'}} + NX_BASE_BRANCH: origin/${{ github.base_ref || 'master'}} jobs: lint: From 5eb49fbb293a737afd528e640701b425fd80ff2a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 12:08:39 +0300 Subject: [PATCH 070/123] Fetch remote refs --- .github/workflows/budibase_ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 693d81372d..52bff87e0c 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -61,6 +61,8 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile + - name: Fetch remote references + run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" # Run build all the projects - run: yarn build --since=${{ env.NX_BASE_BRANCH }} # Check the types of the projects built via esbuild @@ -85,6 +87,8 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile + - name: Fetch remote references + run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: @@ -111,6 +115,8 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile + - name: Fetch remote references + run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" - name: Test worker and server run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 From 62bb5bb4ff85ee59296b3e88492920d3e42346e1 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 12:14:22 +0300 Subject: [PATCH 071/123] Fetch only required branch --- .github/workflows/budibase_ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 52bff87e0c..49d06fc430 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: origin/${{ github.base_ref || 'master'}} + NX_BASE_BRANCH: ${{ github.base_ref || 'master'}} jobs: lint: @@ -62,7 +62,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Fetch remote references - run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" + run: git fetch origin ${{ env.NX_BASE_BRANCH }} # Run build all the projects - run: yarn build --since=${{ env.NX_BASE_BRANCH }} # Check the types of the projects built via esbuild @@ -88,7 +88,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Fetch remote references - run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" + run: git fetch origin ${{ env.NX_BASE_BRANCH }} - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: @@ -116,7 +116,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Fetch remote references - run: git fetch origin "+refs/heads/*:refs/remotes/origin/*" + run: git fetch origin ${{ env.NX_BASE_BRANCH }} - name: Test worker and server run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 From 903b1eac09f7bdbdcaa788dcf767933469094306 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 12:27:14 +0300 Subject: [PATCH 072/123] Fetch-depth --- .github/workflows/budibase_ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 49d06fc430..b2e256b044 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -51,9 +51,12 @@ jobs: with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + fetch-depth: 0 - name: Checkout repo only uses: actions/checkout@v3 if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + with: + fetch-depth: 0 - name: Use Node.js 18.x uses: actions/setup-node@v3 @@ -61,8 +64,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - name: Fetch remote references - run: git fetch origin ${{ env.NX_BASE_BRANCH }} + # Run build all the projects - run: yarn build --since=${{ env.NX_BASE_BRANCH }} # Check the types of the projects built via esbuild @@ -77,9 +79,12 @@ jobs: with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + fetch-depth: 0 - name: Checkout repo only uses: actions/checkout@v3 if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + with: + fetch-depth: 0 - name: Use Node.js 18.x uses: actions/setup-node@v3 @@ -87,8 +92,6 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - name: Fetch remote references - run: git fetch origin ${{ env.NX_BASE_BRANCH }} - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 with: @@ -105,9 +108,12 @@ jobs: with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + fetch-depth: 0 - name: Checkout repo only uses: actions/checkout@v3 if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase' + with: + fetch-depth: 0 - name: Use Node.js 18.x uses: actions/setup-node@v3 @@ -115,8 +121,6 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - name: Fetch remote references - run: git fetch origin ${{ env.NX_BASE_BRANCH }} - name: Test worker and server run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} - uses: codecov/codecov-action@v3 From fc6472c0cccd6ad783232d32ed196ab289bee12a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 12:31:46 +0300 Subject: [PATCH 073/123] Prefix --- .github/workflows/budibase_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index b2e256b044..2953aa0575 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,7 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: ${{ github.base_ref || 'master'}} + NX_BASE_BRANCH: origin/${{ github.base_ref || 'master'}} jobs: lint: From ee2f3e3157e81b9906225601d1fb48ca45d04be5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 12:39:40 +0300 Subject: [PATCH 074/123] Fix build --- .github/workflows/budibase_ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 2953aa0575..cc1244e01a 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -138,6 +138,7 @@ jobs: with: submodules: true token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + fetch-depth: 0 - name: Use Node.js 18.x uses: actions/setup-node@v3 @@ -166,7 +167,7 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn build --projects=@budibase/server,@budibase/worker,@budibase/client + - run: yarn build --scope @budibase/server --scope @budibase/worker --scope @budibase/client - name: Run tests run: | cd qa-core From 2011e1693e35b4102bdbb131dfd23d2f9abd3632 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 8 Aug 2023 12:06:25 +0100 Subject: [PATCH 075/123] PR comments. --- .../server/src/api/controllers/row/utils.ts | 9 ++- packages/server/src/api/routes/row.ts | 72 +++++++++---------- packages/server/src/db/utils.ts | 9 ++- packages/server/src/utilities/security.ts | 6 +- packages/types/src/documents/document.ts | 6 ++ 5 files changed, 57 insertions(+), 45 deletions(-) diff --git a/packages/server/src/api/controllers/row/utils.ts b/packages/server/src/api/controllers/row/utils.ts index 6ff90f2b25..6cc342b8a0 100644 --- a/packages/server/src/api/controllers/row/utils.ts +++ b/packages/server/src/api/controllers/row/utils.ts @@ -45,13 +45,16 @@ export async function findRow(ctx: UserCtx, tableId: string, rowId: string) { } export function getTableId(ctx: Ctx) { - if (ctx.request.body && ctx.request.body.tableId) { + if (ctx.request.body?.tableId) { return ctx.request.body.tableId } - if (ctx.params && ctx.params.tableId) { + if (ctx.params?.sourceId) { + return ctx.params.sourceId + } + if (ctx.params?.tableId) { return ctx.params.tableId } - if (ctx.params && ctx.params.viewName) { + if (ctx.params?.viewName) { return ctx.params.viewName } } diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index 1fd45e0e92..a4ac8aa3ee 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -11,7 +11,7 @@ const router: Router = new Router() router /** - * @api {get} /api/:tableId/:rowId/enrich Get an enriched row + * @api {get} /api/:sourceId/:rowId/enrich Get an enriched row * @apiName Get an enriched row * @apiGroup rows * @apiPermission table read access @@ -25,13 +25,13 @@ router * @apiSuccess {object} row The response body will be the enriched row. */ .get( - "/api/:tableId/:rowId/enrich", - paramSubResource("tableId", "rowId"), + "/api/:sourceId/:rowId/enrich", + paramSubResource("sourceId", "rowId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.fetchEnrichedRow ) /** - * @api {get} /api/:tableId/rows Get all rows in a table + * @api {get} /api/:sourceId/rows Get all rows in a table * @apiName Get all rows in a table * @apiGroup rows * @apiPermission table read access @@ -40,37 +40,37 @@ router * due to its lack of support for pagination. With SQL tables this will retrieve up to a limit and then * will simply stop. * - * @apiParam {string} tableId The ID of the table to retrieve all rows within. + * @apiParam {string} sourceId The ID of the table to retrieve all rows within. * * @apiSuccess {object[]} rows The response body will be an array of all rows found. */ .get( - "/api/:tableId/rows", - paramResource("tableId"), + "/api/:sourceId/rows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.fetch ) /** - * @api {get} /api/:tableId/rows/:rowId Retrieve a single row + * @api {get} /api/:sourceId/rows/:rowId Retrieve a single row * @apiName Retrieve a single row * @apiGroup rows * @apiPermission table read access * @apiDescription This endpoint retrieves only the specified row. If you wish to retrieve * a row by anything other than its _id field, use the search endpoint. * - * @apiParam {string} tableId The ID of the table to retrieve a row from. + * @apiParam {string} sourceId The ID of the table to retrieve a row from. * @apiParam {string} rowId The ID of the row to retrieve. * * @apiSuccess {object} body The response body will be the row that was found. */ .get( - "/api/:tableId/rows/:rowId", - paramSubResource("tableId", "rowId"), + "/api/:sourceId/rows/:rowId", + paramSubResource("sourceId", "rowId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.find ) /** - * @api {post} /api/:tableId/search Search for rows in a table + * @api {post} /api/:sourceId/search Search for rows in a table * @apiName Search for rows in a table * @apiGroup rows * @apiPermission table read access @@ -78,7 +78,7 @@ router * and data UI in the builder are built atop this. All filtering, sorting and pagination is * handled through this, for internal and external (datasource plus, e.g. SQL) tables. * - * @apiParam {string} tableId The ID of the table to retrieve rows from. + * @apiParam {string} sourceId The ID of the table to retrieve rows from. * * @apiParam (Body) {boolean} [paginate] If pagination is required then this should be set to true, * defaults to false. @@ -133,22 +133,22 @@ router * page. */ .post( - "/api/:tableId/search", + "/api/:sourceId/search", internalSearchValidator(), - paramResource("tableId"), + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.search ) // DEPRECATED - this is an old API, but for backwards compat it needs to be // supported still .post( - "/api/search/:tableId/rows", - paramResource("tableId"), + "/api/search/:sourceId/rows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.search ) /** - * @api {post} /api/:tableId/rows Creates a new row + * @api {post} /api/:sourceId/rows Creates a new row * @apiName Creates a new row * @apiGroup rows * @apiPermission table write access @@ -157,7 +157,7 @@ router * links to one. Please note that "_id", "_rev" and "tableId" are fields that are * already used by Budibase tables and cannot be used for columns. * - * @apiParam {string} tableId The ID of the table to save a row to. + * @apiParam {string} sourceId The ID of the table to save a row to. * * @apiParam (Body) {string} [_id] If the row exists already then an ID for the row must be provided. * @apiParam (Body) {string} [_rev] If working with an existing row for an internal table its revision @@ -172,14 +172,14 @@ router * @apiSuccess {object} body The contents of the row that was saved will be returned as well. */ .post( - "/api/:tableId/rows", - paramResource("tableId"), + "/api/:sourceId/rows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), trimViewRowInfo, rowController.save ) /** - * @api {patch} /api/:tableId/rows Updates a row + * @api {patch} /api/:sourceId/rows Updates a row * @apiName Update a row * @apiGroup rows * @apiPermission table write access @@ -187,14 +187,14 @@ router * error if an _id isn't provided, it will only function for existing rows. */ .patch( - "/api/:tableId/rows", - paramResource("tableId"), + "/api/:sourceId/rows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), trimViewRowInfo, rowController.patch ) /** - * @api {post} /api/:tableId/rows/validate Validate inputs for a row + * @api {post} /api/:sourceId/rows/validate Validate inputs for a row * @apiName Validate inputs for a row * @apiGroup rows * @apiPermission table write access @@ -202,7 +202,7 @@ router * given the table schema, this will iterate through all the constraints on the table and * check if the request body is valid. * - * @apiParam {string} tableId The ID of the table the row is to be validated for. + * @apiParam {string} sourceId The ID of the table the row is to be validated for. * * @apiParam (Body) {any} [any] Any fields provided in the request body will be tested * against the table schema and constraints. @@ -214,20 +214,20 @@ router * the schema. */ .post( - "/api/:tableId/rows/validate", - paramResource("tableId"), + "/api/:sourceId/rows/validate", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), rowController.validate ) /** - * @api {delete} /api/:tableId/rows Delete rows + * @api {delete} /api/:sourceId/rows Delete rows * @apiName Delete rows * @apiGroup rows * @apiPermission table write access * @apiDescription This endpoint can delete a single row, or delete them in a bulk * fashion. * - * @apiParam {string} tableId The ID of the table the row is to be deleted from. + * @apiParam {string} sourceId The ID of the table the row is to be deleted from. * * @apiParam (Body) {object[]} [rows] If bulk deletion is desired then provide the rows in this * key of the request body that are to be deleted. @@ -240,29 +240,29 @@ router * is the deleted row. */ .delete( - "/api/:tableId/rows", - paramResource("tableId"), + "/api/:sourceId/rows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), trimViewRowInfo, rowController.destroy ) /** - * @api {post} /api/:tableId/rows/exportRows Export Rows + * @api {post} /api/:sourceId/rows/exportRows Export Rows * @apiName Export rows * @apiGroup rows * @apiPermission table write access * @apiDescription This API can export a number of provided rows * - * @apiParam {string} tableId The ID of the table the row is to be deleted from. + * @apiParam {string} sourceId The ID of the table the row is to be deleted from. * * @apiParam (Body) {object[]} [rows] The row IDs which are to be exported * * @apiSuccess {object[]|object} */ .post( - "/api/:tableId/rows/exportRows", - paramResource("tableId"), + "/api/:sourceId/rows/exportRows", + paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.WRITE), rowController.exportRows ) diff --git a/packages/server/src/db/utils.ts b/packages/server/src/db/utils.ts index e8dc3b3f6c..abea725707 100644 --- a/packages/server/src/db/utils.ts +++ b/packages/server/src/db/utils.ts @@ -1,5 +1,7 @@ import newid from "./newid" import { db as dbCore } from "@budibase/backend-core" +import { DocumentType, VirtualDocumentType } from "@budibase/types" +export { DocumentType, VirtualDocumentType } from "@budibase/types" type Optional = string | null @@ -19,7 +21,6 @@ export const BudibaseInternalDB = { export const SEPARATOR = dbCore.SEPARATOR export const StaticDatabases = dbCore.StaticDatabases -export const DocumentType = dbCore.DocumentType export const APP_PREFIX = dbCore.APP_PREFIX export const APP_DEV_PREFIX = dbCore.APP_DEV_PREFIX export const isDevAppID = dbCore.isDevAppID @@ -284,11 +285,13 @@ export function getMultiIDParams(ids: string[]) { * @returns {string} The new view ID which the view doc can be stored under. */ export function generateViewID(tableId: string) { - return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}${newid()}` + return `${ + VirtualDocumentType.VIEW + }${SEPARATOR}${tableId}${SEPARATOR}${newid()}` } export function isViewID(viewId: string) { - return viewId?.split(SEPARATOR)[0] === DocumentType.VIEW + return viewId?.split(SEPARATOR)[0] === VirtualDocumentType.VIEW } export function extractViewInfoFromID(viewId: string) { diff --git a/packages/server/src/utilities/security.ts b/packages/server/src/utilities/security.ts index 54e19007f1..0da7621773 100644 --- a/packages/server/src/utilities/security.ts +++ b/packages/server/src/utilities/security.ts @@ -1,5 +1,5 @@ import { permissions, roles } from "@budibase/backend-core" -import { DocumentType } from "../db/utils" +import { DocumentType, VirtualDocumentType } from "../db/utils" export const CURRENTLY_SUPPORTED_LEVELS: string[] = [ permissions.PermissionLevel.WRITE, @@ -11,10 +11,10 @@ export function getPermissionType(resourceId: string) { const docType = Object.values(DocumentType).filter(docType => resourceId.startsWith(docType) )[0] - switch (docType) { + switch (docType as DocumentType | VirtualDocumentType) { case DocumentType.TABLE: case DocumentType.ROW: - case DocumentType.VIEW: + case VirtualDocumentType.VIEW: return permissions.PermissionType.TABLE case DocumentType.AUTOMATION: return permissions.PermissionType.AUTOMATION diff --git a/packages/types/src/documents/document.ts b/packages/types/src/documents/document.ts index 164aa79ac9..75f55e1367 100644 --- a/packages/types/src/documents/document.ts +++ b/packages/types/src/documents/document.ts @@ -37,6 +37,12 @@ export enum DocumentType { USER_FLAG = "flag", AUTOMATION_METADATA = "meta_au", AUDIT_LOG = "al", + VIEW = "awd", +} + +// these documents don't really exist, they are part of other +// documents or enriched into existence as part of get requests +export enum VirtualDocumentType { VIEW = "view", } From 0abd1deb3492f80b98b0d34a6709254f393020a6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 8 Aug 2023 13:19:22 +0100 Subject: [PATCH 076/123] Updating test cases, fixes based on running through view/row API. --- .../src/api/controllers/row/external.ts | 13 ++-- .../src/api/controllers/row/internal.ts | 23 +++--- .../server/src/api/controllers/row/utils.ts | 10 ++- .../server/src/api/routes/tests/row.spec.ts | 71 ++----------------- .../server/src/middleware/trimViewRowInfo.ts | 31 +++++--- .../server/src/tests/utilities/api/row.ts | 37 ++++++++-- .../server/src/tests/utilities/api/viewV2.ts | 46 ------------ packages/types/src/api/web/app/rows.ts | 2 + 8 files changed, 87 insertions(+), 146 deletions(-) diff --git a/packages/server/src/api/controllers/row/external.ts b/packages/server/src/api/controllers/row/external.ts index 3ee4ca6edd..bc4edbd661 100644 --- a/packages/server/src/api/controllers/row/external.ts +++ b/packages/server/src/api/controllers/row/external.ts @@ -15,6 +15,7 @@ import { UserCtx, } from "@budibase/types" import sdk from "../../../sdk" +import * as utils from "./utils" export async function handleRequest( operation: Operation, @@ -43,7 +44,7 @@ export async function handleRequest( } export async function patch(ctx: UserCtx) { - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const { _id, ...rowData } = ctx.request.body const validateResult = await sdk.rows.utils.validate({ @@ -70,7 +71,7 @@ export async function patch(ctx: UserCtx) { export async function save(ctx: UserCtx) { const inputs = ctx.request.body - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const validateResult = await sdk.rows.utils.validate({ row: inputs, tableId, @@ -98,12 +99,12 @@ export async function save(ctx: UserCtx) { export async function find(ctx: UserCtx) { const id = ctx.params.rowId - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) return sdk.rows.external.getRow(tableId, id) } export async function destroy(ctx: UserCtx) { - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const _id = ctx.request.body._id const { row } = (await handleRequest(Operation.DELETE, tableId, { id: breakRowIdField(_id), @@ -114,7 +115,7 @@ export async function destroy(ctx: UserCtx) { export async function bulkDestroy(ctx: UserCtx) { const { rows } = ctx.request.body - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) let promises: Promise[] = [] for (let row of rows) { promises.push( @@ -130,7 +131,7 @@ export async function bulkDestroy(ctx: UserCtx) { export async function fetchEnrichedRow(ctx: UserCtx) { const id = ctx.params.rowId - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const { datasourceId, tableName } = breakExternalTableId(tableId) const datasource: Datasource = await sdk.datasources.get(datasourceId!) if (!tableName) { diff --git a/packages/server/src/api/controllers/row/internal.ts b/packages/server/src/api/controllers/row/internal.ts index 2ff1df0933..3432ec80f3 100644 --- a/packages/server/src/api/controllers/row/internal.ts +++ b/packages/server/src/api/controllers/row/internal.ts @@ -13,7 +13,7 @@ import { import { FieldTypes } from "../../../constants" import * as utils from "./utils" import { cloneDeep } from "lodash/fp" -import { context, db as dbCore } from "@budibase/backend-core" +import { context } from "@budibase/backend-core" import { finaliseRow, updateRelatedFormula } from "./staticFormula" import { UserCtx, @@ -26,8 +26,8 @@ import { import sdk from "../../../sdk" export async function patch(ctx: UserCtx) { + const tableId = utils.getTableId(ctx) const inputs = ctx.request.body - const tableId = inputs.tableId const isUserTable = tableId === InternalTables.USER_METADATA let oldRow const dbTable = await sdk.tables.getTable(tableId) @@ -94,7 +94,8 @@ export async function patch(ctx: UserCtx) { export async function save(ctx: UserCtx) { let inputs = ctx.request.body - inputs.tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) + inputs.tableId = tableId if (!inputs._rev && !inputs._id) { inputs._id = generateRowID(inputs.tableId) @@ -132,20 +133,22 @@ export async function save(ctx: UserCtx) { } export async function find(ctx: UserCtx) { - const db = dbCore.getDB(ctx.appId) - const table = await sdk.tables.getTable(ctx.params.tableId) - let row = await utils.findRow(ctx, ctx.params.tableId, ctx.params.rowId) + const tableId = utils.getTableId(ctx), + rowId = ctx.params.rowId + const table = await sdk.tables.getTable(tableId) + let row = await utils.findRow(ctx, tableId, rowId) row = await outputProcessing(table, row) return row } export async function destroy(ctx: UserCtx) { const db = context.getAppDB() + const tableId = utils.getTableId(ctx) const { _id } = ctx.request.body let row = await db.get(_id) let _rev = ctx.request.body._rev || row._rev - if (row.tableId !== ctx.params.tableId) { + if (row.tableId !== tableId) { throw "Supplied tableId doesn't match the row's tableId" } const table = await sdk.tables.getTable(row.tableId) @@ -163,7 +166,7 @@ export async function destroy(ctx: UserCtx) { await updateRelatedFormula(table, row) let response - if (ctx.params.tableId === InternalTables.USER_METADATA) { + if (tableId === InternalTables.USER_METADATA) { ctx.params = { id: _id, } @@ -176,7 +179,7 @@ export async function destroy(ctx: UserCtx) { } export async function bulkDestroy(ctx: UserCtx) { - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const table = await sdk.tables.getTable(tableId) let { rows } = ctx.request.body @@ -216,7 +219,7 @@ export async function bulkDestroy(ctx: UserCtx) { export async function fetchEnrichedRow(ctx: UserCtx) { const db = context.getAppDB() - const tableId = ctx.params.tableId + const tableId = utils.getTableId(ctx) const rowId = ctx.params.rowId // need table to work out where links go in row let [table, row] = await Promise.all([ diff --git a/packages/server/src/api/controllers/row/utils.ts b/packages/server/src/api/controllers/row/utils.ts index 6cc342b8a0..157f18e231 100644 --- a/packages/server/src/api/controllers/row/utils.ts +++ b/packages/server/src/api/controllers/row/utils.ts @@ -45,15 +45,19 @@ export async function findRow(ctx: UserCtx, tableId: string, rowId: string) { } export function getTableId(ctx: Ctx) { - if (ctx.request.body?.tableId) { - return ctx.request.body.tableId - } + // top priority, use the URL first if (ctx.params?.sourceId) { return ctx.params.sourceId } + // check body for a table ID + if (ctx.request.body?.tableId) { + return ctx.request.body.tableId + } + // now check for old way of specifying table ID if (ctx.params?.tableId) { return ctx.params.tableId } + // now check if a specific view name if (ctx.params?.viewName) { return ctx.params.viewName } diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 5e1616340f..8d4c9a91fd 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -16,15 +16,12 @@ import { FieldType, SortType, SortOrder, - DeleteRow, } from "@budibase/types" import { expectAnyInternalColsAttributes, generator, structures, } from "@budibase/backend-core/tests" -import trimViewRowInfoMiddleware from "../../../middleware/trimViewRowInfo" -import router from "../row" describe("/rows", () => { let request = setup.getRequest() @@ -393,18 +390,6 @@ describe("/rows", () => { expect(saved.arrayFieldArrayStrKnown).toEqual(["One"]) expect(saved.optsFieldStrKnown).toEqual("Alpha") }) - - it("should throw an error when creating a table row with view id data", async () => { - const res = await request - .post(`/api/${row.tableId}/rows`) - .send({ ...row, _viewId: generator.guid() }) - .set(config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(400) - expect(res.body.message).toEqual( - "Table row endpoints cannot contain view info" - ) - }) }) describe("patch", () => { @@ -454,25 +439,6 @@ describe("/rows", () => { await assertRowUsage(rowUsage) await assertQueryUsage(queryUsage) }) - - it("should throw an error when creating a table row with view id data", async () => { - const existing = await config.createRow() - - const res = await config.api.row.patch( - table._id!, - { - ...existing, - _id: existing._id!, - _rev: existing._rev!, - tableId: table._id!, - _viewId: generator.guid(), - }, - { expectStatus: 400 } - ) - expect(res.body.message).toEqual( - "Table row endpoints cannot contain view info" - ) - }) }) describe("destroy", () => { @@ -741,7 +707,7 @@ describe("/rows", () => { }) // the environment needs configured for this await setup.switchToSelfHosted(async () => { - context.doInAppContext(config.getAppId(), async () => { + return context.doInAppContext(config.getAppId(), async () => { const enriched = await outputProcessing(table, [row]) expect((enriched as Row[])[0].attachment[0].url).toBe( `/files/signed/prod-budi-app-assets/${config.getProdAppId()}/attachments/${attachmentId}` @@ -847,7 +813,7 @@ describe("/rows", () => { }) const data = randomRowData() - const newRow = await config.api.viewV2.row.create(view.id, { + const newRow = await config.api.row.save(view.id, { tableId: config.table!._id, _viewId: view.id, ...data, @@ -869,16 +835,6 @@ describe("/rows", () => { expect(row.body.age).toBeUndefined() expect(row.body.jobTitle).toBeUndefined() }) - - it("should setup the trimViewRowInfo middleware", async () => { - const route = router.stack.find( - r => - r.methods.includes("POST") && - r.path === "/api/v2/views/:viewId/rows" - ) - expect(route).toBeDefined() - expect(route?.stack).toContainEqual(trimViewRowInfoMiddleware) - }) }) describe("patch", () => { @@ -893,13 +849,13 @@ describe("/rows", () => { }, }) - const newRow = await config.api.viewV2.row.create(view.id, { + const newRow = await config.api.row.save(view.id, { tableId, _viewId: view.id, ...randomRowData(), }) const newData = randomRowData() - await config.api.viewV2.row.update(view.id, newRow._id!, { + await config.api.row.patch(view.id, { tableId, _viewId: view.id, _id: newRow._id!, @@ -922,16 +878,6 @@ describe("/rows", () => { expect(row.body.age).toBeUndefined() expect(row.body.jobTitle).toBeUndefined() }) - - it("should setup the trimViewRowInfo middleware", async () => { - const route = router.stack.find( - r => - r.methods.includes("PATCH") && - r.path === "/api/v2/views/:viewId/rows/:rowId" - ) - expect(route).toBeDefined() - expect(route?.stack).toContainEqual(trimViewRowInfoMiddleware) - }) }) describe("destroy", () => { @@ -950,10 +896,7 @@ describe("/rows", () => { const rowUsage = await getRowUsage() const queryUsage = await getQueryUsage() - const body: DeleteRow = { - _id: createdRow._id!, - } - await config.api.viewV2.row.delete(view.id, body) + await config.api.row.delete(view.id, [createdRow]) await assertRowUsage(rowUsage - 1) await assertQueryUsage(queryUsage + 1) @@ -982,9 +925,7 @@ describe("/rows", () => { const rowUsage = await getRowUsage() const queryUsage = await getQueryUsage() - await config.api.viewV2.row.delete(view.id, { - rows: [rows[0], rows[2]], - }) + await config.api.row.delete(view.id, [rows[0], rows[2]]) await assertRowUsage(rowUsage - 2) await assertQueryUsage(queryUsage + 1) diff --git a/packages/server/src/middleware/trimViewRowInfo.ts b/packages/server/src/middleware/trimViewRowInfo.ts index 763552c3d7..5a207936b2 100644 --- a/packages/server/src/middleware/trimViewRowInfo.ts +++ b/packages/server/src/middleware/trimViewRowInfo.ts @@ -3,26 +3,35 @@ import * as utils from "../db/utils" import sdk from "../sdk" import { db } from "@budibase/backend-core" import { Next } from "koa" +import { getTableId } from "../api/controllers/row/utils" export default async (ctx: Ctx, next: Next) => { const { body } = ctx.request - const { _viewId: viewId } = body + let { _viewId: viewId } = body - const possibleViewId = ctx.params.tableId + const possibleViewId = getTableId(ctx) + if (utils.isViewID(possibleViewId)) { + viewId = possibleViewId + } // nothing to do, it is not a view (just a table ID) - if (!viewId || !utils.isViewID(possibleViewId)) { + if (!viewId) { return next() } - const { tableId } = utils.extractViewInfoFromID(possibleViewId) - const { _viewId, ...trimmedView } = await trimViewFields( - viewId, - tableId, - body - ) - ctx.request.body = trimmedView - ctx.params.tableId = tableId + const { tableId } = utils.extractViewInfoFromID(viewId) + + // don't need to trim delete requests + if (ctx.method.toLowerCase() !== "delete") { + const { _viewId, ...trimmedView } = await trimViewFields( + viewId, + tableId, + body + ) + ctx.request.body = trimmedView + } + + ctx.params.sourceId = tableId return next() } diff --git a/packages/server/src/tests/utilities/api/row.ts b/packages/server/src/tests/utilities/api/row.ts index c7c72368f5..c6ef4606d2 100644 --- a/packages/server/src/tests/utilities/api/row.ts +++ b/packages/server/src/tests/utilities/api/row.ts @@ -1,4 +1,4 @@ -import { PatchRowRequest } from "@budibase/types" +import { PatchRowRequest, SaveRowRequest, Row } from "@budibase/types" import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" @@ -8,12 +8,12 @@ export class RowAPI extends TestAPI { } get = async ( - tableId: string, + sourceId: string, rowId: string, { expectStatus } = { expectStatus: 200 } ) => { const request = this.request - .get(`/api/${tableId}/rows/${rowId}`) + .get(`/api/${sourceId}/rows/${rowId}`) .set(this.config.defaultHeaders()) .expect(expectStatus) if (expectStatus !== 404) { @@ -22,16 +22,43 @@ export class RowAPI extends TestAPI { return request } + save = async ( + sourceId: string, + row: SaveRowRequest, + { expectStatus } = { expectStatus: 200 } + ): Promise => { + const resp = await this.request + .post(`/api/${sourceId}/rows`) + .send(row) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(expectStatus) + return resp.body as Row + } + patch = async ( - tableId: string, + sourceId: string, row: PatchRowRequest, { expectStatus } = { expectStatus: 200 } ) => { return this.request - .patch(`/api/${tableId}/rows`) + .patch(`/api/${sourceId}/rows`) .send(row) .set(this.config.defaultHeaders()) .expect("Content-Type", /json/) .expect(expectStatus) } + + delete = async ( + sourceId: string, + rows: Row[], + { expectStatus } = { expectStatus: 200 } + ) => { + return this.request + .delete(`/api/${sourceId}/rows`) + .send({ rows }) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(expectStatus) + } } diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index 813d2ebfd1..1520154641 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -1,10 +1,6 @@ import { CreateViewRequest, UpdateViewRequest, - DeleteRowRequest, - PatchRowRequest, - PatchRowResponse, - Row, ViewV2, SearchViewRowRequest, } from "@budibase/types" @@ -90,46 +86,4 @@ export class ViewV2API extends TestAPI { .expect("Content-Type", /json/) .expect(expectStatus) } - - row = { - create: async ( - viewId: string, - row: Row, - { expectStatus } = { expectStatus: 200 } - ): Promise => { - const result = await this.request - .post(`/api/v2/views/${viewId}/rows`) - .send(row) - .set(this.config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(expectStatus) - return result.body as Row - }, - update: async ( - viewId: string, - rowId: string, - row: PatchRowRequest, - { expectStatus } = { expectStatus: 200 } - ): Promise => { - const result = await this.request - .patch(`/api/v2/views/${viewId}/rows/${rowId}`) - .send(row) - .set(this.config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(expectStatus) - return result.body as PatchRowResponse - }, - delete: async ( - viewId: string, - body: DeleteRowRequest, - { expectStatus } = { expectStatus: 200 } - ): Promise => { - const result = await this.request - .delete(`/api/v2/views/${viewId}/rows`) - .send(body) - .set(this.config.defaultHeaders()) - .expect(expectStatus) - return result.body - }, - } } diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index f1890ef777..2b51c7b203 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,6 +1,8 @@ import { SearchParams } from "../../../sdk" import { Row } from "../../../documents" +export interface SaveRowRequest extends Row {} + export interface PatchRowRequest extends Row { _id: string _rev: string From c18459d84d7c8979e5402226b6b189033dd386fc Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 8 Aug 2023 13:43:13 +0100 Subject: [PATCH 077/123] Updating trim view info test case. --- .../middleware/tests/trimViewRowInfo.spec.ts | 27 ++----------------- .../server/src/middleware/trimViewRowInfo.ts | 2 +- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/packages/server/src/middleware/tests/trimViewRowInfo.spec.ts b/packages/server/src/middleware/tests/trimViewRowInfo.spec.ts index 427ac9a608..69d1272df9 100644 --- a/packages/server/src/middleware/tests/trimViewRowInfo.spec.ts +++ b/packages/server/src/middleware/tests/trimViewRowInfo.spec.ts @@ -117,7 +117,7 @@ describe("trimViewRowInfo middleware", () => { }) expect(config.request?.body).toEqual(data) - expect(config.params.tableId).toEqual(table._id) + expect(config.params.sourceId).toEqual(table._id) expect(config.next).toBeCalledTimes(1) expect(config.throw).not.toBeCalled() @@ -143,32 +143,9 @@ describe("trimViewRowInfo middleware", () => { name: data.name, address: data.address, }) - expect(config.params.tableId).toEqual(table._id) + expect(config.params.sourceId).toEqual(table._id) expect(config.next).toBeCalledTimes(1) expect(config.throw).not.toBeCalled() }) - - it("it should throw an error if no viewid is provided on the body", async () => { - const data = getRandomData() - await config.executeMiddleware(viewId, { - ...data, - }) - - expect(config.throw).toBeCalledTimes(1) - expect(config.throw).toBeCalledWith(400, "_viewId is required") - expect(config.next).not.toBeCalled() - }) - - it("it should throw an error if no viewid is provided on the parameters", async () => { - const data = getRandomData() - await config.executeMiddleware(undefined as any, { - _viewId: viewId, - ...data, - }) - - expect(config.throw).toBeCalledTimes(1) - expect(config.throw).toBeCalledWith(400, "viewId path is required") - expect(config.next).not.toBeCalled() - }) }) diff --git a/packages/server/src/middleware/trimViewRowInfo.ts b/packages/server/src/middleware/trimViewRowInfo.ts index 5a207936b2..cff9dabd37 100644 --- a/packages/server/src/middleware/trimViewRowInfo.ts +++ b/packages/server/src/middleware/trimViewRowInfo.ts @@ -22,7 +22,7 @@ export default async (ctx: Ctx, next: Next) => { const { tableId } = utils.extractViewInfoFromID(viewId) // don't need to trim delete requests - if (ctx.method.toLowerCase() !== "delete") { + if (ctx?.method?.toLowerCase() !== "delete") { const { _viewId, ...trimmedView } = await trimViewFields( viewId, tableId, From 00e6a43e3ec2c4968af3fc531ad5aeb465b1d52a Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 8 Aug 2023 16:39:05 +0100 Subject: [PATCH 078/123] Form step and field group require form --- packages/client/manifest.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index b6a231917c..925c87e61d 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -2445,6 +2445,7 @@ "name": "Form Step", "icon": "AssetsAdded", "hasChildren": true, + "requiredAncestors": ["form"], "illegalChildren": ["section", "form", "formstep", "formblock"], "styles": ["size"], "size": { @@ -2464,6 +2465,7 @@ "fieldgroup": { "name": "Field Group", "icon": "Group", + "requiredAncestors": ["form"], "illegalChildren": ["section"], "styles": ["size"], "hasChildren": true, From 22b456da5e2562c4efd2c6148e93aa3746132cb8 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 8 Aug 2023 17:13:40 +0100 Subject: [PATCH 079/123] Allow form step to be bindable --- .../ButtonActionEditor/actions/ChangeFormStep.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte index ca2df71c6d..81a2119474 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte @@ -1,10 +1,12 @@