@strapi/strapi 4.14.5 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/strapi.js +1 -6
- package/dist/Strapi.js +454 -532
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +464 -0
- package/dist/Strapi.mjs.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/actions/admin/create-user/action.js +75 -94
- package/dist/commands/actions/admin/create-user/action.js.map +1 -1
- package/dist/commands/actions/admin/create-user/command.d.ts.map +1 -1
- package/dist/commands/actions/admin/create-user/command.js +6 -17
- package/dist/commands/actions/admin/create-user/command.js.map +1 -1
- package/dist/commands/actions/admin/reset-user-password/action.js +33 -36
- package/dist/commands/actions/admin/reset-user-password/action.js.map +1 -1
- package/dist/commands/actions/admin/reset-user-password/command.d.ts.map +1 -1
- package/dist/commands/actions/admin/reset-user-password/command.js +6 -15
- package/dist/commands/actions/admin/reset-user-password/command.js.map +1 -1
- package/dist/commands/actions/build-command/action.js +15 -18
- package/dist/commands/actions/build-command/action.js.map +1 -1
- package/dist/commands/actions/build-command/command.d.ts.map +1 -1
- package/dist/commands/actions/build-command/command.js +6 -13
- package/dist/commands/actions/build-command/command.js.map +1 -1
- package/dist/commands/actions/components/list/action.js +18 -18
- package/dist/commands/actions/components/list/action.js.map +1 -1
- package/dist/commands/actions/components/list/command.d.ts.map +1 -1
- package/dist/commands/actions/components/list/command.js +6 -12
- package/dist/commands/actions/components/list/command.js.map +1 -1
- package/dist/commands/actions/configuration/dump/action.js +33 -43
- package/dist/commands/actions/configuration/dump/action.js.map +1 -1
- package/dist/commands/actions/configuration/dump/command.d.ts.map +1 -1
- package/dist/commands/actions/configuration/dump/command.js +6 -15
- package/dist/commands/actions/configuration/dump/command.js.map +1 -1
- package/dist/commands/actions/configuration/restore/action.js +122 -139
- package/dist/commands/actions/configuration/restore/action.js.map +1 -1
- package/dist/commands/actions/configuration/restore/command.d.ts.map +1 -1
- package/dist/commands/actions/configuration/restore/command.js +6 -15
- package/dist/commands/actions/configuration/restore/command.js.map +1 -1
- package/dist/commands/actions/console/action.js +19 -23
- package/dist/commands/actions/console/action.js.map +1 -1
- package/dist/commands/actions/console/command.d.ts.map +1 -1
- package/dist/commands/actions/console/command.js +6 -12
- package/dist/commands/actions/console/command.js.map +1 -1
- package/dist/commands/actions/content-types/list/action.js +18 -18
- package/dist/commands/actions/content-types/list/action.js.map +1 -1
- package/dist/commands/actions/content-types/list/command.d.ts.map +1 -1
- package/dist/commands/actions/content-types/list/command.js +6 -12
- package/dist/commands/actions/content-types/list/command.js.map +1 -1
- package/dist/commands/actions/controllers/list/action.js +18 -18
- package/dist/commands/actions/controllers/list/action.js.map +1 -1
- package/dist/commands/actions/controllers/list/command.d.ts.map +1 -1
- package/dist/commands/actions/controllers/list/command.js +6 -12
- package/dist/commands/actions/controllers/list/command.js.map +1 -1
- package/dist/commands/actions/develop/action.d.ts +1 -75
- package/dist/commands/actions/develop/action.d.ts.map +1 -1
- package/dist/commands/actions/develop/action.js +184 -177
- package/dist/commands/actions/develop/action.js.map +1 -1
- package/dist/commands/actions/develop/command.d.ts.map +1 -1
- package/dist/commands/actions/develop/command.js +6 -17
- package/dist/commands/actions/develop/command.js.map +1 -1
- package/dist/commands/actions/generate/command.js +30 -16
- package/dist/commands/actions/generate/command.js.map +1 -1
- package/dist/commands/actions/hooks/list/action.js +18 -18
- package/dist/commands/actions/hooks/list/action.js.map +1 -1
- package/dist/commands/actions/hooks/list/command.d.ts.map +1 -1
- package/dist/commands/actions/hooks/list/command.js +6 -12
- package/dist/commands/actions/hooks/list/command.js.map +1 -1
- package/dist/commands/actions/install/action.js +41 -45
- package/dist/commands/actions/install/action.js.map +1 -1
- package/dist/commands/actions/install/command.d.ts.map +1 -1
- package/dist/commands/actions/install/command.js +6 -12
- package/dist/commands/actions/install/command.js.map +1 -1
- package/dist/commands/actions/middlewares/list/action.js +18 -18
- package/dist/commands/actions/middlewares/list/action.js.map +1 -1
- package/dist/commands/actions/middlewares/list/command.d.ts.map +1 -1
- package/dist/commands/actions/middlewares/list/command.js +6 -12
- package/dist/commands/actions/middlewares/list/command.js.map +1 -1
- package/dist/commands/actions/new/action.js +5 -10
- package/dist/commands/actions/new/action.js.map +1 -1
- package/dist/commands/actions/new/command.js +14 -33
- package/dist/commands/actions/new/command.js.map +1 -1
- package/dist/commands/actions/plugin/build-command/action.js +80 -79
- package/dist/commands/actions/plugin/build-command/action.js.map +1 -1
- package/dist/commands/actions/plugin/build-command/command.d.ts.map +1 -1
- package/dist/commands/actions/plugin/build-command/command.js +7 -18
- package/dist/commands/actions/plugin/build-command/command.js.map +1 -1
- package/dist/commands/actions/plugin/watch/action.d.ts +7 -0
- package/dist/commands/actions/plugin/watch/action.d.ts.map +1 -0
- package/dist/commands/actions/plugin/watch/action.js +85 -0
- package/dist/commands/actions/plugin/watch/action.js.map +1 -0
- package/dist/commands/actions/plugin/watch/command.d.ts +7 -0
- package/dist/commands/actions/plugin/watch/command.d.ts.map +1 -0
- package/dist/commands/actions/plugin/watch/command.js +8 -0
- package/dist/commands/actions/plugin/watch/command.js.map +1 -0
- package/dist/commands/actions/policies/list/action.js +18 -18
- package/dist/commands/actions/policies/list/action.js.map +1 -1
- package/dist/commands/actions/policies/list/command.d.ts.map +1 -1
- package/dist/commands/actions/policies/list/command.js +6 -12
- package/dist/commands/actions/policies/list/command.js.map +1 -1
- package/dist/commands/actions/report/action.js +22 -25
- package/dist/commands/actions/report/action.js.map +1 -1
- package/dist/commands/actions/report/command.d.ts.map +1 -1
- package/dist/commands/actions/report/command.js +6 -15
- package/dist/commands/actions/report/command.js.map +1 -1
- package/dist/commands/actions/routes/list/action.js +22 -24
- package/dist/commands/actions/routes/list/action.js.map +1 -1
- package/dist/commands/actions/routes/list/command.d.ts.map +1 -1
- package/dist/commands/actions/routes/list/command.js +6 -12
- package/dist/commands/actions/routes/list/command.js.map +1 -1
- package/dist/commands/actions/services/list/action.js +18 -18
- package/dist/commands/actions/services/list/action.js.map +1 -1
- package/dist/commands/actions/services/list/command.d.ts.map +1 -1
- package/dist/commands/actions/services/list/command.js +6 -12
- package/dist/commands/actions/services/list/command.js.map +1 -1
- package/dist/commands/actions/start/action.d.ts +1 -74
- package/dist/commands/actions/start/action.d.ts.map +1 -1
- package/dist/commands/actions/start/action.js +19 -20
- package/dist/commands/actions/start/action.js.map +1 -1
- package/dist/commands/actions/start/command.d.ts.map +1 -1
- package/dist/commands/actions/start/command.js +6 -12
- package/dist/commands/actions/start/command.js.map +1 -1
- package/dist/commands/actions/telemetry/disable/action.js +72 -72
- package/dist/commands/actions/telemetry/disable/action.js.map +1 -1
- package/dist/commands/actions/telemetry/disable/command.d.ts.map +1 -1
- package/dist/commands/actions/telemetry/disable/command.js +6 -12
- package/dist/commands/actions/telemetry/disable/command.js.map +1 -1
- package/dist/commands/actions/telemetry/enable/action.js +87 -88
- package/dist/commands/actions/telemetry/enable/action.js.map +1 -1
- package/dist/commands/actions/telemetry/enable/command.d.ts.map +1 -1
- package/dist/commands/actions/telemetry/enable/command.js +6 -12
- package/dist/commands/actions/telemetry/enable/command.js.map +1 -1
- package/dist/commands/actions/templates/generate/action.js +59 -73
- package/dist/commands/actions/templates/generate/action.js.map +1 -1
- package/dist/commands/actions/templates/generate/command.d.ts.map +1 -1
- package/dist/commands/actions/templates/generate/command.js +6 -12
- package/dist/commands/actions/templates/generate/command.js.map +1 -1
- package/dist/commands/actions/ts/generate-types/action.js +25 -26
- package/dist/commands/actions/ts/generate-types/action.js.map +1 -1
- package/dist/commands/actions/ts/generate-types/command.d.ts.map +1 -1
- package/dist/commands/actions/ts/generate-types/command.js +9 -16
- package/dist/commands/actions/ts/generate-types/command.js.map +1 -1
- package/dist/commands/actions/uninstall/action.js +60 -62
- package/dist/commands/actions/uninstall/action.js.map +1 -1
- package/dist/commands/actions/uninstall/command.d.ts.map +1 -1
- package/dist/commands/actions/uninstall/command.js +6 -13
- package/dist/commands/actions/uninstall/command.js.map +1 -1
- package/dist/commands/actions/version/command.js +10 -17
- package/dist/commands/actions/version/command.js.map +1 -1
- package/dist/commands/actions/watch-admin/action.js +33 -34
- package/dist/commands/actions/watch-admin/action.js.map +1 -1
- package/dist/commands/actions/watch-admin/command.d.ts.map +1 -1
- package/dist/commands/actions/watch-admin/command.js +6 -13
- package/dist/commands/actions/watch-admin/command.js.map +1 -1
- package/dist/commands/builders/admin.js +46 -50
- package/dist/commands/builders/admin.js.map +1 -1
- package/dist/commands/builders/typescript.js +28 -25
- package/dist/commands/builders/typescript.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +102 -91
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/utils/commander.js +11 -136
- package/dist/commands/utils/commander.js.map +1 -1
- package/dist/commands/utils/helpers.d.ts +4 -6
- package/dist/commands/utils/helpers.d.ts.map +1 -1
- package/dist/commands/utils/helpers.js +57 -155
- package/dist/commands/utils/helpers.js.map +1 -1
- package/dist/commands/utils/logger.js +59 -49
- package/dist/commands/utils/logger.js.map +1 -1
- package/dist/commands/utils/pkg.js +98 -107
- package/dist/commands/utils/pkg.js.map +1 -1
- package/dist/compile.js +15 -17
- package/dist/compile.js.map +1 -1
- package/dist/compile.mjs +17 -0
- package/dist/compile.mjs.map +1 -0
- package/dist/container.js +32 -35
- package/dist/container.js.map +1 -1
- package/dist/container.mjs +36 -0
- package/dist/container.mjs.map +1 -0
- package/dist/core/app-configuration/config-loader.js +17 -20
- package/dist/core/app-configuration/config-loader.js.map +1 -1
- package/dist/core/app-configuration/config-loader.mjs +17 -0
- package/dist/core/app-configuration/config-loader.mjs.map +1 -0
- package/dist/core/app-configuration/index.js +51 -50
- package/dist/core/app-configuration/index.js.map +1 -1
- package/dist/core/app-configuration/index.mjs +51 -0
- package/dist/core/app-configuration/index.mjs.map +1 -0
- package/dist/core/app-configuration/load-config-file.js +34 -38
- package/dist/core/app-configuration/load-config-file.js.map +1 -1
- package/dist/core/app-configuration/load-config-file.mjs +42 -0
- package/dist/core/app-configuration/load-config-file.mjs.map +1 -0
- package/dist/core/bootstrap.js +25 -24
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/bootstrap.mjs +27 -0
- package/dist/core/bootstrap.mjs.map +1 -0
- package/dist/core/domain/content-type/index.js +108 -104
- package/dist/core/domain/content-type/index.js.map +1 -1
- package/dist/core/domain/content-type/index.mjs +119 -0
- package/dist/core/domain/content-type/index.mjs.map +1 -0
- package/dist/core/domain/content-type/validator.js +69 -83
- package/dist/core/domain/content-type/validator.js.map +1 -1
- package/dist/core/domain/content-type/validator.mjs +75 -0
- package/dist/core/domain/content-type/validator.mjs.map +1 -0
- package/dist/core/domain/module/index.js +97 -100
- package/dist/core/domain/module/index.js.map +1 -1
- package/dist/core/domain/module/index.mjs +105 -0
- package/dist/core/domain/module/index.mjs.map +1 -0
- package/dist/core/domain/module/validation.js +21 -25
- package/dist/core/domain/module/validation.js.map +1 -1
- package/dist/core/domain/module/validation.mjs +25 -0
- package/dist/core/domain/module/validation.mjs.map +1 -0
- package/dist/core/loaders/admin.js +13 -15
- package/dist/core/loaders/admin.js.map +1 -1
- package/dist/core/loaders/admin.mjs +15 -0
- package/dist/core/loaders/admin.mjs.map +1 -0
- package/dist/core/loaders/apis.js +109 -135
- package/dist/core/loaders/apis.js.map +1 -1
- package/dist/core/loaders/apis.mjs +128 -0
- package/dist/core/loaders/apis.mjs.map +1 -0
- package/dist/core/loaders/components.js +34 -34
- package/dist/core/loaders/components.js.map +1 -1
- package/dist/core/loaders/components.mjs +36 -0
- package/dist/core/loaders/components.mjs.map +1 -0
- package/dist/core/loaders/index.js +21 -24
- package/dist/core/loaders/index.js.map +1 -1
- package/dist/core/loaders/index.mjs +24 -0
- package/dist/core/loaders/index.mjs.map +1 -0
- package/dist/core/loaders/middlewares.js +25 -28
- package/dist/core/loaders/middlewares.js.map +1 -1
- package/dist/core/loaders/middlewares.mjs +30 -0
- package/dist/core/loaders/middlewares.mjs.map +1 -0
- package/dist/core/loaders/plugins/get-enabled-plugins.js +96 -99
- package/dist/core/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/core/loaders/plugins/get-enabled-plugins.mjs +108 -0
- package/dist/core/loaders/plugins/get-enabled-plugins.mjs.map +1 -0
- package/dist/core/loaders/plugins/get-user-plugins-config.js +23 -27
- package/dist/core/loaders/plugins/get-user-plugins-config.js.map +1 -1
- package/dist/core/loaders/plugins/get-user-plugins-config.mjs +25 -0
- package/dist/core/loaders/plugins/get-user-plugins-config.mjs.map +1 -0
- package/dist/core/loaders/plugins/index.js +92 -96
- package/dist/core/loaders/plugins/index.js.map +1 -1
- package/dist/core/loaders/plugins/index.mjs +104 -0
- package/dist/core/loaders/plugins/index.mjs.map +1 -0
- package/dist/core/loaders/policies.js +21 -24
- package/dist/core/loaders/policies.js.map +1 -1
- package/dist/core/loaders/policies.mjs +24 -0
- package/dist/core/loaders/policies.mjs.map +1 -0
- package/dist/core/loaders/sanitizers.js +4 -4
- package/dist/core/loaders/sanitizers.js.map +1 -1
- package/dist/core/loaders/sanitizers.mjs +7 -0
- package/dist/core/loaders/sanitizers.mjs.map +1 -0
- package/dist/core/loaders/src-index.js +28 -32
- package/dist/core/loaders/src-index.js.map +1 -1
- package/dist/core/loaders/src-index.mjs +34 -0
- package/dist/core/loaders/src-index.mjs.map +1 -0
- package/dist/core/loaders/validators.js +4 -4
- package/dist/core/loaders/validators.js.map +1 -1
- package/dist/core/loaders/validators.mjs +7 -0
- package/dist/core/loaders/validators.mjs.map +1 -0
- package/dist/core/registries/apis.js +20 -21
- package/dist/core/registries/apis.js.map +1 -1
- package/dist/core/registries/apis.mjs +24 -0
- package/dist/core/registries/apis.mjs.map +1 -0
- package/dist/core/registries/config.js +21 -21
- package/dist/core/registries/config.js.map +1 -1
- package/dist/core/registries/config.mjs +22 -0
- package/dist/core/registries/config.mjs.map +1 -0
- package/dist/core/registries/content-types.js +65 -64
- package/dist/core/registries/content-types.js.map +1 -1
- package/dist/core/registries/content-types.mjs +72 -0
- package/dist/core/registries/content-types.mjs.map +1 -0
- package/dist/core/registries/controllers.js +77 -78
- package/dist/core/registries/controllers.js.map +1 -1
- package/dist/core/registries/controllers.mjs +81 -0
- package/dist/core/registries/controllers.mjs.map +1 -0
- package/dist/core/registries/custom-fields.js +66 -69
- package/dist/core/registries/custom-fields.js.map +1 -1
- package/dist/core/registries/custom-fields.mjs +72 -0
- package/dist/core/registries/custom-fields.mjs.map +1 -0
- package/dist/core/registries/hooks.js +55 -56
- package/dist/core/registries/hooks.js.map +1 -1
- package/dist/core/registries/hooks.mjs +59 -0
- package/dist/core/registries/hooks.mjs.map +1 -0
- package/dist/core/registries/middlewares.js +57 -59
- package/dist/core/registries/middlewares.js.map +1 -1
- package/dist/core/registries/middlewares.mjs +61 -0
- package/dist/core/registries/middlewares.mjs.map +1 -0
- package/dist/core/registries/modules.js +36 -37
- package/dist/core/registries/modules.js.map +1 -1
- package/dist/core/registries/modules.mjs +40 -0
- package/dist/core/registries/modules.mjs.map +1 -0
- package/dist/core/registries/plugins.js +20 -21
- package/dist/core/registries/plugins.js.map +1 -1
- package/dist/core/registries/plugins.mjs +24 -0
- package/dist/core/registries/plugins.mjs.map +1 -0
- package/dist/core/registries/policies.js +59 -61
- package/dist/core/registries/policies.js.map +1 -1
- package/dist/core/registries/policies.mjs +63 -0
- package/dist/core/registries/policies.mjs.map +1 -0
- package/dist/core/registries/sanitizers.js +22 -24
- package/dist/core/registries/sanitizers.js.map +1 -1
- package/dist/core/registries/sanitizers.mjs +24 -0
- package/dist/core/registries/sanitizers.mjs.map +1 -0
- package/dist/core/registries/services.js +77 -79
- package/dist/core/registries/services.js.map +1 -1
- package/dist/core/registries/services.mjs +81 -0
- package/dist/core/registries/services.mjs.map +1 -0
- package/dist/core/registries/validators.js +22 -24
- package/dist/core/registries/validators.js.map +1 -1
- package/dist/core/registries/validators.mjs +24 -0
- package/dist/core/registries/validators.mjs.map +1 -0
- package/dist/core/utils.js +19 -20
- package/dist/core/utils.js.map +1 -1
- package/dist/core/utils.mjs +27 -0
- package/dist/core/utils.mjs.map +1 -0
- package/dist/core-api/controller/collection-type.js +90 -93
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs +93 -0
- package/dist/core-api/controller/collection-type.mjs.map +1 -0
- package/dist/core-api/controller/index.js +43 -46
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs +47 -0
- package/dist/core-api/controller/index.mjs.map +1 -0
- package/dist/core-api/controller/single-type.js +48 -50
- package/dist/core-api/controller/single-type.js.map +1 -1
- package/dist/core-api/controller/single-type.mjs +51 -0
- package/dist/core-api/controller/single-type.mjs.map +1 -0
- package/dist/core-api/controller/transform.js +70 -72
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs +84 -0
- package/dist/core-api/controller/transform.mjs.map +1 -0
- package/dist/core-api/routes/index.js +60 -61
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs +67 -0
- package/dist/core-api/routes/index.mjs.map +1 -0
- package/dist/core-api/service/collection-type.js +57 -57
- package/dist/core-api/service/collection-type.js.map +1 -1
- package/dist/core-api/service/collection-type.mjs +62 -0
- package/dist/core-api/service/collection-type.mjs.map +1 -0
- package/dist/core-api/service/get-fetch-params.js +10 -12
- package/dist/core-api/service/get-fetch-params.js.map +1 -1
- package/dist/core-api/service/get-fetch-params.mjs +14 -0
- package/dist/core-api/service/get-fetch-params.mjs.map +1 -0
- package/dist/core-api/service/index.js +13 -15
- package/dist/core-api/service/index.js.map +1 -1
- package/dist/core-api/service/index.mjs +16 -0
- package/dist/core-api/service/index.mjs.map +1 -0
- package/dist/core-api/service/pagination.js +71 -79
- package/dist/core-api/service/pagination.js.map +1 -1
- package/dist/core-api/service/pagination.mjs +89 -0
- package/dist/core-api/service/pagination.mjs.map +1 -0
- package/dist/core-api/service/single-type.js +53 -53
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +58 -0
- package/dist/core-api/service/single-type.mjs.map +1 -0
- package/dist/ee/index.js +128 -160
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +154 -0
- package/dist/ee/index.mjs.map +1 -0
- package/dist/ee/license.js +72 -77
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +86 -0
- package/dist/ee/license.mjs.map +1 -0
- package/dist/factories.js +62 -61
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +71 -0
- package/dist/factories.mjs.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -0
- package/dist/load/filepath-to-prop-path.js +9 -19
- package/dist/load/filepath-to-prop-path.js.map +1 -1
- package/dist/load/filepath-to-prop-path.mjs +10 -0
- package/dist/load/filepath-to-prop-path.mjs.map +1 -0
- package/dist/load/glob.js +11 -16
- package/dist/load/glob.js.map +1 -1
- package/dist/load/glob.mjs +14 -0
- package/dist/load/glob.mjs.map +1 -0
- package/dist/load/load-files.js +35 -43
- package/dist/load/load-files.js.map +1 -1
- package/dist/load/load-files.mjs +35 -0
- package/dist/load/load-files.mjs.map +1 -0
- package/dist/load/package-path.js +6 -10
- package/dist/load/package-path.js.map +1 -1
- package/dist/middlewares/body.js +53 -66
- package/dist/middlewares/body.js.map +1 -1
- package/dist/middlewares/body.mjs +61 -0
- package/dist/middlewares/body.mjs.map +1 -0
- package/dist/middlewares/compression.js +6 -8
- package/dist/middlewares/compression.js.map +1 -1
- package/dist/middlewares/compression.mjs +6 -0
- package/dist/middlewares/compression.mjs.map +1 -0
- package/dist/middlewares/cors.js +45 -48
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/middlewares/cors.mjs +49 -0
- package/dist/middlewares/cors.mjs.map +1 -0
- package/dist/middlewares/errors.js +30 -32
- package/dist/middlewares/errors.js.map +1 -1
- package/dist/middlewares/errors.mjs +33 -0
- package/dist/middlewares/errors.mjs.map +1 -0
- package/dist/middlewares/favicon.js +16 -24
- package/dist/middlewares/favicon.js.map +1 -1
- package/dist/middlewares/favicon.mjs +20 -0
- package/dist/middlewares/favicon.mjs.map +1 -0
- package/dist/middlewares/index.js +32 -32
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/index.mjs +34 -0
- package/dist/middlewares/index.mjs.map +1 -0
- package/dist/middlewares/ip.js +6 -8
- package/dist/middlewares/ip.js.map +1 -1
- package/dist/middlewares/ip.mjs +6 -0
- package/dist/middlewares/ip.mjs.map +1 -0
- package/dist/middlewares/logger.js +8 -9
- package/dist/middlewares/logger.js.map +1 -1
- package/dist/middlewares/logger.mjs +12 -0
- package/dist/middlewares/logger.mjs.map +1 -0
- package/dist/middlewares/powered-by.js +8 -9
- package/dist/middlewares/powered-by.js.map +1 -1
- package/dist/middlewares/powered-by.mjs +14 -0
- package/dist/middlewares/powered-by.mjs.map +1 -0
- package/dist/middlewares/public/index.js +85 -106
- package/dist/middlewares/public/index.js.map +1 -1
- package/dist/middlewares/public/index.mjs +85 -0
- package/dist/middlewares/public/index.mjs.map +1 -0
- package/dist/middlewares/public/serve-static.js +20 -23
- package/dist/middlewares/public/serve-static.js.map +1 -1
- package/dist/middlewares/public/serve-static.mjs +21 -0
- package/dist/middlewares/public/serve-static.mjs.map +1 -0
- package/dist/middlewares/query.js +32 -37
- package/dist/middlewares/query.js.map +1 -1
- package/dist/middlewares/query.mjs +38 -0
- package/dist/middlewares/query.mjs.map +1 -0
- package/dist/middlewares/response-time.js +8 -9
- package/dist/middlewares/response-time.js.map +1 -1
- package/dist/middlewares/response-time.mjs +12 -0
- package/dist/middlewares/response-time.mjs.map +1 -0
- package/dist/middlewares/responses.js +11 -12
- package/dist/middlewares/responses.js.map +1 -1
- package/dist/middlewares/responses.mjs +15 -0
- package/dist/middlewares/responses.mjs.map +1 -0
- package/dist/middlewares/security.js +44 -46
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +48 -0
- package/dist/middlewares/security.mjs.map +1 -0
- package/dist/middlewares/session.js +24 -24
- package/dist/middlewares/session.js.map +1 -1
- package/dist/middlewares/session.mjs +28 -0
- package/dist/middlewares/session.mjs.map +1 -0
- package/dist/migrations/draft-publish.js +27 -36
- package/dist/migrations/draft-publish.js.map +1 -1
- package/dist/migrations/draft-publish.mjs +37 -0
- package/dist/migrations/draft-publish.mjs.map +1 -0
- package/dist/services/auth/index.js +74 -77
- package/dist/services/auth/index.js.map +1 -1
- package/dist/services/auth/index.mjs +80 -0
- package/dist/services/auth/index.mjs.map +1 -0
- package/dist/services/content-api/index.js +54 -57
- package/dist/services/content-api/index.js.map +1 -1
- package/dist/services/content-api/index.mjs +58 -0
- package/dist/services/content-api/index.mjs.map +1 -0
- package/dist/services/content-api/permissions/engine.js +6 -7
- package/dist/services/content-api/permissions/engine.js.map +1 -1
- package/dist/services/content-api/permissions/engine.mjs +6 -0
- package/dist/services/content-api/permissions/engine.mjs.map +1 -0
- package/dist/services/content-api/permissions/index.js +79 -102
- package/dist/services/content-api/permissions/index.js.map +1 -1
- package/dist/services/content-api/permissions/index.mjs +86 -0
- package/dist/services/content-api/permissions/index.mjs.map +1 -0
- package/dist/services/content-api/permissions/providers/action.js +14 -14
- package/dist/services/content-api/permissions/providers/action.js.map +1 -1
- package/dist/services/content-api/permissions/providers/action.mjs +17 -0
- package/dist/services/content-api/permissions/providers/action.mjs.map +1 -0
- package/dist/services/content-api/permissions/providers/condition.js +14 -14
- package/dist/services/content-api/permissions/providers/condition.js.map +1 -1
- package/dist/services/content-api/permissions/providers/condition.mjs +17 -0
- package/dist/services/content-api/permissions/providers/condition.mjs.map +1 -0
- package/dist/services/core-store.js +91 -111
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs +103 -0
- package/dist/services/core-store.mjs.map +1 -0
- package/dist/services/cron.js +60 -66
- package/dist/services/cron.js.map +1 -1
- package/dist/services/cron.mjs +64 -0
- package/dist/services/cron.mjs.map +1 -0
- package/dist/services/custom-fields.js +7 -8
- package/dist/services/custom-fields.js.map +1 -1
- package/dist/services/custom-fields.mjs +11 -0
- package/dist/services/custom-fields.mjs.map +1 -0
- package/dist/services/entity-service/attributes/index.js +17 -21
- package/dist/services/entity-service/attributes/index.js.map +1 -1
- package/dist/services/entity-service/attributes/index.mjs +22 -0
- package/dist/services/entity-service/attributes/index.mjs.map +1 -0
- package/dist/services/entity-service/attributes/transforms.js +17 -19
- package/dist/services/entity-service/attributes/transforms.js.map +1 -1
- package/dist/services/entity-service/attributes/transforms.mjs +19 -0
- package/dist/services/entity-service/attributes/transforms.mjs.map +1 -0
- package/dist/services/entity-service/components.js +336 -333
- package/dist/services/entity-service/components.js.map +1 -1
- package/dist/services/entity-service/components.mjs +382 -0
- package/dist/services/entity-service/components.mjs.map +1 -0
- package/dist/services/entity-service/index.js +314 -297
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs +326 -0
- package/dist/services/entity-service/index.mjs.map +1 -0
- package/dist/services/entity-service/params.js +4 -5
- package/dist/services/entity-service/params.js.map +1 -1
- package/dist/services/entity-service/params.mjs +8 -0
- package/dist/services/entity-service/params.mjs.map +1 -0
- package/dist/services/entity-validator/blocks-validator.js +95 -116
- package/dist/services/entity-validator/blocks-validator.js.map +1 -1
- package/dist/services/entity-validator/blocks-validator.mjs +108 -0
- package/dist/services/entity-validator/blocks-validator.mjs.map +1 -0
- package/dist/services/entity-validator/index.js +284 -297
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +318 -0
- package/dist/services/entity-validator/index.mjs.map +1 -0
- package/dist/services/entity-validator/validators.js +92 -124
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +115 -0
- package/dist/services/entity-validator/validators.mjs.map +1 -0
- package/dist/services/errors.js +64 -66
- package/dist/services/errors.js.map +1 -1
- package/dist/services/errors.mjs +74 -0
- package/dist/services/errors.mjs.map +1 -0
- package/dist/services/event-hub.js +64 -74
- package/dist/services/event-hub.js.map +1 -1
- package/dist/services/event-hub.mjs +68 -0
- package/dist/services/event-hub.mjs.map +1 -0
- package/dist/services/fs.js +48 -51
- package/dist/services/fs.js.map +1 -1
- package/dist/services/fs.mjs +49 -0
- package/dist/services/fs.mjs.map +1 -0
- package/dist/services/metrics/admin-user-hash.js +10 -15
- package/dist/services/metrics/admin-user-hash.js.map +1 -1
- package/dist/services/metrics/admin-user-hash.mjs +12 -0
- package/dist/services/metrics/admin-user-hash.mjs.map +1 -0
- package/dist/services/metrics/index.js +40 -48
- package/dist/services/metrics/index.js.map +1 -1
- package/dist/services/metrics/index.mjs +46 -0
- package/dist/services/metrics/index.mjs.map +1 -0
- package/dist/services/metrics/is-truthy.js +6 -8
- package/dist/services/metrics/is-truthy.js.map +1 -1
- package/dist/services/metrics/is-truthy.mjs +8 -0
- package/dist/services/metrics/is-truthy.mjs.map +1 -0
- package/dist/services/metrics/middleware.js +22 -25
- package/dist/services/metrics/middleware.js.map +1 -1
- package/dist/services/metrics/middleware.mjs +26 -0
- package/dist/services/metrics/middleware.mjs.map +1 -0
- package/dist/services/metrics/rate-limiter.js +19 -19
- package/dist/services/metrics/rate-limiter.js.map +1 -1
- package/dist/services/metrics/rate-limiter.mjs +22 -0
- package/dist/services/metrics/rate-limiter.mjs.map +1 -0
- package/dist/services/metrics/sender.js +69 -72
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +71 -0
- package/dist/services/metrics/sender.mjs.map +1 -0
- package/dist/services/request-context.js +10 -11
- package/dist/services/request-context.js.map +1 -1
- package/dist/services/request-context.mjs +14 -0
- package/dist/services/request-context.mjs.map +1 -0
- package/dist/services/server/admin-api.js +9 -9
- package/dist/services/server/admin-api.js.map +1 -1
- package/dist/services/server/admin-api.mjs +13 -0
- package/dist/services/server/admin-api.mjs.map +1 -0
- package/dist/services/server/api.js +26 -28
- package/dist/services/server/api.js.map +1 -1
- package/dist/services/server/api.mjs +28 -0
- package/dist/services/server/api.mjs.map +1 -0
- package/dist/services/server/compose-endpoint.js +94 -100
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs +114 -0
- package/dist/services/server/compose-endpoint.mjs.map +1 -0
- package/dist/services/server/content-api.js +8 -9
- package/dist/services/server/content-api.js.map +1 -1
- package/dist/services/server/content-api.mjs +12 -0
- package/dist/services/server/content-api.mjs.map +1 -0
- package/dist/services/server/http-server.js +42 -47
- package/dist/services/server/http-server.js.map +1 -1
- package/dist/services/server/http-server.mjs +47 -0
- package/dist/services/server/http-server.mjs.map +1 -0
- package/dist/services/server/index.js +82 -85
- package/dist/services/server/index.js.map +1 -1
- package/dist/services/server/index.mjs +86 -0
- package/dist/services/server/index.mjs.map +1 -0
- package/dist/services/server/koa.js +46 -50
- package/dist/services/server/koa.js.map +1 -1
- package/dist/services/server/koa.mjs +48 -0
- package/dist/services/server/koa.mjs.map +1 -0
- package/dist/services/server/middleware.js +80 -91
- package/dist/services/server/middleware.js.map +1 -1
- package/dist/services/server/middleware.mjs +90 -0
- package/dist/services/server/middleware.mjs.map +1 -0
- package/dist/services/server/policy.js +16 -17
- package/dist/services/server/policy.js.map +1 -1
- package/dist/services/server/policy.mjs +20 -0
- package/dist/services/server/policy.mjs.map +1 -0
- package/dist/services/server/register-middlewares.js +58 -68
- package/dist/services/server/register-middlewares.js.map +1 -1
- package/dist/services/server/register-middlewares.mjs +73 -0
- package/dist/services/server/register-middlewares.mjs.map +1 -0
- package/dist/services/server/register-routes.js +64 -82
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs +75 -0
- package/dist/services/server/register-routes.mjs.map +1 -0
- package/dist/services/server/routing.js +80 -94
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs +89 -0
- package/dist/services/server/routing.mjs.map +1 -0
- package/dist/services/utils/dynamic-zones.js +13 -10
- package/dist/services/utils/dynamic-zones.js.map +1 -1
- package/dist/services/utils/dynamic-zones.mjs +17 -0
- package/dist/services/utils/dynamic-zones.mjs.map +1 -0
- package/dist/services/utils/upload-files.js +59 -68
- package/dist/services/utils/upload-files.js.map +1 -1
- package/dist/services/utils/upload-files.mjs +63 -0
- package/dist/services/utils/upload-files.mjs.map +1 -0
- package/dist/services/webhook-runner.js +122 -130
- package/dist/services/webhook-runner.js.map +1 -1
- package/dist/services/webhook-runner.mjs +131 -0
- package/dist/services/webhook-runner.mjs.map +1 -0
- package/dist/services/webhook-store.js +87 -93
- package/dist/services/webhook-store.js.map +1 -1
- package/dist/services/webhook-store.mjs +100 -0
- package/dist/services/webhook-store.mjs.map +1 -0
- package/dist/services/worker-queue.js +49 -57
- package/dist/services/worker-queue.js.map +1 -1
- package/dist/services/worker-queue.mjs +55 -0
- package/dist/services/worker-queue.mjs.map +1 -0
- package/dist/utils/addSlash.js +13 -13
- package/dist/utils/addSlash.js.map +1 -1
- package/dist/utils/convert-custom-field-type.js +19 -16
- package/dist/utils/convert-custom-field-type.js.map +1 -1
- package/dist/utils/convert-custom-field-type.mjs +24 -0
- package/dist/utils/convert-custom-field-type.mjs.map +1 -0
- package/dist/utils/cron.js +29 -47
- package/dist/utils/cron.js.map +1 -1
- package/dist/utils/cron.mjs +38 -0
- package/dist/utils/cron.mjs.map +1 -0
- package/dist/utils/ee.js +3 -7
- package/dist/utils/ee.js.map +1 -1
- package/dist/utils/ee.mjs +5 -0
- package/dist/utils/ee.mjs.map +1 -0
- package/dist/utils/fetch.js +17 -19
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs +19 -0
- package/dist/utils/fetch.mjs.map +1 -0
- package/dist/utils/get-dirs.js +26 -27
- package/dist/utils/get-dirs.js.map +1 -1
- package/dist/utils/get-dirs.mjs +30 -0
- package/dist/utils/get-dirs.mjs.map +1 -0
- package/dist/utils/is-initialized.js +11 -17
- package/dist/utils/is-initialized.js.map +1 -1
- package/dist/utils/is-initialized.mjs +16 -0
- package/dist/utils/is-initialized.mjs.map +1 -0
- package/dist/utils/lifecycles.js +7 -7
- package/dist/utils/lifecycles.js.map +1 -1
- package/dist/utils/lifecycles.mjs +9 -0
- package/dist/utils/lifecycles.mjs.map +1 -0
- package/dist/utils/machine-id.js +12 -13
- package/dist/utils/machine-id.js.map +1 -1
- package/dist/utils/machine-id.mjs +15 -0
- package/dist/utils/machine-id.mjs.map +1 -0
- package/dist/utils/open-browser.js +8 -10
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/open-browser.mjs +10 -0
- package/dist/utils/open-browser.mjs.map +1 -0
- package/dist/utils/signals.js +13 -16
- package/dist/utils/signals.js.map +1 -1
- package/dist/utils/signals.mjs +17 -0
- package/dist/utils/signals.mjs.map +1 -0
- package/dist/utils/startup-logger.js +73 -66
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs +72 -0
- package/dist/utils/startup-logger.mjs.map +1 -0
- package/dist/utils/update-notifier/index.js +69 -72
- package/dist/utils/update-notifier/index.js.map +1 -1
- package/dist/utils/update-notifier/index.mjs +76 -0
- package/dist/utils/update-notifier/index.mjs.map +1 -0
- package/package.json +26 -25
- package/dist/commands/builders/index.js +0 -11
- package/dist/commands/builders/index.js.map +0 -1
- package/dist/commands/types.js +0 -3
- package/dist/commands/types.js.map +0 -1
- package/dist/load/index.js +0 -11
- package/dist/load/index.js.map +0 -1
- package/dist/services/content-api/permissions/providers/index.js +0 -11
- package/dist/services/content-api/permissions/providers/index.js.map +0 -1
- package/dist/utils/index.js +0 -13
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/postinstall.js +0 -32
- package/dist/utils/postinstall.js.map +0 -1
- package/index.js +0 -5
|
@@ -1,381 +1,384 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const utils_1 = require("@strapi/utils");
|
|
10
|
-
const isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const _$1 = require("lodash");
|
|
4
|
+
const _ = require("lodash/fp");
|
|
5
|
+
const strapiUtils = require("@strapi/utils");
|
|
6
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
7
|
+
const ___default = /* @__PURE__ */ _interopDefault(_$1);
|
|
8
|
+
const isDialectMySQL = () => strapi.db?.dialect.client === "mysql";
|
|
11
9
|
function omitComponentData(contentType, data) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const { attributes } = contentType;
|
|
11
|
+
const componentAttributes = Object.keys(attributes).filter(
|
|
12
|
+
(attributeName) => strapiUtils.contentTypes.isComponentAttribute(attributes[attributeName])
|
|
13
|
+
);
|
|
14
|
+
return _.omit(componentAttributes, data);
|
|
15
15
|
}
|
|
16
|
-
exports.omitComponentData = omitComponentData;
|
|
17
|
-
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
|
|
18
16
|
const createComponents = async (uid, data) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
38
|
-
const components = (await (0, utils_1.mapAsync)(componentValue, (value) => createComponent(componentUID, value), { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }));
|
|
39
|
-
componentBody[attributeName] = components.map(({ id }) => {
|
|
40
|
-
return {
|
|
41
|
-
id,
|
|
42
|
-
__pivot: {
|
|
43
|
-
field: attributeName,
|
|
44
|
-
component_type: componentUID,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
const component = await createComponent(componentUID, componentValue);
|
|
51
|
-
componentBody[attributeName] = {
|
|
52
|
-
id: component.id,
|
|
53
|
-
__pivot: {
|
|
54
|
-
field: attributeName,
|
|
55
|
-
component_type: componentUID,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
continue;
|
|
17
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
18
|
+
const componentBody = {};
|
|
19
|
+
const attributeNames = Object.keys(attributes);
|
|
20
|
+
for (const attributeName of attributeNames) {
|
|
21
|
+
const attribute = attributes[attributeName];
|
|
22
|
+
if (!_.has(attributeName, data) || !strapiUtils.contentTypes.isComponentAttribute(attribute)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (attribute.type === "component") {
|
|
26
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
27
|
+
const componentValue = data[attributeName];
|
|
28
|
+
if (componentValue === null) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (repeatable === true) {
|
|
32
|
+
if (!Array.isArray(componentValue)) {
|
|
33
|
+
throw new Error("Expected an array to create repeatable component");
|
|
60
34
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
35
|
+
const components = await strapiUtils.mapAsync(
|
|
36
|
+
componentValue,
|
|
37
|
+
(value) => createComponent(componentUID, value),
|
|
38
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
39
|
+
);
|
|
40
|
+
componentBody[attributeName] = components.map(({ id }) => {
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
__pivot: {
|
|
44
|
+
field: attributeName,
|
|
45
|
+
component_type: componentUID
|
|
65
46
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
const component = await createComponent(
|
|
51
|
+
componentUID,
|
|
52
|
+
componentValue
|
|
53
|
+
);
|
|
54
|
+
componentBody[attributeName] = {
|
|
55
|
+
id: component.id,
|
|
56
|
+
__pivot: {
|
|
57
|
+
field: attributeName,
|
|
58
|
+
component_type: componentUID
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (attribute.type === "dynamiczone") {
|
|
65
|
+
const dynamiczoneValues = data[attributeName];
|
|
66
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
67
|
+
throw new Error("Expected an array to create repeatable component");
|
|
68
|
+
}
|
|
69
|
+
const createDynamicZoneComponents = async (value) => {
|
|
70
|
+
const { id } = await createComponent(value.__component, value);
|
|
71
|
+
return {
|
|
72
|
+
id,
|
|
73
|
+
__component: value.__component,
|
|
74
|
+
__pivot: {
|
|
75
|
+
field: attributeName
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
componentBody[attributeName] = await strapiUtils.mapAsync(
|
|
80
|
+
dynamiczoneValues,
|
|
81
|
+
createDynamicZoneComponents,
|
|
82
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
83
|
+
);
|
|
84
|
+
continue;
|
|
80
85
|
}
|
|
81
|
-
|
|
86
|
+
}
|
|
87
|
+
return componentBody;
|
|
82
88
|
};
|
|
83
|
-
exports.createComponents = createComponents;
|
|
84
89
|
const getComponents = async (uid, entity) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
const componentAttributes = strapiUtils.contentTypes.getComponentAttributes(strapi.getModel(uid));
|
|
91
|
+
if (___default.default.isEmpty(componentAttributes)) {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
return strapi.query(uid).load(entity, componentAttributes);
|
|
90
95
|
};
|
|
91
|
-
exports.getComponents = getComponents;
|
|
92
|
-
/*
|
|
93
|
-
delete old components
|
|
94
|
-
create or update
|
|
95
|
-
*/
|
|
96
96
|
const updateComponents = async (uid, entityToUpdate, data) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
98
|
+
const componentBody = {};
|
|
99
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
100
|
+
const attribute = attributes[attributeName];
|
|
101
|
+
if (!_.has(attributeName, data)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (attribute.type === "component") {
|
|
105
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
106
|
+
const componentValue = data[attributeName];
|
|
107
|
+
await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);
|
|
108
|
+
if (repeatable === true) {
|
|
109
|
+
if (!Array.isArray(componentValue)) {
|
|
110
|
+
throw new Error("Expected an array to create repeatable component");
|
|
103
111
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
id,
|
|
117
|
-
__pivot: {
|
|
118
|
-
field: attributeName,
|
|
119
|
-
component_type: componentUID,
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
const component = await updateOrCreateComponent(componentUID, componentValue);
|
|
126
|
-
componentBody[attributeName] = component && {
|
|
127
|
-
id: component.id,
|
|
128
|
-
__pivot: {
|
|
129
|
-
field: attributeName,
|
|
130
|
-
component_type: componentUID,
|
|
131
|
-
},
|
|
132
|
-
};
|
|
112
|
+
const components = await strapiUtils.mapAsync(
|
|
113
|
+
componentValue,
|
|
114
|
+
(value) => updateOrCreateComponent(componentUID, value),
|
|
115
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
116
|
+
);
|
|
117
|
+
componentBody[attributeName] = components.filter(___default.default.negate(___default.default.isNil)).map(({ id }) => {
|
|
118
|
+
return {
|
|
119
|
+
id,
|
|
120
|
+
__pivot: {
|
|
121
|
+
field: attributeName,
|
|
122
|
+
component_type: componentUID
|
|
133
123
|
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
const component = await updateOrCreateComponent(componentUID, componentValue);
|
|
128
|
+
componentBody[attributeName] = component && {
|
|
129
|
+
id: component.id,
|
|
130
|
+
__pivot: {
|
|
131
|
+
field: attributeName,
|
|
132
|
+
component_type: componentUID
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (attribute.type === "dynamiczone") {
|
|
139
|
+
const dynamiczoneValues = data[attributeName];
|
|
140
|
+
await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);
|
|
141
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
142
|
+
throw new Error("Expected an array to create repeatable component");
|
|
143
|
+
}
|
|
144
|
+
componentBody[attributeName] = await strapiUtils.mapAsync(
|
|
145
|
+
dynamiczoneValues,
|
|
146
|
+
async (value) => {
|
|
147
|
+
const { id } = await updateOrCreateComponent(value.__component, value);
|
|
148
|
+
return {
|
|
149
|
+
id,
|
|
150
|
+
__component: value.__component,
|
|
151
|
+
__pivot: {
|
|
152
|
+
field: attributeName
|
|
141
153
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
__component: value.__component,
|
|
148
|
-
__pivot: {
|
|
149
|
-
field: attributeName,
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
}, { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity });
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
157
|
+
);
|
|
158
|
+
continue;
|
|
155
159
|
}
|
|
156
|
-
|
|
160
|
+
}
|
|
161
|
+
return componentBody;
|
|
157
162
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
const pickStringifiedId = ({
|
|
164
|
+
id
|
|
165
|
+
}) => {
|
|
166
|
+
if (typeof id === "string") {
|
|
167
|
+
return id;
|
|
168
|
+
}
|
|
169
|
+
return `${id}`;
|
|
164
170
|
};
|
|
165
171
|
const deleteOldComponents = async (uid, componentUID, entityToUpdate, attributeName, componentValue) => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
172
|
+
const previousValue = await strapi.query(uid).load(entityToUpdate, attributeName);
|
|
173
|
+
const idsToKeep = ___default.default.castArray(componentValue).filter(_.has("id")).map(pickStringifiedId);
|
|
174
|
+
const allIds = ___default.default.castArray(previousValue).filter(_.has("id")).map(pickStringifiedId);
|
|
175
|
+
idsToKeep.forEach((id) => {
|
|
176
|
+
if (!allIds.includes(id)) {
|
|
177
|
+
throw new strapiUtils.errors.ApplicationError(
|
|
178
|
+
`Some of the provided components in ${attributeName} are not related to the entity`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
const idsToDelete = ___default.default.difference(allIds, idsToKeep);
|
|
183
|
+
if (idsToDelete.length > 0) {
|
|
184
|
+
for (const idToDelete of idsToDelete) {
|
|
185
|
+
await deleteComponent(componentUID, { id: idToDelete });
|
|
181
186
|
}
|
|
187
|
+
}
|
|
182
188
|
};
|
|
183
189
|
const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamiczoneValues) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (idsToDelete.length > 0) {
|
|
213
|
-
for (const idToDelete of idsToDelete) {
|
|
214
|
-
const { id, __component } = idToDelete;
|
|
215
|
-
await deleteComponent(__component, { id });
|
|
216
|
-
}
|
|
190
|
+
const previousValue = await strapi.query(uid).load(entityToUpdate, attributeName);
|
|
191
|
+
const idsToKeep = ___default.default.castArray(dynamiczoneValues).filter(_.has("id")).map((v) => ({
|
|
192
|
+
id: pickStringifiedId(v),
|
|
193
|
+
__component: v.__component
|
|
194
|
+
}));
|
|
195
|
+
const allIds = ___default.default.castArray(previousValue).filter(_.has("id")).map((v) => ({
|
|
196
|
+
id: pickStringifiedId(v),
|
|
197
|
+
__component: v.__component
|
|
198
|
+
}));
|
|
199
|
+
idsToKeep.forEach(({ id, __component }) => {
|
|
200
|
+
if (!allIds.find((el) => el.id === id && el.__component === __component)) {
|
|
201
|
+
const err = new Error(
|
|
202
|
+
`Some of the provided components in ${attributeName} are not related to the entity`
|
|
203
|
+
);
|
|
204
|
+
Object.assign(err, { status: 400 });
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const idsToDelete = allIds.reduce((acc, { id, __component }) => {
|
|
209
|
+
if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {
|
|
210
|
+
acc.push({ id, __component });
|
|
211
|
+
}
|
|
212
|
+
return acc;
|
|
213
|
+
}, []);
|
|
214
|
+
if (idsToDelete.length > 0) {
|
|
215
|
+
for (const idToDelete of idsToDelete) {
|
|
216
|
+
const { id, __component } = idToDelete;
|
|
217
|
+
await deleteComponent(__component, { id });
|
|
217
218
|
}
|
|
219
|
+
}
|
|
218
220
|
};
|
|
219
221
|
const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {}) => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
222
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
223
|
+
const attributeNames = Object.keys(attributes);
|
|
224
|
+
for (const attributeName of attributeNames) {
|
|
225
|
+
const attribute = attributes[attributeName];
|
|
226
|
+
if (attribute.type === "component" || attribute.type === "dynamiczone") {
|
|
227
|
+
let value;
|
|
228
|
+
if (loadComponents) {
|
|
229
|
+
value = await strapi.query(uid).load(entityToDelete, attributeName);
|
|
230
|
+
} else {
|
|
231
|
+
value = entityToDelete[attributeName];
|
|
232
|
+
}
|
|
233
|
+
if (!value) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (attribute.type === "component") {
|
|
237
|
+
const { component: componentUID } = attribute;
|
|
238
|
+
await strapiUtils.mapAsync(
|
|
239
|
+
___default.default.castArray(value),
|
|
240
|
+
(subValue) => deleteComponent(componentUID, subValue),
|
|
241
|
+
{
|
|
242
|
+
concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
} else {
|
|
246
|
+
await strapiUtils.mapAsync(
|
|
247
|
+
___default.default.castArray(value),
|
|
248
|
+
(subValue) => deleteComponent(subValue.__component, subValue),
|
|
249
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
continue;
|
|
249
253
|
}
|
|
254
|
+
}
|
|
250
255
|
};
|
|
251
|
-
exports.deleteComponents = deleteComponents;
|
|
252
256
|
const cloneComponents = async (uid, entityToClone, data) => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
258
|
+
const componentBody = {};
|
|
259
|
+
const componentData = await getComponents(uid, entityToClone);
|
|
260
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
261
|
+
const attribute = attributes[attributeName];
|
|
262
|
+
if (!_.has(attributeName, data) && !_.has(attributeName, componentData)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (attribute.type === "component") {
|
|
266
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
267
|
+
const componentValue = attributeName in data ? data[attributeName] : componentData[attributeName];
|
|
268
|
+
if (componentValue === null) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (repeatable === true) {
|
|
272
|
+
if (!Array.isArray(componentValue)) {
|
|
273
|
+
throw new Error("Expected an array to create repeatable component");
|
|
261
274
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
|
|
275
|
-
const components = (await (0, utils_1.mapAsync)(componentValue, (value) => cloneComponent(componentUID, value), { concurrency: isDialectMySQL() ? 1 : Infinity }));
|
|
276
|
-
componentBody[attributeName] = components.filter(lodash_1.default.negate(lodash_1.default.isNil)).map(({ id }) => {
|
|
277
|
-
return {
|
|
278
|
-
id,
|
|
279
|
-
__pivot: {
|
|
280
|
-
field: attributeName,
|
|
281
|
-
component_type: componentUID,
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
});
|
|
275
|
+
const components = await strapiUtils.mapAsync(
|
|
276
|
+
componentValue,
|
|
277
|
+
(value) => cloneComponent(componentUID, value),
|
|
278
|
+
{ concurrency: isDialectMySQL() ? 1 : Infinity }
|
|
279
|
+
);
|
|
280
|
+
componentBody[attributeName] = components.filter(___default.default.negate(___default.default.isNil)).map(({ id }) => {
|
|
281
|
+
return {
|
|
282
|
+
id,
|
|
283
|
+
__pivot: {
|
|
284
|
+
field: attributeName,
|
|
285
|
+
component_type: componentUID
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
const component = await cloneComponent(componentUID, componentValue);
|
|
291
|
+
componentBody[attributeName] = component && {
|
|
292
|
+
id: component.id,
|
|
293
|
+
__pivot: {
|
|
294
|
+
field: attributeName,
|
|
295
|
+
component_type: componentUID
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (attribute.type === "dynamiczone") {
|
|
302
|
+
const dynamiczoneValues = _.has(attributeName, data) ? data[attributeName] : componentData[attributeName];
|
|
303
|
+
if (!Array.isArray(dynamiczoneValues)) {
|
|
304
|
+
throw new Error("Expected an array to create repeatable component");
|
|
305
|
+
}
|
|
306
|
+
componentBody[attributeName] = await strapiUtils.mapAsync(
|
|
307
|
+
dynamiczoneValues,
|
|
308
|
+
async (value) => {
|
|
309
|
+
const { id } = await cloneComponent(value.__component, value);
|
|
310
|
+
return {
|
|
311
|
+
id,
|
|
312
|
+
__component: value.__component,
|
|
313
|
+
__pivot: {
|
|
314
|
+
field: attributeName
|
|
304
315
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
__component: value.__component,
|
|
311
|
-
__pivot: {
|
|
312
|
-
field: attributeName,
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
}, { concurrency: isDialectMySQL() ? 1 : Infinity });
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
316
|
+
};
|
|
317
|
+
},
|
|
318
|
+
{ concurrency: isDialectMySQL() ? 1 : Infinity }
|
|
319
|
+
);
|
|
320
|
+
continue;
|
|
318
321
|
}
|
|
319
|
-
|
|
322
|
+
}
|
|
323
|
+
return componentBody;
|
|
320
324
|
};
|
|
321
|
-
exports.cloneComponents = cloneComponents;
|
|
322
|
-
/** *************************
|
|
323
|
-
Component queries
|
|
324
|
-
************************** */
|
|
325
|
-
// components can have nested compos so this must be recursive
|
|
326
325
|
const createComponent = async (uid, data) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
const model = strapi.getModel(uid);
|
|
327
|
+
const componentData = await createComponents(uid, data);
|
|
328
|
+
const transform = _.pipe(
|
|
330
329
|
// Make sure we don't save the component with a pre-defined ID
|
|
331
|
-
|
|
330
|
+
_.omit("id"),
|
|
332
331
|
// Remove the component data from the original data object ...
|
|
333
|
-
(payload) => omitComponentData(model, payload),
|
|
332
|
+
(payload) => omitComponentData(model, payload),
|
|
334
333
|
// ... and assign the newly created component instead
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
_.assign(componentData)
|
|
335
|
+
);
|
|
336
|
+
return strapi.query(uid).create({ data: transform(data) });
|
|
337
337
|
};
|
|
338
|
-
// components can have nested compos so this must be recursive
|
|
339
338
|
const updateComponent = async (uid, componentToUpdate, data) => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
339
|
+
const model = strapi.getModel(uid);
|
|
340
|
+
const componentData = await updateComponents(uid, componentToUpdate, data);
|
|
341
|
+
return strapi.query(uid).update({
|
|
342
|
+
where: {
|
|
343
|
+
id: componentToUpdate.id
|
|
344
|
+
},
|
|
345
|
+
data: Object.assign(omitComponentData(model, data), componentData)
|
|
346
|
+
});
|
|
348
347
|
};
|
|
349
348
|
const updateOrCreateComponent = (componentUID, value) => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
// create
|
|
359
|
-
return createComponent(componentUID, value);
|
|
349
|
+
if (value === null) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
if ("id" in value && typeof value.id !== "undefined") {
|
|
353
|
+
return updateComponent(componentUID, { id: value.id }, value);
|
|
354
|
+
}
|
|
355
|
+
return createComponent(componentUID, value);
|
|
360
356
|
};
|
|
361
357
|
const deleteComponent = async (uid, componentToDelete) => {
|
|
362
|
-
|
|
363
|
-
|
|
358
|
+
await deleteComponents(uid, componentToDelete);
|
|
359
|
+
await strapi.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
364
360
|
};
|
|
365
|
-
exports.deleteComponent = deleteComponent;
|
|
366
361
|
const cloneComponent = async (uid, data) => {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
362
|
+
const model = strapi.getModel(uid);
|
|
363
|
+
if (!("id" in data) || typeof data.id === "undefined") {
|
|
364
|
+
return createComponent(uid, data);
|
|
365
|
+
}
|
|
366
|
+
const componentData = await cloneComponents(uid, { id: data.id }, data);
|
|
367
|
+
const transform = _.pipe(
|
|
373
368
|
// Make sure we don't save the component with a pre-defined ID
|
|
374
|
-
|
|
369
|
+
_.omit("id"),
|
|
375
370
|
// Remove the component data from the original data object ...
|
|
376
|
-
(payload) => omitComponentData(model, payload),
|
|
371
|
+
(payload) => omitComponentData(model, payload),
|
|
377
372
|
// ... and assign the newly created component instead
|
|
378
|
-
|
|
379
|
-
|
|
373
|
+
_.assign(componentData)
|
|
374
|
+
);
|
|
375
|
+
return strapi.query(uid).clone(data.id, { data: transform(data) });
|
|
380
376
|
};
|
|
381
|
-
|
|
377
|
+
exports.cloneComponents = cloneComponents;
|
|
378
|
+
exports.createComponents = createComponents;
|
|
379
|
+
exports.deleteComponent = deleteComponent;
|
|
380
|
+
exports.deleteComponents = deleteComponents;
|
|
381
|
+
exports.getComponents = getComponents;
|
|
382
|
+
exports.omitComponentData = omitComponentData;
|
|
383
|
+
exports.updateComponents = updateComponents;
|
|
384
|
+
//# sourceMappingURL=components.js.map
|