@webiny/api-serverless-cms 5.41.4 → 5.42.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -13,7 +13,9 @@ import { PbAcoContext } from "@webiny/api-page-builder-aco/types";
13
13
  import { ContextPluginCallable } from "@webiny/api";
14
14
  import { GraphQLSchemaPluginConfig } from "@webiny/handler-graphql";
15
15
  import { createSecurityRolePlugin, createSecurityTeamPlugin } from "@webiny/api-security";
16
- export interface Context extends ClientContext, TenancyContext, SecurityContext, I18NContext, I18NContentContext, PbContext, PrerenderingServiceClientContext, FileManagerContext, FormBuilderContext, AcoContext, PbAcoContext, CmsContext {
16
+ import { MailerContext } from "@webiny/api-mailer/types";
17
+ import { Context as LoggerContext } from "@webiny/api-log/types";
18
+ export interface Context extends ClientContext, MailerContext, TenancyContext, SecurityContext, I18NContext, I18NContentContext, PbContext, PrerenderingServiceClientContext, FileManagerContext, FormBuilderContext, AcoContext, PbAcoContext, LoggerContext, CmsContext {
17
19
  }
18
20
  export declare const createContextPlugin: <T extends Context = Context>(callable: ContextPluginCallable<T>) => import("@webiny/api").ContextPlugin<T>;
19
21
  export declare const createGraphQLSchemaPlugin: <T extends Context = Context>(config: GraphQLSchemaPluginConfig<T>) => import("@webiny/handler-graphql").GraphQLSchemaPlugin<T>;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","_handlerGraphql","_apiSecurity","_InstallTenant","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","createContextPlugin","callable","baseCreateContextPlugin","createGraphQLSchemaPlugin","config","baseCreateGraphQLSchemaPlugin"],"sources":["index.ts"],"sourcesContent":["import { ClientContext } from \"@webiny/handler-client/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext } from \"@webiny/api-security/types\";\nimport { I18NContext } from \"@webiny/api-i18n/types\";\nimport { I18NContentContext } from \"@webiny/api-i18n-content/types\";\nimport { PbContext } from \"@webiny/api-page-builder/graphql/types\";\nimport { PrerenderingServiceClientContext } from \"@webiny/api-prerendering-service/client/types\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoContext } from \"@webiny/api-aco/types\";\nimport { PbAcoContext } from \"@webiny/api-page-builder-aco/types\";\nimport { createContextPlugin as baseCreateContextPlugin, ContextPluginCallable } from \"@webiny/api\";\nimport {\n createGraphQLSchemaPlugin as baseCreateGraphQLSchemaPlugin,\n GraphQLSchemaPluginConfig\n} from \"@webiny/handler-graphql\";\nimport { createSecurityRolePlugin, createSecurityTeamPlugin } from \"@webiny/api-security\";\n\nexport interface Context\n extends ClientContext,\n TenancyContext,\n SecurityContext,\n I18NContext,\n I18NContentContext,\n PbContext,\n PrerenderingServiceClientContext,\n FileManagerContext,\n FormBuilderContext,\n AcoContext,\n PbAcoContext,\n CmsContext {}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n) => {\n return baseCreateContextPlugin<T>(callable);\n};\n\nexport const createGraphQLSchemaPlugin = <T extends Context = Context>(\n config: GraphQLSchemaPluginConfig<T>\n) => {\n return baseCreateGraphQLSchemaPlugin<T>(config);\n};\n\nexport { createSecurityRolePlugin, createSecurityTeamPlugin };\n\nexport * from \"./tenancy/InstallTenant\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAIA,IAAAE,YAAA,GAAAF,OAAA;AA8BA,IAAAG,cAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,cAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,cAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,cAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAdO,MAAMS,mBAAmB,GAC5BC,QAAkC,IACjC;EACD,OAAO,IAAAC,wBAAuB,EAAID,QAAQ,CAAC;AAC/C,CAAC;AAACL,OAAA,CAAAI,mBAAA,GAAAA,mBAAA;AAEK,MAAMG,yBAAyB,GAClCC,MAAoC,IACnC;EACD,OAAO,IAAAC,yCAA6B,EAAID,MAAM,CAAC;AACnD,CAAC;AAACR,OAAA,CAAAO,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_api","require","_handlerGraphql","_apiSecurity","_InstallTenant","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","createContextPlugin","callable","baseCreateContextPlugin","createGraphQLSchemaPlugin","config","baseCreateGraphQLSchemaPlugin"],"sources":["index.ts"],"sourcesContent":["import { ClientContext } from \"@webiny/handler-client/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext } from \"@webiny/api-security/types\";\nimport { I18NContext } from \"@webiny/api-i18n/types\";\nimport { I18NContentContext } from \"@webiny/api-i18n-content/types\";\nimport { PbContext } from \"@webiny/api-page-builder/graphql/types\";\nimport { PrerenderingServiceClientContext } from \"@webiny/api-prerendering-service/client/types\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoContext } from \"@webiny/api-aco/types\";\nimport { PbAcoContext } from \"@webiny/api-page-builder-aco/types\";\nimport { ContextPluginCallable, createContextPlugin as baseCreateContextPlugin } from \"@webiny/api\";\nimport {\n createGraphQLSchemaPlugin as baseCreateGraphQLSchemaPlugin,\n GraphQLSchemaPluginConfig\n} from \"@webiny/handler-graphql\";\nimport { createSecurityRolePlugin, createSecurityTeamPlugin } from \"@webiny/api-security\";\nimport { MailerContext } from \"@webiny/api-mailer/types\";\nimport { Context as LoggerContext } from \"@webiny/api-log/types\";\n\nexport interface Context\n extends ClientContext,\n MailerContext,\n TenancyContext,\n SecurityContext,\n I18NContext,\n I18NContentContext,\n PbContext,\n PrerenderingServiceClientContext,\n FileManagerContext,\n FormBuilderContext,\n AcoContext,\n PbAcoContext,\n LoggerContext,\n CmsContext {}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n) => {\n return baseCreateContextPlugin<T>(callable);\n};\n\nexport const createGraphQLSchemaPlugin = <T extends Context = Context>(\n config: GraphQLSchemaPluginConfig<T>\n) => {\n return baseCreateGraphQLSchemaPlugin<T>(config);\n};\n\nexport { createSecurityRolePlugin, createSecurityTeamPlugin };\n\nexport * from \"./tenancy/InstallTenant\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAIA,IAAAE,YAAA,GAAAF,OAAA;AAkCA,IAAAG,cAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,cAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,cAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,cAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAdO,MAAMS,mBAAmB,GAC5BC,QAAkC,IACjC;EACD,OAAO,IAAAC,wBAAuB,EAAID,QAAQ,CAAC;AAC/C,CAAC;AAACL,OAAA,CAAAI,mBAAA,GAAAA,mBAAA;AAEK,MAAMG,yBAAyB,GAClCC,MAAoC,IACnC;EACD,OAAO,IAAAC,yCAA6B,EAAID,MAAM,CAAC;AACnD,CAAC;AAACR,OAAA,CAAAO,yBAAA,GAAAA,yBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-serverless-cms",
3
- "version": "5.41.4",
3
+ "version": "5.42.0-beta.1",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,45 +9,43 @@
9
9
  "description": "Core package for all of our API packages.",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@webiny/api": "5.41.4",
13
- "@webiny/api-aco": "5.41.4",
14
- "@webiny/api-file-manager": "5.41.4",
15
- "@webiny/api-form-builder": "5.41.4",
16
- "@webiny/api-headless-cms": "5.41.4",
17
- "@webiny/api-i18n": "5.41.4",
18
- "@webiny/api-i18n-content": "5.41.4",
19
- "@webiny/api-page-builder": "5.41.4",
20
- "@webiny/api-page-builder-aco": "5.41.4",
21
- "@webiny/api-prerendering-service": "5.41.4",
22
- "@webiny/api-security": "5.41.4",
23
- "@webiny/api-tenancy": "5.41.4",
24
- "@webiny/error": "5.41.4",
25
- "@webiny/handler-client": "5.41.4",
26
- "@webiny/handler-graphql": "5.41.4"
12
+ "@webiny/api": "5.42.0-beta.1",
13
+ "@webiny/api-aco": "5.42.0-beta.1",
14
+ "@webiny/api-file-manager": "5.42.0-beta.1",
15
+ "@webiny/api-form-builder": "5.42.0-beta.1",
16
+ "@webiny/api-headless-cms": "5.42.0-beta.1",
17
+ "@webiny/api-i18n": "5.42.0-beta.1",
18
+ "@webiny/api-i18n-content": "5.42.0-beta.1",
19
+ "@webiny/api-log": "5.42.0-beta.1",
20
+ "@webiny/api-mailer": "5.42.0-beta.1",
21
+ "@webiny/api-page-builder": "5.42.0-beta.1",
22
+ "@webiny/api-page-builder-aco": "5.42.0-beta.1",
23
+ "@webiny/api-prerendering-service": "5.42.0-beta.1",
24
+ "@webiny/api-security": "5.42.0-beta.1",
25
+ "@webiny/api-tenancy": "5.42.0-beta.1",
26
+ "@webiny/error": "5.42.0-beta.1",
27
+ "@webiny/handler-client": "5.42.0-beta.1",
28
+ "@webiny/handler-graphql": "5.42.0-beta.1"
27
29
  },
