@strapi/data-transfer 0.0.0-experimental.62ce06180fe9a772eaeb3d43d238b26644f39f7c → 0.0.0-experimental.6340da17068c3bed7fb006e7bcc554c71129e282

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 (395) hide show
  1. package/LICENSE +19 -4
  2. package/dist/directory/index.d.ts +2 -0
  3. package/dist/directory/index.d.ts.map +1 -0
  4. package/dist/directory/index.js +8 -0
  5. package/dist/directory/index.js.map +1 -0
  6. package/dist/directory/index.mjs +3 -0
  7. package/dist/directory/index.mjs.map +1 -0
  8. package/dist/directory/providers/destination/index.d.ts +38 -0
  9. package/dist/directory/providers/destination/index.d.ts.map +1 -0
  10. package/dist/directory/providers/destination/index.js +184 -0
  11. package/dist/directory/providers/destination/index.js.map +1 -0
  12. package/dist/directory/providers/destination/index.mjs +177 -0
  13. package/dist/directory/providers/destination/index.mjs.map +1 -0
  14. package/dist/directory/providers/destination/utils.d.ts +8 -0
  15. package/dist/directory/providers/destination/utils.d.ts.map +1 -0
  16. package/dist/directory/providers/destination/utils.js +62 -0
  17. package/dist/directory/providers/destination/utils.js.map +1 -0
  18. package/dist/directory/providers/destination/utils.mjs +56 -0
  19. package/dist/directory/providers/destination/utils.mjs.map +1 -0
  20. package/dist/directory/providers/index.d.ts +3 -0
  21. package/dist/directory/providers/index.d.ts.map +1 -0
  22. package/dist/directory/providers/index.js +10 -0
  23. package/dist/directory/providers/index.js.map +1 -0
  24. package/dist/directory/providers/index.mjs +3 -0
  25. package/dist/directory/providers/index.mjs.map +1 -0
  26. package/dist/directory/providers/source/index.d.ts +27 -0
  27. package/dist/directory/providers/source/index.d.ts.map +1 -0
  28. package/dist/directory/providers/source/index.js +266 -0
  29. package/dist/directory/providers/source/index.js.map +1 -0
  30. package/dist/directory/providers/source/index.mjs +259 -0
  31. package/dist/directory/providers/source/index.mjs.map +1 -0
  32. package/dist/engine/errors.js +39 -0
  33. package/dist/engine/errors.js.map +1 -0
  34. package/dist/engine/errors.mjs +34 -0
  35. package/dist/engine/errors.mjs.map +1 -0
  36. package/dist/engine/index.d.ts +2 -3
  37. package/dist/engine/index.d.ts.map +1 -1
  38. package/dist/engine/index.js +922 -0
  39. package/dist/engine/index.js.map +1 -0
  40. package/dist/engine/index.mjs +917 -0
  41. package/dist/engine/index.mjs.map +1 -0
  42. package/dist/engine/validation/provider.d.ts +2 -2
  43. package/dist/engine/validation/provider.d.ts.map +1 -1
  44. package/dist/engine/validation/provider.js +19 -0
  45. package/dist/engine/validation/provider.js.map +1 -0
  46. package/dist/engine/validation/provider.mjs +17 -0
  47. package/dist/engine/validation/provider.mjs.map +1 -0
  48. package/dist/engine/validation/schemas/index.d.ts.map +1 -1
  49. package/dist/engine/validation/schemas/index.js +59 -0
  50. package/dist/engine/validation/schemas/index.js.map +1 -0
  51. package/dist/engine/validation/schemas/index.mjs +57 -0
  52. package/dist/engine/validation/schemas/index.mjs.map +1 -0
  53. package/dist/errors/base.js +13 -0
  54. package/dist/errors/base.js.map +1 -0
  55. package/dist/errors/base.mjs +11 -0
  56. package/dist/errors/base.mjs.map +1 -0
  57. package/dist/errors/constants.d.ts +1 -1
  58. package/dist/errors/constants.d.ts.map +1 -1
  59. package/dist/errors/constants.js +9 -0
  60. package/dist/errors/constants.js.map +1 -0
  61. package/dist/errors/constants.mjs +7 -0
  62. package/dist/errors/constants.mjs.map +1 -0
  63. package/dist/errors/providers.d.ts +1 -1
  64. package/dist/errors/providers.d.ts.map +1 -1
  65. package/dist/errors/providers.js +41 -0
  66. package/dist/errors/providers.js.map +1 -0
  67. package/dist/errors/providers.mjs +36 -0
  68. package/dist/errors/providers.mjs.map +1 -0
  69. package/dist/file/index.js +8 -0
  70. package/dist/file/index.js.map +1 -0
  71. package/dist/file/index.mjs +3 -0
  72. package/dist/file/index.mjs.map +1 -0
  73. package/dist/file/providers/destination/index.d.ts +3 -5
  74. package/dist/file/providers/destination/index.d.ts.map +1 -1
  75. package/dist/file/providers/destination/index.js +254 -0
  76. package/dist/file/providers/destination/index.js.map +1 -0
  77. package/dist/file/providers/destination/index.mjs +246 -0
  78. package/dist/file/providers/destination/index.mjs.map +1 -0
  79. package/dist/file/providers/destination/utils.d.ts +0 -1
  80. package/dist/file/providers/destination/utils.d.ts.map +1 -1
  81. package/dist/file/providers/destination/utils.js +63 -0
  82. package/dist/file/providers/destination/utils.js.map +1 -0
  83. package/dist/file/providers/destination/utils.mjs +60 -0
  84. package/dist/file/providers/destination/utils.mjs.map +1 -0
  85. package/dist/file/providers/index.js +10 -0
  86. package/dist/file/providers/index.js.map +1 -0
  87. package/dist/file/providers/index.mjs +3 -0
  88. package/dist/file/providers/index.mjs.map +1 -0
  89. package/dist/file/providers/source/index.d.ts +3 -3
  90. package/dist/file/providers/source/index.d.ts.map +1 -1
  91. package/dist/file/providers/source/index.js +336 -0
  92. package/dist/file/providers/source/index.js.map +1 -0
  93. package/dist/file/providers/source/index.mjs +328 -0
  94. package/dist/file/providers/source/index.mjs.map +1 -0
  95. package/dist/file/providers/source/utils.d.ts.map +1 -1
  96. package/dist/file/providers/source/utils.js +60 -0
  97. package/dist/file/providers/source/utils.js.map +1 -0
  98. package/dist/file/providers/source/utils.mjs +52 -0
  99. package/dist/file/providers/source/utils.mjs.map +1 -0
  100. package/dist/index.d.ts +1 -0
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +15 -4408
  103. package/dist/index.js.map +1 -1
  104. package/dist/index.mjs +10 -4382
  105. package/dist/index.mjs.map +1 -1
  106. package/dist/strapi/index.js +12 -0
  107. package/dist/strapi/index.js.map +1 -0
  108. package/dist/strapi/index.mjs +7 -0
  109. package/dist/strapi/index.mjs.map +1 -0
  110. package/dist/strapi/providers/index.js +18 -0
  111. package/dist/strapi/providers/index.js.map +1 -0
  112. package/dist/strapi/providers/index.mjs +8 -0
  113. package/dist/strapi/providers/index.mjs.map +1 -0
  114. package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts +26 -0
  115. package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts.map +1 -0
  116. package/dist/strapi/providers/local-destination/assets-destination-writable.js +125 -0
  117. package/dist/strapi/providers/local-destination/assets-destination-writable.js.map +1 -0
  118. package/dist/strapi/providers/local-destination/assets-destination-writable.mjs +123 -0
  119. package/dist/strapi/providers/local-destination/assets-destination-writable.mjs.map +1 -0
  120. package/dist/strapi/providers/local-destination/index.d.ts +5 -3
  121. package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
  122. package/dist/strapi/providers/local-destination/index.js +362 -0
  123. package/dist/strapi/providers/local-destination/index.js.map +1 -0
  124. package/dist/strapi/providers/local-destination/index.mjs +335 -0
  125. package/dist/strapi/providers/local-destination/index.mjs.map +1 -0
  126. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +1 -2
  127. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
  128. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +58 -0
  129. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
  130. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs +51 -0
  131. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -0
  132. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +1 -2
  133. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
  134. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +54 -0
  135. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
  136. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +52 -0
  137. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -0
  138. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts.map +1 -1
  139. package/dist/strapi/providers/local-destination/strategies/restore/index.js +124 -0
  140. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
  141. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +120 -0
  142. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -0
  143. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +1 -2
  144. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
  145. package/dist/strapi/providers/local-destination/strategies/restore/links.js +79 -0
  146. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
  147. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +77 -0
  148. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -0
  149. package/dist/strapi/providers/local-source/assets.d.ts +8 -2
  150. package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
  151. package/dist/strapi/providers/local-source/assets.js +151 -0
  152. package/dist/strapi/providers/local-source/assets.js.map +1 -0
  153. package/dist/strapi/providers/local-source/assets.mjs +147 -0
  154. package/dist/strapi/providers/local-source/assets.mjs.map +1 -0
  155. package/dist/strapi/providers/local-source/configuration.d.ts +0 -1
  156. package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
  157. package/dist/strapi/providers/local-source/configuration.js +47 -0
  158. package/dist/strapi/providers/local-source/configuration.js.map +1 -0
  159. package/dist/strapi/providers/local-source/configuration.mjs +45 -0
  160. package/dist/strapi/providers/local-source/configuration.mjs.map +1 -0
  161. package/dist/strapi/providers/local-source/entities.d.ts +3 -2
  162. package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
  163. package/dist/strapi/providers/local-source/entities.js +66 -0
  164. package/dist/strapi/providers/local-source/entities.js.map +1 -0
  165. package/dist/strapi/providers/local-source/entities.mjs +63 -0
  166. package/dist/strapi/providers/local-source/entities.mjs.map +1 -0
  167. package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts +11 -0
  168. package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts.map +1 -0
  169. package/dist/strapi/providers/local-source/estimate-asset-totals.js +130 -0
  170. package/dist/strapi/providers/local-source/estimate-asset-totals.js.map +1 -0
  171. package/dist/strapi/providers/local-source/estimate-asset-totals.mjs +128 -0
  172. package/dist/strapi/providers/local-source/estimate-asset-totals.mjs.map +1 -0
  173. package/dist/strapi/providers/local-source/index.d.ts +6 -4
  174. package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
  175. package/dist/strapi/providers/local-source/index.js +186 -0
  176. package/dist/strapi/providers/local-source/index.js.map +1 -0
  177. package/dist/strapi/providers/local-source/index.mjs +183 -0
  178. package/dist/strapi/providers/local-source/index.mjs.map +1 -0
  179. package/dist/strapi/providers/local-source/links.d.ts +0 -1
  180. package/dist/strapi/providers/local-source/links.d.ts.map +1 -1
  181. package/dist/strapi/providers/local-source/links.js +26 -0
  182. package/dist/strapi/providers/local-source/links.js.map +1 -0
  183. package/dist/strapi/providers/local-source/links.mjs +24 -0
  184. package/dist/strapi/providers/local-source/links.mjs.map +1 -0
  185. package/dist/strapi/providers/remote-destination/index.d.ts +13 -5
  186. package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
  187. package/dist/strapi/providers/remote-destination/index.js +482 -0
  188. package/dist/strapi/providers/remote-destination/index.js.map +1 -0
  189. package/dist/strapi/providers/remote-destination/index.mjs +480 -0
  190. package/dist/strapi/providers/remote-destination/index.mjs.map +1 -0
  191. package/dist/strapi/providers/remote-source/index.d.ts +11 -6
  192. package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
  193. package/dist/strapi/providers/remote-source/index.js +538 -0
  194. package/dist/strapi/providers/remote-source/index.js.map +1 -0
  195. package/dist/strapi/providers/remote-source/index.mjs +536 -0
  196. package/dist/strapi/providers/remote-source/index.mjs.map +1 -0
  197. package/dist/strapi/providers/utils.d.ts +22 -16
  198. package/dist/strapi/providers/utils.d.ts.map +1 -1
  199. package/dist/strapi/providers/utils.js +178 -0
  200. package/dist/strapi/providers/utils.js.map +1 -0
  201. package/dist/strapi/providers/utils.mjs +174 -0
  202. package/dist/strapi/providers/utils.mjs.map +1 -0
  203. package/dist/strapi/queries/entity.d.ts.map +1 -1
  204. package/dist/strapi/queries/entity.js +125 -0
  205. package/dist/strapi/queries/entity.js.map +1 -0
  206. package/dist/strapi/queries/entity.mjs +123 -0
  207. package/dist/strapi/queries/entity.mjs.map +1 -0
  208. package/dist/strapi/queries/index.js +10 -0
  209. package/dist/strapi/queries/index.js.map +1 -0
  210. package/dist/strapi/queries/index.mjs +5 -0
  211. package/dist/strapi/queries/index.mjs.map +1 -0
  212. package/dist/strapi/queries/link.d.ts +1 -1
  213. package/dist/strapi/queries/link.d.ts.map +1 -1
  214. package/dist/strapi/queries/link.js +298 -0
  215. package/dist/strapi/queries/link.js.map +1 -0
  216. package/dist/strapi/queries/link.mjs +295 -0
  217. package/dist/strapi/queries/link.mjs.map +1 -0
  218. package/dist/strapi/remote/constants.d.ts.map +1 -1
  219. package/dist/strapi/remote/constants.js +11 -0
  220. package/dist/strapi/remote/constants.js.map +1 -0
  221. package/dist/strapi/remote/constants.mjs +8 -0
  222. package/dist/strapi/remote/constants.mjs.map +1 -0
  223. package/dist/strapi/remote/flows/default.d.ts.map +1 -1
  224. package/dist/strapi/remote/flows/default.js +43 -0
  225. package/dist/strapi/remote/flows/default.js.map +1 -0
  226. package/dist/strapi/remote/flows/default.mjs +41 -0
  227. package/dist/strapi/remote/flows/default.mjs.map +1 -0
  228. package/dist/strapi/remote/flows/index.d.ts +1 -1
  229. package/dist/strapi/remote/flows/index.d.ts.map +1 -1
  230. package/dist/strapi/remote/flows/index.js +54 -0
  231. package/dist/strapi/remote/flows/index.js.map +1 -0
  232. package/dist/strapi/remote/flows/index.mjs +52 -0
  233. package/dist/strapi/remote/flows/index.mjs.map +1 -0
  234. package/dist/strapi/remote/handlers/abstract.d.ts +4 -1
  235. package/dist/strapi/remote/handlers/abstract.d.ts.map +1 -1
  236. package/dist/strapi/remote/handlers/constants.js +10 -0
  237. package/dist/strapi/remote/handlers/constants.js.map +1 -0
  238. package/dist/strapi/remote/handlers/constants.mjs +8 -0
  239. package/dist/strapi/remote/handlers/constants.mjs.map +1 -0
  240. package/dist/strapi/remote/handlers/index.js +12 -0
  241. package/dist/strapi/remote/handlers/index.js.map +1 -0
  242. package/dist/strapi/remote/handlers/index.mjs +4 -0
  243. package/dist/strapi/remote/handlers/index.mjs.map +1 -0
  244. package/dist/strapi/remote/handlers/pull.d.ts +2 -3
  245. package/dist/strapi/remote/handlers/pull.d.ts.map +1 -1
  246. package/dist/strapi/remote/handlers/pull.js +369 -0
  247. package/dist/strapi/remote/handlers/pull.js.map +1 -0
  248. package/dist/strapi/remote/handlers/pull.mjs +367 -0
  249. package/dist/strapi/remote/handlers/pull.mjs.map +1 -0
  250. package/dist/strapi/remote/handlers/push.d.ts +16 -5
  251. package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
  252. package/dist/strapi/remote/handlers/push.js +454 -0
  253. package/dist/strapi/remote/handlers/push.js.map +1 -0
  254. package/dist/strapi/remote/handlers/push.mjs +452 -0
  255. package/dist/strapi/remote/handlers/push.mjs.map +1 -0
  256. package/dist/strapi/remote/handlers/utils.d.ts +1 -2
  257. package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
  258. package/dist/strapi/remote/handlers/utils.js +318 -0
  259. package/dist/strapi/remote/handlers/utils.js.map +1 -0
  260. package/dist/strapi/remote/handlers/utils.mjs +312 -0
  261. package/dist/strapi/remote/handlers/utils.mjs.map +1 -0
  262. package/dist/strapi/remote/index.js +10 -0
  263. package/dist/strapi/remote/index.js.map +1 -0
  264. package/dist/strapi/remote/index.mjs +5 -0
  265. package/dist/strapi/remote/index.mjs.map +1 -0
  266. package/dist/strapi/utils/project-settings-logos.d.ts +29 -0
  267. package/dist/strapi/utils/project-settings-logos.d.ts.map +1 -0
  268. package/dist/strapi/utils/project-settings-logos.js +174 -0
  269. package/dist/strapi/utils/project-settings-logos.js.map +1 -0
  270. package/dist/strapi/utils/project-settings-logos.mjs +169 -0
  271. package/dist/strapi/utils/project-settings-logos.mjs.map +1 -0
  272. package/dist/types/common-entities.d.ts +149 -0
  273. package/dist/types/common-entities.d.ts.map +1 -0
  274. package/dist/types/encryption.d.ts +13 -0
  275. package/dist/types/encryption.d.ts.map +1 -0
  276. package/dist/types/index.d.ts +7 -0
  277. package/dist/types/index.d.ts.map +1 -0
  278. package/dist/types/providers.d.ts +49 -0
  279. package/dist/types/providers.d.ts.map +1 -0
  280. package/dist/types/remote/index.d.ts +2 -0
  281. package/dist/types/remote/index.d.ts.map +1 -0
  282. package/dist/types/remote/protocol/auth.d.ts +5 -0
  283. package/dist/types/remote/protocol/auth.d.ts.map +1 -0
  284. package/dist/types/remote/protocol/client/commands.d.ts +37 -0
  285. package/dist/types/remote/protocol/client/commands.d.ts.map +1 -0
  286. package/dist/types/remote/protocol/client/index.d.ts +9 -0
  287. package/dist/types/remote/protocol/client/index.d.ts.map +1 -0
  288. package/dist/types/remote/protocol/client/transfer/action.d.ts +5 -0
  289. package/dist/types/remote/protocol/client/transfer/action.d.ts.map +1 -0
  290. package/dist/types/remote/protocol/client/transfer/index.d.ts +12 -0
  291. package/dist/types/remote/protocol/client/transfer/index.d.ts.map +1 -0
  292. package/dist/types/remote/protocol/client/transfer/pull.d.ts +25 -0
  293. package/dist/types/remote/protocol/client/transfer/pull.d.ts.map +1 -0
  294. package/dist/types/remote/protocol/client/transfer/push.d.ts +29 -0
  295. package/dist/types/remote/protocol/client/transfer/push.d.ts.map +1 -0
  296. package/dist/types/remote/protocol/client/transfer/utils.d.ts +47 -0
  297. package/dist/types/remote/protocol/client/transfer/utils.d.ts.map +1 -0
  298. package/dist/types/remote/protocol/index.d.ts +4 -0
  299. package/dist/types/remote/protocol/index.d.ts.map +1 -0
  300. package/dist/types/remote/protocol/server/error.d.ts +18 -0
  301. package/dist/types/remote/protocol/server/error.d.ts.map +1 -0
  302. package/dist/types/remote/protocol/server/index.d.ts +3 -0
  303. package/dist/types/remote/protocol/server/index.d.ts.map +1 -0
  304. package/dist/types/remote/protocol/server/messaging.d.ts +37 -0
  305. package/dist/types/remote/protocol/server/messaging.d.ts.map +1 -0
  306. package/dist/types/transfer-engine.d.ts +148 -0
  307. package/dist/types/transfer-engine.d.ts.map +1 -0
  308. package/dist/types/utils.d.ts +82 -0
  309. package/dist/types/utils.d.ts.map +1 -0
  310. package/dist/utils/components.d.ts +23 -3
  311. package/dist/utils/components.d.ts.map +1 -1
  312. package/dist/utils/components.js +230 -0
  313. package/dist/utils/components.js.map +1 -0
  314. package/dist/utils/components.mjs +219 -0
  315. package/dist/utils/components.mjs.map +1 -0
  316. package/dist/{engine → utils}/diagnostic.d.ts +1 -0
  317. package/dist/utils/diagnostic.d.ts.map +1 -0
  318. package/dist/utils/diagnostic.js +51 -0
  319. package/dist/utils/diagnostic.js.map +1 -0
  320. package/dist/utils/diagnostic.mjs +49 -0
  321. package/dist/utils/diagnostic.mjs.map +1 -0
  322. package/dist/utils/encryption/decrypt.d.ts +6 -5
  323. package/dist/utils/encryption/decrypt.d.ts.map +1 -1
  324. package/dist/utils/encryption/decrypt.js +47 -0
  325. package/dist/utils/encryption/decrypt.js.map +1 -0
  326. package/dist/utils/encryption/decrypt.mjs +45 -0
  327. package/dist/utils/encryption/decrypt.mjs.map +1 -0
  328. package/dist/utils/encryption/encrypt.d.ts +6 -5
  329. package/dist/utils/encryption/encrypt.d.ts.map +1 -1
  330. package/dist/utils/encryption/encrypt.js +47 -0
  331. package/dist/utils/encryption/encrypt.js.map +1 -0
  332. package/dist/utils/encryption/encrypt.mjs +45 -0
  333. package/dist/utils/encryption/encrypt.mjs.map +1 -0
  334. package/dist/utils/encryption/index.js +10 -0
  335. package/dist/utils/encryption/index.js.map +1 -0
  336. package/dist/utils/encryption/index.mjs +3 -0
  337. package/dist/utils/encryption/index.mjs.map +1 -0
  338. package/dist/utils/index.d.ts +3 -0
  339. package/dist/utils/index.d.ts.map +1 -1
  340. package/dist/utils/index.js +28 -0
  341. package/dist/utils/index.js.map +1 -0
  342. package/dist/utils/index.mjs +17 -0
  343. package/dist/utils/index.mjs.map +1 -0
  344. package/dist/utils/json.d.ts.map +1 -1
  345. package/dist/utils/json.js +96 -0
  346. package/dist/utils/json.js.map +1 -0
  347. package/dist/utils/json.mjs +94 -0
  348. package/dist/utils/json.mjs.map +1 -0
  349. package/dist/utils/middleware.d.ts +1 -1
  350. package/dist/utils/middleware.d.ts.map +1 -1
  351. package/dist/utils/middleware.js +14 -0
  352. package/dist/utils/middleware.js.map +1 -0
  353. package/dist/utils/middleware.mjs +12 -0
  354. package/dist/utils/middleware.mjs.map +1 -0
  355. package/dist/utils/providers.js +12 -0
  356. package/dist/utils/providers.js.map +1 -0
  357. package/dist/utils/providers.mjs +10 -0
  358. package/dist/utils/providers.mjs.map +1 -0
  359. package/dist/utils/schema.d.ts.map +1 -1
  360. package/dist/utils/schema.js +32 -0
  361. package/dist/utils/schema.js.map +1 -0
  362. package/dist/utils/schema.mjs +29 -0
  363. package/dist/utils/schema.mjs.map +1 -0
  364. package/dist/utils/stream.d.ts +0 -1
  365. package/dist/utils/stream.d.ts.map +1 -1
  366. package/dist/utils/stream.js +96 -0
  367. package/dist/utils/stream.js.map +1 -0
  368. package/dist/utils/stream.mjs +92 -0
  369. package/dist/utils/stream.mjs.map +1 -0
  370. package/dist/utils/transaction.d.ts +1 -1
  371. package/dist/utils/transaction.d.ts.map +1 -1
  372. package/dist/utils/transaction.js +93 -0
  373. package/dist/utils/transaction.js.map +1 -0
  374. package/dist/utils/transaction.mjs +91 -0
  375. package/dist/utils/transaction.mjs.map +1 -0
  376. package/dist/utils/transfer-asset-chunk.d.ts +61 -0
  377. package/dist/utils/transfer-asset-chunk.d.ts.map +1 -0
  378. package/dist/utils/transfer-asset-chunk.js +118 -0
  379. package/dist/utils/transfer-asset-chunk.js.map +1 -0
  380. package/dist/utils/transfer-asset-chunk.mjs +112 -0
  381. package/dist/utils/transfer-asset-chunk.mjs.map +1 -0
  382. package/dist/utils/transfer-websocket-json.d.ts +24 -0
  383. package/dist/utils/transfer-websocket-json.d.ts.map +1 -0
  384. package/dist/utils/transfer-websocket-json.js +67 -0
  385. package/dist/utils/transfer-websocket-json.js.map +1 -0
  386. package/dist/utils/transfer-websocket-json.mjs +63 -0
  387. package/dist/utils/transfer-websocket-json.mjs.map +1 -0
  388. package/dist/utils/writable-async-write.d.ts +16 -0
  389. package/dist/utils/writable-async-write.d.ts.map +1 -0
  390. package/dist/utils/writable-async-write.js +61 -0
  391. package/dist/utils/writable-async-write.js.map +1 -0
  392. package/dist/utils/writable-async-write.mjs +59 -0
  393. package/dist/utils/writable-async-write.mjs.map +1 -0
  394. package/package.json +40 -26
  395. package/dist/engine/diagnostic.d.ts.map +0 -1
