@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 @@
1
+ {"version":3,"file":"stream.js","sources":["../../src/upload/stream.ts"],"sourcesContent":["import type { AccountInfo } from '../auth/account-info.ts'\nimport type { RawClient } from '../raw/index.ts'\nimport { IncrementalSha1 } from '../streams/hash.ts'\nimport type { ProgressListener } from '../streams/progress.ts'\nimport { ProgressTracker } from '../streams/progress.ts'\nimport type { EncryptionSetting } from '../types/encryption.ts'\nimport type { FileVersion } from '../types/file.ts'\nimport type { BucketId, LargeFileId } from '../types/ids.ts'\nimport { DEFAULT_CONTENT_TYPE, DEFAULT_TRANSFER_CONCURRENCY } from '../util/defaults.ts'\nimport { toError } from '../util/to-error.ts'\nimport { cancelLargeFileBestEffort } from './cancel.ts'\nimport { Semaphore } from './concurrency.ts'\n\n/** Options for creating a streaming multipart upload sink. */\nexport interface CreateWriteStreamOptions {\n /** Target bucket for the upload. */\n readonly bucketId: BucketId\n /** Destination file name in the bucket. */\n readonly fileName: string\n /** MIME type. Defaults to `b2/x-auto`. */\n readonly contentType?: string\n /** Custom file info stored with the file. */\n readonly fileInfo?: Record<string, string>\n /** Server-side encryption applied to each part. */\n readonly serverSideEncryption?: EncryptionSetting\n /**\n * Target part size in bytes. The stream buffers writes until this many bytes\n * are accumulated, then ships a part. Must be at least the account's\n * absolute minimum part size; the implementation will raise it if too small.\n */\n readonly partSize?: number\n /** Maximum number of parts uploaded in parallel. Defaults to 4. */\n readonly concurrency?: number\n /** Callback invoked with upload progress events. `totalBytes` is `null` (size unknown). */\n readonly onProgress?: ProgressListener\n /** Aborts the upload and cancels the unfinished large file. */\n readonly signal?: AbortSignal\n}\n\n/**\n * Handle returned by `B2Object.createWriteStream`: the Web `WritableStream` to\n * pipe data into, plus a promise that resolves with the finished\n * {@link FileVersion} once the stream is closed and all parts have been\n * uploaded.\n */\nexport interface UploadWriteHandle {\n /** Web `WritableStream` sink to pipe data into. */\n readonly writable: WritableStream<Uint8Array>\n /** Resolves with the finalized file version when the stream closes successfully. */\n readonly done: Promise<FileVersion>\n}\n\n/**\n * Creates a {@link WritableStream} that streams data into a B2 multipart upload.\n *\n * Buffers incoming chunks until `partSize` bytes are accumulated, ships each\n * complete part through the standard multipart engine, and finalizes the file\n * once the stream is closed. Honours backpressure via the queue's bounded\n * concurrency. Streaming uploads do not support resume because the total size\n * and per-part hashes aren't known in advance; use {@link uploadLargeFile} with\n * a buffered source when resume is required.\n *\n * @param raw - Low-level B2 API client.\n * @param accountInfo - Authorized account state (tokens, URLs, part URL pool).\n * @param options - Streaming upload parameters.\n *\n * @returns A {@link UploadWriteHandle} with the writable sink and a completion promise.\n */\nexport function createWriteStream(\n raw: RawClient,\n accountInfo: AccountInfo,\n options: CreateWriteStreamOptions,\n): UploadWriteHandle {\n const minPartSize = accountInfo.getAbsoluteMinimumPartSize()\n const recommendedPartSize = accountInfo.getRecommendedPartSize()\n const partSize = Math.max(options.partSize ?? recommendedPartSize, minPartSize)\n const concurrency = options.concurrency ?? DEFAULT_TRANSFER_CONCURRENCY\n const tracker = new ProgressTracker(options.onProgress, null, null)\n const sem = new Semaphore(concurrency)\n\n let largeFileId: LargeFileId | null = null\n let startPromise: Promise<LargeFileId> | null = null\n let nextPartNumber = 1\n let pendingBytes = 0\n const pending: Uint8Array[] = []\n const partSha1s: string[] = []\n const inflight: Promise<void>[] = []\n let errored: Error | null = null\n\n // ES2024 `Promise.withResolvers()` exposes the resolve/reject pair as\n // properties of the returned object, avoiding the `let resolve!:` /\n // `let reject!:` non-null-assertion pattern needed before this API\n // existed. Available in Node 22 (our minimum), Bun, Deno, modern\n // browsers, and Cloudflare Workers.\n const {\n promise: done,\n resolve: resolveDone,\n reject: rejectDone,\n } = Promise.withResolvers<FileVersion>()\n // Attach a no-op rejection handler so a `done` that rejects before the\n // caller observes it never surfaces as a process-level unhandled rejection.\n // The error is not swallowed: `close()`/`abort()` also reject the writable\n // (so `pipeTo`/`getWriter().close()` throw), and any later `await done` /\n // `done.then(onRejected)` the caller attaches still sees the rejection —\n // extra handlers on the same promise all fire. Mirrors the\n // `task.catch(() => {})` pattern used for inflight part uploads below, and\n // keeps the engine well-behaved under Bun and Node's strict\n // unhandled-rejection mode.\n done.catch(() => {})\n\n function ensureStarted(): Promise<LargeFileId> {\n if (largeFileId !== null) return Promise.resolve(largeFileId)\n if (startPromise !== null) return startPromise\n startPromise = (async () => {\n const resp = await raw.startLargeFile(accountInfo.getApiUrl(), accountInfo.getAuthToken(), {\n bucketId: options.bucketId,\n fileName: options.fileName,\n contentType: options.contentType ?? DEFAULT_CONTENT_TYPE,\n fileInfo: options.fileInfo ?? {},\n ...(options.serverSideEncryption !== undefined\n ? { serverSideEncryption: options.serverSideEncryption }\n : {}),\n })\n largeFileId = resp.fileId\n return largeFileId\n })()\n return startPromise\n }\n\n async function shipPart(data: Uint8Array, partNumber: number): Promise<void> {\n const fileId = await ensureStarted()\n\n const sha1 = new IncrementalSha1()\n await sha1.update(data)\n const sha1Hex = await sha1.digest()\n\n let uploadEntry = accountInfo.checkoutPartUploadUrl(fileId)\n if (!uploadEntry) {\n const resp = await raw.getUploadPartUrl(accountInfo.getApiUrl(), accountInfo.getAuthToken(), {\n fileId,\n })\n uploadEntry = { uploadUrl: resp.uploadUrl, authorizationToken: resp.authorizationToken }\n }\n\n try {\n const result = await raw.uploadPart(\n uploadEntry.uploadUrl,\n {\n authorization: uploadEntry.authorizationToken,\n partNumber,\n contentLength: data.byteLength,\n contentSha1: sha1Hex,\n ...(options.serverSideEncryption !== undefined\n ? { serverSideEncryption: options.serverSideEncryption }\n : {}),\n },\n data as BodyInit,\n options.signal,\n )\n accountInfo.returnPartUploadUrl(fileId, uploadEntry)\n partSha1s[partNumber - 1] = result.contentSha1\n tracker.addBytes(data.byteLength)\n tracker.completePart()\n } catch (err) {\n accountInfo.evictPartUploadUrl(fileId, uploadEntry)\n throw err\n }\n }\n\n function dispatchPart(): void {\n if (pending.length === 0) return\n let data: Uint8Array\n if (pending.length === 1) {\n const head = pending[0]\n if (!head) return\n data = head\n } else {\n const total = pending.reduce((sum, chunk) => sum + chunk.byteLength, 0)\n data = new Uint8Array(total)\n let offset = 0\n for (const chunk of pending) {\n data.set(chunk, offset)\n offset += chunk.byteLength\n }\n }\n pending.length = 0\n pendingBytes = 0\n const partNumber = nextPartNumber++\n const task = (async () => {\n await sem.acquire()\n try {\n await shipPart(data, partNumber)\n } catch (err) {\n errored = toError(err)\n throw err\n } finally {\n sem.release()\n }\n })()\n inflight.push(task)\n // Swallow rejection here; we check `errored` later.\n task.catch(() => {})\n }\n\n const writable = new WritableStream<Uint8Array>({\n async write(chunk: Uint8Array): Promise<void> {\n if (errored) throw errored\n options.signal?.throwIfAborted()\n\n pending.push(chunk)\n pendingBytes += chunk.byteLength\n while (pendingBytes >= partSize) {\n // Pull exactly partSize bytes off the front\n const carved = carveExact(pending, partSize)\n const partNumber = nextPartNumber++\n pendingBytes -= partSize\n const task = (async () => {\n await sem.acquire()\n try {\n await shipPart(carved, partNumber)\n } catch (err) {\n errored = toError(err)\n throw err\n } finally {\n sem.release()\n }\n })()\n inflight.push(task)\n task.catch(() => {})\n }\n },\n\n async close(): Promise<void> {\n try {\n if (errored) throw errored\n options.signal?.throwIfAborted()\n\n // Ship any remaining bytes as the last part. If the total fit in one\n // single buffered batch (no parts shipped yet), we have to use the\n // multipart path anyway since we already called startLargeFile lazily.\n if (pendingBytes > 0) {\n dispatchPart()\n }\n\n await Promise.all(inflight)\n if (errored) throw errored\n\n if (largeFileId === null) {\n // Stream closed before any data was written. Start an empty large\n // file? B2 requires at least 2 parts. Reject — callers shouldn't\n // close an empty stream.\n throw new Error('createWriteStream closed without any data written.')\n }\n\n const result = await raw.finishLargeFile(\n accountInfo.getApiUrl(),\n accountInfo.getAuthToken(),\n { fileId: largeFileId, partSha1Array: partSha1s },\n )\n resolveDone(result)\n } catch (err) {\n // Capture into a const so the cancel closure sees a non-null\n // `fileId`; closures don't observe the outer `!== null` narrowing\n // because the variable is mutable across the lambda boundary.\n const fileIdToCancel = largeFileId\n if (fileIdToCancel !== null) {\n await cancelLargeFileBestEffort(raw, accountInfo, fileIdToCancel)\n }\n rejectDone(err)\n throw err\n }\n },\n\n async abort(reason: unknown): Promise<void> {\n const fileIdToCancel = largeFileId\n if (fileIdToCancel !== null) {\n await cancelLargeFileBestEffort(raw, accountInfo, fileIdToCancel)\n }\n rejectDone(toError(reason))\n },\n })\n\n return { writable, done }\n}\n\n/**\n * Removes exactly `size` bytes from the front of `chunks` (mutates) and returns\n * them as a contiguous Uint8Array. Any trailing remainder of the last chunk\n * stays at the front of `chunks` for the next part.\n *\n * @param chunks - Queue of pending chunks. Modified in place.\n * @param size - Number of bytes to carve off the front.\n *\n * @returns A new Uint8Array containing exactly `size` bytes.\n */\nfunction carveExact(chunks: Uint8Array[], size: number): Uint8Array {\n const out = new Uint8Array(size)\n let written = 0\n while (written < size && chunks.length > 0) {\n const head = chunks[0]\n if (!head) break\n const need = size - written\n if (head.byteLength <= need) {\n out.set(head, written)\n written += head.byteLength\n chunks.shift()\n } else {\n out.set(head.subarray(0, need), written)\n chunks[0] = head.subarray(need)\n written += need\n }\n }\n return out\n}\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ async function bestEffort(fn) {
4
+ try {
5
+ await fn();
6
+ } catch {
7
+ }
8
+ }
9
+ exports.bestEffort = bestEffort;
10
+ //# sourceMappingURL=best-effort.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"best-effort.cjs","sources":["../../src/util/best-effort.ts"],"sourcesContent":["/**\n * Runs an async cleanup operation and swallows any rejection.\n *\n * Used at error-handling boundaries (e.g. after a multipart upload fails,\n * when trying to `cancelLargeFile` on the orphaned upload). The primary\n * error is what the caller wants to see; a secondary failure during\n * cleanup must not shadow it.\n *\n * Naming the pattern instead of inlining a try/catch with an empty catch\n * makes the intent explicit at the call site: this is best-effort cleanup,\n * not a silent error swallow.\n *\n * @param fn - Cleanup async function. Its return value is ignored; any\n * thrown error or rejected promise is caught and discarded.\n *\n * @returns A promise that always resolves, regardless of `fn`'s outcome.\n *\n * @example\n * ```ts\n * try {\n * await uploadParts(...)\n * } catch (err) {\n * await bestEffort(() =>\n * raw.cancelLargeFile(apiUrl, authToken, { fileId: largeFileId }),\n * )\n * throw err\n * }\n * ```\n */\nexport async function bestEffort(fn: () => Promise<unknown>): Promise<void> {\n try {\n await fn()\n } catch {\n // Intentional swallow: this helper exists for cleanup paths where a\n // secondary failure must not shadow the primary error.\n }\n}\n"],"names":[],"mappings":";;AA6BA,eAAsB,WAAW,IAA2C;AAC1E,MAAI;AACF,UAAM,GAAA;AAAA,EACR,QAAQ;AAAA,EAGR;AACF;;"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Runs an async cleanup operation and swallows any rejection.
3
+ *
4
+ * Used at error-handling boundaries (e.g. after a multipart upload fails,
5
+ * when trying to `cancelLargeFile` on the orphaned upload). The primary
6
+ * error is what the caller wants to see; a secondary failure during
7
+ * cleanup must not shadow it.
8
+ *
9
+ * Naming the pattern instead of inlining a try/catch with an empty catch
10
+ * makes the intent explicit at the call site: this is best-effort cleanup,
11
+ * not a silent error swallow.
12
+ *
13
+ * @param fn - Cleanup async function. Its return value is ignored; any
14
+ * thrown error or rejected promise is caught and discarded.
15
+ *
16
+ * @returns A promise that always resolves, regardless of `fn`'s outcome.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * try {
21
+ * await uploadParts(...)
22
+ * } catch (err) {
23
+ * await bestEffort(() =>
24
+ * raw.cancelLargeFile(apiUrl, authToken, { fileId: largeFileId }),
25
+ * )
26
+ * throw err
27
+ * }
28
+ * ```
29
+ */
30
+ export declare function bestEffort(fn: () => Promise<unknown>): Promise<void>;
31
+ //# sourceMappingURL=best-effort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"best-effort.d.ts","sourceRoot":"","sources":["../../src/util/best-effort.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1E"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Runs an async cleanup operation and swallows any rejection.
3
+ *
4
+ * Used at error-handling boundaries (e.g. after a multipart upload fails,
5
+ * when trying to `cancelLargeFile` on the orphaned upload). The primary
6
+ * error is what the caller wants to see; a secondary failure during
7
+ * cleanup must not shadow it.
8
+ *
9
+ * Naming the pattern instead of inlining a try/catch with an empty catch
10
+ * makes the intent explicit at the call site: this is best-effort cleanup,
11
+ * not a silent error swallow.
12
+ *
13
+ * @param fn - Cleanup async function. Its return value is ignored; any
14
+ * thrown error or rejected promise is caught and discarded.
15
+ *
16
+ * @returns A promise that always resolves, regardless of `fn`'s outcome.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * try {
21
+ * await uploadParts(...)
22
+ * } catch (err) {
23
+ * await bestEffort(() =>
24
+ * raw.cancelLargeFile(apiUrl, authToken, { fileId: largeFileId }),
25
+ * )
26
+ * throw err
27
+ * }
28
+ * ```
29
+ */
30
+ export declare function bestEffort(fn: () => Promise<unknown>): Promise<void>;
31
+ //# sourceMappingURL=best-effort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"best-effort.d.ts","sourceRoot":"","sources":["../../src/util/best-effort.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1E"}
@@ -0,0 +1,10 @@
1
+ async function bestEffort(fn) {
2
+ try {
3
+ await fn();
4
+ } catch {
5
+ }
6
+ }
7
+ export {
8
+ bestEffort
9
+ };
10
+ //# sourceMappingURL=best-effort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"best-effort.js","sources":["../../src/util/best-effort.ts"],"sourcesContent":["/**\n * Runs an async cleanup operation and swallows any rejection.\n *\n * Used at error-handling boundaries (e.g. after a multipart upload fails,\n * when trying to `cancelLargeFile` on the orphaned upload). The primary\n * error is what the caller wants to see; a secondary failure during\n * cleanup must not shadow it.\n *\n * Naming the pattern instead of inlining a try/catch with an empty catch\n * makes the intent explicit at the call site: this is best-effort cleanup,\n * not a silent error swallow.\n *\n * @param fn - Cleanup async function. Its return value is ignored; any\n * thrown error or rejected promise is caught and discarded.\n *\n * @returns A promise that always resolves, regardless of `fn`'s outcome.\n *\n * @example\n * ```ts\n * try {\n * await uploadParts(...)\n * } catch (err) {\n * await bestEffort(() =>\n * raw.cancelLargeFile(apiUrl, authToken, { fileId: largeFileId }),\n * )\n * throw err\n * }\n * ```\n */\nexport async function bestEffort(fn: () => Promise<unknown>): Promise<void> {\n try {\n await fn()\n } catch {\n // Intentional swallow: this helper exists for cleanup paths where a\n // secondary failure must not shadow the primary error.\n }\n}\n"],"names":[],"mappings":"AA6BA,eAAsB,WAAW,IAA2C;AAC1E,MAAI;AACF,UAAM,GAAA;AAAA,EACR,QAAQ;AAAA,EAGR;AACF;"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const DEFAULT_TRANSFER_CONCURRENCY = 4;
4
+ const DEFAULT_BULK_CONCURRENCY = 10;
5
+ const DEFAULT_PAGE_SIZE = 1e3;
6
+ const DEFAULT_CONTENT_TYPE = "b2/x-auto";
7
+ exports.DEFAULT_BULK_CONCURRENCY = DEFAULT_BULK_CONCURRENCY;
8
+ exports.DEFAULT_CONTENT_TYPE = DEFAULT_CONTENT_TYPE;
9
+ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
10
+ exports.DEFAULT_TRANSFER_CONCURRENCY = DEFAULT_TRANSFER_CONCURRENCY;
11
+ //# sourceMappingURL=defaults.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.cjs","sources":["../../src/util/defaults.ts"],"sourcesContent":["/**\n * Shared SDK-wide default values.\n *\n * Centralising defaults here makes the trade-offs visible and prevents the\n * drift that creeps in when each module hard-codes its own magic number.\n *\n * @packageDocumentation\n */\n\n/**\n * Default parallel-task count for **data-transfer** operations: uploads\n * (multipart parts), downloads (byte ranges), server-side copies (parts),\n * and sync (file-by-file). Each in-flight task occupies one transport\n * slot and at least one part-worth of memory, so we keep this\n * conservative.\n *\n * Empirically `4` saturates a typical home / office uplink without\n * starving the event loop or risking B2's per-account upload-URL\n * rate-limit. Callers that have measured their environment can override\n * via the `concurrency` option on every transfer method.\n */\nexport const DEFAULT_TRANSFER_CONCURRENCY = 4\n\n/**\n * Default parallel-task count for **bulk metadata** operations:\n * `Bucket.deleteMany` (per-version delete calls), and the action loop in\n * `synchronize` when it dispatches mixed actions in batches.\n *\n * Higher than the transfer default because each task is a tiny API\n * round-trip (no payload), so concurrency is bound by API latency rather\n * than bandwidth or local memory. `10` keeps a delete-of-thousands\n * snappy without overwhelming a single account's request budget.\n */\nexport const DEFAULT_BULK_CONCURRENCY = 10\n\n/**\n * Default `maxFileCount` for list-style endpoints\n * (`b2_list_file_names`, `b2_list_file_versions`, `b2_list_parts`). B2\n * caps `maxFileCount` at `10000` for these endpoints; the SDK requests\n * `1000` per page so a single network blip doesn't lose 10× the work and\n * so callers see results sooner.\n *\n * `b2_list_unfinished_large_files` is capped at `100` server-side and is\n * not affected by this constant.\n */\nexport const DEFAULT_PAGE_SIZE = 1000\n\n/**\n * Default MIME type for uploads when the caller omits `contentType`.\n * B2 documents `b2/x-auto` as the magic value that asks the service to\n * sniff the file's content and pick a sensible `Content-Type` itself.\n * Centralising the literal here keeps the upload, copy, and create-write\n * paths in sync.\n *\n * @see https://www.backblaze.com/apidocs/b2-upload-file\n */\nexport const DEFAULT_CONTENT_TYPE = 'b2/x-auto'\n"],"names":[],"mappings":";;AAqBO,MAAM,+BAA+B;AAYrC,MAAM,2BAA2B;AAYjC,MAAM,oBAAoB;AAW1B,MAAM,uBAAuB;;;;;"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared SDK-wide default values.
3
+ *
4
+ * Centralising defaults here makes the trade-offs visible and prevents the
5
+ * drift that creeps in when each module hard-codes its own magic number.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Default parallel-task count for **data-transfer** operations: uploads
11
+ * (multipart parts), downloads (byte ranges), server-side copies (parts),
12
+ * and sync (file-by-file). Each in-flight task occupies one transport
13
+ * slot and at least one part-worth of memory, so we keep this
14
+ * conservative.
15
+ *
16
+ * Empirically `4` saturates a typical home / office uplink without
17
+ * starving the event loop or risking B2's per-account upload-URL
18
+ * rate-limit. Callers that have measured their environment can override
19
+ * via the `concurrency` option on every transfer method.
20
+ */
21
+ export declare const DEFAULT_TRANSFER_CONCURRENCY = 4;
22
+ /**
23
+ * Default parallel-task count for **bulk metadata** operations:
24
+ * `Bucket.deleteMany` (per-version delete calls), and the action loop in
25
+ * `synchronize` when it dispatches mixed actions in batches.
26
+ *
27
+ * Higher than the transfer default because each task is a tiny API
28
+ * round-trip (no payload), so concurrency is bound by API latency rather
29
+ * than bandwidth or local memory. `10` keeps a delete-of-thousands
30
+ * snappy without overwhelming a single account's request budget.
31
+ */
32
+ export declare const DEFAULT_BULK_CONCURRENCY = 10;
33
+ /**
34
+ * Default `maxFileCount` for list-style endpoints
35
+ * (`b2_list_file_names`, `b2_list_file_versions`, `b2_list_parts`). B2
36
+ * caps `maxFileCount` at `10000` for these endpoints; the SDK requests
37
+ * `1000` per page so a single network blip doesn't lose 10× the work and
38
+ * so callers see results sooner.
39
+ *
40
+ * `b2_list_unfinished_large_files` is capped at `100` server-side and is
41
+ * not affected by this constant.
42
+ */
43
+ export declare const DEFAULT_PAGE_SIZE = 1000;
44
+ /**
45
+ * Default MIME type for uploads when the caller omits `contentType`.
46
+ * B2 documents `b2/x-auto` as the magic value that asks the service to
47
+ * sniff the file's content and pick a sensible `Content-Type` itself.
48
+ * Centralising the literal here keeps the upload, copy, and create-write
49
+ * paths in sync.
50
+ *
51
+ * @see https://www.backblaze.com/apidocs/b2-upload-file
52
+ */
53
+ export declare const DEFAULT_CONTENT_TYPE = "b2/x-auto";
54
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/util/defaults.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,cAAc,CAAA"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared SDK-wide default values.
3
+ *
4
+ * Centralising defaults here makes the trade-offs visible and prevents the
5
+ * drift that creeps in when each module hard-codes its own magic number.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Default parallel-task count for **data-transfer** operations: uploads
11
+ * (multipart parts), downloads (byte ranges), server-side copies (parts),
12
+ * and sync (file-by-file). Each in-flight task occupies one transport
13
+ * slot and at least one part-worth of memory, so we keep this
14
+ * conservative.
15
+ *
16
+ * Empirically `4` saturates a typical home / office uplink without
17
+ * starving the event loop or risking B2's per-account upload-URL
18
+ * rate-limit. Callers that have measured their environment can override
19
+ * via the `concurrency` option on every transfer method.
20
+ */
21
+ export declare const DEFAULT_TRANSFER_CONCURRENCY = 4;
22
+ /**
23
+ * Default parallel-task count for **bulk metadata** operations:
24
+ * `Bucket.deleteMany` (per-version delete calls), and the action loop in
25
+ * `synchronize` when it dispatches mixed actions in batches.
26
+ *
27
+ * Higher than the transfer default because each task is a tiny API
28
+ * round-trip (no payload), so concurrency is bound by API latency rather
29
+ * than bandwidth or local memory. `10` keeps a delete-of-thousands
30
+ * snappy without overwhelming a single account's request budget.
31
+ */
32
+ export declare const DEFAULT_BULK_CONCURRENCY = 10;
33
+ /**
34
+ * Default `maxFileCount` for list-style endpoints
35
+ * (`b2_list_file_names`, `b2_list_file_versions`, `b2_list_parts`). B2
36
+ * caps `maxFileCount` at `10000` for these endpoints; the SDK requests
37
+ * `1000` per page so a single network blip doesn't lose 10× the work and
38
+ * so callers see results sooner.
39
+ *
40
+ * `b2_list_unfinished_large_files` is capped at `100` server-side and is
41
+ * not affected by this constant.
42
+ */
43
+ export declare const DEFAULT_PAGE_SIZE = 1000;
44
+ /**
45
+ * Default MIME type for uploads when the caller omits `contentType`.
46
+ * B2 documents `b2/x-auto` as the magic value that asks the service to
47
+ * sniff the file's content and pick a sensible `Content-Type` itself.
48
+ * Centralising the literal here keeps the upload, copy, and create-write
49
+ * paths in sync.
50
+ *
51
+ * @see https://www.backblaze.com/apidocs/b2-upload-file
52
+ */
53
+ export declare const DEFAULT_CONTENT_TYPE = "b2/x-auto";
54
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/util/defaults.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,cAAc,CAAA"}
@@ -0,0 +1,11 @@
1
+ const DEFAULT_TRANSFER_CONCURRENCY = 4;
2
+ const DEFAULT_BULK_CONCURRENCY = 10;
3
+ const DEFAULT_PAGE_SIZE = 1e3;
4
+ const DEFAULT_CONTENT_TYPE = "b2/x-auto";
5
+ export {
6
+ DEFAULT_BULK_CONCURRENCY,
7
+ DEFAULT_CONTENT_TYPE,
8
+ DEFAULT_PAGE_SIZE,
9
+ DEFAULT_TRANSFER_CONCURRENCY
10
+ };
11
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sources":["../../src/util/defaults.ts"],"sourcesContent":["/**\n * Shared SDK-wide default values.\n *\n * Centralising defaults here makes the trade-offs visible and prevents the\n * drift that creeps in when each module hard-codes its own magic number.\n *\n * @packageDocumentation\n */\n\n/**\n * Default parallel-task count for **data-transfer** operations: uploads\n * (multipart parts), downloads (byte ranges), server-side copies (parts),\n * and sync (file-by-file). Each in-flight task occupies one transport\n * slot and at least one part-worth of memory, so we keep this\n * conservative.\n *\n * Empirically `4` saturates a typical home / office uplink without\n * starving the event loop or risking B2's per-account upload-URL\n * rate-limit. Callers that have measured their environment can override\n * via the `concurrency` option on every transfer method.\n */\nexport const DEFAULT_TRANSFER_CONCURRENCY = 4\n\n/**\n * Default parallel-task count for **bulk metadata** operations:\n * `Bucket.deleteMany` (per-version delete calls), and the action loop in\n * `synchronize` when it dispatches mixed actions in batches.\n *\n * Higher than the transfer default because each task is a tiny API\n * round-trip (no payload), so concurrency is bound by API latency rather\n * than bandwidth or local memory. `10` keeps a delete-of-thousands\n * snappy without overwhelming a single account's request budget.\n */\nexport const DEFAULT_BULK_CONCURRENCY = 10\n\n/**\n * Default `maxFileCount` for list-style endpoints\n * (`b2_list_file_names`, `b2_list_file_versions`, `b2_list_parts`). B2\n * caps `maxFileCount` at `10000` for these endpoints; the SDK requests\n * `1000` per page so a single network blip doesn't lose 10× the work and\n * so callers see results sooner.\n *\n * `b2_list_unfinished_large_files` is capped at `100` server-side and is\n * not affected by this constant.\n */\nexport const DEFAULT_PAGE_SIZE = 1000\n\n/**\n * Default MIME type for uploads when the caller omits `contentType`.\n * B2 documents `b2/x-auto` as the magic value that asks the service to\n * sniff the file's content and pick a sensible `Content-Type` itself.\n * Centralising the literal here keeps the upload, copy, and create-write\n * paths in sync.\n *\n * @see https://www.backblaze.com/apidocs/b2-upload-file\n */\nexport const DEFAULT_CONTENT_TYPE = 'b2/x-auto'\n"],"names":[],"mappings":"AAqBO,MAAM,+BAA+B;AAYrC,MAAM,2BAA2B;AAYjC,MAAM,oBAAoB;AAW1B,MAAM,uBAAuB;"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function normalizeSha1(raw) {
4
+ if (raw === null || raw === void 0 || raw === "none") return null;
5
+ return raw;
6
+ }
7
+ function normalizeFileVersionSha1(fv) {
8
+ return fv.contentSha1 === "none" ? { ...fv, contentSha1: null } : fv;
9
+ }
10
+ function normalizeFileVersionListSha1(resp) {
11
+ return { ...resp, files: resp.files.map(normalizeFileVersionSha1) };
12
+ }
13
+ exports.normalizeFileVersionListSha1 = normalizeFileVersionListSha1;
14
+ exports.normalizeFileVersionSha1 = normalizeFileVersionSha1;
15
+ exports.normalizeSha1 = normalizeSha1;
16
+ //# sourceMappingURL=normalize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.cjs","sources":["../../src/util/normalize.ts"],"sourcesContent":["/**\n * Wire-shape → SDK-shape normalization helpers.\n *\n * B2 occasionally uses sentinel strings on the wire where a missing\n * value would be more idiomatic in TypeScript. The biggest offender is\n * `contentSha1: 'none'` on files completed via `b2_finish_large_file`\n * (multipart-finished files don't have a whole-file SHA-1; B2 sends the\n * literal three-letter string). The SDK's `FileVersion.contentSha1` is\n * typed `string | null` to signal that absence — this module collapses\n * the wire sentinel to `null` so callers can write\n * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.\n *\n * Normalization happens at the RawClient boundary so every SDK consumer\n * (RawClient direct users, the high-level facade, the simulator-driven\n * tests, generated docs) sees the same `null` value.\n *\n * @packageDocumentation\n */\n\n/**\n * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for\n * SHA-1-shaped fields. Any other string passes through unchanged.\n *\n * @param raw - SHA-1 string from the wire, or `null`/`undefined`.\n *\n * @returns A hex SHA-1 string, or `null` when the wire said \"no hash\".\n */\nexport function normalizeSha1(raw: string | null | undefined): string | null {\n if (raw === null || raw === undefined || raw === 'none') return null\n return raw\n}\n\n/**\n * Returns a new file-version-shaped object with the `contentSha1: 'none'`\n * sentinel collapsed to `null`. Pass-through when the value is already\n * `null` or a real hash. The object reference is preserved if no\n * substitution was needed, so callers paying for change detection\n * (e.g. React memo) see referential stability.\n *\n * @typeParam T - Any object with a `contentSha1: string | null` field.\n *\n * @param fv - The wire-shape file-version object.\n *\n * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.\n */\nexport function normalizeFileVersionSha1<T extends { readonly contentSha1: string | null }>(\n fv: T,\n): T {\n return fv.contentSha1 === 'none' ? { ...fv, contentSha1: null } : fv\n}\n\n/**\n * Returns a new list-response object with `normalizeFileVersionSha1`\n * applied to every entry in `files`. Used at the `b2_list_file_names` /\n * `b2_list_file_versions` boundary so list output shares the same\n * SHA-1 semantics as the singular endpoints.\n *\n * @typeParam F - Any object with a `contentSha1: string | null` field.\n * @typeParam R - The list-response shape (must have a `files` array of `F`).\n *\n * @param resp - The wire-shape list response.\n *\n * @returns A response with normalized `files`. `resp.files` is a new array.\n */\nexport function normalizeFileVersionListSha1<\n F extends { readonly contentSha1: string | null },\n R extends { readonly files: readonly F[] },\n>(resp: R): R {\n return { ...resp, files: resp.files.map(normalizeFileVersionSha1) }\n}\n"],"names":[],"mappings":";;AA2BO,SAAS,cAAc,KAA+C;AAC3E,MAAI,QAAQ,QAAQ,QAAQ,UAAa,QAAQ,OAAQ,QAAO;AAChE,SAAO;AACT;AAeO,SAAS,yBACd,IACG;AACH,SAAO,GAAG,gBAAgB,SAAS,EAAE,GAAG,IAAI,aAAa,SAAS;AACpE;AAeO,SAAS,6BAGd,MAAY;AACZ,SAAO,EAAE,GAAG,MAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB,EAAA;AAClE;;;;"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Wire-shape → SDK-shape normalization helpers.
3
+ *
4
+ * B2 occasionally uses sentinel strings on the wire where a missing
5
+ * value would be more idiomatic in TypeScript. The biggest offender is
6
+ * `contentSha1: 'none'` on files completed via `b2_finish_large_file`
7
+ * (multipart-finished files don't have a whole-file SHA-1; B2 sends the
8
+ * literal three-letter string). The SDK's `FileVersion.contentSha1` is
9
+ * typed `string | null` to signal that absence — this module collapses
10
+ * the wire sentinel to `null` so callers can write
11
+ * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.
12
+ *
13
+ * Normalization happens at the RawClient boundary so every SDK consumer
14
+ * (RawClient direct users, the high-level facade, the simulator-driven
15
+ * tests, generated docs) sees the same `null` value.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ /**
20
+ * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for
21
+ * SHA-1-shaped fields. Any other string passes through unchanged.
22
+ *
23
+ * @param raw - SHA-1 string from the wire, or `null`/`undefined`.
24
+ *
25
+ * @returns A hex SHA-1 string, or `null` when the wire said "no hash".
26
+ */
27
+ export declare function normalizeSha1(raw: string | null | undefined): string | null;
28
+ /**
29
+ * Returns a new file-version-shaped object with the `contentSha1: 'none'`
30
+ * sentinel collapsed to `null`. Pass-through when the value is already
31
+ * `null` or a real hash. The object reference is preserved if no
32
+ * substitution was needed, so callers paying for change detection
33
+ * (e.g. React memo) see referential stability.
34
+ *
35
+ * @typeParam T - Any object with a `contentSha1: string | null` field.
36
+ *
37
+ * @param fv - The wire-shape file-version object.
38
+ *
39
+ * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
40
+ */
41
+ export declare function normalizeFileVersionSha1<T extends {
42
+ readonly contentSha1: string | null;
43
+ }>(fv: T): T;
44
+ /**
45
+ * Returns a new list-response object with `normalizeFileVersionSha1`
46
+ * applied to every entry in `files`. Used at the `b2_list_file_names` /
47
+ * `b2_list_file_versions` boundary so list output shares the same
48
+ * SHA-1 semantics as the singular endpoints.
49
+ *
50
+ * @typeParam F - Any object with a `contentSha1: string | null` field.
51
+ * @typeParam R - The list-response shape (must have a `files` array of `F`).
52
+ *
53
+ * @param resp - The wire-shape list response.
54
+ *
55
+ * @returns A response with normalized `files`. `resp.files` is a new array.
56
+ */
57
+ export declare function normalizeFileVersionListSha1<F extends {
58
+ readonly contentSha1: string | null;
59
+ }, R extends {
60
+ readonly files: readonly F[];
61
+ }>(resp: R): R;
62
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxF,EAAE,EAAE,CAAC,GACJ,CAAC,CAEH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACjD,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,EAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,CAEZ"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Wire-shape → SDK-shape normalization helpers.
3
+ *
4
+ * B2 occasionally uses sentinel strings on the wire where a missing
5
+ * value would be more idiomatic in TypeScript. The biggest offender is
6
+ * `contentSha1: 'none'` on files completed via `b2_finish_large_file`
7
+ * (multipart-finished files don't have a whole-file SHA-1; B2 sends the
8
+ * literal three-letter string). The SDK's `FileVersion.contentSha1` is
9
+ * typed `string | null` to signal that absence — this module collapses
10
+ * the wire sentinel to `null` so callers can write
11
+ * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.
12
+ *
13
+ * Normalization happens at the RawClient boundary so every SDK consumer
14
+ * (RawClient direct users, the high-level facade, the simulator-driven
15
+ * tests, generated docs) sees the same `null` value.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ /**
20
+ * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for
21
+ * SHA-1-shaped fields. Any other string passes through unchanged.
22
+ *
23
+ * @param raw - SHA-1 string from the wire, or `null`/`undefined`.
24
+ *
25
+ * @returns A hex SHA-1 string, or `null` when the wire said "no hash".
26
+ */
27
+ export declare function normalizeSha1(raw: string | null | undefined): string | null;
28
+ /**
29
+ * Returns a new file-version-shaped object with the `contentSha1: 'none'`
30
+ * sentinel collapsed to `null`. Pass-through when the value is already
31
+ * `null` or a real hash. The object reference is preserved if no
32
+ * substitution was needed, so callers paying for change detection
33
+ * (e.g. React memo) see referential stability.
34
+ *
35
+ * @typeParam T - Any object with a `contentSha1: string | null` field.
36
+ *
37
+ * @param fv - The wire-shape file-version object.
38
+ *
39
+ * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
40
+ */
41
+ export declare function normalizeFileVersionSha1<T extends {
42
+ readonly contentSha1: string | null;
43
+ }>(fv: T): T;
44
+ /**
45
+ * Returns a new list-response object with `normalizeFileVersionSha1`
46
+ * applied to every entry in `files`. Used at the `b2_list_file_names` /
47
+ * `b2_list_file_versions` boundary so list output shares the same
48
+ * SHA-1 semantics as the singular endpoints.
49
+ *
50
+ * @typeParam F - Any object with a `contentSha1: string | null` field.
51
+ * @typeParam R - The list-response shape (must have a `files` array of `F`).
52
+ *
53
+ * @param resp - The wire-shape list response.
54
+ *
55
+ * @returns A response with normalized `files`. `resp.files` is a new array.
56
+ */
57
+ export declare function normalizeFileVersionListSha1<F extends {
58
+ readonly contentSha1: string | null;
59
+ }, R extends {
60
+ readonly files: readonly F[];
61
+ }>(resp: R): R;
62
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxF,EAAE,EAAE,CAAC,GACJ,CAAC,CAEH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACjD,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,EAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,CAEZ"}
@@ -0,0 +1,16 @@
1
+ function normalizeSha1(raw) {
2
+ if (raw === null || raw === void 0 || raw === "none") return null;
3
+ return raw;
4
+ }
5
+ function normalizeFileVersionSha1(fv) {
6
+ return fv.contentSha1 === "none" ? { ...fv, contentSha1: null } : fv;
7
+ }
8
+ function normalizeFileVersionListSha1(resp) {
9
+ return { ...resp, files: resp.files.map(normalizeFileVersionSha1) };
10
+ }
11
+ export {
12
+ normalizeFileVersionListSha1,
13
+ normalizeFileVersionSha1,
14
+ normalizeSha1
15
+ };
16
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sources":["../../src/util/normalize.ts"],"sourcesContent":["/**\n * Wire-shape → SDK-shape normalization helpers.\n *\n * B2 occasionally uses sentinel strings on the wire where a missing\n * value would be more idiomatic in TypeScript. The biggest offender is\n * `contentSha1: 'none'` on files completed via `b2_finish_large_file`\n * (multipart-finished files don't have a whole-file SHA-1; B2 sends the\n * literal three-letter string). The SDK's `FileVersion.contentSha1` is\n * typed `string | null` to signal that absence — this module collapses\n * the wire sentinel to `null` so callers can write\n * `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.\n *\n * Normalization happens at the RawClient boundary so every SDK consumer\n * (RawClient direct users, the high-level facade, the simulator-driven\n * tests, generated docs) sees the same `null` value.\n *\n * @packageDocumentation\n */\n\n/**\n * Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for\n * SHA-1-shaped fields. Any other string passes through unchanged.\n *\n * @param raw - SHA-1 string from the wire, or `null`/`undefined`.\n *\n * @returns A hex SHA-1 string, or `null` when the wire said \"no hash\".\n */\nexport function normalizeSha1(raw: string | null | undefined): string | null {\n if (raw === null || raw === undefined || raw === 'none') return null\n return raw\n}\n\n/**\n * Returns a new file-version-shaped object with the `contentSha1: 'none'`\n * sentinel collapsed to `null`. Pass-through when the value is already\n * `null` or a real hash. The object reference is preserved if no\n * substitution was needed, so callers paying for change detection\n * (e.g. React memo) see referential stability.\n *\n * @typeParam T - Any object with a `contentSha1: string | null` field.\n *\n * @param fv - The wire-shape file-version object.\n *\n * @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.\n */\nexport function normalizeFileVersionSha1<T extends { readonly contentSha1: string | null }>(\n fv: T,\n): T {\n return fv.contentSha1 === 'none' ? { ...fv, contentSha1: null } : fv\n}\n\n/**\n * Returns a new list-response object with `normalizeFileVersionSha1`\n * applied to every entry in `files`. Used at the `b2_list_file_names` /\n * `b2_list_file_versions` boundary so list output shares the same\n * SHA-1 semantics as the singular endpoints.\n *\n * @typeParam F - Any object with a `contentSha1: string | null` field.\n * @typeParam R - The list-response shape (must have a `files` array of `F`).\n *\n * @param resp - The wire-shape list response.\n *\n * @returns A response with normalized `files`. `resp.files` is a new array.\n */\nexport function normalizeFileVersionListSha1<\n F extends { readonly contentSha1: string | null },\n R extends { readonly files: readonly F[] },\n>(resp: R): R {\n return { ...resp, files: resp.files.map(normalizeFileVersionSha1) }\n}\n"],"names":[],"mappings":"AA2BO,SAAS,cAAc,KAA+C;AAC3E,MAAI,QAAQ,QAAQ,QAAQ,UAAa,QAAQ,OAAQ,QAAO;AAChE,SAAO;AACT;AAeO,SAAS,yBACd,IACG;AACH,SAAO,GAAG,gBAAgB,SAAS,EAAE,GAAG,IAAI,aAAa,SAAS;AACpE;AAeO,SAAS,6BAGd,MAAY;AACZ,SAAO,EAAE,GAAG,MAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB,EAAA;AAClE;"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ async function* paginatePages(fetcher, signal) {
4
+ let cursor;
5
+ while (true) {
6
+ signal?.throwIfAborted();
7
+ const { page, nextCursor } = await fetcher(cursor);
8
+ yield page;
9
+ if (nextCursor === void 0) return;
10
+ cursor = nextCursor;
11
+ }
12
+ }
13
+ async function* paginateItems(fetcher, extractItems, signal) {
14
+ for await (const page of paginatePages(fetcher, signal)) {
15
+ yield* extractItems(page);
16
+ }
17
+ }
18
+ exports.paginateItems = paginateItems;
19
+ exports.paginatePages = paginatePages;
20
+ //# sourceMappingURL=paginator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.cjs","sources":["../../src/util/paginator.ts"],"sourcesContent":["/**\n * Generic pagination helpers for B2 list endpoints.\n *\n * B2 returns paginated results as `{ items, nextCursor }` shapes that differ\n * per endpoint (`nextFileName`, `nextFileId`, `nextPartNumber`,\n * `nextApplicationKeyId`, etc.). These helpers let callers iterate without\n * threading the cursor by hand.\n *\n * Two flavours:\n * - {@link paginatePages} yields each page as the server returned it.\n * Useful when the caller wants the per-page response object (e.g. for\n * access to per-page metadata or to control item-iteration order).\n * - {@link paginateItems} flattens pages and yields individual items.\n * Useful for the common \"iterate everything\" case.\n *\n * Both helpers honour an optional {@link AbortSignal} that aborts the\n * iteration **between fetches**. They do NOT abort an in-flight network\n * request: the underlying list call has its own `signal` parameter and\n * each consumer must wire that through if mid-flight cancellation is\n * required.\n *\n * @packageDocumentation\n *\n * @example\n * ```ts\n * for await (const file of bucket.paginateFileNames({ prefix: 'photos/' })) {\n * console.log(file.fileName, file.contentLength)\n * }\n * ```\n *\n */\n\n/**\n * Options accepted by every `paginateX` method on `Bucket` and `B2Client`.\n */\nexport interface PaginatorOptions {\n /**\n * Maximum items per page. Forwarded to the underlying list call's\n * `maxFileCount` / `maxKeyCount` / `maxPartCount` parameter. B2 caps this\n * at endpoint-specific limits (typically 10000 for files, 100 for parts).\n */\n pageSize?: number\n /**\n * Aborts the iteration between fetches. When already aborted at call time,\n * the iterator throws immediately on its first `next()` call.\n *\n * Note: this does NOT abort an in-flight HTTP request mid-page. The\n * iterator checks `signal.throwIfAborted()` only between fetches.\n */\n signal?: AbortSignal\n}\n\n/**\n * Function that fetches a single page given a cursor.\n *\n * The cursor is `undefined` for the first page, then takes the value of the\n * previous page's `nextCursor` on subsequent calls. Iteration stops when\n * `nextCursor` is `undefined` (or any other falsy value the caller maps to\n * `undefined`).\n *\n * @typeParam Page - The per-page response shape returned by the B2 endpoint.\n * @typeParam Cursor - The cursor type (typically `string` or a `{name, id}` pair).\n */\nexport type PageFetcher<Page, Cursor> = (cursor: Cursor | undefined) => Promise<{\n /** The page just fetched. */\n page: Page\n /** Cursor for the next page, or `undefined` if there are no more pages. */\n nextCursor: Cursor | undefined\n}>\n\n/**\n * Async-iterates one page at a time. Stops when `fetcher` returns\n * `nextCursor: undefined`.\n *\n * @typeParam Page - The per-page response shape.\n * @typeParam Cursor - The cursor type used to request the next page.\n *\n * @param fetcher - Function that fetches one page given the current cursor.\n * @param signal - Optional abort signal. Checked before each fetch.\n *\n * @returns An async iterable of pages.\n *\n * @throws DOMException When `signal` is aborted between fetches.\n *\n * @example\n * ```ts\n * for await (const page of paginatePages(\n * async (cursor) => {\n * const resp = await bucket.listFileNames({ startFileName: cursor })\n * return { page: resp, nextCursor: resp.nextFileName ?? undefined }\n * },\n * abortSignal,\n * )) {\n * for (const file of page.files) { ... }\n * }\n * ```\n */\nexport async function* paginatePages<Page, Cursor>(\n fetcher: PageFetcher<Page, Cursor>,\n signal: AbortSignal | undefined,\n): AsyncIterableIterator<Page> {\n let cursor: Cursor | undefined\n while (true) {\n signal?.throwIfAborted()\n const { page, nextCursor } = await fetcher(cursor)\n yield page\n if (nextCursor === undefined) return\n cursor = nextCursor\n }\n}\n\n/**\n * Async-iterates items by flattening pages. The `extractItems` function\n * pulls the relevant array out of each page (e.g. `page.files`,\n * `page.keys`, `page.parts`). Each item is yielded individually so the\n * caller can `for await (const item of paginator)` rather than nest loops.\n *\n * Aborts between **pages**, not between items: if `signal` is aborted while\n * the caller is processing the items of page N, the iterator will still\n * yield all of page N's remaining items before checking the signal before\n * fetching page N+1.\n *\n * @typeParam Page - The per-page response shape.\n * @typeParam Cursor - The cursor type used to request the next page.\n * @typeParam Item - The item type the caller wants to iterate.\n *\n * @param fetcher - Function that fetches one page given the current cursor.\n * @param extractItems - Pulls the iterable items out of a page.\n * @param signal - Optional abort signal. Checked before each fetch.\n *\n * @returns An async iterable of individual items.\n *\n * @throws DOMException When `signal` is aborted between fetches.\n */\nexport async function* paginateItems<Page, Cursor, Item>(\n fetcher: PageFetcher<Page, Cursor>,\n extractItems: (page: Page) => Iterable<Item>,\n signal: AbortSignal | undefined,\n): AsyncIterableIterator<Item> {\n for await (const page of paginatePages(fetcher, signal)) {\n yield* extractItems(page)\n }\n}\n"],"names":[],"mappings":";;AAiGA,gBAAuB,cACrB,SACA,QAC6B;AAC7B,MAAI;AACJ,SAAO,MAAM;AACX,YAAQ,eAAA;AACR,UAAM,EAAE,MAAM,WAAA,IAAe,MAAM,QAAQ,MAAM;AACjD,UAAM;AACN,QAAI,eAAe,OAAW;AAC9B,aAAS;AAAA,EACX;AACF;AAyBA,gBAAuB,cACrB,SACA,cACA,QAC6B;AAC7B,mBAAiB,QAAQ,cAAc,SAAS,MAAM,GAAG;AACvD,WAAO,aAAa,IAAI;AAAA,EAC1B;AACF;;;"}