28
30
  "devDependencies": {
29
- "@babel/cli": "7.24.1",
30
- "@babel/core": "7.24.3",
31
- "@babel/preset-env": "7.24.3",
32
- "@babel/preset-typescript": "7.24.1",
33
- "@webiny/api-admin-users": "5.41.4",
34
- "@webiny/api-apw": "5.41.4",
35
- "@webiny/api-audit-logs": "5.41.4",
36
- "@webiny/api-headless-cms-aco": "5.41.4",
37
- "@webiny/api-headless-cms-tasks": "5.41.4",
38
- "@webiny/api-page-builder-import-export": "5.41.4",
39
- "@webiny/api-page-builder-import-export-so-ddb": "5.41.4",
40
- "@webiny/api-record-locking": "5.41.4",
41
- "@webiny/api-wcp": "5.41.4",
42
- "@webiny/api-websockets": "5.41.4",
43
- "@webiny/cli": "5.41.4",
44
- "@webiny/handler": "5.41.4",
45
- "@webiny/handler-aws": "5.41.4",
46
- "@webiny/plugins": "5.41.4",
47
- "@webiny/project-utils": "5.41.4",
48
- "@webiny/tasks": "5.41.4",
49
- "graphql": "15.8.0",
50
- "rimraf": "5.0.5",
31
+ "@webiny/api-admin-users": "5.42.0-beta.1",
32
+ "@webiny/api-apw": "5.42.0-beta.1",
33
+ "@webiny/api-audit-logs": "5.42.0-beta.1",
34
+ "@webiny/api-headless-cms-aco": "5.42.0-beta.1",
35
+ "@webiny/api-headless-cms-tasks": "5.42.0-beta.1",
36
+ "@webiny/api-page-builder-import-export": "5.42.0-beta.1",
37
+ "@webiny/api-page-builder-import-export-so-ddb": "5.42.0-beta.1",
38
+ "@webiny/api-record-locking": "5.42.0-beta.1",
39
+ "@webiny/api-wcp": "5.42.0-beta.1",
40
+ "@webiny/api-websockets": "5.42.0-beta.1",
41
+ "@webiny/cli": "5.42.0-beta.1",
42
+ "@webiny/handler": "5.42.0-beta.1",
43
+ "@webiny/handler-aws": "5.42.0-beta.1",
44
+ "@webiny/plugins": "5.42.0-beta.1",
45
+ "@webiny/project-utils": "5.42.0-beta.1",
46
+ "@webiny/tasks": "5.42.0-beta.1",
47
+ "graphql": "15.9.0",
48
+ "rimraf": "6.0.1",
51
49
  "ttypescript": "1.5.15",
52
50
  "typescript": "4.9.5"
53
51
  },
