diff --git a/lerna.json b/lerna.json index be757c1319..a22eb8a4cf 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/.gitignore b/packages/backend-core/.gitignore similarity index 100% rename from packages/auth/.gitignore rename to packages/backend-core/.gitignore diff --git a/packages/auth/LICENSE b/packages/backend-core/LICENSE similarity index 100% rename from packages/auth/LICENSE rename to packages/backend-core/LICENSE diff --git a/packages/auth/README.md b/packages/backend-core/README.md similarity index 78% rename from packages/auth/README.md rename to packages/backend-core/README.md index 4c6a474b5b..f36f80f84d 100644 --- a/packages/auth/README.md +++ b/packages/backend-core/README.md @@ -4,7 +4,7 @@ This library contains core functionality, like auth and security features which are shared between backend services. #### Note about top level JS files -For the purposes of being able to do say `require("@budibase/auth/permissions")` we need to +For the purposes of being able to do say `require("@budibase/backend-core/permissions")` we need to specify the exports at the top-level of the module. For these files they should be limited to a single `require` of the file that should diff --git a/packages/auth/accounts.js b/packages/backend-core/accounts.js similarity index 100% rename from packages/auth/accounts.js rename to packages/backend-core/accounts.js diff --git a/packages/auth/cache.js b/packages/backend-core/cache.js similarity index 100% rename from packages/auth/cache.js rename to packages/backend-core/cache.js diff --git a/packages/auth/constants.js b/packages/backend-core/constants.js similarity index 100% rename from packages/auth/constants.js rename to packages/backend-core/constants.js diff --git a/packages/auth/db.js b/packages/backend-core/db.js similarity index 100% rename from packages/auth/db.js rename to packages/backend-core/db.js diff --git a/packages/auth/deprovision.js b/packages/backend-core/deprovision.js similarity index 100% rename from packages/auth/deprovision.js rename to packages/backend-core/deprovision.js diff --git a/packages/auth/package.json b/packages/backend-core/package.json similarity index 87% rename from packages/auth/package.json rename to packages/backend-core/package.json index dd87412c3f..7d2db8ae98 100644 --- a/packages/auth/package.json +++ b/packages/backend-core/package.json @@ -1,7 +1,7 @@ { - "name": "@budibase/auth", - "version": "1.0.27-alpha.8", - "description": "Authentication middlewares for budibase builder and apps", + "name": "@budibase/backend-core", + "version": "1.0.27-alpha.12", + "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", "license": "GPL-3.0", diff --git a/packages/auth/permissions.js b/packages/backend-core/permissions.js similarity index 100% rename from packages/auth/permissions.js rename to packages/backend-core/permissions.js diff --git a/packages/auth/redis.js b/packages/backend-core/redis.js similarity index 100% rename from packages/auth/redis.js rename to packages/backend-core/redis.js diff --git a/packages/auth/roles.js b/packages/backend-core/roles.js similarity index 100% rename from packages/auth/roles.js rename to packages/backend-core/roles.js diff --git a/packages/auth/scripts/jestSetup.js b/packages/backend-core/scripts/jestSetup.js similarity index 100% rename from packages/auth/scripts/jestSetup.js rename to packages/backend-core/scripts/jestSetup.js diff --git a/packages/auth/sessions.js b/packages/backend-core/sessions.js similarity index 100% rename from packages/auth/sessions.js rename to packages/backend-core/sessions.js diff --git a/packages/auth/src/cache/appMetadata.js b/packages/backend-core/src/cache/appMetadata.js similarity index 100% rename from packages/auth/src/cache/appMetadata.js rename to packages/backend-core/src/cache/appMetadata.js diff --git a/packages/auth/src/cache/user.js b/packages/backend-core/src/cache/user.js similarity index 100% rename from packages/auth/src/cache/user.js rename to packages/backend-core/src/cache/user.js diff --git a/packages/auth/src/cloud/accounts.js b/packages/backend-core/src/cloud/accounts.js similarity index 100% rename from packages/auth/src/cloud/accounts.js rename to packages/backend-core/src/cloud/accounts.js diff --git a/packages/auth/src/cloud/api.js b/packages/backend-core/src/cloud/api.js similarity index 100% rename from packages/auth/src/cloud/api.js rename to packages/backend-core/src/cloud/api.js diff --git a/packages/auth/src/constants.js b/packages/backend-core/src/constants.js similarity index 100% rename from packages/auth/src/constants.js rename to packages/backend-core/src/constants.js diff --git a/packages/auth/src/db/Replication.js b/packages/backend-core/src/db/Replication.js similarity index 100% rename from packages/auth/src/db/Replication.js rename to packages/backend-core/src/db/Replication.js diff --git a/packages/auth/src/db/constants.js b/packages/backend-core/src/db/constants.js similarity index 100% rename from packages/auth/src/db/constants.js rename to packages/backend-core/src/db/constants.js diff --git a/packages/auth/src/db/index.js b/packages/backend-core/src/db/index.js similarity index 100% rename from packages/auth/src/db/index.js rename to packages/backend-core/src/db/index.js diff --git a/packages/auth/src/db/utils.js b/packages/backend-core/src/db/utils.js similarity index 100% rename from packages/auth/src/db/utils.js rename to packages/backend-core/src/db/utils.js diff --git a/packages/auth/src/db/views.js b/packages/backend-core/src/db/views.js similarity index 100% rename from packages/auth/src/db/views.js rename to packages/backend-core/src/db/views.js diff --git a/packages/auth/src/environment.js b/packages/backend-core/src/environment.js similarity index 100% rename from packages/auth/src/environment.js rename to packages/backend-core/src/environment.js diff --git a/packages/auth/src/hashing.js b/packages/backend-core/src/hashing.js similarity index 100% rename from packages/auth/src/hashing.js rename to packages/backend-core/src/hashing.js diff --git a/packages/auth/src/helpers.js b/packages/backend-core/src/helpers.js similarity index 100% rename from packages/auth/src/helpers.js rename to packages/backend-core/src/helpers.js diff --git a/packages/auth/src/index.js b/packages/backend-core/src/index.js similarity index 100% rename from packages/auth/src/index.js rename to packages/backend-core/src/index.js diff --git a/packages/auth/src/middleware/appTenancy.js b/packages/backend-core/src/middleware/appTenancy.js similarity index 100% rename from packages/auth/src/middleware/appTenancy.js rename to packages/backend-core/src/middleware/appTenancy.js diff --git a/packages/auth/src/middleware/auditLog.js b/packages/backend-core/src/middleware/auditLog.js similarity index 100% rename from packages/auth/src/middleware/auditLog.js rename to packages/backend-core/src/middleware/auditLog.js diff --git a/packages/auth/src/middleware/authenticated.js b/packages/backend-core/src/middleware/authenticated.js similarity index 100% rename from packages/auth/src/middleware/authenticated.js rename to packages/backend-core/src/middleware/authenticated.js diff --git a/packages/auth/src/middleware/index.js b/packages/backend-core/src/middleware/index.js similarity index 100% rename from packages/auth/src/middleware/index.js rename to packages/backend-core/src/middleware/index.js diff --git a/packages/auth/src/middleware/matchers.js b/packages/backend-core/src/middleware/matchers.js similarity index 100% rename from packages/auth/src/middleware/matchers.js rename to packages/backend-core/src/middleware/matchers.js diff --git a/packages/auth/src/middleware/passport/google.js b/packages/backend-core/src/middleware/passport/google.js similarity index 100% rename from packages/auth/src/middleware/passport/google.js rename to packages/backend-core/src/middleware/passport/google.js diff --git a/packages/auth/src/middleware/passport/jwt.js b/packages/backend-core/src/middleware/passport/jwt.js similarity index 100% rename from packages/auth/src/middleware/passport/jwt.js rename to packages/backend-core/src/middleware/passport/jwt.js diff --git a/packages/auth/src/middleware/passport/local.js b/packages/backend-core/src/middleware/passport/local.js similarity index 100% rename from packages/auth/src/middleware/passport/local.js rename to packages/backend-core/src/middleware/passport/local.js diff --git a/packages/auth/src/middleware/passport/oidc.js b/packages/backend-core/src/middleware/passport/oidc.js similarity index 100% rename from packages/auth/src/middleware/passport/oidc.js rename to packages/backend-core/src/middleware/passport/oidc.js diff --git a/packages/auth/src/middleware/passport/tests/google.spec.js b/packages/backend-core/src/middleware/passport/tests/google.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/google.spec.js rename to packages/backend-core/src/middleware/passport/tests/google.spec.js diff --git a/packages/auth/src/middleware/passport/tests/oidc.spec.js b/packages/backend-core/src/middleware/passport/tests/oidc.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/oidc.spec.js rename to packages/backend-core/src/middleware/passport/tests/oidc.spec.js diff --git a/packages/auth/src/middleware/passport/tests/third-party-common.spec.js b/packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/third-party-common.spec.js rename to packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js diff --git a/packages/auth/src/middleware/passport/tests/utilities/mock-data.js b/packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js similarity index 100% rename from packages/auth/src/middleware/passport/tests/utilities/mock-data.js rename to packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js diff --git a/packages/auth/src/middleware/passport/third-party-common.js b/packages/backend-core/src/middleware/passport/third-party-common.js similarity index 100% rename from packages/auth/src/middleware/passport/third-party-common.js rename to packages/backend-core/src/middleware/passport/third-party-common.js diff --git a/packages/auth/src/middleware/passport/utils.js b/packages/backend-core/src/middleware/passport/utils.js similarity index 100% rename from packages/auth/src/middleware/passport/utils.js rename to packages/backend-core/src/middleware/passport/utils.js diff --git a/packages/auth/src/middleware/tenancy.js b/packages/backend-core/src/middleware/tenancy.js similarity index 100% rename from packages/auth/src/middleware/tenancy.js rename to packages/backend-core/src/middleware/tenancy.js diff --git a/packages/auth/src/migrations/index.js b/packages/backend-core/src/migrations/index.js similarity index 100% rename from packages/auth/src/migrations/index.js rename to packages/backend-core/src/migrations/index.js diff --git a/packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap b/packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap similarity index 100% rename from packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap rename to packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap diff --git a/packages/auth/src/migrations/tests/index.spec.js b/packages/backend-core/src/migrations/tests/index.spec.js similarity index 100% rename from packages/auth/src/migrations/tests/index.spec.js rename to packages/backend-core/src/migrations/tests/index.spec.js diff --git a/packages/auth/src/objectStore/index.js b/packages/backend-core/src/objectStore/index.js similarity index 100% rename from packages/auth/src/objectStore/index.js rename to packages/backend-core/src/objectStore/index.js diff --git a/packages/auth/src/objectStore/utils.js b/packages/backend-core/src/objectStore/utils.js similarity index 100% rename from packages/auth/src/objectStore/utils.js rename to packages/backend-core/src/objectStore/utils.js diff --git a/packages/auth/src/redis/authRedis.js b/packages/backend-core/src/redis/authRedis.js similarity index 100% rename from packages/auth/src/redis/authRedis.js rename to packages/backend-core/src/redis/authRedis.js diff --git a/packages/auth/src/redis/index.js b/packages/backend-core/src/redis/index.js similarity index 100% rename from packages/auth/src/redis/index.js rename to packages/backend-core/src/redis/index.js diff --git a/packages/auth/src/redis/utils.js b/packages/backend-core/src/redis/utils.js similarity index 100% rename from packages/auth/src/redis/utils.js rename to packages/backend-core/src/redis/utils.js diff --git a/packages/auth/src/security/permissions.js b/packages/backend-core/src/security/permissions.js similarity index 100% rename from packages/auth/src/security/permissions.js rename to packages/backend-core/src/security/permissions.js diff --git a/packages/auth/src/security/roles.js b/packages/backend-core/src/security/roles.js similarity index 100% rename from packages/auth/src/security/roles.js rename to packages/backend-core/src/security/roles.js diff --git a/packages/auth/src/security/sessions.js b/packages/backend-core/src/security/sessions.js similarity index 100% rename from packages/auth/src/security/sessions.js rename to packages/backend-core/src/security/sessions.js diff --git a/packages/auth/src/tenancy/FunctionContext.js b/packages/backend-core/src/tenancy/FunctionContext.js similarity index 100% rename from packages/auth/src/tenancy/FunctionContext.js rename to packages/backend-core/src/tenancy/FunctionContext.js diff --git a/packages/auth/src/tenancy/context.js b/packages/backend-core/src/tenancy/context.js similarity index 100% rename from packages/auth/src/tenancy/context.js rename to packages/backend-core/src/tenancy/context.js diff --git a/packages/auth/src/tenancy/deprovision.js b/packages/backend-core/src/tenancy/deprovision.js similarity index 100% rename from packages/auth/src/tenancy/deprovision.js rename to packages/backend-core/src/tenancy/deprovision.js diff --git a/packages/auth/src/tenancy/index.js b/packages/backend-core/src/tenancy/index.js similarity index 100% rename from packages/auth/src/tenancy/index.js rename to packages/backend-core/src/tenancy/index.js diff --git a/packages/auth/src/tenancy/tenancy.js b/packages/backend-core/src/tenancy/tenancy.js similarity index 100% rename from packages/auth/src/tenancy/tenancy.js rename to packages/backend-core/src/tenancy/tenancy.js diff --git a/packages/auth/src/tests/utilities/db.js b/packages/backend-core/src/tests/utilities/db.js similarity index 100% rename from packages/auth/src/tests/utilities/db.js rename to packages/backend-core/src/tests/utilities/db.js diff --git a/packages/auth/src/tests/utilities/dbConfig.js b/packages/backend-core/src/tests/utilities/dbConfig.js similarity index 100% rename from packages/auth/src/tests/utilities/dbConfig.js rename to packages/backend-core/src/tests/utilities/dbConfig.js diff --git a/packages/auth/src/utils.js b/packages/backend-core/src/utils.js similarity index 100% rename from packages/auth/src/utils.js rename to packages/backend-core/src/utils.js diff --git a/packages/auth/tenancy.js b/packages/backend-core/tenancy.js similarity index 100% rename from packages/auth/tenancy.js rename to packages/backend-core/tenancy.js diff --git a/packages/auth/yarn.lock b/packages/backend-core/yarn.lock similarity index 100% rename from packages/auth/yarn.lock rename to packages/backend-core/yarn.lock diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 996d8f677f..57c8f36d73 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/bbui/yarn.lock b/packages/bbui/yarn.lock index a102e6c148..42c88af5a4 100644 --- a/packages/bbui/yarn.lock +++ b/packages/bbui/yarn.lock @@ -2076,9 +2076,9 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.27: supports-color "^6.1.0" postcss@^8.2.9: - version "8.2.10" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.10.tgz#ca7a042aa8aff494b334d0ff3e9e77079f6f702b" - integrity sha512-b/h7CPV7QEdrqIxtAf2j31U5ef05uBDuvoXv6L51Q4rcS1jdlXAVKJv+atCFdUXYl9dyTHGyoMzIepwowRJjFw== + version "8.2.13" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.13.tgz#dbe043e26e3c068e45113b1ed6375d2d37e2129f" + integrity sha512-FCE5xLH+hjbzRdpbRb1IMCvPv9yZx2QnDarBEYSN0N0HYk+TcXsEhwdFcFb+SRWOKzKGErhIEbBK2ogyLdTtfQ== dependencies: colorette "^1.2.2" nanoid "^3.1.22" diff --git a/packages/builder/package.json b/packages/builder/package.json index 33e91091ba..809db0a5e0 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.27-alpha.8", - "@budibase/client": "^1.0.27-alpha.8", + "@budibase/bbui": "^1.0.27-alpha.12", + "@budibase/client": "^1.0.27-alpha.12", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.27-alpha.8", + "@budibase/string-templates": "^1.0.27-alpha.12", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 7f379ba138..fe94b7e63f 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -9,6 +9,7 @@ Modal, Button, StatusLight, + ActionButton, } from "@budibase/bbui" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" @@ -27,7 +28,7 @@ let blockComplete $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( - step => step.stepId === block.stepId + step => (block.id ? step.id === block.id : step.stepId === block.stepId) ) $: isTrigger = block.type === "TRIGGER" @@ -119,19 +120,13 @@
-
{ - setupToggled = !setupToggled - }} - class="center-items" + (setupToggled = !setupToggled)} + quiet + icon={setupToggled ? "ChevronDown" : "ChevronRight"} > - {#if setupToggled} - - {:else} - - {/if} Setup -
+ {#if !isTrigger}
deleteStep()}> @@ -187,6 +182,7 @@ .splitHeader { display: flex; justify-content: space-between; + align-items: center; } .iconAlign { padding: 0 0 0 var(--spacing-m); diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index d648b3f989..928897d6f5 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -10,6 +10,7 @@ ActionButton, Drawer, Modal, + Detail, } from "@budibase/bbui" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" @@ -37,6 +38,7 @@ let drawer let tempFilters = lookForFilters(schemaProperties) || [] let fillWidth = true + let codeBindingOpen = false $: stepId = block.stepId $: bindings = getAvailableBindings( @@ -233,7 +235,16 @@ onChange(e, key)} value={inputData[key]} /> {:else if value.customType === "code"} -
{JSON.stringify(bindings, null, 2)}
+ (codeBindingOpen = !codeBindingOpen)} + quiet + icon={codeBindingOpen ? "ChevronDown" : "ChevronRight"} + > + Bindings + + {#if codeBindingOpen} +
{JSON.stringify(bindings, null, 2)}
+ {/if} { diff --git a/packages/cli/package.json b/packages/cli/package.json index 911c04f8fb..2fc9b44dbb 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 21a0b40d46..2067aa9e0a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.27-alpha.8", + "@budibase/bbui": "^1.0.27-alpha.12", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.27-alpha.8", + "@budibase/string-templates": "^1.0.27-alpha.12", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index d6d6c4959c..b4ef066333 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/auth": "^1.0.27-alpha.8", - "@budibase/client": "^1.0.27-alpha.8", - "@budibase/string-templates": "^1.0.27-alpha.8", + "@budibase/backend-core": "^1.0.27-alpha.12", + "@budibase/client": "^1.0.27-alpha.12", + "@budibase/string-templates": "^1.0.27-alpha.12", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/server/scripts/replicateApp.js b/packages/server/scripts/replicateApp.js index 8b363309ab..6730fe42d3 100644 --- a/packages/server/scripts/replicateApp.js +++ b/packages/server/scripts/replicateApp.js @@ -7,7 +7,7 @@ const CouchDB = require("../src/db") const { DocumentTypes } = require("../src/db/utils") -const { getAllDbs } = require("@budibase/auth/db") +const { getAllDbs } = require("@budibase/backend-core/db") const appName = process.argv[2].toLowerCase() const remoteUrl = process.argv[3] diff --git a/packages/server/src/api/controllers/apikeys.js b/packages/server/src/api/controllers/apikeys.js index 9b1ddee4c4..f5e36e7435 100644 --- a/packages/server/src/api/controllers/apikeys.js +++ b/packages/server/src/api/controllers/apikeys.js @@ -1,5 +1,5 @@ -const { StaticDatabases } = require("@budibase/auth/db") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { StaticDatabases } = require("@budibase/backend-core/db") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 6f55834a49..48e2b19a9d 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -19,7 +19,10 @@ const { DocumentTypes, AppStatus, } = require("../../db/utils") -const { BUILTIN_ROLE_IDS, AccessController } = require("@budibase/auth/roles") +const { + BUILTIN_ROLE_IDS, + AccessController, +} = require("@budibase/backend-core/roles") const { BASE_LAYOUTS } = require("../../constants/layouts") const { cloneDeep } = require("lodash/fp") const { processObject } = require("@budibase/string-templates") @@ -28,7 +31,7 @@ const { isDevAppID, getDeployedAppID, Replication, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const { USERS_TABLE_SCHEMA } = require("../../constants") const { getDeployedApps, @@ -41,9 +44,9 @@ const { backupClientLibrary, revertClientLibrary, } = require("../../utilities/fileSystem/clientLibrary") -const { getTenantId, isMultiTenant } = require("@budibase/auth/tenancy") +const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy") const { syncGlobalUsers } = require("./user") -const { app: appCache } = require("@budibase/auth/cache") +const { app: appCache } = require("@budibase/backend-core/cache") const { cleanupAutomations } = require("../../automations/utils") const URL_REGEX_SLASH = /\/|\\/g diff --git a/packages/server/src/api/controllers/auth.js b/packages/server/src/api/controllers/auth.js index 53d8ecbacb..3f680225af 100644 --- a/packages/server/src/api/controllers/auth.js +++ b/packages/server/src/api/controllers/auth.js @@ -2,7 +2,7 @@ const CouchDB = require("../../db") const { outputProcessing } = require("../../utilities/rowProcessor") const { InternalTables } = require("../../db/utils") const { getFullUser } = require("../../utilities/users") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") exports.fetchSelf = async ctx => { const appId = ctx.appId diff --git a/packages/server/src/api/controllers/cloud.js b/packages/server/src/api/controllers/cloud.js index a0057d68e4..ea6cc9b71e 100644 --- a/packages/server/src/api/controllers/cloud.js +++ b/packages/server/src/api/controllers/cloud.js @@ -1,5 +1,5 @@ const env = require("../../environment") -const { getAllApps } = require("@budibase/auth/db") +const { getAllApps } = require("@budibase/backend-core/db") const CouchDB = require("../../db") const { exportDB, @@ -7,7 +7,10 @@ const { readFileSync, } = require("../../utilities/fileSystem") const { stringToReadStream } = require("../../utilities") -const { getGlobalDBName, getGlobalDB } = require("@budibase/auth/tenancy") +const { + getGlobalDBName, + getGlobalDB, +} = require("@budibase/backend-core/tenancy") const { create } = require("./application") const { getDocParams, DocumentTypes, isDevAppID } = require("../../db/utils") diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index b99b1a5048..f08b622c3e 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -10,6 +10,7 @@ const { const { BuildSchemaErrors, InvalidColumns } = require("../../constants") const { integrations } = require("../../integrations") const { getDatasourceAndQuery } = require("./row/utils") +const { invalidateDynamicVariables } = require("../../threads/utils") exports.fetch = async function (ctx) { const database = new CouchDB(ctx.appId) @@ -57,10 +58,43 @@ exports.buildSchemaFromDb = async function (ctx) { ctx.body = response } +/** + * Check for variables that have been updated or removed and invalidate them. + */ +const invalidateVariables = async (existingDatasource, updatedDatasource) => { + const existingVariables = existingDatasource.config.dynamicVariables + const updatedVariables = updatedDatasource.config.dynamicVariables + const toInvalidate = [] + + if (!existingVariables) { + return + } + + if (!updatedVariables) { + // invalidate all + toInvalidate.push(...existingVariables) + } else { + // invaldate changed / removed + existingVariables.forEach(existing => { + const unchanged = updatedVariables.find( + updated => + existing.name === updated.name && + existing.queryId === updated.queryId && + existing.value === updated.value + ) + if (!unchanged) { + toInvalidate.push(existing) + } + }) + } + await invalidateDynamicVariables(toInvalidate) +} + exports.update = async function (ctx) { const db = new CouchDB(ctx.appId) const datasourceId = ctx.params.datasourceId let datasource = await db.get(datasourceId) + await invalidateVariables(datasource, ctx.request.body) datasource = { ...datasource, ...ctx.request.body } const response = await db.put(datasource) diff --git a/packages/server/src/api/controllers/deploy/index.js b/packages/server/src/api/controllers/deploy/index.js index c1138f4b03..76d7b75912 100644 --- a/packages/server/src/api/controllers/deploy/index.js +++ b/packages/server/src/api/controllers/deploy/index.js @@ -1,12 +1,12 @@ const CouchDB = require("../../../db") const Deployment = require("./Deployment") -const { Replication, getDeployedAppID } = require("@budibase/auth/db") +const { Replication, getDeployedAppID } = require("@budibase/backend-core/db") const { DocumentTypes, getAutomationParams } = require("../../../db/utils") const { disableAllCrons, enableCronTrigger, } = require("../../../automations/utils") -const { app: appCache } = require("@budibase/auth/cache") +const { app: appCache } = require("@budibase/backend-core/cache") // the max time we can wait for an invalidation to complete before considering it failed const MAX_PENDING_TIME_MS = 30 * 60000 diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index 559ffcbcfd..c7dbbc1e8f 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -4,9 +4,9 @@ const env = require("../../environment") const { checkSlashesInUrl } = require("../../utilities") const { request } = require("../../utilities/workerRequests") const { clearLock } = require("../../utilities/redis") -const { Replication } = require("@budibase/auth").db +const { Replication } = require("@budibase/backend-core").db const { DocumentTypes } = require("../../db/utils") -const { app: appCache } = require("@budibase/auth/cache") +const { app: appCache } = require("@budibase/backend-core/cache") async function redirect(ctx, method, path = "global") { const { devPath } = ctx.params diff --git a/packages/server/src/api/controllers/hosting.js b/packages/server/src/api/controllers/hosting.js index 6b47dc8634..bff37193bd 100644 --- a/packages/server/src/api/controllers/hosting.js +++ b/packages/server/src/api/controllers/hosting.js @@ -1,7 +1,7 @@ const CouchDB = require("../../db") const { getDeployedApps } = require("../../utilities/workerRequests") -const { getScopedConfig } = require("@budibase/auth/db") -const { Configs } = require("@budibase/auth").constants +const { getScopedConfig } = require("@budibase/backend-core/db") +const { Configs } = require("@budibase/backend-core").constants const { checkSlashesInUrl } = require("../../utilities") exports.fetchUrls = async ctx => { diff --git a/packages/server/src/api/controllers/permission.js b/packages/server/src/api/controllers/permission.js index c38740cb01..5c42fe77ef 100644 --- a/packages/server/src/api/controllers/permission.js +++ b/packages/server/src/api/controllers/permission.js @@ -1,10 +1,10 @@ -const { getBuiltinPermissions } = require("@budibase/auth/permissions") +const { getBuiltinPermissions } = require("@budibase/backend-core/permissions") const { isBuiltin, getDBRoleID, getExternalRoleID, getBuiltinRoles, -} = require("@budibase/auth/roles") +} = require("@budibase/backend-core/roles") const { getRoleParams } = require("../../db/utils") const CouchDB = require("../../db") const { diff --git a/packages/server/src/api/controllers/role.js b/packages/server/src/api/controllers/role.js index 7b127fb2d0..b79907031d 100644 --- a/packages/server/src/api/controllers/role.js +++ b/packages/server/src/api/controllers/role.js @@ -4,7 +4,7 @@ const { getRole, isBuiltin, getAllRoles, -} = require("@budibase/auth/roles") +} = require("@budibase/backend-core/roles") const { generateRoleID, getUserMetadataParams, diff --git a/packages/server/src/api/controllers/routing.js b/packages/server/src/api/controllers/routing.js index d281b92fe2..d45d33ed07 100644 --- a/packages/server/src/api/controllers/routing.js +++ b/packages/server/src/api/controllers/routing.js @@ -2,7 +2,7 @@ const { getRoutingInfo } = require("../../utilities/routing") const { getUserRoleHierarchy, BUILTIN_ROLE_IDS, -} = require("@budibase/auth/roles") +} = require("@budibase/backend-core/roles") const URL_SEPARATOR = "/" diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index d8ae77156a..3a2586331a 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -1,6 +1,6 @@ const { SearchIndexes } = require("../../../db/utils") const fetch = require("node-fetch") -const { getCouchUrl } = require("@budibase/auth/db") +const { getCouchUrl } = require("@budibase/backend-core/db") /** * Class to build lucene query URLs. diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index 7898476227..5e0eeb5176 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -1,6 +1,6 @@ const CouchDB = require("../../db") const { getScreenParams, generateScreenID } = require("../../db/utils") -const { AccessController } = require("@budibase/auth/roles") +const { AccessController } = require("@budibase/backend-core/roles") exports.fetch = async ctx => { const appId = ctx.appId diff --git a/packages/server/src/api/controllers/user.js b/packages/server/src/api/controllers/user.js index 902f6ce7e5..d87afc4309 100644 --- a/packages/server/src/api/controllers/user.js +++ b/packages/server/src/api/controllers/user.js @@ -8,10 +8,13 @@ const { InternalTables } = require("../../db/utils") const { getGlobalUsers, getRawGlobalUser } = require("../../utilities/global") const { getFullUser } = require("../../utilities/users") const { isEqual } = require("lodash") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") -const { getDevelopmentAppID, getDeployedAppIDs } = require("@budibase/auth/db") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") +const { + getDevelopmentAppID, + getDeployedAppIDs, +} = require("@budibase/backend-core/db") const { doesDatabaseExist } = require("../../utilities") -const { UserStatus } = require("@budibase/auth/constants") +const { UserStatus } = require("@budibase/backend-core/constants") async function rawMetadata(db) { return ( diff --git a/packages/server/src/api/controllers/webhook.js b/packages/server/src/api/controllers/webhook.js index 2d687955e3..0230fb481b 100644 --- a/packages/server/src/api/controllers/webhook.js +++ b/packages/server/src/api/controllers/webhook.js @@ -3,7 +3,7 @@ const { generateWebhookID, getWebhookParams } = require("../../db/utils") const toJsonSchema = require("to-json-schema") const validate = require("jsonschema").validate const triggers = require("../../automations/triggers") -const { getDeployedAppID } = require("@budibase/auth/db") +const { getDeployedAppID } = require("@budibase/backend-core/db") const AUTOMATION_DESCRIPTION = "Generated from Webhook Schema" diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index dfe1f83fb4..1c8684ad87 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -4,7 +4,7 @@ const { auditLog, buildTenancyMiddleware, buildAppTenancyMiddleware, -} = require("@budibase/auth").auth +} = require("@budibase/backend-core").auth const currentApp = require("../middleware/currentapp") const compress = require("koa-compress") const zlib = require("zlib") diff --git a/packages/server/src/api/routes/apikeys.js b/packages/server/src/api/routes/apikeys.js index d1174eb475..315cffb41a 100644 --- a/packages/server/src/api/routes/apikeys.js +++ b/packages/server/src/api/routes/apikeys.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/apikeys") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/application.js b/packages/server/src/api/routes/application.js index 1a21cc8216..4a7949a2bb 100644 --- a/packages/server/src/api/routes/application.js +++ b/packages/server/src/api/routes/application.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/application") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const usage = require("../../middleware/usageQuota") const router = Router() diff --git a/packages/server/src/api/routes/automation.js b/packages/server/src/api/routes/automation.js index 599b16b583..2bec83d75e 100644 --- a/packages/server/src/api/routes/automation.js +++ b/packages/server/src/api/routes/automation.js @@ -6,7 +6,7 @@ const { BUILDER, PermissionLevels, PermissionTypes, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const Joi = require("joi") const { bodyResource, paramResource } = require("../../middleware/resourceId") const { diff --git a/packages/server/src/api/routes/backup.js b/packages/server/src/api/routes/backup.js index 51c53e37b6..83387ea75a 100644 --- a/packages/server/src/api/routes/backup.js +++ b/packages/server/src/api/routes/backup.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/backup") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/cloud.js b/packages/server/src/api/routes/cloud.js index 02b501c399..3cee889abf 100644 --- a/packages/server/src/api/routes/cloud.js +++ b/packages/server/src/api/routes/cloud.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/cloud") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/component.js b/packages/server/src/api/routes/component.js index 7b14b2b440..0f122169aa 100644 --- a/packages/server/src/api/routes/component.js +++ b/packages/server/src/api/routes/component.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/component") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/datasource.js b/packages/server/src/api/routes/datasource.js index ab5289176a..270e4e286e 100644 --- a/packages/server/src/api/routes/datasource.js +++ b/packages/server/src/api/routes/datasource.js @@ -6,7 +6,7 @@ const { BUILDER, PermissionLevels, PermissionTypes, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const Joi = require("joi") const { DataSourceOperation } = require("../../constants") diff --git a/packages/server/src/api/routes/deploy.js b/packages/server/src/api/routes/deploy.js index 261a440c2e..762646435a 100644 --- a/packages/server/src/api/routes/deploy.js +++ b/packages/server/src/api/routes/deploy.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/deploy") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/dev.js b/packages/server/src/api/routes/dev.js index 0d9bd118aa..165149ca8b 100644 --- a/packages/server/src/api/routes/dev.js +++ b/packages/server/src/api/routes/dev.js @@ -2,7 +2,7 @@ const Router = require("@koa/router") const controller = require("../controllers/dev") const env = require("../../environment") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/hosting.js b/packages/server/src/api/routes/hosting.js index 29e229f843..5af2d3c622 100644 --- a/packages/server/src/api/routes/hosting.js +++ b/packages/server/src/api/routes/hosting.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/hosting") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/integration.js b/packages/server/src/api/routes/integration.js index 6b523867c3..ebe79d978e 100644 --- a/packages/server/src/api/routes/integration.js +++ b/packages/server/src/api/routes/integration.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/integration") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/layout.js b/packages/server/src/api/routes/layout.js index ad3ac0aa9e..fa04b63402 100644 --- a/packages/server/src/api/routes/layout.js +++ b/packages/server/src/api/routes/layout.js @@ -1,6 +1,6 @@ const Router = require("@koa/router") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const controller = require("../controllers/layout") const router = Router() diff --git a/packages/server/src/api/routes/metadata.js b/packages/server/src/api/routes/metadata.js index f4eba64358..129e72b5e7 100644 --- a/packages/server/src/api/routes/metadata.js +++ b/packages/server/src/api/routes/metadata.js @@ -5,7 +5,7 @@ const { AppType, } = require("../../middleware/appInfo") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/permission.js b/packages/server/src/api/routes/permission.js index f395b13577..a868219e83 100644 --- a/packages/server/src/api/routes/permission.js +++ b/packages/server/src/api/routes/permission.js @@ -1,7 +1,10 @@ const Router = require("@koa/router") const controller = require("../controllers/permission") const authorized = require("../../middleware/authorized") -const { BUILDER, PermissionLevels } = require("@budibase/auth/permissions") +const { + BUILDER, + PermissionLevels, +} = require("@budibase/backend-core/permissions") const Joi = require("joi") const joiValidator = require("../../middleware/joi-validator") diff --git a/packages/server/src/api/routes/query.js b/packages/server/src/api/routes/query.js index 466fb1efaf..37a26f6808 100644 --- a/packages/server/src/api/routes/query.js +++ b/packages/server/src/api/routes/query.js @@ -5,7 +5,7 @@ const { PermissionLevels, PermissionTypes, BUILDER, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const { bodyResource, bodySubResource, diff --git a/packages/server/src/api/routes/role.js b/packages/server/src/api/routes/role.js index 8736bb93c6..bf20b01221 100644 --- a/packages/server/src/api/routes/role.js +++ b/packages/server/src/api/routes/role.js @@ -7,7 +7,7 @@ const { BUILTIN_PERMISSION_IDS, BUILDER, PermissionLevels, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/routing.js b/packages/server/src/api/routes/routing.js index 4d75705f14..45ccb7bb64 100644 --- a/packages/server/src/api/routes/routing.js +++ b/packages/server/src/api/routes/routing.js @@ -1,6 +1,6 @@ const Router = require("@koa/router") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const controller = require("../controllers/routing") const router = Router() diff --git a/packages/server/src/api/routes/row.js b/packages/server/src/api/routes/row.js index 8251328df3..aa300108f1 100644 --- a/packages/server/src/api/routes/row.js +++ b/packages/server/src/api/routes/row.js @@ -9,7 +9,7 @@ const { const { PermissionLevels, PermissionTypes, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/screen.js b/packages/server/src/api/routes/screen.js index 3a9baa25fc..cfce67a5dc 100644 --- a/packages/server/src/api/routes/screen.js +++ b/packages/server/src/api/routes/screen.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/screen") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const joiValidator = require("../../middleware/joi-validator") const Joi = require("joi") diff --git a/packages/server/src/api/routes/script.js b/packages/server/src/api/routes/script.js index cda8fa8df9..d0d3214db3 100644 --- a/packages/server/src/api/routes/script.js +++ b/packages/server/src/api/routes/script.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/script") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/static.js b/packages/server/src/api/routes/static.js index 6b695e5ddf..b40d5fe4e9 100644 --- a/packages/server/src/api/routes/static.js +++ b/packages/server/src/api/routes/static.js @@ -6,7 +6,7 @@ const { BUILDER, PermissionTypes, PermissionLevels, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const env = require("../../environment") const { paramResource } = require("../../middleware/resourceId") diff --git a/packages/server/src/api/routes/table.js b/packages/server/src/api/routes/table.js index d8ddbe8133..7b12b9e911 100644 --- a/packages/server/src/api/routes/table.js +++ b/packages/server/src/api/routes/table.js @@ -6,7 +6,7 @@ const { BUILDER, PermissionLevels, PermissionTypes, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const joiValidator = require("../../middleware/joi-validator") const Joi = require("joi") diff --git a/packages/server/src/api/routes/templates.js b/packages/server/src/api/routes/templates.js index ee29730406..710475db84 100644 --- a/packages/server/src/api/routes/templates.js +++ b/packages/server/src/api/routes/templates.js @@ -1,7 +1,7 @@ const Router = require("@koa/router") const controller = require("../controllers/templates") const authorized = require("../../middleware/authorized") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/tests/datasource.spec.js b/packages/server/src/api/routes/tests/datasource.spec.js index 04f4dd77b8..880cc338a2 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.js +++ b/packages/server/src/api/routes/tests/datasource.spec.js @@ -4,6 +4,7 @@ let setup = require("./utilities") let { basicDatasource } = setup.structures let { checkBuilderEndpoint } = require("./utilities/TestFunctions") const pg = require("pg") +const { checkCacheForDynamicVariable } = require("../../../threads/utils") describe("/datasources", () => { let request = setup.getRequest() @@ -31,6 +32,50 @@ describe("/datasources", () => { }) }) + describe("update", () => { + it("should update an existing datasource", async () => { + datasource.name = "Updated Test" + const res = await request + .put(`/api/datasources/${datasource._id}`) + .send(datasource) + .set(config.defaultHeaders()) + .expect('Content-Type', /json/) + .expect(200) + + expect(res.body.datasource.name).toEqual("Updated Test") + expect(res.body.errors).toBeUndefined() + }) + + describe("dynamic variables", () => { + async function preview(datasource, fields) { + return config.previewQuery(request, config, datasource, fields) + } + + it("should invalidate changed or removed variables", async () => { + const { datasource, query } = await config.dynamicVariableDatasource() + // preview once to cache variables + await preview(datasource, { path: "www.test.com", queryString: "test={{ variable3 }}" }) + // check variables in cache + let contents = await checkCacheForDynamicVariable(query._id, "variable3") + expect(contents.rows.length).toEqual(1) + + // update the datasource to remove the variables + datasource.config.dynamicVariables = [] + const res = await request + .put(`/api/datasources/${datasource._id}`) + .send(datasource) + .set(config.defaultHeaders()) + .expect('Content-Type', /json/) + .expect(200) + expect(res.body.errors).toBeUndefined() + + // check variables no longer in cache + contents = await checkCacheForDynamicVariable(query._id, "variable3") + expect(contents).toBe(null) + }) + }) + }) + describe("fetch", () => { it("returns all the datasources from the server", async () => { const res = await request diff --git a/packages/server/src/api/routes/tests/permissions.spec.js b/packages/server/src/api/routes/tests/permissions.spec.js index 0304e551cc..2b231dbe64 100644 --- a/packages/server/src/api/routes/tests/permissions.spec.js +++ b/packages/server/src/api/routes/tests/permissions.spec.js @@ -1,4 +1,4 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const setup = require("./utilities") const { basicRow } = setup.structures diff --git a/packages/server/src/api/routes/tests/query.spec.js b/packages/server/src/api/routes/tests/query.spec.js index c8f842e584..9357d53cde 100644 --- a/packages/server/src/api/routes/tests/query.spec.js +++ b/packages/server/src/api/routes/tests/query.spec.js @@ -4,7 +4,7 @@ jest.mock("node-fetch") // Mock isProdAppID to we can later mock the implementation and pretend we are // using prod app IDs -const authDb = require("@budibase/auth/db") +const authDb = require("@budibase/backend-core/db") const { isProdAppID } = authDb const mockIsProdAppID = jest.fn(isProdAppID) authDb.isProdAppID = mockIsProdAppID @@ -229,52 +229,14 @@ describe("/queries", () => { }) }) - describe("test variables", () => { - async function restDatasource(cfg) { - return await config.createDatasource({ - datasource: { - ...basicDatasource().datasource, - source: "REST", - config: cfg || {}, - }, - }) - } - - async function dynamicVariableDatasource() { - const datasource = await restDatasource() - const basedOnQuery = await config.createQuery({ - ...basicQuery(datasource._id), - fields: { - path: "www.google.com", - }, - }) - await config.updateDatasource({ - ...datasource, - config: { - dynamicVariables: [ - { queryId: basedOnQuery._id, name: "variable3", value: "{{ data.0.[value] }}" } - ] - } - }) - return { datasource, query: basedOnQuery } - } + describe("variables", () => { async function preview(datasource, fields) { - return await request - .post(`/api/queries/preview`) - .send({ - datasourceId: datasource._id, - parameters: {}, - fields, - queryVerb: "read", - }) - .set(config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(200) + return config.previewQuery(request, config, datasource, fields) } it("should work with static variables", async () => { - const datasource = await restDatasource({ + const datasource = await config.restDatasource({ staticVariables: { variable: "google", variable2: "1", @@ -290,7 +252,7 @@ describe("/queries", () => { }) it("should work with dynamic variables", async () => { - const { datasource } = await dynamicVariableDatasource() + const { datasource } = await config.dynamicVariableDatasource() const res = await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}", @@ -300,7 +262,7 @@ describe("/queries", () => { }) it("check that it automatically retries on fail with cached dynamics", async () => { - const { datasource, query: base } = await dynamicVariableDatasource() + const { datasource, query: base } = await config.dynamicVariableDatasource() // preview once to cache await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" }) // check its in cache @@ -313,5 +275,24 @@ describe("/queries", () => { expect(res.body.schemaFields).toEqual(["fails", "url", "opts"]) expect(res.body.rows[0].fails).toEqual(1) }) + + it("deletes variables when linked query is deleted", async () => { + const { datasource, query: base } = await config.dynamicVariableDatasource() + // preview once to cache + await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" }) + // check its in cache + let contents = await checkCacheForDynamicVariable(base._id, "variable3") + expect(contents.rows.length).toEqual(1) + + // delete the query + await request + .delete(`/api/queries/${base._id}/${base._rev}`) + .set(config.defaultHeaders()) + .expect(200) + + // check variables no longer in cache + contents = await checkCacheForDynamicVariable(base._id, "variable3") + expect(contents).toBe(null) + }) }) }) diff --git a/packages/server/src/api/routes/tests/role.spec.js b/packages/server/src/api/routes/tests/role.spec.js index d74a84b2b2..31fd9997d8 100644 --- a/packages/server/src/api/routes/tests/role.spec.js +++ b/packages/server/src/api/routes/tests/role.spec.js @@ -1,7 +1,7 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const { BUILTIN_PERMISSION_IDS, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const setup = require("./utilities") const { basicRole } = setup.structures diff --git a/packages/server/src/api/routes/tests/routing.spec.js b/packages/server/src/api/routes/tests/routing.spec.js index 079fe0dedc..fdc414448c 100644 --- a/packages/server/src/api/routes/tests/routing.spec.js +++ b/packages/server/src/api/routes/tests/routing.spec.js @@ -1,7 +1,7 @@ const setup = require("./utilities") const { basicScreen } = setup.structures const { checkBuilderEndpoint } = require("./utilities/TestFunctions") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const route = "/test" diff --git a/packages/server/src/api/routes/tests/user.spec.js b/packages/server/src/api/routes/tests/user.spec.js index a9e98f2555..29c33b3899 100644 --- a/packages/server/src/api/routes/tests/user.spec.js +++ b/packages/server/src/api/routes/tests/user.spec.js @@ -1,4 +1,4 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const { checkPermissionsEndpoint } = require("./utilities/TestFunctions") const setup = require("./utilities") diff --git a/packages/server/src/api/routes/tests/utilities/TestFunctions.js b/packages/server/src/api/routes/tests/utilities/TestFunctions.js index 857e902b66..9bd54f0d75 100644 --- a/packages/server/src/api/routes/tests/utilities/TestFunctions.js +++ b/packages/server/src/api/routes/tests/utilities/TestFunctions.js @@ -2,7 +2,7 @@ const rowController = require("../../../controllers/row") const appController = require("../../../controllers/application") const CouchDB = require("../../../../db") const { AppStatus } = require("../../../../db/utils") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const { TENANT_ID } = require("../../../../tests/utilities/structures") function Request(appId, params) { diff --git a/packages/server/src/api/routes/user.js b/packages/server/src/api/routes/user.js index 9acd599b71..5ac446d54e 100644 --- a/packages/server/src/api/routes/user.js +++ b/packages/server/src/api/routes/user.js @@ -4,7 +4,7 @@ const authorized = require("../../middleware/authorized") const { PermissionLevels, PermissionTypes, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/view.js b/packages/server/src/api/routes/view.js index b72fe1ac26..9d57d722e1 100644 --- a/packages/server/src/api/routes/view.js +++ b/packages/server/src/api/routes/view.js @@ -7,7 +7,7 @@ const { BUILDER, PermissionTypes, PermissionLevels, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const router = Router() diff --git a/packages/server/src/api/routes/webhook.js b/packages/server/src/api/routes/webhook.js index 73790acd64..561eb8c1ee 100644 --- a/packages/server/src/api/routes/webhook.js +++ b/packages/server/src/api/routes/webhook.js @@ -2,7 +2,7 @@ const Router = require("@koa/router") const controller = require("../controllers/webhook") const authorized = require("../../middleware/authorized") const joiValidator = require("../../middleware/joi-validator") -const { BUILDER } = require("@budibase/auth/permissions") +const { BUILDER } = require("@budibase/backend-core/permissions") const Joi = require("joi") const router = Router() diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index c44b6123aa..060169a777 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -3,7 +3,7 @@ import { ExtendableContext } from "koa" const env = require("./environment") const CouchDB = require("./db") -require("@budibase/auth").init(CouchDB) +require("@budibase/backend-core").init(CouchDB) const Koa = require("koa") const destroyable = require("server-destroy") const koaBody = require("koa-body") diff --git a/packages/server/src/automations/bullboard.js b/packages/server/src/automations/bullboard.js index 67f3f4ce56..32336c4714 100644 --- a/packages/server/src/automations/bullboard.js +++ b/packages/server/src/automations/bullboard.js @@ -6,7 +6,7 @@ const Queue = env.isTest() ? require("../utilities/queue/inMemoryQueue") : require("bull") const { JobQueues } = require("../constants") -const { utils } = require("@budibase/auth/redis") +const { utils } = require("@budibase/backend-core/redis") const { opts, redisProtocolUrl } = utils.getRedisOptions() const CLEANUP_PERIOD_MS = 60 * 1000 diff --git a/packages/server/src/automations/steps/executeQuery.js b/packages/server/src/automations/steps/executeQuery.js index 0fa8661561..99c2c40783 100644 --- a/packages/server/src/automations/steps/executeQuery.js +++ b/packages/server/src/automations/steps/executeQuery.js @@ -72,7 +72,7 @@ exports.run = async function ({ inputs, appId, emitter }) { }) try { - await queryController.execute(ctx) + await queryController.executeV1(ctx) const { data, ...rest } = ctx.body return { response: data, diff --git a/packages/server/src/automations/utils.js b/packages/server/src/automations/utils.js index d9c96963ab..4a554793f8 100644 --- a/packages/server/src/automations/utils.js +++ b/packages/server/src/automations/utils.js @@ -6,7 +6,7 @@ const { queue } = require("./bullboard") const newid = require("../db/newid") const { updateEntityMetadata } = require("../utilities") const { MetadataTypes } = require("../constants") -const { getDeployedAppID } = require("@budibase/auth/db") +const { getDeployedAppID } = require("@budibase/backend-core/db") const { cloneDeep } = require("lodash/fp") const WH_STEP_ID = definitions.WEBHOOK.stepId diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js index c3cb9b7a58..5d04ab870a 100644 --- a/packages/server/src/constants/index.js +++ b/packages/server/src/constants/index.js @@ -1,6 +1,6 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") -const { UserStatus } = require("@budibase/auth").constants -const { ObjectStoreBuckets } = require("@budibase/auth").objectStore +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") +const { UserStatus } = require("@budibase/backend-core").constants +const { ObjectStoreBuckets } = require("@budibase/backend-core").objectStore exports.JobQueues = { AUTOMATIONS: "automationQueue", diff --git a/packages/server/src/constants/screens.js b/packages/server/src/constants/screens.js index 49c21367cd..23f8bc88df 100644 --- a/packages/server/src/constants/screens.js +++ b/packages/server/src/constants/screens.js @@ -1,4 +1,4 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const { BASE_LAYOUT_PROP_IDS } = require("./layouts") exports.createHomeScreen = () => ({ diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js index a453ad8561..5d0df7ef05 100644 --- a/packages/server/src/db/client.js +++ b/packages/server/src/db/client.js @@ -1,5 +1,5 @@ const PouchDB = require("pouchdb") -const { getCouchUrl } = require("@budibase/auth/db") +const { getCouchUrl } = require("@budibase/backend-core/db") const replicationStream = require("pouchdb-replication-stream") const allDbs = require("pouchdb-all-dbs") const find = require("pouchdb-find") diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js index 2d9ef87c87..e19fed0201 100644 --- a/packages/server/src/db/utils.js +++ b/packages/server/src/db/utils.js @@ -9,7 +9,7 @@ const { StaticDatabases, isDevAppID, isProdAppID, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const UNICODE_MAX = "\ufff0" diff --git a/packages/server/src/middleware/authorized.js b/packages/server/src/middleware/authorized.js index 5f21c2d026..b463895a80 100644 --- a/packages/server/src/middleware/authorized.js +++ b/packages/server/src/middleware/authorized.js @@ -2,11 +2,11 @@ const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, -} = require("@budibase/auth/roles") +} = require("@budibase/backend-core/roles") const { PermissionTypes, doesHaveBasePermission, -} = require("@budibase/auth/permissions") +} = require("@budibase/backend-core/permissions") const builderMiddleware = require("./builder") const { isWebhookEndpoint } = require("./utils") diff --git a/packages/server/src/middleware/builder.js b/packages/server/src/middleware/builder.js index f8a84c4c25..d2a8ee80f0 100644 --- a/packages/server/src/middleware/builder.js +++ b/packages/server/src/middleware/builder.js @@ -7,8 +7,8 @@ const { } = require("../utilities/redis") const CouchDB = require("../db") const { DocumentTypes } = require("../db/utils") -const { PermissionTypes } = require("@budibase/auth/permissions") -const { app: appCache } = require("@budibase/auth/cache") +const { PermissionTypes } = require("@budibase/backend-core/permissions") +const { app: appCache } = require("@budibase/backend-core/cache") const DEBOUNCE_TIME_SEC = 30 diff --git a/packages/server/src/middleware/currentapp.js b/packages/server/src/middleware/currentapp.js index 5682a860b9..5eeaac8a33 100644 --- a/packages/server/src/middleware/currentapp.js +++ b/packages/server/src/middleware/currentapp.js @@ -1,11 +1,11 @@ const { getAppId, setCookie, getCookie, clearCookie } = - require("@budibase/auth").utils -const { Cookies } = require("@budibase/auth").constants -const { getRole } = require("@budibase/auth/roles") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") + require("@budibase/backend-core").utils +const { Cookies } = require("@budibase/backend-core").constants +const { getRole } = require("@budibase/backend-core/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const { generateUserMetadataID, isDevAppID } = require("../db/utils") -const { dbExists } = require("@budibase/auth/db") -const { isUserInAppTenant } = require("@budibase/auth/tenancy") +const { dbExists } = require("@budibase/backend-core/db") +const { isUserInAppTenant } = require("@budibase/backend-core/tenancy") const { getCachedSelf } = require("../utilities/global") const CouchDB = require("../db") const env = require("../environment") diff --git a/packages/server/src/middleware/tests/authorized.spec.js b/packages/server/src/middleware/tests/authorized.spec.js index d7052b323b..9775965b5a 100644 --- a/packages/server/src/middleware/tests/authorized.spec.js +++ b/packages/server/src/middleware/tests/authorized.spec.js @@ -9,8 +9,8 @@ jest.mock("../../environment", () => ({ ) const authorizedMiddleware = require("../authorized") const env = require("../../environment") -const { PermissionTypes, PermissionLevels } = require("@budibase/auth/permissions") -require("@budibase/auth").init(require("../../db")) +const { PermissionTypes, PermissionLevels } = require("@budibase/backend-core/permissions") +require("@budibase/backend-core").init(require("../../db")) class TestConfiguration { constructor(role) { diff --git a/packages/server/src/middleware/tests/currentapp.spec.js b/packages/server/src/middleware/tests/currentapp.spec.js index d288320aea..a76f70e754 100644 --- a/packages/server/src/middleware/tests/currentapp.spec.js +++ b/packages/server/src/middleware/tests/currentapp.spec.js @@ -23,7 +23,7 @@ function mockReset() { function mockAuthWithNoCookie() { jest.resetModules() mockWorker() - jest.mock("@budibase/auth/cache", () => ({ + jest.mock("@budibase/backend-core/cache", () => ({ user: { getUser: () => { return { @@ -32,7 +32,7 @@ function mockAuthWithNoCookie() { }, }, })) - jest.mock("@budibase/auth", () => ({ + jest.mock("@budibase/backend-core", () => ({ utils: { getAppId: jest.fn(), setCookie: jest.fn(), @@ -47,7 +47,7 @@ function mockAuthWithNoCookie() { function mockAuthWithCookie() { jest.resetModules() mockWorker() - jest.mock("@budibase/auth", () => ({ + jest.mock("@budibase/backend-core", () => ({ utils: { getAppId: () => { return "app_test" @@ -121,7 +121,7 @@ describe("Current app middleware", () => { async function checkExpected(setCookie) { config.setUser() await config.executeMiddleware() - const cookieFn = require("@budibase/auth").utils.setCookie + const cookieFn = require("@budibase/backend-core").utils.setCookie if (setCookie) { expect(cookieFn).toHaveBeenCalled() } else { @@ -140,7 +140,7 @@ describe("Current app middleware", () => { it("should perform correct when no cookie exists", async () => { mockReset() - jest.mock("@budibase/auth", () => ({ + jest.mock("@budibase/backend-core", () => ({ utils: { getAppId: () => { return "app_test" @@ -157,7 +157,7 @@ describe("Current app middleware", () => { it("lastly check what occurs when cookie doesn't need updated", async () => { mockReset() - jest.mock("@budibase/auth", () => ({ + jest.mock("@budibase/backend-core", () => ({ utils: { getAppId: () => { return "app_test" diff --git a/packages/server/src/middleware/tests/usageQuota.spec.js b/packages/server/src/middleware/tests/usageQuota.spec.js index 42a7ee524f..2e92eb9957 100644 --- a/packages/server/src/middleware/tests/usageQuota.spec.js +++ b/packages/server/src/middleware/tests/usageQuota.spec.js @@ -6,7 +6,7 @@ jest.mock("../../environment", () => ({ isDev: () => true, _set: () => {}, })) -jest.mock("@budibase/auth/tenancy", () => ({ +jest.mock("@budibase/backend-core/tenancy", () => ({ getTenantId: () => "testing123" })) diff --git a/packages/server/src/middleware/usageQuota.js b/packages/server/src/middleware/usageQuota.js index 3f8528d27f..bce13816d1 100644 --- a/packages/server/src/middleware/usageQuota.js +++ b/packages/server/src/middleware/usageQuota.js @@ -1,7 +1,7 @@ const CouchDB = require("../db") const usageQuota = require("../utilities/usageQuota") const env = require("../environment") -const { getTenantId } = require("@budibase/auth/tenancy") +const { getTenantId } = require("@budibase/backend-core/tenancy") const { isExternalTable, isRowId: isExternalRowId, diff --git a/packages/server/src/tests/utilities/TestConfiguration.js b/packages/server/src/tests/utilities/TestConfiguration.js index f003a8a78d..eb1280306d 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.js +++ b/packages/server/src/tests/utilities/TestConfiguration.js @@ -1,4 +1,4 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") const env = require("../../environment") const { basicTable, @@ -15,14 +15,14 @@ const { const controllers = require("./controllers") const supertest = require("supertest") const { cleanup } = require("../../utilities/fileSystem") -const { Cookies, Headers } = require("@budibase/auth").constants -const { jwt } = require("@budibase/auth").auth -const auth = require("@budibase/auth") -const { getGlobalDB } = require("@budibase/auth/tenancy") -const { createASession } = require("@budibase/auth/sessions") -const { user: userCache } = require("@budibase/auth/cache") +const { Cookies, Headers } = require("@budibase/backend-core").constants +const { jwt } = require("@budibase/backend-core").auth +const core = require("@budibase/backend-core") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") +const { createASession } = require("@budibase/backend-core/sessions") +const { user: userCache } = require("@budibase/backend-core/cache") const CouchDB = require("../../db") -auth.init(CouchDB) +core.init(CouchDB) const GLOBAL_USER_ID = "us_uuid1" const EMAIL = "babs@babs.com" @@ -326,6 +326,53 @@ class TestConfiguration { return this.datasource } + async restDatasource(cfg) { + return this.createDatasource({ + datasource: { + ...basicDatasource().datasource, + source: "REST", + config: cfg || {}, + }, + }) + } + + async dynamicVariableDatasource() { + let datasource = await this.restDatasource() + const basedOnQuery = await this.createQuery({ + ...basicQuery(datasource._id), + fields: { + path: "www.google.com", + }, + }) + datasource = await this.updateDatasource({ + ...datasource, + config: { + dynamicVariables: [ + { + queryId: basedOnQuery._id, + name: "variable3", + value: "{{ data.0.[value] }}", + }, + ], + }, + }) + return { datasource, query: basedOnQuery } + } + + async previewQuery(request, config, datasource, fields) { + return request + .post(`/api/queries/preview`) + .send({ + datasourceId: datasource._id, + parameters: {}, + fields, + queryVerb: "read", + }) + .set(config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + } + async createQuery(config = null) { if (!this.datasource && !config) { throw "No data source created for query." diff --git a/packages/server/src/tests/utilities/structures.js b/packages/server/src/tests/utilities/structures.js index 9c900fec09..45a8f2dece 100644 --- a/packages/server/src/tests/utilities/structures.js +++ b/packages/server/src/tests/utilities/structures.js @@ -1,5 +1,5 @@ -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") -const { BUILTIN_PERMISSION_IDS } = require("@budibase/auth/permissions") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") +const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions") const { createHomeScreen } = require("../../constants/screens") const { EMPTY_LAYOUT } = require("../../constants/layouts") const { cloneDeep } = require("lodash/fp") diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index fc9e2a21fc..65a8a82492 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -4,10 +4,10 @@ const actions = require("../automations/actions") const automationUtils = require("../automations/automationUtils") const AutomationEmitter = require("../events/AutomationEmitter") const { processObject } = require("@budibase/string-templates") -const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants +const { DEFAULT_TENANT_ID } = require("@budibase/backend-core").constants const CouchDB = require("../db") const { DocumentTypes, isDevAppID } = require("../db/utils") -const { doInTenant } = require("@budibase/auth/tenancy") +const { doInTenant } = require("@budibase/backend-core/tenancy") const usage = require("../utilities/usageQuota") const { definitions: triggerDefs } = require("../automations/triggerInfo") diff --git a/packages/server/src/threads/query.js b/packages/server/src/threads/query.js index fb82d2b12f..fd04f10fb6 100644 --- a/packages/server/src/threads/query.js +++ b/packages/server/src/threads/query.js @@ -46,7 +46,10 @@ class QueryRunner { // transform as required if (transformer) { - const runner = new ScriptRunner(transformer, { data: rows }) + const runner = new ScriptRunner(transformer, { + data: rows, + params: parameters, + }) rows = runner.execute() } diff --git a/packages/server/src/threads/utils.js b/packages/server/src/threads/utils.js index e989d5cb63..b877906da1 100644 --- a/packages/server/src/threads/utils.js +++ b/packages/server/src/threads/utils.js @@ -1,8 +1,8 @@ const env = require("../environment") const CouchDB = require("../db") -const { init } = require("@budibase/auth") -const redis = require("@budibase/auth/redis") -const { SEPARATOR } = require("@budibase/auth/db") +const { init } = require("@budibase/backend-core") +const redis = require("@budibase/backend-core/redis") +const { SEPARATOR } = require("@budibase/backend-core/db") const { processStringSync } = require("@budibase/string-templates") const VARIABLE_TTL_SECONDS = 3600 diff --git a/packages/server/src/utilities/budibaseDir.js b/packages/server/src/utilities/budibaseDir.js index b61a807306..37d83d48ce 100644 --- a/packages/server/src/utilities/budibaseDir.js +++ b/packages/server/src/utilities/budibaseDir.js @@ -1,7 +1,7 @@ const { join } = require("./centralPath") const { homedir } = require("os") const env = require("../environment") -const { budibaseTempDir } = require("@budibase/auth").objectStore +const { budibaseTempDir } = require("@budibase/backend-core").objectStore module.exports.budibaseAppsDir = function () { return env.BUDIBASE_DIR || join(homedir(), ".budibase") diff --git a/packages/server/src/utilities/fileSystem/utilities.js b/packages/server/src/utilities/fileSystem/utilities.js index 4968ef6310..84a701ee95 100644 --- a/packages/server/src/utilities/fileSystem/utilities.js +++ b/packages/server/src/utilities/fileSystem/utilities.js @@ -9,7 +9,7 @@ const { deleteFolder, uploadDirectory, downloadTarball, -} = require("@budibase/auth").objectStore +} = require("@budibase/backend-core").objectStore /*********************************** * NOTE * diff --git a/packages/server/src/utilities/global.js b/packages/server/src/utilities/global.js index 6527aa0601..7ef1c09405 100644 --- a/packages/server/src/utilities/global.js +++ b/packages/server/src/utilities/global.js @@ -2,11 +2,14 @@ const { getMultiIDParams, getGlobalIDFromUserMetadataID, } = require("../db/utils") -const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") -const { getDeployedAppID } = require("@budibase/auth/db") -const { getGlobalUserParams } = require("@budibase/auth/db") -const { user: userCache } = require("@budibase/auth/cache") -const { getGlobalDB, isUserInAppTenant } = require("@budibase/auth/tenancy") +const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") +const { getDeployedAppID } = require("@budibase/backend-core/db") +const { getGlobalUserParams } = require("@budibase/backend-core/db") +const { user: userCache } = require("@budibase/backend-core/cache") +const { + getGlobalDB, + isUserInAppTenant, +} = require("@budibase/backend-core/tenancy") const env = require("../environment") exports.updateAppRole = (appId, user) => { diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index 389514cc4b..8b51640c97 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -1,6 +1,6 @@ const env = require("../environment") const { OBJ_STORE_DIRECTORY } = require("../constants") -const { sanitizeKey } = require("@budibase/auth/src/objectStore") +const { sanitizeKey } = require("@budibase/backend-core/src/objectStore") const CouchDB = require("../db") const { generateMetadataID } = require("../db/utils") const Readable = require("stream").Readable diff --git a/packages/server/src/utilities/redis.js b/packages/server/src/utilities/redis.js index 151feabdbb..ca2fa3254d 100644 --- a/packages/server/src/utilities/redis.js +++ b/packages/server/src/utilities/redis.js @@ -1,4 +1,4 @@ -const { Client, utils } = require("@budibase/auth/redis") +const { Client, utils } = require("@budibase/backend-core/redis") const { getGlobalIDFromUserMetadataID } = require("../db/utils") const APP_DEV_LOCK_SECONDS = 600 diff --git a/packages/server/src/utilities/rowProcessor/index.js b/packages/server/src/utilities/rowProcessor/index.js index 9229a061e4..4f5d72c179 100644 --- a/packages/server/src/utilities/rowProcessor/index.js +++ b/packages/server/src/utilities/rowProcessor/index.js @@ -5,7 +5,11 @@ const { attachmentsRelativeURL } = require("../index") const { processFormulas } = require("./utils") const { deleteFiles } = require("../../utilities/fileSystem/utilities") const { ObjectStoreBuckets } = require("../../constants") -const { isProdAppID, getDeployedAppID, dbExists } = require("@budibase/auth/db") +const { + isProdAppID, + getDeployedAppID, + dbExists, +} = require("@budibase/backend-core/db") const CouchDB = require("../../db") const BASE_AUTO_ID = 1 diff --git a/packages/server/src/utilities/security.js b/packages/server/src/utilities/security.js index 78b2f5b713..de5b696553 100644 --- a/packages/server/src/utilities/security.js +++ b/packages/server/src/utilities/security.js @@ -3,8 +3,11 @@ const { PermissionTypes, getBuiltinPermissionByID, isPermissionLevelHigherThanRead, -} = require("@budibase/auth/permissions") -const { lowerBuiltinRoleID, getBuiltinRoles } = require("@budibase/auth/roles") +} = require("@budibase/backend-core/permissions") +const { + lowerBuiltinRoleID, + getBuiltinRoles, +} = require("@budibase/backend-core/roles") const { DocumentTypes } = require("../db/utils") const CURRENTLY_SUPPORTED_LEVELS = [ diff --git a/packages/server/src/utilities/usageQuota.js b/packages/server/src/utilities/usageQuota.js index 7bc3e2eb6e..4d88b610e0 100644 --- a/packages/server/src/utilities/usageQuota.js +++ b/packages/server/src/utilities/usageQuota.js @@ -1,9 +1,9 @@ const env = require("../environment") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") const { StaticDatabases, generateNewUsageQuotaDoc, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") exports.Properties = { ROW: "rows", // mostly works - disabled - app / table deletion not yet accounted for diff --git a/packages/server/src/utilities/workerRequests.js b/packages/server/src/utilities/workerRequests.js index 6a15e1b243..92dffc8d3f 100644 --- a/packages/server/src/utilities/workerRequests.js +++ b/packages/server/src/utilities/workerRequests.js @@ -1,10 +1,10 @@ const fetch = require("node-fetch") const env = require("../environment") const { checkSlashesInUrl } = require("./index") -const { getDeployedAppID } = require("@budibase/auth/db") +const { getDeployedAppID } = require("@budibase/backend-core/db") const { updateAppRole } = require("./global") -const { Headers } = require("@budibase/auth/constants") -const { getTenantId, isTenantIdSet } = require("@budibase/auth/tenancy") +const { Headers } = require("@budibase/backend-core/constants") +const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy") function request(ctx, request) { if (!request.headers) { diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 7663d25706..605dcdddac 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -983,9 +983,9 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/auth@^1.0.27-alpha.0": +"@budibase/backend-core@^1.0.27-alpha.0": version "1.0.27-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/auth/-/auth-1.0.27-alpha.0.tgz#8020c205d20d722983906426cb5a1aaf5cc6aba4" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/auth-1.0.27-alpha.0.tgz#8020c205d20d722983906426cb5a1aaf5cc6aba4" integrity sha512-sfXJjQJsFWfgElsHGHn7beERcsrUA5cotN2p9XEp15SrMeEmy4s9a6K58b779QB/d28GXKXtSJwmM/DrptJetQ== dependencies: "@techpass/passport-openidconnect" "^0.3.0" diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 9e941bd33d..6afabea706 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index a5632ca62b..d0f344e051 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.27-alpha.8", + "version": "1.0.27-alpha.12", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.27-alpha.8", - "@budibase/string-templates": "^1.0.27-alpha.8", + "@budibase/backend-core": "^1.0.27-alpha.12", + "@budibase/string-templates": "^1.0.27-alpha.12", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", diff --git a/packages/worker/src/api/controllers/app.js b/packages/worker/src/api/controllers/app.js index fa03c09c55..c08603e57e 100644 --- a/packages/worker/src/api/controllers/app.js +++ b/packages/worker/src/api/controllers/app.js @@ -2,7 +2,7 @@ const { getAllApps, getDeployedAppID, isProdAppID, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const CouchDB = require("../../db") const URL_REGEX_SLASH = /\/|\\/g diff --git a/packages/worker/src/api/controllers/global/auth.js b/packages/worker/src/api/controllers/global/auth.js index 93a15a6514..ef7f6fdfdc 100644 --- a/packages/worker/src/api/controllers/global/auth.js +++ b/packages/worker/src/api/controllers/global/auth.js @@ -1,7 +1,7 @@ -const authPkg = require("@budibase/auth") -const { getScopedConfig } = require("@budibase/auth/db") -const { google } = require("@budibase/auth/src/middleware") -const { oidc } = require("@budibase/auth/src/middleware") +const core = require("@budibase/backend-core") +const { getScopedConfig } = require("@budibase/backend-core/db") +const { google } = require("@budibase/backend-core/src/middleware") +const { oidc } = require("@budibase/backend-core/src/middleware") const { Configs, EmailTemplatePurpose } = require("../../../constants") const { sendEmail, isEmailConfigured } = require("../../../utilities/email") const { @@ -11,15 +11,15 @@ const { getGlobalUserByEmail, hash, platformLogout, -} = authPkg.utils -const { Cookies, Headers } = authPkg.constants -const { passport } = authPkg.auth +} = core.utils +const { Cookies, Headers } = core.constants +const { passport } = core.auth const { checkResetPasswordCode } = require("../../../utilities/redis") const { getGlobalDB, getTenantId, isMultiTenant, -} = require("@budibase/auth/tenancy") +} = require("@budibase/backend-core/tenancy") const env = require("../../../environment") const ssoCallbackUrl = async (config, type) => { @@ -152,7 +152,7 @@ exports.logout = async ctx => { exports.googlePreAuth = async (ctx, next) => { const db = getGlobalDB() - const config = await authPkg.db.getScopedConfig(db, { + const config = await core.db.getScopedConfig(db, { type: Configs.GOOGLE, workspace: ctx.query.workspace, }) @@ -167,7 +167,7 @@ exports.googlePreAuth = async (ctx, next) => { exports.googleAuth = async (ctx, next) => { const db = getGlobalDB() - const config = await authPkg.db.getScopedConfig(db, { + const config = await core.db.getScopedConfig(db, { type: Configs.GOOGLE, workspace: ctx.query.workspace, }) @@ -187,7 +187,7 @@ exports.googleAuth = async (ctx, next) => { async function oidcStrategyFactory(ctx, configId) { const db = getGlobalDB() - const config = await authPkg.db.getScopedConfig(db, { + const config = await core.db.getScopedConfig(db, { type: Configs.OIDC, group: ctx.query.group, }) diff --git a/packages/worker/src/api/controllers/global/configs.js b/packages/worker/src/api/controllers/global/configs.js index b6fcb9ee7d..fff4e277f7 100644 --- a/packages/worker/src/api/controllers/global/configs.js +++ b/packages/worker/src/api/controllers/global/configs.js @@ -4,12 +4,13 @@ const { getGlobalUserParams, getScopedFullConfig, getAllApps, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const { Configs } = require("../../../constants") const email = require("../../../utilities/email") -const { upload, ObjectStoreBuckets } = require("@budibase/auth").objectStore +const { upload, ObjectStoreBuckets } = + require("@budibase/backend-core").objectStore const CouchDB = require("../../../db") -const { getGlobalDB, getTenantId } = require("@budibase/auth/tenancy") +const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy") const env = require("../../../environment") const { googleCallbackUrl, oidcCallbackUrl } = require("./auth") diff --git a/packages/worker/src/api/controllers/global/email.js b/packages/worker/src/api/controllers/global/email.js index e194a30862..125376cdc2 100644 --- a/packages/worker/src/api/controllers/global/email.js +++ b/packages/worker/src/api/controllers/global/email.js @@ -1,5 +1,5 @@ const { sendEmail } = require("../../../utilities/email") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") exports.sendEmail = async ctx => { let { diff --git a/packages/worker/src/api/controllers/global/roles.js b/packages/worker/src/api/controllers/global/roles.js index 1aae07241e..3c977a6290 100644 --- a/packages/worker/src/api/controllers/global/roles.js +++ b/packages/worker/src/api/controllers/global/roles.js @@ -1,9 +1,9 @@ -const { getAllRoles } = require("@budibase/auth/roles") +const { getAllRoles } = require("@budibase/backend-core/roles") const { getAllApps, getDeployedAppID, DocumentTypes, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const CouchDB = require("../../../db") exports.fetch = async ctx => { diff --git a/packages/worker/src/api/controllers/global/sessions.js b/packages/worker/src/api/controllers/global/sessions.js index 170e97d690..4a334037d4 100644 --- a/packages/worker/src/api/controllers/global/sessions.js +++ b/packages/worker/src/api/controllers/global/sessions.js @@ -2,7 +2,7 @@ const { getAllSessions, getUserSessions, invalidateSessions, -} = require("@budibase/auth/sessions") +} = require("@budibase/backend-core/sessions") exports.fetch = async ctx => { ctx.body = await getAllSessions() diff --git a/packages/worker/src/api/controllers/global/templates.js b/packages/worker/src/api/controllers/global/templates.js index 0dc2b8abab..b16e9423ec 100644 --- a/packages/worker/src/api/controllers/global/templates.js +++ b/packages/worker/src/api/controllers/global/templates.js @@ -1,11 +1,11 @@ -const { generateTemplateID } = require("@budibase/auth/db") +const { generateTemplateID } = require("@budibase/backend-core/db") const { TemplateMetadata, TemplateBindings, GLOBAL_OWNER, } = require("../../../constants") const { getTemplates } = require("../../../constants/templates") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") exports.save = async ctx => { const db = getGlobalDB() diff --git a/packages/worker/src/api/controllers/global/users.js b/packages/worker/src/api/controllers/global/users.js index 1f85e316a2..5e96717f8e 100644 --- a/packages/worker/src/api/controllers/global/users.js +++ b/packages/worker/src/api/controllers/global/users.js @@ -2,22 +2,22 @@ const { getGlobalUserParams, StaticDatabases, generateNewUsageQuotaDoc, -} = require("@budibase/auth/db") +} = require("@budibase/backend-core/db") const { hash, getGlobalUserByEmail, saveUser, platformLogout } = - require("@budibase/auth").utils + require("@budibase/backend-core").utils const { EmailTemplatePurpose } = require("../../../constants") const { checkInviteCode } = require("../../../utilities/redis") const { sendEmail } = require("../../../utilities/email") -const { user: userCache } = require("@budibase/auth/cache") -const { invalidateSessions } = require("@budibase/auth/sessions") -const accounts = require("@budibase/auth/accounts") +const { user: userCache } = require("@budibase/backend-core/cache") +const { invalidateSessions } = require("@budibase/backend-core/sessions") +const accounts = require("@budibase/backend-core/accounts") const { getGlobalDB, getTenantId, getTenantUser, doesTenantExist, -} = require("@budibase/auth/tenancy") -const { removeUserFromInfoDB } = require("@budibase/auth/deprovision") +} = require("@budibase/backend-core/tenancy") +const { removeUserFromInfoDB } = require("@budibase/backend-core/deprovision") const env = require("../../../environment") const { syncUserInApps } = require("../../../utilities/appService") diff --git a/packages/worker/src/api/controllers/global/workspaces.js b/packages/worker/src/api/controllers/global/workspaces.js index 48a710c92d..d5d1037d9e 100644 --- a/packages/worker/src/api/controllers/global/workspaces.js +++ b/packages/worker/src/api/controllers/global/workspaces.js @@ -1,5 +1,8 @@ -const { getWorkspaceParams, generateWorkspaceID } = require("@budibase/auth/db") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { + getWorkspaceParams, + generateWorkspaceID, +} = require("@budibase/backend-core/db") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") exports.save = async function (ctx) { const db = getGlobalDB() diff --git a/packages/worker/src/api/controllers/system/tenants.js b/packages/worker/src/api/controllers/system/tenants.js index a96c5e5f9f..4d41ce894c 100644 --- a/packages/worker/src/api/controllers/system/tenants.js +++ b/packages/worker/src/api/controllers/system/tenants.js @@ -1,7 +1,7 @@ const CouchDB = require("../../../db") -const { StaticDatabases } = require("@budibase/auth/db") -const { getTenantId } = require("@budibase/auth/tenancy") -const { deleteTenant } = require("@budibase/auth/deprovision") +const { StaticDatabases } = require("@budibase/backend-core/db") +const { getTenantId } = require("@budibase/backend-core/tenancy") +const { deleteTenant } = require("@budibase/backend-core/deprovision") exports.exists = async ctx => { const tenantId = ctx.request.params diff --git a/packages/worker/src/api/index.js b/packages/worker/src/api/index.js index 3ed6a96ac1..dd9d1c3a53 100644 --- a/packages/worker/src/api/index.js +++ b/packages/worker/src/api/index.js @@ -3,7 +3,7 @@ const compress = require("koa-compress") const zlib = require("zlib") const { routes } = require("./routes") const { buildAuthMiddleware, auditLog, buildTenancyMiddleware } = - require("@budibase/auth").auth + require("@budibase/backend-core").auth const PUBLIC_ENDPOINTS = [ // old deprecated endpoints kept for backwards compat diff --git a/packages/worker/src/api/routes/global/auth.js b/packages/worker/src/api/routes/global/auth.js index 7baad60ecd..20c615b85a 100644 --- a/packages/worker/src/api/routes/global/auth.js +++ b/packages/worker/src/api/routes/global/auth.js @@ -2,7 +2,7 @@ const Router = require("@koa/router") const authController = require("../../controllers/global/auth") const joiValidator = require("../../../middleware/joi-validator") const Joi = require("joi") -const { updateTenantId } = require("@budibase/auth/tenancy") +const { updateTenantId } = require("@budibase/backend-core/tenancy") const router = Router() diff --git a/packages/worker/src/api/routes/tests/auth.spec.js b/packages/worker/src/api/routes/tests/auth.spec.js index 13a93f9cfb..f9dafc45da 100644 --- a/packages/worker/src/api/routes/tests/auth.spec.js +++ b/packages/worker/src/api/routes/tests/auth.spec.js @@ -54,7 +54,7 @@ describe("/api/global/auth", () => { }) describe("oidc", () => { - const auth = require("@budibase/auth").auth + const auth = require("@budibase/backend-core").auth // mock the oidc strategy implementation and return value strategyFactory = jest.fn() diff --git a/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js b/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js index c40b6d8dec..a8824b3db0 100644 --- a/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js +++ b/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js @@ -1,17 +1,17 @@ const env = require("../../../../environment") const controllers = require("./controllers") const supertest = require("supertest") -const { jwt } = require("@budibase/auth").auth -const { Cookies } = require("@budibase/auth").constants +const { jwt } = require("@budibase/backend-core").auth +const { Cookies } = require("@budibase/backend-core").constants const { Configs, LOGO_URL } = require("../../../../constants") -const { getGlobalUserByEmail } = require("@budibase/auth").utils -const { createASession } = require("@budibase/auth/sessions") -const { newid } = require("../../../../../../auth/src/hashing") +const { getGlobalUserByEmail } = require("@budibase/backend-core").utils +const { createASession } = require("@budibase/backend-core/sessions") +const { newid } = require("@budibase/backend-core/src/hashing") const { TENANT_ID } = require("./structures") -const auth = require("@budibase/auth") +const core = require("@budibase/backend-core") const CouchDB = require("../../../../db") -const { doInTenant } = require("@budibase/auth/tenancy") -auth.init(CouchDB) +const { doInTenant } = require("@budibase/backend-core/tenancy") +core.init(CouchDB) class TestConfiguration { constructor(openServer = true) { diff --git a/packages/worker/src/constants/index.js b/packages/worker/src/constants/index.js index a2bc818674..02393bd17c 100644 --- a/packages/worker/src/constants/index.js +++ b/packages/worker/src/constants/index.js @@ -1,4 +1,4 @@ -const { Configs } = require("@budibase/auth").constants +const { Configs } = require("@budibase/backend-core").constants exports.LOGO_URL = "https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg" diff --git a/packages/worker/src/constants/templates/index.js b/packages/worker/src/constants/templates/index.js index ac5427ba1f..cfca00f471 100644 --- a/packages/worker/src/constants/templates/index.js +++ b/packages/worker/src/constants/templates/index.js @@ -6,8 +6,8 @@ const { GLOBAL_OWNER, } = require("../index") const { join } = require("path") -const { getTemplateParams } = require("@budibase/auth/db") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { getTemplateParams } = require("@budibase/backend-core/db") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") exports.EmailTemplates = { [EmailTemplatePurpose.PASSWORD_RECOVERY]: readStaticFile( diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index 632e19280d..d7e7f5ff4f 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -1,7 +1,7 @@ const PouchDB = require("pouchdb") const allDbs = require("pouchdb-all-dbs") const env = require("../environment") -const { getCouchUrl } = require("@budibase/auth/db") +const { getCouchUrl } = require("@budibase/backend-core/db") // level option is purely for testing (development) const COUCH_DB_URL = getCouchUrl() || "http://localhost:10000/db/" diff --git a/packages/worker/src/index.js b/packages/worker/src/index.js index 77430268cd..fc0ab04873 100644 --- a/packages/worker/src/index.js +++ b/packages/worker/src/index.js @@ -1,12 +1,12 @@ // need to load environment first const env = require("./environment") const CouchDB = require("./db") -require("@budibase/auth").init(CouchDB) +require("@budibase/backend-core").init(CouchDB) const Koa = require("koa") const destroyable = require("server-destroy") const koaBody = require("koa-body") const koaSession = require("koa-session") -const { passport } = require("@budibase/auth").auth +const { passport } = require("@budibase/backend-core").auth const logger = require("koa-pino-logger") const http = require("http") const api = require("./api") diff --git a/packages/worker/src/middleware/cloudRestricted.js b/packages/worker/src/middleware/cloudRestricted.js index b29093f77e..817e193f8d 100644 --- a/packages/worker/src/middleware/cloudRestricted.js +++ b/packages/worker/src/middleware/cloudRestricted.js @@ -1,5 +1,5 @@ const env = require("../environment") -const { Headers } = require("@budibase/auth").constants +const { Headers } = require("@budibase/backend-core").constants /** * This is a restricted endpoint in the cloud. diff --git a/packages/worker/src/utilities/appService.js b/packages/worker/src/utilities/appService.js index 23c5581510..36785198d7 100644 --- a/packages/worker/src/utilities/appService.js +++ b/packages/worker/src/utilities/appService.js @@ -1,6 +1,6 @@ const fetch = require("node-fetch") -const { Headers } = require("@budibase/auth/constants") -const { getTenantId, isTenantIdSet } = require("@budibase/auth/tenancy") +const { Headers } = require("@budibase/backend-core/constants") +const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy") const { checkSlashesInUrl } = require("../utilities") const env = require("../environment") diff --git a/packages/worker/src/utilities/email.js b/packages/worker/src/utilities/email.js index f11ec90a27..ae3910ed1e 100644 --- a/packages/worker/src/utilities/email.js +++ b/packages/worker/src/utilities/email.js @@ -1,12 +1,12 @@ const nodemailer = require("nodemailer") const env = require("../environment") -const { getScopedConfig } = require("@budibase/auth/db") +const { getScopedConfig } = require("@budibase/backend-core/db") const { EmailTemplatePurpose, TemplateTypes, Configs } = require("../constants") const { getTemplateByPurpose } = require("../constants/templates") const { getSettingsTemplateContext } = require("./templates") const { processString } = require("@budibase/string-templates") const { getResetPasswordCode, getInviteCode } = require("../utilities/redis") -const { getGlobalDB } = require("@budibase/auth/tenancy") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") const TEST_MODE = false const TYPE = TemplateTypes.EMAIL diff --git a/packages/worker/src/utilities/redis.js b/packages/worker/src/utilities/redis.js index b644d1bc57..2954fcba0a 100644 --- a/packages/worker/src/utilities/redis.js +++ b/packages/worker/src/utilities/redis.js @@ -1,5 +1,5 @@ -const { Client, utils } = require("@budibase/auth/redis") -const { newid } = require("@budibase/auth").utils +const { Client, utils } = require("@budibase/backend-core/redis") +const { newid } = require("@budibase/backend-core").utils function getExpirySecondsForDB(db) { switch (db) { diff --git a/packages/worker/src/utilities/templates.js b/packages/worker/src/utilities/templates.js index f261d9ca33..6e559dec65 100644 --- a/packages/worker/src/utilities/templates.js +++ b/packages/worker/src/utilities/templates.js @@ -1,4 +1,4 @@ -const { getScopedConfig } = require("@budibase/auth/db") +const { getScopedConfig } = require("@budibase/backend-core/db") const { Configs, InternalTemplateBindings, @@ -6,7 +6,10 @@ const { EmailTemplatePurpose, } = require("../constants") const { checkSlashesInUrl } = require("./index") -const { getGlobalDB, addTenantToUrl } = require("@budibase/auth/tenancy") +const { + getGlobalDB, + addTenantToUrl, +} = require("@budibase/backend-core/tenancy") const BASE_COMPANY = "Budibase" exports.getSettingsTemplateContext = async (purpose, code = null) => {