@backblaze-labs/b2-sdk 0.1.0

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 (512) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +21 -0
  3. package/README.md +664 -0
  4. package/dist/auth/account-info.d.cts +51 -0
  5. package/dist/auth/account-info.d.cts.map +1 -0
  6. package/dist/auth/account-info.d.ts +51 -0
  7. package/dist/auth/account-info.d.ts.map +1 -0
  8. package/dist/auth/file.cjs +210 -0
  9. package/dist/auth/file.cjs.map +1 -0
  10. package/dist/auth/file.d.cts +157 -0
  11. package/dist/auth/file.d.cts.map +1 -0
  12. package/dist/auth/file.d.ts +157 -0
  13. package/dist/auth/file.d.ts.map +1 -0
  14. package/dist/auth/file.js +210 -0
  15. package/dist/auth/file.js.map +1 -0
  16. package/dist/auth/in-memory.cjs +184 -0
  17. package/dist/auth/in-memory.cjs.map +1 -0
  18. package/dist/auth/in-memory.d.cts +147 -0
  19. package/dist/auth/in-memory.d.cts.map +1 -0
  20. package/dist/auth/in-memory.d.ts +147 -0
  21. package/dist/auth/in-memory.d.ts.map +1 -0
  22. package/dist/auth/in-memory.js +184 -0
  23. package/dist/auth/in-memory.js.map +1 -0
  24. package/dist/auth/index.cjs +10 -0
  25. package/dist/auth/index.cjs.map +1 -0
  26. package/dist/auth/index.d.cts +6 -0
  27. package/dist/auth/index.d.cts.map +1 -0
  28. package/dist/auth/index.d.ts +6 -0
  29. package/dist/auth/index.d.ts.map +1 -0
  30. package/dist/auth/index.js +10 -0
  31. package/dist/auth/index.js.map +1 -0
  32. package/dist/auth/realms.cjs +12 -0
  33. package/dist/auth/realms.cjs.map +1 -0
  34. package/dist/auth/realms.d.cts +12 -0
  35. package/dist/auth/realms.d.cts.map +1 -0
  36. package/dist/auth/realms.d.ts +12 -0
  37. package/dist/auth/realms.d.ts.map +1 -0
  38. package/dist/auth/realms.js +12 -0
  39. package/dist/auth/realms.js.map +1 -0
  40. package/dist/auth/upload-url-pool.cjs +52 -0
  41. package/dist/auth/upload-url-pool.cjs.map +1 -0
  42. package/dist/auth/upload-url-pool.d.cts +35 -0
  43. package/dist/auth/upload-url-pool.d.cts.map +1 -0
  44. package/dist/auth/upload-url-pool.d.ts +35 -0
  45. package/dist/auth/upload-url-pool.d.ts.map +1 -0
  46. package/dist/auth/upload-url-pool.js +52 -0
  47. package/dist/auth/upload-url-pool.js.map +1 -0
  48. package/dist/bucket.cjs +789 -0
  49. package/dist/bucket.cjs.map +1 -0
  50. package/dist/bucket.d.cts +659 -0
  51. package/dist/bucket.d.cts.map +1 -0
  52. package/dist/bucket.d.ts +659 -0
  53. package/dist/bucket.d.ts.map +1 -0
  54. package/dist/bucket.js +789 -0
  55. package/dist/bucket.js.map +1 -0
  56. package/dist/client.cjs +230 -0
  57. package/dist/client.cjs.map +1 -0
  58. package/dist/client.d.cts +222 -0
  59. package/dist/client.d.cts.map +1 -0
  60. package/dist/client.d.ts +222 -0
  61. package/dist/client.d.ts.map +1 -0
  62. package/dist/client.js +230 -0
  63. package/dist/client.js.map +1 -0
  64. package/dist/copy/large.cjs +74 -0
  65. package/dist/copy/large.cjs.map +1 -0
  66. package/dist/copy/large.d.cts +53 -0
  67. package/dist/copy/large.d.cts.map +1 -0
  68. package/dist/copy/large.d.ts +53 -0
  69. package/dist/copy/large.d.ts.map +1 -0
  70. package/dist/copy/large.js +74 -0
  71. package/dist/copy/large.js.map +1 -0
  72. package/dist/download/parallel.cjs +122 -0
  73. package/dist/download/parallel.cjs.map +1 -0
  74. package/dist/download/parallel.d.cts +42 -0
  75. package/dist/download/parallel.d.cts.map +1 -0
  76. package/dist/download/parallel.d.ts +42 -0
  77. package/dist/download/parallel.d.ts.map +1 -0
  78. package/dist/download/parallel.js +122 -0
  79. package/dist/download/parallel.js.map +1 -0
  80. package/dist/download/single.cjs +117 -0
  81. package/dist/download/single.cjs.map +1 -0
  82. package/dist/download/single.d.cts +152 -0
  83. package/dist/download/single.d.cts.map +1 -0
  84. package/dist/download/single.d.ts +152 -0
  85. package/dist/download/single.d.ts.map +1 -0
  86. package/dist/download/single.js +117 -0
  87. package/dist/download/single.js.map +1 -0
  88. package/dist/errors/index.cjs +268 -0
  89. package/dist/errors/index.cjs.map +1 -0
  90. package/dist/errors/index.d.cts +264 -0
  91. package/dist/errors/index.d.cts.map +1 -0
  92. package/dist/errors/index.d.ts +264 -0
  93. package/dist/errors/index.d.ts.map +1 -0
  94. package/dist/errors/index.js +268 -0
  95. package/dist/errors/index.js.map +1 -0
  96. package/dist/http/retry.cjs +36 -0
  97. package/dist/http/retry.cjs.map +1 -0
  98. package/dist/http/retry.d.cts +34 -0
  99. package/dist/http/retry.d.cts.map +1 -0
  100. package/dist/http/retry.d.ts +34 -0
  101. package/dist/http/retry.d.ts.map +1 -0
  102. package/dist/http/retry.js +36 -0
  103. package/dist/http/retry.js.map +1 -0
  104. package/dist/http/transport.cjs +143 -0
  105. package/dist/http/transport.cjs.map +1 -0
  106. package/dist/http/transport.d.cts +122 -0
  107. package/dist/http/transport.d.cts.map +1 -0
  108. package/dist/http/transport.d.ts +122 -0
  109. package/dist/http/transport.d.ts.map +1 -0
  110. package/dist/http/transport.js +143 -0
  111. package/dist/http/transport.js.map +1 -0
  112. package/dist/http/url-guard.cjs +97 -0
  113. package/dist/http/url-guard.cjs.map +1 -0
  114. package/dist/http/url-guard.d.cts +88 -0
  115. package/dist/http/url-guard.d.cts.map +1 -0
  116. package/dist/http/url-guard.d.ts +88 -0
  117. package/dist/http/url-guard.d.ts.map +1 -0
  118. package/dist/http/url-guard.js +97 -0
  119. package/dist/http/url-guard.js.map +1 -0
  120. package/dist/http/user-agent.cjs +51 -0
  121. package/dist/http/user-agent.cjs.map +1 -0
  122. package/dist/http/user-agent.d.cts +28 -0
  123. package/dist/http/user-agent.d.cts.map +1 -0
  124. package/dist/http/user-agent.d.ts +28 -0
  125. package/dist/http/user-agent.d.ts.map +1 -0
  126. package/dist/http/user-agent.js +51 -0
  127. package/dist/http/user-agent.js.map +1 -0
  128. package/dist/index.cjs +78 -0
  129. package/dist/index.cjs.map +1 -0
  130. package/dist/index.d.cts +39 -0
  131. package/dist/index.d.cts.map +1 -0
  132. package/dist/index.d.ts +39 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +78 -0
  135. package/dist/index.js.map +1 -0
  136. package/dist/notifications/index.cjs +7 -0
  137. package/dist/notifications/index.cjs.map +1 -0
  138. package/dist/notifications/index.d.cts +3 -0
  139. package/dist/notifications/index.d.cts.map +1 -0
  140. package/dist/notifications/index.d.ts +3 -0
  141. package/dist/notifications/index.d.ts.map +1 -0
  142. package/dist/notifications/index.js +7 -0
  143. package/dist/notifications/index.js.map +1 -0
  144. package/dist/notifications/webhook.cjs +106 -0
  145. package/dist/notifications/webhook.cjs.map +1 -0
  146. package/dist/notifications/webhook.d.cts +146 -0
  147. package/dist/notifications/webhook.d.cts.map +1 -0
  148. package/dist/notifications/webhook.d.ts +146 -0
  149. package/dist/notifications/webhook.d.ts.map +1 -0
  150. package/dist/notifications/webhook.js +106 -0
  151. package/dist/notifications/webhook.js.map +1 -0
  152. package/dist/object.cjs +212 -0
  153. package/dist/object.cjs.map +1 -0
  154. package/dist/object.d.cts +263 -0
  155. package/dist/object.d.cts.map +1 -0
  156. package/dist/object.d.ts +263 -0
  157. package/dist/object.d.ts.map +1 -0
  158. package/dist/object.js +212 -0
  159. package/dist/object.js.map +1 -0
  160. package/dist/package.json.cjs +9 -0
  161. package/dist/package.json.cjs.map +1 -0
  162. package/dist/package.json.js +9 -0
  163. package/dist/package.json.js.map +1 -0
  164. package/dist/raw/encoding.cjs +47 -0
  165. package/dist/raw/encoding.cjs.map +1 -0
  166. package/dist/raw/encoding.d.cts +46 -0
  167. package/dist/raw/encoding.d.cts.map +1 -0
  168. package/dist/raw/encoding.d.ts +46 -0
  169. package/dist/raw/encoding.d.ts.map +1 -0
  170. package/dist/raw/encoding.js +47 -0
  171. package/dist/raw/encoding.js.map +1 -0
  172. package/dist/raw/index.cjs +600 -0
  173. package/dist/raw/index.cjs.map +1 -0
  174. package/dist/raw/index.d.cts +381 -0
  175. package/dist/raw/index.d.cts.map +1 -0
  176. package/dist/raw/index.d.ts +381 -0
  177. package/dist/raw/index.d.ts.map +1 -0
  178. package/dist/raw/index.js +601 -0
  179. package/dist/raw/index.js.map +1 -0
  180. package/dist/s3/index.cjs +23 -0
  181. package/dist/s3/index.cjs.map +1 -0
  182. package/dist/s3/index.d.cts +74 -0
  183. package/dist/s3/index.d.cts.map +1 -0
  184. package/dist/s3/index.d.ts +74 -0
  185. package/dist/s3/index.d.ts.map +1 -0
  186. package/dist/s3/index.js +23 -0
  187. package/dist/s3/index.js.map +1 -0
  188. package/dist/simulator/capabilities.cjs +53 -0
  189. package/dist/simulator/capabilities.cjs.map +1 -0
  190. package/dist/simulator/capabilities.d.cts +15 -0
  191. package/dist/simulator/capabilities.d.cts.map +1 -0
  192. package/dist/simulator/capabilities.d.ts +15 -0
  193. package/dist/simulator/capabilities.d.ts.map +1 -0
  194. package/dist/simulator/capabilities.js +53 -0
  195. package/dist/simulator/capabilities.js.map +1 -0
  196. package/dist/simulator/index.cjs +1559 -0
  197. package/dist/simulator/index.cjs.map +1 -0
  198. package/dist/simulator/index.d.cts +495 -0
  199. package/dist/simulator/index.d.cts.map +1 -0
  200. package/dist/simulator/index.d.ts +495 -0
  201. package/dist/simulator/index.d.ts.map +1 -0
  202. package/dist/simulator/index.js +1560 -0
  203. package/dist/simulator/index.js.map +1 -0
  204. package/dist/simulator/validation.cjs +174 -0
  205. package/dist/simulator/validation.cjs.map +1 -0
  206. package/dist/simulator/validation.d.cts +104 -0
  207. package/dist/simulator/validation.d.cts.map +1 -0
  208. package/dist/simulator/validation.d.ts +104 -0
  209. package/dist/simulator/validation.d.ts.map +1 -0
  210. package/dist/simulator/validation.js +174 -0
  211. package/dist/simulator/validation.js.map +1 -0
  212. package/dist/streams/collect.cjs +26 -0
  213. package/dist/streams/collect.cjs.map +1 -0
  214. package/dist/streams/collect.d.cts +18 -0
  215. package/dist/streams/collect.d.cts.map +1 -0
  216. package/dist/streams/collect.d.ts +18 -0
  217. package/dist/streams/collect.d.ts.map +1 -0
  218. package/dist/streams/collect.js +26 -0
  219. package/dist/streams/collect.js.map +1 -0
  220. package/dist/streams/hash.cjs +123 -0
  221. package/dist/streams/hash.cjs.map +1 -0
  222. package/dist/streams/hash.d.cts +42 -0
  223. package/dist/streams/hash.d.cts.map +1 -0
  224. package/dist/streams/hash.d.ts +42 -0
  225. package/dist/streams/hash.d.ts.map +1 -0
  226. package/dist/streams/hash.js +101 -0
  227. package/dist/streams/hash.js.map +1 -0
  228. package/dist/streams/index.cjs +13 -0
  229. package/dist/streams/index.cjs.map +1 -0
  230. package/dist/streams/index.d.cts +7 -0
  231. package/dist/streams/index.d.cts.map +1 -0
  232. package/dist/streams/index.d.ts +7 -0
  233. package/dist/streams/index.d.ts.map +1 -0
  234. package/dist/streams/index.js +13 -0
  235. package/dist/streams/index.js.map +1 -0
  236. package/dist/streams/progress.cjs +47 -0
  237. package/dist/streams/progress.cjs.map +1 -0
  238. package/dist/streams/progress.d.cts +53 -0
  239. package/dist/streams/progress.d.cts.map +1 -0
  240. package/dist/streams/progress.d.ts +53 -0
  241. package/dist/streams/progress.d.ts.map +1 -0
  242. package/dist/streams/progress.js +47 -0
  243. package/dist/streams/progress.js.map +1 -0
  244. package/dist/streams/source.cjs +155 -0
  245. package/dist/streams/source.cjs.map +1 -0
  246. package/dist/streams/source.d.cts +140 -0
  247. package/dist/streams/source.d.cts.map +1 -0
  248. package/dist/streams/source.d.ts +140 -0
  249. package/dist/streams/source.d.ts.map +1 -0
  250. package/dist/streams/source.js +155 -0
  251. package/dist/streams/source.js.map +1 -0
  252. package/dist/sync/actions/index.cjs +191 -0
  253. package/dist/sync/actions/index.cjs.map +1 -0
  254. package/dist/sync/actions/index.d.cts +167 -0
  255. package/dist/sync/actions/index.d.cts.map +1 -0
  256. package/dist/sync/actions/index.d.ts +167 -0
  257. package/dist/sync/actions/index.d.ts.map +1 -0
  258. package/dist/sync/actions/index.js +191 -0
  259. package/dist/sync/actions/index.js.map +1 -0
  260. package/dist/sync/index.cjs +23 -0
  261. package/dist/sync/index.cjs.map +1 -0
  262. package/dist/sync/index.d.cts +21 -0
  263. package/dist/sync/index.d.cts.map +1 -0
  264. package/dist/sync/index.d.ts +21 -0
  265. package/dist/sync/index.d.ts.map +1 -0
  266. package/dist/sync/index.js +23 -0
  267. package/dist/sync/index.js.map +1 -0
  268. package/dist/sync/pairing.cjs +31 -0
  269. package/dist/sync/pairing.cjs.map +1 -0
  270. package/dist/sync/pairing.d.cts +13 -0
  271. package/dist/sync/pairing.d.cts.map +1 -0
  272. package/dist/sync/pairing.d.ts +13 -0
  273. package/dist/sync/pairing.d.ts.map +1 -0
  274. package/dist/sync/pairing.js +31 -0
  275. package/dist/sync/pairing.js.map +1 -0
  276. package/dist/sync/policies/compare.cjs +14 -0
  277. package/dist/sync/policies/compare.cjs.map +1 -0
  278. package/dist/sync/policies/compare.d.cts +13 -0
  279. package/dist/sync/policies/compare.d.cts.map +1 -0
  280. package/dist/sync/policies/compare.d.ts +13 -0
  281. package/dist/sync/policies/compare.d.ts.map +1 -0
  282. package/dist/sync/policies/compare.js +14 -0
  283. package/dist/sync/policies/compare.js.map +1 -0
  284. package/dist/sync/policies/index.cjs +74 -0
  285. package/dist/sync/policies/index.cjs.map +1 -0
  286. package/dist/sync/policies/index.d.cts +42 -0
  287. package/dist/sync/policies/index.d.cts.map +1 -0
  288. package/dist/sync/policies/index.d.ts +42 -0
  289. package/dist/sync/policies/index.d.ts.map +1 -0
  290. package/dist/sync/policies/index.js +74 -0
  291. package/dist/sync/policies/index.js.map +1 -0
  292. package/dist/sync/scanners/b2.cjs +57 -0
  293. package/dist/sync/scanners/b2.cjs.map +1 -0
  294. package/dist/sync/scanners/b2.d.cts +20 -0
  295. package/dist/sync/scanners/b2.d.cts.map +1 -0
  296. package/dist/sync/scanners/b2.d.ts +20 -0
  297. package/dist/sync/scanners/b2.d.ts.map +1 -0
  298. package/dist/sync/scanners/b2.js +57 -0
  299. package/dist/sync/scanners/b2.js.map +1 -0
  300. package/dist/sync/scanners/local.cjs +58 -0
  301. package/dist/sync/scanners/local.cjs.map +1 -0
  302. package/dist/sync/scanners/local.d.cts +24 -0
  303. package/dist/sync/scanners/local.d.cts.map +1 -0
  304. package/dist/sync/scanners/local.d.ts +24 -0
  305. package/dist/sync/scanners/local.d.ts.map +1 -0
  306. package/dist/sync/scanners/local.js +58 -0
  307. package/dist/sync/scanners/local.js.map +1 -0
  308. package/dist/sync/synchronizer.cjs +203 -0
  309. package/dist/sync/synchronizer.cjs.map +1 -0
  310. package/dist/sync/synchronizer.d.cts +52 -0
  311. package/dist/sync/synchronizer.d.cts.map +1 -0
  312. package/dist/sync/synchronizer.d.ts +52 -0
  313. package/dist/sync/synchronizer.d.ts.map +1 -0
  314. package/dist/sync/synchronizer.js +181 -0
  315. package/dist/sync/synchronizer.js.map +1 -0
  316. package/dist/sync/types.d.cts +121 -0
  317. package/dist/sync/types.d.cts.map +1 -0
  318. package/dist/sync/types.d.ts +121 -0
  319. package/dist/sync/types.d.ts.map +1 -0
  320. package/dist/types/auth.cjs +58 -0
  321. package/dist/types/auth.cjs.map +1 -0
  322. package/dist/types/auth.d.cts +150 -0
  323. package/dist/types/auth.d.cts.map +1 -0
  324. package/dist/types/auth.d.ts +150 -0
  325. package/dist/types/auth.d.ts.map +1 -0
  326. package/dist/types/auth.js +58 -0
  327. package/dist/types/auth.js.map +1 -0
  328. package/dist/types/bucket.cjs +44 -0
  329. package/dist/types/bucket.cjs.map +1 -0
  330. package/dist/types/bucket.d.cts +245 -0
  331. package/dist/types/bucket.d.cts.map +1 -0
  332. package/dist/types/bucket.d.ts +245 -0
  333. package/dist/types/bucket.d.ts.map +1 -0
  334. package/dist/types/bucket.js +44 -0
  335. package/dist/types/bucket.js.map +1 -0
  336. package/dist/types/download.d.cts +110 -0
  337. package/dist/types/download.d.cts.map +1 -0
  338. package/dist/types/download.d.ts +110 -0
  339. package/dist/types/download.d.ts.map +1 -0
  340. package/dist/types/encryption.cjs +343 -0
  341. package/dist/types/encryption.cjs.map +1 -0
  342. package/dist/types/encryption.d.cts +132 -0
  343. package/dist/types/encryption.d.cts.map +1 -0
  344. package/dist/types/encryption.d.ts +132 -0
  345. package/dist/types/encryption.d.ts.map +1 -0
  346. package/dist/types/encryption.js +321 -0
  347. package/dist/types/encryption.js.map +1 -0
  348. package/dist/types/errors.d.cts +16 -0
  349. package/dist/types/errors.d.cts.map +1 -0
  350. package/dist/types/errors.d.ts +16 -0
  351. package/dist/types/errors.d.ts.map +1 -0
  352. package/dist/types/file.cjs +23 -0
  353. package/dist/types/file.cjs.map +1 -0
  354. package/dist/types/file.d.cts +220 -0
  355. package/dist/types/file.d.cts.map +1 -0
  356. package/dist/types/file.d.ts +220 -0
  357. package/dist/types/file.d.ts.map +1 -0
  358. package/dist/types/file.js +23 -0
  359. package/dist/types/file.js.map +1 -0
  360. package/dist/types/ids.cjs +27 -0
  361. package/dist/types/ids.cjs.map +1 -0
  362. package/dist/types/ids.d.cts +84 -0
  363. package/dist/types/ids.d.cts.map +1 -0
  364. package/dist/types/ids.d.ts +84 -0
  365. package/dist/types/ids.d.ts.map +1 -0
  366. package/dist/types/ids.js +27 -0
  367. package/dist/types/ids.js.map +1 -0
  368. package/dist/types/index.d.cts +25 -0
  369. package/dist/types/index.d.cts.map +1 -0
  370. package/dist/types/index.d.ts +25 -0
  371. package/dist/types/index.d.ts.map +1 -0
  372. package/dist/types/key.d.cts +84 -0
  373. package/dist/types/key.d.cts.map +1 -0
  374. package/dist/types/key.d.ts +84 -0
  375. package/dist/types/key.d.ts.map +1 -0
  376. package/dist/types/lock.cjs +17 -0
  377. package/dist/types/lock.cjs.map +1 -0
  378. package/dist/types/lock.d.cts +92 -0
  379. package/dist/types/lock.d.cts.map +1 -0
  380. package/dist/types/lock.d.ts +92 -0
  381. package/dist/types/lock.d.ts.map +1 -0
  382. package/dist/types/lock.js +17 -0
  383. package/dist/types/lock.js.map +1 -0
  384. package/dist/types/notifications.cjs +24 -0
  385. package/dist/types/notifications.cjs.map +1 -0
  386. package/dist/types/notifications.d.cts +97 -0
  387. package/dist/types/notifications.d.cts.map +1 -0
  388. package/dist/types/notifications.d.ts +97 -0
  389. package/dist/types/notifications.d.ts.map +1 -0
  390. package/dist/types/notifications.js +24 -0
  391. package/dist/types/notifications.js.map +1 -0
  392. package/dist/types/replication.d.cts +42 -0
  393. package/dist/types/replication.d.cts.map +1 -0
  394. package/dist/types/replication.d.ts +42 -0
  395. package/dist/types/replication.d.ts.map +1 -0
  396. package/dist/types/upload.d.cts +219 -0
  397. package/dist/types/upload.d.cts.map +1 -0
  398. package/dist/types/upload.d.ts +219 -0
  399. package/dist/types/upload.d.ts.map +1 -0
  400. package/dist/upload/cancel.cjs +10 -0
  401. package/dist/upload/cancel.cjs.map +1 -0
  402. package/dist/upload/cancel.d.cts +23 -0
  403. package/dist/upload/cancel.d.cts.map +1 -0
  404. package/dist/upload/cancel.d.ts +23 -0
  405. package/dist/upload/cancel.d.ts.map +1 -0
  406. package/dist/upload/cancel.js +10 -0
  407. package/dist/upload/cancel.js.map +1 -0
  408. package/dist/upload/concurrency.cjs +54 -0
  409. package/dist/upload/concurrency.cjs.map +1 -0
  410. package/dist/upload/concurrency.d.cts +46 -0
  411. package/dist/upload/concurrency.d.cts.map +1 -0
  412. package/dist/upload/concurrency.d.ts +46 -0
  413. package/dist/upload/concurrency.d.ts.map +1 -0
  414. package/dist/upload/concurrency.js +54 -0
  415. package/dist/upload/concurrency.js.map +1 -0
  416. package/dist/upload/large.cjs +222 -0
  417. package/dist/upload/large.cjs.map +1 -0
  418. package/dist/upload/large.d.cts +71 -0
  419. package/dist/upload/large.d.cts.map +1 -0
  420. package/dist/upload/large.d.ts +71 -0
  421. package/dist/upload/large.d.ts.map +1 -0
  422. package/dist/upload/large.js +222 -0
  423. package/dist/upload/large.js.map +1 -0
  424. package/dist/upload/resume.cjs +34 -0
  425. package/dist/upload/resume.cjs.map +1 -0
  426. package/dist/upload/resume.d.cts +33 -0
  427. package/dist/upload/resume.d.cts.map +1 -0
  428. package/dist/upload/resume.d.ts +33 -0
  429. package/dist/upload/resume.d.ts.map +1 -0
  430. package/dist/upload/resume.js +34 -0
  431. package/dist/upload/resume.js.map +1 -0
  432. package/dist/upload/single.cjs +47 -0
  433. package/dist/upload/single.cjs.map +1 -0
  434. package/dist/upload/single.d.cts +51 -0
  435. package/dist/upload/single.d.cts.map +1 -0
  436. package/dist/upload/single.d.ts +51 -0
  437. package/dist/upload/single.d.ts.map +1 -0
  438. package/dist/upload/single.js +47 -0
  439. package/dist/upload/single.js.map +1 -0
  440. package/dist/upload/stream.cjs +198 -0
  441. package/dist/upload/stream.cjs.map +1 -0
  442. package/dist/upload/stream.d.cts +61 -0
  443. package/dist/upload/stream.d.cts.map +1 -0
  444. package/dist/upload/stream.d.ts +61 -0
  445. package/dist/upload/stream.d.ts.map +1 -0
  446. package/dist/upload/stream.js +198 -0
  447. package/dist/upload/stream.js.map +1 -0
  448. package/dist/util/best-effort.cjs +10 -0
  449. package/dist/util/best-effort.cjs.map +1 -0
  450. package/dist/util/best-effort.d.cts +31 -0
  451. package/dist/util/best-effort.d.cts.map +1 -0
  452. package/dist/util/best-effort.d.ts +31 -0
  453. package/dist/util/best-effort.d.ts.map +1 -0
  454. package/dist/util/best-effort.js +10 -0
  455. package/dist/util/best-effort.js.map +1 -0
  456. package/dist/util/defaults.cjs +11 -0
  457. package/dist/util/defaults.cjs.map +1 -0
  458. package/dist/util/defaults.d.cts +54 -0
  459. package/dist/util/defaults.d.cts.map +1 -0
  460. package/dist/util/defaults.d.ts +54 -0
  461. package/dist/util/defaults.d.ts.map +1 -0
  462. package/dist/util/defaults.js +11 -0
  463. package/dist/util/defaults.js.map +1 -0
  464. package/dist/util/normalize.cjs +16 -0
  465. package/dist/util/normalize.cjs.map +1 -0
  466. package/dist/util/normalize.d.cts +62 -0
  467. package/dist/util/normalize.d.cts.map +1 -0
  468. package/dist/util/normalize.d.ts +62 -0
  469. package/dist/util/normalize.d.ts.map +1 -0
  470. package/dist/util/normalize.js +16 -0
  471. package/dist/util/normalize.js.map +1 -0
  472. package/dist/util/paginator.cjs +20 -0
  473. package/dist/util/paginator.cjs.map +1 -0
  474. package/dist/util/paginator.d.cts +120 -0
  475. package/dist/util/paginator.d.cts.map +1 -0
  476. package/dist/util/paginator.d.ts +120 -0
  477. package/dist/util/paginator.d.ts.map +1 -0
  478. package/dist/util/paginator.js +20 -0
  479. package/dist/util/paginator.js.map +1 -0
  480. package/dist/util/plan-ranges.cjs +28 -0
  481. package/dist/util/plan-ranges.cjs.map +1 -0
  482. package/dist/util/plan-ranges.d.cts +56 -0
  483. package/dist/util/plan-ranges.d.cts.map +1 -0
  484. package/dist/util/plan-ranges.d.ts +56 -0
  485. package/dist/util/plan-ranges.d.ts.map +1 -0
  486. package/dist/util/plan-ranges.js +28 -0
  487. package/dist/util/plan-ranges.js.map +1 -0
  488. package/dist/util/text-codec.cjs +7 -0
  489. package/dist/util/text-codec.cjs.map +1 -0
  490. package/dist/util/text-codec.d.cts +26 -0
  491. package/dist/util/text-codec.d.cts.map +1 -0
  492. package/dist/util/text-codec.d.ts +26 -0
  493. package/dist/util/text-codec.d.ts.map +1 -0
  494. package/dist/util/text-codec.js +7 -0
  495. package/dist/util/text-codec.js.map +1 -0
  496. package/dist/util/to-error.cjs +7 -0
  497. package/dist/util/to-error.cjs.map +1 -0
  498. package/dist/util/to-error.d.cts +15 -0
  499. package/dist/util/to-error.d.cts.map +1 -0
  500. package/dist/util/to-error.d.ts +15 -0
  501. package/dist/util/to-error.d.ts.map +1 -0
  502. package/dist/util/to-error.js +7 -0
  503. package/dist/util/to-error.js.map +1 -0
  504. package/dist/version.cjs +6 -0
  505. package/dist/version.cjs.map +1 -0
  506. package/dist/version.d.cts +14 -0
  507. package/dist/version.d.cts.map +1 -0
  508. package/dist/version.d.ts +14 -0
  509. package/dist/version.d.ts.map +1 -0
  510. package/dist/version.js +6 -0
  511. package/dist/version.js.map +1 -0
  512. package/package.json +198 -0
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const encoding = require("../raw/encoding.cjs");
4
+ const progress = require("../streams/progress.cjs");
5
+ const ids = require("../types/ids.cjs");
6
+ const bestEffort = require("../util/best-effort.cjs");
7
+ const normalize = require("../util/normalize.cjs");
8
+ async function downloadById(raw, accountInfo, options) {
9
+ const resp = await raw.downloadFileById(
10
+ accountInfo.getDownloadUrl(),
11
+ accountInfo.getAuthToken(),
12
+ options.fileId,
13
+ toRawDownloadOptions(options)
14
+ );
15
+ const headers = extractDownloadHeaders(resp.headers);
16
+ return {
17
+ headers,
18
+ // HEAD requests legitimately have no body; return an empty stream so the
19
+ // result shape stays consistent.
20
+ body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress)
21
+ };
22
+ }
23
+ async function downloadByName(raw, accountInfo, options) {
24
+ const resp = await raw.downloadFileByName(
25
+ accountInfo.getDownloadUrl(),
26
+ accountInfo.getAuthToken(),
27
+ options.bucketName,
28
+ options.fileName,
29
+ toRawDownloadOptions(options)
30
+ );
31
+ const headers = extractDownloadHeaders(resp.headers);
32
+ return {
33
+ headers,
34
+ body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress)
35
+ };
36
+ }
37
+ async function headById(raw, accountInfo, options) {
38
+ const resp = await raw.downloadFileById(
39
+ accountInfo.getDownloadUrl(),
40
+ accountInfo.getAuthToken(),
41
+ options.fileId,
42
+ { ...toRawDownloadOptions(options), method: "HEAD" }
43
+ );
44
+ if (resp.body !== null) {
45
+ const body = resp.body;
46
+ await bestEffort.bestEffort(() => body.cancel());
47
+ }
48
+ return { headers: extractDownloadHeaders(resp.headers) };
49
+ }
50
+ async function headByName(raw, accountInfo, options) {
51
+ const resp = await raw.downloadFileByName(
52
+ accountInfo.getDownloadUrl(),
53
+ accountInfo.getAuthToken(),
54
+ options.bucketName,
55
+ options.fileName,
56
+ { ...toRawDownloadOptions(options), method: "HEAD" }
57
+ );
58
+ if (resp.body !== null) {
59
+ const body = resp.body;
60
+ await bestEffort.bestEffort(() => body.cancel());
61
+ }
62
+ return { headers: extractDownloadHeaders(resp.headers) };
63
+ }
64
+ function toRawDownloadOptions(options) {
65
+ return {
66
+ ...options.method !== void 0 ? { method: options.method } : {},
67
+ ...options.range !== void 0 ? { range: options.range } : {},
68
+ ...options.serverSideEncryption !== void 0 ? { serverSideEncryption: options.serverSideEncryption } : {},
69
+ ...options.b2ContentDisposition !== void 0 ? { b2ContentDisposition: options.b2ContentDisposition } : {},
70
+ ...options.b2ContentLanguage !== void 0 ? { b2ContentLanguage: options.b2ContentLanguage } : {},
71
+ ...options.b2ContentEncoding !== void 0 ? { b2ContentEncoding: options.b2ContentEncoding } : {},
72
+ ...options.b2ContentType !== void 0 ? { b2ContentType: options.b2ContentType } : {},
73
+ ...options.b2CacheControl !== void 0 ? { b2CacheControl: options.b2CacheControl } : {},
74
+ ...options.b2Expires !== void 0 ? { b2Expires: options.b2Expires } : {},
75
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
76
+ };
77
+ }
78
+ function emptyStream() {
79
+ return new ReadableStream({
80
+ start(controller) {
81
+ controller.close();
82
+ }
83
+ });
84
+ }
85
+ function instrumentProgress(body, totalBytes, listener) {
86
+ if (listener === void 0) return body;
87
+ const tracker = new progress.ProgressTracker(listener, totalBytes, 1);
88
+ const transform = new TransformStream({
89
+ transform(chunk, controller) {
90
+ tracker.addBytes(chunk.byteLength);
91
+ controller.enqueue(chunk);
92
+ },
93
+ flush() {
94
+ tracker.completePart();
95
+ }
96
+ });
97
+ return body.pipeThrough(transform);
98
+ }
99
+ function extractDownloadHeaders(headers) {
100
+ const fileInfo = encoding.parseFileInfoHeaders(headers);
101
+ return {
102
+ contentType: headers.get("Content-Type") ?? "application/octet-stream",
103
+ contentLength: Number.parseInt(headers.get("Content-Length") ?? "0", 10),
104
+ // B2 sends the literal `'none'` for multipart-finished files; collapse
105
+ // to `null` so the typed `string | null` actually means "no SHA-1".
106
+ contentSha1: normalize.normalizeSha1(headers.get("X-Bz-Content-Sha1")),
107
+ fileId: ids.fileId(headers.get("X-Bz-File-Id") ?? ""),
108
+ fileName: decodeURIComponent(headers.get("X-Bz-File-Name") ?? ""),
109
+ fileInfo,
110
+ uploadTimestamp: Number.parseInt(headers.get("X-Bz-Upload-Timestamp") ?? "0", 10)
111
+ };
112
+ }
113
+ exports.downloadById = downloadById;
114
+ exports.downloadByName = downloadByName;
115
+ exports.headById = headById;
116
+ exports.headByName = headByName;
117
+ //# sourceMappingURL=single.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.cjs","sources":["../../src/download/single.ts"],"sourcesContent":["import type { AccountInfo } from '../auth/account-info.ts'\nimport { parseFileInfoHeaders } from '../raw/encoding.ts'\nimport type { DownloadFileOptions, RawClient, SseCDownloadKey } from '../raw/index.ts'\nimport { type ProgressListener, ProgressTracker } from '../streams/progress.ts'\nimport type { DownloadHeaders } from '../types/download.ts'\nimport { type FileId, fileId as fileIdOf } from '../types/ids.ts'\nimport { bestEffort } from '../util/best-effort.ts'\nimport { normalizeSha1 } from '../util/normalize.ts'\n\n/** Result of a single-request file download. */\nexport interface DownloadResult {\n /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */\n readonly headers: DownloadHeaders\n /** Streaming body of the downloaded file. */\n readonly body: ReadableStream<Uint8Array>\n}\n\n/**\n * Result of a HEAD-style metadata fetch. Unlike {@link DownloadResult},\n * this shape has **no** `body` field — the SDK consumes and discards the\n * (logically empty) HEAD response body internally so callers never have\n * to remember to `body.cancel()` after a metadata-only fetch.\n */\nexport interface HeadResult {\n /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */\n readonly headers: DownloadHeaders\n}\n\n/** Shared download options exposed at the high-level facade. */\ninterface DownloadCommonOptions {\n /** HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only response headers without streaming the body. */\n readonly method?: 'GET' | 'HEAD'\n /** Optional HTTP Range header value (e.g. `bytes=0-999`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Signal to abort the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as bytes flow through the returned `body` stream.\n *\n * Wraps the response body in a `TransformStream` that increments a\n * `ProgressTracker` per chunk and emits a `partsCompleted: 1` event when\n * the stream finishes. `totalBytes` is the response's `Content-Length`\n * header (or `null` if the server didn't send one — rare for B2).\n *\n * If the caller does not read the returned body to completion, the\n * tracker's `completePart()` event will not fire. That is intentional:\n * progress is byte-driven, not request-driven.\n */\n readonly onProgress?: ProgressListener\n}\n\n/** Options for downloading a file by its unique ID. */\nexport interface DownloadByIdOptions extends DownloadCommonOptions {\n /** ID of the file version to download. */\n readonly fileId: FileId\n}\n\n/** Options for downloading a file by bucket name and file path. */\nexport interface DownloadByNameOptions extends DownloadCommonOptions {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full file name (path) within the bucket. */\n readonly fileName: string\n}\n\n/**\n * Shared HEAD options. Mirrors {@link DownloadCommonOptions} but omits\n * `method` (always HEAD) and `onProgress` (no body to track).\n */\ntype HeadCommonOptions = Omit<DownloadCommonOptions, 'method' | 'onProgress'>\n\n/** Options for a HEAD-by-ID request. */\nexport interface HeadByIdOptions extends HeadCommonOptions {\n /** ID of the file version to inspect. */\n readonly fileId: FileId\n}\n\n/** Options for a HEAD-by-name request. */\nexport interface HeadByNameOptions extends HeadCommonOptions {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full file name (path) within the bucket. */\n readonly fileName: string\n}\n\n/**\n * Downloads a file by its unique ID in a single HTTP request.\n *\n * Returns a streaming body suitable for small-to-medium files. For large files\n * that benefit from concurrent ranged fetches, use\n * {@link createParallelDownloadStream} instead.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - Download parameters.\n *\n * @returns Parsed headers and a readable stream of file bytes.\n */\nexport async function downloadById(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: DownloadByIdOptions,\n): Promise<DownloadResult> {\n const resp = await raw.downloadFileById(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.fileId,\n toRawDownloadOptions(options),\n )\n\n const headers = extractDownloadHeaders(resp.headers)\n return {\n headers,\n // HEAD requests legitimately have no body; return an empty stream so the\n // result shape stays consistent.\n body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress),\n }\n}\n\n/**\n * Downloads a file by bucket name and file path in a single HTTP request.\n *\n * Returns a streaming body suitable for small-to-medium files. For large files\n * that benefit from concurrent ranged fetches, use\n * {@link createParallelDownloadStream} instead.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - Download parameters.\n *\n * @returns Parsed headers and a readable stream of file bytes.\n */\nexport async function downloadByName(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: DownloadByNameOptions,\n): Promise<DownloadResult> {\n const resp = await raw.downloadFileByName(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.bucketName,\n options.fileName,\n toRawDownloadOptions(options),\n )\n\n const headers = extractDownloadHeaders(resp.headers)\n return {\n headers,\n body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress),\n }\n}\n\n/**\n * Issues a HEAD-by-ID request and returns parsed headers only. Drains\n * the (logically empty) response body internally so callers don't have\n * to remember to `body.cancel()` themselves.\n *\n * Prefer this over `downloadById({ method: 'HEAD' })` — same wire-level\n * effect, but the caller-facing result has no `body` field at all so\n * there's nothing to clean up.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - HEAD parameters (file ID + the same response-header\n * overrides and abort signal that `downloadById` accepts).\n *\n * @returns Parsed download headers (no body field).\n */\nexport async function headById(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: HeadByIdOptions,\n): Promise<HeadResult> {\n const resp = await raw.downloadFileById(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.fileId,\n { ...toRawDownloadOptions(options), method: 'HEAD' },\n )\n // Body for HEAD is normally `null` per the fetch spec. Some transports\n // (notably the SDK's `B2Simulator`) synthesize a non-null body for\n // shape consistency. In either case, cancelling is a no-op for the\n // caller; wrap in `bestEffort` so a stream-lifecycle quirk in a\n // future runtime can't fail an otherwise-successful HEAD.\n if (resp.body !== null) {\n // Bind to a local so the type narrowing carries into the closure;\n // bare `resp.body` in the lambda would re-broaden to `... | null`.\n const body = resp.body\n await bestEffort(() => body.cancel())\n }\n return { headers: extractDownloadHeaders(resp.headers) }\n}\n\n/**\n * Issues a HEAD-by-name request and returns parsed headers only. Drains\n * the (logically empty) response body internally so callers don't have\n * to remember to `body.cancel()` themselves.\n *\n * Prefer this over `downloadByName({ method: 'HEAD' })` — same wire-level\n * effect, but the caller-facing result has no `body` field at all so\n * there's nothing to clean up.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - HEAD parameters (bucket + file name + the same\n * response-header overrides and abort signal that `downloadByName`\n * accepts).\n *\n * @returns Parsed download headers (no body field).\n */\nexport async function headByName(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: HeadByNameOptions,\n): Promise<HeadResult> {\n const resp = await raw.downloadFileByName(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.bucketName,\n options.fileName,\n { ...toRawDownloadOptions(options), method: 'HEAD' },\n )\n if (resp.body !== null) {\n // Bind to a local so the type narrowing carries into the closure;\n // bare `resp.body` in the lambda would re-broaden to `... | null`.\n const body = resp.body\n await bestEffort(() => body.cancel())\n }\n return { headers: extractDownloadHeaders(resp.headers) }\n}\n\n/**\n * Translates the public download-options shape into the raw client's\n * {@link DownloadFileOptions}, dropping the request-target fields (`fileId`,\n * `bucketName`, `fileName`) that don't apply at the transport layer.\n *\n * @param options - Caller-supplied download options.\n *\n * @returns The raw transport-layer options.\n */\nfunction toRawDownloadOptions(options: DownloadCommonOptions): DownloadFileOptions {\n return {\n ...(options.method !== undefined ? { method: options.method } : {}),\n ...(options.range !== undefined ? { range: options.range } : {}),\n ...(options.serverSideEncryption !== undefined\n ? { serverSideEncryption: options.serverSideEncryption }\n : {}),\n ...(options.b2ContentDisposition !== undefined\n ? { b2ContentDisposition: options.b2ContentDisposition }\n : {}),\n ...(options.b2ContentLanguage !== undefined\n ? { b2ContentLanguage: options.b2ContentLanguage }\n : {}),\n ...(options.b2ContentEncoding !== undefined\n ? { b2ContentEncoding: options.b2ContentEncoding }\n : {}),\n ...(options.b2ContentType !== undefined ? { b2ContentType: options.b2ContentType } : {}),\n ...(options.b2CacheControl !== undefined ? { b2CacheControl: options.b2CacheControl } : {}),\n ...(options.b2Expires !== undefined ? { b2Expires: options.b2Expires } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n }\n}\n\n/**\n * Builds an immediately-closed empty ReadableStream. Used as the body of a\n * HEAD download response so callers always get a stream they can `pipeTo`.\n *\n * @returns A ReadableStream that yields zero bytes and immediately closes.\n */\nfunction emptyStream(): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.close()\n },\n })\n}\n\n/**\n * Wraps a body stream with a `TransformStream` that increments a\n * {@link ProgressTracker} for each chunk and reports `partsCompleted: 1`\n * when the stream finishes.\n *\n * When `listener` is undefined the function short-circuits and returns\n * the original stream, so unobserved downloads pay no overhead.\n *\n * @param body - The download response body to wrap.\n * @param totalBytes - Expected total bytes (response `Content-Length`).\n * @param listener - Caller-supplied progress callback, or undefined.\n *\n * @returns A stream that emits the same bytes and reports progress.\n */\nfunction instrumentProgress(\n body: ReadableStream<Uint8Array>,\n totalBytes: number,\n listener: ProgressListener | undefined,\n): ReadableStream<Uint8Array> {\n if (listener === undefined) return body\n const tracker = new ProgressTracker(listener, totalBytes, 1)\n const transform = new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n tracker.addBytes(chunk.byteLength)\n controller.enqueue(chunk)\n },\n flush() {\n tracker.completePart()\n },\n })\n return body.pipeThrough(transform)\n}\n\n/**\n * Extracts B2-specific download headers into a structured object.\n * @param headers - The HTTP response headers from the download.\n *\n * @returns The parsed download metadata.\n */\nfunction extractDownloadHeaders(headers: Headers): DownloadHeaders {\n const fileInfo = parseFileInfoHeaders(headers)\n\n return {\n contentType: headers.get('Content-Type') ?? 'application/octet-stream',\n contentLength: Number.parseInt(headers.get('Content-Length') ?? '0', 10),\n // B2 sends the literal `'none'` for multipart-finished files; collapse\n // to `null` so the typed `string | null` actually means \"no SHA-1\".\n contentSha1: normalizeSha1(headers.get('X-Bz-Content-Sha1')),\n fileId: fileIdOf(headers.get('X-Bz-File-Id') ?? ''),\n fileName: decodeURIComponent(headers.get('X-Bz-File-Name') ?? ''),\n fileInfo,\n uploadTimestamp: Number.parseInt(headers.get('X-Bz-Upload-Timestamp') ?? '0', 10),\n }\n}\n"],"names":["bestEffort","ProgressTracker","parseFileInfoHeaders","normalizeSha1","fileIdOf"],"mappings":";;;;;;;AAgHA,eAAsB,aACpB,KACA,aACA,SACyB;AACzB,QAAM,OAAO,MAAM,IAAI;AAAA,IACrB,YAAY,eAAA;AAAA,IACZ,YAAY,aAAA;AAAA,IACZ,QAAQ;AAAA,IACR,qBAAqB,OAAO;AAAA,EAAA;AAG9B,QAAM,UAAU,uBAAuB,KAAK,OAAO;AACnD,SAAO;AAAA,IACL;AAAA;AAAA;AAAA,IAGA,MAAM,mBAAmB,KAAK,QAAQ,e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AAS,uBAAuB,SAAmC;AACjE,QAAM,WAAWC,SAAAA,qBAAqB,OAAO;AAE7C,SAAO;AAAA,IACL,aAAa,QAAQ,IAAI,cAAc,KAAK;AAAA,IAC5C,eAAe,OAAO,SAAS,QAAQ,IAAI,gBAAgB,KAAK,KAAK,EAAE;AAAA;AAAA;AAAA,IAGvE,aAAaC,UAAAA,cAAc,QAAQ,IAAI,mBAAmB,CAAC;AAAA,IAC3D,QAAQC,IAAAA,OAAS,QAAQ,IAAI,cAAc,KAAK,EAAE;AAAA,IAClD,UAAU,mBAAmB,QAAQ,IAAI,gBAAgB,KAAK,EAAE;AAAA,IAChE;AAAA,IACA,iBAAiB,OAAO,SAAS,QAAQ,IAAI,uBAAuB,KAAK,KAAK,EAAE;AAAA,EAAA;AAEpF;;;;;"}
@@ -0,0 +1,152 @@
1
+ import { AccountInfo } from '../auth/account-info.js';
2
+ import { RawClient, SseCDownloadKey } from '../raw/index.js';
3
+ import { ProgressListener } from '../streams/progress.js';
4
+ import { DownloadHeaders } from '../types/download.js';
5
+ import { FileId } from '../types/ids.js';
6
+ /** Result of a single-request file download. */
7
+ export interface DownloadResult {
8
+ /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */
9
+ readonly headers: DownloadHeaders;
10
+ /** Streaming body of the downloaded file. */
11
+ readonly body: ReadableStream<Uint8Array>;
12
+ }
13
+ /**
14
+ * Result of a HEAD-style metadata fetch. Unlike {@link DownloadResult},
15
+ * this shape has **no** `body` field — the SDK consumes and discards the
16
+ * (logically empty) HEAD response body internally so callers never have
17
+ * to remember to `body.cancel()` after a metadata-only fetch.
18
+ */
19
+ export interface HeadResult {
20
+ /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */
21
+ readonly headers: DownloadHeaders;
22
+ }
23
+ /** Shared download options exposed at the high-level facade. */
24
+ interface DownloadCommonOptions {
25
+ /** HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only response headers without streaming the body. */
26
+ readonly method?: 'GET' | 'HEAD';
27
+ /** Optional HTTP Range header value (e.g. `bytes=0-999`). */
28
+ readonly range?: string;
29
+ /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
30
+ readonly serverSideEncryption?: SseCDownloadKey;
31
+ /** Override the response `Content-Disposition` header. */
32
+ readonly b2ContentDisposition?: string;
33
+ /** Override the response `Content-Language` header. */
34
+ readonly b2ContentLanguage?: string;
35
+ /** Override the response `Content-Encoding` header. */
36
+ readonly b2ContentEncoding?: string;
37
+ /** Override the response `Content-Type` header. */
38
+ readonly b2ContentType?: string;
39
+ /** Override the response `Cache-Control` header. */
40
+ readonly b2CacheControl?: string;
41
+ /** Override the response `Expires` header. */
42
+ readonly b2Expires?: string;
43
+ /** Signal to abort the download. */
44
+ readonly signal?: AbortSignal;
45
+ /**
46
+ * Callback invoked as bytes flow through the returned `body` stream.
47
+ *
48
+ * Wraps the response body in a `TransformStream` that increments a
49
+ * `ProgressTracker` per chunk and emits a `partsCompleted: 1` event when
50
+ * the stream finishes. `totalBytes` is the response's `Content-Length`
51
+ * header (or `null` if the server didn't send one — rare for B2).
52
+ *
53
+ * If the caller does not read the returned body to completion, the
54
+ * tracker's `completePart()` event will not fire. That is intentional:
55
+ * progress is byte-driven, not request-driven.
56
+ */
57
+ readonly onProgress?: ProgressListener;
58
+ }
59
+ /** Options for downloading a file by its unique ID. */
60
+ export interface DownloadByIdOptions extends DownloadCommonOptions {
61
+ /** ID of the file version to download. */
62
+ readonly fileId: FileId;
63
+ }
64
+ /** Options for downloading a file by bucket name and file path. */
65
+ export interface DownloadByNameOptions extends DownloadCommonOptions {
66
+ /** Name of the bucket containing the file. */
67
+ readonly bucketName: string;
68
+ /** Full file name (path) within the bucket. */
69
+ readonly fileName: string;
70
+ }
71
+ /**
72
+ * Shared HEAD options. Mirrors {@link DownloadCommonOptions} but omits
73
+ * `method` (always HEAD) and `onProgress` (no body to track).
74
+ */
75
+ type HeadCommonOptions = Omit<DownloadCommonOptions, 'method' | 'onProgress'>;
76
+ /** Options for a HEAD-by-ID request. */
77
+ export interface HeadByIdOptions extends HeadCommonOptions {
78
+ /** ID of the file version to inspect. */
79
+ readonly fileId: FileId;
80
+ }
81
+ /** Options for a HEAD-by-name request. */
82
+ export interface HeadByNameOptions extends HeadCommonOptions {
83
+ /** Name of the bucket containing the file. */
84
+ readonly bucketName: string;
85
+ /** Full file name (path) within the bucket. */
86
+ readonly fileName: string;
87
+ }
88
+ /**
89
+ * Downloads a file by its unique ID in a single HTTP request.
90
+ *
91
+ * Returns a streaming body suitable for small-to-medium files. For large files
92
+ * that benefit from concurrent ranged fetches, use
93
+ * {@link createParallelDownloadStream} instead.
94
+ *
95
+ * @param raw - Low-level B2 API client.
96
+ * @param accountInfo - Authorized account state.
97
+ * @param options - Download parameters.
98
+ *
99
+ * @returns Parsed headers and a readable stream of file bytes.
100
+ */
101
+ export declare function downloadById(raw: RawClient, accountInfo: AccountInfo, options: DownloadByIdOptions): Promise<DownloadResult>;
102
+ /**
103
+ * Downloads a file by bucket name and file path in a single HTTP request.
104
+ *
105
+ * Returns a streaming body suitable for small-to-medium files. For large files
106
+ * that benefit from concurrent ranged fetches, use
107
+ * {@link createParallelDownloadStream} instead.
108
+ *
109
+ * @param raw - Low-level B2 API client.
110
+ * @param accountInfo - Authorized account state.
111
+ * @param options - Download parameters.
112
+ *
113
+ * @returns Parsed headers and a readable stream of file bytes.
114
+ */
115
+ export declare function downloadByName(raw: RawClient, accountInfo: AccountInfo, options: DownloadByNameOptions): Promise<DownloadResult>;
116
+ /**
117
+ * Issues a HEAD-by-ID request and returns parsed headers only. Drains
118
+ * the (logically empty) response body internally so callers don't have
119
+ * to remember to `body.cancel()` themselves.
120
+ *
121
+ * Prefer this over `downloadById({ method: 'HEAD' })` — same wire-level
122
+ * effect, but the caller-facing result has no `body` field at all so
123
+ * there's nothing to clean up.
124
+ *
125
+ * @param raw - Low-level B2 API client.
126
+ * @param accountInfo - Authorized account state.
127
+ * @param options - HEAD parameters (file ID + the same response-header
128
+ * overrides and abort signal that `downloadById` accepts).
129
+ *
130
+ * @returns Parsed download headers (no body field).
131
+ */
132
+ export declare function headById(raw: RawClient, accountInfo: AccountInfo, options: HeadByIdOptions): Promise<HeadResult>;
133
+ /**
134
+ * Issues a HEAD-by-name request and returns parsed headers only. Drains
135
+ * the (logically empty) response body internally so callers don't have
136
+ * to remember to `body.cancel()` themselves.
137
+ *
138
+ * Prefer this over `downloadByName({ method: 'HEAD' })` — same wire-level
139
+ * effect, but the caller-facing result has no `body` field at all so
140
+ * there's nothing to clean up.
141
+ *
142
+ * @param raw - Low-level B2 API client.
143
+ * @param accountInfo - Authorized account state.
144
+ * @param options - HEAD parameters (bucket + file name + the same
145
+ * response-header overrides and abort signal that `downloadByName`
146
+ * accepts).
147
+ *
148
+ * @returns Parsed download headers (no body field).
149
+ */
150
+ export declare function headByName(raw: RawClient, accountInfo: AccountInfo, options: HeadByNameOptions): Promise<HeadResult>;
151
+ export {};
152
+ //# sourceMappingURL=single.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/download/single.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAK,EAAuB,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtF,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,KAAK,MAAM,EAAsB,MAAM,iBAAiB,CAAA;AAIjE,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAC1C;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACz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7E,wCAAwC;AACxC,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAezB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAczB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,UAAU,CAAC,CAmBrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAerB"}
@@ -0,0 +1,152 @@
1
+ import { AccountInfo } from '../auth/account-info.js';
2
+ import { RawClient, SseCDownloadKey } from '../raw/index.js';
3
+ import { ProgressListener } from '../streams/progress.js';
4
+ import { DownloadHeaders } from '../types/download.js';
5
+ import { FileId } from '../types/ids.js';
6
+ /** Result of a single-request file download. */
7
+ export interface DownloadResult {
8
+ /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */
9
+ readonly headers: DownloadHeaders;
10
+ /** Streaming body of the downloaded file. */
11
+ readonly body: ReadableStream<Uint8Array>;
12
+ }
13
+ /**
14
+ * Result of a HEAD-style metadata fetch. Unlike {@link DownloadResult},
15
+ * this shape has **no** `body` field — the SDK consumes and discards the
16
+ * (logically empty) HEAD response body internally so callers never have
17
+ * to remember to `body.cancel()` after a metadata-only fetch.
18
+ */
19
+ export interface HeadResult {
20
+ /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */
21
+ readonly headers: DownloadHeaders;
22
+ }
23
+ /** Shared download options exposed at the high-level facade. */
24
+ interface DownloadCommonOptions {
25
+ /** HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only response headers without streaming the body. */
26
+ readonly method?: 'GET' | 'HEAD';
27
+ /** Optional HTTP Range header value (e.g. `bytes=0-999`). */
28
+ readonly range?: string;
29
+ /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
30
+ readonly serverSideEncryption?: SseCDownloadKey;
31
+ /** Override the response `Content-Disposition` header. */
32
+ readonly b2ContentDisposition?: string;
33
+ /** Override the response `Content-Language` header. */
34
+ readonly b2ContentLanguage?: string;
35
+ /** Override the response `Content-Encoding` header. */
36
+ readonly b2ContentEncoding?: string;
37
+ /** Override the response `Content-Type` header. */
38
+ readonly b2ContentType?: string;
39
+ /** Override the response `Cache-Control` header. */
40
+ readonly b2CacheControl?: string;
41
+ /** Override the response `Expires` header. */
42
+ readonly b2Expires?: string;
43
+ /** Signal to abort the download. */
44
+ readonly signal?: AbortSignal;
45
+ /**
46
+ * Callback invoked as bytes flow through the returned `body` stream.
47
+ *
48
+ * Wraps the response body in a `TransformStream` that increments a
49
+ * `ProgressTracker` per chunk and emits a `partsCompleted: 1` event when
50
+ * the stream finishes. `totalBytes` is the response's `Content-Length`
51
+ * header (or `null` if the server didn't send one — rare for B2).
52
+ *
53
+ * If the caller does not read the returned body to completion, the
54
+ * tracker's `completePart()` event will not fire. That is intentional:
55
+ * progress is byte-driven, not request-driven.
56
+ */
57
+ readonly onProgress?: ProgressListener;
58
+ }
59
+ /** Options for downloading a file by its unique ID. */
60
+ export interface DownloadByIdOptions extends DownloadCommonOptions {
61
+ /** ID of the file version to download. */
62
+ readonly fileId: FileId;
63
+ }
64
+ /** Options for downloading a file by bucket name and file path. */
65
+ export interface DownloadByNameOptions extends DownloadCommonOptions {
66
+ /** Name of the bucket containing the file. */
67
+ readonly bucketName: string;
68
+ /** Full file name (path) within the bucket. */
69
+ readonly fileName: string;
70
+ }
71
+ /**
72
+ * Shared HEAD options. Mirrors {@link DownloadCommonOptions} but omits
73
+ * `method` (always HEAD) and `onProgress` (no body to track).
74
+ */
75
+ type HeadCommonOptions = Omit<DownloadCommonOptions, 'method' | 'onProgress'>;
76
+ /** Options for a HEAD-by-ID request. */
77
+ export interface HeadByIdOptions extends HeadCommonOptions {
78
+ /** ID of the file version to inspect. */
79
+ readonly fileId: FileId;
80
+ }
81
+ /** Options for a HEAD-by-name request. */
82
+ export interface HeadByNameOptions extends HeadCommonOptions {
83
+ /** Name of the bucket containing the file. */
84
+ readonly bucketName: string;
85
+ /** Full file name (path) within the bucket. */
86
+ readonly fileName: string;
87
+ }
88
+ /**
89
+ * Downloads a file by its unique ID in a single HTTP request.
90
+ *
91
+ * Returns a streaming body suitable for small-to-medium files. For large files
92
+ * that benefit from concurrent ranged fetches, use
93
+ * {@link createParallelDownloadStream} instead.
94
+ *
95
+ * @param raw - Low-level B2 API client.
96
+ * @param accountInfo - Authorized account state.
97
+ * @param options - Download parameters.
98
+ *
99
+ * @returns Parsed headers and a readable stream of file bytes.
100
+ */
101
+ export declare function downloadById(raw: RawClient, accountInfo: AccountInfo, options: DownloadByIdOptions): Promise<DownloadResult>;
102
+ /**
103
+ * Downloads a file by bucket name and file path in a single HTTP request.
104
+ *
105
+ * Returns a streaming body suitable for small-to-medium files. For large files
106
+ * that benefit from concurrent ranged fetches, use
107
+ * {@link createParallelDownloadStream} instead.
108
+ *
109
+ * @param raw - Low-level B2 API client.
110
+ * @param accountInfo - Authorized account state.
111
+ * @param options - Download parameters.
112
+ *
113
+ * @returns Parsed headers and a readable stream of file bytes.
114
+ */
115
+ export declare function downloadByName(raw: RawClient, accountInfo: AccountInfo, options: DownloadByNameOptions): Promise<DownloadResult>;
116
+ /**
117
+ * Issues a HEAD-by-ID request and returns parsed headers only. Drains
118
+ * the (logically empty) response body internally so callers don't have
119
+ * to remember to `body.cancel()` themselves.
120
+ *
121
+ * Prefer this over `downloadById({ method: 'HEAD' })` — same wire-level
122
+ * effect, but the caller-facing result has no `body` field at all so
123
+ * there's nothing to clean up.
124
+ *
125
+ * @param raw - Low-level B2 API client.
126
+ * @param accountInfo - Authorized account state.
127
+ * @param options - HEAD parameters (file ID + the same response-header
128
+ * overrides and abort signal that `downloadById` accepts).
129
+ *
130
+ * @returns Parsed download headers (no body field).
131
+ */
132
+ export declare function headById(raw: RawClient, accountInfo: AccountInfo, options: HeadByIdOptions): Promise<HeadResult>;
133
+ /**
134
+ * Issues a HEAD-by-name request and returns parsed headers only. Drains
135
+ * the (logically empty) response body internally so callers don't have
136
+ * to remember to `body.cancel()` themselves.
137
+ *
138
+ * Prefer this over `downloadByName({ method: 'HEAD' })` — same wire-level
139
+ * effect, but the caller-facing result has no `body` field at all so
140
+ * there's nothing to clean up.
141
+ *
142
+ * @param raw - Low-level B2 API client.
143
+ * @param accountInfo - Authorized account state.
144
+ * @param options - HEAD parameters (bucket + file name + the same
145
+ * response-header overrides and abort signal that `downloadByName`
146
+ * accepts).
147
+ *
148
+ * @returns Parsed download headers (no body field).
149
+ */
150
+ export declare function headByName(raw: RawClient, accountInfo: AccountInfo, options: HeadByNameOptions): Promise<HeadResult>;
151
+ export {};
152
+ //# sourceMappingURL=single.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/download/single.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAK,EAAuB,SAAS,EAAE,eAAe,EAAE,MA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;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAerB"}
@@ -0,0 +1,117 @@
1
+ import { parseFileInfoHeaders } from "../raw/encoding.js";
2
+ import { ProgressTracker } from "../streams/progress.js";
3
+ import { fileId } from "../types/ids.js";
4
+ import { bestEffort } from "../util/best-effort.js";
5
+ import { normalizeSha1 } from "../util/normalize.js";
6
+ async function downloadById(raw, accountInfo, options) {
7
+ const resp = await raw.downloadFileById(
8
+ accountInfo.getDownloadUrl(),
9
+ accountInfo.getAuthToken(),
10
+ options.fileId,
11
+ toRawDownloadOptions(options)
12
+ );
13
+ const headers = extractDownloadHeaders(resp.headers);
14
+ return {
15
+ headers,
16
+ // HEAD requests legitimately have no body; return an empty stream so the
17
+ // result shape stays consistent.
18
+ body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress)
19
+ };
20
+ }
21
+ async function downloadByName(raw, accountInfo, options) {
22
+ const resp = await raw.downloadFileByName(
23
+ accountInfo.getDownloadUrl(),
24
+ accountInfo.getAuthToken(),
25
+ options.bucketName,
26
+ options.fileName,
27
+ toRawDownloadOptions(options)
28
+ );
29
+ const headers = extractDownloadHeaders(resp.headers);
30
+ return {
31
+ headers,
32
+ body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress)
33
+ };
34
+ }
35
+ async function headById(raw, accountInfo, options) {
36
+ const resp = await raw.downloadFileById(
37
+ accountInfo.getDownloadUrl(),
38
+ accountInfo.getAuthToken(),
39
+ options.fileId,
40
+ { ...toRawDownloadOptions(options), method: "HEAD" }
41
+ );
42
+ if (resp.body !== null) {
43
+ const body = resp.body;
44
+ await bestEffort(() => body.cancel());
45
+ }
46
+ return { headers: extractDownloadHeaders(resp.headers) };
47
+ }
48
+ async function headByName(raw, accountInfo, options) {
49
+ const resp = await raw.downloadFileByName(
50
+ accountInfo.getDownloadUrl(),
51
+ accountInfo.getAuthToken(),
52
+ options.bucketName,
53
+ options.fileName,
54
+ { ...toRawDownloadOptions(options), method: "HEAD" }
55
+ );
56
+ if (resp.body !== null) {
57
+ const body = resp.body;
58
+ await bestEffort(() => body.cancel());
59
+ }
60
+ return { headers: extractDownloadHeaders(resp.headers) };
61
+ }
62
+ function toRawDownloadOptions(options) {
63
+ return {
64
+ ...options.method !== void 0 ? { method: options.method } : {},
65
+ ...options.range !== void 0 ? { range: options.range } : {},
66
+ ...options.serverSideEncryption !== void 0 ? { serverSideEncryption: options.serverSideEncryption } : {},
67
+ ...options.b2ContentDisposition !== void 0 ? { b2ContentDisposition: options.b2ContentDisposition } : {},
68
+ ...options.b2ContentLanguage !== void 0 ? { b2ContentLanguage: options.b2ContentLanguage } : {},
69
+ ...options.b2ContentEncoding !== void 0 ? { b2ContentEncoding: options.b2ContentEncoding } : {},
70
+ ...options.b2ContentType !== void 0 ? { b2ContentType: options.b2ContentType } : {},
71
+ ...options.b2CacheControl !== void 0 ? { b2CacheControl: options.b2CacheControl } : {},
72
+ ...options.b2Expires !== void 0 ? { b2Expires: options.b2Expires } : {},
73
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
74
+ };
75
+ }
76
+ function emptyStream() {
77
+ return new ReadableStream({
78
+ start(controller) {
79
+ controller.close();
80
+ }
81
+ });
82
+ }
83
+ function instrumentProgress(body, totalBytes, listener) {
84
+ if (listener === void 0) return body;
85
+ const tracker = new ProgressTracker(listener, totalBytes, 1);
86
+ const transform = new TransformStream({
87
+ transform(chunk, controller) {
88
+ tracker.addBytes(chunk.byteLength);
89
+ controller.enqueue(chunk);
90
+ },
91
+ flush() {
92
+ tracker.completePart();
93
+ }
94
+ });
95
+ return body.pipeThrough(transform);
96
+ }
97
+ function extractDownloadHeaders(headers) {
98
+ const fileInfo = parseFileInfoHeaders(headers);
99
+ return {
100
+ contentType: headers.get("Content-Type") ?? "application/octet-stream",
101
+ contentLength: Number.parseInt(headers.get("Content-Length") ?? "0", 10),
102
+ // B2 sends the literal `'none'` for multipart-finished files; collapse
103
+ // to `null` so the typed `string | null` actually means "no SHA-1".
104
+ contentSha1: normalizeSha1(headers.get("X-Bz-Content-Sha1")),
105
+ fileId: fileId(headers.get("X-Bz-File-Id") ?? ""),
106
+ fileName: decodeURIComponent(headers.get("X-Bz-File-Name") ?? ""),
107
+ fileInfo,
108
+ uploadTimestamp: Number.parseInt(headers.get("X-Bz-Upload-Timestamp") ?? "0", 10)
109
+ };
110
+ }
111
+ export {
112
+ downloadById,
113
+ downloadByName,
114
+ headById,
115
+ headByName
116
+ };
117
+ //# sourceMappingURL=single.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.js","sources":["../../src/download/single.ts"],"sourcesContent":["import type { AccountInfo } from '../auth/account-info.ts'\nimport { parseFileInfoHeaders } from '../raw/encoding.ts'\nimport type { DownloadFileOptions, RawClient, SseCDownloadKey } from '../raw/index.ts'\nimport { type ProgressListener, ProgressTracker } from '../streams/progress.ts'\nimport type { DownloadHeaders } from '../types/download.ts'\nimport { type FileId, fileId as fileIdOf } from '../types/ids.ts'\nimport { bestEffort } from '../util/best-effort.ts'\nimport { normalizeSha1 } from '../util/normalize.ts'\n\n/** Result of a single-request file download. */\nexport interface DownloadResult {\n /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */\n readonly headers: DownloadHeaders\n /** Streaming body of the downloaded file. */\n readonly body: ReadableStream<Uint8Array>\n}\n\n/**\n * Result of a HEAD-style metadata fetch. Unlike {@link DownloadResult},\n * this shape has **no** `body` field — the SDK consumes and discards the\n * (logically empty) HEAD response body internally so callers never have\n * to remember to `body.cancel()` after a metadata-only fetch.\n */\nexport interface HeadResult {\n /** Parsed B2 response headers (content type, SHA-1, file info, etc.). */\n readonly headers: DownloadHeaders\n}\n\n/** Shared download options exposed at the high-level facade. */\ninterface DownloadCommonOptions {\n /** HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only response headers without streaming the body. */\n readonly method?: 'GET' | 'HEAD'\n /** Optional HTTP Range header value (e.g. `bytes=0-999`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Signal to abort the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as bytes flow through the returned `body` stream.\n *\n * Wraps the response body in a `TransformStream` that increments a\n * `ProgressTracker` per chunk and emits a `partsCompleted: 1` event when\n * the stream finishes. `totalBytes` is the response's `Content-Length`\n * header (or `null` if the server didn't send one — rare for B2).\n *\n * If the caller does not read the returned body to completion, the\n * tracker's `completePart()` event will not fire. That is intentional:\n * progress is byte-driven, not request-driven.\n */\n readonly onProgress?: ProgressListener\n}\n\n/** Options for downloading a file by its unique ID. */\nexport interface DownloadByIdOptions extends DownloadCommonOptions {\n /** ID of the file version to download. */\n readonly fileId: FileId\n}\n\n/** Options for downloading a file by bucket name and file path. */\nexport interface DownloadByNameOptions extends DownloadCommonOptions {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full file name (path) within the bucket. */\n readonly fileName: string\n}\n\n/**\n * Shared HEAD options. Mirrors {@link DownloadCommonOptions} but omits\n * `method` (always HEAD) and `onProgress` (no body to track).\n */\ntype HeadCommonOptions = Omit<DownloadCommonOptions, 'method' | 'onProgress'>\n\n/** Options for a HEAD-by-ID request. */\nexport interface HeadByIdOptions extends HeadCommonOptions {\n /** ID of the file version to inspect. */\n readonly fileId: FileId\n}\n\n/** Options for a HEAD-by-name request. */\nexport interface HeadByNameOptions extends HeadCommonOptions {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full file name (path) within the bucket. */\n readonly fileName: string\n}\n\n/**\n * Downloads a file by its unique ID in a single HTTP request.\n *\n * Returns a streaming body suitable for small-to-medium files. For large files\n * that benefit from concurrent ranged fetches, use\n * {@link createParallelDownloadStream} instead.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - Download parameters.\n *\n * @returns Parsed headers and a readable stream of file bytes.\n */\nexport async function downloadById(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: DownloadByIdOptions,\n): Promise<DownloadResult> {\n const resp = await raw.downloadFileById(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.fileId,\n toRawDownloadOptions(options),\n )\n\n const headers = extractDownloadHeaders(resp.headers)\n return {\n headers,\n // HEAD requests legitimately have no body; return an empty stream so the\n // result shape stays consistent.\n body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress),\n }\n}\n\n/**\n * Downloads a file by bucket name and file path in a single HTTP request.\n *\n * Returns a streaming body suitable for small-to-medium files. For large files\n * that benefit from concurrent ranged fetches, use\n * {@link createParallelDownloadStream} instead.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - Download parameters.\n *\n * @returns Parsed headers and a readable stream of file bytes.\n */\nexport async function downloadByName(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: DownloadByNameOptions,\n): Promise<DownloadResult> {\n const resp = await raw.downloadFileByName(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.bucketName,\n options.fileName,\n toRawDownloadOptions(options),\n )\n\n const headers = extractDownloadHeaders(resp.headers)\n return {\n headers,\n body: instrumentProgress(resp.body ?? emptyStream(), headers.contentLength, options.onProgress),\n }\n}\n\n/**\n * Issues a HEAD-by-ID request and returns parsed headers only. Drains\n * the (logically empty) response body internally so callers don't have\n * to remember to `body.cancel()` themselves.\n *\n * Prefer this over `downloadById({ method: 'HEAD' })` — same wire-level\n * effect, but the caller-facing result has no `body` field at all so\n * there's nothing to clean up.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - HEAD parameters (file ID + the same response-header\n * overrides and abort signal that `downloadById` accepts).\n *\n * @returns Parsed download headers (no body field).\n */\nexport async function headById(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: HeadByIdOptions,\n): Promise<HeadResult> {\n const resp = await raw.downloadFileById(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.fileId,\n { ...toRawDownloadOptions(options), method: 'HEAD' },\n )\n // Body for HEAD is normally `null` per the fetch spec. Some transports\n // (notably the SDK's `B2Simulator`) synthesize a non-null body for\n // shape consistency. In either case, cancelling is a no-op for the\n // caller; wrap in `bestEffort` so a stream-lifecycle quirk in a\n // future runtime can't fail an otherwise-successful HEAD.\n if (resp.body !== null) {\n // Bind to a local so the type narrowing carries into the closure;\n // bare `resp.body` in the lambda would re-broaden to `... | null`.\n const body = resp.body\n await bestEffort(() => body.cancel())\n }\n return { headers: extractDownloadHeaders(resp.headers) }\n}\n\n/**\n * Issues a HEAD-by-name request and returns parsed headers only. Drains\n * the (logically empty) response body internally so callers don't have\n * to remember to `body.cancel()` themselves.\n *\n * Prefer this over `downloadByName({ method: 'HEAD' })` — same wire-level\n * effect, but the caller-facing result has no `body` field at all so\n * there's nothing to clean up.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state.\n * @param options - HEAD parameters (bucket + file name + the same\n * response-header overrides and abort signal that `downloadByName`\n * accepts).\n *\n * @returns Parsed download headers (no body field).\n */\nexport async function headByName(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: HeadByNameOptions,\n): Promise<HeadResult> {\n const resp = await raw.downloadFileByName(\n accountInfo.getDownloadUrl(),\n accountInfo.getAuthToken(),\n options.bucketName,\n options.fileName,\n { ...toRawDownloadOptions(options), method: 'HEAD' },\n )\n if (resp.body !== null) {\n // Bind to a local so the type narrowing carries into the closure;\n // bare `resp.body` in the lambda would re-broaden to `... | null`.\n const body = resp.body\n await bestEffort(() => body.cancel())\n }\n return { headers: extractDownloadHeaders(resp.headers) }\n}\n\n/**\n * Translates the public download-options shape into the raw client's\n * {@link DownloadFileOptions}, dropping the request-target fields (`fileId`,\n * `bucketName`, `fileName`) that don't apply at the transport layer.\n *\n * @param options - Caller-supplied download options.\n *\n * @returns The raw transport-layer options.\n */\nfunction toRawDownloadOptions(options: DownloadCommonOptions): DownloadFileOptions {\n return {\n ...(options.method !== undefined ? { method: options.method } : {}),\n ...(options.range !== undefined ? { range: options.range } : {}),\n ...(options.serverSideEncryption !== undefined\n ? { serverSideEncryption: options.serverSideEncryption }\n : {}),\n ...(options.b2ContentDisposition !== undefined\n ? { b2ContentDisposition: options.b2ContentDisposition }\n : {}),\n ...(options.b2ContentLanguage !== undefined\n ? { b2ContentLanguage: options.b2ContentLanguage }\n : {}),\n ...(options.b2ContentEncoding !== undefined\n ? { b2ContentEncoding: options.b2ContentEncoding }\n : {}),\n ...(options.b2ContentType !== undefined ? { b2ContentType: options.b2ContentType } : {}),\n ...(options.b2CacheControl !== undefined ? { b2CacheControl: options.b2CacheControl } : {}),\n ...(options.b2Expires !== undefined ? { b2Expires: options.b2Expires } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n }\n}\n\n/**\n * Builds an immediately-closed empty ReadableStream. Used as the body of a\n * HEAD download response so callers always get a stream they can `pipeTo`.\n *\n * @returns A ReadableStream that yields zero bytes and immediately closes.\n */\nfunction emptyStream(): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.close()\n },\n })\n}\n\n/**\n * Wraps a body stream with a `TransformStream` that increments a\n * {@link ProgressTracker} for each chunk and reports `partsCompleted: 1`\n * when the stream finishes.\n *\n * When `listener` is undefined the function short-circuits and returns\n * the original stream, so unobserved downloads pay no overhead.\n *\n * @param body - The download response body to wrap.\n * @param totalBytes - Expected total bytes (response `Content-Length`).\n * @param listener - Caller-supplied progress callback, or undefined.\n *\n * @returns A stream that emits the same bytes and reports progress.\n */\nfunction instrumentProgress(\n body: ReadableStream<Uint8Array>,\n totalBytes: number,\n listener: ProgressListener | undefined,\n): ReadableStream<Uint8Array> {\n if (listener === undefined) return body\n const tracker = new ProgressTracker(listener, totalBytes, 1)\n const transform = new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n tracker.addBytes(chunk.byteLength)\n controller.enqueue(chunk)\n },\n flush() {\n tracker.completePart()\n },\n })\n return body.pipeThrough(transform)\n}\n\n/**\n * Extracts B2-specific download headers into a structured object.\n * @param headers - The HTTP response headers from the download.\n *\n * @returns The parsed download metadata.\n */\nfunction extractDownloadHeaders(headers: Headers): DownloadHeaders {\n const fileInfo = parseFileInfoHeaders(headers)\n\n return {\n contentType: headers.get('Content-Type') ?? 'application/octet-stream',\n contentLength: Number.parseInt(headers.get('Content-Length') ?? '0', 10),\n // B2 sends the literal `'none'` for multipart-finished files; collapse\n // to `null` so the typed `string | null` actually means \"no SHA-1\".\n contentSha1: normalizeSha1(headers.get('X-Bz-Content-Sha1')),\n fileId: fileIdOf(headers.get('X-Bz-File-Id') ?? ''),\n fileName: decodeURIComponent(headers.get('X-Bz-File-Name') ?? ''),\n fileInfo,\n uploadTimestamp: Number.parseInt(headers.get('X-Bz-Upload-Timestamp') ?? '0', 10),\n }\n}\n"],"names":["fileIdOf"],"mappings":";;;;;AAgHA,eAAsB,aACpB,KACA,aACA,SACyB;AACzB,QAAM,OAAO,MAAM,IAAI;AAAA,IACrB,YAAY,eAAA;AAAA,IACZ,YAAY,aAAA;AAAA,IACZ,QAAQ;AAAA,IACR,qBAAqB,OAAO;AAAA,EAAA;AAG9B,QAAM,UAAU,uBAAuB,KAAK,OAAO;AACnD,SAAO;AAAA,IACL;AAAA;AAAA;AAAA,IAGA,MAAM,mBAAmB,KAAK,QAAQ,eAAe,QAAQ,eAAe,QAAQ,UAAU;AAAA,EAAA;AAElG;AAeA,eAAsB,eACpB,KACA,aACA,SACyB;AACzB,QAAM,OAAO,MAAM,IAA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