@@ -59,5 +57,5 @@
59
57
  "build": "yarn webiny run build",
60
58
  "watch": "yarn webiny run watch"
61
59
  },
62
- "gitHead": "94922b33af59db5afe75127bb07443ce7f1448c4"
60
+ "gitHead": "5e69da579efa4f2c8268e0c97ac6407ddc3f5f07"
63
61
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","InstallTenant","constructor","context","execute","tenant","config","currentTenant","tenancy","getCurrentTenant","fmSettings","fileManager","getSettings","setCurrentTenant","setVersion","WEBINY_VERSION","runOrThrow","isInstalled","security","getVersion","install","adminUsers","i18n","system","getSystemVersion","installSystem","code","defaultLocaleCode","cms","srcPrefix","URL","assetDeliveryDomain","origin","pageBuilder","name","websiteName","insertDemoData","formBuilder","cb","errorCode","err","Error","message","data","error","exports"],"sources":["InstallTenant.ts"],"sourcesContent":["import { Tenant } from \"@webiny/api-tenancy/types\";\nimport Error from \"@webiny/error\";\nimport { Context } from \"~/index\";\n\nexport interface AdminUserInput {\n firstName: string;\n lastName: string;\n email: string;\n password: string;\n group?: string;\n}\n\nexport type AdminUsersInstallationConfig = AdminUserInput | undefined;\n\nexport interface I18nInstallationConfig {\n defaultLocaleCode: string;\n}\n\nexport interface FileManagerInstallationConfig {\n /**\n * Asset delivery origin. This usually points to the main Webiny API origin.\n * E.g., https://some.domain.com/\n *\n * You can change this later in the tenant's File Manager settings.\n */\n assetDeliveryDomain: string;\n}\n\nexport interface PageBuilderInstallationConfig {\n websiteName: string;\n insertDemoData: boolean;\n}\n\nexport interface TenantConfig {\n i18n: I18nInstallationConfig;\n adminUsers?: AdminUsersInstallationConfig;\n fileManager?: FileManagerInstallationConfig;\n pageBuilder?: PageBuilderInstallationConfig;\n}\n\nexport class InstallTenant {\n private readonly context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n async execute(tenant: Tenant, config: TenantConfig): Promise<void> {\n const currentTenant = this.context.tenancy.getCurrentTenant();\n\n // Get current tenant's FileManager settings.\n const fmSettings = await this.context.fileManager.getSettings();\n\n // Switch tenant to the one being installed.\n this.context.tenancy.setCurrentTenant(tenant);\n\n try {\n // TENANCY: Set the app version, as the tenant is already created.\n await this.context.tenancy.setVersion(this.context.WEBINY_VERSION);\n\n // SECURITY: Create initial security groups.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.security.getVersion();\n if (!isInstalled) {\n await this.context.security.install();\n }\n }, \"SECURITY_INSTALL\");\n\n // ADMIN USERS: Optionally, create an admin user for this tenant.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.adminUsers.getVersion();\n if (isInstalled) {\n return;\n }\n\n if (config.adminUsers) {\n await this.context.adminUsers.install(config.adminUsers);\n } else {\n // We always mark `adminUsers` as installed, regardless of the config.\n await this.context.adminUsers.setVersion(this.context.WEBINY_VERSION);\n }\n }, \"ADMIN_USERS_INSTALL\");\n\n // I18N: Create a default locale.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.i18n.system.getSystemVersion();\n if (isInstalled) {\n return;\n }\n\n await this.context.i18n.system.installSystem({\n code: config.i18n.defaultLocaleCode\n });\n }, \"I18N_INSTALL\");\n\n // CMS\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.cms.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.cms.installSystem();\n }, \"CMS_INSTALL\");\n\n // FILE MANAGER: Create File Manager settings.\n const srcPrefix = config.fileManager\n ? `${new URL(config.fileManager.assetDeliveryDomain).origin}/files/`\n : fmSettings?.srcPrefix;\n\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.fileManager.getVersion();\n if (isInstalled) {\n return;\n }\n\n await this.context.fileManager.install({ srcPrefix: srcPrefix || \"\" });\n }, \"FILE_MANAGER_INSTALL\");\n\n // PAGE BUILDER: Create Page Builder settings.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.pageBuilder.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.pageBuilder.installSystem({\n name: config.pageBuilder?.websiteName ?? tenant.name,\n insertDemoData: config.pageBuilder?.insertDemoData ?? false\n });\n }, \"PAGE_BUILDER_INSTALL\");\n\n // FORM BUILDER\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.formBuilder.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.formBuilder.installSystem({});\n }, \"FORM_BUILDER_INSTALL\");\n } finally {\n this.context.tenancy.setCurrentTenant(currentTenant);\n }\n }\n\n private async runOrThrow(cb: () => Promise<void>, errorCode: string): Promise<void> {\n try {\n await cb();\n } catch (err) {\n throw new Error({\n message: err.message,\n code: `INSTALL_TENANT:${errorCode}`,\n data: {\n error: err\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAuCO,MAAMC,aAAa,CAAC;EAGvBC,WAAWA,CAACC,OAAgB,EAAE;IAC1B,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,MAAc,EAAEC,MAAoB,EAAiB;IAC/D,MAAMC,aAAa,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACC,gBAAgB,CAAC,CAAC;;IAE7D;IACA,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACP,OAAO,CAACQ,WAAW,CAACC,WAAW,CAAC,CAAC;;IAE/D;IACA,IAAI,C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,MAAM,IAAI,CAACpB,UAAU,CAAC,YAAY;QAC9B,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACd,OAAO,CAACkC,WAAW,CAACb,gBAAgB,CAAC,CAAC;QACrE,IAAIP,WAAW,EAAE;UACb;QACJ;QACA,MAAM,IAAI,CAACd,OAAO,CAACkC,WAAW,CAACZ,aAAa,CAAC,CAAC,CAAC,CAAC;MACpD,CAAC,EAAE,sBAAsB,CAAC;IAC9B,CAAC,SAAS;MACN,IAAI,CAACtB,OAAO,CAACK,OAAO,CAACK,gBAAgB,CAACN,aAAa,CAAC;IACxD;EACJ;EAEA,MAAcS,UAAUA,CAACsB,EAAuB,EAAEC,SAAiB,EAAiB;IAChF,IAAI;MACA,MAAMD,EAAE,CAAC,CAAC;IACd,CAAC,CAAC,OAAOE,GAAG,EAAE;MACV,MAAM,IAAIC,cAAK,CAAC;QACZC,OAAO,EAAEF,GAAG,CAACE,OAAO;QACpBhB,IAAI,EAAG,kBAAiBa,SAAU,EAAC;QACnCI,IAAI,EAAE;UACFC,KAAK,EAAEJ;QACX;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAACK,OAAA,CAAA5C,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","InstallTenant","constructor","context","execute","tenant","config","currentTenant","tenancy","getCurrentTenant","fmSettings","fileManager","getSettings","setCurrentTenant","setVersion","WEBINY_VERSION","runOrThrow","isInstalled","security","getVersion","install","adminUsers","i18n","system","getSystemVersion","installSystem","code","defaultLocaleCode","cms","srcPrefix","URL","assetDeliveryDomain","origin","pageBuilder","name","websiteName","insertDemoData","formBuilder","cb","errorCode","err","Error","message","data","error","exports"],"sources":["InstallTenant.ts"],"sourcesContent":["import { Tenant } from \"@webiny/api-tenancy/types\";\nimport Error from \"@webiny/error\";\nimport { Context } from \"~/index\";\n\nexport interface AdminUserInput {\n firstName: string;\n lastName: string;\n email: string;\n password: string;\n group?: string;\n}\n\nexport type AdminUsersInstallationConfig = AdminUserInput | undefined;\n\nexport interface I18nInstallationConfig {\n defaultLocaleCode: string;\n}\n\nexport interface FileManagerInstallationConfig {\n /**\n * Asset delivery origin. This usually points to the main Webiny API origin.\n * E.g., https://some.domain.com/\n *\n * You can change this later in the tenant's File Manager settings.\n */\n assetDeliveryDomain: string;\n}\n\nexport interface PageBuilderInstallationConfig {\n websiteName: string;\n insertDemoData: boolean;\n}\n\nexport interface TenantConfig {\n i18n: I18nInstallationConfig;\n adminUsers?: AdminUsersInstallationConfig;\n fileManager?: FileManagerInstallationConfig;\n pageBuilder?: PageBuilderInstallationConfig;\n}\n\nexport class InstallTenant {\n private readonly context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n async execute(tenant: Tenant, config: TenantConfig): Promise<void> {\n const currentTenant = this.context.tenancy.getCurrentTenant();\n\n // Get current tenant's FileManager settings.\n const fmSettings = await this.context.fileManager.getSettings();\n\n // Switch tenant to the one being installed.\n this.context.tenancy.setCurrentTenant(tenant);\n\n try {\n // TENANCY: Set the app version, as the tenant is already created.\n await this.context.tenancy.setVersion(this.context.WEBINY_VERSION);\n\n // SECURITY: Create initial security groups.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.security.getVersion();\n if (!isInstalled) {\n await this.context.security.install();\n }\n }, \"SECURITY_INSTALL\");\n\n // ADMIN USERS: Optionally, create an admin user for this tenant.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.adminUsers.getVersion();\n if (isInstalled) {\n return;\n }\n\n if (config.adminUsers) {\n await this.context.adminUsers.install(config.adminUsers);\n } else {\n // We always mark `adminUsers` as installed, regardless of the config.\n await this.context.adminUsers.setVersion(this.context.WEBINY_VERSION);\n }\n }, \"ADMIN_USERS_INSTALL\");\n\n // I18N: Create a default locale.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.i18n.system.getSystemVersion();\n if (isInstalled) {\n return;\n }\n\n await this.context.i18n.system.installSystem({\n code: config.i18n.defaultLocaleCode\n });\n }, \"I18N_INSTALL\");\n\n // CMS\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.cms.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.cms.installSystem();\n }, \"CMS_INSTALL\");\n\n // FILE MANAGER: Create File Manager settings.\n const srcPrefix = config.fileManager\n ? `${new URL(config.fileManager.assetDeliveryDomain).origin}/files/`\n : fmSettings?.srcPrefix;\n\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.fileManager.getVersion();\n if (isInstalled) {\n return;\n }\n\n await this.context.fileManager.install({ srcPrefix: srcPrefix || \"\" });\n }, \"FILE_MANAGER_INSTALL\");\n\n // PAGE BUILDER: Create Page Builder settings.\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.pageBuilder.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.pageBuilder.installSystem({\n name: config.pageBuilder?.websiteName ?? tenant.name,\n insertDemoData: config.pageBuilder?.insertDemoData ?? false\n });\n }, \"PAGE_BUILDER_INSTALL\");\n\n // FORM BUILDER\n await this.runOrThrow(async () => {\n const isInstalled = await this.context.formBuilder.getSystemVersion();\n if (isInstalled) {\n return;\n }\n await this.context.formBuilder.installSystem({});\n }, \"FORM_BUILDER_INSTALL\");\n } finally {\n this.context.tenancy.setCurrentTenant(currentTenant);\n }\n }\n\n private async runOrThrow(cb: () => Promise<void>, errorCode: string): Promise<void> {\n try {\n await cb();\n } catch (err) {\n throw new Error({\n message: err.message,\n code: `INSTALL_TENANT:${errorCode}`,\n data: {\n error: err\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAuCO,MAAMC,aAAa,CAAC;EAGvBC,WAAWA,CAACC,OAAgB,EAAE;IAC1B,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,MAAc,EAAEC,MAAoB,EAAiB;IAC/D,MAAMC,aAAa,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACC,g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