@strapi/core 0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28 → 0.0.0-experimental.2363945b79274c79e6505e5a6c3cdec876ed8cec

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.

Files changed (124) hide show
  1. package/dist/core-api/controller/collection-type.js.map +1 -1
  2. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  3. package/dist/core-api/controller/index.d.ts.map +1 -1
  4. package/dist/core-api/controller/index.js +6 -1
  5. package/dist/core-api/controller/index.js.map +1 -1
  6. package/dist/core-api/controller/index.mjs +6 -1
  7. package/dist/core-api/controller/index.mjs.map +1 -1
  8. package/dist/core-api/controller/single-type.js.map +1 -1
  9. package/dist/core-api/controller/single-type.mjs.map +1 -1
  10. package/dist/core-api/controller/transform.d.ts +8 -7
  11. package/dist/core-api/controller/transform.d.ts.map +1 -1
  12. package/dist/core-api/controller/transform.js +18 -9
  13. package/dist/core-api/controller/transform.js.map +1 -1
  14. package/dist/core-api/controller/transform.mjs +18 -9
  15. package/dist/core-api/controller/transform.mjs.map +1 -1
  16. package/dist/core-api/service/collection-type.d.ts.map +1 -1
  17. package/dist/core-api/service/collection-type.js.map +1 -1
  18. package/dist/core-api/service/collection-type.mjs.map +1 -1
  19. package/dist/core-api/service/single-type.d.ts +3 -2
  20. package/dist/core-api/service/single-type.d.ts.map +1 -1
  21. package/dist/core-api/service/single-type.js +15 -3
  22. package/dist/core-api/service/single-type.js.map +1 -1
  23. package/dist/core-api/service/single-type.mjs +15 -3
  24. package/dist/core-api/service/single-type.mjs.map +1 -1
  25. package/dist/services/document-service/common.d.ts +2 -2
  26. package/dist/services/document-service/common.d.ts.map +1 -1
  27. package/dist/services/document-service/common.js.map +1 -1
  28. package/dist/services/document-service/common.mjs.map +1 -1
  29. package/dist/services/document-service/index.d.ts.map +1 -1
  30. package/dist/services/document-service/index.js +4 -4
  31. package/dist/services/document-service/index.js.map +1 -1
  32. package/dist/services/document-service/index.mjs +2 -2
  33. package/dist/services/document-service/index.mjs.map +1 -1
  34. package/dist/services/document-service/repository.d.ts +3 -0
  35. package/dist/services/document-service/repository.d.ts.map +1 -0
  36. package/dist/services/document-service/repository.js +309 -0
  37. package/dist/services/document-service/repository.js.map +1 -0
  38. package/dist/services/document-service/repository.mjs +309 -0
  39. package/dist/services/document-service/repository.mjs.map +1 -0
  40. package/dist/services/document-service/transform/fields.d.ts.map +1 -1
  41. package/dist/services/document-service/transform/fields.js +11 -10
  42. package/dist/services/document-service/transform/fields.js.map +1 -1
  43. package/dist/services/document-service/transform/fields.mjs +11 -10
  44. package/dist/services/document-service/transform/fields.mjs.map +1 -1
  45. package/dist/services/document-service/transform/id-transform.d.ts +2 -9
  46. package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
  47. package/dist/services/document-service/transform/id-transform.js +2 -32
  48. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  49. package/dist/services/document-service/transform/id-transform.mjs +2 -32
  50. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  51. package/dist/services/document-service/transform/populate.d.ts.map +1 -1
  52. package/dist/services/document-service/transform/populate.js +0 -10
  53. package/dist/services/document-service/transform/populate.js.map +1 -1
  54. package/dist/services/document-service/transform/populate.mjs +0 -10
  55. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  56. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  57. package/dist/services/document-service/transform/relations/extract/data-ids.js +7 -4
  58. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  59. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +7 -4
  60. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  61. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  62. package/dist/services/document-service/transform/relations/transform/data-ids.js +11 -9
  63. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  64. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +11 -9
  65. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  66. package/dist/services/document-service/transform/relations/utils/data.d.ts +2 -4
  67. package/dist/services/document-service/transform/relations/utils/data.d.ts.map +1 -1
  68. package/dist/services/document-service/transform/relations/utils/data.js +1 -1
  69. package/dist/services/document-service/transform/relations/utils/data.js.map +1 -1
  70. package/dist/services/document-service/transform/relations/utils/data.mjs +1 -1
  71. package/dist/services/document-service/transform/relations/utils/data.mjs.map +1 -1
  72. package/dist/services/document-service/transform/relations/utils/i18n.d.ts +2 -2
  73. package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
  74. package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
  75. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
  76. package/dist/services/document-service/transform/relations/utils/types.d.ts +5 -1
  77. package/dist/services/document-service/transform/relations/utils/types.d.ts.map +1 -1
  78. package/dist/utils/transform-content-types-to-models.d.ts +174 -3
  79. package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
  80. package/dist/utils/transform-content-types-to-models.js +80 -41
  81. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  82. package/dist/utils/transform-content-types-to-models.mjs +79 -41
  83. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  84. package/package.json +14 -14
  85. package/dist/services/document-service/collection-type.d.ts +0 -4
  86. package/dist/services/document-service/collection-type.d.ts.map +0 -1
  87. package/dist/services/document-service/collection-type.js +0 -158
  88. package/dist/services/document-service/collection-type.js.map +0 -1
  89. package/dist/services/document-service/collection-type.mjs +0 -158
  90. package/dist/services/document-service/collection-type.mjs.map +0 -1
  91. package/dist/services/document-service/document-engine.d.ts +0 -8
  92. package/dist/services/document-service/document-engine.d.ts.map +0 -1
  93. package/dist/services/document-service/document-engine.js +0 -249
  94. package/dist/services/document-service/document-engine.js.map +0 -1
  95. package/dist/services/document-service/document-engine.mjs +0 -250
  96. package/dist/services/document-service/document-engine.mjs.map +0 -1
  97. package/dist/services/document-service/repository-factory.d.ts +0 -3
  98. package/dist/services/document-service/repository-factory.d.ts.map +0 -1
  99. package/dist/services/document-service/repository-factory.js +0 -12
  100. package/dist/services/document-service/repository-factory.js.map +0 -1
  101. package/dist/services/document-service/repository-factory.mjs +0 -12
  102. package/dist/services/document-service/repository-factory.mjs.map +0 -1
  103. package/dist/services/document-service/single-type.d.ts +0 -4
  104. package/dist/services/document-service/single-type.d.ts.map +0 -1
  105. package/dist/services/document-service/single-type.js +0 -105
  106. package/dist/services/document-service/single-type.js.map +0 -1
  107. package/dist/services/document-service/single-type.mjs +0 -105
  108. package/dist/services/document-service/single-type.mjs.map +0 -1
  109. package/dist/services/document-service/transform/filters.js +0 -49
  110. package/dist/services/document-service/transform/filters.js.map +0 -1
  111. package/dist/services/document-service/transform/filters.mjs +0 -49
  112. package/dist/services/document-service/transform/filters.mjs.map +0 -1
  113. package/dist/services/document-service/transform/relations/transform/output-ids.js +0 -26
  114. package/dist/services/document-service/transform/relations/transform/output-ids.js.map +0 -1
  115. package/dist/services/document-service/transform/relations/transform/output-ids.mjs +0 -26
  116. package/dist/services/document-service/transform/relations/transform/output-ids.mjs.map +0 -1
  117. package/dist/services/document-service/transform/sort.js +0 -44
  118. package/dist/services/document-service/transform/sort.js.map +0 -1
  119. package/dist/services/document-service/transform/sort.mjs +0 -44
  120. package/dist/services/document-service/transform/sort.mjs.map +0 -1
  121. package/dist/services/document-service/transform/utils.js +0 -23
  122. package/dist/services/document-service/transform/utils.js.map +0 -1
  123. package/dist/services/document-service/transform/utils.mjs +0 -23
  124. package/dist/services/document-service/transform/utils.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"populate.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/transform/populate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAKlD,eAAO,MAAM,iBAAiB,SAAgB,IAAI,QAAQ,OAAO,qBAkChE,CAAC"}
