@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,311 +1,328 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return res;
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const delegate = require("delegates");
|
|
4
|
+
const database = require("@strapi/database");
|
|
5
|
+
const strapiUtils = require("@strapi/utils");
|
|
6
|
+
const uploadFiles = require("../utils/upload-files.js");
|
|
7
|
+
const components = require("./components.js");
|
|
8
|
+
const params = require("./params.js");
|
|
9
|
+
const index = require("./attributes/index.js");
|
|
10
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
|
+
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
12
|
+
const delegate__default = /* @__PURE__ */ _interopDefault(delegate);
|
|
13
|
+
const { transformParamsToQuery } = strapiUtils.convertQueryParams;
|
|
14
|
+
const transformLoadParamsToQuery = (uid, field, params2, pagination = {}) => {
|
|
15
|
+
const query = transformParamsToQuery(uid, { populate: { [field]: params2 } });
|
|
16
|
+
const res = {
|
|
17
|
+
...query.populate[field],
|
|
18
|
+
...pagination
|
|
19
|
+
};
|
|
20
|
+
return res;
|
|
22
21
|
};
|
|
23
22
|
const databaseErrorsToTransform = [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
database.errors.InvalidTimeError,
|
|
24
|
+
database.errors.InvalidDateTimeError,
|
|
25
|
+
database.errors.InvalidDateError,
|
|
26
|
+
database.errors.InvalidRelationError
|
|
28
27
|
];
|
|
29
28
|
const creationPipeline = (data, context) => {
|
|
30
|
-
|
|
29
|
+
return index.applyTransforms(data, context);
|
|
31
30
|
};
|
|
32
31
|
const updatePipeline = (data, context) => {
|
|
33
|
-
|
|
32
|
+
return index.applyTransforms(data, context);
|
|
34
33
|
};
|
|
35
34
|
const ALLOWED_WEBHOOK_EVENTS = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
ENTRY_CREATE: "entry.create",
|
|
36
|
+
ENTRY_UPDATE: "entry.update",
|
|
37
|
+
ENTRY_DELETE: "entry.delete"
|
|
39
38
|
};
|
|
40
|
-
const createDefaultImplementation = ({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findMany' });
|
|
67
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
68
|
-
if (kind === 'singleType') {
|
|
69
|
-
const entity = db.query(uid).findOne(query);
|
|
70
|
-
return this.wrapResult(entity, { uid, action: 'findOne' });
|
|
71
|
-
}
|
|
72
|
-
const entities = await db.query(uid).findMany(query);
|
|
73
|
-
return this.wrapResult(entities, { uid, action: 'findMany' });
|
|
74
|
-
},
|
|
75
|
-
async findPage(uid, opts) {
|
|
76
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findPage' });
|
|
77
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
78
|
-
const page = await db.query(uid).findPage(query);
|
|
79
|
-
return {
|
|
80
|
-
...page,
|
|
81
|
-
results: await this.wrapResult(page.results, { uid, action: 'findPage' }),
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
// TODO: streamline the logic based on the populate option
|
|
85
|
-
async findWithRelationCountsPage(uid, opts) {
|
|
86
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findWithRelationCounts' });
|
|
87
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
88
|
-
const entities = await db.query(uid).findPage(query);
|
|
89
|
-
return {
|
|
90
|
-
...entities,
|
|
91
|
-
results: await this.wrapResult(entities.results, { uid, action: 'findWithRelationCounts' }),
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
async findWithRelationCounts(uid, opts) {
|
|
95
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findWithRelationCounts' });
|
|
96
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
97
|
-
const entities = await db.query(uid).findMany(query);
|
|
98
|
-
return this.wrapResult(entities, { uid, action: 'findWithRelationCounts' });
|
|
99
|
-
},
|
|
100
|
-
async findOne(uid, entityId, opts) {
|
|
101
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findOne' });
|
|
102
|
-
const query = transformParamsToQuery(uid, (0, params_1.pickSelectionParams)(wrappedParams));
|
|
103
|
-
const entity = await db.query(uid).findOne({ ...query, where: { id: entityId } });
|
|
104
|
-
return this.wrapResult(entity, { uid, action: 'findOne' });
|
|
105
|
-
},
|
|
106
|
-
async count(uid, opts) {
|
|
107
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'count' });
|
|
108
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
109
|
-
return db.query(uid).count(query);
|
|
110
|
-
},
|
|
111
|
-
async create(uid, params) {
|
|
112
|
-
const wrappedParams = await this.wrapParams(params, { uid, action: 'create' });
|
|
113
|
-
const { data, files } = wrappedParams;
|
|
114
|
-
if (!data) {
|
|
115
|
-
throw new Error('cannot create');
|
|
116
|
-
}
|
|
117
|
-
const model = strapi.getModel(uid);
|
|
118
|
-
const isDraft = utils_1.contentTypes.isDraft(data, model);
|
|
119
|
-
const validData = await entityValidator.validateEntityCreation(model, data, { isDraft });
|
|
120
|
-
// select / populate
|
|
121
|
-
const query = transformParamsToQuery(uid, (0, params_1.pickSelectionParams)(wrappedParams));
|
|
122
|
-
// TODO: wrap into transaction
|
|
123
|
-
const componentData = await (0, components_1.createComponents)(uid, validData);
|
|
124
|
-
const entityData = creationPipeline(Object.assign((0, components_1.omitComponentData)(model, validData), componentData), {
|
|
125
|
-
contentType: model,
|
|
126
|
-
});
|
|
127
|
-
let entity = await db.query(uid).create({
|
|
128
|
-
...query,
|
|
129
|
-
data: entityData,
|
|
130
|
-
});
|
|
131
|
-
// TODO: do all of this in a transaction to avoid a race condition where entity is created then deleted before we do findOne again
|
|
132
|
-
// TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
|
|
133
|
-
if (files && Object.keys(files).length > 0) {
|
|
134
|
-
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
135
|
-
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
136
|
-
}
|
|
137
|
-
entity = await this.wrapResult(entity, { uid, action: 'create' });
|
|
138
|
-
const { ENTRY_CREATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
139
|
-
await this.emitEvent(uid, ENTRY_CREATE, entity);
|
|
140
|
-
return entity;
|
|
141
|
-
},
|
|
142
|
-
async update(uid, entityId, opts) {
|
|
143
|
-
const wrappedParams = await this.wrapParams(opts, {
|
|
144
|
-
uid,
|
|
145
|
-
action: 'update',
|
|
146
|
-
});
|
|
147
|
-
const { data, files } = wrappedParams;
|
|
148
|
-
const model = strapi.getModel(uid);
|
|
149
|
-
const entityToUpdate = await db.query(uid).findOne({ where: { id: entityId } });
|
|
150
|
-
if (!entityToUpdate) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
const isDraft = utils_1.contentTypes.isDraft(entityToUpdate, model);
|
|
154
|
-
const validData = await entityValidator.validateEntityUpdate(model, data, {
|
|
155
|
-
isDraft,
|
|
156
|
-
}, entityToUpdate);
|
|
157
|
-
const query = transformParamsToQuery(uid, (0, params_1.pickSelectionParams)(wrappedParams));
|
|
158
|
-
// TODO: wrap in transaction
|
|
159
|
-
const componentData = await (0, components_1.updateComponents)(uid, entityToUpdate, validData);
|
|
160
|
-
const entityData = updatePipeline(Object.assign((0, components_1.omitComponentData)(model, validData), componentData), { contentType: model });
|
|
161
|
-
let entity = await db.query(uid).update({
|
|
162
|
-
...query,
|
|
163
|
-
where: { id: entityId },
|
|
164
|
-
data: entityData,
|
|
165
|
-
});
|
|
166
|
-
// TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
|
|
167
|
-
if (files && Object.keys(files).length > 0) {
|
|
168
|
-
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
169
|
-
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
170
|
-
}
|
|
171
|
-
entity = await this.wrapResult(entity, { uid, action: 'update' });
|
|
172
|
-
const { ENTRY_UPDATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
173
|
-
await this.emitEvent(uid, ENTRY_UPDATE, entity);
|
|
174
|
-
return entity;
|
|
175
|
-
},
|
|
176
|
-
async delete(uid, entityId, opts) {
|
|
177
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'delete' });
|
|
178
|
-
// select / populate
|
|
179
|
-
const query = transformParamsToQuery(uid, (0, params_1.pickSelectionParams)(wrappedParams));
|
|
180
|
-
let entityToDelete = await db.query(uid).findOne({
|
|
181
|
-
...query,
|
|
182
|
-
where: { id: entityId },
|
|
183
|
-
});
|
|
184
|
-
if (!entityToDelete) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
const componentsToDelete = await (0, components_1.getComponents)(uid, entityToDelete);
|
|
188
|
-
await db.query(uid).delete({ where: { id: entityToDelete.id } });
|
|
189
|
-
await (0, components_1.deleteComponents)(uid, componentsToDelete, { loadComponents: false });
|
|
190
|
-
entityToDelete = await this.wrapResult(entityToDelete, { uid, action: 'delete' });
|
|
191
|
-
const { ENTRY_DELETE } = ALLOWED_WEBHOOK_EVENTS;
|
|
192
|
-
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
|
|
193
|
-
return entityToDelete;
|
|
194
|
-
},
|
|
195
|
-
async clone(uid, cloneId, opts) {
|
|
196
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'clone' });
|
|
197
|
-
const { data, files } = wrappedParams;
|
|
198
|
-
if (!data) {
|
|
199
|
-
throw new Error('cannot clone');
|
|
200
|
-
}
|
|
201
|
-
const model = strapi.getModel(uid);
|
|
202
|
-
const entityToClone = await db.query(uid).findOne({ where: { id: cloneId } });
|
|
203
|
-
if (!entityToClone) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
const isDraft = utils_1.contentTypes.isDraft(entityToClone, model);
|
|
207
|
-
const validData = await entityValidator.validateEntityUpdate(model,
|
|
208
|
-
// Omit the id, the cloned entity id will be generated by the database
|
|
209
|
-
lodash_1.default.omit(data, ['id']), { isDraft }, entityToClone);
|
|
210
|
-
const query = transformParamsToQuery(uid, (0, params_1.pickSelectionParams)(wrappedParams));
|
|
211
|
-
// TODO: wrap into transaction
|
|
212
|
-
const componentData = await (0, components_1.cloneComponents)(uid, entityToClone, validData);
|
|
213
|
-
const entityData = creationPipeline(Object.assign((0, components_1.omitComponentData)(model, validData), componentData), {
|
|
214
|
-
contentType: model,
|
|
215
|
-
});
|
|
216
|
-
let entity = await db.query(uid).clone(cloneId, {
|
|
217
|
-
...query,
|
|
218
|
-
data: entityData,
|
|
219
|
-
});
|
|
220
|
-
// TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
|
|
221
|
-
if (files && Object.keys(files).length > 0) {
|
|
222
|
-
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
223
|
-
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
224
|
-
}
|
|
225
|
-
const { ENTRY_CREATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
226
|
-
await this.emitEvent(uid, ENTRY_CREATE, entity);
|
|
227
|
-
return entity;
|
|
228
|
-
},
|
|
229
|
-
// FIXME: used only for the CM to be removed
|
|
230
|
-
async deleteMany(uid, opts) {
|
|
231
|
-
const wrappedParams = await this.wrapParams(opts, { uid, action: 'delete' });
|
|
232
|
-
// select / populate
|
|
233
|
-
const query = transformParamsToQuery(uid, wrappedParams);
|
|
234
|
-
let entitiesToDelete = await db.query(uid).findMany(query);
|
|
235
|
-
if (!entitiesToDelete.length) {
|
|
236
|
-
return { count: 0 };
|
|
237
|
-
}
|
|
238
|
-
const componentsToDelete = await Promise.all(entitiesToDelete.map((entityToDelete) => (0, components_1.getComponents)(uid, entityToDelete)));
|
|
239
|
-
const deletedEntities = await db.query(uid).deleteMany(query);
|
|
240
|
-
await Promise.all(componentsToDelete.map((compos) => (0, components_1.deleteComponents)(uid, compos, { loadComponents: false })));
|
|
241
|
-
entitiesToDelete = await this.wrapResult(entitiesToDelete, { uid, action: 'delete' });
|
|
242
|
-
// Trigger webhooks. One for each entity
|
|
243
|
-
const { ENTRY_DELETE } = ALLOWED_WEBHOOK_EVENTS;
|
|
244
|
-
await Promise.all(entitiesToDelete.map((entity) => this.emitEvent(uid, ENTRY_DELETE, entity)));
|
|
245
|
-
return deletedEntities;
|
|
246
|
-
},
|
|
247
|
-
async load(uid, entity, field, params) {
|
|
248
|
-
if (!lodash_1.default.isString(field)) {
|
|
249
|
-
throw new Error(`Invalid load. Expected "${field}" to be a string`);
|
|
250
|
-
}
|
|
251
|
-
const loadedEntity = await db
|
|
252
|
-
.query(uid)
|
|
253
|
-
.load(entity, field, transformLoadParamsToQuery(uid, field, params ?? {}));
|
|
254
|
-
return this.wrapResult(loadedEntity, { uid, field, action: 'load' });
|
|
255
|
-
},
|
|
256
|
-
async loadPages(uid, entity, field, params, pagination = {}) {
|
|
257
|
-
if (!lodash_1.default.isString(field)) {
|
|
258
|
-
throw new Error(`Invalid load. Expected "${field}" to be a string`);
|
|
259
|
-
}
|
|
260
|
-
const { attributes } = strapi.getModel(uid);
|
|
261
|
-
const attribute = attributes[field];
|
|
262
|
-
if (!utils_1.relations.isAnyToMany(attribute)) {
|
|
263
|
-
throw new Error(`Invalid load. Expected "${field}" to be an anyToMany relational attribute`);
|
|
264
|
-
}
|
|
265
|
-
const query = transformLoadParamsToQuery(uid, field, params ?? {}, pagination);
|
|
266
|
-
const loadedPage = await db.query(uid).loadPages(entity, field, query);
|
|
267
|
-
return {
|
|
268
|
-
...loadedPage,
|
|
269
|
-
results: await this.wrapResult(loadedPage.results, { uid, field, action: 'load' }),
|
|
270
|
-
};
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
exports.default = (ctx) => {
|
|
274
|
-
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
|
275
|
-
ctx.strapi.webhookStore?.addAllowedEvent(key, value);
|
|
39
|
+
const createDefaultImplementation = ({
|
|
40
|
+
strapi,
|
|
41
|
+
db,
|
|
42
|
+
eventHub,
|
|
43
|
+
entityValidator
|
|
44
|
+
}) => ({
|
|
45
|
+
/**
|
|
46
|
+
* Upload files utility
|
|
47
|
+
*/
|
|
48
|
+
uploadFiles,
|
|
49
|
+
async wrapParams(options = {}) {
|
|
50
|
+
return options;
|
|
51
|
+
},
|
|
52
|
+
async wrapResult(result = {}) {
|
|
53
|
+
return result;
|
|
54
|
+
},
|
|
55
|
+
async emitEvent(uid, event, entity) {
|
|
56
|
+
if (uid === "admin::audit-log") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const model = strapi.getModel(uid);
|
|
60
|
+
const sanitizedEntity = await strapiUtils.sanitize.sanitizers.defaultSanitizeOutput(model, entity);
|
|
61
|
+
eventHub.emit(event, {
|
|
62
|
+
model: model.modelName,
|
|
63
|
+
uid: model.uid,
|
|
64
|
+
entry: sanitizedEntity
|
|
276
65
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
66
|
+
},
|
|
67
|
+
async findMany(uid, opts) {
|
|
68
|
+
const { kind } = strapi.getModel(uid);
|
|
69
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "findMany" });
|
|
70
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
71
|
+
if (kind === "singleType") {
|
|
72
|
+
const entity = db.query(uid).findOne(query);
|
|
73
|
+
return this.wrapResult(entity, { uid, action: "findOne" });
|
|
74
|
+
}
|
|
75
|
+
const entities = await db.query(uid).findMany(query);
|
|
76
|
+
return this.wrapResult(entities, { uid, action: "findMany" });
|
|
77
|
+
},
|
|
78
|
+
async findPage(uid, opts) {
|
|
79
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "findPage" });
|
|
80
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
81
|
+
const page = await db.query(uid).findPage(query);
|
|
82
|
+
return {
|
|
83
|
+
...page,
|
|
84
|
+
results: await this.wrapResult(page.results, { uid, action: "findPage" })
|
|
287
85
|
};
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
86
|
+
},
|
|
87
|
+
// TODO: streamline the logic based on the populate option
|
|
88
|
+
async findWithRelationCountsPage(uid, opts) {
|
|
89
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "findWithRelationCounts" });
|
|
90
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
91
|
+
const entities = await db.query(uid).findPage(query);
|
|
92
|
+
return {
|
|
93
|
+
...entities,
|
|
94
|
+
results: await this.wrapResult(entities.results, { uid, action: "findWithRelationCounts" })
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
async findWithRelationCounts(uid, opts) {
|
|
98
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "findWithRelationCounts" });
|
|
99
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
100
|
+
const entities = await db.query(uid).findMany(query);
|
|
101
|
+
return this.wrapResult(entities, { uid, action: "findWithRelationCounts" });
|
|
102
|
+
},
|
|
103
|
+
async findOne(uid, entityId, opts) {
|
|
104
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "findOne" });
|
|
105
|
+
const query = transformParamsToQuery(uid, params.pickSelectionParams(wrappedParams));
|
|
106
|
+
const entity = await db.query(uid).findOne({ ...query, where: { id: entityId } });
|
|
107
|
+
return this.wrapResult(entity, { uid, action: "findOne" });
|
|
108
|
+
},
|
|
109
|
+
async count(uid, opts) {
|
|
110
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "count" });
|
|
111
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
112
|
+
return db.query(uid).count(query);
|
|
113
|
+
},
|
|
114
|
+
async create(uid, params$1) {
|
|
115
|
+
const wrappedParams = await this.wrapParams(params$1, { uid, action: "create" });
|
|
116
|
+
const { data, files } = wrappedParams;
|
|
117
|
+
if (!data) {
|
|
118
|
+
throw new Error("cannot create");
|
|
119
|
+
}
|
|
120
|
+
const model = strapi.getModel(uid);
|
|
121
|
+
const isDraft = strapiUtils.contentTypes.isDraft(data, model);
|
|
122
|
+
const validData = await entityValidator.validateEntityCreation(model, data, { isDraft });
|
|
123
|
+
const query = transformParamsToQuery(uid, params.pickSelectionParams(wrappedParams));
|
|
124
|
+
const componentData = await components.createComponents(uid, validData);
|
|
125
|
+
const entityData = creationPipeline(
|
|
126
|
+
Object.assign(components.omitComponentData(model, validData), componentData),
|
|
127
|
+
{
|
|
128
|
+
contentType: model
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
let entity = await db.query(uid).create({
|
|
132
|
+
...query,
|
|
133
|
+
data: entityData
|
|
134
|
+
});
|
|
135
|
+
if (files && Object.keys(files).length > 0) {
|
|
136
|
+
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
137
|
+
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
138
|
+
}
|
|
139
|
+
entity = await this.wrapResult(entity, { uid, action: "create" });
|
|
140
|
+
const { ENTRY_CREATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
141
|
+
await this.emitEvent(uid, ENTRY_CREATE, entity);
|
|
142
|
+
return entity;
|
|
143
|
+
},
|
|
144
|
+
async update(uid, entityId, opts) {
|
|
145
|
+
const wrappedParams = await this.wrapParams(opts, {
|
|
146
|
+
uid,
|
|
147
|
+
action: "update"
|
|
308
148
|
});
|
|
309
|
-
|
|
149
|
+
const { data, files } = wrappedParams;
|
|
150
|
+
const model = strapi.getModel(uid);
|
|
151
|
+
const entityToUpdate = await db.query(uid).findOne({ where: { id: entityId } });
|
|
152
|
+
if (!entityToUpdate) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const isDraft = strapiUtils.contentTypes.isDraft(entityToUpdate, model);
|
|
156
|
+
const validData = await entityValidator.validateEntityUpdate(
|
|
157
|
+
model,
|
|
158
|
+
data,
|
|
159
|
+
{
|
|
160
|
+
isDraft
|
|
161
|
+
},
|
|
162
|
+
entityToUpdate
|
|
163
|
+
);
|
|
164
|
+
const query = transformParamsToQuery(uid, params.pickSelectionParams(wrappedParams));
|
|
165
|
+
const componentData = await components.updateComponents(uid, entityToUpdate, validData);
|
|
166
|
+
const entityData = updatePipeline(
|
|
167
|
+
Object.assign(components.omitComponentData(model, validData), componentData),
|
|
168
|
+
{ contentType: model }
|
|
169
|
+
);
|
|
170
|
+
let entity = await db.query(uid).update({
|
|
171
|
+
...query,
|
|
172
|
+
where: { id: entityId },
|
|
173
|
+
data: entityData
|
|
174
|
+
});
|
|
175
|
+
if (files && Object.keys(files).length > 0) {
|
|
176
|
+
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
177
|
+
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
178
|
+
}
|
|
179
|
+
entity = await this.wrapResult(entity, { uid, action: "update" });
|
|
180
|
+
const { ENTRY_UPDATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
181
|
+
await this.emitEvent(uid, ENTRY_UPDATE, entity);
|
|
182
|
+
return entity;
|
|
183
|
+
},
|
|
184
|
+
async delete(uid, entityId, opts) {
|
|
185
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "delete" });
|
|
186
|
+
const query = transformParamsToQuery(uid, params.pickSelectionParams(wrappedParams));
|
|
187
|
+
let entityToDelete = await db.query(uid).findOne({
|
|
188
|
+
...query,
|
|
189
|
+
where: { id: entityId }
|
|
190
|
+
});
|
|
191
|
+
if (!entityToDelete) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const componentsToDelete = await components.getComponents(uid, entityToDelete);
|
|
195
|
+
await db.query(uid).delete({ where: { id: entityToDelete.id } });
|
|
196
|
+
await components.deleteComponents(uid, componentsToDelete, { loadComponents: false });
|
|
197
|
+
entityToDelete = await this.wrapResult(entityToDelete, { uid, action: "delete" });
|
|
198
|
+
const { ENTRY_DELETE } = ALLOWED_WEBHOOK_EVENTS;
|
|
199
|
+
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
|
|
200
|
+
return entityToDelete;
|
|
201
|
+
},
|
|
202
|
+
async clone(uid, cloneId, opts) {
|
|
203
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "clone" });
|
|
204
|
+
const { data, files } = wrappedParams;
|
|
205
|
+
if (!data) {
|
|
206
|
+
throw new Error("cannot clone");
|
|
207
|
+
}
|
|
208
|
+
const model = strapi.getModel(uid);
|
|
209
|
+
const entityToClone = await db.query(uid).findOne({ where: { id: cloneId } });
|
|
210
|
+
if (!entityToClone) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const isDraft = strapiUtils.contentTypes.isDraft(entityToClone, model);
|
|
214
|
+
const validData = await entityValidator.validateEntityUpdate(
|
|
215
|
+
model,
|
|
216
|
+
// Omit the id, the cloned entity id will be generated by the database
|
|
217
|
+
___default.default.omit(data, ["id"]),
|
|
218
|
+
{ isDraft },
|
|
219
|
+
entityToClone
|
|
220
|
+
);
|
|
221
|
+
const query = transformParamsToQuery(uid, params.pickSelectionParams(wrappedParams));
|
|
222
|
+
const componentData = await components.cloneComponents(uid, entityToClone, validData);
|
|
223
|
+
const entityData = creationPipeline(
|
|
224
|
+
Object.assign(components.omitComponentData(model, validData), componentData),
|
|
225
|
+
{
|
|
226
|
+
contentType: model
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
let entity = await db.query(uid).clone(cloneId, {
|
|
230
|
+
...query,
|
|
231
|
+
data: entityData
|
|
232
|
+
});
|
|
233
|
+
if (files && Object.keys(files).length > 0) {
|
|
234
|
+
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
235
|
+
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
236
|
+
}
|
|
237
|
+
const { ENTRY_CREATE } = ALLOWED_WEBHOOK_EVENTS;
|
|
238
|
+
await this.emitEvent(uid, ENTRY_CREATE, entity);
|
|
239
|
+
return entity;
|
|
240
|
+
},
|
|
241
|
+
// FIXME: used only for the CM to be removed
|
|
242
|
+
async deleteMany(uid, opts) {
|
|
243
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: "delete" });
|
|
244
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
245
|
+
let entitiesToDelete = await db.query(uid).findMany(query);
|
|
246
|
+
if (!entitiesToDelete.length) {
|
|
247
|
+
return { count: 0 };
|
|
248
|
+
}
|
|
249
|
+
const componentsToDelete = await Promise.all(
|
|
250
|
+
entitiesToDelete.map((entityToDelete) => components.getComponents(uid, entityToDelete))
|
|
251
|
+
);
|
|
252
|
+
const deletedEntities = await db.query(uid).deleteMany(query);
|
|
253
|
+
await Promise.all(
|
|
254
|
+
componentsToDelete.map(
|
|
255
|
+
(compos) => components.deleteComponents(uid, compos, { loadComponents: false })
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
entitiesToDelete = await this.wrapResult(entitiesToDelete, { uid, action: "delete" });
|
|
259
|
+
const { ENTRY_DELETE } = ALLOWED_WEBHOOK_EVENTS;
|
|
260
|
+
await Promise.all(entitiesToDelete.map((entity) => this.emitEvent(uid, ENTRY_DELETE, entity)));
|
|
261
|
+
return deletedEntities;
|
|
262
|
+
},
|
|
263
|
+
async load(uid, entity, field, params2) {
|
|
264
|
+
if (!___default.default.isString(field)) {
|
|
265
|
+
throw new Error(`Invalid load. Expected "${field}" to be a string`);
|
|
266
|
+
}
|
|
267
|
+
const loadedEntity = await db.query(uid).load(entity, field, transformLoadParamsToQuery(uid, field, params2 ?? {}));
|
|
268
|
+
return this.wrapResult(loadedEntity, { uid, field, action: "load" });
|
|
269
|
+
},
|
|
270
|
+
async loadPages(uid, entity, field, params2, pagination = {}) {
|
|
271
|
+
if (!___default.default.isString(field)) {
|
|
272
|
+
throw new Error(`Invalid load. Expected "${field}" to be a string`);
|
|
273
|
+
}
|
|
274
|
+
const { attributes } = strapi.getModel(uid);
|
|
275
|
+
const attribute = attributes[field];
|
|
276
|
+
if (!strapiUtils.relations.isAnyToMany(attribute)) {
|
|
277
|
+
throw new Error(`Invalid load. Expected "${field}" to be an anyToMany relational attribute`);
|
|
278
|
+
}
|
|
279
|
+
const query = transformLoadParamsToQuery(uid, field, params2 ?? {}, pagination);
|
|
280
|
+
const loadedPage = await db.query(uid).loadPages(entity, field, query);
|
|
281
|
+
return {
|
|
282
|
+
...loadedPage,
|
|
283
|
+
results: await this.wrapResult(loadedPage.results, { uid, field, action: "load" })
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const createEntityService = (ctx) => {
|
|
288
|
+
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
|
289
|
+
ctx.strapi.webhookStore?.addAllowedEvent(key, value);
|
|
290
|
+
});
|
|
291
|
+
const implementation = createDefaultImplementation(ctx);
|
|
292
|
+
const service = {
|
|
293
|
+
implementation,
|
|
294
|
+
decorate(decorator) {
|
|
295
|
+
if (typeof decorator !== "function") {
|
|
296
|
+
throw new Error(`Decorator must be a function, received ${typeof decorator}`);
|
|
297
|
+
}
|
|
298
|
+
this.implementation = { ...this.implementation, ...decorator(this.implementation) };
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const delegator = delegate__default.default(service, "implementation");
|
|
303
|
+
Object.keys(service.implementation).forEach((key) => delegator.method(key));
|
|
304
|
+
service.decorate((oldService) => {
|
|
305
|
+
const newService = ___default.default.mapValues(
|
|
306
|
+
oldService,
|
|
307
|
+
(method, methodName) => async function(...args) {
|
|
308
|
+
try {
|
|
309
|
+
return await oldService[methodName].call(this, ...args);
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (databaseErrorsToTransform.some(
|
|
312
|
+
(errorToTransform) => error instanceof errorToTransform
|
|
313
|
+
)) {
|
|
314
|
+
if (error instanceof Error) {
|
|
315
|
+
throw new strapiUtils.errors.ValidationError(error.message);
|
|
316
|
+
}
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
return newService;
|
|
324
|
+
});
|
|
325
|
+
return service;
|
|
310
326
|
};
|
|
311
|
-
|
|
327
|
+
module.exports = createEntityService;
|
|
328
|
+
//# sourceMappingURL=index.js.map
|