@strapi/core 5.0.0-alpha.5 → 5.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Strapi.d.ts +33 -33
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +5 -1
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +5 -1
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/container.d.ts +2 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js.map +1 -1
- package/dist/container.mjs.map +1 -1
- package/dist/core-api/controller/collection-type.d.ts +3 -3
- package/dist/core-api/controller/collection-type.d.ts.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.d.ts +3 -3
- package/dist/core-api/controller/index.d.ts.map +1 -1
- package/dist/core-api/controller/index.js +5 -5
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs +6 -6
- package/dist/core-api/controller/index.mjs.map +1 -1
- package/dist/core-api/controller/single-type.d.ts +3 -3
- package/dist/core-api/controller/single-type.d.ts.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.d.ts +2 -2
- package/dist/core-api/controller/transform.d.ts.map +1 -1
- package/dist/core-api/controller/transform.js +2 -5
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs +2 -5
- package/dist/core-api/controller/transform.mjs.map +1 -1
- package/dist/core-api/service/collection-type.d.ts +10 -10
- package/dist/core-api/service/collection-type.d.ts.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/index.d.ts +3 -3
- package/dist/core-api/service/index.d.ts.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/single-type.d.ts +4 -4
- package/dist/core-api/service/single-type.d.ts.map +1 -1
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/domain/content-type/index.d.ts +1 -1
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/module/index.d.ts +24 -23
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +2 -1
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +3 -2
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/ee/index.d.ts +2 -2
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +2 -2
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.d.ts +10 -10
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +6 -2
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +6 -2
- package/dist/factories.mjs.map +1 -1
- package/dist/loaders/admin.d.ts +2 -2
- package/dist/loaders/admin.d.ts.map +1 -1
- package/dist/loaders/admin.js.map +1 -1
- package/dist/loaders/admin.mjs.map +1 -1
- package/dist/loaders/apis.d.ts +2 -2
- package/dist/loaders/apis.d.ts.map +1 -1
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/components.d.ts +2 -2
- package/dist/loaders/components.d.ts.map +1 -1
- package/dist/loaders/components.js.map +1 -1
- package/dist/loaders/components.mjs.map +1 -1
- package/dist/loaders/index.d.ts +2 -2
- package/dist/loaders/index.d.ts.map +1 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/index.mjs.map +1 -1
- package/dist/loaders/middlewares.d.ts +2 -2
- package/dist/loaders/middlewares.d.ts.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.d.ts +2 -2
- package/dist/loaders/plugins/get-enabled-plugins.d.ts.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/index.d.ts +2 -2
- package/dist/loaders/plugins/index.d.ts.map +1 -1
- package/dist/loaders/plugins/index.js.map +1 -1
- package/dist/loaders/plugins/index.mjs.map +1 -1
- package/dist/loaders/policies.d.ts +2 -2
- package/dist/loaders/policies.d.ts.map +1 -1
- package/dist/loaders/policies.js.map +1 -1
- package/dist/loaders/policies.mjs.map +1 -1
- package/dist/loaders/sanitizers.d.ts +2 -2
- package/dist/loaders/sanitizers.d.ts.map +1 -1
- package/dist/loaders/sanitizers.js.map +1 -1
- package/dist/loaders/sanitizers.mjs.map +1 -1
- package/dist/loaders/src-index.d.ts +2 -2
- package/dist/loaders/src-index.d.ts.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.d.ts +2 -2
- package/dist/loaders/validators.d.ts.map +1 -1
- package/dist/loaders/validators.js.map +1 -1
- package/dist/loaders/validators.mjs.map +1 -1
- package/dist/middlewares/body.d.ts +2 -2
- package/dist/middlewares/body.d.ts.map +1 -1
- package/dist/middlewares/body.js.map +1 -1
- package/dist/middlewares/body.mjs.map +1 -1
- package/dist/middlewares/compression.d.ts +2 -2
- package/dist/middlewares/compression.d.ts.map +1 -1
- package/dist/middlewares/compression.js.map +1 -1
- package/dist/middlewares/compression.mjs.map +1 -1
- package/dist/middlewares/cors.d.ts +2 -2
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs.map +1 -1
- package/dist/middlewares/errors.d.ts +2 -2
- package/dist/middlewares/errors.d.ts.map +1 -1
- package/dist/middlewares/errors.js.map +1 -1
- package/dist/middlewares/errors.mjs.map +1 -1
- package/dist/middlewares/favicon.d.ts +2 -2
- package/dist/middlewares/favicon.d.ts.map +1 -1
- package/dist/middlewares/favicon.js.map +1 -1
- package/dist/middlewares/favicon.mjs.map +1 -1
- package/dist/middlewares/index.d.ts +2 -2
- package/dist/middlewares/index.d.ts.map +1 -1
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/index.mjs.map +1 -1
- package/dist/middlewares/ip.d.ts +2 -2
- package/dist/middlewares/ip.d.ts.map +1 -1
- package/dist/middlewares/ip.js.map +1 -1
- package/dist/middlewares/ip.mjs.map +1 -1
- package/dist/middlewares/logger.d.ts +2 -2
- package/dist/middlewares/logger.d.ts.map +1 -1
- package/dist/middlewares/logger.js.map +1 -1
- package/dist/middlewares/logger.mjs.map +1 -1
- package/dist/middlewares/powered-by.d.ts +2 -2
- package/dist/middlewares/powered-by.d.ts.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.d.ts +2 -2
- package/dist/middlewares/public.d.ts.map +1 -1
- package/dist/middlewares/public.js.map +1 -1
- package/dist/middlewares/public.mjs.map +1 -1
- package/dist/middlewares/query.d.ts +2 -2
- package/dist/middlewares/query.d.ts.map +1 -1
- package/dist/middlewares/query.js.map +1 -1
- package/dist/middlewares/query.mjs.map +1 -1
- package/dist/middlewares/response-time.d.ts +2 -2
- package/dist/middlewares/response-time.d.ts.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.d.ts +3 -3
- package/dist/middlewares/responses.d.ts.map +1 -1
- package/dist/middlewares/responses.js.map +1 -1
- package/dist/middlewares/responses.mjs.map +1 -1
- package/dist/middlewares/security.d.ts +2 -2
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/middlewares/session.d.ts +2 -2
- package/dist/middlewares/session.d.ts.map +1 -1
- package/dist/middlewares/session.js.map +1 -1
- package/dist/middlewares/session.mjs.map +1 -1
- package/dist/registries/apis.d.ts +2 -2
- package/dist/registries/apis.d.ts.map +1 -1
- package/dist/registries/apis.js.map +1 -1
- package/dist/registries/apis.mjs.map +1 -1
- package/dist/registries/components.d.ts +6 -6
- package/dist/registries/components.d.ts.map +1 -1
- package/dist/registries/components.js.map +1 -1
- package/dist/registries/components.mjs.map +1 -1
- package/dist/registries/config.d.ts +2 -2
- package/dist/registries/config.d.ts.map +1 -1
- package/dist/registries/config.js +15 -3
- package/dist/registries/config.js.map +1 -1
- package/dist/registries/config.mjs +16 -4
- package/dist/registries/config.mjs.map +1 -1
- package/dist/registries/content-types.d.ts +5 -5
- package/dist/registries/content-types.d.ts.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.d.ts +10 -10
- package/dist/registries/controllers.d.ts.map +1 -1
- package/dist/registries/controllers.js.map +1 -1
- package/dist/registries/controllers.mjs.map +1 -1
- package/dist/registries/custom-fields.d.ts +3 -3
- package/dist/registries/custom-fields.d.ts.map +1 -1
- package/dist/registries/custom-fields.js.map +1 -1
- package/dist/registries/custom-fields.mjs.map +1 -1
- package/dist/registries/middlewares.d.ts +6 -6
- package/dist/registries/middlewares.d.ts.map +1 -1
- package/dist/registries/middlewares.js.map +1 -1
- package/dist/registries/middlewares.mjs.map +1 -1
- package/dist/registries/modules.d.ts +2 -2
- package/dist/registries/modules.d.ts.map +1 -1
- package/dist/registries/modules.js.map +1 -1
- package/dist/registries/modules.mjs.map +1 -1
- package/dist/registries/plugins.d.ts +5 -5
- package/dist/registries/plugins.d.ts.map +1 -1
- package/dist/registries/plugins.js.map +1 -1
- package/dist/registries/plugins.mjs.map +1 -1
- package/dist/registries/policies.d.ts +23 -11
- package/dist/registries/policies.d.ts.map +1 -1
- package/dist/registries/policies.js +64 -18
- package/dist/registries/policies.js.map +1 -1
- package/dist/registries/policies.mjs +65 -19
- package/dist/registries/policies.mjs.map +1 -1
- package/dist/registries/services.d.ts +8 -8
- package/dist/registries/services.d.ts.map +1 -1
- package/dist/registries/services.js.map +1 -1
- package/dist/registries/services.mjs.map +1 -1
- package/dist/services/auth/index.d.ts +4 -4
- package/dist/services/auth/index.d.ts.map +1 -1
- package/dist/services/auth/index.js.map +1 -1
- package/dist/services/auth/index.mjs.map +1 -1
- package/dist/services/content-api/index.d.ts +21 -3
- package/dist/services/content-api/index.d.ts.map +1 -1
- package/dist/services/content-api/index.js +27 -1
- package/dist/services/content-api/index.js.map +1 -1
- package/dist/services/content-api/index.mjs +27 -1
- package/dist/services/content-api/index.mjs.map +1 -1
- package/dist/services/content-api/permissions/index.d.ts +3 -3
- package/dist/services/content-api/permissions/index.d.ts.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/cron.d.ts +2 -2
- package/dist/services/cron.d.ts.map +1 -1
- package/dist/services/cron.js.map +1 -1
- package/dist/services/cron.mjs.map +1 -1
- package/dist/services/custom-fields.d.ts +2 -2
- package/dist/services/custom-fields.d.ts.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/common.d.ts +2 -2
- package/dist/services/document-service/common.d.ts.map +1 -1
- package/dist/services/document-service/common.js.map +1 -1
- package/dist/services/document-service/common.mjs.map +1 -1
- package/dist/services/document-service/document-engine.d.ts +2 -0
- package/dist/services/document-service/document-engine.d.ts.map +1 -0
- package/dist/services/document-service/draft-and-publish.d.ts +7 -7
- package/dist/services/document-service/draft-and-publish.d.ts.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/index.d.ts +2 -2
- package/dist/services/document-service/index.d.ts.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.d.ts +5 -5
- package/dist/services/document-service/internationalization.d.ts.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/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +5 -3
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +6 -4
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/fields.d.ts +2 -2
- package/dist/services/document-service/transform/fields.d.ts.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.d.ts +3 -3
- package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/id-transform.d.ts +2 -2
- package/dist/services/document-service/transform/id-transform.d.ts.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.d.ts +2 -2
- package/dist/services/document-service/transform/populate.d.ts.map +1 -1
- package/dist/services/document-service/transform/populate.js +1 -1
- package/dist/services/document-service/transform/populate.js.map +1 -1
- package/dist/services/document-service/transform/populate.mjs +1 -1
- package/dist/services/document-service/transform/populate.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +2 -2
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js +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 +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.d.ts +2 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts +2 -0
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.d.ts +3 -3
- package/dist/services/document-service/transform/relations/utils/dp.d.ts.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.d.ts +4 -4
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts.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/types.d.ts +3 -3
- package/dist/services/document-service/transform/types.d.ts.map +1 -1
- package/dist/services/document-service/utils/populate.d.ts +2 -2
- package/dist/services/document-service/utils/populate.d.ts.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/entity-service/attributes/index.d.ts +4 -4
- package/dist/services/entity-service/attributes/index.d.ts.map +1 -1
- package/dist/services/entity-service/attributes/index.js.map +1 -1
- package/dist/services/entity-service/attributes/index.mjs.map +1 -1
- package/dist/services/entity-service/attributes/transforms.d.ts +3 -3
- package/dist/services/entity-service/attributes/transforms.d.ts.map +1 -1
- package/dist/services/entity-service/attributes/transforms.js.map +1 -1
- package/dist/services/entity-service/attributes/transforms.mjs.map +1 -1
- package/dist/services/entity-service/components.d.ts +87 -12
- package/dist/services/entity-service/components.d.ts.map +1 -1
- package/dist/services/entity-service/components.js.map +1 -1
- package/dist/services/entity-service/components.mjs.map +1 -1
- package/dist/services/entity-service/index.d.ts +4 -4
- package/dist/services/entity-service/index.d.ts.map +1 -1
- package/dist/services/entity-service/index.js +14 -15
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs +15 -16
- package/dist/services/entity-service/index.mjs.map +1 -1
- package/dist/services/entity-service/params.d.ts +5 -5
- package/dist/services/entity-service/params.d.ts.map +1 -1
- package/dist/services/entity-service/params.js.map +1 -1
- package/dist/services/entity-service/params.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts +2 -2
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +7 -2
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +7 -2
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts +18 -18
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js +6 -1
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +6 -1
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/features.d.ts +3 -3
- package/dist/services/features.d.ts.map +1 -1
- package/dist/services/features.js.map +1 -1
- package/dist/services/features.mjs.map +1 -1
- package/dist/services/fs.d.ts +2 -2
- package/dist/services/fs.d.ts.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.d.ts +2 -2
- package/dist/services/metrics/admin-user-hash.d.ts.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.d.ts +2 -2
- package/dist/services/metrics/index.d.ts.map +1 -1
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs.map +1 -1
- package/dist/services/metrics/middleware.d.ts +2 -2
- package/dist/services/metrics/middleware.d.ts.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/sender.d.ts +3 -3
- package/dist/services/metrics/sender.d.ts.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.d.ts +7 -0
- package/dist/services/query-params.d.ts.map +1 -0
- package/dist/services/query-params.js +12 -0
- package/dist/services/query-params.js.map +1 -0
- package/dist/services/query-params.mjs +13 -0
- package/dist/services/query-params.mjs.map +1 -0
- package/dist/services/server/admin-api.d.ts +3 -3
- package/dist/services/server/admin-api.d.ts.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.d.ts +3 -3
- package/dist/services/server/api.d.ts.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.d.ts +2 -2
- package/dist/services/server/compose-endpoint.d.ts.map +1 -1
- package/dist/services/server/compose-endpoint.js +1 -2
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs +2 -3
- package/dist/services/server/compose-endpoint.mjs.map +1 -1
- package/dist/services/server/content-api.d.ts +3 -3
- package/dist/services/server/content-api.d.ts.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.d.ts +2 -2
- package/dist/services/server/http-server.d.ts.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.d.ts +2 -2
- package/dist/services/server/index.d.ts.map +1 -1
- package/dist/services/server/index.js +1 -2
- package/dist/services/server/index.js.map +1 -1
- package/dist/services/server/index.mjs +1 -2
- package/dist/services/server/index.mjs.map +1 -1
- package/dist/services/server/middleware.d.ts +4 -4
- package/dist/services/server/middleware.d.ts.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.d.ts +3 -3
- package/dist/services/server/policy.d.ts.map +1 -1
- package/dist/services/server/policy.js +4 -4
- package/dist/services/server/policy.js.map +1 -1
- package/dist/services/server/policy.mjs +4 -4
- package/dist/services/server/policy.mjs.map +1 -1
- package/dist/services/server/register-middlewares.d.ts +2 -2
- package/dist/services/server/register-middlewares.d.ts.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.d.ts +2 -2
- package/dist/services/server/register-routes.d.ts.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.d.ts +4 -4
- package/dist/services/server/routing.d.ts.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.d.ts.map +1 -1
- package/dist/services/utils/dynamic-zones.js +2 -1
- package/dist/services/utils/dynamic-zones.js.map +1 -1
- package/dist/services/utils/dynamic-zones.mjs +2 -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/utils/convert-custom-field-type.d.ts +2 -2
- package/dist/utils/convert-custom-field-type.d.ts.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/fetch.d.ts +3 -3
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/get-dirs.d.ts +3 -3
- package/dist/utils/get-dirs.d.ts.map +1 -1
- package/dist/utils/get-dirs.js.map +1 -1
- package/dist/utils/get-dirs.mjs.map +1 -1
- package/dist/utils/is-initialized.d.ts +2 -2
- package/dist/utils/is-initialized.d.ts.map +1 -1
- package/dist/utils/is-initialized.js.map +1 -1
- package/dist/utils/is-initialized.mjs.map +1 -1
- package/dist/utils/open-browser.d.ts +2 -2
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/open-browser.mjs.map +1 -1
- package/dist/utils/signals.d.ts +2 -2
- package/dist/utils/signals.d.ts.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 +2 -2
- package/dist/utils/startup-logger.d.ts.map +1 -1
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.d.ts +34 -84
- package/dist/utils/transform-content-types-to-models.d.ts.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.d.ts +2 -2
- package/dist/utils/update-notifier/index.d.ts.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,5 +1,5 @@
|
|
1
1
|
import { type Model } from '@strapi/database';
|
2
|
-
import {
|
2
|
+
import type { Struct, Schema } from '@strapi/types';
|
3
3
|
import { createId } from '@paralleldrive/cuid2';
|
4
4
|
/**
|
5
5
|
* Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them
|
@@ -14,98 +14,48 @@ export declare const COMPONENT_TYPE_COLUMN = "component_type";
|
|
14
14
|
export declare const ENTITY = "entity";
|
15
15
|
export declare const getComponentJoinTableName: (collectionName: string) => string;
|
16
16
|
export declare const getDzJoinTableName: (collectionName: string) => string;
|
17
|
-
export type LoadedContentTypeModel =
|
18
|
-
export declare const transformAttribute: (name: string, attribute: Attribute.
|
17
|
+
export type LoadedContentTypeModel = Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;
|
18
|
+
export declare const transformAttribute: (name: string, attribute: Schema.Attribute.AnyAttribute, contentType: LoadedContentTypeModel) => (Schema.Attribute.OfType<"biginteger"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxOption<string> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"boolean"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<boolean> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"blocks"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"datetime"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.DateTimeValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"date"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.DateValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"decimal"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"email"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"enumeration"> & Schema.Attribute.EnumerationProperties<string[]> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"float"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"integer"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<number> & Schema.Attribute.MinMaxOption<number> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.UniqueOption) | (Schema.Attribute.OfType<"json"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.RequiredOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.DefaultOption<import("@strapi/types/dist/utils").JSONPrimitive>) | (Schema.Attribute.OfType<"password"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
19
|
+
useJoinTable?: boolean | undefined;
|
20
|
+
} & {
|
19
21
|
relation: "morphToOne";
|
20
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption
|
22
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
23
|
+
useJoinTable?: boolean | undefined;
|
24
|
+
} & {
|
21
25
|
relation: "morphToMany";
|
22
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption
|
26
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.CommonBidirectionalProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
27
|
+
useJoinTable?: boolean | undefined;
|
28
|
+
} & {
|
23
29
|
relation: "oneToOne";
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}, {
|
28
|
-
mappedBy?: string | undefined;
|
29
|
-
}> & {
|
30
|
-
mappedBy?: string | undefined;
|
31
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
32
|
-
relation: "oneToOne";
|
33
|
-
target: import("@strapi/types/dist/types/core/common/uid").ContentType;
|
34
|
-
} & import("@strapi/types/dist/types/utils").Without<{
|
35
|
-
mappedBy?: string | undefined;
|
36
|
-
}, {
|
37
|
-
inversedBy?: string | undefined;
|
38
|
-
}> & {
|
39
|
-
inversedBy?: string | undefined;
|
40
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
41
|
-
relation: "oneToMany";
|
42
|
-
target: import("@strapi/types/dist/types/core/common/uid").ContentType;
|
43
|
-
} & import("@strapi/types/dist/types/utils").Without<{
|
44
|
-
inversedBy?: string | undefined;
|
45
|
-
}, {
|
46
|
-
mappedBy?: string | undefined;
|
47
|
-
}> & {
|
48
|
-
mappedBy?: string | undefined;
|
49
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
30
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.CommonBidirectionalProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
31
|
+
useJoinTable?: boolean | undefined;
|
32
|
+
} & {
|
50
33
|
relation: "oneToMany";
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}, {
|
55
|
-
inversedBy?: string | undefined;
|
56
|
-
}> & {
|
57
|
-
inversedBy?: string | undefined;
|
58
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
34
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.CommonBidirectionalProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
35
|
+
useJoinTable?: boolean | undefined;
|
36
|
+
} & {
|
59
37
|
relation: "manyToOne";
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}, {
|
64
|
-
mappedBy?: string | undefined;
|
65
|
-
}> & {
|
66
|
-
mappedBy?: string | undefined;
|
67
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
68
|
-
relation: "manyToOne";
|
69
|
-
target: import("@strapi/types/dist/types/core/common/uid").ContentType;
|
70
|
-
} & import("@strapi/types/dist/types/utils").Without<{
|
71
|
-
mappedBy?: string | undefined;
|
72
|
-
}, {
|
73
|
-
inversedBy?: string | undefined;
|
74
|
-
}> & {
|
75
|
-
inversedBy?: string | undefined;
|
76
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
77
|
-
relation: "manyToMany";
|
78
|
-
target: import("@strapi/types/dist/types/core/common/uid").ContentType;
|
79
|
-
} & import("@strapi/types/dist/types/utils").Without<{
|
80
|
-
inversedBy?: string | undefined;
|
81
|
-
}, {
|
82
|
-
mappedBy?: string | undefined;
|
83
|
-
}> & {
|
84
|
-
mappedBy?: string | undefined;
|
85
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
38
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.CommonBidirectionalProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
39
|
+
useJoinTable?: boolean | undefined;
|
40
|
+
} & {
|
86
41
|
relation: "manyToMany";
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
}, {
|
91
|
-
inversedBy?: string | undefined;
|
92
|
-
}> & {
|
93
|
-
inversedBy?: string | undefined;
|
94
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | (Attribute.OfType<"relation"> & {
|
42
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.XWayCommonProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
43
|
+
useJoinTable?: boolean | undefined;
|
44
|
+
} & {
|
95
45
|
relation: "oneWay";
|
96
|
-
|
97
|
-
|
46
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.XWayCommonProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
47
|
+
useJoinTable?: boolean | undefined;
|
48
|
+
} & {
|
98
49
|
relation: "manyWay";
|
99
|
-
|
100
|
-
|
50
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.MorphReferenceCommonProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
51
|
+
useJoinTable?: boolean | undefined;
|
52
|
+
} & {
|
101
53
|
relation: "morphOne";
|
102
|
-
|
103
|
-
|
104
|
-
} &
|
54
|
+
}) | (Schema.Attribute.OfType<"relation"> & Schema.Attribute.MorphReferenceCommonProperties<import("@strapi/types/dist/uid").ContentType> & Schema.Attribute.ConfigurableOption & Schema.Attribute.PrivateOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption & Schema.Attribute.RequiredOption & {
|
55
|
+
useJoinTable?: boolean | undefined;
|
56
|
+
} & {
|
105
57
|
relation: "morphMany";
|
106
|
-
|
107
|
-
morphBy?: string | undefined;
|
108
|
-
} & Attribute.ConfigurableOption & Attribute.PrivateOption & Attribute.WritableOption & Attribute.VisibleOption & Attribute.RequiredOption) | Attribute.RichText | (Attribute.OfType<"string"> & Attribute.StringProperties & Attribute.ConfigurableOption & Attribute.DefaultOption<string> & Attribute.MinMaxLengthOption & Attribute.PrivateOption & Attribute.UniqueOption & Attribute.RequiredOption & Attribute.WritableOption & Attribute.VisibleOption) | Attribute.Text | Attribute.Time | Attribute.Timestamp | Attribute.UID<string, Attribute.UIDOptions> | {
|
58
|
+
}) | (Schema.Attribute.OfType<"richtext"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"string"> & Schema.Attribute.StringProperties & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.UniqueOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"text"> & Schema.Attribute.TextProperties & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.UniqueOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"time"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.TimeValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"timestamp"> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<Schema.Attribute.TimestampValue> & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.UniqueOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | (Schema.Attribute.OfType<"uid"> & Schema.Attribute.UIDProperties<string, Schema.Attribute.UIDOptions> & Schema.Attribute.ConfigurableOption & Schema.Attribute.DefaultOption<string> & Schema.Attribute.MinMaxLengthOption & Schema.Attribute.PrivateOption & Schema.Attribute.RequiredOption & Schema.Attribute.WritableOption & Schema.Attribute.VisibleOption) | {
|
109
59
|
type: string;
|
110
60
|
relation: string;
|
111
61
|
target: string;
|
@@ -169,7 +119,7 @@ export declare const transformAttribute: (name: string, attribute: Attribute.Any
|
|
169
119
|
morphBy?: undefined;
|
170
120
|
};
|
171
121
|
export declare const transformAttributes: (contentType: LoadedContentTypeModel) => {};
|
172
|
-
export declare const hasComponentsOrDz: (contentType: LoadedContentTypeModel) => contentType is
|
122
|
+
export declare const hasComponentsOrDz: (contentType: LoadedContentTypeModel) => contentType is Struct.ContentTypeSchema & Required<Pick<Struct.ContentTypeSchema, "uid" | "collectionName" | "modelName">> & {
|
173
123
|
type: 'dynamiczone' | 'component';
|
174
124
|
};
|
175
125
|
export declare const createDocumentId: typeof createId;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/transform-content-types-to-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,
|
1
|
+
{"version":3,"file":"transform-content-types-to-models.d.ts","sourceRoot":"","sources":["../../src/utils/transform-content-types-to-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMhD;;;;;GAKG;AAEH,eAAO,MAAM,2BAA2B,eAAe,CAAC;AACxD,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,6BAA6B,cAAc,CAAC;AACzD,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAO,MAAM,yBAAyB,mBAAoB,MAAM,WACmB,CAAC;AAEpF,eAAO,MAAM,kBAAkB,mBAAoB,MAAM,WACmB,CAAC;AAI7E,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,iBAAiB,GAC3D,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC;AAGnF,eAAO,MAAM,kBAAkB,SACvB,MAAM,aACD,OAAO,SAAS,CAAC,YAAY,eAC3B,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAiB,sBAAsB,OAOtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,sBAAsB;UACc,aAAa,GAAG,WAAW;CAI7E,CAAC;AAEF,eAAO,MAAM,gBAAgB,iBAAW,CAAC;AA6EzC,eAAO,MAAM,6BAA6B,iBAAkB,sBAAsB,EAAE,KAAG,KAAK,EAiD3F,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, utils } from '@strapi/database';\nimport { Schema, Attribute } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\nconst { identifiers } = utils;\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n */\n\nexport const COMPONENT_JOIN_TABLE_SUFFIX = 'components';\nexport const DZ_JOIN_TABLE_SUFFIX = 'components';\nexport const COMPONENT_INVERSE_COLUMN_NAME = 'component';\nexport const COMPONENT_TYPE_COLUMN = 'component_type';\nexport const ENTITY = 'entity';\n\nexport const getComponentJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: COMPONENT_JOIN_TABLE_SUFFIX });\n\nexport const getDzJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: DZ_JOIN_TABLE_SUFFIX });\n\nconst { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Schema.ContentType &\n Required<Pick<Schema.ContentType, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Attribute.Any,\n contentType: LoadedContentTypeModel\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n on: {\n field: name,\n },\n orderColumnName: order,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n typeColumn: {\n name: COMPONENT_TYPE_COLUMN,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (contentType: LoadedContentTypeModel) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(attrName, contentType.attributes[attrName]!, contentType),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n ({ type }) => type === 'dynamiczone' || type === 'component'\n );\n};\n\nexport const createDocumentId = createId;\n\n// Creates the\nconst createCompoLinkModel = (contentType: LoadedContentTypeModel): Model => {\n const name = getComponentJoinTableName(contentType.collectionName);\n\n const entityId = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const componentId = identifiers.getJoinColumnAttributeIdName(COMPONENT_INVERSE_COLUMN_NAME);\n const fkIndex = identifiers.getFkIndexName([contentType.collectionName, ENTITY]);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [id]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [COMPONENT_TYPE_COLUMN]: {\n type: 'string',\n },\n [field]: {\n type: 'string',\n },\n [order]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, field]),\n columns: [field],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, COMPONENT_TYPE_COLUMN]),\n columns: [COMPONENT_TYPE_COLUMN],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, field, COMPONENT_TYPE_COLUMN],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [id],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (contentTypes: LoadedContentTypeModel[]): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Attribute.Any> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', id];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: identifiers.getTableName(contentType.collectionName),\n attributes: {\n [id]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType),\n },\n };\n\n models.push(model);\n });\n\n return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AAAA,IAAA;AAGF,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"transform-content-types-to-models.js","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, utils } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\nconst { identifiers } = utils;\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n */\n\nexport const COMPONENT_JOIN_TABLE_SUFFIX = 'components';\nexport const DZ_JOIN_TABLE_SUFFIX = 'components';\nexport const COMPONENT_INVERSE_COLUMN_NAME = 'component';\nexport const COMPONENT_TYPE_COLUMN = 'component_type';\nexport const ENTITY = 'entity';\n\nexport const getComponentJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: COMPONENT_JOIN_TABLE_SUFFIX });\n\nexport const getDzJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: DZ_JOIN_TABLE_SUFFIX });\n\nconst { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n on: {\n field: name,\n },\n orderColumnName: order,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n typeColumn: {\n name: COMPONENT_TYPE_COLUMN,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (contentType: LoadedContentTypeModel) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(attrName, contentType.attributes[attrName]!, contentType),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n ({ type }) => type === 'dynamiczone' || type === 'component'\n );\n};\n\nexport const createDocumentId = createId;\n\n// Creates the\nconst createCompoLinkModel = (contentType: LoadedContentTypeModel): Model => {\n const name = getComponentJoinTableName(contentType.collectionName);\n\n const entityId = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const componentId = identifiers.getJoinColumnAttributeIdName(COMPONENT_INVERSE_COLUMN_NAME);\n const fkIndex = identifiers.getFkIndexName([contentType.collectionName, ENTITY]);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [id]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [COMPONENT_TYPE_COLUMN]: {\n type: 'string',\n },\n [field]: {\n type: 'string',\n },\n [order]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, field]),\n columns: [field],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, COMPONENT_TYPE_COLUMN]),\n columns: [COMPONENT_TYPE_COLUMN],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, field, COMPONENT_TYPE_COLUMN],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [id],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (contentTypes: LoadedContentTypeModel[]): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', id];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: identifiers.getTableName(contentType.collectionName),\n attributes: {\n [id]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType),\n },\n };\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":["utils","createId","assert","_"],"mappings":";;;;;;;;;AAMA,MAAM,EAAE,YAAgB,IAAAA;AASjB,MAAM,8BAA8B;AACpC,MAAM,uBAAuB;AAC7B,MAAM,gCAAgC;AACtC,MAAM,wBAAwB;AAC9B,MAAM,SAAS;AAET,MAAA,4BAA4B,CAAC,mBACxC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,6BAA6B;AAErE,MAAA,qBAAqB,CAAC,mBACjC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,sBAAsB;AAE3E,MAAM,EAAE,WAAW,IAAI,cAAc,OAAO,cAAc,MAAU,IAAA;AAM7D,MAAM,qBAAqB,CAChC,MACA,WACA,gBACG;AACH,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,SAAS;AACL,aAAA;AAAA,QACL,MAAM;AAAA,QACN,UAAU,UAAU,aAAa,OAAO,cAAc;AAA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;AAIA,UAAA,yBAAyB,CAAC,eAAe,EAAE;AAC1C,WAAA,KAAK,YAAY,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,kBAAkB;AAC7D,YAAA,0BAA0BC,WAAAA,QAAE,UAAU,aAAa;AACrD,UAAA,uBAAuB,SAAS,uBAAuB,GAAG;AAC5D,cAAM,IAAI;AAAA,UACR,kBAAkB,aAAa,+DAA+D,YAAY,SAAS,gBAAgB,aAAa;AAAA,QAAA;AAAA,MAEpJ;AAAA,IAAA,CACD;AAEG,QAAA,kBAAkB,WAAW,GAAG;AAC5B,YAAA,iBAAiB,qBAAqB,WAAW;AACvD,aAAO,KAAK,cAAc;AAAA,IAC5B;AAEA,UAAM,QAAe;AAAA,MACnB,KAAK,YAAY;AAAA,MACjB,cAAc,YAAY;AAAA,MAC1B,WAAW,YAAY,aAAa,YAAY,cAAc;AAAA,MAC9D,YAAY;AAAA,QACV,CAAC,EAAE,GAAG;AAAA,UACJ,MAAM;AAAA,QACR;AAAA,QACA,GAAG;AAAA,QACH,GAAG,oBAAoB,WAAW;AAAA,MACpC;AAAA,IAAA;AAGF,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;;;;;;;;;;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, utils } from '@strapi/database';\nimport { Schema, Attribute } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\nconst { identifiers } = utils;\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n */\n\nexport const COMPONENT_JOIN_TABLE_SUFFIX = 'components';\nexport const DZ_JOIN_TABLE_SUFFIX = 'components';\nexport const COMPONENT_INVERSE_COLUMN_NAME = 'component';\nexport const COMPONENT_TYPE_COLUMN = 'component_type';\nexport const ENTITY = 'entity';\n\nexport const getComponentJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: COMPONENT_JOIN_TABLE_SUFFIX });\n\nexport const getDzJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: DZ_JOIN_TABLE_SUFFIX });\n\nconst { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Schema.ContentType &\n Required<Pick<Schema.ContentType, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Attribute.Any,\n contentType: LoadedContentTypeModel\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n on: {\n field: name,\n },\n orderColumnName: order,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n typeColumn: {\n name: COMPONENT_TYPE_COLUMN,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (contentType: LoadedContentTypeModel) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(attrName, contentType.attributes[attrName]!, contentType),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n ({ type }) => type === 'dynamiczone' || type === 'component'\n );\n};\n\nexport const createDocumentId = createId;\n\n// Creates the\nconst createCompoLinkModel = (contentType: LoadedContentTypeModel): Model => {\n const name = getComponentJoinTableName(contentType.collectionName);\n\n const entityId = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const componentId = identifiers.getJoinColumnAttributeIdName(COMPONENT_INVERSE_COLUMN_NAME);\n const fkIndex = identifiers.getFkIndexName([contentType.collectionName, ENTITY]);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [id]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [COMPONENT_TYPE_COLUMN]: {\n type: 'string',\n },\n [field]: {\n type: 'string',\n },\n [order]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, field]),\n columns: [field],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, COMPONENT_TYPE_COLUMN]),\n columns: [COMPONENT_TYPE_COLUMN],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, field, COMPONENT_TYPE_COLUMN],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [id],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (contentTypes: LoadedContentTypeModel[]): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Attribute.Any> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', id];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: identifiers.getTableName(contentType.collectionName),\n attributes: {\n [id]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType),\n },\n };\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,EAAE,YAAgB,IAAA;AASjB,MAAM,8BAA8B;AACpC,MAAM,uBAAuB;AAC7B,MAAM,gCAAgC;AACtC,MAAM,wBAAwB;AAC9B,MAAM,SAAS;AAET,MAAA,4BAA4B,CAAC,mBACxC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,6BAA6B;AAErE,MAAA,qBAAqB,CAAC,mBACjC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,sBAAsB;AAE3E,MAAM,EAAE,WAAW,IAAI,cAAc,OAAO,cAAc,MAAU,IAAA;AAM7D,MAAM,qBAAqB,CAChC,MACA,WACA,gBACG;AACH,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,SAAS;AACL,aAAA;AAAA,QACL,MAAM;AAAA,QACN,UAAU,UAAU,aAAa,OAAO,cAAc;AAAA,QACtD,QAAQ;AAAA,QACR,SAAS;AAAA,MAAA;AAAA,IAEb;AAAA,IACA,KAAK,aAAa;AACV,YAAA,gBAAgB,0BAA0B,YAAY,cAAc;AACpE,YAAA,uBAAuB,YAAY,6BAA6B,MAAM;AAC5E,YAAM,wBAAwB,YAAY;AAAA,QACxC;AAAA,MAAA;AAGK,aAAA;AAAA,QACL,MAAM;AAAA,QACN,UAAU,UAAU,eAAe,OAAO,cAAc;AAAA,QACxD,QAAQ,UAAU;AAAA;AAAA;AAAA,QAIlB,WAAW;AAAA,UACT,MAAM;AAAA,UACN,YAAY;AAAA,YACV,MAAM;AAAA,YACN,kBAAkB;AAAA,UACpB;AAAA,UACA,mBAAmB;AAAA,YACjB,MAAM;AAAA,YACN,kBAAkB;AAAA,UACpB;AAAA,UACA,IAAI;AAAA,YACF,OAAO;AAAA,UACT;AAAA,UACA,iBAAiB;AAAA,UACjB,SAAS;AAAA,YACP,OAAO;AA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AA,QACH,GAAG,oBAAoB,WAAW;AAAA,MACpC;AAAA,IAAA;AAGF,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;"}
|
1
|
+
{"version":3,"file":"transform-content-types-to-models.mjs","sources":["../../src/utils/transform-content-types-to-models.ts"],"sourcesContent":["import { type Model, utils } from '@strapi/database';\nimport type { Struct, Schema } from '@strapi/types';\nimport { createId } from '@paralleldrive/cuid2';\nimport assert from 'node:assert';\nimport _ from 'lodash/fp';\n\nconst { identifiers } = utils;\n\n/**\n * Because strapi/database models don't know about things like components or dynamic zones, we use this file to convert them\n * to a relations format that it recognizes\n *\n * Therefore we have to keep an additional set of helpers/extensions to the database naming methods\n */\n\nexport const COMPONENT_JOIN_TABLE_SUFFIX = 'components';\nexport const DZ_JOIN_TABLE_SUFFIX = 'components';\nexport const COMPONENT_INVERSE_COLUMN_NAME = 'component';\nexport const COMPONENT_TYPE_COLUMN = 'component_type';\nexport const ENTITY = 'entity';\n\nexport const getComponentJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: COMPONENT_JOIN_TABLE_SUFFIX });\n\nexport const getDzJoinTableName = (collectionName: string) =>\n identifiers.getTableName(collectionName, { suffix: DZ_JOIN_TABLE_SUFFIX });\n\nconst { ID_COLUMN: id, FIELD_COLUMN: field, ORDER_COLUMN: order } = identifiers;\n\nexport type LoadedContentTypeModel = Struct.ContentTypeSchema &\n Required<Pick<Struct.ContentTypeSchema, 'collectionName' | 'uid' | 'modelName'>>;\n\n// Transforms an attribute (particularly for relation types) into the format that strapi/database accepts\nexport const transformAttribute = (\n name: string,\n attribute: Schema.Attribute.AnyAttribute,\n contentType: LoadedContentTypeModel\n) => {\n switch (attribute.type) {\n case 'media': {\n return {\n type: 'relation',\n relation: attribute.multiple === true ? 'morphMany' : 'morphOne',\n target: 'plugin::upload.file',\n morphBy: 'related',\n };\n }\n case 'component': {\n const joinTableName = getComponentJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: attribute.repeatable === true ? 'oneToMany' : 'oneToOne',\n target: attribute.component,\n\n // We need the join table name to be deterministic,\n // We need to allow passing the join table name as an option\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n inverseJoinColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n on: {\n field: name,\n },\n orderColumnName: order,\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n case 'dynamiczone': {\n const joinTableName = getDzJoinTableName(contentType.collectionName);\n const joinColumnEntityName = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const joinColumnInverseName = identifiers.getJoinColumnAttributeIdName(\n COMPONENT_INVERSE_COLUMN_NAME\n );\n\n return {\n type: 'relation',\n relation: 'morphToMany',\n // TODO: handle restrictions at some point\n // target: attribute.components,\n joinTable: {\n name: joinTableName,\n joinColumn: {\n name: joinColumnEntityName,\n referencedColumn: id,\n },\n morphColumn: {\n idColumn: {\n name: joinColumnInverseName,\n referencedColumn: id,\n },\n typeColumn: {\n name: COMPONENT_TYPE_COLUMN,\n },\n typeField: '__component',\n },\n on: {\n field: name,\n },\n orderBy: {\n order: 'asc',\n },\n pivotColumns: [joinColumnEntityName, joinColumnInverseName, field, COMPONENT_TYPE_COLUMN],\n },\n };\n }\n default: {\n return attribute;\n }\n }\n};\n\nexport const transformAttributes = (contentType: LoadedContentTypeModel) => {\n return Object.keys(contentType.attributes! || {}).reduce((attrs, attrName) => {\n return {\n ...attrs,\n [attrName]: transformAttribute(attrName, contentType.attributes[attrName]!, contentType),\n };\n }, {});\n};\n\nexport const hasComponentsOrDz = (\n contentType: LoadedContentTypeModel\n): contentType is LoadedContentTypeModel & { type: 'dynamiczone' | 'component' } => {\n return Object.values(contentType.attributes || {}).some(\n ({ type }) => type === 'dynamiczone' || type === 'component'\n );\n};\n\nexport const createDocumentId = createId;\n\n// Creates the\nconst createCompoLinkModel = (contentType: LoadedContentTypeModel): Model => {\n const name = getComponentJoinTableName(contentType.collectionName);\n\n const entityId = identifiers.getJoinColumnAttributeIdName(ENTITY);\n const componentId = identifiers.getJoinColumnAttributeIdName(COMPONENT_INVERSE_COLUMN_NAME);\n const fkIndex = identifiers.getFkIndexName([contentType.collectionName, ENTITY]);\n\n return {\n // TODO: make sure there can't be any conflicts with a prefix\n singularName: name,\n uid: name,\n tableName: name,\n attributes: {\n [id]: {\n type: 'increments',\n },\n [entityId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [componentId]: {\n type: 'integer',\n column: {\n unsigned: true,\n },\n },\n [COMPONENT_TYPE_COLUMN]: {\n type: 'string',\n },\n [field]: {\n type: 'string',\n },\n [order]: {\n type: 'float',\n column: {\n unsigned: true,\n defaultTo: null,\n },\n },\n },\n indexes: [\n {\n name: identifiers.getIndexName([contentType.collectionName, field]),\n columns: [field],\n },\n {\n name: identifiers.getIndexName([contentType.collectionName, COMPONENT_TYPE_COLUMN]),\n columns: [COMPONENT_TYPE_COLUMN],\n },\n {\n name: fkIndex,\n columns: [entityId],\n },\n {\n // NOTE: since we don't include attribute names, we need to be careful not to create another unique index\n name: identifiers.getUniqueIndexName([contentType.collectionName]),\n columns: [entityId, componentId, field, COMPONENT_TYPE_COLUMN],\n type: 'unique',\n },\n ],\n foreignKeys: [\n {\n name: fkIndex,\n columns: [entityId],\n referencedColumns: [id],\n referencedTable: identifiers.getTableName(contentType.collectionName),\n onDelete: 'CASCADE',\n },\n ],\n };\n};\n\nexport const transformContentTypesToModels = (contentTypes: LoadedContentTypeModel[]): Model[] => {\n const models: Model[] = [];\n\n contentTypes.forEach((contentType) => {\n assert(contentType.collectionName, 'Content type \"collectionName\" is required');\n assert(contentType.modelName, 'Content type \"modelName\" is required');\n assert(contentType.uid, 'Content type \"uid\" is required');\n\n // Add document id to content types\n // as it is not documented\n const documentIdAttribute: Record<string, Schema.Attribute.AnyAttribute> =\n contentType.modelType === 'contentType'\n ? { documentId: { type: 'string', default: createDocumentId } }\n : {};\n\n // TODO: this needs to be combined with getReservedNames, we should not be maintaining two lists\n // Prevent user from creating a documentId attribute\n const reservedAttributeNames = ['document_id', id];\n Object.keys(contentType.attributes || {}).forEach((attributeName) => {\n const snakeCasedAttributeName = _.snakeCase(attributeName);\n if (reservedAttributeNames.includes(snakeCasedAttributeName)) {\n throw new Error(\n `The attribute \"${attributeName}\" is reserved and cannot be used in a model. Please rename \"${contentType.modelName}\" attribute \"${attributeName}\" to something else.`\n );\n }\n });\n\n if (hasComponentsOrDz(contentType)) {\n const compoLinkModel = createCompoLinkModel(contentType);\n models.push(compoLinkModel);\n }\n\n const model: Model = {\n uid: contentType.uid,\n singularName: contentType.modelName,\n tableName: identifiers.getTableName(contentType.collectionName),\n attributes: {\n [id]: {\n type: 'increments',\n },\n ...documentIdAttribute,\n ...transformAttributes(contentType),\n },\n };\n\n models.push(model);\n });\n\n return models;\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,EAAE,YAAgB,IAAA;AASjB,MAAM,8BAA8B;AACpC,MAAM,uBAAuB;AAC7B,MAAM,gCAAgC;AACtC,MAAM,wBAAwB;AAC9B,MAAM,SAAS;AAET,MAAA,4BAA4B,CAAC,mBACxC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,6BAA6B;AAErE,MAAA,qBAAqB,CAAC,mBACjC,YAAY,aAAa,gBAAgB,EAAE,QAAQ,sBAAsB;AAE3E,MAAM,EAAE,WAAW,IAAI,cAAc,OAAO,cAAc,MAAU,IAAA;AAM7D,MAAM,qBAAqB,CAChC,MACA,WACA,gBACG;AACH,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,SAAS;AACL,aAAA;AAAA,QACL,MAAM;AAAA,QACN,UAAU,UAAU,aAAa,OAAO,c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eAAe,EAAE;AAC1C,WAAA,KAAK,YAAY,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,kBAAkB;AAC7D,YAAA,0BAA0B,EAAE,UAAU,aAAa;AACrD,UAAA,uBAAuB,SAAS,uBAAuB,GAAG;AAC5D,cAAM,IAAI;AAAA,UACR,kBAAkB,aAAa,+DAA+D,YAAY,SAAS,gBAAgB,aAAa;AAAA,QAAA;AAAA,MAEpJ;AAAA,IAAA,CACD;AAEG,QAAA,kBAAkB,WAAW,GAAG;AAC5B,YAAA,iBAAiB,qBAAqB,WAAW;AACvD,aAAO,KAAK,cAAc;AAAA,IAC5B;AAEA,UAAM,QAAe;AAAA,MACnB,KAAK,YAAY;AAAA,MACjB,cAAc,YAAY;AAAA,MAC1B,WAAW,YAAY,aAAa,YAAY,cAAc;AAAA,MAC9D,YAAY;AAAA,QACV,CAAC,EAAE,GAAG;AAAA,UACJ,MAAM;AAAA,QACR;AAAA,QACA,GAAG;AAAA,QACH,GAAG,oBAAoB,WAAW;AAAA,MACpC;AAAA,IAAA;AAGF,WAAO,KAAK,KAAK;AAAA,EAAA,CAClB;AAEM,SAAA;AACT;"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
export declare const createUpdateNotifier: (strapi: Strapi) => {
|
1
|
+
import type { Core } from '@strapi/types';
|
2
|
+
export declare const createUpdateNotifier: (strapi: Core.Strapi) => {
|
3
3
|
notify({ checkInterval, notifInterval }?: {
|
4
4
|
checkInterval?: number | undefined;
|
5
5
|
notifInterval?: number | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/update-notifier/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/update-notifier/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AA0B1C,eAAO,MAAM,oBAAoB,WAAY,KAAK,MAAM;;;;;CAqEvD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/update-notifier/index.ts"],"sourcesContent":["import path from 'path';\nimport packageJson from 'package-json';\nimport Configstore from 'configstore';\nimport semver from 'semver';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { env } from '@strapi/utils';\nimport type {
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/update-notifier/index.ts"],"sourcesContent":["import path from 'path';\nimport packageJson from 'package-json';\nimport Configstore from 'configstore';\nimport semver from 'semver';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { env } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../../../package.json');\n\nconst CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day\nconst NOTIF_INTERVAL = 1000 * 60 * 60 * 24 * 7; // 1 week\nconst boxenOptions: boxen.Options = {\n padding: 1,\n margin: 1,\n align: 'center',\n borderColor: 'yellow',\n borderStyle: 'round',\n};\n\nconst getUpdateMessage = (newVersion: string, currentVersion: string) => {\n const currentVersionLog = chalk.dim(currentVersion);\n const newVersionLog = chalk.green(newVersion);\n const releaseLink = chalk.bold('https://github.com/strapi/strapi/releases');\n\n return `\nA new version of Strapi is available ${currentVersionLog} → ${newVersionLog}\nCheck out the new releases at: ${releaseLink}\n`.trim();\n};\n\nexport const createUpdateNotifier = (strapi: Core.Strapi) => {\n let config: InstanceType<typeof Configstore>;\n\n try {\n config = new Configstore(\n pkg.name,\n {},\n { configPath: path.join(strapi.dirs.app.root, '.strapi-updater.json') }\n );\n } catch {\n // we don't have write access to the file system\n // we silence the error\n }\n\n const checkUpdate = async (checkInterval: number) => {\n const now = Date.now();\n const lastUpdateCheck = config.get('lastUpdateCheck') || 0;\n if (lastUpdateCheck + checkInterval > now) {\n return;\n }\n\n try {\n const res = await packageJson(pkg.name);\n if (res.version) {\n config.set('latest', res.version);\n config.set('lastUpdateCheck', now);\n }\n } catch {\n // silence error if offline\n }\n };\n\n const display = (notifInterval: number) => {\n const now = Date.now();\n const latestVersion = config.get('latest');\n const lastNotification = config.get('lastNotification') || 0;\n\n if (\n !process.stdout.isTTY ||\n lastNotification + notifInterval > now ||\n !semver.valid(latestVersion) ||\n !semver.valid(pkg.version) ||\n semver.lte(latestVersion, pkg.version)\n ) {\n return;\n }\n\n const message = boxen(getUpdateMessage(latestVersion, pkg.version), boxenOptions);\n config.set('lastNotification', now);\n console.log(message);\n };\n\n return {\n notify({ checkInterval = CHECK_INTERVAL, notifInterval = NOTIF_INTERVAL } = {}) {\n // TODO v6: Remove this warning\n if (env.bool('STRAPI_DISABLE_UPDATE_NOTIFICATION', false)) {\n strapi.log.warn(\n 'STRAPI_DISABLE_UPDATE_NOTIFICATION is no longer supported. Instead, set logger.updates.enabled to false in your server configuration.'\n );\n }\n\n if (!strapi.config.get('server.logger.updates.enabled') || !config) {\n return;\n }\n\n display(notifInterval);\n checkUpdate(checkInterval); // doesn't need to await\n },\n };\n};\n"],"names":["chalk","Configstore","path","packageJson","semver","boxen","env"],"mappings":";;;;;;;;;;;;;;;;AAUA,MAAM,MAAM,QAAQ,uBAAuB;AAE3C,MAAM,iBAAiB,MAAO,KAAK,KAAK,KAAK;AAC7C,MAAM,iBAAiB,MAAO,KAAK,KAAK,KAAK;AAC7C,MAAM,eAA8B;AAAA,EAClC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,aAAa;AACf;AAEA,MAAM,mBAAmB,CAAC,YAAoB,mBAA2B;AACjE,QAAA,oBAAoBA,eAAAA,QAAM,IAAI,cAAc;AAC5C,QAAA,gBAAgBA,eAAAA,QAAM,MAAM,UAAU;AACtC,QAAA,cAAcA,eAAAA,QAAM,KAAK,2CAA2C;AAEnE,SAAA;AAAA,uCAC8B,iBAAiB,MAAM,aAAa;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,GAAG;AACzD,eAAO,IAAI;AAAA,UACT;AAAA,QAAA;AAAA,MAEJ;AAEA,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,KAAK,CAAC,QAAQ;AAClE;AAAA,MACF;AAEA,cAAQ,aAAa;AACrB,kBAAY,aAAa;AAAA,IAC3B;AAAA,EAAA;AAEJ;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/utils/update-notifier/index.ts"],"sourcesContent":["import path from 'path';\nimport packageJson from 'package-json';\nimport Configstore from 'configstore';\nimport semver from 'semver';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { env } from '@strapi/utils';\nimport type {
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/utils/update-notifier/index.ts"],"sourcesContent":["import path from 'path';\nimport packageJson from 'package-json';\nimport Configstore from 'configstore';\nimport semver from 'semver';\nimport boxen from 'boxen';\nimport chalk from 'chalk';\nimport { env } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../../../package.json');\n\nconst CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day\nconst NOTIF_INTERVAL = 1000 * 60 * 60 * 24 * 7; // 1 week\nconst boxenOptions: boxen.Options = {\n padding: 1,\n margin: 1,\n align: 'center',\n borderColor: 'yellow',\n borderStyle: 'round',\n};\n\nconst getUpdateMessage = (newVersion: string, currentVersion: string) => {\n const currentVersionLog = chalk.dim(currentVersion);\n const newVersionLog = chalk.green(newVersion);\n const releaseLink = chalk.bold('https://github.com/strapi/strapi/releases');\n\n return `\nA new version of Strapi is available ${currentVersionLog} → ${newVersionLog}\nCheck out the new releases at: ${releaseLink}\n`.trim();\n};\n\nexport const createUpdateNotifier = (strapi: Core.Strapi) => {\n let config: InstanceType<typeof Configstore>;\n\n try {\n config = new Configstore(\n pkg.name,\n {},\n { configPath: path.join(strapi.dirs.app.root, '.strapi-updater.json') }\n );\n } catch {\n // we don't have write access to the file system\n // we silence the error\n }\n\n const checkUpdate = async (checkInterval: number) => {\n const now = Date.now();\n const lastUpdateCheck = config.get('lastUpdateCheck') || 0;\n if (lastUpdateCheck + checkInterval > now) {\n return;\n }\n\n try {\n const res = await packageJson(pkg.name);\n if (res.version) {\n config.set('latest', res.version);\n config.set('lastUpdateCheck', now);\n }\n } catch {\n // silence error if offline\n }\n };\n\n const display = (notifInterval: number) => {\n const now = Date.now();\n const latestVersion = config.get('latest');\n const lastNotification = config.get('lastNotification') || 0;\n\n if (\n !process.stdout.isTTY ||\n lastNotification + notifInterval > now ||\n !semver.valid(latestVersion) ||\n !semver.valid(pkg.version) ||\n semver.lte(latestVersion, pkg.version)\n ) {\n return;\n }\n\n const message = boxen(getUpdateMessage(latestVersion, pkg.version), boxenOptions);\n config.set('lastNotification', now);\n console.log(message);\n };\n\n return {\n notify({ checkInterval = CHECK_INTERVAL, notifInterval = NOTIF_INTERVAL } = {}) {\n // TODO v6: Remove this warning\n if (env.bool('STRAPI_DISABLE_UPDATE_NOTIFICATION', false)) {\n strapi.log.warn(\n 'STRAPI_DISABLE_UPDATE_NOTIFICATION is no longer supported. Instead, set logger.updates.enabled to false in your server configuration.'\n );\n }\n\n if (!strapi.config.get('server.logger.updates.enabled') || !config) {\n return;\n }\n\n display(notifInterval);\n checkUpdate(checkInterval); // doesn't need to await\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,MAAM,QAAQ,uBAAuB;AAE3C,MAAM,iBAAiB,MAAO,KAAK,KAAK,KAAK;AAC7C,MAAM,iBAAiB,MAAO,KAAK,KAAK,KAAK;AAC7C,MAAM,eAA8B;AAAA,EAClC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,aAAa;AACf;AAEA,MAAM,mBAAmB,CAAC,YAAoB,mBAA2B;AACjE,QAAA,oBAAoB,MAAM,IAAI,cAAc;AAC5C,QAAA,gBAAgB,MAAM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gB,eAAe,IAAI,IAAI;AAE9E,UAAI,IAAI,KAAK,sCAAsC,KAAK,GAAG;AACzD,eAAO,IAAI;AAAA,UACT;AAAA,QAAA;AAAA,MAEJ;AAEA,UAAI,CAAC,OAAO,OAAO,IAAI,+BAA+B,KAAK,CAAC,QAAQ;AAClE;AAAA,MACF;AAEA,cAAQ,aAAa;AACrB,kBAAY,aAAa;AAAA,IAC3B;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@strapi/core",
|
3
|
-
"version": "5.0.0-alpha.
|
3
|
+
"version": "5.0.0-alpha.8",
|
4
4
|
"description": "Core of Strapi",
|
5
5
|
"homepage": "https://strapi.io",
|
6
6
|
"bugs": {
|
@@ -55,16 +55,16 @@
|
|
55
55
|
"@koa/cors": "3.4.3",
|
56
56
|
"@koa/router": "10.1.1",
|
57
57
|
"@paralleldrive/cuid2": "2.2.2",
|
58
|
-
"@strapi/admin": "5.0.0-alpha.
|
59
|
-
"@strapi/database": "5.0.0-alpha.
|
60
|
-
"@strapi/generate-new": "5.0.0-alpha.
|
61
|
-
"@strapi/generators": "5.0.0-alpha.
|
62
|
-
"@strapi/logger": "5.0.0-alpha.
|
63
|
-
"@strapi/pack-up": "5.0.0-alpha.
|
64
|
-
"@strapi/permissions": "5.0.0-alpha.
|
65
|
-
"@strapi/types": "5.0.0-alpha.
|
66
|
-
"@strapi/typescript-utils": "5.0.0-alpha.
|
67
|
-
"@strapi/utils": "5.0.0-alpha.
|
58
|
+
"@strapi/admin": "5.0.0-alpha.8",
|
59
|
+
"@strapi/database": "5.0.0-alpha.8",
|
60
|
+
"@strapi/generate-new": "5.0.0-alpha.8",
|
61
|
+
"@strapi/generators": "5.0.0-alpha.8",
|
62
|
+
"@strapi/logger": "5.0.0-alpha.8",
|
63
|
+
"@strapi/pack-up": "5.0.0-alpha.8",
|
64
|
+
"@strapi/permissions": "5.0.0-alpha.8",
|
65
|
+
"@strapi/types": "5.0.0-alpha.8",
|
66
|
+
"@strapi/typescript-utils": "5.0.0-alpha.8",
|
67
|
+
"@strapi/utils": "5.0.0-alpha.8",
|
68
68
|
"bcryptjs": "2.4.3",
|
69
69
|
"boxen": "5.1.2",
|
70
70
|
"chalk": "4.1.2",
|
@@ -122,13 +122,13 @@
|
|
122
122
|
"@types/node": "18.19.24",
|
123
123
|
"@types/node-schedule": "2.1.0",
|
124
124
|
"@types/statuses": "2.0.1",
|
125
|
-
"eslint-config-custom": "5.0.0-alpha.
|
125
|
+
"eslint-config-custom": "5.0.0-alpha.8",
|
126
126
|
"supertest": "6.3.3",
|
127
|
-
"tsconfig": "5.0.0-alpha.
|
127
|
+
"tsconfig": "5.0.0-alpha.8"
|
128
128
|
},
|
129
129
|
"engines": {
|
130
130
|
"node": ">=18.0.0 <=20.x.x",
|
131
131
|
"npm": ">=6.0.0"
|
132
132
|
},
|
133
|
-
"gitHead": "
|
133
|
+
"gitHead": "ac4bbf6602523215c40548a8a09079076b3dadda"
|
134
134
|
}
|