@strapi/core 5.28.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Strapi.js +13 -13
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +13 -13
- package/dist/Strapi.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +2 -15
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +2 -15
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/package.json.js +11 -11
- package/dist/package.json.mjs +11 -11
- package/dist/services/document-service/utils/clean-component-join-table.d.ts.map +1 -1
- package/dist/services/document-service/utils/clean-component-join-table.js +145 -0
- package/dist/services/document-service/utils/clean-component-join-table.js.map +1 -0
- package/dist/services/document-service/utils/clean-component-join-table.mjs +143 -0
- package/dist/services/document-service/utils/clean-component-join-table.mjs.map +1 -0
- package/package.json +11 -11
package/dist/Strapi.js
CHANGED
|
@@ -44,6 +44,7 @@ var index$6 = require('./services/document-service/index.js');
|
|
|
44
44
|
var contentSourceMaps = require('./services/content-source-maps.js');
|
|
45
45
|
var coreStore = require('./services/core-store.js');
|
|
46
46
|
var config = require('./services/config.js');
|
|
47
|
+
var cleanComponentJoinTable = require('./services/document-service/utils/clean-component-join-table.js');
|
|
47
48
|
|
|
48
49
|
function _interopNamespaceDefault(e) {
|
|
49
50
|
var n = Object.create(null);
|
|
@@ -64,7 +65,6 @@ function _interopNamespaceDefault(e) {
|
|
|
64
65
|
|
|
65
66
|
var globalAgent__namespace = /*#__PURE__*/_interopNamespaceDefault(globalAgent);
|
|
66
67
|
|
|
67
|
-
// import { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';
|
|
68
68
|
class Strapi extends container.Container {
|
|
69
69
|
get admin() {
|
|
70
70
|
return this.get('admin');
|
|
@@ -365,18 +365,18 @@ class Strapi extends container.Container {
|
|
|
365
365
|
pivot: 'component_type'
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
368
|
+
const alreadyRanComponentRepair = await this.store.get({
|
|
369
|
+
type: 'strapi',
|
|
370
|
+
key: 'unidirectional-join-table-repair-ran'
|
|
371
|
+
});
|
|
372
|
+
if (!alreadyRanComponentRepair) {
|
|
373
|
+
await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable.cleanComponentJoinTable);
|
|
374
|
+
await this.store.set({
|
|
375
|
+
type: 'strapi',
|
|
376
|
+
key: 'unidirectional-join-table-repair-ran',
|
|
377
|
+
value: true
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
380
|
if (this.EE) {
|
|
381
381
|
await index.checkLicense({
|
|
382
382
|
strapi: this
|
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 tsUtils from '@strapi/typescript-utils';\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 getNumberOfConditionalFields from './services/utils/conditional-fields';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\nimport { createContentSourceMapsService } from './services/content-source-maps';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\n// import { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';\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 sessionManager(): Modules.SessionManager.SessionManagerService {\n return this.get('sessionManager');\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('db', () => {\n const tsDir = tsUtils.resolveOutDirSync(this.dirs.app.root);\n const tsMigrationsEnabled =\n this.config.get('database.settings.useTypescriptMigrations') === true && tsDir;\n const projectDir = tsMigrationsEnabled ? tsDir : this.dirs.app.root;\n return new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(projectDir, 'database/migrations'),\n },\n },\n })\n );\n })\n .add('reload', () => createReloader(this))\n .add('content-source-maps', () => createContentSourceMapsService(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 numberOfConditionalFields: getNumberOfConditionalFields(),\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 // NOTE: commenting out repair logic for now as it is causing relationship loss in some cases\n // will revisit soon in the future PR\n\n const status = await this.db.schema.sync();\n\n // // if schemas have changed, run repairs\n if (status === 'CHANGED') {\n await this.db.repair.removeOrphanMorphType({ pivot: 'component_type' });\n }\n\n // const alreadyRanComponentRepair = await this.store.get({\n // type: 'strapi',\n // key: 'unidirectional-join-table-repair-ran',\n // });\n\n // if (!alreadyRanComponentRepair) {\n // await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable);\n // await this.store.set({\n // type: 'strapi',\n // key: 'unidirectional-join-table-repair-ran',\n // value: true,\n // });\n // }\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":["Strapi","Container","admin","get","EE","utils","isEE","ee","dirs","config","reload","db","requestContext","customFields","entityValidator","entityService","documents","features","fetch","cron","log","startupLogger","eventHub","fs","server","telemetry","sessionManager","store","services","getAll","service","uid","controllers","controller","contentTypes","contentType","name","components","policies","policy","middlewares","middleware","plugins","plugin","hooks","hook","apis","api","auth","contentAPI","sanitizers","validators","start","isLoaded","load","listen","error","stopWithError","registerInternalServices","createConfigProvider","internal_config","logger","createLogger","level","add","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","createFeaturesService","createCustomFields","createEntityService","strapi","createDocumentService","tsDir","tsUtils","resolveOutDirSync","app","root","tsMigrationsEnabled","projectDir","Database","_","merge","settings","migrations","dir","path","join","createReloader","createContentSourceMapsService","sendStartupTelemetry","send","groupProperties","database","Object","keys","numberOfAllContentTypes","size","numberOfComponents","numberOfDynamicZones","getNumberOfDynamicZones","numberOfConditionalFields","getNumberOfConditionalFields","numberOfCustomControllers","values","filter","undefined","factories","length","environment","catch","openAdmin","isInitialized","shouldOpenAdmin","e","postListen","logStartupMessage","info","Promise","resolve","reject","onListen","listenSocket","host","port","err","customMessage","debug","stop","exitCode","destroy","process","exit","register","bootstrap","init","provider","providers","runPluginsLifecycles","REGISTER","runUserLifecycles","configureGlobalProxy","models","metadata","identifiers","oldContentTypes","getSchemaConnection","hasTable","coreStoreModel","tableName","type","key","call","status","schema","sync","repair","removeOrphanMorphType","pivot","checkLicense","set","value","initMiddlewares","initRouting","permissions","registerActions","BOOTSTRAP","globalProxy","httpProxy","httpsProxy","globalAgent","global","GLOBAL_AGENT","HTTP_PROXY","HTTPS_PROXY","DESTROY","removeAllListeners","lifecycleName","userLifecycleFunction","isFunction","getModel","query","constructor","opts","loadConfiguration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;AAEA,MAAMA,MAAeC,SAAAA,mBAAAA,CAAAA;AAmBnB,IAAA,IAAIC,KAAqB,GAAA;QACvB,OAAO,IAAI,CAACC,GAAG,CAAC,OAAA,CAAA;AAClB;AAEA,IAAA,IAAIC,EAAc,GAAA;QAChB,OAAOC,KAAQ,CAACC,IAAI;AACtB;AAEA,IAAA,IAAIC,EAAwB,GAAA;AAC1B,QAAA,OAAOF,KAAQ;AACjB;AAEA,IAAA,IAAIG,IAA+B,GAAA;AACjC,QAAA,OAAO,IAA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QAC/B,KAAK,EAAA;aALPrI,QAAoB,GAAA,KAAA;AAEpBO,QAAAA,IAAAA,CAAAA,eAAAA,GAA2C,EAAC;QAK1C,IAAI,CAACA,eAAe,GAAG+H,yBAAkBD,CAAAA,IAAAA,CAAAA;AAEzC,QAAA,IAAI,CAAChI,wBAAwB,EAAA;QAE7B,KAAK,MAAMiF,YAAYC,iBAAW,CAAA;YAChCD,QAASD,CAAAA,IAAI,GAAG,IAAI,CAAA;AACtB;AACF;AA8gBF;;;;"}
|
|
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 tsUtils from '@strapi/typescript-utils';\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 getNumberOfConditionalFields from './services/utils/conditional-fields';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\nimport { createContentSourceMapsService } from './services/content-source-maps';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\nimport { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';\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 sessionManager(): Modules.SessionManager.SessionManagerService {\n return this.get('sessionManager');\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('db', () => {\n const tsDir = tsUtils.resolveOutDirSync(this.dirs.app.root);\n const tsMigrationsEnabled =\n this.config.get('database.settings.useTypescriptMigrations') === true && tsDir;\n const projectDir = tsMigrationsEnabled ? tsDir : this.dirs.app.root;\n return new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(projectDir, 'database/migrations'),\n },\n },\n })\n );\n })\n .add('reload', () => createReloader(this))\n .add('content-source-maps', () => createContentSourceMapsService(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 numberOfConditionalFields: getNumberOfConditionalFields(),\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 // NOTE: commenting out repair logic for now as it is causing relationship loss in some cases\n // will revisit soon in the future PR\n\n const status = await this.db.schema.sync();\n\n // // if schemas have changed, run repairs\n if (status === 'CHANGED') {\n await this.db.repair.removeOrphanMorphType({ pivot: 'component_type' });\n }\n\n const alreadyRanComponentRepair = await this.store.get({\n type: 'strapi',\n key: 'unidirectional-join-table-repair-ran',\n });\n\n if (!alreadyRanComponentRepair) {\n await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable);\n await this.store.set({\n type: 'strapi',\n key: 'unidirectional-join-table-repair-ran',\n value: true,\n });\n }\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":["Strapi","Container","admin","get","EE","utils","isEE","ee","dirs","config","reload","db","requestContext","customFields","entityValidator","entityService","documents","features","fetch","cron","log","startupLogger","eventHub","fs","server","telemetry","sessionManager","store","services","getAll","service","uid","controllers","controller","contentTypes","contentType","name","components","policies","policy","middlewares","middleware","plugins","plugin","hooks","hook","apis","api","auth","contentAPI","sanitizers","validators","start","isLoaded","load","listen","error","stopWithError","registerInternalServices","createConfigProvider","internal_config","logger","createLogger","level","add","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","createFeaturesService","createCustomFields","createEntityService","strapi","createDocumentService","tsDir","tsUtils","resolveOutDirSync","app","root","tsMigrationsEnabled","projectDir","Database","_","merge","settings","migrations","dir","path","join","createReloader","createContentSourceMapsService","sendStartupTelemetry","send","groupProperties","database","Object","keys","numberOfAllContentTypes","size","numberOfComponents","numberOfDynamicZones","getNumberOfDynamicZones","numberOfConditionalFields","getNumberOfConditionalFields","numberOfCustomControllers","values","filter","undefined","factories","length","environment","catch","openAdmin","isInitialized","shouldOpenAdmin","e","postListen","logStartupMessage","info","Promise","resolve","reject","onListen","listenSocket","host","port","err","customMessage","debug","stop","exitCode","destroy","process","exit","register","bootstrap","init","provider","providers","runPluginsLifecycles","REGISTER","runUserLifecycles","configureGlobalProxy","models","metadata","identifiers","oldContentTypes","getSchemaConnection","hasTable","coreStoreModel","tableName","type","key","call","status","schema","sync","repair","removeOrphanMorphType","pivot","alreadyRanComponentRepair","processUnidirectionalJoinTables","cleanComponentJoinTable","set","value","checkLicense","initMiddlewares","initRouting","permissions","registerActions","BOOTSTRAP","globalProxy","httpProxy","httpsProxy","globalAgent","global","GLOBAL_AGENT","HTTP_PROXY","HTTPS_PROXY","DESTROY","removeAllListeners","lifecycleName","userLifecycleFunction","isFunction","getModel","query","constructor","opts","loadConfiguration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA,MAAeC,SAAAA,mBAAAA,CAAAA;AAmBnB,IAAA,IAAIC,KAAqB,GAAA;QACvB,OAAO,IAAI,CAACC,GAAG,CAAC,OAAA,CAAA;AAClB;AAEA,IAAA,IAAIC,EAAc,GAAA;QAChB,OAAOC,KAAQ,CAACC,IAAI;AACtB;AAEA,IAAA,IAAIC,EAAwB,GAAA;AAC1B,QAAA,OAAOF,KAAQ;AACjB;AAEA,IAAA,IAAIG,IAA+B,GAAA;AACjC,QAAA,OAAO,IAAI,CAACC,MAAM,CAACN,GAAG,CAAC,MAAA,CAAA;AACzB;AAEA,IAAA,IAAIO,MAAwB,GAAA;QAC1B,OAAO,IAAI,CAACP,GAAG,CAAC,QAAA,CAAA;AAClB;AAEA,IAAA,IAAIQ,EAAe,GAAA;QACjB,OAAO,IAAI,CAACR,GAAG,CAAC,IAAA,CAAA;AAClB;AAEA,IAAA,IAAIS,cAAwD,GAAA;QAC1D,OAAO,IAAI,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AAA,OAAO,IAAI,CAACpB,EAAE,CAACgL,KAAK,CAAC5J,GAAAA,CAAAA;AACvB;AAvhBA6J,IAAAA,WAAAA,CAAYC,IAAmB,CAAE;QAC/B,KAAK,EAAA;aALPxI,QAAoB,GAAA,KAAA;AAEpBO,QAAAA,IAAAA,CAAAA,eAAAA,GAA2C,EAAC;QAK1C,IAAI,CAACA,eAAe,GAAGkI,yBAAkBD,CAAAA,IAAAA,CAAAA;AAEzC,QAAA,IAAI,CAACnI,wBAAwB,EAAA;QAE7B,KAAK,MAAMiF,YAAYC,iBAAW,CAAA;YAChCD,QAASD,CAAAA,IAAI,GAAG,IAAI,CAAA;AACtB;AACF;AA8gBF;;;;"}
|
package/dist/Strapi.mjs
CHANGED
|
@@ -42,8 +42,8 @@ import { createDocumentService } from './services/document-service/index.mjs';
|
|
|
42
42
|
import { createContentSourceMapsService } from './services/content-source-maps.mjs';
|
|
43
43
|
import { coreStoreModel } from './services/core-store.mjs';
|
|
44
44
|
import { createConfigProvider } from './services/config.mjs';
|
|
45
|
+
import { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table.mjs';
|
|
45
46
|
|
|
46
|
-
// import { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';
|
|
47
47
|
class Strapi extends Container {
|
|
48
48
|
get admin() {
|
|
49
49
|
return this.get('admin');
|
|
@@ -344,18 +344,18 @@ class Strapi extends Container {
|
|
|
344
344
|
pivot: 'component_type'
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
347
|
+
const alreadyRanComponentRepair = await this.store.get({
|
|
348
|
+
type: 'strapi',
|
|
349
|
+
key: 'unidirectional-join-table-repair-ran'
|
|
350
|
+
});
|
|
351
|
+
if (!alreadyRanComponentRepair) {
|
|
352
|
+
await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable);
|
|
353
|
+
await this.store.set({
|
|
354
|
+
type: 'strapi',
|
|
355
|
+
key: 'unidirectional-join-table-repair-ran',
|
|
356
|
+
value: true
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
359
|
if (this.EE) {
|
|
360
360
|
await index.checkLicense({
|
|
361
361
|
strapi: this
|
package/dist/Strapi.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strapi.mjs","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 tsUtils from '@strapi/typescript-utils';\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 getNumberOfConditionalFields from './services/utils/conditional-fields';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\nimport { createContentSourceMapsService } from './services/content-source-maps';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\n// import { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';\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 sessionManager(): Modules.SessionManager.SessionManagerService {\n return this.get('sessionManager');\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('db', () => {\n const tsDir = tsUtils.resolveOutDirSync(this.dirs.app.root);\n const tsMigrationsEnabled =\n this.config.get('database.settings.useTypescriptMigrations') === true && tsDir;\n const projectDir = tsMigrationsEnabled ? tsDir : this.dirs.app.root;\n return new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(projectDir, 'database/migrations'),\n },\n },\n })\n );\n })\n .add('reload', () => createReloader(this))\n .add('content-source-maps', () => createContentSourceMapsService(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 numberOfConditionalFields: getNumberOfConditionalFields(),\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 // NOTE: commenting out repair logic for now as it is causing relationship loss in some cases\n // will revisit soon in the future PR\n\n const status = await this.db.schema.sync();\n\n // // if schemas have changed, run repairs\n if (status === 'CHANGED') {\n await this.db.repair.removeOrphanMorphType({ pivot: 'component_type' });\n }\n\n // const alreadyRanComponentRepair = await this.store.get({\n // type: 'strapi',\n // key: 'unidirectional-join-table-repair-ran',\n // });\n\n // if (!alreadyRanComponentRepair) {\n // await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable);\n // await this.store.set({\n // type: 'strapi',\n // key: 'unidirectional-join-table-repair-ran',\n // value: true,\n // });\n // }\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":["Strapi","Container","admin","get","EE","utils","isEE","ee","dirs","config","reload","db","requestContext","customFields","entityValidator","entityService","documents","features","fetch","cron","log","startupLogger","eventHub","fs","server","telemetry","sessionManager","store","services","getAll","service","uid","controllers","controller","contentTypes","contentType","name","components","policies","policy","middlewares","middleware","plugins","plugin","hooks","hook","apis","api","auth","contentAPI","sanitizers","validators","start","isLoaded","load","listen","error","stopWithError","registerInternalServices","createConfigProvider","internal_config","logger","createLogger","level","add","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","createFeaturesService","createCustomFields","createEntityService","strapi","createDocumentService","tsDir","tsUtils","resolveOutDirSync","app","root","tsMigrationsEnabled","projectDir","Database","_","merge","settings","migrations","dir","path","join","createReloader","createContentSourceMapsService","sendStartupTelemetry","send","groupProperties","database","Object","keys","numberOfAllContentTypes","size","numberOfComponents","numberOfDynamicZones","getNumberOfDynamicZones","numberOfConditionalFields","getNumberOfConditionalFields","numberOfCustomControllers","values","filter","undefined","factories","length","environment","catch","openAdmin","isInitialized","shouldOpenAdmin","e","postListen","logStartupMessage","info","Promise","resolve","reject","onListen","listenSocket","host","port","err","customMessage","debug","stop","exitCode","destroy","process","exit","register","bootstrap","init","provider","providers","runPluginsLifecycles","REGISTER","runUserLifecycles","configureGlobalProxy","models","metadata","identifiers","oldContentTypes","getSchemaConnection","hasTable","coreStoreModel","tableName","type","key","call","status","schema","sync","repair","removeOrphanMorphType","pivot","checkLicense","set","value","initMiddlewares","initRouting","permissions","registerActions","BOOTSTRAP","globalProxy","httpProxy","httpsProxy","globalAgent","global","GLOBAL_AGENT","HTTP_PROXY","HTTPS_PROXY","DESTROY","removeAllListeners","lifecycleName","userLifecycleFunction","isFunction","getModel","query","constructor","opts","loadConfiguration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;AAEA,MAAMA,MAAeC,SAAAA,SAAAA,CAAAA;AAmBnB,IAAA,IAAIC,KAAqB,GAAA;QACvB,OAAO,IAAI,CAACC,GAAG,CAAC,OAAA,CAAA;AAClB;AAEA,IAAA,IAAIC,EAAc,GAAA;QAChB,OAAOC,KAAQ,CAACC,IAAI;AACtB;AAEA,IAAA,IAAIC,EAAwB,GAAA;AAC1B,QAAA,OAAOF,KAAQ;AACjB;AAEA,IAAA,IAAIG,IAA+B,GAAA;AACjC,QAAA,OAAO,IAAI,CAACC,MAAM,CAACN,GAAG,CAAC,MAAA,CAAA;AACzB;AAEA,IAAA,IAAIO,MAAwB,GAAA;QAC1B,OAAO,IAAI,CAACP,GAAG,CAAC,QAAA,CAAA;AAClB;AAEA,IAAA,IAAIQ,EAAe,GAAA;QACjB,OAAO,IAAI,CAACR,GAAG,CAAC,IAAA,CAAA;AAClB;AAEA,IAAA,IAAIS,cAAwD,GAAA;QAC1D,OAAO,IAAI,CAACT,GAAG,CAAC,gBAAA,CAAA;AAClB;AAEA,IAAA,IAAIU,YAAkD,GAAA;QACpD,OAAO,IAAI,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["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 tsUtils from '@strapi/typescript-utils';\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 getNumberOfConditionalFields from './services/utils/conditional-fields';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\nimport { createContentSourceMapsService } from './services/content-source-maps';\n\nimport { coreStoreModel } from './services/core-store';\nimport { createConfigProvider } from './services/config';\n\nimport { cleanComponentJoinTable } from './services/document-service/utils/clean-component-join-table';\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 sessionManager(): Modules.SessionManager.SessionManagerService {\n return this.get('sessionManager');\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('db', () => {\n const tsDir = tsUtils.resolveOutDirSync(this.dirs.app.root);\n const tsMigrationsEnabled =\n this.config.get('database.settings.useTypescriptMigrations') === true && tsDir;\n const projectDir = tsMigrationsEnabled ? tsDir : this.dirs.app.root;\n return new Database(\n _.merge(this.config.get('database'), {\n logger,\n settings: {\n migrations: {\n dir: path.join(projectDir, 'database/migrations'),\n },\n },\n })\n );\n })\n .add('reload', () => createReloader(this))\n .add('content-source-maps', () => createContentSourceMapsService(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 numberOfConditionalFields: getNumberOfConditionalFields(),\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 // NOTE: commenting out repair logic for now as it is causing relationship loss in some cases\n // will revisit soon in the future PR\n\n const status = await this.db.schema.sync();\n\n // // if schemas have changed, run repairs\n if (status === 'CHANGED') {\n await this.db.repair.removeOrphanMorphType({ pivot: 'component_type' });\n }\n\n const alreadyRanComponentRepair = await this.store.get({\n type: 'strapi',\n key: 'unidirectional-join-table-repair-ran',\n });\n\n if (!alreadyRanComponentRepair) {\n await this.db.repair.processUnidirectionalJoinTables(cleanComponentJoinTable);\n await this.store.set({\n type: 'strapi',\n key: 'unidirectional-join-table-repair-ran',\n value: true,\n });\n }\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":["Strapi","Container","admin","get","EE","utils","isEE","ee","dirs","config","reload","db","requestContext","customFields","entityValidator","entityService","documents","features","fetch","cron","log","startupLogger","eventHub","fs","server","telemetry","sessionManager","store","services","getAll","service","uid","controllers","controller","contentTypes","contentType","name","components","policies","policy","middlewares","middleware","plugins","plugin","hooks","hook","apis","api","auth","contentAPI","sanitizers","validators","start","isLoaded","load","listen","error","stopWithError","registerInternalServices","createConfigProvider","internal_config","logger","createLogger","level","add","createQueryParamService","createContentAPI","createAuth","createServer","createStrapiFs","createEventHub","createFeaturesService","createCustomFields","createEntityService","strapi","createDocumentService","tsDir","tsUtils","resolveOutDirSync","app","root","tsMigrationsEnabled","projectDir","Database","_","merge","settings","migrations","dir","path","join","createReloader","createContentSourceMapsService","sendStartupTelemetry","send","groupProperties","database","Object","keys","numberOfAllContentTypes","size","numberOfComponents","numberOfDynamicZones","getNumberOfDynamicZones","numberOfConditionalFields","getNumberOfConditionalFields","numberOfCustomControllers","values","filter","undefined","factories","length","environment","catch","openAdmin","isInitialized","shouldOpenAdmin","e","postListen","logStartupMessage","info","Promise","resolve","reject","onListen","listenSocket","host","port","err","customMessage","debug","stop","exitCode","destroy","process","exit","register","bootstrap","init","provider","providers","runPluginsLifecycles","REGISTER","runUserLifecycles","configureGlobalProxy","models","metadata","identifiers","oldContentTypes","getSchemaConnection","hasTable","coreStoreModel","tableName","type","key","call","status","schema","sync","repair","removeOrphanMorphType","pivot","alreadyRanComponentRepair","processUnidirectionalJoinTables","cleanComponentJoinTable","set","value","checkLicense","initMiddlewares","initRouting","permissions","registerActions","BOOTSTRAP","globalProxy","httpProxy","httpsProxy","globalAgent","global","GLOBAL_AGENT","HTTP_PROXY","HTTPS_PROXY","DESTROY","removeAllListeners","lifecycleName","userLifecycleFunction","isFunction","getModel","query","constructor","opts","loadConfiguration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA,MAAeC,SAAAA,SAAAA,CAAAA;AAmBnB,IAAA,IAAIC,KAAqB,GAAA;QACvB,OAAO,IAAI,CAACC,GAAG,CAAC,OAAA,CAAA;AAClB;AAEA,IAAA,IAAIC,EAAc,GAAA;QAChB,OAAOC,KAAQ,CAACC,IAAI;AACtB;AAEA,IAAA,IAAIC,EAAwB,GAAA;AAC1B,QAAA,OAAOF,KAAQ;AACjB;AAEA,IAAA,IAAIG,IAA+B,GAAA;AACjC,QAAA,OAAO,IAAI,CAACC,MAAM,CAACN,GAAG,CAAC,MAAA,CAAA;AACzB;AAEA,IAAA,IAAIO,MAAwB,GAAA;QAC1B,OAAO,IAAI,CAACP,GAAG,CAAC,QAAA,CAAA;AAClB;AAEA,IAAA,IAAIQ,EAAe,GAAA;QACjB,OAAO,IAAI,CAACR,GAAG,CAAC,IAAA,CAAA;AAClB;AAEA,IAAA,IAAIS,cAAwD,GAAA;QAC1D,OAAO,IAAI,CAACT,GAAG,CAAC,gBAAA,CAAA;AAClB;AAEA,IAAA,IAAIU,YAAkD,GAAA;QACpD,OAAO,IAAI,CAACV,GAAG,CAAC,cAAA,CAAA;AAClB;AAEA,IAAA,IAAIW,eAA2D,GAAA;QAC7D,OAAO,IAAI,CAACX,GAAG,CAAC,iBAAA,CAAA;AAClB;AAEA;;AAEC,MACD,IAAIY,aAAqD,GAAA;QACvD,OAAO,IAAI,CAACZ,GAAG,CAAC,eAAA,CAAA;AAClB;AAEA,IAAA,IAAIa,SAAuC,GAAA;QACzC,OAAO,IAAI,CAACb,GAAG,CAAC,WAAA,CAAA;AAClB;AAEA,IAA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AA8gBF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAgC3D,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAkEjD,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var fp = require('lodash/fp');
|
|
4
4
|
var helmet = require('koa-helmet');
|
|
5
|
+
var strapiUtils = require('@strapi/utils');
|
|
5
6
|
|
|
6
7
|
const defaults = {
|
|
7
8
|
crossOriginEmbedderPolicy: false,
|
|
@@ -11,21 +12,7 @@ const defaults = {
|
|
|
11
12
|
contentSecurityPolicy: {
|
|
12
13
|
useDefaults: true,
|
|
13
14
|
directives: {
|
|
14
|
-
|
|
15
|
-
"'self'",
|
|
16
|
-
'https:'
|
|
17
|
-
],
|
|
18
|
-
'img-src': [
|
|
19
|
-
"'self'",
|
|
20
|
-
'data:',
|
|
21
|
-
'blob:',
|
|
22
|
-
'https://market-assets.strapi.io'
|
|
23
|
-
],
|
|
24
|
-
'media-src': [
|
|
25
|
-
"'self'",
|
|
26
|
-
'data:',
|
|
27
|
-
'blob:'
|
|
28
|
-
],
|
|
15
|
+
...strapiUtils.CSP_DEFAULTS,
|
|
29
16
|
upgradeInsecureRequests: null
|
|
30
17
|
}
|
|
31
18
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n
|
|
1
|
+
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\nimport { CSP_DEFAULTS } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n ...CSP_DEFAULTS,\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaults","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","originAgentCluster","contentSecurityPolicy","useDefaults","directives","CSP_DEFAULTS","upgradeInsecureRequests","xssFilter","hsts","maxAge","includeSubDomains","frameguard","action","mergeConfig","existingConfig","newConfig","mergeWith","obj","src","Array","isArray","concat","undefined","security","config","strapi","ctx","next","helmetConfig","defaultsDeep","specialPaths","plugin","service","playground","isEnabled","gqlConfig","push","method","some","str","path","startsWith","includes","process","env","NODE_ENV","get","helmet"],"mappings":";;;;;;AAQA,MAAMA,QAAmB,GAAA;IACvBC,yBAA2B,EAAA,KAAA;IAC3BC,uBAAyB,EAAA,KAAA;IACzBC,yBAA2B,EAAA,KAAA;IAC3BC,kBAAoB,EAAA,KAAA;IACpBC,qBAAuB,EAAA;QACrBC,WAAa,EAAA,IAAA;QACbC,UAAY,EAAA;AACV,YAAA,GAAGC,wBAAY;YACfC,uBAAyB,EAAA;AAC3B;AACF,KAAA;IACAC,SAAW,EAAA,KAAA;IACXC,IAAM,EAAA;QACJC,MAAQ,EAAA,QAAA;QACRC,iBAAmB,EAAA;AACrB,KAAA;IACAC,UAAY,EAAA;QACVC,MAAQ,EAAA;AACV;AACF,CAAA;AAEA,MAAMC,WAAAA,GAAc,CAACC,cAAwBC,EAAAA,SAAAA,GAAAA;AAC3C,IAAA,OAAOC,aACL,CAACC,GAAAA,EAAKC,GAASC,GAAAA,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAAA,IAAQE,KAAMC,CAAAA,OAAO,CAACF,GAAOD,CAAAA,GAAAA,GAAAA,CAAII,MAAM,CAACH,GAAAA,CAAAA,GAAOI,WAC5ER,cACAC,EAAAA,SAAAA,CAAAA;AAEJ,CAAA;AAEO,MAAMQ,WACX,CAACC,MAAAA,EAAQ,EAAEC,MAAM,EAAE,GACnB,CAACC,GAAKC,EAAAA,IAAAA,GAAAA;QACJ,IAAIC,YAAAA,GAAuBC,gBAAahC,QAAU2B,EAAAA,MAAAA,CAAAA;AAClD,QAAA,MAAMM,YAAe,GAAA;AAAC,YAAA;AAAiB,SAAA;AAEvC,QAAA,MAAM1B,UAKF,GAAA;YACF,YAAc,EAAA;AAAC,gBAAA,QAAA;AAAU,gBAAA,iBAAA;AAAmB,gBAAA;AAAmB,aAAA;YAC/D,SAAW,EAAA;AAAC,gBAAA,QAAA;AAAU,gBAAA,OAAA;AAAS,gBAAA,kBAAA;A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CAACC,OAAQC,CAAAA,GAAG,CAACC,QAAQ,IAAI,EACzDnB,CAAAA,IAAAA,GAAAA,CAAIW,MAAM,KAAK,SACfX,GAAIc,CAAAA,IAAI,CAACC,UAAU,CAAChB,OAAOD,MAAM,CAACsB,GAAG,CAAC,YACtC,CAAA,CAAA,EAAA;AACAlB,YAAAA,YAAAA,GAAef,YAAYe,YAAc,EAAA;gBACvC1B,qBAAuB,EAAA;oBACrBE,UAAY,EAAA;wBACV,YAAc,EAAA;AAAC,4BAAA,QAAA;AAAU,4BAAA;AAAkB,yBAAA;wBAC3C,aAAe,EAAA;AAAC,4BAAA,QAAA;AAAU,4BAAA,OAAA;AAAS,4BAAA,QAAA;AAAU,4BAAA;AAAM;AACrD;AACF;AACF,aAAA,CAAA;AACF;QAEA,OAAO2C,MAAAA,CAAOnB,cAAcF,GAAKC,EAAAA,IAAAA,CAAAA;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defaultsDeep, mergeWith } from 'lodash/fp';
|
|
2
2
|
import helmet from 'koa-helmet';
|
|
3
|
+
import { CSP_DEFAULTS } from '@strapi/utils';
|
|
3
4
|
|
|
4
5
|
const defaults = {
|
|
5
6
|
crossOriginEmbedderPolicy: false,
|
|
@@ -9,21 +10,7 @@ const defaults = {
|
|
|
9
10
|
contentSecurityPolicy: {
|
|
10
11
|
useDefaults: true,
|
|
11
12
|
directives: {
|
|
12
|
-
|
|
13
|
-
"'self'",
|
|
14
|
-
'https:'
|
|
15
|
-
],
|
|
16
|
-
'img-src': [
|
|
17
|
-
"'self'",
|
|
18
|
-
'data:',
|
|
19
|
-
'blob:',
|
|
20
|
-
'https://market-assets.strapi.io'
|
|
21
|
-
],
|
|
22
|
-
'media-src': [
|
|
23
|
-
"'self'",
|
|
24
|
-
'data:',
|
|
25
|
-
'blob:'
|
|
26
|
-
],
|
|
13
|
+
...CSP_DEFAULTS,
|
|
27
14
|
upgradeInsecureRequests: null
|
|
28
15
|
}
|
|
29
16
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n
|
|
1
|
+
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\nimport { CSP_DEFAULTS } from '@strapi/utils';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n ...CSP_DEFAULTS,\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaults","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","originAgentCluster","contentSecurityPolicy","useDefaults","directives","CSP_DEFAULTS","upgradeInsecureRequests","xssFilter","hsts","maxAge","includeSubDomains","frameguard","action","mergeConfig","existingConfig","newConfig","mergeWith","obj","src","Array","isArray","concat","undefined","security","config","strapi","ctx","next","helmetConfig","defaultsDeep","specialPaths","plugin","service","playground","isEnabled","gqlConfig","push","method","some","str","path","startsWith","includes","process","env","NODE_ENV","get","helmet"],"mappings":";;;;AAQA,MAAMA,QAAmB,GAAA;IACvBC,yBAA2B,EAAA,KAAA;IAC3BC,uBAAyB,EAAA,KAAA;IACzBC,yBAA2B,EAAA,KAAA;IAC3BC,kBAAoB,EAAA,KAAA;IACpBC,qBAAuB,EAAA;QACrBC,WAAa,EAAA,IAAA;QACbC,UAAY,EAAA;AACV,YAAA,GAAGC,YAAY;YACfC,uBAAyB,EAAA;AAC3B;AACF,KAAA;IACAC,SAAW,EAAA,KAAA;IACXC,IAAM,EAAA;QACJC,MAAQ,EAAA,QAAA;QACRC,iBAAmB,EAAA;AACrB,KAAA;IACAC,UAAY,EAAA;QACVC,MAAQ,EAAA;AACV;AACF,CAAA;AAEA,MAAMC,WAAAA,GAAc,CAACC,cAAwBC,EAAAA,SAAAA,GAAAA;AAC3C,IAAA,OAAOC,UACL,CAACC,GAAAA,EAAKC,GAASC,GAAAA,KAAAA,CAAMC,OAAO,CAACH,GAAAA,CAAAA,IAAQE,KAAMC,CAAAA,OAAO,CAACF,GAAOD,CAAAA,GAAAA,GAAAA,CAAII,MAAM,CAACH,GAAAA,CAAAA,GAAOI,WAC5ER,cACAC,EAAAA,SAAAA,CAAAA;AAEJ,CAAA;AAEO,MAAMQ,WACX,CAACC,MAAAA,EAAQ,EAAEC,MAAM,EAAE,GACnB,CAACC,GAAKC,EAAAA,IAAAA,GAAAA;QACJ,IAAIC,YAAAA,GAAuBC,aAAahC,QAAU2B,EAAAA,MAAAA,CAAAA;AAClD,QAAA,MAAMM,YAAe,GAAA;AAAC,YAAA;AAAiB,SAAA;AAEvC,QAAA,MAAM1B,UAKF,GAAA;YACF,YAAc,EAAA;AAAC,gBAAA,QAAA;AAAU,gBAAA,iBAAA;AAAmB,gBAAA;AAAmB,aAAA;YAC/D,SAAW,EAAA;AAAC,gBAAA,QAAA;AAAU,g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;AAAe,YAAA;SAAO,CAACsC,QAAQ,CAACC,OAAQC,CAAAA,GAAG,CAACC,QAAQ,IAAI,EACzDnB,CAAAA,IAAAA,GAAAA,CAAIW,MAAM,KAAK,SACfX,GAAIc,CAAAA,IAAI,CAACC,UAAU,CAAChB,OAAOD,MAAM,CAACsB,GAAG,CAAC,YACtC,CAAA,CAAA,EAAA;AACAlB,YAAAA,YAAAA,GAAef,YAAYe,YAAc,EAAA;gBACvC1B,qBAAuB,EAAA;oBACrBE,UAAY,EAAA;wBACV,YAAc,EAAA;AAAC,4BAAA,QAAA;AAAU,4BAAA;AAAkB,yBAAA;wBAC3C,aAAe,EAAA;AAAC,4BAAA,QAAA;AAAU,4BAAA,OAAA;AAAS,4BAAA,QAAA;AAAU,4BAAA;AAAM;AACrD;AACF;AACF,aAAA,CAAA;AACF;QAEA,OAAO2C,MAAAA,CAAOnB,cAAcF,GAAKC,EAAAA,IAAAA,CAAAA;;;;;"}
|
package/dist/package.json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/core";
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.30.0";
|
|
7
7
|
var description = "Core of Strapi";
|
|
8
8
|
var homepage = "https://strapi.io";
|
|
9
9
|
var bugs = {
|
|
@@ -59,14 +59,14 @@ var dependencies = {
|
|
|
59
59
|
"@koa/cors": "5.0.0",
|
|
60
60
|
"@koa/router": "12.0.2",
|
|
61
61
|
"@paralleldrive/cuid2": "2.2.2",
|
|
62
|
-
"@strapi/admin": "5.
|
|
63
|
-
"@strapi/database": "5.
|
|
64
|
-
"@strapi/generators": "5.
|
|
65
|
-
"@strapi/logger": "5.
|
|
66
|
-
"@strapi/permissions": "5.
|
|
67
|
-
"@strapi/types": "5.
|
|
68
|
-
"@strapi/typescript-utils": "5.
|
|
69
|
-
"@strapi/utils": "5.
|
|
62
|
+
"@strapi/admin": "5.30.0",
|
|
63
|
+
"@strapi/database": "5.30.0",
|
|
64
|
+
"@strapi/generators": "5.30.0",
|
|
65
|
+
"@strapi/logger": "5.30.0",
|
|
66
|
+
"@strapi/permissions": "5.30.0",
|
|
67
|
+
"@strapi/types": "5.30.0",
|
|
68
|
+
"@strapi/typescript-utils": "5.30.0",
|
|
69
|
+
"@strapi/utils": "5.30.0",
|
|
70
70
|
"@vercel/stega": "0.1.2",
|
|
71
71
|
bcryptjs: "2.4.3",
|
|
72
72
|
boxen: "5.1.2",
|
|
@@ -134,9 +134,9 @@ var devDependencies = {
|
|
|
134
134
|
"@types/node": "18.19.24",
|
|
135
135
|
"@types/node-schedule": "2.1.7",
|
|
136
136
|
"@types/statuses": "2.0.1",
|
|
137
|
-
"eslint-config-custom": "5.
|
|
137
|
+
"eslint-config-custom": "5.30.0",
|
|
138
138
|
supertest: "6.3.3",
|
|
139
|
-
tsconfig: "5.
|
|
139
|
+
tsconfig: "5.30.0"
|
|
140
140
|
};
|
|
141
141
|
var engines = {
|
|
142
142
|
node: ">=18.0.0 <=22.x.x",
|
package/dist/package.json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/core";
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.30.0";
|
|
3
3
|
var description = "Core of Strapi";
|
|
4
4
|
var homepage = "https://strapi.io";
|
|
5
5
|
var bugs = {
|
|
@@ -55,14 +55,14 @@ var dependencies = {
|
|
|
55
55
|
"@koa/cors": "5.0.0",
|
|
56
56
|
"@koa/router": "12.0.2",
|
|
57
57
|
"@paralleldrive/cuid2": "2.2.2",
|
|
58
|
-
"@strapi/admin": "5.
|
|
59
|
-
"@strapi/database": "5.
|
|
60
|
-
"@strapi/generators": "5.
|
|
61
|
-
"@strapi/logger": "5.
|
|
62
|
-
"@strapi/permissions": "5.
|
|
63
|
-
"@strapi/types": "5.
|
|
64
|
-
"@strapi/typescript-utils": "5.
|
|
65
|
-
"@strapi/utils": "5.
|
|
58
|
+
"@strapi/admin": "5.30.0",
|
|
59
|
+
"@strapi/database": "5.30.0",
|
|
60
|
+
"@strapi/generators": "5.30.0",
|
|
61
|
+
"@strapi/logger": "5.30.0",
|
|
62
|
+
"@strapi/permissions": "5.30.0",
|
|
63
|
+
"@strapi/types": "5.30.0",
|
|
64
|
+
"@strapi/typescript-utils": "5.30.0",
|
|
65
|
+
"@strapi/utils": "5.30.0",
|
|
66
66
|
"@vercel/stega": "0.1.2",
|
|
67
67
|
bcryptjs: "2.4.3",
|
|
68
68
|
boxen: "5.1.2",
|
|
@@ -130,9 +130,9 @@ var devDependencies = {
|
|
|
130
130
|
"@types/node": "18.19.24",
|
|
131
131
|
"@types/node-schedule": "2.1.7",
|
|
132
132
|
"@types/statuses": "2.0.1",
|
|
133
|
-
"eslint-config-custom": "5.
|
|
133
|
+
"eslint-config-custom": "5.30.0",
|
|
134
134
|
supertest: "6.3.3",
|
|
135
|
-
tsconfig: "5.
|
|
135
|
+
tsconfig: "5.30.0"
|
|
136
136
|
};
|
|
137
137
|
var engines = {
|
|
138
138
|
node: ">=18.0.0 <=22.x.x",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-component-join-table.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/clean-component-join-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,OAC9B,QAAQ,iBACG,MAAM,YACX,GAAG,eACA,GAAG,KACf,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"clean-component-join-table.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/clean-component-join-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,OAC9B,QAAQ,iBACG,MAAM,YACX,GAAG,eACA,GAAG,KACf,QAAQ,MAAM,CAoDhB,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components = require('../components.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cleans ghost relations with publication state mismatches from a join table
|
|
7
|
+
* Uses schema-based draft/publish checking like prevention fix
|
|
8
|
+
*/ const cleanComponentJoinTable = async (db, joinTableName, relation, sourceModel)=>{
|
|
9
|
+
try {
|
|
10
|
+
// Get the target model metadata
|
|
11
|
+
const targetModel = db.metadata.get(relation.target);
|
|
12
|
+
if (!targetModel) {
|
|
13
|
+
db.logger.debug(`Target model ${relation.target} not found, skipping ${joinTableName}`);
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
// Check if source supports draft/publish, if it doesnt it should contain duplicate states
|
|
17
|
+
const sourceContentType = strapi.contentTypes[sourceModel.uid];
|
|
18
|
+
// It could be a model, which does not have the draftAndPublish option
|
|
19
|
+
const sourceSupportsDraftPublish = sourceContentType?.options?.draftAndPublish;
|
|
20
|
+
if (sourceContentType && !sourceSupportsDraftPublish) {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
// Check if target supports draft/publish using schema-based approach (like prevention fix)
|
|
24
|
+
const targetContentType = strapi.contentTypes[relation.target];
|
|
25
|
+
const targetSupportsDraftPublish = targetContentType?.options?.draftAndPublish || false;
|
|
26
|
+
if (!targetSupportsDraftPublish) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
// Find entries with publication state mismatches
|
|
30
|
+
const ghostEntries = await findPublicationStateMismatches(db, joinTableName, relation, targetModel, sourceModel);
|
|
31
|
+
if (ghostEntries.length === 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
// Remove ghost entries
|
|
35
|
+
await db.connection(joinTableName).whereIn('id', ghostEntries).del();
|
|
36
|
+
db.logger.debug(`Removed ${ghostEntries.length} ghost relations with publication state mismatches from ${joinTableName}`);
|
|
37
|
+
return ghostEntries.length;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
40
|
+
db.logger.error(`Failed to clean join table "${joinTableName}": ${errorMessage}`);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const findContentTypeParentForComponentInstance = async (componentSchema, componentId)=>{
|
|
45
|
+
// Get the parent schemas that could contain this component
|
|
46
|
+
const parentSchemas = components.getParentSchemasForComponent(componentSchema);
|
|
47
|
+
if (parentSchemas.length === 0) {
|
|
48
|
+
// No potential parents
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// Find the actual parent for THIS specific component instance
|
|
52
|
+
const parent = await components.findComponentParent(componentSchema, componentId, parentSchemas);
|
|
53
|
+
if (!parent) {
|
|
54
|
+
// No parent found for this component instance
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (strapi.components[parent.uid]) {
|
|
58
|
+
// If the parent is a component, we need to check its parents recursively
|
|
59
|
+
const parentComponentSchema = strapi.components[parent.uid];
|
|
60
|
+
return findContentTypeParentForComponentInstance(parentComponentSchema, parent.parentId);
|
|
61
|
+
}
|
|
62
|
+
if (strapi.contentTypes[parent.uid]) {
|
|
63
|
+
// Found a content type parent
|
|
64
|
+
return parent;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Finds join table entries with publication state mismatches
|
|
70
|
+
* Uses existing component parent detection from document service
|
|
71
|
+
*/ const findPublicationStateMismatches = async (db, joinTableName, relation, targetModel, sourceModel)=>{
|
|
72
|
+
try {
|
|
73
|
+
// Get join column names using proper functions (addressing PR feedback)
|
|
74
|
+
const sourceColumn = relation.joinTable.joinColumn.name;
|
|
75
|
+
const targetColumn = relation.joinTable.inverseJoinColumn.name;
|
|
76
|
+
// Get all join entries with their target entities
|
|
77
|
+
const query = db.connection(joinTableName).select(`${joinTableName}.id as join_id`, `${joinTableName}.${sourceColumn} as source_id`, `${joinTableName}.${targetColumn} as target_id`, `${targetModel.tableName}.published_at as target_published_at`).leftJoin(targetModel.tableName, `${joinTableName}.${targetColumn}`, `${targetModel.tableName}.id`);
|
|
78
|
+
const joinEntries = await query;
|
|
79
|
+
// Group by source_id to find duplicates pointing to draft/published versions of same entity
|
|
80
|
+
const entriesBySource = {};
|
|
81
|
+
for (const entry of joinEntries){
|
|
82
|
+
const sourceId = entry.source_id;
|
|
83
|
+
if (!entriesBySource[sourceId]) {
|
|
84
|
+
entriesBySource[sourceId] = [];
|
|
85
|
+
}
|
|
86
|
+
entriesBySource[sourceId].push(entry);
|
|
87
|
+
}
|
|
88
|
+
const ghostEntries = [];
|
|
89
|
+
// Check if this is a join table (ends with _lnk)
|
|
90
|
+
const isRelationJoinTable = joinTableName.endsWith('_lnk');
|
|
91
|
+
const isComponentModel = !sourceModel.uid?.startsWith('api::') && !sourceModel.uid?.startsWith('plugin::') && sourceModel.uid?.includes('.');
|
|
92
|
+
// Check for draft/publish inconsistencies
|
|
93
|
+
for (const [sourceId, entries] of Object.entries(entriesBySource)){
|
|
94
|
+
// Skip entries with single relations
|
|
95
|
+
if (entries.length <= 1) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// For component join tables, check if THIS specific component instance's parent supports D&P
|
|
99
|
+
if (isRelationJoinTable && isComponentModel) {
|
|
100
|
+
try {
|
|
101
|
+
const componentSchema = strapi.components[sourceModel.uid];
|
|
102
|
+
if (!componentSchema) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const parent = await findContentTypeParentForComponentInstance(componentSchema, sourceId);
|
|
106
|
+
if (!parent) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// Check if THIS component instance's parent supports draft/publish
|
|
110
|
+
const parentContentType = strapi.contentTypes[parent.uid];
|
|
111
|
+
if (!parentContentType?.options?.draftAndPublish) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// If we reach here, this component instance's parent DOES support D&P
|
|
115
|
+
// Continue to process this component instance for ghost relations
|
|
116
|
+
} catch (error) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Find ghost relations (same logic as original but with improved parent checking)
|
|
121
|
+
for (const entry of entries){
|
|
122
|
+
if (entry.target_published_at === null) {
|
|
123
|
+
// This is a draft target - find its published version
|
|
124
|
+
const draftTarget = await db.connection(targetModel.tableName).select('document_id').where('id', entry.target_id).first();
|
|
125
|
+
if (draftTarget) {
|
|
126
|
+
const publishedVersion = await db.connection(targetModel.tableName).select('id', 'document_id').where('document_id', draftTarget.document_id).whereNotNull('published_at').first();
|
|
127
|
+
if (publishedVersion) {
|
|
128
|
+
// Check if we also have a relation to the published version
|
|
129
|
+
const publishedRelation = entries.find((e)=>e.target_id === publishedVersion.id);
|
|
130
|
+
if (publishedRelation) {
|
|
131
|
+
ghostEntries.push(publishedRelation.join_id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return ghostEntries;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.cleanComponentJoinTable = cleanComponentJoinTable;
|
|
145
|
+
//# sourceMappingURL=clean-component-join-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-component-join-table.js","sources":["../../../../src/services/document-service/utils/clean-component-join-table.ts"],"sourcesContent":["import type { Database } from '@strapi/database';\nimport type { Schema } from '@strapi/types';\nimport { findComponentParent, getParentSchemasForComponent } from '../components';\n\n/**\n * Cleans ghost relations with publication state mismatches from a join table\n * Uses schema-based draft/publish checking like prevention fix\n */\nexport const cleanComponentJoinTable = async (\n db: Database,\n joinTableName: string,\n relation: any,\n sourceModel: any\n): Promise<number> => {\n try {\n // Get the target model metadata\n const targetModel = db.metadata.get(relation.target);\n if (!targetModel) {\n db.logger.debug(`Target model ${relation.target} not found, skipping ${joinTableName}`);\n return 0;\n }\n\n // Check if source supports draft/publish, if it doesnt it should contain duplicate states\n const sourceContentType = strapi.contentTypes[sourceModel.uid];\n // It could be a model, which does not have the draftAndPublish option\n const sourceSupportsDraftPublish = sourceContentType?.options?.draftAndPublish;\n\n if (sourceContentType && !sourceSupportsDraftPublish) {\n return 0;\n }\n\n // Check if target supports draft/publish using schema-based approach (like prevention fix)\n const targetContentType =\n strapi.contentTypes[relation.target as keyof typeof strapi.contentTypes];\n const targetSupportsDraftPublish = targetContentType?.options?.draftAndPublish || false;\n\n if (!targetSupportsDraftPublish) {\n return 0;\n }\n\n // Find entries with publication state mismatches\n const ghostEntries = await findPublicationStateMismatches(\n db,\n joinTableName,\n relation,\n targetModel,\n sourceModel\n );\n\n if (ghostEntries.length === 0) {\n return 0;\n }\n\n // Remove ghost entries\n await db.connection(joinTableName).whereIn('id', ghostEntries).del();\n db.logger.debug(\n `Removed ${ghostEntries.length} ghost relations with publication state mismatches from ${joinTableName}`\n );\n\n return ghostEntries.length;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n db.logger.error(`Failed to clean join table \"${joinTableName}\": ${errorMessage}`);\n return 0;\n }\n};\n\nconst findContentTypeParentForComponentInstance = async (\n componentSchema: Schema.Component,\n componentId: number | string\n): Promise<{ uid: string; table: string; parentId: number | string } | null> => {\n // Get the parent schemas that could contain this component\n const parentSchemas = getParentSchemasForComponent(componentSchema);\n if (parentSchemas.length === 0) {\n // No potential parents\n return null;\n }\n\n // Find the actual parent for THIS specific component instance\n const parent = await findComponentParent(componentSchema, componentId, parentSchemas);\n if (!parent) {\n // No parent found for this component instance\n return null;\n }\n\n if (strapi.components[parent.uid as keyof typeof strapi.components]) {\n // If the parent is a component, we need to check its parents recursively\n const parentComponentSchema = strapi.components[parent.uid as keyof typeof strapi.components];\n return findContentTypeParentForComponentInstance(parentComponentSchema, parent.parentId);\n }\n\n if (strapi.contentTypes[parent.uid as keyof typeof strapi.contentTypes]) {\n // Found a content type parent\n return parent;\n }\n\n return null;\n};\n\n/**\n * Finds join table entries with publication state mismatches\n * Uses existing component parent detection from document service\n */\nconst findPublicationStateMismatches = async (\n db: Database,\n joinTableName: string,\n relation: any,\n targetModel: any,\n sourceModel: any\n): Promise<number[]> => {\n try {\n // Get join column names using proper functions (addressing PR feedback)\n const sourceColumn = relation.joinTable.joinColumn.name;\n const targetColumn = relation.joinTable.inverseJoinColumn.name;\n\n // Get all join entries with their target entities\n const query = db\n .connection(joinTableName)\n .select(\n `${joinTableName}.id as join_id`,\n `${joinTableName}.${sourceColumn} as source_id`,\n `${joinTableName}.${targetColumn} as target_id`,\n `${targetModel.tableName}.published_at as target_published_at`\n )\n .leftJoin(\n targetModel.tableName,\n `${joinTableName}.${targetColumn}`,\n `${targetModel.tableName}.id`\n );\n\n const joinEntries = await query;\n\n // Group by source_id to find duplicates pointing to draft/published versions of same entity\n const entriesBySource: { [key: string]: any[] } = {};\n for (const entry of joinEntries) {\n const sourceId = entry.source_id;\n if (!entriesBySource[sourceId]) {\n entriesBySource[sourceId] = [];\n }\n entriesBySource[sourceId].push(entry);\n }\n\n const ghostEntries: number[] = [];\n\n // Check if this is a join table (ends with _lnk)\n const isRelationJoinTable = joinTableName.endsWith('_lnk');\n const isComponentModel =\n !sourceModel.uid?.startsWith('api::') &&\n !sourceModel.uid?.startsWith('plugin::') &&\n sourceModel.uid?.includes('.');\n\n // Check for draft/publish inconsistencies\n for (const [sourceId, entries] of Object.entries(entriesBySource)) {\n // Skip entries with single relations\n if (entries.length <= 1) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // For component join tables, check if THIS specific component instance's parent supports D&P\n if (isRelationJoinTable && isComponentModel) {\n try {\n const componentSchema = strapi.components[sourceModel.uid] as Schema.Component;\n if (!componentSchema) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const parent = await findContentTypeParentForComponentInstance(componentSchema, sourceId);\n if (!parent) {\n continue;\n }\n\n // Check if THIS component instance's parent supports draft/publish\n const parentContentType =\n strapi.contentTypes[parent.uid as keyof typeof strapi.contentTypes];\n if (!parentContentType?.options?.draftAndPublish) {\n // This component instance's parent does NOT support D&P - skip cleanup\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // If we reach here, this component instance's parent DOES support D&P\n // Continue to process this component instance for ghost relations\n } catch (error) {\n // Skip this component instance on error\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n // Find ghost relations (same logic as original but with improved parent checking)\n for (const entry of entries) {\n if (entry.target_published_at === null) {\n // This is a draft target - find its published version\n const draftTarget = await db\n .connection(targetModel.tableName)\n .select('document_id')\n .where('id', entry.target_id)\n .first();\n\n if (draftTarget) {\n const publishedVersion = await db\n .connection(targetModel.tableName)\n .select('id', 'document_id')\n .where('document_id', draftTarget.document_id)\n .whereNotNull('published_at')\n .first();\n\n if (publishedVersion) {\n // Check if we also have a relation to the published version\n const publishedRelation = entries.find((e) => e.target_id === publishedVersion.id);\n if (publishedRelation) {\n ghostEntries.push(publishedRelation.join_id);\n }\n }\n }\n }\n }\n }\n\n return ghostEntries;\n } catch (error) {\n return [];\n }\n};\n"],"names":["cleanComponentJoinTable","db","joinTableName","relation","sourceModel","targetModel","metadata","get","target","logger","debug","sourceContentType","strapi","contentTypes","uid","sourceSupportsDraftPublish","options","draftAndPublish","targetContentType","targetSupportsDraftPublish","ghostEntries","findPublicationStateMismatches","length","connection","whereIn","del","error","errorMessage","Error","message","String","findContentTypeParentForComponentInstance","componentSchema","componentId","parentSchemas","getParentSchemasForComponent","parent","findComponentParent","components","parentComponentSchema","parentId","sourceColumn","joinTable","joinColumn","name","targetColumn","inverseJoinColumn","query","select","tableName","leftJoin","joinEntries","entriesBySource","entry","sourceId","source_id","push","isRelationJoinTable","endsWith","isComponentModel","startsWith","includes","entries","Object","parentContentType","target_published_at","draftTarget","where","target_id","first","publishedVersion","document_id","whereNotNull","publishedRelation","find","e","id","join_id"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CAAAA,UAAU,CAAClB,WAAY4C,CAAAA,SAAS,EAChCD,MAAM,CAAC,MAAM,aACbmB,CAAAA,CAAAA,KAAK,CAAC,aAAeD,EAAAA,WAAAA,CAAYK,WAAW,CAC5CC,CAAAA,YAAY,CAAC,cAAA,CAAA,CACbH,KAAK,EAAA;AAER,wBAAA,IAAIC,gBAAkB,EAAA;;4BAEpB,MAAMG,iBAAAA,GAAoBX,OAAQY,CAAAA,IAAI,CAAC,CAACC,IAAMA,CAAEP,CAAAA,SAAS,KAAKE,gBAAAA,CAAiBM,EAAE,CAAA;AACjF,4BAAA,IAAIH,iBAAmB,EAAA;gCACrBrD,YAAaoC,CAAAA,IAAI,CAACiB,iBAAAA,CAAkBI,OAAO,CAAA;AAC7C;AACF;AACF;AACF;AACF;AACF;QAEA,OAAOzD,YAAAA;AACT,KAAA,CAAE,OAAOM,KAAO,EAAA;AACd,QAAA,OAAO,EAAE;AACX;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { getParentSchemasForComponent, findComponentParent } from '../components.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cleans ghost relations with publication state mismatches from a join table
|
|
5
|
+
* Uses schema-based draft/publish checking like prevention fix
|
|
6
|
+
*/ const cleanComponentJoinTable = async (db, joinTableName, relation, sourceModel)=>{
|
|
7
|
+
try {
|
|
8
|
+
// Get the target model metadata
|
|
9
|
+
const targetModel = db.metadata.get(relation.target);
|
|
10
|
+
if (!targetModel) {
|
|
11
|
+
db.logger.debug(`Target model ${relation.target} not found, skipping ${joinTableName}`);
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
// Check if source supports draft/publish, if it doesnt it should contain duplicate states
|
|
15
|
+
const sourceContentType = strapi.contentTypes[sourceModel.uid];
|
|
16
|
+
// It could be a model, which does not have the draftAndPublish option
|
|
17
|
+
const sourceSupportsDraftPublish = sourceContentType?.options?.draftAndPublish;
|
|
18
|
+
if (sourceContentType && !sourceSupportsDraftPublish) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
// Check if target supports draft/publish using schema-based approach (like prevention fix)
|
|
22
|
+
const targetContentType = strapi.contentTypes[relation.target];
|
|
23
|
+
const targetSupportsDraftPublish = targetContentType?.options?.draftAndPublish || false;
|
|
24
|
+
if (!targetSupportsDraftPublish) {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
// Find entries with publication state mismatches
|
|
28
|
+
const ghostEntries = await findPublicationStateMismatches(db, joinTableName, relation, targetModel, sourceModel);
|
|
29
|
+
if (ghostEntries.length === 0) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
// Remove ghost entries
|
|
33
|
+
await db.connection(joinTableName).whereIn('id', ghostEntries).del();
|
|
34
|
+
db.logger.debug(`Removed ${ghostEntries.length} ghost relations with publication state mismatches from ${joinTableName}`);
|
|
35
|
+
return ghostEntries.length;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
38
|
+
db.logger.error(`Failed to clean join table "${joinTableName}": ${errorMessage}`);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const findContentTypeParentForComponentInstance = async (componentSchema, componentId)=>{
|
|
43
|
+
// Get the parent schemas that could contain this component
|
|
44
|
+
const parentSchemas = getParentSchemasForComponent(componentSchema);
|
|
45
|
+
if (parentSchemas.length === 0) {
|
|
46
|
+
// No potential parents
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// Find the actual parent for THIS specific component instance
|
|
50
|
+
const parent = await findComponentParent(componentSchema, componentId, parentSchemas);
|
|
51
|
+
if (!parent) {
|
|
52
|
+
// No parent found for this component instance
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (strapi.components[parent.uid]) {
|
|
56
|
+
// If the parent is a component, we need to check its parents recursively
|
|
57
|
+
const parentComponentSchema = strapi.components[parent.uid];
|
|
58
|
+
return findContentTypeParentForComponentInstance(parentComponentSchema, parent.parentId);
|
|
59
|
+
}
|
|
60
|
+
if (strapi.contentTypes[parent.uid]) {
|
|
61
|
+
// Found a content type parent
|
|
62
|
+
return parent;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Finds join table entries with publication state mismatches
|
|
68
|
+
* Uses existing component parent detection from document service
|
|
69
|
+
*/ const findPublicationStateMismatches = async (db, joinTableName, relation, targetModel, sourceModel)=>{
|
|
70
|
+
try {
|
|
71
|
+
// Get join column names using proper functions (addressing PR feedback)
|
|
72
|
+
const sourceColumn = relation.joinTable.joinColumn.name;
|
|
73
|
+
const targetColumn = relation.joinTable.inverseJoinColumn.name;
|
|
74
|
+
// Get all join entries with their target entities
|
|
75
|
+
const query = db.connection(joinTableName).select(`${joinTableName}.id as join_id`, `${joinTableName}.${sourceColumn} as source_id`, `${joinTableName}.${targetColumn} as target_id`, `${targetModel.tableName}.published_at as target_published_at`).leftJoin(targetModel.tableName, `${joinTableName}.${targetColumn}`, `${targetModel.tableName}.id`);
|
|
76
|
+
const joinEntries = await query;
|
|
77
|
+
// Group by source_id to find duplicates pointing to draft/published versions of same entity
|
|
78
|
+
const entriesBySource = {};
|
|
79
|
+
for (const entry of joinEntries){
|
|
80
|
+
const sourceId = entry.source_id;
|
|
81
|
+
if (!entriesBySource[sourceId]) {
|
|
82
|
+
entriesBySource[sourceId] = [];
|
|
83
|
+
}
|
|
84
|
+
entriesBySource[sourceId].push(entry);
|
|
85
|
+
}
|
|
86
|
+
const ghostEntries = [];
|
|
87
|
+
// Check if this is a join table (ends with _lnk)
|
|
88
|
+
const isRelationJoinTable = joinTableName.endsWith('_lnk');
|
|
89
|
+
const isComponentModel = !sourceModel.uid?.startsWith('api::') && !sourceModel.uid?.startsWith('plugin::') && sourceModel.uid?.includes('.');
|
|
90
|
+
// Check for draft/publish inconsistencies
|
|
91
|
+
for (const [sourceId, entries] of Object.entries(entriesBySource)){
|
|
92
|
+
// Skip entries with single relations
|
|
93
|
+
if (entries.length <= 1) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// For component join tables, check if THIS specific component instance's parent supports D&P
|
|
97
|
+
if (isRelationJoinTable && isComponentModel) {
|
|
98
|
+
try {
|
|
99
|
+
const componentSchema = strapi.components[sourceModel.uid];
|
|
100
|
+
if (!componentSchema) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const parent = await findContentTypeParentForComponentInstance(componentSchema, sourceId);
|
|
104
|
+
if (!parent) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
// Check if THIS component instance's parent supports draft/publish
|
|
108
|
+
const parentContentType = strapi.contentTypes[parent.uid];
|
|
109
|
+
if (!parentContentType?.options?.draftAndPublish) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
// If we reach here, this component instance's parent DOES support D&P
|
|
113
|
+
// Continue to process this component instance for ghost relations
|
|
114
|
+
} catch (error) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Find ghost relations (same logic as original but with improved parent checking)
|
|
119
|
+
for (const entry of entries){
|
|
120
|
+
if (entry.target_published_at === null) {
|
|
121
|
+
// This is a draft target - find its published version
|
|
122
|
+
const draftTarget = await db.connection(targetModel.tableName).select('document_id').where('id', entry.target_id).first();
|
|
123
|
+
if (draftTarget) {
|
|
124
|
+
const publishedVersion = await db.connection(targetModel.tableName).select('id', 'document_id').where('document_id', draftTarget.document_id).whereNotNull('published_at').first();
|
|
125
|
+
if (publishedVersion) {
|
|
126
|
+
// Check if we also have a relation to the published version
|
|
127
|
+
const publishedRelation = entries.find((e)=>e.target_id === publishedVersion.id);
|
|
128
|
+
if (publishedRelation) {
|
|
129
|
+
ghostEntries.push(publishedRelation.join_id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return ghostEntries;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { cleanComponentJoinTable };
|
|
143
|
+
//# sourceMappingURL=clean-component-join-table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-component-join-table.mjs","sources":["../../../../src/services/document-service/utils/clean-component-join-table.ts"],"sourcesContent":["import type { Database } from '@strapi/database';\nimport type { Schema } from '@strapi/types';\nimport { findComponentParent, getParentSchemasForComponent } from '../components';\n\n/**\n * Cleans ghost relations with publication state mismatches from a join table\n * Uses schema-based draft/publish checking like prevention fix\n */\nexport const cleanComponentJoinTable = async (\n db: Database,\n joinTableName: string,\n relation: any,\n sourceModel: any\n): Promise<number> => {\n try {\n // Get the target model metadata\n const targetModel = db.metadata.get(relation.target);\n if (!targetModel) {\n db.logger.debug(`Target model ${relation.target} not found, skipping ${joinTableName}`);\n return 0;\n }\n\n // Check if source supports draft/publish, if it doesnt it should contain duplicate states\n const sourceContentType = strapi.contentTypes[sourceModel.uid];\n // It could be a model, which does not have the draftAndPublish option\n const sourceSupportsDraftPublish = sourceContentType?.options?.draftAndPublish;\n\n if (sourceContentType && !sourceSupportsDraftPublish) {\n return 0;\n }\n\n // Check if target supports draft/publish using schema-based approach (like prevention fix)\n const targetContentType =\n strapi.contentTypes[relation.target as keyof typeof strapi.contentTypes];\n const targetSupportsDraftPublish = targetContentType?.options?.draftAndPublish || false;\n\n if (!targetSupportsDraftPublish) {\n return 0;\n }\n\n // Find entries with publication state mismatches\n const ghostEntries = await findPublicationStateMismatches(\n db,\n joinTableName,\n relation,\n targetModel,\n sourceModel\n );\n\n if (ghostEntries.length === 0) {\n return 0;\n }\n\n // Remove ghost entries\n await db.connection(joinTableName).whereIn('id', ghostEntries).del();\n db.logger.debug(\n `Removed ${ghostEntries.length} ghost relations with publication state mismatches from ${joinTableName}`\n );\n\n return ghostEntries.length;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n db.logger.error(`Failed to clean join table \"${joinTableName}\": ${errorMessage}`);\n return 0;\n }\n};\n\nconst findContentTypeParentForComponentInstance = async (\n componentSchema: Schema.Component,\n componentId: number | string\n): Promise<{ uid: string; table: string; parentId: number | string } | null> => {\n // Get the parent schemas that could contain this component\n const parentSchemas = getParentSchemasForComponent(componentSchema);\n if (parentSchemas.length === 0) {\n // No potential parents\n return null;\n }\n\n // Find the actual parent for THIS specific component instance\n const parent = await findComponentParent(componentSchema, componentId, parentSchemas);\n if (!parent) {\n // No parent found for this component instance\n return null;\n }\n\n if (strapi.components[parent.uid as keyof typeof strapi.components]) {\n // If the parent is a component, we need to check its parents recursively\n const parentComponentSchema = strapi.components[parent.uid as keyof typeof strapi.components];\n return findContentTypeParentForComponentInstance(parentComponentSchema, parent.parentId);\n }\n\n if (strapi.contentTypes[parent.uid as keyof typeof strapi.contentTypes]) {\n // Found a content type parent\n return parent;\n }\n\n return null;\n};\n\n/**\n * Finds join table entries with publication state mismatches\n * Uses existing component parent detection from document service\n */\nconst findPublicationStateMismatches = async (\n db: Database,\n joinTableName: string,\n relation: any,\n targetModel: any,\n sourceModel: any\n): Promise<number[]> => {\n try {\n // Get join column names using proper functions (addressing PR feedback)\n const sourceColumn = relation.joinTable.joinColumn.name;\n const targetColumn = relation.joinTable.inverseJoinColumn.name;\n\n // Get all join entries with their target entities\n const query = db\n .connection(joinTableName)\n .select(\n `${joinTableName}.id as join_id`,\n `${joinTableName}.${sourceColumn} as source_id`,\n `${joinTableName}.${targetColumn} as target_id`,\n `${targetModel.tableName}.published_at as target_published_at`\n )\n .leftJoin(\n targetModel.tableName,\n `${joinTableName}.${targetColumn}`,\n `${targetModel.tableName}.id`\n );\n\n const joinEntries = await query;\n\n // Group by source_id to find duplicates pointing to draft/published versions of same entity\n const entriesBySource: { [key: string]: any[] } = {};\n for (const entry of joinEntries) {\n const sourceId = entry.source_id;\n if (!entriesBySource[sourceId]) {\n entriesBySource[sourceId] = [];\n }\n entriesBySource[sourceId].push(entry);\n }\n\n const ghostEntries: number[] = [];\n\n // Check if this is a join table (ends with _lnk)\n const isRelationJoinTable = joinTableName.endsWith('_lnk');\n const isComponentModel =\n !sourceModel.uid?.startsWith('api::') &&\n !sourceModel.uid?.startsWith('plugin::') &&\n sourceModel.uid?.includes('.');\n\n // Check for draft/publish inconsistencies\n for (const [sourceId, entries] of Object.entries(entriesBySource)) {\n // Skip entries with single relations\n if (entries.length <= 1) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // For component join tables, check if THIS specific component instance's parent supports D&P\n if (isRelationJoinTable && isComponentModel) {\n try {\n const componentSchema = strapi.components[sourceModel.uid] as Schema.Component;\n if (!componentSchema) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const parent = await findContentTypeParentForComponentInstance(componentSchema, sourceId);\n if (!parent) {\n continue;\n }\n\n // Check if THIS component instance's parent supports draft/publish\n const parentContentType =\n strapi.contentTypes[parent.uid as keyof typeof strapi.contentTypes];\n if (!parentContentType?.options?.draftAndPublish) {\n // This component instance's parent does NOT support D&P - skip cleanup\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // If we reach here, this component instance's parent DOES support D&P\n // Continue to process this component instance for ghost relations\n } catch (error) {\n // Skip this component instance on error\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n // Find ghost relations (same logic as original but with improved parent checking)\n for (const entry of entries) {\n if (entry.target_published_at === null) {\n // This is a draft target - find its published version\n const draftTarget = await db\n .connection(targetModel.tableName)\n .select('document_id')\n .where('id', entry.target_id)\n .first();\n\n if (draftTarget) {\n const publishedVersion = await db\n .connection(targetModel.tableName)\n .select('id', 'document_id')\n .where('document_id', draftTarget.document_id)\n .whereNotNull('published_at')\n .first();\n\n if (publishedVersion) {\n // Check if we also have a relation to the published version\n const publishedRelation = entries.find((e) => e.target_id === publishedVersion.id);\n if (publishedRelation) {\n ghostEntries.push(publishedRelation.join_id);\n }\n }\n }\n }\n }\n }\n\n return ghostEntries;\n } catch (error) {\n return [];\n }\n};\n"],"names":["cleanComponentJoinTable","db","joinTableName","relation","sourceModel","targetModel","metadata","get","target","logger","debug","sourceContentType","strapi","contentTypes","uid","sourceSupportsDraftPublish","options","draftAndPublish","targetContentType","targetSupportsDraftPublish","ghostEntries","findPublicationStateMismatches","length","connection","whereIn","del","error","errorMessage","Error","message","String","findContentTypeParentForComponentInstance","componentSchema","componentId","parentSchemas","getParentSchemasForComponent","parent","findComponentParent","components","parentComponentSchema","parentId","sourceColumn","joinTable","joinColumn","name","targetColumn","inverseJoinColumn","query","select","tableName","leftJoin","joinEntries","entriesBySource","entry","sourceId","source_id","push","isRelationJoinTable","endsWith","isComponentModel","startsWith","includes","entries","Object","parentContentType","target_published_at","draftTarget","where","target_id","first","publishedVersion","document_id","whereNotNull","publishedRelation","find","e","id","join_id"],"mappings":";;AAIA;;;AAGC,IACYA,MAAAA,uBAAAA,GAA0B,OACrCC,EAAAA,EACAC,eACAC,QACAC,EAAAA,WAAAA,GAAAA;IAEA,IAAI;;AAEF,QAAA,MAAMC,cAAcJ,EAAGK,CAAAA,QAAQ,CAACC,GAAG,CAACJ,SAASK,MAAM,CAAA;AACnD,QAAA,IAAI,CAACH,WAAa,EAAA;AAChBJ,YAAAA,EAAAA,CAAGQ,MAAM,CAACC,KAAK,CAAC,CAAC,aAAa,EAAEP,QAAAA,CAASK,MAAM,CAAC,qBAAqB,EAAEN,cAAc,CAAC,CAAA;YACtF,OAAO,CAAA;AACT;;AAGA,QAAA,MAAMS,oBAAoBC,MAAOC,CAAAA,YAAY,CAACT,WAAAA,CAAYU,GAAG,CAAC;;QAE9D,MAAMC,0BAAAA,GAA6BJ,mBAAmBK,OAASC,EAAAA,eAAAA;QAE/D,IAAIN,iBAAAA,IAAqB,CAACI,0BAA4B,EAAA;YACpD,OAAO,CAAA;AACT;;AAGA,QAAA,MAAMG,oBACJN,MAAOC,CAAAA,YAAY,CAACV,QAAAA,CAASK,MAAM,CA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
|
3
|
+
"version": "5.30.0",
|
|
4
4
|
"description": "Core of Strapi",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"@koa/cors": "5.0.0",
|
|
57
57
|
"@koa/router": "12.0.2",
|
|
58
58
|
"@paralleldrive/cuid2": "2.2.2",
|
|
59
|
-
"@strapi/admin": "5.
|
|
60
|
-
"@strapi/database": "5.
|
|
61
|
-
"@strapi/generators": "5.
|
|
62
|
-
"@strapi/logger": "5.
|
|
63
|
-
"@strapi/permissions": "5.
|
|
64
|
-
"@strapi/types": "5.
|
|
65
|
-
"@strapi/typescript-utils": "5.
|
|
66
|
-
"@strapi/utils": "5.
|
|
59
|
+
"@strapi/admin": "5.30.0",
|
|
60
|
+
"@strapi/database": "5.30.0",
|
|
61
|
+
"@strapi/generators": "5.30.0",
|
|
62
|
+
"@strapi/logger": "5.30.0",
|
|
63
|
+
"@strapi/permissions": "5.30.0",
|
|
64
|
+
"@strapi/types": "5.30.0",
|
|
65
|
+
"@strapi/typescript-utils": "5.30.0",
|
|
66
|
+
"@strapi/utils": "5.30.0",
|
|
67
67
|
"@vercel/stega": "0.1.2",
|
|
68
68
|
"bcryptjs": "2.4.3",
|
|
69
69
|
"boxen": "5.1.2",
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
"@types/node": "18.19.24",
|
|
132
132
|
"@types/node-schedule": "2.1.7",
|
|
133
133
|
"@types/statuses": "2.0.1",
|
|
134
|
-
"eslint-config-custom": "5.
|
|
134
|
+
"eslint-config-custom": "5.30.0",
|
|
135
135
|
"supertest": "6.3.3",
|
|
136
|
-
"tsconfig": "5.
|
|
136
|
+
"tsconfig": "5.30.0"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": ">=18.0.0 <=22.x.x",
|