From 13273947848ce1ec2fcfe79ac21c02203f1f40a6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 10 Jan 2022 19:33:00 +0000 Subject: [PATCH] Switching out @budibase/auth to @budibase/backend-core. --- packages/backend-core/README.md | 2 +- packages/server/package.json | 2 +- packages/server/scripts/replicateApp.js | 2 +- packages/server/src/api/controllers/apikeys.js | 4 ++-- packages/server/src/api/controllers/application.js | 11 +++++++---- packages/server/src/api/controllers/auth.js | 2 +- packages/server/src/api/controllers/cloud.js | 7 +++++-- .../server/src/api/controllers/deploy/index.js | 4 ++-- packages/server/src/api/controllers/dev.js | 4 ++-- packages/server/src/api/controllers/hosting.js | 4 ++-- packages/server/src/api/controllers/permission.js | 4 ++-- packages/server/src/api/controllers/role.js | 2 +- packages/server/src/api/controllers/routing.js | 2 +- .../src/api/controllers/row/internalSearch.js | 2 +- packages/server/src/api/controllers/screen.js | 2 +- packages/server/src/api/controllers/user.js | 9 ++++++--- packages/server/src/api/controllers/webhook.js | 2 +- packages/server/src/api/index.js | 2 +- packages/server/src/api/routes/apikeys.js | 2 +- packages/server/src/api/routes/application.js | 2 +- packages/server/src/api/routes/automation.js | 2 +- packages/server/src/api/routes/backup.js | 2 +- packages/server/src/api/routes/cloud.js | 2 +- packages/server/src/api/routes/component.js | 2 +- packages/server/src/api/routes/datasource.js | 2 +- packages/server/src/api/routes/deploy.js | 2 +- packages/server/src/api/routes/dev.js | 2 +- packages/server/src/api/routes/hosting.js | 2 +- packages/server/src/api/routes/integration.js | 2 +- packages/server/src/api/routes/layout.js | 2 +- packages/server/src/api/routes/metadata.js | 2 +- packages/server/src/api/routes/permission.js | 5 ++++- packages/server/src/api/routes/query.js | 2 +- packages/server/src/api/routes/role.js | 2 +- packages/server/src/api/routes/routing.js | 2 +- packages/server/src/api/routes/row.js | 2 +- packages/server/src/api/routes/screen.js | 2 +- packages/server/src/api/routes/script.js | 2 +- packages/server/src/api/routes/static.js | 2 +- packages/server/src/api/routes/table.js | 2 +- packages/server/src/api/routes/templates.js | 2 +- .../src/api/routes/tests/permissions.spec.js | 2 +- packages/server/src/api/routes/tests/query.spec.js | 2 +- packages/server/src/api/routes/tests/role.spec.js | 4 ++-- .../server/src/api/routes/tests/routing.spec.js | 2 +- packages/server/src/api/routes/tests/user.spec.js | 2 +- .../api/routes/tests/utilities/TestFunctions.js | 2 +- packages/server/src/api/routes/user.js | 2 +- packages/server/src/api/routes/view.js | 2 +- packages/server/src/api/routes/webhook.js | 2 +- packages/server/src/app.ts | 2 +- packages/server/src/automations/bullboard.js | 2 +- packages/server/src/automations/utils.js | 2 +- packages/server/src/constants/index.js | 6 +++--- packages/server/src/constants/screens.js | 2 +- packages/server/src/db/client.js | 2 +- packages/server/src/db/utils.js | 2 +- packages/server/src/middleware/authorized.js | 4 ++-- packages/server/src/middleware/builder.js | 4 ++-- packages/server/src/middleware/currentapp.js | 12 ++++++------ .../server/src/middleware/tests/authorized.spec.js | 4 ++-- .../server/src/middleware/tests/currentapp.spec.js | 12 ++++++------ .../server/src/middleware/tests/usageQuota.spec.js | 2 +- packages/server/src/middleware/usageQuota.js | 2 +- .../src/tests/utilities/TestConfiguration.js | 14 +++++++------- packages/server/src/tests/utilities/structures.js | 4 ++-- packages/server/src/threads/automation.js | 4 ++-- packages/server/src/threads/utils.js | 6 +++--- packages/server/src/utilities/budibaseDir.js | 2 +- .../server/src/utilities/fileSystem/utilities.js | 2 +- packages/server/src/utilities/global.js | 13 ++++++++----- packages/server/src/utilities/index.js | 2 +- packages/server/src/utilities/redis.js | 2 +- packages/server/src/utilities/security.js | 7 +++++-- packages/server/src/utilities/usageQuota.js | 4 ++-- packages/server/src/utilities/workerRequests.js | 6 +++--- packages/server/yarn.lock | 4 ++-- packages/worker/package.json | 2 +- packages/worker/src/api/controllers/app.js | 2 +- packages/worker/src/api/controllers/global/auth.js | 10 +++++----- .../worker/src/api/controllers/global/configs.js | 7 ++++--- .../worker/src/api/controllers/global/email.js | 2 +- .../worker/src/api/controllers/global/roles.js | 4 ++-- .../worker/src/api/controllers/global/sessions.js | 2 +- .../worker/src/api/controllers/global/templates.js | 4 ++-- .../worker/src/api/controllers/global/users.js | 14 +++++++------- .../src/api/controllers/global/workspaces.js | 7 +++++-- .../worker/src/api/controllers/system/tenants.js | 6 +++--- packages/worker/src/api/index.js | 2 +- packages/worker/src/api/routes/global/auth.js | 2 +- packages/worker/src/api/routes/tests/auth.spec.js | 2 +- .../routes/tests/utilities/TestConfiguration.js | 12 ++++++------ packages/worker/src/constants/index.js | 2 +- packages/worker/src/constants/templates/index.js | 4 ++-- packages/worker/src/db/index.js | 2 +- packages/worker/src/index.js | 4 ++-- packages/worker/src/middleware/cloudRestricted.js | 2 +- packages/worker/src/utilities/appService.js | 4 ++-- packages/worker/src/utilities/email.js | 4 ++-- packages/worker/src/utilities/redis.js | 4 ++-- packages/worker/src/utilities/templates.js | 7 +++++-- 101 files changed, 200 insertions(+), 175 deletions(-) diff --git a/packages/backend-core/README.md b/packages/backend-core/README.md index 4c6a474b5b..f36f80f84d 100644 --- a/packages/backend-core/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/server/package.json b/packages/server/package.json index 33b55d8785..2df34b41c5 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -70,7 +70,7 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/auth": "^1.0.27-alpha.7", + "@budibase/backend-core": "^1.0.27-alpha.7", "@budibase/client": "^1.0.27-alpha.7", "@budibase/string-templates": "^1.0.27-alpha.7", "@bull-board/api": "^3.7.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/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/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..2cb80a870a 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 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/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 7a64b1a039..ae47d19207 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 2b189b8660..bb5fa4de3f 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..59c3b1d7fb 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,12 +15,12 @@ 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 auth = 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) 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/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 c33ce083c1..9fe9978bad 100644 --- a/packages/server/src/utilities/fileSystem/utilities.js +++ b/packages/server/src/utilities/fileSystem/utilities.js @@ -8,7 +8,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/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 1980b13ef0..73fe83a170 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") function getNewQuotaReset() { return Date.now() + 2592000000 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/worker/package.json b/packages/worker/package.json index e64b982a17..e8301b6892 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -29,7 +29,7 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.27-alpha.7", + "@budibase/backend-core": "^1.0.27-alpha.7", "@budibase/string-templates": "^1.0.27-alpha.7", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.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..07eb1bf8e0 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 authPkg = 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 { @@ -19,7 +19,7 @@ const { getGlobalDB, getTenantId, isMultiTenant, -} = require("@budibase/auth/tenancy") +} = require("@budibase/backend-core/tenancy") const env = require("../../../environment") const ssoCallbackUrl = async (config, type) => { 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 87194a7ceb..3016255d70 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..05cfffac72 100644 --- a/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js +++ b/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js @@ -1,16 +1,16 @@ 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 { getGlobalUserByEmail } = require("@budibase/backend-core").utils +const { createASession } = require("@budibase/backend-core/sessions") const { newid } = require("../../../../../../auth/src/hashing") const { TENANT_ID } = require("./structures") -const auth = require("@budibase/auth") +const auth = require("@budibase/backend-core") const CouchDB = require("../../../../db") -const { doInTenant } = require("@budibase/auth/tenancy") +const { doInTenant } = require("@budibase/backend-core/tenancy") auth.init(CouchDB) class TestConfiguration { 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) => {