@strapi/core 0.0.0-experimental.117b0ba4c41638592858ef7c29fec09396cf01be → 0.0.0-experimental.1610404a03d98b65f497f9adda35815021b8fd76
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.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.js +1 -2
- package/dist/Strapi.js.map +1 -1
- package/dist/configuration/config-loader.js +1 -2
- package/dist/configuration/config-loader.js.map +1 -1
- package/dist/configuration/config-loader.mjs +1 -2
- package/dist/configuration/config-loader.mjs.map +1 -1
- package/dist/core-api/service/single-type.js +1 -2
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +1 -2
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +6 -1
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +6 -1
- package/dist/ee/index.mjs.map +1 -1
- package/dist/loaders/plugins/index.js +1 -2
- package/dist/loaders/plugins/index.js.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +18 -4
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +18 -4
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.js +2 -4
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs +2 -4
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +1 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.js +3 -6
- package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs +3 -6
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.d.ts +11 -8
- package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.js +28 -18
- package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.mjs +29 -19
- package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
- package/dist/services/metrics/index.js +1 -2
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs +1 -2
- package/dist/services/metrics/index.mjs.map +1 -1
- package/dist/utils/load-files.js +1 -2
- package/dist/utils/load-files.js.map +1 -1
- package/dist/utils/load-files.mjs +1 -2
- package/dist/utils/load-files.mjs.map +1 -1
- package/package.json +15 -15
package/dist/Strapi.js
CHANGED
|
@@ -37,8 +37,7 @@ const coreStore = require("./services/core-store.js");
|
|
|
37
37
|
const config = require("./services/config.js");
|
|
38
38
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
39
39
|
function _interopNamespace(e) {
|
|
40
|
-
if (e && e.__esModule)
|
|
41
|
-
return e;
|
|
40
|
+
if (e && e.__esModule) return e;
|
|
42
41
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
43
42
|
if (e) {
|
|
44
43
|
for (const k in e) {
|
package/dist/Strapi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strapi.js","sources":["../src/Strapi.ts"],"sourcesContent":["import * as globalAgent from 'global-agent';\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\n\nimport type { Core, Modules, UID, Schema } from '@strapi/types';\n\nimport { loadConfiguration } from './configuration';\n\nimport * as factories from './factories';\n\nimport * as utils from './utils';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport { createReloader } from './services/reloader';\n\nimport { providers } from './providers';\nimport createEntityService from './services/entity-service';\nimport createQueryParamService from './services/query-params';\n\nimport entityValidator from './services/entity-validator';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\nclass Strapi extends Container implements Core.Strapi {\n app: any;\n\n isLoaded: boolean = false;\n\n internal_config: Record<string, unknown> = {};\n\n constructor(opts: StrapiOptions) {\n super();\n\n this.internal_config = loadConfiguration(opts);\n\n this.registerInternalServices();\n\n for (const provider of providers) {\n provider.init?.(this);\n }\n }\n\n get admin(): Core.Module {\n return this.get('admin');\n }\n\n get EE(): boolean {\n return utils.ee.isEE;\n }\n\n get ee(): Core.Strapi['ee'] {\n return utils.ee;\n }\n\n get dirs(): Core.StrapiDirectories {\n return this.config.get('dirs');\n }\n\n get reload(): Core.Reloader {\n return this.get('reload');\n }\n\n get db(): Database {\n return this.get('db');\n }\n\n get requestContext(): Modules.RequestContext.RequestContext {\n return this.get('requestContext');\n }\n\n get customFields(): Modules.CustomFields.CustomFields {\n return this.get('customFields');\n }\n\n get entityValidator(): Modules.EntityValidator.EntityValidator {\n return this.get('entityValidator');\n }\n\n /**\n * @deprecated `strapi.entityService` will be removed in the next major version\n */\n get entityService(): Modules.EntityService.EntityService {\n return this.get('entityService');\n }\n\n get documents(): Modules.Documents.Service {\n return this.get('documents');\n }\n\n get features(): FeaturesService {\n return this.get('features');\n }\n\n get fetch(): Modules.Fetch.Fetch {\n return this.get('fetch');\n }\n\n get cron(): Modules.Cron.CronService {\n return this.get('cron');\n }\n\n get log(): Logger {\n return this.get('logger');\n }\n\n get startupLogger(): Core.StartupLogger {\n return this.get('startupLogger');\n }\n\n get eventHub(): Modules.EventHub.EventHub {\n return this.get('eventHub');\n }\n\n get fs(): Core.StrapiFS {\n return this.get('fs');\n }\n\n get server(): Modules.Server.Server {\n return this.get('server');\n }\n\n get telemetry(): Modules.Metrics.TelemetryService {\n return this.get('telemetry');\n }\n\n get store(): Modules.CoreStore.CoreStore {\n return this.get('coreStore');\n }\n\n get config() {\n return this.get('config');\n }\n\n get services() {\n return this.get('services').getAll();\n }\n\n service(uid: UID.Service) {\n return this.get('services').get(uid);\n }\n\n get controllers() {\n return this.get('controllers').getAll();\n }\n\n controller(uid: UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Schema.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Schema.Components {\n return this.get('components').getAll();\n }\n\n get policies() {\n return this.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.get('policies').get(name);\n }\n\n get middlewares() {\n return this.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Core.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Core.Plugin {\n return this.get('plugins').get(name);\n }\n\n get hooks() {\n return this.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.get('hooks').get(name);\n }\n\n get apis() {\n return this.get('apis').getAll();\n }\n\n api(name: string): Core.Module {\n return this.get('apis').get(name);\n }\n\n get auth() {\n return this.get('auth');\n }\n\n get contentAPI() {\n return this.get('content-api');\n }\n\n get sanitizers() {\n return this.get('sanitizers');\n }\n\n get validators() {\n return this.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 // TODO: split into more providers\n registerInternalServices() {\n const config = createConfigProvider(this.internal_config, this);\n\n const logger = createLogger({\n level: 'http', // Strapi defaults to level 'http'\n ...config.get('logger'), // DEPRECATED\n ...config.get('server.logger.config'),\n });\n\n // Instantiate the Strapi container\n this.add('config', () => config)\n .add('query-params', createQueryParamService(this))\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('server', () => createServer(this))\n .add('fs', () => createStrapiFs(this))\n .add('eventHub', () => createEventHub())\n .add('startupLogger', () => utils.createStartupLogger(this))\n .add('logger', () => logger)\n .add('fetch', () => utils.createStrapiFetch(this))\n .add('features', () => createFeaturesService(this))\n .add('requestContext', requestContext)\n .add('customFields', createCustomFields(this))\n .add('entityValidator', entityValidator)\n .add('entityService', () => createEntityService({ strapi: this, db: this.db }))\n .add('documents', () => createDocumentService(this))\n .add(\n 'db',\n () =>\n new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(this.dirs.app.root, 'database/migrations'),\n },\n },\n })\n )\n )\n .add('reload', () => createReloader(this));\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Core.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.log.info('Strapi started successfully');\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 load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this;\n }\n\n async register() {\n // @ts-expect-error: init is internal\n this.ee.init(this.dirs.app.root, this.log);\n\n for (const provider of providers) {\n await provider.register?.(this);\n }\n\n await this.runPluginsLifecycles(utils.LIFECYCLES.REGISTER);\n await this.runUserLifecycles(utils.LIFECYCLES.REGISTER);\n\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n this.configureGlobalProxy();\n\n const models = [\n ...utils.transformContentTypesToModels(\n [...Object.values(this.contentTypes), ...Object.values(this.components)],\n this.db.metadata.identifiers\n ),\n ...this.get('models').get(),\n ];\n\n await this.db.init({ models });\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\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 utils.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.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runPluginsLifecycles(utils.LIFECYCLES.BOOTSTRAP);\n\n for (const provider of providers) {\n await provider.bootstrap?.(this);\n }\n\n await this.runUserLifecycles(utils.LIFECYCLES.BOOTSTRAP);\n\n return this;\n }\n\n configureGlobalProxy() {\n const globalProxy = this.config.get('server.proxy.global');\n const httpProxy = this.config.get('server.proxy.http') || globalProxy;\n const httpsProxy = this.config.get('server.proxy.https') || globalProxy;\n\n if (!httpProxy && !httpsProxy) {\n return;\n }\n\n globalAgent.bootstrap();\n\n if (httpProxy) {\n this.log.info(`Using HTTP proxy: ${httpProxy}`);\n (global as any).GLOBAL_AGENT.HTTP_PROXY = httpProxy;\n }\n\n if (httpsProxy) {\n this.log.info(`Using HTTPS proxy: ${httpsProxy}`);\n (global as any).GLOBAL_AGENT.HTTPS_PROXY = httpsProxy;\n }\n }\n\n async destroy() {\n this.log.info('Shutting down Strapi');\n await this.runPluginsLifecycles(utils.LIFECYCLES.DESTROY);\n\n for (const provider of providers) {\n await provider.destroy?.(this);\n }\n\n await this.runUserLifecycles(utils.LIFECYCLES.DESTROY);\n\n await this.server.destroy();\n\n this.eventHub.destroy();\n\n await this.db?.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 this.log.info('Strapi has been shut down');\n }\n\n async runPluginsLifecycles(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n }\n\n async runUserLifecycles(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\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: UID.ContentType): Schema.ContentType;\n getModel(uid: UID.Component): Schema.Component;\n getModel<TUID extends UID.Schema>(uid: TUID): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as UID.Component];\n }\n }\n\n /**\n * @deprecated Use `strapi.db.query` instead\n */\n query(uid: UID.Schema) {\n return this.db.query(uid);\n }\n}\n\nexport interface StrapiOptions {\n appDir: string;\n distDir: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\nexport default Strapi;\n"],"names":["Container","loadConfiguration","providers","utils.ee","config","createConfigProvider","logger","createLogger","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","utils.createStartupLogger","utils.createStrapiFetch","createFeaturesService","createCustomFields","entityValidator","createEntityService","createDocumentService","Database","_","path","createReloader","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","utils.LIFECYCLES","utils.convertCustomFieldType","utils.transformContentTypesToModels","coreStoreModel","globalAgent","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,eAAeA,UAAAA,UAAiC;AAAA,EACpD;AAAA,EAEA,WAAoB;AAAA,EAEpB,kBAA2C,CAAA;AAAA,EAE3C,YAAY,MAAqB;AACzB;AAED,SAAA,kBAAkBC,wBAAkB,IAAI;AAE7C,SAAK,yBAAyB;AAE9B,eAAW,YAAYC,mBAAW;AAChC,eAAS,OAAO,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,IAAI,QAAqB;AAChB,WAAA,KAAK,IAAI,OAAO;AAAA,EACzB;AAAA,EA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BJ,WAAM,WAAW,OAAO;AAExD,eAAW,YAAY5B,mBAAW;AAC1B,YAAA,SAAS,UAAU,IAAI;AAAA,IAC/B;AAEA,UAAM,KAAK,kBAAkB4B,WAAM,WAAW,OAAO;AAE/C,UAAA,KAAK,OAAO;AAElB,SAAK,SAAS;AAER,UAAA,KAAK,IAAI;AAEf,YAAQ,mBAAmB;AAG3B,WAAO,OAAO;AAET,SAAA,IAAI,KAAK,2BAA2B;AAAA,EAC3C;AAAA,EAEA,MAAM,qBAAqB,eAAqD;AAE9E,UAAM,KAAK,IAAI,SAAS,EAAE,aAAa,EAAE;AAAA,EAC3C;AAAA,EAEA,MAAM,kBAAkB,eAAqD;AAE3E,UAAM,wBAAwB,KAAK,OAAO,KAAK,IAAI,aAAa;AAC5D,QAAAK,GAAAA,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SAAkC,KAA8D;AAC1F,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAAsB;AAAA,IACjD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAAoB;AAAA,IAC7C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAiB;AACd,WAAA,KAAK,GAAG,MAAM,GAAG;AAAA,EAC1B;AACF;;"}
|
|
1
|
+
{"version":3,"file":"Strapi.js","sources":["../src/Strapi.ts"],"sourcesContent":["import * as globalAgent from 'global-agent';\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\n\nimport type { Core, Modules, UID, Schema } from '@strapi/types';\n\nimport { loadConfiguration } from './configuration';\n\nimport * as factories from './factories';\n\nimport * as utils from './utils';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport { createReloader } from './services/reloader';\n\nimport { providers } from './providers';\nimport createEntityService from './services/entity-service';\nimport createQueryParamService from './services/query-params';\n\nimport entityValidator from './services/entity-validator';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\nclass Strapi extends Container implements Core.Strapi {\n app: any;\n\n isLoaded: boolean = false;\n\n internal_config: Record<string, unknown> = {};\n\n constructor(opts: StrapiOptions) {\n super();\n\n this.internal_config = loadConfiguration(opts);\n\n this.registerInternalServices();\n\n for (const provider of providers) {\n provider.init?.(this);\n }\n }\n\n get admin(): Core.Module {\n return this.get('admin');\n }\n\n get EE(): boolean {\n return utils.ee.isEE;\n }\n\n get ee(): Core.Strapi['ee'] {\n return utils.ee;\n }\n\n get dirs(): Core.StrapiDirectories {\n return this.config.get('dirs');\n }\n\n get reload(): Core.Reloader {\n return this.get('reload');\n }\n\n get db(): Database {\n return this.get('db');\n }\n\n get requestContext(): Modules.RequestContext.RequestContext {\n return this.get('requestContext');\n }\n\n get customFields(): Modules.CustomFields.CustomFields {\n return this.get('customFields');\n }\n\n get entityValidator(): Modules.EntityValidator.EntityValidator {\n return this.get('entityValidator');\n }\n\n /**\n * @deprecated `strapi.entityService` will be removed in the next major version\n */\n get entityService(): Modules.EntityService.EntityService {\n return this.get('entityService');\n }\n\n get documents(): Modules.Documents.Service {\n return this.get('documents');\n }\n\n get features(): FeaturesService {\n return this.get('features');\n }\n\n get fetch(): Modules.Fetch.Fetch {\n return this.get('fetch');\n }\n\n get cron(): Modules.Cron.CronService {\n return this.get('cron');\n }\n\n get log(): Logger {\n return this.get('logger');\n }\n\n get startupLogger(): Core.StartupLogger {\n return this.get('startupLogger');\n }\n\n get eventHub(): Modules.EventHub.EventHub {\n return this.get('eventHub');\n }\n\n get fs(): Core.StrapiFS {\n return this.get('fs');\n }\n\n get server(): Modules.Server.Server {\n return this.get('server');\n }\n\n get telemetry(): Modules.Metrics.TelemetryService {\n return this.get('telemetry');\n }\n\n get store(): Modules.CoreStore.CoreStore {\n return this.get('coreStore');\n }\n\n get config() {\n return this.get('config');\n }\n\n get services() {\n return this.get('services').getAll();\n }\n\n service(uid: UID.Service) {\n return this.get('services').get(uid);\n }\n\n get controllers() {\n return this.get('controllers').getAll();\n }\n\n controller(uid: UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Schema.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Schema.Components {\n return this.get('components').getAll();\n }\n\n get policies() {\n return this.get('policies').getAll();\n }\n\n policy(name: string) {\n return this.get('policies').get(name);\n }\n\n get middlewares() {\n return this.get('middlewares').getAll();\n }\n\n middleware(name: string) {\n return this.get('middlewares').get(name);\n }\n\n get plugins(): Record<string, Core.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Core.Plugin {\n return this.get('plugins').get(name);\n }\n\n get hooks() {\n return this.get('hooks').getAll();\n }\n\n hook(name: string) {\n return this.get('hooks').get(name);\n }\n\n get apis() {\n return this.get('apis').getAll();\n }\n\n api(name: string): Core.Module {\n return this.get('apis').get(name);\n }\n\n get auth() {\n return this.get('auth');\n }\n\n get contentAPI() {\n return this.get('content-api');\n }\n\n get sanitizers() {\n return this.get('sanitizers');\n }\n\n get validators() {\n return this.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 // TODO: split into more providers\n registerInternalServices() {\n const config = createConfigProvider(this.internal_config, this);\n\n const logger = createLogger({\n level: 'http', // Strapi defaults to level 'http'\n ...config.get('logger'), // DEPRECATED\n ...config.get('server.logger.config'),\n });\n\n // Instantiate the Strapi container\n this.add('config', () => config)\n .add('query-params', createQueryParamService(this))\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('server', () => createServer(this))\n .add('fs', () => createStrapiFs(this))\n .add('eventHub', () => createEventHub())\n .add('startupLogger', () => utils.createStartupLogger(this))\n .add('logger', () => logger)\n .add('fetch', () => utils.createStrapiFetch(this))\n .add('features', () => createFeaturesService(this))\n .add('requestContext', requestContext)\n .add('customFields', createCustomFields(this))\n .add('entityValidator', entityValidator)\n .add('entityService', () => createEntityService({ strapi: this, db: this.db }))\n .add('documents', () => createDocumentService(this))\n .add(\n 'db',\n () =>\n new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(this.dirs.app.root, 'database/migrations'),\n },\n },\n })\n )\n )\n .add('reload', () => createReloader(this));\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Core.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.log.info('Strapi started successfully');\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 load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this;\n }\n\n async register() {\n // @ts-expect-error: init is internal\n this.ee.init(this.dirs.app.root, this.log);\n\n for (const provider of providers) {\n await provider.register?.(this);\n }\n\n await this.runPluginsLifecycles(utils.LIFECYCLES.REGISTER);\n await this.runUserLifecycles(utils.LIFECYCLES.REGISTER);\n\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n this.configureGlobalProxy();\n\n const models = [\n ...utils.transformContentTypesToModels(\n [...Object.values(this.contentTypes), ...Object.values(this.components)],\n this.db.metadata.identifiers\n ),\n ...this.get('models').get(),\n ];\n\n await this.db.init({ models });\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\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 utils.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.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runPluginsLifecycles(utils.LIFECYCLES.BOOTSTRAP);\n\n for (const provider of providers) {\n await provider.bootstrap?.(this);\n }\n\n await this.runUserLifecycles(utils.LIFECYCLES.BOOTSTRAP);\n\n return this;\n }\n\n configureGlobalProxy() {\n const globalProxy = this.config.get('server.proxy.global');\n const httpProxy = this.config.get('server.proxy.http') || globalProxy;\n const httpsProxy = this.config.get('server.proxy.https') || globalProxy;\n\n if (!httpProxy && !httpsProxy) {\n return;\n }\n\n globalAgent.bootstrap();\n\n if (httpProxy) {\n this.log.info(`Using HTTP proxy: ${httpProxy}`);\n (global as any).GLOBAL_AGENT.HTTP_PROXY = httpProxy;\n }\n\n if (httpsProxy) {\n this.log.info(`Using HTTPS proxy: ${httpsProxy}`);\n (global as any).GLOBAL_AGENT.HTTPS_PROXY = httpsProxy;\n }\n }\n\n async destroy() {\n this.log.info('Shutting down Strapi');\n await this.runPluginsLifecycles(utils.LIFECYCLES.DESTROY);\n\n for (const provider of providers) {\n await provider.destroy?.(this);\n }\n\n await this.runUserLifecycles(utils.LIFECYCLES.DESTROY);\n\n await this.server.destroy();\n\n this.eventHub.destroy();\n\n await this.db?.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 this.log.info('Strapi has been shut down');\n }\n\n async runPluginsLifecycles(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n }\n\n async runUserLifecycles(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\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: UID.ContentType): Schema.ContentType;\n getModel(uid: UID.Component): Schema.Component;\n getModel<TUID extends UID.Schema>(uid: TUID): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as UID.Component];\n }\n }\n\n /**\n * @deprecated Use `strapi.db.query` instead\n */\n query(uid: UID.Schema) {\n return this.db.query(uid);\n }\n}\n\nexport interface StrapiOptions {\n appDir: string;\n distDir: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\nexport default Strapi;\n"],"names":["Container","loadConfiguration","providers","utils.ee","config","createConfigProvider","logger","createLogger","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","utils.createStartupLogger","utils.createStrapiFetch","createFeaturesService","createCustomFields","entityValidator","createEntityService","createDocumentService","Database","_","path","createReloader","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","utils.LIFECYCLES","utils.convertCustomFieldType","utils.transformContentTypesToModels","coreStoreModel","globalAgent","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,eAAeA,UAAAA,UAAiC;AAAA,EACpD;AAAA,EAEA,WAAoB;AAAA,EAEpB,kBAA2C,CAAA;AAAA,EAE3C,YAAY,MAAqB;AACzB;AAED,SAAA,kBAAkBC,wBAAkB,IAAI;AAE7C,SAAK,yBAAyB;AAE9B,eAAW,YAAYC,mBAAW;AAChC,eAAS,OAAO,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,IAAI,QAAqB;AAChB,WAAA,KAAK,IAAI,OAAO;AAAA,EACzB;AAAA,EAEA,IAAI,KAAc;AAChB,WAAOC,QAAS;AAAA,EAClB;AAAA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AC1B,YAAA,SAAS,UAAU,IAAI;AAAA,IAC/B;AAEA,UAAM,KAAK,kBAAkB4B,WAAM,WAAW,OAAO;AAE/C,UAAA,KAAK,OAAO;AAElB,SAAK,SAAS;AAER,UAAA,KAAK,IAAI;AAEf,YAAQ,mBAAmB;AAG3B,WAAO,OAAO;AAET,SAAA,IAAI,KAAK,2BAA2B;AAAA,EAC3C;AAAA,EAEA,MAAM,qBAAqB,eAAqD;AAE9E,UAAM,KAAK,IAAI,SAAS,EAAE,aAAa,EAAE;AAAA,EAC3C;AAAA,EAEA,MAAM,kBAAkB,eAAqD;AAE3E,UAAM,wBAAwB,KAAK,OAAO,KAAK,IAAI,aAAa;AAC5D,QAAAK,GAAAA,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SAAkC,KAA8D;AAC1F,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAAsB;AAAA,IACjD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAAoB;AAAA,IAC7C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAiB;AACd,WAAA,KAAK,GAAG,MAAM,GAAG;AAAA,EAC1B;AACF;;"}
|
|
@@ -48,8 +48,7 @@ const logWarning = (message) => {
|
|
|
48
48
|
console.warn(message);
|
|
49
49
|
};
|
|
50
50
|
const loadConfigDir = (dir) => {
|
|
51
|
-
if (!fs__default.default.existsSync(dir))
|
|
52
|
-
return {};
|
|
51
|
+
if (!fs__default.default.existsSync(dir)) return {};
|
|
53
52
|
const allFiles = fs__default.default.readdirSync(dir, { withFileTypes: true });
|
|
54
53
|
const seenFilenames = /* @__PURE__ */ new Set();
|
|
55
54
|
const configFiles = allFiles.reduce((acc, file) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sources":["../../src/configuration/config-loader.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport { loadConfigFile } from '../utils/load-config-file';\n\nconst VALID_EXTENSIONS = ['.js', '.json'];\n\n// These filenames are restricted, but will also emit a warning that the filename is probably a mistake\nconst MISTAKEN_FILENAMES = {\n middleware: 'middlewares',\n plugin: 'plugins',\n};\n\n// the following are restricted to prevent conflicts with existing STRAPI_* env vars or root level config options\n// must all be lowercase to match validator\nconst RESTRICTED_FILENAMES = [\n // existing env vars\n 'uuid',\n 'hosting',\n 'license',\n 'enforce',\n 'disable',\n 'enable',\n 'telemetry',\n\n // reserved for future internal use\n 'strapi',\n 'internal',\n\n // root level config options\n // TODO: it would be better to move these out of the root config and allow them to be loaded\n 'launchedAt',\n 'serveAdminPanel',\n 'autoReload',\n 'environment',\n 'packageJsonStrapi',\n 'info',\n 'autoReload',\n 'dirs',\n\n // probably mistaken/typo filenames\n ...Object.keys(MISTAKEN_FILENAMES),\n];\n\n// Existing Strapi configuration files\nconst STRAPI_CONFIG_FILENAMES = [\n 'admin',\n 'server',\n 'api',\n 'database',\n 'middlewares',\n 'plugins',\n 'features',\n];\n\n// Note: we don't have access to strapi logger at this point so we can't use it\nconst logWarning = (message: string) => {\n console.warn(message);\n};\n\nexport default (dir: string) => {\n if (!fs.existsSync(dir)) return {};\n\n const allFiles = fs.readdirSync(dir, { withFileTypes: true });\n const seenFilenames = new Set<string>();\n const configFiles = allFiles.reduce((acc, file) => {\n const baseName = path.basename(file.name, path.extname(file.name));\n const baseNameLower = baseName.toLowerCase();\n const extension = path.extname(file.name);\n const extensionLower = extension.toLowerCase();\n\n if (!file.isFile()) {\n return acc;\n }\n\n if (!VALID_EXTENSIONS.includes(extensionLower)) {\n logWarning(\n `Config file not loaded, extension must be one of ${VALID_EXTENSIONS.join(',')}): ${\n file.name\n }`\n );\n return acc;\n }\n\n if (RESTRICTED_FILENAMES.includes(baseNameLower)) {\n logWarning(`Config file not loaded, restricted filename: ${file.name}`);\n\n // suggest the filename they probably meant\n if (baseNameLower in MISTAKEN_FILENAMES) {\n console.log(\n `Did you mean ${MISTAKEN_FILENAMES[baseNameLower as keyof typeof MISTAKEN_FILENAMES]}]} ?`\n );\n }\n\n return acc;\n }\n\n // restricted names and Strapi configs are also restricted from being prefixes\n const restrictedPrefix = [...RESTRICTED_FILENAMES, ...STRAPI_CONFIG_FILENAMES].find(\n (restrictedName) =>\n restrictedName.startsWith(baseNameLower) && restrictedName !== baseNameLower\n );\n if (restrictedPrefix) {\n logWarning(\n `Config file not loaded, filename cannot start with ${restrictedPrefix}: ${file.name}`\n );\n }\n\n /**\n * Note: If user config files contain non-alpha-numeric characters, we won't be able to auto-load env\n * into them.\n *\n * For the initial feature, we will only load our internal configs, but later when we provide a method\n * to define the shape of custom configs, we will need to warn that those filenames can't be loaded\n * for technical limitations on env variable names\n * */\n // if (!/^[A-Za-z0-9]+$/.test(baseName)) {\n // logWarning(\"Using a non-alphanumeric config file name prevents Strapi from auto-loading it from environment variables.\")\n // }\n\n // filter filenames without case-insensitive uniqueness\n if (seenFilenames.has(baseNameLower)) {\n logWarning(\n `Config file not loaded, case-insensitive name matches other config file: ${file.name}`\n );\n return acc;\n }\n seenFilenames.add(baseNameLower);\n\n // If file passes all filters, add it to the accumulator\n acc.push(file);\n return acc;\n }, [] as fs.Dirent[]);\n\n return configFiles.reduce(\n (acc, file) => {\n const key = path.basename(file.name, path.extname(file.name));\n\n acc[key] = loadConfigFile(path.resolve(dir, file.name));\n\n return acc;\n },\n {} as Record<string, unknown>\n );\n};\n"],"names":["fs","path","loadConfigFile"],"mappings":";;;;;;;AAIA,MAAM,mBAAmB,CAAC,OAAO,OAAO;AAGxC,MAAM,qBAAqB;AAAA,EACzB,YAAY;AAAA,EACZ,QAAQ;AACV;AAIA,MAAM,uBAAuB;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA,GAAG,OAAO,KAAK,kBAAkB;AACnC;AAGA,MAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,aAAa,CAAC,YAAoB;AACtC,UAAQ,KAAK,OAAO;AACtB;AAEA,MAAe,gBAAA,CAAC,QAAgB;
|
|
1
|
+
{"version":3,"file":"config-loader.js","sources":["../../src/configuration/config-loader.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport { loadConfigFile } from '../utils/load-config-file';\n\nconst VALID_EXTENSIONS = ['.js', '.json'];\n\n// These filenames are restricted, but will also emit a warning that the filename is probably a mistake\nconst MISTAKEN_FILENAMES = {\n middleware: 'middlewares',\n plugin: 'plugins',\n};\n\n// the following are restricted to prevent conflicts with existing STRAPI_* env vars or root level config options\n// must all be lowercase to match validator\nconst RESTRICTED_FILENAMES = [\n // existing env vars\n 'uuid',\n 'hosting',\n 'license',\n 'enforce',\n 'disable',\n 'enable',\n 'telemetry',\n\n // reserved for future internal use\n 'strapi',\n 'internal',\n\n // root level config options\n // TODO: it would be better to move these out of the root config and allow them to be loaded\n 'launchedAt',\n 'serveAdminPanel',\n 'autoReload',\n 'environment',\n 'packageJsonStrapi',\n 'info',\n 'autoReload',\n 'dirs',\n\n // probably mistaken/typo filenames\n ...Object.keys(MISTAKEN_FILENAMES),\n];\n\n// Existing Strapi configuration files\nconst STRAPI_CONFIG_FILENAMES = [\n 'admin',\n 'server',\n 'api',\n 'database',\n 'middlewares',\n 'plugins',\n 'features',\n];\n\n// Note: we don't have access to strapi logger at this point so we can't use it\nconst logWarning = (message: string) => {\n console.warn(message);\n};\n\nexport default (dir: string) => {\n if (!fs.existsSync(dir)) return {};\n\n const allFiles = fs.readdirSync(dir, { withFileTypes: true });\n const seenFilenames = new Set<string>();\n const configFiles = allFiles.reduce((acc, file) => {\n const baseName = path.basename(file.name, path.extname(file.name));\n const baseNameLower = baseName.toLowerCase();\n const extension = path.extname(file.name);\n const extensionLower = extension.toLowerCase();\n\n if (!file.isFile()) {\n return acc;\n }\n\n if (!VALID_EXTENSIONS.includes(extensionLower)) {\n logWarning(\n `Config file not loaded, extension must be one of ${VALID_EXTENSIONS.join(',')}): ${\n file.name\n }`\n );\n return acc;\n }\n\n if (RESTRICTED_FILENAMES.includes(baseNameLower)) {\n logWarning(`Config file not loaded, restricted filename: ${file.name}`);\n\n // suggest the filename they probably meant\n if (baseNameLower in MISTAKEN_FILENAMES) {\n console.log(\n `Did you mean ${MISTAKEN_FILENAMES[baseNameLower as keyof typeof MISTAKEN_FILENAMES]}]} ?`\n );\n }\n\n return acc;\n }\n\n // restricted names and Strapi configs are also restricted from being prefixes\n const restrictedPrefix = [...RESTRICTED_FILENAMES, ...STRAPI_CONFIG_FILENAMES].find(\n (restrictedName) =>\n restrictedName.startsWith(baseNameLower) && restrictedName !== baseNameLower\n );\n if (restrictedPrefix) {\n logWarning(\n `Config file not loaded, filename cannot start with ${restrictedPrefix}: ${file.name}`\n );\n }\n\n /**\n * Note: If user config files contain non-alpha-numeric characters, we won't be able to auto-load env\n * into them.\n *\n * For the initial feature, we will only load our internal configs, but later when we provide a method\n * to define the shape of custom configs, we will need to warn that those filenames can't be loaded\n * for technical limitations on env variable names\n * */\n // if (!/^[A-Za-z0-9]+$/.test(baseName)) {\n // logWarning(\"Using a non-alphanumeric config file name prevents Strapi from auto-loading it from environment variables.\")\n // }\n\n // filter filenames without case-insensitive uniqueness\n if (seenFilenames.has(baseNameLower)) {\n logWarning(\n `Config file not loaded, case-insensitive name matches other config file: ${file.name}`\n );\n return acc;\n }\n seenFilenames.add(baseNameLower);\n\n // If file passes all filters, add it to the accumulator\n acc.push(file);\n return acc;\n }, [] as fs.Dirent[]);\n\n return configFiles.reduce(\n (acc, file) => {\n const key = path.basename(file.name, path.extname(file.name));\n\n acc[key] = loadConfigFile(path.resolve(dir, file.name));\n\n return acc;\n },\n {} as Record<string, unknown>\n );\n};\n"],"names":["fs","path","loadConfigFile"],"mappings":";;;;;;;AAIA,MAAM,mBAAmB,CAAC,OAAO,OAAO;AAGxC,MAAM,qBAAqB;AAAA,EACzB,YAAY;AAAA,EACZ,QAAQ;AACV;AAIA,MAAM,uBAAuB;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA,GAAG,OAAO,KAAK,kBAAkB;AACnC;AAGA,MAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,aAAa,CAAC,YAAoB;AACtC,UAAQ,KAAK,OAAO;AACtB;AAEA,MAAe,gBAAA,CAAC,QAAgB;AAC9B,MAAI,CAACA,YAAAA,QAAG,WAAW,GAAG,UAAU,CAAA;AAEhC,QAAM,WAAWA,YAAAA,QAAG,YAAY,KAAK,EAAE,eAAe,MAAM;AACtD,QAAA,oCAAoB;AAC1B,QAAM,cAAc,SAAS,OAAO,CAAC,KAAK,SAAS;AAC3C,UAAA,WAAWC,cAAAA,QAAK,SAAS,KAAK,MAAMA,cAAK,QAAA,QAAQ,KAAK,IAAI,CAAC;AAC3D,UAAA,gBAAgB,SAAS;AAC/B,UAAM,YAAYA,cAAA,QAAK,QAAQ,KAAK,IAAI;AAClC,UAAA,iBAAiB,UAAU;AAE7B,QAAA,CAAC,KAAK,UAAU;AACX,aAAA;AAAA,IACT;AAEA,QAAI,CAAC,iBAAiB,SAAS,cAAc,GAAG;AAC9C;AAAA,QACE,oDAAoD,iBAAiB,KAAK,GAAG,CAAC,MAC5E,KAAK,IACP;AAAA,MAAA;AAEK,aAAA;AAAA,IACT;AAEI,QAAA,qBAAqB,SAAS,aAAa,GAAG;AACrC,iBAAA,gDAAgD,KAAK,IAAI,EAAE;AAGtE,UAAI,iBAAiB,oBAAoB;AAC/B,gBAAA;AAAA,UACN,gBAAgB,mBAAmB,aAAgD,CAAC;AAAA,QAAA;AAAA,MAExF;AAEO,aAAA;AAAA,IACT;AAGA,UAAM,mBAAmB,CAAC,GAAG,sBAAsB,GAAG,uBAAuB,EAAE;AAAA,MAC7E,CAAC,mBACC,eAAe,WAAW,aAAa,KAAK,mBAAmB;AAAA,IAAA;AAEnE,QAAI,kBAAkB;AACpB;AAAA,QACE,sDAAsD,gBAAgB,KAAK,KAAK,IAAI;AAAA,MAAA;AAAA,IAExF;AAeI,QAAA,cAAc,IAAI,aAAa,GAAG;AACpC;AAAA,QACE,4EAA4E,KAAK,IAAI;AAAA,MAAA;AAEhF,aAAA;AAAA,IACT;AACA,kBAAc,IAAI,aAAa;AAG/B,QAAI,KAAK,IAAI;AACN,WAAA;AAAA,EACT,GAAG,CAAiB,CAAA;AAEpB,SAAO,YAAY;AAAA,IACjB,CAAC,KAAK,SAAS;AACP,YAAA,MAAMA,cAAAA,QAAK,SAAS,KAAK,MAAMA,cAAK,QAAA,QAAQ,KAAK,IAAI,CAAC;AAExD,UAAA,GAAG,IAAIC,eAAAA,eAAeD,cAAA,QAAK,QAAQ,KAAK,KAAK,IAAI,CAAC;AAE/C,aAAA;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EAAA;AAEL;;"}
|
|
@@ -44,8 +44,7 @@ const logWarning = (message) => {
|
|
|
44
44
|
console.warn(message);
|
|
45
45
|
};
|
|
46
46
|
const loadConfigDir = (dir) => {
|
|
47
|
-
if (!fs.existsSync(dir))
|
|
48
|
-
return {};
|
|
47
|
+
if (!fs.existsSync(dir)) return {};
|
|
49
48
|
const allFiles = fs.readdirSync(dir, { withFileTypes: true });
|
|
50
49
|
const seenFilenames = /* @__PURE__ */ new Set();
|
|
51
50
|
const configFiles = allFiles.reduce((acc, file) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.mjs","sources":["../../src/configuration/config-loader.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport { loadConfigFile } from '../utils/load-config-file';\n\nconst VALID_EXTENSIONS = ['.js', '.json'];\n\n// These filenames are restricted, but will also emit a warning that the filename is probably a mistake\nconst MISTAKEN_FILENAMES = {\n middleware: 'middlewares',\n plugin: 'plugins',\n};\n\n// the following are restricted to prevent conflicts with existing STRAPI_* env vars or root level config options\n// must all be lowercase to match validator\nconst RESTRICTED_FILENAMES = [\n // existing env vars\n 'uuid',\n 'hosting',\n 'license',\n 'enforce',\n 'disable',\n 'enable',\n 'telemetry',\n\n // reserved for future internal use\n 'strapi',\n 'internal',\n\n // root level config options\n // TODO: it would be better to move these out of the root config and allow them to be loaded\n 'launchedAt',\n 'serveAdminPanel',\n 'autoReload',\n 'environment',\n 'packageJsonStrapi',\n 'info',\n 'autoReload',\n 'dirs',\n\n // probably mistaken/typo filenames\n ...Object.keys(MISTAKEN_FILENAMES),\n];\n\n// Existing Strapi configuration files\nconst STRAPI_CONFIG_FILENAMES = [\n 'admin',\n 'server',\n 'api',\n 'database',\n 'middlewares',\n 'plugins',\n 'features',\n];\n\n// Note: we don't have access to strapi logger at this point so we can't use it\nconst logWarning = (message: string) => {\n console.warn(message);\n};\n\nexport default (dir: string) => {\n if (!fs.existsSync(dir)) return {};\n\n const allFiles = fs.readdirSync(dir, { withFileTypes: true });\n const seenFilenames = new Set<string>();\n const configFiles = allFiles.reduce((acc, file) => {\n const baseName = path.basename(file.name, path.extname(file.name));\n const baseNameLower = baseName.toLowerCase();\n const extension = path.extname(file.name);\n const extensionLower = extension.toLowerCase();\n\n if (!file.isFile()) {\n return acc;\n }\n\n if (!VALID_EXTENSIONS.includes(extensionLower)) {\n logWarning(\n `Config file not loaded, extension must be one of ${VALID_EXTENSIONS.join(',')}): ${\n file.name\n }`\n );\n return acc;\n }\n\n if (RESTRICTED_FILENAMES.includes(baseNameLower)) {\n logWarning(`Config file not loaded, restricted filename: ${file.name}`);\n\n // suggest the filename they probably meant\n if (baseNameLower in MISTAKEN_FILENAMES) {\n console.log(\n `Did you mean ${MISTAKEN_FILENAMES[baseNameLower as keyof typeof MISTAKEN_FILENAMES]}]} ?`\n );\n }\n\n return acc;\n }\n\n // restricted names and Strapi configs are also restricted from being prefixes\n const restrictedPrefix = [...RESTRICTED_FILENAMES, ...STRAPI_CONFIG_FILENAMES].find(\n (restrictedName) =>\n restrictedName.startsWith(baseNameLower) && restrictedName !== baseNameLower\n );\n if (restrictedPrefix) {\n logWarning(\n `Config file not loaded, filename cannot start with ${restrictedPrefix}: ${file.name}`\n );\n }\n\n /**\n * Note: If user config files contain non-alpha-numeric characters, we won't be able to auto-load env\n * into them.\n *\n * For the initial feature, we will only load our internal configs, but later when we provide a method\n * to define the shape of custom configs, we will need to warn that those filenames can't be loaded\n * for technical limitations on env variable names\n * */\n // if (!/^[A-Za-z0-9]+$/.test(baseName)) {\n // logWarning(\"Using a non-alphanumeric config file name prevents Strapi from auto-loading it from environment variables.\")\n // }\n\n // filter filenames without case-insensitive uniqueness\n if (seenFilenames.has(baseNameLower)) {\n logWarning(\n `Config file not loaded, case-insensitive name matches other config file: ${file.name}`\n );\n return acc;\n }\n seenFilenames.add(baseNameLower);\n\n // If file passes all filters, add it to the accumulator\n acc.push(file);\n return acc;\n }, [] as fs.Dirent[]);\n\n return configFiles.reduce(\n (acc, file) => {\n const key = path.basename(file.name, path.extname(file.name));\n\n acc[key] = loadConfigFile(path.resolve(dir, file.name));\n\n return acc;\n },\n {} as Record<string, unknown>\n );\n};\n"],"names":[],"mappings":";;;AAIA,MAAM,mBAAmB,CAAC,OAAO,OAAO;AAGxC,MAAM,qBAAqB;AAAA,EACzB,YAAY;AAAA,EACZ,QAAQ;AACV;AAIA,MAAM,uBAAuB;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA,GAAG,OAAO,KAAK,kBAAkB;AACnC;AAGA,MAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,aAAa,CAAC,YAAoB;AACtC,UAAQ,KAAK,OAAO;AACtB;AAEA,MAAe,gBAAA,CAAC,QAAgB;
|
|
1
|
+
{"version":3,"file":"config-loader.mjs","sources":["../../src/configuration/config-loader.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport { loadConfigFile } from '../utils/load-config-file';\n\nconst VALID_EXTENSIONS = ['.js', '.json'];\n\n// These filenames are restricted, but will also emit a warning that the filename is probably a mistake\nconst MISTAKEN_FILENAMES = {\n middleware: 'middlewares',\n plugin: 'plugins',\n};\n\n// the following are restricted to prevent conflicts with existing STRAPI_* env vars or root level config options\n// must all be lowercase to match validator\nconst RESTRICTED_FILENAMES = [\n // existing env vars\n 'uuid',\n 'hosting',\n 'license',\n 'enforce',\n 'disable',\n 'enable',\n 'telemetry',\n\n // reserved for future internal use\n 'strapi',\n 'internal',\n\n // root level config options\n // TODO: it would be better to move these out of the root config and allow them to be loaded\n 'launchedAt',\n 'serveAdminPanel',\n 'autoReload',\n 'environment',\n 'packageJsonStrapi',\n 'info',\n 'autoReload',\n 'dirs',\n\n // probably mistaken/typo filenames\n ...Object.keys(MISTAKEN_FILENAMES),\n];\n\n// Existing Strapi configuration files\nconst STRAPI_CONFIG_FILENAMES = [\n 'admin',\n 'server',\n 'api',\n 'database',\n 'middlewares',\n 'plugins',\n 'features',\n];\n\n// Note: we don't have access to strapi logger at this point so we can't use it\nconst logWarning = (message: string) => {\n console.warn(message);\n};\n\nexport default (dir: string) => {\n if (!fs.existsSync(dir)) return {};\n\n const allFiles = fs.readdirSync(dir, { withFileTypes: true });\n const seenFilenames = new Set<string>();\n const configFiles = allFiles.reduce((acc, file) => {\n const baseName = path.basename(file.name, path.extname(file.name));\n const baseNameLower = baseName.toLowerCase();\n const extension = path.extname(file.name);\n const extensionLower = extension.toLowerCase();\n\n if (!file.isFile()) {\n return acc;\n }\n\n if (!VALID_EXTENSIONS.includes(extensionLower)) {\n logWarning(\n `Config file not loaded, extension must be one of ${VALID_EXTENSIONS.join(',')}): ${\n file.name\n }`\n );\n return acc;\n }\n\n if (RESTRICTED_FILENAMES.includes(baseNameLower)) {\n logWarning(`Config file not loaded, restricted filename: ${file.name}`);\n\n // suggest the filename they probably meant\n if (baseNameLower in MISTAKEN_FILENAMES) {\n console.log(\n `Did you mean ${MISTAKEN_FILENAMES[baseNameLower as keyof typeof MISTAKEN_FILENAMES]}]} ?`\n );\n }\n\n return acc;\n }\n\n // restricted names and Strapi configs are also restricted from being prefixes\n const restrictedPrefix = [...RESTRICTED_FILENAMES, ...STRAPI_CONFIG_FILENAMES].find(\n (restrictedName) =>\n restrictedName.startsWith(baseNameLower) && restrictedName !== baseNameLower\n );\n if (restrictedPrefix) {\n logWarning(\n `Config file not loaded, filename cannot start with ${restrictedPrefix}: ${file.name}`\n );\n }\n\n /**\n * Note: If user config files contain non-alpha-numeric characters, we won't be able to auto-load env\n * into them.\n *\n * For the initial feature, we will only load our internal configs, but later when we provide a method\n * to define the shape of custom configs, we will need to warn that those filenames can't be loaded\n * for technical limitations on env variable names\n * */\n // if (!/^[A-Za-z0-9]+$/.test(baseName)) {\n // logWarning(\"Using a non-alphanumeric config file name prevents Strapi from auto-loading it from environment variables.\")\n // }\n\n // filter filenames without case-insensitive uniqueness\n if (seenFilenames.has(baseNameLower)) {\n logWarning(\n `Config file not loaded, case-insensitive name matches other config file: ${file.name}`\n );\n return acc;\n }\n seenFilenames.add(baseNameLower);\n\n // If file passes all filters, add it to the accumulator\n acc.push(file);\n return acc;\n }, [] as fs.Dirent[]);\n\n return configFiles.reduce(\n (acc, file) => {\n const key = path.basename(file.name, path.extname(file.name));\n\n acc[key] = loadConfigFile(path.resolve(dir, file.name));\n\n return acc;\n },\n {} as Record<string, unknown>\n );\n};\n"],"names":[],"mappings":";;;AAIA,MAAM,mBAAmB,CAAC,OAAO,OAAO;AAGxC,MAAM,qBAAqB;AAAA,EACzB,YAAY;AAAA,EACZ,QAAQ;AACV;AAIA,MAAM,uBAAuB;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA,GAAG,OAAO,KAAK,kBAAkB;AACnC;AAGA,MAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,aAAa,CAAC,YAAoB;AACtC,UAAQ,KAAK,OAAO;AACtB;AAEA,MAAe,gBAAA,CAAC,QAAgB;AAC9B,MAAI,CAAC,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhC,QAAM,WAAW,GAAG,YAAY,KAAK,EAAE,eAAe,MAAM;AACtD,QAAA,oCAAoB;AAC1B,QAAM,cAAc,SAAS,OAAO,CAAC,KAAK,SAAS;AAC3C,UAAA,WAAW,KAAK,SAAS,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI,CAAC;AAC3D,UAAA,gBAAgB,SAAS;AAC/B,UAAM,YAAY,KAAK,QAAQ,KAAK,IAAI;AAClC,UAAA,iBAAiB,UAAU;AAE7B,QAAA,CAAC,KAAK,UAAU;AACX,aAAA;AAAA,IACT;AAEA,QAAI,CAAC,iBAAiB,SAAS,cAAc,GAAG;AAC9C;AAAA,QACE,oDAAoD,iBAAiB,KAAK,GAAG,CAAC,MAC5E,KAAK,IACP;AAAA,MAAA;AAEK,aAAA;AAAA,IACT;AAEI,QAAA,qBAAqB,SAAS,aAAa,GAAG;AACrC,iBAAA,gDAAgD,KAAK,IAAI,EAAE;AAGtE,UAAI,iBAAiB,oBAAoB;AAC/B,gBAAA;AAAA,UACN,gBAAgB,mBAAmB,aAAgD,CAAC;AAAA,QAAA;AAAA,MAExF;AAEO,aAAA;AAAA,IACT;AAGA,UAAM,mBAAmB,CAAC,GAAG,sBAAsB,GAAG,uBAAuB,EAAE;AAAA,MAC7E,CAAC,mBACC,eAAe,WAAW,aAAa,KAAK,mBAAmB;AAAA,IAAA;AAEnE,QAAI,kBAAkB;AACpB;AAAA,QACE,sDAAsD,gBAAgB,KAAK,KAAK,IAAI;AAAA,MAAA;AAAA,IAExF;AAeI,QAAA,cAAc,IAAI,aAAa,GAAG;AACpC;AAAA,QACE,4EAA4E,KAAK,IAAI;AAAA,MAAA;AAEhF,aAAA;AAAA,IACT;AACA,kBAAc,IAAI,aAAa;AAG/B,QAAI,KAAK,IAAI;AACN,WAAA;AAAA,EACT,GAAG,CAAiB,CAAA;AAEpB,SAAO,YAAY;AAAA,IACjB,CAAC,KAAK,SAAS;AACP,YAAA,MAAM,KAAK,SAAS,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI,CAAC;AAExD,UAAA,GAAG,IAAI,eAAe,KAAK,QAAQ,KAAK,KAAK,IAAI,CAAC;AAE/C,aAAA;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EAAA;AAEL;"}
|
|
@@ -29,8 +29,7 @@ class SingleTypeService extends coreService.CoreService {
|
|
|
29
29
|
async delete(params = {}) {
|
|
30
30
|
const { uid } = this.contentType;
|
|
31
31
|
const documentId = await this.getDocumentId();
|
|
32
|
-
if (!documentId)
|
|
33
|
-
return { deletedEntries: 0 };
|
|
32
|
+
if (!documentId) return { deletedEntries: 0 };
|
|
34
33
|
const { entries } = await strapi.documents(uid).delete({
|
|
35
34
|
...this.getFetchParams(params),
|
|
36
35
|
documentId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":["CoreService"],"mappings":";;;AAGO,MAAM,0BAA0BA,YAAAA,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC
|
|
1
|
+
{"version":3,"file":"single-type.js","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":["CoreService"],"mappings":";;;AAGO,MAAM,0BAA0BA,YAAAA,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC,WAAmB,QAAA,EAAE,gBAAgB,EAAE;AAEtC,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAEM,MAAA,0BAA0B,CAC9B,gBACoC;AAC7B,SAAA,IAAI,kBAAkB,WAAW;AAC1C;;;"}
|
|
@@ -27,8 +27,7 @@ class SingleTypeService extends CoreService {
|
|
|
27
27
|
async delete(params = {}) {
|
|
28
28
|
const { uid } = this.contentType;
|
|
29
29
|
const documentId = await this.getDocumentId();
|
|
30
|
-
if (!documentId)
|
|
31
|
-
return { deletedEntries: 0 };
|
|
30
|
+
if (!documentId) return { deletedEntries: 0 };
|
|
32
31
|
const { entries } = await strapi.documents(uid).delete({
|
|
33
32
|
...this.getFetchParams(params),
|
|
34
33
|
documentId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":[],"mappings":";AAGO,MAAM,0BAA0B,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC
|
|
1
|
+
{"version":3,"file":"single-type.mjs","sources":["../../../src/core-api/service/single-type.ts"],"sourcesContent":["import type { Struct, Core } from '@strapi/types';\nimport { CoreService } from './core-service';\n\nexport class SingleTypeService extends CoreService implements Core.CoreAPI.Service.SingleType {\n private contentType: Struct.SingleTypeSchema;\n\n constructor(contentType: Struct.SingleTypeSchema) {\n super();\n\n this.contentType = contentType;\n }\n\n async getDocumentId() {\n const { uid } = this.contentType;\n\n return strapi.db\n .query(uid)\n .findOne()\n .then((document) => document?.documentId as string);\n }\n\n async find(params = {}) {\n const { uid } = this.contentType;\n\n return strapi.documents(uid).findFirst(this.getFetchParams(params));\n }\n\n async createOrUpdate(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n\n if (documentId) {\n return strapi.documents(uid).update({\n ...this.getFetchParams(params),\n documentId,\n });\n }\n\n return strapi.documents(uid).create(this.getFetchParams(params));\n }\n\n async delete(params = {}) {\n const { uid } = this.contentType;\n\n const documentId = await this.getDocumentId();\n if (!documentId) return { deletedEntries: 0 };\n\n const { entries } = await strapi.documents(uid).delete({\n ...this.getFetchParams(params),\n documentId,\n });\n\n return { deletedEntries: entries.length };\n }\n}\n\nconst createSingleTypeService = (\n contentType: Struct.SingleTypeSchema\n): Core.CoreAPI.Service.SingleType => {\n return new SingleTypeService(contentType);\n};\n\nexport { createSingleTypeService };\n"],"names":[],"mappings":";AAGO,MAAM,0BAA0B,YAAuD;AAAA,EACpF;AAAA,EAER,YAAY,aAAsC;AAC1C;AAEN,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,gBAAgB;AACd,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,GACX,MAAM,GAAG,EACT,UACA,KAAK,CAAC,aAAa,UAAU,UAAoB;AAAA,EACtD;AAAA,EAEA,MAAM,KAAK,SAAS,IAAI;AAChB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEd,WAAA,OAAO,UAAU,GAAG,EAAE,UAAU,KAAK,eAAe,MAAM,CAAC;AAAA,EACpE;AAAA,EAEA,MAAM,eAAe,SAAS,IAAI;AAC1B,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAE9B,QAAI,YAAY;AACd,aAAO,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,QAClC,GAAG,KAAK,eAAe,MAAM;AAAA,QAC7B;AAAA,MAAA,CACD;AAAA,IACH;AAEO,WAAA,OAAO,UAAU,GAAG,EAAE,OAAO,KAAK,eAAe,MAAM,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,OAAO,SAAS,IAAI;AAClB,UAAA,EAAE,IAAI,IAAI,KAAK;AAEf,UAAA,aAAa,MAAM,KAAK;AAC9B,QAAI,CAAC,WAAmB,QAAA,EAAE,gBAAgB,EAAE;AAEtC,UAAA,EAAE,YAAY,MAAM,OAAO,UAAU,GAAG,EAAE,OAAO;AAAA,MACrD,GAAG,KAAK,eAAe,MAAM;AAAA,MAC7B;AAAA,IAAA,CACD;AAEM,WAAA,EAAE,gBAAgB,QAAQ;EACnC;AACF;AAEM,MAAA,0BAA0B,CAC9B,gBACoC;AAC7B,SAAA,IAAI,kBAAkB,WAAW;AAC1C;"}
|
package/dist/ee/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ee/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ee/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;iCAsPb,MAAM;;;AAfnC,wBAiBG"}
|
package/dist/ee/index.js
CHANGED
|
@@ -120,7 +120,12 @@ const checkLicense = async ({ strapi: strapi2 }) => {
|
|
|
120
120
|
process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === "true";
|
|
121
121
|
if (!shouldStayOffline) {
|
|
122
122
|
await onlineUpdate({ strapi: strapi2 });
|
|
123
|
-
strapi2.cron.add({
|
|
123
|
+
strapi2.cron.add({
|
|
124
|
+
onlineUpdate: {
|
|
125
|
+
task: () => onlineUpdate({ strapi: strapi2 }),
|
|
126
|
+
options: cron.shiftCronExpression("0 0 */12 * * *")
|
|
127
|
+
}
|
|
128
|
+
});
|
|
124
129
|
} else {
|
|
125
130
|
if (!ee.licenseInfo.expireAt) {
|
|
126
131
|
return disable("Your license does not have offline support.");
|
package/dist/ee/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/ee/index.ts"],"sourcesContent":["import { pick, isEqual } from 'lodash/fp';\nimport type { Logger } from '@strapi/logger';\nimport type { Core } from '@strapi/types';\n\nimport { readLicense, verifyLicense, fetchLicense, LicenseCheckError } from './license';\nimport { shiftCronExpression } from '../utils/cron';\n\nconst ONE_MINUTE = 1000 * 60;\n\ninterface EE {\n enabled: boolean;\n licenseInfo: {\n licenseKey?: string;\n features?: Array<{ name: string; [key: string]: any } | string>;\n expireAt?: string;\n seats?: number;\n type?: string;\n };\n logger?: Logger;\n}\n\nconst ee: EE = {\n enabled: false,\n licenseInfo: {},\n};\n\nconst disable = (message: string) => {\n // Prevent emitting ee.disable if it was already disabled\n const shouldEmitEvent = ee.enabled !== false;\n\n ee.logger?.warn(`${message} Switching to CE.`);\n // Only keep the license key for potential re-enabling during a later check\n ee.licenseInfo = pick('licenseKey', ee.licenseInfo);\n\n ee.enabled = false;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.disable');\n }\n};\n\nconst enable = () => {\n // Prevent emitting ee.enable if it was already enabled\n const shouldEmitEvent = ee.enabled !== true;\n\n ee.enabled = true;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.enable');\n }\n};\n\nlet initialized = false;\n\n/**\n * Optimistically enable EE if the format of the license is valid, only run once.\n */\nconst init = (licenseDir: string, logger?: Logger) => {\n if (initialized) {\n return;\n }\n\n initialized = true;\n ee.logger = logger;\n\n if (process.env.STRAPI_DISABLE_EE?.toLowerCase() === 'true') {\n return;\n }\n\n try {\n const license = process.env.STRAPI_LICENSE || readLicense(licenseDir);\n\n if (license) {\n ee.licenseInfo = verifyLicense(license);\n enable();\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n};\n\n/**\n * Contact the license registry to update the license to its latest state.\n *\n * Store the result in database to avoid unecessary requests, and will fallback to that in case of a network failure.\n */\nconst onlineUpdate = async ({ strapi }: { strapi: Core.Strapi }) => {\n const { get, commit, rollback } = (await strapi.db?.transaction()) as any;\n const transaction = get();\n\n try {\n const storedInfo = await strapi.db\n ?.queryBuilder('strapi::core-store')\n .where({ key: 'ee_information' })\n .select('value')\n .first()\n .transacting(transaction)\n .forUpdate()\n .execute()\n .then((result: any) => (result ? JSON.parse(result.value) : result));\n\n const shouldContactRegistry = (storedInfo?.lastCheckAt ?? 0) < Date.now() - ONE_MINUTE;\n const result: {\n license?: string | null;\n error?: string;\n lastCheckAt?: number;\n } = { lastCheckAt: Date.now() };\n\n const fallback = (error: Error) => {\n if (error instanceof LicenseCheckError && error.shouldFallback && storedInfo?.license) {\n ee.logger?.warn(\n `${error.message} The last stored one will be used as a potential fallback.`\n );\n return storedInfo.license;\n }\n\n result.error = error.message;\n disable(error.message);\n };\n\n if (!ee?.licenseInfo?.licenseKey) {\n throw new Error('Missing license key.');\n }\n\n const license = shouldContactRegistry\n ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(\n fallback\n )\n : storedInfo.license;\n\n if (license) {\n try {\n // Verify license and check if its info changed\n const newLicenseInfo = verifyLicense(license);\n const licenseInfoChanged =\n !isEqual(newLicenseInfo.features, ee.licenseInfo.features) ||\n newLicenseInfo.seats !== ee.licenseInfo.seats ||\n newLicenseInfo.type !== ee.licenseInfo.type;\n\n // Store the new license info\n ee.licenseInfo = newLicenseInfo;\n const wasEnabled = ee.enabled;\n validateInfo();\n\n // Notify EE features\n if (licenseInfoChanged && wasEnabled) {\n strapi.eventHub.emit('ee.update');\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n } else if (!shouldContactRegistry) {\n disable(storedInfo.error);\n }\n\n if (shouldContactRegistry) {\n result.license = license ?? null;\n const query = strapi.db.queryBuilder('strapi::core-store').transacting(transaction);\n\n if (!storedInfo) {\n query.insert({ key: 'ee_information', value: JSON.stringify(result) });\n } else {\n query.update({ value: JSON.stringify(result) }).where({ key: 'ee_information' });\n }\n\n await query.execute();\n }\n\n await commit();\n } catch (error) {\n // Example of errors: SQLite does not support FOR UPDATE\n await rollback();\n }\n};\n\nconst validateInfo = () => {\n if (typeof ee.licenseInfo.expireAt === 'undefined') {\n throw new Error('Missing license key.');\n }\n\n const expirationTime = new Date(ee.licenseInfo.expireAt).getTime();\n\n if (expirationTime < new Date().getTime()) {\n return disable('License expired.');\n }\n\n enable();\n};\n\nconst checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => {\n const shouldStayOffline =\n ee.licenseInfo.type === 'gold' &&\n // This env variable support is temporarily used to ease the migration between online vs offline\n process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === 'true';\n\n if (!shouldStayOffline) {\n await onlineUpdate({ strapi });\n strapi.cron.add({ [shiftCronExpression('0 0 */12 * * *')]: onlineUpdate });\n } else {\n if (!ee.licenseInfo.expireAt) {\n return disable('Your license does not have offline support.');\n }\n\n validateInfo();\n }\n};\n\nconst list = () => {\n return (\n ee.licenseInfo.features?.map((feature) =>\n typeof feature === 'object' ? feature : { name: feature }\n ) || []\n );\n};\n\nconst get = (featureName: string) => list().find((feature) => feature.name === featureName);\n\nexport default Object.freeze({\n init,\n checkLicense,\n\n get isEE() {\n return ee.enabled;\n },\n\n get seats() {\n return ee.licenseInfo.seats;\n },\n\n features: Object.freeze({\n list,\n get,\n isEnabled: (featureName: string) => get(featureName) !== undefined,\n }),\n});\n"],"names":["pick","license","readLicense","verifyLicense","strapi","get","result","LicenseCheckError","fetchLicense","isEqual","shiftCronExpression"],"mappings":";;;;AAOA,MAAM,aAAa,MAAO;AAc1B,M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QAAQ,SAAS,WAAW;AAE1F,MAAe,QAAA,OAAO,OAAO;AAAA,EAC3B;AAAA,EACA;AAAA,EAEA,IAAI,OAAO;AACT,WAAO,GAAG;AAAA,EACZ;AAAA,EAEA,IAAI,QAAQ;AACV,WAAO,GAAG,YAAY;AAAA,EACxB;AAAA,EAEA,UAAU,OAAO,OAAO;AAAA,IACtB;AAAA,IACA;AAAA,IACA,WAAW,CAAC,gBAAwB,IAAI,WAAW,MAAM;AAAA,EAAA,CAC1D;AACH,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/ee/index.ts"],"sourcesContent":["import { pick, isEqual } from 'lodash/fp';\nimport type { Logger } from '@strapi/logger';\nimport type { Core } from '@strapi/types';\n\nimport { readLicense, verifyLicense, fetchLicense, LicenseCheckError } from './license';\nimport { shiftCronExpression } from '../utils/cron';\n\nconst ONE_MINUTE = 1000 * 60;\n\ninterface EE {\n enabled: boolean;\n licenseInfo: {\n licenseKey?: string;\n features?: Array<{ name: string; [key: string]: any } | string>;\n expireAt?: string;\n seats?: number;\n type?: string;\n };\n logger?: Logger;\n}\n\nconst ee: EE = {\n enabled: false,\n licenseInfo: {},\n};\n\nconst disable = (message: string) => {\n // Prevent emitting ee.disable if it was already disabled\n const shouldEmitEvent = ee.enabled !== false;\n\n ee.logger?.warn(`${message} Switching to CE.`);\n // Only keep the license key for potential re-enabling during a later check\n ee.licenseInfo = pick('licenseKey', ee.licenseInfo);\n\n ee.enabled = false;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.disable');\n }\n};\n\nconst enable = () => {\n // Prevent emitting ee.enable if it was already enabled\n const shouldEmitEvent = ee.enabled !== true;\n\n ee.enabled = true;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.enable');\n }\n};\n\nlet initialized = false;\n\n/**\n * Optimistically enable EE if the format of the license is valid, only run once.\n */\nconst init = (licenseDir: string, logger?: Logger) => {\n if (initialized) {\n return;\n }\n\n initialized = true;\n ee.logger = logger;\n\n if (process.env.STRAPI_DISABLE_EE?.toLowerCase() === 'true') {\n return;\n }\n\n try {\n const license = process.env.STRAPI_LICENSE || readLicense(licenseDir);\n\n if (license) {\n ee.licenseInfo = verifyLicense(license);\n enable();\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n};\n\n/**\n * Contact the license registry to update the license to its latest state.\n *\n * Store the result in database to avoid unecessary requests, and will fallback to that in case of a network failure.\n */\nconst onlineUpdate = async ({ strapi }: { strapi: Core.Strapi }) => {\n const { get, commit, rollback } = (await strapi.db?.transaction()) as any;\n const transaction = get();\n\n try {\n const storedInfo = await strapi.db\n ?.queryBuilder('strapi::core-store')\n .where({ key: 'ee_information' })\n .select('value')\n .first()\n .transacting(transaction)\n .forUpdate()\n .execute()\n .then((result: any) => (result ? JSON.parse(result.value) : result));\n\n const shouldContactRegistry = (storedInfo?.lastCheckAt ?? 0) < Date.now() - ONE_MINUTE;\n const result: {\n license?: string | null;\n error?: string;\n lastCheckAt?: number;\n } = { lastCheckAt: Date.now() };\n\n const fallback = (error: Error) => {\n if (error instanceof LicenseCheckError && error.shouldFallback && storedInfo?.license) {\n ee.logger?.warn(\n `${error.message} The last stored one will be used as a potential fallback.`\n );\n return storedInfo.license;\n }\n\n result.error = error.message;\n disable(error.message);\n };\n\n if (!ee?.licenseInfo?.licenseKey) {\n throw new Error('Missing license key.');\n }\n\n const license = shouldContactRegistry\n ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(\n fallback\n )\n : storedInfo.license;\n\n if (license) {\n try {\n // Verify license and check if its info changed\n const newLicenseInfo = verifyLicense(license);\n const licenseInfoChanged =\n !isEqual(newLicenseInfo.features, ee.licenseInfo.features) ||\n newLicenseInfo.seats !== ee.licenseInfo.seats ||\n newLicenseInfo.type !== ee.licenseInfo.type;\n\n // Store the new license info\n ee.licenseInfo = newLicenseInfo;\n const wasEnabled = ee.enabled;\n validateInfo();\n\n // Notify EE features\n if (licenseInfoChanged && wasEnabled) {\n strapi.eventHub.emit('ee.update');\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n } else if (!shouldContactRegistry) {\n disable(storedInfo.error);\n }\n\n if (shouldContactRegistry) {\n result.license = license ?? null;\n const query = strapi.db.queryBuilder('strapi::core-store').transacting(transaction);\n\n if (!storedInfo) {\n query.insert({ key: 'ee_information', value: JSON.stringify(result) });\n } else {\n query.update({ value: JSON.stringify(result) }).where({ key: 'ee_information' });\n }\n\n await query.execute();\n }\n\n await commit();\n } catch (error) {\n // Example of errors: SQLite does not support FOR UPDATE\n await rollback();\n }\n};\n\nconst validateInfo = () => {\n if (typeof ee.licenseInfo.expireAt === 'undefined') {\n throw new Error('Missing license key.');\n }\n\n const expirationTime = new Date(ee.licenseInfo.expireAt).getTime();\n\n if (expirationTime < new Date().getTime()) {\n return disable('License expired.');\n }\n\n enable();\n};\n\nconst checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => {\n const shouldStayOffline =\n ee.licenseInfo.type === 'gold' &&\n // This env variable support is temporarily used to ease the migration between online vs offline\n process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === 'true';\n\n if (!shouldStayOffline) {\n await onlineUpdate({ strapi });\n\n strapi.cron.add({\n onlineUpdate: {\n task: () => onlineUpdate({ strapi }),\n options: shiftCronExpression('0 0 */12 * * *'),\n },\n });\n } else {\n if (!ee.licenseInfo.expireAt) {\n return disable('Your license does not have offline support.');\n }\n\n validateInfo();\n }\n};\n\nconst list = () => {\n return (\n ee.licenseInfo.features?.map((feature) =>\n typeof feature === 'object' ? feature : { name: feature }\n ) || []\n );\n};\n\nconst get = (featureName: string) => list().find((feature) => feature.name === featureName);\n\nexport default Object.freeze({\n init,\n checkLicense,\n\n get isEE() {\n return ee.enabled;\n },\n\n get seats() {\n return ee.licenseInfo.seats;\n },\n\n features: Object.freeze({\n list,\n get,\n isEnabled: (featureName: string) => get(featureName) !== undefined,\n }),\n});\n"],"names":["pick","license","readLicense","verifyLicense","strapi","get","result","LicenseCheckError","fetchLicense","isEqual","shiftCronExpression"],"mappings":";;;;AAOA,MAAM,aAAa,MAAO;AAc1B,MAAM,KAAS;AAAA,EACb,SAAS;AAAA,EACT,aAAa,CAAC;AAChB;AAEA,MAAM,UAAU,CAAC,YAAoB;AAE7B,QAAA,kBAAkB,GAAG,YAAY;AAEvC,KAAG,QAAQ,KAAK,GAAG,OAAO,mBAAmB;AAE7C,KAAG,cAAcA,GAAA,KAAK,cAAc,GAAG,WAAW;AAElD,KAAG,UAAU;AAEb,MAAI,iBAAiB;AAEZ,WAAA,SAAS,KAAK,YAAY;AAAA,EACnC;AACF;AAEA,MAAM,SAAS,MAAM;AAEb,QAAA,kBAAkB,GAAG,YAAY;AAEvC,KAAG,UAAU;AAEb,MAAI,iBAAiB;AAEZ,WAAA,SAAS,KAAK,WAAW;AAAA,EAClC;AACF;AAEA,IAAI,cAAc;AAKlB,MAAM,OAAO,CAAC,YAAoB,WAAoB;AACpD,MAAI,aAAa;AACf;AAAA,EACF;AAEc,gBAAA;AACd,KAAG,SAAS;AAEZ,MAAI,QAAQ,IAAI,mBAAmB,YAAA,MAAkB,QAAQ;AAC3D;AAAA,EACF;AAEI,MAAA;AACF,UAAMC,YAAU,QAAQ,IAAI,kBAAkBC,QAAAA,YAAY,UAAU;AAEpE,QAAID,WAAS;AACR,SAAA,cAAcE,sBAAcF,SAAO;AAC/B;IACT;AAAA,WACO,OAAO;AACd,QAAI,iBAAiB,OAAO;AAC1B,cAAQ,MAAM,OAAO;AAAA,IAAA,OAChB;AACL,cAAQ,kBAAkB;AAAA,IAC5B;AAAA,EACF;AACF;AAOA,MAAM,eAAe,OAAO,EAAE,QAAAG,cAAsC;AAC5D,QAAA,EAAE,KAAAC,MAAK,QAAQ,SAAc,IAAA,MAAMD,QAAO,IAAI;AACpD,QAAM,cAAcC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UAAU;AAC5B,aAAO,QAAQ,6CAA6C;AAAA,IAC9D;AAEa;EACf;AACF;AAEA,MAAM,OAAO,MAAM;AAEf,SAAA,GAAG,YAAY,UAAU;AAAA,IAAI,CAAC,YAC5B,OAAO,YAAY,WAAW,UAAU,EAAE,MAAM,QAAQ;AAAA,OACrD;AAET;AAEA,MAAM,MAAM,CAAC,gBAAwB,OAAO,KAAK,CAAC,YAAY,QAAQ,SAAS,WAAW;AAE1F,MAAe,QAAA,OAAO,OAAO;AAAA,EAC3B;AAAA,EACA;AAAA,EAEA,IAAI,OAAO;AACT,WAAO,GAAG;AAAA,EACZ;AAAA,EAEA,IAAI,QAAQ;AACV,WAAO,GAAG,YAAY;AAAA,EACxB;AAAA,EAEA,UAAU,OAAO,OAAO;AAAA,IACtB;AAAA,IACA;AAAA,IACA,WAAW,CAAC,gBAAwB,IAAI,WAAW,MAAM;AAAA,EAAA,CAC1D;AACH,CAAC;;"}
|
package/dist/ee/index.mjs
CHANGED
|
@@ -119,7 +119,12 @@ const checkLicense = async ({ strapi: strapi2 }) => {
|
|
|
119
119
|
process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === "true";
|
|
120
120
|
if (!shouldStayOffline) {
|
|
121
121
|
await onlineUpdate({ strapi: strapi2 });
|
|
122
|
-
strapi2.cron.add({
|
|
122
|
+
strapi2.cron.add({
|
|
123
|
+
onlineUpdate: {
|
|
124
|
+
task: () => onlineUpdate({ strapi: strapi2 }),
|
|
125
|
+
options: shiftCronExpression("0 0 */12 * * *")
|
|
126
|
+
}
|
|
127
|
+
});
|
|
123
128
|
} else {
|
|
124
129
|
if (!ee.licenseInfo.expireAt) {
|
|
125
130
|
return disable("Your license does not have offline support.");
|
package/dist/ee/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ee/index.ts"],"sourcesContent":["import { pick, isEqual } from 'lodash/fp';\nimport type { Logger } from '@strapi/logger';\nimport type { Core } from '@strapi/types';\n\nimport { readLicense, verifyLicense, fetchLicense, LicenseCheckError } from './license';\nimport { shiftCronExpression } from '../utils/cron';\n\nconst ONE_MINUTE = 1000 * 60;\n\ninterface EE {\n enabled: boolean;\n licenseInfo: {\n licenseKey?: string;\n features?: Array<{ name: string; [key: string]: any } | string>;\n expireAt?: string;\n seats?: number;\n type?: string;\n };\n logger?: Logger;\n}\n\nconst ee: EE = {\n enabled: false,\n licenseInfo: {},\n};\n\nconst disable = (message: string) => {\n // Prevent emitting ee.disable if it was already disabled\n const shouldEmitEvent = ee.enabled !== false;\n\n ee.logger?.warn(`${message} Switching to CE.`);\n // Only keep the license key for potential re-enabling during a later check\n ee.licenseInfo = pick('licenseKey', ee.licenseInfo);\n\n ee.enabled = false;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.disable');\n }\n};\n\nconst enable = () => {\n // Prevent emitting ee.enable if it was already enabled\n const shouldEmitEvent = ee.enabled !== true;\n\n ee.enabled = true;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.enable');\n }\n};\n\nlet initialized = false;\n\n/**\n * Optimistically enable EE if the format of the license is valid, only run once.\n */\nconst init = (licenseDir: string, logger?: Logger) => {\n if (initialized) {\n return;\n }\n\n initialized = true;\n ee.logger = logger;\n\n if (process.env.STRAPI_DISABLE_EE?.toLowerCase() === 'true') {\n return;\n }\n\n try {\n const license = process.env.STRAPI_LICENSE || readLicense(licenseDir);\n\n if (license) {\n ee.licenseInfo = verifyLicense(license);\n enable();\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n};\n\n/**\n * Contact the license registry to update the license to its latest state.\n *\n * Store the result in database to avoid unecessary requests, and will fallback to that in case of a network failure.\n */\nconst onlineUpdate = async ({ strapi }: { strapi: Core.Strapi }) => {\n const { get, commit, rollback } = (await strapi.db?.transaction()) as any;\n const transaction = get();\n\n try {\n const storedInfo = await strapi.db\n ?.queryBuilder('strapi::core-store')\n .where({ key: 'ee_information' })\n .select('value')\n .first()\n .transacting(transaction)\n .forUpdate()\n .execute()\n .then((result: any) => (result ? JSON.parse(result.value) : result));\n\n const shouldContactRegistry = (storedInfo?.lastCheckAt ?? 0) < Date.now() - ONE_MINUTE;\n const result: {\n license?: string | null;\n error?: string;\n lastCheckAt?: number;\n } = { lastCheckAt: Date.now() };\n\n const fallback = (error: Error) => {\n if (error instanceof LicenseCheckError && error.shouldFallback && storedInfo?.license) {\n ee.logger?.warn(\n `${error.message} The last stored one will be used as a potential fallback.`\n );\n return storedInfo.license;\n }\n\n result.error = error.message;\n disable(error.message);\n };\n\n if (!ee?.licenseInfo?.licenseKey) {\n throw new Error('Missing license key.');\n }\n\n const license = shouldContactRegistry\n ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(\n fallback\n )\n : storedInfo.license;\n\n if (license) {\n try {\n // Verify license and check if its info changed\n const newLicenseInfo = verifyLicense(license);\n const licenseInfoChanged =\n !isEqual(newLicenseInfo.features, ee.licenseInfo.features) ||\n newLicenseInfo.seats !== ee.licenseInfo.seats ||\n newLicenseInfo.type !== ee.licenseInfo.type;\n\n // Store the new license info\n ee.licenseInfo = newLicenseInfo;\n const wasEnabled = ee.enabled;\n validateInfo();\n\n // Notify EE features\n if (licenseInfoChanged && wasEnabled) {\n strapi.eventHub.emit('ee.update');\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n } else if (!shouldContactRegistry) {\n disable(storedInfo.error);\n }\n\n if (shouldContactRegistry) {\n result.license = license ?? null;\n const query = strapi.db.queryBuilder('strapi::core-store').transacting(transaction);\n\n if (!storedInfo) {\n query.insert({ key: 'ee_information', value: JSON.stringify(result) });\n } else {\n query.update({ value: JSON.stringify(result) }).where({ key: 'ee_information' });\n }\n\n await query.execute();\n }\n\n await commit();\n } catch (error) {\n // Example of errors: SQLite does not support FOR UPDATE\n await rollback();\n }\n};\n\nconst validateInfo = () => {\n if (typeof ee.licenseInfo.expireAt === 'undefined') {\n throw new Error('Missing license key.');\n }\n\n const expirationTime = new Date(ee.licenseInfo.expireAt).getTime();\n\n if (expirationTime < new Date().getTime()) {\n return disable('License expired.');\n }\n\n enable();\n};\n\nconst checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => {\n const shouldStayOffline =\n ee.licenseInfo.type === 'gold' &&\n // This env variable support is temporarily used to ease the migration between online vs offline\n process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === 'true';\n\n if (!shouldStayOffline) {\n await onlineUpdate({ strapi });\n strapi.cron.add({ [shiftCronExpression('0 0 */12 * * *')]: onlineUpdate });\n } else {\n if (!ee.licenseInfo.expireAt) {\n return disable('Your license does not have offline support.');\n }\n\n validateInfo();\n }\n};\n\nconst list = () => {\n return (\n ee.licenseInfo.features?.map((feature) =>\n typeof feature === 'object' ? feature : { name: feature }\n ) || []\n );\n};\n\nconst get = (featureName: string) => list().find((feature) => feature.name === featureName);\n\nexport default Object.freeze({\n init,\n checkLicense,\n\n get isEE() {\n return ee.enabled;\n },\n\n get seats() {\n return ee.licenseInfo.seats;\n },\n\n features: Object.freeze({\n list,\n get,\n isEnabled: (featureName: string) => get(featureName) !== undefined,\n }),\n});\n"],"names":["strapi","get","result"],"mappings":";;;AAOA,MAAM,aAAa,MAAO;AAc1B,MAAM,KAAS;AAAA,EACb,SAAS;AAAA,EACT,aAAa,CAAC;AAChB;AAEA,MAAM,UAAU,CAAC,YAAoB;AAE7B,QAAA,kBAAkB,GAAG,YAAY;AAEvC,KAAG,QAAQ,KAAK,GAAG,OAAO,mBAAmB;AAE7C,KAAG,cAAc,KAAK,cAAc,GAAG,WAAW;AAElD,KAAG,UAAU;AAEb,MAAI,iBAAiB;AAEZ,WAAA,SAAS,KAAK,YAAY;AAAA,EACnC;AACF;AAEA,MAAM,SAAS,MAAM;AAEb,QAAA,kBAAkB,GAAG,YAAY;AAEvC,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type { Logger } from '@strapi/logger';\nimport type { Core } from '@strapi/types';\n\nimport { readLicense, verifyLicense, fetchLicense, LicenseCheckError } from './license';\nimport { shiftCronExpression } from '../utils/cron';\n\nconst ONE_MINUTE = 1000 * 60;\n\ninterface EE {\n enabled: boolean;\n licenseInfo: {\n licenseKey?: string;\n features?: Array<{ name: string; [key: string]: any } | string>;\n expireAt?: string;\n seats?: number;\n type?: string;\n };\n logger?: Logger;\n}\n\nconst ee: EE = {\n enabled: false,\n licenseInfo: {},\n};\n\nconst disable = (message: string) => {\n // Prevent emitting ee.disable if it was already disabled\n const shouldEmitEvent = ee.enabled !== false;\n\n ee.logger?.warn(`${message} Switching to CE.`);\n // Only keep the license key for potential re-enabling during a later check\n ee.licenseInfo = pick('licenseKey', ee.licenseInfo);\n\n ee.enabled = false;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.disable');\n }\n};\n\nconst enable = () => {\n // Prevent emitting ee.enable if it was already enabled\n const shouldEmitEvent = ee.enabled !== true;\n\n ee.enabled = true;\n\n if (shouldEmitEvent) {\n // Notify EE features that they should be disabled\n strapi.eventHub.emit('ee.enable');\n }\n};\n\nlet initialized = false;\n\n/**\n * Optimistically enable EE if the format of the license is valid, only run once.\n */\nconst init = (licenseDir: string, logger?: Logger) => {\n if (initialized) {\n return;\n }\n\n initialized = true;\n ee.logger = logger;\n\n if (process.env.STRAPI_DISABLE_EE?.toLowerCase() === 'true') {\n return;\n }\n\n try {\n const license = process.env.STRAPI_LICENSE || readLicense(licenseDir);\n\n if (license) {\n ee.licenseInfo = verifyLicense(license);\n enable();\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n};\n\n/**\n * Contact the license registry to update the license to its latest state.\n *\n * Store the result in database to avoid unecessary requests, and will fallback to that in case of a network failure.\n */\nconst onlineUpdate = async ({ strapi }: { strapi: Core.Strapi }) => {\n const { get, commit, rollback } = (await strapi.db?.transaction()) as any;\n const transaction = get();\n\n try {\n const storedInfo = await strapi.db\n ?.queryBuilder('strapi::core-store')\n .where({ key: 'ee_information' })\n .select('value')\n .first()\n .transacting(transaction)\n .forUpdate()\n .execute()\n .then((result: any) => (result ? JSON.parse(result.value) : result));\n\n const shouldContactRegistry = (storedInfo?.lastCheckAt ?? 0) < Date.now() - ONE_MINUTE;\n const result: {\n license?: string | null;\n error?: string;\n lastCheckAt?: number;\n } = { lastCheckAt: Date.now() };\n\n const fallback = (error: Error) => {\n if (error instanceof LicenseCheckError && error.shouldFallback && storedInfo?.license) {\n ee.logger?.warn(\n `${error.message} The last stored one will be used as a potential fallback.`\n );\n return storedInfo.license;\n }\n\n result.error = error.message;\n disable(error.message);\n };\n\n if (!ee?.licenseInfo?.licenseKey) {\n throw new Error('Missing license key.');\n }\n\n const license = shouldContactRegistry\n ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(\n fallback\n )\n : storedInfo.license;\n\n if (license) {\n try {\n // Verify license and check if its info changed\n const newLicenseInfo = verifyLicense(license);\n const licenseInfoChanged =\n !isEqual(newLicenseInfo.features, ee.licenseInfo.features) ||\n newLicenseInfo.seats !== ee.licenseInfo.seats ||\n newLicenseInfo.type !== ee.licenseInfo.type;\n\n // Store the new license info\n ee.licenseInfo = newLicenseInfo;\n const wasEnabled = ee.enabled;\n validateInfo();\n\n // Notify EE features\n if (licenseInfoChanged && wasEnabled) {\n strapi.eventHub.emit('ee.update');\n }\n } catch (error) {\n if (error instanceof Error) {\n disable(error.message);\n } else {\n disable('Invalid license.');\n }\n }\n } else if (!shouldContactRegistry) {\n disable(storedInfo.error);\n }\n\n if (shouldContactRegistry) {\n result.license = license ?? null;\n const query = strapi.db.queryBuilder('strapi::core-store').transacting(transaction);\n\n if (!storedInfo) {\n query.insert({ key: 'ee_information', value: JSON.stringify(result) });\n } else {\n query.update({ value: JSON.stringify(result) }).where({ key: 'ee_information' });\n }\n\n await query.execute();\n }\n\n await commit();\n } catch (error) {\n // Example of errors: SQLite does not support FOR UPDATE\n await rollback();\n }\n};\n\nconst validateInfo = () => {\n if (typeof ee.licenseInfo.expireAt === 'undefined') {\n throw new Error('Missing license key.');\n }\n\n const expirationTime = new Date(ee.licenseInfo.expireAt).getTime();\n\n if (expirationTime < new Date().getTime()) {\n return disable('License expired.');\n }\n\n enable();\n};\n\nconst checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => {\n const shouldStayOffline =\n ee.licenseInfo.type === 'gold' &&\n // This env variable support is temporarily used to ease the migration between online vs offline\n process.env.STRAPI_DISABLE_LICENSE_PING?.toLowerCase() === 'true';\n\n if (!shouldStayOffline) {\n await onlineUpdate({ strapi });\n\n strapi.cron.add({\n onlineUpdate: {\n task: () => onlineUpdate({ strapi }),\n options: shiftCronExpression('0 0 */12 * * *'),\n },\n });\n } else {\n if (!ee.licenseInfo.expireAt) {\n return disable('Your license does not have offline support.');\n }\n\n validateInfo();\n }\n};\n\nconst list = () => {\n return (\n ee.licenseInfo.features?.map((feature) =>\n typeof feature === 'object' ? feature : { name: feature }\n ) || []\n );\n};\n\nconst get = (featureName: string) => list().find((feature) => feature.name === featureName);\n\nexport default Object.freeze({\n init,\n checkLicense,\n\n get isEE() {\n return ee.enabled;\n },\n\n get seats() {\n return ee.licenseInfo.seats;\n },\n\n features: Object.freeze({\n list,\n get,\n isEnabled: (featureName: string) => get(featureName) !== undefined,\n }),\n});\n"],"names":["strapi","get","result"],"mappings":";;;AAOA,MAAM,aAAa,MAAO;AAc1B,MAAM,KAAS;AAAA,EACb,SAAS;AAAA,EACT,aAAa,CAAC;AAChB;AAEA,MAAM,UAAU,CAAC,YAAoB;AAE7B,QAAA,kBAAkB,GAAG,YAAY;AAEvC,KAAG,QAAQ,KAAK,GAAG,OAAO,mBAAmB;AAE7C,KAAG,cAAc,KAAK,cAAc,GAAG,WAAW;AAElD,KAAG,UAAU;AAEb,MAAI,iBAAiB;AAEZ,WAAA,SAAS,KAAK,YAAY;AAAA,EAC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BAAwB,IAAI,WAAW,MAAM;AAAA,EAAA,CAC1D;AACH,CAAC;"}
|
|
@@ -11,8 +11,7 @@ const getUserPluginsConfig = require("./get-user-plugins-config.js");
|
|
|
11
11
|
const index = require("../../domain/content-type/index.js");
|
|
12
12
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
13
13
|
function _interopNamespace(e) {
|
|
14
|
-
if (e && e.__esModule)
|
|
15
|
-
return e;
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
16
15
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
17
16
|
if (e) {
|
|
18
17
|
for (const k in e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["fse","loadFiles","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","resolve","join","loadConfigFile","defaults","getGlobalId"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/loaders/plugins/index.ts"],"sourcesContent":["import { join } from 'path';\nimport fse from 'fs-extra';\nimport { defaultsDeep, defaults, getOr, get } from 'lodash/fp';\nimport * as resolve from 'resolve.exports';\n\nimport { env } from '@strapi/utils';\nimport type { Core, Plugin, Struct } from '@strapi/types';\nimport { loadConfigFile } from '../../utils/load-config-file';\nimport { loadFiles } from '../../utils/load-files';\nimport { getEnabledPlugins } from './get-enabled-plugins';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\nimport { getGlobalId } from '../../domain/content-type';\n\ninterface Plugins {\n [key: string]: Plugin.LoadedPlugin;\n}\n\nconst defaultPlugin = {\n bootstrap() {},\n destroy() {},\n register() {},\n config: {\n default: {},\n validator() {},\n },\n routes: [],\n controllers: {},\n services: {},\n policies: {},\n middlewares: {},\n contentTypes: {},\n};\n\nconst applyUserExtension = async (plugins: Plugins) => {\n const extensionsDir = strapi.dirs.dist.extensions;\n if (!(await fse.pathExists(extensionsDir))) {\n return;\n }\n\n const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');\n const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n // first: load json schema\n for (const ctName of Object.keys(plugin.contentTypes)) {\n const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);\n if (extendedSchema) {\n plugin.contentTypes[ctName].schema = {\n ...plugin.contentTypes[ctName].schema,\n ...extendedSchema,\n };\n }\n }\n // second: execute strapi-server extension\n const strapiServer = get([pluginName, 'strapi-server'], strapiServers);\n if (strapiServer) {\n plugins[pluginName] = await strapiServer(plugin);\n }\n }\n};\n\nconst applyUserConfig = async (plugins: Plugins) => {\n const userPluginsConfig = await getUserPluginsConfig();\n\n for (const pluginName of Object.keys(plugins)) {\n const plugin = plugins[pluginName];\n const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);\n const defaultConfig =\n typeof plugin.config.default === 'function'\n ? plugin.config.default({ env })\n : plugin.config.default;\n\n const config = defaultsDeep(defaultConfig, userPluginConfig);\n try {\n plugin.config.validator(config);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error regarding ${pluginName} config: ${e.message}`);\n }\n\n throw e;\n }\n plugin.config = config;\n }\n};\n\nexport default async function loadPlugins(strapi: Core.Strapi) {\n const plugins: Plugins = {};\n\n const enabledPlugins = await getEnabledPlugins(strapi);\n\n strapi.config.set('enabledPlugins', enabledPlugins);\n\n for (const pluginName of Object.keys(enabledPlugins)) {\n const enabledPlugin = enabledPlugins[pluginName];\n\n let serverEntrypointPath;\n let resolvedExport = './strapi-server.js';\n\n try {\n resolvedExport = (\n resolve.exports(enabledPlugin.packageInfo, 'strapi-server', {\n require: true,\n }) ?? './strapi-server.js'\n ).toString();\n } catch (e) {\n // no export map or missing strapi-server export => fallback to default\n }\n\n try {\n serverEntrypointPath = join(enabledPlugin.pathToPlugin, resolvedExport);\n } catch (e) {\n throw new Error(\n `Error loading the plugin ${pluginName} because ${pluginName} is not installed. Please either install the plugin or remove it's configuration.`\n );\n }\n\n // only load plugins with a server entrypoint\n if (!(await fse.pathExists(serverEntrypointPath))) {\n continue;\n }\n\n const pluginServer = loadConfigFile(serverEntrypointPath);\n plugins[pluginName] = {\n ...defaultPlugin,\n ...pluginServer,\n contentTypes: formatContentTypes(pluginName, pluginServer.contentTypes ?? {}),\n config: defaults(defaultPlugin.config, pluginServer.config),\n routes: pluginServer.routes ?? defaultPlugin.routes,\n };\n }\n\n // TODO: validate plugin format\n await applyUserConfig(plugins);\n await applyUserExtension(plugins);\n\n for (const pluginName of Object.keys(plugins)) {\n strapi.get('plugins').add(pluginName, plugins[pluginName]);\n }\n}\n\nconst formatContentTypes = (\n pluginName: string,\n contentTypes: Record<string, { schema: Struct.ContentTypeSchema }>\n) => {\n Object.values(contentTypes).forEach((definition) => {\n const { schema } = definition;\n\n Object.assign(schema, {\n plugin: pluginName,\n collectionName:\n schema.collectionName || `${pluginName}_${schema.info.singularName}`.toLowerCase(),\n globalId: getGlobalId(schema, pluginName),\n });\n });\n\n return contentTypes;\n};\n"],"names":["fse","loadFiles","get","getUserPluginsConfig","getOr","env","defaultsDeep","strapi","getEnabledPlugins","resolve","join","loadConfigFile","defaults","getGlobalId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgB;AAAA,EACpB,YAAY;AAAA,EAAC;AAAA,EACb,UAAU;AAAA,EAAC;AAAA,EACX,WAAW;AAAA,EAAC;AAAA,EACZ,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,IACV,YAAY;AAAA,IAAC;AAAA,EACf;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAAA,EACd,cAAc,CAAC;AACjB;AAEA,MAAM,qBAAqB,OA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AAE,QAAQ,CAAC,eAAe;AAC5C,UAAA,EAAE,OAAW,IAAA;AAEnB,WAAO,OAAO,QAAQ;AAAA,MACpB,QAAQ;AAAA,MACR,gBACE,OAAO,kBAAkB,GAAG,UAAU,IAAI,OAAO,KAAK,YAAY,GAAG,YAAY;AAAA,MACnF,UAAUM,MAAAA,YAAY,QAAQ,UAAU;AAAA,IAAA,CACzC;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAmB3E,eAAO,MAAM,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/repository.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAmB3E,eAAO,MAAM,2BAA2B,EAAE,uBAuYzC,CAAC"}
|
|
@@ -228,13 +228,20 @@ const createContentTypeRepository = (uid) => {
|
|
|
228
228
|
select: ["id", "locale"]
|
|
229
229
|
})
|
|
230
230
|
]);
|
|
231
|
-
const relationsToSync = await unidirectionalRelations.load(uid,
|
|
231
|
+
const relationsToSync = await unidirectionalRelations.load(uid, {
|
|
232
|
+
newVersions: draftsToPublish,
|
|
233
|
+
oldVersions: oldPublishedVersions
|
|
234
|
+
});
|
|
232
235
|
await strapiUtils.async.map(oldPublishedVersions, (entry) => entries$1.delete(entry.id));
|
|
233
236
|
const publishedEntries = await strapiUtils.async.map(
|
|
234
237
|
draftsToPublish,
|
|
235
238
|
(draft) => entries$1.publish(draft, queryParams)
|
|
236
239
|
);
|
|
237
|
-
await unidirectionalRelations.sync(
|
|
240
|
+
await unidirectionalRelations.sync(
|
|
241
|
+
[...oldPublishedVersions, ...draftsToPublish],
|
|
242
|
+
publishedEntries,
|
|
243
|
+
relationsToSync
|
|
244
|
+
);
|
|
238
245
|
publishedEntries.forEach(emitEvent("entry.publish"));
|
|
239
246
|
return { documentId, entries: publishedEntries };
|
|
240
247
|
}
|
|
@@ -278,13 +285,20 @@ const createContentTypeRepository = (uid) => {
|
|
|
278
285
|
select: ["id", "locale"]
|
|
279
286
|
})
|
|
280
287
|
]);
|
|
281
|
-
const relationsToSync = await unidirectionalRelations.load(uid,
|
|
288
|
+
const relationsToSync = await unidirectionalRelations.load(uid, {
|
|
289
|
+
newVersions: versionsToDraft,
|
|
290
|
+
oldVersions: oldDrafts
|
|
291
|
+
});
|
|
282
292
|
await strapiUtils.async.map(oldDrafts, (entry) => entries$1.delete(entry.id));
|
|
283
293
|
const draftEntries = await strapiUtils.async.map(
|
|
284
294
|
versionsToDraft,
|
|
285
295
|
(entry) => entries$1.discardDraft(entry, queryParams)
|
|
286
296
|
);
|
|
287
|
-
await unidirectionalRelations.sync(
|
|
297
|
+
await unidirectionalRelations.sync(
|
|
298
|
+
[...oldDrafts, ...versionsToDraft],
|
|
299
|
+
draftEntries,
|
|
300
|
+
relationsToSync
|
|
301
|
+
);
|
|
288
302
|
draftEntries.forEach(emitEvent("entry.draft-discard"));
|
|
289
303
|
return { documentId, entries: draftEntries };
|
|
290
304
|
}
|