@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,328 @@
1
+ import zip from 'zlib';
2
+ import path from 'path';
3
+ import { PassThrough, pipeline } from 'stream';
4
+ import fs__default from 'fs-extra';
5
+ import { Parser } from 'tar';
6
+ import { isEmpty, keyBy } from 'lodash/fp';
7
+ import { chain } from 'stream-chain';
8
+ import { parser } from 'stream-json/jsonl/Parser';
9
+ import 'crypto';
10
+ import { createDecryptionCipher } from '../../../utils/encryption/decrypt.mjs';
11
+ import { write } from '../../../utils/writable-async-write.mjs';
12
+ import { collect } from '../../../utils/stream.mjs';
13
+ import { schemasToValidJSON } from '../../../utils/schema.mjs';
14
+ import 'events';
15
+ import { ProviderInitializationError, ProviderTransferError } from '../../../errors/providers.mjs';
16
+ import { isFilePathInDirname, unknownPathToPosix, isPathEquivalent } from './utils.mjs';
17
+
18
+ function _class_private_field_loose_base(receiver, privateKey) {
19
+ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
20
+ throw new TypeError("attempted to use private field on non-instance");
21
+ }
22
+ return receiver;
23
+ }
24
+ var id = 0;
25
+ function _class_private_field_loose_key(name) {
26
+ return "__private_" + id++ + "_" + name;
27
+ }
28
+ /**
29
+ * Constant for the metadata file path
30
+ */ const METADATA_FILE_PATH = 'metadata.json';
31
+ const createLocalFileSourceProvider = (options)=>{
32
+ return new LocalFileSourceProvider(options);
33
+ };
34
+ var _metadata = /*#__PURE__*/ _class_private_field_loose_key("_metadata"), _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), /**
35
+ * tar `Parser` invokes the pipeline completion callback when the archive ends, but it does not
36
+ * reliably await async `onReadEntry` — defer `end` until outstanding async entry work is done.
37
+ */ _endPassThroughWhenTarIdle = /*#__PURE__*/ _class_private_field_loose_key("_endPassThroughWhenTarIdle"), _loadMetadata = /*#__PURE__*/ _class_private_field_loose_key("_loadMetadata"), _loadAssetMetadata = /*#__PURE__*/ _class_private_field_loose_key("_loadAssetMetadata"), _getBackupStream = /*#__PURE__*/ _class_private_field_loose_key("_getBackupStream"), // `directory` must be posix formatted path
38
+ _streamJsonlDirectory = /*#__PURE__*/ _class_private_field_loose_key("_streamJsonlDirectory"), _parseJSONFile = /*#__PURE__*/ _class_private_field_loose_key("_parseJSONFile");
39
+ class LocalFileSourceProvider {
40
+ /**
41
+ * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
42
+ */ async bootstrap(diagnostics) {
43
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
44
+ const { path: filePath } = this.options.file;
45
+ try {
46
+ // Read the metadata to ensure the file can be parsed
47
+ await _class_private_field_loose_base(this, _loadMetadata)[_loadMetadata]();
48
+ // TODO: we might also need to read the schema.jsonl files & implements a custom stream-check
49
+ } catch (e) {
50
+ if (this.options?.encryption?.enabled) {
51
+ throw new ProviderInitializationError(`Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`);
52
+ }
53
+ throw new ProviderInitializationError(`File '${filePath}' is not a valid Strapi data file.`);
54
+ }
55
+ if (!_class_private_field_loose_base(this, _metadata)[_metadata]) {
56
+ throw new ProviderInitializationError('Could not load metadata from Strapi data file.');
57
+ }
58
+ }
59
+ async getMetadata() {
60
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
61
+ if (!_class_private_field_loose_base(this, _metadata)[_metadata]) {
62
+ await _class_private_field_loose_base(this, _loadMetadata)[_loadMetadata]();
63
+ }
64
+ return _class_private_field_loose_base(this, _metadata)[_metadata] ?? null;
65
+ }
66
+ async getSchemas() {
67
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schemas');
68
+ const schemaCollection = await collect(this.createSchemasReadStream());
69
+ if (isEmpty(schemaCollection)) {
70
+ throw new ProviderInitializationError('Could not load schemas from Strapi data file.');
71
+ }
72
+ // Group schema by UID
73
+ const schemas = keyBy('uid', schemaCollection);
74
+ // Transform to valid JSON
75
+ return schemasToValidJSON(schemas);
76
+ }
77
+ createEntitiesReadStream() {
78
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
79
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('entities');
80
+ }
81
+ createSchemasReadStream() {
82
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating schemas read stream');
83
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('schemas');
84
+ }
85
+ createLinksReadStream() {
86
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links read stream');
87
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('links');
88
+ }
89
+ createConfigurationReadStream() {
90
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration read stream');
91
+ // NOTE: TBD
92
+ return _class_private_field_loose_base(this, _streamJsonlDirectory)[_streamJsonlDirectory]('configuration');
93
+ }
94
+ createAssetsReadStream() {
95
+ const inStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
96
+ const outStream = new PassThrough({
97
+ objectMode: true
98
+ });
99
+ const loadAssetMetadata = _class_private_field_loose_base(this, _loadAssetMetadata)[_loadAssetMetadata].bind(this);
100
+ _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets read stream');
101
+ let activeAsyncEntries = 0;
102
+ const runReadEntry = async (fn)=>{
103
+ activeAsyncEntries += 1;
104
+ try {
105
+ await fn();
106
+ } finally{
107
+ activeAsyncEntries -= 1;
108
+ }
109
+ };
110
+ pipeline([
111
+ inStream,
112
+ new Parser({
113
+ // find only files in the assets/uploads folder
114
+ filter (filePath, entry) {
115
+ if (!('type' in entry) || entry.type !== 'File') {
116
+ return false;
117
+ }
118
+ return isFilePathInDirname('assets/uploads', filePath);
119
+ },
120
+ async onReadEntry (entry) {
121
+ await runReadEntry(async ()=>{
122
+ const { path: filePath, size = 0 } = entry;
123
+ const normalizedPath = unknownPathToPosix(filePath);
124
+ const file = path.basename(normalizedPath);
125
+ let metadata;
126
+ try {
127
+ metadata = await loadAssetMetadata(`assets/metadata/${file}.json`);
128
+ } catch (error) {
129
+ throw new Error(`Failed to read metadata for ${file}`);
130
+ }
131
+ const asset = {
132
+ metadata,
133
+ filename: file,
134
+ filepath: normalizedPath,
135
+ stats: {
136
+ size
137
+ },
138
+ stream: entry
139
+ };
140
+ await write(outStream, asset);
141
+ });
142
+ }
143
+ })
144
+ ], (err)=>_class_private_field_loose_base(this, _endPassThroughWhenTarIdle)[_endPassThroughWhenTarIdle](outStream, ()=>activeAsyncEntries, err));
145
+ return outStream;
146
+ }
147
+ constructor(options){
148
+ Object.defineProperty(this, _reportInfo, {
149
+ value: reportInfo
150
+ });
151
+ Object.defineProperty(this, _endPassThroughWhenTarIdle, {
152
+ value: endPassThroughWhenTarIdle
153
+ });
154
+ Object.defineProperty(this, _loadMetadata, {
155
+ value: loadMetadata
156
+ });
157
+ Object.defineProperty(this, _loadAssetMetadata, {
158
+ value: loadAssetMetadata
159
+ });
160
+ Object.defineProperty(this, _getBackupStream, {
161
+ value: getBackupStream
162
+ });
163
+ Object.defineProperty(this, _streamJsonlDirectory, {
164
+ value: streamJsonlDirectory
165
+ });
166
+ // For collecting an entire JSON file then parsing it, not for streaming JSONL
167
+ Object.defineProperty(this, _parseJSONFile, {
168
+ value: parseJSONFile
169
+ });
170
+ Object.defineProperty(this, _metadata, {
171
+ writable: true,
172
+ value: void 0
173
+ });
174
+ Object.defineProperty(this, _diagnostics, {
175
+ writable: true,
176
+ value: void 0
177
+ });
178
+ this.type = 'source';
179
+ this.name = 'source::local-file';
180
+ this.options = options;
181
+ const { encryption } = this.options;
182
+ if (encryption.enabled && encryption.key === undefined) {
183
+ throw new Error('Missing encryption key');
184
+ }
185
+ }
186
+ }
187
+ function reportInfo(message) {
188
+ _class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
189
+ details: {
190
+ createdAt: new Date(),
191
+ message,
192
+ origin: 'file-source-provider'
193
+ },
194
+ kind: 'info'
195
+ });
196
+ }
197
+ function endPassThroughWhenTarIdle(outStream, activeAsyncEntries, err) {
198
+ if (err) {
199
+ outStream.destroy(err);
200
+ return;
201
+ }
202
+ const tick = ()=>{
203
+ if (activeAsyncEntries() === 0) {
204
+ outStream.end();
205
+ } else {
206
+ setImmediate(tick);
207
+ }
208
+ };
209
+ tick();
210
+ }
211
+ async function loadMetadata() {
212
+ const backupStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
213
+ _class_private_field_loose_base(this, _metadata)[_metadata] = await _class_private_field_loose_base(this, _parseJSONFile)[_parseJSONFile](backupStream, METADATA_FILE_PATH);
214
+ }
215
+ async function loadAssetMetadata(path) {
216
+ const backupStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
217
+ return _class_private_field_loose_base(this, _parseJSONFile)[_parseJSONFile](backupStream, path);
218
+ }
219
+ function getBackupStream() {
220
+ const { file, encryption, compression } = this.options;
221
+ const streams = [];
222
+ try {
223
+ streams.push(fs__default.createReadStream(file.path));
224
+ } catch (e) {
225
+ throw new Error(`Could not read backup file path provided at "${this.options.file.path}"`);
226
+ }
227
+ if (encryption.enabled && encryption.key) {
228
+ streams.push(createDecryptionCipher(encryption.key));
229
+ }
230
+ if (compression.enabled) {
231
+ streams.push(zip.createGunzip());
232
+ }
233
+ return chain(streams);
234
+ }
235
+ function streamJsonlDirectory(directory) {
236
+ const inStream = _class_private_field_loose_base(this, _getBackupStream)[_getBackupStream]();
237
+ const outStream = new PassThrough({
238
+ objectMode: true
239
+ });
240
+ let activeAsyncEntries = 0;
241
+ const runReadEntry = async (fn)=>{
242
+ activeAsyncEntries += 1;
243
+ try {
244
+ await fn();
245
+ } finally{
246
+ activeAsyncEntries -= 1;
247
+ }
248
+ };
249
+ pipeline([
250
+ inStream,
251
+ new Parser({
252
+ filter (filePath, entry) {
253
+ if (!('type' in entry) || entry.type !== 'File') {
254
+ return false;
255
+ }
256
+ return isFilePathInDirname(directory, filePath);
257
+ },
258
+ async onReadEntry (entry) {
259
+ await runReadEntry(async ()=>{
260
+ const transforms = [
261
+ // JSONL parser to read the data chunks one by one (line by line)
262
+ parser({
263
+ checkErrors: true
264
+ }),
265
+ // The JSONL parser returns each line as key/value
266
+ (line)=>line.value
267
+ ];
268
+ const stream = entry.pipe(chain(transforms));
269
+ try {
270
+ for await (const chunk of stream){
271
+ await write(outStream, chunk);
272
+ }
273
+ } catch (e) {
274
+ outStream.destroy(new ProviderTransferError(`Error parsing backup files from backup file ${entry.path}: ${e.message}`, {
275
+ details: {
276
+ error: e
277
+ }
278
+ }));
279
+ }
280
+ });
281
+ }
282
+ })
283
+ ], (err)=>_class_private_field_loose_base(this, _endPassThroughWhenTarIdle)[_endPassThroughWhenTarIdle](outStream, ()=>activeAsyncEntries, err));
284
+ return outStream;
285
+ }
286
+ async function parseJSONFile(fileStream, filePath) {
287
+ return new Promise((resolve, reject)=>{
288
+ pipeline([
289
+ fileStream,
290
+ // Custom backup archive parsing
291
+ new Parser({
292
+ /**
293
+ * Filter the parsed entries to only keep the one that matches the given filepath
294
+ */ filter (entryPath, entry) {
295
+ if (!('type' in entry) || entry.type !== 'File') {
296
+ return false;
297
+ }
298
+ return isPathEquivalent(entryPath, filePath);
299
+ },
300
+ async onReadEntry (entry) {
301
+ // Collect all the content of the entry stream (ReadEntry has no .collect() in tar v7)
302
+ const chunks = [];
303
+ for await (const chunk of entry){
304
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
305
+ }
306
+ try {
307
+ // Parse from buffer array to string to JSON
308
+ const parsedContent = JSON.parse(Buffer.concat(chunks).toString());
309
+ // Resolve the Promise with the parsed content
310
+ resolve(parsedContent);
311
+ } catch (e) {
312
+ reject(e);
313
+ } finally{
314
+ // Cleanup (close the stream associated to the entry)
315
+ entry.destroy();
316
+ }
317
+ }
318
+ })
319
+ ], ()=>{
320
+ // If the promise hasn't been resolved and we've parsed all
321
+ // the archive entries, then the file doesn't exist
322
+ reject(new Error(`File "${filePath}" not found`));
323
+ });
324
+ });
325
+ }
326
+
327
+ export { createLocalFileSourceProvider };
328
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/file/providers/source/index.ts"],"sourcesContent":["import type { Stats } from 'node:fs';\nimport type { Readable } from 'stream';\n\nimport zip from 'zlib';\nimport path from 'path';\nimport { pipeline, PassThrough } from 'stream';\nimport fs from 'fs-extra';\nimport { Parser, type ReadEntry } from 'tar';\nimport { isEmpty, keyBy } from 'lodash/fp';\nimport { chain } from 'stream-chain';\nimport { parser } from 'stream-json/jsonl/Parser';\nimport type { Struct } from '@strapi/types';\n\nimport type { IAsset, IMetadata, ISourceProvider, ProviderType, IFile } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\n\nimport * as utils from '../../../utils';\nimport { write } from '../../../utils/writable-async-write';\nimport { ProviderInitializationError, ProviderTransferError } from '../../../errors/providers';\nimport { isFilePathInDirname, isPathEquivalent, unknownPathToPosix } from './utils';\n\ntype StreamItemArray = Parameters<typeof chain>[0];\n\n/**\n * Constant for the metadata file path\n */\nconst METADATA_FILE_PATH = 'metadata.json';\n\n/**\n * Provider options\n */\nexport interface ILocalFileSourceProviderOptions {\n file: {\n path: string; // the file to load\n };\n\n encryption: {\n enabled: boolean; // if the file is encrypted (and should be decrypted)\n key?: string; // the key to decrypt the file\n };\n\n compression: {\n enabled: boolean; // if the file is compressed (and should be decompressed)\n };\n}\n\nexport const createLocalFileSourceProvider = (options: ILocalFileSourceProviderOptions) => {\n return new LocalFileSourceProvider(options);\n};\n\nclass LocalFileSourceProvider implements ISourceProvider {\n type: ProviderType = 'source';\n\n name = 'source::local-file';\n\n options: ILocalFileSourceProviderOptions;\n\n #metadata?: IMetadata;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalFileSourceProviderOptions) {\n this.options = options;\n\n const { encryption } = this.options;\n\n if (encryption.enabled && encryption.key === undefined) {\n throw new Error('Missing encryption key');\n }\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'file-source-provider',\n },\n kind: 'info',\n });\n }\n\n /**\n * tar `Parser` invokes the pipeline completion callback when the archive ends, but it does not\n * reliably await async `onReadEntry` — defer `end` until outstanding async entry work is done.\n */\n #endPassThroughWhenTarIdle(\n outStream: PassThrough,\n activeAsyncEntries: () => number,\n err?: Error | null\n ) {\n if (err) {\n outStream.destroy(err);\n return;\n }\n const tick = () => {\n if (activeAsyncEntries() === 0) {\n outStream.end();\n } else {\n setImmediate(tick);\n }\n };\n tick();\n }\n\n /**\n * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.\n */\n async bootstrap(diagnostics: IDiagnosticReporter) {\n this.#diagnostics = diagnostics;\n const { path: filePath } = this.options.file;\n\n try {\n // Read the metadata to ensure the file can be parsed\n await this.#loadMetadata();\n // TODO: we might also need to read the schema.jsonl files & implements a custom stream-check\n } catch (e) {\n if (this.options?.encryption?.enabled) {\n throw new ProviderInitializationError(\n `Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`\n );\n }\n throw new ProviderInitializationError(`File '${filePath}' is not a valid Strapi data file.`);\n }\n\n if (!this.#metadata) {\n throw new ProviderInitializationError('Could not load metadata from Strapi data file.');\n }\n }\n\n async #loadMetadata() {\n const backupStream = this.#getBackupStream();\n this.#metadata = await this.#parseJSONFile<IMetadata>(backupStream, METADATA_FILE_PATH);\n }\n\n async #loadAssetMetadata(path: string) {\n const backupStream = this.#getBackupStream();\n return this.#parseJSONFile<IFile>(backupStream, path);\n }\n\n async getMetadata() {\n this.#reportInfo('getting metadata');\n if (!this.#metadata) {\n await this.#loadMetadata();\n }\n\n return this.#metadata ?? null;\n }\n\n async getSchemas() {\n this.#reportInfo('getting schemas');\n const schemaCollection = await utils.stream.collect<Struct.Schema>(\n this.createSchemasReadStream()\n );\n\n if (isEmpty(schemaCollection)) {\n throw new ProviderInitializationError('Could not load schemas from Strapi data file.');\n }\n\n // Group schema by UID\n const schemas = keyBy('uid', schemaCollection);\n\n // Transform to valid JSON\n return utils.schema.schemasToValidJSON(schemas);\n }\n\n createEntitiesReadStream(): Readable {\n this.#reportInfo('creating entities read stream');\n return this.#streamJsonlDirectory('entities');\n }\n\n createSchemasReadStream(): Readable {\n this.#reportInfo('creating schemas read stream');\n return this.#streamJsonlDirectory('schemas');\n }\n\n createLinksReadStream(): Readable {\n this.#reportInfo('creating links read stream');\n return this.#streamJsonlDirectory('links');\n }\n\n createConfigurationReadStream(): Readable {\n this.#reportInfo('creating configuration read stream');\n // NOTE: TBD\n return this.#streamJsonlDirectory('configuration');\n }\n\n createAssetsReadStream(): Readable | Promise<Readable> {\n const inStream = this.#getBackupStream();\n const outStream = new PassThrough({ objectMode: true });\n const loadAssetMetadata = this.#loadAssetMetadata.bind(this);\n this.#reportInfo('creating assets read stream');\n\n let activeAsyncEntries = 0;\n const runReadEntry = async (fn: () => Promise<void>) => {\n activeAsyncEntries += 1;\n try {\n await fn();\n } finally {\n activeAsyncEntries -= 1;\n }\n };\n\n pipeline(\n [\n inStream,\n new Parser({\n // find only files in the assets/uploads folder\n filter(filePath: string, entry: Stats | ReadEntry) {\n if (!('type' in entry) || entry.type !== 'File') {\n return false;\n }\n return isFilePathInDirname('assets/uploads', filePath);\n },\n async onReadEntry(entry: ReadEntry) {\n await runReadEntry(async () => {\n const { path: filePath, size = 0 } = entry;\n const normalizedPath = unknownPathToPosix(filePath);\n const file = path.basename(normalizedPath);\n let metadata;\n try {\n metadata = await loadAssetMetadata(`assets/metadata/${file}.json`);\n } catch (error) {\n throw new Error(`Failed to read metadata for ${file}`);\n }\n const asset: IAsset = {\n metadata,\n filename: file,\n filepath: normalizedPath,\n stats: { size },\n stream: entry as unknown as Readable,\n };\n await write(outStream, asset);\n });\n },\n }),\n ],\n (err) => this.#endPassThroughWhenTarIdle(outStream, () => activeAsyncEntries, err)\n );\n\n return outStream;\n }\n\n #getBackupStream() {\n const { file, encryption, compression } = this.options;\n\n const streams: StreamItemArray = [];\n\n try {\n streams.push(fs.createReadStream(file.path));\n } catch (e) {\n throw new Error(`Could not read backup file path provided at \"${this.options.file.path}\"`);\n }\n\n if (encryption.enabled && encryption.key) {\n streams.push(utils.encryption.createDecryptionCipher(encryption.key));\n }\n\n if (compression.enabled) {\n streams.push(zip.createGunzip());\n }\n\n return chain(streams);\n }\n\n // `directory` must be posix formatted path\n #streamJsonlDirectory(directory: string) {\n const inStream = this.#getBackupStream();\n\n const outStream = new PassThrough({ objectMode: true });\n\n let activeAsyncEntries = 0;\n const runReadEntry = async (fn: () => Promise<void>) => {\n activeAsyncEntries += 1;\n try {\n await fn();\n } finally {\n activeAsyncEntries -= 1;\n }\n };\n\n pipeline(\n [\n inStream,\n new Parser({\n filter(filePath: string, entry: Stats | ReadEntry) {\n if (!('type' in entry) || entry.type !== 'File') {\n return false;\n }\n\n return isFilePathInDirname(directory, filePath);\n },\n\n async onReadEntry(entry: ReadEntry) {\n await runReadEntry(async () => {\n const transforms = [\n // JSONL parser to read the data chunks one by one (line by line)\n parser({\n checkErrors: true,\n }),\n // The JSONL parser returns each line as key/value\n (line: { key: string; value: object }) => line.value,\n ];\n\n const stream = entry.pipe(chain(transforms));\n\n try {\n for await (const chunk of stream) {\n await write(outStream, chunk);\n }\n } catch (e: unknown) {\n outStream.destroy(\n new ProviderTransferError(\n `Error parsing backup files from backup file ${entry.path}: ${\n (e as Error).message\n }`,\n {\n details: {\n error: e,\n },\n }\n )\n );\n }\n });\n },\n }),\n ],\n (err) => this.#endPassThroughWhenTarIdle(outStream, () => activeAsyncEntries, err)\n );\n\n return outStream;\n }\n\n // For collecting an entire JSON file then parsing it, not for streaming JSONL\n async #parseJSONFile<T extends object>(fileStream: Readable, filePath: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n pipeline(\n [\n fileStream,\n // Custom backup archive parsing\n new Parser({\n /**\n * Filter the parsed entries to only keep the one that matches the given filepath\n */\n filter(entryPath: string, entry: Stats | ReadEntry) {\n if (!('type' in entry) || entry.type !== 'File') {\n return false;\n }\n\n return isPathEquivalent(entryPath, filePath);\n },\n\n async onReadEntry(entry: ReadEntry) {\n // Collect all the content of the entry stream (ReadEntry has no .collect() in tar v7)\n const chunks: Buffer[] = [];\n for await (const chunk of entry) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n\n try {\n // Parse from buffer array to string to JSON\n const parsedContent = JSON.parse(Buffer.concat(chunks).toString());\n\n // Resolve the Promise with the parsed content\n resolve(parsedContent);\n } catch (e) {\n reject(e);\n } finally {\n // Cleanup (close the stream associated to the entry)\n entry.destroy();\n }\n },\n }),\n ],\n () => {\n // If the promise hasn't been resolved and we've parsed all\n // the archive entries, then the file doesn't exist\n reject(new Error(`File \"${filePath}\" not found`));\n }\n );\n });\n }\n}\n"],"names":["METADATA_FILE_PATH","createLocalFileSourceProvider","options","LocalFileSourceProvider","bootstrap","diagnostics","path","filePath","file","e","encryption","enabled","ProviderInitializationError","getMetadata","getSchemas","schemaCollection","utils","createSchemasReadStream","isEmpty","schemas","keyBy","createEntitiesReadStream","createLinksReadStream","createConfigurationReadStream","createAssetsReadStream","inStream","outStream","PassThrough","objectMode","loadAssetMetadata","bind","activeAsyncEntries","runReadEntry","fn","pipeline","Parser","filter","entry","type","isFilePathInDirname","onReadEntry","size","normalizedPath","unknownPathToPosix","basename","metadata","error","Error","asset","filename","filepath","stats","stream","write","err","name","key","undefined","message","report","details","createdAt","Date","origin","kind","destroy","tick","end","setImmediate","backupStream","compression","streams","push","fs","createReadStream","zip","createGunzip","chain","directory","transforms","parser","checkErrors","line","value","pipe","chunk","ProviderTransferError","fileStream","Promise","resolve","reject","entryPath","isPathEquivalent","chunks","Buffer","isBuffer","from","parsedContent","JSON","parse","concat","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;AAEC,IACD,MAAMA,kBAAAA,GAAqB,eAAA;AAoBpB,MAAMC,gCAAgC,CAACC,OAAAA,GAAAA;AAC5C,IAAA,OAAO,IAAIC,uBAAAA,CAAwBD,OAAAA,CAAAA;AACrC;AASE,IAAA,SAAA,iBAAA,8BAAA,CAAA,WAAA,CAAA,EAEA,6EAYA,WAAA,iBAAA,8BAAA,CAAA,aAAA,CAAA;;;AAcC,MACD,0BAAA,iBAAA,8BAAA,CAAA,4BAAA,CAAA,EA4CM,aAAA,iBAAA,8BAAA,CAAA,eAAA,CAAA,EAKA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA,EA4GN,gBAAA,iBAAA,8BAAA,CAAA,kBAAA,CAAA;AAuBA,qBAAA,iBAAA,8BAAA,CAAA,uBAAA,CAAA,EAqEM,cAAA,iBAAA,8BAAA,CAAA,gBAAA,CAAA;AA7RR,MAAMC,uBAAAA,CAAAA;AAuDJ;;MAGA,MAAMC,SAAAA,CAAUC,WAAgC,EAAE;QAChD,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;QACpB,MAAM,EAAEC,MAAMC,QAAQ,EAAE,GAAG,IAAI,CAACL,OAAO,CAACM,IAAI;QAE5C,IAAI;;YAEF,MAAM,+BAAA,CAAA,IAAI,EAAC,aAAA,CAAA,CAAA,aAAA,CAAA,EAAA;;AAEb,QAAA,CAAA,CAAE,OAAOC,CAAAA,EAAG;AACV,YAAA,IAAI,IAAI,CAACP,OAAO,EAAEQ,YAAYC,OAAAA,EAAS;AACrC,gBAAA,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;;AAER4B,wBAAAA,KAAAA,CAAM4B,OAAO,EAAA;AACf,oBAAA;AACF,gBAAA;AACF,aAAA;SACD,EACD,IAAA;;;AAGEyB,YAAAA,MAAAA,CAAO,IAAI3C,KAAAA,CAAM,CAAC,MAAM,EAAExC,QAAAA,CAAS,WAAW,CAAC,CAAA,CAAA;AACjD,QAAA,CAAA,CAAA;AAEJ,IAAA,CAAA,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/source/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;KAUK;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,YAAY,MAAM,YAGzE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,SAAS,MAAM,YAM5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,WAOlD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/source/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;KAUK;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM,EAAE,UAAU,MAAM,YAGzE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,YAM5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,WAOlD,CAAC"}
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var path__default = /*#__PURE__*/_interopDefault(path);
8
+
9
+ /**
10
+ * Note: in versions of the transfer engine <=4.9.0, exports were generated with windows paths
11
+ * on Windows systems, and posix paths on posix systems.
12
+ *
13
+ * We now store all paths as posix, but need to leave a separator conversion for legacy purposes, and to
14
+ * support manually-created tar files coming from Windows systems (ie, if a user creates a
15
+ * backup file with a windows tar tool rather than using the `export` command)
16
+ *
17
+ * Because of this, export/import files may never contain files with a forward slash in the name, even escaped
18
+ *
19
+ * */ /**
20
+ * Check if the directory of a given filePath (which can be either posix or win32) resolves to the same as the given posix-format path posixDirName
21
+ * We must be able to assume the first argument is a path to a directory and the second is a path to a file, otherwise path.dirname will interpret a path without any slashes as the filename
22
+ *
23
+ * @param {string} posixDirName A posix path pointing to a directory
24
+ * @param {string} filePath an unknown filesystem path pointing to a file
25
+ * @returns {boolean} is the file located in the given directory
26
+ */ const isFilePathInDirname = (posixDirName, filePath)=>{
27
+ const normalizedDir = path__default.default.posix.dirname(unknownPathToPosix(filePath));
28
+ return isPathEquivalent(posixDirName, normalizedDir);
29
+ };
30
+ /**
31
+ * Check if two paths that can be either in posix or win32 format resolves to the same file
32
+ *
33
+ * @param {string} pathA a path that may be either win32 or posix
34
+ * @param {string} pathB a path that may be either win32 or posix
35
+ *
36
+ * @returns {boolean} do paths point to the same place
37
+ */ const isPathEquivalent = (pathA, pathB)=>{
38
+ // Check if paths appear to be win32 or posix, and if win32 convert to posix
39
+ const normalizedPathA = path__default.default.posix.normalize(unknownPathToPosix(pathA));
40
+ const normalizedPathB = path__default.default.posix.normalize(unknownPathToPosix(pathB));
41
+ return !path__default.default.posix.relative(normalizedPathB, normalizedPathA).length;
42
+ };
43
+ /**
44
+ * Convert an unknown format path (win32 or posix) to a posix path
45
+ *
46
+ * @param {string} filePath a path that may be either win32 or posix
47
+ *
48
+ * @returns {string} a posix path
49
+ */ const unknownPathToPosix = (filePath)=>{
50
+ // if it includes a forward slash, it must be posix already -- we will not support win32 with mixed path separators
51
+ if (filePath.includes(path__default.default.posix.sep)) {
52
+ return filePath;
53
+ }
54
+ return path__default.default.normalize(filePath).split(path__default.default.win32.sep).join(path__default.default.posix.sep);
55
+ };
56
+
57
+ exports.isFilePathInDirname = isFilePathInDirname;
58
+ exports.isPathEquivalent = isPathEquivalent;
59
+ exports.unknownPathToPosix = unknownPathToPosix;
60
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/file/providers/source/utils.ts"],"sourcesContent":["import path from 'path';\n\n/**\n * Note: in versions of the transfer engine <=4.9.0, exports were generated with windows paths\n * on Windows systems, and posix paths on posix systems.\n *\n * We now store all paths as posix, but need to leave a separator conversion for legacy purposes, and to\n * support manually-created tar files coming from Windows systems (ie, if a user creates a\n * backup file with a windows tar tool rather than using the `export` command)\n *\n * Because of this, export/import files may never contain files with a forward slash in the name, even escaped\n *\n * */\n\n/**\n * Check if the directory of a given filePath (which can be either posix or win32) resolves to the same as the given posix-format path posixDirName\n * We must be able to assume the first argument is a path to a directory and the second is a path to a file, otherwise path.dirname will interpret a path without any slashes as the filename\n *\n * @param {string} posixDirName A posix path pointing to a directory\n * @param {string} filePath an unknown filesystem path pointing to a file\n * @returns {boolean} is the file located in the given directory\n */\nexport const isFilePathInDirname = (posixDirName: string, filePath: string) => {\n const normalizedDir = path.posix.dirname(unknownPathToPosix(filePath));\n return isPathEquivalent(posixDirName, normalizedDir);\n};\n\n/**\n * Check if two paths that can be either in posix or win32 format resolves to the same file\n *\n * @param {string} pathA a path that may be either win32 or posix\n * @param {string} pathB a path that may be either win32 or posix\n *\n * @returns {boolean} do paths point to the same place\n */\nexport const isPathEquivalent = (pathA: string, pathB: string) => {\n // Check if paths appear to be win32 or posix, and if win32 convert to posix\n const normalizedPathA = path.posix.normalize(unknownPathToPosix(pathA));\n const normalizedPathB = path.posix.normalize(unknownPathToPosix(pathB));\n\n return !path.posix.relative(normalizedPathB, normalizedPathA).length;\n};\n\n/**\n * Convert an unknown format path (win32 or posix) to a posix path\n *\n * @param {string} filePath a path that may be either win32 or posix\n *\n * @returns {string} a posix path\n */\nexport const unknownPathToPosix = (filePath: string) => {\n // if it includes a forward slash, it must be posix already -- we will not support win32 with mixed path separators\n if (filePath.includes(path.posix.sep)) {\n return filePath;\n }\n\n return path.normalize(filePath).split(path.win32.sep).join(path.posix.sep);\n};\n"],"names":["isFilePathInDirname","posixDirName","filePath","normalizedDir","path","posix","dirname","unknownPathToPosix","isPathEquivalent","pathA","pathB","normalizedPathA","normalize","normalizedPathB","relative","length","includes","sep","split","win32","join"],"mappings":";;;;;;;;AAEA;;;;;;;;;;;;;;;;;AAmBC,IACM,MAAMA,mBAAAA,GAAsB,CAACC,YAAAA,EAAsBC,QAAAA,GAAAA;AACxD,IAAA,MAAMC,gBAAgBC,qBAAAA,CAAKC,KAAK,CAACC,OAAO,CAACC,kBAAAA,CAAmBL,QAAAA,CAAAA,CAAAA;AAC5D,IAAA,OAAOM,iBAAiBP,YAAAA,EAAcE,aAAAA,CAAAA;AACxC;AAEA;;;;;;;AAOC,IACM,MAAMK,gBAAAA,GAAmB,CAACC,KAAAA,EAAeC,KAAAA,GAAAA;;AAE9C,IAAA,MAAMC,kBAAkBP,qBAAAA,CAAKC,KAAK,CAACO,SAAS,CAACL,kBAAAA,CAAmBE,KAAAA,CAAAA,CAAAA;AAChE,IAAA,MAAMI,kBAAkBT,qBAAAA,CAAKC,KAAK,CAACO,SAAS,CAACL,kBAAAA,CAAmBG,KAAAA,CAAAA,CAAAA;IAEhE,OAAO,CAACN,sBAAKC,KAAK,CAACS,QAAQ,CAACD,eAAAA,EAAiBF,iBAAiBI,MAAM;AACtE;AAEA;;;;;;IAOO,MAAMR,kBAAAA,GAAqB,CAACL,QAAAA,GAAAA;;AAEjC,IAAA,IAAIA,SAASc,QAAQ,CAACZ,sBAAKC,KAAK,CAACY,GAAG,CAAA,EAAG;QACrC,OAAOf,QAAAA;AACT,IAAA;AAEA,IAAA,OAAOE,sBAAKQ,SAAS,CAACV,QAAAA,CAAAA,CAAUgB,KAAK,CAACd,qBAAAA,CAAKe,KAAK,CAACF,GAAG,EAAEG,IAAI,CAAChB,qBAAAA,CAAKC,KAAK,CAACY,GAAG,CAAA;AAC3E;;;;;;"}
@@ -0,0 +1,52 @@
1
+ import path from 'path';
2
+
3
+ /**
4
+ * Note: in versions of the transfer engine <=4.9.0, exports were generated with windows paths
5
+ * on Windows systems, and posix paths on posix systems.
6
+ *
7
+ * We now store all paths as posix, but need to leave a separator conversion for legacy purposes, and to
8
+ * support manually-created tar files coming from Windows systems (ie, if a user creates a
9
+ * backup file with a windows tar tool rather than using the `export` command)
10
+ *
11
+ * Because of this, export/import files may never contain files with a forward slash in the name, even escaped
12
+ *
13
+ * */ /**
14
+ * Check if the directory of a given filePath (which can be either posix or win32) resolves to the same as the given posix-format path posixDirName
15
+ * We must be able to assume the first argument is a path to a directory and the second is a path to a file, otherwise path.dirname will interpret a path without any slashes as the filename
16
+ *
17
+ * @param {string} posixDirName A posix path pointing to a directory
18
+ * @param {string} filePath an unknown filesystem path pointing to a file
19
+ * @returns {boolean} is the file located in the given directory
20
+ */ const isFilePathInDirname = (posixDirName, filePath)=>{
21
+ const normalizedDir = path.posix.dirname(unknownPathToPosix(filePath));
22
+ return isPathEquivalent(posixDirName, normalizedDir);
23
+ };
24
+ /**
25
+ * Check if two paths that can be either in posix or win32 format resolves to the same file
26
+ *
27
+ * @param {string} pathA a path that may be either win32 or posix
28
+ * @param {string} pathB a path that may be either win32 or posix
29
+ *
30
+ * @returns {boolean} do paths point to the same place
31
+ */ const isPathEquivalent = (pathA, pathB)=>{
32
+ // Check if paths appear to be win32 or posix, and if win32 convert to posix
33
+ const normalizedPathA = path.posix.normalize(unknownPathToPosix(pathA));
34
+ const normalizedPathB = path.posix.normalize(unknownPathToPosix(pathB));
35
+ return !path.posix.relative(normalizedPathB, normalizedPathA).length;
36
+ };
37
+ /**
38
+ * Convert an unknown format path (win32 or posix) to a posix path
39
+ *
40
+ * @param {string} filePath a path that may be either win32 or posix
41
+ *
42
+ * @returns {string} a posix path
43
+ */ const unknownPathToPosix = (filePath)=>{
44
+ // if it includes a forward slash, it must be posix already -- we will not support win32 with mixed path separators
45
+ if (filePath.includes(path.posix.sep)) {
46
+ return filePath;
47
+ }
48
+ return path.normalize(filePath).split(path.win32.sep).join(path.posix.sep);
49
+ };
50
+
51
+ export { isFilePathInDirname, isPathEquivalent, unknownPathToPosix };
52
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../../../src/file/providers/source/utils.ts"],"sourcesContent":["import path from 'path';\n\n/**\n * Note: in versions of the transfer engine <=4.9.0, exports were generated with windows paths\n * on Windows systems, and posix paths on posix systems.\n *\n * We now store all paths as posix, but need to leave a separator conversion for legacy purposes, and to\n * support manually-created tar files coming from Windows systems (ie, if a user creates a\n * backup file with a windows tar tool rather than using the `export` command)\n *\n * Because of this, export/import files may never contain files with a forward slash in the name, even escaped\n *\n * */\n\n/**\n * Check if the directory of a given filePath (which can be either posix or win32) resolves to the same as the given posix-format path posixDirName\n * We must be able to assume the first argument is a path to a directory and the second is a path to a file, otherwise path.dirname will interpret a path without any slashes as the filename\n *\n * @param {string} posixDirName A posix path pointing to a directory\n * @param {string} filePath an unknown filesystem path pointing to a file\n * @returns {boolean} is the file located in the given directory\n */\nexport const isFilePathInDirname = (posixDirName: string, filePath: string) => {\n const normalizedDir = path.posix.dirname(unknownPathToPosix(filePath));\n return isPathEquivalent(posixDirName, normalizedDir);\n};\n\n/**\n * Check if two paths that can be either in posix or win32 format resolves to the same file\n *\n * @param {string} pathA a path that may be either win32 or posix\n * @param {string} pathB a path that may be either win32 or posix\n *\n * @returns {boolean} do paths point to the same place\n */\nexport const isPathEquivalent = (pathA: string, pathB: string) => {\n // Check if paths appear to be win32 or posix, and if win32 convert to posix\n const normalizedPathA = path.posix.normalize(unknownPathToPosix(pathA));\n const normalizedPathB = path.posix.normalize(unknownPathToPosix(pathB));\n\n return !path.posix.relative(normalizedPathB, normalizedPathA).length;\n};\n\n/**\n * Convert an unknown format path (win32 or posix) to a posix path\n *\n * @param {string} filePath a path that may be either win32 or posix\n *\n * @returns {string} a posix path\n */\nexport const unknownPathToPosix = (filePath: string) => {\n // if it includes a forward slash, it must be posix already -- we will not support win32 with mixed path separators\n if (filePath.includes(path.posix.sep)) {\n return filePath;\n }\n\n return path.normalize(filePath).split(path.win32.sep).join(path.posix.sep);\n};\n"],"names":["isFilePathInDirname","posixDirName","filePath","normalizedDir","path","posix","dirname","unknownPathToPosix","isPathEquivalent","pathA","pathB","normalizedPathA","normalize","normalizedPathB","relative","length","includes","sep","split","win32","join"],"mappings":";;AAEA;;;;;;;;;;;;;;;;;AAmBC,IACM,MAAMA,mBAAAA,GAAsB,CAACC,YAAAA,EAAsBC,QAAAA,GAAAA;AACxD,IAAA,MAAMC,gBAAgBC,IAAAA,CAAKC,KAAK,CAACC,OAAO,CAACC,kBAAAA,CAAmBL,QAAAA,CAAAA,CAAAA;AAC5D,IAAA,OAAOM,iBAAiBP,YAAAA,EAAcE,aAAAA,CAAAA;AACxC;AAEA;;;;;;;AAOC,IACM,MAAMK,gBAAAA,GAAmB,CAACC,KAAAA,EAAeC,KAAAA,GAAAA;;AAE9C,IAAA,MAAMC,kBAAkBP,IAAAA,CAAKC,KAAK,CAACO,SAAS,CAACL,kBAAAA,CAAmBE,KAAAA,CAAAA,CAAAA;AAChE,IAAA,MAAMI,kBAAkBT,IAAAA,CAAKC,KAAK,CAACO,SAAS,CAACL,kBAAAA,CAAmBG,KAAAA,CAAAA,CAAAA;IAEhE,OAAO,CAACN,KAAKC,KAAK,CAACS,QAAQ,CAACD,eAAAA,EAAiBF,iBAAiBI,MAAM;AACtE;AAEA;;;;;;IAOO,MAAMR,kBAAAA,GAAqB,CAACL,QAAAA,GAAAA;;AAEjC,IAAA,IAAIA,SAASc,QAAQ,CAACZ,KAAKC,KAAK,CAACY,GAAG,CAAA,EAAG;QACrC,OAAOf,QAAAA;AACT,IAAA;AAEA,IAAA,OAAOE,KAAKQ,SAAS,CAACV,QAAAA,CAAAA,CAAUgB,KAAK,CAACd,IAAAA,CAAKe,KAAK,CAACF,GAAG,EAAEG,IAAI,CAAChB,IAAAA,CAAKC,KAAK,CAACY,GAAG,CAAA;AAC3E;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as engine from './engine';
2
2
  export * as strapi from './strapi';
3
3
  export * as file from './file';
4
+ export * as directory from './directory';
4
5
  export * as utils from './utils';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}