@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,151 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var stream = require('stream');
5
+ var fs = require('fs-extra');
6
+
7
+ function getFileStream(filepath, strapi, isLocal = false) {
8
+ if (isLocal) {
9
+ // Todo: handle errors
10
+ return fs.createReadStream(filepath);
11
+ }
12
+ const readableStream = new stream.PassThrough();
13
+ // fetch the image from remote url and stream it
14
+ strapi.fetch(filepath).then((res)=>{
15
+ if (res.status !== 200) {
16
+ readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));
17
+ return;
18
+ }
19
+ if (res.body) {
20
+ // pipe the image data
21
+ stream.Readable.fromWeb(res.body).pipe(readableStream);
22
+ } else {
23
+ readableStream.emit('error', new Error('Empty data found for file'));
24
+ }
25
+ }).catch((error)=>{
26
+ readableStream.emit('error', error);
27
+ });
28
+ return readableStream;
29
+ }
30
+ function getFileStatsForTransfer(filepath, strapi, isLocal = false) {
31
+ if (isLocal) {
32
+ return fs.stat(filepath);
33
+ }
34
+ return new Promise((resolve, reject)=>{
35
+ strapi.fetch(filepath).then((res)=>{
36
+ if (res.status !== 200) {
37
+ reject(new Error(`Request failed with status code ${res.status}`));
38
+ return;
39
+ }
40
+ const contentLength = res.headers.get('content-length');
41
+ const stats = {
42
+ size: contentLength ? parseInt(contentLength, 10) : 0
43
+ };
44
+ resolve(stats);
45
+ }).catch((error)=>{
46
+ reject(error);
47
+ });
48
+ });
49
+ }
50
+ async function signUploadFileForTransfer(strapi, file) {
51
+ const { provider } = strapi.plugins.upload;
52
+ const { provider: providerName } = strapi.config.get('plugin.upload');
53
+ const isPrivate = await provider.isPrivate();
54
+ if (file?.provider === providerName && isPrivate) {
55
+ const signUrl = async (f)=>{
56
+ const signedUrl = await provider.getSignedUrl(f);
57
+ f.url = signedUrl.url;
58
+ };
59
+ await signUrl(file);
60
+ if (file.formats) {
61
+ for (const format of Object.keys(file.formats)){
62
+ await signUrl(file.formats[format]);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ const missingAssetWarningMessage = (file, filepath, format)=>{
68
+ const formatPart = format ? ` (format: ${format})` : '';
69
+ return `[Data transfer] Media item ${file.id} (hash: ${file.hash}) exists in database but no corresponding file was found to transfer${formatPart}. Path: ${filepath}`;
70
+ };
71
+ /**
72
+ * Generate and consume assets streams in order to stream each file individually
73
+ */ const createAssetsStream = (strapi, options = {})=>{
74
+ const warnMissingAsset = (message)=>{
75
+ strapi.log.warn(message);
76
+ options.onWarning?.(message);
77
+ };
78
+ const generator = async function*() {
79
+ const stream = strapi.db.queryBuilder('plugin::upload.file')// Create a query builder instance (default type is 'select')
80
+ // Fetch all columns
81
+ .select('*')// Get a readable stream
82
+ .stream();
83
+ for await (const file of stream){
84
+ const isLocalProvider = file.provider === 'local';
85
+ if (!isLocalProvider) {
86
+ await signUploadFileForTransfer(strapi, file);
87
+ }
88
+ const filepath = isLocalProvider ? path.join(strapi.dirs.static.public, file.url) : file.url;
89
+ let stats;
90
+ try {
91
+ stats = await getFileStatsForTransfer(filepath, strapi, isLocalProvider);
92
+ } catch (err) {
93
+ const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
94
+ if (code === 'ENOENT') {
95
+ warnMissingAsset(missingAssetWarningMessage(file, filepath));
96
+ continue;
97
+ }
98
+ throw err;
99
+ }
100
+ const stream = getFileStream(filepath, strapi, isLocalProvider);
101
+ yield {
102
+ metadata: file,
103
+ filepath,
104
+ filename: file.hash + file.ext,
105
+ stream,
106
+ stats: {
107
+ size: stats.size
108
+ }
109
+ };
110
+ if (file.formats) {
111
+ for (const format of Object.keys(file.formats)){
112
+ const fileFormat = file.formats[format];
113
+ const fileFormatFilepath = isLocalProvider ? path.join(strapi.dirs.static.public, fileFormat.url) : fileFormat.url;
114
+ let fileFormatStats;
115
+ try {
116
+ fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, isLocalProvider);
117
+ } catch (err) {
118
+ const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
119
+ if (code === 'ENOENT') {
120
+ warnMissingAsset(missingAssetWarningMessage(file, fileFormatFilepath, format));
121
+ continue;
122
+ }
123
+ throw err;
124
+ }
125
+ const fileFormatStream = getFileStream(fileFormatFilepath, strapi, isLocalProvider);
126
+ const metadata = {
127
+ ...fileFormat,
128
+ type: format,
129
+ id: file.id,
130
+ mainHash: file.hash
131
+ };
132
+ yield {
133
+ metadata,
134
+ filepath: fileFormatFilepath,
135
+ filename: fileFormat.hash + fileFormat.ext,
136
+ stream: fileFormatStream,
137
+ stats: {
138
+ size: fileFormatStats.size
139
+ }
140
+ };
141
+ }
142
+ }
143
+ }
144
+ };
145
+ return stream.Duplex.from(generator());
146
+ };
147
+
148
+ exports.createAssetsStream = createAssetsStream;
149
+ exports.getFileStatsForTransfer = getFileStatsForTransfer;
150
+ exports.signUploadFileForTransfer = signUploadFileForTransfer;
151
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sources":["../../../../src/strapi/providers/local-source/assets.ts"],"sourcesContent":["import { join } from 'path';\nimport { Duplex, PassThrough, Readable } from 'stream';\nimport { stat, createReadStream, ReadStream } from 'fs-extra';\nimport * as webStream from 'stream/web';\nimport type { Core } from '@strapi/types';\n\nimport type { IAsset, IFile } from '../../../types';\n\nfunction getFileStream(\n filepath: string,\n strapi: Core.Strapi,\n isLocal = false\n): PassThrough | ReadStream {\n if (isLocal) {\n // Todo: handle errors\n return createReadStream(filepath);\n }\n\n const readableStream = new PassThrough();\n\n // fetch the image from remote url and stream it\n strapi\n .fetch(filepath)\n .then((res: Response) => {\n if (res.status !== 200) {\n readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));\n return;\n }\n\n if (res.body) {\n // pipe the image data\n Readable.fromWeb(res.body as webStream.ReadableStream<Uint8Array>).pipe(readableStream);\n } else {\n readableStream.emit('error', new Error('Empty data found for file'));\n }\n })\n .catch((error: unknown) => {\n readableStream.emit('error', error);\n });\n\n return readableStream;\n}\n\nexport function getFileStatsForTransfer(\n filepath: string,\n strapi: Core.Strapi,\n isLocal = false\n): Promise<{ size: number }> {\n if (isLocal) {\n return stat(filepath);\n }\n return new Promise((resolve, reject) => {\n strapi\n .fetch(filepath)\n .then((res: Response) => {\n if (res.status !== 200) {\n reject(new Error(`Request failed with status code ${res.status}`));\n return;\n }\n\n const contentLength = res.headers.get('content-length');\n const stats = {\n size: contentLength ? parseInt(contentLength, 10) : 0,\n };\n\n resolve(stats);\n })\n .catch((error: unknown) => {\n reject(error);\n });\n });\n}\n\nexport async function signUploadFileForTransfer(strapi: Core.Strapi, file: IFile) {\n const { provider } = strapi.plugins.upload;\n const { provider: providerName } = strapi.config.get('plugin.upload') as { provider: string };\n const isPrivate = await provider.isPrivate();\n if (file?.provider === providerName && isPrivate) {\n const signUrl = async (f: IFile) => {\n const signedUrl = await provider.getSignedUrl(f);\n f.url = signedUrl.url;\n };\n\n await signUrl(file);\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n await signUrl(file.formats[format]);\n }\n }\n }\n}\n\nconst missingAssetWarningMessage = (file: IFile, filepath: string, format?: string): string => {\n const formatPart = format ? ` (format: ${format})` : '';\n return `[Data transfer] Media item ${file.id} (hash: ${file.hash}) exists in database but no corresponding file was found to transfer${formatPart}. Path: ${filepath}`;\n};\n\n/**\n * Generate and consume assets streams in order to stream each file individually\n */\nexport const createAssetsStream = (\n strapi: Core.Strapi,\n options: { onWarning?: (message: string) => void } = {}\n): Duplex => {\n const warnMissingAsset = (message: string) => {\n strapi.log.warn(message);\n options.onWarning?.(message);\n };\n\n const generator: () => AsyncGenerator<IAsset, void> = async function* () {\n const stream: Readable = strapi.db\n .queryBuilder('plugin::upload.file')\n // Create a query builder instance (default type is 'select')\n // Fetch all columns\n .select('*')\n // Get a readable stream\n .stream();\n\n for await (const file of stream) {\n const isLocalProvider = file.provider === 'local';\n if (!isLocalProvider) {\n await signUploadFileForTransfer(strapi, file);\n }\n const filepath = isLocalProvider ? join(strapi.dirs.static.public, file.url) : file.url;\n let stats: { size: number };\n try {\n stats = await getFileStatsForTransfer(filepath, strapi, isLocalProvider);\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n warnMissingAsset(missingAssetWarningMessage(file, filepath));\n continue;\n }\n throw err;\n }\n const stream = getFileStream(filepath, strapi, isLocalProvider);\n\n yield {\n metadata: file,\n filepath,\n filename: file.hash + file.ext,\n stream,\n stats: { size: stats.size },\n };\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = isLocalProvider\n ? join(strapi.dirs.static.public, fileFormat.url)\n : fileFormat.url;\n let fileFormatStats: { size: number };\n try {\n fileFormatStats = await getFileStatsForTransfer(\n fileFormatFilepath,\n strapi,\n isLocalProvider\n );\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n warnMissingAsset(missingAssetWarningMessage(file, fileFormatFilepath, format));\n continue;\n }\n throw err;\n }\n const fileFormatStream = getFileStream(fileFormatFilepath, strapi, isLocalProvider);\n const metadata = { ...fileFormat, type: format, id: file.id, mainHash: file.hash };\n yield {\n metadata,\n filepath: fileFormatFilepath,\n filename: fileFormat.hash + fileFormat.ext,\n stream: fileFormatStream,\n stats: { size: fileFormatStats.size },\n };\n }\n }\n }\n };\n\n return Duplex.from(generator());\n};\n"],"names":["getFileStream","filepath","strapi","isLocal","createReadStream","readableStream","PassThrough","fetch","then","res","status","emit","Error","body","Readable","fromWeb","pipe","catch","error","getFileStatsForTransfer","stat","Promise","resolve","reject","contentLength","headers","get","stats","size","parseInt","signUploadFileForTransfer","file","provider","plugins","upload","providerName","config","isPrivate","signUrl","f","signedUrl","getSignedUrl","url","formats","format","Object","keys","missingAssetWarningMessage","formatPart","id","hash","createAssetsStream","options","warnMissingAsset","message","log","warn","onWarning","generator","stream","db","queryBuilder","select","isLocalProvider","join","dirs","static","public","err","code","undefined","metadata","filename","ext","fileFormat","fileFormatFilepath","fileFormatStats","fileFormatStream","type","mainHash","Duplex","from"],"mappings":";;;;;;AAQA,SAASA,cACPC,QAAgB,EAChBC,MAAmB,EACnBC,UAAU,KAAK,EAAA;AAEf,IAAA,IAAIA,OAAAA,EAAS;;AAEX,QAAA,OAAOC,mBAAAA,CAAiBH,QAAAA,CAAAA;AAC1B,IAAA;AAEA,IAAA,MAAMI,iBAAiB,IAAIC,kBAAAA,EAAAA;;AAG3BJ,IAAAA,MAAAA,CACGK,KAAK,CAACN,QAAAA,CAAAA,CACNO,IAAI,CAAC,CAACC,GAAAA,GAAAA;QACL,IAAIA,GAAAA,CAAIC,MAAM,KAAK,GAAA,EAAK;YACtBL,cAAAA,CAAeM,IAAI,CAAC,OAAA,EAAS,IAAIC,KAAAA,CAAM,CAAC,gCAAgC,EAAEH,GAAAA,CAAIC,MAAM,CAAA,CAAE,CAAA,CAAA;AACtF,YAAA;AACF,QAAA;QAEA,IAAID,GAAAA,CAAII,IAAI,EAAE;;AAEZC,YAAAA,eAAAA,CAASC,OAAO,CAACN,GAAAA,CAAII,IAAI,CAAA,CAA0CG,IAAI,CAACX,cAAAA,CAAAA;QAC1E,CAAA,MAAO;AACLA,YAAAA,cAAAA,CAAeM,IAAI,CAAC,OAAA,EAAS,IAAIC,KAAAA,CAAM,2BAAA,CAAA,CAAA;AACzC,QAAA;IACF,CAAA,CAAA,CACCK,KAAK,CAAC,C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A,MAAMQ,QAAAA,GAAW;AAAE,wBAAA,GAAGG,UAAU;wBAAEI,IAAAA,EAAMlC,MAAAA;AAAQK,wBAAAA,EAAAA,EAAIlB,KAAKkB,EAAE;AAAE8B,wBAAAA,QAAAA,EAAUhD,KAAKmB;AAAK,qBAAA;oBACjF,MAAM;AACJqB,wBAAAA,QAAAA;wBACAtE,QAAAA,EAAU0E,kBAAAA;AACVH,wBAAAA,QAAAA,EAAUE,UAAAA,CAAWxB,IAAI,GAAGwB,UAAAA,CAAWD,GAAG;wBAC1Cd,MAAAA,EAAQkB,gBAAAA;wBACRlD,KAAAA,EAAO;AAAEC,4BAAAA,IAAAA,EAAMgD,gBAAgBhD;AAAK;AACtC,qBAAA;AACF,gBAAA;AACF,YAAA;AACF,QAAA;AACF,IAAA,CAAA;IAEA,OAAOoD,aAAAA,CAAOC,IAAI,CAACvB,SAAAA,EAAAA,CAAAA;AACrB;;;;;;"}
@@ -0,0 +1,147 @@
1
+ import { join } from 'path';
2
+ import { Duplex, PassThrough, Readable } from 'stream';
3
+ import { stat, createReadStream } from 'fs-extra';
4
+
5
+ function getFileStream(filepath, strapi, isLocal = false) {
6
+ if (isLocal) {
7
+ // Todo: handle errors
8
+ return createReadStream(filepath);
9
+ }
10
+ const readableStream = new PassThrough();
11
+ // fetch the image from remote url and stream it
12
+ strapi.fetch(filepath).then((res)=>{
13
+ if (res.status !== 200) {
14
+ readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));
15
+ return;
16
+ }
17
+ if (res.body) {
18
+ // pipe the image data
19
+ Readable.fromWeb(res.body).pipe(readableStream);
20
+ } else {
21
+ readableStream.emit('error', new Error('Empty data found for file'));
22
+ }
23
+ }).catch((error)=>{
24
+ readableStream.emit('error', error);
25
+ });
26
+ return readableStream;
27
+ }
28
+ function getFileStatsForTransfer(filepath, strapi, isLocal = false) {
29
+ if (isLocal) {
30
+ return stat(filepath);
31
+ }
32
+ return new Promise((resolve, reject)=>{
33
+ strapi.fetch(filepath).then((res)=>{
34
+ if (res.status !== 200) {
35
+ reject(new Error(`Request failed with status code ${res.status}`));
36
+ return;
37
+ }
38
+ const contentLength = res.headers.get('content-length');
39
+ const stats = {
40
+ size: contentLength ? parseInt(contentLength, 10) : 0
41
+ };
42
+ resolve(stats);
43
+ }).catch((error)=>{
44
+ reject(error);
45
+ });
46
+ });
47
+ }
48
+ async function signUploadFileForTransfer(strapi, file) {
49
+ const { provider } = strapi.plugins.upload;
50
+ const { provider: providerName } = strapi.config.get('plugin.upload');
51
+ const isPrivate = await provider.isPrivate();
52
+ if (file?.provider === providerName && isPrivate) {
53
+ const signUrl = async (f)=>{
54
+ const signedUrl = await provider.getSignedUrl(f);
55
+ f.url = signedUrl.url;
56
+ };
57
+ await signUrl(file);
58
+ if (file.formats) {
59
+ for (const format of Object.keys(file.formats)){
60
+ await signUrl(file.formats[format]);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ const missingAssetWarningMessage = (file, filepath, format)=>{
66
+ const formatPart = format ? ` (format: ${format})` : '';
67
+ return `[Data transfer] Media item ${file.id} (hash: ${file.hash}) exists in database but no corresponding file was found to transfer${formatPart}. Path: ${filepath}`;
68
+ };
69
+ /**
70
+ * Generate and consume assets streams in order to stream each file individually
71
+ */ const createAssetsStream = (strapi, options = {})=>{
72
+ const warnMissingAsset = (message)=>{
73
+ strapi.log.warn(message);
74
+ options.onWarning?.(message);
75
+ };
76
+ const generator = async function*() {
77
+ const stream = strapi.db.queryBuilder('plugin::upload.file')// Create a query builder instance (default type is 'select')
78
+ // Fetch all columns
79
+ .select('*')// Get a readable stream
80
+ .stream();
81
+ for await (const file of stream){
82
+ const isLocalProvider = file.provider === 'local';
83
+ if (!isLocalProvider) {
84
+ await signUploadFileForTransfer(strapi, file);
85
+ }
86
+ const filepath = isLocalProvider ? join(strapi.dirs.static.public, file.url) : file.url;
87
+ let stats;
88
+ try {
89
+ stats = await getFileStatsForTransfer(filepath, strapi, isLocalProvider);
90
+ } catch (err) {
91
+ const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
92
+ if (code === 'ENOENT') {
93
+ warnMissingAsset(missingAssetWarningMessage(file, filepath));
94
+ continue;
95
+ }
96
+ throw err;
97
+ }
98
+ const stream = getFileStream(filepath, strapi, isLocalProvider);
99
+ yield {
100
+ metadata: file,
101
+ filepath,
102
+ filename: file.hash + file.ext,
103
+ stream,
104
+ stats: {
105
+ size: stats.size
106
+ }
107
+ };
108
+ if (file.formats) {
109
+ for (const format of Object.keys(file.formats)){
110
+ const fileFormat = file.formats[format];
111
+ const fileFormatFilepath = isLocalProvider ? join(strapi.dirs.static.public, fileFormat.url) : fileFormat.url;
112
+ let fileFormatStats;
113
+ try {
114
+ fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, isLocalProvider);
115
+ } catch (err) {
116
+ const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
117
+ if (code === 'ENOENT') {
118
+ warnMissingAsset(missingAssetWarningMessage(file, fileFormatFilepath, format));
119
+ continue;
120
+ }
121
+ throw err;
122
+ }
123
+ const fileFormatStream = getFileStream(fileFormatFilepath, strapi, isLocalProvider);
124
+ const metadata = {
125
+ ...fileFormat,
126
+ type: format,
127
+ id: file.id,
128
+ mainHash: file.hash
129
+ };
130
+ yield {
131
+ metadata,
132
+ filepath: fileFormatFilepath,
133
+ filename: fileFormat.hash + fileFormat.ext,
134
+ stream: fileFormatStream,
135
+ stats: {
136
+ size: fileFormatStats.size
137
+ }
138
+ };
139
+ }
140
+ }
141
+ }
142
+ };
143
+ return Duplex.from(generator());
144
+ };
145
+
146
+ export { createAssetsStream, getFileStatsForTransfer, signUploadFileForTransfer };
147
+ //# sourceMappingURL=assets.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.mjs","sources":["../../../../src/strapi/providers/local-source/assets.ts"],"sourcesContent":["import { join } from 'path';\nimport { Duplex, PassThrough, Readable } from 'stream';\nimport { stat, createReadStream, ReadStream } from 'fs-extra';\nimport * as webStream from 'stream/web';\nimport type { Core } from '@strapi/types';\n\nimport type { IAsset, IFile } from '../../../types';\n\nfunction getFileStream(\n filepath: string,\n strapi: Core.Strapi,\n isLocal = false\n): PassThrough | ReadStream {\n if (isLocal) {\n // Todo: handle errors\n return createReadStream(filepath);\n }\n\n const readableStream = new PassThrough();\n\n // fetch the image from remote url and stream it\n strapi\n .fetch(filepath)\n .then((res: Response) => {\n if (res.status !== 200) {\n readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));\n return;\n }\n\n if (res.body) {\n // pipe the image data\n Readable.fromWeb(res.body as webStream.ReadableStream<Uint8Array>).pipe(readableStream);\n } else {\n readableStream.emit('error', new Error('Empty data found for file'));\n }\n })\n .catch((error: unknown) => {\n readableStream.emit('error', error);\n });\n\n return readableStream;\n}\n\nexport function getFileStatsForTransfer(\n filepath: string,\n strapi: Core.Strapi,\n isLocal = false\n): Promise<{ size: number }> {\n if (isLocal) {\n return stat(filepath);\n }\n return new Promise((resolve, reject) => {\n strapi\n .fetch(filepath)\n .then((res: Response) => {\n if (res.status !== 200) {\n reject(new Error(`Request failed with status code ${res.status}`));\n return;\n }\n\n const contentLength = res.headers.get('content-length');\n const stats = {\n size: contentLength ? parseInt(contentLength, 10) : 0,\n };\n\n resolve(stats);\n })\n .catch((error: unknown) => {\n reject(error);\n });\n });\n}\n\nexport async function signUploadFileForTransfer(strapi: Core.Strapi, file: IFile) {\n const { provider } = strapi.plugins.upload;\n const { provider: providerName } = strapi.config.get('plugin.upload') as { provider: string };\n const isPrivate = await provider.isPrivate();\n if (file?.provider === providerName && isPrivate) {\n const signUrl = async (f: IFile) => {\n const signedUrl = await provider.getSignedUrl(f);\n f.url = signedUrl.url;\n };\n\n await signUrl(file);\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n await signUrl(file.formats[format]);\n }\n }\n }\n}\n\nconst missingAssetWarningMessage = (file: IFile, filepath: string, format?: string): string => {\n const formatPart = format ? ` (format: ${format})` : '';\n return `[Data transfer] Media item ${file.id} (hash: ${file.hash}) exists in database but no corresponding file was found to transfer${formatPart}. Path: ${filepath}`;\n};\n\n/**\n * Generate and consume assets streams in order to stream each file individually\n */\nexport const createAssetsStream = (\n strapi: Core.Strapi,\n options: { onWarning?: (message: string) => void } = {}\n): Duplex => {\n const warnMissingAsset = (message: string) => {\n strapi.log.warn(message);\n options.onWarning?.(message);\n };\n\n const generator: () => AsyncGenerator<IAsset, void> = async function* () {\n const stream: Readable = strapi.db\n .queryBuilder('plugin::upload.file')\n // Create a query builder instance (default type is 'select')\n // Fetch all columns\n .select('*')\n // Get a readable stream\n .stream();\n\n for await (const file of stream) {\n const isLocalProvider = file.provider === 'local';\n if (!isLocalProvider) {\n await signUploadFileForTransfer(strapi, file);\n }\n const filepath = isLocalProvider ? join(strapi.dirs.static.public, file.url) : file.url;\n let stats: { size: number };\n try {\n stats = await getFileStatsForTransfer(filepath, strapi, isLocalProvider);\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n warnMissingAsset(missingAssetWarningMessage(file, filepath));\n continue;\n }\n throw err;\n }\n const stream = getFileStream(filepath, strapi, isLocalProvider);\n\n yield {\n metadata: file,\n filepath,\n filename: file.hash + file.ext,\n stream,\n stats: { size: stats.size },\n };\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = isLocalProvider\n ? join(strapi.dirs.static.public, fileFormat.url)\n : fileFormat.url;\n let fileFormatStats: { size: number };\n try {\n fileFormatStats = await getFileStatsForTransfer(\n fileFormatFilepath,\n strapi,\n isLocalProvider\n );\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n warnMissingAsset(missingAssetWarningMessage(file, fileFormatFilepath, format));\n continue;\n }\n throw err;\n }\n const fileFormatStream = getFileStream(fileFormatFilepath, strapi, isLocalProvider);\n const metadata = { ...fileFormat, type: format, id: file.id, mainHash: file.hash };\n yield {\n metadata,\n filepath: fileFormatFilepath,\n filename: fileFormat.hash + fileFormat.ext,\n stream: fileFormatStream,\n stats: { size: fileFormatStats.size },\n };\n }\n }\n }\n };\n\n return Duplex.from(generator());\n};\n"],"names":["getFileStream","filepath","strapi","isLocal","createReadStream","readableStream","PassThrough","fetch","then","res","status","emit","Error","body","Readable","fromWeb","pipe","catch","error","getFileStatsForTransfer","stat","Promise","resolve","reject","contentLength","headers","get","stats","size","parseInt","signUploadFileForTransfer","file","provider","plugins","upload","providerName","config","isPrivate","signUrl","f","signedUrl","getSignedUrl","url","formats","format","Object","keys","missingAssetWarningMessage","formatPart","id","hash","createAssetsStream","options","warnMissingAsset","message","log","warn","onWarning","generator","stream","db","queryBuilder","select","isLocalProvider","join","dirs","static","public","err","code","undefined","metadata","filename","ext","fileFormat","fileFormatFilepath","fileFormatStats","fileFormatStream","type","mainHash","Duplex","from"],"mappings":";;;;AAQA,SAASA,cACPC,QAAgB,EAChBC,MAAmB,EACnBC,UAAU,KAAK,EAAA;AAEf,IAAA,IAAIA,OAAAA,EAAS;;AAEX,QAAA,OAAOC,gBAAAA,CAAiBH,QAAAA,CAAAA;AAC1B,IAAA;AAEA,IAAA,MAAMI,iBAAiB,IAAIC,WAAAA,EAAAA;;AAG3BJ,IAAAA,MAAAA,CACGK,KAAK,CAACN,QAAAA,CAAAA,CACNO,IAAI,CAAC,CAACC,GAAAA,GAAAA;QACL,IAAIA,GAAAA,CAAIC,MAAM,KAAK,GAAA,EAAK;YACtBL,cAAAA,CAAeM,IAAI,CAAC,OAAA,EAAS,IAAIC,KAAAA,CAAM,CAAC,gCAAgC,EAAEH,GAAAA,CAAIC,MAAM,CAAA,CAAE,CAAA,CAAA;AACtF,YAAA;AACF,QAAA;QAEA,IAAID,GAAAA,CAAII,IAAI,EAAE;;AAEZC,YAAAA,QAAAA,CAASC,OAAO,CAACN,GAAAA,CAAII,IAAI,CAAA,CAA0CG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AAAA,CAAAA,CAAAA;AACtE,4BAAA;AACF,wBAAA;wBACA,MAAMwB,GAAAA;AACR,oBAAA;oBACA,MAAMS,gBAAAA,GAAmB7E,aAAAA,CAAc2E,kBAAAA,EAAoBzE,MAAAA,EAAQ6D,eAAAA,CAAAA;AACnE,oBAAA,MAAMQ,QAAAA,GAAW;AAAE,wBAAA,GAAGG,UAAU;wBAAEI,IAAAA,EAAMlC,MAAAA;AAAQK,wBAAAA,EAAAA,EAAIlB,KAAKkB,EAAE;AAAE8B,wBAAAA,QAAAA,EAAUhD,KAAKmB;AAAK,qBAAA;oBACjF,MAAM;AACJqB,wBAAAA,QAAAA;wBACAtE,QAAAA,EAAU0E,kBAAAA;AACVH,wBAAAA,QAAAA,EAAUE,UAAAA,CAAWxB,IAAI,GAAGwB,UAAAA,CAAWD,GAAG;wBAC1Cd,MAAAA,EAAQkB,gBAAAA;wBACRlD,KAAAA,EAAO;AAAEC,4BAAAA,IAAAA,EAAMgD,gBAAgBhD;AAAK;AACtC,qBAAA;AACF,gBAAA;AACF,YAAA;AACF,QAAA;AACF,IAAA,CAAA;IAEA,OAAOoD,MAAAA,CAAOC,IAAI,CAACvB,SAAAA,EAAAA,CAAAA;AACrB;;;;"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable } from 'stream';
3
2
  import type { Core } from '@strapi/types';
4
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,WAAY,KAAK,MAAM,KAAG,QAyB/D,CAAC"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,IAAI,CAAC,MAAM,KAAG,QAoC/D,CAAC"}
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var stream = require('stream');
4
+ var streamChain = require('stream-chain');
5
+ var fp = require('lodash/fp');
6
+ var projectSettingsLogos = require('../../utils/project-settings-logos.js');
7
+
8
+ /**
9
+ * Create a readable stream that export the Strapi app configuration
10
+ */ const createConfigurationStream = (strapi)=>{
11
+ return stream.Readable.from(async function* configurationGenerator() {
12
+ // Core Store
13
+ const coreStoreStream = streamChain.chain([
14
+ strapi.db.queryBuilder('strapi::core-store').stream(),
15
+ (data)=>fp.set('value', JSON.parse(data.value), data),
16
+ wrapConfigurationItem('core-store')
17
+ ]);
18
+ // Webhook
19
+ const webhooksStream = streamChain.chain([
20
+ strapi.db.queryBuilder('strapi::webhook').stream(),
21
+ wrapConfigurationItem('webhook')
22
+ ]);
23
+ const streams = [
24
+ coreStoreStream,
25
+ webhooksStream
26
+ ];
27
+ for (const stream of streams){
28
+ for await (const item of stream){
29
+ if (item.type === 'core-store') {
30
+ yield {
31
+ ...item,
32
+ value: await projectSettingsLogos.enrichProjectSettingsForExport(strapi, item.value)
33
+ };
34
+ continue;
35
+ }
36
+ yield item;
37
+ }
38
+ }
39
+ }());
40
+ };
41
+ const wrapConfigurationItem = (type)=>(value)=>({
42
+ type,
43
+ value
44
+ });
45
+
46
+ exports.createConfigurationStream = createConfigurationStream;
47
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport { set } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => set('value', JSON.parse(data.value), data),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","set","JSON","parse","value","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;;;;;AAQA;;IAGO,MAAMA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,eAAAA,CAASC,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;;AAEf,QAAA,MAAMC,kBAAkBC,iBAAAA,CAAM;AAC5BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;YACnD,CAACC,IAAAA,GAASC,OAAI,OAAA,EAASC,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKI,KAAK,CAAA,EAAGJ,IAAAA,CAAAA;YAC/CK,qBAAAA,CAAsB,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBV,iBAAAA,CAAM;AAC3BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDM,qBAAAA,CAAsB,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAAA,GAAU;AAACZ,YAAAA,eAAAA;AAAiBW,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMP,UAAUQ,OAAAA,CAAS;YAC5B,WAAW,MAAMC,QAAQT,MAAAA,CAAQ;gBAC/B,IAAIS,IAAAA,CAAKC,IAAI,KAAK,YAAA,EAAc;oBAC9B,MAAM;AACJ,wBAAA,GAAGD,IAAI;AACPJ,wBAAAA,KAAAA,EAAO,MAAMM,mDAAAA,CACXnB,MAAAA,EACAiB,IAAAA,CAAKJ,KAAK;AAEd,qBAAA;AACA,oBAAA;AACF,gBAAA;gBAEA,MAAMI,IAAAA;AACR,YAAA;AACF,QAAA;AACF,IAAA,CAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAAA,GAAwB,CAACI,IAAAA,GAAmC,CAACL,SAAoB;AACrFK,YAAAA,IAAAA;AACAL,YAAAA;SACF,CAAA;;;;"}
@@ -0,0 +1,45 @@
1
+ import { Readable } from 'stream';
2
+ import { chain } from 'stream-chain';
3
+ import { set } from 'lodash/fp';
4
+ import { enrichProjectSettingsForExport } from '../../utils/project-settings-logos.mjs';
5
+
6
+ /**
7
+ * Create a readable stream that export the Strapi app configuration
8
+ */ const createConfigurationStream = (strapi)=>{
9
+ return Readable.from(async function* configurationGenerator() {
10
+ // Core Store
11
+ const coreStoreStream = chain([
12
+ strapi.db.queryBuilder('strapi::core-store').stream(),
13
+ (data)=>set('value', JSON.parse(data.value), data),
14
+ wrapConfigurationItem('core-store')
15
+ ]);
16
+ // Webhook
17
+ const webhooksStream = chain([
18
+ strapi.db.queryBuilder('strapi::webhook').stream(),
19
+ wrapConfigurationItem('webhook')
20
+ ]);
21
+ const streams = [
22
+ coreStoreStream,
23
+ webhooksStream
24
+ ];
25
+ for (const stream of streams){
26
+ for await (const item of stream){
27
+ if (item.type === 'core-store') {
28
+ yield {
29
+ ...item,
30
+ value: await enrichProjectSettingsForExport(strapi, item.value)
31
+ };
32
+ continue;
33
+ }
34
+ yield item;
35
+ }
36
+ }
37
+ }());
38
+ };
39
+ const wrapConfigurationItem = (type)=>(value)=>({
40
+ type,
41
+ value
42
+ });
43
+
44
+ export { createConfigurationStream };
45
+ //# sourceMappingURL=configuration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.mjs","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport { set } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => set('value', JSON.parse(data.value), data),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","set","JSON","parse","value","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;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Core } from '@strapi/types';
4
3
  /**
5
4
  * Generate and consume content-types streams in order to stream each entity individually
6
5
  */
7
- export declare const createEntitiesStream: (strapi: Core.Strapi) => Readable;
6
+ export declare const createEntitiesStream: (strapi: Core.Strapi, options?: {
7
+ onWarning?: (message: string) => void;
8
+ }) => Readable;
8
9
  /**
9
10
  * Create an entity transform stream which convert the output of
10
11
  * the multi-content-types stream to the transfer entity format
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAKlD;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAY,KAAK,MAAM,KAAG,QAuC1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAO,SAchD,CAAC"}
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAKlD;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,IAAI,CAAC,MAAM,EACnB,UAAS;IAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,KACtD,QA8CF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAO,SAchD,CAAC"}
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var stream = require('stream');
4
+ var entity = require('../../queries/entity.js');
5
+ require('lodash/fp');
6
+
7
+ /**
8
+ * Generate and consume content-types streams in order to stream each entity individually
9
+ */ const createEntitiesStream = (strapi, options = {})=>{
10
+ const contentTypes = Object.values(strapi.contentTypes);
11
+ async function* contentTypeStreamGenerator() {
12
+ for (const contentType of contentTypes){
13
+ const query = entity.createEntityQuery(strapi).call(null, contentType.uid);
14
+ const stream = strapi.db// Create a query builder instance (default type is 'select')
15
+ .queryBuilder(contentType.uid)// Fetch all columns
16
+ .select('*')// Apply the populate
17
+ .populate(query.deepPopulateComponentLikeQuery)// Get a readable stream
18
+ .stream();
19
+ yield {
20
+ contentType,
21
+ stream
22
+ };
23
+ }
24
+ }
25
+ return stream.Readable.from(async function* entitiesGenerator() {
26
+ for await (const { stream, contentType } of contentTypeStreamGenerator()){
27
+ try {
28
+ for await (const entity of stream){
29
+ yield {
30
+ entity,
31
+ contentType
32
+ };
33
+ }
34
+ } catch (error) {
35
+ // Surface the failure instead of silently dropping the remaining
36
+ // entities of this content type: every entity skipped here leaves
37
+ // dangling links pointing at rows that were never transferred
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ options.onWarning?.(`Failed to read all entities of type "${contentType.uid}" from the source, the remaining entities of this type were skipped: ${message}`);
40
+ } finally{
41
+ stream.destroy();
42
+ }
43
+ }
44
+ }());
45
+ };
46
+ /**
47
+ * Create an entity transform stream which convert the output of
48
+ * the multi-content-types stream to the transfer entity format
49
+ */ const createEntitiesTransformStream = ()=>{
50
+ return new stream.Transform({
51
+ objectMode: true,
52
+ transform (data, _encoding, callback) {
53
+ const { entity, contentType } = data;
54
+ const { id, ...attributes } = entity;
55
+ callback(null, {
56
+ type: contentType.uid,
57
+ id,
58
+ data: attributes
59
+ });
60
+ }
61
+ });
62
+ };
63
+
64
+ exports.createEntitiesStream = createEntitiesStream;
65
+ exports.createEntitiesTransformStream = createEntitiesTransformStream;
66
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport * as shared from '../../queries';\nimport { IEntity } from '../../../types';\n\n/**\n * Generate and consume content-types streams in order to stream each entity individually\n */\nexport const createEntitiesStream = (\n strapi: Core.Strapi,\n options: { onWarning?: (message: string) => void } = {}\n): Readable => {\n const contentTypes: Struct.ContentTypeSchema[] = Object.values(strapi.contentTypes);\n\n async function* contentTypeStreamGenerator() {\n for (const contentType of contentTypes) {\n const query = shared.entity.createEntityQuery(strapi).call(null, contentType.uid);\n\n const stream: Readable = strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder(contentType.uid)\n // Fetch all columns\n .select('*')\n // Apply the populate\n .populate(query.deepPopulateComponentLikeQuery)\n // Get a readable stream\n .stream();\n\n yield { contentType, stream };\n }\n }\n\n return Readable.from(\n (async function* entitiesGenerator(): AsyncGenerator<{\n entity: IEntity;\n contentType: Struct.ContentTypeSchema;\n }> {\n for await (const { stream, contentType } of contentTypeStreamGenerator()) {\n try {\n for await (const entity of stream) {\n yield { entity, contentType };\n }\n } catch (error) {\n // Surface the failure instead of silently dropping the remaining\n // entities of this content type: every entity skipped here leaves\n // dangling links pointing at rows that were never transferred\n const message = error instanceof Error ? error.message : String(error);\n\n options.onWarning?.(\n `Failed to read all entities of type \"${contentType.uid}\" from the source, the remaining entities of this type were skipped: ${message}`\n );\n } finally {\n stream.destroy();\n }\n }\n })()\n );\n};\n\n/**\n * Create an entity transform stream which convert the output of\n * the multi-content-types stream to the transfer entity format\n */\nexport const createEntitiesTransformStream = (): Transform => {\n return new Transform({\n objectMode: true,\n transform(data, _encoding, callback) {\n const { entity, contentType } = data;\n const { id, ...attributes } = entity;\n\n callback(null, {\n type: contentType.uid,\n id,\n data: attributes,\n });\n },\n });\n};\n"],"names":["createEntitiesStream","strapi","options","contentTypes","Object","values","contentTypeStreamGenerator","contentType","query","shared","call","uid","stream","db","queryBuilder","select","populate","deepPopulateComponentLikeQuery","Readable","from","entitiesGenerator","entity","error","message","Error","String","onWarning","destroy","createEntitiesTransformStream","Transform","objectMode","transform","data","_encoding","callback","id","attributes","type"],"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E5I,CAAA,QAAU;AACRX,gBAAAA,MAAAA,CAAOe,OAAO,EAAA;AAChB,YAAA;AACF,QAAA;AACF,IAAA,CAAA,EAAA,CAAA;AAEJ;AAEA;;;UAIaC,6BAAAA,GAAgC,IAAA;AAC3C,IAAA,OAAO,IAAIC,gBAAAA,CAAU;QACnBC,UAAAA,EAAY,IAAA;AACZC,QAAAA,SAAAA,CAAAA,CAAUC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,EAAA;AACjC,YAAA,MAAM,EAAEb,MAAM,EAAEd,WAAW,EAAE,GAAGyB,IAAAA;AAChC,YAAA,MAAM,EAAEG,EAAE,EAAE,GAAGC,YAAY,GAAGf,MAAAA;AAE9Ba,YAAAA,QAAAA,CAAS,IAAA,EAAM;AACbG,gBAAAA,IAAAA,EAAM9B,YAAYI,GAAG;AACrBwB,gBAAAA,EAAAA;gBACAH,IAAAA,EAAMI;AACR,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF;;;;;"}
@@ -0,0 +1,63 @@
1
+ import { Readable, Transform } from 'stream';
2
+ import { createEntityQuery } from '../../queries/entity.mjs';
3
+ import 'lodash/fp';
4
+
5
+ /**
6
+ * Generate and consume content-types streams in order to stream each entity individually
7
+ */ const createEntitiesStream = (strapi, options = {})=>{
8
+ const contentTypes = Object.values(strapi.contentTypes);
9
+ async function* contentTypeStreamGenerator() {
10
+ for (const contentType of contentTypes){
11
+ const query = createEntityQuery(strapi).call(null, contentType.uid);
12
+ const stream = strapi.db// Create a query builder instance (default type is 'select')
13
+ .queryBuilder(contentType.uid)// Fetch all columns
14
+ .select('*')// Apply the populate
15
+ .populate(query.deepPopulateComponentLikeQuery)// Get a readable stream
16
+ .stream();
17
+ yield {
18
+ contentType,
19
+ stream
20
+ };
21
+ }
22
+ }
23
+ return Readable.from(async function* entitiesGenerator() {
24
+ for await (const { stream, contentType } of contentTypeStreamGenerator()){
25
+ try {
26
+ for await (const entity of stream){
27
+ yield {
28
+ entity,
29
+ contentType
30
+ };
31
+ }
32
+ } catch (error) {
33
+ // Surface the failure instead of silently dropping the remaining
34
+ // entities of this content type: every entity skipped here leaves
35
+ // dangling links pointing at rows that were never transferred
36
+ const message = error instanceof Error ? error.message : String(error);
37
+ options.onWarning?.(`Failed to read all entities of type "${contentType.uid}" from the source, the remaining entities of this type were skipped: ${message}`);
38
+ } finally{
39
+ stream.destroy();
40
+ }
41
+ }
42
+ }());
43
+ };
44
+ /**
45
+ * Create an entity transform stream which convert the output of
46
+ * the multi-content-types stream to the transfer entity format
47
+ */ const createEntitiesTransformStream = ()=>{
48
+ return new Transform({
49
+ objectMode: true,
50
+ transform (data, _encoding, callback) {
51
+ const { entity, contentType } = data;
52
+ const { id, ...attributes } = entity;
53
+ callback(null, {
54
+ type: contentType.uid,
55
+ id,
56
+ data: attributes
57
+ });
58
+ }
59
+ });
60
+ };
61
+
62
+ export { createEntitiesStream, createEntitiesTransformStream };
63
+ //# sourceMappingURL=entities.mjs.map