@strapi/strapi 4.16.2 → 4.18.0

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.
Files changed (102) hide show
  1. package/dist/Strapi.d.ts.map +1 -1
  2. package/dist/Strapi.js +2 -1
  3. package/dist/Strapi.js.map +1 -1
  4. package/dist/Strapi.mjs +2 -1
  5. package/dist/Strapi.mjs.map +1 -1
  6. package/dist/admin.d.ts +2 -2
  7. package/dist/admin.d.ts.map +1 -1
  8. package/dist/admin.js.map +1 -1
  9. package/dist/admin.mjs.map +1 -1
  10. package/dist/commands/actions/plugin/build-command/action.d.ts +2 -1
  11. package/dist/commands/actions/plugin/build-command/action.d.ts.map +1 -1
  12. package/dist/commands/actions/plugin/build-command/action.js +3 -6
  13. package/dist/commands/actions/plugin/build-command/action.js.map +1 -1
  14. package/dist/commands/actions/plugin/build-command/command.js +2 -2
  15. package/dist/commands/actions/plugin/build-command/command.js.map +1 -1
  16. package/dist/commands/actions/plugin/init/action.d.ts +7 -0
  17. package/dist/commands/actions/plugin/init/action.d.ts.map +1 -0
  18. package/dist/commands/actions/plugin/init/action.js +418 -0
  19. package/dist/commands/actions/plugin/init/action.js.map +1 -0
  20. package/dist/commands/actions/plugin/init/command.d.ts +7 -0
  21. package/dist/commands/actions/plugin/init/command.d.ts.map +1 -0
  22. package/dist/commands/actions/plugin/init/command.js +9 -0
  23. package/dist/commands/actions/plugin/init/command.js.map +1 -0
  24. package/dist/commands/actions/plugin/init/files/admin.d.ts +5 -0
  25. package/dist/commands/actions/plugin/init/files/admin.d.ts.map +1 -0
  26. package/dist/commands/actions/plugin/init/files/admin.js +283 -0
  27. package/dist/commands/actions/plugin/init/files/admin.js.map +1 -0
  28. package/dist/commands/actions/plugin/init/files/editorConfig.d.ts +4 -0
  29. package/dist/commands/actions/plugin/init/files/editorConfig.d.ts.map +1 -0
  30. package/dist/commands/actions/plugin/init/files/editorConfig.js +26 -0
  31. package/dist/commands/actions/plugin/init/files/editorConfig.js.map +1 -0
  32. package/dist/commands/actions/plugin/init/files/eslint.d.ts +4 -0
  33. package/dist/commands/actions/plugin/init/files/eslint.d.ts.map +1 -0
  34. package/dist/commands/actions/plugin/init/files/eslint.js +11 -0
  35. package/dist/commands/actions/plugin/init/files/eslint.js.map +1 -0
  36. package/dist/commands/actions/plugin/init/files/gitIgnore.d.ts +4 -0
  37. package/dist/commands/actions/plugin/init/files/gitIgnore.d.ts.map +1 -0
  38. package/dist/commands/actions/plugin/init/files/gitIgnore.js +34 -0
  39. package/dist/commands/actions/plugin/init/files/gitIgnore.js.map +1 -0
  40. package/dist/commands/actions/plugin/init/files/prettier.d.ts +5 -0
  41. package/dist/commands/actions/plugin/init/files/prettier.d.ts.map +1 -0
  42. package/dist/commands/actions/plugin/init/files/prettier.js +25 -0
  43. package/dist/commands/actions/plugin/init/files/prettier.js.map +1 -0
  44. package/dist/commands/actions/plugin/init/files/server.d.ts +5 -0
  45. package/dist/commands/actions/plugin/init/files/server.d.ts.map +1 -0
  46. package/dist/commands/actions/plugin/init/files/server.js +360 -0
  47. package/dist/commands/actions/plugin/init/files/server.js.map +1 -0
  48. package/dist/commands/actions/plugin/init/files/typescript.d.ts +9 -0
  49. package/dist/commands/actions/plugin/init/files/typescript.d.ts.map +1 -0
  50. package/dist/commands/actions/plugin/init/files/typescript.js +66 -0
  51. package/dist/commands/actions/plugin/init/files/typescript.js.map +1 -0
  52. package/dist/commands/actions/plugin/link-watch/action.d.ts +6 -0
  53. package/dist/commands/actions/plugin/link-watch/action.d.ts.map +1 -0
  54. package/dist/commands/actions/plugin/link-watch/action.js +86 -0
  55. package/dist/commands/actions/plugin/link-watch/action.js.map +1 -0
  56. package/dist/commands/actions/plugin/link-watch/command.d.ts +7 -0
  57. package/dist/commands/actions/plugin/link-watch/command.d.ts.map +1 -0
  58. package/dist/commands/actions/plugin/link-watch/command.js +8 -0
  59. package/dist/commands/actions/plugin/link-watch/command.js.map +1 -0
  60. package/dist/commands/actions/plugin/verify/action.d.ts +7 -0
  61. package/dist/commands/actions/plugin/verify/action.d.ts.map +1 -0
  62. package/dist/commands/actions/plugin/verify/action.js +34 -0
  63. package/dist/commands/actions/plugin/verify/action.js.map +1 -0
  64. package/dist/commands/actions/plugin/verify/command.d.ts +7 -0
  65. package/dist/commands/actions/plugin/verify/command.d.ts.map +1 -0
  66. package/dist/commands/actions/plugin/verify/command.js +8 -0
  67. package/dist/commands/actions/plugin/verify/command.js.map +1 -0
  68. package/dist/commands/actions/plugin/watch/action.d.ts +2 -2
  69. package/dist/commands/actions/plugin/watch/action.d.ts.map +1 -1
  70. package/dist/commands/actions/plugin/watch/action.js +4 -7
  71. package/dist/commands/actions/plugin/watch/action.js.map +1 -1
  72. package/dist/commands/actions/plugin/watch/command.d.ts +1 -1
  73. package/dist/commands/actions/plugin/watch/command.js +2 -2
  74. package/dist/commands/actions/plugin/watch/command.js.map +1 -1
  75. package/dist/commands/actions/watch-admin/action.d.ts +2 -2
  76. package/dist/commands/actions/watch-admin/action.d.ts.map +1 -1
  77. package/dist/commands/actions/watch-admin/action.js +1 -1
  78. package/dist/commands/actions/watch-admin/action.js.map +1 -1
  79. package/dist/commands/actions/watch-admin/command.js +2 -2
  80. package/dist/commands/actions/watch-admin/command.js.map +1 -1
  81. package/dist/commands/index.d.ts +3 -0
  82. package/dist/commands/index.d.ts.map +1 -1
  83. package/dist/commands/index.js +8 -2
  84. package/dist/commands/index.js.map +1 -1
  85. package/dist/commands/utils/logger.js.map +1 -1
  86. package/dist/commands/utils/pkg.d.ts +2 -0
  87. package/dist/commands/utils/pkg.d.ts.map +1 -1
  88. package/dist/commands/utils/pkg.js +1 -0
  89. package/dist/commands/utils/pkg.js.map +1 -1
  90. package/dist/factories.js +2 -2
  91. package/dist/factories.js.map +1 -1
  92. package/dist/factories.mjs +2 -2
  93. package/dist/factories.mjs.map +1 -1
  94. package/dist/middlewares/security.d.ts.map +1 -1
  95. package/dist/middlewares/security.js +10 -0
  96. package/dist/middlewares/security.js.map +1 -1
  97. package/dist/middlewares/security.mjs +10 -0
  98. package/dist/middlewares/security.mjs.map +1 -1
  99. package/dist/services/entity-validator/index.js.map +1 -1
  100. package/dist/services/entity-validator/index.mjs.map +1 -1
  101. package/dist/utils/startup-logger.js.map +1 -1
  102. package/package.json +27 -21
