@strapi/core 0.0.0-next.d6ed4fcf2c833656b8c91a90909c1e77c79379e5 → 0.0.0-next.e61eff51f9834ffdef16bdc236aecab5f837723b

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 (685) hide show
  1. package/dist/Strapi.d.ts.map +1 -1
  2. package/dist/configuration/index.d.ts.map +1 -1
  3. package/dist/index.js +9954 -27
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +9932 -29
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/middlewares/body.d.ts.map +1 -1
  8. package/dist/migrations/database/5.0.0-discard-drafts.d.ts +2 -2
  9. package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
  10. package/dist/migrations/draft-publish.d.ts +1 -1
  11. package/dist/migrations/draft-publish.d.ts.map +1 -1
  12. package/dist/services/document-service/components.d.ts.map +1 -1
  13. package/dist/services/document-service/draft-and-publish.d.ts +1 -1
  14. package/dist/services/document-service/draft-and-publish.d.ts.map +1 -1
  15. package/dist/services/document-service/events.d.ts +1 -1
  16. package/dist/services/document-service/events.d.ts.map +1 -1
  17. package/dist/services/document-service/repository.d.ts.map +1 -1
  18. package/dist/services/document-service/transform/id-map.d.ts +1 -1
  19. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  20. package/dist/services/document-service/transform/id-transform.d.ts +1 -1
  21. package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
  22. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +1 -1
  23. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  24. package/dist/services/document-service/transform/relations/utils/dp.d.ts +1 -1
  25. package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -1
  26. package/dist/services/document-service/transform/relations/utils/i18n.d.ts +1 -1
  27. package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
  28. package/dist/services/document-service/utils/populate.d.ts +1 -1
  29. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  30. package/dist/services/document-service/utils/unidirectional-relations.d.ts +1 -1
  31. package/dist/services/document-service/utils/unidirectional-relations.d.ts.map +1 -1
  32. package/dist/services/entity-validator/index.d.ts +1 -1
  33. package/dist/services/entity-validator/index.d.ts.map +1 -1
  34. package/dist/services/metrics/middleware.d.ts.map +1 -1
  35. package/dist/services/metrics/rate-limiter.d.ts.map +1 -1
  36. package/dist/utils/update-notifier/index.d.ts.map +1 -1
  37. package/package.json +24 -25
  38. package/dist/Strapi.js +0 -434
  39. package/dist/Strapi.js.map +0 -1
  40. package/dist/Strapi.mjs +0 -413
  41. package/dist/Strapi.mjs.map +0 -1
  42. package/dist/compile.js +0 -18
  43. package/dist/compile.js.map +0 -1
  44. package/dist/compile.mjs +0 -17
  45. package/dist/compile.mjs.map +0 -1
  46. package/dist/configuration/config-loader.js +0 -105
  47. package/dist/configuration/config-loader.js.map +0 -1
  48. package/dist/configuration/config-loader.mjs +0 -103
  49. package/dist/configuration/config-loader.mjs.map +0 -1
  50. package/dist/configuration/get-dirs.js +0 -31
  51. package/dist/configuration/get-dirs.js.map +0 -1
  52. package/dist/configuration/get-dirs.mjs +0 -31
  53. package/dist/configuration/get-dirs.mjs.map +0 -1
  54. package/dist/configuration/index.js +0 -80
  55. package/dist/configuration/index.js.map +0 -1
  56. package/dist/configuration/index.mjs +0 -75
  57. package/dist/configuration/index.mjs.map +0 -1
  58. package/dist/configuration/urls.js +0 -68
  59. package/dist/configuration/urls.js.map +0 -1
  60. package/dist/configuration/urls.mjs +0 -66
  61. package/dist/configuration/urls.mjs.map +0 -1
  62. package/dist/container.js +0 -30
  63. package/dist/container.js.map +0 -1
  64. package/dist/container.mjs +0 -30
  65. package/dist/container.mjs.map +0 -1
  66. package/dist/core-api/controller/collection-type.js +0 -84
  67. package/dist/core-api/controller/collection-type.js.map +0 -1
  68. package/dist/core-api/controller/collection-type.mjs +0 -84
  69. package/dist/core-api/controller/collection-type.mjs.map +0 -1
  70. package/dist/core-api/controller/index.js +0 -52
  71. package/dist/core-api/controller/index.js.map +0 -1
  72. package/dist/core-api/controller/index.mjs +0 -52
  73. package/dist/core-api/controller/index.mjs.map +0 -1
  74. package/dist/core-api/controller/single-type.js +0 -46
  75. package/dist/core-api/controller/single-type.js.map +0 -1
  76. package/dist/core-api/controller/single-type.mjs +0 -46
  77. package/dist/core-api/controller/single-type.mjs.map +0 -1
  78. package/dist/core-api/controller/transform.js +0 -76
  79. package/dist/core-api/controller/transform.js.map +0 -1
  80. package/dist/core-api/controller/transform.mjs +0 -76
  81. package/dist/core-api/controller/transform.mjs.map +0 -1
  82. package/dist/core-api/routes/index.js +0 -67
  83. package/dist/core-api/routes/index.js.map +0 -1
  84. package/dist/core-api/routes/index.mjs +0 -67
  85. package/dist/core-api/routes/index.mjs.map +0 -1
  86. package/dist/core-api/service/collection-type.js +0 -67
  87. package/dist/core-api/service/collection-type.js.map +0 -1
  88. package/dist/core-api/service/collection-type.mjs +0 -67
  89. package/dist/core-api/service/collection-type.mjs.map +0 -1
  90. package/dist/core-api/service/core-service.js +0 -12
  91. package/dist/core-api/service/core-service.js.map +0 -1
  92. package/dist/core-api/service/core-service.mjs +0 -12
  93. package/dist/core-api/service/core-service.mjs.map +0 -1
  94. package/dist/core-api/service/index.js +0 -16
  95. package/dist/core-api/service/index.js.map +0 -1
  96. package/dist/core-api/service/index.mjs +0 -16
  97. package/dist/core-api/service/index.mjs.map +0 -1
  98. package/dist/core-api/service/pagination.js +0 -52
  99. package/dist/core-api/service/pagination.js.map +0 -1
  100. package/dist/core-api/service/pagination.mjs +0 -52
  101. package/dist/core-api/service/pagination.mjs.map +0 -1
  102. package/dist/core-api/service/single-type.js +0 -45
  103. package/dist/core-api/service/single-type.js.map +0 -1
  104. package/dist/core-api/service/single-type.mjs +0 -45
  105. package/dist/core-api/service/single-type.mjs.map +0 -1
  106. package/dist/domain/content-type/index.js +0 -111
  107. package/dist/domain/content-type/index.js.map +0 -1
  108. package/dist/domain/content-type/index.mjs +0 -109
  109. package/dist/domain/content-type/index.mjs.map +0 -1
  110. package/dist/domain/content-type/validator.js +0 -77
  111. package/dist/domain/content-type/validator.js.map +0 -1
  112. package/dist/domain/content-type/validator.mjs +0 -75
  113. package/dist/domain/content-type/validator.mjs.map +0 -1
  114. package/dist/domain/module/index.js +0 -107
  115. package/dist/domain/module/index.js.map +0 -1
  116. package/dist/domain/module/index.mjs +0 -105
  117. package/dist/domain/module/index.mjs.map +0 -1
  118. package/dist/domain/module/validation.js +0 -25
  119. package/dist/domain/module/validation.js.map +0 -1
  120. package/dist/domain/module/validation.mjs +0 -25
  121. package/dist/domain/module/validation.mjs.map +0 -1
  122. package/dist/ee/index.js +0 -158
  123. package/dist/ee/index.js.map +0 -1
  124. package/dist/ee/index.mjs +0 -159
  125. package/dist/ee/index.mjs.map +0 -1
  126. package/dist/ee/license.js +0 -91
  127. package/dist/ee/license.js.map +0 -1
  128. package/dist/ee/license.mjs +0 -88
  129. package/dist/ee/license.mjs.map +0 -1
  130. package/dist/factories.js +0 -80
  131. package/dist/factories.js.map +0 -1
  132. package/dist/factories.mjs +0 -80
  133. package/dist/factories.mjs.map +0 -1
  134. package/dist/loaders/admin.js +0 -26
  135. package/dist/loaders/admin.js.map +0 -1
  136. package/dist/loaders/admin.mjs +0 -25
  137. package/dist/loaders/admin.mjs.map +0 -1
  138. package/dist/loaders/apis.js +0 -137
  139. package/dist/loaders/apis.js.map +0 -1
  140. package/dist/loaders/apis.mjs +0 -135
  141. package/dist/loaders/apis.mjs.map +0 -1
  142. package/dist/loaders/components.js +0 -38
  143. package/dist/loaders/components.js.map +0 -1
  144. package/dist/loaders/components.mjs +0 -37
  145. package/dist/loaders/components.mjs.map +0 -1
  146. package/dist/loaders/index.js +0 -24
  147. package/dist/loaders/index.js.map +0 -1
  148. package/dist/loaders/index.mjs +0 -24
  149. package/dist/loaders/index.mjs.map +0 -1
  150. package/dist/loaders/middlewares.js +0 -31
  151. package/dist/loaders/middlewares.js.map +0 -1
  152. package/dist/loaders/middlewares.mjs +0 -30
  153. package/dist/loaders/middlewares.mjs.map +0 -1
  154. package/dist/loaders/plugins/get-enabled-plugins.js +0 -141
  155. package/dist/loaders/plugins/get-enabled-plugins.js.map +0 -1
  156. package/dist/loaders/plugins/get-enabled-plugins.mjs +0 -117
  157. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +0 -1
  158. package/dist/loaders/plugins/get-user-plugins-config.js +0 -27
  159. package/dist/loaders/plugins/get-user-plugins-config.js.map +0 -1
  160. package/dist/loaders/plugins/get-user-plugins-config.mjs +0 -25
  161. package/dist/loaders/plugins/get-user-plugins-config.mjs.map +0 -1
  162. package/dist/loaders/plugins/index.js +0 -144
  163. package/dist/loaders/plugins/index.js.map +0 -1
  164. package/dist/loaders/plugins/index.mjs +0 -125
  165. package/dist/loaders/plugins/index.mjs.map +0 -1
  166. package/dist/loaders/policies.js +0 -25
  167. package/dist/loaders/policies.js.map +0 -1
  168. package/dist/loaders/policies.mjs +0 -24
  169. package/dist/loaders/policies.mjs.map +0 -1
  170. package/dist/loaders/sanitizers.js +0 -6
  171. package/dist/loaders/sanitizers.js.map +0 -1
  172. package/dist/loaders/sanitizers.mjs +0 -7
  173. package/dist/loaders/sanitizers.mjs.map +0 -1
  174. package/dist/loaders/src-index.js +0 -33
  175. package/dist/loaders/src-index.js.map +0 -1
  176. package/dist/loaders/src-index.mjs +0 -34
  177. package/dist/loaders/src-index.mjs.map +0 -1
  178. package/dist/loaders/validators.js +0 -6
  179. package/dist/loaders/validators.js.map +0 -1
  180. package/dist/loaders/validators.mjs +0 -7
  181. package/dist/loaders/validators.mjs.map +0 -1
  182. package/dist/middlewares/body.js +0 -65
  183. package/dist/middlewares/body.js.map +0 -1
  184. package/dist/middlewares/body.mjs +0 -61
  185. package/dist/middlewares/body.mjs.map +0 -1
  186. package/dist/middlewares/compression.js +0 -8
  187. package/dist/middlewares/compression.js.map +0 -1
  188. package/dist/middlewares/compression.mjs +0 -6
  189. package/dist/middlewares/compression.mjs.map +0 -1
  190. package/dist/middlewares/cors.js +0 -53
  191. package/dist/middlewares/cors.js.map +0 -1
  192. package/dist/middlewares/cors.mjs +0 -51
  193. package/dist/middlewares/cors.mjs.map +0 -1
  194. package/dist/middlewares/errors.js +0 -33
  195. package/dist/middlewares/errors.js.map +0 -1
  196. package/dist/middlewares/errors.mjs +0 -33
  197. package/dist/middlewares/errors.mjs.map +0 -1
  198. package/dist/middlewares/favicon.js +0 -22
  199. package/dist/middlewares/favicon.js.map +0 -1
  200. package/dist/middlewares/favicon.mjs +0 -20
  201. package/dist/middlewares/favicon.mjs.map +0 -1
  202. package/dist/middlewares/index.js +0 -34
  203. package/dist/middlewares/index.js.map +0 -1
  204. package/dist/middlewares/index.mjs +0 -34
  205. package/dist/middlewares/index.mjs.map +0 -1
  206. package/dist/middlewares/ip.js +0 -8
  207. package/dist/middlewares/ip.js.map +0 -1
  208. package/dist/middlewares/ip.mjs +0 -6
  209. package/dist/middlewares/ip.mjs.map +0 -1
  210. package/dist/middlewares/logger.js +0 -12
  211. package/dist/middlewares/logger.js.map +0 -1
  212. package/dist/middlewares/logger.mjs +0 -12
  213. package/dist/middlewares/logger.mjs.map +0 -1
  214. package/dist/middlewares/powered-by.js +0 -14
  215. package/dist/middlewares/powered-by.js.map +0 -1
  216. package/dist/middlewares/powered-by.mjs +0 -14
  217. package/dist/middlewares/powered-by.mjs.map +0 -1
  218. package/dist/middlewares/public.js +0 -34
  219. package/dist/middlewares/public.js.map +0 -1
  220. package/dist/middlewares/public.mjs +0 -32
  221. package/dist/middlewares/public.mjs.map +0 -1
  222. package/dist/middlewares/query.js +0 -40
  223. package/dist/middlewares/query.js.map +0 -1
  224. package/dist/middlewares/query.mjs +0 -38
  225. package/dist/middlewares/query.mjs.map +0 -1
  226. package/dist/middlewares/response-time.js +0 -12
  227. package/dist/middlewares/response-time.js.map +0 -1
  228. package/dist/middlewares/response-time.mjs +0 -12
  229. package/dist/middlewares/response-time.mjs.map +0 -1
  230. package/dist/middlewares/responses.js +0 -15
  231. package/dist/middlewares/responses.js.map +0 -1
  232. package/dist/middlewares/responses.mjs +0 -15
  233. package/dist/middlewares/responses.mjs.map +0 -1
  234. package/dist/middlewares/security.js +0 -78
  235. package/dist/middlewares/security.js.map +0 -1
  236. package/dist/middlewares/security.mjs +0 -76
  237. package/dist/middlewares/security.mjs.map +0 -1
  238. package/dist/middlewares/session.js +0 -30
  239. package/dist/middlewares/session.js.map +0 -1
  240. package/dist/middlewares/session.mjs +0 -28
  241. package/dist/middlewares/session.mjs.map +0 -1
  242. package/dist/migrations/database/5.0.0-discard-drafts.js +0 -106
  243. package/dist/migrations/database/5.0.0-discard-drafts.js.map +0 -1
  244. package/dist/migrations/database/5.0.0-discard-drafts.mjs +0 -106
  245. package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +0 -1
  246. package/dist/migrations/draft-publish.js +0 -42
  247. package/dist/migrations/draft-publish.js.map +0 -1
  248. package/dist/migrations/draft-publish.mjs +0 -42
  249. package/dist/migrations/draft-publish.mjs.map +0 -1
  250. package/dist/migrations/i18n.js +0 -54
  251. package/dist/migrations/i18n.js.map +0 -1
  252. package/dist/migrations/i18n.mjs +0 -54
  253. package/dist/migrations/i18n.mjs.map +0 -1
  254. package/dist/migrations/index.js +0 -15
  255. package/dist/migrations/index.js.map +0 -1
  256. package/dist/migrations/index.mjs +0 -15
  257. package/dist/migrations/index.mjs.map +0 -1
  258. package/dist/providers/admin.js +0 -20
  259. package/dist/providers/admin.js.map +0 -1
  260. package/dist/providers/admin.mjs +0 -21
  261. package/dist/providers/admin.mjs.map +0 -1
  262. package/dist/providers/coreStore.js +0 -11
  263. package/dist/providers/coreStore.js.map +0 -1
  264. package/dist/providers/coreStore.mjs +0 -12
  265. package/dist/providers/coreStore.mjs.map +0 -1
  266. package/dist/providers/cron.js +0 -20
  267. package/dist/providers/cron.js.map +0 -1
  268. package/dist/providers/cron.mjs +0 -21
  269. package/dist/providers/cron.mjs.map +0 -1
  270. package/dist/providers/index.js +0 -11
  271. package/dist/providers/index.js.map +0 -1
  272. package/dist/providers/index.mjs +0 -11
  273. package/dist/providers/index.mjs.map +0 -1
  274. package/dist/providers/provider.js +0 -5
  275. package/dist/providers/provider.js.map +0 -1
  276. package/dist/providers/provider.mjs +0 -5
  277. package/dist/providers/provider.mjs.map +0 -1
  278. package/dist/providers/registries.js +0 -35
  279. package/dist/providers/registries.js.map +0 -1
  280. package/dist/providers/registries.mjs +0 -36
  281. package/dist/providers/registries.mjs.map +0 -1
  282. package/dist/providers/telemetry.js +0 -19
  283. package/dist/providers/telemetry.js.map +0 -1
  284. package/dist/providers/telemetry.mjs +0 -20
  285. package/dist/providers/telemetry.mjs.map +0 -1
  286. package/dist/providers/webhooks.js +0 -30
  287. package/dist/providers/webhooks.js.map +0 -1
  288. package/dist/providers/webhooks.mjs +0 -31
  289. package/dist/providers/webhooks.mjs.map +0 -1
  290. package/dist/registries/apis.js +0 -23
  291. package/dist/registries/apis.js.map +0 -1
  292. package/dist/registries/apis.mjs +0 -24
  293. package/dist/registries/apis.mjs.map +0 -1
  294. package/dist/registries/components.js +0 -45
  295. package/dist/registries/components.js.map +0 -1
  296. package/dist/registries/components.mjs +0 -46
  297. package/dist/registries/components.mjs.map +0 -1
  298. package/dist/registries/content-types.js +0 -70
  299. package/dist/registries/content-types.js.map +0 -1
  300. package/dist/registries/content-types.mjs +0 -71
  301. package/dist/registries/content-types.mjs.map +0 -1
  302. package/dist/registries/controllers.js +0 -80
  303. package/dist/registries/controllers.js.map +0 -1
  304. package/dist/registries/controllers.mjs +0 -81
  305. package/dist/registries/controllers.mjs.map +0 -1
  306. package/dist/registries/custom-fields.js +0 -71
  307. package/dist/registries/custom-fields.js.map +0 -1
  308. package/dist/registries/custom-fields.mjs +0 -72
  309. package/dist/registries/custom-fields.mjs.map +0 -1
  310. package/dist/registries/hooks.js +0 -58
  311. package/dist/registries/hooks.js.map +0 -1
  312. package/dist/registries/hooks.mjs +0 -59
  313. package/dist/registries/hooks.mjs.map +0 -1
  314. package/dist/registries/middlewares.js +0 -60
  315. package/dist/registries/middlewares.js.map +0 -1
  316. package/dist/registries/middlewares.mjs +0 -61
  317. package/dist/registries/middlewares.mjs.map +0 -1
  318. package/dist/registries/models.js +0 -16
  319. package/dist/registries/models.js.map +0 -1
  320. package/dist/registries/models.mjs +0 -16
  321. package/dist/registries/models.mjs.map +0 -1
  322. package/dist/registries/modules.js +0 -39
  323. package/dist/registries/modules.js.map +0 -1
  324. package/dist/registries/modules.mjs +0 -40
  325. package/dist/registries/modules.mjs.map +0 -1
  326. package/dist/registries/namespace.js +0 -27
  327. package/dist/registries/namespace.js.map +0 -1
  328. package/dist/registries/namespace.mjs +0 -27
  329. package/dist/registries/namespace.mjs.map +0 -1
  330. package/dist/registries/plugins.js +0 -23
  331. package/dist/registries/plugins.js.map +0 -1
  332. package/dist/registries/plugins.mjs +0 -24
  333. package/dist/registries/plugins.mjs.map +0 -1
  334. package/dist/registries/policies.js +0 -108
  335. package/dist/registries/policies.js.map +0 -1
  336. package/dist/registries/policies.mjs +0 -109
  337. package/dist/registries/policies.mjs.map +0 -1
  338. package/dist/registries/sanitizers.js +0 -25
  339. package/dist/registries/sanitizers.js.map +0 -1
  340. package/dist/registries/sanitizers.mjs +0 -24
  341. package/dist/registries/sanitizers.mjs.map +0 -1
  342. package/dist/registries/services.js +0 -80
  343. package/dist/registries/services.js.map +0 -1
  344. package/dist/registries/services.mjs +0 -81
  345. package/dist/registries/services.mjs.map +0 -1
  346. package/dist/registries/validators.js +0 -25
  347. package/dist/registries/validators.js.map +0 -1
  348. package/dist/registries/validators.mjs +0 -24
  349. package/dist/registries/validators.mjs.map +0 -1
  350. package/dist/services/auth/index.js +0 -81
  351. package/dist/services/auth/index.js.map +0 -1
  352. package/dist/services/auth/index.mjs +0 -80
  353. package/dist/services/auth/index.mjs.map +0 -1
  354. package/dist/services/config.js +0 -47
  355. package/dist/services/config.js.map +0 -1
  356. package/dist/services/config.mjs +0 -47
  357. package/dist/services/config.mjs.map +0 -1
  358. package/dist/services/content-api/index.js +0 -85
  359. package/dist/services/content-api/index.js.map +0 -1
  360. package/dist/services/content-api/index.mjs +0 -84
  361. package/dist/services/content-api/index.mjs.map +0 -1
  362. package/dist/services/content-api/permissions/engine.js +0 -7
  363. package/dist/services/content-api/permissions/engine.js.map +0 -1
  364. package/dist/services/content-api/permissions/engine.mjs +0 -6
  365. package/dist/services/content-api/permissions/engine.mjs.map +0 -1
  366. package/dist/services/content-api/permissions/index.js +0 -87
  367. package/dist/services/content-api/permissions/index.js.map +0 -1
  368. package/dist/services/content-api/permissions/index.mjs +0 -86
  369. package/dist/services/content-api/permissions/index.mjs.map +0 -1
  370. package/dist/services/content-api/permissions/providers/action.js +0 -16
  371. package/dist/services/content-api/permissions/providers/action.js.map +0 -1
  372. package/dist/services/content-api/permissions/providers/action.mjs +0 -17
  373. package/dist/services/content-api/permissions/providers/action.mjs.map +0 -1
  374. package/dist/services/content-api/permissions/providers/condition.js +0 -16
  375. package/dist/services/content-api/permissions/providers/condition.js.map +0 -1
  376. package/dist/services/content-api/permissions/providers/condition.mjs +0 -17
  377. package/dist/services/content-api/permissions/providers/condition.mjs.map +0 -1
  378. package/dist/services/core-store.js +0 -107
  379. package/dist/services/core-store.js.map +0 -1
  380. package/dist/services/core-store.mjs +0 -107
  381. package/dist/services/core-store.mjs.map +0 -1
  382. package/dist/services/cron.js +0 -67
  383. package/dist/services/cron.js.map +0 -1
  384. package/dist/services/cron.mjs +0 -68
  385. package/dist/services/cron.mjs.map +0 -1
  386. package/dist/services/custom-fields.js +0 -10
  387. package/dist/services/custom-fields.js.map +0 -1
  388. package/dist/services/custom-fields.mjs +0 -11
  389. package/dist/services/custom-fields.mjs.map +0 -1
  390. package/dist/services/document-service/attributes/index.js +0 -22
  391. package/dist/services/document-service/attributes/index.js.map +0 -1
  392. package/dist/services/document-service/attributes/index.mjs +0 -22
  393. package/dist/services/document-service/attributes/index.mjs.map +0 -1
  394. package/dist/services/document-service/attributes/transforms.js +0 -20
  395. package/dist/services/document-service/attributes/transforms.js.map +0 -1
  396. package/dist/services/document-service/attributes/transforms.mjs +0 -19
  397. package/dist/services/document-service/attributes/transforms.mjs.map +0 -1
  398. package/dist/services/document-service/common.js +0 -7
  399. package/dist/services/document-service/common.js.map +0 -1
  400. package/dist/services/document-service/common.mjs +0 -7
  401. package/dist/services/document-service/common.mjs.map +0 -1
  402. package/dist/services/document-service/components.js +0 -288
  403. package/dist/services/document-service/components.js.map +0 -1
  404. package/dist/services/document-service/components.mjs +0 -286
  405. package/dist/services/document-service/components.mjs.map +0 -1
  406. package/dist/services/document-service/draft-and-publish.js +0 -69
  407. package/dist/services/document-service/draft-and-publish.js.map +0 -1
  408. package/dist/services/document-service/draft-and-publish.mjs +0 -69
  409. package/dist/services/document-service/draft-and-publish.mjs.map +0 -1
  410. package/dist/services/document-service/entries.js +0 -95
  411. package/dist/services/document-service/entries.js.map +0 -1
  412. package/dist/services/document-service/entries.mjs +0 -95
  413. package/dist/services/document-service/entries.mjs.map +0 -1
  414. package/dist/services/document-service/events.js +0 -47
  415. package/dist/services/document-service/events.js.map +0 -1
  416. package/dist/services/document-service/events.mjs +0 -47
  417. package/dist/services/document-service/events.mjs.map +0 -1
  418. package/dist/services/document-service/index.js +0 -36
  419. package/dist/services/document-service/index.js.map +0 -1
  420. package/dist/services/document-service/index.mjs +0 -36
  421. package/dist/services/document-service/index.mjs.map +0 -1
  422. package/dist/services/document-service/internationalization.js +0 -63
  423. package/dist/services/document-service/internationalization.js.map +0 -1
  424. package/dist/services/document-service/internationalization.mjs +0 -63
  425. package/dist/services/document-service/internationalization.mjs.map +0 -1
  426. package/dist/services/document-service/middlewares/errors.js +0 -25
  427. package/dist/services/document-service/middlewares/errors.js.map +0 -1
  428. package/dist/services/document-service/middlewares/errors.mjs +0 -25
  429. package/dist/services/document-service/middlewares/errors.mjs.map +0 -1
  430. package/dist/services/document-service/middlewares/middleware-manager.js +0 -49
  431. package/dist/services/document-service/middlewares/middleware-manager.js.map +0 -1
  432. package/dist/services/document-service/middlewares/middleware-manager.mjs +0 -49
  433. package/dist/services/document-service/middlewares/middleware-manager.mjs.map +0 -1
  434. package/dist/services/document-service/params.js +0 -8
  435. package/dist/services/document-service/params.js.map +0 -1
  436. package/dist/services/document-service/params.mjs +0 -8
  437. package/dist/services/document-service/params.mjs.map +0 -1
  438. package/dist/services/document-service/repository.js +0 -329
  439. package/dist/services/document-service/repository.js.map +0 -1
  440. package/dist/services/document-service/repository.mjs +0 -329
  441. package/dist/services/document-service/repository.mjs.map +0 -1
  442. package/dist/services/document-service/transform/data.js +0 -15
  443. package/dist/services/document-service/transform/data.js.map +0 -1
  444. package/dist/services/document-service/transform/data.mjs +0 -15
  445. package/dist/services/document-service/transform/data.mjs.map +0 -1
  446. package/dist/services/document-service/transform/fields.js +0 -24
  447. package/dist/services/document-service/transform/fields.js.map +0 -1
  448. package/dist/services/document-service/transform/fields.mjs +0 -24
  449. package/dist/services/document-service/transform/fields.mjs.map +0 -1
  450. package/dist/services/document-service/transform/id-map.js +0 -85
  451. package/dist/services/document-service/transform/id-map.js.map +0 -1
  452. package/dist/services/document-service/transform/id-map.mjs +0 -85
  453. package/dist/services/document-service/transform/id-map.mjs.map +0 -1
  454. package/dist/services/document-service/transform/id-transform.js +0 -33
  455. package/dist/services/document-service/transform/id-transform.js.map +0 -1
  456. package/dist/services/document-service/transform/id-transform.mjs +0 -33
  457. package/dist/services/document-service/transform/id-transform.mjs.map +0 -1
  458. package/dist/services/document-service/transform/populate.js +0 -21
  459. package/dist/services/document-service/transform/populate.js.map +0 -1
  460. package/dist/services/document-service/transform/populate.mjs +0 -21
  461. package/dist/services/document-service/transform/populate.mjs.map +0 -1
  462. package/dist/services/document-service/transform/query.js +0 -9
  463. package/dist/services/document-service/transform/query.js.map +0 -1
  464. package/dist/services/document-service/transform/query.mjs +0 -9
  465. package/dist/services/document-service/transform/query.mjs.map +0 -1
  466. package/dist/services/document-service/transform/relations/extract/data-ids.js +0 -64
  467. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +0 -1
  468. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +0 -64
  469. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +0 -1
  470. package/dist/services/document-service/transform/relations/transform/data-ids.js +0 -85
  471. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +0 -1
  472. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +0 -85
  473. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +0 -1
  474. package/dist/services/document-service/transform/relations/transform/default-locale.js +0 -32
  475. package/dist/services/document-service/transform/relations/transform/default-locale.js.map +0 -1
  476. package/dist/services/document-service/transform/relations/transform/default-locale.mjs +0 -32
  477. package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +0 -1
  478. package/dist/services/document-service/transform/relations/utils/dp.js +0 -30
  479. package/dist/services/document-service/transform/relations/utils/dp.js.map +0 -1
  480. package/dist/services/document-service/transform/relations/utils/dp.mjs +0 -30
  481. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +0 -1
  482. package/dist/services/document-service/transform/relations/utils/i18n.js +0 -25
  483. package/dist/services/document-service/transform/relations/utils/i18n.js.map +0 -1
  484. package/dist/services/document-service/transform/relations/utils/i18n.mjs +0 -25
  485. package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +0 -1
  486. package/dist/services/document-service/transform/relations/utils/map-relation.js +0 -84
  487. package/dist/services/document-service/transform/relations/utils/map-relation.js.map +0 -1
  488. package/dist/services/document-service/transform/relations/utils/map-relation.mjs +0 -84
  489. package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +0 -1
  490. package/dist/services/document-service/utils/populate.js +0 -47
  491. package/dist/services/document-service/utils/populate.js.map +0 -1
  492. package/dist/services/document-service/utils/populate.mjs +0 -47
  493. package/dist/services/document-service/utils/populate.mjs.map +0 -1
  494. package/dist/services/document-service/utils/unidirectional-relations.js +0 -68
  495. package/dist/services/document-service/utils/unidirectional-relations.js.map +0 -1
  496. package/dist/services/document-service/utils/unidirectional-relations.mjs +0 -68
  497. package/dist/services/document-service/utils/unidirectional-relations.mjs.map +0 -1
  498. package/dist/services/entity-service/index.js +0 -169
  499. package/dist/services/entity-service/index.js.map +0 -1
  500. package/dist/services/entity-service/index.mjs +0 -167
  501. package/dist/services/entity-service/index.mjs.map +0 -1
  502. package/dist/services/entity-validator/blocks-validator.js +0 -128
  503. package/dist/services/entity-validator/blocks-validator.js.map +0 -1
  504. package/dist/services/entity-validator/blocks-validator.mjs +0 -128
  505. package/dist/services/entity-validator/blocks-validator.mjs.map +0 -1
  506. package/dist/services/entity-validator/index.js +0 -389
  507. package/dist/services/entity-validator/index.js.map +0 -1
  508. package/dist/services/entity-validator/index.mjs +0 -388
  509. package/dist/services/entity-validator/index.mjs.map +0 -1
  510. package/dist/services/entity-validator/validators.js +0 -241
  511. package/dist/services/entity-validator/validators.js.map +0 -1
  512. package/dist/services/entity-validator/validators.mjs +0 -239
  513. package/dist/services/entity-validator/validators.mjs.map +0 -1
  514. package/dist/services/errors.js +0 -76
  515. package/dist/services/errors.js.map +0 -1
  516. package/dist/services/errors.mjs +0 -74
  517. package/dist/services/errors.mjs.map +0 -1
  518. package/dist/services/event-hub.js +0 -72
  519. package/dist/services/event-hub.js.map +0 -1
  520. package/dist/services/event-hub.mjs +0 -73
  521. package/dist/services/event-hub.mjs.map +0 -1
  522. package/dist/services/features.js +0 -17
  523. package/dist/services/features.js.map +0 -1
  524. package/dist/services/features.mjs +0 -17
  525. package/dist/services/features.mjs.map +0 -1
  526. package/dist/services/fs.js +0 -51
  527. package/dist/services/fs.js.map +0 -1
  528. package/dist/services/fs.mjs +0 -49
  529. package/dist/services/fs.mjs.map +0 -1
  530. package/dist/services/metrics/admin-user-hash.js +0 -14
  531. package/dist/services/metrics/admin-user-hash.js.map +0 -1
  532. package/dist/services/metrics/admin-user-hash.mjs +0 -12
  533. package/dist/services/metrics/admin-user-hash.mjs.map +0 -1
  534. package/dist/services/metrics/index.js +0 -44
  535. package/dist/services/metrics/index.js.map +0 -1
  536. package/dist/services/metrics/index.mjs +0 -45
  537. package/dist/services/metrics/index.mjs.map +0 -1
  538. package/dist/services/metrics/is-truthy.js +0 -9
  539. package/dist/services/metrics/is-truthy.js.map +0 -1
  540. package/dist/services/metrics/is-truthy.mjs +0 -8
  541. package/dist/services/metrics/is-truthy.mjs.map +0 -1
  542. package/dist/services/metrics/middleware.js +0 -25
  543. package/dist/services/metrics/middleware.js.map +0 -1
  544. package/dist/services/metrics/middleware.mjs +0 -26
  545. package/dist/services/metrics/middleware.mjs.map +0 -1
  546. package/dist/services/metrics/rate-limiter.js +0 -21
  547. package/dist/services/metrics/rate-limiter.js.map +0 -1
  548. package/dist/services/metrics/rate-limiter.mjs +0 -22
  549. package/dist/services/metrics/rate-limiter.mjs.map +0 -1
  550. package/dist/services/metrics/sender.js +0 -76
  551. package/dist/services/metrics/sender.js.map +0 -1
  552. package/dist/services/metrics/sender.mjs +0 -70
  553. package/dist/services/metrics/sender.mjs.map +0 -1
  554. package/dist/services/query-params.js +0 -12
  555. package/dist/services/query-params.js.map +0 -1
  556. package/dist/services/query-params.mjs +0 -13
  557. package/dist/services/query-params.mjs.map +0 -1
  558. package/dist/services/reloader.js +0 -36
  559. package/dist/services/reloader.js.map +0 -1
  560. package/dist/services/reloader.mjs +0 -36
  561. package/dist/services/reloader.mjs.map +0 -1
  562. package/dist/services/request-context.js +0 -13
  563. package/dist/services/request-context.js.map +0 -1
  564. package/dist/services/request-context.mjs +0 -14
  565. package/dist/services/request-context.mjs.map +0 -1
  566. package/dist/services/server/admin-api.js +0 -13
  567. package/dist/services/server/admin-api.js.map +0 -1
  568. package/dist/services/server/admin-api.mjs +0 -13
  569. package/dist/services/server/admin-api.mjs.map +0 -1
  570. package/dist/services/server/api.js +0 -30
  571. package/dist/services/server/api.js.map +0 -1
  572. package/dist/services/server/api.mjs +0 -28
  573. package/dist/services/server/api.mjs.map +0 -1
  574. package/dist/services/server/compose-endpoint.js +0 -117
  575. package/dist/services/server/compose-endpoint.js.map +0 -1
  576. package/dist/services/server/compose-endpoint.mjs +0 -116
  577. package/dist/services/server/compose-endpoint.mjs.map +0 -1
  578. package/dist/services/server/content-api.js +0 -12
  579. package/dist/services/server/content-api.js.map +0 -1
  580. package/dist/services/server/content-api.mjs +0 -12
  581. package/dist/services/server/content-api.mjs.map +0 -1
  582. package/dist/services/server/http-server.js +0 -50
  583. package/dist/services/server/http-server.js.map +0 -1
  584. package/dist/services/server/http-server.mjs +0 -48
  585. package/dist/services/server/http-server.mjs.map +0 -1
  586. package/dist/services/server/index.js +0 -87
  587. package/dist/services/server/index.js.map +0 -1
  588. package/dist/services/server/index.mjs +0 -85
  589. package/dist/services/server/index.mjs.map +0 -1
  590. package/dist/services/server/koa.js +0 -52
  591. package/dist/services/server/koa.js.map +0 -1
  592. package/dist/services/server/koa.mjs +0 -48
  593. package/dist/services/server/koa.mjs.map +0 -1
  594. package/dist/services/server/middleware.js +0 -92
  595. package/dist/services/server/middleware.js.map +0 -1
  596. package/dist/services/server/middleware.mjs +0 -90
  597. package/dist/services/server/middleware.mjs.map +0 -1
  598. package/dist/services/server/policy.js +0 -20
  599. package/dist/services/server/policy.js.map +0 -1
  600. package/dist/services/server/policy.mjs +0 -20
  601. package/dist/services/server/policy.mjs.map +0 -1
  602. package/dist/services/server/register-middlewares.js +0 -72
  603. package/dist/services/server/register-middlewares.js.map +0 -1
  604. package/dist/services/server/register-middlewares.mjs +0 -73
  605. package/dist/services/server/register-middlewares.mjs.map +0 -1
  606. package/dist/services/server/register-routes.js +0 -76
  607. package/dist/services/server/register-routes.js.map +0 -1
  608. package/dist/services/server/register-routes.mjs +0 -75
  609. package/dist/services/server/register-routes.mjs.map +0 -1
  610. package/dist/services/server/routing.js +0 -91
  611. package/dist/services/server/routing.js.map +0 -1
  612. package/dist/services/server/routing.mjs +0 -89
  613. package/dist/services/server/routing.mjs.map +0 -1
  614. package/dist/services/utils/dynamic-zones.js +0 -17
  615. package/dist/services/utils/dynamic-zones.js.map +0 -1
  616. package/dist/services/utils/dynamic-zones.mjs +0 -18
  617. package/dist/services/utils/dynamic-zones.mjs.map +0 -1
  618. package/dist/services/webhook-runner.js +0 -133
  619. package/dist/services/webhook-runner.js.map +0 -1
  620. package/dist/services/webhook-runner.mjs +0 -131
  621. package/dist/services/webhook-runner.mjs.map +0 -1
  622. package/dist/services/webhook-store.js +0 -110
  623. package/dist/services/webhook-store.js.map +0 -1
  624. package/dist/services/webhook-store.mjs +0 -110
  625. package/dist/services/webhook-store.mjs.map +0 -1
  626. package/dist/services/worker-queue.js +0 -56
  627. package/dist/services/worker-queue.js.map +0 -1
  628. package/dist/services/worker-queue.mjs +0 -55
  629. package/dist/services/worker-queue.mjs.map +0 -1
  630. package/dist/utils/convert-custom-field-type.js +0 -24
  631. package/dist/utils/convert-custom-field-type.js.map +0 -1
  632. package/dist/utils/convert-custom-field-type.mjs +0 -24
  633. package/dist/utils/convert-custom-field-type.mjs.map +0 -1
  634. package/dist/utils/cron.js +0 -38
  635. package/dist/utils/cron.js.map +0 -1
  636. package/dist/utils/cron.mjs +0 -38
  637. package/dist/utils/cron.mjs.map +0 -1
  638. package/dist/utils/fetch.js +0 -21
  639. package/dist/utils/fetch.js.map +0 -1
  640. package/dist/utils/fetch.mjs +0 -21
  641. package/dist/utils/fetch.mjs.map +0 -1
  642. package/dist/utils/filepath-to-prop-path.js +0 -33
  643. package/dist/utils/filepath-to-prop-path.js.map +0 -1
  644. package/dist/utils/filepath-to-prop-path.mjs +0 -30
  645. package/dist/utils/filepath-to-prop-path.mjs.map +0 -1
  646. package/dist/utils/is-initialized.js +0 -16
  647. package/dist/utils/is-initialized.js.map +0 -1
  648. package/dist/utils/is-initialized.mjs +0 -16
  649. package/dist/utils/is-initialized.mjs.map +0 -1
  650. package/dist/utils/lifecycles.js +0 -9
  651. package/dist/utils/lifecycles.js.map +0 -1
  652. package/dist/utils/lifecycles.mjs +0 -9
  653. package/dist/utils/lifecycles.mjs.map +0 -1
  654. package/dist/utils/load-config-file.js +0 -45
  655. package/dist/utils/load-config-file.js.map +0 -1
  656. package/dist/utils/load-config-file.mjs +0 -42
  657. package/dist/utils/load-config-file.mjs.map +0 -1
  658. package/dist/utils/load-files.js +0 -38
  659. package/dist/utils/load-files.js.map +0 -1
  660. package/dist/utils/load-files.mjs +0 -34
  661. package/dist/utils/load-files.mjs.map +0 -1
  662. package/dist/utils/open-browser.js +0 -11
  663. package/dist/utils/open-browser.js.map +0 -1
  664. package/dist/utils/open-browser.mjs +0 -9
  665. package/dist/utils/open-browser.mjs.map +0 -1
  666. package/dist/utils/resolve-working-dirs.js +0 -13
  667. package/dist/utils/resolve-working-dirs.js.map +0 -1
  668. package/dist/utils/resolve-working-dirs.mjs +0 -11
  669. package/dist/utils/resolve-working-dirs.mjs.map +0 -1
  670. package/dist/utils/signals.js +0 -17
  671. package/dist/utils/signals.js.map +0 -1
  672. package/dist/utils/signals.mjs +0 -17
  673. package/dist/utils/signals.mjs.map +0 -1
  674. package/dist/utils/startup-logger.js +0 -86
  675. package/dist/utils/startup-logger.js.map +0 -1
  676. package/dist/utils/startup-logger.mjs +0 -82
  677. package/dist/utils/startup-logger.mjs.map +0 -1
  678. package/dist/utils/transform-content-types-to-models.js +0 -288
  679. package/dist/utils/transform-content-types-to-models.js.map +0 -1
  680. package/dist/utils/transform-content-types-to-models.mjs +0 -285
  681. package/dist/utils/transform-content-types-to-models.mjs.map +0 -1
  682. package/dist/utils/update-notifier/index.js +0 -85
  683. package/dist/utils/update-notifier/index.js.map +0 -1
  684. package/dist/utils/update-notifier/index.mjs +0 -78
  685. package/dist/utils/update-notifier/index.mjs.map +0 -1
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const i18n = require("../utils/i18n.js");
4
- const mapRelation = require("../utils/map-relation.js");
5
- const setDefaultLocaleToRelations = (data, uid) => {
6
- if (i18n.isLocalizedContentType(uid)) {
7
- return data;
8
- }
9
- let defaultLocale;
10
- return mapRelation.traverseEntityRelations(
11
- async ({ key, value }, { set }) => {
12
- const relation = await mapRelation.mapRelation(async (relation2) => {
13
- if (!relation2 || !relation2?.documentId || relation2?.locale) {
14
- return relation2;
15
- }
16
- if (!defaultLocale) {
17
- defaultLocale = await i18n.getDefaultLocale();
18
- }
19
- const position = relation2.position;
20
- if (position && typeof position === "object" && !position.locale) {
21
- relation2.position.locale = defaultLocale;
22
- }
23
- return { ...relation2, locale: defaultLocale };
24
- }, value);
25
- set(key, relation);
26
- },
27
- { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },
28
- data
29
- );
30
- };
31
- exports.setDefaultLocaleToRelations = setDefaultLocaleToRelations;
32
- //# sourceMappingURL=default-locale.js.map
@@ -1 +0,0 @@
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,32 +0,0 @@
1
- import { isLocalizedContentType, getDefaultLocale } from "../utils/i18n.mjs";
2
- import { traverseEntityRelations as traverseEntityRelationsCurried, mapRelation as mapRelationCurried } from "../utils/map-relation.mjs";
3
- const setDefaultLocaleToRelations = (data, uid) => {
4
- if (isLocalizedContentType(uid)) {
5
- return data;
6
- }
7
- let defaultLocale;
8
- return traverseEntityRelationsCurried(
9
- async ({ key, value }, { set }) => {
10
- const relation = await mapRelationCurried(async (relation2) => {
11
- if (!relation2 || !relation2?.documentId || relation2?.locale) {
12
- return relation2;
13
- }
14
- if (!defaultLocale) {
15
- defaultLocale = await getDefaultLocale();
16
- }
17
- const position = relation2.position;
18
- if (position && typeof position === "object" && !position.locale) {
19
- relation2.position.locale = defaultLocale;
20
- }
21
- return { ...relation2, locale: defaultLocale };
22
- }, value);
23
- set(key, relation);
24
- },
25
- { schema: strapi.getModel(uid), getModel: strapi.getModel.bind(strapi) },
26
- data
27
- );
28
- };
29
- export {
30
- setDefaultLocaleToRelations
31
- };
32
- //# sourceMappingURL=default-locale.mjs.map
@@ -1 +0,0 @@
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,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fp = require("lodash/fp");
4
- const strapiUtils = require("@strapi/utils");
5
- const getRelationTargetStatus = (relation, opts) => {
6
- const targetContentType = strapi.getModel(opts.targetUid);
7
- const sourceContentType = strapi.getModel(opts.sourceUid);
8
- const targetHasDP = strapiUtils.contentTypes.hasDraftAndPublish(targetContentType);
9
- const sourceHasDP = strapiUtils.contentTypes.hasDraftAndPublish(sourceContentType);
10
- if (!targetHasDP) {
11
- return ["published"];
12
- }
13
- if (sourceHasDP && !fp.isNil(opts.sourceStatus)) {
14
- return [opts.sourceStatus];
15
- }
16
- if (relation.status) {
17
- switch (relation.status) {
18
- case "published":
19
- return ["published"];
20
- default:
21
- return ["draft"];
22
- }
23
- }
24
- if (!sourceHasDP) {
25
- return ["draft", "published"];
26
- }
27
- return ["draft"];
28
- };
29
- exports.getRelationTargetStatus = getRelationTargetStatus;
30
- //# sourceMappingURL=dp.js.map
@@ -1 +0,0 @@
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,30 +0,0 @@
1
- import { isNil } from "lodash/fp";
2
- import { contentTypes } from "@strapi/utils";
3
- const getRelationTargetStatus = (relation, opts) => {
4
- const targetContentType = strapi.getModel(opts.targetUid);
5
- const sourceContentType = strapi.getModel(opts.sourceUid);
6
- const targetHasDP = contentTypes.hasDraftAndPublish(targetContentType);
7
- const sourceHasDP = contentTypes.hasDraftAndPublish(sourceContentType);
8
- if (!targetHasDP) {
9
- return ["published"];
10
- }
11
- if (sourceHasDP && !isNil(opts.sourceStatus)) {
12
- return [opts.sourceStatus];
13
- }
14
- if (relation.status) {
15
- switch (relation.status) {
16
- case "published":
17
- return ["published"];
18
- default:
19
- return ["draft"];
20
- }
21
- }
22
- if (!sourceHasDP) {
23
- return ["draft", "published"];
24
- }
25
- return ["draft"];
26
- };
27
- export {
28
- getRelationTargetStatus
29
- };
30
- //# sourceMappingURL=dp.mjs.map
@@ -1 +0,0 @@
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,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const isLocalizedContentType = (uid) => {
4
- const model = strapi.getModel(uid);
5
- return strapi.plugin("i18n").service("content-types").isLocalizedContentType(model);
6
- };
7
- const getDefaultLocale = () => {
8
- return strapi.plugin("i18n").service("locales").getDefaultLocale();
9
- };
10
- const getRelationTargetLocale = (relation, opts) => {
11
- const targetLocale = relation.locale || opts.sourceLocale;
12
- const isTargetLocalized = isLocalizedContentType(opts.targetUid);
13
- const isSourceLocalized = isLocalizedContentType(opts.sourceUid);
14
- if (isSourceLocalized && isTargetLocalized) {
15
- return opts.sourceLocale;
16
- }
17
- if (isTargetLocalized) {
18
- return targetLocale;
19
- }
20
- return null;
21
- };
22
- exports.getDefaultLocale = getDefaultLocale;
23
- exports.getRelationTargetLocale = getRelationTargetLocale;
24
- exports.isLocalizedContentType = isLocalizedContentType;
25
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
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,25 +0,0 @@
1
- const isLocalizedContentType = (uid) => {
2
- const model = strapi.getModel(uid);
3
- return strapi.plugin("i18n").service("content-types").isLocalizedContentType(model);
4
- };
5
- const getDefaultLocale = () => {
6
- return strapi.plugin("i18n").service("locales").getDefaultLocale();
7
- };
8
- const getRelationTargetLocale = (relation, opts) => {
9
- const targetLocale = relation.locale || opts.sourceLocale;
10
- const isTargetLocalized = isLocalizedContentType(opts.targetUid);
11
- const isSourceLocalized = isLocalizedContentType(opts.sourceUid);
12
- if (isSourceLocalized && isTargetLocalized) {
13
- return opts.sourceLocale;
14
- }
15
- if (isTargetLocalized) {
16
- return targetLocale;
17
- }
18
- return null;
19
- };
20
- export {
21
- getDefaultLocale,
22
- getRelationTargetLocale,
23
- isLocalizedContentType
24
- };
25
- //# sourceMappingURL=i18n.mjs.map
@@ -1 +0,0 @@
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;"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fp = require("lodash/fp");
4
- const strapiUtils = require("@strapi/utils");
5
- const isNumeric = (value) => {
6
- if (Array.isArray(value)) return false;
7
- const parsed = parseInt(value, 10);
8
- return !Number.isNaN(parsed);
9
- };
10
- const toArray = (value) => {
11
- if (fp.isNil(value)) return value;
12
- if (Array.isArray(value)) return value;
13
- return [value];
14
- };
15
- const mapRelation = async (callback, rel, isRecursive = false) => {
16
- let relation = rel;
17
- const wrapInSet = (value) => {
18
- if (isRecursive) {
19
- return value;
20
- }
21
- return { set: toArray(value) };
22
- };
23
- if (fp.isNil(relation)) {
24
- return callback(relation);
25
- }
26
- if (Array.isArray(relation)) {
27
- return strapiUtils.async.map(relation, (r) => mapRelation(callback, r, true)).then((result) => result.flat().filter(Boolean)).then(wrapInSet);
28
- }
29
- if (fp.isObject(relation)) {
30
- if ("id" in relation || "documentId" in relation) {
31
- const result = await callback(relation);
32
- return wrapInSet(result);
33
- }
34
- if (!relation.set && !relation.disconnect && !relation.connect) {
35
- return callback(relation);
36
- }
37
- if (relation.set) {
38
- const set = await mapRelation(callback, relation.set, true);
39
- relation = { ...relation, set: toArray(set) };
40
- }
41
- if (relation.disconnect) {
42
- const disconnect = await mapRelation(callback, relation.disconnect, true);
43
- relation = { ...relation, disconnect: toArray(disconnect) };
44
- }
45
- if (relation.connect) {
46
- const connect = await mapRelation(callback, relation.connect, true);
47
- relation = { ...relation, connect: toArray(connect) };
48
- }
49
- return relation;
50
- }
51
- if (isNumeric(relation)) {
52
- const result = await callback({ id: relation });
53
- return wrapInSet(result);
54
- }
55
- if (typeof relation === "string") {
56
- const result = await callback({ documentId: relation });
57
- return wrapInSet(result);
58
- }
59
- return callback(relation);
60
- };
61
- const traverseEntityRelations = async (visitor, options, data) => {
62
- return strapiUtils.traverseEntity(
63
- async (options2, utils) => {
64
- const { attribute } = options2;
65
- if (!attribute) {
66
- return;
67
- }
68
- if (attribute.type !== "relation") {
69
- return;
70
- }
71
- if (attribute.useJoinTable === false) {
72
- return;
73
- }
74
- return visitor(options2, utils);
75
- },
76
- options,
77
- data
78
- );
79
- };
80
- const mapRelationCurried = fp.curry(mapRelation);
81
- const traverseEntityRelationsCurried = fp.curry(traverseEntityRelations);
82
- exports.mapRelation = mapRelationCurried;
83
- exports.traverseEntityRelations = traverseEntityRelationsCurried;
84
- //# sourceMappingURL=map-relation.js.map
@@ -1 +0,0 @@
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;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,MAAAA,GAAA,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,MAAAA,GAAAA,MAAM,QAAQ,GAAG;AACnB,WAAO,SAAS,QAAQ;AAAA,EAAA;AAItB,MAAA,MAAM,QAAQ,QAAQ,GAAG;AACpB,WAAAC,YAAA,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,MAAAC,GAAAA,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,SAAS,QAAQ;AAAA,IAAA;AAI1B,QAAI,SAAS,KAAK;AAChB,YAAM,MAAW,MAAM,YAAY,UAAU,SAAS,KAAK,IAAI;AAC/D,iBAAW,EAAE,GAAG,UAAU,KAAK,QAAQ,GAAG,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,84 +0,0 @@
1
- import { curry, isNil, isObject } from "lodash/fp";
2
- import { async, traverseEntity } from "@strapi/utils";
3
- const isNumeric = (value) => {
4
- if (Array.isArray(value)) return false;
5
- const parsed = parseInt(value, 10);
6
- return !Number.isNaN(parsed);
7
- };
8
- const toArray = (value) => {
9
- if (isNil(value)) return value;
10
- if (Array.isArray(value)) return value;
11
- return [value];
12
- };
13
- const mapRelation = async (callback, rel, isRecursive = false) => {
14
- let relation = rel;
15
- const wrapInSet = (value) => {
16
- if (isRecursive) {
17
- return value;
18
- }
19
- return { set: toArray(value) };
20
- };
21
- if (isNil(relation)) {
22
- return callback(relation);
23
- }
24
- if (Array.isArray(relation)) {
25
- return async.map(relation, (r) => mapRelation(callback, r, true)).then((result) => result.flat().filter(Boolean)).then(wrapInSet);
26
- }
27
- if (isObject(relation)) {
28
- if ("id" in relation || "documentId" in relation) {
29
- const result = await callback(relation);
30
- return wrapInSet(result);
31
- }
32
- if (!relation.set && !relation.disconnect && !relation.connect) {
33
- return callback(relation);
34
- }
35
- if (relation.set) {
36
- const set = await mapRelation(callback, relation.set, true);
37
- relation = { ...relation, set: toArray(set) };
38
- }
39
- if (relation.disconnect) {
40
- const disconnect = await mapRelation(callback, relation.disconnect, true);
41
- relation = { ...relation, disconnect: toArray(disconnect) };
42
- }
43
- if (relation.connect) {
44
- const connect = await mapRelation(callback, relation.connect, true);
45
- relation = { ...relation, connect: toArray(connect) };
46
- }
47
- return relation;
48
- }
49
- if (isNumeric(relation)) {
50
- const result = await callback({ id: relation });
51
- return wrapInSet(result);
52
- }
53
- if (typeof relation === "string") {
54
- const result = await callback({ documentId: relation });
55
- return wrapInSet(result);
56
- }
57
- return callback(relation);
58
- };
59
- const traverseEntityRelations = async (visitor, options, data) => {
60
- return traverseEntity(
61
- async (options2, utils) => {
62
- const { attribute } = options2;
63
- if (!attribute) {
64
- return;
65
- }
66
- if (attribute.type !== "relation") {
67
- return;
68
- }
69
- if (attribute.useJoinTable === false) {
70
- return;
71
- }
72
- return visitor(options2, utils);
73
- },
74
- options,
75
- data
76
- );
77
- };
78
- const mapRelationCurried = curry(mapRelation);
79
- const traverseEntityRelationsCurried = curry(traverseEntityRelations);
80
- export {
81
- mapRelationCurried as mapRelation,
82
- traverseEntityRelationsCurried as traverseEntityRelations
83
- };
84
- //# sourceMappingURL=map-relation.mjs.map
@@ -1 +0,0 @@
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,SAAS,QAAQ;AAAA,IAAA;AAI1B,QAAI,SAAS,KAAK;AAChB,YAAM,MAAW,MAAM,YAAY,UAAU,SAAS,KAAK,IAAI;AAC/D,iBAAW,EAAE,GAAG,UAAU,KAAK,QAAQ,GAAG,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,SAAA;AAAA,IACL,OAAOA,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,qBAAqB,MAAM,WAAW;AACtC,MAAA,iCAAiC,MAAM,uBAAuB;"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const strapiUtils = require("@strapi/utils");
4
- const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = strapiUtils.contentTypes.constants;
5
- const getDeepPopulate = (uid, opts = {}) => {
6
- const model = strapi.getModel(uid);
7
- const attributes = Object.entries(model.attributes);
8
- return attributes.reduce((acc, [attributeName, attribute]) => {
9
- switch (attribute.type) {
10
- case "relation": {
11
- const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
12
- if (isMorphRelation) {
13
- break;
14
- }
15
- const isVisible = strapiUtils.contentTypes.isVisibleAttribute(model, attributeName);
16
- const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);
17
- if (isVisible || isCreatorField) {
18
- acc[attributeName] = { select: opts.relationalFields };
19
- }
20
- break;
21
- }
22
- case "media": {
23
- acc[attributeName] = { select: ["*"] };
24
- break;
25
- }
26
- case "component": {
27
- const populate = getDeepPopulate(attribute.component, opts);
28
- acc[attributeName] = { populate };
29
- break;
30
- }
31
- case "dynamiczone": {
32
- const populatedComponents = (attribute.components || []).reduce(
33
- (acc2, componentUID) => {
34
- acc2[componentUID] = { populate: getDeepPopulate(componentUID, opts) };
35
- return acc2;
36
- },
37
- {}
38
- );
39
- acc[attributeName] = { on: populatedComponents };
40
- break;
41
- }
42
- }
43
- return acc;
44
- }, {});
45
- };
46
- exports.getDeepPopulate = getDeepPopulate;
47
- //# sourceMappingURL=populate.js.map
@@ -1 +0,0 @@
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,47 +0,0 @@
1
- import { contentTypes } from "@strapi/utils";
2
- const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;
3
- const getDeepPopulate = (uid, opts = {}) => {
4
- const model = strapi.getModel(uid);
5
- const attributes = Object.entries(model.attributes);
6
- return attributes.reduce((acc, [attributeName, attribute]) => {
7
- switch (attribute.type) {
8
- case "relation": {
9
- const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
10
- if (isMorphRelation) {
11
- break;
12
- }
13
- const isVisible = contentTypes.isVisibleAttribute(model, attributeName);
14
- const isCreatorField = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(attributeName);
15
- if (isVisible || isCreatorField) {
16
- acc[attributeName] = { select: opts.relationalFields };
17
- }
18
- break;
19
- }
20
- case "media": {
21
- acc[attributeName] = { select: ["*"] };
22
- break;
23
- }
24
- case "component": {
25
- const populate = getDeepPopulate(attribute.component, opts);
26
- acc[attributeName] = { populate };
27
- break;
28
- }
29
- case "dynamiczone": {
30
- const populatedComponents = (attribute.components || []).reduce(
31
- (acc2, componentUID) => {
32
- acc2[componentUID] = { populate: getDeepPopulate(componentUID, opts) };
33
- return acc2;
34
- },
35
- {}
36
- );
37
- acc[attributeName] = { on: populatedComponents };
38
- break;
39
- }
40
- }
41
- return acc;
42
- }, {});
43
- };
44
- export {
45
- getDeepPopulate
46
- };
47
- //# sourceMappingURL=populate.mjs.map
@@ -1 +0,0 @@
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;"}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fp = require("lodash/fp");
4
- const load = async (uid, { oldVersions, newVersions }) => {
5
- const updates = [];
6
- await strapi.db.transaction(async ({ trx }) => {
7
- const contentTypes = Object.values(strapi.contentTypes);
8
- const components = Object.values(strapi.components);
9
- for (const model of [...contentTypes, ...components]) {
10
- const dbModel = strapi.db.metadata.get(model.uid);
11
- for (const attribute of Object.values(dbModel.attributes)) {
12
- if (attribute.type !== "relation" || attribute.target !== uid || attribute.inversedBy || attribute.mappedBy) {
13
- continue;
14
- }
15
- const joinTable = attribute.joinTable;
16
- if (!joinTable) {
17
- continue;
18
- }
19
- const { name: sourceColumnName } = joinTable.joinColumn;
20
- const { name: targetColumnName } = joinTable.inverseJoinColumn;
21
- const ids = oldVersions.map((entry) => entry.id);
22
- const oldVersionsRelations = await strapi.db.getConnection().select("*").from(joinTable.name).whereIn(targetColumnName, ids).transacting(trx);
23
- if (oldVersionsRelations.length > 0) {
24
- updates.push({ joinTable, relations: oldVersionsRelations });
25
- }
26
- if (!model.options?.draftAndPublish) {
27
- const ids2 = newVersions.map((entry) => entry.id);
28
- const newVersionsRelations = await strapi.db.getConnection().select("*").from(joinTable.name).whereIn(targetColumnName, ids2).transacting(trx);
29
- if (newVersionsRelations.length > 0) {
30
- const discardToAdd = newVersionsRelations.filter((relation) => {
31
- const matchingOldVerion = oldVersionsRelations.find((oldRelation) => {
32
- return oldRelation[sourceColumnName] === relation[sourceColumnName];
33
- });
34
- return !matchingOldVerion;
35
- }).map(fp.omit("id"));
36
- updates.push({ joinTable, relations: discardToAdd });
37
- }
38
- }
39
- }
40
- }
41
- });
42
- return updates;
43
- };
44
- const sync = async (oldEntries, newEntries, oldRelations) => {
45
- const newEntryByLocale = fp.keyBy("locale", newEntries);
46
- const oldEntriesMap = oldEntries.reduce(
47
- (acc, entry) => {
48
- const newEntry = newEntryByLocale[entry.locale];
49
- if (!newEntry) return acc;
50
- acc[entry.id] = newEntry.id;
51
- return acc;
52
- },
53
- {}
54
- );
55
- await strapi.db.transaction(async ({ trx }) => {
56
- for (const { joinTable, relations } of oldRelations) {
57
- const column = joinTable.inverseJoinColumn.name;
58
- const newRelations = relations.map((relation) => {
59
- const newId = oldEntriesMap[relation[column]];
60
- return { ...relation, [column]: newId };
61
- });
62
- await trx.batchInsert(joinTable.name, newRelations, 1e3);
63
- }
64
- });
65
- };
66
- exports.load = load;
67
- exports.sync = sync;
68
- //# sourceMappingURL=unidirectional-relations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unidirectional-relations.js","sources":["../../../../src/services/document-service/utils/unidirectional-relations.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport { keyBy, omit } from 'lodash/fp';\n\nimport { UID, Schema } from '@strapi/types';\n\ninterface LoadContext {\n oldVersions: { id: string; locale: string }[];\n newVersions: { id: string; locale: string }[];\n}\n\n/**\n * Loads lingering relations that need to be updated when overriding a published or draft entry.\n * This is necessary because the relations are uni-directional and the target entry is not aware of the source entry.\n * This is not the case for bi-directional relations, where the target entry is also linked to the source entry.\n */\nconst load = async (uid: UID.ContentType, { oldVersions, newVersions }: LoadContext) => {\n const updates = [] as any;\n\n // Iterate all components and content types to find relations that need to be updated\n await strapi.db.transaction(async ({ trx }) => {\n const contentTypes = Object.values(strapi.contentTypes) as Schema.ContentType[];\n const components = Object.values(strapi.components) as Schema.Component[];\n\n for (const model of [...contentTypes, ...components]) {\n const dbModel = strapi.db.metadata.get(model.uid);\n\n for (const attribute of Object.values(dbModel.attributes) as any) {\n /**\n * Only consider unidirectional relations\n */\n if (\n attribute.type !== 'relation' ||\n attribute.target !== uid ||\n attribute.inversedBy ||\n attribute.mappedBy\n ) {\n continue;\n }\n\n // TODO: joinColumn relations\n const joinTable = attribute.joinTable;\n if (!joinTable) {\n continue;\n }\n\n const { name: sourceColumnName } = joinTable.joinColumn;\n const { name: targetColumnName } = joinTable.inverseJoinColumn;\n\n /**\n * Load all relations that need to be updated\n */\n // NOTE: when the model has draft and publish, we can assume relation are only draft to draft & published to published\n const ids = oldVersions.map((entry) => entry.id);\n\n const oldVersionsRelations = await strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids)\n .transacting(trx);\n\n if (oldVersionsRelations.length > 0) {\n updates.push({ joinTable, relations: oldVersionsRelations });\n }\n\n /**\n * if publishing\n * if published version exists\n * updated published versions links\n * else\n * create link to newly published version\n *\n * if discarding\n * if published version link exists & not draft version link\n * create link to new draft version\n */\n\n if (!model.options?.draftAndPublish) {\n const ids = newVersions.map((entry) => entry.id);\n\n const newVersionsRelations = await strapi.db\n .getConnection()\n .select('*')\n .from(joinTable.name)\n .whereIn(targetColumnName, ids)\n .transacting(trx);\n\n if (newVersionsRelations.length > 0) {\n // when publishing a draft that doesn't have a published version yet,\n // copy the links to the draft over to the published version\n // when discarding a published version, if no drafts exists\n const discardToAdd = newVersionsRelations\n .filter((relation) => {\n const matchingOldVerion = oldVersionsRelations.find((oldRelation) => {\n return oldRelation[sourceColumnName] === relation[sourceColumnName];\n });\n\n return !matchingOldVerion;\n })\n .map(omit('id'));\n\n updates.push({ joinTable, relations: discardToAdd });\n }\n }\n }\n }\n });\n\n return updates;\n};\n\n/**\n * Updates uni directional relations to target the right entries when overriding published or draft entries.\n *\n * @param oldEntries The old entries that are being overridden\n * @param newEntries The new entries that are overriding the old ones\n * @param oldRelations The relations that were previously loaded with `load` @see load\n */\nconst sync = async (\n oldEntries: { id: string; locale: string }[],\n newEntries: { id: string; locale: string }[],\n oldRelations: { joinTable: any; relations: any[] }[]\n) => {\n /**\n * Create a map of old entry ids to new entry ids\n *\n * Will be used to update the relation target ids\n */\n const newEntryByLocale = keyBy('locale', newEntries);\n const oldEntriesMap = oldEntries.reduce(\n (acc, entry) => {\n const newEntry = newEntryByLocale[entry.locale];\n if (!newEntry) return acc;\n acc[entry.id] = newEntry.id;\n return acc;\n },\n {} as Record<string, string>\n );\n\n await strapi.db.transaction(async ({ trx }) => {\n // Iterate old relations that are deleted and insert the new ones\n for (const { joinTable, relations } of oldRelations) {\n // Update old ids with the new ones\n const column = joinTable.inverseJoinColumn.name;\n\n const newRelations = relations.map((relation) => {\n const newId = oldEntriesMap[relation[column]];\n return { ...relation, [column]: newId };\n });\n\n // Insert those relations into the join table\n await trx.batchInsert(joinTable.name, newRelations, 1000);\n }\n });\n};\n\nexport { load, sync };\n"],"names":["ids","omit","keyBy"],"mappings":";;;AAeA,MAAM,OAAO,OAAO,KAAsB,EAAE,aAAa,kBAA+B;AACtF,QAAM,UAAU,CAAC;AAGjB,QAAM,OAAO,GAAG,YAAY,OAAO,EAAE,UAAU;AAC7C,UAAM,eAAe,OAAO,OAAO,OAAO,YAAY;AACtD,UAAM,aAAa,OAAO,OAAO,OAAO,UAAU;AAElD,eAAW,SAAS,CAAC,GAAG,cAAc,GAAG,UAAU,GAAG;AACpD,YAAM,UAAU,OAAO,GAAG,SAAS,IAAI,MAAM,GAAG;AAEhD,iBAAW,aAAa,OAAO,OAAO,QAAQ,UAAU,GAAU;AAK9D,YAAA,UAAU,SAAS,cACnB,UAAU,WAAW,OACrB,UAAU,cACV,UAAU,UACV;AACA;AAAA,QAAA;AAIF,cAAM,YAAY,UAAU;AAC5B,YAAI,CAAC,WAAW;AACd;AAAA,QAAA;AAGF,cAAM,EAAE,MAAM,iBAAiB,IAAI,UAAU;AAC7C,cAAM,EAAE,MAAM,iBAAiB,IAAI,UAAU;AAM7C,cAAM,MAAM,YAAY,IAAI,CAAC,UAAU,MAAM,EAAE;AAE/C,cAAM,uBAAuB,MAAM,OAAO,GACvC,cAAc,EACd,OAAO,GAAG,EACV,KAAK,UAAU,IAAI,EACnB,QAAQ,kBAAkB,GAAG,EAC7B,YAAY,GAAG;AAEd,YAAA,qBAAqB,SAAS,GAAG;AACnC,kBAAQ,KAAK,EAAE,WAAW,WAAW,sBAAsB;AAAA,QAAA;AAezD,YAAA,CAAC,MAAM,SAAS,iBAAiB;AACnC,gBAAMA,OAAM,YAAY,IAAI,CAAC,UAAU,MAAM,EAAE;AAE/C,gBAAM,uBAAuB,MAAM,OAAO,GACvC,cAAc,EACd,OAAO,GAAG,EACV,KAAK,UAAU,IAAI,EACnB,QAAQ,kBAAkBA,IAAG,EAC7B,YAAY,GAAG;AAEd,cAAA,qBAAqB,SAAS,GAAG;AAInC,kBAAM,eAAe,qBAClB,OAAO,CAAC,aAAa;AACpB,oBAAM,oBAAoB,qBAAqB,KAAK,CAAC,gBAAgB;AACnE,uBAAO,YAAY,gBAAgB,MAAM,SAAS,gBAAgB;AAAA,cAAA,CACnE;AAED,qBAAO,CAAC;AAAA,YACT,CAAA,EACA,IAAIC,QAAK,IAAI,CAAC;AAEjB,oBAAQ,KAAK,EAAE,WAAW,WAAW,cAAc;AAAA,UAAA;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,EACF,CACD;AAEM,SAAA;AACT;AASA,MAAM,OAAO,OACX,YACA,YACA,iBACG;AAMG,QAAA,mBAAmBC,GAAAA,MAAM,UAAU,UAAU;AACnD,QAAM,gBAAgB,WAAW;AAAA,IAC/B,CAAC,KAAK,UAAU;AACR,YAAA,WAAW,iBAAiB,MAAM,MAAM;AAC1C,UAAA,CAAC,SAAiB,QAAA;AAClB,UAAA,MAAM,EAAE,IAAI,SAAS;AAClB,aAAA;AAAA,IACT;AAAA,IACA,CAAA;AAAA,EACF;AAEA,QAAM,OAAO,GAAG,YAAY,OAAO,EAAE,UAAU;AAE7C,eAAW,EAAE,WAAW,UAAU,KAAK,cAAc;AAE7C,YAAA,SAAS,UAAU,kBAAkB;AAE3C,YAAM,eAAe,UAAU,IAAI,CAAC,aAAa;AAC/C,cAAM,QAAQ,cAAc,SAAS,MAAM,CAAC;AAC5C,eAAO,EAAE,GAAG,UAAU,CAAC,MAAM,GAAG,MAAM;AAAA,MAAA,CACvC;AAGD,YAAM,IAAI,YAAY,UAAU,MAAM,cAAc,GAAI;AAAA,IAAA;AAAA,EAC1D,CACD;AACH;;;"}