@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,917 @@
1
+ import { Transform, PassThrough } from 'stream';
2
+ import { pipeline } from 'stream/promises';
3
+ import { extname } from 'path';
4
+ import { EOL } from 'os';
5
+ import { chain } from 'stream-chain';
6
+ import { isEmpty, last, set, pick, isNumber, uniq } from 'lodash/fp';
7
+ import { diff as diff$1 } from 'semver';
8
+ import { compareSchemas } from './validation/schemas/index.mjs';
9
+ import { validateProvider } from './validation/provider.mjs';
10
+ import { TransferEngineError, TransferEngineValidationError } from './errors.mjs';
11
+ import * as errors from './errors.mjs';
12
+ export { errors };
13
+ import { createDiagnosticReporter } from '../utils/diagnostic.mjs';
14
+ import 'crypto';
15
+ import 'node:events';
16
+ import 'node:stream/promises';
17
+ import { filter, map } from '../utils/stream.mjs';
18
+ import { diff } from '../utils/json.mjs';
19
+ import 'events';
20
+ import { runMiddleware } from '../utils/middleware.mjs';
21
+ import { ProviderTransferError } from '../errors/providers.mjs';
22
+
23
+ function _class_private_field_loose_base(receiver, privateKey) {
24
+ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
25
+ throw new TypeError("attempted to use private field on non-instance");
26
+ }
27
+ return receiver;
28
+ }
29
+ var id = 0;
30
+ function _class_private_field_loose_key(name) {
31
+ return "__private_" + id++ + "_" + name;
32
+ }
33
+ const TRANSFER_STAGES = Object.freeze([
34
+ 'entities',
35
+ 'links',
36
+ 'assets',
37
+ 'schemas',
38
+ 'configuration'
39
+ ]);
40
+ /**
41
+ * Preset filters for only/exclude options
42
+ * */ const TransferGroupPresets = {
43
+ content: {
44
+ links: true,
45
+ entities: true
46
+ },
47
+ files: {
48
+ assets: true
49
+ },
50
+ config: {
51
+ configuration: true
52
+ }
53
+ };
54
+ const DEFAULT_VERSION_STRATEGY = 'ignore';
55
+ const DEFAULT_SCHEMA_STRATEGY = 'strict';
56
+ var _metadata = /*#__PURE__*/ _class_private_field_loose_key("_metadata"), _schema = /*#__PURE__*/ _class_private_field_loose_key("_schema"), _handlers = /*#__PURE__*/ _class_private_field_loose_key("_handlers"), _currentStreamController = /*#__PURE__*/ _class_private_field_loose_key("_currentStreamController"), _aborted = /*#__PURE__*/ _class_private_field_loose_key("_aborted"), /**
57
+ * Create and return a transform stream based on the given stage and options.
58
+ *
59
+ * Allowed transformations includes 'filter' and 'map'.
60
+ */ _createStageTransformStream = /*#__PURE__*/ _class_private_field_loose_key("_createStageTransformStream"), /**
61
+ * Update the Engine's transfer progress data for a given stage.
62
+ *
63
+ * Providing aggregate options enable custom computation to get the size (bytes) or the aggregate key associated with the data
64
+ */ _updateTransferProgress = /*#__PURE__*/ _class_private_field_loose_key("_updateTransferProgress"), /**
65
+ * Create and return a PassThrough stream for per-object progress tracking.
66
+ * Upon writing data into it, it'll update the Engine's transfer progress data and trigger stage update events.
67
+ */ _progressTracker = /*#__PURE__*/ _class_private_field_loose_key("_progressTracker"), /**
68
+ * Create and return a PassThrough stream for per-chunk progress tracking (used for assets).
69
+ * Pipes each asset's binary stream through a Transform that counts bytes and forwards chunks,
70
+ * then replaces asset.stream with that transform so the destination has a single consumer.
71
+ * This avoids consuming the stream (which would leave the destination with an empty stream)
72
+ * and ensures backpressure is applied so memory is not held for the entire transfer.
73
+ */ _progressTrackerChunks = /*#__PURE__*/ _class_private_field_loose_key("_progressTrackerChunks"), _updateAggregateBytes = /*#__PURE__*/ _class_private_field_loose_key("_updateAggregateBytes"), _incrementAggregateCount = /*#__PURE__*/ _class_private_field_loose_key("_incrementAggregateCount"), /**
74
+ * Shorthand method used to trigger transfer update events to every listeners
75
+ */ _emitTransferUpdate = /*#__PURE__*/ _class_private_field_loose_key("_emitTransferUpdate"), /**
76
+ * Shorthand method used to trigger stage update events to every listeners
77
+ */ _emitStageUpdate = /*#__PURE__*/ _class_private_field_loose_key("_emitStageUpdate"), /**
78
+ * Run a version check between two strapi version (source and destination) using the strategy given to the engine during initialization.
79
+ *
80
+ * If there is a mismatch, throws a validation error.
81
+ */ _assertStrapiVersionIntegrity = /*#__PURE__*/ _class_private_field_loose_key("_assertStrapiVersionIntegrity"), /**
82
+ * Run a check between two set of schemas (source and destination) using the strategy given to the engine during initialization.
83
+ *
84
+ * If there are differences and/or incompatibilities between source and destination schemas, then throw a validation error.
85
+ */ _assertSchemasMatching = /*#__PURE__*/ _class_private_field_loose_key("_assertSchemasMatching"), _transferStage = /*#__PURE__*/ _class_private_field_loose_key("_transferStage"), _resolveProviderResource = /*#__PURE__*/ _class_private_field_loose_key("_resolveProviderResource"), _getSchemas = /*#__PURE__*/ _class_private_field_loose_key("_getSchemas"), _mergeSourceStageTotals = /*#__PURE__*/ _class_private_field_loose_key("_mergeSourceStageTotals");
86
+ class TransferEngine {
87
+ onSchemaDiff(handler) {
88
+ _class_private_field_loose_base(this, _handlers)[_handlers]?.schemaDiff?.push(handler);
89
+ }
90
+ addErrorHandler(handlerName, handler) {
91
+ if (!_class_private_field_loose_base(this, _handlers)[_handlers].errors[handlerName]) {
92
+ _class_private_field_loose_base(this, _handlers)[_handlers].errors[handlerName] = [];
93
+ }
94
+ _class_private_field_loose_base(this, _handlers)[_handlers].errors[handlerName]?.push(handler);
95
+ }
96
+ async attemptResolveError(error) {
97
+ const context = {};
98
+ if (error instanceof ProviderTransferError && error.details?.details.code) {
99
+ const errorCode = error.details?.details.code;
100
+ if (!_class_private_field_loose_base(this, _handlers)[_handlers].errors[errorCode]) {
101
+ _class_private_field_loose_base(this, _handlers)[_handlers].errors[errorCode] = [];
102
+ }
103
+ await runMiddleware(context ?? {}, _class_private_field_loose_base(this, _handlers)[_handlers].errors[errorCode] ?? []);
104
+ }
105
+ return !!context.ignore;
106
+ }
107
+ /**
108
+ * Report a fatal error and throw it
109
+ */ panic(error) {
110
+ this.reportError(error, 'fatal');
111
+ throw error;
112
+ }
113
+ /**
114
+ * Report an error diagnostic
115
+ */ reportError(error, severity) {
116
+ this.diagnostics.report({
117
+ kind: 'error',
118
+ details: {
119
+ severity,
120
+ createdAt: new Date(),
121
+ name: error.name,
122
+ message: error.message,
123
+ error
124
+ }
125
+ });
126
+ }
127
+ /**
128
+ * Report a warning diagnostic
129
+ */ reportWarning(message, origin1) {
130
+ this.diagnostics.report({
131
+ kind: 'warning',
132
+ details: {
133
+ createdAt: new Date(),
134
+ message,
135
+ origin: origin1
136
+ }
137
+ });
138
+ }
139
+ /**
140
+ * Report an info diagnostic
141
+ */ reportInfo(message, params) {
142
+ this.diagnostics.report({
143
+ kind: 'info',
144
+ details: {
145
+ createdAt: new Date(),
146
+ message,
147
+ params,
148
+ origin: 'engine'
149
+ }
150
+ });
151
+ }
152
+ shouldSkipStage(stage) {
153
+ const { exclude, only } = this.options;
154
+ // schemas must always be included
155
+ if (stage === 'schemas') {
156
+ return false;
157
+ }
158
+ // everything is included by default unless 'only' has been set
159
+ let included = isEmpty(only);
160
+ if (only && only.length > 0) {
161
+ included = only.some((transferGroup)=>{
162
+ return TransferGroupPresets[transferGroup][stage];
163
+ });
164
+ }
165
+ if (exclude && exclude.length > 0) {
166
+ if (included) {
167
+ included = !exclude.some((transferGroup)=>{
168
+ return TransferGroupPresets[transferGroup][stage];
169
+ });
170
+ }
171
+ }
172
+ return !included;
173
+ }
174
+ // Cause an ongoing transfer to abort gracefully
175
+ async abortTransfer() {
176
+ _class_private_field_loose_base(this, _aborted)[_aborted] = true;
177
+ _class_private_field_loose_base(this, _currentStreamController)[_currentStreamController]?.abort();
178
+ throw new TransferEngineError('fatal', 'Transfer aborted.');
179
+ }
180
+ async init() {
181
+ // Resolve providers' resource and store
182
+ // them in the engine's internal state
183
+ await _class_private_field_loose_base(this, _resolveProviderResource)[_resolveProviderResource]();
184
+ // Update the destination provider's source metadata
185
+ const { source: sourceMetadata } = _class_private_field_loose_base(this, _metadata)[_metadata];
186
+ if (sourceMetadata) {
187
+ this.destinationProvider.setMetadata?.('source', sourceMetadata);
188
+ }
189
+ }
190
+ /**
191
+ * Run the bootstrap method in both source and destination providers
192
+ */ async bootstrap() {
193
+ const results = await Promise.allSettled([
194
+ this.sourceProvider.bootstrap?.(this.diagnostics),
195
+ this.destinationProvider.bootstrap?.(this.diagnostics)
196
+ ]);
197
+ results.forEach((result)=>{
198
+ if (result.status === 'rejected') {
199
+ this.panic(result.reason);
200
+ }
201
+ });
202
+ }
203
+ /**
204
+ * Run the close method in both source and destination providers
205
+ */ async close() {
206
+ const results = await Promise.allSettled([
207
+ this.sourceProvider.close?.(),
208
+ this.destinationProvider.close?.()
209
+ ]);
210
+ results.forEach((result)=>{
211
+ if (result.status === 'rejected') {
212
+ this.panic(result.reason);
213
+ }
214
+ });
215
+ }
216
+ async integrityCheck() {
217
+ const sourceMetadata = await this.sourceProvider.getMetadata();
218
+ const destinationMetadata = await this.destinationProvider.getMetadata();
219
+ if (sourceMetadata && destinationMetadata) {
220
+ _class_private_field_loose_base(this, _assertStrapiVersionIntegrity)[_assertStrapiVersionIntegrity](sourceMetadata?.strapi?.version, destinationMetadata?.strapi?.version);
221
+ }
222
+ const { sourceSchemas, destinationSchemas } = await _class_private_field_loose_base(this, _getSchemas)[_getSchemas]();
223
+ try {
224
+ if (sourceSchemas && destinationSchemas) {
225
+ _class_private_field_loose_base(this, _assertSchemasMatching)[_assertSchemasMatching](sourceSchemas, destinationSchemas);
226
+ }
227
+ } catch (error) {
228
+ // if this is a schema matching error, allow handlers to resolve it
229
+ if (error instanceof TransferEngineValidationError && error.details?.details?.diffs) {
230
+ const schemaDiffs = error.details?.details?.diffs;
231
+ const context = {
232
+ ignoredDiffs: {},
233
+ diffs: schemaDiffs,
234
+ source: this.sourceProvider,
235
+ destination: this.destinationProvider
236
+ };
237
+ // if we don't have any handlers, throw the original error
238
+ if (isEmpty(_class_private_field_loose_base(this, _handlers)[_handlers].schemaDiff)) {
239
+ throw error;
240
+ }
241
+ await runMiddleware(context, _class_private_field_loose_base(this, _handlers)[_handlers].schemaDiff);
242
+ // if there are any remaining diffs that weren't ignored
243
+ const unresolvedDiffs = diff(context.diffs, context.ignoredDiffs);
244
+ if (unresolvedDiffs.length) {
245
+ this.panic(new TransferEngineValidationError('Unresolved differences in schema', {
246
+ check: 'schema.changes',
247
+ unresolvedDiffs
248
+ }));
249
+ }
250
+ return;
251
+ }
252
+ throw error;
253
+ }
254
+ }
255
+ async transfer() {
256
+ // reset data between transfers
257
+ this.progress.data = {};
258
+ try {
259
+ _class_private_field_loose_base(this, _emitTransferUpdate)[_emitTransferUpdate]('init');
260
+ await this.bootstrap();
261
+ await this.init();
262
+ await this.integrityCheck();
263
+ _class_private_field_loose_base(this, _emitTransferUpdate)[_emitTransferUpdate]('start');
264
+ await this.beforeTransfer();
265
+ // Run the transfer stages
266
+ await this.transferSchemas();
267
+ await this.transferEntities();
268
+ await this.transferAssets();
269
+ await this.transferLinks();
270
+ await this.transferConfiguration();
271
+ // Gracefully close the providers
272
+ await this.close();
273
+ _class_private_field_loose_base(this, _emitTransferUpdate)[_emitTransferUpdate]('finish');
274
+ } catch (e) {
275
+ _class_private_field_loose_base(this, _emitTransferUpdate)[_emitTransferUpdate]('error', {
276
+ error: e
277
+ });
278
+ const lastDiagnostic = last(this.diagnostics.stack.items);
279
+ // Do not report an error diagnostic if the last one reported the same error
280
+ if (e instanceof Error && (!lastDiagnostic || lastDiagnostic.kind !== 'error' || lastDiagnostic.details.error !== e)) {
281
+ this.reportError(e, e.severity || 'fatal');
282
+ }
283
+ // Rollback the destination provider if an exception is thrown during the transfer
284
+ // Note: This will be configurable in the future
285
+ await this.destinationProvider.rollback?.(e);
286
+ throw e;
287
+ }
288
+ return {
289
+ source: this.sourceProvider.results,
290
+ destination: this.destinationProvider.results,
291
+ engine: this.progress.data
292
+ };
293
+ }
294
+ async beforeTransfer() {
295
+ const runWithDiagnostic = async (provider)=>{
296
+ try {
297
+ await provider.beforeTransfer?.();
298
+ } catch (error) {
299
+ if (error instanceof Error) {
300
+ const resolved = await this.attemptResolveError(error);
301
+ if (resolved) {
302
+ return;
303
+ }
304
+ this.panic(error);
305
+ } else {
306
+ this.panic(new Error(`Unknwon error when executing "beforeTransfer" on the ${origin} provider`));
307
+ }
308
+ }
309
+ };
310
+ await runWithDiagnostic(this.sourceProvider);
311
+ await runWithDiagnostic(this.destinationProvider);
312
+ }
313
+ async transferSchemas() {
314
+ const stage = 'schemas';
315
+ if (this.shouldSkipStage(stage)) {
316
+ return;
317
+ }
318
+ const source = await this.sourceProvider.createSchemasReadStream?.();
319
+ const destination = await this.destinationProvider.createSchemasWriteStream?.();
320
+ const transform = _class_private_field_loose_base(this, _createStageTransformStream)[_createStageTransformStream](stage);
321
+ const tracker = _class_private_field_loose_base(this, _progressTracker)[_progressTracker](stage, {
322
+ key: (value)=>value.modelType
323
+ });
324
+ await _class_private_field_loose_base(this, _transferStage)[_transferStage]({
325
+ stage,
326
+ source,
327
+ destination,
328
+ transform,
329
+ tracker
330
+ });
331
+ }
332
+ async transferEntities() {
333
+ const stage = 'entities';
334
+ if (this.shouldSkipStage(stage)) {
335
+ return;
336
+ }
337
+ const source = await this.sourceProvider.createEntitiesReadStream?.();
338
+ const destination = await this.destinationProvider.createEntitiesWriteStream?.();
339
+ const transform = chain([
340
+ _class_private_field_loose_base(this, _createStageTransformStream)[_createStageTransformStream](stage),
341
+ new Transform({
342
+ objectMode: true,
343
+ transform: async (entity, _encoding, callback)=>{
344
+ const { destinationSchemas: schemas } = await _class_private_field_loose_base(this, _getSchemas)[_getSchemas]();
345
+ if (!schemas) {
346
+ return callback(null, entity);
347
+ }
348
+ // TODO: this would be safer if we only ignored things in ignoredDiffs, otherwise continue and let an error be thrown
349
+ const availableContentTypes = Object.entries(schemas).filter(([, schema])=>schema.modelType === 'contentType').map(([uid])=>uid);
350
+ // If the type of the transferred entity doesn't exist in the destination, then discard it
351
+ if (!availableContentTypes.includes(entity.type)) {
352
+ return callback(null, undefined);
353
+ }
354
+ const { type, data } = entity;
355
+ const attributes = schemas[type].attributes;
356
+ const attributesToKeep = Object.keys(attributes).concat('documentId');
357
+ const updatedEntity = set('data', pick(attributesToKeep, data), entity);
358
+ callback(null, updatedEntity);
359
+ }
360
+ })
361
+ ]);
362
+ const tracker = _class_private_field_loose_base(this, _progressTracker)[_progressTracker](stage, {
363
+ key: (value)=>value.type
364
+ });
365
+ await _class_private_field_loose_base(this, _transferStage)[_transferStage]({
366
+ stage,
367
+ source,
368
+ destination,
369
+ transform,
370
+ tracker
371
+ });
372
+ }
373
+ async transferLinks() {
374
+ const stage = 'links';
375
+ if (this.shouldSkipStage(stage)) {
376
+ return;
377
+ }
378
+ const source = await this.sourceProvider.createLinksReadStream?.();
379
+ const destination = await this.destinationProvider.createLinksWriteStream?.();
380
+ const transform = chain([
381
+ _class_private_field_loose_base(this, _createStageTransformStream)[_createStageTransformStream](stage),
382
+ new Transform({
383
+ objectMode: true,
384
+ transform: async (link, _encoding, callback)=>{
385
+ const { destinationSchemas: schemas } = await _class_private_field_loose_base(this, _getSchemas)[_getSchemas]();
386
+ if (!schemas) {
387
+ return callback(null, link);
388
+ }
389
+ // TODO: this would be safer if we only ignored things in ignoredDiffs, otherwise continue and let an error be thrown
390
+ const availableContentTypes = Object.keys(schemas);
391
+ const isValidType = (uid)=>availableContentTypes.includes(uid);
392
+ if (!isValidType(link.left.type) || !isValidType(link.right.type)) {
393
+ return callback(null, undefined); // ignore the link
394
+ }
395
+ callback(null, link);
396
+ }
397
+ })
398
+ ]);
399
+ const tracker = _class_private_field_loose_base(this, _progressTracker)[_progressTracker](stage);
400
+ await _class_private_field_loose_base(this, _transferStage)[_transferStage]({
401
+ stage,
402
+ source,
403
+ destination,
404
+ transform,
405
+ tracker
406
+ });
407
+ }
408
+ async transferAssets() {
409
+ const stage = 'assets';
410
+ if (this.shouldSkipStage(stage)) {
411
+ return;
412
+ }
413
+ const source = await this.sourceProvider.createAssetsReadStream?.();
414
+ const destination = await this.destinationProvider.createAssetsWriteStream?.();
415
+ const transform = _class_private_field_loose_base(this, _createStageTransformStream)[_createStageTransformStream](stage);
416
+ const tracker = _class_private_field_loose_base(this, _progressTrackerChunks)[_progressTrackerChunks](stage, {
417
+ key: (value)=>extname(value.filename) || 'No extension'
418
+ });
419
+ await _class_private_field_loose_base(this, _mergeSourceStageTotals)[_mergeSourceStageTotals](stage);
420
+ await _class_private_field_loose_base(this, _transferStage)[_transferStage]({
421
+ stage,
422
+ source,
423
+ destination,
424
+ transform,
425
+ tracker
426
+ });
427
+ }
428
+ async transferConfiguration() {
429
+ const stage = 'configuration';
430
+ if (this.shouldSkipStage(stage)) {
431
+ return;
432
+ }
433
+ const source = await this.sourceProvider.createConfigurationReadStream?.();
434
+ const destination = await this.destinationProvider.createConfigurationWriteStream?.();
435
+ const transform = _class_private_field_loose_base(this, _createStageTransformStream)[_createStageTransformStream](stage);
436
+ const tracker = _class_private_field_loose_base(this, _progressTracker)[_progressTracker](stage);
437
+ await _class_private_field_loose_base(this, _transferStage)[_transferStage]({
438
+ stage,
439
+ source,
440
+ destination,
441
+ transform,
442
+ tracker
443
+ });
444
+ }
445
+ constructor(sourceProvider, destinationProvider, options){
446
+ Object.defineProperty(this, _createStageTransformStream, {
447
+ value: createStageTransformStream
448
+ });
449
+ Object.defineProperty(this, _updateTransferProgress, {
450
+ value: updateTransferProgress
451
+ });
452
+ Object.defineProperty(this, _progressTracker, {
453
+ value: progressTracker
454
+ });
455
+ Object.defineProperty(this, _progressTrackerChunks, {
456
+ value: progressTrackerChunks
457
+ });
458
+ Object.defineProperty(this, _emitTransferUpdate, {
459
+ value: emitTransferUpdate
460
+ });
461
+ Object.defineProperty(this, _emitStageUpdate, {
462
+ value: emitStageUpdate
463
+ });
464
+ Object.defineProperty(this, _assertStrapiVersionIntegrity, {
465
+ value: assertStrapiVersionIntegrity
466
+ });
467
+ Object.defineProperty(this, _assertSchemasMatching, {
468
+ value: assertSchemasMatching
469
+ });
470
+ Object.defineProperty(this, _transferStage, {
471
+ value: transferStage
472
+ });
473
+ Object.defineProperty(this, _resolveProviderResource, {
474
+ value: resolveProviderResource
475
+ });
476
+ Object.defineProperty(this, _getSchemas, {
477
+ value: getSchemas
478
+ });
479
+ /**
480
+ * Merge optional source-reported totals into progress before the stage starts (CLI ETA / totals).
481
+ */ Object.defineProperty(this, _mergeSourceStageTotals, {
482
+ value: mergeSourceStageTotals
483
+ });
484
+ Object.defineProperty(this, _metadata, {
485
+ writable: true,
486
+ value: void 0
487
+ });
488
+ Object.defineProperty(this, _schema, {
489
+ writable: true,
490
+ value: void 0
491
+ });
492
+ Object.defineProperty(this, _handlers, {
493
+ writable: true,
494
+ value: void 0
495
+ });
496
+ Object.defineProperty(this, _currentStreamController, {
497
+ writable: true,
498
+ value: void 0
499
+ });
500
+ Object.defineProperty(this, _aborted, {
501
+ writable: true,
502
+ value: void 0
503
+ });
504
+ Object.defineProperty(this, _updateAggregateBytes, {
505
+ writable: true,
506
+ value: void 0
507
+ });
508
+ Object.defineProperty(this, _incrementAggregateCount, {
509
+ writable: true,
510
+ value: void 0
511
+ });
512
+ _class_private_field_loose_base(this, _metadata)[_metadata] = {};
513
+ _class_private_field_loose_base(this, _schema)[_schema] = {};
514
+ _class_private_field_loose_base(this, _handlers)[_handlers] = {
515
+ schemaDiff: [],
516
+ errors: {}
517
+ };
518
+ _class_private_field_loose_base(this, _aborted)[_aborted] = false;
519
+ _class_private_field_loose_base(this, _updateAggregateBytes)[_updateAggregateBytes] = (stageProgress, key, bytes)=>{
520
+ if (!stageProgress.aggregates) {
521
+ stageProgress.aggregates = {};
522
+ }
523
+ if (!stageProgress.aggregates[key]) {
524
+ stageProgress.aggregates[key] = {
525
+ count: 0,
526
+ bytes: 0
527
+ };
528
+ }
529
+ stageProgress.aggregates[key].bytes += bytes;
530
+ };
531
+ _class_private_field_loose_base(this, _incrementAggregateCount)[_incrementAggregateCount] = (stageProgress, key)=>{
532
+ if (!stageProgress.aggregates) {
533
+ stageProgress.aggregates = {};
534
+ }
535
+ if (!stageProgress.aggregates[key]) {
536
+ stageProgress.aggregates[key] = {
537
+ count: 0,
538
+ bytes: 0
539
+ };
540
+ }
541
+ stageProgress.aggregates[key].count += 1;
542
+ };
543
+ this.diagnostics = createDiagnosticReporter();
544
+ validateProvider('source', sourceProvider);
545
+ validateProvider('destination', destinationProvider);
546
+ this.sourceProvider = sourceProvider;
547
+ this.destinationProvider = destinationProvider;
548
+ this.options = options;
549
+ this.progress = {
550
+ data: {},
551
+ stream: new PassThrough({
552
+ objectMode: true
553
+ })
554
+ };
555
+ }
556
+ }
557
+ function createStageTransformStream(key, options = {}) {
558
+ const { includeGlobal = true } = options;
559
+ const { throttle } = this.options;
560
+ const { global: globalTransforms, [key]: stageTransforms } = this.options?.transforms ?? {};
561
+ let stream = new PassThrough({
562
+ objectMode: true
563
+ });
564
+ const applyTransforms = (transforms = [])=>{
565
+ const chainTransforms = [];
566
+ for (const transform of transforms){
567
+ if ('filter' in transform) {
568
+ chainTransforms.push(filter(transform.filter));
569
+ }
570
+ if ('map' in transform) {
571
+ chainTransforms.push(map(transform.map));
572
+ }
573
+ }
574
+ if (chainTransforms.length) {
575
+ stream = stream.pipe(chain(chainTransforms));
576
+ }
577
+ };
578
+ if (includeGlobal) {
579
+ applyTransforms(globalTransforms);
580
+ }
581
+ if (isNumber(throttle) && throttle > 0) {
582
+ stream = stream.pipe(new PassThrough({
583
+ objectMode: true,
584
+ async transform (data, _encoding, callback) {
585
+ await new Promise((resolve)=>{
586
+ setTimeout(resolve, throttle);
587
+ });
588
+ callback(null, data);
589
+ }
590
+ }));
591
+ }
592
+ applyTransforms(stageTransforms);
593
+ return stream;
594
+ }
595
+ function updateTransferProgress(stage, data, aggregate) {
596
+ if (!this.progress.data[stage]) {
597
+ this.progress.data[stage] = {
598
+ count: 0,
599
+ bytes: 0,
600
+ startTime: Date.now()
601
+ };
602
+ }
603
+ const stageProgress = this.progress.data[stage];
604
+ if (!stageProgress) {
605
+ return;
606
+ }
607
+ const size = aggregate?.size?.(data) ?? JSON.stringify(data).length;
608
+ const key = aggregate?.key?.(data);
609
+ stageProgress.count += 1;
610
+ stageProgress.bytes += size;
611
+ // Handle aggregate updates if necessary
612
+ if (key) {
613
+ if (!stageProgress.aggregates) {
614
+ stageProgress.aggregates = {};
615
+ }
616
+ const { aggregates } = stageProgress;
617
+ if (!aggregates[key]) {
618
+ aggregates[key] = {
619
+ count: 0,
620
+ bytes: 0
621
+ };
622
+ }
623
+ aggregates[key].count += 1;
624
+ aggregates[key].bytes += size;
625
+ }
626
+ }
627
+ function progressTracker(stage, aggregate) {
628
+ return new PassThrough({
629
+ objectMode: true,
630
+ transform: (data, _encoding, callback)=>{
631
+ _class_private_field_loose_base(this, _updateTransferProgress)[_updateTransferProgress](stage, data, aggregate);
632
+ _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate]('progress', stage);
633
+ callback(null, data);
634
+ }
635
+ });
636
+ }
637
+ function progressTrackerChunks(stage, aggregate) {
638
+ const updateAggregateBytes = _class_private_field_loose_base(this, _updateAggregateBytes)[_updateAggregateBytes].bind(this);
639
+ const incrementAggregateCount = _class_private_field_loose_base(this, _incrementAggregateCount)[_incrementAggregateCount].bind(this);
640
+ const emitStageUpdate = _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate].bind(this);
641
+ return new PassThrough({
642
+ objectMode: true,
643
+ transform: (asset, _encoding, callback)=>{
644
+ if (!asset?.stream || typeof asset.stream.pipe !== 'function') {
645
+ return callback(null, asset);
646
+ }
647
+ const key = aggregate?.key?.(asset);
648
+ if (!this.progress.data[stage]) {
649
+ this.progress.data[stage] = {
650
+ count: 0,
651
+ bytes: 0,
652
+ startTime: Date.now()
653
+ };
654
+ }
655
+ const stageProgress = this.progress.data[stage];
656
+ if (!stageProgress) {
657
+ throw new TransferEngineError('fatal', 'Stage progress data not found');
658
+ }
659
+ const progressTransform = new Transform({
660
+ objectMode: true,
661
+ transform (chunk, _enc, cb) {
662
+ // Asset file reads should yield Buffers; avoid skewing totals if not.
663
+ const byteLength = Buffer.isBuffer(chunk) ? chunk.length : 1;
664
+ stageProgress.bytes += byteLength;
665
+ if (key) {
666
+ updateAggregateBytes(stageProgress, key, byteLength);
667
+ }
668
+ emitStageUpdate('progress', stage);
669
+ cb(null, chunk);
670
+ },
671
+ flush (cb) {
672
+ stageProgress.count += 1;
673
+ if (key) {
674
+ incrementAggregateCount(stageProgress, key);
675
+ }
676
+ emitStageUpdate('progress', stage);
677
+ cb(null);
678
+ }
679
+ });
680
+ asset.stream.on('error', (err)=>progressTransform.destroy(err));
681
+ asset.stream.pipe(progressTransform);
682
+ asset.stream = progressTransform;
683
+ callback(null, asset);
684
+ }
685
+ });
686
+ }
687
+ function emitTransferUpdate(type, payload) {
688
+ this.progress.stream.emit(`transfer::${type}`, payload);
689
+ }
690
+ function emitStageUpdate(type, transferStage) {
691
+ this.progress.stream.emit(`stage::${type}`, {
692
+ data: this.progress.data,
693
+ stage: transferStage
694
+ });
695
+ }
696
+ function assertStrapiVersionIntegrity(sourceVersion, destinationVersion) {
697
+ const strategy = this.options.versionStrategy || DEFAULT_VERSION_STRATEGY;
698
+ const reject = ()=>{
699
+ throw new TransferEngineValidationError(`The source and destination provide are targeting incompatible Strapi versions (using the "${strategy}" strategy). The source (${this.sourceProvider.name}) version is ${sourceVersion} and the destination (${this.destinationProvider.name}) version is ${destinationVersion}`, {
700
+ check: 'strapi.version',
701
+ strategy,
702
+ versions: {
703
+ source: sourceVersion,
704
+ destination: destinationVersion
705
+ }
706
+ });
707
+ };
708
+ if (!sourceVersion || !destinationVersion || strategy === 'ignore' || destinationVersion === sourceVersion) {
709
+ return;
710
+ }
711
+ let diff;
712
+ try {
713
+ diff = diff$1(sourceVersion, destinationVersion);
714
+ } catch {
715
+ reject();
716
+ }
717
+ if (!diff) {
718
+ return;
719
+ }
720
+ const validPatch = [
721
+ 'prelease',
722
+ 'build'
723
+ ];
724
+ const validMinor = [
725
+ ...validPatch,
726
+ 'patch',
727
+ 'prepatch'
728
+ ];
729
+ const validMajor = [
730
+ ...validMinor,
731
+ 'minor',
732
+ 'preminor'
733
+ ];
734
+ if (strategy === 'patch' && validPatch.includes(diff)) {
735
+ return;
736
+ }
737
+ if (strategy === 'minor' && validMinor.includes(diff)) {
738
+ return;
739
+ }
740
+ if (strategy === 'major' && validMajor.includes(diff)) {
741
+ return;
742
+ }
743
+ reject();
744
+ }
745
+ function assertSchemasMatching(sourceSchemas, destinationSchemas) {
746
+ const strategy = this.options.schemaStrategy || DEFAULT_SCHEMA_STRATEGY;
747
+ if (strategy === 'ignore') {
748
+ return;
749
+ }
750
+ const keys = uniq(Object.keys(sourceSchemas).concat(Object.keys(destinationSchemas)));
751
+ const diffs = {};
752
+ keys.forEach((key)=>{
753
+ const sourceSchema = sourceSchemas[key];
754
+ const destinationSchema = destinationSchemas[key];
755
+ const schemaDiffs = compareSchemas(sourceSchema, destinationSchema, strategy);
756
+ if (schemaDiffs.length) {
757
+ diffs[key] = schemaDiffs;
758
+ }
759
+ });
760
+ if (!isEmpty(diffs)) {
761
+ const formattedDiffs = Object.entries(diffs).map(([uid, ctDiffs])=>{
762
+ let msg = `- ${uid}:${EOL}`;
763
+ msg += ctDiffs.sort((a, b)=>a.kind > b.kind ? -1 : 1).map((diff)=>{
764
+ const path = diff.path.join('.');
765
+ if (diff.kind === 'added') {
766
+ return `${path} exists in destination schema but not in source schema and the data will not be transferred.`;
767
+ }
768
+ if (diff.kind === 'deleted') {
769
+ return `${path} exists in source schema but not in destination schema and the data will not be transferred.`;
770
+ }
771
+ if (diff.kind === 'modified') {
772
+ if (diff.types[0] === diff.types[1]) {
773
+ return `Schema value changed at "${path}": "${diff.values[0]}" (${diff.types[0]}) => "${diff.values[1]}" (${diff.types[1]})`;
774
+ }
775
+ return `Schema has differing data types at "${path}": "${diff.values[0]}" (${diff.types[0]}) => "${diff.values[1]}" (${diff.types[1]})`;
776
+ }
777
+ throw new TransferEngineValidationError(`Invalid diff found for "${uid}"`, {
778
+ check: `schema on ${uid}`
779
+ });
780
+ }).map((line)=>` - ${line}`).join(EOL);
781
+ return msg;
782
+ }).join(EOL);
783
+ throw new TransferEngineValidationError(`Invalid schema changes detected during integrity checks (using the ${strategy} strategy). Please find a summary of the changes below:\n${formattedDiffs}`, {
784
+ check: 'schema.changes',
785
+ strategy,
786
+ diffs
787
+ });
788
+ }
789
+ }
790
+ async function transferStage(options) {
791
+ if (_class_private_field_loose_base(this, _aborted)[_aborted]) {
792
+ throw new TransferEngineError('fatal', 'Transfer aborted.');
793
+ }
794
+ const { stage, source, destination, transform, tracker } = options;
795
+ const updateEndTime = ()=>{
796
+ const stageData = this.progress.data[stage];
797
+ if (stageData) {
798
+ stageData.endTime = Date.now();
799
+ }
800
+ };
801
+ if (!source || !destination || this.shouldSkipStage(stage)) {
802
+ // Wait until source and destination are closed
803
+ const results = await Promise.allSettled([
804
+ source,
805
+ destination
806
+ ].map((stream)=>{
807
+ // if stream is undefined or already closed, resolve immediately
808
+ if (!stream || stream.destroyed) {
809
+ return Promise.resolve();
810
+ }
811
+ // Wait until the close event is produced and then destroy the stream and resolve
812
+ return new Promise((resolve, reject)=>{
813
+ stream.on('close', resolve).on('error', reject).destroy();
814
+ });
815
+ }));
816
+ results.forEach((state)=>{
817
+ if (state.status === 'rejected') {
818
+ this.reportWarning(state.reason, `transfer(${stage})`);
819
+ }
820
+ });
821
+ _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate]('skip', stage);
822
+ return;
823
+ }
824
+ _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate]('start', stage);
825
+ try {
826
+ const streams = [
827
+ source
828
+ ];
829
+ if (transform) {
830
+ streams.push(transform);
831
+ }
832
+ if (tracker) {
833
+ streams.push(tracker);
834
+ }
835
+ streams.push(destination);
836
+ // NOTE: to debug/confirm backpressure issues from misbehaving stream, uncomment the following lines
837
+ // source.on('pause', () => console.log(`[${stage}] Source paused due to backpressure`));
838
+ // source.on('resume', () => console.log(`[${stage}] Source resumed`));
839
+ // destination.on('drain', () =>
840
+ // console.log(`[${stage}] Destination drained, resuming data flow`)
841
+ // );
842
+ // destination.on('error', (err) => console.error(`[${stage}] Destination error:`, err));
843
+ const controller = new AbortController();
844
+ const { signal } = controller;
845
+ // Store the controller so you can cancel later
846
+ _class_private_field_loose_base(this, _currentStreamController)[_currentStreamController] = controller;
847
+ await pipeline(streams, {
848
+ signal
849
+ });
850
+ _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate]('finish', stage);
851
+ } catch (e) {
852
+ updateEndTime();
853
+ _class_private_field_loose_base(this, _emitStageUpdate)[_emitStageUpdate]('error', stage);
854
+ this.reportError(e, 'error');
855
+ if (!destination.destroyed) {
856
+ destination.destroy(e);
857
+ }
858
+ throw e;
859
+ } finally{
860
+ updateEndTime();
861
+ }
862
+ }
863
+ async function resolveProviderResource() {
864
+ const sourceMetadata = await this.sourceProvider.getMetadata();
865
+ const destinationMetadata = await this.destinationProvider.getMetadata();
866
+ if (sourceMetadata) {
867
+ _class_private_field_loose_base(this, _metadata)[_metadata].source = sourceMetadata;
868
+ }
869
+ if (destinationMetadata) {
870
+ _class_private_field_loose_base(this, _metadata)[_metadata].destination = destinationMetadata;
871
+ }
872
+ }
873
+ async function getSchemas() {
874
+ if (!_class_private_field_loose_base(this, _schema)[_schema].source) {
875
+ _class_private_field_loose_base(this, _schema)[_schema].source = await this.sourceProvider.getSchemas?.();
876
+ }
877
+ if (!_class_private_field_loose_base(this, _schema)[_schema].destination) {
878
+ _class_private_field_loose_base(this, _schema)[_schema].destination = await this.destinationProvider.getSchemas?.();
879
+ }
880
+ return {
881
+ sourceSchemas: _class_private_field_loose_base(this, _schema)[_schema].source,
882
+ destinationSchemas: _class_private_field_loose_base(this, _schema)[_schema].destination
883
+ };
884
+ }
885
+ async function mergeSourceStageTotals(stage) {
886
+ const getTotals = this.sourceProvider.getStageTotals;
887
+ if (!getTotals) {
888
+ return;
889
+ }
890
+ const totals = await getTotals.call(this.sourceProvider, stage);
891
+ if (!totals || totals.totalBytes == null && totals.totalCount == null) {
892
+ return;
893
+ }
894
+ if (!this.progress.data[stage]) {
895
+ this.progress.data[stage] = {
896
+ count: 0,
897
+ bytes: 0,
898
+ startTime: Date.now()
899
+ };
900
+ }
901
+ const stageProgress = this.progress.data[stage];
902
+ if (!stageProgress) {
903
+ return;
904
+ }
905
+ if (totals.totalBytes != null) {
906
+ stageProgress.totalBytes = totals.totalBytes;
907
+ }
908
+ if (totals.totalCount != null) {
909
+ stageProgress.totalCount = totals.totalCount;
910
+ }
911
+ }
912
+ const createTransferEngine = (sourceProvider, destinationProvider, options)=>{
913
+ return new TransferEngine(sourceProvider, destinationProvider, options);
914
+ };
915
+
916
+ export { DEFAULT_SCHEMA_STRATEGY, DEFAULT_VERSION_STRATEGY, TRANSFER_STAGES, TransferGroupPresets, createTransferEngine };
917
+ //# sourceMappingURL=index.mjs.map