From 72534c6ed20559efb4d2d70cda140d5421759eb2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 31 Jan 2022 17:53:19 +0000 Subject: [PATCH] Refactoring backend-core tenancy to context, splitting out tenancy functionality to its own area. --- packages/backend-core/context.js | 2 +- packages/backend-core/deprovision.js | 2 +- .../backend-core/src/{tenancy => context}/FunctionContext.js | 0 packages/backend-core/src/{tenancy => context}/deprovision.js | 2 +- .../backend-core/src/{tenancy/context.js => context/index.js} | 0 packages/backend-core/src/middleware/appTenancy.js | 2 +- packages/backend-core/src/middleware/tenancy.js | 2 +- packages/backend-core/src/security/roles.js | 2 +- packages/backend-core/src/tenancy/index.js | 2 +- packages/backend-core/src/tenancy/tenancy.js | 2 +- 10 files changed, 8 insertions(+), 8 deletions(-) rename packages/backend-core/src/{tenancy => context}/FunctionContext.js (100%) rename packages/backend-core/src/{tenancy => context}/deprovision.js (98%) rename packages/backend-core/src/{tenancy/context.js => context/index.js} (100%) diff --git a/packages/backend-core/context.js b/packages/backend-core/context.js index 5cf9642392..4bc100687d 100644 --- a/packages/backend-core/context.js +++ b/packages/backend-core/context.js @@ -5,7 +5,7 @@ const { getAppId, updateAppId, doInAppContext, -} = require("./src/tenancy/context") +} = require("./src/context") module.exports = { getAppDB, diff --git a/packages/backend-core/deprovision.js b/packages/backend-core/deprovision.js index b4b8dc6110..672da214ff 100644 --- a/packages/backend-core/deprovision.js +++ b/packages/backend-core/deprovision.js @@ -1 +1 @@ -module.exports = require("./src/tenancy/deprovision") +module.exports = require("./src/context/deprovision") diff --git a/packages/backend-core/src/tenancy/FunctionContext.js b/packages/backend-core/src/context/FunctionContext.js similarity index 100% rename from packages/backend-core/src/tenancy/FunctionContext.js rename to packages/backend-core/src/context/FunctionContext.js diff --git a/packages/backend-core/src/tenancy/deprovision.js b/packages/backend-core/src/context/deprovision.js similarity index 98% rename from packages/backend-core/src/tenancy/deprovision.js rename to packages/backend-core/src/context/deprovision.js index 608ca1b84a..1fbc2c8398 100644 --- a/packages/backend-core/src/tenancy/deprovision.js +++ b/packages/backend-core/src/context/deprovision.js @@ -1,6 +1,6 @@ const { getGlobalUserParams, getAllApps } = require("../db/utils") const { getDB, getCouch } = require("../db") -const { getGlobalDB } = require("./tenancy") +const { getGlobalDB } = require("../tenancy") const { StaticDatabases } = require("../db/constants") const TENANT_DOC = StaticDatabases.PLATFORM_INFO.docs.tenants diff --git a/packages/backend-core/src/tenancy/context.js b/packages/backend-core/src/context/index.js similarity index 100% rename from packages/backend-core/src/tenancy/context.js rename to packages/backend-core/src/context/index.js diff --git a/packages/backend-core/src/middleware/appTenancy.js b/packages/backend-core/src/middleware/appTenancy.js index 60d7448af2..b0430a0051 100644 --- a/packages/backend-core/src/middleware/appTenancy.js +++ b/packages/backend-core/src/middleware/appTenancy.js @@ -5,7 +5,7 @@ const { DEFAULT_TENANT_ID, updateAppId, } = require("../tenancy") -const ContextFactory = require("../tenancy/FunctionContext") +const ContextFactory = require("../context/FunctionContext") const { getTenantIDFromAppID } = require("../db/utils") module.exports = () => { diff --git a/packages/backend-core/src/middleware/tenancy.js b/packages/backend-core/src/middleware/tenancy.js index adfd36a503..5bb81f8824 100644 --- a/packages/backend-core/src/middleware/tenancy.js +++ b/packages/backend-core/src/middleware/tenancy.js @@ -1,5 +1,5 @@ const { setTenantId } = require("../tenancy") -const ContextFactory = require("../tenancy/FunctionContext") +const ContextFactory = require("../context/FunctionContext") const { buildMatcherRegex, matches } = require("./matchers") module.exports = ( diff --git a/packages/backend-core/src/security/roles.js b/packages/backend-core/src/security/roles.js index ca61ab41c6..82bfbd5212 100644 --- a/packages/backend-core/src/security/roles.js +++ b/packages/backend-core/src/security/roles.js @@ -6,7 +6,7 @@ const { DocumentTypes, SEPARATOR, } = require("../db/utils") -const { getAppDB } = require("../tenancy/context") +const { getAppDB } = require("../context") const { getDB } = require("../db") const BUILTIN_IDS = { diff --git a/packages/backend-core/src/tenancy/index.js b/packages/backend-core/src/tenancy/index.js index 2fe257d885..c847033a12 100644 --- a/packages/backend-core/src/tenancy/index.js +++ b/packages/backend-core/src/tenancy/index.js @@ -1,4 +1,4 @@ module.exports = { - ...require("./context"), + ...require("../context"), ...require("./tenancy"), } diff --git a/packages/backend-core/src/tenancy/tenancy.js b/packages/backend-core/src/tenancy/tenancy.js index de597eac01..8360198b60 100644 --- a/packages/backend-core/src/tenancy/tenancy.js +++ b/packages/backend-core/src/tenancy/tenancy.js @@ -1,6 +1,6 @@ const { getDB } = require("../db") const { SEPARATOR, StaticDatabases, DocumentTypes } = require("../db/constants") -const { getTenantId, DEFAULT_TENANT_ID, isMultiTenant } = require("./context") +const { getTenantId, DEFAULT_TENANT_ID, isMultiTenant } = require("../context") const env = require("../environment") const TENANT_DOC = StaticDatabases.PLATFORM_INFO.docs.tenants