@strapi/core 0.0.0-experimental.020096d91bef5bab5a6c32b4216da5aeb9383d33 → 0.0.0-experimental.19b15f2f555510eb5507d89fcaf5efa172002608
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +3 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +3 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +1 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +1 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +2 -2
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +2 -2
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/migrations/draft-publish.d.ts +17 -0
- package/dist/migrations/draft-publish.d.ts.map +1 -0
- package/dist/migrations/draft-publish.js +59 -0
- package/dist/migrations/draft-publish.js.map +1 -0
- package/dist/migrations/draft-publish.mjs +59 -0
- package/dist/migrations/draft-publish.mjs.map +1 -0
- package/dist/services/document-service/repository.js +1 -1
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +1 -1
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.js +1 -1
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs +1 -1
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/entity-service/params.d.ts +1 -1
- package/dist/services/entity-service/params.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/Strapi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strapi.d.ts","sourceRoot":"","sources":["../src/Strapi.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EACV,MAAM,IAAI,OAAO,EACjB,MAAM,EACN,aAAa,EACb,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,MAAM,EACN,MAAM,EACN,MAAM,EACP,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,OAAO,MAAM,WAAW,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAA4B,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAa/E,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Strapi.d.ts","sourceRoot":"","sources":["../src/Strapi.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EACV,MAAM,IAAI,OAAO,EACjB,MAAM,EACN,aAAa,EACb,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,K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I,CAAC,QAAQ,SAAI,GAAG,KAAK;IAWzB,qBAAqB;IAQf,QAAQ;IAwBR,SAAS;IA6ET,IAAI;IASJ,aAAa;IAWb,sBAAsB,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS;IAiBhF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;IAarD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM;CAG7B;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,UAAU,IAAI;IACZ,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IACnC,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;CACzB;AAQD,QAAA,MAAM,IAAI,EAAE,IAAoD,CAAC;AAEjE,eAAe,IAAI,CAAC"}
|
package/dist/Strapi.js
CHANGED
|
@@ -53,6 +53,7 @@ const index$1 = require("./services/content-api/index.js");
|
|
|
53
53
|
const dynamicZones = require("./services/utils/dynamic-zones.js");
|
|
54
54
|
const features = require("./services/features.js");
|
|
55
55
|
const index$a = require("./services/document-service/index.js");
|
|
56
|
+
const draftPublish = require("./migrations/draft-publish.js");
|
|
56
57
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
57
58
|
const path__default = /* @__PURE__ */ _interopDefault(path);
|
|
58
59
|
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
@@ -321,6 +322,8 @@ class Strapi extends container.Container {
|
|
|
321
322
|
registerInternalHooks() {
|
|
322
323
|
this.get("hooks").set("strapi::content-types.beforeSync", strapiUtils.hooks.createAsyncParallelHook());
|
|
323
324
|
this.get("hooks").set("strapi::content-types.afterSync", strapiUtils.hooks.createAsyncParallelHook());
|
|
325
|
+
this.hook("strapi::content-types.beforeSync").register(draftPublish.disable);
|
|
326
|
+
this.hook("strapi::content-types.afterSync").register(draftPublish.enable);
|
|
324
327
|
}
|
|
325
328
|
async register() {
|
|
326
329
|
await index$7.loadApplicationContext(this);
|
package/dist/Strapi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strapi.js","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n EntityService,\n Documents,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport * as registries from './registries';\nimport * as loaders from './loaders';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\n\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi extends Container implements StrapiI {\n server: Server;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n documents?: Documents.Service;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n // @ts-expect-error - Assigned in constructor\n ee: StrapiI['ee'];\n\n constructor(opts: StrapiOptions = {}) {\n super();\n\n utils.destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.add('config', registries.config(appConfig, this))\n .add('content-types', registries.contentTypes())\n .add('components', registries.components())\n .add('services', registries.services(this))\n .add('policies', registries.policies())\n .add('middlewares', registries.middlewares())\n .add('hooks', registries.hooks())\n .add('controllers', registries.controllers(this))\n .add('modules', registries.modules(this))\n .add('plugins', registries.plugins(this))\n .add('custom-fields', registries.customFields(this))\n .add('apis', registries.apis(this))\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators())\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('models', registries.models());\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = utils.createStartupLogger(this);\n\n // We will continue to support 'logger' to prevent unnecessary deprecations but prioritize server.logger.config\n // So we find: server.logger.config || logger || 'info'\n const logLevel = this.config.get(\n 'server.logger.config',\n this.config.get('logger', { level: 'info' })\n );\n this.log = createLogger(logLevel);\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = utils.createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n utils.createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n utils.ee.init(this.dirs.app.root, this.log);\n return utils.ee.isEE;\n },\n configurable: false,\n });\n\n Object.defineProperty<Strapi>(this, 'ee', {\n get: () => utils.ee,\n configurable: false,\n });\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: Common.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: Common.UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Shared.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, Common.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Common.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 // api(name) {\n // return this.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.get('apis').getAll();\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 async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(utils.LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n registerInternalHooks() {\n this.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n this.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n }\n\n async register() {\n await loaders.loadApplicationContext(this);\n\n this.get('models').add(coreStoreModel).add(webhookModel);\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const models = [\n ...utils.transformContentTypesToModels([\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ]),\n ...this.get('models').get(),\n ];\n\n this.db = await Database.init({ ...this.config.get('database'), models });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n this.documents = createDocumentService(this);\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await utils.ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): StrapiI;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}): StrapiI => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["path","Container","utils.destroyOnSignal","loadConfiguration","registries.config","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.sanitizers","registries.validators","createContentAPI","createAuth","registries.models","utils.getDirs","createServer","createStrapiFs","createEventHub","utils.createStartupLogger","createLogger","createCronService","createTelemetry","createCustomFields","utils.createStrapiFetch","createFeaturesService","utils.createUpdateNotifier","utils.ee","utils.LIFECYCLES","_","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","hooks","loaders.loadApplicationContext","coreStoreModel","webhookModel","createWebhookRunner","utils.convertCustomFieldType","models","utils.transformContentTypesToModels","Database","createCoreStore","createWebhookStore","entityValidator","createEntityService","createDocumentService","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAASA,cAAA,QAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAUA,cAAA,QAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;AAAA,IACzB;AAAA,EACF;AAEO,SAAA,eAA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,WAAW,UAAU;AACzB,WAAA,eAAe,IAAI,OAAO;AAAA,IACjC;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB,eAAqD;AAEhF,UAAM,KAAK,IAAI,SAAS,EAAE,aAAa,EAAE;AAGzC,UAAM,yBAAyB,KAAK,SAAS,KAAK,MAAM,aAAa;AACjE,QAAAqB,IAAAA,WAAW,sBAAsB,GAAG;AACtC,YAAM,uBAAuB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC/C;AAGA,UAAM,wBAAwB,KAAK,OAAO,KAAK,IAAI,aAAa;AAC5D,QAAAA,IAAAA,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SACE,KACmD;AAC/C,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAA6B;AAAA,IACxD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAA2B;AAAA,IACpD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAgB;AACjD,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"Strapi.js","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n EntityService,\n Documents,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport * as registries from './registries';\nimport * as loaders from './loaders';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\n\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi extends Container implements StrapiI {\n server: Server;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n documents?: Documents.Service;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n // @ts-expect-error - Assigned in constructor\n ee: StrapiI['ee'];\n\n constructor(opts: StrapiOptions = {}) {\n super();\n\n utils.destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.add('config', registries.config(appConfig, this))\n .add('content-types', registries.contentTypes())\n .add('components', registries.components())\n .add('services', registries.services(this))\n .add('policies', registries.policies())\n .add('middlewares', registries.middlewares())\n .add('hooks', registries.hooks())\n .add('controllers', registries.controllers(this))\n .add('modules', registries.modules(this))\n .add('plugins', registries.plugins(this))\n .add('custom-fields', registries.customFields(this))\n .add('apis', registries.apis(this))\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators())\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('models', registries.models());\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = utils.createStartupLogger(this);\n\n // We will continue to support 'logger' to prevent unnecessary deprecations but prioritize server.logger.config\n // So we find: server.logger.config || logger || 'info'\n const logLevel = this.config.get(\n 'server.logger.config',\n this.config.get('logger', { level: 'info' })\n );\n this.log = createLogger(logLevel);\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = utils.createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n utils.createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n utils.ee.init(this.dirs.app.root, this.log);\n return utils.ee.isEE;\n },\n configurable: false,\n });\n\n Object.defineProperty<Strapi>(this, 'ee', {\n get: () => utils.ee,\n configurable: false,\n });\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: Common.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: Common.UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Shared.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, Common.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Common.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 // api(name) {\n // return this.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.get('apis').getAll();\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 async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(utils.LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n registerInternalHooks() {\n this.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n this.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await loaders.loadApplicationContext(this);\n\n this.get('models').add(coreStoreModel).add(webhookModel);\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const models = [\n ...utils.transformContentTypesToModels([\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ]),\n ...this.get('models').get(),\n ];\n\n this.db = await Database.init({ ...this.config.get('database'), models });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n this.documents = createDocumentService(this);\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await utils.ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): StrapiI;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}): StrapiI => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["path","Container","utils.destroyOnSignal","loadConfiguration","registries.config","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.sanitizers","registries.validators","createContentAPI","createAuth","registries.models","utils.getDirs","createServer","createStrapiFs","createEventHub","utils.createStartupLogger","createLogger","createCronService","createTelemetry","createCustomFields","utils.createStrapiFetch","createFeaturesService","utils.createUpdateNotifier","utils.ee","utils.LIFECYCLES","_","getNumberOfDynamicZones","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","hooks","draftAndPublishSync.disable","draftAndPublishSync.enable","loaders.loadApplicationContext","coreStoreModel","webhookModel","createWebhookRunner","utils.convertCustomFieldType","models","utils.transformContentTypesToModels","Database","createCoreStore","createWebhookStore","entityValidator","createEntityService","createDocumentService","isFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAASA,cAAA,QAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAUA,cAAA,QAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;AAAA,IACzB;AAAA,EACF;AAEO,SAAA,eAAe,QAAQ,cAAc;AAAA,IAC1C,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,IAAI,OAAO;AAET,UAAI,MAAM,eAAe,SAAS,UAAU,MAAM;AAChD,cAAM,gBAAgB;AAAA,MACxB;AACA,YAAM,aAAa;AAAA,IACrB;AAAA,IACA,MAAM;AACJ,aAAO,MAAM;AAAA,IACf;AAAA,EAAA,CACD;AAED,SAAO,cAAc;AACrB,SAAO,aAAa;AAEb,SAAA;AACT;AAIA,MAAM,eAAeC,UAAAA,UAA6B;AAAA,EAChD;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,E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,WAAW,qBAAqB,GAAG;AACrC,YAAM,sBAAsB,EAAE,QAAQ,KAAM,CAAA;AAAA,IAC9C;AAAA,EACF;AAAA,EAIA,SACE,KACmD;AAC/C,QAAA,OAAO,KAAK,cAAc;AACrB,aAAA,KAAK,aAAa,GAA6B;AAAA,IACxD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAA2B;AAAA,IACpD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAgB;AACjD,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;;"}
|
package/dist/Strapi.mjs
CHANGED
|
@@ -53,6 +53,7 @@ import createContentAPI from "./services/content-api/index.mjs";
|
|
|
53
53
|
import getNumberOfDynamicZones from "./services/utils/dynamic-zones.mjs";
|
|
54
54
|
import { createFeaturesService } from "./services/features.mjs";
|
|
55
55
|
import { createDocumentService } from "./services/document-service/index.mjs";
|
|
56
|
+
import { disable as disableDraftAndPublish, enable as enableDraftAndPublish } from "./migrations/draft-publish.mjs";
|
|
56
57
|
const resolveWorkingDirectories = (opts) => {
|
|
57
58
|
const cwd = process.cwd();
|
|
58
59
|
const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;
|
|
@@ -318,6 +319,8 @@ class Strapi extends Container {
|
|
|
318
319
|
registerInternalHooks() {
|
|
319
320
|
this.get("hooks").set("strapi::content-types.beforeSync", hooks.createAsyncParallelHook());
|
|
320
321
|
this.get("hooks").set("strapi::content-types.afterSync", hooks.createAsyncParallelHook());
|
|
322
|
+
this.hook("strapi::content-types.beforeSync").register(disableDraftAndPublish);
|
|
323
|
+
this.hook("strapi::content-types.afterSync").register(enableDraftAndPublish);
|
|
321
324
|
}
|
|
322
325
|
async register() {
|
|
323
326
|
await loadApplicationContext(this);
|
package/dist/Strapi.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strapi.mjs","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n EntityService,\n Documents,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport * as registries from './registries';\nimport * as loaders from './loaders';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\n\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi extends Container implements StrapiI {\n server: Server;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n documents?: Documents.Service;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n // @ts-expect-error - Assigned in constructor\n ee: StrapiI['ee'];\n\n constructor(opts: StrapiOptions = {}) {\n super();\n\n utils.destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.add('config', registries.config(appConfig, this))\n .add('content-types', registries.contentTypes())\n .add('components', registries.components())\n .add('services', registries.services(this))\n .add('policies', registries.policies())\n .add('middlewares', registries.middlewares())\n .add('hooks', registries.hooks())\n .add('controllers', registries.controllers(this))\n .add('modules', registries.modules(this))\n .add('plugins', registries.plugins(this))\n .add('custom-fields', registries.customFields(this))\n .add('apis', registries.apis(this))\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators())\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('models', registries.models());\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = utils.createStartupLogger(this);\n\n // We will continue to support 'logger' to prevent unnecessary deprecations but prioritize server.logger.config\n // So we find: server.logger.config || logger || 'info'\n const logLevel = this.config.get(\n 'server.logger.config',\n this.config.get('logger', { level: 'info' })\n );\n this.log = createLogger(logLevel);\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = utils.createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n utils.createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n utils.ee.init(this.dirs.app.root, this.log);\n return utils.ee.isEE;\n },\n configurable: false,\n });\n\n Object.defineProperty<Strapi>(this, 'ee', {\n get: () => utils.ee,\n configurable: false,\n });\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: Common.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: Common.UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Shared.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, Common.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Common.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 // api(name) {\n // return this.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.get('apis').getAll();\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 async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(utils.LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n registerInternalHooks() {\n this.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n this.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n }\n\n async register() {\n await loaders.loadApplicationContext(this);\n\n this.get('models').add(coreStoreModel).add(webhookModel);\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const models = [\n ...utils.transformContentTypesToModels([\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ]),\n ...this.get('models').get(),\n ];\n\n this.db = await Database.init({ ...this.config.get('database'), models });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n this.documents = createDocumentService(this);\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await utils.ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): StrapiI;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}): StrapiI => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["utils.destroyOnSignal","registries.config","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.sanitizers","registries.validators","createAuth","registries.models","utils.getDirs","utils.createStartupLogger","createTelemetry","requestContext","utils.createStrapiFetch","utils.createUpdateNotifier","utils.ee","utils.LIFECYCLES","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","loaders.loadApplicationContext","utils.convertCustomFieldType","utils.transformContentTypesToModels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAU,KAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;AAAA,IACzB;AAAA,EACF;AAEO,SAAA,eAAe,QAAQ,cAAc;AAAA,IAC1C,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,IAAI,OAAO;AAET,UAAI,MAAM,eAAe,SAAS,UAAU,MAAM;AAChD,cAAM,gBAAgB;AAAA,MACxB;AACA,YAAM,aAAa;AAAA,IACrB;AAAA,IACA,MAAM;AACJ,aAAO,MAAM;AAAA,IACf;AAAA,EAAA,CACD;AAED,SAAO,cAAc;AACrB,SAAO,aAAa;AAEb,SAAA;AACT;AAIA,MAAM,eAAe,UAA6B;AAAA,EAChD;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;A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AAAA,IACxD;AAEI,QAAA,OAAO,KAAK,YAAY;AACnB,aAAA,KAAK,WAAW,GAA2B;AAAA,IACpD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KAAwB;AACrB,WAAA,KAAK,GAAI,MAAM,GAAG;AAAA,EAC3B;AACF;AAeA,MAAM,SAAS,CAAC,UAAyB,OAAgB;AACjD,QAAA,SAAS,IAAI,OAAO,OAAO;AACjC,SAAO,SAAS;AACT,SAAA;AACT;AAEA,MAAM,OAAa,OAAO,OAAO,QAAQ,EAAE,WAAW,QAAS,CAAA;"}
|
|
1
|
+
{"version":3,"file":"Strapi.mjs","sources":["../src/Strapi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\nimport path from 'path';\nimport _ from 'lodash';\nimport { isFunction } from 'lodash/fp';\nimport { Logger, createLogger } from '@strapi/logger';\nimport { Database } from '@strapi/database';\nimport { hooks } from '@strapi/utils';\nimport type {\n Strapi as StrapiI,\n Server,\n EntityService,\n Documents,\n EventHub,\n StartupLogger,\n CronService,\n WebhookStore,\n CoreStore,\n TelemetryService,\n RequestContext,\n CustomFields,\n Fetch,\n StrapiFS,\n StrapiDirectories,\n Reloader,\n EntityValidator,\n Common,\n Shared,\n Schema,\n} from '@strapi/types';\n\nimport loadConfiguration from './configuration';\n\nimport * as factories from './factories';\nimport compile from './compile';\n\nimport * as utils from './utils';\nimport * as registries from './registries';\nimport * as loaders from './loaders';\nimport { Container } from './container';\nimport createStrapiFs from './services/fs';\nimport createEventHub from './services/event-hub';\nimport { createServer } from './services/server';\nimport createWebhookRunner, { WebhookRunner } from './services/webhook-runner';\nimport { webhookModel, createWebhookStore } from './services/webhook-store';\nimport { createCoreStore, coreStoreModel } from './services/core-store';\nimport createEntityService from './services/entity-service';\n\nimport createCronService from './services/cron';\nimport entityValidator from './services/entity-validator';\nimport createTelemetry from './services/metrics';\nimport requestContext from './services/request-context';\nimport createAuth from './services/auth';\nimport createCustomFields from './services/custom-fields';\nimport createContentAPI from './services/content-api';\nimport getNumberOfDynamicZones from './services/utils/dynamic-zones';\nimport { FeaturesService, createFeaturesService } from './services/features';\nimport { createDocumentService } from './services/document-service';\n\n// TODO: move somewhere else\nimport * as draftAndPublishSync from './migrations/draft-publish';\n\n/**\n * Resolve the working directories based on the instance options.\n *\n * Behavior:\n * - `appDir` is the directory where Strapi will write every file (schemas, generated APIs, controllers or services)\n * - `distDir` is the directory where Strapi will read configurations, schemas and any compiled code\n *\n * Default values:\n * - If `appDir` is `undefined`, it'll be set to `process.cwd()`\n * - If `distDir` is `undefined`, it'll be set to `appDir`\n */\nconst resolveWorkingDirectories = (opts: { appDir?: string; distDir?: string }) => {\n const cwd = process.cwd();\n\n const appDir = opts.appDir ? path.resolve(cwd, opts.appDir) : cwd;\n const distDir = opts.distDir ? path.resolve(cwd, opts.distDir) : appDir;\n\n return { app: appDir, dist: distDir };\n};\n\nconst reloader = (strapi: Strapi) => {\n const state = {\n shouldReload: 0,\n isWatching: true,\n };\n\n function reload() {\n if (state.shouldReload > 0) {\n // Reset the reloading state\n state.shouldReload -= 1;\n reload.isReloading = false;\n return;\n }\n\n if (strapi.config.get('autoReload')) {\n process.send?.('reload');\n }\n }\n\n Object.defineProperty(reload, 'isWatching', {\n configurable: true,\n enumerable: true,\n set(value) {\n // Special state when the reloader is disabled temporarly (see GraphQL plugin example).\n if (state.isWatching === false && value === true) {\n state.shouldReload += 1;\n }\n state.isWatching = value;\n },\n get() {\n return state.isWatching;\n },\n });\n\n reload.isReloading = false;\n reload.isWatching = true;\n\n return reload;\n};\n\nexport type LoadedStrapi = Required<Strapi>;\n\nclass Strapi extends Container implements StrapiI {\n server: Server;\n\n log: Logger;\n\n fs: StrapiFS;\n\n eventHub: EventHub;\n\n startupLogger: StartupLogger;\n\n cron: CronService;\n\n webhookRunner?: WebhookRunner;\n\n webhookStore?: WebhookStore;\n\n store?: CoreStore;\n\n entityValidator?: EntityValidator;\n\n entityService?: EntityService.EntityService;\n\n documents?: Documents.Service;\n\n telemetry: TelemetryService;\n\n requestContext: RequestContext;\n\n customFields: CustomFields.CustomFields;\n\n fetch: Fetch;\n\n dirs: StrapiDirectories;\n\n admin?: Common.Module;\n\n isLoaded: boolean;\n\n db?: Database;\n\n app: any;\n\n EE?: boolean;\n\n reload: Reloader;\n\n features: FeaturesService;\n\n // @ts-expect-error - Assigned in constructor\n ee: StrapiI['ee'];\n\n constructor(opts: StrapiOptions = {}) {\n super();\n\n utils.destroyOnSignal(this);\n\n const rootDirs = resolveWorkingDirectories(opts);\n\n // Load the app configuration from the dist directory\n const appConfig = loadConfiguration(rootDirs, opts);\n\n // Instantiate the Strapi container\n this.add('config', registries.config(appConfig, this))\n .add('content-types', registries.contentTypes())\n .add('components', registries.components())\n .add('services', registries.services(this))\n .add('policies', registries.policies())\n .add('middlewares', registries.middlewares())\n .add('hooks', registries.hooks())\n .add('controllers', registries.controllers(this))\n .add('modules', registries.modules(this))\n .add('plugins', registries.plugins(this))\n .add('custom-fields', registries.customFields(this))\n .add('apis', registries.apis(this))\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators())\n .add('content-api', createContentAPI(this))\n .add('auth', createAuth())\n .add('models', registries.models());\n\n // Create a mapping of every useful directory (for the app, dist and static directories)\n this.dirs = utils.getDirs(rootDirs, { strapi: this });\n\n // Strapi state management variables\n this.isLoaded = false;\n this.reload = reloader(this);\n\n // Instantiate the Koa app & the HTTP server\n this.server = createServer(this);\n\n // Strapi utils instantiation\n this.fs = createStrapiFs(this);\n this.eventHub = createEventHub();\n this.startupLogger = utils.createStartupLogger(this);\n\n // We will continue to support 'logger' to prevent unnecessary deprecations but prioritize server.logger.config\n // So we find: server.logger.config || logger || 'info'\n const logLevel = this.config.get(\n 'server.logger.config',\n this.config.get('logger', { level: 'info' })\n );\n this.log = createLogger(logLevel);\n this.cron = createCronService();\n this.telemetry = createTelemetry(this);\n this.requestContext = requestContext;\n this.customFields = createCustomFields(this);\n this.fetch = utils.createStrapiFetch(this);\n this.features = createFeaturesService(this);\n\n utils.createUpdateNotifier(this).notify();\n\n Object.defineProperty<Strapi>(this, 'EE', {\n get: () => {\n utils.ee.init(this.dirs.app.root, this.log);\n return utils.ee.isEE;\n },\n configurable: false,\n });\n\n Object.defineProperty<Strapi>(this, 'ee', {\n get: () => utils.ee,\n configurable: false,\n });\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: Common.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: Common.UID.Controller) {\n return this.get('controllers').get(uid);\n }\n\n get contentTypes(): Shared.ContentTypes {\n return this.get('content-types').getAll();\n }\n\n contentType(name: Common.UID.ContentType) {\n return this.get('content-types').get(name);\n }\n\n get components(): Shared.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, Common.Plugin> {\n return this.get('plugins').getAll();\n }\n\n plugin(name: string): Common.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 // api(name) {\n // return this.get('apis').get(name);\n // }\n\n get api(): Record<string, Common.Module> {\n return this.get('apis').getAll();\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 async destroy() {\n await this.server.destroy();\n await this.runLifecyclesFunctions(utils.LIFECYCLES.DESTROY);\n\n this.eventHub.destroy();\n\n await this.db?.destroy();\n\n this.telemetry.destroy();\n this.cron.destroy();\n\n process.removeAllListeners();\n\n // @ts-expect-error: Allow clean delete of global.strapi to allow re-instanciation\n delete global.strapi;\n }\n\n sendStartupTelemetry() {\n // Emit started event.\n // do not await to avoid slower startup\n // This event is anonymous\n this.telemetry\n .send('didStartServer', {\n groupProperties: {\n database: this.config.get('database.connection.client'),\n plugins: Object.keys(this.plugins),\n numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n numberOfComponents: _.size(this.components),\n numberOfDynamicZones: getNumberOfDynamicZones(),\n numberOfCustomControllers: Object.values<Common.Controller>(this.controllers).filter(\n // TODO: Fix this at the content API loader level to prevent future types issues\n (controller) => controller !== undefined && factories.isCustomController(controller)\n ).length,\n environment: this.config.environment,\n // TODO: to add back\n // providers: this.config.installedProviders,\n },\n })\n .catch(this.log.error);\n }\n\n async openAdmin({ isInitialized }: { isInitialized: boolean }) {\n const shouldOpenAdmin =\n this.config.get('environment') === 'development' &&\n this.config.get('admin.autoOpen', true) !== false;\n\n if (shouldOpenAdmin && !isInitialized) {\n try {\n await utils.openBrowser(this.config);\n this.telemetry.send('didOpenTab');\n } catch (e) {\n this.telemetry.send('didNotOpenTab');\n }\n }\n }\n\n async postListen() {\n const isInitialized = await utils.isInitialized(this);\n\n this.startupLogger.logStartupMessage({ isInitialized });\n\n this.sendStartupTelemetry();\n this.openAdmin({ isInitialized });\n }\n\n /**\n * Add behaviors to the server\n */\n async listen() {\n return new Promise<void>((resolve, reject) => {\n const onListen = async () => {\n try {\n await this.postListen();\n\n resolve();\n } catch (error) {\n reject(error);\n }\n };\n\n const listenSocket = this.config.get('server.socket');\n\n if (listenSocket) {\n this.server.listen(listenSocket, onListen);\n } else {\n const { host, port } = this.config.get('server');\n\n this.server.listen(port, host, onListen);\n }\n });\n }\n\n stopWithError(err: unknown, customMessage?: string): never {\n this.log.debug(`⛔️ Server wasn't able to start properly.`);\n if (customMessage) {\n this.log.error(customMessage);\n }\n\n this.log.error(err);\n return this.stop();\n }\n\n stop(exitCode = 1): never {\n this.destroy();\n\n if (this.config.get('autoReload')) {\n process.send?.('stop');\n }\n\n // Kill process\n process.exit(exitCode);\n }\n\n registerInternalHooks() {\n this.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n this.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n this.hook('strapi::content-types.beforeSync').register(draftAndPublishSync.disable);\n this.hook('strapi::content-types.afterSync').register(draftAndPublishSync.enable);\n }\n\n async register() {\n await loaders.loadApplicationContext(this);\n\n this.get('models').add(coreStoreModel).add(webhookModel);\n\n // init webhook runner\n this.webhookRunner = createWebhookRunner({\n eventHub: this.eventHub,\n logger: this.log,\n configuration: this.config.get('server.webhooks', {}),\n fetch: this.fetch,\n });\n\n this.registerInternalHooks();\n\n this.telemetry.register();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.REGISTER);\n // NOTE: Swap type customField for underlying data type\n utils.convertCustomFieldType(this);\n\n return this;\n }\n\n async bootstrap() {\n const models = [\n ...utils.transformContentTypesToModels([\n ...Object.values(this.contentTypes),\n ...Object.values(this.components),\n ]),\n ...this.get('models').get(),\n ];\n\n this.db = await Database.init({ ...this.config.get('database'), models });\n\n this.store = createCoreStore({ db: this.db });\n this.webhookStore = createWebhookStore({ db: this.db });\n\n this.entityValidator = entityValidator;\n this.entityService = createEntityService({\n strapi: this,\n db: this.db,\n eventHub: this.eventHub,\n entityValidator: this.entityValidator,\n });\n\n this.documents = createDocumentService(this);\n\n if (this.config.get('server.cron.enabled', true)) {\n const cronTasks = this.config.get('server.cron.tasks', {});\n this.cron.add(cronTasks);\n }\n\n this.telemetry.bootstrap();\n\n let oldContentTypes;\n if (await this.db.getSchemaConnection().hasTable(coreStoreModel.tableName)) {\n oldContentTypes = await this.store.get({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n });\n }\n\n await this.hook('strapi::content-types.beforeSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.db.schema.sync();\n\n if (this.EE) {\n await utils.ee.checkLicense({ strapi: this });\n }\n\n await this.hook('strapi::content-types.afterSync').call({\n oldContentTypes,\n contentTypes: this.contentTypes,\n });\n\n await this.store.set({\n type: 'strapi',\n name: 'content_types',\n key: 'schema',\n value: this.contentTypes,\n });\n\n await this.startWebhooks();\n\n await this.server.initMiddlewares();\n this.server.initRouting();\n\n await this.contentAPI.permissions.registerActions();\n\n await this.runLifecyclesFunctions(utils.LIFECYCLES.BOOTSTRAP);\n\n this.cron.start();\n\n return this;\n }\n\n async load() {\n await this.register();\n await this.bootstrap();\n\n this.isLoaded = true;\n\n return this as this & Required<StrapiI>;\n }\n\n async startWebhooks() {\n const webhooks = await this.webhookStore?.findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n this.webhookRunner?.add(webhook);\n }\n }\n\n async runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy') {\n // plugins\n await this.get('modules')[lifecycleName]();\n\n // admin\n const adminLifecycleFunction = this.admin && this.admin[lifecycleName];\n if (isFunction(adminLifecycleFunction)) {\n await adminLifecycleFunction({ strapi: this });\n }\n\n // user\n const userLifecycleFunction = this.app && this.app[lifecycleName];\n if (isFunction(userLifecycleFunction)) {\n await userLifecycleFunction({ strapi: this });\n }\n }\n\n getModel(uid: Common.UID.ContentType): Schema.ContentType;\n getModel(uid: Common.UID.Component): Schema.Component;\n getModel<TUID extends Common.UID.Schema>(\n uid: TUID\n ): Schema.ContentType | Schema.Component | undefined {\n if (uid in this.contentTypes) {\n return this.contentTypes[uid as Common.UID.ContentType];\n }\n\n if (uid in this.components) {\n return this.components[uid as Common.UID.Component];\n }\n }\n\n /**\n * Binds queries with a specific model\n * @param {string} uid\n */\n query(uid: Common.UID.Schema) {\n return this.db!.query(uid);\n }\n}\n\ninterface StrapiOptions {\n appDir?: string;\n distDir?: string;\n autoReload?: boolean;\n serveAdminPanel?: boolean;\n}\n\ninterface Init {\n (options?: StrapiOptions): StrapiI;\n factories: typeof factories;\n compile: typeof compile;\n}\n\nconst initFn = (options: StrapiOptions = {}): StrapiI => {\n const strapi = new Strapi(options);\n global.strapi = strapi as LoadedStrapi;\n return strapi;\n};\n\nconst init: Init = Object.assign(initFn, { factories, compile });\n\nexport default init;\n"],"names":["utils.destroyOnSignal","registries.config","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.sanitizers","registries.validators","createAuth","registries.models","utils.getDirs","utils.createStartupLogger","createTelemetry","requestContext","utils.createStrapiFetch","utils.createUpdateNotifier","utils.ee","utils.LIFECYCLES","factories.isCustomController","isInitialized","utils.openBrowser","utils.isInitialized","draftAndPublishSync.disable","draftAndPublishSync.enable","loaders.loadApplicationContext","utils.convertCustomFieldType","utils.transformContentTypesToModels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM,4BAA4B,CAAC,SAAgD;AAC3E,QAAA,MAAM,QAAQ;AAEd,QAAA,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,KAAK,MAAM,IAAI;AACxD,QAAA,UAAU,KAAK,UAAU,KAAK,QAAQ,KAAK,KAAK,OAAO,IAAI;AAEjE,SAAO,EAAE,KAAK,QAAQ,MAAM,QAAQ;AACtC;AAEA,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,QAAQ;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAGd,WAAS,SAAS;AACZ,QAAA,MAAM,eAAe,GAAG;AAE1B,YAAM,gBAAgB;AACtB,aAAO,cAAc;AACrB;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,IAAI,YAAY,GAAG;AACnC,cAAQ,OAAO,QAAQ;AAAA,IACzB;AAAA,EACF;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AE,OAAO,CAAC,CAAC;CACrC,CAAC;AAUF,QAAA,MAAM,iBAAiB,QAAS,MAAM,cAAc,qBAAqB,uBAiCxE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/content-type/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAUF,QAAA,MAAM,iBAAiB,QAAS,MAAM,cAAc,qBAAqB,uBAiCxE,CAAC;AAyDF,QAAA,MAAM,WAAW,WAAY,OAAO,WAAW,WAAW,MAAM,WAK/D,CAAC;AAmBF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -51,7 +51,7 @@ const addTimestamps = (schema) => {
|
|
|
51
51
|
};
|
|
52
52
|
const addDraftAndPublish = (schema) => {
|
|
53
53
|
if (!___default.default.has(schema, "options.draftAndPublish")) {
|
|
54
|
-
___default.default.set(schema, "options.draftAndPublish",
|
|
54
|
+
___default.default.set(schema, "options.draftAndPublish", false);
|
|
55
55
|
}
|
|
56
56
|
schema.attributes[PUBLISHED_AT_ATTRIBUTE] = {
|
|
57
57
|
type: "datetime",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/domain/content-type/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash/fp';\nimport _ from 'lodash';\nimport { yup, contentTypes as contentTypesUtils } from '@strapi/utils';\nimport type { Schema } from '@strapi/types';\nimport { validateContentTypeDefinition } from './validator';\n\nexport type ContentTypeDefinition = {\n schema: Schema.ContentType;\n actions: Record<string, unknown>;\n lifecycles: Record<string, unknown>;\n};\n\nconst {\n CREATED_AT_ATTRIBUTE,\n UPDATED_AT_ATTRIBUTE,\n PUBLISHED_AT_ATTRIBUTE,\n CREATED_BY_ATTRIBUTE,\n UPDATED_BY_ATTRIBUTE,\n} = contentTypesUtils.constants;\n\nconst createContentType = (uid: string, definition: ContentTypeDefinition) => {\n try {\n validateContentTypeDefinition(definition);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`Content Type Definition is invalid for ${uid}'.\\n${e.errors}`);\n }\n\n throw e;\n }\n\n const { schema, actions, lifecycles } = cloneDeep(definition);\n\n // general info\n Object.assign(schema, {\n uid,\n modelType: 'contentType',\n kind: schema.kind || 'collectionType',\n __schema__: pickSchema(definition.schema),\n modelName: definition.schema.info.singularName,\n actions,\n lifecycles,\n });\n\n addTimestamps(schema);\n\n // Published at is added regardless of draft and publish being enabled\n // In case it is not enabled, value will be always published, and it will not contain a draft\n addDraftAndPublish(schema);\n\n addCreatorFields(schema);\n\n return schema;\n};\n\nconst addTimestamps = (schema: Schema.ContentType) => {\n // attributes\n Object.assign(schema.attributes, {\n [CREATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n // TODO: handle on edit set to new date\n [UPDATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n });\n};\n\nconst addDraftAndPublish = (schema: Schema.ContentType) => {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/domain/content-type/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash/fp';\nimport _ from 'lodash';\nimport { yup, contentTypes as contentTypesUtils } from '@strapi/utils';\nimport type { Schema } from '@strapi/types';\nimport { validateContentTypeDefinition } from './validator';\n\nexport type ContentTypeDefinition = {\n schema: Schema.ContentType;\n actions: Record<string, unknown>;\n lifecycles: Record<string, unknown>;\n};\n\nconst {\n CREATED_AT_ATTRIBUTE,\n UPDATED_AT_ATTRIBUTE,\n PUBLISHED_AT_ATTRIBUTE,\n CREATED_BY_ATTRIBUTE,\n UPDATED_BY_ATTRIBUTE,\n} = contentTypesUtils.constants;\n\nconst createContentType = (uid: string, definition: ContentTypeDefinition) => {\n try {\n validateContentTypeDefinition(definition);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`Content Type Definition is invalid for ${uid}'.\\n${e.errors}`);\n }\n\n throw e;\n }\n\n const { schema, actions, lifecycles } = cloneDeep(definition);\n\n // general info\n Object.assign(schema, {\n uid,\n modelType: 'contentType',\n kind: schema.kind || 'collectionType',\n __schema__: pickSchema(definition.schema),\n modelName: definition.schema.info.singularName,\n actions,\n lifecycles,\n });\n\n addTimestamps(schema);\n\n // Published at is added regardless of draft and publish being enabled\n // In case it is not enabled, value will be always published, and it will not contain a draft\n addDraftAndPublish(schema);\n\n addCreatorFields(schema);\n\n return schema;\n};\n\nconst addTimestamps = (schema: Schema.ContentType) => {\n // attributes\n Object.assign(schema.attributes, {\n [CREATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n // TODO: handle on edit set to new date\n [UPDATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n });\n};\n\nconst addDraftAndPublish = (schema: Schema.ContentType) => {\n if (!_.has(schema, 'options.draftAndPublish')) {\n _.set(schema, 'options.draftAndPublish', false); // Disabled by default\n }\n\n schema.attributes[PUBLISHED_AT_ATTRIBUTE] = {\n type: 'datetime',\n configurable: false,\n writable: true,\n visible: false,\n default() {\n return new Date();\n },\n };\n};\n\nconst addCreatorFields = (schema: Schema.ContentType) => {\n const isPrivate = !_.get(schema, 'options.populateCreatorFields', false);\n\n schema.attributes[CREATED_BY_ATTRIBUTE] = {\n type: 'relation',\n relation: 'oneToOne',\n target: 'admin::user',\n configurable: false,\n writable: false,\n visible: false,\n useJoinTable: false,\n private: isPrivate,\n };\n\n schema.attributes[UPDATED_BY_ATTRIBUTE] = {\n type: 'relation',\n relation: 'oneToOne',\n target: 'admin::user',\n configurable: false,\n writable: false,\n visible: false,\n useJoinTable: false,\n private: isPrivate,\n };\n};\n\nconst getGlobalId = (schema: Schema.ContentType, prefix?: string) => {\n const modelName = schema.info.singularName;\n const globalId = prefix ? `${prefix}-${modelName}` : modelName;\n\n return schema.globalId || _.upperFirst(_.camelCase(globalId));\n};\n\nconst pickSchema = (model: Schema.ContentType) => {\n const schema = _.cloneDeep(\n _.pick(model, [\n 'connection',\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n ])\n );\n\n schema.kind = model.kind || 'collectionType';\n return schema;\n};\n\nexport { createContentType, getGlobalId };\n"],"names":["contentTypesUtils","validateContentTypeDefinition","yup","cloneDeep","_"],"mappings":";;;;;;;;AAYA,MAAM;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAIA,YAAAA,aAAkB;AAEhB,MAAA,oBAAoB,CAAC,KAAa,eAAsC;AACxE,MAAA;AACFC,cAAA,8BAA8B,UAAU;AAAA,WACjC,GAAG;AACN,QAAA,aAAaC,gBAAI,iBAAiB;AAC9B,YAAA,IAAI,MAAM,0CAA0C,GAAG;AAAA,EAAO,EAAE,MAAM,EAAE;AAAA,IAChF;AAEM,UAAA;AAAA,EACR;AAEA,QAAM,EAAE,QAAQ,SAAS,WAAW,IAAIC,EAAAA,UAAU,UAAU;AAG5D,SAAO,OAAO,QAAQ;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,IACX,MAAM,OAAO,QAAQ;AAAA,IACrB,YAAY,WAAW,WAAW,MAAM;AAAA,IACxC,WAAW,WAAW,OAAO,KAAK;AAAA,IAClC;AAAA,IACA;AAAA,EAAA,CACD;AAED,gBAAc,MAAM;AAIpB,qBAAmB,MAAM;AAEzB,mBAAiB,MAAM;AAEhB,SAAA;AACT;AAEA,MAAM,gBAAgB,CAAC,WAA+B;AAE7C,SAAA,OAAO,OAAO,YAAY;AAAA,IAC/B,CAAC,oBAAoB,GAAG;AAAA,MACtB,MAAM;AAAA,IACR;AAAA;AAAA,IAEA,CAAC,oBAAoB,GAAG;AAAA,MACtB,MAA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AGI,SAAA,OAAO,MAAM,QAAQ;AACrB,SAAA;AACT;;;"}
|
|
@@ -47,7 +47,7 @@ const addTimestamps = (schema) => {
|
|
|
47
47
|
};
|
|
48
48
|
const addDraftAndPublish = (schema) => {
|
|
49
49
|
if (!_.has(schema, "options.draftAndPublish")) {
|
|
50
|
-
_.set(schema, "options.draftAndPublish",
|
|
50
|
+
_.set(schema, "options.draftAndPublish", false);
|
|
51
51
|
}
|
|
52
52
|
schema.attributes[PUBLISHED_AT_ATTRIBUTE] = {
|
|
53
53
|
type: "datetime",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/domain/content-type/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash/fp';\nimport _ from 'lodash';\nimport { yup, contentTypes as contentTypesUtils } from '@strapi/utils';\nimport type { Schema } from '@strapi/types';\nimport { validateContentTypeDefinition } from './validator';\n\nexport type ContentTypeDefinition = {\n schema: Schema.ContentType;\n actions: Record<string, unknown>;\n lifecycles: Record<string, unknown>;\n};\n\nconst {\n CREATED_AT_ATTRIBUTE,\n UPDATED_AT_ATTRIBUTE,\n PUBLISHED_AT_ATTRIBUTE,\n CREATED_BY_ATTRIBUTE,\n UPDATED_BY_ATTRIBUTE,\n} = contentTypesUtils.constants;\n\nconst createContentType = (uid: string, definition: ContentTypeDefinition) => {\n try {\n validateContentTypeDefinition(definition);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`Content Type Definition is invalid for ${uid}'.\\n${e.errors}`);\n }\n\n throw e;\n }\n\n const { schema, actions, lifecycles } = cloneDeep(definition);\n\n // general info\n Object.assign(schema, {\n uid,\n modelType: 'contentType',\n kind: schema.kind || 'collectionType',\n __schema__: pickSchema(definition.schema),\n modelName: definition.schema.info.singularName,\n actions,\n lifecycles,\n });\n\n addTimestamps(schema);\n\n // Published at is added regardless of draft and publish being enabled\n // In case it is not enabled, value will be always published, and it will not contain a draft\n addDraftAndPublish(schema);\n\n addCreatorFields(schema);\n\n return schema;\n};\n\nconst addTimestamps = (schema: Schema.ContentType) => {\n // attributes\n Object.assign(schema.attributes, {\n [CREATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n // TODO: handle on edit set to new date\n [UPDATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n });\n};\n\nconst addDraftAndPublish = (schema: Schema.ContentType) => {\n
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/domain/content-type/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash/fp';\nimport _ from 'lodash';\nimport { yup, contentTypes as contentTypesUtils } from '@strapi/utils';\nimport type { Schema } from '@strapi/types';\nimport { validateContentTypeDefinition } from './validator';\n\nexport type ContentTypeDefinition = {\n schema: Schema.ContentType;\n actions: Record<string, unknown>;\n lifecycles: Record<string, unknown>;\n};\n\nconst {\n CREATED_AT_ATTRIBUTE,\n UPDATED_AT_ATTRIBUTE,\n PUBLISHED_AT_ATTRIBUTE,\n CREATED_BY_ATTRIBUTE,\n UPDATED_BY_ATTRIBUTE,\n} = contentTypesUtils.constants;\n\nconst createContentType = (uid: string, definition: ContentTypeDefinition) => {\n try {\n validateContentTypeDefinition(definition);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`Content Type Definition is invalid for ${uid}'.\\n${e.errors}`);\n }\n\n throw e;\n }\n\n const { schema, actions, lifecycles } = cloneDeep(definition);\n\n // general info\n Object.assign(schema, {\n uid,\n modelType: 'contentType',\n kind: schema.kind || 'collectionType',\n __schema__: pickSchema(definition.schema),\n modelName: definition.schema.info.singularName,\n actions,\n lifecycles,\n });\n\n addTimestamps(schema);\n\n // Published at is added regardless of draft and publish being enabled\n // In case it is not enabled, value will be always published, and it will not contain a draft\n addDraftAndPublish(schema);\n\n addCreatorFields(schema);\n\n return schema;\n};\n\nconst addTimestamps = (schema: Schema.ContentType) => {\n // attributes\n Object.assign(schema.attributes, {\n [CREATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n // TODO: handle on edit set to new date\n [UPDATED_AT_ATTRIBUTE]: {\n type: 'datetime',\n },\n });\n};\n\nconst addDraftAndPublish = (schema: Schema.ContentType) => {\n if (!_.has(schema, 'options.draftAndPublish')) {\n _.set(schema, 'options.draftAndPublish', false); // Disabled by default\n }\n\n schema.attributes[PUBLISHED_AT_ATTRIBUTE] = {\n type: 'datetime',\n configurable: false,\n writable: true,\n visible: false,\n default() {\n return new Date();\n },\n };\n};\n\nconst addCreatorFields = (schema: Schema.ContentType) => {\n const isPrivate = !_.get(schema, 'options.populateCreatorFields', false);\n\n schema.attributes[CREATED_BY_ATTRIBUTE] = {\n type: 'relation',\n relation: 'oneToOne',\n target: 'admin::user',\n configurable: false,\n writable: false,\n visible: false,\n useJoinTable: false,\n private: isPrivate,\n };\n\n schema.attributes[UPDATED_BY_ATTRIBUTE] = {\n type: 'relation',\n relation: 'oneToOne',\n target: 'admin::user',\n configurable: false,\n writable: false,\n visible: false,\n useJoinTable: false,\n private: isPrivate,\n };\n};\n\nconst getGlobalId = (schema: Schema.ContentType, prefix?: string) => {\n const modelName = schema.info.singularName;\n const globalId = prefix ? `${prefix}-${modelName}` : modelName;\n\n return schema.globalId || _.upperFirst(_.camelCase(globalId));\n};\n\nconst pickSchema = (model: Schema.ContentType) => {\n const schema = _.cloneDeep(\n _.pick(model, [\n 'connection',\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n ])\n );\n\n schema.kind = model.kind || 'collectionType';\n return schema;\n};\n\nexport { createContentType, getGlobalId };\n"],"names":["contentTypesUtils"],"mappings":";;;;AAYA,MAAM;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAIA,aAAkB;AAEhB,MAAA,oBAAoB,CAAC,KAAa,eAAsC;AACxE,MAAA;AACF,kCAA8B,UAAU;AAAA,WACjC,GAAG;AACN,QAAA,aAAa,IAAI,iBAAiB;AAC9B,YAAA,IAAI,MAAM,0CAA0C,GAAG;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A,IACxC,MAAM;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,UAAU;AAAA,IACV,SAAS;AAAA,IACT,cAAc;AAAA,IACd,SAAS;AAAA,EAAA;AAEb;AAEM,MAAA,cAAc,CAAC,QAA4B,WAAoB;AAC7D,QAAA,YAAY,OAAO,KAAK;AAC9B,QAAM,WAAW,SAAS,GAAG,MAAM,IAAI,SAAS,KAAK;AAErD,SAAO,OAAO,YAAY,EAAE,WAAW,EAAE,UAAU,QAAQ,CAAC;AAC9D;AAEA,MAAM,aAAa,CAAC,UAA8B;AAChD,QAAM,SAAS,EAAE;AAAA,IACf,EAAE,KAAK,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EAAA;AAGI,SAAA,OAAO,MAAM,QAAQ;AACrB,SAAA;AACT;"}
|
|
@@ -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;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAkEnD,CAAC"}
|
|
@@ -55,12 +55,12 @@ const security = (config, { strapi }) => (ctx, next) => {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
58
|
+
if (process.env.NODE_ENV === "development" && ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
59
59
|
helmetConfig = _.merge(helmetConfig, {
|
|
60
60
|
contentSecurityPolicy: {
|
|
61
61
|
directives: {
|
|
62
62
|
"script-src": ["'self'", "'unsafe-inline'"],
|
|
63
|
-
"connect-src": ["'self'", "https:", "ws:"]
|
|
63
|
+
"connect-src": ["'self'", "http:", "https:", "ws:"]
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } 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 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\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\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\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 = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n if (ctx.method === 'GET'
|
|
1
|
+
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } 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 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\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\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\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 = merge(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 if (\n process.env.NODE_ENV === 'development' &&\n ctx.method === 'GET' &&\n ['/admin'].some((str) => ctx.path.startsWith(str))\n ) {\n helmetConfig = merge(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":["defaultsDeep","merge","helmet"],"mappings":";;;;;;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBA,EAAAA,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAEtC,QAAM,aAKF;AAAA,IACF,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,IAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,IAC9D,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,EAAA;AAIZ,MAAA,OAAO,OAAO,SAAS,GAAG,QAAQ,OAAO,EAAE,WAAW,aAAa;AACrE,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAE5B,eAAA,YAAY,EAAE,KAAK,wBAAwB;AAC3C,eAAA,SAAS,EAAE,KAAK,oDAAoD;AACpE,eAAA,cAAc,EAAE,KAAK,QAAQ;AAC7B,eAAA,cAAc,EAAE,KAAK,kDAAkD;AACvE,eAAA,WAAW,EAAE,KAAK,QAAQ;AAC1B,eAAA,WAAW,EAAE,KAAK,iCAAiC;AAAA,EAChE;AAGA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAeC,QAAM,cAAc;AAAA,MACjC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAUA,MACE,QAAQ,IAAI,aAAa,iBACzB,IAAI,WAAW,SACf,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GACjD;AACA,mBAAeA,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,SAAS,UAAU,KAAK;AAAA,QACpD;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAOC,gBAAO,QAAA,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
|
|
@@ -51,12 +51,12 @@ const security = (config, { strapi }) => (ctx, next) => {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
54
|
+
if (process.env.NODE_ENV === "development" && ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
55
55
|
helmetConfig = merge(helmetConfig, {
|
|
56
56
|
contentSecurityPolicy: {
|
|
57
57
|
directives: {
|
|
58
58
|
"script-src": ["'self'", "'unsafe-inline'"],
|
|
59
|
-
"connect-src": ["'self'", "https:", "ws:"]
|
|
59
|
+
"connect-src": ["'self'", "http:", "https:", "ws:"]
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } 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 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\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\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\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 = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n if (ctx.method === 'GET'
|
|
1
|
+
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } 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 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\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\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\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 = merge(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 if (\n process.env.NODE_ENV === 'development' &&\n ctx.method === 'GET' &&\n ['/admin'].some((str) => ctx.path.startsWith(str))\n ) {\n helmetConfig = merge(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":[],"mappings":";;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;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AU,KAAK;AAAA,QACpD;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAO,OAAO,YAAY,EAAE,KAAK,IAAI;AACvC;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from '@strapi/types';
|
|
2
|
+
interface Input {
|
|
3
|
+
oldContentTypes: Record<string, Schema.ContentType>;
|
|
4
|
+
contentTypes: Record<string, Schema.ContentType>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Enable draft and publish for content types.
|
|
8
|
+
*
|
|
9
|
+
* Draft and publish disabled content types will have their entries published,
|
|
10
|
+
* this migration clones those entries as drafts.
|
|
11
|
+
*
|
|
12
|
+
* TODO: Clone components, dynamic zones and relations
|
|
13
|
+
*/
|
|
14
|
+
declare const enableDraftAndPublish: ({ oldContentTypes, contentTypes }: Input) => Promise<void>;
|
|
15
|
+
declare const disableDraftAndPublish: ({ oldContentTypes, contentTypes }: Input) => Promise<void>;
|
|
16
|
+
export { enableDraftAndPublish as enable, disableDraftAndPublish as disable };
|
|
17
|
+
//# sourceMappingURL=draft-publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-publish.d.ts","sourceRoot":"","sources":["../../src/migrations/draft-publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,UAAU,KAAK;IACb,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;CAClD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,sCAA6C,KAAK,kBAqE5E,CAAC;AAEF,QAAA,MAAM,sBAAsB,sCAA6C,KAAK,kBAqB7E,CAAC;AAEF,OAAO,EAAE,qBAAqB,IAAI,MAAM,EAAE,sBAAsB,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const strapiUtils = require("@strapi/utils");
|
|
4
|
+
const enableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
|
|
5
|
+
if (!oldContentTypes) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
for (const uid in contentTypes) {
|
|
9
|
+
if (!oldContentTypes[uid]) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const oldContentType = oldContentTypes[uid];
|
|
13
|
+
const contentType = contentTypes[uid];
|
|
14
|
+
if (!strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
|
|
15
|
+
const metadata = strapi.db.metadata.get(uid);
|
|
16
|
+
const attributes = Object.values(metadata.attributes).reduce((acc, attribute) => {
|
|
17
|
+
if (["id"].includes(attribute.columnName)) {
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
20
|
+
if (strapiUtils.contentTypes.isScalarAttribute(attribute)) {
|
|
21
|
+
acc.push(attribute.columnName);
|
|
22
|
+
}
|
|
23
|
+
return acc;
|
|
24
|
+
}, []);
|
|
25
|
+
const qb = strapi.db?.getConnection();
|
|
26
|
+
await qb.into(qb.raw(`${metadata.tableName} (${attributes.join(", ")})`)).insert((subQb) => {
|
|
27
|
+
subQb.select(
|
|
28
|
+
...attributes.map((att) => {
|
|
29
|
+
if (att === "published_at") {
|
|
30
|
+
return qb.raw("NULL as published_at");
|
|
31
|
+
}
|
|
32
|
+
if (att === "updated_at") {
|
|
33
|
+
return qb.raw(`?? as updated_at`, [qb.fn.now()]);
|
|
34
|
+
}
|
|
35
|
+
return att;
|
|
36
|
+
})
|
|
37
|
+
).from(metadata.tableName).whereNotNull("published_at");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const disableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
|
|
43
|
+
if (!oldContentTypes) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const uid in contentTypes) {
|
|
47
|
+
if (!oldContentTypes[uid]) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const oldContentType = oldContentTypes[uid];
|
|
51
|
+
const contentType = contentTypes[uid];
|
|
52
|
+
if (strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && !strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
|
|
53
|
+
await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.disable = disableDraftAndPublish;
|
|
58
|
+
exports.enable = enableDraftAndPublish;
|
|
59
|
+
//# sourceMappingURL=draft-publish.js.map
|