@strapi/strapi 4.15.5-alpha.6 → 4.16.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.
- package/dist/Strapi.d.ts +2 -0
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +3 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +3 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +3 -0
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs +2 -0
- package/dist/admin.mjs.map +1 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.js +2 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.mjs +2 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +2 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +2 -1
- package/dist/ee/license.mjs.map +1 -1
- package/dist/services/features.d.ts +10 -0
- package/dist/services/features.d.ts.map +1 -0
- package/dist/services/features.js +17 -0
- package/dist/services/features.js.map +1 -0
- package/dist/services/features.mjs +17 -0
- package/dist/services/features.mjs.map +1 -0
- package/dist/services/server/register-middlewares.js +1 -1
- package/dist/services/server/register-middlewares.js.map +1 -1
- package/dist/services/server/register-middlewares.mjs +1 -1
- package/dist/services/server/register-middlewares.mjs.map +1 -1
- package/package.json +20 -19
package/dist/Strapi.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Strapi as StrapiI, Server, Container, EntityService, EventHub, Sta
|
|
|
4
4
|
import * as factories from './factories';
|
|
5
5
|
import compile from './compile';
|
|
6
6
|
import { WebhookRunner } from './services/webhook-runner';
|
|
7
|
+
import { FeaturesService } from './services/features';
|
|
7
8
|
export type LoadedStrapi = Required<Strapi>;
|
|
8
9
|
declare class Strapi implements StrapiI {
|
|
9
10
|
server: Server;
|
|
@@ -30,6 +31,7 @@ declare class Strapi implements StrapiI {
|
|
|
30
31
|
EE?: boolean;
|
|
31
32
|
components: Shared.Components;
|
|
32
33
|
reload: Reloader;
|
|
34
|
+
features: FeaturesService;
|
|
33
35
|
constructor(opts?: StrapiOptions);
|
|
34
36
|
get config(): any;
|
|
35
37
|
get services(): any;
|
package/dist/Strapi.d.ts.map
CHANGED
|
@@ -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;
|
|
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,EAC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AQ;IAIR,cAAc;IAId,eAAe;IAIf,OAAO;IAIP,cAAc;IAId,cAAc;IAIpB,qBAAqB;IAaf,QAAQ;IAkCR,SAAS;IA6ET,IAAI;IASJ,aAAa;IAWb,sBAAsB,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS;IAiBhF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;IAarD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM;CAG7B;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,UAAU,IAAI;IACZ,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAClC,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;CACzB;AAQD,QAAA,MAAM,IAAI,EAAE,IAAoD,CAAC;AAEjE,eAAe,IAAI,CAAC"}
|
package/dist/Strapi.js
CHANGED
|
@@ -50,6 +50,7 @@ const sanitizers = require("./core/registries/sanitizers.js");
|
|
|
50
50
|
const validators = require("./core/registries/validators.js");
|
|
51
51
|
const convertCustomFieldType = require("./utils/convert-custom-field-type.js");
|
|
52
52
|
const draftPublish = require("./migrations/draft-publish.js");
|
|
53
|
+
const features = require("./services/features.js");
|
|
53
54
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
54
55
|
const path__default = /* @__PURE__ */ _interopDefault(path);
|
|
55
56
|
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
@@ -116,6 +117,7 @@ class Strapi {
|
|
|
116
117
|
EE;
|
|
117
118
|
components;
|
|
118
119
|
reload;
|
|
120
|
+
features;
|
|
119
121
|
constructor(opts = {}) {
|
|
120
122
|
signals.destroyOnSignal(this);
|
|
121
123
|
const rootDirs = resolveWorkingDirectories(opts);
|
|
@@ -135,6 +137,7 @@ class Strapi {
|
|
|
135
137
|
this.requestContext = requestContext;
|
|
136
138
|
this.customFields = customFields$1(this);
|
|
137
139
|
this.fetch = fetch.createStrapiFetch(this);
|
|
140
|
+
this.features = features.createFeaturesService(this);
|
|
138
141
|
index$5(this).notify();
|
|
139
142
|
Object.defineProperty(this, "EE", {
|
|
140
143
|
get: () => {
|
package/dist/Strapi.js.map
CHANGED
|
@@ -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';\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 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\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.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 environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n });\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","createUpdateNotifier","ee","LIFECYCLES","_","getNumberOfDynamicZones","isInitialized","utils.openBrowser","utils.isInitialized","loaders","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable","createWebhookRunner","contentTypes","coreStoreModel","webhookModel","Database","createCoreStore","createWebhookStore","entityValidator","createEntityService","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,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,EAEA;AAAA,E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a;AACvD,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,eAAW,WAAW,UAAU;AACzB,WAAA,eAAe,IAAI,OAAO;AAAA,IACjC;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB,eAAqD;AAEhF,UAAM,KAAK,UAAU,IAAI,SAAS,EAAE,aAAa;AAGjD,UAAM,yBAAyB,KAAK,SAAS,KAAK,MAAM,aAAa;AACjE,QAAAmB,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;;"}
|
|
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.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 environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n });\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","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,YA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AAA,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
|
@@ -49,6 +49,7 @@ import sanitizersRegistry from "./core/registries/sanitizers.mjs";
|
|
|
49
49
|
import validatorsRegistry from "./core/registries/validators.mjs";
|
|
50
50
|
import convertCustomFieldType from "./utils/convert-custom-field-type.mjs";
|
|
51
51
|
import { disable as disableDraftAndPublish, enable as enableDraftAndPublish } from "./migrations/draft-publish.mjs";
|
|
52
|
+
import { createFeaturesService } from "./services/features.mjs";
|
|
52
53
|
const resolveWorkingDirectories = (opts) => {
|
|
53
54
|
const cwd = process.cwd();
|
|
54
55
|
const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
|
|
@@ -112,6 +113,7 @@ class Strapi {
|
|
|
112
113
|
EE;
|
|
113
114
|
components;
|
|
114
115
|
reload;
|
|
116
|
+
features;
|
|
115
117
|
constructor(opts = {}) {
|
|
116
118
|
destroyOnSignal(this);
|
|
117
119
|
const rootDirs = resolveWorkingDirectories(opts);
|
|
@@ -131,6 +133,7 @@ class Strapi {
|
|
|
131
133
|
this.requestContext = requestCtx;
|
|
132
134
|
this.customFields = createCustomFields(this);
|
|
133
135
|
this.fetch = createStrapiFetch(this);
|
|
136
|
+
this.features = createFeaturesService(this);
|
|
134
137
|
createUpdateNotifier(this).notify();
|
|
135
138
|
Object.defineProperty(this, "EE", {
|
|
136
139
|
get: () => {
|
package/dist/Strapi.mjs.map
CHANGED
|
@@ -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';\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 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\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.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 environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n });\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","isInitialized","utils.openBrowser","utils.isInitialized","draftAndPublishSync.disable","draftAndPublishSync.enable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,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;AAAA,IACzB;AAAA,EACF;AAEO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AAa,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.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 environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n });\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","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,IAA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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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;
|
|
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"}
|
package/dist/admin.js
CHANGED
|
@@ -4,10 +4,12 @@ const strapiAdmin = require("@strapi/admin/strapi-admin");
|
|
|
4
4
|
const contentTypeBuilder = require("@strapi/plugin-content-type-builder/strapi-admin");
|
|
5
5
|
const email = require("@strapi/plugin-email/strapi-admin");
|
|
6
6
|
const upload = require("@strapi/plugin-upload/strapi-admin");
|
|
7
|
+
const contentReleases = require("@strapi/content-releases/strapi-admin");
|
|
7
8
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
9
|
const contentTypeBuilder__default = /* @__PURE__ */ _interopDefault(contentTypeBuilder);
|
|
9
10
|
const email__default = /* @__PURE__ */ _interopDefault(email);
|
|
10
11
|
const upload__default = /* @__PURE__ */ _interopDefault(upload);
|
|
12
|
+
const contentReleases__default = /* @__PURE__ */ _interopDefault(contentReleases);
|
|
11
13
|
const render = (mountNode, { plugins, ...restArgs }) => {
|
|
12
14
|
return strapiAdmin.renderAdmin(mountNode, {
|
|
13
15
|
...restArgs,
|
|
@@ -16,6 +18,7 @@ const render = (mountNode, { plugins, ...restArgs }) => {
|
|
|
16
18
|
// @ts-expect-error – TODO: fix this
|
|
17
19
|
email: email__default.default,
|
|
18
20
|
upload: upload__default.default,
|
|
21
|
+
contentReleases: contentReleases__default.default,
|
|
19
22
|
...plugins
|
|
20
23
|
}
|
|
21
24
|
});
|
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\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 ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","contentTypeBuilder","email","upload"],"mappings":"
|
|
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;;"}
|
package/dist/admin.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { renderAdmin } from "@strapi/admin/strapi-admin";
|
|
|
2
2
|
import contentTypeBuilder from "@strapi/plugin-content-type-builder/strapi-admin";
|
|
3
3
|
import email from "@strapi/plugin-email/strapi-admin";
|
|
4
4
|
import upload from "@strapi/plugin-upload/strapi-admin";
|
|
5
|
+
import contentReleases from "@strapi/content-releases/strapi-admin";
|
|
5
6
|
const render = (mountNode, { plugins, ...restArgs }) => {
|
|
6
7
|
return renderAdmin(mountNode, {
|
|
7
8
|
...restArgs,
|
|
@@ -10,6 +11,7 @@ const render = (mountNode, { plugins, ...restArgs }) => {
|
|
|
10
11
|
// @ts-expect-error – TODO: fix this
|
|
11
12
|
email,
|
|
12
13
|
upload,
|
|
14
|
+
contentReleases,
|
|
13
15
|
...plugins
|
|
14
16
|
}
|
|
15
17
|
});
|
package/dist/admin.mjs.map
CHANGED
|
@@ -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\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 ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-enabled-plugins.d.ts","sourceRoot":"","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"get-enabled-plugins.d.ts","sourceRoot":"","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AA4E5C,eAAO,MAAM,iBAAiB,WAAkB,MAAM;;kBA2ErD,CAAC"}
|
|
@@ -12,7 +12,8 @@ const INTERNAL_PLUGINS = [
|
|
|
12
12
|
"@strapi/plugin-content-manager",
|
|
13
13
|
"@strapi/plugin-content-type-builder",
|
|
14
14
|
"@strapi/plugin-email",
|
|
15
|
-
"@strapi/plugin-upload"
|
|
15
|
+
"@strapi/plugin-upload",
|
|
16
|
+
"@strapi/content-releases"
|
|
16
17
|
];
|
|
17
18
|
const isStrapiPlugin = (info) => _$1.get("strapi.kind", info) === "plugin";
|
|
18
19
|
const validatePluginName = (pluginName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-enabled-plugins.js","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","isKebabCase","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-enabled-plugins.js","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","isKebabCase","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,IAAAA,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AAC7C,MAAA,CAACC,YAAAA,YAAY,UAAU,GAAG;AAC5B,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;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7 +8,8 @@ const INTERNAL_PLUGINS = [
|
|
|
8
8
|
"@strapi/plugin-content-manager",
|
|
9
9
|
"@strapi/plugin-content-type-builder",
|
|
10
10
|
"@strapi/plugin-email",
|
|
11
|
-
"@strapi/plugin-upload"
|
|
11
|
+
"@strapi/plugin-upload",
|
|
12
|
+
"@strapi/content-releases"
|
|
12
13
|
];
|
|
13
14
|
const isStrapiPlugin = (info) => get("strapi.kind", info) === "plugin";
|
|
14
15
|
const validatePluginName = (pluginName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../../src/core/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AAC7C,MAAA,CAAC,YAAY,UAAU,GAAG;AAC5B,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAAA;AAGvB,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAe,QAAQ,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAe,QAAQ,OAAO,KAAK,IAAI,MAAM,YAAY,OAAO;AAE5D,YAAA,CAAC,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gB,UAAU,IAAI;AAAA,MAC5B,GAAG,sBAAsB,WAAW;AAAA,MACpC,MAAM,CAAC;AAAA,IAAA;AAGT,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAc,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AAAA,MAC3D;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0B,IAAI,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiC;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiB;AAAA,IACrB,aAAa,eAAe;AAAA,IAC5B,aAAa,8BAA8B;AAAA,IAC3C,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;"}
|
package/dist/ee/license.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACvE;
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACvE;AAiBD,cAAM,iBAAkB,SAAQ,KAAK;IACnC,cAAc,UAAS;gBAEX,OAAO,EAAE,MAAM,EAAE,cAAc,UAAQ;CAKpD;AAED,QAAA,MAAM,WAAW,cAAe,MAAM,uBASrC,CAAC;AAEF,QAAA,MAAM,aAAa,YAAa,MAAM,gBA2BrC,CAAC;AAMF,QAAA,MAAM,YAAY;YAAgC,MAAM;QAAS,MAAM,aAAa,MAAM,iBA2BzF,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/ee/license.js
CHANGED
|
@@ -15,7 +15,8 @@ const DEFAULT_FEATURES = {
|
|
|
15
15
|
// Set a null retention duration to allow the user to override it
|
|
16
16
|
// The default of 90 days is set in the audit logs service
|
|
17
17
|
{ name: "audit-logs", options: { retentionDays: null } },
|
|
18
|
-
{ name: "review-workflows" }
|
|
18
|
+
{ name: "review-workflows" },
|
|
19
|
+
{ name: "cms-content-releases" }
|
|
19
20
|
]
|
|
20
21
|
};
|
|
21
22
|
const publicKey = fs__default.default.readFileSync(path.resolve(__dirname, "../../resources/key.pub"));
|
package/dist/ee/license.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license.js","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Strapi } from '@strapi/types';\n\nimport machineId from '../utils/machine-id';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async ({ strapi }: { strapi: Strapi }, key: string, projectId: string) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineId() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":["fs","resolve","path","join","crypto"],"mappings":";;;;;;;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,
|
|
1
|
+
{"version":3,"file":"license.js","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Strapi } from '@strapi/types';\n\nimport machineId from '../utils/machine-id';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async ({ strapi }: { strapi: Strapi }, key: string, projectId: string) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineId() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":["fs","resolve","path","join","crypto"],"mappings":";;;;;;;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBA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AAA,IAAI,kBAAkB,+DAA+D,IAAI;AACjG;AAEA,MAAM,eAAe,OAAO,EAAE,UAA8B,KAAa,cAAsB;AAC7F,QAAM,WAAW,MAAM,OACpB,MAAM,mDAAmD;AAAA,IACxD,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,EAAE,KAAK,WAAW,UAAU,UAAU,GAAG;AAAA,EAAA,CAC/D,EACA,MAAM,UAAU;AAEnB,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc;AAEnD,MAAA,aAAa,SAAS,kBAAkB,GAAG;AAC7C,UAAM,EAAE,MAAM,MAAA,IAAU,MAAM,SAAS,KAAK;AAE5C,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,KAAK;AAAA,MACd,KAAK;AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;;;;;"}
|
package/dist/ee/license.mjs
CHANGED
|
@@ -10,7 +10,8 @@ const DEFAULT_FEATURES = {
|
|
|
10
10
|
// Set a null retention duration to allow the user to override it
|
|
11
11
|
// The default of 90 days is set in the audit logs service
|
|
12
12
|
{ name: "audit-logs", options: { retentionDays: null } },
|
|
13
|
-
{ name: "review-workflows" }
|
|
13
|
+
{ name: "review-workflows" },
|
|
14
|
+
{ name: "cms-content-releases" }
|
|
14
15
|
]
|
|
15
16
|
};
|
|
16
17
|
const publicKey = fs.readFileSync(resolve(__dirname, "../../resources/key.pub"));
|
package/dist/ee/license.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Strapi } from '@strapi/types';\n\nimport machineId from '../utils/machine-id';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async ({ strapi }: { strapi: Strapi }, key: string, projectId: string) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineId() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,
|
|
1
|
+
{"version":3,"file":"license.mjs","sources":["../../src/ee/license.ts"],"sourcesContent":["import fs from 'fs';\nimport { join, resolve } from 'path';\nimport crypto from 'crypto';\nimport type { Strapi } from '@strapi/types';\n\nimport machineId from '../utils/machine-id';\n\ninterface LicenseInfo {\n type: 'bronze' | 'silver' | 'gold';\n expireAt?: string;\n seats?: number;\n features?: Array<{ name: string; options?: Record<string, unknown> }>;\n}\n\nconst DEFAULT_FEATURES = {\n bronze: [],\n silver: [],\n gold: [\n { name: 'sso' },\n // Set a null retention duration to allow the user to override it\n // The default of 90 days is set in the audit logs service\n { name: 'audit-logs', options: { retentionDays: null } },\n { name: 'review-workflows' },\n { name: 'cms-content-releases' },\n ],\n};\n\nconst publicKey = fs.readFileSync(resolve(__dirname, '../../resources/key.pub'));\n\nclass LicenseCheckError extends Error {\n shouldFallback = false;\n\n constructor(message: string, shouldFallback = false) {\n super(message);\n\n this.shouldFallback = shouldFallback;\n }\n}\n\nconst readLicense = (directory: string) => {\n try {\n const path = join(directory, 'license.txt');\n return fs.readFileSync(path).toString();\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code !== 'ENOENT') {\n throw Error('License file not readable, review its format and access rules.');\n }\n }\n};\n\nconst verifyLicense = (license: string) => {\n const [signature, base64Content] = Buffer.from(license, 'base64').toString().split('\\n');\n\n if (!signature || !base64Content) {\n throw new Error('Invalid license.');\n }\n\n const stringifiedContent = Buffer.from(base64Content, 'base64').toString();\n\n const verify = crypto.createVerify('RSA-SHA256');\n verify.update(stringifiedContent);\n verify.end();\n\n const verified = verify.verify(publicKey, signature, 'base64');\n\n if (!verified) {\n throw new Error('Invalid license.');\n }\n\n const licenseInfo: LicenseInfo = JSON.parse(stringifiedContent);\n\n if (!licenseInfo.features) {\n licenseInfo.features = DEFAULT_FEATURES[licenseInfo.type];\n }\n\n Object.freeze(licenseInfo.features);\n return licenseInfo;\n};\n\nconst throwError = () => {\n throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);\n};\n\nconst fetchLicense = async ({ strapi }: { strapi: Strapi }, key: string, projectId: string) => {\n const response = await strapi\n .fetch(`https://license.strapi.io/api/licenses/validate`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ key, projectId, deviceId: machineId() }),\n })\n .catch(throwError);\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType?.includes('application/json')) {\n const { data, error } = await response.json();\n\n switch (response.status) {\n case 200:\n return data.license;\n case 400:\n throw new LicenseCheckError(error.message);\n case 404:\n throw new LicenseCheckError('The license used does not exists.');\n default:\n throwError();\n }\n } else {\n throwError();\n }\n};\n\nexport { readLicense, verifyLicense, fetchLicense, LicenseCheckError };\n"],"names":[],"mappings":";;;;AAcA,MAAM,mBAAmB;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,IACJ,EAAE,MAAM,MAAM;AAAA;AAAA;AAAA,IAGd,EAAE,MAAM,cAAc,SAAS,EAAE,eAAe,OAAO;AAAA,IACvD,EAAE,MAAM,mBAAmB;AAAA,IAC3B,EAAE,MAAM,uBAAuB;AAAA,EACjC;AACF;AAEA,MAAM,YAAY,G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OACpB,MAAM,mDAAmD;AAAA,IACxD,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,EAAE,KAAK,WAAW,UAAU,UAAU,GAAG;AAAA,EAAA,CAC/D,EACA,MAAM,UAAU;AAEnB,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc;AAEnD,MAAA,aAAa,SAAS,kBAAkB,GAAG;AAC7C,UAAM,EAAE,MAAM,MAAA,IAAU,MAAM,SAAS,KAAK;AAE5C,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,KAAK;AAAA,MACd,KAAK;AACG,cAAA,IAAI,kBAAkB,MAAM,OAAO;AAAA,MAC3C,KAAK;AACG,cAAA,IAAI,kBAAkB,mCAAmC;AAAA,MACjE;AACa;IACf;AAAA,EAAA,OACK;AACM;EACb;AACF;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The features service is responsible for managing features within strapi,
|
|
3
|
+
* including interacting with the feature configuration file to know
|
|
4
|
+
* which are enabled and disabled.
|
|
5
|
+
*/
|
|
6
|
+
import type { Strapi, FeaturesService } from '@strapi/types';
|
|
7
|
+
declare const createFeaturesService: (strapi: Strapi) => FeaturesService;
|
|
8
|
+
export { createFeaturesService };
|
|
9
|
+
export type { FeaturesService };
|
|
10
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/services/features.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAI7E,QAAA,MAAM,qBAAqB,WAAY,MAAM,KAAG,eAa/C,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createFeaturesService = (strapi) => {
|
|
4
|
+
const service = {
|
|
5
|
+
get config() {
|
|
6
|
+
return strapi.config.get("features");
|
|
7
|
+
},
|
|
8
|
+
future: {
|
|
9
|
+
isEnabled(futureFlagName) {
|
|
10
|
+
return service.config?.future?.[futureFlagName] === true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return service;
|
|
15
|
+
};
|
|
16
|
+
exports.createFeaturesService = createFeaturesService;
|
|
17
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Strapi, FeaturesService, FeaturesConfig } from '@strapi/types';\n\ntype FeatureName = keyof FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Strapi): FeaturesService => {\n const service: FeaturesService = {\n get config() {\n return strapi.config.get<FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type { FeaturesService };\n"],"names":[],"mappings":";;AAUM,MAAA,wBAAwB,CAAC,WAAoC;AACjE,QAAM,UAA2B;AAAA,IAC/B,IAAI,SAAS;AACJ,aAAA,OAAO,OAAO,IAA+B,UAAU;AAAA,IAChE;AAAA,IACA,QAAQ;AAAA,MACN,UAAU,gBAAiC;AACzC,eAAO,QAAQ,QAAQ,SAAS,cAA6B,MAAM;AAAA,MACrE;AAAA,IACF;AAAA,EAAA;AAGK,SAAA;AACT;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const createFeaturesService = (strapi) => {
|
|
2
|
+
const service = {
|
|
3
|
+
get config() {
|
|
4
|
+
return strapi.config.get("features");
|
|
5
|
+
},
|
|
6
|
+
future: {
|
|
7
|
+
isEnabled(futureFlagName) {
|
|
8
|
+
return service.config?.future?.[futureFlagName] === true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return service;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
createFeaturesService
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=features.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.mjs","sources":["../../src/services/features.ts"],"sourcesContent":["/**\n * The features service is responsible for managing features within strapi,\n * including interacting with the feature configuration file to know\n * which are enabled and disabled.\n */\n\nimport type { Strapi, FeaturesService, FeaturesConfig } from '@strapi/types';\n\ntype FeatureName = keyof FeaturesConfig['future'];\n\nconst createFeaturesService = (strapi: Strapi): FeaturesService => {\n const service: FeaturesService = {\n get config() {\n return strapi.config.get<FeaturesService['config']>('features');\n },\n future: {\n isEnabled(futureFlagName: string): boolean {\n return service.config?.future?.[futureFlagName as FeatureName] === true;\n },\n },\n };\n\n return service;\n};\n\nexport { createFeaturesService };\nexport type { FeaturesService };\n"],"names":[],"mappings":"AAUM,MAAA,wBAAwB,CAAC,WAAoC;AACjE,QAAM,UAA2B;AAAA,IAC/B,IAAI,SAAS;AACJ,aAAA,OAAO,OAAO,IAA+B,UAAU;AAAA,IAChE;AAAA,IACA,QAAQ;AAAA,MACN,UAAU,gBAAiC;AACzC,eAAO,QAAQ,QAAQ,SAAS,cAA6B,MAAM;AAAA,MACrE;AAAA,IACF;AAAA,EAAA;AAGK,SAAA;AACT;"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
const strapiUtils = require("@strapi/utils");
|
|
3
3
|
const middleware = require("./middleware.js");
|
|
4
4
|
const defaultConfig = [
|
|
5
|
+
"strapi::logger",
|
|
5
6
|
"strapi::errors",
|
|
6
7
|
"strapi::security",
|
|
7
8
|
"strapi::cors",
|
|
8
9
|
"strapi::poweredBy",
|
|
9
10
|
"strapi::session",
|
|
10
|
-
"strapi::logger",
|
|
11
11
|
"strapi::query",
|
|
12
12
|
"strapi::body",
|
|
13
13
|
"strapi::favicon",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-middlewares.js","sources":["../../../src/services/server/register-middlewares.ts"],"sourcesContent":["import { yup } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { resolveMiddlewares } from './middleware';\n\ntype MiddlewareConfig = (string | { name?: string; resolve?: string; config?: unknown })[];\n\nconst defaultConfig = [\n 'strapi::
|
|
1
|
+
{"version":3,"file":"register-middlewares.js","sources":["../../../src/services/server/register-middlewares.ts"],"sourcesContent":["import { yup } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { resolveMiddlewares } from './middleware';\n\ntype MiddlewareConfig = (string | { name?: string; resolve?: string; config?: unknown })[];\n\nconst defaultConfig = [\n 'strapi::logger',\n 'strapi::errors',\n 'strapi::security',\n 'strapi::cors',\n 'strapi::poweredBy',\n 'strapi::session',\n 'strapi::query',\n 'strapi::body',\n 'strapi::favicon',\n 'strapi::public',\n];\n\nconst requiredMiddlewares = [\n 'strapi::errors',\n 'strapi::security',\n 'strapi::cors',\n 'strapi::query',\n 'strapi::body',\n 'strapi::public',\n 'strapi::favicon',\n];\n\nconst middlewareConfigSchema = yup.array().of(\n yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'object') {\n return yup\n .object({\n name: yup.string(),\n resolve: yup.string(),\n config: yup.mixed(),\n })\n .required()\n .noUnknown();\n }\n\n return yup.mixed().test(() => false);\n }) as any // FIXME: yup v1\n);\n\n/**\n * Register middlewares in router\n */\nconst registerApplicationMiddlewares = async (strapi: Strapi) => {\n const middlewareConfig: MiddlewareConfig = strapi.config.get('middlewares', defaultConfig);\n\n await validateMiddlewareConfig(middlewareConfig);\n\n const middlewares = await resolveMiddlewares(middlewareConfig, strapi);\n\n checkRequiredMiddlewares(middlewares);\n\n // NOTE: exclude middlewares that return nothing.\n // this is used for middlewares that only extend the app only need to be added in certain conditions\n for (const middleware of middlewares) {\n strapi.server.use(middleware.handler);\n }\n};\n\n/**\n *\n * @param {MiddlewaresConfig} config\n */\nconst validateMiddlewareConfig = async (config: MiddlewareConfig) => {\n try {\n await middlewareConfigSchema.validate(config, { strict: true, abortEarly: false });\n } catch (error) {\n throw new Error(\n 'Invalid middleware configuration. Expected Array<string|{name?: string, resolve?: string, config: any}.'\n );\n }\n};\n\n/**\n * Check if some required middlewares are missing in configure middlewares\n * @param {Middlewares} middlewares\n */\nconst checkRequiredMiddlewares = (middlewares: { name: string | null }[]) => {\n const missingMiddlewares = requiredMiddlewares.filter((name) => {\n return middlewares.findIndex((mdl) => mdl.name === name) === -1;\n });\n\n if (missingMiddlewares.length > 0) {\n throw new Error(\n `Missing required middlewares in configuration. Add the following middlewares: \"${missingMiddlewares.join(\n ', '\n )}\".`\n );\n }\n};\n\nexport default registerApplicationMiddlewares;\n"],"names":["yup","resolveMiddlewares","middleware"],"mappings":";;;AAMA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,yBAAyBA,YAAAA,IAAI,MAAA,EAAQ;AAAA,EACzCA,gBAAI,KAAK,CAAC,UAAU;AACd,QAAA,OAAO,UAAU,UAAU;AACtB,aAAAA,gBAAI,SAAS;IACtB;AAEI,QAAA,OAAO,UAAU,UAAU;AAC7B,aAAOA,YAAAA,IACJ,OAAO;AAAA,QACN,MAAMA,gBAAI,OAAO;AAAA,QACjB,SAASA,gBAAI,OAAO;AAAA,QACpB,QAAQA,gBAAI,MAAM;AAAA,MAAA,CACnB,EACA,WACA;IACL;AAEA,WAAOA,YAAI,IAAA,MAAA,EAAQ,KAAK,MAAM,KAAK;AAAA,EAAA,CACpC;AAAA;AACH;AAKM,MAAA,iCAAiC,OAAO,WAAmB;AAC/D,QAAM,mBAAqC,OAAO,OAAO,IAAI,eAAe,aAAa;AAEzF,QAAM,yBAAyB,gBAAgB;AAE/C,QAAM,cAAc,MAAMC,WAAAA,mBAAmB,kBAAkB,MAAM;AAErE,2BAAyB,WAAW;AAIpC,aAAWC,eAAc,aAAa;AAC7B,WAAA,OAAO,IAAIA,YAAW,OAAO;AAAA,EACtC;AACF;AAMA,MAAM,2BAA2B,OAAO,WAA6B;AAC/D,MAAA;AACI,UAAA,uBAAuB,SAAS,QAAQ,EAAE,QAAQ,MAAM,YAAY,OAAO;AAAA,WAC1E,OAAO;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACF;AAMA,MAAM,2BAA2B,CAAC,gBAA2C;AAC3E,QAAM,qBAAqB,oBAAoB,OAAO,CAAC,SAAS;AAC9D,WAAO,YAAY,UAAU,CAAC,QAAQ,IAAI,SAAS,IAAI,MAAM;AAAA,EAAA,CAC9D;AAEG,MAAA,mBAAmB,SAAS,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,kFAAkF,mBAAmB;AAAA,QACnG;AAAA,MACD,CAAA;AAAA,IAAA;AAAA,EAEL;AACF;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { yup } from "@strapi/utils";
|
|
2
2
|
import { resolveMiddlewares } from "./middleware.mjs";
|
|
3
3
|
const defaultConfig = [
|
|
4
|
+
"strapi::logger",
|
|
4
5
|
"strapi::errors",
|
|
5
6
|
"strapi::security",
|
|
6
7
|
"strapi::cors",
|
|
7
8
|
"strapi::poweredBy",
|
|
8
9
|
"strapi::session",
|
|
9
|
-
"strapi::logger",
|
|
10
10
|
"strapi::query",
|
|
11
11
|
"strapi::body",
|
|
12
12
|
"strapi::favicon",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-middlewares.mjs","sources":["../../../src/services/server/register-middlewares.ts"],"sourcesContent":["import { yup } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { resolveMiddlewares } from './middleware';\n\ntype MiddlewareConfig = (string | { name?: string; resolve?: string; config?: unknown })[];\n\nconst defaultConfig = [\n 'strapi::
|
|
1
|
+
{"version":3,"file":"register-middlewares.mjs","sources":["../../../src/services/server/register-middlewares.ts"],"sourcesContent":["import { yup } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { resolveMiddlewares } from './middleware';\n\ntype MiddlewareConfig = (string | { name?: string; resolve?: string; config?: unknown })[];\n\nconst defaultConfig = [\n 'strapi::logger',\n 'strapi::errors',\n 'strapi::security',\n 'strapi::cors',\n 'strapi::poweredBy',\n 'strapi::session',\n 'strapi::query',\n 'strapi::body',\n 'strapi::favicon',\n 'strapi::public',\n];\n\nconst requiredMiddlewares = [\n 'strapi::errors',\n 'strapi::security',\n 'strapi::cors',\n 'strapi::query',\n 'strapi::body',\n 'strapi::public',\n 'strapi::favicon',\n];\n\nconst middlewareConfigSchema = yup.array().of(\n yup.lazy((value) => {\n if (typeof value === 'string') {\n return yup.string().required();\n }\n\n if (typeof value === 'object') {\n return yup\n .object({\n name: yup.string(),\n resolve: yup.string(),\n config: yup.mixed(),\n })\n .required()\n .noUnknown();\n }\n\n return yup.mixed().test(() => false);\n }) as any // FIXME: yup v1\n);\n\n/**\n * Register middlewares in router\n */\nconst registerApplicationMiddlewares = async (strapi: Strapi) => {\n const middlewareConfig: MiddlewareConfig = strapi.config.get('middlewares', defaultConfig);\n\n await validateMiddlewareConfig(middlewareConfig);\n\n const middlewares = await resolveMiddlewares(middlewareConfig, strapi);\n\n checkRequiredMiddlewares(middlewares);\n\n // NOTE: exclude middlewares that return nothing.\n // this is used for middlewares that only extend the app only need to be added in certain conditions\n for (const middleware of middlewares) {\n strapi.server.use(middleware.handler);\n }\n};\n\n/**\n *\n * @param {MiddlewaresConfig} config\n */\nconst validateMiddlewareConfig = async (config: MiddlewareConfig) => {\n try {\n await middlewareConfigSchema.validate(config, { strict: true, abortEarly: false });\n } catch (error) {\n throw new Error(\n 'Invalid middleware configuration. Expected Array<string|{name?: string, resolve?: string, config: any}.'\n );\n }\n};\n\n/**\n * Check if some required middlewares are missing in configure middlewares\n * @param {Middlewares} middlewares\n */\nconst checkRequiredMiddlewares = (middlewares: { name: string | null }[]) => {\n const missingMiddlewares = requiredMiddlewares.filter((name) => {\n return middlewares.findIndex((mdl) => mdl.name === name) === -1;\n });\n\n if (missingMiddlewares.length > 0) {\n throw new Error(\n `Missing required middlewares in configuration. Add the following middlewares: \"${missingMiddlewares.join(\n ', '\n )}\".`\n );\n }\n};\n\nexport default registerApplicationMiddlewares;\n"],"names":[],"mappings":";;AAMA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,yBAAyB,IAAI,MAAA,EAAQ;AAAA,EACzC,IAAI,KAAK,CAAC,UAAU;AACd,QAAA,OAAO,UAAU,UAAU;AACtB,aAAA,IAAI,SAAS;IACtB;AAEI,QAAA,OAAO,UAAU,UAAU;AAC7B,aAAO,IACJ,OAAO;AAAA,QACN,MAAM,IAAI,OAAO;AAAA,QACjB,SAAS,IAAI,OAAO;AAAA,QACpB,QAAQ,IAAI,MAAM;AAAA,MAAA,CACnB,EACA,WACA;IACL;AAEA,WAAO,IAAI,MAAA,EAAQ,KAAK,MAAM,KAAK;AAAA,EAAA,CACpC;AAAA;AACH;AAKM,MAAA,iCAAiC,OAAO,WAAmB;AAC/D,QAAM,mBAAqC,OAAO,OAAO,IAAI,eAAe,aAAa;AAEzF,QAAM,yBAAyB,gBAAgB;AAE/C,QAAM,cAAc,MAAM,mBAAmB,kBAAkB,MAAM;AAErE,2BAAyB,WAAW;AAIpC,aAAW,cAAc,aAAa;AAC7B,WAAA,OAAO,IAAI,WAAW,OAAO;AAAA,EACtC;AACF;AAMA,MAAM,2BAA2B,OAAO,WAA6B;AAC/D,MAAA;AACI,UAAA,uBAAuB,SAAS,QAAQ,EAAE,QAAQ,MAAM,YAAY,OAAO;AAAA,WAC1E,OAAO;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACF;AAMA,MAAM,2BAA2B,CAAC,gBAA2C;AAC3E,QAAM,qBAAqB,oBAAoB,OAAO,CAAC,SAAS;AAC9D,WAAO,YAAY,UAAU,CAAC,QAAQ,IAAI,SAAS,IAAI,MAAM;AAAA,EAAA,CAC9D;AAEG,MAAA,mBAAmB,SAAS,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,kFAAkF,mBAAmB;AAAA,QACnG;AAAA,MACD,CAAA;AAAA,IAAA;AAAA,EAEL;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -114,21 +114,22 @@
|
|
|
114
114
|
"dependencies": {
|
|
115
115
|
"@koa/cors": "3.4.3",
|
|
116
116
|
"@koa/router": "10.1.1",
|
|
117
|
-
"@strapi/admin": "4.
|
|
118
|
-
"@strapi/
|
|
119
|
-
"@strapi/
|
|
120
|
-
"@strapi/
|
|
121
|
-
"@strapi/
|
|
122
|
-
"@strapi/
|
|
123
|
-
"@strapi/
|
|
124
|
-
"@strapi/
|
|
125
|
-
"@strapi/
|
|
126
|
-
"@strapi/plugin-content-
|
|
127
|
-
"@strapi/plugin-
|
|
128
|
-
"@strapi/plugin-
|
|
129
|
-
"@strapi/
|
|
130
|
-
"@strapi/
|
|
131
|
-
"@strapi/utils": "4.
|
|
117
|
+
"@strapi/admin": "4.16.0",
|
|
118
|
+
"@strapi/content-releases": "4.16.0",
|
|
119
|
+
"@strapi/data-transfer": "4.16.0",
|
|
120
|
+
"@strapi/database": "4.16.0",
|
|
121
|
+
"@strapi/generate-new": "4.16.0",
|
|
122
|
+
"@strapi/generators": "4.16.0",
|
|
123
|
+
"@strapi/logger": "4.16.0",
|
|
124
|
+
"@strapi/pack-up": "4.16.0",
|
|
125
|
+
"@strapi/permissions": "4.16.0",
|
|
126
|
+
"@strapi/plugin-content-manager": "4.16.0",
|
|
127
|
+
"@strapi/plugin-content-type-builder": "4.16.0",
|
|
128
|
+
"@strapi/plugin-email": "4.16.0",
|
|
129
|
+
"@strapi/plugin-upload": "4.16.0",
|
|
130
|
+
"@strapi/types": "4.16.0",
|
|
131
|
+
"@strapi/typescript-utils": "4.16.0",
|
|
132
|
+
"@strapi/utils": "4.16.0",
|
|
132
133
|
"bcryptjs": "2.4.3",
|
|
133
134
|
"boxen": "5.1.2",
|
|
134
135
|
"chalk": "4.1.2",
|
|
@@ -188,13 +189,13 @@
|
|
|
188
189
|
"@types/node": "18.18.4",
|
|
189
190
|
"@types/node-schedule": "2.1.0",
|
|
190
191
|
"@types/statuses": "2.0.1",
|
|
191
|
-
"eslint-config-custom": "4.
|
|
192
|
+
"eslint-config-custom": "4.16.0",
|
|
192
193
|
"supertest": "6.3.3",
|
|
193
|
-
"tsconfig": "4.
|
|
194
|
+
"tsconfig": "4.16.0"
|
|
194
195
|
},
|
|
195
196
|
"engines": {
|
|
196
197
|
"node": ">=18.0.0 <=20.x.x",
|
|
197
198
|
"npm": ">=6.0.0"
|
|
198
199
|
},
|
|
199
|
-
"gitHead": "
|
|
200
|
+
"gitHead": "b8acb528cd7a2c45467b3b84e79c10f7e652a844"
|
|
200
201
|
}
|