1
+ {"version":3,"file":"populate.d.ts","sourceRoot":"","sources":["../../../../src/services/document-service/transform/populate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlD,eAAO,MAAM,iBAAiB,SAAgB,IAAI,QAAQ,OAAO,qBAqBhE,CAAC"}
@@ -1,23 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const strapiUtils = require("@strapi/utils");
4
- const utils = require("./utils.js");
5
- const filters = require("./filters.js");
6
4
  const fields = require("./fields.js");
7
5
  const transformPopulate = async (data, opts) => {
8
- utils.switchDocumentIdForId(data);
9
- const allKeysAreDocumentId = Object.keys(data).every((key) => key === "documentId");
10
- if (allKeysAreDocumentId) {
11
- return data;
12
- }
13
6
  return strapiUtils.traverse.traverseQueryPopulate(
14
7
  async ({ attribute, key, value }, { set }) => {
15
8
  if (!value || typeof value !== "object" || attribute?.type !== "relation") {
16
9
  return;
17
10
  }
18
- if ("filters" in value) {
19
- value.filters = await filters.transformFilters(value.filters, opts);
20
- }
21
11
  if ("fields" in value && Array.isArray(value.fields)) {
22
12
  value.fields = fields.transformFields(value.fields);
23
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport { type Data, type Options } from './types';\nimport { switchDocumentIdForId } from './utils';\nimport { transformFilters } from './filters';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: Options) => {\n // Before doing the filters traversal change any top level 'id' properties to 'documentId'\n switchDocumentIdForId(data);\n\n const allKeysAreDocumentId = Object.keys(data).every((key) => key === 'documentId');\n if (allKeysAreDocumentId) {\n // If every key is a documentId, skip the traversal\n return data;\n }\n\n return traverse.traverseQueryPopulate(\n async ({ attribute, key, value }, { set }) => {\n if (!value || typeof value !== 'object' || attribute?.type !== 'relation') {\n return;\n }\n\n /*\n If the attribute is a relation\n Look for filters or fields in the value \n and apply the relevant transformation to these objects\n */\n if ('filters' in value) {\n value.filters = await transformFilters(value.filters as Data, opts);\n }\n\n if ('fields' in value && Array.isArray(value.fields)) {\n value.fields = transformFields(value.fields);\n }\n\n set(key, value);\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n"],"names":["switchDocumentIdForId","traverse","transformFilters","transformFields"],"mappings":";;;;;;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAAkB;AAEpEA,QAAA,sBAAsB,IAAI;AAEpB,QAAA,uBAAuB,OAAO,KAAK,IAAI,EAAE,MAAM,CAAC,QAAQ,QAAQ,YAAY;AAClF,MAAI,sBAAsB;AAEjB,WAAA;AAAA,EACT;AAEA,SAAOC,YAAS,SAAA;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MACF;AAOA,UAAI,aAAa,OAAO;AACtB,cAAM,UAAU,MAAMC,QAAAA,iBAAiB,MAAM,SAAiB,IAAI;AAAA,MACpE;AAEA,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAASC,OAAAA,gBAAgB,MAAM,MAAM;AAAA,MAC7C;AAEA,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport { type Data, type Options } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: Options) => {\n return traverse.traverseQueryPopulate(\n async ({ attribute, key, value }, { set }) => {\n if (!value || typeof value !== 'object' || attribute?.type !== 'relation') {\n return;\n }\n\n /*\n If the attribute is a relation\n Look for fields in the value\n and apply the relevant transformation to these objects\n */\n if ('fields' in value && Array.isArray(value.fields)) {\n value.fields = transformFields(value.fields);\n }\n\n set(key, value);\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n"],"names":["traverse","transformFields"],"mappings":";;;;AAIa,MAAA,oBAAoB,OAAO,MAAY,SAAkB;AACpE,SAAOA,YAAS,SAAA;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MACF;AAOA,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAASC,OAAAA,gBAAgB,MAAM,MAAM;AAAA,MAC7C;AAEA,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;;"}
@@ -1,21 +1,11 @@
1
1
  import { traverse } from "@strapi/utils";
2
- import { switchDocumentIdForId } from "./utils.mjs";
3
- import { transformFilters } from "./filters.mjs";
4
2
  import { transformFields } from "./fields.mjs";
5
3
  const transformPopulate = async (data, opts) => {
6
- switchDocumentIdForId(data);
7
- const allKeysAreDocumentId = Object.keys(data).every((key) => key === "documentId");
8
- if (allKeysAreDocumentId) {
9
- return data;
10
- }
11
4
  return traverse.traverseQueryPopulate(
12
5
  async ({ attribute, key, value }, { set }) => {
13
6
  if (!value || typeof value !== "object" || attribute?.type !== "relation") {
14
7
  return;
15
8
  }
16
- if ("filters" in value) {
17
- value.filters = await transformFilters(value.filters, opts);
18
- }
19
9
  if ("fields" in value && Array.isArray(value.fields)) {
20
10
  value.fields = transformFields(value.fields);
21
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport { type Data, type Options } from './types';\nimport { switchDocumentIdForId } from './utils';\nimport { transformFilters } from './filters';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: Options) => {\n // Before doing the filters traversal change any top level 'id' properties to 'documentId'\n switchDocumentIdForId(data);\n\n const allKeysAreDocumentId = Object.keys(data).every((key) => key === 'documentId');\n if (allKeysAreDocumentId) {\n // If every key is a documentId, skip the traversal\n return data;\n }\n\n return traverse.traverseQueryPopulate(\n async ({ attribute, key, value }, { set }) => {\n if (!value || typeof value !== 'object' || attribute?.type !== 'relation') {\n return;\n }\n\n /*\n If the attribute is a relation\n Look for filters or fields in the value \n and apply the relevant transformation to these objects\n */\n if ('filters' in value) {\n value.filters = await transformFilters(value.filters as Data, opts);\n }\n\n if ('fields' in value && Array.isArray(value.fields)) {\n value.fields = transformFields(value.fields);\n }\n\n set(key, value);\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n"],"names":[],"mappings":";;;;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAAkB;AAEpE,wBAAsB,IAAI;AAEpB,QAAA,uBAAuB,OAAO,KAAK,IAAI,EAAE,MAAM,CAAC,QAAQ,QAAQ,YAAY;AAClF,MAAI,sBAAsB;AAEjB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MACF;AAOA,UAAI,aAAa,OAAO;AACtB,cAAM,UAAU,MAAM,iBAAiB,MAAM,SAAiB,IAAI;AAAA,MACpE;AAEA,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAAS,gBAAgB,MAAM,MAAM;AAAA,MAC7C;AAEA,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport { type Data, type Options } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: Options) => {\n return traverse.traverseQueryPopulate(\n async ({ attribute, key, value }, { set }) => {\n if (!value || typeof value !== 'object' || attribute?.type !== 'relation') {\n return;\n }\n\n /*\n If the attribute is a relation\n Look for fields in the value\n and apply the relevant transformation to these objects\n */\n if ('fields' in value && Array.isArray(value.fields)) {\n value.fields = transformFields(value.fields);\n }\n\n set(key, value);\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n"],"names":[],"mappings":";;AAIa,MAAA,oBAAoB,OAAO,MAAY,SAAkB;AACpE,SAAO,SAAS;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MACF;AAOA,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAAS,gBAAgB,MAAM,MAAM;AAAA,MAC7C;AAEA,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,MAAM,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAoErC;;;GAGG;AACH,QAAA,MAAM,cAAc,UACX,KAAK,QACN,OAAO,MAAM,EAAE,GAAG,CAAC,QACnB;IAAE,GAAG,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,qDA6B5E,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"data-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,MAAM,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAyErC;;;GAGG;AACH,QAAA,MAAM,cAAc,UACX,KAAK,QACN,OAAO,MAAM,EAAE,GAAG,CAAC,QACnB;IAAE,GAAG,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,qDA6B5E,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -9,13 +9,16 @@ const handlePrimitive = (relation) => {
9
9
  return [];
10
10
  }
11
11
  if (data.isShortHand(relation)) {
12
- return [{ id: relation }];
12
+ return [{ documentId: relation }];
13
13
  }
14
14
  if (data.isLongHand(relation)) {
15
- return [{ id: relation.id, locale: relation.locale }];
15
+ if ("documentId" in relation) {
16
+ return [{ documentId: relation.documentId, locale: relation.locale }];
17
+ }
18
+ return [];
16
19
  }
17
20
  if (Array.isArray(relation)) {
18
- return relation.map((item) => data.isShortHand(item) ? { id: item } : item);
21
+ return relation.map((item) => data.isShortHand(item) ? { documentId: item } : item);
19
22
  }
20
23
  return [];
21
24
  };
@@ -57,7 +60,7 @@ const extractDataIds = (idMap, data2, opts) => {
57
60
  extractedIds.forEach((relation) => {
58
61
  idMap.add({
59
62
  uid: target,
60
- documentId: relation.id,
63
+ documentId: relation.documentId,
61
64
  locale: i18n.getRelationTargetLocale(relation, {
62
65
  targetUid: target,
63
66
  sourceUid: opts.uid,
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { ShortHand, LongHand, ID } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\ntype ExtractedId = { id: ID; locale?: string };\n\n/**\n * Get relation ids from primitive representation (id, id[], {id}, {id}[])\n */\nconst handlePrimitive = (\n relation: ShortHand | LongHand | ShortHand[] | LongHand[] | null | undefined | any\n): LongHand[] => {\n if (!relation) {\n return []; // null\n }\n if (isShortHand(relation)) {\n return [{ id: relation }]; // id\n }\n if (isLongHand(relation)) {\n // @ts-expect-error - TODO: Add relation type\n return [{ id: relation.id, locale: relation.locale }]; // { id, locale? }\n }\n if (Array.isArray(relation)) {\n return relation.map((item) => (isShortHand(item) ? { id: item } : item)); // id[]\n }\n\n return [];\n};\n\n/**\n * Get all relations document ids from a relation input value\n */\nconst extractRelationIds = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>\n): ExtractedId[] => {\n const ids = handlePrimitive(relation);\n if (!isObject(relation)) return ids;\n\n if ('set' in relation) ids.push(...handlePrimitive(relation.set)); // set: id[]\n if ('disconnect' in relation) ids.push(...handlePrimitive(relation.disconnect)); // disconnect: id[]\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n if (!relation.connect) return [];\n ids.push(...handlePrimitive(relation.connect));\n\n // handle positional arguments\n const connect = Array.isArray(relation.connect) ? relation.connect : [relation.connect];\n connect.forEach((relation) => {\n if (isShortHand(relation) || !('position' in relation)) return;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n ids.push(...handlePrimitive({ ...position, id: position.before }));\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n ids.push(...handlePrimitive({ ...position, id: position.after }));\n }\n });\n }\n\n return ids;\n};\n\n/**\n * Iterate over all attributes of a Data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: { uid: Common.UID.Schema; locale?: string | null; isDraft?: boolean }\n) => {\n return traverseEntity(\n ({ value, attribute }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const extractedIds = extractRelationIds(value as any);\n\n // TODO: Handle morph relations (they have multiple targets)\n const target = attribute.target;\n if (!target) return;\n\n extractedIds.forEach((relation) => {\n idMap.add({\n uid: target,\n documentId: relation.id as string,\n locale: getRelationTargetLocale(relation, {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }),\n isDraft: opts.isDraft,\n });\n });\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["isShortHand","isLongHand","isObject","relation","data","traverseEntity","getRelationTargetLocale"],"mappings":";;;;;;AAaA,MAAM,kBAAkB,CACtB,aACe;AACf,MAAI,CAAC,UAAU;AACb,WAAO;EACT;AACI,MAAAA,KAAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,CAAC,EAAE,IAAI,SAAA,CAAU;AAAA,EAC1B;AACI,MAAAC,KAAAA,WAAW,QAAQ,GAAG;AAEjB,WAAA,CAAC,EAAE,IAAI,SAAS,IAAI,QAAQ,SAAS,QAAQ;AAAA,EACtD;AACI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAUD,KAAA,YAAY,IAAI,IAAI,EAAE,IAAI,KAAK,IAAI,IAAK;AAAA,EACzE;AAEA,SAAO;AACT;AAKA,MAAM,qBAAqB,CACzB,aACkB;AACZ,QAAA,MAAM,gBAAgB,QAAQ;AAChC,MAAA,CAACE,WAAS,QAAQ;AAAU,WAA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;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpCF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { ShortHand, LongHand, LongHandDocument } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\n/**\n * Get relation ids from primitive representation (id, id[], {id}, {id}[])\n */\nconst handlePrimitive = (\n relation: ShortHand | LongHand | ShortHand[] | LongHand[] | null | undefined | any\n): LongHandDocument[] => {\n if (!relation) {\n return []; // null\n }\n\n if (isShortHand(relation)) {\n return [{ documentId: relation }]; // id\n }\n\n if (isLongHand(relation)) {\n // { documentId, locale? }\n if ('documentId' in relation) {\n return [{ documentId: relation.documentId, locale: relation.locale }];\n }\n // { id }\n return [];\n }\n\n if (Array.isArray(relation)) {\n return relation.map((item) => (isShortHand(item) ? { documentId: item } : item)); // id[]\n }\n\n return [];\n};\n\n/**\n * Get all relations document ids from a relation input value\n */\nconst extractRelationIds = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>\n): LongHandDocument[] => {\n const ids = handlePrimitive(relation);\n if (!isObject(relation)) return ids;\n\n if ('set' in relation) ids.push(...handlePrimitive(relation.set)); // set: id[]\n if ('disconnect' in relation) ids.push(...handlePrimitive(relation.disconnect)); // disconnect: id[]\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n if (!relation.connect) return [];\n ids.push(...handlePrimitive(relation.connect));\n\n // handle positional arguments\n const connect = Array.isArray(relation.connect) ? relation.connect : [relation.connect];\n connect.forEach((relation) => {\n if (isShortHand(relation) || !('position' in relation)) return;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n ids.push(...handlePrimitive({ ...position, id: position.before }));\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n ids.push(...handlePrimitive({ ...position, id: position.after }));\n }\n });\n }\n\n return ids;\n};\n\n/**\n * Iterate over all attributes of a Data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: { uid: Common.UID.Schema; locale?: string | null; isDraft?: boolean }\n) => {\n return traverseEntity(\n ({ value, attribute }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const extractedIds = extractRelationIds(value as any);\n\n // TODO: Handle morph relations (they have multiple targets)\n const target = attribute.target;\n if (!target) return;\n\n extractedIds.forEach((relation) => {\n idMap.add({\n uid: target,\n documentId: relation.documentId,\n locale: getRelationTargetLocale(relation, {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }),\n isDraft: opts.isDraft,\n });\n });\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["isShortHand","isLongHand","isObject","relation","data","traverseEntity","getRelationTargetLocale"],"mappings":";;;;;;AAWA,MAAM,kBAAkB,CACtB,aACuB;AACvB,MAAI,CAAC,UAAU;AACb,WAAO;EACT;AAEI,MAAAA,KAAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,CAAC,EAAE,YAAY,SAAA,CAAU;AAAA,EAClC;AAEI,MAAAC,KAAAA,WAAW,QAAQ,GAAG;AAExB,QAAI,gBAAgB,UAAU;AACrB,aAAA,CAAC,EAAE,YAAY,SAAS,YAAY,QAAQ,SAAS,QAAQ;AAAA,IACtE;AAEA,WAAO;EACT;AAEI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAUD,KAAA,YAAY,IAAI,IAAI,EAAE,YAAY,KAAK,IAAI,IAAK;AAAA,EACjF;A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X,WAAW,KAAK;AAAA,cAChB,cAAc,KAAK;AAAA,YAAA,CACpB;AAAA,YACD,SAAS,KAAK;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpCF;AAAA,EAAA;AAEJ;;"}
@@ -7,13 +7,16 @@ const handlePrimitive = (relation) => {
7
7
  return [];
8
8
  }
9
9
  if (isShortHand(relation)) {
10
- return [{ id: relation }];
10
+ return [{ documentId: relation }];
11
11
  }
12
12
  if (isLongHand(relation)) {
13
- return [{ id: relation.id, locale: relation.locale }];
13
+ if ("documentId" in relation) {
14
+ return [{ documentId: relation.documentId, locale: relation.locale }];
15
+ }
16
+ return [];
14
17
  }
15
18
  if (Array.isArray(relation)) {
16
- return relation.map((item) => isShortHand(item) ? { id: item } : item);
19
+ return relation.map((item) => isShortHand(item) ? { documentId: item } : item);
17
20
  }
18
21
  return [];
19
22
  };
@@ -55,7 +58,7 @@ const extractDataIds = (idMap, data, opts) => {
55
58
  extractedIds.forEach((relation) => {
56
59
  idMap.add({
57
60
  uid: target,
58
- documentId: relation.id,
61
+ documentId: relation.documentId,
59
62
  locale: getRelationTargetLocale(relation, {
60
63
  targetUid: target,
61
64
  sourceUid: opts.uid,
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { ShortHand, LongHand, ID } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\ntype ExtractedId = { id: ID; locale?: string };\n\n/**\n * Get relation ids from primitive representation (id, id[], {id}, {id}[])\n */\nconst handlePrimitive = (\n relation: ShortHand | LongHand | ShortHand[] | LongHand[] | null | undefined | any\n): LongHand[] => {\n if (!relation) {\n return []; // null\n }\n if (isShortHand(relation)) {\n return [{ id: relation }]; // id\n }\n if (isLongHand(relation)) {\n // @ts-expect-error - TODO: Add relation type\n return [{ id: relation.id, locale: relation.locale }]; // { id, locale? }\n }\n if (Array.isArray(relation)) {\n return relation.map((item) => (isShortHand(item) ? { id: item } : item)); // id[]\n }\n\n return [];\n};\n\n/**\n * Get all relations document ids from a relation input value\n */\nconst extractRelationIds = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>\n): ExtractedId[] => {\n const ids = handlePrimitive(relation);\n if (!isObject(relation)) return ids;\n\n if ('set' in relation) ids.push(...handlePrimitive(relation.set)); // set: id[]\n if ('disconnect' in relation) ids.push(...handlePrimitive(relation.disconnect)); // disconnect: id[]\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n if (!relation.connect) return [];\n ids.push(...handlePrimitive(relation.connect));\n\n // handle positional arguments\n const connect = Array.isArray(relation.connect) ? relation.connect : [relation.connect];\n connect.forEach((relation) => {\n if (isShortHand(relation) || !('position' in relation)) return;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n ids.push(...handlePrimitive({ ...position, id: position.before }));\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n ids.push(...handlePrimitive({ ...position, id: position.after }));\n }\n });\n }\n\n return ids;\n};\n\n/**\n * Iterate over all attributes of a Data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: { uid: Common.UID.Schema; locale?: string | null; isDraft?: boolean }\n) => {\n return traverseEntity(\n ({ value, attribute }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const extractedIds = extractRelationIds(value as any);\n\n // TODO: Handle morph relations (they have multiple targets)\n const target = attribute.target;\n if (!target) return;\n\n extractedIds.forEach((relation) => {\n idMap.add({\n uid: target,\n documentId: relation.id as string,\n locale: getRelationTargetLocale(relation, {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }),\n isDraft: opts.isDraft,\n });\n });\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["relation"],"mappings":";;;;AAaA,MAAM,kBAAkB,CACtB,aACe;AACf,MAAI,CAAC,UAAU;AACb,WAAO;EACT;AACI,MAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,CAAC,EAAE,IAAI,SAAA,CAAU;AAAA,EAC1B;AACI,MAAA,WAAW,QAAQ,GAAG;AAEjB,WAAA,CAAC,EAAE,IAAI,SAAS,IAAI,QAAQ,SAAS,QAAQ;AAAA,EACtD;AACI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAU,YAAY,IAAI,IAAI,EAAE,IAAI,KAAK,IAAI,IAAK;AAAA,EACzE;AAEA,SAAO;AACT;AAKA,MAAM,qBAAqB,CACzB,aACkB;AACZ,QAAA,MAAM,gBAAgB,QAAQ;AAChC,MAAA,CAAC,SAAS,QAAQ;AAAU,WAAA;AAEhC,MAAI,SAAS;AAAU,QAAI,KAAK,GAAG,gBAAgB,SAAS,GAAG,CAAC;AAChE,MAAI,gBAAgB;AAAU,QAAI,KAAK,GAAG,gBAAgB,SAAS,UAAU,CAAC;AAC9E,MAAI,aAAa,UAAU;AAEzB,QAAI,CAAC,SAAS;AAAS,aAAO;AAC9B,QAAI,KAAK,GAAG,gBAAgB,SAAS,OAAO,CAAC;AAGvC,UAAA,UAAU,MAAM,QAAQ,SAAS,OAAO,IAAI,SAAS,UAAU,CAAC,SAAS,OAAO;AAC9E,YAAA,QAAQ,CAACA,cAAa;AAC5B,UAAI,YAAYA,SAAQ,KAAK,EAAE,cAAcA;AAAW;AAElD,YAAA,EAAE,SAAaA,IAAAA;AAGrB,UAAI,UAAU,QAAQ;AAChB,YAAA,KAAK,GAAG,gBAAgB,EAAE,GAAG,UAAU,IAAI,SAAS,OAAQ,CAAA,CAAC;AAAA,MACnE;AAGA,UAAI,UAAU,OAAO;AACf,YAAA,KAAK,GAAG,gBAAgB,EAAE,GAAG,UAAU,IAAI,SAAS,MAAO,CAAA,CAAC;AAAA,MAClE;AAAA,IAAA,CACD;AAAA,EACH;AAEO,SAAA;AACT;AAMA,MAAM,iBAAiB,CACrB,OACA,MACA,SACG;AACI,SAAA;AAAA,IACL,CAAC,EAAE,OAAO,gBAAgB;AAEpB,UAAA,UAAU,SAAS,YAAY;AAC3B,cAAA,eAAe,mBAAmB,KAAY;AAGpD,cAAM,SAAS,UAAU;AACzB,YAAI,CAAC;AAAQ;AAEA,qBAAA,QAAQ,CAAC,aAAa;AACjC,gBAAM,IAAI;AAAA,YACR,KAAK;AAAA,YACL,YAAY,SAAS;AAAA,YACrB,QAAQ,wBAAwB,UAAU;AAAA,cACxC,WAAW;AAAA,cACX,WAAW,KAAK;AAAA,cAChB,cAAc,KAAK;AAAA,YAAA,CACpB;AAAA,YACD,SAAS,KAAK;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { ShortHand, LongHand, LongHandDocument } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\n/**\n * Get relation ids from primitive representation (id, id[], {id}, {id}[])\n */\nconst handlePrimitive = (\n relation: ShortHand | LongHand | ShortHand[] | LongHand[] | null | undefined | any\n): LongHandDocument[] => {\n if (!relation) {\n return []; // null\n }\n\n if (isShortHand(relation)) {\n return [{ documentId: relation }]; // id\n }\n\n if (isLongHand(relation)) {\n // { documentId, locale? }\n if ('documentId' in relation) {\n return [{ documentId: relation.documentId, locale: relation.locale }];\n }\n // { id }\n return [];\n }\n\n if (Array.isArray(relation)) {\n return relation.map((item) => (isShortHand(item) ? { documentId: item } : item)); // id[]\n }\n\n return [];\n};\n\n/**\n * Get all relations document ids from a relation input value\n */\nconst extractRelationIds = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>\n): LongHandDocument[] => {\n const ids = handlePrimitive(relation);\n if (!isObject(relation)) return ids;\n\n if ('set' in relation) ids.push(...handlePrimitive(relation.set)); // set: id[]\n if ('disconnect' in relation) ids.push(...handlePrimitive(relation.disconnect)); // disconnect: id[]\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n if (!relation.connect) return [];\n ids.push(...handlePrimitive(relation.connect));\n\n // handle positional arguments\n const connect = Array.isArray(relation.connect) ? relation.connect : [relation.connect];\n connect.forEach((relation) => {\n if (isShortHand(relation) || !('position' in relation)) return;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n ids.push(...handlePrimitive({ ...position, id: position.before }));\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n ids.push(...handlePrimitive({ ...position, id: position.after }));\n }\n });\n }\n\n return ids;\n};\n\n/**\n * Iterate over all attributes of a Data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: { uid: Common.UID.Schema; locale?: string | null; isDraft?: boolean }\n) => {\n return traverseEntity(\n ({ value, attribute }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const extractedIds = extractRelationIds(value as any);\n\n // TODO: Handle morph relations (they have multiple targets)\n const target = attribute.target;\n if (!target) return;\n\n extractedIds.forEach((relation) => {\n idMap.add({\n uid: target,\n documentId: relation.documentId,\n locale: getRelationTargetLocale(relation, {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }),\n isDraft: opts.isDraft,\n });\n });\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["relation"],"mappings":";;;;AAWA,MAAM,kBAAkB,CACtB,aACuB;AACvB,MAAI,CAAC,UAAU;AACb,WAAO;EACT;AAEI,MAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,CAAC,EAAE,YAAY,SAAA,CAAU;AAAA,EAClC;AAEI,MAAA,WAAW,QAAQ,GAAG;AAExB,QAAI,gBAAgB,UAAU;AACrB,aAAA,CAAC,EAAE,YAAY,SAAS,YAAY,QAAQ,SAAS,QAAQ;AAAA,IACtE;AAEA,WAAO;EACT;AAEI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAU,YAAY,IAAI,IAAI,EAAE,YAAY,KAAK,IAAI,IAAK;AAAA,EACjF;AAEA,SAAO;AACT;AAKA,MAAM,qBAAqB,CACzB,aACuB;AACjB,QAAA,MAAM,gBAAgB,QAAQ;AAChC,MAAA,CAAC,SAAS,QAAQ;AAAU,WAAA;AAEhC,MAAI,SAAS;AAAU,QAAI,KAAK,GAAG,gBAAgB,SAAS,GAAG,CAAC;AAChE,MAAI,gBAAgB;AAAU,QAAI,KAAK,GAAG,gBAAgB,SAAS,UAAU,CAAC;AAC9E,MAAI,aAAa,UAAU;AAEzB,QAAI,CAAC,SAAS;AAAS,aAAO;AAC9B,QAAI,KAAK,GAAG,gBAAgB,SAAS,OAAO,CAAC;AAGvC,UAAA,UAAU,MAAM,QAAQ,SAAS,OAAO,IAAI,SAAS,UAAU,CAAC,SAAS,OAAO;AAC9E,YAAA,QAAQ,CAACA,cAAa;AAC5B,UAAI,YAAYA,SAAQ,KAAK,EAAE,cAAcA;AAAW;AAElD,YAAA,EAAE,SAAaA,IAAAA;AAGrB,UAAI,UAAU,QAAQ;AAChB,YAAA,KAAK,GAAG,gBAAgB,EAAE,GAAG,UAAU,IAAI,SAAS,OAAQ,CAAA,CAAC;AAAA,MACnE;AAGA,UAAI,UAAU,OAAO;AACf,YAAA,KAAK,GAAG,gBAAgB,EAAE,GAAG,UAAU,IAAI,SAAS,MAAO,CAAA,CAAC;AAAA,MAClE;AAAA,IAAA,CACD;AAAA,EACH;AAEO,SAAA;AACT;AAMA,MAAM,iBAAiB,CACrB,OACA,MACA,SACG;AACI,SAAA;AAAA,IACL,CAAC,EAAE,OAAO,gBAAgB;AAEpB,UAAA,UAAU,SAAS,YAAY;AAC3B,cAAA,eAAe,mBAAmB,KAAY;AAGpD,cAAM,SAAS,UAAU;AACzB,YAAI,CAAC;AAAQ;AAEA,qBAAA,QAAQ,CAAC,aAAa;AACjC,gBAAM,IAAI;AAAA,YACR,KAAK;AAAA,YACL,YAAY,SAAS;AAAA,YACrB,QAAQ,wBAAwB,UAAU;AAAA,cACxC,WAAW;AAAA,cACX,WAAW,KAAK;AAAA,cAChB,cAAc,KAAK;AAAA,YAAA,CACpB;AAAA,YACD,SAAS,KAAK;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,MAAM,EAAE,MAAM,eAAe,CAAC;AAKjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AA4GrC,QAAA,MAAM,uBAAuB,UACpB,KAAK,QACN,OAAO,MAAM,EAAE,GAAG,CAAC,QACnB;IACJ,GAAG,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,qDAwCF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"data-ids.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,MAAM,EAAE,MAAM,eAAe,CAAC;AAKjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AA8GrC,QAAA,MAAM,uBAAuB,UACpB,KAAK,QACN,OAAO,MAAM,EAAE,GAAG,CAAC,QACnB;IACJ,GAAG,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,qDAwCF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const strapiUtils = require("@strapi/utils");
4
3
  const _ = require("lodash/fp");
4
+ const strapiUtils = require("@strapi/utils");
5
5
  const data = require("../utils/data.js");
6
6
  const i18n = require("../utils/i18n.js");
7
7
  const isNumeric = (value) => {
8
+ if (Array.isArray(value))
9
+ return false;
8
10
  const parsed = parseInt(value, 10);
9
11
  return !Number.isNaN(parsed);
10
12
  };
@@ -19,12 +21,12 @@ const transformPrimitive = (relation, getId) => {
19
21
  return getId(relation);
20
22
  }
21
23
  if (data.isLongHand(relation)) {
22
- if (isNumeric(relation.id))
24
+ if (!("documentId" in relation))
23
25
  return relation;
24
- const id = getId(relation.id, relation.locale);
25
- if (!id)
26
+ const entryId = getId(relation.documentId, relation.locale);
27
+ if (!entryId)
26
28
  return void 0;
27
- return { ...relation, id };
29
+ return { ...relation, id: entryId };
28
30
  }
29
31
  if (Array.isArray(relation)) {
30
32
  return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean);
@@ -50,11 +52,11 @@ const transformRelationIdsVisitor = (relation, getId) => {
50
52
  return relation2;
51
53
  const { position } = relation2;
52
54
  if (position?.before) {
53
- const { id } = transformPrimitive({ ...position, id: position.before }, getId);
55
+ const { id } = transformPrimitive({ ...position, documentId: position.before }, getId);
54
56
  position.before = id;
55
57
  }
56
58
  if (position?.after) {
57
- const { id } = transformPrimitive({ ...position, id: position.after }, getId);
59
+ const { id } = transformPrimitive({ ...position, documentId: position.after }, getId);
58
60
  position.after = id;
59
61
  }
60
62
  return relation2;
@@ -88,7 +90,7 @@ const transformDataIdsVisitor = (idMap, data2, opts) => {
88
90
  uid: target,
89
91
  documentId,
90
92
  locale: i18n.getRelationTargetLocale(
91
- { id: documentId, locale },
93
+ { documentId, locale },
92
94
  {
93
95
  targetUid: target,
94
96
  sourceUid: opts.uid,
@@ -101,7 +103,7 @@ const transformDataIdsVisitor = (idMap, data2, opts) => {
101
103
  return entryId;
102
104
  if (opts.allowMissingId)
103
105
  return null;
104
- throw new Error(`Document with id "${documentId}" not found`);
106
+ throw new strapiUtils.errors.ValidationError(`Document with id "${documentId}" not found`);
105
107
  };
106
108
  const newRelation = transformRelationIdsVisitor(value, getId);
107
109
  set(key, newRelation);
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { isObject, isNil } from 'lodash/fp';\nimport { ShortHand, LongHand, ID, GetId } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\nconst isNumeric = (value: any): value is number => {\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst transformPrimitive = <T extends ShortHand | LongHand>(\n relation: T | T[] | null | undefined,\n getId: GetId\n): T | T[] | undefined => {\n // If id value is a number, return it as is, it's already an entry id\n if (isNumeric(relation)) {\n return relation;\n }\n\n // null\n if (isNil(relation)) {\n return relation as T | undefined;\n }\n\n // id\n if (isShortHand(relation)) {\n return getId(relation) as T;\n }\n\n // { id }\n if (isLongHand(relation)) {\n // It's already an entry id\n if (isNumeric(relation.id)) return relation;\n\n // @ts-expect-error - TODO: Add relation type\n const id = getId(relation.id, relation.locale) as T;\n\n // If the id is not found, return undefined\n if (!id) return undefined;\n\n return { ...(relation as object), id } as T;\n }\n\n // id[]\n if (Array.isArray(relation)) {\n return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean) as T[];\n }\n return undefined;\n};\n\nconst transformRelationIdsVisitor = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>,\n getId: GetId\n): EntityService.Params.Attribute.RelationInputValue<T> => {\n const map = transformPrimitive(relation as any, getId);\n if (map) return map;\n\n if (!isObject(relation)) return relation;\n\n // set: id[]\n // what if result of mapPrimitive is undefined?\n if ('set' in relation) {\n relation.set = transformPrimitive(relation.set as any, getId);\n }\n if ('disconnect' in relation) {\n relation.disconnect = transformPrimitive(relation.disconnect as any, getId);\n }\n\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n relation.connect = transformPrimitive(relation.connect as any, getId);\n\n const mapPosition = (relation: any) => {\n if (isShortHand(relation) || !('position' in relation)) return relation;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n const { id } = transformPrimitive({ ...position, id: position.before }, getId);\n position.before = id;\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n const { id } = transformPrimitive({ ...position, id: position.after }, getId);\n position.after = id;\n }\n\n return relation;\n };\n\n if (Array.isArray(relation.connect)) {\n relation.connect = relation.connect.map(mapPosition);\n } else {\n relation.connect = mapPosition(relation.connect);\n }\n }\n\n return relation;\n};\n\nconst EXCLUDED_FIELDS = [\n 'createdBy',\n 'updatedBy',\n 'localizations',\n 'strapi_stage',\n 'strapi_assignee',\n];\n\nconst transformDataIdsVisitor = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: {\n uid: Common.UID.Schema;\n locale?: string | null;\n isDraft?: boolean;\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n }\n) => {\n return traverseEntity(\n ({ key, value, attribute }, { set }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const target = attribute.target;\n // TODO: Handle polymorphic relations\n if (!target) return;\n // TODO: Handle this differently\n if (EXCLUDED_FIELDS.includes(key)) return;\n\n const getId = (documentId: ID, locale?: string): ID | null => {\n const entryId = idMap.get({\n uid: target,\n documentId: documentId as string,\n locale: getRelationTargetLocale(\n { id: documentId, locale },\n {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }\n ),\n isDraft: opts.isDraft,\n });\n\n if (entryId) return entryId;\n if (opts.allowMissingId) return null;\n\n throw new Error(`Document with id \"${documentId}\" not found`);\n };\n\n const newRelation = transformRelationIdsVisitor(value as any, getId);\n set(key, newRelation as any);\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["isNil","isShortHand","isLongHand","isObject","relation","data","traverseEntity","getRelationTargetLocale"],"mappings":";;;;;;AAQA,MAAM,YAAY,CAAC,UAAgC;AAC3C,QAAA,SAAS,SAAS,OAAO,EAAE;AAC1B,SAAA,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEA,MAAM,qBAAqB,CACzB,UACA,UACwB;AAEpB,MAAA,UAAU,QAAQ,GAAG;AAChB,WAAA;AAAA,EACT;AAGI,MAAAA,EAAAA,MAAM,QAAQ,GAAG;AACZ,WAAA;AAAA,EACT;AAGI,MAAAC,KAAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,MAAM,QAAQ;AAAA,EACvB;AAGI,MAAAC,KAAAA,WAAW,QAAQ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,IAAA,OAC9C;AACI,eAAA,UAAU,YAAY,SAAS,OAAO;AAAA,IACjD;AAAA,EACF;AAEO,SAAA;AACT;AAEA,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,0BAA0B,CAC9B,OACAC,OACA,SAMG;AACI,SAAAC,YAAA;AAAA,IACL,CAAC,EAAE,KAAK,OAAO,aAAa,EAAE,UAAU;AAElC,UAAA,UAAU,SAAS,YAAY;AACjC,cAAM,SAAS,UAAU;AAEzB,YAAI,CAAC;AAAQ;AAET,YAAA,gBAAgB,SAAS,GAAG;AAAG;AAE7B,cAAA,QAAQ,CAAC,YAAgB,WAA+B;AACtD,gBAAA,UAAU,MAAM,IAAI;AAAA,YACxB,KAAK;AAAA,YACL;AAAA,YACA,QAAQC,KAAA;AAAA,cACN,EAAE,IAAI,YAAY,OAAO;AAAA,cACzB;AAAA,gBACE,WAAW;AAAA,gBACX,WAAW,KAAK;AAAA,gBAChB,cAAc,KAAK;AAAA,cACrB;AAAA,YACF;AAAA,YACA,SAAS,KAAK;AAAA,UAAA,CACf;AAEG,cAAA;AAAgB,mBAAA;AACpB,cAAI,KAAK;AAAuB,mBAAA;AAEhC,gBAAM,IAAI,MAAM,qBAAqB,UAAU,aAAa;AAAA,QAAA;AAGxD,cAAA,cAAc,4BAA4B,OAAc,KAAK;AACnE,YAAI,KAAK,WAAkB;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpCF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { isObject, isNil } from 'lodash/fp';\n\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity, errors } from '@strapi/utils';\n\nimport { ShortHand, LongHand, ID, GetId } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst transformPrimitive = <T extends ShortHand | LongHand>(\n relation: T | T[] | null | undefined,\n getId: GetId\n): T | T[] | undefined => {\n // TODO: Remove this, we should use the long hand version with 'id' for this case\n // If id value is a number, return it as is, it's already an entry id\n if (isNumeric(relation)) {\n return relation;\n }\n\n // null\n if (isNil(relation)) {\n return relation as T | undefined;\n }\n\n // id\n if (isShortHand(relation)) {\n return getId(relation) as T;\n }\n\n // { id }\n if (isLongHand(relation)) {\n // If the id is already an entry id, return it as is\n if (!('documentId' in relation)) return relation;\n\n // @ts-expect-error - TODO: Add relation type\n const entryId = getId(relation.documentId, relation.locale) as T;\n\n // If the id is not found, return undefined\n if (!entryId) return undefined;\n\n return { ...(relation as object), id: entryId } as T;\n }\n\n // id[]\n if (Array.isArray(relation)) {\n return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean) as T[];\n }\n return undefined;\n};\n\nconst transformRelationIdsVisitor = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>,\n getId: GetId\n): EntityService.Params.Attribute.RelationInputValue<T> => {\n const map = transformPrimitive(relation as any, getId);\n if (map) return map;\n\n if (!isObject(relation)) return relation;\n\n // set: id[]\n // what if result of mapPrimitive is undefined?\n if ('set' in relation) {\n relation.set = transformPrimitive(relation.set as any, getId);\n }\n if ('disconnect' in relation) {\n relation.disconnect = transformPrimitive(relation.disconnect as any, getId);\n }\n\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n relation.connect = transformPrimitive(relation.connect as any, getId);\n\n const mapPosition = (relation: any) => {\n if (isShortHand(relation) || !('position' in relation)) return relation;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n const { id } = transformPrimitive({ ...position, documentId: position.before }, getId);\n position.before = id;\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n const { id } = transformPrimitive({ ...position, documentId: position.after }, getId);\n position.after = id;\n }\n\n return relation;\n };\n\n if (Array.isArray(relation.connect)) {\n relation.connect = relation.connect.map(mapPosition);\n } else {\n relation.connect = mapPosition(relation.connect);\n }\n }\n\n return relation;\n};\n\nconst EXCLUDED_FIELDS = [\n 'createdBy',\n 'updatedBy',\n 'localizations',\n 'strapi_stage',\n 'strapi_assignee',\n];\n\nconst transformDataIdsVisitor = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: {\n uid: Common.UID.Schema;\n locale?: string | null;\n isDraft?: boolean;\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n }\n) => {\n return traverseEntity(\n ({ key, value, attribute }, { set }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const target = attribute.target;\n // TODO: Handle polymorphic relations\n if (!target) return;\n // TODO: Handle this differently\n if (EXCLUDED_FIELDS.includes(key)) return;\n\n const getId = (documentId: ID, locale?: string): ID | null => {\n const entryId = idMap.get({\n uid: target,\n documentId,\n locale: getRelationTargetLocale(\n { documentId, locale },\n {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }\n ),\n isDraft: opts.isDraft,\n });\n\n if (entryId) return entryId;\n if (opts.allowMissingId) return null;\n\n throw new errors.ValidationError(`Document with id \"${documentId}\" not found`);\n };\n\n const newRelation = transformRelationIdsVisitor(value as any, getId);\n set(key, newRelation as any);\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["isNil","isShortHand","isLongHand","isObject","relation","data","traverseEntity","getRelationTargetLocale","errors"],"mappings":";;;;;;AAUA,MAAM,YAAY,CAAC,UAAgC;AAC7C,MAAA,MAAM,QAAQ,KAAK;AAAU,WAAA;AAC3B,QAAA,SAAS,SAAS,OAAO,EAAE;A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;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpCH;AAAA,EAAA;AAEJ;;"}
@@ -1,8 +1,10 @@
1
- import { traverseEntity } from "@strapi/utils";
2
1
  import { isObject, isNil } from "lodash/fp";
2
+ import { traverseEntity, errors } from "@strapi/utils";
3
3
  import { isShortHand, isLongHand } from "../utils/data.mjs";
4
4
  import { getRelationTargetLocale } from "../utils/i18n.mjs";
5
5
  const isNumeric = (value) => {
6
+ if (Array.isArray(value))
7
+ return false;
6
8
  const parsed = parseInt(value, 10);
7
9
  return !Number.isNaN(parsed);
8
10
  };
@@ -17,12 +19,12 @@ const transformPrimitive = (relation, getId) => {
17
19
  return getId(relation);
18
20
  }
19
21
  if (isLongHand(relation)) {
20
- if (isNumeric(relation.id))
22
+ if (!("documentId" in relation))
21
23
  return relation;
22
- const id = getId(relation.id, relation.locale);
23
- if (!id)
24
+ const entryId = getId(relation.documentId, relation.locale);
25
+ if (!entryId)
24
26
  return void 0;
25
- return { ...relation, id };
27
+ return { ...relation, id: entryId };
26
28
  }
27
29
  if (Array.isArray(relation)) {
28
30
  return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean);
@@ -48,11 +50,11 @@ const transformRelationIdsVisitor = (relation, getId) => {
48
50
  return relation2;
49
51
  const { position } = relation2;
50
52
  if (position?.before) {
51
- const { id } = transformPrimitive({ ...position, id: position.before }, getId);
53
+ const { id } = transformPrimitive({ ...position, documentId: position.before }, getId);
52
54
  position.before = id;
53
55
  }
54
56
  if (position?.after) {
55
- const { id } = transformPrimitive({ ...position, id: position.after }, getId);
57
+ const { id } = transformPrimitive({ ...position, documentId: position.after }, getId);
56
58
  position.after = id;
57
59
  }
58
60
  return relation2;
@@ -86,7 +88,7 @@ const transformDataIdsVisitor = (idMap, data, opts) => {
86
88
  uid: target,
87
89
  documentId,
88
90
  locale: getRelationTargetLocale(
89
- { id: documentId, locale },
91
+ { documentId, locale },
90
92
  {
91
93
  targetUid: target,
92
94
  sourceUid: opts.uid,
@@ -99,7 +101,7 @@ const transformDataIdsVisitor = (idMap, data, opts) => {
99
101
  return entryId;
100
102
  if (opts.allowMissingId)
101
103
  return null;
102
- throw new Error(`Document with id "${documentId}" not found`);
104
+ throw new errors.ValidationError(`Document with id "${documentId}" not found`);
103
105
  };
104
106
  const newRelation = transformRelationIdsVisitor(value, getId);
105
107
  set(key, newRelation);
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { isObject, isNil } from 'lodash/fp';\nimport { ShortHand, LongHand, ID, GetId } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\nconst isNumeric = (value: any): value is number => {\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst transformPrimitive = <T extends ShortHand | LongHand>(\n relation: T | T[] | null | undefined,\n getId: GetId\n): T | T[] | undefined => {\n // If id value is a number, return it as is, it's already an entry id\n if (isNumeric(relation)) {\n return relation;\n }\n\n // null\n if (isNil(relation)) {\n return relation as T | undefined;\n }\n\n // id\n if (isShortHand(relation)) {\n return getId(relation) as T;\n }\n\n // { id }\n if (isLongHand(relation)) {\n // It's already an entry id\n if (isNumeric(relation.id)) return relation;\n\n // @ts-expect-error - TODO: Add relation type\n const id = getId(relation.id, relation.locale) as T;\n\n // If the id is not found, return undefined\n if (!id) return undefined;\n\n return { ...(relation as object), id } as T;\n }\n\n // id[]\n if (Array.isArray(relation)) {\n return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean) as T[];\n }\n return undefined;\n};\n\nconst transformRelationIdsVisitor = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>,\n getId: GetId\n): EntityService.Params.Attribute.RelationInputValue<T> => {\n const map = transformPrimitive(relation as any, getId);\n if (map) return map;\n\n if (!isObject(relation)) return relation;\n\n // set: id[]\n // what if result of mapPrimitive is undefined?\n if ('set' in relation) {\n relation.set = transformPrimitive(relation.set as any, getId);\n }\n if ('disconnect' in relation) {\n relation.disconnect = transformPrimitive(relation.disconnect as any, getId);\n }\n\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n relation.connect = transformPrimitive(relation.connect as any, getId);\n\n const mapPosition = (relation: any) => {\n if (isShortHand(relation) || !('position' in relation)) return relation;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n const { id } = transformPrimitive({ ...position, id: position.before }, getId);\n position.before = id;\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n const { id } = transformPrimitive({ ...position, id: position.after }, getId);\n position.after = id;\n }\n\n return relation;\n };\n\n if (Array.isArray(relation.connect)) {\n relation.connect = relation.connect.map(mapPosition);\n } else {\n relation.connect = mapPosition(relation.connect);\n }\n }\n\n return relation;\n};\n\nconst EXCLUDED_FIELDS = [\n 'createdBy',\n 'updatedBy',\n 'localizations',\n 'strapi_stage',\n 'strapi_assignee',\n];\n\nconst transformDataIdsVisitor = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: {\n uid: Common.UID.Schema;\n locale?: string | null;\n isDraft?: boolean;\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n }\n) => {\n return traverseEntity(\n ({ key, value, attribute }, { set }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const target = attribute.target;\n // TODO: Handle polymorphic relations\n if (!target) return;\n // TODO: Handle this differently\n if (EXCLUDED_FIELDS.includes(key)) return;\n\n const getId = (documentId: ID, locale?: string): ID | null => {\n const entryId = idMap.get({\n uid: target,\n documentId: documentId as string,\n locale: getRelationTargetLocale(\n { id: documentId, locale },\n {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }\n ),\n isDraft: opts.isDraft,\n });\n\n if (entryId) return entryId;\n if (opts.allowMissingId) return null;\n\n throw new Error(`Document with id \"${documentId}\" not found`);\n };\n\n const newRelation = transformRelationIdsVisitor(value as any, getId);\n set(key, newRelation as any);\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["relation"],"mappings":";;;;AAQA,MAAM,YAAY,CAAC,UAAgC;AAC3C,QAAA,SAAS,SAAS,OAAO,EAAE;AAC1B,SAAA,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEA,MAAM,qBAAqB,CACzB,UACA,UACwB;AAEpB,MAAA,UAAU,QAAQ,GAAG;AAChB,WAAA;AAAA,EACT;AAGI,MAAA,MAAM,QAAQ,GAAG;AACZ,WAAA;AAAA,EACT;AAGI,MAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,MAAM,QAAQ;AAAA,EACvB;AAGI,MAAA,WAAW,QAAQ,GAAG;AAEpB,QAAA,UAAU,SAAS,EAAE;AAAU,aAAA;AAGnC,UAAM,KAAK,MAAM,SAAS,IAAI,SAAS,MAAM;AAG7C,QAAI,CAAC;AAAW,aAAA;AAET,WAAA,EAAE,GAAI,UAAqB;EACpC;AAGI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAS,mBAAmB,MAAM,KAAK,CAAC,EAAE,OAAO,OAAO;AAAA,EAC/E;AACO,SAAA;AACT;AAEA,MAAM,8BAA8B,CAClC,UACA,UACyD;AACnD,QAAA,MAAM,mBAAmB,UAAiB,KAAK;AACjD,MAAA;AAAY,WAAA;AAEZ,MAAA,CAAC,SAAS,QAAQ;AAAU,WAAA;AAIhC,MAAI,SAAS,UAAU;AACrB,aAAS,MAAM,mBAAmB,SAAS,KAAY,KAAK;AAAA,EAC9D;AACA,MAAI,gBAAgB,UAAU;AAC5B,aAAS,aAAa,mBAAmB,SAAS,YAAmB,KAAK;AAAA,EAC5E;AAEA,MAAI,aAA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A,YACA,SAAS,KAAK;AAAA,UAAA,CACf;AAEG,cAAA;AAAgB,mBAAA;AACpB,cAAI,KAAK;AAAuB,mBAAA;AAEhC,gBAAM,IAAI,MAAM,qBAAqB,UAAU,aAAa;AAAA,QAAA;AAGxD,cAAA,cAAc,4BAA4B,OAAc,KAAK;AACnE,YAAI,KAAK,WAAkB;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { isObject, isNil } from 'lodash/fp';\n\nimport { EntityService, Attribute, Common } from '@strapi/types';\nimport { traverseEntity, errors } from '@strapi/utils';\n\nimport { ShortHand, LongHand, ID, GetId } from '../utils/types';\nimport { isShortHand, isLongHand } from '../utils/data';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\n\nconst isNumeric = (value: any): value is number => {\n if (Array.isArray(value)) return false; // Handle [1, 'docId'] case\n const parsed = parseInt(value, 10);\n return !Number.isNaN(parsed);\n};\n\nconst transformPrimitive = <T extends ShortHand | LongHand>(\n relation: T | T[] | null | undefined,\n getId: GetId\n): T | T[] | undefined => {\n // TODO: Remove this, we should use the long hand version with 'id' for this case\n // If id value is a number, return it as is, it's already an entry id\n if (isNumeric(relation)) {\n return relation;\n }\n\n // null\n if (isNil(relation)) {\n return relation as T | undefined;\n }\n\n // id\n if (isShortHand(relation)) {\n return getId(relation) as T;\n }\n\n // { id }\n if (isLongHand(relation)) {\n // If the id is already an entry id, return it as is\n if (!('documentId' in relation)) return relation;\n\n // @ts-expect-error - TODO: Add relation type\n const entryId = getId(relation.documentId, relation.locale) as T;\n\n // If the id is not found, return undefined\n if (!entryId) return undefined;\n\n return { ...(relation as object), id: entryId } as T;\n }\n\n // id[]\n if (Array.isArray(relation)) {\n return relation.map((item) => transformPrimitive(item, getId)).filter(Boolean) as T[];\n }\n return undefined;\n};\n\nconst transformRelationIdsVisitor = <T extends Attribute.RelationKind.Any>(\n relation: EntityService.Params.Attribute.RelationInputValue<T>,\n getId: GetId\n): EntityService.Params.Attribute.RelationInputValue<T> => {\n const map = transformPrimitive(relation as any, getId);\n if (map) return map;\n\n if (!isObject(relation)) return relation;\n\n // set: id[]\n // what if result of mapPrimitive is undefined?\n if ('set' in relation) {\n relation.set = transformPrimitive(relation.set as any, getId);\n }\n if ('disconnect' in relation) {\n relation.disconnect = transformPrimitive(relation.disconnect as any, getId);\n }\n\n if ('connect' in relation) {\n // connect: id[] | { id } | ...\n relation.connect = transformPrimitive(relation.connect as any, getId);\n\n const mapPosition = (relation: any) => {\n if (isShortHand(relation) || !('position' in relation)) return relation;\n\n const { position } = relation;\n\n // { connect: { id: id, position: { before: id } } }\n if (position?.before) {\n const { id } = transformPrimitive({ ...position, documentId: position.before }, getId);\n position.before = id;\n }\n\n // { connect: { id: id, position: { after: id } } }\n if (position?.after) {\n const { id } = transformPrimitive({ ...position, documentId: position.after }, getId);\n position.after = id;\n }\n\n return relation;\n };\n\n if (Array.isArray(relation.connect)) {\n relation.connect = relation.connect.map(mapPosition);\n } else {\n relation.connect = mapPosition(relation.connect);\n }\n }\n\n return relation;\n};\n\nconst EXCLUDED_FIELDS = [\n 'createdBy',\n 'updatedBy',\n 'localizations',\n 'strapi_stage',\n 'strapi_assignee',\n];\n\nconst transformDataIdsVisitor = (\n idMap: IdMap,\n data: Record<string, any>,\n opts: {\n uid: Common.UID.Schema;\n locale?: string | null;\n isDraft?: boolean;\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n }\n) => {\n return traverseEntity(\n ({ key, value, attribute }, { set }) => {\n // Find relational attributes, and return the document ids\n if (attribute.type === 'relation') {\n const target = attribute.target;\n // TODO: Handle polymorphic relations\n if (!target) return;\n // TODO: Handle this differently\n if (EXCLUDED_FIELDS.includes(key)) return;\n\n const getId = (documentId: ID, locale?: string): ID | null => {\n const entryId = idMap.get({\n uid: target,\n documentId,\n locale: getRelationTargetLocale(\n { documentId, locale },\n {\n targetUid: target as Common.UID.Schema,\n sourceUid: opts.uid,\n sourceLocale: opts.locale,\n }\n ),\n isDraft: opts.isDraft,\n });\n\n if (entryId) return entryId;\n if (opts.allowMissingId) return null;\n\n throw new errors.ValidationError(`Document with id \"${documentId}\" not found`);\n };\n\n const newRelation = transformRelationIdsVisitor(value as any, getId);\n set(key, newRelation as any);\n }\n },\n { schema: strapi.getModel(opts.uid) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["relation"],"mappings":";;;;AAUA,MAAM,YAAY,CAAC,UAAgC;AAC7C,MAAA,MAAM,QAAQ,KAAK;AAAU,WAAA;AAC3B,QAAA,SAAS,SAAS,OAAO,EAAE;AAC1B,SAAA,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEA,MAAM,qBAAqB,CACzB,UACA,UACwB;AAGpB,MAAA,UAAU,QAAQ,GAAG;AAChB,WAAA;AAAA,EACT;AAGI,MAAA,MAAM,QAAQ,GAAG;AACZ,WAAA;AAAA,EACT;AAGI,MAAA,YAAY,QAAQ,GAAG;AACzB,WAAO,MAAM,QAAQ;AAAA,EACvB;AAGI,MAAA,WAAW,QAAQ,GAAG;AAExB,QAAI,EAAE,gBAAgB;AAAkB,aAAA;AAGxC,UAAM,UAAU,MAAM,SAAS,YAAY,SAAS,MAAM;AAG1D,QAAI,CAAC;AAAgB,aAAA;AAErB,WAAO,EAAE,GAAI,UAAqB,IAAI,QAAQ;AAAA,EAChD;AAGI,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,SAAS,IAAI,CAAC,SAAS,mBAAmB,MAAM,KAAK,CAAC,EAAE,OAAO,OAAO;AAAA,EAC/E;AACO,SAAA;AACT;AAEA,MAAM,8BAA8B,CAClC,UACA,UACyD;AACnD,QAAA,MAAM,mBAAmB,UAAiB,KAAK;AACjD,MAAA;AAAY,WAAA;AAEZ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;AACtD,gBAAA,UAAU,MAAM,IAAI;AAAA,YACxB,KAAK;AAAA,YACL;AAAA,YACA,QAAQ;AAAA,cACN,EAAE,YAAY,OAAO;AAAA,cACrB;AAAA,gBACE,WAAW;AAAA,gBACX,WAAW,KAAK;AAAA,gBAChB,cAAc,KAAK;AAAA,cACrB;AAAA,YACF;AAAA,YACA,SAAS,KAAK;AAAA,UAAA,CACf;AAEG,cAAA;AAAgB,mBAAA;AACpB,cAAI,KAAK;AAAuB,mBAAA;AAEhC,gBAAM,IAAI,OAAO,gBAAgB,qBAAqB,UAAU,aAAa;AAAA,QAAA;AAGzE,cAAA,cAAc,4BAA4B,OAAc,KAAK;AACnE,YAAI,KAAK,WAAkB;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE;AAAA,IACpC;AAAA,EAAA;AAEJ;"}
@@ -1,6 +1,4 @@
1
- import { ID } from './types';
1
+ import { ID, LongHand } from './types';
2
2
  export declare const isShortHand: (relation: any) => relation is ID;
3
- export declare const isLongHand: (relation: any) => relation is {
4
- id: ID;
5
- };
3
+ export declare const isLongHand: (relation: any) => relation is LongHand;
6
4
  //# sourceMappingURL=data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,WAAW,aAAc,GAAG,mBAExC,CAAC;AAEF,eAAO,MAAM,UAAU,aAAc,GAAG;QAAqB,EAAE;CAE9D,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,WAAW,aAAc,GAAG,mBAExC,CAAC;AAEF,eAAO,MAAM,UAAU,aAAc,GAAG,yBAEvC,CAAC"}
@@ -5,7 +5,7 @@ const isShortHand = (relation) => {
5
5
  return typeof relation === "string" || typeof relation === "number";
6
6
  };
7
7
  const isLongHand = (relation) => {
8
- return _.isObject(relation) && "id" in relation;
8
+ return _.isObject(relation) && ("id" in relation || "documentId" in relation);
9
9
  };
10
10
  exports.isLongHand = isLongHand;
11
11
  exports.isShortHand = isShortHand;
@@ -1 +1 @@
1
- {"version":3,"file":"data.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { ID } from './types';\n\nexport const isShortHand = (relation: any): relation is ID => {\n return typeof relation === 'string' || typeof relation === 'number';\n};\n\nexport const isLongHand = (relation: any): relation is { id: ID } => {\n return isObject(relation) && 'id' in relation;\n};\n"],"names":["isObject"],"mappings":";;;AAGa,MAAA,cAAc,CAAC,aAAkC;AAC5D,SAAO,OAAO,aAAa,YAAY,OAAO,aAAa;AAC7D;AAEa,MAAA,aAAa,CAAC,aAA0C;AAC5D,SAAAA,WAAS,QAAQ,KAAK,QAAQ;AACvC;;;"}
1
+ {"version":3,"file":"data.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { ID, LongHand } from './types';\n\nexport const isShortHand = (relation: any): relation is ID => {\n return typeof relation === 'string' || typeof relation === 'number';\n};\n\nexport const isLongHand = (relation: any): relation is LongHand => {\n return isObject(relation) && ('id' in relation || 'documentId' in relation);\n};\n"],"names":["isObject"],"mappings":";;;AAGa,MAAA,cAAc,CAAC,aAAkC;AAC5D,SAAO,OAAO,aAAa,YAAY,OAAO,aAAa;AAC7D;AAEa,MAAA,aAAa,CAAC,aAAwC;AACjE,SAAOA,EAAAA,SAAS,QAAQ,MAAM,QAAQ,YAAY,gBAAgB;AACpE;;;"}
@@ -3,7 +3,7 @@ const isShortHand = (relation) => {
3
3
  return typeof relation === "string" || typeof relation === "number";
4
4
  };
5
5
  const isLongHand = (relation) => {
6
- return isObject(relation) && "id" in relation;
6
+ return isObject(relation) && ("id" in relation || "documentId" in relation);
7
7
  };
8
8
  export {
9
9
  isLongHand,
@@ -1 +1 @@
1
- {"version":3,"file":"data.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { ID } from './types';\n\nexport const isShortHand = (relation: any): relation is ID => {\n return typeof relation === 'string' || typeof relation === 'number';\n};\n\nexport const isLongHand = (relation: any): relation is { id: ID } => {\n return isObject(relation) && 'id' in relation;\n};\n"],"names":[],"mappings":";AAGa,MAAA,cAAc,CAAC,aAAkC;AAC5D,SAAO,OAAO,aAAa,YAAY,OAAO,aAAa;AAC7D;AAEa,MAAA,aAAa,CAAC,aAA0C;AAC5D,SAAA,SAAS,QAAQ,KAAK,QAAQ;AACvC;"}
1
+ {"version":3,"file":"data.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/data.ts"],"sourcesContent":["import { isObject } from 'lodash/fp';\nimport { ID, LongHand } from './types';\n\nexport const isShortHand = (relation: any): relation is ID => {\n return typeof relation === 'string' || typeof relation === 'number';\n};\n\nexport const isLongHand = (relation: any): relation is LongHand => {\n return isObject(relation) && ('id' in relation || 'documentId' in relation);\n};\n"],"names":[],"mappings":";AAGa,MAAA,cAAc,CAAC,aAAkC;AAC5D,SAAO,OAAO,aAAa,YAAY,OAAO,aAAa;AAC7D;AAEa,MAAA,aAAa,CAAC,aAAwC;AACjE,SAAO,SAAS,QAAQ,MAAM,QAAQ,YAAY,gBAAgB;AACpE;"}
@@ -1,8 +1,8 @@
1
1
  import { Common } from '@strapi/types';
2
- import { LongHand } from './types';
2
+ import { LongHandDocument } from './types';
3
3
  export declare const isLocalizedContentType: (uid: Common.UID.Schema) => any;
4
4
  export declare const getDefaultLocale: () => string;
5
- export declare const getRelationTargetLocale: (relation: LongHand, opts: {
5
+ export declare const getRelationTargetLocale: (relation: LongHandDocument, opts: {
6
6
  targetUid: Common.UID.Schema;
7
7
  sourceUid: Common.UID.Schema;
8
8
  sourceLocale?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,eAAO,MAAM,sBAAsB,QAAS,OAAO,GAAG,CAAC,MAAM,QAG5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAI5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,QAAQ,QACZ;IACJ,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,kBAuBF,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,sBAAsB,QAAS,OAAO,GAAG,CAAC,MAAM,QAG5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAI5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,gBAAgB,QACpB;IACJ,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,kBAuBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { LongHand } from './types';\n\nexport const isLocalizedContentType = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n // TODO: Fix this\n // return strapi.plugin('i18n').service('locales').getDefaultLocale();\n return 'en';\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHand,\n opts: {\n targetUid: Common.UID.Schema;\n sourceUid: Common.UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const defaultLocale = getDefaultLocale();\n const targetLocale = relation.locale || opts.sourceLocale || defaultLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Locale validations\n if (isSourceLocalized && isTargetLocalized) {\n // Check the targetLocale matches\n if (targetLocale !== opts.sourceLocale) {\n throw new errors.ValidationError(\n `Relation locale does not match the source locale ${JSON.stringify(relation)}`\n );\n }\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":["errors"],"mappings":";;;AAIa,MAAA,yBAAyB,CAAC,QAA2B;AAC1D,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AAG7B,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACH,QAAM,gBAAgB;AACtB,QAAM,eAAe,SAAS,UAAU,KAAK,gBAAgB;AAEvD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAEtC,QAAA,iBAAiB,KAAK,cAAc;AACtC,YAAM,IAAIA,YAAO,OAAA;AAAA,QACf,oDAAoD,KAAK,UAAU,QAAQ,CAAC;AAAA,MAAA;AAAA,IAEhF;AAAA,EACF;AAEA,MAAI,mBAAmB;AACd,WAAA;AAAA,EACT;AAEO,SAAA;AACT;;;;"}
1
+ {"version":3,"file":"i18n.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n // TODO: Fix this\n // return strapi.plugin('i18n').service('locales').getDefaultLocale();\n return 'en';\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: Common.UID.Schema;\n sourceUid: Common.UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const defaultLocale = getDefaultLocale();\n const targetLocale = relation.locale || opts.sourceLocale || defaultLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Locale validations\n if (isSourceLocalized && isTargetLocalized) {\n // Check the targetLocale matches\n if (targetLocale !== opts.sourceLocale) {\n throw new errors.ValidationError(\n `Relation locale does not match the source locale ${JSON.stringify(relation)}`\n );\n }\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":["errors"],"mappings":";;;AAIa,MAAA,yBAAyB,CAAC,QAA2B;AAC1D,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AAG7B,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACH,QAAM,gBAAgB;AACtB,QAAM,eAAe,SAAS,UAAU,KAAK,gBAAgB;AAEvD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAEtC,QAAA,iBAAiB,KAAK,cAAc;AACtC,YAAM,IAAIA,YAAO,OAAA;AAAA,QACf,oDAAoD,KAAK,UAAU,QAAQ,CAAC;AAAA,MAAA;AAAA,IAEhF;AAAA,EACF;AAEA,MAAI,mBAAmB;AACd,WAAA;AAAA,EACT;AAEO,SAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { LongHand } from './types';\n\nexport const isLocalizedContentType = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n // TODO: Fix this\n // return strapi.plugin('i18n').service('locales').getDefaultLocale();\n return 'en';\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHand,\n opts: {\n targetUid: Common.UID.Schema;\n sourceUid: Common.UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const defaultLocale = getDefaultLocale();\n const targetLocale = relation.locale || opts.sourceLocale || defaultLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Locale validations\n if (isSourceLocalized && isTargetLocalized) {\n // Check the targetLocale matches\n if (targetLocale !== opts.sourceLocale) {\n throw new errors.ValidationError(\n `Relation locale does not match the source locale ${JSON.stringify(relation)}`\n );\n }\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":";AAIa,MAAA,yBAAyB,CAAC,QAA2B;AAC1D,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AAG7B,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACH,QAAM,gBAAgB;AACtB,QAAM,eAAe,SAAS,UAAU,KAAK,gBAAgB;AAEvD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAEtC,QAAA,iBAAiB,KAAK,cAAc;AACtC,YAAM,IAAI,OAAO;AAAA,QACf,oDAAoD,KAAK,UAAU,QAAQ,CAAC;AAAA,MAAA;AAAA,IAEhF;AAAA,EACF;AAEA,MAAI,mBAAmB;AACd,WAAA;AAAA,EACT;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"i18n.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { Common } from '@strapi/types';\nimport { errors } from '@strapi/utils';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: Common.UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n // TODO: Fix this\n // return strapi.plugin('i18n').service('locales').getDefaultLocale();\n return 'en';\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: Common.UID.Schema;\n sourceUid: Common.UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const defaultLocale = getDefaultLocale();\n const targetLocale = relation.locale || opts.sourceLocale || defaultLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Locale validations\n if (isSourceLocalized && isTargetLocalized) {\n // Check the targetLocale matches\n if (targetLocale !== opts.sourceLocale) {\n throw new errors.ValidationError(\n `Relation locale does not match the source locale ${JSON.stringify(relation)}`\n );\n }\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":";AAIa,MAAA,yBAAyB,CAAC,QAA2B;AAC1D,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AAG7B,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACH,QAAM,gBAAgB;AACtB,QAAM,eAAe,SAAS,UAAU,KAAK,gBAAgB;AAEvD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAEtC,QAAA,iBAAiB,KAAK,cAAc;AACtC,YAAM,IAAI,OAAO;AAAA,QACf,oDAAoD,KAAK,UAAU,QAAQ,CAAC;AAAA,MAAA;AAAA,IAEhF;AAAA,EACF;AAEA,MAAI,mBAAmB;AACd,WAAA;AAAA,EACT;AAEO,SAAA;AACT;"}
@@ -1,8 +1,12 @@
1
1
  export type ID = string | number;
2
2
  export type ShortHand = ID;
3
- export type LongHand = {
3
+ export type LongHandEntity = {
4
4
  id: ID;
5
+ };
6
+ export type LongHandDocument = {
7
+ documentId: ID;
5
8
  locale?: string;
6
9
  };
10
+ export type LongHand = LongHandEntity | LongHandDocument;
7
11
  export type GetId = (relation: ID) => ID | null;
8
12
  //# sourceMappingURL=types.d.ts.map
@@ -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;AAC3B,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,EAAE,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,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,CAAA;CAAE,CAAC;AACxC,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACnE,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAEzD,MAAM,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC"}