@strapi/core 5.4.1 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/dist/Strapi.js +1 -2
  2. package/dist/Strapi.js.map +1 -1
  3. package/dist/Strapi.mjs.map +1 -1
  4. package/dist/compile.js.map +1 -1
  5. package/dist/compile.mjs.map +1 -1
  6. package/dist/configuration/config-loader.js +1 -2
  7. package/dist/configuration/config-loader.js.map +1 -1
  8. package/dist/configuration/config-loader.mjs +1 -2
  9. package/dist/configuration/config-loader.mjs.map +1 -1
  10. package/dist/configuration/get-dirs.js.map +1 -1
  11. package/dist/configuration/get-dirs.mjs.map +1 -1
  12. package/dist/configuration/index.js.map +1 -1
  13. package/dist/configuration/index.mjs.map +1 -1
  14. package/dist/configuration/urls.js.map +1 -1
  15. package/dist/configuration/urls.mjs.map +1 -1
  16. package/dist/container.js.map +1 -1
  17. package/dist/container.mjs.map +1 -1
  18. package/dist/core-api/controller/collection-type.js.map +1 -1
  19. package/dist/core-api/controller/collection-type.mjs.map +1 -1
  20. package/dist/core-api/controller/index.js.map +1 -1
  21. package/dist/core-api/controller/index.mjs.map +1 -1
  22. package/dist/core-api/controller/single-type.js.map +1 -1
  23. package/dist/core-api/controller/single-type.mjs.map +1 -1
  24. package/dist/core-api/controller/transform.js.map +1 -1
  25. package/dist/core-api/controller/transform.mjs.map +1 -1
  26. package/dist/core-api/routes/index.js.map +1 -1
  27. package/dist/core-api/routes/index.mjs.map +1 -1
  28. package/dist/core-api/service/collection-type.js.map +1 -1
  29. package/dist/core-api/service/collection-type.mjs.map +1 -1
  30. package/dist/core-api/service/core-service.js.map +1 -1
  31. package/dist/core-api/service/core-service.mjs.map +1 -1
  32. package/dist/core-api/service/index.js.map +1 -1
  33. package/dist/core-api/service/index.mjs.map +1 -1
  34. package/dist/core-api/service/pagination.js.map +1 -1
  35. package/dist/core-api/service/pagination.mjs.map +1 -1
  36. package/dist/core-api/service/single-type.js +1 -2
  37. package/dist/core-api/service/single-type.js.map +1 -1
  38. package/dist/core-api/service/single-type.mjs +1 -2
  39. package/dist/core-api/service/single-type.mjs.map +1 -1
  40. package/dist/domain/content-type/index.js.map +1 -1
  41. package/dist/domain/content-type/index.mjs.map +1 -1
  42. package/dist/domain/content-type/validator.js.map +1 -1
  43. package/dist/domain/content-type/validator.mjs.map +1 -1
  44. package/dist/domain/module/index.js.map +1 -1
  45. package/dist/domain/module/index.mjs.map +1 -1
  46. package/dist/domain/module/validation.js.map +1 -1
  47. package/dist/domain/module/validation.mjs.map +1 -1
  48. package/dist/ee/index.js.map +1 -1
  49. package/dist/ee/index.mjs.map +1 -1
  50. package/dist/ee/license.js.map +1 -1
  51. package/dist/ee/license.mjs.map +1 -1
  52. package/dist/factories.js.map +1 -1
  53. package/dist/factories.mjs.map +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/loaders/admin.js.map +1 -1
  56. package/dist/loaders/admin.mjs.map +1 -1
  57. package/dist/loaders/apis.js.map +1 -1
  58. package/dist/loaders/apis.mjs.map +1 -1
  59. package/dist/loaders/components.js.map +1 -1
  60. package/dist/loaders/components.mjs.map +1 -1
  61. package/dist/loaders/middlewares.js.map +1 -1
  62. package/dist/loaders/middlewares.mjs.map +1 -1
  63. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  64. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  65. package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
  66. package/dist/loaders/plugins/get-user-plugins-config.mjs.map +1 -1
  67. package/dist/loaders/plugins/index.js +1 -2
  68. package/dist/loaders/plugins/index.js.map +1 -1
  69. package/dist/loaders/plugins/index.mjs.map +1 -1
  70. package/dist/loaders/policies.js.map +1 -1
  71. package/dist/loaders/policies.mjs.map +1 -1
  72. package/dist/loaders/sanitizers.js.map +1 -1
  73. package/dist/loaders/sanitizers.mjs.map +1 -1
  74. package/dist/loaders/src-index.js.map +1 -1
  75. package/dist/loaders/src-index.mjs.map +1 -1
  76. package/dist/loaders/validators.js.map +1 -1
  77. package/dist/loaders/validators.mjs.map +1 -1
  78. package/dist/middlewares/body.js.map +1 -1
  79. package/dist/middlewares/body.mjs.map +1 -1
  80. package/dist/middlewares/cors.js.map +1 -1
  81. package/dist/middlewares/cors.mjs.map +1 -1
  82. package/dist/middlewares/errors.js.map +1 -1
  83. package/dist/middlewares/errors.mjs.map +1 -1
  84. package/dist/middlewares/favicon.js.map +1 -1
  85. package/dist/middlewares/favicon.mjs.map +1 -1
  86. package/dist/middlewares/index.js.map +1 -1
  87. package/dist/middlewares/logger.js.map +1 -1
  88. package/dist/middlewares/logger.mjs.map +1 -1
  89. package/dist/middlewares/powered-by.js.map +1 -1
  90. package/dist/middlewares/powered-by.mjs.map +1 -1
  91. package/dist/middlewares/public.js.map +1 -1
  92. package/dist/middlewares/public.mjs.map +1 -1
  93. package/dist/middlewares/query.js.map +1 -1
  94. package/dist/middlewares/query.mjs.map +1 -1
  95. package/dist/middlewares/response-time.js.map +1 -1
  96. package/dist/middlewares/response-time.mjs.map +1 -1
  97. package/dist/middlewares/responses.js.map +1 -1
  98. package/dist/middlewares/responses.mjs.map +1 -1
  99. package/dist/middlewares/security.js.map +1 -1
  100. package/dist/middlewares/security.mjs.map +1 -1
  101. package/dist/middlewares/session.js.map +1 -1
  102. package/dist/middlewares/session.mjs.map +1 -1
  103. package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
  104. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
  105. package/dist/migrations/draft-publish.js.map +1 -1
  106. package/dist/migrations/draft-publish.mjs.map +1 -1
  107. package/dist/migrations/i18n.js.map +1 -1
  108. package/dist/migrations/i18n.mjs.map +1 -1
  109. package/dist/migrations/index.js.map +1 -1
  110. package/dist/migrations/index.mjs.map +1 -1
  111. package/dist/providers/admin.js.map +1 -1
  112. package/dist/providers/admin.mjs.map +1 -1
  113. package/dist/providers/coreStore.js.map +1 -1
  114. package/dist/providers/coreStore.mjs.map +1 -1
  115. package/dist/providers/cron.js.map +1 -1
  116. package/dist/providers/cron.mjs.map +1 -1
  117. package/dist/providers/registries.js.map +1 -1
  118. package/dist/providers/registries.mjs.map +1 -1
  119. package/dist/providers/telemetry.js.map +1 -1
  120. package/dist/providers/telemetry.mjs.map +1 -1
  121. package/dist/providers/webhooks.js.map +1 -1
  122. package/dist/providers/webhooks.mjs.map +1 -1
  123. package/dist/registries/apis.js.map +1 -1
  124. package/dist/registries/apis.mjs.map +1 -1
  125. package/dist/registries/components.js.map +1 -1
  126. package/dist/registries/components.mjs.map +1 -1
  127. package/dist/registries/content-types.js.map +1 -1
  128. package/dist/registries/content-types.mjs.map +1 -1
  129. package/dist/registries/controllers.js.map +1 -1
  130. package/dist/registries/controllers.mjs.map +1 -1
  131. package/dist/registries/custom-fields.js.map +1 -1
  132. package/dist/registries/custom-fields.mjs.map +1 -1
  133. package/dist/registries/hooks.js.map +1 -1
  134. package/dist/registries/hooks.mjs.map +1 -1
  135. package/dist/registries/middlewares.js.map +1 -1
  136. package/dist/registries/middlewares.mjs.map +1 -1
  137. package/dist/registries/models.js.map +1 -1
  138. package/dist/registries/models.mjs.map +1 -1
  139. package/dist/registries/modules.js.map +1 -1
  140. package/dist/registries/modules.mjs.map +1 -1
  141. package/dist/registries/namespace.js.map +1 -1
  142. package/dist/registries/namespace.mjs.map +1 -1
  143. package/dist/registries/plugins.js.map +1 -1
  144. package/dist/registries/plugins.mjs.map +1 -1
  145. package/dist/registries/policies.js.map +1 -1
  146. package/dist/registries/policies.mjs.map +1 -1
  147. package/dist/registries/sanitizers.js.map +1 -1
  148. package/dist/registries/sanitizers.mjs.map +1 -1
  149. package/dist/registries/services.js.map +1 -1
  150. package/dist/registries/services.mjs.map +1 -1
  151. package/dist/registries/validators.js.map +1 -1
  152. package/dist/registries/validators.mjs.map +1 -1
  153. package/dist/services/auth/index.js.map +1 -1
  154. package/dist/services/auth/index.mjs.map +1 -1
  155. package/dist/services/config.js.map +1 -1
  156. package/dist/services/config.mjs.map +1 -1
  157. package/dist/services/content-api/index.js.map +1 -1
  158. package/dist/services/content-api/index.mjs.map +1 -1
  159. package/dist/services/content-api/permissions/index.js.map +1 -1
  160. package/dist/services/content-api/permissions/index.mjs.map +1 -1
  161. package/dist/services/content-api/permissions/providers/action.js.map +1 -1
  162. package/dist/services/content-api/permissions/providers/action.mjs.map +1 -1
  163. package/dist/services/content-api/permissions/providers/condition.js.map +1 -1
  164. package/dist/services/content-api/permissions/providers/condition.mjs.map +1 -1
  165. package/dist/services/core-store.js.map +1 -1
  166. package/dist/services/core-store.mjs.map +1 -1
  167. package/dist/services/cron.js +1 -2
  168. package/dist/services/cron.js.map +1 -1
  169. package/dist/services/cron.mjs +1 -2
  170. package/dist/services/cron.mjs.map +1 -1
  171. package/dist/services/custom-fields.js.map +1 -1
  172. package/dist/services/custom-fields.mjs.map +1 -1
  173. package/dist/services/document-service/attributes/index.js.map +1 -1
  174. package/dist/services/document-service/attributes/index.mjs.map +1 -1
  175. package/dist/services/document-service/attributes/transforms.js.map +1 -1
  176. package/dist/services/document-service/attributes/transforms.mjs.map +1 -1
  177. package/dist/services/document-service/components.js.map +1 -1
  178. package/dist/services/document-service/components.mjs.map +1 -1
  179. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  180. package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
  181. package/dist/services/document-service/entries.js.map +1 -1
  182. package/dist/services/document-service/entries.mjs.map +1 -1
  183. package/dist/services/document-service/events.js.map +1 -1
  184. package/dist/services/document-service/events.mjs.map +1 -1
  185. package/dist/services/document-service/index.js.map +1 -1
  186. package/dist/services/document-service/index.mjs.map +1 -1
  187. package/dist/services/document-service/internationalization.js.map +1 -1
  188. package/dist/services/document-service/internationalization.mjs.map +1 -1
  189. package/dist/services/document-service/middlewares/errors.js.map +1 -1
  190. package/dist/services/document-service/middlewares/errors.mjs.map +1 -1
  191. package/dist/services/document-service/middlewares/middleware-manager.js.map +1 -1
  192. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +1 -1
  193. package/dist/services/document-service/repository.js.map +1 -1
  194. package/dist/services/document-service/repository.mjs.map +1 -1
  195. package/dist/services/document-service/transform/data.js.map +1 -1
  196. package/dist/services/document-service/transform/data.mjs.map +1 -1
  197. package/dist/services/document-service/transform/fields.js.map +1 -1
  198. package/dist/services/document-service/transform/fields.mjs.map +1 -1
  199. package/dist/services/document-service/transform/id-map.js +2 -4
  200. package/dist/services/document-service/transform/id-map.js.map +1 -1
  201. package/dist/services/document-service/transform/id-map.mjs +2 -4
  202. package/dist/services/document-service/transform/id-map.mjs.map +1 -1
  203. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  204. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  205. package/dist/services/document-service/transform/populate.js.map +1 -1
  206. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  207. package/dist/services/document-service/transform/query.js.map +1 -1
  208. package/dist/services/document-service/transform/query.mjs.map +1 -1
  209. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  210. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  211. package/dist/services/document-service/transform/relations/transform/data-ids.js +1 -2
  212. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  213. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -2
  214. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  215. package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -1
  216. package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -1
  217. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
  218. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -1
  219. package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
  220. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
  221. package/dist/services/document-service/transform/relations/utils/map-relation.js +3 -6
  222. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
  223. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +3 -6
  224. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
  225. package/dist/services/document-service/utils/populate.js.map +1 -1
  226. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  227. package/dist/services/document-service/utils/unidirectional-relations.js +1 -2
  228. package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
  229. package/dist/services/document-service/utils/unidirectional-relations.mjs +1 -2
  230. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
  231. package/dist/services/entity-service/index.js.map +1 -1
  232. package/dist/services/entity-service/index.mjs.map +1 -1
  233. package/dist/services/entity-validator/blocks-validator.js.map +1 -1
  234. package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
  235. package/dist/services/entity-validator/index.js.map +1 -1
  236. package/dist/services/entity-validator/index.mjs.map +1 -1
  237. package/dist/services/entity-validator/validators.js.map +1 -1
  238. package/dist/services/entity-validator/validators.mjs.map +1 -1
  239. package/dist/services/errors.js.map +1 -1
  240. package/dist/services/errors.mjs.map +1 -1
  241. package/dist/services/event-hub.js.map +1 -1
  242. package/dist/services/event-hub.mjs.map +1 -1
  243. package/dist/services/features.js.map +1 -1
  244. package/dist/services/features.mjs.map +1 -1
  245. package/dist/services/fs.js.map +1 -1
  246. package/dist/services/fs.mjs.map +1 -1
  247. package/dist/services/metrics/admin-user-hash.js.map +1 -1
  248. package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
  249. package/dist/services/metrics/index.js +1 -2
  250. package/dist/services/metrics/index.js.map +1 -1
  251. package/dist/services/metrics/index.mjs +1 -2
  252. package/dist/services/metrics/index.mjs.map +1 -1
  253. package/dist/services/metrics/is-truthy.js.map +1 -1
  254. package/dist/services/metrics/middleware.js.map +1 -1
  255. package/dist/services/metrics/middleware.mjs.map +1 -1
  256. package/dist/services/metrics/rate-limiter.js.map +1 -1
  257. package/dist/services/metrics/rate-limiter.mjs.map +1 -1
  258. package/dist/services/metrics/sender.js.map +1 -1
  259. package/dist/services/metrics/sender.mjs.map +1 -1
  260. package/dist/services/query-params.js.map +1 -1
  261. package/dist/services/query-params.mjs.map +1 -1
  262. package/dist/services/reloader.js.map +1 -1
  263. package/dist/services/reloader.mjs.map +1 -1
  264. package/dist/services/request-context.js.map +1 -1
  265. package/dist/services/request-context.mjs.map +1 -1
  266. package/dist/services/server/admin-api.js.map +1 -1
  267. package/dist/services/server/admin-api.mjs.map +1 -1
  268. package/dist/services/server/api.js.map +1 -1
  269. package/dist/services/server/api.mjs.map +1 -1
  270. package/dist/services/server/compose-endpoint.js.map +1 -1
  271. package/dist/services/server/compose-endpoint.mjs.map +1 -1
  272. package/dist/services/server/content-api.js.map +1 -1
  273. package/dist/services/server/content-api.mjs.map +1 -1
  274. package/dist/services/server/http-server.js.map +1 -1
  275. package/dist/services/server/http-server.mjs.map +1 -1
  276. package/dist/services/server/index.js.map +1 -1
  277. package/dist/services/server/index.mjs.map +1 -1
  278. package/dist/services/server/koa.js.map +1 -1
  279. package/dist/services/server/koa.mjs.map +1 -1
  280. package/dist/services/server/middleware.js.map +1 -1
  281. package/dist/services/server/middleware.mjs.map +1 -1
  282. package/dist/services/server/policy.js.map +1 -1
  283. package/dist/services/server/policy.mjs.map +1 -1
  284. package/dist/services/server/register-middlewares.js.map +1 -1
  285. package/dist/services/server/register-middlewares.mjs.map +1 -1
  286. package/dist/services/server/register-routes.js.map +1 -1
  287. package/dist/services/server/register-routes.mjs.map +1 -1
  288. package/dist/services/server/routing.js.map +1 -1
  289. package/dist/services/server/routing.mjs.map +1 -1
  290. package/dist/services/utils/dynamic-zones.js.map +1 -1
  291. package/dist/services/utils/dynamic-zones.mjs.map +1 -1
  292. package/dist/services/webhook-runner.js.map +1 -1
  293. package/dist/services/webhook-runner.mjs.map +1 -1
  294. package/dist/services/webhook-store.js.map +1 -1
  295. package/dist/services/webhook-store.mjs.map +1 -1
  296. package/dist/services/worker-queue.js.map +1 -1
  297. package/dist/services/worker-queue.mjs.map +1 -1
  298. package/dist/utils/convert-custom-field-type.js.map +1 -1
  299. package/dist/utils/convert-custom-field-type.mjs.map +1 -1
  300. package/dist/utils/cron.js.map +1 -1
  301. package/dist/utils/cron.mjs.map +1 -1
  302. package/dist/utils/fetch.js.map +1 -1
  303. package/dist/utils/fetch.mjs.map +1 -1
  304. package/dist/utils/filepath-to-prop-path.js.map +1 -1
  305. package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
  306. package/dist/utils/is-initialized.js.map +1 -1
  307. package/dist/utils/is-initialized.mjs.map +1 -1
  308. package/dist/utils/load-config-file.js.map +1 -1
  309. package/dist/utils/load-config-file.mjs.map +1 -1
  310. package/dist/utils/load-files.js +1 -2
  311. package/dist/utils/load-files.js.map +1 -1
  312. package/dist/utils/load-files.mjs +1 -2
  313. package/dist/utils/load-files.mjs.map +1 -1
  314. package/dist/utils/resolve-working-dirs.js.map +1 -1
  315. package/dist/utils/resolve-working-dirs.mjs.map +1 -1
  316. package/dist/utils/signals.js.map +1 -1
  317. package/dist/utils/signals.mjs.map +1 -1
  318. package/dist/utils/startup-logger.d.ts.map +1 -1
  319. package/dist/utils/startup-logger.js +6 -1
  320. package/dist/utils/startup-logger.js.map +1 -1
  321. package/dist/utils/startup-logger.mjs +6 -1
  322. package/dist/utils/startup-logger.mjs.map +1 -1
  323. package/dist/utils/transform-content-types-to-models.js.map +1 -1
  324. package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
  325. package/dist/utils/update-notifier/index.js.map +1 -1
  326. package/dist/utils/update-notifier/index.mjs.map +1 -1
  327. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"id-map.js","sources":["../../../../src/services/document-service/transform/id-map.ts"],"sourcesContent":["import { Core, Data, UID } from '@strapi/types';\nimport { async, contentTypes } from '@strapi/utils';\n\nconst hasDraftAndPublish = (uid: UID.CollectionType) => {\n const model = strapi.getModel(uid);\n return contentTypes.hasDraftAndPublish(model);\n};\n\n/**\n * TODO: Find a better way to encode keys than this\n * This converts an object into a string by joining its keys and values,\n * so it can be used as a key in a Map.\n *\n * @example\n * const obj = { a: 1, b: 2 };\n * const key = encodeKey(obj);\n * ^ \"a:::1&&b:::2\"\n */\nconst encodeKey = (obj: any) => {\n // Ignore status field for models without draft and publish\n if (!hasDraftAndPublish(obj.uid)) {\n delete obj.status;\n }\n\n // Sort keys to always keep the same order when encoding\n const keys = Object.keys(obj).sort();\n return keys.map((key) => `${key}:::${obj[key]}`).join('&&');\n};\n\ninterface KeyFields {\n uid: string;\n documentId: Data.ID;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\nexport interface IdMap {\n loadedIds: Map<string, string>;\n toLoadIds: Map<string, KeyFields>;\n // Make the Keys type to be the params of add\n add(keys: KeyFields): void;\n load(): Promise<void>;\n get(keys: KeyFields): string | undefined;\n clear(): void;\n}\n\n/**\n * Holds a registry of document ids and their corresponding entity ids.\n */\nconst createIdMap = ({ strapi }: { strapi: Core.Strapi }): IdMap => {\n const loadedIds = new Map();\n const toLoadIds = new Map();\n\n return {\n loadedIds,\n toLoadIds,\n /**\n * Register a new document id and its corresponding entity id.\n */\n add(keyFields: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keyFields });\n\n // If the id is already loaded, do nothing\n if (loadedIds.has(key)) return;\n // If the id is already in the toLoadIds, do nothing\n if (toLoadIds.has(key)) return;\n\n // Add the id to the toLoadIds\n toLoadIds.set(key, keyFields);\n },\n\n /**\n * Load all ids from the registry.\n */\n async load() {\n // Document Id to Entry Id queries are batched by its uid and locale\n // TODO: Add publication state too\n const loadIdValues = Array.from(toLoadIds.values());\n\n // 1. Group ids to query together\n const idsByUidAndLocale = loadIdValues.reduce((acc, { documentId, ...rest }) => {\n const key = encodeKey(rest);\n const ids = acc[key] || { ...rest, documentIds: [] };\n ids.documentIds.push(documentId);\n return { ...acc, [key]: ids };\n }, {});\n\n // 2. Query ids\n await async.map(\n Object.values(idsByUidAndLocale),\n async ({ uid, locale, documentIds, status }: any) => {\n const findParams = {\n select: ['id', 'documentId', 'locale', 'publishedAt'],\n where: {\n documentId: { $in: documentIds },\n locale: locale || null,\n },\n } as any;\n\n if (hasDraftAndPublish(uid)) {\n findParams.where.publishedAt = status === 'draft' ? null : { $ne: null };\n }\n\n const result = await strapi?.db?.query(uid).findMany(findParams);\n\n // 3. Store result in loadedIds\n result?.forEach(({ documentId, id, locale, publishedAt }: any) => {\n const key = encodeKey({\n documentId,\n uid,\n locale,\n status: publishedAt ? 'published' : 'draft',\n });\n loadedIds.set(key, id);\n });\n }\n );\n\n // 4. Clear toLoadIds\n toLoadIds.clear();\n },\n\n /**\n * Get the entity id for a given document id.\n */\n get(keys: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keys });\n return loadedIds.get(key);\n },\n\n /**\n * Clear the registry.\n */\n clear() {\n loadedIds.clear();\n toLoadIds.clear();\n },\n };\n};\n\nexport { createIdMap };\n"],"names":["contentTypes","strapi","async","locale"],"mappings":";;;AAGA,MAAM,qBAAqB,CAAC,QAA4B;AAChD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAAA,YAAA,aAAa,mBAAmB,KAAK;AAC9C;AAYA,MAAM,YAAY,CAAC,QAAa;AAE9B,MAAI,CAAC,mBAAmB,IAAI,GAAG,GAAG;AAChC,WAAO,IAAI;AAAA,EACb;AAGA,QAAM,OAAO,OAAO,KAAK,GAAG,EAAE,KAAK;AACnC,SAAO,KAAK,IAAI,CAAC,QAAQ,GAAG,GAAG,MAAM,IAAI,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI;AAC5D;AAsBA,MAAM,cAAc,CAAC,EAAE,QAAAC,cAA6C;AAC5D,QAAA,gCAAgB;AAChB,QAAA,gCAAgB;AAEf,SAAA;AAAA,IACL;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,IAAI,WAAsB;AAClB,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,UAAA,CAAW;AAGrE,UAAA,UAAU,IAAI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IAAI,MAAiB;AACb,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,KAAA,CAAM;AAC7D,aAAA,UAAU,IAAI,GAAG;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,QAAQ;AACN,gBAAU,MAAM;AAChB,gBAAU,MAAM;AAAA,IAClB;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"id-map.js","sources":["../../../../src/services/document-service/transform/id-map.ts"],"sourcesContent":["import { Core, Data, UID } from '@strapi/types';\nimport { async, contentTypes } from '@strapi/utils';\n\nconst hasDraftAndPublish = (uid: UID.CollectionType) => {\n const model = strapi.getModel(uid);\n return contentTypes.hasDraftAndPublish(model);\n};\n\n/**\n * TODO: Find a better way to encode keys than this\n * This converts an object into a string by joining its keys and values,\n * so it can be used as a key in a Map.\n *\n * @example\n * const obj = { a: 1, b: 2 };\n * const key = encodeKey(obj);\n * ^ \"a:::1&&b:::2\"\n */\nconst encodeKey = (obj: any) => {\n // Ignore status field for models without draft and publish\n if (!hasDraftAndPublish(obj.uid)) {\n delete obj.status;\n }\n\n // Sort keys to always keep the same order when encoding\n const keys = Object.keys(obj).sort();\n return keys.map((key) => `${key}:::${obj[key]}`).join('&&');\n};\n\ninterface KeyFields {\n uid: string;\n documentId: Data.ID;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\nexport interface IdMap {\n loadedIds: Map<string, string>;\n toLoadIds: Map<string, KeyFields>;\n // Make the Keys type to be the params of add\n add(keys: KeyFields): void;\n load(): Promise<void>;\n get(keys: KeyFields): string | undefined;\n clear(): void;\n}\n\n/**\n * Holds a registry of document ids and their corresponding entity ids.\n */\nconst createIdMap = ({ strapi }: { strapi: Core.Strapi }): IdMap => {\n const loadedIds = new Map();\n const toLoadIds = new Map();\n\n return {\n loadedIds,\n toLoadIds,\n /**\n * Register a new document id and its corresponding entity id.\n */\n add(keyFields: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keyFields });\n\n // If the id is already loaded, do nothing\n if (loadedIds.has(key)) return;\n // If the id is already in the toLoadIds, do nothing\n if (toLoadIds.has(key)) return;\n\n // Add the id to the toLoadIds\n toLoadIds.set(key, keyFields);\n },\n\n /**\n * Load all ids from the registry.\n */\n async load() {\n // Document Id to Entry Id queries are batched by its uid and locale\n // TODO: Add publication state too\n const loadIdValues = Array.from(toLoadIds.values());\n\n // 1. Group ids to query together\n const idsByUidAndLocale = loadIdValues.reduce((acc, { documentId, ...rest }) => {\n const key = encodeKey(rest);\n const ids = acc[key] || { ...rest, documentIds: [] };\n ids.documentIds.push(documentId);\n return { ...acc, [key]: ids };\n }, {});\n\n // 2. Query ids\n await async.map(\n Object.values(idsByUidAndLocale),\n async ({ uid, locale, documentIds, status }: any) => {\n const findParams = {\n select: ['id', 'documentId', 'locale', 'publishedAt'],\n where: {\n documentId: { $in: documentIds },\n locale: locale || null,\n },\n } as any;\n\n if (hasDraftAndPublish(uid)) {\n findParams.where.publishedAt = status === 'draft' ? null : { $ne: null };\n }\n\n const result = await strapi?.db?.query(uid).findMany(findParams);\n\n // 3. Store result in loadedIds\n result?.forEach(({ documentId, id, locale, publishedAt }: any) => {\n const key = encodeKey({\n documentId,\n uid,\n locale,\n status: publishedAt ? 'published' : 'draft',\n });\n loadedIds.set(key, id);\n });\n }\n );\n\n // 4. Clear toLoadIds\n toLoadIds.clear();\n },\n\n /**\n * Get the entity id for a given document id.\n */\n get(keys: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keys });\n return loadedIds.get(key);\n },\n\n /**\n * Clear the registry.\n */\n clear() {\n loadedIds.clear();\n toLoadIds.clear();\n },\n };\n};\n\nexport { createIdMap };\n"],"names":["contentTypes","strapi","async","locale"],"mappings":";;;AAGA,MAAM,qBAAqB,CAAC,QAA4B;AAChD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAAA,YAAA,aAAa,mBAAmB,KAAK;AAC9C;AAYA,MAAM,YAAY,CAAC,QAAa;AAE9B,MAA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I,cAAA,mBAAmB,GAAG,GAAG;AAC3B,uBAAW,MAAM,cAAc,WAAW,UAAU,OAAO,EAAE,KAAK,KAAK;AAAA,UAAA;AAGnE,gBAAA,SAAS,MAAMD,SAAQ,IAAI,MAAM,GAAG,EAAE,SAAS,UAAU;AAGvD,kBAAA,QAAQ,CAAC,EAAE,YAAY,IAAI,QAAAE,SAAQ,kBAAuB;AAChE,kBAAM,MAAM,UAAU;AAAA,cACpB;AAAA,cACA;AAAA,cACA,QAAAA;AAAAA,cACA,QAAQ,cAAc,cAAc;AAAA,YAAA,CACrC;AACS,sBAAA,IAAI,KAAK,EAAE;AAAA,UAAA,CACtB;AAAA,QAAA;AAAA,MAEL;AAGA,gBAAU,MAAM;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,MAAiB;AACb,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,MAAM;AAC7D,aAAA,UAAU,IAAI,GAAG;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,QAAQ;AACN,gBAAU,MAAM;AAChB,gBAAU,MAAM;AAAA,IAAA;AAAA,EAEpB;AACF;;"}
@@ -21,10 +21,8 @@ const createIdMap = ({ strapi: strapi2 }) => {
21
21
  */
22
22
  add(keyFields) {
23
23
  const key = encodeKey({ status: "published", locale: null, ...keyFields });
24
- if (loadedIds.has(key))
25
- return;
26
- if (toLoadIds.has(key))
27
- return;
24
+ if (loadedIds.has(key)) return;
25
+ if (toLoadIds.has(key)) return;
28
26
  toLoadIds.set(key, keyFields);
29
27
  },
30
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"id-map.mjs","sources":["../../../../src/services/document-service/transform/id-map.ts"],"sourcesContent":["import { Core, Data, UID } from '@strapi/types';\nimport { async, contentTypes } from '@strapi/utils';\n\nconst hasDraftAndPublish = (uid: UID.CollectionType) => {\n const model = strapi.getModel(uid);\n return contentTypes.hasDraftAndPublish(model);\n};\n\n/**\n * TODO: Find a better way to encode keys than this\n * This converts an object into a string by joining its keys and values,\n * so it can be used as a key in a Map.\n *\n * @example\n * const obj = { a: 1, b: 2 };\n * const key = encodeKey(obj);\n * ^ \"a:::1&&b:::2\"\n */\nconst encodeKey = (obj: any) => {\n // Ignore status field for models without draft and publish\n if (!hasDraftAndPublish(obj.uid)) {\n delete obj.status;\n }\n\n // Sort keys to always keep the same order when encoding\n const keys = Object.keys(obj).sort();\n return keys.map((key) => `${key}:::${obj[key]}`).join('&&');\n};\n\ninterface KeyFields {\n uid: string;\n documentId: Data.ID;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\nexport interface IdMap {\n loadedIds: Map<string, string>;\n toLoadIds: Map<string, KeyFields>;\n // Make the Keys type to be the params of add\n add(keys: KeyFields): void;\n load(): Promise<void>;\n get(keys: KeyFields): string | undefined;\n clear(): void;\n}\n\n/**\n * Holds a registry of document ids and their corresponding entity ids.\n */\nconst createIdMap = ({ strapi }: { strapi: Core.Strapi }): IdMap => {\n const loadedIds = new Map();\n const toLoadIds = new Map();\n\n return {\n loadedIds,\n toLoadIds,\n /**\n * Register a new document id and its corresponding entity id.\n */\n add(keyFields: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keyFields });\n\n // If the id is already loaded, do nothing\n if (loadedIds.has(key)) return;\n // If the id is already in the toLoadIds, do nothing\n if (toLoadIds.has(key)) return;\n\n // Add the id to the toLoadIds\n toLoadIds.set(key, keyFields);\n },\n\n /**\n * Load all ids from the registry.\n */\n async load() {\n // Document Id to Entry Id queries are batched by its uid and locale\n // TODO: Add publication state too\n const loadIdValues = Array.from(toLoadIds.values());\n\n // 1. Group ids to query together\n const idsByUidAndLocale = loadIdValues.reduce((acc, { documentId, ...rest }) => {\n const key = encodeKey(rest);\n const ids = acc[key] || { ...rest, documentIds: [] };\n ids.documentIds.push(documentId);\n return { ...acc, [key]: ids };\n }, {});\n\n // 2. Query ids\n await async.map(\n Object.values(idsByUidAndLocale),\n async ({ uid, locale, documentIds, status }: any) => {\n const findParams = {\n select: ['id', 'documentId', 'locale', 'publishedAt'],\n where: {\n documentId: { $in: documentIds },\n locale: locale || null,\n },\n } as any;\n\n if (hasDraftAndPublish(uid)) {\n findParams.where.publishedAt = status === 'draft' ? null : { $ne: null };\n }\n\n const result = await strapi?.db?.query(uid).findMany(findParams);\n\n // 3. Store result in loadedIds\n result?.forEach(({ documentId, id, locale, publishedAt }: any) => {\n const key = encodeKey({\n documentId,\n uid,\n locale,\n status: publishedAt ? 'published' : 'draft',\n });\n loadedIds.set(key, id);\n });\n }\n );\n\n // 4. Clear toLoadIds\n toLoadIds.clear();\n },\n\n /**\n * Get the entity id for a given document id.\n */\n get(keys: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keys });\n return loadedIds.get(key);\n },\n\n /**\n * Clear the registry.\n */\n clear() {\n loadedIds.clear();\n toLoadIds.clear();\n },\n };\n};\n\nexport { createIdMap };\n"],"names":["strapi","locale"],"mappings":";AAGA,MAAM,qBAAqB,CAAC,QAA4B;AAChD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,aAAa,mBAAmB,KAAK;AAC9C;AAYA,MAAM,YAAY,CAAC,QAAa;AAE9B,MAAI,CAAC,mBAAmB,IAAI,GAAG,GAAG;AAChC,WAAO,IAAI;AAAA,EACb;AAGA,QAAM,OAAO,OAAO,KAAK,GAAG,EAAE,KAAK;AACnC,SAAO,KAAK,IAAI,CAAC,QAAQ,GAAG,GAAG,MAAM,IAAI,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI;AAC5D;AAsBA,MAAM,cAAc,CAAC,EAAE,QAAAA,cAA6C;AAC5D,QAAA,gCAAgB;AAChB,QAAA,gCAAgB;AAEf,SAAA;AAAA,IACL;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,IAAI,WAAsB;AAClB,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,UAAA,CAAW;AAGrE,UAAA,UAAU,IAAI,GAAG;AA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,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,KAAA,CAAM;AAC7D,aAAA,UAAU,IAAI,GAAG;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,QAAQ;AACN,gBAAU,MAAM;AAChB,gBAAU,MAAM;AAAA,IAClB;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"id-map.mjs","sources":["../../../../src/services/document-service/transform/id-map.ts"],"sourcesContent":["import { Core, Data, UID } from '@strapi/types';\nimport { async, contentTypes } from '@strapi/utils';\n\nconst hasDraftAndPublish = (uid: UID.CollectionType) => {\n const model = strapi.getModel(uid);\n return contentTypes.hasDraftAndPublish(model);\n};\n\n/**\n * TODO: Find a better way to encode keys than this\n * This converts an object into a string by joining its keys and values,\n * so it can be used as a key in a Map.\n *\n * @example\n * const obj = { a: 1, b: 2 };\n * const key = encodeKey(obj);\n * ^ \"a:::1&&b:::2\"\n */\nconst encodeKey = (obj: any) => {\n // Ignore status field for models without draft and publish\n if (!hasDraftAndPublish(obj.uid)) {\n delete obj.status;\n }\n\n // Sort keys to always keep the same order when encoding\n const keys = Object.keys(obj).sort();\n return keys.map((key) => `${key}:::${obj[key]}`).join('&&');\n};\n\ninterface KeyFields {\n uid: string;\n documentId: Data.ID;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\nexport interface IdMap {\n loadedIds: Map<string, string>;\n toLoadIds: Map<string, KeyFields>;\n // Make the Keys type to be the params of add\n add(keys: KeyFields): void;\n load(): Promise<void>;\n get(keys: KeyFields): string | undefined;\n clear(): void;\n}\n\n/**\n * Holds a registry of document ids and their corresponding entity ids.\n */\nconst createIdMap = ({ strapi }: { strapi: Core.Strapi }): IdMap => {\n const loadedIds = new Map();\n const toLoadIds = new Map();\n\n return {\n loadedIds,\n toLoadIds,\n /**\n * Register a new document id and its corresponding entity id.\n */\n add(keyFields: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keyFields });\n\n // If the id is already loaded, do nothing\n if (loadedIds.has(key)) return;\n // If the id is already in the toLoadIds, do nothing\n if (toLoadIds.has(key)) return;\n\n // Add the id to the toLoadIds\n toLoadIds.set(key, keyFields);\n },\n\n /**\n * Load all ids from the registry.\n */\n async load() {\n // Document Id to Entry Id queries are batched by its uid and locale\n // TODO: Add publication state too\n const loadIdValues = Array.from(toLoadIds.values());\n\n // 1. Group ids to query together\n const idsByUidAndLocale = loadIdValues.reduce((acc, { documentId, ...rest }) => {\n const key = encodeKey(rest);\n const ids = acc[key] || { ...rest, documentIds: [] };\n ids.documentIds.push(documentId);\n return { ...acc, [key]: ids };\n }, {});\n\n // 2. Query ids\n await async.map(\n Object.values(idsByUidAndLocale),\n async ({ uid, locale, documentIds, status }: any) => {\n const findParams = {\n select: ['id', 'documentId', 'locale', 'publishedAt'],\n where: {\n documentId: { $in: documentIds },\n locale: locale || null,\n },\n } as any;\n\n if (hasDraftAndPublish(uid)) {\n findParams.where.publishedAt = status === 'draft' ? null : { $ne: null };\n }\n\n const result = await strapi?.db?.query(uid).findMany(findParams);\n\n // 3. Store result in loadedIds\n result?.forEach(({ documentId, id, locale, publishedAt }: any) => {\n const key = encodeKey({\n documentId,\n uid,\n locale,\n status: publishedAt ? 'published' : 'draft',\n });\n loadedIds.set(key, id);\n });\n }\n );\n\n // 4. Clear toLoadIds\n toLoadIds.clear();\n },\n\n /**\n * Get the entity id for a given document id.\n */\n get(keys: KeyFields) {\n const key = encodeKey({ status: 'published', locale: null, ...keys });\n return loadedIds.get(key);\n },\n\n /**\n * Clear the registry.\n */\n clear() {\n loadedIds.clear();\n toLoadIds.clear();\n },\n };\n};\n\nexport { createIdMap };\n"],"names":["strapi","locale"],"mappings":";AAGA,MAAM,qBAAqB,CAAC,QAA4B;AAChD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,aAAa,mBAAmB,KAAK;AAC9C;AAYA,MAAM,YAAY,CAAC,QAAa;AAE9B,MAAI,CAAC,mBAAmB,IAAI,GAAG,GAAG;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,MAAM,cAAc,WAAW,UAAU,OAAO,EAAE,KAAK,KAAK;AAAA,UAAA;AAGnE,gBAAA,SAAS,MAAMA,SAAQ,IAAI,MAAM,GAAG,EAAE,SAAS,UAAU;AAGvD,kBAAA,QAAQ,CAAC,EAAE,YAAY,IAAI,QAAAC,SAAQ,kBAAuB;AAChE,kBAAM,MAAM,UAAU;AAAA,cACpB;AAAA,cACA;AAAA,cACA,QAAAA;AAAAA,cACA,QAAQ,cAAc,cAAc;AAAA,YAAA,CACrC;AACS,sBAAA,IAAI,KAAK,EAAE;AAAA,UAAA,CACtB;AAAA,QAAA;AAAA,MAEL;AAGA,gBAAU,MAAM;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,MAAiB;AACb,YAAA,MAAM,UAAU,EAAE,QAAQ,aAAa,QAAQ,MAAM,GAAG,MAAM;AAC7D,aAAA,UAAU,IAAI,GAAG;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA,IAKA,QAAQ;AACN,gBAAU,MAAM;AAChB,gBAAU,MAAM;AAAA,IAAA;AAAA,EAEpB;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"id-transform.js","sources":["../../../../src/services/document-service/transform/id-transform.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID, Modules } from '@strapi/types';\n\nimport { transformData } from './data';\nimport { transformFields } from './fields';\nimport { transformPopulate } from './populate';\n\n/**\n * Transform input of a query to map document ids to entity ids.\n */\nasync function transformParamsDocumentId(\n uid: UID.Schema,\n query: Modules.Documents.Params.All\n): Promise<Modules.Documents.Params.All> {\n // Transform relational documentIds to entity ids\n let data = query.data;\n if (query.data) {\n data = await transformData(query.data, {\n locale: query.locale,\n status: query.status,\n uid,\n });\n }\n\n // Make sure documentId is always present in the response\n let fields = query.fields;\n if (query.fields) {\n fields = transformFields(query.fields) as typeof query.fields;\n }\n\n let populate = query.populate;\n if (query.populate) {\n populate = (await transformPopulate(query.populate, { uid })) as typeof query.populate;\n }\n\n return {\n ...query,\n data,\n fields,\n populate,\n };\n}\n\nconst curriedTransformParamsDocumentId = curry(transformParamsDocumentId);\n\nexport { curriedTransformParamsDocumentId as transformParamsDocumentId };\n"],"names":["data","transformData","fields","transformFields","populate","transformPopulate","curry"],"mappings":";;;;;;AAWA,eAAe,0BACb,KACA,OACuC;AAEvC,MAAIA,SAAO,MAAM;AACjB,MAAI,MAAM,MAAM;AACPA,aAAA,MAAMC,KAAAA,cAAc,MAAM,MAAM;AAAA,MACrC,QAAQ,MAAM;AAAA,MACd,QAAQ,MAAM;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EACH;AAGA,MAAIC,WAAS,MAAM;AACnB,MAAI,MAAM,QAAQ;AACPA,eAAAC,OAAA,gBAAgB,MAAM,MAAM;AAAA,EACvC;AAEA,MAAIC,aAAW,MAAM;AACrB,MAAI,MAAM,UAAU;AAClBA,iBAAY,MAAMC,SAAAA,kBAAkB,MAAM,UAAU,EAAE,KAAK;AAAA,EAC7D;AAEO,SAAA;AAAA,IACL,GAAG;AAAA,IAAA,MACHL;AAAAA,IAAA,QACAE;AAAAA,IAAA,UACAE;AAAAA,EAAA;AAEJ;AAEM,MAAA,mCAAmCE,SAAM,yBAAyB;;"}
1
+ {"version":3,"file":"id-transform.js","sources":["../../../../src/services/document-service/transform/id-transform.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID, Modules } from '@strapi/types';\n\nimport { transformData } from './data';\nimport { transformFields } from './fields';\nimport { transformPopulate } from './populate';\n\n/**\n * Transform input of a query to map document ids to entity ids.\n */\nasync function transformParamsDocumentId(\n uid: UID.Schema,\n query: Modules.Documents.Params.All\n): Promise<Modules.Documents.Params.All> {\n // Transform relational documentIds to entity ids\n let data = query.data;\n if (query.data) {\n data = await transformData(query.data, {\n locale: query.locale,\n status: query.status,\n uid,\n });\n }\n\n // Make sure documentId is always present in the response\n let fields = query.fields;\n if (query.fields) {\n fields = transformFields(query.fields) as typeof query.fields;\n }\n\n let populate = query.populate;\n if (query.populate) {\n populate = (await transformPopulate(query.populate, { uid })) as typeof query.populate;\n }\n\n return {\n ...query,\n data,\n fields,\n populate,\n };\n}\n\nconst curriedTransformParamsDocumentId = curry(transformParamsDocumentId);\n\nexport { curriedTransformParamsDocumentId as transformParamsDocumentId };\n"],"names":["data","transformData","fields","transformFields","populate","transformPopulate","curry"],"mappings":";;;;;;AAWA,eAAe,0BACb,KACA,OACuC;AAEvC,MAAIA,SAAO,MAAM;AACjB,MAAI,MAAM,MAAM;AACPA,aAAA,MAAMC,KAAAA,cAAc,MAAM,MAAM;AAAA,MACrC,QAAQ,MAAM;AAAA,MACd,QAAQ,MAAM;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EAAA;AAIH,MAAIC,WAAS,MAAM;AACnB,MAAI,MAAM,QAAQ;AACPA,eAAAC,OAAAA,gBAAgB,MAAM,MAAM;AAAA,EAAA;AAGvC,MAAIC,aAAW,MAAM;AACrB,MAAI,MAAM,UAAU;AAClBA,iBAAY,MAAMC,SAAAA,kBAAkB,MAAM,UAAU,EAAE,KAAK;AAAA,EAAA;AAGtD,SAAA;AAAA,IACL,GAAG;AAAA,IAAA,MACHL;AAAAA,IAAA,QACAE;AAAAA,IACAE,UAAAA;AAAAA,EACF;AACF;AAEM,MAAA,mCAAmCE,SAAM,yBAAyB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"id-transform.mjs","sources":["../../../../src/services/document-service/transform/id-transform.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID, Modules } from '@strapi/types';\n\nimport { transformData } from './data';\nimport { transformFields } from './fields';\nimport { transformPopulate } from './populate';\n\n/**\n * Transform input of a query to map document ids to entity ids.\n */\nasync function transformParamsDocumentId(\n uid: UID.Schema,\n query: Modules.Documents.Params.All\n): Promise<Modules.Documents.Params.All> {\n // Transform relational documentIds to entity ids\n let data = query.data;\n if (query.data) {\n data = await transformData(query.data, {\n locale: query.locale,\n status: query.status,\n uid,\n });\n }\n\n // Make sure documentId is always present in the response\n let fields = query.fields;\n if (query.fields) {\n fields = transformFields(query.fields) as typeof query.fields;\n }\n\n let populate = query.populate;\n if (query.populate) {\n populate = (await transformPopulate(query.populate, { uid })) as typeof query.populate;\n }\n\n return {\n ...query,\n data,\n fields,\n populate,\n };\n}\n\nconst curriedTransformParamsDocumentId = curry(transformParamsDocumentId);\n\nexport { curriedTransformParamsDocumentId as transformParamsDocumentId };\n"],"names":[],"mappings":";;;;AAWA,eAAe,0BACb,KACA,OACuC;AAEvC,MAAI,OAAO,MAAM;AACjB,MAAI,MAAM,MAAM;AACP,WAAA,MAAM,cAAc,MAAM,MAAM;AAAA,MACrC,QAAQ,MAAM;AAAA,MACd,QAAQ,MAAM;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EACH;AAGA,MAAI,SAAS,MAAM;AACnB,MAAI,MAAM,QAAQ;AACP,aAAA,gBAAgB,MAAM,MAAM;AAAA,EACvC;AAEA,MAAI,WAAW,MAAM;AACrB,MAAI,MAAM,UAAU;AAClB,eAAY,MAAM,kBAAkB,MAAM,UAAU,EAAE,KAAK;AAAA,EAC7D;AAEO,SAAA;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEM,MAAA,mCAAmC,MAAM,yBAAyB;"}
1
+ {"version":3,"file":"id-transform.mjs","sources":["../../../../src/services/document-service/transform/id-transform.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID, Modules } from '@strapi/types';\n\nimport { transformData } from './data';\nimport { transformFields } from './fields';\nimport { transformPopulate } from './populate';\n\n/**\n * Transform input of a query to map document ids to entity ids.\n */\nasync function transformParamsDocumentId(\n uid: UID.Schema,\n query: Modules.Documents.Params.All\n): Promise<Modules.Documents.Params.All> {\n // Transform relational documentIds to entity ids\n let data = query.data;\n if (query.data) {\n data = await transformData(query.data, {\n locale: query.locale,\n status: query.status,\n uid,\n });\n }\n\n // Make sure documentId is always present in the response\n let fields = query.fields;\n if (query.fields) {\n fields = transformFields(query.fields) as typeof query.fields;\n }\n\n let populate = query.populate;\n if (query.populate) {\n populate = (await transformPopulate(query.populate, { uid })) as typeof query.populate;\n }\n\n return {\n ...query,\n data,\n fields,\n populate,\n };\n}\n\nconst curriedTransformParamsDocumentId = curry(transformParamsDocumentId);\n\nexport { curriedTransformParamsDocumentId as transformParamsDocumentId };\n"],"names":[],"mappings":";;;;AAWA,eAAe,0BACb,KACA,OACuC;AAEvC,MAAI,OAAO,MAAM;AACjB,MAAI,MAAM,MAAM;AACP,WAAA,MAAM,cAAc,MAAM,MAAM;AAAA,MACrC,QAAQ,MAAM;AAAA,MACd,QAAQ,MAAM;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EAAA;AAIH,MAAI,SAAS,MAAM;AACnB,MAAI,MAAM,QAAQ;AACP,aAAA,gBAAgB,MAAM,MAAM;AAAA,EAAA;AAGvC,MAAI,WAAW,MAAM;AACrB,MAAI,MAAM,UAAU;AAClB,eAAY,MAAM,kBAAkB,MAAM,UAAU,EAAE,KAAK;AAAA,EAAA;AAGtD,SAAA;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEM,MAAA,mCAAmC,MAAM,yBAAyB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport type { UID } from '@strapi/types';\n\nimport { type Data } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: { uid: UID.Schema }) => {\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), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n"],"names":["traverse","transformFields"],"mappings":";;;;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAA8B;AAChF,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,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC5E;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 { UID } from '@strapi/types';\n\nimport { type Data } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: { uid: UID.Schema }) => {\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), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n"],"names":["traverse","transformFields"],"mappings":";;;;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAA8B;AAChF,SAAOA,YAAS,SAAA;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MAAA;AAQF,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAASC,uBAAgB,MAAM,MAAM;AAAA,MAAA;AAG7C,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC5E;AAAA,EACF;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/transform/populate.ts"],"sourcesContent":["import { traverse } from '@strapi/utils';\nimport type { UID } from '@strapi/types';\n\nimport { type Data } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: { uid: UID.Schema }) => {\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), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n"],"names":[],"mappings":";;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAA8B;AAChF,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,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC5E;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 { UID } from '@strapi/types';\n\nimport { type Data } from './types';\nimport { transformFields } from './fields';\n\nexport const transformPopulate = async (data: Data, opts: { uid: UID.Schema }) => {\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), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n"],"names":[],"mappings":";;AAMa,MAAA,oBAAoB,OAAO,MAAY,SAA8B;AAChF,SAAO,SAAS;AAAA,IACd,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,UAAU;AAC5C,UAAI,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,YAAY;AACzE;AAAA,MAAA;AAQF,UAAI,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,cAAA,SAAS,gBAAgB,MAAM,MAAM;AAAA,MAAA;AAG7C,UAAI,KAAK,KAAK;AAAA,IAChB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,KAAK,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC5E;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sources":["../../../../src/services/document-service/transform/query.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { curry, assoc } from 'lodash/fp';\n\nconst transformParamsToQuery = curry((uid: UID.Schema, params: any) => {\n const query = strapi.get('query-params').transform(uid, params);\n\n return assoc('where', { ...params?.lookup, ...query.where }, query);\n});\n\nexport { transformParamsToQuery };\n"],"names":["curry","assoc"],"mappings":";;;AAIA,MAAM,yBAAyBA,GAAA,MAAM,CAAC,KAAiB,WAAgB;AACrE,QAAM,QAAQ,OAAO,IAAI,cAAc,EAAE,UAAU,KAAK,MAAM;AAEvD,SAAAC,GAAA,MAAM,SAAS,EAAE,GAAG,QAAQ,QAAQ,GAAG,MAAM,SAAS,KAAK;AACpE,CAAC;;"}
1
+ {"version":3,"file":"query.js","sources":["../../../../src/services/document-service/transform/query.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { curry, assoc } from 'lodash/fp';\n\nconst transformParamsToQuery = curry((uid: UID.Schema, params: any) => {\n const query = strapi.get('query-params').transform(uid, params);\n\n return assoc('where', { ...params?.lookup, ...query.where }, query);\n});\n\nexport { transformParamsToQuery };\n"],"names":["curry","assoc"],"mappings":";;;AAIA,MAAM,yBAAyBA,GAAA,MAAM,CAAC,KAAiB,WAAgB;AACrE,QAAM,QAAQ,OAAO,IAAI,cAAc,EAAE,UAAU,KAAK,MAAM;AAEvD,SAAAC,GAAA,MAAM,SAAS,EAAE,GAAG,QAAQ,QAAQ,GAAG,MAAM,MAAM,GAAG,KAAK;AACpE,CAAC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"query.mjs","sources":["../../../../src/services/document-service/transform/query.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { curry, assoc } from 'lodash/fp';\n\nconst transformParamsToQuery = curry((uid: UID.Schema, params: any) => {\n const query = strapi.get('query-params').transform(uid, params);\n\n return assoc('where', { ...params?.lookup, ...query.where }, query);\n});\n\nexport { transformParamsToQuery };\n"],"names":[],"mappings":";AAIA,MAAM,yBAAyB,MAAM,CAAC,KAAiB,WAAgB;AACrE,QAAM,QAAQ,OAAO,IAAI,cAAc,EAAE,UAAU,KAAK,MAAM;AAEvD,SAAA,MAAM,SAAS,EAAE,GAAG,QAAQ,QAAQ,GAAG,MAAM,SAAS,KAAK;AACpE,CAAC;"}
1
+ {"version":3,"file":"query.mjs","sources":["../../../../src/services/document-service/transform/query.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { curry, assoc } from 'lodash/fp';\n\nconst transformParamsToQuery = curry((uid: UID.Schema, params: any) => {\n const query = strapi.get('query-params').transform(uid, params);\n\n return assoc('where', { ...params?.lookup, ...query.where }, query);\n});\n\nexport { transformParamsToQuery };\n"],"names":[],"mappings":";AAIA,MAAM,yBAAyB,MAAM,CAAC,KAAiB,WAAgB;AACrE,QAAM,QAAQ,OAAO,IAAI,cAAc,EAAE,UAAU,KAAK,MAAM;AAEvD,SAAA,MAAM,SAAS,EAAE,GAAG,QAAQ,QAAQ,GAAG,MAAM,MAAM,GAAG,KAAK;AACpE,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID } from '@strapi/types';\nimport { relations } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { LongHandDocument } from '../utils/types';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\n/**\n * Load a relation documentId into the idMap.\n */\nconst addRelationDocId = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n targetStatus.forEach((status) => {\n idMap.add({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status,\n });\n });\n }\n);\n\n/**\n * Iterate over all relations of a data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ attribute, value }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const addDocId = addRelationDocId(idMap, source);\n\n return mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Regular relations will always target the same target\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid = isPolymorphicRelation ? relation.__type : attribute.target;\n\n addDocId(targetUid, relation);\n\n // Handle positional arguments\n const position = relation.position;\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position?.before) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.before });\n }\n\n if (position?.after) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.after });\n }\n\n return relation;\n }, value as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["relations","curry","getRelationTargetLocale","getRelationTargetStatus","traverseEntityRelations","mapRelation"],"mappings":";;;;;;;AAUA,MAAM,EAAE,cAAkB,IAAAA;AAW1B,MAAM,mBAAmBC,GAAA;AAAA,EACvB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAC9E,UAAA,eAAeC,6BAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEK,UAAA,eAAeC,2BAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEY,iBAAA,QAAQ,CAAC,WAAW;AAC/B,YAAM,IAAI;AAAA,QACR,KAAK;AAAA,QACL,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EACH;AACF;AAMA,MAAM,iBAAiB,CAAC,OAAc,MAA2B,WAAoB;AAC5E,SAAAC,YAAA;AAAA,IACL,OAAO,EAAE,WAAW,YAAY;AAC9B,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AACM,YAAA,wBAAwB,cAAc,SAAS;AAC/C,YAAA,WAAW,iBAAiB,OAAO,MAAM;AAExC,aAAAC,YAAAA,YAAY,CAAC,aAAa;AAC/B,YAAI,CAAC,YAAY,CAAC,SAAS,YAAY;AAC9B,iBAAA;AAAA,QACT;AAIA,cAAM,YAAY,wBAAwB,SAAS,SAAS,UAAU;AAEtE,iBAAS,WAAW,QAAQ;AAG5B,cAAM,WAAW,SAAS;AAG1B,YAAI,oBAAoB;AACpB,YAAA,yBAAyB,UAAU,QAAQ;AAC7C,8BAAoB,SAAS;AAAA,QAC/B;AAEA,YAAI,UAAU,QAAQ;AACX,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,OAAA,CAAQ;AAAA,QACvF;AAEA,YAAI,UAAU,OAAO;AACV,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,MAAA,CAAO;AAAA,QACtF;AAEO,eAAA;AAAA,SACN,KAAY;AAAA,IACjB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID } from '@strapi/types';\nimport { relations } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { LongHandDocument } from '../utils/types';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\n/**\n * Load a relation documentId into the idMap.\n */\nconst addRelationDocId = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n targetStatus.forEach((status) => {\n idMap.add({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status,\n });\n });\n }\n);\n\n/**\n * Iterate over all relations of a data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ attribute, value }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const addDocId = addRelationDocId(idMap, source);\n\n return mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Regular relations will always target the same target\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid = isPolymorphicRelation ? relation.__type : attribute.target;\n\n addDocId(targetUid, relation);\n\n // Handle positional arguments\n const position = relation.position;\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position?.before) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.before });\n }\n\n if (position?.after) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.after });\n }\n\n return relation;\n }, value as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["relations","curry","getRelationTargetLocale","getRelationTargetStatus","traverseEntityRelations","mapRelation"],"mappings":";;;;;;;AAUA,MAAM,EAAE,cAAkB,IAAAA,YAAA;AAW1B,MAAM,mBAAmBC,GAAA;AAAA,EACvB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAC9E,UAAA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AM,EAAE;AAAA,IAC9E;AAAA,EACF;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID } from '@strapi/types';\nimport { relations } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { LongHandDocument } from '../utils/types';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\n/**\n * Load a relation documentId into the idMap.\n */\nconst addRelationDocId = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n targetStatus.forEach((status) => {\n idMap.add({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status,\n });\n });\n }\n);\n\n/**\n * Iterate over all relations of a data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ attribute, value }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const addDocId = addRelationDocId(idMap, source);\n\n return mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Regular relations will always target the same target\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid = isPolymorphicRelation ? relation.__type : attribute.target;\n\n addDocId(targetUid, relation);\n\n // Handle positional arguments\n const position = relation.position;\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position?.before) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.before });\n }\n\n if (position?.after) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.after });\n }\n\n return relation;\n }, value as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["traverseEntityRelations","mapRelation"],"mappings":";;;;;AAUA,MAAM,EAAE,cAAkB,IAAA;AAW1B,MAAM,mBAAmB;AAAA,EACvB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAC9E,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEK,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEY,iBAAA,QAAQ,CAAC,WAAW;AAC/B,YAAM,IAAI;AAAA,QACR,KAAK;AAAA,QACL,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EACH;AACF;AAMA,MAAM,iBAAiB,CAAC,OAAc,MAA2B,WAAoB;AAC5E,SAAAA;AAAAA,IACL,OAAO,EAAE,WAAW,YAAY;AAC9B,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AACM,YAAA,wBAAwB,cAAc,SAAS;AAC/C,YAAA,WAAW,iBAAiB,OAAO,MAAM;AAExC,aAAAC,mBAAY,CAAC,aAAa;AAC/B,YAAI,CAAC,YAAY,CAAC,SAAS,YAAY;AAC9B,iBAAA;AAAA,QACT;AAIA,cAAM,YAAY,wBAAwB,SAAS,SAAS,UAAU;AAEtE,iBAAS,WAAW,QAAQ;AAG5B,cAAM,WAAW,SAAS;AAG1B,YAAI,oBAAoB;AACpB,YAAA,yBAAyB,UAAU,QAAQ;AAC7C,8BAAoB,SAAS;AAAA,QAC/B;AAEA,YAAI,UAAU,QAAQ;AACX,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,OAAA,CAAQ;AAAA,QACvF;AAEA,YAAI,UAAU,OAAO;AACV,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,MAAA,CAAO;AAAA,QACtF;AAEO,eAAA;AAAA,SACN,KAAY;AAAA,IACjB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/extract/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport { UID } from '@strapi/types';\nimport { relations } from '@strapi/utils';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\nimport { LongHandDocument } from '../utils/types';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n}\n\n/**\n * Load a relation documentId into the idMap.\n */\nconst addRelationDocId = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n targetStatus.forEach((status) => {\n idMap.add({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status,\n });\n });\n }\n);\n\n/**\n * Iterate over all relations of a data object and extract all relational document ids.\n * Those will later be transformed to entity ids.\n */\nconst extractDataIds = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ attribute, value }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const addDocId = addRelationDocId(idMap, source);\n\n return mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Regular relations will always target the same target\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid = isPolymorphicRelation ? relation.__type : attribute.target;\n\n addDocId(targetUid, relation);\n\n // Handle positional arguments\n const position = relation.position;\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position?.before) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.before });\n }\n\n if (position?.after) {\n addDocId(positionTargetUid, { ...relation, ...position, documentId: position.after });\n }\n\n return relation;\n }, value as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { extractDataIds };\n"],"names":["traverseEntityRelations","mapRelation"],"mappings":";;;;;AAUA,MAAM,EAAE,cAAkB,IAAA;AAW1B,MAAM,mBAAmB;AAAA,EACvB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAC9E,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEK,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAEY,iBAAA,QAAQ,CAAC,WAAW;AAC/B,YAAM,IAAI;AAAA,QACR,KAAK;AAAA,QACL,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA;AAEL;AAMA,MAAM,iBAAiB,CAAC,OAAc,MAA2B,WAAoB;AAC5E,SAAAA;AAAAA,IACL,OAAO,EAAE,WAAW,YAAY;AAC9B,UAAI,CAAC,WAAW;AACd;AAAA,MAAA;AAEI,YAAA,wBAAwB,cAAc,SAAS;AAC/C,YAAA,WAAW,iBAAiB,OAAO,MAAM;AAExC,aAAAC,mBAAY,CAAC,aAAa;AAC/B,YAAI,CAAC,YAAY,CAAC,SAAS,YAAY;AAC9B,iBAAA;AAAA,QAAA;AAKT,cAAM,YAAY,wBAAwB,SAAS,SAAS,UAAU;AAEtE,iBAAS,WAAW,QAAQ;AAG5B,cAAM,WAAW,SAAS;AAG1B,YAAI,oBAAoB;AACpB,YAAA,yBAAyB,UAAU,QAAQ;AAC7C,8BAAoB,SAAS;AAAA,QAAA;AAG/B,YAAI,UAAU,QAAQ;AACX,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,QAAQ;AAAA,QAAA;AAGvF,YAAI,UAAU,OAAO;AACV,mBAAA,mBAAmB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,OAAO;AAAA,QAAA;AAG/E,eAAA;AAAA,SACN,KAAY;AAAA,IACjB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EACF;AACF;"}
@@ -26,8 +26,7 @@ const getRelationIds = fp.curry(
26
26
  locale: targetLocale,
27
27
  status: tStatus
28
28
  });