@@ -1 +1 @@
1
- {"version":3,"file":"Strapi.d.ts","sourceRoot":"","sources":["../src/Strapi.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EACV,MAAM,IAAI,OAAO,EACjB,MAAM,EACN,SAAS,EACT,aAAa,EACb,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,MAAM,EACN,MAAM,EACN,MAAM,EACP,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,OAAO,MAAM,WAAW,CAAC;AAOhC,OAA4B,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAqC/E,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AA8D7E,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE5C,cAAM,MAAO,YAAW,OAAO;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,SAAS,CAAC;IAErB,GAAG,EAAE,MAAM,CAAC;IAEZ,EAAE,EAAE,QAAQ,CAAC;IAEb,QAAQ,EAAE,QAAQ,CAAC;IAEnB,aAAa,EAAE,aAAa,CAAC;IAE7B,IAAI,EAAE,WAAW,CAAC;IAElB,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,YAAY,CAAC,EAAE,YAAY,CAAC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"}
package/dist/Strapi.js CHANGED
@@ -241,7 +241,8 @@ class Strapi {
241
241
  numberOfComponents: ___default.default.size(this.components),
242
242
  numberOfDynamicZones: dynamicZones(),
243
243
  numberOfCustomControllers: Object.values(this.controllers).filter(
244
- factories.isCustomController
244
+ // TODO: Fix this at the content API loader level to prevent future types issues
245
+ (controller) => controller !== void 0 && factories.isCustomController(controller)
245
246
  ).length,
246
247
  environment: this.config.environment
247
248
  // TODO: to add back
@@ -1 +1 @@
1
- {"version":3,"file":"Strapi.js","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n Container,\n EntityService,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './core/app-configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport { createContainer } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport createUpdateNotifier from './utils/update-notifier';\nimport createStartupLogger from './utils/startup-logger';\nimport { createStrapiFetch } from './utils/fetch';\nimport { LIFECYCLES } from './utils/lifecycles';\nimport ee from './utils/ee';\nimport contentTypesRegistry from './core/registries/content-types';\nimport servicesRegistry from './core/registries/services';\nimport policiesRegistry from './core/registries/policies';\nimport middlewaresRegistry from './core/registries/middlewares';\nimport hooksRegistry from './core/registries/hooks';\nimport controllersRegistry from './core/registries/controllers';\nimport modulesRegistry from './core/registries/modules';\nimport pluginsRegistry from './core/registries/plugins';\nimport customFieldsRegistry from './core/registries/custom-fields';\nimport createConfigProvider from './core/registries/config';\nimport apisRegistry from './core/registries/apis';\nimport bootstrap from './core/bootstrap';\nimport loaders from './core/loaders';\nimport { destroyOnSignal } from './utils/signals';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport sanitizersRegistry from './core/registries/sanitizers';\nimport validatorsRegistry from './core/registries/validators';\nimport convertCustomFieldType from './utils/convert-custom-field-type';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\nimport { FeaturesService, createFeaturesService } from './services/features';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi implements StrapiI {\n server: Server;\n\n container: Container;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n components: Shared.Components;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n constructor(opts: StrapiOptions = {}) {\n destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.container = createContainer(this)\n .register('config', createConfigProvider(appConfig))\n .register('content-types', contentTypesRegistry())\n .register('services', servicesRegistry(this))\n .register('policies', policiesRegistry())\n .register('middlewares', middlewaresRegistry())\n .register('hooks', hooksRegistry())\n .register('controllers', controllersRegistry(this))\n .register('modules', modulesRegistry(this))\n .register('plugins', pluginsRegistry(this))\n .register('custom-fields', customFieldsRegistry(this))\n .register('apis', apisRegistry(this))\n .register('auth', createAuth())\n .register('content-api', createContentAPI(this))\n .register('sanitizers', sanitizersRegistry())\n .register('validators', validatorsRegistry());\n\n this.components = {};\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = createStartupLogger(this);\n this.log = createLogger(this.config.get('logger', {}));\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n ee.init(this.dirs.app.root, this.log);\n return ee.isEE;\n },\n configurable: false,\n });\n }\n\n get config() {\n return this.container.get('config');\n }\n\n get services() {\n return this.container.get('services').getAll();\n }\n\n service(uid: Common.UID.Service) {\n return this.container.get('services').get(uid);\n }\n\n get controllers() {\n return this.container.get('controllers').getAll();\n }\n\n controller(uid: Common.UID.Controller) {\n return this.container.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.container.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.container.get('content-types').get(name);\n }\n\n get policies() {\n return this.container.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.container.get('policies').get(name);\n }\n\n get middlewares() {\n return this.container.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.container.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Common.Plugin> {\n return this.container.get('plugins').getAll();\n }\n\n plugin(name: string): Common.Plugin {\n return this.container.get('plugins').get(name);\n }\n\n get hooks() {\n return this.container.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.container.get('hooks').get(name);\n }\n\n // api(name) {\n // return this.container.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.container.get('apis').getAll();\n }\n\n get auth() {\n return this.container.get('auth');\n }\n\n get contentAPI() {\n return this.container.get('content-api');\n }\n\n get sanitizers() {\n return this.container.get('sanitizers');\n }\n\n get validators() {\n return this.container.get('validators');\n }\n\n async start() {\n try {\n if (!this.isLoaded) {\n await this.load();\n }\n\n await this.listen();\n\n return this;\n } catch (error) {\n return this.stopWithError(error);\n }\n }\n\n async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n factories.isCustomController\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n async loadAdmin() {\n await loaders.loadAdmin(this);\n }\n\n async loadPlugins() {\n await loaders.loadPlugins(this);\n }\n\n async loadPolicies() {\n await loaders.loadPolicies(this);\n }\n\n async loadAPIs() {\n await loaders.loadAPIs(this);\n }\n\n async loadComponents() {\n this.components = await loaders.loadComponents(this);\n }\n\n async loadMiddlewares() {\n await loaders.loadMiddlewares(this);\n }\n\n async loadApp() {\n this.app = await loaders.loadSrcIndex(this);\n }\n\n async loadSanitizers() {\n await loaders.loadSanitizers(this);\n }\n\n async loadValidators() {\n await loaders.loadValidators(this);\n }\n\n registerInternalHooks() {\n this.container\n .get('hooks')\n .set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n\n this.container\n .get('hooks')\n .set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await Promise.all([\n this.loadApp(),\n this.loadSanitizers(),\n this.loadValidators(),\n this.loadPlugins(),\n this.loadAdmin(),\n this.loadAPIs(),\n this.loadComponents(),\n this.loadMiddlewares(),\n this.loadPolicies(),\n ]);\n\n await bootstrap({ strapi: this });\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const contentTypes = [\n coreStoreModel,\n webhookModel,\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ];\n\n this.db = await Database.init({\n ...this.config.get('database'),\n models: Database.transformContentTypes(contentTypes),\n });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.collectionName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.container.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): Strapi;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}) => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["path","destroyOnSignal","loadConfiguration","createContainer","createConfigProvider","contentTypesRegistry","servicesRegistry","policiesRegistry","middlewaresRegistry","hooksRegistry","controllersRegistry","modulesRegistry","pluginsRegistry","customFieldsRegistry","apisRegistry","createAuth","createContentAPI","sanitizersRegistry","validatorsRegistry","utils.getDirs","createServer","createStrapiFs","createEventHub","createStartupLogger","createLogger","createCronService","createTelemetry","createCustomFields","createStrapiFetch","createFeaturesService","createUpdateNotifier","ee","LIFECYCLES","_","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","loaders","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable","createWebhookRunner","contentTypes","coreStoreModel","webhookModel","Database","createCoreStore","createWebhookStore","entityValidator","createEntityService","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAASA,cAAA,QAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAUA,cAAA,QAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;AAAA,IACzB;AAAA,EACF;AAEO,SAAA,eAAe,QAAQ,cAAc;AAAA,IAC1C,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,IAAI,OAAO;AAET,UAAI,MAAM,eAAe,SAAS,UAAU,MAAM;AAChD,cAAM,gBAAgB;AAAA,MACxB;AACA,YAAM,aAAa;AAAA,IACrB;AAAA,IACA,MAAM;AACJ,aAAO,MAAM;AAAA,IACf;AAAA,EAAA,CACD;AAED,SAAO,cAAc;AACrB,SAAO,aAAa;AAEb,SAAA;AACT;AAIA,MAAM,OAA0B;AAAA,EAC9B;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAE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\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n Container,\n EntityService,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './core/app-configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport { createContainer } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport createUpdateNotifier from './utils/update-notifier';\nimport createStartupLogger from './utils/startup-logger';\nimport { createStrapiFetch } from './utils/fetch';\nimport { LIFECYCLES } from './utils/lifecycles';\nimport ee from './utils/ee';\nimport contentTypesRegistry from './core/registries/content-types';\nimport servicesRegistry from './core/registries/services';\nimport policiesRegistry from './core/registries/policies';\nimport middlewaresRegistry from './core/registries/middlewares';\nimport hooksRegistry from './core/registries/hooks';\nimport controllersRegistry from './core/registries/controllers';\nimport modulesRegistry from './core/registries/modules';\nimport pluginsRegistry from './core/registries/plugins';\nimport customFieldsRegistry from './core/registries/custom-fields';\nimport createConfigProvider from './core/registries/config';\nimport apisRegistry from './core/registries/apis';\nimport bootstrap from './core/bootstrap';\nimport loaders from './core/loaders';\nimport { destroyOnSignal } from './utils/signals';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport sanitizersRegistry from './core/registries/sanitizers';\nimport validatorsRegistry from './core/registries/validators';\nimport convertCustomFieldType from './utils/convert-custom-field-type';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\nimport { FeaturesService, createFeaturesService } from './services/features';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi implements StrapiI {\n server: Server;\n\n container: Container;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n components: Shared.Components;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n constructor(opts: StrapiOptions = {}) {\n destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.container = createContainer(this)\n .register('config', createConfigProvider(appConfig))\n .register('content-types', contentTypesRegistry())\n .register('services', servicesRegistry(this))\n .register('policies', policiesRegistry())\n .register('middlewares', middlewaresRegistry())\n .register('hooks', hooksRegistry())\n .register('controllers', controllersRegistry(this))\n .register('modules', modulesRegistry(this))\n .register('plugins', pluginsRegistry(this))\n .register('custom-fields', customFieldsRegistry(this))\n .register('apis', apisRegistry(this))\n .register('auth', createAuth())\n .register('content-api', createContentAPI(this))\n .register('sanitizers', sanitizersRegistry())\n .register('validators', validatorsRegistry());\n\n this.components = {};\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = createStartupLogger(this);\n this.log = createLogger(this.config.get('logger', {}));\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n ee.init(this.dirs.app.root, this.log);\n return ee.isEE;\n },\n configurable: false,\n });\n }\n\n get config() {\n return this.container.get('config');\n }\n\n get services() {\n return this.container.get('services').getAll();\n }\n\n service(uid: Common.UID.Service) {\n return this.container.get('services').get(uid);\n }\n\n get controllers() {\n return this.container.get('controllers').getAll();\n }\n\n controller(uid: Common.UID.Controller) {\n return this.container.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.container.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.container.get('content-types').get(name);\n }\n\n get policies() {\n return this.container.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.container.get('policies').get(name);\n }\n\n get middlewares() {\n return this.container.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.container.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Common.Plugin> {\n return this.container.get('plugins').getAll();\n }\n\n plugin(name: string): Common.Plugin {\n return this.container.get('plugins').get(name);\n }\n\n get hooks() {\n return this.container.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.container.get('hooks').get(name);\n }\n\n // api(name) {\n // return this.container.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.container.get('apis').getAll();\n }\n\n get auth() {\n return this.container.get('auth');\n }\n\n get contentAPI() {\n return this.container.get('content-api');\n }\n\n get sanitizers() {\n return this.container.get('sanitizers');\n }\n\n get validators() {\n return this.container.get('validators');\n }\n\n async start() {\n try {\n if (!this.isLoaded) {\n await this.load();\n }\n\n await this.listen();\n\n return this;\n } catch (error) {\n return this.stopWithError(error);\n }\n }\n\n async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n async loadAdmin() {\n await loaders.loadAdmin(this);\n }\n\n async loadPlugins() {\n await loaders.loadPlugins(this);\n }\n\n async loadPolicies() {\n await loaders.loadPolicies(this);\n }\n\n async loadAPIs() {\n await loaders.loadAPIs(this);\n }\n\n async loadComponents() {\n this.components = await loaders.loadComponents(this);\n }\n\n async loadMiddlewares() {\n await loaders.loadMiddlewares(this);\n }\n\n async loadApp() {\n this.app = await loaders.loadSrcIndex(this);\n }\n\n async loadSanitizers() {\n await loaders.loadSanitizers(this);\n }\n\n async loadValidators() {\n await loaders.loadValidators(this);\n }\n\n registerInternalHooks() {\n this.container\n .get('hooks')\n .set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n\n this.container\n .get('hooks')\n .set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await Promise.all([\n this.loadApp(),\n this.loadSanitizers(),\n this.loadValidators(),\n this.loadPlugins(),\n this.loadAdmin(),\n this.loadAPIs(),\n this.loadComponents(),\n this.loadMiddlewares(),\n this.loadPolicies(),\n ]);\n\n await bootstrap({ strapi: this });\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const contentTypes = [\n coreStoreModel,\n webhookModel,\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ];\n\n this.db = await Database.init({\n ...this.config.get('database'),\n models: Database.transformContentTypes(contentTypes),\n });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.collectionName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.container.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): Strapi;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}) => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["path","destroyOnSignal","loadConfiguration","createContainer","createConfigProvider","contentTypesRegistry","servicesRegistry","policiesRegistry","middlewaresRegistry","hooksRegistry","controllersRegistry","modulesRegistry","pluginsRegistry","customFieldsRegistry","apisRegistry","createAuth","createContentAPI","sanitizersRegistry","validatorsRegistry","utils.getDirs","createServer","createStrapiFs","createEventHub","createStartupLogger","createLogger","createCronService","createTelemetry","createCustomFields","createStrapiFetch","createFeaturesService","createUpdateNotifier","ee","LIFECYCLES","_","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","loaders","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable","createWebhookRunner","contentTypes","coreStoreModel","webhookModel","Database","createCoreStore","createWebhookStore","entityValidator","createEntityService","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAASA,cAAA,QAAK,QAAQ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AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB,eAAqD;AAEhF,UAAM,KAAK,UAAU,IAAI,SAAS,EAAE,aAAa;AAGjD,UAAM,yBAAyB,KAAK,SAAS,KAAK,MAAM,aAAa;AACjE,QAAAoB,IAAAA,WAAW,sBAAsB,GAAG;AACtC,YAAM,uBAAuB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC/C;AAGA,UAAM,wBAAwB,KAAK,OAAO,KAAK,IAAI,aAAa;AAC5D,QAAAA,IAAAA,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SACE,KACmD;AAC/C,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAA6B;AAAA,IACxD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAA2B;AAAA,IACpD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAO;AACxC,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;;"}
package/dist/Strapi.mjs CHANGED
@@ -238,7 +238,8 @@ class Strapi {
238
238
  numberOfComponents: _.size(this.components),
239
239
  numberOfDynamicZones: getNumberOfDynamicZones(),
240
240
  numberOfCustomControllers: Object.values(this.controllers).filter(
241
- isCustomController
241
+ // TODO: Fix this at the content API loader level to prevent future types issues
242
+ (controller) => controller !== void 0 && isCustomController(controller)
242
243
  ).length,
243
244
  environment: this.config.environment
244
245
  // TODO: to add back
@@ -1 +1 @@
1
- {"version":3,"file":"Strapi.mjs","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n Container,\n EntityService,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './core/app-configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport { createContainer } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport createUpdateNotifier from './utils/update-notifier';\nimport createStartupLogger from './utils/startup-logger';\nimport { createStrapiFetch } from './utils/fetch';\nimport { LIFECYCLES } from './utils/lifecycles';\nimport ee from './utils/ee';\nimport contentTypesRegistry from './core/registries/content-types';\nimport servicesRegistry from './core/registries/services';\nimport policiesRegistry from './core/registries/policies';\nimport middlewaresRegistry from './core/registries/middlewares';\nimport hooksRegistry from './core/registries/hooks';\nimport controllersRegistry from './core/registries/controllers';\nimport modulesRegistry from './core/registries/modules';\nimport pluginsRegistry from './core/registries/plugins';\nimport customFieldsRegistry from './core/registries/custom-fields';\nimport createConfigProvider from './core/registries/config';\nimport apisRegistry from './core/registries/apis';\nimport bootstrap from './core/bootstrap';\nimport loaders from './core/loaders';\nimport { destroyOnSignal } from './utils/signals';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport sanitizersRegistry from './core/registries/sanitizers';\nimport validatorsRegistry from './core/registries/validators';\nimport convertCustomFieldType from './utils/convert-custom-field-type';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\nimport { FeaturesService, createFeaturesService } from './services/features';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi implements StrapiI {\n server: Server;\n\n container: Container;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n components: Shared.Components;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n constructor(opts: StrapiOptions = {}) {\n destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.container = createContainer(this)\n .register('config', createConfigProvider(appConfig))\n .register('content-types', contentTypesRegistry())\n .register('services', servicesRegistry(this))\n .register('policies', policiesRegistry())\n .register('middlewares', middlewaresRegistry())\n .register('hooks', hooksRegistry())\n .register('controllers', controllersRegistry(this))\n .register('modules', modulesRegistry(this))\n .register('plugins', pluginsRegistry(this))\n .register('custom-fields', customFieldsRegistry(this))\n .register('apis', apisRegistry(this))\n .register('auth', createAuth())\n .register('content-api', createContentAPI(this))\n .register('sanitizers', sanitizersRegistry())\n .register('validators', validatorsRegistry());\n\n this.components = {};\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = createStartupLogger(this);\n this.log = createLogger(this.config.get('logger', {}));\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n ee.init(this.dirs.app.root, this.log);\n return ee.isEE;\n },\n configurable: false,\n });\n }\n\n get config() {\n return this.container.get('config');\n }\n\n get services() {\n return this.container.get('services').getAll();\n }\n\n service(uid: Common.UID.Service) {\n return this.container.get('services').get(uid);\n }\n\n get controllers() {\n return this.container.get('controllers').getAll();\n }\n\n controller(uid: Common.UID.Controller) {\n return this.container.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.container.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.container.get('content-types').get(name);\n }\n\n get policies() {\n return this.container.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.container.get('policies').get(name);\n }\n\n get middlewares() {\n return this.container.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.container.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Common.Plugin> {\n return this.container.get('plugins').getAll();\n }\n\n plugin(name: string): Common.Plugin {\n return this.container.get('plugins').get(name);\n }\n\n get hooks() {\n return this.container.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.container.get('hooks').get(name);\n }\n\n // api(name) {\n // return this.container.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.container.get('apis').getAll();\n }\n\n get auth() {\n return this.container.get('auth');\n }\n\n get contentAPI() {\n return this.container.get('content-api');\n }\n\n get sanitizers() {\n return this.container.get('sanitizers');\n }\n\n get validators() {\n return this.container.get('validators');\n }\n\n async start() {\n try {\n if (!this.isLoaded) {\n await this.load();\n }\n\n await this.listen();\n\n return this;\n } catch (error) {\n return this.stopWithError(error);\n }\n }\n\n async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n factories.isCustomController\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n async loadAdmin() {\n await loaders.loadAdmin(this);\n }\n\n async loadPlugins() {\n await loaders.loadPlugins(this);\n }\n\n async loadPolicies() {\n await loaders.loadPolicies(this);\n }\n\n async loadAPIs() {\n await loaders.loadAPIs(this);\n }\n\n async loadComponents() {\n this.components = await loaders.loadComponents(this);\n }\n\n async loadMiddlewares() {\n await loaders.loadMiddlewares(this);\n }\n\n async loadApp() {\n this.app = await loaders.loadSrcIndex(this);\n }\n\n async loadSanitizers() {\n await loaders.loadSanitizers(this);\n }\n\n async loadValidators() {\n await loaders.loadValidators(this);\n }\n\n registerInternalHooks() {\n this.container\n .get('hooks')\n .set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n\n this.container\n .get('hooks')\n .set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await Promise.all([\n this.loadApp(),\n this.loadSanitizers(),\n this.loadValidators(),\n this.loadPlugins(),\n this.loadAdmin(),\n this.loadAPIs(),\n this.loadComponents(),\n this.loadMiddlewares(),\n this.loadPolicies(),\n ]);\n\n await bootstrap({ strapi: this });\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const contentTypes = [\n coreStoreModel,\n webhookModel,\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ];\n\n this.db = await Database.init({\n ...this.config.get('database'),\n models: Database.transformContentTypes(contentTypes),\n });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.collectionName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.container.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): Strapi;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}) => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["createAuth","utils.getDirs","createTelemetry","requestContext","ee","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAU,KAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;A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AM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAO;AACxC,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;"}
1
+ {"version":3,"file":"Strapi.mjs","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n Container,\n EntityService,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './core/app-configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport { createContainer } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport createUpdateNotifier from './utils/update-notifier';\nimport createStartupLogger from './utils/startup-logger';\nimport { createStrapiFetch } from './utils/fetch';\nimport { LIFECYCLES } from './utils/lifecycles';\nimport ee from './utils/ee';\nimport contentTypesRegistry from './core/registries/content-types';\nimport servicesRegistry from './core/registries/services';\nimport policiesRegistry from './core/registries/policies';\nimport middlewaresRegistry from './core/registries/middlewares';\nimport hooksRegistry from './core/registries/hooks';\nimport controllersRegistry from './core/registries/controllers';\nimport modulesRegistry from './core/registries/modules';\nimport pluginsRegistry from './core/registries/plugins';\nimport customFieldsRegistry from './core/registries/custom-fields';\nimport createConfigProvider from './core/registries/config';\nimport apisRegistry from './core/registries/apis';\nimport bootstrap from './core/bootstrap';\nimport loaders from './core/loaders';\nimport { destroyOnSignal } from './utils/signals';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport sanitizersRegistry from './core/registries/sanitizers';\nimport validatorsRegistry from './core/registries/validators';\nimport convertCustomFieldType from './utils/convert-custom-field-type';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\nimport { FeaturesService, createFeaturesService } from './services/features';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi implements StrapiI {\n server: Server;\n\n container: Container;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n components: Shared.Components;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n constructor(opts: StrapiOptions = {}) {\n destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.container = createContainer(this)\n .register('config', createConfigProvider(appConfig))\n .register('content-types', contentTypesRegistry())\n .register('services', servicesRegistry(this))\n .register('policies', policiesRegistry())\n .register('middlewares', middlewaresRegistry())\n .register('hooks', hooksRegistry())\n .register('controllers', controllersRegistry(this))\n .register('modules', modulesRegistry(this))\n .register('plugins', pluginsRegistry(this))\n .register('custom-fields', customFieldsRegistry(this))\n .register('apis', apisRegistry(this))\n .register('auth', createAuth())\n .register('content-api', createContentAPI(this))\n .register('sanitizers', sanitizersRegistry())\n .register('validators', validatorsRegistry());\n\n this.components = {};\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = createStartupLogger(this);\n this.log = createLogger(this.config.get('logger', {}));\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n ee.init(this.dirs.app.root, this.log);\n return ee.isEE;\n },\n configurable: false,\n });\n }\n\n get config() {\n return this.container.get('config');\n }\n\n get services() {\n return this.container.get('services').getAll();\n }\n\n service(uid: Common.UID.Service) {\n return this.container.get('services').get(uid);\n }\n\n get controllers() {\n return this.container.get('controllers').getAll();\n }\n\n controller(uid: Common.UID.Controller) {\n return this.container.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.container.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.container.get('content-types').get(name);\n }\n\n get policies() {\n return this.container.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.container.get('policies').get(name);\n }\n\n get middlewares() {\n return this.container.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.container.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Common.Plugin> {\n return this.container.get('plugins').getAll();\n }\n\n plugin(name: string): Common.Plugin {\n return this.container.get('plugins').get(name);\n }\n\n get hooks() {\n return this.container.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.container.get('hooks').get(name);\n }\n\n // api(name) {\n // return this.container.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.container.get('apis').getAll();\n }\n\n get auth() {\n return this.container.get('auth');\n }\n\n get contentAPI() {\n return this.container.get('content-api');\n }\n\n get sanitizers() {\n return this.container.get('sanitizers');\n }\n\n get validators() {\n return this.container.get('validators');\n }\n\n async start() {\n try {\n if (!this.isLoaded) {\n await this.load();\n }\n\n await this.listen();\n\n return this;\n } catch (error) {\n return this.stopWithError(error);\n }\n }\n\n async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n async loadAdmin() {\n await loaders.loadAdmin(this);\n }\n\n async loadPlugins() {\n await loaders.loadPlugins(this);\n }\n\n async loadPolicies() {\n await loaders.loadPolicies(this);\n }\n\n async loadAPIs() {\n await loaders.loadAPIs(this);\n }\n\n async loadComponents() {\n this.components = await loaders.loadComponents(this);\n }\n\n async loadMiddlewares() {\n await loaders.loadMiddlewares(this);\n }\n\n async loadApp() {\n this.app = await loaders.loadSrcIndex(this);\n }\n\n async loadSanitizers() {\n await loaders.loadSanitizers(this);\n }\n\n async loadValidators() {\n await loaders.loadValidators(this);\n }\n\n registerInternalHooks() {\n this.container\n .get('hooks')\n .set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n\n this.container\n .get('hooks')\n .set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await Promise.all([\n this.loadApp(),\n this.loadSanitizers(),\n this.loadValidators(),\n this.loadPlugins(),\n this.loadAdmin(),\n this.loadAPIs(),\n this.loadComponents(),\n this.loadMiddlewares(),\n this.loadPolicies(),\n ]);\n\n await bootstrap({ strapi: this });\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const contentTypes = [\n coreStoreModel,\n webhookModel,\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ];\n\n this.db = await Database.init({\n ...this.config.get('database'),\n models: Database.transformContentTypes(contentTypes),\n });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.collectionName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.container.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): Strapi;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}) => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["createAuth","utils.getDirs","createTelemetry","requestContext","ee","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAU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QAAQ,KAAM,CAAA;AAAA,IAC/C;AAGA,UAAM,wBAAwB,KAAK,OAAO,KAAK,IAAI,aAAa;AAC5D,QAAA,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SACE,KACmD;AAC/C,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAA6B;AAAA,IACxD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAA2B;AAAA,IACpD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAO;AACxC,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;"}
package/dist/admin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { RenderAdminArgs } from '@strapi/admin/strapi-admin';
1
+ import { RenderAdminArgs, Store } from '@strapi/admin/strapi-admin';
2
2
  declare const render: (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => Promise<void>;
3
3
  export { render as renderAdmin };
4
- export type { RenderAdminArgs };
4
+ export type { RenderAdminArgs, Store };
5
5
  //# sourceMappingURL=admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAS1E,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,kBAYvF,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQjF,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,kBAYvF,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC"}
package/dist/admin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentTypeBuilder from '@strapi/plugin-content-type-builder/strapi-admin';\nimport email from '@strapi/plugin-email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/plugin-upload/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentReleases from '@strapi/content-releases/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n contentReleases,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","contentTypeBuilder","email","upload","contentReleases"],"mappings":";;;;;;;;;;;;AASA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAOA,YAAAA,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,wBAAwBC,4BAAA;AAAA;AAAA,MAAA,OAExBC,eAAA;AAAA,MAAA,QACAC,gBAAA;AAAA,MAAA,iBACAC,yBAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;;"}
1
+ {"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin, Store } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/plugin-content-type-builder/strapi-admin';\nimport email from '@strapi/plugin-email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/plugin-upload/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentReleases from '@strapi/content-releases/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n contentReleases,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs, Store };\n"],"names":["renderAdmin","contentTypeBuilder","email","upload","contentReleases"],"mappings":";;;;;;;;;;;;AAQA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAOA,YAAAA,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,wBAAwBC,4BAAA;AAAA;AAAA,MAAA,OAExBC,eAAA;AAAA,MAAA,QACAC,gBAAA;AAAA,MAAA,iBACAC,yBAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentTypeBuilder from '@strapi/plugin-content-type-builder/strapi-admin';\nimport email from '@strapi/plugin-email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/plugin-upload/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentReleases from '@strapi/content-releases/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n contentReleases,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":[],"mappings":";;;;;AASA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAO,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,wBAAwB;AAAA;AAAA,MAExB;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin, Store } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/plugin-content-type-builder/strapi-admin';\nimport email from '@strapi/plugin-email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/plugin-upload/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport contentReleases from '@strapi/content-releases/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n contentReleases,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs, Store };\n"],"names":[],"mappings":";;;;;AAQA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAO,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,wBAAwB;AAAA;AAAA,MAExB;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;"}
@@ -1,7 +1,8 @@
1
1
  import { BuildCLIOptions } from '@strapi/pack-up';
2
+ import { CLIContext } from '../../../types';
2
3
  interface ActionOptions extends BuildCLIOptions {
3
4
  force?: boolean;
4
5
  }
5
- declare const _default: ({ force, ...opts }: ActionOptions) => Promise<void>;
6
+ declare const _default: ({ force, ...opts }: ActionOptions, _cmd: unknown, { logger, cwd }: CLIContext) => Promise<void>;
6
7
  export default _default;
7
8
  //# sourceMappingURL=action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/build-command/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAKvE,UAAU,aAAc,SAAQ,eAAe;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;6CAEyC,aAAa;AAAvD,wBA+FE"}
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/build-command/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAGvE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,UAAU,aAAc,SAAQ,eAAe;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;6CAGqB,aAAa,QAC3B,OAAO,mBACI,UAAU;AAH7B,wBAgGE"}
@@ -3,18 +3,15 @@ const boxen = require("boxen");
3
3
  const chalk = require("chalk");
4
4
  const packUp = require("@strapi/pack-up");
5
5
  const helpers = require("../../../utils/helpers.js");
6
- const logger = require("../../../utils/logger.js");
7
6
  const pkg = require("../../../utils/pkg.js");
8
7
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
8
  const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
10
9
  const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
11
- const action = async ({ force, ...opts }) => {
12
- const logger$1 = logger.createLogger({ debug: opts.debug, silent: opts.silent, timestamp: false });
10
+ const action = async ({ force, ...opts }, _cmd, { logger, cwd }) => {
13
11
  try {
14
12
  process.env.NODE_ENV = "production";
15
13
  await helpers.notifyExperimentalCommand("plugin:build", { force });
16
- const cwd = process.cwd();
17
- const pkg$1 = await pkg.loadPkg({ cwd, logger: logger$1 });
14
+ const pkg$1 = await pkg.loadPkg({ cwd, logger });
18
15
  const pkgJson = await pkg.validatePkg({ pkg: pkg$1 });
19
16
  if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
20
17
  throw new Error(
@@ -66,7 +63,7 @@ const action = async ({ force, ...opts }) => {
66
63
  ...opts
67
64
  });
68
65
  } catch (err) {
69
- logger$1.error(
66
+ logger.error(
70
67
  "There seems to be an unexpected error, try again with --debug for more information \n"
71
68
  );
72
69
  if (err instanceof Error && err.stack) {
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sources":["../../../../../src/commands/actions/plugin/build-command/action.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { BuildCLIOptions, ConfigBundle, build } from '@strapi/pack-up';\nimport { notifyExperimentalCommand } from '../../../utils/helpers';\nimport { createLogger } from '../../../utils/logger';\nimport { Export, loadPkg, validatePkg } from '../../../utils/pkg';\n\ninterface ActionOptions extends BuildCLIOptions {\n force?: boolean;\n}\n\nexport default async ({ force, ...opts }: ActionOptions) => {\n const logger = createLogger({ debug: opts.debug, silent: opts.silent, timestamp: false });\n try {\n /**\n * ALWAYS set production for using plugin build CLI.\n */\n process.env.NODE_ENV = 'production';\n /**\n * Notify users this is an experimental command and get them to approve first\n * this can be opted out by setting the argument --yes\n */\n await notifyExperimentalCommand('plugin:build', { force });\n\n const cwd = process.cwd();\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await build({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n"],"names":["logger","createLogger","notifyExperimentalCommand","pkg","loadPkg","validatePkg","build","chalk","boxen"],"mappings":";;;;;;;;;;AAWA,MAAA,SAAe,OAAO,EAAE,OAAO,GAAG,WAA0B;AACpD,QAAAA,WAASC,OAAAA,aAAa,EAAE,OAAO,KAAK,OAAO,QAAQ,KAAK,QAAQ,WAAW,MAAO,CAAA;AACpF,MAAA;AAIF,YAAQ,IAAI,WAAW;AAKvB,UAAMC,kCAA0B,gBAAgB,EAAE,MAAO,CAAA;AAEnD,UAAA,MAAM,QAAQ;AAEpB,UAAMC,QAAM,MAAMC,IAAA,QAAQ,EAAE,KAAKJ,QAAAA,SAAQ,CAAA;AACzC,UAAM,UAAU,MAAMK,IAAAA,YAAY,EAAEF,KA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CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;"}
1
+ {"version":3,"file":"action.js","sources":["../../../../../src/commands/actions/plugin/build-command/action.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { BuildCLIOptions, ConfigBundle, build } from '@strapi/pack-up';\nimport { notifyExperimentalCommand } from '../../../utils/helpers';\nimport { Export, loadPkg, validatePkg } from '../../../utils/pkg';\nimport { CLIContext } from '../../../types';\n\ninterface ActionOptions extends BuildCLIOptions {\n force?: boolean;\n}\n\nexport default async (\n { force, ...opts }: ActionOptions,\n _cmd: unknown,\n { logger, cwd }: CLIContext\n) => {\n try {\n /**\n * ALWAYS set production for using plugin build CLI.\n */\n process.env.NODE_ENV = 'production';\n /**\n * Notify users this is an experimental command and get them to approve first\n * this can be opted out by setting the argument --force\n */\n await notifyExperimentalCommand('plugin:build', { force });\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await build({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n"],"names":["notifyExperimentalCommand","pkg","loadPkg","validatePkg","build","chalk","boxen"],"mappings":";;;;;;;;;AAWA,MAAA,SAAe,OACb,EAAE,OAAO,GAAG,KAAA,GACZ,MACA,EAAE,QAAQ,UACP;AACC,MAAA;AAIF,YAAQ,IAAI,WAAW;AAKvB,UAAMA,kCAA0B,gBAAgB,EAAE,MAAO,CAAA;AAEzD,UAAMC,QAAM,MAAMC,IAAA,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAMC,IAAAA,YAAY,EAAEF,KAAAA,MAAK,CAAA;AAErC,QAAA,CAAC,QAAQ,QAAQ,gBAAgB,KAAK,CAAC,QAAQ,QAAQ,iBAAiB,GAAG;AAC7E,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,UAA0B,CAAA;AAE5B,QAAA,QAAQ,QAAQ,gBAAgB,GAAG;AAC/B,YAAA,MAAM,QAAQ,QAAQ,gBAAgB;AAE5C,YAAM,SAAuB;AAAA,QAC3B,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,SAAS;AAAA,MAAA;AAGX,UAAI,IAAI,OAAO;AACb,eAAO,QAAQ,IAAI;AAEnB,eAAO,WAAW;AAAA,MACpB;AAEA,cAAQ,KAAK,MAAM;AAAA,IACrB;AAEI,QAAA,QAAQ,QAAQ,iBAAiB,GAAG;AAChC,YAAA,MAAM,QAAQ,QAAQ,iBAAiB;AAE7C,YAAM,SAAuB;AAAA,QAC3B,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,SAAS,IAAI;AAAA,QACb,SAAS;AAAA,MAAA;AAGX,UAAI,IAAI,OAAO;AACb,eAAO,QAAQ,IAAI;AAEnB,eAAO,WAAW;AAAA,MACpB;AAEA,cAAQ,KAAK,MAAM;AAAA,IACrB;AAEA,UAAMG,aAAM;AAAA,MACV;AAAA,MACA,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN;AAAA,QACA,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMN,SAAS,CAAC;AAAA,MACZ;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,WACM,KAAK;AACL,WAAA;AAAA,MACL;AAAA,IAAA;AAEE,QAAA,eAAe,SAAS,IAAI,OAAO;AAC7B,cAAA;AAAA,QACNC,eAAAA,QAAM;AAAA,UACJC,eAAA,QAAM,IAAI,OAAO;AAAA,YACf,SAAS;AAAA,YACT,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;"}
@@ -2,8 +2,8 @@
2
2
  const commander = require("../../../utils/commander.js");
3
3
  const helpers = require("../../../utils/helpers.js");
4
4
  const action = require("./action.js");
5
- const command = ({ command: command2 }) => {
6
- command2.command("plugin:build").description("Bundle your strapi plugin for publishing.").addOption(commander.forceOption).option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).option("--sourcemap", "produce sourcemaps", false).option("--minify", "minify the output", false).action(helpers.runAction("plugin:build", action));
5
+ const command = ({ command: command2, ctx }) => {
6
+ command2.command("plugin:build").description("Bundle your strapi plugin for publishing.").addOption(commander.forceOption).option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).option("--sourcemap", "produce sourcemaps", false).option("--minify", "minify the output", false).action((...args) => helpers.runAction("plugin:build", action)(...args, ctx));
7
7
  };
8
8
  module.exports = command;
9
9
  //# sourceMappingURL=command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sources":["../../../../../src/commands/actions/plugin/build-command/command.ts"],"sourcesContent":["import { forceOption } from '../../../utils/commander';\nimport type { StrapiCommand } from '../../../types';\nimport { runAction } from '../../../utils/helpers';\nimport action from './action';\n\n/**\n * `$ strapi plugin:build`\n */\nconst command: StrapiCommand = ({ command }) => {\n command\n .command('plugin:build')\n .description('Bundle your strapi plugin for publishing.')\n .addOption(forceOption)\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--sourcemap', 'produce sourcemaps', false)\n .option('--minify', 'minify the output', false)\n .action(runAction('plugin:build', action));\n};\n\nexport default command;\n"],"names":["command","forceOption","runAction"],"mappings":";;;;AAQA,MAAM,UAAyB,CAAC,EAAE,SAAAA,eAAc;AAC9CA,WACG,QAAQ,cAAc,EACtB,YAAY,2CAA2C,EACvD,UAAUC,UAAW,WAAA,EACrB,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,eAAe,sBAAsB,KAAK,EACjD,OAAO,YAAY,qBAAqB,KAAK,EAC7C,OAAOC,QAAU,UAAA,gBAAgB,MAAM,CAAC;AAC7C;;"}
1
+ {"version":3,"file":"command.js","sources":["../../../../../src/commands/actions/plugin/build-command/command.ts"],"sourcesContent":["import { forceOption } from '../../../utils/commander';\nimport type { StrapiCommand } from '../../../types';\nimport { runAction } from '../../../utils/helpers';\nimport action from './action';\n\n/**\n * `$ strapi plugin:build`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:build')\n .description('Bundle your strapi plugin for publishing.')\n .addOption(forceOption)\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--sourcemap', 'produce sourcemaps', false)\n .option('--minify', 'minify the output', false)\n .action((...args) => runAction('plugin:build', action)(...args, ctx));\n};\n\nexport default command;\n"],"names":["command","forceOption","runAction"],"mappings":";;;;AAQA,MAAM,UAAyB,CAAC,EAAE,SAAAA,UAAS,UAAU;AACnDA,WACG,QAAQ,cAAc,EACtB,YAAY,2CAA2C,EACvD,UAAUC,qBAAW,EACrB,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,eAAe,sBAAsB,KAAK,EACjD,OAAO,YAAY,qBAAqB,KAAK,EAC7C,OAAO,IAAI,SAASC,kBAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;;"}
@@ -0,0 +1,7 @@
1
+ import { InitOptions } from '@strapi/pack-up';
2
+ import { CLIContext } from '../../../types';
3
+ interface ActionOptions extends Pick<InitOptions, 'silent' | 'debug'> {
4
+ }
5
+ declare const _default: (packagePath: string, { silent, debug }: ActionOptions, { logger, cwd }: CLIContext) => Promise<void>;
6
+ export default _default;
7
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/init/action.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAMZ,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,UAAU,aAAc,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC;CAAG;sCAGzD,MAAM,qBACA,aAAa,mBACf,UAAU;AAH7B,wBAuCE"}