@strapi/core 0.0.0-experimental.8294852592c0a1fb061c5d3576327fa0e80bab5b → 0.0.0-experimental.94632b9dc1ff6c9600db6db51cd6dd2d693f5204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts +5 -3
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +19 -7
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +19 -7
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +4 -4
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +1 -1
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/configuration/urls.d.ts +8 -0
- package/dist/configuration/urls.d.ts.map +1 -0
- package/dist/configuration/urls.js +68 -0
- package/dist/configuration/urls.js.map +1 -0
- package/dist/configuration/urls.mjs +66 -0
- package/dist/configuration/urls.mjs.map +1 -0
- package/dist/core-api/controller/index.d.ts.map +1 -1
- package/dist/core-api/controller/index.js +6 -1
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs +6 -1
- package/dist/core-api/controller/index.mjs.map +1 -1
- package/dist/core-api/controller/transform.d.ts +8 -7
- package/dist/core-api/controller/transform.d.ts.map +1 -1
- package/dist/core-api/controller/transform.js +18 -9
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs +18 -9
- package/dist/core-api/controller/transform.mjs.map +1 -1
- package/dist/core-api/service/single-type.d.ts +1 -1
- package/dist/core-api/service/single-type.d.ts.map +1 -1
- package/dist/core-api/service/single-type.js +3 -4
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs +3 -4
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +3 -0
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +3 -0
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/domain/content-type/validator.d.ts.map +1 -1
- package/dist/domain/content-type/validator.js +1 -1
- package/dist/domain/content-type/validator.js.map +1 -1
- package/dist/domain/content-type/validator.mjs +2 -2
- package/dist/domain/content-type/validator.mjs.map +1 -1
- package/dist/domain/module/index.d.ts.map +1 -1
- package/dist/domain/module/index.js +2 -3
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs +2 -3
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs.map +1 -1
- package/dist/loaders/apis.js +1 -1
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs +2 -2
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs +2 -2
- package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +2 -2
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +2 -2
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/migrations/draft-publish.d.ts +17 -0
- package/dist/migrations/draft-publish.d.ts.map +1 -0
- package/dist/migrations/draft-publish.js +59 -0
- package/dist/migrations/draft-publish.js.map +1 -0
- package/dist/migrations/draft-publish.mjs +59 -0
- package/dist/migrations/draft-publish.mjs.map +1 -0
- package/dist/registries/config.d.ts +2 -2
- package/dist/registries/config.d.ts.map +1 -1
- package/dist/registries/config.js +14 -6
- package/dist/registries/config.js.map +1 -1
- package/dist/registries/config.mjs +15 -5
- package/dist/registries/config.mjs.map +1 -1
- package/dist/services/document-service/common.d.ts +2 -2
- package/dist/services/document-service/common.d.ts.map +1 -1
- package/dist/services/document-service/common.js.map +1 -1
- package/dist/services/document-service/common.mjs.map +1 -1
- package/dist/services/document-service/draft-and-publish.d.ts +9 -23
- package/dist/services/document-service/draft-and-publish.d.ts.map +1 -1
- package/dist/services/document-service/draft-and-publish.js +37 -9
- package/dist/services/document-service/draft-and-publish.js.map +1 -1
- package/dist/services/document-service/draft-and-publish.mjs +38 -10
- package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
- package/dist/services/document-service/index.d.ts.map +1 -1
- package/dist/services/document-service/index.js +10 -8
- package/dist/services/document-service/index.js.map +1 -1
- package/dist/services/document-service/index.mjs +4 -2
- package/dist/services/document-service/index.mjs.map +1 -1
- package/dist/services/document-service/middlewares/errors.d.ts +6 -0
- package/dist/services/document-service/middlewares/errors.d.ts.map +1 -0
- package/dist/services/document-service/middlewares/errors.js +25 -0
- package/dist/services/document-service/middlewares/errors.js.map +1 -0
- package/dist/services/document-service/middlewares/errors.mjs +25 -0
- package/dist/services/document-service/middlewares/errors.mjs.map +1 -0
- package/dist/services/document-service/middlewares/index.d.ts +3 -0
- package/dist/services/document-service/middlewares/index.d.ts.map +1 -0
- package/dist/services/document-service/{middlewares.d.ts → middlewares/middleware-manager.d.ts} +3 -4
- package/dist/services/document-service/middlewares/middleware-manager.d.ts.map +1 -0
- package/dist/services/document-service/{middlewares.js → middlewares/middleware-manager.js} +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -0
- package/dist/services/document-service/{middlewares.mjs → middlewares/middleware-manager.mjs} +1 -1
- package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -0
- package/dist/services/document-service/repository.d.ts +3 -0
- package/dist/services/document-service/repository.d.ts.map +1 -0
- package/dist/services/document-service/repository.js +295 -0
- package/dist/services/document-service/repository.js.map +1 -0
- package/dist/services/document-service/repository.mjs +295 -0
- package/dist/services/document-service/repository.mjs.map +1 -0
- package/dist/services/document-service/transform/id-map.d.ts +1 -1
- package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
- package/dist/services/document-service/transform/id-map.js +15 -9
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs +16 -10
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/id-transform.d.ts +4 -18
- package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
- package/dist/services/document-service/transform/id-transform.js +18 -12
- package/dist/services/document-service/transform/id-transform.js.map +1 -1
- package/dist/services/document-service/transform/id-transform.mjs +18 -12
- package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
- package/dist/services/document-service/transform/populate.d.ts +5 -2
- package/dist/services/document-service/transform/populate.d.ts.map +1 -1
- package/dist/services/document-service/transform/populate.js.map +1 -1
- package/dist/services/document-service/transform/populate.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js +23 -12
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs +23 -12
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +61 -37
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +62 -38
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.d.ts +10 -0
- package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.js +25 -0
- package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -0
- package/dist/services/document-service/transform/relations/utils/dp.mjs +25 -0
- package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -0
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts +2 -2
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.js +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.mjs +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/types.d.ts +4 -1
- package/dist/services/document-service/transform/relations/utils/types.d.ts.map +1 -1
- package/dist/services/document-service/transform/types.d.ts +1 -1
- package/dist/services/document-service/transform/types.d.ts.map +1 -1
- package/dist/services/document-service/utils/populate.d.ts +8 -1
- package/dist/services/document-service/utils/populate.d.ts.map +1 -1
- package/dist/services/document-service/utils/populate.js +5 -5
- package/dist/services/document-service/utils/populate.js.map +1 -1
- package/dist/services/document-service/utils/populate.mjs +5 -5
- package/dist/services/document-service/utils/populate.mjs.map +1 -1
- package/dist/services/entity-service/components.d.ts +1 -4
- package/dist/services/entity-service/components.d.ts.map +1 -1
- package/dist/services/entity-service/components.js +13 -99
- package/dist/services/entity-service/components.js.map +1 -1
- package/dist/services/entity-service/components.mjs +14 -100
- package/dist/services/entity-service/components.mjs.map +1 -1
- package/dist/services/entity-service/index.d.ts +1 -3
- package/dist/services/entity-service/index.d.ts.map +1 -1
- package/dist/services/entity-service/index.js +34 -199
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs +27 -192
- package/dist/services/entity-service/index.mjs.map +1 -1
- package/dist/services/entity-service/params.d.ts +4 -4
- package/dist/services/entity-service/params.d.ts.map +1 -1
- package/dist/services/entity-service/params.js +1 -1
- package/dist/services/entity-service/params.js.map +1 -1
- package/dist/services/entity-service/params.mjs +1 -1
- package/dist/services/entity-service/params.mjs.map +1 -1
- package/dist/services/entity-validator/index.js +1 -1
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +1 -1
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/utils/is-initialized.js +1 -1
- package/dist/utils/is-initialized.js.map +1 -1
- package/dist/utils/is-initialized.mjs +1 -1
- package/dist/utils/is-initialized.mjs.map +1 -1
- package/dist/utils/load-config-file.js +1 -1
- package/dist/utils/load-config-file.js.map +1 -1
- package/dist/utils/load-config-file.mjs +2 -2
- package/dist/utils/load-config-file.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/services/document-service/document-engine.d.ts +0 -8
- package/dist/services/document-service/document-engine.d.ts.map +0 -1
- package/dist/services/document-service/document-engine.js +0 -241
- package/dist/services/document-service/document-engine.js.map +0 -1
- package/dist/services/document-service/document-engine.mjs +0 -242
- package/dist/services/document-service/document-engine.mjs.map +0 -1
- package/dist/services/document-service/middlewares.d.ts.map +0 -1
- package/dist/services/document-service/middlewares.js.map +0 -1
- package/dist/services/document-service/middlewares.mjs.map +0 -1
- package/dist/services/document-service/repositories/content-type.d.ts +0 -3
- package/dist/services/document-service/repositories/content-type.d.ts.map +0 -1
- package/dist/services/document-service/repositories/content-type.js +0 -139
- package/dist/services/document-service/repositories/content-type.js.map +0 -1
- package/dist/services/document-service/repositories/content-type.mjs +0 -139
- package/dist/services/document-service/repositories/content-type.mjs.map +0 -1
- package/dist/services/document-service/transform/filters.d.ts +0 -3
- package/dist/services/document-service/transform/filters.d.ts.map +0 -1
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts +0 -4
- package/dist/services/document-service/transform/relations/transform/output-ids.d.ts.map +0 -1
- package/dist/services/document-service/transform/sort.d.ts +0 -5
- package/dist/services/document-service/transform/sort.d.ts.map +0 -1
- package/dist/services/document-service/transform/utils.d.ts +0 -9
- package/dist/services/document-service/transform/utils.d.ts.map +0 -1
- package/dist/services/utils/upload-files.d.ts +0 -8
- package/dist/services/utils/upload-files.d.ts.map +0 -1
- package/dist/services/utils/upload-files.js +0 -64
- package/dist/services/utils/upload-files.js.map +0 -1
- package/dist/services/utils/upload-files.mjs +0 -63
- package/dist/services/utils/upload-files.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAE3B,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,EAAE,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAE3B,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAEzD,MAAM,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/transform/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/transform/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Common } from '@strapi/types';
|
|
2
|
-
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* Fields to select when populating relations
|
|
5
|
+
*/
|
|
6
|
+
relationalFields?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const getDeepPopulate: (uid: Common.UID.Schema, opts?: Options) => any;
|
|
9
|
+
export {};
|
|
3
10
|
//# sourceMappingURL=populate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/populate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"populate.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/utils/populate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,UAAU,OAAO;IACf;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAGD,eAAO,MAAM,eAAe,QAAS,OAAO,GAAG,CAAC,MAAM,SAAQ,OAAO,QA8CpE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const strapiUtils = require("@strapi/utils");
|
|
4
|
-
const getDeepPopulate = (uid) => {
|
|
4
|
+
const getDeepPopulate = (uid, opts = {}) => {
|
|
5
5
|
const model = strapi.getModel(uid);
|
|
6
6
|
const attributes = Object.entries(model.attributes);
|
|
7
7
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
|
@@ -9,23 +9,23 @@ const getDeepPopulate = (uid) => {
|
|
|
9
9
|
case "relation": {
|
|
10
10
|
const isVisible = strapiUtils.contentTypes.isVisibleAttribute(model, attributeName);
|
|
11
11
|
if (isVisible) {
|
|
12
|
-
acc[attributeName] = {
|
|
12
|
+
acc[attributeName] = { select: opts.relationalFields };
|
|
13
13
|
}
|
|
14
14
|
break;
|
|
15
15
|
}
|
|
16
16
|
case "media": {
|
|
17
|
-
acc[attributeName] = {
|
|
17
|
+
acc[attributeName] = { select: ["id"] };
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
20
20
|
case "component": {
|
|
21
|
-
const populate = getDeepPopulate(attribute.component);
|
|
21
|
+
const populate = getDeepPopulate(attribute.component, opts);
|
|
22
22
|
acc[attributeName] = { populate };
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "dynamiczone": {
|
|
26
26
|
const populatedComponents = (attribute.components || []).reduce(
|
|
27
27
|
(acc2, componentUID) => {
|
|
28
|
-
acc2[componentUID] = { populate: getDeepPopulate(componentUID) };
|
|
28
|
+
acc2[componentUID] = { populate: getDeepPopulate(componentUID, opts) };
|
|
29
29
|
return acc2;
|
|
30
30
|
},
|
|
31
31
|
{}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n const attributes = Object.entries(model.attributes);\n\n return attributes.reduce((acc: any, [attributeName, attribute]) => {\n switch (attribute.type) {\n case 'relation': {\n // TODO: Should this just be a plain list?\n // Ignore createdBy, updatedBy, ...\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n if (isVisible) {\n acc[attributeName] = {
|
|
1
|
+
{"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\ninterface Options {\n /**\n * Fields to select when populating relations\n */\n relationalFields?: string[];\n}\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: Common.UID.Schema, opts: Options = {}) => {\n const model = strapi.getModel(uid);\n const attributes = Object.entries(model.attributes);\n\n return attributes.reduce((acc: any, [attributeName, attribute]) => {\n switch (attribute.type) {\n case 'relation': {\n // TODO: Should this just be a plain list?\n // Ignore createdBy, updatedBy, ...\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n if (isVisible) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n break;\n }\n\n case 'media': {\n acc[attributeName] = { select: ['id'] };\n break;\n }\n\n case 'component': {\n const populate = getDeepPopulate(attribute.component, opts);\n acc[attributeName] = { populate };\n break;\n }\n\n case 'dynamiczone': {\n // Use fragments to populate the dynamic zone components\n const populatedComponents = (attribute.components || []).reduce(\n (acc: any, componentUID: Common.UID.Component) => {\n acc[componentUID] = { populate: getDeepPopulate(componentUID, opts) };\n return acc;\n },\n {}\n );\n\n acc[attributeName] = { on: populatedComponents };\n break;\n }\n default:\n break;\n }\n\n return acc;\n }, {});\n};\n"],"names":["contentTypes","acc"],"mappings":";;;AAWO,MAAM,kBAAkB,CAAC,KAAwB,OAAgB,OAAO;AACvE,QAAA,QAAQ,OAAO,SAAS,GAAG;AACjC,QAAM,aAAa,OAAO,QAAQ,MAAM,UAAU;AAElD,SAAO,WAAW,OAAO,CAAC,KAAU,CAAC,eAAe,SAAS,MAAM;AACjE,YAAQ,UAAU,MAAM;AAAA,MACtB,KAAK,YAAY;AAGf,cAAM,YAAYA,YAAA,aAAa,mBAAmB,OAAO,aAAa;AACtE,YAAI,WAAW;AACb,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QACvD;AACA;AAAA,MACF;AAAA,MAEA,KAAK,SAAS;AACZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;AACtC;AAAA,MACF;AAAA,MAEA,KAAK,aAAa;AAChB,cAAM,WAAW,gBAAgB,UAAU,WAAW,IAAI;AACtD,YAAA,aAAa,IAAI,EAAE;AACvB;AAAA,MACF;AAAA,MAEA,KAAK,eAAe;AAElB,cAAM,uBAAuB,UAAU,cAAc,CAAI,GAAA;AAAA,UACvD,CAACC,MAAU,iBAAuC;AAChDA,iBAAI,YAAY,IAAI,EAAE,UAAU,gBAAgB,cAAc,IAAI;AAC3DA,mBAAAA;AAAAA,UACT;AAAA,UACA,CAAC;AAAA,QAAA;AAGH,YAAI,aAAa,IAAI,EAAE,IAAI,oBAAoB;AAC/C;AAAA,MACF;AAAA,IAGF;AAEO,WAAA;AAAA,EACT,GAAG,CAAE,CAAA;AACP;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { contentTypes } from "@strapi/utils";
|
|
2
|
-
const getDeepPopulate = (uid) => {
|
|
2
|
+
const getDeepPopulate = (uid, opts = {}) => {
|
|
3
3
|
const model = strapi.getModel(uid);
|
|
4
4
|
const attributes = Object.entries(model.attributes);
|
|
5
5
|
return attributes.reduce((acc, [attributeName, attribute]) => {
|
|
@@ -7,23 +7,23 @@ const getDeepPopulate = (uid) => {
|
|
|
7
7
|
case "relation": {
|
|
8
8
|
const isVisible = contentTypes.isVisibleAttribute(model, attributeName);
|
|
9
9
|
if (isVisible) {
|
|
10
|
-
acc[attributeName] = {
|
|
10
|
+
acc[attributeName] = { select: opts.relationalFields };
|
|
11
11
|
}
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
14
14
|
case "media": {
|
|
15
|
-
acc[attributeName] = {
|
|
15
|
+
acc[attributeName] = { select: ["id"] };
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
18
|
case "component": {
|
|
19
|
-
const populate = getDeepPopulate(attribute.component);
|
|
19
|
+
const populate = getDeepPopulate(attribute.component, opts);
|
|
20
20
|
acc[attributeName] = { populate };
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
23
|
case "dynamiczone": {
|
|
24
24
|
const populatedComponents = (attribute.components || []).reduce(
|
|
25
25
|
(acc2, componentUID) => {
|
|
26
|
-
acc2[componentUID] = { populate: getDeepPopulate(componentUID) };
|
|
26
|
+
acc2[componentUID] = { populate: getDeepPopulate(componentUID, opts) };
|
|
27
27
|
return acc2;
|
|
28
28
|
},
|
|
29
29
|
{}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n const attributes = Object.entries(model.attributes);\n\n return attributes.reduce((acc: any, [attributeName, attribute]) => {\n switch (attribute.type) {\n case 'relation': {\n // TODO: Should this just be a plain list?\n // Ignore createdBy, updatedBy, ...\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n if (isVisible) {\n acc[attributeName] = {
|
|
1
|
+
{"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\ninterface Options {\n /**\n * Fields to select when populating relations\n */\n relationalFields?: string[];\n}\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: Common.UID.Schema, opts: Options = {}) => {\n const model = strapi.getModel(uid);\n const attributes = Object.entries(model.attributes);\n\n return attributes.reduce((acc: any, [attributeName, attribute]) => {\n switch (attribute.type) {\n case 'relation': {\n // TODO: Should this just be a plain list?\n // Ignore createdBy, updatedBy, ...\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n if (isVisible) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n break;\n }\n\n case 'media': {\n acc[attributeName] = { select: ['id'] };\n break;\n }\n\n case 'component': {\n const populate = getDeepPopulate(attribute.component, opts);\n acc[attributeName] = { populate };\n break;\n }\n\n case 'dynamiczone': {\n // Use fragments to populate the dynamic zone components\n const populatedComponents = (attribute.components || []).reduce(\n (acc: any, componentUID: Common.UID.Component) => {\n acc[componentUID] = { populate: getDeepPopulate(componentUID, opts) };\n return acc;\n },\n {}\n );\n\n acc[attributeName] = { on: populatedComponents };\n break;\n }\n default:\n break;\n }\n\n return acc;\n }, {});\n};\n"],"names":["acc"],"mappings":";AAWO,MAAM,kBAAkB,CAAC,KAAwB,OAAgB,OAAO;AACvE,QAAA,QAAQ,OAAO,SAAS,GAAG;AACjC,QAAM,aAAa,OAAO,QAAQ,MAAM,UAAU;AAElD,SAAO,WAAW,OAAO,CAAC,KAAU,CAAC,eAAe,SAAS,MAAM;AACjE,YAAQ,UAAU,MAAM;AAAA,MACtB,KAAK,YAAY;AAGf,cAAM,YAAY,aAAa,mBAAmB,OAAO,aAAa;AACtE,YAAI,WAAW;AACb,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QACvD;AACA;AAAA,MACF;AAAA,MAEA,KAAK,SAAS;AACZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;AACtC;AAAA,MACF;AAAA,MAEA,KAAK,aAAa;AAChB,cAAM,WAAW,gBAAgB,UAAU,WAAW,IAAI;AACtD,YAAA,aAAa,IAAI,EAAE;AACvB;AAAA,MACF;AAAA,MAEA,KAAK,eAAe;AAElB,cAAM,uBAAuB,UAAU,cAAc,CAAI,GAAA;AAAA,UACvD,CAACA,MAAU,iBAAuC;AAChDA,iBAAI,YAAY,IAAI,EAAE,UAAU,gBAAgB,cAAc,IAAI;AAC3DA,mBAAAA;AAAAA,UACT;AAAA,UACA,CAAC;AAAA,QAAA;AAGH,YAAI,aAAa,IAAI,EAAE,IAAI,oBAAoB;AAC/C;AAAA,MACF;AAAA,IAGF;AAEO,WAAA;AAAA,EACT,GAAG,CAAE,CAAA;AACP;"}
|
|
@@ -15,9 +15,6 @@ declare const updateComponents: <TUID extends Common.UID.Schema, TData extends P
|
|
|
15
15
|
declare const deleteComponents: <TUID extends Common.UID.Schema, TEntity extends Attribute.GetValues<TUID, Attribute.GetKeys<TUID>>>(uid: TUID, entityToDelete: TEntity, { loadComponents }?: {
|
|
16
16
|
loadComponents?: boolean | undefined;
|
|
17
17
|
}) => Promise<void>;
|
|
18
|
-
declare const cloneComponents: <TUID extends Common.UID.Schema>(uid: TUID, entityToClone: {
|
|
19
|
-
id: EntityService.Params.Attribute.ID;
|
|
20
|
-
}, data: EntityService.Params.Data.Input<TUID>) => Promise<ComponentBody>;
|
|
21
18
|
declare const deleteComponent: <TUID extends `${string}.${string}`>(uid: TUID, componentToDelete: Attribute.GetValues<TUID, Attribute.GetKeys<TUID>>) => Promise<void>;
|
|
22
|
-
export { omitComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent,
|
|
19
|
+
export { omitComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent, };
|
|
23
20
|
//# sourceMappingURL=components.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/services/entity-service/components.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAS,aAAa,EAAE,MAAM,eAAe,CAAC;AAGrF,KAAK,gBAAgB,CAAC,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,SAAS,CAAC,SAAS,CACzE,IAAI,EACJ,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC,CAC3D,CAAC;AAMF,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAC7B,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,GAChD,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAC/C,SAAS,CAAC,WAAW,CACxB,CAAC;CACH,CAAC;AAIF,iBAAS,iBAAiB,CACxB,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAC/D,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvE,iBAAS,iBAAiB,CACxB,WAAW,EAAE,MAAM,CAAC,SAAS,EAC7B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAC7D,OAAO,CAAC,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AC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvE,iBAAS,iBAAiB,CACxB,WAAW,EAAE,MAAM,CAAC,SAAS,EAC7B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAC7D,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAcrE,QAAA,MAAM,gBAAgB,yIAqGrB,CAAC;AAEF,QAAA,MAAM,aAAa,sDAET;IAAE,EAAE,EAAE,cAAc,MAAM,UAAU,CAAC,EAAE,CAAA;CAAE,oCASlD,CAAC;AAMF,QAAA,MAAM,gBAAgB,4HAKJ;IAAE,EAAE,EAAE,cAAc,MAAM,UAAU,CAAC,EAAE,CAAA;CAAE,wCA2F1D,CAAC;AAkGF,QAAA,MAAM,gBAAgB;;mBAkDrB,CAAC;AA8DF,QAAA,MAAM,eAAe,yIAMpB,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
|
|
@@ -32,7 +32,7 @@ const createComponents = async (uid, data) => {
|
|
|
32
32
|
if (!Array.isArray(componentValue)) {
|
|
33
33
|
throw new Error("Expected an array to create repeatable component");
|
|
34
34
|
}
|
|
35
|
-
const components = await strapiUtils.
|
|
35
|
+
const components = await strapiUtils.async.map(
|
|
36
36
|
componentValue,
|
|
37
37
|
(value) => createComponent(componentUID, value),
|
|
38
38
|
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
@@ -76,7 +76,7 @@ const createComponents = async (uid, data) => {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
|
-
componentBody[attributeName] = await strapiUtils.
|
|
79
|
+
componentBody[attributeName] = await strapiUtils.async.map(
|
|
80
80
|
dynamiczoneValues,
|
|
81
81
|
createDynamicZoneComponents,
|
|
82
82
|
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
@@ -91,7 +91,7 @@ const getComponents = async (uid, entity) => {
|
|
|
91
91
|
if (___default.default.isEmpty(componentAttributes)) {
|
|
92
92
|
return {};
|
|
93
93
|
}
|
|
94
|
-
return strapi.query(uid).load(entity, componentAttributes);
|
|
94
|
+
return strapi.db.query(uid).load(entity, componentAttributes);
|
|
95
95
|
};
|
|
96
96
|
const updateComponents = async (uid, entityToUpdate, data) => {
|
|
97
97
|
const { attributes = {} } = strapi.getModel(uid);
|
|
@@ -109,7 +109,7 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
|
|
109
109
|
if (!Array.isArray(componentValue)) {
|
|
110
110
|
throw new Error("Expected an array to create repeatable component");
|
|
111
111
|
}
|
|
112
|
-
const components = await strapiUtils.
|
|
112
|
+
const components = await strapiUtils.async.map(
|
|
113
113
|
componentValue,
|
|
114
114
|
(value) => updateOrCreateComponent(componentUID, value),
|
|
115
115
|
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
@@ -141,7 +141,7 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
|
|
141
141
|
if (!Array.isArray(dynamiczoneValues)) {
|
|
142
142
|
throw new Error("Expected an array to create repeatable component");
|
|
143
143
|
}
|
|
144
|
-
componentBody[attributeName] = await strapiUtils.
|
|
144
|
+
componentBody[attributeName] = await strapiUtils.async.map(
|
|
145
145
|
dynamiczoneValues,
|
|
146
146
|
async (value) => {
|
|
147
147
|
const { id } = await updateOrCreateComponent(value.__component, value);
|
|
@@ -169,7 +169,7 @@ const pickStringifiedId = ({
|
|
|
169
169
|
return `${id}`;
|
|
170
170
|
};
|
|
171
171
|
const deleteOldComponents = async (uid, componentUID, entityToUpdate, attributeName, componentValue) => {
|
|
172
|
-
const previousValue = await strapi.query(uid).load(entityToUpdate, attributeName);
|
|
172
|
+
const previousValue = await strapi.db.query(uid).load(entityToUpdate, attributeName);
|
|
173
173
|
const idsToKeep = ___default.default.castArray(componentValue).filter(_.has("id")).map(pickStringifiedId);
|
|
174
174
|
const allIds = ___default.default.castArray(previousValue).filter(_.has("id")).map(pickStringifiedId);
|
|
175
175
|
idsToKeep.forEach((id) => {
|
|
@@ -187,7 +187,7 @@ const deleteOldComponents = async (uid, componentUID, entityToUpdate, attributeN
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamiczoneValues) => {
|
|
190
|
-
const previousValue = await strapi.query(uid).load(entityToUpdate, attributeName);
|
|
190
|
+
const previousValue = await strapi.db.query(uid).load(entityToUpdate, attributeName);
|
|
191
191
|
const idsToKeep = ___default.default.castArray(dynamiczoneValues).filter(_.has("id")).map((v) => ({
|
|
192
192
|
id: pickStringifiedId(v),
|
|
193
193
|
__component: v.__component
|
|
@@ -226,7 +226,7 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
|
226
226
|
if (attribute.type === "component" || attribute.type === "dynamiczone") {
|
|
227
227
|
let value;
|
|
228
228
|
if (loadComponents) {
|
|
229
|
-
value = await strapi.query(uid).load(entityToDelete, attributeName);
|
|
229
|
+
value = await strapi.db.query(uid).load(entityToDelete, attributeName);
|
|
230
230
|
} else {
|
|
231
231
|
value = entityToDelete[attributeName];
|
|
232
232
|
}
|
|
@@ -235,7 +235,7 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
|
235
235
|
}
|
|
236
236
|
if (attribute.type === "component") {
|
|
237
237
|
const { component: componentUID } = attribute;
|
|
238
|
-
await strapiUtils.
|
|
238
|
+
await strapiUtils.async.map(
|
|
239
239
|
___default.default.castArray(value),
|
|
240
240
|
(subValue) => deleteComponent(componentUID, subValue),
|
|
241
241
|
{
|
|
@@ -243,7 +243,7 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
245
|
} else {
|
|
246
|
-
await strapiUtils.
|
|
246
|
+
await strapiUtils.async.map(
|
|
247
247
|
___default.default.castArray(value),
|
|
248
248
|
(subValue) => deleteComponent(subValue.__component, subValue),
|
|
249
249
|
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
@@ -253,75 +253,6 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
|
-
const cloneComponents = async (uid, entityToClone, data) => {
|
|
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");
|
|
274
|
-
}
|
|
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
|
|
286
|
-
}
|
|
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
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
},
|
|
318
|
-
{ concurrency: isDialectMySQL() ? 1 : Infinity }
|
|
319
|
-
);
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return componentBody;
|
|
324
|
-
};
|
|
325
256
|
const createComponent = async (uid, data) => {
|
|
326
257
|
const model = strapi.getModel(uid);
|
|
327
258
|
const componentData = await createComponents(uid, data);
|
|
@@ -333,12 +264,12 @@ const createComponent = async (uid, data) => {
|
|
|
333
264
|
// ... and assign the newly created component instead
|
|
334
265
|
_.assign(componentData)
|
|
335
266
|
);
|
|
336
|
-
return strapi.query(uid).create({ data: transform(data) });
|
|
267
|
+
return strapi.db.query(uid).create({ data: transform(data) });
|
|
337
268
|
};
|
|
338
269
|
const updateComponent = async (uid, componentToUpdate, data) => {
|
|
339
270
|
const model = strapi.getModel(uid);
|
|
340
271
|
const componentData = await updateComponents(uid, componentToUpdate, data);
|
|
341
|
-
return strapi.query(uid).update({
|
|
272
|
+
return strapi.db.query(uid).update({
|
|
342
273
|
where: {
|
|
343
274
|
id: componentToUpdate.id
|
|
344
275
|
},
|
|
@@ -356,25 +287,8 @@ const updateOrCreateComponent = (componentUID, value) => {
|
|
|
356
287
|
};
|
|
357
288
|
const deleteComponent = async (uid, componentToDelete) => {
|
|
358
289
|
await deleteComponents(uid, componentToDelete);
|
|
359
|
-
await strapi.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
360
|
-
};
|
|
361
|
-
const cloneComponent = async (uid, data) => {
|
|
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(
|
|
368
|
-
// Make sure we don't save the component with a pre-defined ID
|
|
369
|
-
_.omit("id"),
|
|
370
|
-
// Remove the component data from the original data object ...
|
|
371
|
-
(payload) => omitComponentData(model, payload),
|
|
372
|
-
// ... and assign the newly created component instead
|
|
373
|
-
_.assign(componentData)
|
|
374
|
-
);
|
|
375
|
-
return strapi.query(uid).clone(data.id, { data: transform(data) });
|
|
290
|
+
await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });
|
|
376
291
|
};
|
|
377
|
-
exports.cloneComponents = cloneComponents;
|
|
378
292
|
exports.createComponents = createComponents;
|
|
379
293
|
exports.deleteComponent = deleteComponent;
|
|
380
294
|
exports.deleteComponents = deleteComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../../../src/services/entity-service/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { has, omit, pipe, assign } from 'lodash/fp';\nimport type { Attribute, Common, Schema, Utils, EntityService } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, mapAsync, errors } from '@strapi/utils';\n\ntype LoadedComponents<TUID extends Common.UID.Schema> = Attribute.GetValues<\n TUID,\n Attribute.GetKeysByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype ComponentValue = Attribute.GetValue<\n Attribute.Component<Common.UID.Component, false> | Attribute.Component<Common.UID.Component, true>\n>;\n\ntype ComponentBody = {\n [key: string]: Attribute.GetValue<\n | Attribute.Component<Common.UID.Component, false>\n | Attribute.Component<Common.UID.Component, true>\n | Attribute.DynamicZone\n >;\n};\n\nconst isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';\n\nfunction omitComponentData(\n contentType: Schema.ContentType,\n data: EntityService.Params.Data.Input<Schema.ContentType['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.ContentType['uid']>>;\nfunction omitComponentData(\n contentType: Schema.Component,\n data: EntityService.Params.Data.Input<Schema.Component['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.Component['uid']>>;\nfunction omitComponentData(\n contentType: Schema.ContentType | Schema.Component,\n data: EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>> {\n const { attributes } = contentType;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n}\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <\n TUID extends Common.UID.Schema,\n TData extends EntityService.Params.Data.Input<TUID>\n>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await mapAsync(\n componentValue,\n (value: any) => createComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Attribute.GetValue<Attribute.Component<Common.UID.Component, true>>;\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as EntityService.Params.Data.Input<Common.UID.Component>\n );\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as EntityService.Params.Attribute.GetValue<Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await mapAsync(\n dynamiczoneValues,\n createDynamicZoneComponents,\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n entity: { id: EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <\n TUID extends Common.UID.Schema,\n TData extends Partial<EntityService.Params.Data.Input<TUID>>\n>(\n uid: TUID,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[\n attributeName as keyof TData\n ] as Attribute.GetValue<Attribute.Component>;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await mapAsync(\n componentValue,\n (value: any) => updateOrCreateComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Attribute.GetValue<Attribute.Component<Common.UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Attribute.GetValue<Attribute.DynamicZone>;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await mapAsync(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: EntityService.Params.Attribute.ID;\n}): EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n componentUID: Common.UID.Component,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: Attribute.GetValue<Attribute.Component>\n) => {\n const previousValue = (await strapi\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: Attribute.GetValue<Attribute.DynamicZone>\n) => {\n const previousValue = (await strapi\n .query(uid)\n .load(entityToUpdate, attributeName)) as Attribute.GetValue<Attribute.DynamicZone>;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = Attribute.GetValue<Attribute.DynamicZone>;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <\n TUID extends Common.UID.Schema,\n TEntity extends Attribute.GetValues<TUID>\n>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n if (loadComponents) {\n value = await strapi.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await mapAsync(\n _.castArray(value),\n (subValue: any) => deleteComponent(componentUID, subValue),\n {\n concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,\n }\n );\n } else {\n // delete dynamic zone components\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await mapAsync(\n _.castArray(value),\n (subValue: any) => deleteComponent(subValue.__component, subValue),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n }\n\n continue;\n }\n }\n};\n\nconst cloneComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n entityToClone: { id: EntityService.Params.Attribute.ID },\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n const componentData = await getComponents(uid, entityToClone);\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n // If the attribute is not set or on the component to clone, skip it\n if (!has(attributeName, data) && !has(attributeName, componentData)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = (\n attributeName in data\n ? data[attributeName as keyof typeof data]\n : componentData[attributeName as keyof typeof componentData]\n ) as ComponentValue;\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await mapAsync(\n componentValue,\n (value: any) => cloneComponent(componentUID, value),\n { concurrency: isDialectMySQL() ? 1 : Infinity }\n )) as Attribute.GetValue<Attribute.Component<Common.UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await cloneComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = has(attributeName, data)\n ? data[attributeName as keyof typeof data]\n : componentData[attributeName as keyof typeof componentData];\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await mapAsync(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await cloneComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() ? 1 : Infinity }\n );\n continue;\n }\n }\n\n return componentBody;\n};\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid);\n\n const componentData = await createComponents(uid, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n componentToUpdate: { id: EntityService.Params.Attribute.ID },\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid);\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: Object.assign(omitComponentData(model, data), componentData),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends Common.UID.Component>(\n componentUID: TUID,\n value: EntityService.Params.Data.Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n componentToDelete: Attribute.GetValues<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\nconst cloneComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid);\n\n if (!('id' in data) || typeof data.id === 'undefined') {\n return createComponent(uid, data);\n }\n\n const componentData = await cloneComponents(uid, { id: data.id }, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.query(uid).clone(data.id, { data: transform(data) });\n};\n\nexport {\n omitComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n cloneComponents,\n};\n"],"names":["contentTypesUtils","omit","has","mapAsync","_","errors","pipe","assign"],"mappings":";;;;;;;AAsBA,MAAM,iBAAiB,MAAM,OAAO,IAAI,QAAQ,WAAW;AAU3D,SAAS,kBACP,aACA,MAC+F;AACzF,QAAA,EAAE,WAAe,IAAA;AACvB,QAAM,sBAAsB,OAAO,KAAK,UAAU,EAAE;AAAA,IAAO,CAAC,kBAC1DA,YAAA,aAAkB,qBAAqB,WAAW,aAAa,CAAC;AAAA,EAAA;AAG3D,SAAAC,EAAA,KAAK,qBAAqB,IAAI;AACvC;AAGM,MAAA,mBAAmB,OAIvB,KACA,SACG;AACH,QAAM,EAAE,aAAa,OAAO,OAAO,SAAS,GAAG;AAE/C,QAAM,gBAA+B,CAAA;AAE/B,QAAA,iBAAiB,OAAO,KAAK,UAAU;AAE7C,aAAW,iBAAiB,gBAAgB;AACpC,UAAA,YAAY,WAAW,aAAa;AAEtC,QAAA,CAACC,EAAAA,IAAI,eAAe,IAAI,KAAK,CAACF,yBAAkB,qBAAqB,SAAS,GAAG;AACnF;AAAA,IACF;AAEI,QAAA,UAAU,SAAS,aAAa;AAClC,YAAM,EAAE,WAAW,cAAc,aAAa,UAAU;AAElD,YAAA,iBAAiB,KAAK,aAA4B;AAExD,UAAI,mBAAmB,MAAM;AAC3B;AAAA,MACF;AAEA,UAAI,eAAe,MAAM;AACvB,YAAI,CAAC,MAAM,QAAQ,cAAc,GAAG;AAC5B,gBAAA,IAAI,MAAM,kDAAkD;AAAA,QACpE;AAGA,cAAM,aAAc,MAAM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cACA,UACG;AACH,MAAI,UAAU,MAAM;AACX,WAAA;AAAA,EACT;AAGA,MAAI,QAAQ,SAAS,OAAO,MAAM,OAAO,aAAa;AAEpD,WAAO,gBAAgB,cAAc,EAAE,IAAI,MAAM,GAAA,GAAM,KAAK;AAAA,EAC9D;AAGO,SAAA,gBAAgB,cAAc,KAAK;AAC5C;AAEM,MAAA,kBAAkB,OACtB,KACA,sBACG;AACG,QAAA,iBAAiB,KAAK,iBAAiB;AAC7C,QAAM,OAAO,MAAM,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,kBAAkB,GAAG,EAAG,CAAA;AACxE;AAEA,MAAM,iBAAiB,OACrB,KACA,SACG;AACG,QAAA,QAAQ,OAAO,SAAS,GAAG;AAEjC,MAAI,EAAE,QAAQ,SAAS,OAAO,KAAK,OAAO,aAAa;AAC9C,WAAA,gBAAgB,KAAK,IAAI;AAAA,EAClC;AAEM,QAAA,gBAAgB,MAAM,gBAAgB,KAAK,EAAE,IAAI,KAAK,MAAM,IAAI;AACtE,QAAM,YAAYD,EAAA;AAAA;AAAA,IAEhBL,EAAAA,KAAK,IAAI;AAAA;AAAA,IAET,CAAC,YAAY,kBAAkB,OAAO,OAAO;AAAA;AAAA,IAE7CM,EAAAA,OAAO,aAAa;AAAA,EAAA;AAGtB,SAAO,OAAO,MAAM,GAAG,EAAE,MAAM,KAAK,IAAI,EAAE,MAAM,UAAU,IAAI,EAAG,CAAA;AACnE;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../../../src/services/entity-service/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { has, omit, pipe, assign } from 'lodash/fp';\nimport type { Attribute, Common, Schema, Utils, EntityService } from '@strapi/types';\nimport { contentTypes as contentTypesUtils, async, errors } from '@strapi/utils';\n\ntype LoadedComponents<TUID extends Common.UID.Schema> = Attribute.GetValues<\n TUID,\n Attribute.GetKeysByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype ComponentValue = Attribute.GetValue<\n Attribute.Component<Common.UID.Component, false> | Attribute.Component<Common.UID.Component, true>\n>;\n\ntype ComponentBody = {\n [key: string]: Attribute.GetValue<\n | Attribute.Component<Common.UID.Component, false>\n | Attribute.Component<Common.UID.Component, true>\n | Attribute.DynamicZone\n >;\n};\n\nconst isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';\n\nfunction omitComponentData(\n contentType: Schema.ContentType,\n data: EntityService.Params.Data.Input<Schema.ContentType['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.ContentType['uid']>>;\nfunction omitComponentData(\n contentType: Schema.Component,\n data: EntityService.Params.Data.Input<Schema.Component['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.Component['uid']>>;\nfunction omitComponentData(\n contentType: Schema.ContentType | Schema.Component,\n data: EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n): Partial<EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>> {\n const { attributes } = contentType;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n}\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <\n TUID extends Common.UID.Schema,\n TData extends EntityService.Params.Data.Input<TUID>\n>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => createComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Attribute.GetValue<Attribute.Component<Common.UID.Component, true>>;\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as EntityService.Params.Data.Input<Common.UID.Component>\n );\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as EntityService.Params.Attribute.GetValue<Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n createDynamicZoneComponents,\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n entity: { id: EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.db.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <\n TUID extends Common.UID.Schema,\n TData extends Partial<EntityService.Params.Data.Input<TUID>>\n>(\n uid: TUID,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[\n attributeName as keyof TData\n ] as Attribute.GetValue<Attribute.Component>;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => updateOrCreateComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Attribute.GetValue<Attribute.Component<Common.UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Attribute.GetValue<Attribute.DynamicZone>;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: EntityService.Params.Attribute.ID;\n}): EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n componentUID: Common.UID.Component,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: Attribute.GetValue<Attribute.Component>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends Common.UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: Attribute.GetValue<Attribute.DynamicZone>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as Attribute.GetValue<Attribute.DynamicZone>;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = Attribute.GetValue<Attribute.DynamicZone>;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <\n TUID extends Common.UID.Schema,\n TEntity extends Attribute.GetValues<TUID>\n>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n if (loadComponents) {\n value = await strapi.db.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(componentUID, subValue),\n {\n concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,\n }\n );\n } else {\n // delete dynamic zone components\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(subValue.__component, subValue),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n }\n\n continue;\n }\n }\n};\n\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid);\n\n const componentData = await createComponents(uid, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.db.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n componentToUpdate: { id: EntityService.Params.Attribute.ID },\n data: EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid);\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.db.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: Object.assign(omitComponentData(model, data), componentData),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends Common.UID.Component>(\n componentUID: TUID,\n value: EntityService.Params.Data.Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends Common.UID.Component>(\n uid: TUID,\n componentToDelete: Attribute.GetValues<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\nexport {\n omitComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n};\n"],"names":["contentTypesUtils","omit","has","async","_","errors","pipe","assign"],"mappings":";;;;;;;AAsBA,MAAM,iBAAiB,MAAM,OAAO,IAAI,QAAQ,WAAW;AAU3D,SAAS,kBACP,aACA,MAC+F;AACzF,QAAA,EAAE,WAAe,IAAA;AACvB,QAAM,sBAAsB,OAAO,KAAK,UAAU,EAAE;AAAA,IAAO,CAAC,kBAC1DA,YAAA,aAAkB,qBAAqB,WAAW,aAAa,CAAC;AAAA,EAAA;AAG3D,SAAAC,EAAA,KAAK,qBAAqB,IAAI;AACvC;AAGM,MAAA,mBAAmB,OAIvB,KACA,SACG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