@@ -0,0 +1,230 @@
1
+ 'use strict';
2
+
3
+ var _ = require('lodash');
4
+ var fp = require('lodash/fp');
5
+ var utils = require('@strapi/utils');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var ___default = /*#__PURE__*/_interopDefault(_);
10
+
11
+ const isDialectMySQL = ()=>strapi.db?.dialect.client === 'mysql';
12
+ function omitComponentData(contentType, data) {
13
+ const { attributes } = contentType;
14
+ const componentAttributes = Object.keys(attributes).filter((attributeName)=>utils.contentTypes.isComponentAttribute(attributes[attributeName]));
15
+ return fp.omit(componentAttributes, data);
16
+ }
17
+ // NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
18
+ const createComponents = async (uid, data)=>{
19
+ const { attributes = {} } = strapi.getModel(uid);
20
+ const componentBody = {};
21
+ const attributeNames = Object.keys(attributes);
22
+ for (const attributeName of attributeNames){
23
+ const attribute = attributes[attributeName];
24
+ if (!fp.has(attributeName, data) || !utils.contentTypes.isComponentAttribute(attribute)) {
25
+ continue;
26
+ }
27
+ if (attribute.type === 'component') {
28
+ const { component: componentUID, repeatable = false } = attribute;
29
+ const componentValue = data[attributeName];
30
+ if (componentValue === null) {
31
+ continue;
32
+ }
33
+ if (repeatable === true) {
34
+ if (!Array.isArray(componentValue)) {
35
+ throw new Error('Expected an array to create repeatable component');
36
+ }
37
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
38
+ const components = await utils.async.map(componentValue, (value)=>createComponent(componentUID, value), {
39
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
40
+ });
41
+ componentBody[attributeName] = components.map(({ id })=>{
42
+ return {
43
+ id,
44
+ __pivot: {
45
+ field: attributeName,
46
+ component_type: componentUID
47
+ }
48
+ };
49
+ });
50
+ } else {
51
+ const component = await createComponent(componentUID, componentValue);
52
+ componentBody[attributeName] = {
53
+ id: component.id,
54
+ __pivot: {
55
+ field: attributeName,
56
+ component_type: componentUID
57
+ }
58
+ };
59
+ }
60
+ continue;
61
+ }
62
+ if (attribute.type === 'dynamiczone') {
63
+ const dynamiczoneValues = data[attributeName];
64
+ if (!Array.isArray(dynamiczoneValues)) {
65
+ throw new Error('Expected an array to create repeatable component');
66
+ }
67
+ const createDynamicZoneComponents = async (value)=>{
68
+ const { id } = await createComponent(value.__component, value);
69
+ return {
70
+ id,
71
+ __component: value.__component,
72
+ __pivot: {
73
+ field: attributeName
74
+ }
75
+ };
76
+ };
77
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
78
+ componentBody[attributeName] = await utils.async.map(dynamiczoneValues, createDynamicZoneComponents, {
79
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
80
+ });
81
+ continue;
82
+ }
83
+ }
84
+ return componentBody;
85
+ };
86
+ const getComponents = async (uid, entity)=>{
87
+ const componentAttributes = utils.contentTypes.getComponentAttributes(strapi.getModel(uid));
88
+ if (___default.default.isEmpty(componentAttributes)) {
89
+ return {};
90
+ }
91
+ return strapi.db.query(uid).load(entity, componentAttributes);
92
+ };
93
+ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {})=>{
94
+ const { attributes = {} } = strapi.getModel(uid);
95
+ const attributeNames = Object.keys(attributes);
96
+ for (const attributeName of attributeNames){
97
+ const attribute = attributes[attributeName];
98
+ if (attribute.type === 'component' || attribute.type === 'dynamiczone') {
99
+ let value;
100
+ if (loadComponents) {
101
+ value = await strapi.db.query(uid).load(entityToDelete, attributeName);
102
+ } else {
103
+ value = entityToDelete[attributeName];
104
+ }
105
+ if (!value) {
106
+ continue;
107
+ }
108
+ if (attribute.type === 'component') {
109
+ const { component: componentUID } = attribute;
110
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
111
+ await utils.async.map(___default.default.castArray(value), (subValue)=>deleteComponent(componentUID, subValue), {
112
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
113
+ });
114
+ } else {
115
+ // delete dynamic zone components
116
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
117
+ await utils.async.map(___default.default.castArray(value), (subValue)=>deleteComponent(subValue.__component, subValue), {
118
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
119
+ });
120
+ }
121
+ continue;
122
+ }
123
+ }
124
+ };
125
+ /** *************************
126
+ Component queries
127
+ ************************** */ // components can have nested compos so this must be recursive
128
+ const createComponent = async (uid, data)=>{
129
+ const model = strapi.getModel(uid);
130
+ const componentData = await createComponents(uid, data);
131
+ const transform = fp.pipe(// Make sure we don't save the component with a pre-defined ID
132
+ fp.omit('id'), // Remove the component data from the original data object ...
133
+ (payload)=>omitComponentData(model, payload), // ... and assign the newly created component instead
134
+ fp.assign(componentData));
135
+ return strapi.db.query(uid).create({
136
+ data: transform(data)
137
+ });
138
+ };
139
+ const deleteComponent = async (uid, componentToDelete)=>{
140
+ await deleteComponents(uid, componentToDelete);
141
+ await strapi.db.query(uid).delete({
142
+ where: {
143
+ id: componentToDelete.id
144
+ }
145
+ });
146
+ };
147
+ /**
148
+ * Walk the source data and the newly created entity in parallel and collect
149
+ * the [old ID, new ID] couple of every component instance found in both trees
150
+ * (components & dynamic zones, including nested ones).
151
+ *
152
+ * Unlike a JSON diff, couples are also collected when the ID did not change,
153
+ * so the result is an exhaustive map of every component instance that was
154
+ * re-created with the entity.
155
+ */ const collectComponentIdMappings = ({ data, created, schema, strapi: strapi1 })=>{
156
+ const mappings = [];
157
+ const visitComponent = (uid, oldValue, newValue)=>{
158
+ if (!___default.default.isObjectLike(oldValue) || !___default.default.isObjectLike(newValue)) {
159
+ return;
160
+ }
161
+ if (typeof oldValue.id === 'number' && typeof newValue.id === 'number') {
162
+ mappings.push({
163
+ uid,
164
+ oldID: oldValue.id,
165
+ newID: newValue.id
166
+ });
167
+ }
168
+ const componentSchema = strapi1.getModel(uid);
169
+ // Collect nested components & dynamic zones
170
+ if (componentSchema) {
171
+ visitSchema(componentSchema, oldValue, newValue);
172
+ }
173
+ };
174
+ const visitSchema = (currentSchema, oldData, newData)=>{
175
+ if (!___default.default.isObjectLike(oldData) || !___default.default.isObjectLike(newData)) {
176
+ return;
177
+ }
178
+ const { attributes = {} } = currentSchema;
179
+ for (const [attributeName, attribute] of Object.entries(attributes)){
180
+ const oldValue = oldData[attributeName];
181
+ const newValue = newData[attributeName];
182
+ if (___default.default.isNil(oldValue) || ___default.default.isNil(newValue)) {
183
+ continue;
184
+ }
185
+ if (attribute.type === 'component') {
186
+ const { component: componentUID, repeatable = false } = attribute;
187
+ if (repeatable === true) {
188
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
189
+ continue;
190
+ }
191
+ // Components are created (and thus populated back) in the same
192
+ // order as the source data, pair them by index
193
+ const length = Math.min(oldValue.length, newValue.length);
194
+ for(let i = 0; i < length; i += 1){
195
+ visitComponent(componentUID, oldValue[i], newValue[i]);
196
+ }
197
+ } else {
198
+ visitComponent(componentUID, oldValue, newValue);
199
+ }
200
+ }
201
+ if (attribute.type === 'dynamiczone') {
202
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
203
+ continue;
204
+ }
205
+ const length = Math.min(oldValue.length, newValue.length);
206
+ for(let i = 0; i < length; i += 1){
207
+ const oldItem = oldValue[i];
208
+ const newItem = newValue[i];
209
+ const componentUID = oldItem?.__component;
210
+ // Both items must reference the same dynamic zone component for the
211
+ // ID couple to be meaningful
212
+ if (!componentUID || newItem?.__component && newItem.__component !== componentUID) {
213
+ continue;
214
+ }
215
+ visitComponent(componentUID, oldItem, newItem);
216
+ }
217
+ }
218
+ }
219
+ };
220
+ visitSchema(schema, data, created);
221
+ return mappings;
222
+ };
223
+
224
+ exports.collectComponentIdMappings = collectComponentIdMappings;
225
+ exports.createComponents = createComponents;
226
+ exports.deleteComponent = deleteComponent;
227
+ exports.deleteComponents = deleteComponents;
228
+ exports.getComponents = getComponents;
229
+ exports.omitComponentData = omitComponentData;
230
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sources":["../../src/utils/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { get, has, omit, pipe, assign } from 'lodash/fp';\n\nimport { contentTypes as contentTypesUtils, async, errors } from '@strapi/utils';\nimport type { Modules, UID, Data, Utils, Schema, Core } from '@strapi/types';\n\ntype LoadedComponents<TUID extends UID.Schema> = Data.Entity<\n TUID,\n Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype ComponentValue = Schema.Attribute.Value<\n Schema.Attribute.Component<UID.Component, false> | Schema.Attribute.Component<UID.Component, true>\n>;\n\ntype ComponentBody = {\n [key: string]: Schema.Attribute.Value<\n | Schema.Attribute.Component<UID.Component, false>\n | Schema.Attribute.Component<UID.Component, true>\n | Schema.Attribute.DynamicZone\n >;\n};\n\nconst isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';\n\nfunction omitComponentData(\n contentType: Schema.ContentType,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>>;\nfunction omitComponentData(\n contentType: Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.Component['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.Component['uid']>>;\nfunction omitComponentData(\n contentType: Schema.ContentType | Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n): Partial<\n Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n> {\n const { attributes } = contentType;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n}\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <\n TUID extends UID.Schema,\n TData extends Modules.EntityService.Params.Data.Input<TUID>,\n>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => createComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as Modules.EntityService.Params.Data.Input<UID.Component>\n );\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Modules.EntityService.Params.Attribute.GetValue<Schema.Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n createDynamicZoneComponents,\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entity: { id: Modules.EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.db.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <\n TUID extends UID.Schema,\n TData extends Partial<Modules.EntityService.Params.Data.Input<TUID>>,\n>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.Component>;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => updateOrCreateComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: Modules.EntityService.Params.Attribute.ID;\n}): Modules.EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n componentUID: UID.Component,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: Schema.Attribute.Value<Schema.Attribute.Component>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: Schema.Attribute.Value<Schema.Attribute.DynamicZone>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <TUID extends UID.Schema, TEntity extends Data.Entity<TUID>>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n if (loadComponents) {\n value = await strapi.db.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(componentUID, subValue),\n {\n concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,\n }\n );\n } else {\n // delete dynamic zone components\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(subValue.__component, subValue),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n }\n\n continue;\n }\n }\n};\n\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends UID.Component = UID.Component>(\n uid: TUID,\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await createComponents(uid, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.db.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.db.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: Object.assign(omitComponentData(model, data), componentData),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends UID.Component>(\n componentUID: TUID,\n value: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToDelete: Data.Component<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\ninterface IComponentIdMapping {\n uid: UID.Component;\n oldID: number;\n newID: number;\n}\n\n/**\n * Walk the source data and the newly created entity in parallel and collect\n * the [old ID, new ID] couple of every component instance found in both trees\n * (components & dynamic zones, including nested ones).\n *\n * Unlike a JSON diff, couples are also collected when the ID did not change,\n * so the result is an exhaustive map of every component instance that was\n * re-created with the entity.\n */\nconst collectComponentIdMappings = ({\n data,\n created,\n schema,\n strapi,\n}: {\n data: any;\n created: any;\n schema: Schema.Schema;\n strapi: Core.Strapi;\n}): IComponentIdMapping[] => {\n const mappings: IComponentIdMapping[] = [];\n\n const visitComponent = (uid: UID.Component, oldValue: any, newValue: any) => {\n if (!_.isObjectLike(oldValue) || !_.isObjectLike(newValue)) {\n return;\n }\n\n if (typeof oldValue.id === 'number' && typeof newValue.id === 'number') {\n mappings.push({ uid, oldID: oldValue.id, newID: newValue.id });\n }\n\n const componentSchema = strapi.getModel(uid);\n\n // Collect nested components & dynamic zones\n if (componentSchema) {\n visitSchema(componentSchema, oldValue, newValue);\n }\n };\n\n const visitSchema = (currentSchema: Schema.Schema, oldData: any, newData: any) => {\n if (!_.isObjectLike(oldData) || !_.isObjectLike(newData)) {\n return;\n }\n\n const { attributes = {} } = currentSchema;\n\n for (const [attributeName, attribute] of Object.entries(attributes)) {\n const oldValue = oldData[attributeName];\n const newValue = newData[attributeName];\n\n if (_.isNil(oldValue) || _.isNil(newValue)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n if (repeatable === true) {\n if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {\n continue;\n }\n\n // Components are created (and thus populated back) in the same\n // order as the source data, pair them by index\n const length = Math.min(oldValue.length, newValue.length);\n\n for (let i = 0; i < length; i += 1) {\n visitComponent(componentUID, oldValue[i], newValue[i]);\n }\n } else {\n visitComponent(componentUID, oldValue, newValue);\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {\n continue;\n }\n\n const length = Math.min(oldValue.length, newValue.length);\n\n for (let i = 0; i < length; i += 1) {\n const oldItem = oldValue[i];\n const newItem = newValue[i];\n const componentUID = oldItem?.__component;\n\n // Both items must reference the same dynamic zone component for the\n // ID couple to be meaningful\n if (!componentUID || (newItem?.__component && newItem.__component !== componentUID)) {\n continue;\n }\n\n visitComponent(componentUID, oldItem, newItem);\n }\n }\n }\n };\n\n visitSchema(schema, data, created);\n\n return mappings;\n};\n\n/**\n * Resolve the component UID of an entity's attribute based\n * on a given path (components & dynamic zones only)\n */\nconst resolveComponentUID = ({\n paths,\n strapi,\n data,\n contentType,\n}: {\n paths: string[];\n strapi: Core.Strapi;\n data: any;\n contentType: Schema.ContentType;\n}): UID.Schema | undefined => {\n let value: unknown = data;\n let cType:\n | Schema.ContentType\n | Schema.Component\n | ((...opts: any[]) => Schema.ContentType | Schema.Component) = contentType;\n for (const path of paths) {\n value = get(path, value);\n\n // Needed when the value of cType should be computed\n // based on the next value (eg: dynamic zones)\n if (typeof cType === 'function') {\n cType = cType(value);\n }\n\n if (path in cType.attributes) {\n const attribute: Schema.Attribute.AnyAttribute = cType.attributes[path];\n\n if (attribute.type === 'component') {\n cType = strapi.getModel(attribute.component);\n }\n\n if (attribute.type === 'dynamiczone') {\n cType = ({ __component }: { __component: UID.Component }) => strapi.getModel(__component);\n }\n }\n }\n\n if ('uid' in cType) {\n return cType.uid;\n }\n\n return undefined;\n};\n\nexport {\n omitComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n collectComponentIdMappings,\n resolveComponentUID,\n};\n"],"names":["isDialectMySQL","strapi","db","dialect","client","omitComponentData","contentType","data","attributes","componentAttributes","Object","keys","filter","attributeName","contentTypesUtils","isComponentAttribute","omit","createComponents","uid","getModel","componentBody","attributeNames","attribute","has","type","component","componentUID","repeatable","componentValue","Array","isArray","Error","components","async","map","value","createComponent","concurrency","inTransaction","Infinity","id","__pivot","field","component_type","dynamiczoneValues","createDynamicZoneComponents","__component","getComponents","entity","getComponentAttributes","_","isEmpty","query","load","deleteComponents","entityToDelete","loadComponents","castArray","subValue","deleteComponent","model","componentData","transform","pipe","payload","assign","create","componentToDelete","delete","where","collectComponentIdMappings","created","schema","mappings","visitComponent","oldValue","newValue","isObjectLike","push","oldID","newID","componentSchema","visitSchema","currentSchema","oldData","newData","entries","isNil","length","Math","min","i","oldItem","newItem"],"mappings":";;;;;;;;;;AAuBA,MAAMA,iBAAiB,IAAMC,MAAAA,CAAOC,EAAE,EAAEC,QAAQC,MAAAA,KAAW,OAAA;AAU3D,SAASC,iBAAAA,CACPC,WAAkD,EAClDC,IAAkG,EAAA;IAIlG,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,IAAA,MAAMG,mBAAAA,GAAsBC,MAAAA,CAAOC,IAAI,CAACH,YAAYI,MAAM,CAAC,CAACC,aAAAA,GAC1DC,kBAAAA,CAAkBC,oBAAoB,CAACP,UAAU,CAACK,aAAAA,CAAc,CAAA,CAAA;AAGlE,IAAA,OAAOG,QAAKP,mBAAAA,EAAqBF,IAAAA,CAAAA;AACnC;AAEA;AACA,MAAMU,gBAAAA,GAAmB,OAIvBC,GAAAA,EACAX,IAAAA,GAAAA;IAEA,MAAM,EAAEC,aAAa,EAAE,EAAE,GAAGP,MAAAA,CAAOkB,QAAQ,CAACD,GAAAA,CAAAA;AAE5C,IAAA,MAAME,gBAA+B,EAAC;IAEtC,MAAMC,cAAAA,GAAiBX,MAAAA,CAAOC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,CAAAA;AACzC,gBAAA;AACF,YAAA;YAEA,IAAItD,SAAAA,CAAUE,IAAI,KAAK,aAAA,EAAe;gBACpC,IAAI,CAACK,MAAMC,OAAO,CAAC6C,aAAa,CAAC9C,KAAAA,CAAMC,OAAO,CAAC8C,QAAAA,CAAAA,EAAW;AACxD,oBAAA;AACF,gBAAA;gBAEA,MAAMY,MAAAA,GAASC,KAAKC,GAAG,CAACf,SAASa,MAAM,EAAEZ,SAASY,MAAM,CAAA;AAExD,gBAAA,IAAK,IAAIG,CAAAA,GAAI,CAAA,EAAGA,CAAAA,GAAIH,MAAAA,EAAQG,KAAK,CAAA,CAAG;oBAClC,MAAMC,OAAAA,GAAUjB,QAAQ,CAACgB,CAAAA,CAAE;oBAC3B,MAAME,OAAAA,GAAUjB,QAAQ,CAACe,CAAAA,CAAE;AAC3B,oBAAA,MAAMjE,eAAekE,OAAAA,EAAS9C,WAAAA;;;AAI9B,oBAAA,IAAI,CAACpB,YAAAA,IAAiBmE,OAAAA,EAAS/C,eAAe+C,OAAAA,CAAQ/C,WAAW,KAAKpB,YAAAA,EAAe;AACnF,wBAAA;AACF,oBAAA;AAEAgD,oBAAAA,cAAAA,CAAehD,cAAckE,OAAAA,EAASC,OAAAA,CAAAA;AACxC,gBAAA;AACF,YAAA;AACF,QAAA;AACF,IAAA,CAAA;AAEAX,IAAAA,WAAAA,CAAYV,QAAQjE,IAAAA,EAAMgE,OAAAA,CAAAA;IAE1B,OAAOE,QAAAA;AACT;;;;;;;;;"}
@@ -0,0 +1,219 @@
1
+ import _ from 'lodash';
2
+ import { has, pipe, omit, assign } from 'lodash/fp';
3
+ import { async, contentTypes } from '@strapi/utils';
4
+
5
+ const isDialectMySQL = ()=>strapi.db?.dialect.client === 'mysql';
6
+ function omitComponentData(contentType, data) {
7
+ const { attributes } = contentType;
8
+ const componentAttributes = Object.keys(attributes).filter((attributeName)=>contentTypes.isComponentAttribute(attributes[attributeName]));
9
+ return omit(componentAttributes, data);
10
+ }
11
+ // NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
12
+ const createComponents = async (uid, data)=>{
13
+ const { attributes = {} } = strapi.getModel(uid);
14
+ const componentBody = {};
15
+ const attributeNames = Object.keys(attributes);
16
+ for (const attributeName of attributeNames){
17
+ const attribute = attributes[attributeName];
18
+ if (!has(attributeName, data) || !contentTypes.isComponentAttribute(attribute)) {
19
+ continue;
20
+ }
21
+ if (attribute.type === 'component') {
22
+ const { component: componentUID, repeatable = false } = attribute;
23
+ const componentValue = data[attributeName];
24
+ if (componentValue === null) {
25
+ continue;
26
+ }
27
+ if (repeatable === true) {
28
+ if (!Array.isArray(componentValue)) {
29
+ throw new Error('Expected an array to create repeatable component');
30
+ }
31
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
32
+ const components = await async.map(componentValue, (value)=>createComponent(componentUID, value), {
33
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
34
+ });
35
+ componentBody[attributeName] = components.map(({ id })=>{
36
+ return {
37
+ id,
38
+ __pivot: {
39
+ field: attributeName,
40
+ component_type: componentUID
41
+ }
42
+ };
43
+ });
44
+ } else {
45
+ const component = await createComponent(componentUID, componentValue);
46
+ componentBody[attributeName] = {
47
+ id: component.id,
48
+ __pivot: {
49
+ field: attributeName,
50
+ component_type: componentUID
51
+ }
52
+ };
53
+ }
54
+ continue;
55
+ }
56
+ if (attribute.type === 'dynamiczone') {
57
+ const dynamiczoneValues = data[attributeName];
58
+ if (!Array.isArray(dynamiczoneValues)) {
59
+ throw new Error('Expected an array to create repeatable component');
60
+ }
61
+ const createDynamicZoneComponents = async (value)=>{
62
+ const { id } = await createComponent(value.__component, value);
63
+ return {
64
+ id,
65
+ __component: value.__component,
66
+ __pivot: {
67
+ field: attributeName
68
+ }
69
+ };
70
+ };
71
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
72
+ componentBody[attributeName] = await async.map(dynamiczoneValues, createDynamicZoneComponents, {
73
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
74
+ });
75
+ continue;
76
+ }
77
+ }
78
+ return componentBody;
79
+ };
80
+ const getComponents = async (uid, entity)=>{
81
+ const componentAttributes = contentTypes.getComponentAttributes(strapi.getModel(uid));
82
+ if (_.isEmpty(componentAttributes)) {
83
+ return {};
84
+ }
85
+ return strapi.db.query(uid).load(entity, componentAttributes);
86
+ };
87
+ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {})=>{
88
+ const { attributes = {} } = strapi.getModel(uid);
89
+ const attributeNames = Object.keys(attributes);
90
+ for (const attributeName of attributeNames){
91
+ const attribute = attributes[attributeName];
92
+ if (attribute.type === 'component' || attribute.type === 'dynamiczone') {
93
+ let value;
94
+ if (loadComponents) {
95
+ value = await strapi.db.query(uid).load(entityToDelete, attributeName);
96
+ } else {
97
+ value = entityToDelete[attributeName];
98
+ }
99
+ if (!value) {
100
+ continue;
101
+ }
102
+ if (attribute.type === 'component') {
103
+ const { component: componentUID } = attribute;
104
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
105
+ await async.map(_.castArray(value), (subValue)=>deleteComponent(componentUID, subValue), {
106
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
107
+ });
108
+ } else {
109
+ // delete dynamic zone components
110
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
111
+ await async.map(_.castArray(value), (subValue)=>deleteComponent(subValue.__component, subValue), {
112
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
113
+ });
114
+ }
115
+ continue;
116
+ }
117
+ }
118
+ };
119
+ /** *************************
120
+ Component queries
121
+ ************************** */ // components can have nested compos so this must be recursive
122
+ const createComponent = async (uid, data)=>{
123
+ const model = strapi.getModel(uid);
124
+ const componentData = await createComponents(uid, data);
125
+ const transform = pipe(// Make sure we don't save the component with a pre-defined ID
126
+ omit('id'), // Remove the component data from the original data object ...
127
+ (payload)=>omitComponentData(model, payload), // ... and assign the newly created component instead
128
+ assign(componentData));
129
+ return strapi.db.query(uid).create({
130
+ data: transform(data)
131
+ });
132
+ };
133
+ const deleteComponent = async (uid, componentToDelete)=>{
134
+ await deleteComponents(uid, componentToDelete);
135
+ await strapi.db.query(uid).delete({
136
+ where: {
137
+ id: componentToDelete.id
138
+ }
139
+ });
140
+ };
141
+ /**
142
+ * Walk the source data and the newly created entity in parallel and collect
143
+ * the [old ID, new ID] couple of every component instance found in both trees
144
+ * (components & dynamic zones, including nested ones).
145
+ *
146
+ * Unlike a JSON diff, couples are also collected when the ID did not change,
147
+ * so the result is an exhaustive map of every component instance that was
148
+ * re-created with the entity.
149
+ */ const collectComponentIdMappings = ({ data, created, schema, strapi: strapi1 })=>{
150
+ const mappings = [];
151
+ const visitComponent = (uid, oldValue, newValue)=>{
152
+ if (!_.isObjectLike(oldValue) || !_.isObjectLike(newValue)) {
153
+ return;
154
+ }
155
+ if (typeof oldValue.id === 'number' && typeof newValue.id === 'number') {
156
+ mappings.push({
157
+ uid,
158
+ oldID: oldValue.id,
159
+ newID: newValue.id
160
+ });
161
+ }
162
+ const componentSchema = strapi1.getModel(uid);
163
+ // Collect nested components & dynamic zones
164
+ if (componentSchema) {
165
+ visitSchema(componentSchema, oldValue, newValue);
166
+ }
167
+ };
168
+ const visitSchema = (currentSchema, oldData, newData)=>{
169
+ if (!_.isObjectLike(oldData) || !_.isObjectLike(newData)) {
170
+ return;
171
+ }
172
+ const { attributes = {} } = currentSchema;
173
+ for (const [attributeName, attribute] of Object.entries(attributes)){
174
+ const oldValue = oldData[attributeName];
175
+ const newValue = newData[attributeName];
176
+ if (_.isNil(oldValue) || _.isNil(newValue)) {
177
+ continue;
178
+ }
179
+ if (attribute.type === 'component') {
180
+ const { component: componentUID, repeatable = false } = attribute;
181
+ if (repeatable === true) {
182
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
183
+ continue;
184
+ }
185
+ // Components are created (and thus populated back) in the same
186
+ // order as the source data, pair them by index
187
+ const length = Math.min(oldValue.length, newValue.length);
188
+ for(let i = 0; i < length; i += 1){
189
+ visitComponent(componentUID, oldValue[i], newValue[i]);
190
+ }
191
+ } else {
192
+ visitComponent(componentUID, oldValue, newValue);
193
+ }
194
+ }
195
+ if (attribute.type === 'dynamiczone') {
196
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
197
+ continue;
198
+ }
199
+ const length = Math.min(oldValue.length, newValue.length);
200
+ for(let i = 0; i < length; i += 1){
201
+ const oldItem = oldValue[i];
202
+ const newItem = newValue[i];
203
+ const componentUID = oldItem?.__component;
204
+ // Both items must reference the same dynamic zone component for the
205
+ // ID couple to be meaningful
206
+ if (!componentUID || newItem?.__component && newItem.__component !== componentUID) {
207
+ continue;
208
+ }
209
+ visitComponent(componentUID, oldItem, newItem);
210
+ }
211
+ }
212
+ }
213
+ };
214
+ visitSchema(schema, data, created);
215
+ return mappings;
216
+ };
217
+
218
+ export { collectComponentIdMappings, createComponents, deleteComponent, deleteComponents, getComponents, omitComponentData };
219
+ //# sourceMappingURL=components.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","sources":["../../src/utils/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { get, has, omit, pipe, assign } from 'lodash/fp';\n\nimport { contentTypes as contentTypesUtils, async, errors } from '@strapi/utils';\nimport type { Modules, UID, Data, Utils, Schema, Core } from '@strapi/types';\n\ntype LoadedComponents<TUID extends UID.Schema> = Data.Entity<\n TUID,\n Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype ComponentValue = Schema.Attribute.Value<\n Schema.Attribute.Component<UID.Component, false> | Schema.Attribute.Component<UID.Component, true>\n>;\n\ntype ComponentBody = {\n [key: string]: Schema.Attribute.Value<\n | Schema.Attribute.Component<UID.Component, false>\n | Schema.Attribute.Component<UID.Component, true>\n | Schema.Attribute.DynamicZone\n >;\n};\n\nconst isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';\n\nfunction omitComponentData(\n contentType: Schema.ContentType,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>>;\nfunction omitComponentData(\n contentType: Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.Component['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.Component['uid']>>;\nfunction omitComponentData(\n contentType: Schema.ContentType | Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n): Partial<\n Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n> {\n const { attributes } = contentType;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n}\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <\n TUID extends UID.Schema,\n TData extends Modules.EntityService.Params.Data.Input<TUID>,\n>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => createComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as Modules.EntityService.Params.Data.Input<UID.Component>\n );\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Modules.EntityService.Params.Attribute.GetValue<Schema.Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n createDynamicZoneComponents,\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entity: { id: Modules.EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.db.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <\n TUID extends UID.Schema,\n TData extends Partial<Modules.EntityService.Params.Data.Input<TUID>>,\n>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.Component>;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => updateOrCreateComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: Modules.EntityService.Params.Attribute.ID;\n}): Modules.EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n componentUID: UID.Component,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: Schema.Attribute.Value<Schema.Attribute.Component>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: Schema.Attribute.Value<Schema.Attribute.DynamicZone>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <TUID extends UID.Schema, TEntity extends Data.Entity<TUID>>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n if (loadComponents) {\n value = await strapi.db.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(componentUID, subValue),\n {\n concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,\n }\n );\n } else {\n // delete dynamic zone components\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(subValue.__component, subValue),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n }\n\n continue;\n }\n }\n};\n\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends UID.Component = UID.Component>(\n uid: TUID,\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await createComponents(uid, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.db.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.db.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: Object.assign(omitComponentData(model, data), componentData),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends UID.Component>(\n componentUID: TUID,\n value: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToDelete: Data.Component<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\ninterface IComponentIdMapping {\n uid: UID.Component;\n oldID: number;\n newID: number;\n}\n\n/**\n * Walk the source data and the newly created entity in parallel and collect\n * the [old ID, new ID] couple of every component instance found in both trees\n * (components & dynamic zones, including nested ones).\n *\n * Unlike a JSON diff, couples are also collected when the ID did not change,\n * so the result is an exhaustive map of every component instance that was\n * re-created with the entity.\n */\nconst collectComponentIdMappings = ({\n data,\n created,\n schema,\n strapi,\n}: {\n data: any;\n created: any;\n schema: Schema.Schema;\n strapi: Core.Strapi;\n}): IComponentIdMapping[] => {\n const mappings: IComponentIdMapping[] = [];\n\n const visitComponent = (uid: UID.Component, oldValue: any, newValue: any) => {\n if (!_.isObjectLike(oldValue) || !_.isObjectLike(newValue)) {\n return;\n }\n\n if (typeof oldValue.id === 'number' && typeof newValue.id === 'number') {\n mappings.push({ uid, oldID: oldValue.id, newID: newValue.id });\n }\n\n const componentSchema = strapi.getModel(uid);\n\n // Collect nested components & dynamic zones\n if (componentSchema) {\n visitSchema(componentSchema, oldValue, newValue);\n }\n };\n\n const visitSchema = (currentSchema: Schema.Schema, oldData: any, newData: any) => {\n if (!_.isObjectLike(oldData) || !_.isObjectLike(newData)) {\n return;\n }\n\n const { attributes = {} } = currentSchema;\n\n for (const [attributeName, attribute] of Object.entries(attributes)) {\n const oldValue = oldData[attributeName];\n const newValue = newData[attributeName];\n\n if (_.isNil(oldValue) || _.isNil(newValue)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n if (repeatable === true) {\n if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {\n continue;\n }\n\n // Components are created (and thus populated back) in the same\n // order as the source data, pair them by index\n const length = Math.min(oldValue.length, newValue.length);\n\n for (let i = 0; i < length; i += 1) {\n visitComponent(componentUID, oldValue[i], newValue[i]);\n }\n } else {\n visitComponent(componentUID, oldValue, newValue);\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {\n continue;\n }\n\n const length = Math.min(oldValue.length, newValue.length);\n\n for (let i = 0; i < length; i += 1) {\n const oldItem = oldValue[i];\n const newItem = newValue[i];\n const componentUID = oldItem?.__component;\n\n // Both items must reference the same dynamic zone component for the\n // ID couple to be meaningful\n if (!componentUID || (newItem?.__component && newItem.__component !== componentUID)) {\n continue;\n }\n\n visitComponent(componentUID, oldItem, newItem);\n }\n }\n }\n };\n\n visitSchema(schema, data, created);\n\n return mappings;\n};\n\n/**\n * Resolve the component UID of an entity's attribute based\n * on a given path (components & dynamic zones only)\n */\nconst resolveComponentUID = ({\n paths,\n strapi,\n data,\n contentType,\n}: {\n paths: string[];\n strapi: Core.Strapi;\n data: any;\n contentType: Schema.ContentType;\n}): UID.Schema | undefined => {\n let value: unknown = data;\n let cType:\n | Schema.ContentType\n | Schema.Component\n | ((...opts: any[]) => Schema.ContentType | Schema.Component) = contentType;\n for (const path of paths) {\n value = get(path, value);\n\n // Needed when the value of cType should be computed\n // based on the next value (eg: dynamic zones)\n if (typeof cType === 'function') {\n cType = cType(value);\n }\n\n if (path in cType.attributes) {\n const attribute: Schema.Attribute.AnyAttribute = cType.attributes[path];\n\n if (attribute.type === 'component') {\n cType = strapi.getModel(attribute.component);\n }\n\n if (attribute.type === 'dynamiczone') {\n cType = ({ __component }: { __component: UID.Component }) => strapi.getModel(__component);\n }\n }\n }\n\n if ('uid' in cType) {\n return cType.uid;\n }\n\n return undefined;\n};\n\nexport {\n omitComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n collectComponentIdMappings,\n resolveComponentUID,\n};\n"],"names":["isDialectMySQL","strapi","db","dialect","client","omitComponentData","contentType","data","attributes","componentAttributes","Object","keys","filter","attributeName","contentTypesUtils","isComponentAttribute","omit","createComponents","uid","getModel","componentBody","attributeNames","attribute","has","type","component","componentUID","repeatable","componentValue","Array","isArray","Error","components","async","map","value","createComponent","concurrency","inTransaction","Infinity","id","__pivot","field","component_type","dynamiczoneValues","createDynamicZoneComponents","__component","getComponents","entity","getComponentAttributes","_","isEmpty","query","load","deleteComponents","entityToDelete","loadComponents","castArray","subValue","deleteComponent","model","componentData","transform","pipe","payload","assign","create","componentToDelete","delete","where","collectComponentIdMappings","created","schema","mappings","visitComponent","oldValue","newValue","isObjectLike","push","oldID","newID","componentSchema","visitSchema","currentSchema","oldData","newData","entries","isNil","length","Math","min","i","oldItem","newItem"],"mappings":";;;;AAuBA,MAAMA,iBAAiB,IAAMC,MAAAA,CAAOC,EAAE,EAAEC,QAAQC,MAAAA,KAAW,OAAA;AAU3D,SAASC,iBAAAA,CACPC,WAAkD,EAClDC,IAAkG,EAAA;IAIlG,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,IAAA,MAAMG,mBAAAA,GAAsBC,MAAAA,CAAOC,IAAI,CAACH,YAAYI,MAAM,CAAC,CAACC,aAAAA,GAC1DC,YAAAA,CAAkBC,oBAAo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OAAOE,QAAAA;AACT;;;;"}
@@ -25,6 +25,7 @@ export type WarningDiagnostic = GenericDiagnostic<'warning', {
25
25
  origin?: string;
26
26
  }>;
27
27
  export type InfoDiagnostic<T = unknown> = GenericDiagnostic<'info', {
28
+ origin?: string;
28
29
  params?: T;
29
30
  }>;
30
31
  export interface IDiagnosticReporter {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../src/utils/diagnostic.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,GAAG,OAAO,IAAI;IACrE,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;KACjB,GAAG,CAAC,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,CAC1E,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,UAAU,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,KAC7D,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,cAAc,cAAc,EAAE,CAAC;AAE5E,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,SAAS,YAAY,GAC5E,kBAAkB,GAClB,CAAC,SAAS,cAAc,MAAM,CAAC,EAAE,GAC/B,CAAC,SAAS,cAAc,GACtB,kBAAkB,CAAC,CAAC,CAAC,GACrB,KAAK,GACP,KAAK,CAAC;AAEZ,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,iBAAiB,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