29
- if (entryId)
30
- ids.push(entryId);
29
+ if (entryId) ids.push(entryId);
31
30
  }
32
31
  if (!ids.length && !source.allowMissingId) {
33
32
  throw new strapiUtils.errors.ValidationError(
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform all relational document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid: UID.Schema = isPolymorphicRelation ? relation.__type : attribute.target;\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, value as any);\n\n set(key, newRelation as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["relations","curry","getRelationTargetLocale","getRelationTargetStatus","errors","traverseEntityRelations","mapRelation","newRelation"],"mappings":";;;;;;;AAWA,MAAM,EAAE,cAAkB,IAAAA;AAY1B,MAAM,iBAAiBC,GAAA;AAAA,EACrB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAE9E,UAAA,eAAeC,6BAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAGK,UAAA,eAAeC,2BAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAED,UAAM,MAAY,CAAA;AAKlB,eAAW,WAAW,cAAc;AAC5B,YAAA,UAAU,MAAM,IAAI;AAAA,QACxB,KAAK;AAAA,QACL,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR,QAAQ;AAAA,MAAA,CACT;AAEG,UAAA;AAAS,YA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AAI,uBAAuB;AACzBA,yBAAY,SAAS;AAAA,UACvB;AAEOA,iBAAAA;AAAAA,QAAA,CACR;AAAA,SACA,KAAY;AAEf,UAAI,KAAK,WAAkB;AAAA,IAC7B;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"data-ids.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform all relational document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid: UID.Schema = isPolymorphicRelation ? relation.__type : attribute.target;\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, value as any);\n\n set(key, newRelation as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["relations","curry","getRelationTargetLocale","getRelationTargetStatus","errors","traverseEntityRelations","mapRelation","newRelation"],"mappings":";;;;;;;AAWA,MAAM,EAAE,cAAkB,IAAAA,YAAA;AAY1B,MAAM,iBAA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AAAA,QAAA;AAG/B,YAAI,SAAS,QAAQ;AACb,gBAAA,iBAAiB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,OAAO;AACzE,gBAAA,YAAkB,OAAO,mBAAmB,cAAc;AACvD,mBAAA,SAAS,UAAU,GAAG,CAAC;AAAA,QAAA;AAGlC,YAAI,SAAS,OAAO;AACZ,gBAAA,gBAAgB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,MAAM;AAC7E,mBAAS,QAAQ,OAAO,mBAAmB,aAAa,EAAE,GAAG,CAAC;AAAA,QAAA;AAIzD,eAAA,KAAK,IAAI,CAAC,OAAO;AAChBC,gBAAAA,eAAc,EAAE,GAAG;AAEzB,cAAI,SAAS,UAAU;AACrBA,yBAAY,WAAW;AAAA,UAAA;AAIzB,cAAI,uBAAuB;AACzBA,yBAAY,SAAS;AAAA,UAAA;AAGhBA,iBAAAA;AAAAA,QAAA,CACR;AAAA,SACA,KAAY;AAEf,UAAI,KAAK,WAAkB;AAAA,IAC7B;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EACF;AACF;;"}
@@ -24,8 +24,7 @@ const getRelationIds = curry(
24
24
  locale: targetLocale,
25
25
  status: tStatus
26
26
  });
