From 6bc88d8c797e758f7e499301b8ea26075d148068 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Oct 2024 11:39:56 +0200 Subject: [PATCH 01/53] yarn add zod --- packages/types/package.json | 3 +- yarn.lock | 281 ++++++++++++++++++++---------------- 2 files changed, 162 insertions(+), 122 deletions(-) diff --git a/packages/types/package.json b/packages/types/package.json index bce25c7086..7e0f98b367 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -22,6 +22,7 @@ "typescript": "5.5.2" }, "dependencies": { - "scim-patch": "^0.8.1" + "scim-patch": "^0.8.1", + "zod": "^3.23.8" } } diff --git a/yarn.lock b/yarn.lock index 1198e98ad6..bc18155a9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -764,20 +764,20 @@ "@azure/abort-controller" "^1.0.0" tslib "^2.2.0" -"@azure/identity@4.2.1", "@azure/identity@^3.4.1": - version "4.2.1" - resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.2.1.tgz#22b366201e989b7b41c0e1690e103bd579c31e4c" - integrity sha512-U8hsyC9YPcEIzoaObJlRDvp7KiF0MGS7xcWbyJSVvXRkC/HXo1f0oYeBYmEvVgRfacw7GHf6D6yAoh9JHz6A5Q== +"@azure/identity@^3.4.1": + version "3.4.2" + resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-3.4.2.tgz#6b01724c9caac7cadab6b63c76584345bda8e2de" + integrity sha512-0q5DL4uyR0EZ4RXQKD8MadGH6zTIcloUoS/RVbCpNpej4pwte0xpqYxk8K97Py2RiuUvI7F4GXpoT4046VfufA== dependencies: "@azure/abort-controller" "^1.0.0" "@azure/core-auth" "^1.5.0" "@azure/core-client" "^1.4.0" "@azure/core-rest-pipeline" "^1.1.0" "@azure/core-tracing" "^1.0.0" - "@azure/core-util" "^1.3.0" + "@azure/core-util" "^1.6.1" "@azure/logger" "^1.0.0" - "@azure/msal-browser" "^3.11.1" - "@azure/msal-node" "^2.9.2" + "@azure/msal-browser" "^3.5.0" + "@azure/msal-node" "^2.5.1" events "^3.0.0" jws "^4.0.0" open "^8.0.0" @@ -808,10 +808,10 @@ dependencies: tslib "^2.2.0" -"@azure/msal-browser@^3.11.1": - version "3.24.0" - resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-3.24.0.tgz#3208047672d0b0c943b0bef5f995d510d6582ae4" - integrity sha512-JGNV9hTYAa7lsum9IMIibn2kKczAojNihGo1hi7pG0kNrcKej530Fl6jxwM05A44/6I079CSn6WxYxbVhKUmWg== +"@azure/msal-browser@^3.5.0": + version "3.25.0" + resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-3.25.0.tgz#7ce0949977bc9e0c58319f7090c44fe5537104d4" + integrity sha512-a0Y7pmSy8SC1s9bvwr+REvyAA1nQcITlZvkElM2gNUPYFTTNUTEdcpg73TmawNucyMdZ9xb/GFcuhrLOqYAzwg== dependencies: "@azure/msal-common" "14.15.0" @@ -820,10 +820,10 @@ resolved "https://registry.yarnpkg.com/@azure/msal-common/-/msal-common-14.15.0.tgz#0e27ac0bb88fe100f4f8d1605b64d5c268636a55" integrity sha512-ImAQHxmpMneJ/4S8BRFhjt1MZ3bppmpRPYYNyzeQPeFN288YKbb8TmmISQEbtfkQ1BPASvYZU5doIZOPBAqENQ== -"@azure/msal-node@^2.9.2": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@azure/msal-node/-/msal-node-2.14.0.tgz#7881895d41b03d8b9b38a29550ba3bbb15f73b3c" - integrity sha512-rrfzIpG3Q1rHjVYZmHAEDidWAZZ2cgkxlIcMQ8dHebRISaZ2KCV33Q8Vs+uaV6lxweROabNxKFlR2lIKagZqYg== +"@azure/msal-node@^2.5.1": + version "2.15.0" + resolved "https://registry.yarnpkg.com/@azure/msal-node/-/msal-node-2.15.0.tgz#50bf8e692a6656027c073a75d877a8a478aafdfd" + integrity sha512-gVPW8YLz92ZeCibQH2QUw96odJoiM3k/ZPH3f2HxptozmH6+OnyyvKXo/Egg39HAM230akarQKHf0W74UHlh0Q== dependencies: "@azure/msal-common" "14.15.0" jsonwebtoken "^9.0.0" @@ -2051,44 +2051,6 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@2.32.11": - version "0.0.0" - dependencies: - "@budibase/nano" "10.1.5" - "@budibase/pouchdb-replication-stream" "1.2.11" - "@budibase/shared-core" "0.0.0" - "@budibase/types" "0.0.0" - aws-cloudfront-sign "3.0.2" - aws-sdk "2.1030.0" - bcrypt "5.1.0" - bcryptjs "2.4.3" - bull "4.10.1" - correlation-id "4.0.0" - dd-trace "5.2.0" - dotenv "16.0.1" - ioredis "5.3.2" - joi "17.6.0" - jsonwebtoken "9.0.2" - knex "2.4.2" - koa-passport "^6.0.0" - koa-pino-logger "4.0.0" - lodash "4.17.21" - node-fetch "2.6.7" - passport-google-oauth "2.0.0" - passport-local "1.0.0" - passport-oauth2-refresh "^2.1.0" - pino "8.11.0" - pino-http "8.3.3" - posthog-node "4.0.1" - pouchdb "7.3.0" - pouchdb-find "7.2.2" - redlock "4.2.0" - rotating-file-stream "3.1.0" - sanitize-s3-objectkey "0.0.1" - semver "^7.5.4" - tar-fs "2.1.1" - uuid "^8.3.2" - "@budibase/handlebars-helpers@^0.13.2": version "0.13.2" resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.13.2.tgz#73ab51c464e91fd955b429017648e0257060db77" @@ -2131,47 +2093,6 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@npm:@budibase/pro@latest": - version "2.32.11" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.32.11.tgz#c94d534f829ca0ef252677757e157a7e58b87b4d" - integrity sha512-mOkqJpqHKWsfTWZwWcvBCYFUIluSUHltQNinc1ZRsg9rC3OKoHSDop6gzm744++H/GzGRN8V86kLhCgtNIlkpA== - dependencies: - "@anthropic-ai/sdk" "^0.27.3" - "@budibase/backend-core" "2.32.11" - "@budibase/shared-core" "2.32.11" - "@budibase/string-templates" "2.32.11" - "@budibase/types" "2.32.11" - "@koa/router" "8.0.8" - bull "4.10.1" - dd-trace "5.2.0" - joi "17.6.0" - jsonwebtoken "9.0.2" - lru-cache "^7.14.1" - memorystream "^0.3.1" - node-fetch "2.6.7" - openai "4.59.0" - scim-patch "^0.8.1" - scim2-parse-filter "^0.2.8" - -"@budibase/shared-core@2.32.11": - version "0.0.0" - dependencies: - "@budibase/types" "0.0.0" - cron-validate "1.4.5" - -"@budibase/string-templates@2.32.11": - version "0.0.0" - dependencies: - "@budibase/handlebars-helpers" "^0.13.2" - dayjs "^1.10.8" - handlebars "^4.7.8" - lodash.clonedeep "^4.5.0" - -"@budibase/types@2.32.11": - version "0.0.0" - dependencies: - scim-patch "^0.8.1" - "@bull-board/api@5.10.2": version "5.10.2" resolved "https://registry.yarnpkg.com/@bull-board/api/-/api-5.10.2.tgz#ae8ff6918b23897bf879a6ead3683f964374c4b3" @@ -7326,7 +7247,23 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== -axios@1.1.3, axios@1.6.3, axios@^0.21.1, axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.5.0, axios@^1.6.2: +axios@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.1.3.tgz#8274250dada2edf53814ed7db644b9c2866c1e35" + integrity sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + +axios@^0.21.1: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + +axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.5.0, axios@^1.6.2: version "1.6.3" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.3.tgz#7f50f23b3aa246eff43c54834272346c396613f4" integrity sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww== @@ -11126,7 +11063,14 @@ fast-url-parser@^1.1.3: dependencies: punycode "^1.3.2" -fast-xml-parser@4.2.5, fast-xml-parser@4.4.1, fast-xml-parser@^4.1.3, fast-xml-parser@^4.2.2, fast-xml-parser@^4.2.5: +fast-xml-parser@4.2.5: + version "4.2.5" + resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz#a6747a09296a6cb34f2ae634019bf1738f3b421f" + integrity sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g== + dependencies: + strnum "^1.0.5" + +fast-xml-parser@^4.1.3, fast-xml-parser@^4.2.2, fast-xml-parser@^4.2.5: version "4.4.1" resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz#86dbf3f18edf8739326447bcaac31b4ae7f6514f" integrity sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw== @@ -11375,6 +11319,11 @@ fn.name@1.x.x: resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== +follow-redirects@^1.14.0: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + follow-redirects@^1.15.0: version "1.15.6" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" @@ -12457,7 +12406,12 @@ http-assert@^1.3.0: deep-equal "~1.0.1" http-errors "~1.8.0" -http-cache-semantics@3.8.1, http-cache-semantics@4.1.1, http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: +http-cache-semantics@3.8.1: + version "3.8.1" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" + integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== + +http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== @@ -12977,6 +12931,11 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + is-builtin-module@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169" @@ -13453,11 +13412,6 @@ isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== -isobject@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" - integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== - isolated-vm@^4.7.2: version "4.7.2" resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-4.7.2.tgz#5670d5cce1d92004f9b825bec5b0b11fc7501b65" @@ -14362,7 +14316,14 @@ kill-port@^1.6.1: get-them-args "1.3.2" shell-exec "1.0.2" -kind-of@6.0.3, kind-of@^3.0.2, kind-of@^3.1.0, kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: +kind-of@^3.0.2, kind-of@^3.1.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== + dependencies: + is-buffer "^1.1.5" + +kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -15982,7 +15943,7 @@ msgpackr-extract@^3.0.2: "@msgpackr-extract/msgpackr-extract-linux-x64" "3.0.2" "@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.2" -msgpackr@1.10.1, msgpackr@^1.5.2: +msgpackr@^1.5.2: version "1.10.1" resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555" integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ== @@ -16176,13 +16137,25 @@ node-domexception@1.0.0: resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== -node-fetch@2.6.0, node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.6.9, node-fetch@^2.7.0: +node-fetch@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + +node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.9, node-fetch@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-forge@^1.2.1, node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -17318,7 +17291,15 @@ passport-strategy@1.x.x, passport-strategy@^1.0.0: resolved "https://registry.yarnpkg.com/passport-strategy/-/passport-strategy-1.0.0.tgz#b5539aa8fc225a3d1ad179476ddf236b440f52e4" integrity sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA== -passport@0.6.0, passport@^0.4.0, passport@^0.6.0: +passport@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/passport/-/passport-0.4.1.tgz#941446a21cb92fc688d97a0861c38ce9f738f270" + integrity sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg== + dependencies: + passport-strategy "1.x.x" + pause "0.0.1" + +passport@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/passport/-/passport-0.6.0.tgz#e869579fab465b5c0b291e841e6cc95c005fac9d" integrity sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug== @@ -18578,7 +18559,7 @@ pseudomap@^1.0.2: resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== -psl@^1.1.33: +psl@^1.1.28, psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -19613,6 +19594,11 @@ sax@1.2.1: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA== +sax@>=0.1.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" + integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== + sax@>=0.6.0: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -19685,13 +19671,33 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@7.5.3, semver@^5.5.0, semver@^5.6.0, semver@^5.7.1, semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.3, semver@~2.3.1: +"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0, semver@^5.7.1: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + +semver@7.5.3, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3: version "7.5.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== dependencies: lru-cache "^6.0.0" +semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.5.4, semver@^7.6.0, semver@^7.6.3: + version "7.6.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== + +semver@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52" + integrity sha512-abLdIKCosKfpnmhS52NCTjO4RiLspDfsn37prjzGrp9im5DPJOgh82Os92vtwGh6XdQryKI/7SREZnV+aqiXrA== + seq-queue@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e" @@ -21270,7 +21276,7 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2, tough-cookie@~2.5.0: +"tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2: version "4.1.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== @@ -21280,6 +21286,14 @@ tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0 universalify "^0.2.0" url-parse "^1.5.3" +tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + tr46@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" @@ -21795,14 +21809,6 @@ unpipe@1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== -unset-value@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-2.0.1.tgz#57bed0c22d26f28d69acde5df9a11b77c74d2df3" - integrity sha512-2hvrBfjUE00PkqN+q0XP6yRAOGrR06uSiUoIQGZkc7GxvQ9H7v8quUPNtZjMg4uux69i8HWpIjLPUKwCuRGyNg== - dependencies: - has-value "^2.0.2" - isobject "^4.0.0" - untildify@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" @@ -22586,10 +22592,33 @@ xml-parse-from-string@^1.0.0: resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28" integrity sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g== -xml2js@0.1.x, xml2js@0.4.19, xml2js@0.5.0, xml2js@0.6.2, xml2js@^0.4.19, xml2js@^0.4.5: - version "0.6.2" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499" - integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA== +xml2js@0.1.x: + version "0.1.14" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.1.14.tgz#5274e67f5a64c5f92974cd85139e0332adc6b90c" + integrity sha512-pbdws4PPPNc1HPluSUKamY4GWMk592K7qwcj6BExbVOhhubub8+pMda/ql68b6L3luZs/OGjGSB5goV7SnmgnA== + dependencies: + sax ">=0.1.1" + +xml2js@0.4.19: + version "0.4.19" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7" + integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q== + dependencies: + sax ">=0.6.0" + xmlbuilder "~9.0.1" + +xml2js@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7" + integrity sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA== + dependencies: + sax ">=0.6.0" + xmlbuilder "~11.0.0" + +xml2js@^0.4.19, xml2js@^0.4.5: + version "0.4.23" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66" + integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug== dependencies: sax ">=0.6.0" xmlbuilder "~11.0.0" @@ -22599,6 +22628,11 @@ xmlbuilder@~11.0.0: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== +xmlbuilder@~9.0.1: + version "9.0.7" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" + integrity sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" @@ -22846,3 +22880,8 @@ zip-stream@^6.0.1: archiver-utils "^5.0.0" compress-commons "^6.0.2" readable-stream "^4.0.0" + +zod@^3.23.8: + version "3.23.8" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" + integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== From 5a8aba7f523f8c6a2a877121128257285992bbad Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Oct 2024 11:41:04 +0200 Subject: [PATCH 02/53] zod validator --- .../server/src/middleware/zod-validator.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/server/src/middleware/zod-validator.ts diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts new file mode 100644 index 0000000000..6fb338e5e8 --- /dev/null +++ b/packages/server/src/middleware/zod-validator.ts @@ -0,0 +1,33 @@ +import { AnyZodObject } from "zod" +import { Ctx } from "@budibase/types" + +function validate(schema: AnyZodObject, property: "body" | "params") { + // Return a Koa middleware function + return (ctx: Ctx, next: any) => { + if (!schema) { + return next() + } + let params = null + if (ctx[property] != null) { + params = ctx[property] + } else if (property === "body" && ctx.request[property] != null) { + params = ctx.request[property] + } else if (ctx.request.get(property) != null) { + params = ctx.request.get(property) + } + + const { error } = schema.safeParse(params) + if (error) { + ctx.throw(400, `Invalid ${property} - ${error.message}`) + } + return next() + } +} + +export function validateBody(schema: AnyZodObject) { + return validate(schema, "body") +} + +// export function validateParams(schema: Joi.Schema) { +// return validate(schema, "params") +// } From 36410aac0bff05ff4f507613c1003c9268e3a036 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 4 Oct 2024 11:45:18 +0200 Subject: [PATCH 03/53] Display readable errors --- packages/server/package.json | 6 +- .../server/src/middleware/zod-validator.ts | 6 +- yarn.lock | 270 ++++++++---------- 3 files changed, 129 insertions(+), 153 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 76dd03b5a8..15e78fe7a8 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -119,7 +119,8 @@ "uuid": "^8.3.2", "validate.js": "0.13.1", "worker-farm": "1.7.0", - "xml2js": "0.5.0" + "xml2js": "0.5.0", + "zod-validation-error": "^3.4.0" }, "devDependencies": { "@babel/preset-env": "7.16.11", @@ -158,7 +159,8 @@ "tsconfig-paths": "4.0.0", "typescript": "5.5.2", "update-dotenv": "1.1.1", - "yargs": "13.2.4" + "yargs": "13.2.4", + "zod": "^3.23.8" }, "nx": { "targets": { diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index 6fb338e5e8..7b51d908c1 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -1,6 +1,8 @@ -import { AnyZodObject } from "zod" import { Ctx } from "@budibase/types" +import { AnyZodObject } from "zod" +import { fromZodError } from "zod-validation-error" + function validate(schema: AnyZodObject, property: "body" | "params") { // Return a Koa middleware function return (ctx: Ctx, next: any) => { @@ -18,7 +20,7 @@ function validate(schema: AnyZodObject, property: "body" | "params") { const { error } = schema.safeParse(params) if (error) { - ctx.throw(400, `Invalid ${property} - ${error.message}`) + ctx.throw(400, fromZodError(error)) } return next() } diff --git a/yarn.lock b/yarn.lock index bc18155a9d..9b258a2ba0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -764,20 +764,20 @@ "@azure/abort-controller" "^1.0.0" tslib "^2.2.0" -"@azure/identity@^3.4.1": - version "3.4.2" - resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-3.4.2.tgz#6b01724c9caac7cadab6b63c76584345bda8e2de" - integrity sha512-0q5DL4uyR0EZ4RXQKD8MadGH6zTIcloUoS/RVbCpNpej4pwte0xpqYxk8K97Py2RiuUvI7F4GXpoT4046VfufA== +"@azure/identity@4.2.1", "@azure/identity@^3.4.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.2.1.tgz#22b366201e989b7b41c0e1690e103bd579c31e4c" + integrity sha512-U8hsyC9YPcEIzoaObJlRDvp7KiF0MGS7xcWbyJSVvXRkC/HXo1f0oYeBYmEvVgRfacw7GHf6D6yAoh9JHz6A5Q== dependencies: "@azure/abort-controller" "^1.0.0" "@azure/core-auth" "^1.5.0" "@azure/core-client" "^1.4.0" "@azure/core-rest-pipeline" "^1.1.0" "@azure/core-tracing" "^1.0.0" - "@azure/core-util" "^1.6.1" + "@azure/core-util" "^1.3.0" "@azure/logger" "^1.0.0" - "@azure/msal-browser" "^3.5.0" - "@azure/msal-node" "^2.5.1" + "@azure/msal-browser" "^3.11.1" + "@azure/msal-node" "^2.9.2" events "^3.0.0" jws "^4.0.0" open "^8.0.0" @@ -808,7 +808,7 @@ dependencies: tslib "^2.2.0" -"@azure/msal-browser@^3.5.0": +"@azure/msal-browser@^3.11.1": version "3.25.0" resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-3.25.0.tgz#7ce0949977bc9e0c58319f7090c44fe5537104d4" integrity sha512-a0Y7pmSy8SC1s9bvwr+REvyAA1nQcITlZvkElM2gNUPYFTTNUTEdcpg73TmawNucyMdZ9xb/GFcuhrLOqYAzwg== @@ -820,7 +820,7 @@ resolved "https://registry.yarnpkg.com/@azure/msal-common/-/msal-common-14.15.0.tgz#0e27ac0bb88fe100f4f8d1605b64d5c268636a55" integrity sha512-ImAQHxmpMneJ/4S8BRFhjt1MZ3bppmpRPYYNyzeQPeFN288YKbb8TmmISQEbtfkQ1BPASvYZU5doIZOPBAqENQ== -"@azure/msal-node@^2.5.1": +"@azure/msal-node@^2.9.2": version "2.15.0" resolved "https://registry.yarnpkg.com/@azure/msal-node/-/msal-node-2.15.0.tgz#50bf8e692a6656027c073a75d877a8a478aafdfd" integrity sha512-gVPW8YLz92ZeCibQH2QUw96odJoiM3k/ZPH3f2HxptozmH6+OnyyvKXo/Egg39HAM230akarQKHf0W74UHlh0Q== @@ -2051,6 +2051,44 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@budibase/backend-core@2.32.12": + version "0.0.0" + dependencies: + "@budibase/nano" "10.1.5" + "@budibase/pouchdb-replication-stream" "1.2.11" + "@budibase/shared-core" "0.0.0" + "@budibase/types" "0.0.0" + aws-cloudfront-sign "3.0.2" + aws-sdk "2.1030.0" + bcrypt "5.1.0" + bcryptjs "2.4.3" + bull "4.10.1" + correlation-id "4.0.0" + dd-trace "5.2.0" + dotenv "16.0.1" + ioredis "5.3.2" + joi "17.6.0" + jsonwebtoken "9.0.2" + knex "2.4.2" + koa-passport "^6.0.0" + koa-pino-logger "4.0.0" + lodash "4.17.21" + node-fetch "2.6.7" + passport-google-oauth "2.0.0" + passport-local "1.0.0" + passport-oauth2-refresh "^2.1.0" + pino "8.11.0" + pino-http "8.3.3" + posthog-node "4.0.1" + pouchdb "7.3.0" + pouchdb-find "7.2.2" + redlock "4.2.0" + rotating-file-stream "3.1.0" + sanitize-s3-objectkey "0.0.1" + semver "^7.5.4" + tar-fs "2.1.1" + uuid "^8.3.2" + "@budibase/handlebars-helpers@^0.13.2": version "0.13.2" resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.13.2.tgz#73ab51c464e91fd955b429017648e0257060db77" @@ -2093,6 +2131,48 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" +"@budibase/pro@npm:@budibase/pro@latest": + version "2.32.12" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.32.12.tgz#a5a975ad223e40eb186576f9982e9bef583da906" + integrity sha512-18BeOwMKAkjrgIeyvXTnUc07pcFKdEg0aYqoOxkGsz182YUEk1r+unalvSSBW8hsKObZw1pkcx45dAFfI14wLA== + dependencies: + "@anthropic-ai/sdk" "^0.27.3" + "@budibase/backend-core" "2.32.12" + "@budibase/shared-core" "2.32.12" + "@budibase/string-templates" "2.32.12" + "@budibase/types" "2.32.12" + "@koa/router" "8.0.8" + bull "4.10.1" + dd-trace "5.2.0" + joi "17.6.0" + jsonwebtoken "9.0.2" + lru-cache "^7.14.1" + memorystream "^0.3.1" + node-fetch "2.6.7" + openai "4.59.0" + scim-patch "^0.8.1" + scim2-parse-filter "^0.2.8" + +"@budibase/shared-core@2.32.12": + version "0.0.0" + dependencies: + "@budibase/types" "0.0.0" + cron-validate "1.4.5" + +"@budibase/string-templates@2.32.12": + version "0.0.0" + dependencies: + "@budibase/handlebars-helpers" "^0.13.2" + dayjs "^1.10.8" + handlebars "^4.7.8" + lodash.clonedeep "^4.5.0" + +"@budibase/types@2.32.12": + version "0.0.0" + dependencies: + scim-patch "^0.8.1" + zod "^3.23.8" + "@bull-board/api@5.10.2": version "5.10.2" resolved "https://registry.yarnpkg.com/@bull-board/api/-/api-5.10.2.tgz#ae8ff6918b23897bf879a6ead3683f964374c4b3" @@ -7247,23 +7327,7 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== -axios@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.1.3.tgz#8274250dada2edf53814ed7db644b9c2866c1e35" - integrity sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA== - dependencies: - follow-redirects "^1.15.0" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - -axios@^0.21.1: - version "0.21.4" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" - integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== - dependencies: - follow-redirects "^1.14.0" - -axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.5.0, axios@^1.6.2: +axios@1.1.3, axios@1.6.3, axios@^0.21.1, axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.5.0, axios@^1.6.2: version "1.6.3" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.3.tgz#7f50f23b3aa246eff43c54834272346c396613f4" integrity sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww== @@ -11063,14 +11127,7 @@ fast-url-parser@^1.1.3: dependencies: punycode "^1.3.2" -fast-xml-parser@4.2.5: - version "4.2.5" - resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz#a6747a09296a6cb34f2ae634019bf1738f3b421f" - integrity sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g== - dependencies: - strnum "^1.0.5" - -fast-xml-parser@^4.1.3, fast-xml-parser@^4.2.2, fast-xml-parser@^4.2.5: +fast-xml-parser@4.2.5, fast-xml-parser@4.4.1, fast-xml-parser@^4.1.3, fast-xml-parser@^4.2.2, fast-xml-parser@^4.2.5: version "4.4.1" resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz#86dbf3f18edf8739326447bcaac31b4ae7f6514f" integrity sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw== @@ -11319,11 +11376,6 @@ fn.name@1.x.x: resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== -follow-redirects@^1.14.0: - version "1.15.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" - integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== - follow-redirects@^1.15.0: version "1.15.6" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" @@ -12406,12 +12458,7 @@ http-assert@^1.3.0: deep-equal "~1.0.1" http-errors "~1.8.0" -http-cache-semantics@3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" - integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== - -http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: +http-cache-semantics@3.8.1, http-cache-semantics@4.1.1, http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== @@ -12931,11 +12978,6 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-buffer@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" - integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== - is-builtin-module@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169" @@ -13412,6 +13454,11 @@ isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== +isobject@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" + integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== + isolated-vm@^4.7.2: version "4.7.2" resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-4.7.2.tgz#5670d5cce1d92004f9b825bec5b0b11fc7501b65" @@ -14316,14 +14363,7 @@ kill-port@^1.6.1: get-them-args "1.3.2" shell-exec "1.0.2" -kind-of@^3.0.2, kind-of@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== - dependencies: - is-buffer "^1.1.5" - -kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: +kind-of@6.0.3, kind-of@^3.0.2, kind-of@^3.1.0, kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -15943,7 +15983,7 @@ msgpackr-extract@^3.0.2: "@msgpackr-extract/msgpackr-extract-linux-x64" "3.0.2" "@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.2" -msgpackr@^1.5.2: +msgpackr@1.10.1, msgpackr@^1.5.2: version "1.10.1" resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555" integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ== @@ -16137,25 +16177,13 @@ node-domexception@1.0.0: resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== -node-fetch@2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" - integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== - -node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7: +node-fetch@2.6.0, node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.6.9, node-fetch@^2.7.0: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" -node-fetch@^2.6.9, node-fetch@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - node-forge@^1.2.1, node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -17291,15 +17319,7 @@ passport-strategy@1.x.x, passport-strategy@^1.0.0: resolved "https://registry.yarnpkg.com/passport-strategy/-/passport-strategy-1.0.0.tgz#b5539aa8fc225a3d1ad179476ddf236b440f52e4" integrity sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA== -passport@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/passport/-/passport-0.4.1.tgz#941446a21cb92fc688d97a0861c38ce9f738f270" - integrity sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg== - dependencies: - passport-strategy "1.x.x" - pause "0.0.1" - -passport@^0.6.0: +passport@0.6.0, passport@^0.4.0, passport@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/passport/-/passport-0.6.0.tgz#e869579fab465b5c0b291e841e6cc95c005fac9d" integrity sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug== @@ -18559,7 +18579,7 @@ pseudomap@^1.0.2: resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -19594,11 +19614,6 @@ sax@1.2.1: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA== -sax@>=0.1.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" - integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== - sax@>=0.6.0: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -19671,33 +19686,13 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0, semver@^5.7.1: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -semver@7.5.3, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3: +"semver@2 || 3 || 4 || 5", semver@7.5.3, semver@^5.5.0, semver@^5.6.0, semver@^5.7.1, semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.3, semver@~2.3.1: version "7.5.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -semver@^7.5.4, semver@^7.6.0, semver@^7.6.3: - version "7.6.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" - integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== - -semver@~2.3.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52" - integrity sha512-abLdIKCosKfpnmhS52NCTjO4RiLspDfsn37prjzGrp9im5DPJOgh82Os92vtwGh6XdQryKI/7SREZnV+aqiXrA== - seq-queue@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e" @@ -21276,7 +21271,7 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -"tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2: +tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2, tough-cookie@~2.5.0: version "4.1.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== @@ -21286,14 +21281,6 @@ touch@^3.1.0: universalify "^0.2.0" url-parse "^1.5.3" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tr46@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" @@ -21809,6 +21796,14 @@ unpipe@1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== +unset-value@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-2.0.1.tgz#57bed0c22d26f28d69acde5df9a11b77c74d2df3" + integrity sha512-2hvrBfjUE00PkqN+q0XP6yRAOGrR06uSiUoIQGZkc7GxvQ9H7v8quUPNtZjMg4uux69i8HWpIjLPUKwCuRGyNg== + dependencies: + has-value "^2.0.2" + isobject "^4.0.0" + untildify@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" @@ -22592,33 +22587,10 @@ xml-parse-from-string@^1.0.0: resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28" integrity sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g== -xml2js@0.1.x: - version "0.1.14" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.1.14.tgz#5274e67f5a64c5f92974cd85139e0332adc6b90c" - integrity sha512-pbdws4PPPNc1HPluSUKamY4GWMk592K7qwcj6BExbVOhhubub8+pMda/ql68b6L3luZs/OGjGSB5goV7SnmgnA== - dependencies: - sax ">=0.1.1" - -xml2js@0.4.19: - version "0.4.19" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7" - integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q== - dependencies: - sax ">=0.6.0" - xmlbuilder "~9.0.1" - -xml2js@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7" - integrity sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA== - dependencies: - sax ">=0.6.0" - xmlbuilder "~11.0.0" - -xml2js@^0.4.19, xml2js@^0.4.5: - version "0.4.23" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66" - integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug== +xml2js@0.1.x, xml2js@0.4.19, xml2js@0.5.0, xml2js@0.6.2, xml2js@^0.4.19, xml2js@^0.4.5: + version "0.6.2" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499" + integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA== dependencies: sax ">=0.6.0" xmlbuilder "~11.0.0" @@ -22628,11 +22600,6 @@ xmlbuilder@~11.0.0: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== -xmlbuilder@~9.0.1: - version "9.0.7" - resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" - integrity sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ== - xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" @@ -22881,6 +22848,11 @@ zip-stream@^6.0.1: compress-commons "^6.0.2" readable-stream "^4.0.0" +zod-validation-error@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/zod-validation-error/-/zod-validation-error-3.4.0.tgz#3a8a1f55c65579822d7faa190b51336c61bee2a6" + integrity sha512-ZOPR9SVY6Pb2qqO5XHt+MkkTRxGXb4EVtnjc9JpXUOtUB1T9Ru7mZOT361AN3MsetVe7R0a1KZshJDZdgp9miQ== + zod@^3.23.8: version "3.23.8" resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" From eea9eade5c0eedfeb578a9b688a3654ec93e7280 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Oct 2024 12:40:09 +0200 Subject: [PATCH 04/53] Start types --- .../server/src/api/controllers/row/index.ts | 9 ++++--- packages/types/src/api/web/app/rows.ts | 27 +++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 680a7671d5..769a1dbe5e 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -17,6 +17,7 @@ import { GetRowResponse, PatchRowRequest, PatchRowResponse, + RequiredKeys, Row, RowAttachment, RowSearchParams, @@ -211,15 +212,17 @@ export async function search(ctx: Ctx) { await context.ensureSnippetContext(true) + const searchRequest = ctx.request.body + const enrichedQuery = await utils.enrichSearchContext( - { ...ctx.request.body.query }, + { ...searchRequest.query }, { user: sdk.users.getUserContextBindings(ctx.user), } ) - const searchParams: RowSearchParams = { - ...ctx.request.body, + const searchParams: RequiredKeys = { + ...searchRequest, query: enrichedQuery, tableId, viewId, diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index ce6f6f672d..166c6965c4 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,7 +1,8 @@ import { SearchFilters, RowSearchParams } from "../../../sdk" import { Row } from "../../../documents" -import { PaginationResponse, SortOrder } from "../../../api" +import { PaginationResponse, SortOrder, SortType } from "../../../api" import { ReadStream } from "fs" +import { z } from "zod" export interface SaveRowRequest extends Row {} @@ -13,7 +14,29 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} -export interface SearchRowRequest extends Omit {} +const searchRowRequest = z.object({ + table: z.string(), + query: z.object({ + allOr: z.boolean().optional(), + }), + paginate: z.boolean().optional(), + bookmark: z.union([z.string(), z.number()]).optional(), + limit: z.number().optional(), + sort: z.string().optional(), + sortOrder: z.nativeEnum(SortOrder).optional(), + sortType: z.nativeEnum(SortType).optional(), + version: z.string().optional(), + disableEscaping: z.boolean().optional(), + countRows: z.boolean().optional(), + + // viewId?: string + // query?: SearchFilters + + // fields?: string[] + // indexer?: () => Promise + // rows?: Row[] +}) +export type SearchRowRequest = z.infer export interface SearchViewRowRequest extends Pick< From d1a69a66607e43ca7ec80c308f474deef65de8d8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 11:40:29 +0200 Subject: [PATCH 05/53] Use validation --- packages/server/src/api/routes/row.ts | 3 +++ packages/server/src/middleware/zod-validator.ts | 2 +- packages/types/src/api/web/app/rows.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index e443b2daeb..fc09b8c81d 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -5,6 +5,8 @@ import { paramResource, paramSubResource } from "../../middleware/resourceId" import { permissions } from "@budibase/backend-core" import { internalSearchValidator } from "./utils/validators" import trimViewRowInfo from "../../middleware/trimViewRowInfo" +import { validateBody } from "../../middleware/zod-validator" +import { searchRowRequestValidator } from "@budibase/types" const { PermissionType, PermissionLevel } = permissions @@ -32,6 +34,7 @@ router .post( "/api/:sourceId/search", internalSearchValidator(), + validateBody(searchRowRequestValidator), paramResource("sourceId"), authorized(PermissionType.TABLE, PermissionLevel.READ), rowController.search diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index 7b51d908c1..6611efbeb1 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -30,6 +30,6 @@ export function validateBody(schema: AnyZodObject) { return validate(schema, "body") } -// export function validateParams(schema: Joi.Schema) { +// export function validateParams(schema: AnyZodObject) { // return validate(schema, "params") // } diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 166c6965c4..e696430eb4 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -15,7 +15,6 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} const searchRowRequest = z.object({ - table: z.string(), query: z.object({ allOr: z.boolean().optional(), }), @@ -36,6 +35,7 @@ const searchRowRequest = z.object({ // indexer?: () => Promise // rows?: Row[] }) +export const searchRowRequestValidator = searchRowRequest export type SearchRowRequest = z.infer export interface SearchViewRowRequest From 76f155f31124656a9bba6c41c2fb995ed526655c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 12:31:10 +0200 Subject: [PATCH 06/53] Fix jest import issues --- packages/types/src/api/web/app/rows.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index e696430eb4..3aee8e754e 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,6 +1,10 @@ -import { SearchFilters, RowSearchParams } from "../../../sdk" +import { SearchFilters } from "../../../sdk" import { Row } from "../../../documents" -import { PaginationResponse, SortOrder, SortType } from "../../../api" +import { + PaginationResponse, + SortOrder, + SortType, +} from "../../../api/web/pagination" import { ReadStream } from "fs" import { z } from "zod" From b6731494e7138189d5dc36f3c2feeeccf033e303 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 12:39:14 +0200 Subject: [PATCH 07/53] Trim object --- packages/server/src/middleware/zod-validator.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index 6611efbeb1..f990ee0642 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -10,18 +10,25 @@ function validate(schema: AnyZodObject, property: "body" | "params") { return next() } let params = null + let setClean: ((data: any) => void) | undefined if (ctx[property] != null) { params = ctx[property] + setClean = data => (ctx[property] = data) } else if (property === "body" && ctx.request[property] != null) { params = ctx.request[property] - } else if (ctx.request.get(property) != null) { - params = ctx.request.get(property) + setClean = data => (ctx.request[property] = data) + } else if (property === "params") { + params = ctx.request.query + setClean = data => (ctx.request.query = data) } - const { error } = schema.safeParse(params) - if (error) { - ctx.throw(400, fromZodError(error)) + const result = schema.safeParse(params) + if (!result.success) { + ctx.throw(400, fromZodError(result.error)) + } else { + setClean?.(result.data) } + return next() } } From 7b789e785369ff3ed121b677fb3340a75ba798f0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 13:11:32 +0200 Subject: [PATCH 08/53] Type query --- packages/types/src/api/web/app/rows.ts | 43 +++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 3aee8e754e..45e065cc59 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,4 +1,11 @@ -import { SearchFilters } from "../../../sdk" +import { + ArrayOperator, + BasicOperator, + LogicalOperator, + RangeOperator, + SearchFilterKey, + SearchFilters, +} from "../../../sdk" import { Row } from "../../../documents" import { PaginationResponse, @@ -18,9 +25,43 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} +// TODO: exclude InternalSearchFilterOperator.COMPLEX_ID_OPERATOR +const stringBasicFilter = z.record(z.string(), z.string()) +const basicFilter = z.record(z.string(), z.any()) +const arrayFilter = z.any() +const logicFilter = z.any() + +const stringOrNumber = z.union([z.string(), z.number()]) + +const queryFilterValidation: Record = { + [BasicOperator.STRING]: stringBasicFilter.optional(), + [BasicOperator.FUZZY]: stringBasicFilter.optional(), + [RangeOperator.RANGE]: z + .record( + z.string(), + z.union([ + z.object({ high: stringOrNumber, low: stringOrNumber }), + z.object({ high: stringOrNumber }), + z.object({ low: stringOrNumber }), + ]) + ) + .optional(), + [BasicOperator.EQUAL]: basicFilter.optional(), + [BasicOperator.NOT_EQUAL]: basicFilter.optional(), + [BasicOperator.EMPTY]: basicFilter.optional(), + [BasicOperator.NOT_EMPTY]: basicFilter.optional(), + [ArrayOperator.ONE_OF]: arrayFilter.optional(), + [ArrayOperator.CONTAINS]: arrayFilter.optional(), + [ArrayOperator.NOT_CONTAINS]: arrayFilter.optional(), + [ArrayOperator.CONTAINS_ANY]: arrayFilter.optional(), + [LogicalOperator.AND]: logicFilter.optional(), + [LogicalOperator.OR]: logicFilter.optional(), +} + const searchRowRequest = z.object({ query: z.object({ allOr: z.boolean().optional(), + ...queryFilterValidation, }), paginate: z.boolean().optional(), bookmark: z.union([z.string(), z.number()]).optional(), From 4324d9683306eb1667c0948313f39d8c5d83118d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 13:20:20 +0200 Subject: [PATCH 09/53] Add onEmptyFilter --- packages/types/src/api/web/app/rows.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 45e065cc59..4652ea7df5 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -1,6 +1,7 @@ import { ArrayOperator, BasicOperator, + EmptyFilterOption, LogicalOperator, RangeOperator, SearchFilterKey, @@ -59,10 +60,13 @@ const queryFilterValidation: Record = { } const searchRowRequest = z.object({ - query: z.object({ - allOr: z.boolean().optional(), - ...queryFilterValidation, - }), + query: z + .object({ + allOr: z.boolean().optional(), + onEmptyFilter: z.nativeEnum(EmptyFilterOption).optional(), + ...queryFilterValidation, + }) + .optional(), paginate: z.boolean().optional(), bookmark: z.union([z.string(), z.number()]).optional(), limit: z.number().optional(), From e6b3b4f2a1ef732460b850dd3f5afdcb22a88e6d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 13:33:27 +0200 Subject: [PATCH 10/53] Type array filter --- packages/types/src/api/web/app/rows.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 4652ea7df5..6cc5e575a6 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -29,7 +29,7 @@ export interface PatchRowResponse extends Row {} // TODO: exclude InternalSearchFilterOperator.COMPLEX_ID_OPERATOR const stringBasicFilter = z.record(z.string(), z.string()) const basicFilter = z.record(z.string(), z.any()) -const arrayFilter = z.any() +const arrayFilter = z.record(z.string(), z.union([z.any().array(), z.string()])) const logicFilter = z.any() const stringOrNumber = z.union([z.string(), z.number()]) From e095a596a151582d1070bd661a4579bfb491d0d8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 13:40:39 +0200 Subject: [PATCH 11/53] Type logic filter --- packages/types/src/api/web/app/rows.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 6cc5e575a6..a02081366c 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -30,7 +30,11 @@ export interface PatchRowResponse extends Row {} const stringBasicFilter = z.record(z.string(), z.string()) const basicFilter = z.record(z.string(), z.any()) const arrayFilter = z.record(z.string(), z.union([z.any().array(), z.string()])) -const logicFilter = z.any() +const logicFilter = z.lazy(() => + z.object({ + conditions: z.array(z.object(queryFilterValidation)), + }) +) const stringOrNumber = z.union([z.string(), z.number()]) From 60a5f4a2e72da9130cedb32c5ed4948d3eb2934b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 15:11:11 +0200 Subject: [PATCH 12/53] Types --- packages/server/src/api/controllers/row/index.ts | 13 ++++++++++++- packages/server/src/api/routes/tests/search.spec.ts | 1 + packages/types/src/api/web/app/rows.ts | 7 ------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 769a1dbe5e..0e4e305ce7 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -222,10 +222,21 @@ export async function search(ctx: Ctx) { ) const searchParams: RequiredKeys = { - ...searchRequest, query: enrichedQuery, tableId, viewId, + bookmark: searchRequest.bookmark, + paginate: searchRequest.paginate, + limit: searchRequest.limit, + sort: searchRequest.sort, + sortOrder: searchRequest.sortOrder, + sortType: searchRequest.sortType, + countRows: searchRequest.countRows, + version: searchRequest.version, + disableEscaping: searchRequest.disableEscaping, + fields: undefined, + indexer: undefined, + rows: undefined, } ctx.status = 200 diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 1ccc9bfdc9..a53f650d22 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -187,6 +187,7 @@ describe.each([ if (isInMemory) { return dataFilters.search(_.cloneDeep(rows), { ...this.query, + query: this.query.query!, }) } else { return config.api.row.search(tableOrViewId, this.query) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index a02081366c..013e349fe5 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -80,13 +80,6 @@ const searchRowRequest = z.object({ version: z.string().optional(), disableEscaping: z.boolean().optional(), countRows: z.boolean().optional(), - - // viewId?: string - // query?: SearchFilters - - // fields?: string[] - // indexer?: () => Promise - // rows?: Row[] }) export const searchRowRequestValidator = searchRowRequest export type SearchRowRequest = z.infer From 5cad93ff75eb1eb02669c1edb35e90457fa4e29f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 15:15:54 +0200 Subject: [PATCH 13/53] Fix --- packages/server/src/api/controllers/row/views.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 622688deb6..9ceb14ed2c 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -35,7 +35,7 @@ export async function searchView( > = { tableId: view.tableId, viewId: view.id, - query: body.query, + query: body.query || {}, fields: viewFields, ...getSortOptions(body, view), limit: body.limit, From 6edaf5e160dbd6cbabc76c30df3ab2f83d9a9772 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 4 Nov 2024 13:33:12 +0000 Subject: [PATCH 14/53] Making sure all protected columns are kept during row save/patch operations. --- .../server/src/utilities/rowProcessor/index.ts | 14 ++++++++++---- packages/shared-core/src/constants/rows.ts | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index 910e9d220f..331d868dc7 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -31,6 +31,8 @@ import { import { isExternalTableID } from "../../integrations/utils" import { helpers, + isExternalColumnName, + isInternalColumnName, PROTECTED_EXTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS, } from "@budibase/shared-core" @@ -202,14 +204,18 @@ export async function inputProcessing( const clonedRow = cloneDeep(row) const table = await getTableFromSource(source) - const dontCleanseKeys = ["type", "_id", "_rev", "tableId"] for (const [key, value] of Object.entries(clonedRow)) { const field = table.schema[key] // cleanse fields that aren't in the schema + if ( + !field && isExternalTableID(table._id!) + ? !isExternalColumnName(key) + : !isInternalColumnName(key) + ) { + delete clonedRow[key] + } + // field isn't found - might be a built-in column, skip over it if (!field) { - if (dontCleanseKeys.indexOf(key) === -1) { - delete clonedRow[key] - } continue } // remove any formula values, they are to be generated diff --git a/packages/shared-core/src/constants/rows.ts b/packages/shared-core/src/constants/rows.ts index 03663a4014..23c123aaf4 100644 --- a/packages/shared-core/src/constants/rows.ts +++ b/packages/shared-core/src/constants/rows.ts @@ -12,3 +12,7 @@ export const PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"] as const export function isInternalColumnName(name: string): boolean { return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name) } + +export function isExternalColumnName(name: string): boolean { + return (PROTECTED_EXTERNAL_COLUMNS as readonly string[]).includes(name) +} From 6bb668ee33fd84fb12b98c9120725ca718c43654 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 15:03:09 +0100 Subject: [PATCH 15/53] Fix tests --- packages/server/src/api/routes/tests/row.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 8c4a01b07b..9213967d38 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -2799,6 +2799,8 @@ describe.each([ name: "foo", description: "bar", tableId, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }) }) @@ -2820,6 +2822,8 @@ describe.each([ id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, [`fk_${o2mTable.name}_fk_o2m`]: isInternal ? undefined : user.id, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }) }) @@ -2840,6 +2844,8 @@ describe.each([ _rev: expect.any(String), id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }) }) @@ -2917,6 +2923,8 @@ describe.each([ id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, [`fk_${o2mTable.name}_fk_o2m`]: isInternal ? undefined : user.id, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }) }) @@ -2941,6 +2949,8 @@ describe.each([ _rev: expect.any(String), id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }) }) From 8519cfc495b281dd6fbc588d4496ec9bf9852ecc Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 14:05:57 +0100 Subject: [PATCH 16/53] Fix typing --- packages/server/src/api/controllers/row/utils/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/utils/utils.ts b/packages/server/src/api/controllers/row/utils/utils.ts index 4188fcced3..5b60143792 100644 --- a/packages/server/src/api/controllers/row/utils/utils.ts +++ b/packages/server/src/api/controllers/row/utils/utils.ts @@ -175,7 +175,7 @@ export async function enrichArrayContext( } export async function enrichSearchContext( - fields: Record, + fields: Record | undefined, inputs = {}, helpers = true ): Promise> { From 3250ad49476c81520c5039240e535b17dc0b25ad Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 14:15:46 +0100 Subject: [PATCH 17/53] Allow nullable bookmarks --- .../src/api/routes/tests/search.spec.ts | 21 ++++++++++++++++--- packages/types/src/api/web/app/rows.ts | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index fe13e5311f..6600cf0da1 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -24,6 +24,7 @@ import { JsonFieldSubType, LogicalOperator, RelationshipType, + RequiredKeys, Row, RowSearchParams, SearchFilters, @@ -206,9 +207,23 @@ datasourceDescribe( private async performSearch(): Promise> { if (isInMemory) { - return dataFilters.search(_.cloneDeep(rows), { - ...this.query, - }) + const query: RequiredKeys> = { + sort: this.query.sort, + query: this.query.query || {}, + paginate: this.query.paginate, + bookmark: this.query.bookmark, + limit: this.query.limit, + sortOrder: this.query.sortOrder, + sortType: this.query.sortType, + version: this.query.version, + disableEscaping: this.query.disableEscaping, + countRows: this.query.countRows, + viewId: undefined, + fields: undefined, + indexer: undefined, + rows: undefined, + } + return dataFilters.search(_.cloneDeep(rows), query) } else { return config.api.row.search(tableOrViewId, this.query) } diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 013e349fe5..34ef1ee4c1 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -72,7 +72,7 @@ const searchRowRequest = z.object({ }) .optional(), paginate: z.boolean().optional(), - bookmark: z.union([z.string(), z.number()]).optional(), + bookmark: z.union([z.string(), z.number()]).nullable().optional(), limit: z.number().optional(), sort: z.string().optional(), sortOrder: z.nativeEnum(SortOrder).optional(), From cf7daf06027a9811e647cd06f33b123cdffbc3ed Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 14:16:10 +0100 Subject: [PATCH 18/53] Fix --- packages/server/src/api/routes/tests/search.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 6600cf0da1..2c13cac014 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -211,7 +211,7 @@ datasourceDescribe( sort: this.query.sort, query: this.query.query || {}, paginate: this.query.paginate, - bookmark: this.query.bookmark, + bookmark: this.query.bookmark ?? undefined, limit: this.query.limit, sortOrder: this.query.sortOrder, sortType: this.query.sortType, From 414d79d73c2db01a40b4a298abcec592a8867bbd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 14:16:26 +0100 Subject: [PATCH 19/53] Fix types --- packages/server/src/api/controllers/row/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index abc751b5e4..fbaf9f8462 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -255,7 +255,7 @@ export async function search(ctx: Ctx) { query: enrichedQuery, tableId, viewId, - bookmark: searchRequest.bookmark, + bookmark: searchRequest.bookmark ?? undefined, paginate: searchRequest.paginate, limit: searchRequest.limit, sort: searchRequest.sort, From 94f475c0607a001f131da6146b3b6fe55af63a2d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 16:09:03 +0100 Subject: [PATCH 20/53] Exclude InternalSearchFilterOperator.COMPLEX_ID_OPERATOR --- packages/types/src/api/web/app/rows.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 34ef1ee4c1..520983d353 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -2,6 +2,7 @@ import { ArrayOperator, BasicOperator, EmptyFilterOption, + InternalSearchFilterOperator, LogicalOperator, RangeOperator, SearchFilterKey, @@ -26,10 +27,15 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} -// TODO: exclude InternalSearchFilterOperator.COMPLEX_ID_OPERATOR -const stringBasicFilter = z.record(z.string(), z.string()) -const basicFilter = z.record(z.string(), z.any()) -const arrayFilter = z.record(z.string(), z.union([z.any().array(), z.string()])) +const fieldKey = z + .string() + .refine(s => s !== InternalSearchFilterOperator.COMPLEX_ID_OPERATOR, { + message: `Key '${InternalSearchFilterOperator.COMPLEX_ID_OPERATOR}' is not allowed`, + }) + +const stringBasicFilter = z.record(fieldKey, z.string()) +const basicFilter = z.record(fieldKey, z.any()) +const arrayFilter = z.record(fieldKey, z.union([z.any().array(), z.string()])) const logicFilter = z.lazy(() => z.object({ conditions: z.array(z.object(queryFilterValidation)), @@ -43,7 +49,7 @@ const queryFilterValidation: Record = { [BasicOperator.FUZZY]: stringBasicFilter.optional(), [RangeOperator.RANGE]: z .record( - z.string(), + fieldKey, z.union([ z.object({ high: stringOrNumber, low: stringOrNumber }), z.object({ high: stringOrNumber }), From ed6d434843f87dfc1287217c54baa9bfe8b3976c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 16:14:03 +0100 Subject: [PATCH 21/53] Fix --- packages/server/src/api/controllers/row/views.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 7d0957b2fc..58bd40b529 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -29,19 +29,20 @@ export async function searchView( await context.ensureSnippetContext(true) - const searchOptions: RequiredKeys & - RequiredKeys< - Pick - > = { + const searchOptions: RequiredKeys = { tableId: view.tableId, viewId: view.id, query: body.query || {}, fields: viewFields, ...getSortOptions(body, view), limit: body.limit, - bookmark: body.bookmark, + bookmark: body.bookmark ?? undefined, paginate: body.paginate, countRows: body.countRows, + version: undefined, + disableEscaping: undefined, + indexer: undefined, + rows: undefined, } const result = await sdk.rows.search(searchOptions, { From 2fb4c11484cbf2a5eecdaacc6c0efba536544281 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 20 Nov 2024 18:32:02 +0100 Subject: [PATCH 22/53] Update yarn.lock --- yarn.lock | 7 ------- 1 file changed, 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index aaadbbe7bd..0e7f680619 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5751,13 +5751,6 @@ dependencies: "@types/koa" "*" -"@types/koa__router@8.0.8": - version "8.0.8" - resolved "https://registry.yarnpkg.com/@types/koa__router/-/koa__router-8.0.8.tgz#b1e0e9a512498777d3366bbdf0e853df27ec831c" - integrity sha512-9pGCaDtzCsj4HJ8HmGuqzk8+s57sPj4njWd08GG5o92n5Xp9io2snc40CPpXFhoKcZ8OKhuu6ht4gNou9e1C2w== - dependencies: - "@types/koa" "*" - "@types/lodash@4.14.200": version "4.14.200" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.200.tgz#435b6035c7eba9cdf1e039af8212c9e9281e7149" From b75e2e85c67e05b37ff203679e1fdb28a324c38e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Nov 2024 12:03:13 +0000 Subject: [PATCH 23/53] Fixing issues with retrieval. --- packages/server/src/api/controllers/row/staticFormula.ts | 9 ++++++--- packages/server/src/utilities/rowProcessor/index.ts | 9 ++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index 31a6678012..74a558e228 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -162,9 +162,12 @@ export async function finaliseRow( }) } - const response = await db.put(row) - // for response, calculate the formulas for the enriched row - enrichedRow._rev = response.rev + await db.put(row) + const retrieved = await db.tryGet(row._id) + enrichedRow = { + ...enrichedRow, + ...retrieved, + } enrichedRow = await processFormulas(table, enrichedRow, { dynamic: false, }) diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index d9bdb8eb5b..14b524fd95 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -204,12 +204,11 @@ export async function inputProcessing( for (const [key, value] of Object.entries(clonedRow)) { const field = table.schema[key] + const isBuiltinColumn = isExternalTableID(table._id!) + ? isExternalColumnName(key) + : isInternalColumnName(key) // cleanse fields that aren't in the schema - if ( - !field && isExternalTableID(table._id!) - ? !isExternalColumnName(key) - : !isInternalColumnName(key) - ) { + if (!field && !isBuiltinColumn) { delete clonedRow[key] } // field isn't found - might be a built-in column, skip over it From a190feb4ea5053be8228f9bdc0bd8d83f1343890 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Nov 2024 12:05:16 +0000 Subject: [PATCH 24/53] Fixing test cases. --- .../server/src/api/routes/tests/row.spec.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index aa78973ab4..c91be2b9ae 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -2607,8 +2607,8 @@ if (descriptions.length) { name: "foo", description: "bar", tableId, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: isInternal ? new Date().toISOString() : undefined, + updatedAt: isInternal ? new Date().toISOString() : undefined, }) }) @@ -2630,8 +2630,8 @@ if (descriptions.length) { id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, [`fk_${o2mTable.name}_fk_o2m`]: isInternal ? undefined : user.id, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: isInternal ? new Date().toISOString() : undefined, + updatedAt: isInternal ? new Date().toISOString() : undefined, }) }) @@ -2654,8 +2654,8 @@ if (descriptions.length) { _rev: expect.any(String), id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: isInternal ? new Date().toISOString() : undefined, + updatedAt: isInternal ? new Date().toISOString() : undefined, }) }) @@ -2735,8 +2735,8 @@ if (descriptions.length) { id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, [`fk_${o2mTable.name}_fk_o2m`]: isInternal ? undefined : user.id, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: isInternal ? new Date().toISOString() : undefined, + updatedAt: isInternal ? new Date().toISOString() : undefined, }) }) @@ -2761,8 +2761,8 @@ if (descriptions.length) { _rev: expect.any(String), id: isInternal ? undefined : expect.any(Number), type: isInternal ? "row" : undefined, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: isInternal ? new Date().toISOString() : undefined, + updatedAt: isInternal ? new Date().toISOString() : undefined, }) }) From a27c28ccdff8cf8b55b28d9c268642a33d571a30 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Nov 2024 15:54:59 +0000 Subject: [PATCH 25/53] Fixing test case. --- packages/server/src/api/controllers/row/staticFormula.ts | 7 ++----- packages/server/src/api/routes/tests/row.spec.ts | 6 +++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index 74a558e228..b9751b1ce2 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -15,7 +15,7 @@ import { } from "@budibase/types" import * as linkRows from "../../../db/linkedRows" import isEqual from "lodash/isEqual" -import { cloneDeep } from "lodash/fp" +import { cloneDeep, merge } from "lodash/fp" import sdk from "../../../sdk" import * as pro from "@budibase/pro" @@ -164,10 +164,7 @@ export async function finaliseRow( await db.put(row) const retrieved = await db.tryGet(row._id) - enrichedRow = { - ...enrichedRow, - ...retrieved, - } + enrichedRow = merge(retrieved, enrichedRow) enrichedRow = await processFormulas(table, enrichedRow, { dynamic: false, }) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index c91be2b9ae..970e5f3619 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -85,7 +85,7 @@ function encodeJS(binding: string) { return `{{ js "${Buffer.from(binding).toString("base64")}"}}` } -const descriptions = datasourceDescribe({ exclude: [DatabaseName.MONGODB] }) +const descriptions = datasourceDescribe({ only: [DatabaseName.SQS] }) if (descriptions.length) { describe.each(descriptions)( @@ -2571,12 +2571,14 @@ if (descriptions.length) { let tableId: string let o2mData: Row[] let m2mData: Row[] + let isRelationship: boolean beforeAll(async () => { const table = await config.api.table.save( defaultTable({ schema: relSchema() }) ) tableId = table._id! + isRelationship = relSchema().user.type === FieldType.LINK o2mData = [ await dataGenerator(o2mTable._id!), @@ -2763,6 +2765,8 @@ if (descriptions.length) { type: isInternal ? "row" : undefined, createdAt: isInternal ? new Date().toISOString() : undefined, updatedAt: isInternal ? new Date().toISOString() : undefined, + users: isRelationship ? undefined : [], + user: isRelationship ? undefined : [], }) }) From 49af5501f1bbd09009238715a355cd5a025365eb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 15:05:37 +0000 Subject: [PATCH 26/53] Adding test container debug. --- .github/workflows/budibase_ci.yml | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 1258bddcca..7c48bbc774 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -26,7 +26,8 @@ env: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} NX_BASE_BRANCH: origin/${{ github.base_ref }} ONLY_AFFECTED_TASKS: ${{ github.event_name == 'pull_request' }} - IS_OSS_CONTRIBUTOR: ${{ inputs.run_as_oss == true || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase') }} + IS_OSS_CONTRIBUTOR: ${{ inputs.run_as_oss == true || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase') } + DEBUG: testcontainers* jobs: lint: diff --git a/yarn.lock b/yarn.lock index dd01832bba..edd5550b30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12635,6 +12635,11 @@ husky@^8.0.3: resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== +husky@^9.1.4: + version "9.1.7" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d" + integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA== + ical-generator@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ical-generator/-/ical-generator-4.1.0.tgz#2a336c951864c5583a2aa715d16f2edcdfd2d90b" From f556a2b3ce373423615e745711467569051cfd30 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 15:11:58 +0000 Subject: [PATCH 27/53] 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 7c48bbc774..05837f217c 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -26,7 +26,7 @@ env: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} NX_BASE_BRANCH: origin/${{ github.base_ref }} ONLY_AFFECTED_TASKS: ${{ github.event_name == 'pull_request' }} - IS_OSS_CONTRIBUTOR: ${{ inputs.run_as_oss == true || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase') } + IS_OSS_CONTRIBUTOR: ${{ inputs.run_as_oss == true || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase') }} DEBUG: testcontainers* jobs: From 70cdb99583c4b7ee0d72f2cec47c02181c2e9651 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 15:30:48 +0000 Subject: [PATCH 28/53] Increasing timeouts. --- packages/server/src/integrations/tests/utils/index.ts | 3 +++ packages/server/src/integrations/tests/utils/oracle.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/integrations/tests/utils/index.ts b/packages/server/src/integrations/tests/utils/index.ts index dcdaece191..e5d2e1f229 100644 --- a/packages/server/src/integrations/tests/utils/index.ts +++ b/packages/server/src/integrations/tests/utils/index.ts @@ -102,6 +102,9 @@ function createDummyTest() { } export function datasourceDescribe(opts: DatasourceDescribeOpts) { + // tests that call this need a lot longer timeouts + jest.setTimeout(120000) + if (process.env.DATASOURCE === "none") { createDummyTest() } diff --git a/packages/server/src/integrations/tests/utils/oracle.ts b/packages/server/src/integrations/tests/utils/oracle.ts index 8e7fd6c900..2ec8da5902 100644 --- a/packages/server/src/integrations/tests/utils/oracle.ts +++ b/packages/server/src/integrations/tests/utils/oracle.ts @@ -25,7 +25,7 @@ export async function getDatasource(): Promise { }) .withWaitStrategy( Wait.forLogMessage("DATABASE IS READY TO USE!").withStartupTimeout( - 20000 + 60000 ) ) ) From ce44975317dbc389a763883118ad52c2393de37e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 18:07:44 +0000 Subject: [PATCH 29/53] Removing test changes. --- .github/workflows/budibase_ci.yml | 1 - packages/server/src/api/routes/tests/row.spec.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 05837f217c..1258bddcca 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -27,7 +27,6 @@ env: NX_BASE_BRANCH: origin/${{ github.base_ref }} ONLY_AFFECTED_TASKS: ${{ github.event_name == 'pull_request' }} IS_OSS_CONTRIBUTOR: ${{ inputs.run_as_oss == true || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'Budibase/budibase') }} - DEBUG: testcontainers* jobs: lint: diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 970e5f3619..14be60aa8c 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -85,7 +85,7 @@ function encodeJS(binding: string) { return `{{ js "${Buffer.from(binding).toString("base64")}"}}` } -const descriptions = datasourceDescribe({ only: [DatabaseName.SQS] }) +const descriptions = datasourceDescribe({ exclude: [DatabaseName.MONGODB] }) if (descriptions.length) { describe.each(descriptions)( From b95b53f648cf87e3398ea9bb0da7fe9394470684 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 18:09:09 +0000 Subject: [PATCH 30/53] Correcting yarn lock. --- yarn.lock | 5 ----- 1 file changed, 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index edd5550b30..dd01832bba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12635,11 +12635,6 @@ husky@^8.0.3: resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== -husky@^9.1.4: - version "9.1.7" - resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d" - integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA== - ical-generator@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ical-generator/-/ical-generator-4.1.0.tgz#2a336c951864c5583a2aa715d16f2edcdfd2d90b" From 04ea2b99e9a0ec190c37172bd7c4d397eef99cf4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Nov 2024 18:37:05 +0000 Subject: [PATCH 31/53] Fixing issue uncovered by test case. --- .../src/api/controllers/row/staticFormula.ts | 17 ++++++++++++++++- .../server/src/api/routes/tests/row.spec.ts | 17 ++--------------- .../rowProcessor/bbReferenceProcessor.ts | 4 ++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index b9751b1ce2..ff2381e61c 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -19,6 +19,17 @@ import { cloneDeep, merge } from "lodash/fp" import sdk from "../../../sdk" import * as pro from "@budibase/pro" +function mergeRows(row1: Row, row2: Row) { + const merged = merge(row1, row2) + // make sure any specifically undefined fields are removed + for (const key of Object.keys(row2)) { + if (row2[key] === undefined) { + delete merged[key] + } + } + return merged +} + /** * This function runs through a list of enriched rows, looks at the rows which * are related and then checks if they need the state of their formulas @@ -164,7 +175,11 @@ export async function finaliseRow( await db.put(row) const retrieved = await db.tryGet(row._id) - enrichedRow = merge(retrieved, enrichedRow) + if (!retrieved) { + throw new Error(`Unable to retrieve row ${row._id} after saving.`) + } + + enrichedRow = mergeRows(retrieved, enrichedRow) enrichedRow = await processFormulas(table, enrichedRow, { dynamic: false, }) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 14be60aa8c..25c9b8abef 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -2571,14 +2571,12 @@ if (descriptions.length) { let tableId: string let o2mData: Row[] let m2mData: Row[] - let isRelationship: boolean beforeAll(async () => { const table = await config.api.table.save( defaultTable({ schema: relSchema() }) ) tableId = table._id! - isRelationship = relSchema().user.type === FieldType.LINK o2mData = [ await dataGenerator(o2mTable._id!), @@ -2755,19 +2753,8 @@ if (descriptions.length) { user: null, users: null, }) - expect(updatedRow).toEqual({ - name: "foo", - description: "bar", - tableId, - _id: row._id, - _rev: expect.any(String), - id: isInternal ? undefined : expect.any(Number), - type: isInternal ? "row" : undefined, - createdAt: isInternal ? new Date().toISOString() : undefined, - updatedAt: isInternal ? new Date().toISOString() : undefined, - users: isRelationship ? undefined : [], - user: isRelationship ? undefined : [], - }) + expect(updatedRow.user).toBeUndefined() + expect(updatedRow.users).toBeUndefined() }) it("fetch all will populate the relationships", async () => { diff --git a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts index b02ea2ff60..6c8ecc3167 100644 --- a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts +++ b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts @@ -153,10 +153,10 @@ export async function processOutputBBReference( } export async function processOutputBBReferences( - value: string | null | undefined, + value: string | string[] | null | undefined, subtype: BBReferenceFieldSubType ): Promise { - if (!value) { + if (!value || (Array.isArray(value) && value.length === 0)) { return undefined } const ids = From 1e01f0d7575b5d66f0b18338d80c4bcf626f6d8d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:03:58 +0100 Subject: [PATCH 32/53] Update yarn.lock --- yarn.lock | 102 ------------------------------------------------------ 1 file changed, 102 deletions(-) diff --git a/yarn.lock b/yarn.lock index ceebc9ebdf..70d3c2d4b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2483,13 +2483,6 @@ resolved "https://registry.yarnpkg.com/@datadog/libdatadog/-/libdatadog-0.2.2.tgz#ac02c76ac9a38250dca740727c7cdf00244ce3d3" integrity sha512-rTWo96mEPTY5UbtGoFj8/wY0uKSViJhsPg/Z6aoFWBFXQ8b45Ix2e/yvf92AAwrhG+gPLTxEqTXh3kef2dP8Ow== -"@datadog/native-appsec@8.1.1": - version "8.1.1" - resolved "https://registry.yarnpkg.com/@datadog/native-appsec/-/native-appsec-8.1.1.tgz#76aa34697e6ecbd3d9ef7e6938d3cdcfa689b1f3" - integrity sha512-mf+Ym/AzET4FeUTXOs8hz0uLOSsVIUnavZPUx8YoKWK5lKgR2L+CLfEzOpjBwgFpDgbV8I1/vyoGelgGpsMKHA== - dependencies: - node-gyp-build "^3.9.0" - "@datadog/native-appsec@8.3.0": version "8.3.0" resolved "https://registry.yarnpkg.com/@datadog/native-appsec/-/native-appsec-8.3.0.tgz#91afd89d18d386be4da8a1b0e04500f2f8b5eb66" @@ -2497,14 +2490,6 @@ dependencies: node-gyp-build "^3.9.0" -"@datadog/native-iast-rewriter@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@datadog/native-iast-rewriter/-/native-iast-rewriter-2.4.1.tgz#e8211f78c818906513fb96a549374da0382c7623" - integrity sha512-j3auTmyyn63e2y+SL28CGNy/l+jXQyh+pxqoGTacWaY5FW/dvo5nGQepAismgJ3qJ8VhQfVWRdxBSiT7wu9clw== - dependencies: - lru-cache "^7.14.0" - node-gyp-build "^4.5.0" - "@datadog/native-iast-rewriter@2.5.0": version "2.5.0" resolved "https://registry.yarnpkg.com/@datadog/native-iast-rewriter/-/native-iast-rewriter-2.5.0.tgz#b613defe86e78168f750d1f1662d4ffb3cf002e6" @@ -2513,13 +2498,6 @@ lru-cache "^7.14.0" node-gyp-build "^4.5.0" -"@datadog/native-iast-taint-tracking@3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@datadog/native-iast-taint-tracking/-/native-iast-taint-tracking-3.1.0.tgz#7b2ed7f8fad212d65e5ab03bcdea8b42a3051b2e" - integrity sha512-rw6qSjmxmu1yFHVvZLXFt/rVq2tUZXocNogPLB8n7MPpA0jijNGb109WokWw5ITImiW91GcGDuBW6elJDVKouQ== - dependencies: - node-gyp-build "^3.9.0" - "@datadog/native-iast-taint-tracking@3.2.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@datadog/native-iast-taint-tracking/-/native-iast-taint-tracking-3.2.0.tgz#9fb6823d82f934e12c06ea1baa7399ca80deb2ec" @@ -2527,14 +2505,6 @@ dependencies: node-gyp-build "^3.9.0" -"@datadog/native-metrics@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@datadog/native-metrics/-/native-metrics-2.0.0.tgz#65bf03313ee419956361e097551db36173e85712" - integrity sha512-YklGVwUtmKGYqFf1MNZuOHvTYdKuR4+Af1XkWcMD8BwOAjxmd9Z+97328rCOY8TFUJzlGUPaXzB8j2qgG/BMwA== - dependencies: - node-addon-api "^6.1.0" - node-gyp-build "^3.9.0" - "@datadog/native-metrics@^3.0.1": version "3.0.1" resolved "https://registry.yarnpkg.com/@datadog/native-metrics/-/native-metrics-3.0.1.tgz#dc276c93785c0377a048e316f23b7c8ff3acfa84" @@ -2543,17 +2513,6 @@ node-addon-api "^6.1.0" node-gyp-build "^3.9.0" -"@datadog/pprof@5.3.0": - version "5.3.0" - resolved "https://registry.yarnpkg.com/@datadog/pprof/-/pprof-5.3.0.tgz#c2f58d328ecced7f99887f1a559d7fe3aecb9219" - integrity sha512-53z2Q3K92T6Pf4vz4Ezh8kfkVEvLzbnVqacZGgcbkP//q0joFzO8q00Etw1S6NdnCX0XmX08ULaF4rUI5r14mw== - dependencies: - delay "^5.0.0" - node-gyp-build "<4.0" - p-limit "^3.1.0" - pprof-format "^2.1.0" - source-map "^0.7.4" - "@datadog/pprof@5.4.1": version "5.4.1" resolved "https://registry.yarnpkg.com/@datadog/pprof/-/pprof-5.4.1.tgz#08c9bcf5d8efb2eeafdfc9f5bb5402f79fb41266" @@ -3470,16 +3429,6 @@ resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796" integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== -"@jsep-plugin/assignment@^1.2.1": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@jsep-plugin/assignment/-/assignment-1.3.0.tgz#fcfc5417a04933f7ceee786e8ab498aa3ce2b242" - integrity sha512-VVgV+CXrhbMI3aSusQyclHkenWSAm95WaiKrMxRFam3JSUiIaQjoMIw2sEs/OX4XifnqeQUN4DYbJjlA8EfktQ== - -"@jsep-plugin/regex@^1.0.3": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@jsep-plugin/regex/-/regex-1.0.4.tgz#cb2fc423220fa71c609323b9ba7f7d344a755fcc" - integrity sha512-q7qL4Mgjs1vByCaTnDFcBnV9HS7GVPJX5vyVoCgZHNSC9rjwIlmbXG5sUuorR5ndfHAIlJ8pVStxvjXHbNvtUg== - "@koa/cors@5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@koa/cors/-/cors-5.0.0.tgz#0029b5f057fa0d0ae0e37dd2c89ece315a0daffd" @@ -9311,43 +9260,6 @@ dc-polyfill@^0.1.4: resolved "https://registry.yarnpkg.com/dc-polyfill/-/dc-polyfill-0.1.6.tgz#c2940fa68ffb24a7bf127cc6cfdd15b39f0e7f02" integrity sha512-UV33cugmCC49a5uWAApM+6Ev9ZdvIUMTrtCO9fj96TPGOQiea54oeO3tiEVdVeo3J9N2UdJEmbS4zOkkEA35uQ== -dd-trace@5.23.0: - version "5.23.0" - resolved "https://registry.yarnpkg.com/dd-trace/-/dd-trace-5.23.0.tgz#a0c11863406de440a6675648caf06e1d07d67ba8" - integrity sha512-nLvwSGpTMIk6S3sMSge6yFqqgqI573VgZc8MF31vl6K0ouJoE7OkVx9cmSVjS4CbSi525tcKq9z7tApsNLpVLQ== - dependencies: - "@datadog/native-appsec" "8.1.1" - "@datadog/native-iast-rewriter" "2.4.1" - "@datadog/native-iast-taint-tracking" "3.1.0" - "@datadog/native-metrics" "^2.0.0" - "@datadog/pprof" "5.3.0" - "@datadog/sketches-js" "^2.1.0" - "@opentelemetry/api" ">=1.0.0 <1.9.0" - "@opentelemetry/core" "^1.14.0" - crypto-randomuuid "^1.0.0" - dc-polyfill "^0.1.4" - ignore "^5.2.4" - import-in-the-middle "1.11.2" - int64-buffer "^0.1.9" - istanbul-lib-coverage "3.2.0" - jest-docblock "^29.7.0" - jsonpath-plus "^9.0.0" - koalas "^1.0.2" - limiter "1.1.5" - lodash.sortby "^4.7.0" - lru-cache "^7.14.0" - module-details-from-path "^1.0.3" - msgpack-lite "^0.1.26" - opentracing ">=0.12.1" - path-to-regexp "^0.1.10" - pprof-format "^2.1.0" - protobufjs "^7.2.5" - retry "^0.13.1" - rfdc "^1.3.1" - semver "^7.5.4" - shell-quote "^1.8.1" - tlhunter-sorted-set "^0.1.0" - dd-trace@5.26.0: version "5.26.0" resolved "https://registry.yarnpkg.com/dd-trace/-/dd-trace-5.26.0.tgz#cc55061f66742bf01d0d7dc9f75c0e4937c82f40" @@ -14100,11 +14012,6 @@ jsdom@^21.1.1: ws "^8.13.0" xml-name-validator "^4.0.0" -jsep@^1.3.8: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jsep/-/jsep-1.4.0.tgz#19feccbfa51d8a79f72480b4b8e40ce2e17152f0" - integrity sha512-B7qPcEVE3NVkmSJbaYxvv4cHkVW7DQsZz13pUMrfS8z8Q/BuShN+gcTXrUlPiGqM2/t/EEaI030bpxMqY8gMlw== - jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -14208,15 +14115,6 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== -jsonpath-plus@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/jsonpath-plus/-/jsonpath-plus-9.0.0.tgz#bb8703ee481531142bca8dee9a42fe72b8358a7f" - integrity sha512-bqE77VIDStrOTV/czspZhTn+o27Xx9ZJRGVkdVShEtPoqsIx5yALv3lWVU6y+PqYvWPJNWE7ORCQheQkEe0DDA== - dependencies: - "@jsep-plugin/assignment" "^1.2.1" - "@jsep-plugin/regex" "^1.0.3" - jsep "^1.3.8" - jsonschema@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.4.0.tgz#1afa34c4bc22190d8e42271ec17ac8b3404f87b2" From b8a2c4d6b3872a572eebe0e0e6d5af0448ce309a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:14:25 +0100 Subject: [PATCH 33/53] Lint --- packages/server/src/api/routes/tests/search.spec.ts | 1 - packages/server/src/middleware/zod-validator.ts | 4 ---- 2 files changed, 5 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 5edc4f29ad..5384444067 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -24,7 +24,6 @@ import { JsonFieldSubType, LogicalOperator, RelationshipType, - RequiredKeys, Row, RowSearchParams, SearchFilters, diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index f990ee0642..0ad346afc3 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -36,7 +36,3 @@ function validate(schema: AnyZodObject, property: "body" | "params") { export function validateBody(schema: AnyZodObject) { return validate(schema, "body") } - -// export function validateParams(schema: AnyZodObject) { -// return validate(schema, "params") -// } From 0cef937a14c5d40a8f663f7a1baf37aeaeafa217 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:15:19 +0100 Subject: [PATCH 34/53] Update deps --- packages/types/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/types/package.json b/packages/types/package.json index aa67a2e5b4..ae99d31838 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -20,10 +20,10 @@ "@types/redlock": "4.0.7", "rimraf": "3.0.2", "typescript": "5.5.2", - "koa-useragent": "^4.1.0" + "koa-useragent": "^4.1.0", + "zod": "^3.23.8" }, "dependencies": { - "scim-patch": "^0.8.1", - "zod": "^3.23.8" + "scim-patch": "^0.8.1" } } From ab00add0ff77d982bd6cedb279b2f04d8eafa87b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:23:03 +0100 Subject: [PATCH 35/53] Change to nullish --- packages/types/src/api/web/app/rows.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows.ts index 520983d353..cb213f4a1e 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows.ts @@ -78,11 +78,11 @@ const searchRowRequest = z.object({ }) .optional(), paginate: z.boolean().optional(), - bookmark: z.union([z.string(), z.number()]).nullable().optional(), + bookmark: z.union([z.string(), z.number()]).nullish(), limit: z.number().optional(), sort: z.string().optional(), sortOrder: z.nativeEnum(SortOrder).optional(), - sortType: z.nativeEnum(SortType).optional(), + sortType: z.nativeEnum(SortType).nullish(), version: z.string().optional(), disableEscaping: z.boolean().optional(), countRows: z.boolean().optional(), From 792388f1e10d98212fd36223f15ebaacbdbe1b52 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:23:46 +0100 Subject: [PATCH 36/53] Renames --- packages/types/src/api/web/app/{rows.ts => rows/index.ts} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename packages/types/src/api/web/app/{rows.ts => rows/index.ts} (96%) diff --git a/packages/types/src/api/web/app/rows.ts b/packages/types/src/api/web/app/rows/index.ts similarity index 96% rename from packages/types/src/api/web/app/rows.ts rename to packages/types/src/api/web/app/rows/index.ts index cb213f4a1e..001066d7fb 100644 --- a/packages/types/src/api/web/app/rows.ts +++ b/packages/types/src/api/web/app/rows/index.ts @@ -7,13 +7,13 @@ import { RangeOperator, SearchFilterKey, SearchFilters, -} from "../../../sdk" -import { Row } from "../../../documents" +} from "../../../../sdk" +import { Row } from "../../../../documents" import { PaginationResponse, SortOrder, SortType, -} from "../../../api/web/pagination" +} from "../../../../api/web/pagination" import { ReadStream } from "fs" import { z } from "zod" From e3e82f2fb84ddea121634a6e8ad28a15a467bc19 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:33:31 +0100 Subject: [PATCH 37/53] Move types --- packages/types/src/api/web/app/rows/index.ts | 104 +----------------- packages/types/src/api/web/app/rows/search.ts | 100 +++++++++++++++++ 2 files changed, 104 insertions(+), 100 deletions(-) create mode 100644 packages/types/src/api/web/app/rows/search.ts diff --git a/packages/types/src/api/web/app/rows/index.ts b/packages/types/src/api/web/app/rows/index.ts index 001066d7fb..2642a8b04e 100644 --- a/packages/types/src/api/web/app/rows/index.ts +++ b/packages/types/src/api/web/app/rows/index.ts @@ -1,21 +1,9 @@ -import { - ArrayOperator, - BasicOperator, - EmptyFilterOption, - InternalSearchFilterOperator, - LogicalOperator, - RangeOperator, - SearchFilterKey, - SearchFilters, -} from "../../../../sdk" +import { SearchFilters } from "../../../../sdk" import { Row } from "../../../../documents" -import { - PaginationResponse, - SortOrder, - SortType, -} from "../../../../api/web/pagination" +import { SortOrder } from "../../../../api/web/pagination" import { ReadStream } from "fs" -import { z } from "zod" + +export * from "./search" export interface SaveRowRequest extends Row {} @@ -27,90 +15,6 @@ export interface PatchRowRequest extends Row { export interface PatchRowResponse extends Row {} -const fieldKey = z - .string() - .refine(s => s !== InternalSearchFilterOperator.COMPLEX_ID_OPERATOR, { - message: `Key '${InternalSearchFilterOperator.COMPLEX_ID_OPERATOR}' is not allowed`, - }) - -const stringBasicFilter = z.record(fieldKey, z.string()) -const basicFilter = z.record(fieldKey, z.any()) -const arrayFilter = z.record(fieldKey, z.union([z.any().array(), z.string()])) -const logicFilter = z.lazy(() => - z.object({ - conditions: z.array(z.object(queryFilterValidation)), - }) -) - -const stringOrNumber = z.union([z.string(), z.number()]) - -const queryFilterValidation: Record = { - [BasicOperator.STRING]: stringBasicFilter.optional(), - [BasicOperator.FUZZY]: stringBasicFilter.optional(), - [RangeOperator.RANGE]: z - .record( - fieldKey, - z.union([ - z.object({ high: stringOrNumber, low: stringOrNumber }), - z.object({ high: stringOrNumber }), - z.object({ low: stringOrNumber }), - ]) - ) - .optional(), - [BasicOperator.EQUAL]: basicFilter.optional(), - [BasicOperator.NOT_EQUAL]: basicFilter.optional(), - [BasicOperator.EMPTY]: basicFilter.optional(), - [BasicOperator.NOT_EMPTY]: basicFilter.optional(), - [ArrayOperator.ONE_OF]: arrayFilter.optional(), - [ArrayOperator.CONTAINS]: arrayFilter.optional(), - [ArrayOperator.NOT_CONTAINS]: arrayFilter.optional(), - [ArrayOperator.CONTAINS_ANY]: arrayFilter.optional(), - [LogicalOperator.AND]: logicFilter.optional(), - [LogicalOperator.OR]: logicFilter.optional(), -} - -const searchRowRequest = z.object({ - query: z - .object({ - allOr: z.boolean().optional(), - onEmptyFilter: z.nativeEnum(EmptyFilterOption).optional(), - ...queryFilterValidation, - }) - .optional(), - paginate: z.boolean().optional(), - bookmark: z.union([z.string(), z.number()]).nullish(), - limit: z.number().optional(), - sort: z.string().optional(), - sortOrder: z.nativeEnum(SortOrder).optional(), - sortType: z.nativeEnum(SortType).nullish(), - version: z.string().optional(), - disableEscaping: z.boolean().optional(), - countRows: z.boolean().optional(), -}) -export const searchRowRequestValidator = searchRowRequest -export type SearchRowRequest = z.infer - -export interface SearchViewRowRequest - extends Pick< - SearchRowRequest, - | "sort" - | "sortOrder" - | "sortType" - | "limit" - | "bookmark" - | "paginate" - | "query" - | "countRows" - > {} - -export interface SearchRowResponse { - rows: any[] -} - -export interface PaginatedSearchRowResponse - extends SearchRowResponse, - PaginationResponse {} - export interface ExportRowsRequest { rows?: string[] columns?: string[] diff --git a/packages/types/src/api/web/app/rows/search.ts b/packages/types/src/api/web/app/rows/search.ts new file mode 100644 index 0000000000..b74e490677 --- /dev/null +++ b/packages/types/src/api/web/app/rows/search.ts @@ -0,0 +1,100 @@ +import { + ArrayOperator, + BasicOperator, + EmptyFilterOption, + InternalSearchFilterOperator, + LogicalOperator, + RangeOperator, + SearchFilterKey, +} from "../../../../sdk" +import { Row } from "../../../../documents" +import { + PaginationResponse, + SortOrder, + SortType, +} from "../../../../api/web/pagination" +import { z } from "zod" + +const fieldKey = z + .string() + .refine(s => s !== InternalSearchFilterOperator.COMPLEX_ID_OPERATOR, { + message: `Key '${InternalSearchFilterOperator.COMPLEX_ID_OPERATOR}' is not allowed`, + }) + +const stringBasicFilter = z.record(fieldKey, z.string()) +const basicFilter = z.record(fieldKey, z.any()) +const arrayFilter = z.record(fieldKey, z.union([z.any().array(), z.string()])) +const logicFilter = z.lazy(() => + z.object({ + conditions: z.array(z.object(queryFilterValidation)), + }) +) + +const stringOrNumber = z.union([z.string(), z.number()]) + +const queryFilterValidation: Record = { + [BasicOperator.STRING]: stringBasicFilter.optional(), + [BasicOperator.FUZZY]: stringBasicFilter.optional(), + [RangeOperator.RANGE]: z + .record( + fieldKey, + z.union([ + z.object({ high: stringOrNumber, low: stringOrNumber }), + z.object({ high: stringOrNumber }), + z.object({ low: stringOrNumber }), + ]) + ) + .optional(), + [BasicOperator.EQUAL]: basicFilter.optional(), + [BasicOperator.NOT_EQUAL]: basicFilter.optional(), + [BasicOperator.EMPTY]: basicFilter.optional(), + [BasicOperator.NOT_EMPTY]: basicFilter.optional(), + [ArrayOperator.ONE_OF]: arrayFilter.optional(), + [ArrayOperator.CONTAINS]: arrayFilter.optional(), + [ArrayOperator.NOT_CONTAINS]: arrayFilter.optional(), + [ArrayOperator.CONTAINS_ANY]: arrayFilter.optional(), + [LogicalOperator.AND]: logicFilter.optional(), + [LogicalOperator.OR]: logicFilter.optional(), +} + +const searchRowRequest = z.object({ + query: z + .object({ + allOr: z.boolean().optional(), + onEmptyFilter: z.nativeEnum(EmptyFilterOption).optional(), + ...queryFilterValidation, + }) + .optional(), + paginate: z.boolean().optional(), + bookmark: z.union([z.string(), z.number()]).nullish(), + limit: z.number().optional(), + sort: z.string().optional(), + sortOrder: z.nativeEnum(SortOrder).optional(), + sortType: z.nativeEnum(SortType).nullish(), + version: z.string().optional(), + disableEscaping: z.boolean().optional(), + countRows: z.boolean().optional(), +}) + +export const searchRowRequestValidator = searchRowRequest + +export type SearchRowRequest = z.infer +export type SearchViewRowRequest = Pick< + SearchRowRequest, + | "sort" + | "sortOrder" + | "sortType" + | "limit" + | "bookmark" + | "paginate" + | "query" + | "countRows" +> + +export interface SearchRowResponse { + rows: Row[] +} + +export interface PaginatedSearchRowResponse + extends SearchRowResponse, + PaginationResponse {} From 7ed45f71d273b1d12f6c377181a1c40d850a5d22 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:35:24 +0100 Subject: [PATCH 38/53] Fix type tests --- .../src/api/routes/tests/search.spec.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 5384444067..8ba165ded0 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -24,6 +24,7 @@ import { JsonFieldSubType, LogicalOperator, RelationshipType, + RequiredKeys, Row, RowSearchParams, SearchFilters, @@ -208,9 +209,25 @@ if (descriptions.length) { private async performSearch(): Promise> { if (isInMemory) { - return dataFilters.search(_.cloneDeep(rows), { - ...this.query, - }) + const inMemoryQuery: RequiredKeys< + Omit + > = { + sort: this.query.sort, + query: { ...this.query.query }, + paginate: this.query.paginate, + bookmark: this.query.bookmark ?? undefined, + limit: this.query.limit, + sortOrder: this.query.sortOrder, + sortType: this.query.sortType ?? undefined, + version: this.query.version, + disableEscaping: this.query.disableEscaping, + countRows: this.query.countRows, + viewId: undefined, + fields: undefined, + indexer: undefined, + rows: undefined, + } + return dataFilters.search(_.cloneDeep(rows), inMemoryQuery) } else { return config.api.row.search(tableOrViewId, this.query) } From 0501980e45c25ef0f13c3240fb6168abcec75532 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 28 Nov 2024 16:44:25 +0100 Subject: [PATCH 39/53] Fix types --- packages/server/src/api/controllers/row/index.ts | 2 +- packages/server/src/api/controllers/row/views.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index fbaf9f8462..2dc9381183 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -260,7 +260,7 @@ export async function search(ctx: Ctx) { limit: searchRequest.limit, sort: searchRequest.sort, sortOrder: searchRequest.sortOrder, - sortType: searchRequest.sortType, + sortType: searchRequest.sortType ?? undefined, countRows: searchRequest.countRows, version: searchRequest.version, disableEscaping: searchRequest.disableEscaping, diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index eb010fee98..0655a3b38f 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -57,7 +57,7 @@ function getSortOptions(request: SearchViewRowRequest, view: ViewV2) { return { sort: request.sort, sortOrder: request.sortOrder, - sortType: request.sortType, + sortType: request.sortType ?? undefined, } } if (view.sort) { From bcd8bcdc1c9e1446148d9dc76e024e3ae3508adf Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 28 Nov 2024 17:17:29 +0000 Subject: [PATCH 40/53] Fixing issue detected by test. --- packages/server/src/api/controllers/row/staticFormula.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index ff2381e61c..4464b7f44a 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -179,6 +179,7 @@ export async function finaliseRow( throw new Error(`Unable to retrieve row ${row._id} after saving.`) } + delete enrichedRow._rev enrichedRow = mergeRows(retrieved, enrichedRow) enrichedRow = await processFormulas(table, enrichedRow, { dynamic: false, From 6f8f866b7e39761ad96f5ecf4036dc651c507979 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Thu, 28 Nov 2024 23:37:20 +0530 Subject: [PATCH 41/53] fix: loop context lost when max iterations are reached. Add/test cases for the same --- .../tests/scenarios/looping.spec.ts | 38 +++++++++++++++++++ packages/server/src/constants/index.ts | 1 - packages/server/src/threads/automation.ts | 20 +++------- .../documents/app/automation/automation.ts | 1 + 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/packages/server/src/automations/tests/scenarios/looping.spec.ts b/packages/server/src/automations/tests/scenarios/looping.spec.ts index 9c5313e9da..66614e716a 100644 --- a/packages/server/src/automations/tests/scenarios/looping.spec.ts +++ b/packages/server/src/automations/tests/scenarios/looping.spec.ts @@ -152,6 +152,44 @@ describe("Loop automations", () => { ) }) + it("ensure the loop stops if the max iterations are reached", async () => { + const builder = createAutomationBuilder({ + name: "Test Loop max iterations", + }) + + const results = await builder + .appAction({ fields: {} }) + .loop({ + option: LoopStepType.ARRAY, + binding: ["test", "test2", "test3"], + iterations: 2, + }) + .serverLog({ text: "{{loop.currentItem}}" }) + .serverLog({ text: "{{steps.1.iterations}}" }) + .run() + + expect(results.steps[1].outputs.iterations).toBe(2) + }) + + it("should run an automation with loop and max iterations to ensure context correctness further down the tree", async () => { + const builder = createAutomationBuilder({ + name: "Test context down tree with Loop and max iterations", + }) + + const results = await builder + .appAction({ fields: {} }) + .loop({ + option: LoopStepType.ARRAY, + binding: ["test", "test2", "test3"], + iterations: 2, + }) + .serverLog({ text: "{{loop.currentItem}}" }) + .serverLog({ text: "{{steps.1.iterations}}" }) + .run() + + expect(results.steps[2].outputs.message).toContain("- 2") + }) + it("should run an automation where a loop is successfully run twice", async () => { const builder = createAutomationBuilder({ name: "Test Trigger with Loop and Create Row", diff --git a/packages/server/src/constants/index.ts b/packages/server/src/constants/index.ts index 604a81cd9f..89e2f26516 100644 --- a/packages/server/src/constants/index.ts +++ b/packages/server/src/constants/index.ts @@ -137,7 +137,6 @@ export enum InvalidColumns { export enum AutomationErrors { INCORRECT_TYPE = "INCORRECT_TYPE", - MAX_ITERATIONS = "MAX_ITERATIONS_REACHED", FAILURE_CONDITION = "FAILURE_CONDITION_MET", } diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 33e11a6ac0..051b485a54 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -392,6 +392,7 @@ class Orchestrator { let iterationCount = 0 let shouldCleanup = true + let reachedMaxIterations = false for (let loopStepIndex = 0; loopStepIndex < iterations; loopStepIndex++) { try { @@ -419,19 +420,8 @@ class Orchestrator { loopStepIndex === env.AUTOMATION_MAX_ITERATIONS || (loopStep.inputs.iterations && loopStepIndex === maxIterations) ) { - this.updateContextAndOutput( - pathStepIdx + 1, - steps[stepToLoopIndex], - { - items: this.loopStepOutputs, - iterations: loopStepIndex, - }, - { - status: AutomationErrors.MAX_ITERATIONS, - success: true, - } - ) - shouldCleanup = false + reachedMaxIterations = true + shouldCleanup = true break } @@ -480,7 +470,9 @@ class Orchestrator { success: true, } : { - success: true, + success: reachedMaxIterations + ? AutomationStepStatus.MAX_ITERATIONS + : true, items: this.loopStepOutputs, iterations: iterationCount, } diff --git a/packages/types/src/documents/app/automation/automation.ts b/packages/types/src/documents/app/automation/automation.ts index 1af892d8d1..71530c7939 100644 --- a/packages/types/src/documents/app/automation/automation.ts +++ b/packages/types/src/documents/app/automation/automation.ts @@ -174,6 +174,7 @@ export enum AutomationFeature { export enum AutomationStepStatus { NO_ITERATIONS = "no_iterations", + MAX_ITERATIONS = "max_iterations_reached", } export enum AutomationStatus { From 26f2c69fb94e8fdb065000983dc94f65253a610d Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Fri, 29 Nov 2024 15:30:20 +0530 Subject: [PATCH 42/53] fix PR comment for keeping status boolean and adding status conditionally --- packages/server/src/threads/automation.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 051b485a54..7e8f947580 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -470,13 +470,15 @@ class Orchestrator { success: true, } : { - success: reachedMaxIterations - ? AutomationStepStatus.MAX_ITERATIONS - : true, + success: true, items: this.loopStepOutputs, iterations: iterationCount, } + if (reachedMaxIterations && iterations !== 0) { + tempOutput.status = AutomationStepStatus.MAX_ITERATIONS + } + // Loop Step clean up this.executionOutput.steps.splice(pathStepIdx, 0, { id: steps[stepToLoopIndex].id, From a6022c11a5e1ab2826b4950d5fa23b2ef083e06f Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Fri, 29 Nov 2024 16:52:55 +0530 Subject: [PATCH 43/53] fix loop not counting as step, test case failing --- .../server/src/automations/tests/scenarios/looping.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/automations/tests/scenarios/looping.spec.ts b/packages/server/src/automations/tests/scenarios/looping.spec.ts index 66614e716a..0baa69b3bc 100644 --- a/packages/server/src/automations/tests/scenarios/looping.spec.ts +++ b/packages/server/src/automations/tests/scenarios/looping.spec.ts @@ -168,7 +168,7 @@ describe("Loop automations", () => { .serverLog({ text: "{{steps.1.iterations}}" }) .run() - expect(results.steps[1].outputs.iterations).toBe(2) + expect(results.steps[0].outputs.iterations).toBe(2) }) it("should run an automation with loop and max iterations to ensure context correctness further down the tree", async () => { @@ -187,7 +187,7 @@ describe("Loop automations", () => { .serverLog({ text: "{{steps.1.iterations}}" }) .run() - expect(results.steps[2].outputs.message).toContain("- 2") + expect(results.steps[1].outputs.message).toContain("- 2") }) it("should run an automation where a loop is successfully run twice", async () => { From b48f2d83bad0082915cc0ea6c4a94ebf24a2f89a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 12:31:26 +0100 Subject: [PATCH 44/53] Add flag --- packages/types/src/sdk/featureFlag.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts index 64a7362e9f..387b7e884a 100644 --- a/packages/types/src/sdk/featureFlag.ts +++ b/packages/types/src/sdk/featureFlag.ts @@ -4,8 +4,8 @@ export enum FeatureFlag { AUTOMATION_BRANCHING = "AUTOMATION_BRANCHING", AI_CUSTOM_CONFIGS = "AI_CUSTOM_CONFIGS", DEFAULT_VALUES = "DEFAULT_VALUES", - BUDIBASE_AI = "BUDIBASE_AI", + USE_ZOD_VALIDATOR = "USE_ZOD_VALIDATOR", } export interface TenantFeatureFlags { From 0ea5117a295cd6afd25cfcc0619149389da2f0f9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:04:09 +0100 Subject: [PATCH 45/53] Use record to provide typings --- packages/backend-core/src/features/features.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/features/features.ts b/packages/backend-core/src/features/features.ts index b3f016e88a..7f53f9b7d3 100644 --- a/packages/backend-core/src/features/features.ts +++ b/packages/backend-core/src/features/features.ts @@ -266,12 +266,13 @@ export class FlagSet, T extends { [key: string]: V }> { // new flag, add it here and use the `fetch` and `get` functions to access it. // All of the machinery in this file is to make sure that flags have their // default values set correctly and their types flow through the system. -export const flags = new FlagSet({ +const flagsConfig: Record> = { [FeatureFlag.DEFAULT_VALUES]: Flag.boolean(true), [FeatureFlag.AUTOMATION_BRANCHING]: Flag.boolean(true), [FeatureFlag.AI_CUSTOM_CONFIGS]: Flag.boolean(true), [FeatureFlag.BUDIBASE_AI]: Flag.boolean(true), -}) +} +export const flags = new FlagSet(flagsConfig) type UnwrapPromise = T extends Promise ? U : T export type FeatureFlags = UnwrapPromise> From 40f50710e56e442aca5b581bc749d33f262bebe5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 12:54:34 +0100 Subject: [PATCH 46/53] Clean old flags --- packages/types/src/sdk/featureFlag.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts index 387b7e884a..98e744324c 100644 --- a/packages/types/src/sdk/featureFlag.ts +++ b/packages/types/src/sdk/featureFlag.ts @@ -1,6 +1,4 @@ export enum FeatureFlag { - PER_CREATOR_PER_USER_PRICE = "PER_CREATOR_PER_USER_PRICE", - PER_CREATOR_PER_USER_PRICE_ALERT = "PER_CREATOR_PER_USER_PRICE_ALERT", AUTOMATION_BRANCHING = "AUTOMATION_BRANCHING", AI_CUSTOM_CONFIGS = "AI_CUSTOM_CONFIGS", DEFAULT_VALUES = "DEFAULT_VALUES", From 96916a469d112a19fe9b9a39d7620d0523b7bdec Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:05:03 +0100 Subject: [PATCH 47/53] Configure flag --- packages/backend-core/src/features/features.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/backend-core/src/features/features.ts b/packages/backend-core/src/features/features.ts index 7f53f9b7d3..650254fcb2 100644 --- a/packages/backend-core/src/features/features.ts +++ b/packages/backend-core/src/features/features.ts @@ -271,6 +271,7 @@ const flagsConfig: Record> = { [FeatureFlag.AUTOMATION_BRANCHING]: Flag.boolean(true), [FeatureFlag.AI_CUSTOM_CONFIGS]: Flag.boolean(true), [FeatureFlag.BUDIBASE_AI]: Flag.boolean(true), + [FeatureFlag.USE_ZOD_VALIDATOR]: Flag.boolean(env.isDev()), } export const flags = new FlagSet(flagsConfig) From ccbf282c69ef4f4373de6a54513d60c94f3e7f30 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:07:24 +0100 Subject: [PATCH 48/53] Flag zod --- packages/server/src/middleware/zod-validator.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index 0ad346afc3..e8cc2c470a 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -1,11 +1,16 @@ -import { Ctx } from "@budibase/types" +import { features } from "@budibase/backend-core" +import { Ctx, FeatureFlag } from "@budibase/types" import { AnyZodObject } from "zod" import { fromZodError } from "zod-validation-error" function validate(schema: AnyZodObject, property: "body" | "params") { // Return a Koa middleware function - return (ctx: Ctx, next: any) => { + return async (ctx: Ctx, next: any) => { + if (!(await features.flags.isEnabled(FeatureFlag.USE_ZOD_VALIDATOR))) { + return next() + } + if (!schema) { return next() } From a2f1977376762889ab9bee6c57611bd4650d3e85 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:12:30 +0100 Subject: [PATCH 49/53] Add validation for search view --- packages/server/src/api/routes/row.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index fc09b8c81d..61cdee0c2f 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -90,6 +90,7 @@ router router.post( "/api/v2/views/:viewId/search", internalSearchValidator(), + validateBody(searchRowRequestValidator), authorizedResource(PermissionType.VIEW, PermissionLevel.READ, "viewId"), rowController.views.searchView ) From 26be5740857eb2475fa7d51760494dbe201720d8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:15:32 +0100 Subject: [PATCH 50/53] Fix nullish --- packages/types/src/api/web/app/rows/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/api/web/app/rows/search.ts b/packages/types/src/api/web/app/rows/search.ts index b74e490677..7ba23bceca 100644 --- a/packages/types/src/api/web/app/rows/search.ts +++ b/packages/types/src/api/web/app/rows/search.ts @@ -68,7 +68,7 @@ const searchRowRequest = z.object({ paginate: z.boolean().optional(), bookmark: z.union([z.string(), z.number()]).nullish(), limit: z.number().optional(), - sort: z.string().optional(), + sort: z.string().nullish(), sortOrder: z.nativeEnum(SortOrder).optional(), sortType: z.nativeEnum(SortType).nullish(), version: z.string().optional(), From 57c466366360b034d5b59fe4fc346e7e18e44d87 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:49:43 +0100 Subject: [PATCH 51/53] Fix types --- packages/server/src/api/controllers/row/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 2dc9381183..cc5491e54f 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -258,7 +258,7 @@ export async function search(ctx: Ctx) { bookmark: searchRequest.bookmark ?? undefined, paginate: searchRequest.paginate, limit: searchRequest.limit, - sort: searchRequest.sort, + sort: searchRequest.sort ?? undefined, sortOrder: searchRequest.sortOrder, sortType: searchRequest.sortType ?? undefined, countRows: searchRequest.countRows, From a2730279d4e82a33496d4b60515e1d25356725d4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:51:31 +0100 Subject: [PATCH 52/53] Fix types --- packages/server/src/api/routes/tests/search.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 8ba165ded0..c66197334e 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -212,7 +212,7 @@ if (descriptions.length) { const inMemoryQuery: RequiredKeys< Omit > = { - sort: this.query.sort, + sort: this.query.sort ?? undefined, query: { ...this.query.query }, paginate: this.query.paginate, bookmark: this.query.bookmark ?? undefined, From 39859e10ed32c8c25f0f540087b858be18a3b135 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Fri, 29 Nov 2024 13:12:13 +0000 Subject: [PATCH 53/53] Don't fetch account for identifyTenantGroup posthog event (#15092) * Don't fetch account for identifyTenantGroup posthog event * Support self hosted * Fix types --- .../backend-core/src/events/identification.ts | 16 +--------------- .../src/migrations/functions/backfill/global.ts | 9 +++++---- .../worker/src/api/controllers/global/users.ts | 13 +++++-------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/packages/backend-core/src/events/identification.ts b/packages/backend-core/src/events/identification.ts index 69bf7009b2..6117f4b485 100644 --- a/packages/backend-core/src/events/identification.ts +++ b/packages/backend-core/src/events/identification.ts @@ -121,7 +121,7 @@ const identifyInstallationGroup = async ( const identifyTenantGroup = async ( tenantId: string, - account: Account | undefined, + hosting: Hosting, timestamp?: string | number ): Promise => { const id = await getEventTenantId(tenantId) @@ -129,26 +129,12 @@ const identifyTenantGroup = async ( const installationId = await getInstallationId() const environment = getDeploymentEnvironment() - let hosting: Hosting - let profession: string | undefined - let companySize: string | undefined - - if (account) { - profession = account.profession - companySize = account.size - hosting = account.hosting - } else { - hosting = getHostingFromEnv() - } - const group: TenantGroup = { id, type, hosting, environment, installationId, - profession, - companySize, } await identifyGroup(group, timestamp) diff --git a/packages/server/src/migrations/functions/backfill/global.ts b/packages/server/src/migrations/functions/backfill/global.ts index a56c92492b..7f718cee2f 100644 --- a/packages/server/src/migrations/functions/backfill/global.ts +++ b/packages/server/src/migrations/functions/backfill/global.ts @@ -9,11 +9,12 @@ import { db as dbUtils, } from "@budibase/backend-core" import { - QuotaUsage, - CloudAccount, App, - TenantBackfillSucceededEvent, + CloudAccount, Event, + Hosting, + QuotaUsage, + TenantBackfillSucceededEvent, User, } from "@budibase/types" import env from "../../../environment" @@ -125,7 +126,7 @@ export const run = async (db: any) => { try { await events.identification.identifyTenantGroup( tenantId, - account, + env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD, timestamp ) } catch (e) { diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts index 2479a50d9e..e977d5ff5d 100644 --- a/packages/worker/src/api/controllers/global/users.ts +++ b/packages/worker/src/api/controllers/global/users.ts @@ -6,12 +6,12 @@ import { AddSSoUserRequest, BulkUserRequest, BulkUserResponse, - CloudAccount, CreateAdminUserRequest, CreateAdminUserResponse, Ctx, DeleteInviteUserRequest, DeleteInviteUsersRequest, + Hosting, InviteUserRequest, InviteUsersRequest, InviteUsersResponse, @@ -26,7 +26,6 @@ import { UserIdentifier, } from "@budibase/types" import { - accounts, users, cache, ErrorCode, @@ -192,12 +191,10 @@ export const adminUser = async ( lastName: familyName, }) - // events - let account: CloudAccount | undefined - if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { - account = await accounts.getAccountByTenantId(tenantId) - } - await events.identification.identifyTenantGroup(tenantId, account) + await events.identification.identifyTenantGroup( + tenantId, + env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD + ) ctx.body = { _id: finalUser._id!,