@strapi/core 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Strapi.js +1 -2
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs.map +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/compile.mjs.map +1 -1
- package/dist/configuration/config-loader.js +1 -2
- package/dist/configuration/config-loader.js.map +1 -1
- package/dist/configuration/config-loader.mjs +1 -2
- package/dist/configuration/config-loader.mjs.map +1 -1
- package/dist/configuration/get-dirs.js.map +1 -1
- package/dist/configuration/get-dirs.mjs.map +1 -1
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/configuration/urls.js.map +1 -1
- package/dist/configuration/urls.mjs.map +1 -1
- package/dist/container.js.map +1 -1
- package/dist/container.mjs.map +1 -1
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs.map +1 -1
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs.map +1 -1
- package/dist/core-api/controller/single-type.js.map +1 -1
- package/dist/core-api/controller/single-type.mjs.map +1 -1
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs.map +1 -1
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/core-api/service/collection-type.js.map +1 -1
- package/dist/core-api/service/collection-type.mjs.map +1 -1
- package/dist/core-api/service/core-service.js.map +1 -1
- package/dist/core-api/service/core-service.mjs.map +1 -1
- package/dist/core-api/service/index.js.map +1 -1
- package/dist/core-api/service/index.mjs.map +1 -1
- package/dist/core-api/service/pagination.js.map +1 -1
- package/dist/core-api/service/pagination.mjs.map +1 -1
- package/dist/core-api/service/single-type.js +1 -2
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +1 -2
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/domain/content-type/validator.js.map +1 -1
- package/dist/domain/content-type/validator.mjs.map +1 -1
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/domain/module/validation.js.map +1 -1
- package/dist/domain/module/validation.mjs.map +1 -1
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loaders/admin.js.map +1 -1
- package/dist/loaders/admin.mjs.map +1 -1
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/components.js.map +1 -1
- package/dist/loaders/components.mjs.map +1 -1
- package/dist/loaders/middlewares.js.map +1 -1
- package/dist/loaders/middlewares.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
- package/dist/loaders/plugins/get-user-plugins-config.mjs.map +1 -1
- package/dist/loaders/plugins/index.js +1 -2
- package/dist/loaders/plugins/index.js.map +1 -1
- package/dist/loaders/plugins/index.mjs.map +1 -1
- package/dist/loaders/policies.js.map +1 -1
- package/dist/loaders/policies.mjs.map +1 -1
- package/dist/loaders/sanitizers.js.map +1 -1
- package/dist/loaders/sanitizers.mjs.map +1 -1
- package/dist/loaders/src-index.js.map +1 -1
- package/dist/loaders/src-index.mjs.map +1 -1
- package/dist/loaders/validators.js.map +1 -1
- package/dist/loaders/validators.mjs.map +1 -1
- package/dist/middlewares/body.js.map +1 -1
- package/dist/middlewares/body.mjs.map +1 -1
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs.map +1 -1
- package/dist/middlewares/errors.js.map +1 -1
- package/dist/middlewares/errors.mjs.map +1 -1
- package/dist/middlewares/favicon.js.map +1 -1
- package/dist/middlewares/favicon.mjs.map +1 -1
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/logger.js.map +1 -1
- package/dist/middlewares/logger.mjs.map +1 -1
- package/dist/middlewares/powered-by.js.map +1 -1
- package/dist/middlewares/powered-by.mjs.map +1 -1
- package/dist/middlewares/public.js.map +1 -1
- package/dist/middlewares/public.mjs.map +1 -1
- package/dist/middlewares/query.js.map +1 -1
- package/dist/middlewares/query.mjs.map +1 -1
- package/dist/middlewares/response-time.js.map +1 -1
- package/dist/middlewares/response-time.mjs.map +1 -1
- package/dist/middlewares/responses.js.map +1 -1
- package/dist/middlewares/responses.mjs.map +1 -1
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/middlewares/session.js.map +1 -1
- package/dist/middlewares/session.mjs.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
- package/dist/migrations/draft-publish.js.map +1 -1
- package/dist/migrations/draft-publish.mjs.map +1 -1
- package/dist/migrations/i18n.js.map +1 -1
- package/dist/migrations/i18n.mjs.map +1 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/providers/admin.js.map +1 -1
- package/dist/providers/admin.mjs.map +1 -1
- package/dist/providers/coreStore.js.map +1 -1
- package/dist/providers/coreStore.mjs.map +1 -1
- package/dist/providers/cron.js.map +1 -1
- package/dist/providers/cron.mjs.map +1 -1
- package/dist/providers/registries.js.map +1 -1
- package/dist/providers/registries.mjs.map +1 -1
- package/dist/providers/telemetry.js.map +1 -1
- package/dist/providers/telemetry.mjs.map +1 -1
- package/dist/providers/webhooks.js.map +1 -1
- package/dist/providers/webhooks.mjs.map +1 -1
- package/dist/registries/apis.js.map +1 -1
- package/dist/registries/apis.mjs.map +1 -1
- package/dist/registries/components.js.map +1 -1
- package/dist/registries/components.mjs.map +1 -1
- package/dist/registries/content-types.js.map +1 -1
- package/dist/registries/content-types.mjs.map +1 -1
- package/dist/registries/controllers.js.map +1 -1
- package/dist/registries/controllers.mjs.map +1 -1
- package/dist/registries/custom-fields.js.map +1 -1
- package/dist/registries/custom-fields.mjs.map +1 -1
- package/dist/registries/hooks.js.map +1 -1
- package/dist/registries/hooks.mjs.map +1 -1
- package/dist/registries/middlewares.js.map +1 -1
- package/dist/registries/middlewares.mjs.map +1 -1
- package/dist/registries/models.js.map +1 -1
- package/dist/registries/models.mjs.map +1 -1
- package/dist/registries/modules.js.map +1 -1
- package/dist/registries/modules.mjs.map +1 -1
- package/dist/registries/namespace.js.map +1 -1
- package/dist/registries/namespace.mjs.map +1 -1
- package/dist/registries/plugins.js.map +1 -1
- package/dist/registries/plugins.mjs.map +1 -1
- package/dist/registries/policies.js.map +1 -1
- package/dist/registries/policies.mjs.map +1 -1
- package/dist/registries/sanitizers.js.map +1 -1
- package/dist/registries/sanitizers.mjs.map +1 -1
- package/dist/registries/services.js.map +1 -1
- package/dist/registries/services.mjs.map +1 -1
- package/dist/registries/validators.js.map +1 -1
- package/dist/registries/validators.mjs.map +1 -1
- package/dist/services/auth/index.js.map +1 -1
- package/dist/services/auth/index.mjs.map +1 -1
- package/dist/services/config.js.map +1 -1
- package/dist/services/config.mjs.map +1 -1
- package/dist/services/content-api/index.js.map +1 -1
- package/dist/services/content-api/index.mjs.map +1 -1
- package/dist/services/content-api/permissions/index.js.map +1 -1
- package/dist/services/content-api/permissions/index.mjs.map +1 -1
- package/dist/services/content-api/permissions/providers/action.js.map +1 -1
- package/dist/services/content-api/permissions/providers/action.mjs.map +1 -1
- package/dist/services/content-api/permissions/providers/condition.js.map +1 -1
- package/dist/services/content-api/permissions/providers/condition.mjs.map +1 -1
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/cron.js +1 -2
- package/dist/services/cron.js.map +1 -1
- package/dist/services/cron.mjs +1 -2
- package/dist/services/cron.mjs.map +1 -1
- package/dist/services/custom-fields.js.map +1 -1
- package/dist/services/custom-fields.mjs.map +1 -1
- package/dist/services/document-service/attributes/index.js.map +1 -1
- package/dist/services/document-service/attributes/index.mjs.map +1 -1
- package/dist/services/document-service/attributes/transforms.js.map +1 -1
- package/dist/services/document-service/attributes/transforms.mjs.map +1 -1
- package/dist/services/document-service/components.js.map +1 -1
- package/dist/services/document-service/components.mjs.map +1 -1
- package/dist/services/document-service/draft-and-publish.js.map +1 -1
- package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/events.js.map +1 -1
- package/dist/services/document-service/events.mjs.map +1 -1
- package/dist/services/document-service/index.js.map +1 -1
- package/dist/services/document-service/index.mjs.map +1 -1
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/middlewares/errors.js.map +1 -1
- package/dist/services/document-service/middlewares/errors.mjs.map +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/data.js.map +1 -1
- package/dist/services/document-service/transform/data.mjs.map +1 -1
- package/dist/services/document-service/transform/fields.js.map +1 -1
- package/dist/services/document-service/transform/fields.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.js +2 -4
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs +2 -4
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/id-transform.js.map +1 -1
- package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
- package/dist/services/document-service/transform/populate.js.map +1 -1
- package/dist/services/document-service/transform/populate.mjs.map +1 -1
- package/dist/services/document-service/transform/query.js.map +1 -1
- package/dist/services/document-service/transform/query.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +1 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.js +3 -6
- package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs +3 -6
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/services/document-service/utils/populate.js.map +1 -1
- package/dist/services/document-service/utils/populate.mjs.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.js +1 -2
- package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.mjs +1 -2
- package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs.map +1 -1
- package/dist/services/entity-validator/blocks-validator.js.map +1 -1
- package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/errors.js.map +1 -1
- package/dist/services/errors.mjs.map +1 -1
- package/dist/services/event-hub.js.map +1 -1
- package/dist/services/event-hub.mjs.map +1 -1
- package/dist/services/features.js.map +1 -1
- package/dist/services/features.mjs.map +1 -1
- package/dist/services/fs.js.map +1 -1
- package/dist/services/fs.mjs.map +1 -1
- package/dist/services/metrics/admin-user-hash.js.map +1 -1
- package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
- package/dist/services/metrics/index.js +1 -2
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs +1 -2
- package/dist/services/metrics/index.mjs.map +1 -1
- package/dist/services/metrics/is-truthy.js.map +1 -1
- package/dist/services/metrics/middleware.js.map +1 -1
- package/dist/services/metrics/middleware.mjs.map +1 -1
- package/dist/services/metrics/rate-limiter.js.map +1 -1
- package/dist/services/metrics/rate-limiter.mjs.map +1 -1
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs.map +1 -1
- package/dist/services/query-params.js.map +1 -1
- package/dist/services/query-params.mjs.map +1 -1
- package/dist/services/reloader.js.map +1 -1
- package/dist/services/reloader.mjs.map +1 -1
- package/dist/services/request-context.js.map +1 -1
- package/dist/services/request-context.mjs.map +1 -1
- package/dist/services/server/admin-api.js.map +1 -1
- package/dist/services/server/admin-api.mjs.map +1 -1
- package/dist/services/server/api.js.map +1 -1
- package/dist/services/server/api.mjs.map +1 -1
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs.map +1 -1
- package/dist/services/server/content-api.js.map +1 -1
- package/dist/services/server/content-api.mjs.map +1 -1
- package/dist/services/server/http-server.js.map +1 -1
- package/dist/services/server/http-server.mjs.map +1 -1
- package/dist/services/server/index.js.map +1 -1
- package/dist/services/server/index.mjs.map +1 -1
- package/dist/services/server/koa.js.map +1 -1
- package/dist/services/server/koa.mjs.map +1 -1
- package/dist/services/server/middleware.js.map +1 -1
- package/dist/services/server/middleware.mjs.map +1 -1
- package/dist/services/server/policy.js.map +1 -1
- package/dist/services/server/policy.mjs.map +1 -1
- package/dist/services/server/register-middlewares.js.map +1 -1
- package/dist/services/server/register-middlewares.mjs.map +1 -1
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/services/utils/dynamic-zones.js.map +1 -1
- package/dist/services/utils/dynamic-zones.mjs.map +1 -1
- package/dist/services/webhook-runner.js.map +1 -1
- package/dist/services/webhook-runner.mjs.map +1 -1
- package/dist/services/webhook-store.js.map +1 -1
- package/dist/services/webhook-store.mjs.map +1 -1
- package/dist/services/worker-queue.js.map +1 -1
- package/dist/services/worker-queue.mjs.map +1 -1
- package/dist/utils/convert-custom-field-type.js.map +1 -1
- package/dist/utils/convert-custom-field-type.mjs.map +1 -1
- package/dist/utils/cron.js.map +1 -1
- package/dist/utils/cron.mjs.map +1 -1
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/filepath-to-prop-path.js.map +1 -1
- package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
- package/dist/utils/is-initialized.js.map +1 -1
- package/dist/utils/is-initialized.mjs.map +1 -1
- package/dist/utils/load-config-file.js.map +1 -1
- package/dist/utils/load-config-file.mjs.map +1 -1
- package/dist/utils/load-files.js +1 -2
- package/dist/utils/load-files.js.map +1 -1
- package/dist/utils/load-files.mjs +1 -2
- package/dist/utils/load-files.mjs.map +1 -1
- package/dist/utils/resolve-working-dirs.js.map +1 -1
- package/dist/utils/resolve-working-dirs.mjs.map +1 -1
- package/dist/utils/signals.js.map +1 -1
- package/dist/utils/signals.mjs.map +1 -1
- package/dist/utils/startup-logger.d.ts.map +1 -1
- package/dist/utils/startup-logger.js +6 -1
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs +6 -1
- package/dist/utils/startup-logger.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.js.map +1 -1
- package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
- package/dist/utils/update-notifier/index.js.map +1 -1
- package/dist/utils/update-notifier/index.mjs.map +1 -1
- package/package.json +14 -14
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n '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\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["mergeWith","defaultsDeep","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,
|
1
|
+
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n '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\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["mergeWith","defaultsDeep","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,IAAA;AAAA,EAE7B;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EAAA;AAEZ;AAEA,MAAM,cAAc,CAAC,gBAAwB,cAAsB;AAC1D,SAAAA,GAAA;AAAA,IACL,CAAC,KAAK,QAAS,MAAM,QAAQ,GAAG,KAAK,MAAM,QAAQ,GAAG,IAAI,IAAI,OAAO,GAAG,IAAI;AAAA,IAC5E;AAAA,IACA;AAAA,EACF;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBC,GAAAA,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,CAAA;AAAA,EACf;AAGI,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,EAAA;AAIhE,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAe,YAAY,cAAc;AAAA,MACvC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA;AAaD,MAAA,CAAC,eAAe,MAAM,EAAE,SAAS,QAAQ,IAAI,YAAY,EAAE,KAC3D,IAAI,WAAW,SACf,IAAI,KAAK,WAAW,OAAO,OAAO,IAAI,YAAY,CAAC,GACnD;AACA,mBAAe,YAAY,cAAc;AAAA,MACvC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,SAAS,UAAU,KAAK;AAAA,QAAA;AAAA,MACpD;AAAA,IACF,CACD;AAAA,EAAA;AAGH,SAAOC,wBAAO,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n '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\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"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,
|
1
|
+
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, mergeWith } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n '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\nconst mergeConfig = (existingConfig: Config, newConfig: Config) => {\n return mergeWith(\n (obj, src) => (Array.isArray(obj) && Array.isArray(src) ? obj.concat(src) : undefined),\n existingConfig,\n newConfig\n );\n};\n\nexport const security: Core.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = mergeConfig(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n\n if (\n ['development', 'test'].includes(process.env.NODE_ENV ?? '') &&\n ctx.method === 'GET' &&\n ctx.path.startsWith(strapi.config.get('admin.path'))\n ) {\n helmetConfig = mergeConfig(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"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,IAAA;AAAA,EAE7B;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EAAA;AAEZ;AAEA,MAAM,cAAc,CAAC,gBAAwB,cAAsB;AAC1D,SAAA;AAAA,IACL,CAAC,KAAK,QAAS,MAAM,QAAQ,GAAG,KAAK,MAAM,QAAQ,GAAG,IAAI,IAAI,OAAO,GAAG,IAAI;AAAA,IAC5E;AAAA,IACA;AAAA,EACF;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuB,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,CAAA;AAAA,EACf;AAGI,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,EAAA;AAIhE,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAe,YAAY,cAAc;AAAA,MACvC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA;AAaD,MAAA,CAAC,eAAe,MAAM,EAAE,SAAS,QAAQ,IAAI,YAAY,EAAE,KAC3D,IAAI,WAAW,SACf,IAAI,KAAK,WAAW,OAAO,OAAO,IAAI,YAAY,CAAC,GACnD;AACA,mBAAe,YAAY,cAAc;AAAA,MACvC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,SAAS,UAAU,KAAK;AAAA,QAAA;AAAA,MACpD;AAAA,IACF,CACD;AAAA,EAAA;AAGH,SAAO,OAAO,YAAY,EAAE,KAAK,IAAI;AACvC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"session.js","sources":["../../src/middlewares/session.ts"],"sourcesContent":["import { isEmpty, isArray } from 'lodash/fp';\nimport koaSession from 'koa-session';\nimport type { Core } from '@strapi/types';\n\nconst defaultConfig = {\n key: 'koa.sess',\n maxAge: 86400000,\n autoCommit: true,\n overwrite: true,\n httpOnly: true,\n signed: true,\n rolling: false,\n renew: false,\n secure: process.env.NODE_ENV === 'production',\n sameSite: undefined,\n};\n\nexport const session: Core.MiddlewareFactory<Partial<koaSession.opts>> = (\n userConfig,\n { strapi }\n) => {\n const { keys } = strapi.server.app;\n if (!isArray(keys) || isEmpty(keys) || keys.some(isEmpty)) {\n throw new Error(\n `App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])`\n );\n }\n\n const config: Partial<koaSession.opts> = { ...defaultConfig, ...userConfig };\n\n strapi.server.use(koaSession(config, strapi.server.app));\n};\n"],"names":["isArray","isEmpty","koaSession"],"mappings":";;;;;;AAIA,MAAM,gBAAgB;AAAA,EACpB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC,UAAU;AACZ;AAEO,MAAM,UAA4D,CACvE,YACA,EAAE,aACC;AACH,QAAM,EAAE,
|
1
|
+
{"version":3,"file":"session.js","sources":["../../src/middlewares/session.ts"],"sourcesContent":["import { isEmpty, isArray } from 'lodash/fp';\nimport koaSession from 'koa-session';\nimport type { Core } from '@strapi/types';\n\nconst defaultConfig = {\n key: 'koa.sess',\n maxAge: 86400000,\n autoCommit: true,\n overwrite: true,\n httpOnly: true,\n signed: true,\n rolling: false,\n renew: false,\n secure: process.env.NODE_ENV === 'production',\n sameSite: undefined,\n};\n\nexport const session: Core.MiddlewareFactory<Partial<koaSession.opts>> = (\n userConfig,\n { strapi }\n) => {\n const { keys } = strapi.server.app;\n if (!isArray(keys) || isEmpty(keys) || keys.some(isEmpty)) {\n throw new Error(\n `App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])`\n );\n }\n\n const config: Partial<koaSession.opts> = { ...defaultConfig, ...userConfig };\n\n strapi.server.use(koaSession(config, strapi.server.app));\n};\n"],"names":["isArray","isEmpty","koaSession"],"mappings":";;;;;;AAIA,MAAM,gBAAgB;AAAA,EACpB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC,UAAU;AACZ;AAEO,MAAM,UAA4D,CACvE,YACA,EAAE,aACC;AACH,QAAM,EAAE,KAAA,IAAS,OAAO,OAAO;AAC3B,MAAA,CAACA,GAAAA,QAAQ,IAAI,KAAKC,GAAA,QAAQ,IAAI,KAAK,KAAK,KAAKA,GAAAA,OAAO,GAAG;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,SAAmC,EAAE,GAAG,eAAe,GAAG,WAAW;AAE3E,SAAO,OAAO,IAAIC,oBAAA,QAAW,QAAQ,OAAO,OAAO,GAAG,CAAC;AACzD;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"session.mjs","sources":["../../src/middlewares/session.ts"],"sourcesContent":["import { isEmpty, isArray } from 'lodash/fp';\nimport koaSession from 'koa-session';\nimport type { Core } from '@strapi/types';\n\nconst defaultConfig = {\n key: 'koa.sess',\n maxAge: 86400000,\n autoCommit: true,\n overwrite: true,\n httpOnly: true,\n signed: true,\n rolling: false,\n renew: false,\n secure: process.env.NODE_ENV === 'production',\n sameSite: undefined,\n};\n\nexport const session: Core.MiddlewareFactory<Partial<koaSession.opts>> = (\n userConfig,\n { strapi }\n) => {\n const { keys } = strapi.server.app;\n if (!isArray(keys) || isEmpty(keys) || keys.some(isEmpty)) {\n throw new Error(\n `App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])`\n );\n }\n\n const config: Partial<koaSession.opts> = { ...defaultConfig, ...userConfig };\n\n strapi.server.use(koaSession(config, strapi.server.app));\n};\n"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC,UAAU;AACZ;AAEO,MAAM,UAA4D,CACvE,YACA,EAAE,aACC;AACH,QAAM,EAAE,
|
1
|
+
{"version":3,"file":"session.mjs","sources":["../../src/middlewares/session.ts"],"sourcesContent":["import { isEmpty, isArray } from 'lodash/fp';\nimport koaSession from 'koa-session';\nimport type { Core } from '@strapi/types';\n\nconst defaultConfig = {\n key: 'koa.sess',\n maxAge: 86400000,\n autoCommit: true,\n overwrite: true,\n httpOnly: true,\n signed: true,\n rolling: false,\n renew: false,\n secure: process.env.NODE_ENV === 'production',\n sameSite: undefined,\n};\n\nexport const session: Core.MiddlewareFactory<Partial<koaSession.opts>> = (\n userConfig,\n { strapi }\n) => {\n const { keys } = strapi.server.app;\n if (!isArray(keys) || isEmpty(keys) || keys.some(isEmpty)) {\n throw new Error(\n `App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])`\n );\n }\n\n const config: Partial<koaSession.opts> = { ...defaultConfig, ...userConfig };\n\n strapi.server.use(koaSession(config, strapi.server.app));\n};\n"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC,UAAU;AACZ;AAEO,MAAM,UAA4D,CACvE,YACA,EAAE,aACC;AACH,QAAM,EAAE,KAAA,IAAS,OAAO,OAAO;AAC3B,MAAA,CAAC,QAAQ,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,KAAK,OAAO,GAAG;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,SAAmC,EAAE,GAAG,eAAe,GAAG,WAAW;AAE3E,SAAO,OAAO,IAAI,WAAW,QAAQ,OAAO,OAAO,GAAG,CAAC;AACzD;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["contentTypes","createDocumentService","async"],"mappings":";;;;AAyBA,MAAM,qBAAqB,OAAO,KAAW,SAAc;AACzD,QAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,MAAI,CAAC,UAAU;AACN,WAAA;AAAA,
|
1
|
+
{"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["contentTypes","createDocumentService","async"],"mappings":";;;;AAyBA,MAAM,qBAAqB,OAAO,KAAW,SAAc;AACzD,QAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,MAAI,CAAC,UAAU;AACN,WAAA;AAAA,EAAA;AAGT,QAAM,MAAM,KAAK;AACX,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,QAAA,QAAQA,YAAAA,aAAa,mBAAmB,KAAK;AACnD,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AAMA,eAAe,4BAA4B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAED,QAAM,OAAO,GAAG,SAAS,IAAI,GAAG;AAG1B,QAAA,mBAAmB,OAAO,OAAO,KAAK,UAAU,EAAE,OAAO,CAAC,KAAK,cAAmB;AACtF,QAAI,CAAC,IAAI,EAAE,SAAS,UAAU,UAAU,GAAG;AAClC,aAAA;AAAA,IAAA;AAGL,QAAAA,YAAA,aAAa,kBAAkB,SAAS,GAAG;AACzC,UAAA,KAAK,UAAU,UAAU;AAAA,IAAA;AAGxB,WAAA;AAAA,EACT,GAAG,EAAc;AASjB,QAAM,IAEH;AAAA,IACC,IAAI,IAAI,OAAO,iBAAiB,IAAI,MAAM,IAAI,EAAE,KAAK,IAAI,CAAC,KAAK;AAAA,MAC7D,KAAK;AAAA,MACL,GAAG;AAAA,IACJ,CAAA;AAAA,EAAA,EAEF,OAAO,CAAC,UAAsB;AAG1B,UAAA;AAAA,MACC,GAAG,iBAAiB,IAAI,CAAC,QAAgB;AAEvC,YAAI,QAAQ,gBAAgB;AACnB,iBAAA,IAAI,IAAI,cAAc,cAAc;AAAA,QAAA;AAGtC,eAAA;AAAA,MACR,CAAA;AAAA,MAEF,KAAK,KAAK,SAAS,EAEnB,aAAa,cAAc;AAAA,EAAA,CAC/B;AACL;AAQA,gBAAuB,kBAAkB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IAAA;AAGF,cAAA;AACJ,UAAA;AAAA,EAAA;AAEV;AAMA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,QAAM,WAAW,CAAC;AAClB,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,QAAQ,MAAM,mBAAmB,KAAK,IAAI;AAChD,QAAI,OAAO;AACT,eAAS,KAAK,IAAI;AAAA,IAAA;AAAA,EACpB;AAMF,aAAW,SAAS,UAAU;AAC5B,UAAM,4BAA4B,EAAE,IAAI,KAAK,KAAK,MAAM,KAAK;AAAA,EAAA;AAazD,QAAA,kBAAkBC,4BAAsB,QAAQ;AAAA,IACpD,MAAM,uBAAuB,GAAG,MAAM;AAC7B,aAAA;AAAA,IACT;AAAA,IACA,MAAM,qBAAqB,GAAG,MAAM;AAI3B,aAAA;AAAA,IAAA;AAAA,EACT,CACD;AAED,aAAW,SAAS,UAAU;AAC5B,UAAM,eAAe,OAAO,UAC1B,gBAAgB,MAAM,GAAsB,EAAE,aAAa;AAAA,MACzD,YAAY,MAAM;AAAA,MAClB,QAAQ,MAAM;AAAA,IAAA,CACf;AAEc,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,MAAM,IAAI,CAAC,GAAG;AAGxE,YAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,GAAG;AAAA,IAAA;AAAA,EACzD;AAEJ;AAEO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AACV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EAAA;AAErC;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":[],"mappings":";;AAyBA,MAAM,qBAAqB,OAAO,KAAW,SAAc;AACzD,QAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,MAAI,CAAC,UAAU;AACN,WAAA;AAAA,
|
1
|
+
{"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n batchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n batchSize?: number;\n}) {\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":[],"mappings":";;AAyBA,MAAM,qBAAqB,OAAO,KAAW,SAAc;AACzD,QAAM,WAAW,MAAM,IAAI,OAAO,SAAS,KAAK,SAAS;AAEzD,MAAI,CAAC,UAAU;AACN,WAAA;AAAA,EAAA;AAGT,QAAM,MAAM,KAAK;AACX,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC3B,QAAA,QAAQ,aAAa,mBAAmB,KAAK;AACnD,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AAMA,eAAe,4BAA4B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAED,QAAM,OAAO,GAAG,SAAS,IAAI,GAAG;AAG1B,QAAA,mBAAmB,OAAO,OAAO,KAAK,UAAU,EAAE,OAAO,CAAC,KAAK,cAAmB;AACtF,QAAI,CAAC,IAAI,EAAE,SAAS,UAAU,UAAU,GAAG;AAClC,aAAA;AAAA,IAAA;AAGL,QAAA,aAAa,kBAAkB,SAAS,GAAG;AACzC,UAAA,KAAK,UAAU,UAAU;AAAA,IAAA;AAGxB,WAAA;AAAA,EACT,GAAG,EAAc;AASjB,QAAM,IAEH;AAAA,IACC,IAAI,IAAI,OAAO,iBAAiB,IAAI,MAAM,IAAI,EAAE,KAAK,IAAI,CAAC,KAAK;AAAA,MAC7D,KAAK;AAAA,MACL,GAAG;AAAA,IACJ,CAAA;AAAA,EAAA,EAEF,OAAO,CAAC,UAAsB;AAG1B,UAAA;AAAA,MACC,GAAG,iBAAiB,IAAI,CAAC,QAAgB;AAEvC,YAAI,QAAQ,gBAAgB;AACnB,iBAAA,IAAI,IAAI,cAAc,cAAc;AAAA,QAAA;AAGtC,eAAA;AAAA,MACR,CAAA;AAAA,MAEF,KAAK,KAAK,SAAS,EAEnB,aAAa,cAAc;AAAA,EAAA,CAC/B;AACL;AAQA,gBAAuB,kBAAkB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACd,GAKG;AACD,MAAI,SAAS;AACb,MAAI,UAAU;AAEd,SAAO,SAAS;AAEd,UAAM,QAA2B,MAAM,GACpC,aAAa,GAAG,EAChB,OAAO,CAAC,MAAM,cAAc,QAAQ,CAAC,EACrC,MAAM,EAAE,aAAa,EAAE,KAAK,KAAO,EAAA,CAAC,EACpC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,QAAQ,IAAI,EACZ,YAAY,GAAG,EACf,QAAQ;AAEP,QAAA,MAAM,SAAS,WAAW;AAClB,gBAAA;AAAA,IAAA;AAGF,cAAA;AACJ,UAAA;AAAA,EAAA;AAEV;AAMA,MAAM,YAAY,OAAO,KAAW,OAAiB;AACnD,QAAM,WAAW,CAAC;AAClB,aAAW,QAAQ,GAAG,SAAS,OAAA,GAAU;AACvC,UAAM,QAAQ,MAAM,mBAAmB,KAAK,IAAI;AAChD,QAAI,OAAO;AACT,eAAS,KAAK,IAAI;AAAA,IAAA;AAAA,EACpB;AAMF,aAAW,SAAS,UAAU;AAC5B,UAAM,4BAA4B,EAAE,IAAI,KAAK,KAAK,MAAM,KAAK;AAAA,EAAA;AAazD,QAAA,kBAAkB,sBAAsB,QAAQ;AAAA,IACpD,MAAM,uBAAuB,GAAG,MAAM;AAC7B,aAAA;AAAA,IACT;AAAA,IACA,MAAM,qBAAqB,GAAG,MAAM;AAI3B,aAAA;AAAA,IAAA;AAAA,EACT,CACD;AAED,aAAW,SAAS,UAAU;AAC5B,UAAM,eAAe,OAAO,UAC1B,gBAAgB,MAAM,GAAsB,EAAE,aAAa;AAAA,MACzD,YAAY,MAAM;AAAA,MAClB,QAAQ,MAAM;AAAA,IAAA,CACf;AAEc,qBAAA,SAAS,kBAAkB,EAAE,IAAI,KAAK,KAAK,MAAM,IAAI,CAAC,GAAG;AAGxE,YAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,GAAG;AAAA,IAAA;AAAA,EACzD;AAEJ;AAEO,MAAM,wBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM,GAAG,KAAK,IAAI;AACV,UAAA,UAAU,KAAK,EAAE;AAAA,EACzB;AAAA,EACA,MAAM,OAAO;AACL,UAAA,IAAI,MAAM,iBAAiB;AAAA,EAAA;AAErC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"draft-publish.js","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\nexport interface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypesUtils","getBatchToDiscard","async"],"mappings":";;;;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiB,mBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,
|
1
|
+
{"version":3,"file":"draft-publish.js","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\nexport interface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypesUtils","getBatchToDiscard","async"],"mappings":";;;;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiB,mBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAIF,SAAO,OAAO,GAAG,YAAY,OAAO,QAAQ;AAC1C,eAAW,OAAO,cAAc;AAC1B,UAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,MAAA;AAGI,YAAA,iBAAiB,gBAAgB,GAAG;AACpC,YAAA,cAAc,aAAa,GAAG;AAIlC,UAAA,CAACA,yBAAkB,mBAAmB,cAAc,KACpDA,yBAAkB,mBAAmB,WAAW,GAChD;AACA,cAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAU,EAEpB,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,yBAAA,SAASC,sCAAkB,EAAE,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG;AACxE,gBAAMC,YAAAA,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,QAAA;AAAA,MAC1D;AAAA,IACF;AAAA,EACF,CACD;AACH;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiB,mBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAIlC,QAAAF,YAAAA,aAAkB,mBAAmB,cAAc,KACnD,CAACA,yBAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,SAAS,MAAM,EAAE,cAAc,KAAM,CAAA,EAAE,QAAQ;AAAA,IAAA;AAAA,EACpF;AAEJ;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"draft-publish.mjs","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\nexport interface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypes","contentTypesUtils"],"mappings":";;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiBA,cAAAA,qBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,
|
1
|
+
{"version":3,"file":"draft-publish.mjs","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, async } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\nimport { getBatchToDiscard } from './database/5.0.0-discard-drafts';\n\nexport interface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const discardDraft = async (entry: { documentId: string; locale: string }) =>\n strapi\n .documents(uid as any)\n // Discard draft by referencing the documentId and locale\n .discardDraft({ documentId: entry.documentId, locale: entry.locale });\n\n /**\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n */\n for await (const batch of getBatchToDiscard({ db: strapi.db, trx, uid })) {\n await async.map(batch, discardDraft, { concurrency: 10 });\n }\n }\n }\n });\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypes","contentTypesUtils"],"mappings":";;AAkBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiBA,cAAAA,qBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAIF,SAAO,OAAO,GAAG,YAAY,OAAO,QAAQ;AAC1C,eAAW,OAAOA,gBAAc;AAC1B,UAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,MAAA;AAGI,YAAA,iBAAiB,gBAAgB,GAAG;AACpC,YAAA,cAAcA,eAAa,GAAG;AAIlC,UAAA,CAACC,aAAkB,mBAAmB,cAAc,KACpDA,aAAkB,mBAAmB,WAAW,GAChD;AACA,cAAM,eAAe,OAAO,UAC1B,OACG,UAAU,GAAU,EAEpB,aAAa,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ;AAMvD,yBAAA,SAAS,kBAAkB,EAAE,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG;AACxE,gBAAM,MAAM,IAAI,OAAO,cAAc,EAAE,aAAa,IAAI;AAAA,QAAA;AAAA,MAC1D;AAAA,IACF;AAAA,EACF,CACD;AACH;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiBD,cAAAA,qBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAAC,aAAkB,mBAAmB,cAAc,KACnD,CAACA,aAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,SAAS,MAAM,EAAE,cAAc,KAAM,CAAA,EAAE,QAAQ;AAAA,IAAA;AAAA,EACpF;AAEJ;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"i18n.js","sources":["../../src/migrations/i18n.ts"],"sourcesContent":["import { Input } from './draft-publish';\n\n// if i18N enabled set default locale\nconst enableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db.query(uid).updateMany({\n where: { locale: null },\n data: { locale: defaultLocale },\n });\n }\n }\n};\n\nconst disableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await Promise.all([\n // Delete all entities that are not in the default locale\n strapi.db.query(uid).deleteMany({\n where: { locale: { $ne: defaultLocale } },\n }),\n // Set locale to null for the rest\n strapi.db.query(uid).updateMany({\n where: { locale: { $eq: defaultLocale } },\n data: { locale: null },\n }),\n ]);\n }\n }\n};\n\nexport { enableI18n as enable, disableI18n as disable };\n"],"names":[],"mappings":";;AAGA,MAAM,aAAa,OAAO,EAAE,iBAAiB,mBAA0B;AAC/D,QAAA,EAAE,
|
1
|
+
{"version":3,"file":"i18n.js","sources":["../../src/migrations/i18n.ts"],"sourcesContent":["import { Input } from './draft-publish';\n\n// if i18N enabled set default locale\nconst enableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db.query(uid).updateMany({\n where: { locale: null },\n data: { locale: defaultLocale },\n });\n }\n }\n};\n\nconst disableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await Promise.all([\n // Delete all entities that are not in the default locale\n strapi.db.query(uid).deleteMany({\n where: { locale: { $ne: defaultLocale } },\n }),\n // Set locale to null for the rest\n strapi.db.query(uid).updateMany({\n where: { locale: { $eq: defaultLocale } },\n data: { locale: null },\n }),\n ]);\n }\n }\n};\n\nexport { enableI18n as enable, disableI18n as disable };\n"],"names":[],"mappings":";;AAGA,MAAM,aAAa,OAAO,EAAE,iBAAiB,mBAA0B;AAC/D,QAAA,EAAE,uBAAuB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,eAAe,KAAK,CAAC;AACjF,QAAA,EAAE,iBAAiB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,SAAS,KAAK,CAAC;AAE3E,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAEpC,QAAI,CAAC,uBAAuB,cAAc,KAAK,uBAAuB,WAAW,GAAG;AAC5E,YAAA,gBAAgB,MAAM,iBAAiB;AAE7C,YAAM,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,QACpC,OAAO,EAAE,QAAQ,KAAK;AAAA,QACtB,MAAM,EAAE,QAAQ,cAAc;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EACH;AAEJ;AAEA,MAAM,cAAc,OAAO,EAAE,iBAAiB,mBAA0B;AAChE,QAAA,EAAE,uBAAuB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,eAAe,KAAK,CAAC;AACjF,QAAA,EAAE,iBAAiB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,SAAS,KAAK,CAAC;AAE3E,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAGpC,QAAI,uBAAuB,cAAc,KAAK,CAAC,uBAAuB,WAAW,GAAG;AAC5E,YAAA,gBAAgB,MAAM,iBAAiB;AAE7C,YAAM,QAAQ,IAAI;AAAA;AAAA,QAEhB,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,UAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAgB,EAAA;AAAA,QAAA,CACzC;AAAA;AAAA,QAED,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,UAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB;AAAA,UACxC,MAAM,EAAE,QAAQ,KAAK;AAAA,QACtB,CAAA;AAAA,MAAA,CACF;AAAA,IAAA;AAAA,EACH;AAEJ;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"i18n.mjs","sources":["../../src/migrations/i18n.ts"],"sourcesContent":["import { Input } from './draft-publish';\n\n// if i18N enabled set default locale\nconst enableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db.query(uid).updateMany({\n where: { locale: null },\n data: { locale: defaultLocale },\n });\n }\n }\n};\n\nconst disableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await Promise.all([\n // Delete all entities that are not in the default locale\n strapi.db.query(uid).deleteMany({\n where: { locale: { $ne: defaultLocale } },\n }),\n // Set locale to null for the rest\n strapi.db.query(uid).updateMany({\n where: { locale: { $eq: defaultLocale } },\n data: { locale: null },\n }),\n ]);\n }\n }\n};\n\nexport { enableI18n as enable, disableI18n as disable };\n"],"names":[],"mappings":"AAGA,MAAM,aAAa,OAAO,EAAE,iBAAiB,mBAA0B;AAC/D,QAAA,EAAE,
|
1
|
+
{"version":3,"file":"i18n.mjs","sources":["../../src/migrations/i18n.ts"],"sourcesContent":["import { Input } from './draft-publish';\n\n// if i18N enabled set default locale\nconst enableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n if (!isLocalizedContentType(oldContentType) && isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await strapi.db.query(uid).updateMany({\n where: { locale: null },\n data: { locale: defaultLocale },\n });\n }\n }\n};\n\nconst disableI18n = async ({ oldContentTypes, contentTypes }: Input) => {\n const { isLocalizedContentType } = strapi.plugin('i18n')?.service('content-types') ?? {};\n const { getDefaultLocale } = strapi.plugin('i18n')?.service('locales') ?? {};\n\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if i18N is disabled remove non default locales before sync\n if (isLocalizedContentType(oldContentType) && !isLocalizedContentType(contentType)) {\n const defaultLocale = await getDefaultLocale();\n\n await Promise.all([\n // Delete all entities that are not in the default locale\n strapi.db.query(uid).deleteMany({\n where: { locale: { $ne: defaultLocale } },\n }),\n // Set locale to null for the rest\n strapi.db.query(uid).updateMany({\n where: { locale: { $eq: defaultLocale } },\n data: { locale: null },\n }),\n ]);\n }\n }\n};\n\nexport { enableI18n as enable, disableI18n as disable };\n"],"names":[],"mappings":"AAGA,MAAM,aAAa,OAAO,EAAE,iBAAiB,mBAA0B;AAC/D,QAAA,EAAE,uBAAuB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,eAAe,KAAK,CAAC;AACjF,QAAA,EAAE,iBAAiB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,SAAS,KAAK,CAAC;AAE3E,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAEpC,QAAI,CAAC,uBAAuB,cAAc,KAAK,uBAAuB,WAAW,GAAG;AAC5E,YAAA,gBAAgB,MAAM,iBAAiB;AAE7C,YAAM,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,QACpC,OAAO,EAAE,QAAQ,KAAK;AAAA,QACtB,MAAM,EAAE,QAAQ,cAAc;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EACH;AAEJ;AAEA,MAAM,cAAc,OAAO,EAAE,iBAAiB,mBAA0B;AAChE,QAAA,EAAE,uBAAuB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,eAAe,KAAK,CAAC;AACjF,QAAA,EAAE,iBAAiB,IAAI,OAAO,OAAO,MAAM,GAAG,QAAQ,SAAS,KAAK,CAAC;AAE3E,MAAI,CAAC,iBAAiB;AACpB;AAAA,EAAA;AAGF,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IAAA;AAGI,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAc,aAAa,GAAG;AAGpC,QAAI,uBAAuB,cAAc,KAAK,CAAC,uBAAuB,WAAW,GAAG;AAC5E,YAAA,gBAAgB,MAAM,iBAAiB;AAE7C,YAAM,QAAQ,IAAI;AAAA;AAAA,QAEhB,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,UAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAgB,EAAA;AAAA,QAAA,CACzC;AAAA;AAAA,QAED,OAAO,GAAG,MAAM,GAAG,EAAE,WAAW;AAAA,UAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB;AAAA,UACxC,MAAM,EAAE,QAAQ,KAAK;AAAA,QACtB,CAAA;AAAA,MAAA,CACF;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["i18nMigrations.enable","draftPublishMigrations.enable","i18nMigrations.disable","draftPublishMigrations.disable"],"mappings":";;;;AAIA,MAAM,SAAS,OAAO,EAAE,iBAAiB,mBAA0B;AACjE,QAAMA,YAAsB,EAAE,iBAAiB,
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["i18nMigrations.enable","draftPublishMigrations.enable","i18nMigrations.disable","draftPublishMigrations.disable"],"mappings":";;;;AAIA,MAAM,SAAS,OAAO,EAAE,iBAAiB,mBAA0B;AACjE,QAAMA,YAAsB,EAAE,iBAAiB,cAAc;AAC7D,QAAMC,oBAA8B,EAAE,iBAAiB,cAAc;AACvE;AAEA,MAAM,UAAU,OAAO,EAAE,iBAAiB,mBAA0B;AAClE,QAAMC,aAAuB,EAAE,iBAAiB,cAAc;AAC9D,QAAMC,qBAA+B,EAAE,iBAAiB,cAAc;AACxE;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["i18nMigrations.enable","draftPublishMigrations.enable","i18nMigrations.disable","draftPublishMigrations.disable"],"mappings":";;AAIA,MAAM,SAAS,OAAO,EAAE,iBAAiB,mBAA0B;AACjE,QAAMA,WAAsB,EAAE,iBAAiB,
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/migrations/index.ts"],"sourcesContent":["import * as draftPublishMigrations from './draft-publish';\nimport * as i18nMigrations from './i18n';\nimport type { Input } from './draft-publish';\n\nconst enable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.enable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.enable({ oldContentTypes, contentTypes });\n};\n\nconst disable = async ({ oldContentTypes, contentTypes }: Input) => {\n await i18nMigrations.disable({ oldContentTypes, contentTypes });\n await draftPublishMigrations.disable({ oldContentTypes, contentTypes });\n};\n\nexport { enable, disable };\n"],"names":["i18nMigrations.enable","draftPublishMigrations.enable","i18nMigrations.disable","draftPublishMigrations.disable"],"mappings":";;AAIA,MAAM,SAAS,OAAO,EAAE,iBAAiB,mBAA0B;AACjE,QAAMA,WAAsB,EAAE,iBAAiB,cAAc;AAC7D,QAAMC,sBAA8B,EAAE,iBAAiB,cAAc;AACvE;AAEA,MAAM,UAAU,OAAO,EAAE,iBAAiB,mBAA0B;AAClE,QAAMC,YAAuB,EAAE,iBAAiB,cAAc;AAC9D,QAAMC,uBAA+B,EAAE,iBAAiB,cAAc;AACxE;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"admin.js","sources":["../../src/providers/admin.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport loadAdmin from '../loaders/admin';\n\nexport default defineProvider({\n init(strapi) {\n // eslint-disable-next-line node/no-missing-require\n strapi.add('admin', () => require('@strapi/admin/strapi-server'));\n },\n\n async register(strapi) {\n await loadAdmin(strapi);\n\n await strapi.get('admin')?.register({ strapi });\n },\n\n async bootstrap(strapi) {\n await strapi.get('admin')?.bootstrap({ strapi });\n },\n\n async destroy(strapi) {\n await strapi.get('admin')?.destroy({ strapi });\n },\n});\n"],"names":["defineProvider","loadAdmin"],"mappings":";;;AAGA,MAAA,QAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAEX,WAAO,IAAI,SAAS,MAAM,QAAQ,6BAA6B,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,SAAS,QAAQ;AACrB,UAAMC,QAAU,MAAM;AAEtB,UAAM,OAAO,IAAI,OAAO,GAAG,SAAS,EAAE,QAAQ;AAAA,EAChD;AAAA,EAEA,MAAM,UAAU,QAAQ;AACtB,UAAM,OAAO,IAAI,OAAO,GAAG,UAAU,EAAE,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,QAAQ,QAAQ;AACpB,UAAM,OAAO,IAAI,OAAO,GAAG,QAAQ,EAAE,QAAQ;AAAA,
|
1
|
+
{"version":3,"file":"admin.js","sources":["../../src/providers/admin.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport loadAdmin from '../loaders/admin';\n\nexport default defineProvider({\n init(strapi) {\n // eslint-disable-next-line node/no-missing-require\n strapi.add('admin', () => require('@strapi/admin/strapi-server'));\n },\n\n async register(strapi) {\n await loadAdmin(strapi);\n\n await strapi.get('admin')?.register({ strapi });\n },\n\n async bootstrap(strapi) {\n await strapi.get('admin')?.bootstrap({ strapi });\n },\n\n async destroy(strapi) {\n await strapi.get('admin')?.destroy({ strapi });\n },\n});\n"],"names":["defineProvider","loadAdmin"],"mappings":";;;AAGA,MAAA,QAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAEX,WAAO,IAAI,SAAS,MAAM,QAAQ,6BAA6B,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,SAAS,QAAQ;AACrB,UAAMC,QAAU,MAAM;AAEtB,UAAM,OAAO,IAAI,OAAO,GAAG,SAAS,EAAE,QAAQ;AAAA,EAChD;AAAA,EAEA,MAAM,UAAU,QAAQ;AACtB,UAAM,OAAO,IAAI,OAAO,GAAG,UAAU,EAAE,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,QAAQ,QAAQ;AACpB,UAAM,OAAO,IAAI,OAAO,GAAG,QAAQ,EAAE,QAAQ;AAAA,EAAA;AAEjD,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"admin.mjs","sources":["../../src/providers/admin.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport loadAdmin from '../loaders/admin';\n\nexport default defineProvider({\n init(strapi) {\n // eslint-disable-next-line node/no-missing-require\n strapi.add('admin', () => require('@strapi/admin/strapi-server'));\n },\n\n async register(strapi) {\n await loadAdmin(strapi);\n\n await strapi.get('admin')?.register({ strapi });\n },\n\n async bootstrap(strapi) {\n await strapi.get('admin')?.bootstrap({ strapi });\n },\n\n async destroy(strapi) {\n await strapi.get('admin')?.destroy({ strapi });\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,QAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAEX,WAAO,IAAI,SAAS,MAAM,QAAQ,6BAA6B,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,SAAS,QAAQ;AACrB,UAAM,UAAU,MAAM;AAEtB,UAAM,OAAO,IAAI,OAAO,GAAG,SAAS,EAAE,QAAQ;AAAA,EAChD;AAAA,EAEA,MAAM,UAAU,QAAQ;AACtB,UAAM,OAAO,IAAI,OAAO,GAAG,UAAU,EAAE,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,QAAQ,QAAQ;AACpB,UAAM,OAAO,IAAI,OAAO,GAAG,QAAQ,EAAE,QAAQ;AAAA,
|
1
|
+
{"version":3,"file":"admin.mjs","sources":["../../src/providers/admin.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport loadAdmin from '../loaders/admin';\n\nexport default defineProvider({\n init(strapi) {\n // eslint-disable-next-line node/no-missing-require\n strapi.add('admin', () => require('@strapi/admin/strapi-server'));\n },\n\n async register(strapi) {\n await loadAdmin(strapi);\n\n await strapi.get('admin')?.register({ strapi });\n },\n\n async bootstrap(strapi) {\n await strapi.get('admin')?.bootstrap({ strapi });\n },\n\n async destroy(strapi) {\n await strapi.get('admin')?.destroy({ strapi });\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,QAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAEX,WAAO,IAAI,SAAS,MAAM,QAAQ,6BAA6B,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,SAAS,QAAQ;AACrB,UAAM,UAAU,MAAM;AAEtB,UAAM,OAAO,IAAI,OAAO,GAAG,SAAS,EAAE,QAAQ;AAAA,EAChD;AAAA,EAEA,MAAM,UAAU,QAAQ;AACtB,UAAM,OAAO,IAAI,OAAO,GAAG,UAAU,EAAE,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,QAAQ,QAAQ;AACpB,UAAM,OAAO,IAAI,OAAO,GAAG,QAAQ,EAAE,QAAQ;AAAA,EAAA;AAEjD,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coreStore.js","sources":["../../src/providers/coreStore.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createCoreStore, coreStoreModel } from '../services/core-store';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(coreStoreModel);\n strapi.add('coreStore', () => createCoreStore({ db: strapi.db }));\n },\n});\n"],"names":["defineProvider","coreStoreModel","createCoreStore"],"mappings":";;;AAGA,MAAA,YAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAIC,
|
1
|
+
{"version":3,"file":"coreStore.js","sources":["../../src/providers/coreStore.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createCoreStore, coreStoreModel } from '../services/core-store';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(coreStoreModel);\n strapi.add('coreStore', () => createCoreStore({ db: strapi.db }));\n },\n});\n"],"names":["defineProvider","coreStoreModel","createCoreStore"],"mappings":";;;AAGA,MAAA,YAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAIC,YAAAA,cAAc;AAChC,WAAA,IAAI,aAAa,MAAMC,YAAAA,gBAAgB,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;AAAA,EAAA;AAEpE,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coreStore.mjs","sources":["../../src/providers/coreStore.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createCoreStore, coreStoreModel } from '../services/core-store';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(coreStoreModel);\n strapi.add('coreStore', () => createCoreStore({ db: strapi.db }));\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,YAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAI,cAAc;AAChC,WAAA,IAAI,aAAa,MAAM,gBAAgB,EAAE,IAAI,OAAO,
|
1
|
+
{"version":3,"file":"coreStore.mjs","sources":["../../src/providers/coreStore.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createCoreStore, coreStoreModel } from '../services/core-store';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(coreStoreModel);\n strapi.add('coreStore', () => createCoreStore({ db: strapi.db }));\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,YAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAI,cAAc;AAChC,WAAA,IAAI,aAAa,MAAM,gBAAgB,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;AAAA,EAAA;AAEpE,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cron.js","sources":["../../src/providers/cron.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createCronService from '../services/cron';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('cron', () => createCronService());\n },\n async bootstrap(strapi) {\n if (strapi.config.get('server.cron.enabled', true)) {\n const cronTasks = strapi.config.get('server.cron.tasks', {});\n strapi.get('cron').add(cronTasks);\n }\n\n strapi.get('cron').start();\n },\n async destroy(strapi) {\n strapi.get('cron').destroy();\n },\n});\n"],"names":["defineProvider","createCronService"],"mappings":";;;AAGA,MAAA,OAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,MAAMC,
|
1
|
+
{"version":3,"file":"cron.js","sources":["../../src/providers/cron.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createCronService from '../services/cron';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('cron', () => createCronService());\n },\n async bootstrap(strapi) {\n if (strapi.config.get('server.cron.enabled', true)) {\n const cronTasks = strapi.config.get('server.cron.tasks', {});\n strapi.get('cron').add(cronTasks);\n }\n\n strapi.get('cron').start();\n },\n async destroy(strapi) {\n strapi.get('cron').destroy();\n },\n});\n"],"names":["defineProvider","createCronService"],"mappings":";;;AAGA,MAAA,OAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,MAAMC,OAAA,CAAmB;AAAA,EAC9C;AAAA,EACA,MAAM,UAAU,QAAQ;AACtB,QAAI,OAAO,OAAO,IAAI,uBAAuB,IAAI,GAAG;AAClD,YAAM,YAAY,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAC3D,aAAO,IAAI,MAAM,EAAE,IAAI,SAAS;AAAA,IAAA;AAG3B,WAAA,IAAI,MAAM,EAAE,MAAM;AAAA,EAC3B;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,MAAM,EAAE,QAAQ;AAAA,EAAA;AAE/B,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cron.mjs","sources":["../../src/providers/cron.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createCronService from '../services/cron';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('cron', () => createCronService());\n },\n async bootstrap(strapi) {\n if (strapi.config.get('server.cron.enabled', true)) {\n const cronTasks = strapi.config.get('server.cron.tasks', {});\n strapi.get('cron').add(cronTasks);\n }\n\n strapi.get('cron').start();\n },\n async destroy(strapi) {\n strapi.get('cron').destroy();\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,OAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,MAAM,
|
1
|
+
{"version":3,"file":"cron.mjs","sources":["../../src/providers/cron.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createCronService from '../services/cron';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('cron', () => createCronService());\n },\n async bootstrap(strapi) {\n if (strapi.config.get('server.cron.enabled', true)) {\n const cronTasks = strapi.config.get('server.cron.tasks', {});\n strapi.get('cron').add(cronTasks);\n }\n\n strapi.get('cron').start();\n },\n async destroy(strapi) {\n strapi.get('cron').destroy();\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAA,OAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,MAAM,kBAAA,CAAmB;AAAA,EAC9C;AAAA,EACA,MAAM,UAAU,QAAQ;AACtB,QAAI,OAAO,OAAO,IAAI,uBAAuB,IAAI,GAAG;AAClD,YAAM,YAAY,OAAO,OAAO,IAAI,qBAAqB,CAAA,CAAE;AAC3D,aAAO,IAAI,MAAM,EAAE,IAAI,SAAS;AAAA,IAAA;AAG3B,WAAA,IAAI,MAAM,EAAE,MAAM;AAAA,EAC3B;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,MAAM,EAAE,QAAQ;AAAA,EAAA;AAE/B,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"registries.js","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as syncMigrations from '../migrations';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(syncMigrations.disable);\n strapi.hook('strapi::content-types.afterSync').register(syncMigrations.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["defineProvider","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","loadApplicationContext","hooks","syncMigrations.disable","syncMigrations.enable","discardDocumentDrafts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMC,aAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,WAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,SAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,SAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,YAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,OAAkB,EACrC,IAAI,eAAe,MAAMC,YAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,aAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,KAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,
|
1
|
+
{"version":3,"file":"registries.js","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as syncMigrations from '../migrations';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(syncMigrations.disable);\n strapi.hook('strapi::content-types.afterSync').register(syncMigrations.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["defineProvider","registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","loadApplicationContext","hooks","syncMigrations.disable","syncMigrations.enable","discardDocumentDrafts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMC,aAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,WAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,SAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,SAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,YAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,OAAkB,EACrC,IAAI,eAAe,MAAMC,YAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,QAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,aAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,KAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,OAAkB,SAAA,CAAC,EACvC,IAAI,cAAcC,WAAuB,CAAA,EACzC,IAAI,cAAcC,YAAuB;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAMC,MAAAA,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EAAE,IAAI,oCAAoCC,YAAAA,MAAM,yBAAyB;AAC3F,WAAO,IAAI,OAAO,EAAE,IAAI,mCAAmCA,YAAAA,MAAM,yBAAyB;AAG1F,WAAO,KAAK,kCAAkC,EAAE,SAASC,QAAAA,OAAsB;AAC/E,WAAO,KAAK,iCAAiC,EAAE,SAASC,QAAAA,MAAqB;AAG7E,WAAO,GAAG,WAAW,UAAU,SAAS,SAASC,yCAAqB;AAAA,EAAA;AAE1E,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"registries.mjs","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as syncMigrations from '../migrations';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(syncMigrations.disable);\n strapi.hook('strapi::content-types.afterSync').register(syncMigrations.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","syncMigrations.disable","syncMigrations.enable"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMA,qBAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,mBAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,iBAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,iBAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,oBAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,eAAkB,EACrC,IAAI,eAAe,MAAMC,oBAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,qBAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,aAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,
|
1
|
+
{"version":3,"file":"registries.mjs","sources":["../../src/providers/registries.ts"],"sourcesContent":["import { hooks } from '@strapi/utils';\n\nimport { defineProvider } from './provider';\nimport * as registries from '../registries';\nimport { loadApplicationContext } from '../loaders';\nimport * as syncMigrations from '../migrations';\nimport { discardDocumentDrafts } from '../migrations/database/5.0.0-discard-drafts';\n\nexport default defineProvider({\n init(strapi) {\n strapi\n .add('content-types', () => registries.contentTypes())\n .add('components', () => registries.components())\n .add('services', () => registries.services(strapi))\n .add('policies', () => registries.policies())\n .add('middlewares', () => registries.middlewares())\n .add('hooks', () => registries.hooks())\n .add('controllers', () => registries.controllers(strapi))\n .add('modules', () => registries.modules(strapi))\n .add('plugins', () => registries.plugins(strapi))\n .add('custom-fields', () => registries.customFields(strapi))\n .add('apis', () => registries.apis(strapi))\n .add('models', () => registries.models())\n .add('sanitizers', registries.sanitizers())\n .add('validators', registries.validators());\n },\n async register(strapi) {\n await loadApplicationContext(strapi);\n\n strapi.get('hooks').set('strapi::content-types.beforeSync', hooks.createAsyncParallelHook());\n strapi.get('hooks').set('strapi::content-types.afterSync', hooks.createAsyncParallelHook());\n\n // Content migration to enable draft and publish\n strapi.hook('strapi::content-types.beforeSync').register(syncMigrations.disable);\n strapi.hook('strapi::content-types.afterSync').register(syncMigrations.enable);\n\n // Database migrations\n strapi.db.migrations.providers.internal.register(discardDocumentDrafts);\n },\n});\n"],"names":["registries.contentTypes","registries.components","registries.services","registries.policies","registries.middlewares","registries.hooks","registries.controllers","registries.modules","registries.plugins","registries.customFields","registries.apis","registries.models","registries.sanitizers","registries.validators","syncMigrations.disable","syncMigrations.enable"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,MAAA,aAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AAER,WAAA,IAAI,iBAAiB,MAAMA,qBAAyB,CAAA,EACpD,IAAI,cAAc,MAAMC,mBAAuB,CAAA,EAC/C,IAAI,YAAY,MAAMC,iBAAoB,MAAM,CAAC,EACjD,IAAI,YAAY,MAAMC,iBAAqB,CAAA,EAC3C,IAAI,eAAe,MAAMC,oBAAuB,CAAC,EACjD,IAAI,SAAS,MAAMC,eAAkB,EACrC,IAAI,eAAe,MAAMC,oBAAuB,MAAM,CAAC,EACvD,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,WAAW,MAAMC,gBAAmB,MAAM,CAAC,EAC/C,IAAI,iBAAiB,MAAMC,qBAAwB,MAAM,CAAC,EAC1D,IAAI,QAAQ,MAAMC,aAAgB,MAAM,CAAC,EACzC,IAAI,UAAU,MAAMC,SAAkB,CAAC,EACvC,IAAI,cAAcC,mBAAuB,CAAA,EACzC,IAAI,cAAcC,oBAAuB;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,QAAQ;AACrB,UAAM,uBAAuB,MAAM;AAEnC,WAAO,IAAI,OAAO,EAAE,IAAI,oCAAoC,MAAM,yBAAyB;AAC3F,WAAO,IAAI,OAAO,EAAE,IAAI,mCAAmC,MAAM,yBAAyB;AAG1F,WAAO,KAAK,kCAAkC,EAAE,SAASC,OAAsB;AAC/E,WAAO,KAAK,iCAAiC,EAAE,SAASC,MAAqB;AAG7E,WAAO,GAAG,WAAW,UAAU,SAAS,SAAS,qBAAqB;AAAA,EAAA;AAE1E,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"telemetry.js","sources":["../../src/providers/telemetry.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createTelemetry from '../services/metrics';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('telemetry', () => createTelemetry(strapi));\n },\n async register(strapi) {\n strapi.get('telemetry').register();\n },\n async bootstrap(strapi) {\n strapi.get('telemetry').bootstrap();\n },\n async destroy(strapi) {\n strapi.get('telemetry').destroy();\n },\n});\n"],"names":["defineProvider","createTelemetry"],"mappings":";;;AAGA,MAAA,YAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,aAAa,MAAMC,MAAgB,MAAM,CAAC;AAAA,EACvD;AAAA,EACA,MAAM,SAAS,QAAQ;AACd,WAAA,IAAI,WAAW,EAAE,SAAS;AAAA,EACnC;AAAA,EACA,MAAM,UAAU,QAAQ;AACf,WAAA,IAAI,WAAW,EAAE,UAAU;AAAA,EACpC;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,WAAW,EAAE,QAAQ;AAAA,
|
1
|
+
{"version":3,"file":"telemetry.js","sources":["../../src/providers/telemetry.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createTelemetry from '../services/metrics';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('telemetry', () => createTelemetry(strapi));\n },\n async register(strapi) {\n strapi.get('telemetry').register();\n },\n async bootstrap(strapi) {\n strapi.get('telemetry').bootstrap();\n },\n async destroy(strapi) {\n strapi.get('telemetry').destroy();\n },\n});\n"],"names":["defineProvider","createTelemetry"],"mappings":";;;AAGA,MAAA,YAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,aAAa,MAAMC,MAAgB,MAAM,CAAC;AAAA,EACvD;AAAA,EACA,MAAM,SAAS,QAAQ;AACd,WAAA,IAAI,WAAW,EAAE,SAAS;AAAA,EACnC;AAAA,EACA,MAAM,UAAU,QAAQ;AACf,WAAA,IAAI,WAAW,EAAE,UAAU;AAAA,EACpC;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,WAAW,EAAE,QAAQ;AAAA,EAAA;AAEpC,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"telemetry.mjs","sources":["../../src/providers/telemetry.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createTelemetry from '../services/metrics';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('telemetry', () => createTelemetry(strapi));\n },\n async register(strapi) {\n strapi.get('telemetry').register();\n },\n async bootstrap(strapi) {\n strapi.get('telemetry').bootstrap();\n },\n async destroy(strapi) {\n strapi.get('telemetry').destroy();\n },\n});\n"],"names":["createTelemetry"],"mappings":";;AAGA,MAAA,YAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,aAAa,MAAMA,wBAAgB,MAAM,CAAC;AAAA,EACvD;AAAA,EACA,MAAM,SAAS,QAAQ;AACd,WAAA,IAAI,WAAW,EAAE,SAAS;AAAA,EACnC;AAAA,EACA,MAAM,UAAU,QAAQ;AACf,WAAA,IAAI,WAAW,EAAE,UAAU;AAAA,EACpC;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,WAAW,EAAE,QAAQ;AAAA,
|
1
|
+
{"version":3,"file":"telemetry.mjs","sources":["../../src/providers/telemetry.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport createTelemetry from '../services/metrics';\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('telemetry', () => createTelemetry(strapi));\n },\n async register(strapi) {\n strapi.get('telemetry').register();\n },\n async bootstrap(strapi) {\n strapi.get('telemetry').bootstrap();\n },\n async destroy(strapi) {\n strapi.get('telemetry').destroy();\n },\n});\n"],"names":["createTelemetry"],"mappings":";;AAGA,MAAA,YAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,aAAa,MAAMA,wBAAgB,MAAM,CAAC;AAAA,EACvD;AAAA,EACA,MAAM,SAAS,QAAQ;AACd,WAAA,IAAI,WAAW,EAAE,SAAS;AAAA,EACnC;AAAA,EACA,MAAM,UAAU,QAAQ;AACf,WAAA,IAAI,WAAW,EAAE,UAAU;AAAA,EACpC;AAAA,EACA,MAAM,QAAQ,QAAQ;AACb,WAAA,IAAI,WAAW,EAAE,QAAQ;AAAA,EAAA;AAEpC,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"webhooks.js","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","webhookModel","createWebhookStore","createWebhookRunner","webhooks"],"mappings":";;;;AAIA,MAAA,WAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAIC,
|
1
|
+
{"version":3,"file":"webhooks.js","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["defineProvider","webhookModel","createWebhookStore","createWebhookRunner","webhooks"],"mappings":";;;;AAIA,MAAA,WAAeA,wBAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAIC,aAAAA,YAAY;AAE9B,WAAA,IAAI,gBAAgB,MAAMC,aAAAA,mBAAmB,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;AAC/D,WAAA;AAAA,MAAI;AAAA,MAAiB,MAC1BC,cAAoB;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,eAAe,OAAO,OAAO,IAAI,mBAAmB,CAAA,CAAE;AAAA,QACtD,OAAO,OAAO;AAAA,MACf,CAAA;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM,UAAU,QAAQ;AACtB,UAAMC,YAAW,MAAM,OAAO,IAAI,cAAc,EAAE,aAAa;AAC/D,QAAI,CAACA,WAAU;AACb;AAAA,IAAA;AAGF,eAAW,WAAWA,WAAU;AAC9B,aAAO,IAAI,eAAe,EAAE,IAAI,OAAO;AAAA,IAAA;AAAA,EACzC;AAEJ,CAAC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"webhooks.mjs","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["webhooks"],"mappings":";;;AAIA,MAAA,WAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAI,YAAY;AAE9B,WAAA,IAAI,gBAAgB,MAAM,mBAAmB,EAAE,IAAI,OAAO,
|
1
|
+
{"version":3,"file":"webhooks.mjs","sources":["../../src/providers/webhooks.ts"],"sourcesContent":["import { defineProvider } from './provider';\nimport { createWebhookStore, webhookModel } from '../services/webhook-store';\nimport createWebhookRunner from '../services/webhook-runner';\n\nexport default defineProvider({\n init(strapi) {\n strapi.get('models').add(webhookModel);\n\n strapi.add('webhookStore', () => createWebhookStore({ db: strapi.db }));\n strapi.add('webhookRunner', () =>\n createWebhookRunner({\n eventHub: strapi.eventHub,\n logger: strapi.log,\n configuration: strapi.config.get('server.webhooks', {}),\n fetch: strapi.fetch,\n })\n );\n },\n async bootstrap(strapi) {\n const webhooks = await strapi.get('webhookStore').findWebhooks();\n if (!webhooks) {\n return;\n }\n\n for (const webhook of webhooks) {\n strapi.get('webhookRunner').add(webhook);\n }\n },\n});\n"],"names":["webhooks"],"mappings":";;;AAIA,MAAA,WAAe,eAAe;AAAA,EAC5B,KAAK,QAAQ;AACX,WAAO,IAAI,QAAQ,EAAE,IAAI,YAAY;AAE9B,WAAA,IAAI,gBAAgB,MAAM,mBAAmB,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;AAC/D,WAAA;AAAA,MAAI;AAAA,MAAiB,MAC1B,oBAAoB;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,eAAe,OAAO,OAAO,IAAI,mBAAmB,CAAA,CAAE;AAAA,QACtD,OAAO,OAAO;AAAA,MACf,CAAA;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM,UAAU,QAAQ;AACtB,UAAMA,YAAW,MAAM,OAAO,IAAI,cAAc,EAAE,aAAa;AAC/D,QAAI,CAACA,WAAU;AACb;AAAA,IAAA;AAGF,eAAW,WAAWA,WAAU;AAC9B,aAAO,IAAI,eAAe,EAAE,IAAI,OAAO;AAAA,IAAA;AAAA,EACzC;AAEJ,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,
|
1
|
+
{"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["has"],"mappings":";;AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,CAAC;AAEhC,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAAA,GAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAAA;AAGzD,YAAA,MAAM,OAAO,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAElE,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IAAA;AAAA,EAEvB;AACF;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"apis.mjs","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":[],"mappings":";AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,
|
1
|
+
{"version":3,"file":"apis.mjs","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":[],"mappings":";AAGM,MAAA,eAAe,CAAC,WAAwB;AAC5C,QAAM,OAAgC,CAAC;AAEhC,SAAA;AAAA,IACL,IAAI,MAAc;AAChB,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,IACA,IAAI,SAAiB,WAAoB;AACnC,UAAA,IAAI,SAAS,IAAI,GAAG;AACtB,cAAM,IAAI,MAAM,OAAO,OAAO,+BAA+B;AAAA,MAAA;AAGzD,YAAA,MAAM,OAAO,IAAI,SAAS,EAAE,IAAI,QAAQ,OAAO,IAAI,SAAS;AAElE,WAAK,OAAO,IAAI;AAEhB,aAAO,KAAK,OAAO;AAAA,IAAA;AAAA,EAEvB;AACF;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,
|
1
|
+
{"version":3,"file":"components.js","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["has"],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAC;AAE5D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAAA,GAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MAAA;AAGjE,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAAA;AAAA,IAClC;AAAA,EAEJ;AACF;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"components.mjs","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,
|
1
|
+
{"version":3,"file":"components.mjs","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,aAA4D,CAAC;AAE5D,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAwB;AACf,aAAA,OAAO,KAAK,UAAU;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB;AACtB,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA;AAAA;AAAA;AAAA,IAKA,SAAS;AACA,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAoB,WAAmC;AACrD,UAAA,IAAI,KAAK,UAAU,GAAG;AACxB,cAAM,IAAI,MAAM,aAAa,GAAG,+BAA+B;AAAA,MAAA;AAGjE,iBAAW,GAAG,IAAI;AAEX,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,eAA8D;AAChE,iBAAW,OAAO,OAAO,KAAK,aAAa,GAAsB;AAC/D,aAAK,IAAI,KAAK,cAAc,GAAG,CAAC;AAAA,MAAA;AAAA,IAClC;AAAA,EAEJ;AACF;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,
|
1
|
+
{"version":3,"file":"content-types.js","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has","createContentType"],"mappings":";;;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MACjI;AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAC;AAEzD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AACjB,aAAAC,GAAA,OAAO,CAAC,GAAG,QAAQC,uBAAa,KAAKF,WAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAMG,UAAAA,aAAa,WAAWH,WAAS;AAEzC,YAAAI,GAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QAAA;AAGpE,qBAAa,GAAG,IAAIC,MAAAA,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MAAA;AAAA,IAEzE;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MAAA;AAGvD,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"content-types.mjs","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":[],"mappings":";;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,
|
1
|
+
{"version":3,"file":"content-types.mjs","sources":["../../src/registries/content-types.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { UID, Struct } from '@strapi/types';\nimport { createContentType, ContentTypeDefinition } from '../domain/content-type';\nimport { addNamespace, hasNamespace } from './namespace';\n\ntype ContentTypesInput = Record<string, ContentTypeDefinition>;\ntype ContentTypeExtendFn = (contentType: Struct.ContentTypeSchema) => Struct.ContentTypeSchema;\n\nconst validateKeySameToSingularName = (contentTypes: ContentTypesInput) => {\n for (const ctName of Object.keys(contentTypes)) {\n const contentType = contentTypes[ctName];\n\n if (ctName !== contentType.schema.info.singularName) {\n throw new Error(\n `The key of the content-type should be the same as its singularName. Found ${ctName} and ${contentType.schema.info.singularName}.`\n );\n }\n }\n};\n\nconst contentTypesRegistry = () => {\n const contentTypes: Record<string, Struct.ContentTypeSchema> = {};\n\n return {\n /**\n * Returns this list of registered contentTypes uids\n */\n keys() {\n return Object.keys(contentTypes);\n },\n\n /**\n * Returns the instance of a contentType. Instantiate the contentType if not already done\n */\n get(uid: UID.ContentType) {\n return contentTypes[uid];\n },\n\n /**\n * Returns a map with all the contentTypes in a namespace\n */\n getAll(namespace: string) {\n return pickBy((_, uid) => hasNamespace(uid, namespace))(contentTypes);\n },\n\n /**\n * Registers a contentType\n */\n set(uid: UID.ContentType, contentType: Struct.ContentTypeSchema) {\n contentTypes[uid] = contentType;\n return this;\n },\n\n /**\n * Registers a map of contentTypes for a specific namespace\n */\n add(namespace: string, newContentTypes: ContentTypesInput) {\n validateKeySameToSingularName(newContentTypes);\n\n for (const rawCtName of Object.keys(newContentTypes)) {\n const uid = addNamespace(rawCtName, namespace);\n\n if (has(uid, contentTypes)) {\n throw new Error(`Content-type ${uid} has already been registered.`);\n }\n\n contentTypes[uid] = createContentType(uid, newContentTypes[rawCtName]);\n }\n },\n\n /**\n * Wraps a contentType to extend it\n */\n extend(ctUID: UID.ContentType, extendFn: ContentTypeExtendFn) {\n const currentContentType = this.get(ctUID);\n\n if (!currentContentType) {\n throw new Error(`Content-Type ${ctUID} doesn't exist`);\n }\n\n extendFn(currentContentType);\n\n return this;\n },\n };\n};\n\nexport default contentTypesRegistry;\n"],"names":[],"mappings":";;;AAQA,MAAM,gCAAgC,CAAC,iBAAoC;AACzE,aAAW,UAAU,OAAO,KAAK,YAAY,GAAG;AACxC,UAAA,cAAc,aAAa,MAAM;AAEvC,QAAI,WAAW,YAAY,OAAO,KAAK,cAAc;AACnD,YAAM,IAAI;AAAA,QACR,6EAA6E,MAAM,QAAQ,YAAY,OAAO,KAAK,YAAY;AAAA,MACjI;AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,MAAM,uBAAuB,MAAM;AACjC,QAAM,eAAyD,CAAC;AAEzD,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,YAAY;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB;AACxB,aAAO,aAAa,GAAG;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,WAAmB;AACjB,aAAA,OAAO,CAAC,GAAG,QAAQ,aAAa,KAAK,SAAS,CAAC,EAAE,YAAY;AAAA,IACtE;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAsB,aAAuC;AAC/D,mBAAa,GAAG,IAAI;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,WAAmB,iBAAoC;AACzD,oCAA8B,eAAe;AAE7C,iBAAW,aAAa,OAAO,KAAK,eAAe,GAAG;AAC9C,cAAA,MAAM,aAAa,WAAW,SAAS;AAEzC,YAAA,IAAI,KAAK,YAAY,GAAG;AAC1B,gBAAM,IAAI,MAAM,gBAAgB,GAAG,+BAA+B;AAAA,QAAA;AAGpE,qBAAa,GAAG,IAAI,kBAAkB,KAAK,gBAAgB,SAAS,CAAC;AAAA,MAAA;AAAA,IAEzE;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,OAAwB,UAA+B;AACtD,YAAA,qBAAqB,KAAK,IAAI,KAAK;AAEzC,UAAI,CAAC,oBAAoB;AACvB,cAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAAA,MAAA;AAGvD,eAAS,kBAAkB;AAEpB,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,
|
1
|
+
{"version":3,"file":"controllers.js","sources":["../../src/registries/controllers.ts"],"sourcesContent":["import { pickBy, has } from 'lodash/fp';\nimport type { Core, UID } from '@strapi/types';\nimport { addNamespace, hasNamespace } from './namespace';\n\nexport type ControllerFactory =\n | ((params: { strapi: Core.Strapi }) => Core.Controller)\n | Core.Controller;\nexport type ControllerFactoryMap = Record<UID.Controller, ControllerFactory>;\nexport type ControllerMap = Record<UID.Controller, Core.Controller>;\nexport type ControllerExtendFn = (service: Core.Controller) => Core.Controller;\n\nconst controllersRegistry = (strapi: Core.Strapi) => {\n const controllers: ControllerFactoryMap = {};\n const instances: ControllerMap = {};\n\n return {\n /**\n * Returns this list of registered controllers uids\n */\n keys() {\n return Object.keys(controllers);\n },\n\n /**\n * Returns the instance of a controller. Instantiate the controller if not already done\n */\n get(uid: UID.Controller) {\n if (instances[uid]) {\n return instances[uid];\n }\n\n const controller = controllers[uid];\n\n if (controller) {\n instances[uid] = typeof controller === 'function' ? controller({ strapi }) : controller;\n return instances[uid];\n }\n },\n\n /**\n * Returns a map with all the controller in a namespace\n */\n getAll(namespace: string) {\n const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);\n\n const map = {};\n for (const uid of Object.keys(filteredControllers) as UID.Controller[]) {\n Object.defineProperty(map, uid, {\n enumerable: true,\n get: () => {\n return this.get(uid);\n },\n });\n }\n\n return map;\n },\n\n /**\n * Registers a controller\n */\n set(uid: UID.Controller, value: ControllerFactory) {\n controllers[uid] = value;\n delete instances[uid];\n return this;\n },\n\n /**\n * Registers a map of controllers for a specific namespace\n */\n add(namespace: string, newControllers: ControllerFactoryMap) {\n for (const controllerName of Object.keys(newControllers) as UID.Controller[]) {\n const controller = newControllers[controllerName];\n const uid = addNamespace(controllerName, namespace) as UID.Controller;\n\n if (has(uid, controllers)) {\n throw new Error(`Controller ${uid} has already been registered.`);\n }\n\n controllers[uid] = controller;\n }\n\n return this;\n },\n\n /**\n * Wraps a controller to extend it\n */\n extend(controllerUID: UID.Controller, extendFn: ControllerExtendFn) {\n const currentController = this.get(controllerUID);\n\n if (!currentController) {\n throw new Error(`Controller ${controllerUID} doesn't exist`);\n }\n\n const newController = extendFn(currentController);\n instances[controllerUID] = newController;\n\n return this;\n },\n };\n};\n\nexport default controllersRegistry;\n"],"names":["namespace","pickBy","hasNamespace","addNamespace","has"],"mappings":";;;AAWM,MAAA,sBAAsB,CAAC,WAAwB;AACnD,QAAM,cAAoC,CAAC;AAC3C,QAAM,YAA2B,CAAC;AAE3B,SAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AACE,aAAA,OAAO,KAAK,WAAW;AAAA,IAChC;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB;AACnB,UAAA,UAAU,GAAG,GAAG;AAClB,eAAO,UAAU,GAAG;AAAA,MAAA;AAGhB,YAAA,aAAa,YAAY,GAAG;AAElC,UAAI,YAAY;AACJ,kBAAA,GAAG,IAAI,OAAO,eAAe,aAAa,WAAW,EAAE,OAAQ,CAAA,IAAI;AAC7E,eAAO,UAAU,GAAG;AAAA,MAAA;AAAA,IAExB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAOA,aAAmB;AAClB,YAAA,sBAAsBC,UAAO,CAAC,GAAG,QAAQC,uBAAa,KAAKF,WAAS,CAAC,EAAE,WAAW;AAExF,YAAM,MAAM,CAAC;AACb,iBAAW,OAAO,OAAO,KAAK,mBAAmB,GAAuB;AAC/D,eAAA,eAAe,KAAK,KAAK;AAAA,UAC9B,YAAY;AAAA,UACZ,KAAK,MAAM;AACF,mBAAA,KAAK,IAAI,GAAG;AAAA,UAAA;AAAA,QACrB,CACD;AAAA,MAAA;AAGI,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,KAAqB,OAA0B;AACjD,kBAAY,GAAG,IAAI;AACnB,aAAO,UAAU,GAAG;AACb,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,IAAIA,aAAmB,gBAAsC;AAC3D,iBAAW,kBAAkB,OAAO,KAAK,cAAc,GAAuB;AACtE,cAAA,aAAa,eAAe,cAAc;AAC1C,cAAA,MAAMG,UAAAA,aAAa,gBAAgBH,WAAS;AAE9C,YAAAI,GAAA,IAAI,KAAK,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,cAAc,GAAG,+BAA+B;AAAA,QAAA;AAGlE,oBAAY,GAAG,IAAI;AAAA,MAAA;AAGd,aAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,eAA+B,UAA8B;AAC5D,YAAA,oBAAoB,KAAK,IAAI,aAAa;AAEhD,UAAI,CAAC,mBAAmB;AACtB,cAAM,IAAI,MAAM,cAAc,aAAa,gBAAgB;AAAA,MAAA;AAGvD,YAAA,gBAAgB,SAAS,iBAAiB;AAChD,gBAAU,aAAa,IAAI;AAEpB,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;;"}
|