27
- if (entryId)
28
- ids.push(entryId);
27
+ if (entryId) ids.push(entryId);
29
28
  }
30
29
  if (!ids.length && !source.allowMissingId) {
31
30
  throw new errors.ValidationError(
@@ -1 +1 @@
1
- {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform all relational document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid: UID.Schema = isPolymorphicRelation ? relation.__type : attribute.target;\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, value as any);\n\n set(key, newRelation as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["traverseEntityRelations","mapRelation","newRelation"],"mappings":";;;;;AAWA,MAAM,EAAE,cAAkB,IAAA;AAY1B,MAAM,iBAAiB;AAAA,EACrB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAE9E,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAGK,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAED,UAAM,MAAY,CAAA;AAKlB,eAAW,WAAW,cAAc;AAC5B,YAAA,UAAU,MAAM,IAAI;AAAA,QACxB,KAAK;AAAA,QACL,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR,QAAQ;AAAA,MAAA,CACT;AAEG,UAAA;AAAS,YAAI,KAAK,OAAO;AAAA,IAC/B;AAEA,QAAI,CAAC,IAAI,UAAU,CAAC,OAAO,gBAAgB;AACzC,YAAM,IAAI,OAAO;AAAA,QACf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A,IAC7B;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"data-ids.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/data-ids.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID } from '@strapi/types';\nimport { errors, relations } from '@strapi/utils';\n\nimport { ID, LongHandDocument } from '../utils/types';\nimport { IdMap } from '../../id-map';\nimport { getRelationTargetLocale } from '../utils/i18n';\nimport { getRelationTargetStatus } from '../utils/dp';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\nconst { isPolymorphic } = relations;\n\ninterface Options {\n uid: UID.Schema;\n locale?: string | null;\n status?: 'draft' | 'published';\n allowMissingId?: boolean; // Whether to ignore missing ids and not throw any error\n}\n\n/**\n * Get the entry ids for a given documentId.\n */\nconst getRelationIds = curry(\n (idMap: IdMap, source: Options, targetUid: UID.Schema, relation: LongHandDocument) => {\n // locale to connect to\n const targetLocale = getRelationTargetLocale(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceLocale: source.locale,\n });\n\n // status(es) to connect to\n const targetStatus = getRelationTargetStatus(relation, {\n targetUid,\n sourceUid: source.uid,\n sourceStatus: source.status,\n });\n\n const ids: ID[] = [];\n\n // Find mapping between documentID -> id(s).\n // There are scenarios where a single documentID can map to multiple ids.\n // e.g when connecting Non DP -> DP and connecting to both the draft and publish version at the same time\n for (const tStatus of targetStatus) {\n const entryId = idMap.get({\n uid: targetUid,\n documentId: relation.documentId,\n locale: targetLocale,\n status: tStatus,\n });\n\n if (entryId) ids.push(entryId);\n }\n\n if (!ids.length && !source.allowMissingId) {\n throw new errors.ValidationError(\n `Document with id \"${relation.documentId}\", locale \"${targetLocale}\" not found`\n );\n }\n\n return ids;\n }\n);\n\n/**\n * Iterate over all relations of a data object and transform all relational document ids to entity ids.\n */\nconst transformDataIdsVisitor = (idMap: IdMap, data: Record<string, any>, source: Options) => {\n return traverseEntityRelations(\n async ({ key, value, attribute }, { set }) => {\n if (!attribute) {\n return;\n }\n const isPolymorphicRelation = isPolymorphic(attribute);\n const getIds = getRelationIds(idMap, source);\n\n // Transform the relation documentId to entity id\n const newRelation = await mapRelation((relation) => {\n if (!relation || !relation.documentId) {\n return relation;\n }\n\n // Find relational attributes, and return the document ids\n // if its a polymorphic relation we need to get it from the data itself\n const targetUid: UID.Schema = isPolymorphicRelation ? relation.__type : attribute.target;\n const ids: ID[] = getIds(targetUid, relation);\n\n // Handle positional arguments\n const position = { ...relation.position };\n\n // The positional relation target uid can be different for polymorphic relations\n let positionTargetUid: UID.Schema = targetUid;\n if (isPolymorphicRelation && position?.__type) {\n positionTargetUid = position.__type;\n }\n\n if (position.before) {\n const beforeRelation = { ...relation, ...position, documentId: position.before };\n const beforeIds: ID[] = getIds(positionTargetUid, beforeRelation);\n position.before = beforeIds.at(0);\n }\n\n if (position.after) {\n const afterRelation = { ...relation, ...position, documentId: position.after };\n position.after = getIds(positionTargetUid, afterRelation).at(0);\n }\n\n // Transform all ids to new relations\n return ids?.map((id) => {\n const newRelation = { id } as typeof relation;\n\n if (relation.position) {\n newRelation.position = position;\n }\n\n // Insert type if its a polymorphic relation\n if (isPolymorphicRelation) {\n newRelation.__type = targetUid;\n }\n\n return newRelation;\n });\n }, value as any);\n\n set(key, newRelation as any);\n },\n { schema: strapi.getModel(source.uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { transformDataIdsVisitor };\n"],"names":["traverseEntityRelations","mapRelation","newRelation"],"mappings":";;;;;AAWA,MAAM,EAAE,cAAkB,IAAA;AAY1B,MAAM,iBAAiB;AAAA,EACrB,CAAC,OAAc,QAAiB,WAAuB,aAA+B;AAE9E,UAAA,eAAe,wBAAwB,UAAU;AAAA,MACrD;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IAAA,CACtB;AAGK,UAAA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AAA;AAGlC,YAAI,SAAS,OAAO;AACZ,gBAAA,gBAAgB,EAAE,GAAG,UAAU,GAAG,UAAU,YAAY,SAAS,MAAM;AAC7E,mBAAS,QAAQ,OAAO,mBAAmB,aAAa,EAAE,GAAG,CAAC;AAAA,QAAA;AAIzD,eAAA,KAAK,IAAI,CAAC,OAAO;AAChBC,gBAAAA,eAAc,EAAE,GAAG;AAEzB,cAAI,SAAS,UAAU;AACrBA,yBAAY,WAAW;AAAA,UAAA;AAIzB,cAAI,uBAAuB;AACzBA,yBAAY,SAAS;AAAA,UAAA;AAGhBA,iBAAAA;AAAAA,QAAA,CACR;AAAA,SACA,KAAY;AAEf,UAAI,KAAK,WAAkB;AAAA,IAC7B;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,OAAO,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IAC9E;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-locale.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/default-locale.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { getDefaultLocale, isLocalizedContentType } from '../utils/i18n';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\n/**\n * In scenarios like Non i18n CT -> i18n CT\n * relations can be connected to multiple locales,\n * in case user does not provide the locale, this sets it to the default one.\n */\nconst setDefaultLocaleToRelations = (data: Record<string, any>, uid: UID.Schema) => {\n // I18n CT -> anything will already have a locale set (source locale)\n if (isLocalizedContentType(uid)) {\n return data;\n }\n\n // Store the default locale to avoid multiple calls\n let defaultLocale: string;\n\n /**\n * Traverse the entity input data and set the default locale to relations\n */\n return traverseEntityRelations(\n async ({ key, value }, { set }) => {\n /**\n * Assign default locale on long hand expressed relations\n * e.g { documentId } -> { documentId, locale }\n */\n const relation = await mapRelation(async (relation) => {\n if (!relation || !relation?.documentId || relation?.locale) {\n return relation;\n }\n\n // Set default locale if not provided\n if (!defaultLocale) {\n defaultLocale = await getDefaultLocale();\n }\n\n // Assign default locale to the positional argument\n const position = relation.position;\n if (position && typeof position === 'object' && !position.locale) {\n relation.position.locale = defaultLocale;\n }\n\n return { ...relation, locale: defaultLocale };\n }, value as any);\n\n // @ts-expect-error - fix type\n set(key, relation);\n },\n { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { setDefaultLocaleToRelations };\n"],"names":["isLocalizedContentType","traverseEntityRelations","mapRelation","relation","getDefaultLocale"],"mappings":";;;;AAUM,MAAA,8BAA8B,CAAC,MAA2B,QAAoB;AAE9E,MAAAA,KAAAA,uBAAuB,GAAG,GAAG;AACxB,WAAA;AAAA,EACT;AAGI,MAAA;AAKG,SAAAC,YAAA;AAAA,IACL,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU;AAKjC,YAAM,WAAW,MAAMC,wBAAY,OAAOC,cAAa;AACrD,YAAI,CAACA,aAAY,CAACA,WAAU,cAAcA,WAAU,QAAQ;AACnDA,iBAAAA;AAAAA,QACT;AAGA,YAAI,CAAC,eAAe;AAClB,0BAAgB,MAAMC,KAAAA;QACxB;AAGA,cAAM,WAAWD,UAAS;AAC1B,YAAI,YAAY,OAAO,aAAa,YAAY,CAAC,SAAS,QAAQ;AAChEA,oBAAS,SAAS,SAAS;AAAA,QAC7B;AAEA,eAAO,EAAE,GAAGA,WAAU,QAAQ,cAAc;AAAA,SAC3C,KAAY;AAGf,UAAI,KAAK,QAAQ;AAAA,IACnB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IACvE;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"default-locale.js","sources":["../../../../../../src/services/document-service/transform/relations/transform/default-locale.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { getDefaultLocale, isLocalizedContentType } from '../utils/i18n';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\n/**\n * In scenarios like Non i18n CT -> i18n CT\n * relations can be connected to multiple locales,\n * in case user does not provide the locale, this sets it to the default one.\n */\nconst setDefaultLocaleToRelations = (data: Record<string, any>, uid: UID.Schema) => {\n // I18n CT -> anything will already have a locale set (source locale)\n if (isLocalizedContentType(uid)) {\n return data;\n }\n\n // Store the default locale to avoid multiple calls\n let defaultLocale: string;\n\n /**\n * Traverse the entity input data and set the default locale to relations\n */\n return traverseEntityRelations(\n async ({ key, value }, { set }) => {\n /**\n * Assign default locale on long hand expressed relations\n * e.g { documentId } -> { documentId, locale }\n */\n const relation = await mapRelation(async (relation) => {\n if (!relation || !relation?.documentId || relation?.locale) {\n return relation;\n }\n\n // Set default locale if not provided\n if (!defaultLocale) {\n defaultLocale = await getDefaultLocale();\n }\n\n // Assign default locale to the positional argument\n const position = relation.position;\n if (position && typeof position === 'object' && !position.locale) {\n relation.position.locale = defaultLocale;\n }\n\n return { ...relation, locale: defaultLocale };\n }, value as any);\n\n // @ts-expect-error - fix type\n set(key, relation);\n },\n { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { setDefaultLocaleToRelations };\n"],"names":["isLocalizedContentType","traverseEntityRelations","mapRelation","relation","getDefaultLocale"],"mappings":";;;;AAUM,MAAA,8BAA8B,CAAC,MAA2B,QAAoB;AAE9E,MAAAA,KAAAA,uBAAuB,GAAG,GAAG;AACxB,WAAA;AAAA,EAAA;AAIL,MAAA;AAKG,SAAAC,YAAA;AAAA,IACL,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU;AAKjC,YAAM,WAAW,MAAMC,wBAAY,OAAOC,cAAa;AACrD,YAAI,CAACA,aAAY,CAACA,WAAU,cAAcA,WAAU,QAAQ;AACnDA,iBAAAA;AAAAA,QAAA;AAIT,YAAI,CAAC,eAAe;AAClB,0BAAgB,MAAMC,KAAAA,iBAAiB;AAAA,QAAA;AAIzC,cAAM,WAAWD,UAAS;AAC1B,YAAI,YAAY,OAAO,aAAa,YAAY,CAAC,SAAS,QAAQ;AAChEA,oBAAS,SAAS,SAAS;AAAA,QAAA;AAG7B,eAAO,EAAE,GAAGA,WAAU,QAAQ,cAAc;AAAA,SAC3C,KAAY;AAGf,UAAI,KAAK,QAAQ;AAAA,IACnB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IACvE;AAAA,EACF;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-locale.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/default-locale.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { getDefaultLocale, isLocalizedContentType } from '../utils/i18n';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\n/**\n * In scenarios like Non i18n CT -> i18n CT\n * relations can be connected to multiple locales,\n * in case user does not provide the locale, this sets it to the default one.\n */\nconst setDefaultLocaleToRelations = (data: Record<string, any>, uid: UID.Schema) => {\n // I18n CT -> anything will already have a locale set (source locale)\n if (isLocalizedContentType(uid)) {\n return data;\n }\n\n // Store the default locale to avoid multiple calls\n let defaultLocale: string;\n\n /**\n * Traverse the entity input data and set the default locale to relations\n */\n return traverseEntityRelations(\n async ({ key, value }, { set }) => {\n /**\n * Assign default locale on long hand expressed relations\n * e.g { documentId } -> { documentId, locale }\n */\n const relation = await mapRelation(async (relation) => {\n if (!relation || !relation?.documentId || relation?.locale) {\n return relation;\n }\n\n // Set default locale if not provided\n if (!defaultLocale) {\n defaultLocale = await getDefaultLocale();\n }\n\n // Assign default locale to the positional argument\n const position = relation.position;\n if (position && typeof position === 'object' && !position.locale) {\n relation.position.locale = defaultLocale;\n }\n\n return { ...relation, locale: defaultLocale };\n }, value as any);\n\n // @ts-expect-error - fix type\n set(key, relation);\n },\n { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { setDefaultLocaleToRelations };\n"],"names":["traverseEntityRelations","mapRelation","relation"],"mappings":";;AAUM,MAAA,8BAA8B,CAAC,MAA2B,QAAoB;AAE9E,MAAA,uBAAuB,GAAG,GAAG;AACxB,WAAA;AAAA,EACT;AAGI,MAAA;AAKG,SAAAA;AAAAA,IACL,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU;AAKjC,YAAM,WAAW,MAAMC,mBAAY,OAAOC,cAAa;AACrD,YAAI,CAACA,aAAY,CAACA,WAAU,cAAcA,WAAU,QAAQ;AACnDA,iBAAAA;AAAAA,QACT;AAGA,YAAI,CAAC,eAAe;AAClB,0BAAgB,MAAM;QACxB;AAGA,cAAM,WAAWA,UAAS;AAC1B,YAAI,YAAY,OAAO,aAAa,YAAY,CAAC,SAAS,QAAQ;AAChEA,oBAAS,SAAS,SAAS;AAAA,QAC7B;AAEA,eAAO,EAAE,GAAGA,WAAU,QAAQ,cAAc;AAAA,SAC3C,KAAY;AAGf,UAAI,KAAK,QAAQ;AAAA,IACnB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IACvE;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"default-locale.mjs","sources":["../../../../../../src/services/document-service/transform/relations/transform/default-locale.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\n\nimport { getDefaultLocale, isLocalizedContentType } from '../utils/i18n';\nimport { mapRelation, traverseEntityRelations } from '../utils/map-relation';\n\n/**\n * In scenarios like Non i18n CT -> i18n CT\n * relations can be connected to multiple locales,\n * in case user does not provide the locale, this sets it to the default one.\n */\nconst setDefaultLocaleToRelations = (data: Record<string, any>, uid: UID.Schema) => {\n // I18n CT -> anything will already have a locale set (source locale)\n if (isLocalizedContentType(uid)) {\n return data;\n }\n\n // Store the default locale to avoid multiple calls\n let defaultLocale: string;\n\n /**\n * Traverse the entity input data and set the default locale to relations\n */\n return traverseEntityRelations(\n async ({ key, value }, { set }) => {\n /**\n * Assign default locale on long hand expressed relations\n * e.g { documentId } -> { documentId, locale }\n */\n const relation = await mapRelation(async (relation) => {\n if (!relation || !relation?.documentId || relation?.locale) {\n return relation;\n }\n\n // Set default locale if not provided\n if (!defaultLocale) {\n defaultLocale = await getDefaultLocale();\n }\n\n // Assign default locale to the positional argument\n const position = relation.position;\n if (position && typeof position === 'object' && !position.locale) {\n relation.position.locale = defaultLocale;\n }\n\n return { ...relation, locale: defaultLocale };\n }, value as any);\n\n // @ts-expect-error - fix type\n set(key, relation);\n },\n { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },\n data\n );\n};\n\nexport { setDefaultLocaleToRelations };\n"],"names":["traverseEntityRelations","mapRelation","relation"],"mappings":";;AAUM,MAAA,8BAA8B,CAAC,MAA2B,QAAoB;AAE9E,MAAA,uBAAuB,GAAG,GAAG;AACxB,WAAA;AAAA,EAAA;AAIL,MAAA;AAKG,SAAAA;AAAAA,IACL,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU;AAKjC,YAAM,WAAW,MAAMC,mBAAY,OAAOC,cAAa;AACrD,YAAI,CAACA,aAAY,CAACA,WAAU,cAAcA,WAAU,QAAQ;AACnDA,iBAAAA;AAAAA,QAAA;AAIT,YAAI,CAAC,eAAe;AAClB,0BAAgB,MAAM,iBAAiB;AAAA,QAAA;AAIzC,cAAM,WAAWA,UAAS;AAC1B,YAAI,YAAY,OAAO,aAAa,YAAY,CAAC,SAAS,QAAQ;AAChEA,oBAAS,SAAS,SAAS;AAAA,QAAA;AAG7B,eAAO,EAAE,GAAGA,WAAU,QAAQ,cAAc;AAAA,SAC3C,KAAY;AAGf,UAAI,KAAK,QAAQ;AAAA,IACnB;AAAA,IACA,EAAE,QAAQ,OAAO,SAAS,GAAG,GAAG,UAAU,OAAO,SAAS,KAAK,MAAM,EAAE;AAAA,IACvE;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"dp.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/dp.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\n\nimport { contentTypes } from '@strapi/utils';\nimport { UID } from '@strapi/types';\n\nimport { LongHandDocument } from './types';\n\ntype Status = 'draft' | 'published';\n\nexport const getRelationTargetStatus = (\n relation: Pick<LongHandDocument, 'documentId' | 'status'>,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceStatus?: Status;\n }\n): Status[] => {\n // Ignore if the target content type does not have draft and publish enabled\n const targetContentType = strapi.getModel(opts.targetUid);\n const sourceContentType = strapi.getModel(opts.sourceUid);\n\n const targetHasDP = contentTypes.hasDraftAndPublish(targetContentType);\n const sourceHasDP = contentTypes.hasDraftAndPublish(sourceContentType);\n\n if (!targetHasDP) {\n return ['published'];\n }\n\n /**\n * If both source and target have DP enabled,\n * connect it to the same status as the source status\n */\n if (sourceHasDP && !isNil(opts.sourceStatus)) {\n return [opts.sourceStatus];\n }\n\n /**\n * Use the status from the relation if it's set\n */\n if (relation.status) {\n switch (relation.status) {\n case 'published':\n return ['published'];\n default:\n // Default to draft if it's an invalid status (e.g. modified)\n return ['draft'];\n }\n }\n\n /**\n * If DP is disabled and relation does not specify any status\n * Connect to both draft and published versions\n */\n if (!sourceHasDP) {\n return ['draft', 'published'];\n }\n\n // Default to draft as a fallback\n return ['draft'];\n};\n"],"names":["contentTypes","isNil"],"mappings":";;;;AASa,MAAA,0BAA0B,CACrC,UACA,SAKa;AAEb,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AACxD,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AAElD,QAAA,cAAcA,YAAAA,aAAa,mBAAmB,iBAAiB;AAC/D,QAAA,cAAcA,YAAAA,aAAa,mBAAmB,iBAAiB;AAErE,MAAI,CAAC,aAAa;AAChB,WAAO,CAAC,WAAW;AAAA,EACrB;AAMA,MAAI,eAAe,CAACC,GAAAA,MAAM,KAAK,YAAY,GAAG;AACrC,WAAA,CAAC,KAAK,YAAY;AAAA,EAC3B;AAKA,MAAI,SAAS,QAAQ;AACnB,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,CAAC,WAAW;AAAA,MACrB;AAEE,eAAO,CAAC,OAAO;AAAA,IACnB;AAAA,EACF;AAMA,MAAI,CAAC,aAAa;AACT,WAAA,CAAC,SAAS,WAAW;AAAA,EAC9B;AAGA,SAAO,CAAC,OAAO;AACjB;;"}
1
+ {"version":3,"file":"dp.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/dp.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\n\nimport { contentTypes } from '@strapi/utils';\nimport { UID } from '@strapi/types';\n\nimport { LongHandDocument } from './types';\n\ntype Status = 'draft' | 'published';\n\nexport const getRelationTargetStatus = (\n relation: Pick<LongHandDocument, 'documentId' | 'status'>,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceStatus?: Status;\n }\n): Status[] => {\n // Ignore if the target content type does not have draft and publish enabled\n const targetContentType = strapi.getModel(opts.targetUid);\n const sourceContentType = strapi.getModel(opts.sourceUid);\n\n const targetHasDP = contentTypes.hasDraftAndPublish(targetContentType);\n const sourceHasDP = contentTypes.hasDraftAndPublish(sourceContentType);\n\n if (!targetHasDP) {\n return ['published'];\n }\n\n /**\n * If both source and target have DP enabled,\n * connect it to the same status as the source status\n */\n if (sourceHasDP && !isNil(opts.sourceStatus)) {\n return [opts.sourceStatus];\n }\n\n /**\n * Use the status from the relation if it's set\n */\n if (relation.status) {\n switch (relation.status) {\n case 'published':\n return ['published'];\n default:\n // Default to draft if it's an invalid status (e.g. modified)\n return ['draft'];\n }\n }\n\n /**\n * If DP is disabled and relation does not specify any status\n * Connect to both draft and published versions\n */\n if (!sourceHasDP) {\n return ['draft', 'published'];\n }\n\n // Default to draft as a fallback\n return ['draft'];\n};\n"],"names":["contentTypes","isNil"],"mappings":";;;;AASa,MAAA,0BAA0B,CACrC,UACA,SAKa;AAEb,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AACxD,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AAElD,QAAA,cAAcA,YAAAA,aAAa,mBAAmB,iBAAiB;AAC/D,QAAA,cAAcA,YAAAA,aAAa,mBAAmB,iBAAiB;AAErE,MAAI,CAAC,aAAa;AAChB,WAAO,CAAC,WAAW;AAAA,EAAA;AAOrB,MAAI,eAAe,CAACC,GAAAA,MAAM,KAAK,YAAY,GAAG;AACrC,WAAA,CAAC,KAAK,YAAY;AAAA,EAAA;AAM3B,MAAI,SAAS,QAAQ;AACnB,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,CAAC,WAAW;AAAA,MACrB;AAEE,eAAO,CAAC,OAAO;AAAA,IAAA;AAAA,EACnB;AAOF,MAAI,CAAC,aAAa;AACT,WAAA,CAAC,SAAS,WAAW;AAAA,EAAA;AAI9B,SAAO,CAAC,OAAO;AACjB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"dp.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/dp.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\n\nimport { contentTypes } from '@strapi/utils';\nimport { UID } from '@strapi/types';\n\nimport { LongHandDocument } from './types';\n\ntype Status = 'draft' | 'published';\n\nexport const getRelationTargetStatus = (\n relation: Pick<LongHandDocument, 'documentId' | 'status'>,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceStatus?: Status;\n }\n): Status[] => {\n // Ignore if the target content type does not have draft and publish enabled\n const targetContentType = strapi.getModel(opts.targetUid);\n const sourceContentType = strapi.getModel(opts.sourceUid);\n\n const targetHasDP = contentTypes.hasDraftAndPublish(targetContentType);\n const sourceHasDP = contentTypes.hasDraftAndPublish(sourceContentType);\n\n if (!targetHasDP) {\n return ['published'];\n }\n\n /**\n * If both source and target have DP enabled,\n * connect it to the same status as the source status\n */\n if (sourceHasDP && !isNil(opts.sourceStatus)) {\n return [opts.sourceStatus];\n }\n\n /**\n * Use the status from the relation if it's set\n */\n if (relation.status) {\n switch (relation.status) {\n case 'published':\n return ['published'];\n default:\n // Default to draft if it's an invalid status (e.g. modified)\n return ['draft'];\n }\n }\n\n /**\n * If DP is disabled and relation does not specify any status\n * Connect to both draft and published versions\n */\n if (!sourceHasDP) {\n return ['draft', 'published'];\n }\n\n // Default to draft as a fallback\n return ['draft'];\n};\n"],"names":[],"mappings":";;AASa,MAAA,0BAA0B,CACrC,UACA,SAKa;AAEb,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AACxD,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AAElD,QAAA,cAAc,aAAa,mBAAmB,iBAAiB;AAC/D,QAAA,cAAc,aAAa,mBAAmB,iBAAiB;AAErE,MAAI,CAAC,aAAa;AAChB,WAAO,CAAC,WAAW;AAAA,EACrB;AAMA,MAAI,eAAe,CAAC,MAAM,KAAK,YAAY,GAAG;AACrC,WAAA,CAAC,KAAK,YAAY;AAAA,EAC3B;AAKA,MAAI,SAAS,QAAQ;AACnB,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,CAAC,WAAW;AAAA,MACrB;AAEE,eAAO,CAAC,OAAO;AAAA,IACnB;AAAA,EACF;AAMA,MAAI,CAAC,aAAa;AACT,WAAA,CAAC,SAAS,WAAW;AAAA,EAC9B;AAGA,SAAO,CAAC,OAAO;AACjB;"}
1
+ {"version":3,"file":"dp.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/dp.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\n\nimport { contentTypes } from '@strapi/utils';\nimport { UID } from '@strapi/types';\n\nimport { LongHandDocument } from './types';\n\ntype Status = 'draft' | 'published';\n\nexport const getRelationTargetStatus = (\n relation: Pick<LongHandDocument, 'documentId' | 'status'>,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceStatus?: Status;\n }\n): Status[] => {\n // Ignore if the target content type does not have draft and publish enabled\n const targetContentType = strapi.getModel(opts.targetUid);\n const sourceContentType = strapi.getModel(opts.sourceUid);\n\n const targetHasDP = contentTypes.hasDraftAndPublish(targetContentType);\n const sourceHasDP = contentTypes.hasDraftAndPublish(sourceContentType);\n\n if (!targetHasDP) {\n return ['published'];\n }\n\n /**\n * If both source and target have DP enabled,\n * connect it to the same status as the source status\n */\n if (sourceHasDP && !isNil(opts.sourceStatus)) {\n return [opts.sourceStatus];\n }\n\n /**\n * Use the status from the relation if it's set\n */\n if (relation.status) {\n switch (relation.status) {\n case 'published':\n return ['published'];\n default:\n // Default to draft if it's an invalid status (e.g. modified)\n return ['draft'];\n }\n }\n\n /**\n * If DP is disabled and relation does not specify any status\n * Connect to both draft and published versions\n */\n if (!sourceHasDP) {\n return ['draft', 'published'];\n }\n\n // Default to draft as a fallback\n return ['draft'];\n};\n"],"names":[],"mappings":";;AASa,MAAA,0BAA0B,CACrC,UACA,SAKa;AAEb,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AACxD,QAAM,oBAAoB,OAAO,SAAS,KAAK,SAAS;AAElD,QAAA,cAAc,aAAa,mBAAmB,iBAAiB;AAC/D,QAAA,cAAc,aAAa,mBAAmB,iBAAiB;AAErE,MAAI,CAAC,aAAa;AAChB,WAAO,CAAC,WAAW;AAAA,EAAA;AAOrB,MAAI,eAAe,CAAC,MAAM,KAAK,YAAY,GAAG;AACrC,WAAA,CAAC,KAAK,YAAY;AAAA,EAAA;AAM3B,MAAI,SAAS,QAAQ;AACnB,YAAQ,SAAS,QAAQ;AAAA,MACvB,KAAK;AACH,eAAO,CAAC,WAAW;AAAA,MACrB;AAEE,eAAO,CAAC,OAAO;AAAA,IAAA;AAAA,EACnB;AAOF,MAAI,CAAC,aAAa;AACT,WAAA,CAAC,SAAS,WAAW;AAAA,EAAA;AAI9B,SAAO,CAAC,OAAO;AACjB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { UID } from '@strapi/types';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const targetLocale = relation.locale || opts.sourceLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Both source and target locales should match\n if (isSourceLocalized && isTargetLocalized) {\n return opts.sourceLocale;\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":";;AAGa,MAAA,yBAAyB,CAAC,QAAoB;AACnD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AACpC,SAAO,OAAO,OAAO,MAAM,EAAE,QAAQ,SAAS,EAAE;AAClD;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACG,QAAA,eAAe,SAAS,UAAU,KAAK;AAEvC,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAC1C,WAAO,KAAK;AAAA,EACd;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 { UID } from '@strapi/types';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const targetLocale = relation.locale || opts.sourceLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Both source and target locales should match\n if (isSourceLocalized && isTargetLocalized) {\n return opts.sourceLocale;\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":";;AAGa,MAAA,yBAAyB,CAAC,QAAoB;AACnD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AACpC,SAAO,OAAO,OAAO,MAAM,EAAE,QAAQ,SAAS,EAAE,iBAAiB;AACnE;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACG,QAAA,eAAe,SAAS,UAAU,KAAK;AAEvC,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAC1C,WAAO,KAAK;AAAA,EAAA;AAGd,MAAI,mBAAmB;AACd,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import { UID } from '@strapi/types';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const targetLocale = relation.locale || opts.sourceLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Both source and target locales should match\n if (isSourceLocalized && isTargetLocalized) {\n return opts.sourceLocale;\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":"AAGa,MAAA,yBAAyB,CAAC,QAAoB;AACnD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AACpC,SAAO,OAAO,OAAO,MAAM,EAAE,QAAQ,SAAS,EAAE;AAClD;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACG,QAAA,eAAe,SAAS,UAAU,KAAK;AAEvC,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAC1C,WAAO,KAAK;AAAA,EACd;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 { UID } from '@strapi/types';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: UID.Schema) => {\n const model = strapi.getModel(uid);\n return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nexport const getRelationTargetLocale = (\n relation: LongHandDocument,\n opts: {\n targetUid: UID.Schema;\n sourceUid: UID.Schema;\n sourceLocale?: string | null;\n }\n) => {\n const targetLocale = relation.locale || opts.sourceLocale;\n\n const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n // Both source and target locales should match\n if (isSourceLocalized && isTargetLocalized) {\n return opts.sourceLocale;\n }\n\n if (isTargetLocalized) {\n return targetLocale;\n }\n\n return null;\n};\n"],"names":[],"mappings":"AAGa,MAAA,yBAAyB,CAAC,QAAoB;AACnD,QAAA,QAAQ,OAAO,SAAS,GAAG;AAC1B,SAAA,OAAO,OAAO,MAAM,EAAE,QAAQ,eAAe,EAAE,uBAAuB,KAAK;AACpF;AAEO,MAAM,mBAAmB,MAAM;AACpC,SAAO,OAAO,OAAO,MAAM,EAAE,QAAQ,SAAS,EAAE,iBAAiB;AACnE;AAEa,MAAA,0BAA0B,CACrC,UACA,SAKG;AACG,QAAA,eAAe,SAAS,UAAU,KAAK;AAEvC,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AACzD,QAAA,oBAAoB,uBAAuB,KAAK,SAAS;AAG/D,MAAI,qBAAqB,mBAAmB;AAC1C,WAAO,KAAK;AAAA,EAAA;AAGd,MAAI,mBAAmB;AACd,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;"}
@@ -3,16 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const fp = require("lodash/fp");
4
4
  const strapiUtils = require("@strapi/utils");
5
5
  const isNumeric = (value) => {
6
- if (Array.isArray(value))
7
- return false;
6
+ if (Array.isArray(value)) return false;
8
7
  const parsed = parseInt(value, 10);
9
8
  return !Number.isNaN(parsed);
10
9
  };
11
10
  const toArray = (value) => {
12
- if (fp.isNil(value))
13
- return value;
14
- if (Array.isArray(value))
15
- return value;
11
+ if (fp.isNil(value)) return value;
12
+ if (Array.isArray(value)) return value;
16
13
  return [value];
17
14
  };
18
15
  const mapRelation = async (callback, rel, isRecursive = false) => {
@@ -1 +1 @@
1
- {"version":3,"file":"map-relation.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\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 toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) return value;\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n\n/**\n * There are multiple ways to create Strapi relations.\n * This is a utility to traverse and transform relation data\n *\n *\n * For consistency and ease of use, the response will always be an object with the following shape:\n * { set: [{...}], connect: [{...}], disconnect: [{...}] }\n *\n * @example\n * transformRelationData({\n * onLongHand: (relation) => {\n * // Change the id of the relation\n * return { id: 'other' };\n * },\n * }, relation)\n */\nconst mapRelation = async (\n callback: (relation: any) => any,\n rel: Relation,\n isRecursive = false\n): Promise<Relation> => {\n let relation: Relation = rel;\n\n const wrapInSet = (value: any) => {\n // Ignore wrapping if it's a recursive call\n if (isRecursive) {\n return value;\n }\n return { set: toArray(value) };\n };\n\n // undefined | null\n if (isNil(relation)) {\n return callback(relation);\n }\n\n // LongHand[] | ShortHand[]\n if (Array.isArray(relation)) {\n return async\n .map(relation, (r: Relation) => mapRelation(callback, r, true))\n .then((result: any) => result.flat().filter(Boolean))\n .then(wrapInSet);\n }\n\n // LongHand\n if (isObject(relation)) {\n // { id: 1 } || { documentId: 1 }\n if ('id' in relation || 'documentId' in relation) {\n const result = await callback(relation);\n return wrapInSet(result);\n }\n\n // If not connecting anything, return default visitor\n if (!relation.set && !relation.disconnect && !relation.connect) {\n return callback(relation);\n }\n\n // { set }\n if (relation.set) {\n const set: any = await mapRelation(callback, relation.set, true);\n relation = { ...relation, set: toArray(set) };\n }\n\n // { disconnect}\n if (relation.disconnect) {\n const disconnect: any = await mapRelation(callback, relation.disconnect, true);\n relation = { ...relation, disconnect: toArray(disconnect) };\n }\n\n // { connect }\n if (relation.connect) {\n // Transform the relation to connect\n const connect: any = await mapRelation(callback, relation.connect, true);\n relation = { ...relation, connect: toArray(connect) };\n }\n\n return relation;\n }\n\n // ShortHand\n if (isNumeric(relation)) {\n const result = await callback({ id: relation });\n return wrapInSet(result);\n }\n\n if (typeof relation === 'string') {\n const result = await callback({ documentId: relation });\n return wrapInSet(result);\n }\n\n // Anything else\n return callback(relation);\n};\n\ntype TraverseEntity = Parameters<typeof traverseEntity>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options: TraverseEntity[1],\n data: TraverseEntity[2]\n) => {\n return traverseEntity(\n async (options, utils) => {\n const { attribute } = options;\n\n if (!attribute) {\n return;\n }\n\n if (attribute.type !== 'relation') {\n return;\n }\n\n // TODO: Handle join columns\n if (attribute.useJoinTable === false) {\n return;\n }\n\n return visitor(options, utils);\n },\n options,\n data\n );\n};\n\nconst mapRelationCurried = curry(mapRelation);\nconst traverseEntityRelationsCurried = curry(traverseEntityRelations);\n\nexport {\n mapRelationCurried as mapRelation,\n traverseEntityRelationsCurried as traverseEntityRelations,\n};\n"],"names":["isNil","async","isObject","traverseEntity","options","curry"],"mappings":";;;;AAOA,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,UAAU,CAAC,UAAe;AAE9B,MAAIA,GAAAA,MAAM,KAAK;AAAU,WAAA;AACrB,MAAA,MAAM,QAAQ,KAAK;AAAU,WAAA;AAEjC,SAAO,CAAC,KAAK;AACf;AAkBA,MAAM,cAAc,OAClB,UACA,KACA,cAAc,UACQ;AACtB,MAAI,WAAqB;AAEnB,QAAA,YAAY,CAAC,UAAe;AAEhC,QAAI,aAAa;AACR,aAAA;AAAA,IACT;AACA,WAAO,EAAE,KAAK,QAAQ,KAAK,EAAE;AAA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AGA,SAAO,SAAS,QAAQ;AAC1B;AAOA,MAAM,0BAA0B,OAC9B,SACA,SACA,SACG;AACI,SAAAC,YAAA;AAAA,IACL,OAAOC,UAAS,UAAU;AAClB,YAAA,EAAE,UAAcA,IAAAA;AAEtB,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AAEI,UAAA,UAAU,SAAS,YAAY;AACjC;AAAA,MACF;AAGI,UAAA,UAAU,iBAAiB,OAAO;AACpC;AAAA,MACF;AAEO,aAAA,QAAQA,UAAS,KAAK;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqBC,SAAM,WAAW;AACtC,MAAA,iCAAiCA,SAAM,uBAAuB;;;"}
1
+ {"version":3,"file":"map-relation.js","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\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 toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) return value;\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n\n/**\n * There are multiple ways to create Strapi relations.\n * This is a utility to traverse and transform relation data\n *\n *\n * For consistency and ease of use, the response will always be an object with the following shape:\n * { set: [{...}], connect: [{...}], disconnect: [{...}] }\n *\n * @example\n * transformRelationData({\n * onLongHand: (relation) => {\n * // Change the id of the relation\n * return { id: 'other' };\n * },\n * }, relation)\n */\nconst mapRelation = async (\n callback: (relation: any) => any,\n rel: Relation,\n isRecursive = false\n): Promise<Relation> => {\n let relation: Relation = rel;\n\n const wrapInSet = (value: any) => {\n // Ignore wrapping if it's a recursive call\n if (isRecursive) {\n return value;\n }\n return { set: toArray(value) };\n };\n\n // undefined | null\n if (isNil(relation)) {\n return callback(relation);\n }\n\n // LongHand[] | ShortHand[]\n if (Array.isArray(relation)) {\n return async\n .map(relation, (r: Relation) => mapRelation(callback, r, true))\n .then((result: any) => result.flat().filter(Boolean))\n .then(wrapInSet);\n }\n\n // LongHand\n if (isObject(relation)) {\n // { id: 1 } || { documentId: 1 }\n if ('id' in relation || 'documentId' in relation) {\n const result = await callback(relation);\n return wrapInSet(result);\n }\n\n // If not connecting anything, return default visitor\n if (!relation.set && !relation.disconnect && !relation.connect) {\n return callback(relation);\n }\n\n // { set }\n if (relation.set) {\n const set: any = await mapRelation(callback, relation.set, true);\n relation = { ...relation, set: toArray(set) };\n }\n\n // { disconnect}\n if (relation.disconnect) {\n const disconnect: any = await mapRelation(callback, relation.disconnect, true);\n relation = { ...relation, disconnect: toArray(disconnect) };\n }\n\n // { connect }\n if (relation.connect) {\n // Transform the relation to connect\n const connect: any = await mapRelation(callback, relation.connect, true);\n relation = { ...relation, connect: toArray(connect) };\n }\n\n return relation;\n }\n\n // ShortHand\n if (isNumeric(relation)) {\n const result = await callback({ id: relation });\n return wrapInSet(result);\n }\n\n if (typeof relation === 'string') {\n const result = await callback({ documentId: relation });\n return wrapInSet(result);\n }\n\n // Anything else\n return callback(relation);\n};\n\ntype TraverseEntity = Parameters<typeof traverseEntity>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options: TraverseEntity[1],\n data: TraverseEntity[2]\n) => {\n return traverseEntity(\n async (options, utils) => {\n const { attribute } = options;\n\n if (!attribute) {\n return;\n }\n\n if (attribute.type !== 'relation') {\n return;\n }\n\n // TODO: Handle join columns\n if (attribute.useJoinTable === false) {\n return;\n }\n\n return visitor(options, utils);\n },\n options,\n data\n );\n};\n\nconst mapRelationCurried = curry(mapRelation);\nconst traverseEntityRelationsCurried = curry(traverseEntityRelations);\n\nexport {\n mapRelationCurried as mapRelation,\n traverseEntityRelationsCurried as traverseEntityRelations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EAAE;AAAA,IAAA;AAI9C,QAAI,SAAS,YAAY;AACvB,YAAM,aAAkB,MAAM,YAAY,UAAU,SAAS,YAAY,IAAI;AAC7E,iBAAW,EAAE,GAAG,UAAU,YAAY,QAAQ,UAAU,EAAE;AAAA,IAAA;AAI5D,QAAI,SAAS,SAAS;AAEpB,YAAM,UAAe,MAAM,YAAY,UAAU,SAAS,SAAS,IAAI;AACvE,iBAAW,EAAE,GAAG,UAAU,SAAS,QAAQ,OAAO,EAAE;AAAA,IAAA;AAG/C,WAAA;AAAA,EAAA;AAIL,MAAA,UAAU,QAAQ,GAAG;AACvB,UAAM,SAAS,MAAM,SAAS,EAAE,IAAI,UAAU;AAC9C,WAAO,UAAU,MAAM;AAAA,EAAA;AAGrB,MAAA,OAAO,aAAa,UAAU;AAChC,UAAM,SAAS,MAAM,SAAS,EAAE,YAAY,UAAU;AACtD,WAAO,UAAU,MAAM;AAAA,EAAA;AAIzB,SAAO,SAAS,QAAQ;AAC1B;AAOA,MAAM,0BAA0B,OAC9B,SACA,SACA,SACG;AACI,SAAAC,YAAA;AAAA,IACL,OAAOC,UAAS,UAAU;AAClB,YAAA,EAAE,cAAcA;AAEtB,UAAI,CAAC,WAAW;AACd;AAAA,MAAA;AAGE,UAAA,UAAU,SAAS,YAAY;AACjC;AAAA,MAAA;AAIE,UAAA,UAAU,iBAAiB,OAAO;AACpC;AAAA,MAAA;AAGK,aAAA,QAAQA,UAAS,KAAK;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEM,MAAA,qBAAqBC,SAAM,WAAW;AACtC,MAAA,iCAAiCA,SAAM,uBAAuB;;;"}
@@ -1,16 +1,13 @@
1
1
  import { curry, isNil, isObject } from "lodash/fp";
2
2
  import { async, traverseEntity } from "@strapi/utils";
3
3
  const isNumeric = (value) => {
4
- if (Array.isArray(value))
5
- return false;
4
+ if (Array.isArray(value)) return false;
6
5
  const parsed = parseInt(value, 10);
7
6
  return !Number.isNaN(parsed);
8
7
  };
9
8
  const toArray = (value) => {
10
- if (isNil(value))
11
- return value;
12
- if (Array.isArray(value))
13
- return value;
9
+ if (isNil(value)) return value;
10
+ if (Array.isArray(value)) return value;
14
11
  return [value];
15
12
  };
16
13
  const mapRelation = async (callback, rel, isRecursive = false) => {
@@ -1 +1 @@
1
- {"version":3,"file":"map-relation.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\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 toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) return value;\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n\n/**\n * There are multiple ways to create Strapi relations.\n * This is a utility to traverse and transform relation data\n *\n *\n * For consistency and ease of use, the response will always be an object with the following shape:\n * { set: [{...}], connect: [{...}], disconnect: [{...}] }\n *\n * @example\n * transformRelationData({\n * onLongHand: (relation) => {\n * // Change the id of the relation\n * return { id: 'other' };\n * },\n * }, relation)\n */\nconst mapRelation = async (\n callback: (relation: any) => any,\n rel: Relation,\n isRecursive = false\n): Promise<Relation> => {\n let relation: Relation = rel;\n\n const wrapInSet = (value: any) => {\n // Ignore wrapping if it's a recursive call\n if (isRecursive) {\n return value;\n }\n return { set: toArray(value) };\n };\n\n // undefined | null\n if (isNil(relation)) {\n return callback(relation);\n }\n\n // LongHand[] | ShortHand[]\n if (Array.isArray(relation)) {\n return async\n .map(relation, (r: Relation) => mapRelation(callback, r, true))\n .then((result: any) => result.flat().filter(Boolean))\n .then(wrapInSet);\n }\n\n // LongHand\n if (isObject(relation)) {\n // { id: 1 } || { documentId: 1 }\n if ('id' in relation || 'documentId' in relation) {\n const result = await callback(relation);\n return wrapInSet(result);\n }\n\n // If not connecting anything, return default visitor\n if (!relation.set && !relation.disconnect && !relation.connect) {\n return callback(relation);\n }\n\n // { set }\n if (relation.set) {\n const set: any = await mapRelation(callback, relation.set, true);\n relation = { ...relation, set: toArray(set) };\n }\n\n // { disconnect}\n if (relation.disconnect) {\n const disconnect: any = await mapRelation(callback, relation.disconnect, true);\n relation = { ...relation, disconnect: toArray(disconnect) };\n }\n\n // { connect }\n if (relation.connect) {\n // Transform the relation to connect\n const connect: any = await mapRelation(callback, relation.connect, true);\n relation = { ...relation, connect: toArray(connect) };\n }\n\n return relation;\n }\n\n // ShortHand\n if (isNumeric(relation)) {\n const result = await callback({ id: relation });\n return wrapInSet(result);\n }\n\n if (typeof relation === 'string') {\n const result = await callback({ documentId: relation });\n return wrapInSet(result);\n }\n\n // Anything else\n return callback(relation);\n};\n\ntype TraverseEntity = Parameters<typeof traverseEntity>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options: TraverseEntity[1],\n data: TraverseEntity[2]\n) => {\n return traverseEntity(\n async (options, utils) => {\n const { attribute } = options;\n\n if (!attribute) {\n return;\n }\n\n if (attribute.type !== 'relation') {\n return;\n }\n\n // TODO: Handle join columns\n if (attribute.useJoinTable === false) {\n return;\n }\n\n return visitor(options, utils);\n },\n options,\n data\n );\n};\n\nconst mapRelationCurried = curry(mapRelation);\nconst traverseEntityRelationsCurried = curry(traverseEntityRelations);\n\nexport {\n mapRelationCurried as mapRelation,\n traverseEntityRelationsCurried as traverseEntityRelations,\n};\n"],"names":["options"],"mappings":";;AAOA,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,UAAU,CAAC,UAAe;AAE9B,MAAI,MAAM,KAAK;AAAU,WAAA;AACrB,MA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AAQ,GAAG;AACvB,UAAM,SAAS,MAAM,SAAS,EAAE,IAAI,SAAU,CAAA;AAC9C,WAAO,UAAU,MAAM;AAAA,EACzB;AAEI,MAAA,OAAO,aAAa,UAAU;AAChC,UAAM,SAAS,MAAM,SAAS,EAAE,YAAY,SAAU,CAAA;AACtD,WAAO,UAAU,MAAM;AAAA,EACzB;AAGA,SAAO,SAAS,QAAQ;AAC1B;AAOA,MAAM,0BAA0B,OAC9B,SACA,SACA,SACG;AACI,SAAA;AAAA,IACL,OAAOA,UAAS,UAAU;AAClB,YAAA,EAAE,UAAcA,IAAAA;AAEtB,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AAEI,UAAA,UAAU,SAAS,YAAY;AACjC;AAAA,MACF;AAGI,UAAA,UAAU,iBAAiB,OAAO;AACpC;AAAA,MACF;AAEO,aAAA,QAAQA,UAAS,KAAK;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,MAAM,WAAW;AACtC,MAAA,iCAAiC,MAAM,uBAAuB;"}
1
+ {"version":3,"file":"map-relation.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/map-relation.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\nimport { isObject, curry, isNil } from 'lodash/fp';\n\nimport { traverseEntity, async } from '@strapi/utils';\n\nimport { Relation } from './types';\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 toArray = (value: any) => {\n // Keep value as it is if it's a nullish value\n if (isNil(value)) return value;\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n\n/**\n * There are multiple ways to create Strapi relations.\n * This is a utility to traverse and transform relation data\n *\n *\n * For consistency and ease of use, the response will always be an object with the following shape:\n * { set: [{...}], connect: [{...}], disconnect: [{...}] }\n *\n * @example\n * transformRelationData({\n * onLongHand: (relation) => {\n * // Change the id of the relation\n * return { id: 'other' };\n * },\n * }, relation)\n */\nconst mapRelation = async (\n callback: (relation: any) => any,\n rel: Relation,\n isRecursive = false\n): Promise<Relation> => {\n let relation: Relation = rel;\n\n const wrapInSet = (value: any) => {\n // Ignore wrapping if it's a recursive call\n if (isRecursive) {\n return value;\n }\n return { set: toArray(value) };\n };\n\n // undefined | null\n if (isNil(relation)) {\n return callback(relation);\n }\n\n // LongHand[] | ShortHand[]\n if (Array.isArray(relation)) {\n return async\n .map(relation, (r: Relation) => mapRelation(callback, r, true))\n .then((result: any) => result.flat().filter(Boolean))\n .then(wrapInSet);\n }\n\n // LongHand\n if (isObject(relation)) {\n // { id: 1 } || { documentId: 1 }\n if ('id' in relation || 'documentId' in relation) {\n const result = await callback(relation);\n return wrapInSet(result);\n }\n\n // If not connecting anything, return default visitor\n if (!relation.set && !relation.disconnect && !relation.connect) {\n return callback(relation);\n }\n\n // { set }\n if (relation.set) {\n const set: any = await mapRelation(callback, relation.set, true);\n relation = { ...relation, set: toArray(set) };\n }\n\n // { disconnect}\n if (relation.disconnect) {\n const disconnect: any = await mapRelation(callback, relation.disconnect, true);\n relation = { ...relation, disconnect: toArray(disconnect) };\n }\n\n // { connect }\n if (relation.connect) {\n // Transform the relation to connect\n const connect: any = await mapRelation(callback, relation.connect, true);\n relation = { ...relation, connect: toArray(connect) };\n }\n\n return relation;\n }\n\n // ShortHand\n if (isNumeric(relation)) {\n const result = await callback({ id: relation });\n return wrapInSet(result);\n }\n\n if (typeof relation === 'string') {\n const result = await callback({ documentId: relation });\n return wrapInSet(result);\n }\n\n // Anything else\n return callback(relation);\n};\n\ntype TraverseEntity = Parameters<typeof traverseEntity>;\n\n/**\n * Utility function, same as `traverseEntity` but only for relations.\n */\nconst traverseEntityRelations = async (\n visitor: TraverseEntity[0],\n options: TraverseEntity[1],\n data: TraverseEntity[2]\n) => {\n return traverseEntity(\n async (options, utils) => {\n const { attribute } = options;\n\n if (!attribute) {\n return;\n }\n\n if (attribute.type !== 'relation') {\n return;\n }\n\n // TODO: Handle join columns\n if (attribute.useJoinTable === false) {\n return;\n }\n\n return visitor(options, utils);\n },\n options,\n data\n );\n};\n\nconst mapRelationCurried = curry(mapRelation);\nconst traverseEntityRelationsCurried = curry(traverseEntityRelations);\n\nexport {\n mapRelationCurried as mapRelation,\n traverseEntityRelationsCurried as traverseEntityRelations,\n};\n"],"names":["options"],"mappings":";;AAOA,MAAM,YAAY,CAAC,UAAgC;AACjD,MAAI,MAAM,QAAQ,KAAK,EAAU,QAAA;AAC3B,QAAA,SAAS,SAAS,OAAO,EAAE;AAC1B,SAAA,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEA,MAAM,UAAU,CAAC,UAAe;AAE1B,MAAA,MAAM,KAAK,EAAU,QAAA;AACzB,MAAI,MAAM,QAAQ,KAAK,EAAU,QAAA;AAEjC,SAAO,CAAC,KAAK;AACf;AAkBA,MAAM,cAAc,OAClB,UACA,KACA,cAAc,UACQ;AACtB,MAAI,WAAqB;AAEnB,QAAA,YAAY,CAAC,UAAe;AAEhC,QAAI,aAAa;AACR,aAAA;AAAA,IAAA;AAET,WAAO,EAAE,KAAK,QAAQ,KAAK,EAAE;AAAA,EAC/B;AAGI,MAAA,MAAM,QAAQ,GAAG;AACnB,WAAO,SAAS,QAAQ;AAAA,EAAA;AAItB,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAA,MACJ,IAAI,UAAU,CAAC,MAAgB,YAAY,UAAU,GAAG,IAAI,CAAC,EAC7D,KAAK,CAAC,WAAgB,OAAO,KAAK,EAAE,OAAO,OAAO,CAAC,EACnD,KAAK,SAAS;AAAA,EAAA;AAIf,MAAA,SAAS,QAAQ,GAAG;AAElB,QAAA,QAAQ,YAAY,gBAAgB,UAAU;AAC1C,YAAA,SAAS,MAAM,SAAS,QAAQ;AACtC,aAAO,UAAU,MAAM;AAAA,IAAA;AAIrB,QAAA,CAAC,SAAS,OAAO,CAAC,SAAS,cAAc,CAAC,SAAS,SAAS;AAC9D,aAAO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ts"],"sourcesContent":["import { UID } 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\nconst { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: 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: Support polymorphic relations\n const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');\n if (isMorphRelation) {\n break;\n }\n\n // Ignore not visible fields other than createdBy and updatedBy\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);\n\n if (isVisible || isCreatorField) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n\n break;\n }\n\n case 'media': {\n // We populate all media fields for completeness of webhook responses\n // see https://github.com/strapi/strapi/issues/21546\n acc[attributeName] = { select: ['*'] };\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: 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":";;;AAUA,MAAM,EAAE,sBAAsB,yBAAyBA,YAAAA,aAAa;AAG7D,MAAM,kBAAkB,CAAC,KAAiB,OAAgB,OAAO;AAChE,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;AAEf,cAAM,kBAAkB,UAAU,SAAS,YAAY,EAAE,WAAW,OAAO;AAC3E,YAAI,iBAAiB;AACnB;AAAA,QACF;AAGA,cAAM,YAAYA,YAAA,aAAa,mBAAmB,OAAO,aAAa;AACtE,cAAM,iBAAiB,CAAC,sBAAsB,oBAAoB,EAAE,SAAS,aAAa;AAE1F,YAAI,aAAa,gBAAgB;AAC/B,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QACvD;AAEA;AAAA,MACF;AAAA,MAEA,KAAK,SAAS;AAGZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;AACrC;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,iBAAgC;AACzCA,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
+ {"version":3,"file":"populate.js","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { UID } 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\nconst { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: 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: Support polymorphic relations\n const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');\n if (isMorphRelation) {\n break;\n }\n\n // Ignore not visible fields other than createdBy and updatedBy\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);\n\n if (isVisible || isCreatorField) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n\n break;\n }\n\n case 'media': {\n // We populate all media fields for completeness of webhook responses\n // see https://github.com/strapi/strapi/issues/21546\n acc[attributeName] = { select: ['*'] };\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: 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":";;;AAUA,MAAM,EAAE,sBAAsB,yBAAyBA,YAAAA,aAAa;AAG7D,MAAM,kBAAkB,CAAC,KAAiB,OAAgB,OAAO;AAChE,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;AAEf,cAAM,kBAAkB,UAAU,SAAS,YAAY,EAAE,WAAW,OAAO;AAC3E,YAAI,iBAAiB;AACnB;AAAA,QAAA;AAIF,cAAM,YAAYA,YAAA,aAAa,mBAAmB,OAAO,aAAa;AACtE,cAAM,iBAAiB,CAAC,sBAAsB,oBAAoB,EAAE,SAAS,aAAa;AAE1F,YAAI,aAAa,gBAAgB;AAC/B,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QAAA;AAGvD;AAAA,MAAA;AAAA,MAGF,KAAK,SAAS;AAGZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;AACrC;AAAA,MAAA;AAAA,MAGF,KAAK,aAAa;AAChB,cAAM,WAAW,gBAAgB,UAAU,WAAW,IAAI;AACtD,YAAA,aAAa,IAAI,EAAE,SAAS;AAChC;AAAA,MAAA;AAAA,MAGF,KAAK,eAAe;AAElB,cAAM,uBAAuB,UAAU,cAAc,CAAI,GAAA;AAAA,UACvD,CAACC,MAAU,iBAAgC;AACzCA,iBAAI,YAAY,IAAI,EAAE,UAAU,gBAAgB,cAAc,IAAI,EAAE;AAC7DA,mBAAAA;AAAAA,UACT;AAAA,UACA,CAAA;AAAA,QACF;AAEA,YAAI,aAAa,IAAI,EAAE,IAAI,oBAAoB;AAC/C;AAAA,MAAA;AAAA,IAGA;AAGG,WAAA;AAAA,EACT,GAAG,EAAE;AACP;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { UID } 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\nconst { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: 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: Support polymorphic relations\n const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');\n if (isMorphRelation) {\n break;\n }\n\n // Ignore not visible fields other than createdBy and updatedBy\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);\n\n if (isVisible || isCreatorField) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n\n break;\n }\n\n case 'media': {\n // We populate all media fields for completeness of webhook responses\n // see https://github.com/strapi/strapi/issues/21546\n acc[attributeName] = { select: ['*'] };\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: 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":";AAUA,MAAM,EAAE,sBAAsB,yBAAyB,aAAa;AAG7D,MAAM,kBAAkB,CAAC,KAAiB,OAAgB,OAAO;AAChE,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;AAEf,cAAM,kBAAkB,UAAU,SAAS,YAAY,EAAE,WAAW,OAAO;AAC3E,YAAI,iBAAiB;AACnB;AAAA,QACF;AAGA,cAAM,YAAY,aAAa,mBAAmB,OAAO,aAAa;AACtE,cAAM,iBAAiB,CAAC,sBAAsB,oBAAoB,EAAE,SAAS,aAAa;AAE1F,YAAI,aAAa,gBAAgB;AAC/B,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QACvD;AAEA;AAAA,MACF;AAAA,MAEA,KAAK,SAAS;AAGZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;AACrC;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,iBAAgC;AACzCA,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
+ {"version":3,"file":"populate.mjs","sources":["../../../../src/services/document-service/utils/populate.ts"],"sourcesContent":["import { UID } 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\nconst { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;\n\n// We want to build a populate object based on the schema\nexport const getDeepPopulate = (uid: 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: Support polymorphic relations\n const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');\n if (isMorphRelation) {\n break;\n }\n\n // Ignore not visible fields other than createdBy and updatedBy\n const isVisible = contentTypes.isVisibleAttribute(model, attributeName);\n const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);\n\n if (isVisible || isCreatorField) {\n acc[attributeName] = { select: opts.relationalFields };\n }\n\n break;\n }\n\n case 'media': {\n // We populate all media fields for completeness of webhook responses\n // see https://github.com/strapi/strapi/issues/21546\n acc[attributeName] = { select: ['*'] };\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: 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":";AAUA,MAAM,EAAE,sBAAsB,yBAAyB,aAAa;AAG7D,MAAM,kBAAkB,CAAC,KAAiB,OAAgB,OAAO;AAChE,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;AAEf,cAAM,kBAAkB,UAAU,SAAS,YAAY,EAAE,WAAW,OAAO;AAC3E,YAAI,iBAAiB;AACnB;AAAA,QAAA;AAIF,cAAM,YAAY,aAAa,mBAAmB,OAAO,aAAa;AACtE,cAAM,iBAAiB,CAAC,sBAAsB,oBAAoB,EAAE,SAAS,aAAa;AAE1F,YAAI,aAAa,gBAAgB;AAC/B,cAAI,aAAa,IAAI,EAAE,QAAQ,KAAK,iBAAiB;AAAA,QAAA;AAGvD;AAAA,MAAA;AAAA,MAGF,KAAK,SAAS;AAGZ,YAAI,aAAa,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;AACrC;AAAA,MAAA;AAAA,MAGF,KAAK,aAAa;AAChB,cAAM,WAAW,gBAAgB,UAAU,WAAW,IAAI;AACtD,YAAA,aAAa,IAAI,EAAE,SAAS;AAChC;AAAA,MAAA;AAAA,MAGF,KAAK,eAAe;AAElB,cAAM,uBAAuB,UAAU,cAAc,CAAI,GAAA;AAAA,UACvD,CAACA,MAAU,iBAAgC;AACzCA,iBAAI,YAAY,IAAI,EAAE,UAAU,gBAAgB,cAAc,IAAI,EAAE;AAC7DA,mBAAAA;AAAAA,UACT;AAAA,UACA,CAAA;AAAA,QACF;AAEA,YAAI,aAAa,IAAI,EAAE,IAAI,oBAAoB;AAC/C;AAAA,MAAA;AAAA,IAGA;AAGG,WAAA;AAAA,EACT,GAAG,EAAE;AACP;"}
@@ -46,8 +46,7 @@ const sync = async (oldEntries, newEntries, oldRelations) => {
46
46
  const oldEntriesMap = oldEntries.reduce(
47
47
  (acc, entry) => {
48
48
  const newEntry = newEntryByLocale[entry.locale];
49
- if (!newEntry)
50
- return acc;
49
+ if (!newEntry) return acc;
51
50
  acc[entry.id] = newEntry.id;
52
51
  return acc;
53
52
  },