@strapi/core 0.0.0-experimental.3f7b2587c5e3d548262671895cf11d8bf8c → 0.0.0-experimental.45c1b845d32b56e7c14f4155ec0d4a2d2774c77e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +8 -4
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +7 -3
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +4 -4
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +1 -1
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/configuration/urls.d.ts +8 -0
- package/dist/configuration/urls.d.ts.map +1 -0
- package/dist/configuration/urls.js +68 -0
- package/dist/configuration/urls.js.map +1 -0
- package/dist/configuration/urls.mjs +66 -0
- package/dist/configuration/urls.mjs.map +1 -0
- package/dist/core-api/controller/collection-type.d.ts +1 -1
- package/dist/core-api/controller/collection-type.d.ts.map +1 -1
- package/dist/core-api/controller/collection-type.js +9 -20
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs +8 -20
- package/dist/core-api/controller/collection-type.mjs.map +1 -1
- package/dist/core-api/controller/index.d.ts.map +1 -1
- package/dist/core-api/controller/index.js +8 -3
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs +8 -3
- package/dist/core-api/controller/index.mjs.map +1 -1
- package/dist/core-api/controller/single-type.d.ts +1 -1
- package/dist/core-api/controller/single-type.d.ts.map +1 -1
- package/dist/core-api/controller/single-type.js +6 -11
- package/dist/core-api/controller/single-type.js.map +1 -1
- package/dist/core-api/controller/single-type.mjs +5 -11
- package/dist/core-api/controller/single-type.mjs.map +1 -1
- package/dist/core-api/controller/transform.d.ts +9 -17
- package/dist/core-api/controller/transform.d.ts.map +1 -1
- package/dist/core-api/controller/transform.js +9 -14
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs +9 -14
- package/dist/core-api/controller/transform.mjs.map +1 -1
- package/dist/core-api/service/collection-type.d.ts +28 -5
- package/dist/core-api/service/collection-type.d.ts.map +1 -1
- package/dist/core-api/service/collection-type.js +47 -49
- package/dist/core-api/service/collection-type.js.map +1 -1
- package/dist/core-api/service/collection-type.mjs +47 -50
- package/dist/core-api/service/collection-type.mjs.map +1 -1
- package/dist/core-api/service/core-service.d.ts +4 -0
- package/dist/core-api/service/core-service.d.ts.map +1 -0
- package/dist/core-api/service/core-service.js +12 -0
- package/dist/core-api/service/core-service.js.map +1 -0
- package/dist/core-api/service/core-service.mjs +12 -0
- package/dist/core-api/service/core-service.mjs.map +1 -0
- package/dist/core-api/service/index.js +2 -2
- package/dist/core-api/service/index.js.map +1 -1
- package/dist/core-api/service/index.mjs +4 -4
- package/dist/core-api/service/index.mjs.map +1 -1
- package/dist/core-api/service/pagination.d.ts +1 -5
- package/dist/core-api/service/pagination.d.ts.map +1 -1
- package/dist/core-api/service/pagination.js +0 -11
- package/dist/core-api/service/pagination.js.map +1 -1
- package/dist/core-api/service/pagination.mjs +0 -11
- package/dist/core-api/service/pagination.mjs.map +1 -1
- package/dist/core-api/service/single-type.d.ts +14 -8
- package/dist/core-api/service/single-type.d.ts.map +1 -1
- package/dist/core-api/service/single-type.js +35 -50
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +34 -50
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +3 -0
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +3 -0
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/domain/content-type/validator.d.ts.map +1 -1
- package/dist/domain/content-type/validator.js +1 -1
- package/dist/domain/content-type/validator.js.map +1 -1
- package/dist/domain/content-type/validator.mjs +2 -2
- package/dist/domain/content-type/validator.mjs.map +1 -1
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +2 -3
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +2 -3
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +2 -12
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +2 -12
- package/dist/factories.mjs.map +1 -1
- package/dist/loaders/apis.js +1 -1
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs +2 -2
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs +2 -2
- package/dist/loaders/plugins/get-enabled-plugins.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 +14 -6
- package/dist/registries/config.js.map +1 -1
- package/dist/registries/config.mjs +15 -5
- package/dist/registries/config.mjs.map +1 -1
- package/dist/registries/content-types.d.ts.map +1 -1
- package/dist/registries/content-types.js +1 -2
- package/dist/registries/content-types.js.map +1 -1
- package/dist/registries/content-types.mjs +1 -2
- package/dist/registries/content-types.mjs.map +1 -1
- package/dist/services/document-service/common.d.ts +4 -0
- package/dist/services/document-service/common.d.ts.map +1 -0
- package/dist/services/document-service/common.js +7 -0
- package/dist/services/document-service/common.js.map +1 -0
- package/dist/services/document-service/common.mjs +7 -0
- package/dist/services/document-service/common.mjs.map +1 -0
- package/dist/services/document-service/draft-and-publish.d.ts +10 -0
- package/dist/services/document-service/draft-and-publish.d.ts.map +1 -0
- package/dist/services/document-service/draft-and-publish.js +69 -0
- package/dist/services/document-service/draft-and-publish.js.map +1 -0
- package/dist/services/document-service/draft-and-publish.mjs +69 -0
- package/dist/services/document-service/draft-and-publish.mjs.map +1 -0
- package/dist/services/document-service/{document-service.d.ts → index.d.ts} +2 -4
- package/dist/services/document-service/index.d.ts.map +1 -0
- package/dist/services/document-service/index.js +22 -0
- package/dist/services/document-service/index.js.map +1 -0
- package/dist/services/document-service/index.mjs +22 -0
- package/dist/services/document-service/index.mjs.map +1 -0
- package/dist/services/document-service/internationalization.d.ts +8 -0
- package/dist/services/document-service/internationalization.d.ts.map +1 -0
- package/dist/services/document-service/internationalization.js +54 -0
- package/dist/services/document-service/internationalization.js.map +1 -0
- package/dist/services/document-service/internationalization.mjs +54 -0
- package/dist/services/document-service/internationalization.mjs.map +1 -0
- package/dist/services/document-service/middlewares.d.ts +8 -0
- package/dist/services/document-service/middlewares.d.ts.map +1 -0
- package/dist/services/document-service/middlewares.js +46 -0
- package/dist/services/document-service/middlewares.js.map +1 -0
- package/dist/services/document-service/middlewares.mjs +46 -0
- package/dist/services/document-service/middlewares.mjs.map +1 -0
- package/dist/services/document-service/repository.d.ts +3 -0
- package/dist/services/document-service/repository.d.ts.map +1 -0
- package/dist/services/document-service/repository.js +304 -0
- package/dist/services/document-service/repository.js.map +1 -0
- package/dist/services/document-service/repository.mjs +304 -0
- package/dist/services/document-service/repository.mjs.map +1 -0
- package/dist/services/document-service/transform/data.d.ts +5 -0
- package/dist/services/document-service/transform/data.d.ts.map +1 -0
- package/dist/services/document-service/transform/data.js +13 -0
- package/dist/services/document-service/transform/data.js.map +1 -0
- package/dist/services/document-service/transform/data.mjs +13 -0
- package/dist/services/document-service/transform/data.mjs.map +1 -0
- package/dist/services/document-service/transform/fields.d.ts +5 -0
- package/dist/services/document-service/transform/fields.d.ts.map +1 -0
- package/dist/services/document-service/transform/fields.js +24 -0
- package/dist/services/document-service/transform/fields.js.map +1 -0
- package/dist/services/document-service/transform/fields.mjs +24 -0
- package/dist/services/document-service/transform/fields.mjs.map +1 -0
- package/dist/services/document-service/transform/filters.d.ts +3 -0
- package/dist/services/document-service/transform/filters.d.ts.map +1 -0
- package/dist/services/document-service/transform/id-map.d.ts +23 -0
- package/dist/services/document-service/transform/id-map.d.ts.map +1 -0
- package/dist/services/document-service/transform/id-map.js +78 -0
- package/dist/services/document-service/transform/id-map.js.map +1 -0
- package/dist/services/document-service/transform/id-map.mjs +78 -0
- package/dist/services/document-service/transform/id-map.mjs.map +1 -0
- package/dist/services/document-service/transform/id-transform.d.ts +5 -0
- package/dist/services/document-service/transform/id-transform.d.ts.map +1 -0
- package/dist/services/document-service/transform/id-transform.js +33 -0
- package/dist/services/document-service/transform/id-transform.js.map +1 -0
- package/dist/services/document-service/transform/id-transform.mjs +33 -0
- package/dist/services/document-service/transform/id-transform.mjs.map +1 -0
- package/dist/services/document-service/transform/populate.d.ts +6 -0
- package/dist/services/document-service/transform/populate.d.ts.map +1 -0
- package/dist/services/document-service/transform/populate.js +21 -0
- package/dist/services/document-service/transform/populate.js.map +1 -0
- package/dist/services/document-service/transform/populate.mjs +21 -0
- package/dist/services/document-service/transform/populate.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +13 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.js +90 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs +90 -0
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts +10 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.js +141 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +141 -0
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts +4 -0
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/data.d.ts +4 -0
- package/dist/services/document-service/transform/relations/utils/data.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/data.js +12 -0
- package/dist/services/document-service/transform/relations/utils/data.js.map +1 -0
- package/dist/services/document-service/transform/relations/utils/data.mjs +12 -0
- package/dist/services/document-service/transform/relations/utils/data.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.d.ts +10 -0
- package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.js +25 -0
- package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.mjs +25 -0
- package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts +10 -0
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/i18n.js +31 -0
- package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -0
- package/dist/services/document-service/transform/relations/utils/i18n.mjs +31 -0
- package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/utils/types.d.ts +15 -0
- package/dist/services/document-service/transform/relations/utils/types.d.ts.map +1 -0
- package/dist/services/document-service/transform/sort.d.ts +5 -0
- package/dist/services/document-service/transform/sort.d.ts.map +1 -0
- package/dist/services/document-service/transform/types.d.ts +13 -0
- package/dist/services/document-service/transform/types.d.ts.map +1 -0
- package/dist/services/document-service/transform/utils.d.ts +9 -0
- package/dist/services/document-service/transform/utils.d.ts.map +1 -0
- package/dist/services/document-service/utils/populate.d.ts +3 -0
- package/dist/services/document-service/utils/populate.d.ts.map +1 -0
- package/dist/services/document-service/utils/populate.js +41 -0
- package/dist/services/document-service/utils/populate.js.map +1 -0
- package/dist/services/document-service/utils/populate.mjs +41 -0
- package/dist/services/document-service/utils/populate.mjs.map +1 -0
- package/dist/services/entity-service/components.js +8 -8
- package/dist/services/entity-service/components.js.map +1 -1
- package/dist/services/entity-service/components.mjs +9 -9
- package/dist/services/entity-service/components.mjs.map +1 -1
- package/dist/services/entity-service/index.d.ts.map +1 -1
- package/dist/services/entity-service/index.js +3 -3
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs +3 -3
- package/dist/services/entity-service/index.mjs.map +1 -1
- package/dist/services/entity-service/params.d.ts +4 -4
- package/dist/services/entity-service/params.d.ts.map +1 -1
- package/dist/services/entity-service/params.js +1 -1
- package/dist/services/entity-service/params.js.map +1 -1
- package/dist/services/entity-service/params.mjs +1 -1
- package/dist/services/entity-service/params.mjs.map +1 -1
- package/dist/services/entity-validator/blocks-validator.d.ts.map +1 -1
- package/dist/services/entity-validator/blocks-validator.js +22 -2
- package/dist/services/entity-validator/blocks-validator.js.map +1 -1
- package/dist/services/entity-validator/blocks-validator.mjs +22 -2
- package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js +7 -8
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +7 -8
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/server/compose-endpoint.d.ts.map +1 -1
- package/dist/services/server/compose-endpoint.js +3 -0
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs +3 -0
- package/dist/services/server/compose-endpoint.mjs.map +1 -1
- package/dist/services/webhook-store.js +2 -2
- package/dist/services/webhook-store.js.map +1 -1
- package/dist/services/webhook-store.mjs +2 -2
- package/dist/services/webhook-store.mjs.map +1 -1
- package/dist/utils/load-config-file.js +1 -1
- package/dist/utils/load-config-file.js.map +1 -1
- package/dist/utils/load-config-file.mjs +2 -2
- package/dist/utils/load-config-file.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.d.ts +174 -3
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/dist/utils/transform-content-types-to-models.js +80 -41
- package/dist/utils/transform-content-types-to-models.js.map +1 -1
- package/dist/utils/transform-content-types-to-models.mjs +79 -41
- package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/core-api/service/get-fetch-params.d.ts +0 -7
- package/dist/core-api/service/get-fetch-params.d.ts.map +0 -1
- package/dist/core-api/service/get-fetch-params.js +0 -14
- package/dist/core-api/service/get-fetch-params.js.map +0 -1
- package/dist/core-api/service/get-fetch-params.mjs +0 -14
- package/dist/core-api/service/get-fetch-params.mjs.map +0 -1
- package/dist/services/document-service/document-engine.d.ts +0 -8
- package/dist/services/document-service/document-engine.d.ts.map +0 -1
- package/dist/services/document-service/document-engine.js +0 -200
- package/dist/services/document-service/document-engine.js.map +0 -1
- package/dist/services/document-service/document-engine.mjs +0 -201
- package/dist/services/document-service/document-engine.mjs.map +0 -1
- package/dist/services/document-service/document-service.d.ts.map +0 -1
- package/dist/services/document-service/document-service.js +0 -132
- package/dist/services/document-service/document-service.js.map +0 -1
- package/dist/services/document-service/document-service.mjs +0 -132
- package/dist/services/document-service/document-service.mjs.map +0 -1
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.d.ts +0 -26
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.d.ts.map +0 -1
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.js +0 -58
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.js.map +0 -1
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.mjs +0 -58
- package/dist/services/document-service/middlewares/defaults/draft-and-publish.mjs.map +0 -1
- package/dist/services/document-service/middlewares/defaults/index.d.ts +0 -3
- package/dist/services/document-service/middlewares/defaults/index.d.ts.map +0 -1
- package/dist/services/document-service/middlewares/defaults/index.js +0 -82
- package/dist/services/document-service/middlewares/defaults/index.js.map +0 -1
- package/dist/services/document-service/middlewares/defaults/index.mjs +0 -82
- package/dist/services/document-service/middlewares/defaults/index.mjs.map +0 -1
- package/dist/services/document-service/middlewares/defaults/locales.d.ts +0 -18
- package/dist/services/document-service/middlewares/defaults/locales.d.ts.map +0 -1
- package/dist/services/document-service/middlewares/defaults/locales.js +0 -50
- package/dist/services/document-service/middlewares/defaults/locales.js.map +0 -1
- package/dist/services/document-service/middlewares/defaults/locales.mjs +0 -50
- package/dist/services/document-service/middlewares/defaults/locales.mjs.map +0 -1
- package/dist/services/document-service/middlewares/index.d.ts +0 -11
- package/dist/services/document-service/middlewares/index.d.ts.map +0 -1
- package/dist/services/document-service/middlewares/index.js +0 -59
- package/dist/services/document-service/middlewares/index.js.map +0 -1
- package/dist/services/document-service/middlewares/index.mjs +0 -59
- package/dist/services/document-service/middlewares/index.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/domain/module/index.ts"],"sourcesContent":["import _ from 'lodash';\nimport { yup } from '@strapi/utils';\nimport type { Strapi, Common, Schema } from '@strapi/types';\n\nimport { removeNamespace } from '../../registries/namespace';\nimport { validateModule } from './validation';\n\ninterface LifecyclesState {\n bootstrap?: boolean;\n register?: boolean;\n destroy?: boolean;\n}\n\nexport interface RawModule {\n config?: Record<string, unknown>;\n routes?: Common.Module['routes'];\n controllers?: Common.Module['controllers'];\n services?: Common.Module['services'];\n contentTypes?: Common.Module['contentTypes'];\n policies?: Common.Module['policies'];\n middlewares?: Common.Module['middlewares'];\n bootstrap?: (params: { strapi: Strapi }) => Promise<void>;\n register?: (params: { strapi: Strapi }) => Promise<void>;\n destroy?: (params: { strapi: Strapi }) => Promise<void>;\n}\n\nexport interface Module {\n bootstrap: () => Promise<void>;\n register: () => Promise<void>;\n destroy: () => Promise<void>;\n load: () => void;\n routes: Common.Module['routes'];\n config: (path: string, defaultValue?: unknown) => unknown;\n contentType: (ctName: Common.UID.ContentType) => Schema.ContentType;\n contentTypes: Record<string, Schema.ContentType>;\n service: (serviceName: Common.UID.Service) => Common.Service;\n services: Record<string, Common.Service>;\n policy: (policyName: Common.UID.Policy) => Common.Policy;\n policies: Record<string, Common.Policy>;\n middleware: (middlewareName: Common.UID.Middleware) => Common.Middleware;\n middlewares: Record<string, Common.Middleware>;\n controller: (controllerName: Common.UID.Controller) => Common.Controller;\n controllers: Record<string, Common.Controller>;\n}\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/domain/module/index.ts"],"sourcesContent":["import _ from 'lodash';\nimport { yup } from '@strapi/utils';\nimport type { Strapi, Common, Schema } from '@strapi/types';\n\nimport { removeNamespace } from '../../registries/namespace';\nimport { validateModule } from './validation';\n\ninterface LifecyclesState {\n bootstrap?: boolean;\n register?: boolean;\n destroy?: boolean;\n}\n\nexport interface RawModule {\n config?: Record<string, unknown>;\n routes?: Common.Module['routes'];\n controllers?: Common.Module['controllers'];\n services?: Common.Module['services'];\n contentTypes?: Common.Module['contentTypes'];\n policies?: Common.Module['policies'];\n middlewares?: Common.Module['middlewares'];\n bootstrap?: (params: { strapi: Strapi }) => Promise<void>;\n register?: (params: { strapi: Strapi }) => Promise<void>;\n destroy?: (params: { strapi: Strapi }) => Promise<void>;\n}\n\nexport interface Module {\n bootstrap: () => Promise<void>;\n register: () => Promise<void>;\n destroy: () => Promise<void>;\n load: () => void;\n routes: Common.Module['routes'];\n config: (path: string, defaultValue?: unknown) => unknown;\n contentType: (ctName: Common.UID.ContentType) => Schema.ContentType;\n contentTypes: Record<string, Schema.ContentType>;\n service: (serviceName: Common.UID.Service) => Common.Service;\n services: Record<string, Common.Service>;\n policy: (policyName: Common.UID.Policy) => Common.Policy;\n policies: Record<string, Common.Policy>;\n middleware: (middlewareName: Common.UID.Middleware) => Common.Middleware;\n middlewares: Record<string, Common.Middleware>;\n controller: (controllerName: Common.UID.Controller) => Common.Controller;\n controllers: Record<string, Common.Controller>;\n}\n\n// Removes the namespace from a map with keys prefixed with a namespace\nconst removeNamespacedKeys = <T extends Record<string, unknown>>(map: T, namespace: string) => {\n return _.mapKeys(map, (value, key) => removeNamespace(key, namespace));\n};\n\nconst defaultModule = {\n config: {},\n routes: [],\n controllers: {},\n services: {},\n contentTypes: {},\n policies: {},\n middlewares: {},\n};\n\nexport const createModule = (namespace: string, rawModule: RawModule, strapi: Strapi): Module => {\n _.defaults(rawModule, defaultModule);\n\n try {\n validateModule(rawModule);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`strapi-server.js is invalid for '${namespace}'.\\n${e.errors.join('\\n')}`);\n }\n }\n\n const called: LifecyclesState = {};\n return {\n async bootstrap() {\n if (called.bootstrap) {\n throw new Error(`Bootstrap for ${namespace} has already been called`);\n }\n called.bootstrap = true;\n await (rawModule.bootstrap && rawModule.bootstrap({ strapi }));\n },\n async register() {\n if (called.register) {\n throw new Error(`Register for ${namespace} has already been called`);\n }\n called.register = true;\n await (rawModule.register && rawModule.register({ strapi }));\n },\n async destroy() {\n if (called.destroy) {\n throw new Error(`Destroy for ${namespace} has already been called`);\n }\n called.destroy = true;\n await (rawModule.destroy && rawModule.destroy({ strapi }));\n },\n load() {\n strapi.get('content-types').add(namespace, rawModule.contentTypes);\n strapi.get('services').add(namespace, rawModule.services);\n strapi.get('policies').add(namespace, rawModule.policies);\n strapi.get('middlewares').add(namespace, rawModule.middlewares);\n strapi.get('controllers').add(namespace, rawModule.controllers);\n strapi.get('config').set(namespace, rawModule.config);\n },\n get routes() {\n return rawModule.routes ?? {};\n },\n config(path: string, defaultValue: unknown) {\n return strapi.get('config').get(`${namespace}.${path}`, defaultValue);\n },\n contentType(ctName: Common.UID.ContentType) {\n return strapi.get('content-types').get(`${namespace}.${ctName}`);\n },\n get contentTypes() {\n const contentTypes = strapi.get('content-types').getAll(namespace);\n return removeNamespacedKeys(contentTypes, namespace);\n },\n service(serviceName: Common.UID.Service) {\n return strapi.get('services').get(`${namespace}.${serviceName}`);\n },\n get services() {\n const services = strapi.get('services').getAll(namespace);\n return removeNamespacedKeys(services, namespace);\n },\n policy(policyName: Common.UID.Policy) {\n return strapi.get('policies').get(`${namespace}.${policyName}`);\n },\n get policies() {\n const policies = strapi.get('policies').getAll(namespace);\n return removeNamespacedKeys(policies, namespace);\n },\n middleware(middlewareName: Common.UID.Middleware) {\n return strapi.get('middlewares').get(`${namespace}.${middlewareName}`);\n },\n get middlewares() {\n const middlewares = strapi.get('middlewares').getAll(namespace);\n return removeNamespacedKeys(middlewares, namespace);\n },\n controller(controllerName: Common.UID.Controller) {\n return strapi.get('controllers').get(`${namespace}.${controllerName}`);\n },\n get controllers() {\n const controllers = strapi.get('controllers').getAll(namespace);\n return removeNamespacedKeys(controllers, namespace);\n },\n };\n};\n"],"names":["namespace","_","removeNamespace","validateModule","yup"],"mappings":";;;;;;;;AA8CA,MAAM,uBAAuB,CAAoC,KAAQA,gBAAsB;AACtF,SAAAC,WAAA,QAAE,QAAQ,KAAK,CAAC,OAAO,QAAQC,0BAAgB,KAAKF,WAAS,CAAC;AACvE;AAEA,MAAM,gBAAgB;AAAA,EACpB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,cAAc,CAAC;AAAA,EACf,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAChB;AAEO,MAAM,eAAe,CAACA,YAAmB,WAAsB,WAA2B;AAC7FC,aAAAA,QAAA,SAAS,WAAW,aAAa;AAE/B,MAAA;AACFE,eAAA,eAAe,SAAS;AAAA,WACjB,GAAG;AACN,QAAA,aAAaC,gBAAI,iBAAiB;AAC9B,YAAA,IAAI,MAAM,oCAAoCJ,UAAS;AAAA,EAAO,EAAE,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,IAC3F;AAAA,EACF;AAEA,QAAM,SAA0B,CAAA;AACzB,SAAA;AAAA,IACL,MAAM,YAAY;AAChB,UAAI,OAAO,WAAW;AACpB,cAAM,IAAI,MAAM,iBAAiBA,UAAS,0BAA0B;AAAA,MACtE;AACA,aAAO,YAAY;AACnB,aAAO,UAAU,aAAa,UAAU,UAAU,EAAE,OAAQ,CAAA;AAAA,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,GAAGA,UAAS,IAAI,WAAW,EAAE;AAAA,IACjE;AAAA,IACA,IAAI,WAAW;AACb,YAAM,WAAW,OAAO,IAAI,UAAU,EAAE,OAAOA,UAAS;AACjD,aAAA,qBAAqB,UAAUA,UAAS;AAAA,IACjD;AAAA,IACA,OAAO,YAA+B;AAC7B,aAAA,OAAO,IAAI,UAAU,EAAE,IAAI,GAAGA,UAAS,IAAI,UAAU,EAAE;AAAA,IAChE;AAAA,IACA,IAAI,WAAW;AACb,YAAM,WAAW,OAAO,IAAI,UAAU,EAAE,OAAOA,UAAS;AACjD,aAAA,qBAAqB,UAAUA,UAAS;AAAA,IACjD;AAAA,IACA,WAAW,gBAAuC;AACzC,aAAA,OAAO,IAAI,aAAa,EAAE,IAAI,GAAGA,UAAS,IAAI,cAAc,EAAE;AAAA,IACvE;AAAA,IACA,IAAI,cAAc;AAChB,YAAM,cAAc,OAAO,IAAI,aAAa,EAAE,OAAOA,UAAS;AACvD,aAAA,qBAAqB,aAAaA,UAAS;AAAA,IACpD;AAAA,IACA,WAAW,gBAAuC;AACzC,aAAA,OAAO,IAAI,aAAa,EAAE,IAAI,GAAGA,UAAS,IAAI,cAAc,EAAE;AAAA,IACvE;AAAA,IACA,IAAI,cAAc;AAChB,YAAM,cAAc,OAAO,IAAI,aAAa,EAAE,OAAOA,UAAS;AACvD,aAAA,qBAAqB,aAAaA,UAAS;AAAA,IACpD;AAAA,EAAA;AAEJ;;"}
|
|
@@ -2,7 +2,6 @@ import _ from "lodash";
|
|
|
2
2
|
import { yup } from "@strapi/utils";
|
|
3
3
|
import { removeNamespace } from "../../registries/namespace.mjs";
|
|
4
4
|
import { validateModule } from "./validation.mjs";
|
|
5
|
-
const uidToPath = (uid) => uid.replace("::", ".");
|
|
6
5
|
const removeNamespacedKeys = (map, namespace) => {
|
|
7
6
|
return _.mapKeys(map, (value, key) => removeNamespace(key, namespace));
|
|
8
7
|
};
|
|
@@ -54,13 +53,13 @@ ${e.errors.join("\n")}`);
|
|
|
54
53
|
strapi.get("policies").add(namespace, rawModule.policies);
|
|
55
54
|
strapi.get("middlewares").add(namespace, rawModule.middlewares);
|
|
56
55
|
strapi.get("controllers").add(namespace, rawModule.controllers);
|
|
57
|
-
strapi.get("config").set(
|
|
56
|
+
strapi.get("config").set(namespace, rawModule.config);
|
|
58
57
|
},
|
|
59
58
|
get routes() {
|
|
60
59
|
return rawModule.routes ?? {};
|
|
61
60
|
},
|
|
62
61
|
config(path, defaultValue) {
|
|
63
|
-
return strapi.get("config").get(`${
|
|
62
|
+
return strapi.get("config").get(`${namespace}.${path}`, defaultValue);
|
|
64
63
|
},
|
|
65
64
|
contentType(ctName) {
|
|
66
65
|
return strapi.get("content-types").get(`${namespace}.${ctName}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/domain/module/index.ts"],"sourcesContent":["import _ from 'lodash';\nimport { yup } from '@strapi/utils';\nimport type { Strapi, Common, Schema } from '@strapi/types';\n\nimport { removeNamespace } from '../../registries/namespace';\nimport { validateModule } from './validation';\n\ninterface LifecyclesState {\n bootstrap?: boolean;\n register?: boolean;\n destroy?: boolean;\n}\n\nexport interface RawModule {\n config?: Record<string, unknown>;\n routes?: Common.Module['routes'];\n controllers?: Common.Module['controllers'];\n services?: Common.Module['services'];\n contentTypes?: Common.Module['contentTypes'];\n policies?: Common.Module['policies'];\n middlewares?: Common.Module['middlewares'];\n bootstrap?: (params: { strapi: Strapi }) => Promise<void>;\n register?: (params: { strapi: Strapi }) => Promise<void>;\n destroy?: (params: { strapi: Strapi }) => Promise<void>;\n}\n\nexport interface Module {\n bootstrap: () => Promise<void>;\n register: () => Promise<void>;\n destroy: () => Promise<void>;\n load: () => void;\n routes: Common.Module['routes'];\n config: (path: string, defaultValue?: unknown) => unknown;\n contentType: (ctName: Common.UID.ContentType) => Schema.ContentType;\n contentTypes: Record<string, Schema.ContentType>;\n service: (serviceName: Common.UID.Service) => Common.Service;\n services: Record<string, Common.Service>;\n policy: (policyName: Common.UID.Policy) => Common.Policy;\n policies: Record<string, Common.Policy>;\n middleware: (middlewareName: Common.UID.Middleware) => Common.Middleware;\n middlewares: Record<string, Common.Middleware>;\n controller: (controllerName: Common.UID.Controller) => Common.Controller;\n controllers: Record<string, Common.Controller>;\n}\n\
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/domain/module/index.ts"],"sourcesContent":["import _ from 'lodash';\nimport { yup } from '@strapi/utils';\nimport type { Strapi, Common, Schema } from '@strapi/types';\n\nimport { removeNamespace } from '../../registries/namespace';\nimport { validateModule } from './validation';\n\ninterface LifecyclesState {\n bootstrap?: boolean;\n register?: boolean;\n destroy?: boolean;\n}\n\nexport interface RawModule {\n config?: Record<string, unknown>;\n routes?: Common.Module['routes'];\n controllers?: Common.Module['controllers'];\n services?: Common.Module['services'];\n contentTypes?: Common.Module['contentTypes'];\n policies?: Common.Module['policies'];\n middlewares?: Common.Module['middlewares'];\n bootstrap?: (params: { strapi: Strapi }) => Promise<void>;\n register?: (params: { strapi: Strapi }) => Promise<void>;\n destroy?: (params: { strapi: Strapi }) => Promise<void>;\n}\n\nexport interface Module {\n bootstrap: () => Promise<void>;\n register: () => Promise<void>;\n destroy: () => Promise<void>;\n load: () => void;\n routes: Common.Module['routes'];\n config: (path: string, defaultValue?: unknown) => unknown;\n contentType: (ctName: Common.UID.ContentType) => Schema.ContentType;\n contentTypes: Record<string, Schema.ContentType>;\n service: (serviceName: Common.UID.Service) => Common.Service;\n services: Record<string, Common.Service>;\n policy: (policyName: Common.UID.Policy) => Common.Policy;\n policies: Record<string, Common.Policy>;\n middleware: (middlewareName: Common.UID.Middleware) => Common.Middleware;\n middlewares: Record<string, Common.Middleware>;\n controller: (controllerName: Common.UID.Controller) => Common.Controller;\n controllers: Record<string, Common.Controller>;\n}\n\n// Removes the namespace from a map with keys prefixed with a namespace\nconst removeNamespacedKeys = <T extends Record<string, unknown>>(map: T, namespace: string) => {\n return _.mapKeys(map, (value, key) => removeNamespace(key, namespace));\n};\n\nconst defaultModule = {\n config: {},\n routes: [],\n controllers: {},\n services: {},\n contentTypes: {},\n policies: {},\n middlewares: {},\n};\n\nexport const createModule = (namespace: string, rawModule: RawModule, strapi: Strapi): Module => {\n _.defaults(rawModule, defaultModule);\n\n try {\n validateModule(rawModule);\n } catch (e) {\n if (e instanceof yup.ValidationError) {\n throw new Error(`strapi-server.js is invalid for '${namespace}'.\\n${e.errors.join('\\n')}`);\n }\n }\n\n const called: LifecyclesState = {};\n return {\n async bootstrap() {\n if (called.bootstrap) {\n throw new Error(`Bootstrap for ${namespace} has already been called`);\n }\n called.bootstrap = true;\n await (rawModule.bootstrap && rawModule.bootstrap({ strapi }));\n },\n async register() {\n if (called.register) {\n throw new Error(`Register for ${namespace} has already been called`);\n }\n called.register = true;\n await (rawModule.register && rawModule.register({ strapi }));\n },\n async destroy() {\n if (called.destroy) {\n throw new Error(`Destroy for ${namespace} has already been called`);\n }\n called.destroy = true;\n await (rawModule.destroy && rawModule.destroy({ strapi }));\n },\n load() {\n strapi.get('content-types').add(namespace, rawModule.contentTypes);\n strapi.get('services').add(namespace, rawModule.services);\n strapi.get('policies').add(namespace, rawModule.policies);\n strapi.get('middlewares').add(namespace, rawModule.middlewares);\n strapi.get('controllers').add(namespace, rawModule.controllers);\n strapi.get('config').set(namespace, rawModule.config);\n },\n get routes() {\n return rawModule.routes ?? {};\n },\n config(path: string, defaultValue: unknown) {\n return strapi.get('config').get(`${namespace}.${path}`, defaultValue);\n },\n contentType(ctName: Common.UID.ContentType) {\n return strapi.get('content-types').get(`${namespace}.${ctName}`);\n },\n get contentTypes() {\n const contentTypes = strapi.get('content-types').getAll(namespace);\n return removeNamespacedKeys(contentTypes, namespace);\n },\n service(serviceName: Common.UID.Service) {\n return strapi.get('services').get(`${namespace}.${serviceName}`);\n },\n get services() {\n const services = strapi.get('services').getAll(namespace);\n return removeNamespacedKeys(services, namespace);\n },\n policy(policyName: Common.UID.Policy) {\n return strapi.get('policies').get(`${namespace}.${policyName}`);\n },\n get policies() {\n const policies = strapi.get('policies').getAll(namespace);\n return removeNamespacedKeys(policies, namespace);\n },\n middleware(middlewareName: Common.UID.Middleware) {\n return strapi.get('middlewares').get(`${namespace}.${middlewareName}`);\n },\n get middlewares() {\n const middlewares = strapi.get('middlewares').getAll(namespace);\n return removeNamespacedKeys(middlewares, namespace);\n },\n controller(controllerName: Common.UID.Controller) {\n return strapi.get('controllers').get(`${namespace}.${controllerName}`);\n },\n get controllers() {\n const controllers = strapi.get('controllers').getAll(namespace);\n return removeNamespacedKeys(controllers, namespace);\n },\n };\n};\n"],"names":[],"mappings":";;;;AA8CA,MAAM,uBAAuB,CAAoC,KAAQ,cAAsB;AACtF,SAAA,EAAE,QAAQ,KAAK,CAAC,OAAO,QAAQ,gBAAgB,KAAK,SAAS,CAAC;AACvE;AAEA,MAAM,gBAAgB;AAAA,EACpB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC;AAAA,EACT,aAAa,CAAC;AAAA,EACd,UAAU,CAAC;AAAA,EACX,cAAc,CAAC;AAAA,EACf,UAAU,CAAC;AAAA,EACX,aAAa,CAAC;AAChB;AAEO,MAAM,eAAe,CAAC,WAAmB,WAAsB,WAA2B;AAC7F,IAAA,SAAS,WAAW,aAAa;AAE/B,MAAA;AACF,mBAAe,SAAS;AAAA,WACjB,GAAG;AACN,QAAA,aAAa,IAAI,iBAAiB;AAC9B,YAAA,IAAI,MAAM,oCAAoC,SAAS;AAAA,EAAO,EAAE,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,IAC3F;AAAA,EACF;AAEA,QAAM,SAA0B,CAAA;AACzB,SAAA;AAAA,IACL,MAAM,YAAY;AAChB,UAAI,OAAO,WAAW;AACpB,cAAM,IAAI,MAAM,iBAAiB,SAAS,0BAA0B;AAAA,MACtE;AACA,aAAO,YAAY;AACnB,aAAO,UAAU,aAAa,UAAU,UAAU,EAAE,OAAQ,CAAA;AAAA,IAC9D;AAAA,IACA,MAAM,WAAW;AACf,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IACA,IAAI,WAAW;AACb,YAAM,WAAW,OAAO,IAAI,UAAU,EAAE,OAAO,SAAS;AACjD,aAAA,qBAAqB,UAAU,SAAS;AAAA,IACjD;AAAA,IACA,OAAO,YAA+B;AAC7B,aAAA,OAAO,IAAI,UAAU,EAAE,IAAI,GAAG,SAAS,IAAI,UAAU,EAAE;AAAA,IAChE;AAAA,IACA,IAAI,WAAW;AACb,YAAM,WAAW,OAAO,IAAI,UAAU,EAAE,OAAO,SAAS;AACjD,aAAA,qBAAqB,UAAU,SAAS;AAAA,IACjD;AAAA,IACA,WAAW,gBAAuC;AACzC,aAAA,OAAO,IAAI,aAAa,EAAE,IAAI,GAAG,SAAS,IAAI,cAAc,EAAE;AAAA,IACvE;AAAA,IACA,IAAI,cAAc;AAChB,YAAM,cAAc,OAAO,IAAI,aAAa,EAAE,OAAO,SAAS;AACvD,aAAA,qBAAqB,aAAa,SAAS;AAAA,IACpD;AAAA,IACA,WAAW,gBAAuC;AACzC,aAAA,OAAO,IAAI,aAAa,EAAE,IAAI,GAAG,SAAS,IAAI,cAAc,EAAE;AAAA,IACvE;AAAA,IACA,IAAI,cAAc;AAChB,YAAM,cAAc,OAAO,IAAI,aAAa,EAAE,OAAO,SAAS;AACvD,aAAA,qBAAqB,aAAa,SAAS;AAAA,IACpD;AAAA,EAAA;AAEJ;"}
|
package/dist/factories.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src/factories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAUpE,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../src/factories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAUpE,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAElF,QAAA,MAAM,oBAAoB;YAOM,MAAM;yNAwBrC,CAAC;AAEF,iBAAS,iBAAiB,CACxB,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,WAAW,EACnC,QAAQ,SAAS,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAEjD,GAAG,EAAE,IAAI,EACT,GAAG,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;YAE9D,MAAM;MAAK,QAAQ,GAAG,QAAQ,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CActF;AAED,iBAAS,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,WAAW,EACxD,GAAG,EAAE,CAAC,EACN,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,MAAM,CAAC,MAAM,CA+BvB;AAED,QAAA,MAAM,kBAAkB,kDAAiD,OAExE,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/factories.js
CHANGED
|
@@ -7,19 +7,9 @@ const index$2 = require("./core-api/routes/index.js");
|
|
|
7
7
|
const symbols = {
|
|
8
8
|
CustomController: Symbol("StrapiCustomCoreController")
|
|
9
9
|
};
|
|
10
|
-
const getContentTypeProxy = (strapi2, uid) => {
|
|
11
|
-
return new Proxy(strapi2.contentType(uid), {
|
|
12
|
-
get(target, prop) {
|
|
13
|
-
const contentType = strapi2.contentType(uid);
|
|
14
|
-
if (prop in contentType) {
|
|
15
|
-
return contentType[prop];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
10
|
const createCoreController = (uid, cfg) => {
|
|
21
11
|
return ({ strapi: strapi2 }) => {
|
|
22
|
-
const baseController = index.createController({ contentType:
|
|
12
|
+
const baseController = index.createController({ contentType: strapi2.contentType(uid) });
|
|
23
13
|
const userCtrl = typeof cfg === "function" ? cfg({ strapi: strapi2 }) : cfg ?? {};
|
|
24
14
|
for (const methodName of Object.keys(baseController)) {
|
|
25
15
|
if (userCtrl[methodName] === void 0) {
|
|
@@ -40,7 +30,7 @@ const createCoreController = (uid, cfg) => {
|
|
|
40
30
|
};
|
|
41
31
|
function createCoreService(uid, cfg) {
|
|
42
32
|
return ({ strapi: strapi2 }) => {
|
|
43
|
-
const baseService = index$1.createService({ contentType:
|
|
33
|
+
const baseService = index$1.createService({ contentType: strapi2.contentType(uid) });
|
|
44
34
|
const userService = typeof cfg === "function" ? cfg({ strapi: strapi2 }) : cfg ?? {};
|
|
45
35
|
for (const methodName of Object.keys(baseService)) {
|
|
46
36
|
if (userService[methodName] === void 0) {
|
package/dist/factories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\
|
|
1
|
+
{"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends Common.UID.ContentType,\n TService extends CoreApi.Service.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Service.Extendable<TUID> & TService>>\n) {\n return ({ strapi }: { strapi: Strapi }): TService & CoreApi.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends Common.UID.ContentType>(\n uid: T,\n cfg?: CoreApi.Router.RouterConfig<T>\n): CoreApi.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: CoreApi.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Common.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","createController","createService","createRoutes","pipe","routes","omit","pick"],"mappings":";;;;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAIM,MAAA,uBAAuB,CAI3B,KACA,QACG;AACH,SAAO,CAAC,EAAE,QAAAA,cAAqF;AACvF,UAAA,iBAAiBC,uBAAiB,EAAE,aAAaD,QAAO,YAAY,GAAG,GAAG;AAE1E,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAQ,CAAA,IAAI,OAAQ;AAEvE,eAAW,cAAc,OAAO,KAAK,cAAc,GAAyC;AACtF,UAAA,SAAS,UAAU,MAAM,QAAW;AAC7B,iBAAA,UAAU,IAAI,eAAe,UAAU;AAAA,MAClD;AAAA,IACF;AAEO,WAAA,eAAe,UAAU,cAAc;AAExC,UAAA,WAAW,OAAO,QAAQ;AAChC,QAAI,UAAU;AACL,aAAA,eAAe,UAAU,QAAQ,kBAAkB;AAAA,QACxD,UA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AAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,CAA8B,eAA2B;AAClF,SAAO,QAAQ,oBAAoB;AACrC;;;;;"}
|
package/dist/factories.mjs
CHANGED
|
@@ -5,19 +5,9 @@ import { createRoutes } from "./core-api/routes/index.mjs";
|
|
|
5
5
|
const symbols = {
|
|
6
6
|
CustomController: Symbol("StrapiCustomCoreController")
|
|
7
7
|
};
|
|
8
|
-
const getContentTypeProxy = (strapi2, uid) => {
|
|
9
|
-
return new Proxy(strapi2.contentType(uid), {
|
|
10
|
-
get(target, prop) {
|
|
11
|
-
const contentType = strapi2.contentType(uid);
|
|
12
|
-
if (prop in contentType) {
|
|
13
|
-
return contentType[prop];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
8
|
const createCoreController = (uid, cfg) => {
|
|
19
9
|
return ({ strapi: strapi2 }) => {
|
|
20
|
-
const baseController = createController({ contentType:
|
|
10
|
+
const baseController = createController({ contentType: strapi2.contentType(uid) });
|
|
21
11
|
const userCtrl = typeof cfg === "function" ? cfg({ strapi: strapi2 }) : cfg ?? {};
|
|
22
12
|
for (const methodName of Object.keys(baseController)) {
|
|
23
13
|
if (userCtrl[methodName] === void 0) {
|
|
@@ -38,7 +28,7 @@ const createCoreController = (uid, cfg) => {
|
|
|
38
28
|
};
|
|
39
29
|
function createCoreService(uid, cfg) {
|
|
40
30
|
return ({ strapi: strapi2 }) => {
|
|
41
|
-
const baseService = createService({ contentType:
|
|
31
|
+
const baseService = createService({ contentType: strapi2.contentType(uid) });
|
|
42
32
|
const userService = typeof cfg === "function" ? cfg({ strapi: strapi2 }) : cfg ?? {};
|
|
43
33
|
for (const methodName of Object.keys(baseService)) {
|
|
44
34
|
if (userService[methodName] === void 0) {
|
package/dist/factories.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\
|
|
1
|
+
{"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: strapi.contentType(uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends Common.UID.ContentType,\n TService extends CoreApi.Service.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Service.Extendable<TUID> & TService>>\n) {\n return ({ strapi }: { strapi: Strapi }): TService & CoreApi.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: strapi.contentType(uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends Common.UID.ContentType>(\n uid: T,\n cfg?: CoreApi.Router.RouterConfig<T>\n): CoreApi.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: CoreApi.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Common.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","routes"],"mappings":";;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAIM,MAAA,uBAAuB,CAI3B,KACA,QACG;AACH,SAAO,CAAC,EAAE,QAAAA,cAAqF;AACvF,UAAA,iBAAiB,iBAAiB,EAAE,aAAaA,QAAO,YAAY,GAAG,GAAG;AAE1E,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAQ,CAAA,IAAI,OAAQ;AAEvE,eAAW,cAAc,OAAO,KAAK,cAAc,GA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AAA,UACrB,CAACC,YAAY,SAAS,KAAK,QAAQA,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAO,KAAK,MAAMA,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MACvC;AAEO,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,CAA8B,eAA2B;AAClF,SAAO,QAAQ,oBAAoB;AACrC;"}
|
package/dist/loaders/apis.js
CHANGED
|
@@ -13,7 +13,7 @@ const DEFAULT_CONTENT_TYPE = {
|
|
|
13
13
|
actions: {},
|
|
14
14
|
lifecycles: {}
|
|
15
15
|
};
|
|
16
|
-
const normalizeName = (name) => strapiUtils.isKebabCase(name) ? name : ___default.default.kebabCase(name);
|
|
16
|
+
const normalizeName = (name) => strapiUtils.strings.isKebabCase(name) ? name : ___default.default.kebabCase(name);
|
|
17
17
|
const isDirectory = (fd) => fd.isDirectory();
|
|
18
18
|
const isDotFile = (fd) => fd.name.startsWith(".");
|
|
19
19
|
async function loadAPIs(strapi) {
|
package/dist/loaders/apis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.js","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport {
|
|
1
|
+
{"version":3,"file":"apis.js","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Strapi, Common, Schema } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Common.Router>;\n controllers: Record<string, Common.Controller>;\n services: Record<string, Common.Service>;\n policies: Record<string, Common.Policy>;\n middlewares: Record<string, Common.Middleware>;\n contentTypes: Record<string, { schema: Schema.ContentType }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] =\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ]);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = await loadDir(join(dir, fd.name));\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return contentTypes;\n};\n\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = await loadFile(join(dir, fd.name));\n }\n\n return root;\n};\n\nconst loadFile = (file: string) => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return importDefault(file);\n case '.json':\n return fse.readJSON(file);\n default:\n return {};\n }\n};\n"],"names":["strings","_","existsSync","fse","join","index","isEmpty","getGlobalId","extname","basename","importDefault"],"mappings":";;;;;;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAC;AACf;AAGA,MAAM,gBAAgB,CAAC,SAAkBA,YAAQ,QAAA,YAAY,IAAI,IAAI,OAAOC,WAAE,QAAA,UAAU,IAAI;AAE5F,MAAM,cAAc,CAAC,OAAmB,GAAG,YAAY;AACvD,MAAM,YAAY,CAAC,OAAmB,GAAG,KAAK,WAAW,GAAG;AAE5D,eAA8B,SAAS,QAAgB;AACrD,MAAI,CAACC,IAAW,WAAA,OAAO,KAAK,KAAK,GAAG,GAAG;AACrC;AAAA,EACF;AAEM,QAAA,UAAU,OAAO,MAAMC,aAAA,QAAI,QAAQ,OAAO,KAAK,KAAK,KAAK,EAAE,eAAe,KAAM,CAAA,GACnF,OAAO,WAAW,EAClB,OAAOF,mBAAE,OAAO,SAAS,CAAC;AAE7B,QAAM,OAAa,CAAA;AAGnB,aAAW,SAAS,SAAS;AACrB,UAAA,UAAU,cAAc,MAAM,IAAI;AAClC,UAAA,MAAM,MAAM,QAAQ,SAASG,KAAAA,KAAK,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,CAAC;AAEzE,SAAK,OAAO,IAAI;AAAA,EAClB;AAEA,8BAA4B,IAAI;AAEhC,aAAW,WAAW,OAAO,KAAK,IAAI,GAAG;AACvC,WAAO,IAAI,MAAM,EAAE,IAAI,SAAS,KAAK,OAAO,CAAC;AAAA,EAC/C;AACF;AAEA,MAAM,8BAA8B,CAAC,SAAe;AAClD,QAAM,iBAAiB,OAAO,OAAO,IAAI,EAAE,QAAQ,CAAC,QAAQ,OAAO,OAAO,IAAI,YAAY,CAAC;AAE3F,QAAM,QAAkB,CAAA;AACxB,iBAAe,QAAQ,CAAC,EAAE,aAAa;AACj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,OAAgC,CAAA;AACtC,aAAW,MAAM,KAAK;AAChB,QAAA,CAAC,GAAG,OAAO,KAAKK,aAAQ,GAAG,IAAI,MAAM,QAAQ;AAC/C;AAAA,IACF;AAEA,UAAM,MAAMC,KAAS,SAAA,GAAG,MAAMD,KAAAA,QAAQ,GAAG,IAAI,CAAC;AAEzC,SAAA,cAAc,GAAG,CAAC,IAAI,MAAM,SAASJ,KAAK,KAAA,KAAK,GAAG,IAAI,CAAC;AAAA,EAC9D;AAEO,SAAA;AACT;AAEA,MAAM,WAAW,CAAC,SAAiB;AAC3B,QAAA,MAAMI,aAAQ,IAAI;AAExB,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAOE,YAAAA,cAAc,IAAI;AAAA,IAC3B,KAAK;AACI,aAAAP,aAAA,QAAI,SAAS,IAAI;AAAA,IAC1B;AACE,aAAO;EACX;AACF;;"}
|
package/dist/loaders/apis.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join, extname, basename } from "path";
|
|
2
2
|
import fse, { existsSync } from "fs-extra";
|
|
3
3
|
import _ from "lodash";
|
|
4
|
-
import {
|
|
4
|
+
import { strings, importDefault } from "@strapi/utils";
|
|
5
5
|
import { isEmpty } from "lodash/fp";
|
|
6
6
|
import { getGlobalId } from "../domain/content-type/index.mjs";
|
|
7
7
|
const DEFAULT_CONTENT_TYPE = {
|
|
@@ -9,7 +9,7 @@ const DEFAULT_CONTENT_TYPE = {
|
|
|
9
9
|
actions: {},
|
|
10
10
|
lifecycles: {}
|
|
11
11
|
};
|
|
12
|
-
const normalizeName = (name) => isKebabCase(name) ? name : _.kebabCase(name);
|
|
12
|
+
const normalizeName = (name) => strings.isKebabCase(name) ? name : _.kebabCase(name);
|
|
13
13
|
const isDirectory = (fd) => fd.isDirectory();
|
|
14
14
|
const isDotFile = (fd) => fd.name.startsWith(".");
|
|
15
15
|
async function loadAPIs(strapi) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.mjs","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport {
|
|
1
|
+
{"version":3,"file":"apis.mjs","sources":["../../src/loaders/apis.ts"],"sourcesContent":["import { join, extname, basename } from 'path';\nimport fse, { existsSync } from 'fs-extra';\nimport _ from 'lodash';\nimport { strings, importDefault } from '@strapi/utils';\nimport { isEmpty } from 'lodash/fp';\nimport type { Strapi, Common, Schema } from '@strapi/types';\nimport { getGlobalId, type ContentTypeDefinition } from '../domain/content-type';\n\ninterface API {\n bootstrap: () => void | Promise<void>;\n destroy: () => void | Promise<void>;\n register: () => void | Promise<void>;\n config: Record<string, unknown>;\n routes: Record<string, Common.Router>;\n controllers: Record<string, Common.Controller>;\n services: Record<string, Common.Service>;\n policies: Record<string, Common.Policy>;\n middlewares: Record<string, Common.Middleware>;\n contentTypes: Record<string, { schema: Schema.ContentType }>;\n}\n\ninterface APIs {\n [key: string]: API;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n schema: {},\n actions: {},\n lifecycles: {},\n};\n\n// to handle names with numbers in it we first check if it is already in kebabCase\nconst normalizeName = (name: string) => (strings.isKebabCase(name) ? name : _.kebabCase(name));\n\nconst isDirectory = (fd: fse.Dirent) => fd.isDirectory();\nconst isDotFile = (fd: fse.Dirent) => fd.name.startsWith('.');\n\nexport default async function loadAPIs(strapi: Strapi) {\n if (!existsSync(strapi.dirs.dist.api)) {\n return;\n }\n\n const apisFDs = await (await fse.readdir(strapi.dirs.dist.api, { withFileTypes: true }))\n .filter(isDirectory)\n .filter(_.negate(isDotFile));\n\n const apis: APIs = {};\n\n // only load folders\n for (const apiFD of apisFDs) {\n const apiName = normalizeName(apiFD.name);\n const api = await loadAPI(apiName, join(strapi.dirs.dist.api, apiFD.name));\n\n apis[apiName] = api;\n }\n\n validateContentTypesUnicity(apis);\n\n for (const apiName of Object.keys(apis)) {\n strapi.get('apis').add(apiName, apis[apiName]);\n }\n}\n\nconst validateContentTypesUnicity = (apis: APIs) => {\n const allApisSchemas = Object.values(apis).flatMap((api) => Object.values(api.contentTypes));\n\n const names: string[] = [];\n allApisSchemas.forEach(({ schema }) => {\n if (schema.info.singularName) {\n const singularName = _.kebabCase(schema.info.singularName);\n if (names.includes(singularName)) {\n throw new Error(`The singular name \"${schema.info.singularName}\" should be unique`);\n }\n names.push(singularName);\n }\n\n if (schema.info.pluralName) {\n const pluralName = _.kebabCase(schema.info.pluralName);\n if (names.includes(pluralName)) {\n throw new Error(`The plural name \"${schema.info.pluralName}\" should be unique`);\n }\n names.push(pluralName);\n }\n });\n};\n\nconst loadAPI = async (apiName: string, dir: string) => {\n const [index, config, routes, controllers, services, policies, middlewares, contentTypes] =\n await Promise.all([\n loadIndex(dir),\n loadDir(join(dir, 'config')),\n loadDir(join(dir, 'routes')),\n loadDir(join(dir, 'controllers')),\n loadDir(join(dir, 'services')),\n loadDir(join(dir, 'policies')),\n loadDir(join(dir, 'middlewares')),\n loadContentTypes(apiName, join(dir, 'content-types')),\n ]);\n\n return {\n ...(index || {}),\n config: config || {},\n routes: routes || [],\n controllers: controllers || {},\n services: services || {},\n policies: policies || {},\n middlewares: middlewares || {},\n contentTypes: contentTypes || {},\n };\n};\n\nconst loadIndex = async (dir: string) => {\n if (await fse.pathExists(join(dir, 'index.js'))) {\n return loadFile(join(dir, 'index.js'));\n }\n};\n\nconst loadContentTypes = async (apiName: string, dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n const contentTypes: API['contentTypes'] = {};\n\n // only load folders\n for (const fd of fds) {\n if (fd.isFile()) {\n continue;\n }\n\n const contentTypeName = normalizeName(fd.name);\n const loadedContentType = await loadDir(join(dir, fd.name));\n\n if (isEmpty(loadedContentType) || isEmpty(loadedContentType.schema)) {\n throw new Error(`Could not load content type found at ${dir}`);\n }\n\n const contentType = {\n ...DEFAULT_CONTENT_TYPE,\n ...loadedContentType,\n } as ContentTypeDefinition;\n\n Object.assign(contentType.schema, {\n apiName,\n collectionName: contentType.schema.collectionName || contentType.schema.info.singularName,\n globalId: getGlobalId(contentType.schema),\n });\n\n contentTypes[normalizeName(contentTypeName)] = contentType;\n }\n\n return contentTypes;\n};\n\nconst loadDir = async (dir: string) => {\n if (!(await fse.pathExists(dir))) {\n return;\n }\n\n const fds = await fse.readdir(dir, { withFileTypes: true });\n\n const root: Record<string, unknown> = {};\n for (const fd of fds) {\n if (!fd.isFile() || extname(fd.name) === '.map') {\n continue;\n }\n\n const key = basename(fd.name, extname(fd.name));\n\n root[normalizeName(key)] = await loadFile(join(dir, fd.name));\n }\n\n return root;\n};\n\nconst loadFile = (file: string) => {\n const ext = extname(file);\n\n switch (ext) {\n case '.js':\n return importDefault(file);\n case '.json':\n return fse.readJSON(file);\n default:\n return {};\n }\n};\n"],"names":[],"mappings":";;;;;;AAyBA,MAAM,uBAAuB;AAAA,EAC3B,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,YAAY,CAAC;AACf;AAGA,MAAM,gBAAgB,CAAC,SAAkB,QAAQ,YAAY,IAAI,IAAI,OAAO,EAAE,UAAU,IAAI;AAE5F,MAAM,cAAc,CAAC,OAAmB,GAAG,YAAY;AACvD,MAAM,YAAY,CAAC,OAAmB,GAAG,KAAK,WAAW,GAAG;AAE5D,eAA8B,SAAS,QAAgB;AACrD,MAAI,CAAC,WAAW,OAAO,KAAK,KAAK,GAAG,GAAG;AACrC;AAAA,EACF;AAEM,QAAA,UAAU,OAAO,MAAM,IAAI,QAAQ,OAAO,KAAK,KAAK,KAAK,EAAE,eAAe,KAAM,CAAA,GACnF,OAAO,WAAW,EAClB,OAAO,EAAE,OAAO,SAAS,CAAC;AAE7B,QAAM,OAAa,CAAA;AAGnB,aAAW,SAAS,SAAS;AACrB,UAAA,UAAU,cAAc,MAAM,IAAI;AAClC,UAAA,MAAM,MAAM,QAAQ,SAAS,KAAK,OAAO,KAAK,KAAK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AAM;AAAA,IAAA,CACzC;AAEY,iBAAA,cAAc,eAAe,CAAC,IAAI;AAAA,EACjD;AAEO,SAAA;AACT;AAEA,MAAM,UAAU,OAAO,QAAgB;AACrC,MAAI,CAAE,MAAM,IAAI,WAAW,GAAG,GAAI;AAChC;AAAA,EACF;AAEM,QAAA,MAAM,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE1D,QAAM,OAAgC,CAAA;AACtC,aAAW,MAAM,KAAK;AAChB,QAAA,CAAC,GAAG,OAAO,KAAK,QAAQ,GAAG,IAAI,MAAM,QAAQ;AAC/C;AAAA,IACF;AAEA,UAAM,MAAM,SAAS,GAAG,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEzC,SAAA,cAAc,GAAG,CAAC,IAAI,MAAM,SAAS,KAAK,KAAK,GAAG,IAAI,CAAC;AAAA,EAC9D;AAEO,SAAA;AACT;AAEA,MAAM,WAAW,CAAC,SAAiB;AAC3B,QAAA,MAAM,QAAQ,IAAI;AAExB,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO,cAAc,IAAI;AAAA,IAC3B,KAAK;AACI,aAAA,IAAI,SAAS,IAAI;AAAA,IAC1B;AACE,aAAO;EACX;AACF;"}
|
|
@@ -17,7 +17,7 @@ const INTERNAL_PLUGINS = [
|
|
|
17
17
|
];
|
|
18
18
|
const isStrapiPlugin = (info) => _$1.get("strapi.kind", info) === "plugin";
|
|
19
19
|
const validatePluginName = (pluginName) => {
|
|
20
|
-
if (!strapiUtils.isKebabCase(pluginName)) {
|
|
20
|
+
if (!strapiUtils.strings.isKebabCase(pluginName)) {
|
|
21
21
|
throw new Error(`Plugin name "${pluginName}" is not in kebab (an-example-of-kebab-case)`);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport {
|
|
1
|
+
{"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","strings","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,IAAAA,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAACC,YAAA,QAAQ,YAAY,UAAU,GAAG;AACpC,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAAA;AAGvB,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAAC,KAAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAeC,KAAQ,QAAA,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAeC,KAAAA,QAAQ,OAAO,KAAK,IAAI,MAAM,YAAY,OAAO;AAE5D,YAAA,CAACC,cAAW,YAAY,KAAK,CAACC,GAAAA,SAAS,YAAY,EAAE,eAAe;AACtE,gBAAM,IAAI,MAAM,GAAG,YAAY,OAAO,uBAAuB;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAEA,wBAAoB,eAAe;AAAA,EACrC;AA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nD,QAAI,cAAc;AACV,YAAA,cAAcP,KAAAA,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AAAA,MAC3D;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0BQ,IAAAA,IAAIC,IAAAA,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiCC,IAAA;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiBC,IAAA;AAAA,IACrBC,IAAAA,aAAa,eAAe;AAAA,IAC5BA,IAAAA,aAAa,8BAA8B;AAAA,IAC3CF,IAAAA,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;;"}
|
|
@@ -2,7 +2,7 @@ import { join, dirname, resolve } from "path";
|
|
|
2
2
|
import { existsSync, statSync } from "fs";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import { map, prop, pickBy, pipe, defaultsDeep, get } from "lodash/fp";
|
|
5
|
-
import {
|
|
5
|
+
import { strings } from "@strapi/utils";
|
|
6
6
|
import { getUserPluginsConfig } from "./get-user-plugins-config.mjs";
|
|
7
7
|
const INTERNAL_PLUGINS = [
|
|
8
8
|
"@strapi/plugin-content-manager",
|
|
@@ -13,7 +13,7 @@ const INTERNAL_PLUGINS = [
|
|
|
13
13
|
];
|
|
14
14
|
const isStrapiPlugin = (info) => get("strapi.kind", info) === "plugin";
|
|
15
15
|
const validatePluginName = (pluginName) => {
|
|
16
|
-
if (!isKebabCase(pluginName)) {
|
|
16
|
+
if (!strings.isKebabCase(pluginName)) {
|
|
17
17
|
throw new Error(`Plugin name "${pluginName}" is not in kebab (an-example-of-kebab-case)`);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport {
|
|
1
|
+
{"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAAC,QAAQ,YAAY,UAAU,GAAG;AACpC,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAAA;AAGvB,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;AACD,UAAA;AACF,uBAAe,QAAQ,QAAQ,QAAQ,YAAY,OAAO,CAAC;AAAA,eACpD,GAAG;AACV,uBAAe,QAAQ,OAAO,KAAK,IAAI,MAAM,YAAY,OAAO;AAE5D,YAAA,CAAC,WAAW,YAAY,KAAK,CAAC,SAAS,YAAY,EAAE,eAAe;AACtE,gBAAM,IAAI,MAAM,GAAG,YAAY,OAAO,uBAAuB;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAEA,wBAAoB,eAAe;AAAA,EACrC;AAEO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,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AAAA,MAC3D;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0B,IAAI,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiC;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiB;AAAA,IACrB,aAAa,eAAe;AAAA,IAC5B,aAAa,8BAA8B;AAAA,IAC3C,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigProvider } from '@strapi/types';
|
|
2
|
-
declare const _default: (initialConfig?: {}) => ConfigProvider;
|
|
1
|
+
import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';
|
|
2
|
+
declare const _default: (initialConfig?: {}, strapi?: Strapi | LoadedStrapi) => ConfigProvider;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/registries/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/registries/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;sDAK7B,MAAM,GAAG,YAAY,KAAG,cAAc;AAAnF,wBAgCE"}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const _ = require("lodash");
|
|
3
|
-
const
|
|
4
|
-
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
5
|
-
const config = (initialConfig = {}) => {
|
|
3
|
+
const config = (initialConfig = {}, strapi) => {
|
|
6
4
|
const _config = { ...initialConfig };
|
|
5
|
+
const transformDeprecatedPaths = (path) => {
|
|
6
|
+
if (_.isString(path) && path.startsWith("plugin.")) {
|
|
7
|
+
const newPath = path.replace("plugin.", "plugin::");
|
|
8
|
+
(strapi?.log?.warn ?? console.warn)(
|
|
9
|
+
`Using dot notation for model config namespaces is deprecated, for example "plugin::myplugin" should be used instead of "plugin.myplugin". Modifying requested path ${path} to ${newPath}`
|
|
10
|
+
);
|
|
11
|
+
return newPath;
|
|
12
|
+
}
|
|
13
|
+
return path;
|
|
14
|
+
};
|
|
7
15
|
return {
|
|
8
16
|
..._config,
|
|
9
17
|
// TODO: to remove
|
|
10
18
|
get(path, defaultValue) {
|
|
11
|
-
return
|
|
19
|
+
return _.get(_config, transformDeprecatedPaths(path), defaultValue);
|
|
12
20
|
},
|
|
13
21
|
set(path, val) {
|
|
14
|
-
|
|
22
|
+
_.set(_config, transformDeprecatedPaths(path), val);
|
|
15
23
|
return this;
|
|
16
24
|
},
|
|
17
25
|
has(path) {
|
|
18
|
-
return
|
|
26
|
+
return _.has(_config, path);
|
|
19
27
|
}
|
|
20
28
|
};
|
|
21
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider } from '@strapi/types';\nimport
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';\nimport { get, set, has, isString, type PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}, strapi?: Strapi | LoadedStrapi): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n // Accessing model configs with dot (.) was deprecated between v4->v5, but to avoid a major breaking change\n // we will still support certain namespaces, currently only 'plugin.'\n const transformDeprecatedPaths = (path: PropertyName) => {\n if (isString(path) && path.startsWith('plugin.')) {\n const newPath = path.replace('plugin.', 'plugin::');\n\n // strapi logger may not be loaded yet, so fall back to console\n (strapi?.log?.warn ?? console.warn)(\n `Using dot notation for model config namespaces is deprecated, for example \"plugin::myplugin\" should be used instead of \"plugin.myplugin\". Modifying requested path ${path} to ${newPath}`\n );\n return newPath;\n }\n\n return path;\n };\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return get(_config, transformDeprecatedPaths(path), defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n set(_config, transformDeprecatedPaths(path), val);\n return this;\n },\n has(path: PropertyName) {\n return has(_config, path);\n },\n };\n};\n"],"names":["isString","get","set","has"],"mappings":";;AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAC,GAAG,WAAmD;AAC/E,QAAA,UAAkB,EAAE,GAAG;AAIvB,QAAA,2BAA2B,CAAC,SAAuB;AACvD,QAAIA,EAAAA,SAAS,IAAI,KAAK,KAAK,WAAW,SAAS,GAAG;AAChD,YAAM,UAAU,KAAK,QAAQ,WAAW,UAAU;AAGjD,OAAA,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC5B,sKAAsK,IAAI,OAAO,OAAO;AAAA,MAAA;AAEnL,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAOC,EAAAA,IAAI,SAAS,yBAAyB,IAAI,GAAG,YAAY;AAAA,IAClE;AAAA,IACA,IAAI,MAAoB,KAAc;AACpCC,QAAAA,IAAI,SAAS,yBAAyB,IAAI,GAAG,GAAG;AACzC,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAAC,EAAA,IAAI,SAAS,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEJ;;"}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
const config = (initialConfig = {}) => {
|
|
1
|
+
import { get, set, has, isString } from "lodash";
|
|
2
|
+
const config = (initialConfig = {}, strapi) => {
|
|
3
3
|
const _config = { ...initialConfig };
|
|
4
|
+
const transformDeprecatedPaths = (path) => {
|
|
5
|
+
if (isString(path) && path.startsWith("plugin.")) {
|
|
6
|
+
const newPath = path.replace("plugin.", "plugin::");
|
|
7
|
+
(strapi?.log?.warn ?? console.warn)(
|
|
8
|
+
`Using dot notation for model config namespaces is deprecated, for example "plugin::myplugin" should be used instead of "plugin.myplugin". Modifying requested path ${path} to ${newPath}`
|
|
9
|
+
);
|
|
10
|
+
return newPath;
|
|
11
|
+
}
|
|
12
|
+
return path;
|
|
13
|
+
};
|
|
4
14
|
return {
|
|
5
15
|
..._config,
|
|
6
16
|
// TODO: to remove
|
|
7
17
|
get(path, defaultValue) {
|
|
8
|
-
return
|
|
18
|
+
return get(_config, transformDeprecatedPaths(path), defaultValue);
|
|
9
19
|
},
|
|
10
20
|
set(path, val) {
|
|
11
|
-
|
|
21
|
+
set(_config, transformDeprecatedPaths(path), val);
|
|
12
22
|
return this;
|
|
13
23
|
},
|
|
14
24
|
has(path) {
|
|
15
|
-
return
|
|
25
|
+
return has(_config, path);
|
|
16
26
|
}
|
|
17
27
|
};
|
|
18
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider } from '@strapi/types';\nimport
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';\nimport { get, set, has, isString, type PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}, strapi?: Strapi | LoadedStrapi): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n // Accessing model configs with dot (.) was deprecated between v4->v5, but to avoid a major breaking change\n // we will still support certain namespaces, currently only 'plugin.'\n const transformDeprecatedPaths = (path: PropertyName) => {\n if (isString(path) && path.startsWith('plugin.')) {\n const newPath = path.replace('plugin.', 'plugin::');\n\n // strapi logger may not be loaded yet, so fall back to console\n (strapi?.log?.warn ?? console.warn)(\n `Using dot notation for model config namespaces is deprecated, for example \"plugin::myplugin\" should be used instead of \"plugin.myplugin\". Modifying requested path ${path} to ${newPath}`\n );\n return newPath;\n }\n\n return path;\n };\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return get(_config, transformDeprecatedPaths(path), defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n set(_config, transformDeprecatedPaths(path), val);\n return this;\n },\n has(path: PropertyName) {\n return has(_config, path);\n },\n };\n};\n"],"names":[],"mappings":";AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAC,GAAG,WAAmD;AAC/E,QAAA,UAAkB,EAAE,GAAG;AAIvB,QAAA,2BAA2B,CAAC,SAAuB;AACvD,QAAI,SAAS,IAAI,KAAK,KAAK,WAAW,SAAS,GAAG;AAChD,YAAM,UAAU,KAAK,QAAQ,WAAW,UAAU;AAGjD,OAAA,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC5B,sKAAsK,IAAI,OAAO,OAAO;AAAA,MAAA;AAEnL,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAO,IAAI,SAAS,yBAAyB,IAAI,GAAG,YAAY;AAAA,IAClE;AAAA,IACA,IAAI,MAAoB,KAAc;AACpC,UAAI,SAAS,yBAAyB,IAAI,GAAG,GAAG;AACzC,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAA,IAAI,SAAS,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/registries/content-types.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAqB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGlF,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAC/D,KAAK,mBAAmB,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC;AAcnF,QAAA,MAAM,oBAAoB;IAItB;;OAEG;;IAKH;;OAEG;aACM,OAAO,GAAG,CAAC,WAAW;IAI/B;;OAEG;sBACe,MAAM;IAIxB;;OAEG;aACM,OAAO,GAAG,CAAC,WAAW,eAAe,OAAO,WAAW;IAKhE;;OAEG;mBACY,MAAM,mBAAmB,iBAAiB;IAczD;;OAEG;kBACW,OAAO,GAAG,CAAC,WAAW,YAAY,mBAAmB;
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/registries/content-types.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAqB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGlF,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAC/D,KAAK,mBAAmB,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC;AAcnF,QAAA,MAAM,oBAAoB;IAItB;;OAEG;;IAKH;;OAEG;aACM,OAAO,GAAG,CAAC,WAAW;IAI/B;;OAEG;sBACe,MAAM;IAIxB;;OAEG;aACM,OAAO,GAAG,CAAC,WAAW,eAAe,OAAO,WAAW;IAKhE;;OAEG;mBACY,MAAM,mBAAmB,iBAAiB;IAczD;;OAEG;kBACW,OAAO,GAAG,CA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