@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,120 @@
1
+ /**
2
+ * Generic pagination helpers for B2 list endpoints.
3
+ *
4
+ * B2 returns paginated results as `{ items, nextCursor }` shapes that differ
5
+ * per endpoint (`nextFileName`, `nextFileId`, `nextPartNumber`,
6
+ * `nextApplicationKeyId`, etc.). These helpers let callers iterate without
7
+ * threading the cursor by hand.
8
+ *
9
+ * Two flavours:
10
+ * - {@link paginatePages} yields each page as the server returned it.
11
+ * Useful when the caller wants the per-page response object (e.g. for
12
+ * access to per-page metadata or to control item-iteration order).
13
+ * - {@link paginateItems} flattens pages and yields individual items.
14
+ * Useful for the common "iterate everything" case.
15
+ *
16
+ * Both helpers honour an optional {@link AbortSignal} that aborts the
17
+ * iteration **between fetches**. They do NOT abort an in-flight network
18
+ * request: the underlying list call has its own `signal` parameter and
19
+ * each consumer must wire that through if mid-flight cancellation is
20
+ * required.
21
+ *
22
+ * @packageDocumentation
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * for await (const file of bucket.paginateFileNames({ prefix: 'photos/' })) {
27
+ * console.log(file.fileName, file.contentLength)
28
+ * }
29
+ * ```
30
+ *
31
+ */
32
+ /**
33
+ * Options accepted by every `paginateX` method on `Bucket` and `B2Client`.
34
+ */
35
+ export interface PaginatorOptions {
36
+ /**
37
+ * Maximum items per page. Forwarded to the underlying list call's
38
+ * `maxFileCount` / `maxKeyCount` / `maxPartCount` parameter. B2 caps this
39
+ * at endpoint-specific limits (typically 10000 for files, 100 for parts).
40
+ */
41
+ pageSize?: number;
42
+ /**
43
+ * Aborts the iteration between fetches. When already aborted at call time,
44
+ * the iterator throws immediately on its first `next()` call.
45
+ *
46
+ * Note: this does NOT abort an in-flight HTTP request mid-page. The
47
+ * iterator checks `signal.throwIfAborted()` only between fetches.
48
+ */
49
+ signal?: AbortSignal;
50
+ }
51
+ /**
52
+ * Function that fetches a single page given a cursor.
53
+ *
54
+ * The cursor is `undefined` for the first page, then takes the value of the
55
+ * previous page's `nextCursor` on subsequent calls. Iteration stops when
56
+ * `nextCursor` is `undefined` (or any other falsy value the caller maps to
57
+ * `undefined`).
58
+ *
59
+ * @typeParam Page - The per-page response shape returned by the B2 endpoint.
60
+ * @typeParam Cursor - The cursor type (typically `string` or a `{name, id}` pair).
61
+ */
62
+ export type PageFetcher<Page, Cursor> = (cursor: Cursor | undefined) => Promise<{
63
+ /** The page just fetched. */
64
+ page: Page;
65
+ /** Cursor for the next page, or `undefined` if there are no more pages. */
66
+ nextCursor: Cursor | undefined;
67
+ }>;
68
+ /**
69
+ * Async-iterates one page at a time. Stops when `fetcher` returns
70
+ * `nextCursor: undefined`.
71
+ *
72
+ * @typeParam Page - The per-page response shape.
73
+ * @typeParam Cursor - The cursor type used to request the next page.
74
+ *
75
+ * @param fetcher - Function that fetches one page given the current cursor.
76
+ * @param signal - Optional abort signal. Checked before each fetch.
77
+ *
78
+ * @returns An async iterable of pages.
79
+ *
80
+ * @throws DOMException When `signal` is aborted between fetches.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * for await (const page of paginatePages(
85
+ * async (cursor) => {
86
+ * const resp = await bucket.listFileNames({ startFileName: cursor })
87
+ * return { page: resp, nextCursor: resp.nextFileName ?? undefined }
88
+ * },
89
+ * abortSignal,
90
+ * )) {
91
+ * for (const file of page.files) { ... }
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function paginatePages<Page, Cursor>(fetcher: PageFetcher<Page, Cursor>, signal: AbortSignal | undefined): AsyncIterableIterator<Page>;
96
+ /**
97
+ * Async-iterates items by flattening pages. The `extractItems` function
98
+ * pulls the relevant array out of each page (e.g. `page.files`,
99
+ * `page.keys`, `page.parts`). Each item is yielded individually so the
100
+ * caller can `for await (const item of paginator)` rather than nest loops.
101
+ *
102
+ * Aborts between **pages**, not between items: if `signal` is aborted while
103
+ * the caller is processing the items of page N, the iterator will still
104
+ * yield all of page N's remaining items before checking the signal before
105
+ * fetching page N+1.
106
+ *
107
+ * @typeParam Page - The per-page response shape.
108
+ * @typeParam Cursor - The cursor type used to request the next page.
109
+ * @typeParam Item - The item type the caller wants to iterate.
110
+ *
111
+ * @param fetcher - Function that fetches one page given the current cursor.
112
+ * @param extractItems - Pulls the iterable items out of a page.
113
+ * @param signal - Optional abort signal. Checked before each fetch.
114
+ *
115
+ * @returns An async iterable of individual items.
116
+ *
117
+ * @throws DOMException When `signal` is aborted between fetches.
118
+ */
119
+ export declare function paginateItems<Page, Cursor, Item>(fetcher: PageFetcher<Page, Cursor>, extractItems: (page: Page) => Iterable<Item>, signal: AbortSignal | undefined): AsyncIterableIterator<Item>;
120
+ //# sourceMappingURL=paginator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../src/util/paginator.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;IAC9E,6BAA6B;IAC7B,IAAI,EAAE,IAAI,CAAA;IACV,2EAA2E;IAC3E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAuB,aAAa,CAAC,IAAI,EAAE,MAAM,EAC/C,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAClC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,qBAAqB,CAAC,IAAI,CAAC,CAS7B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAuB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EACrD,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAClC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,qBAAqB,CAAC,IAAI,CAAC,CAI7B"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Generic pagination helpers for B2 list endpoints.
3
+ *
4
+ * B2 returns paginated results as `{ items, nextCursor }` shapes that differ
5
+ * per endpoint (`nextFileName`, `nextFileId`, `nextPartNumber`,
6
+ * `nextApplicationKeyId`, etc.). These helpers let callers iterate without
7
+ * threading the cursor by hand.
8
+ *
9
+ * Two flavours:
10
+ * - {@link paginatePages} yields each page as the server returned it.
11
+ * Useful when the caller wants the per-page response object (e.g. for
12
+ * access to per-page metadata or to control item-iteration order).
13
+ * - {@link paginateItems} flattens pages and yields individual items.
14
+ * Useful for the common "iterate everything" case.
15
+ *
16
+ * Both helpers honour an optional {@link AbortSignal} that aborts the
17
+ * iteration **between fetches**. They do NOT abort an in-flight network
18
+ * request: the underlying list call has its own `signal` parameter and
19
+ * each consumer must wire that through if mid-flight cancellation is
20
+ * required.
21
+ *
22
+ * @packageDocumentation
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * for await (const file of bucket.paginateFileNames({ prefix: 'photos/' })) {
27
+ * console.log(file.fileName, file.contentLength)
28
+ * }
29
+ * ```
30
+ *
31
+ */
32
+ /**
33
+ * Options accepted by every `paginateX` method on `Bucket` and `B2Client`.
34
+ */
35
+ export interface PaginatorOptions {
36
+ /**
37
+ * Maximum items per page. Forwarded to the underlying list call's
38
+ * `maxFileCount` / `maxKeyCount` / `maxPartCount` parameter. B2 caps this
39
+ * at endpoint-specific limits (typically 10000 for files, 100 for parts).
40
+ */
41
+ pageSize?: number;
42
+ /**
43
+ * Aborts the iteration between fetches. When already aborted at call time,
44
+ * the iterator throws immediately on its first `next()` call.
45
+ *
46
+ * Note: this does NOT abort an in-flight HTTP request mid-page. The
47
+ * iterator checks `signal.throwIfAborted()` only between fetches.
48
+ */
49
+ signal?: AbortSignal;
50
+ }
51
+ /**
52
+ * Function that fetches a single page given a cursor.
53
+ *
54
+ * The cursor is `undefined` for the first page, then takes the value of the
55
+ * previous page's `nextCursor` on subsequent calls. Iteration stops when
56
+ * `nextCursor` is `undefined` (or any other falsy value the caller maps to
57
+ * `undefined`).
58
+ *
59
+ * @typeParam Page - The per-page response shape returned by the B2 endpoint.
60
+ * @typeParam Cursor - The cursor type (typically `string` or a `{name, id}` pair).
61
+ */
62
+ export type PageFetcher<Page, Cursor> = (cursor: Cursor | undefined) => Promise<{
63
+ /** The page just fetched. */
64
+ page: Page;
65
+ /** Cursor for the next page, or `undefined` if there are no more pages. */
66
+ nextCursor: Cursor | undefined;
67
+ }>;
68
+ /**
69
+ * Async-iterates one page at a time. Stops when `fetcher` returns
70
+ * `nextCursor: undefined`.
71
+ *
72
+ * @typeParam Page - The per-page response shape.
73
+ * @typeParam Cursor - The cursor type used to request the next page.
74
+ *
75
+ * @param fetcher - Function that fetches one page given the current cursor.
76
+ * @param signal - Optional abort signal. Checked before each fetch.
77
+ *
78
+ * @returns An async iterable of pages.
79
+ *
80
+ * @throws DOMException When `signal` is aborted between fetches.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * for await (const page of paginatePages(
85
+ * async (cursor) => {
86
+ * const resp = await bucket.listFileNames({ startFileName: cursor })
87
+ * return { page: resp, nextCursor: resp.nextFileName ?? undefined }
88
+ * },
89
+ * abortSignal,
90
+ * )) {
91
+ * for (const file of page.files) { ... }
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function paginatePages<Page, Cursor>(fetcher: PageFetcher<Page, Cursor>, signal: AbortSignal | undefined): AsyncIterableIterator<Page>;
96
+ /**
97
+ * Async-iterates items by flattening pages. The `extractItems` function
98
+ * pulls the relevant array out of each page (e.g. `page.files`,
99
+ * `page.keys`, `page.parts`). Each item is yielded individually so the
100
+ * caller can `for await (const item of paginator)` rather than nest loops.
101
+ *
102
+ * Aborts between **pages**, not between items: if `signal` is aborted while
103
+ * the caller is processing the items of page N, the iterator will still
104
+ * yield all of page N's remaining items before checking the signal before
105
+ * fetching page N+1.
106
+ *
107
+ * @typeParam Page - The per-page response shape.
108
+ * @typeParam Cursor - The cursor type used to request the next page.
109
+ * @typeParam Item - The item type the caller wants to iterate.
110
+ *
111
+ * @param fetcher - Function that fetches one page given the current cursor.
112
+ * @param extractItems - Pulls the iterable items out of a page.
113
+ * @param signal - Optional abort signal. Checked before each fetch.
114
+ *
115
+ * @returns An async iterable of individual items.
116
+ *
117
+ * @throws DOMException When `signal` is aborted between fetches.
118
+ */
119
+ export declare function paginateItems<Page, Cursor, Item>(fetcher: PageFetcher<Page, Cursor>, extractItems: (page: Page) => Iterable<Item>, signal: AbortSignal | undefined): AsyncIterableIterator<Item>;
120
+ //# sourceMappingURL=paginator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../src/util/paginator.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;IAC9E,6BAA6B;IAC7B,IAAI,EAAE,IAAI,CAAA;IACV,2EAA2E;IAC3E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAuB,aAAa,CAAC,IAAI,EAAE,MAAM,EAC/C,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAClC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,qBAAqB,CAAC,IAAI,CAAC,CAS7B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAuB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EACrD,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAClC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,qBAAqB,CAAC,IAAI,CAAC,CAI7B"}
@@ -0,0 +1,20 @@
1
+ async function* paginatePages(fetcher, signal) {
2
+ let cursor;
3
+ while (true) {
4
+ signal?.throwIfAborted();
5
+ const { page, nextCursor } = await fetcher(cursor);
6
+ yield page;
7
+ if (nextCursor === void 0) return;
8
+ cursor = nextCursor;
9
+ }
10
+ }
11
+ async function* paginateItems(fetcher, extractItems, signal) {
12
+ for await (const page of paginatePages(fetcher, signal)) {
13
+ yield* extractItems(page);
14
+ }
15
+ }
16
+ export {
17
+ paginateItems,
18
+ paginatePages
19
+ };
20
+ //# sourceMappingURL=paginator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.js","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;"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function planRanges(totalSize, chunkSize) {
4
+ const plans = [];
5
+ let offset = 0;
6
+ let index = 0;
7
+ while (offset < totalSize) {
8
+ const length = Math.min(chunkSize, totalSize - offset);
9
+ const end = offset + length - 1;
10
+ plans.push({
11
+ partNumber: index + 1,
12
+ index,
13
+ offset,
14
+ length,
15
+ start: offset,
16
+ end
17
+ });
18
+ offset += length;
19
+ index++;
20
+ }
21
+ return plans;
22
+ }
23
+ function byteRangeHeader(start, end) {
24
+ return `bytes=${start}-${end}`;
25
+ }
26
+ exports.byteRangeHeader = byteRangeHeader;
27
+ exports.planRanges = planRanges;
28
+ //# sourceMappingURL=plan-ranges.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ranges.cjs","sources":["../../src/util/plan-ranges.ts"],"sourcesContent":["/**\n * Inclusive byte range plan for a single chunk of a larger sequence.\n *\n * Carries every commonly-needed shape so the three call sites (multipart\n * upload, server-side multipart copy, parallel-ranged download) can\n * destructure the fields they want without re-deriving them:\n *\n * - `partNumber` is 1-based to match the B2 `b2_upload_part` /\n * `b2_copy_part` wire format.\n * - `index` is 0-based for callers that key into a `Map` or array slot.\n * - `offset` + `length` are the upload-style framing (where in the\n * source to read, how many bytes).\n * - `start` + `end` (both inclusive) are the HTTP `Range:` /\n * `Content-Range:` framing.\n */\nexport interface RangePlan {\n /** 1-based part number for B2 multipart endpoints. */\n readonly partNumber: number\n /** 0-based slot index for in-memory bookkeeping. */\n readonly index: number\n /** Inclusive byte offset where this range begins. */\n readonly offset: number\n /** Number of bytes in this range. */\n readonly length: number\n /** Alias for {@link offset} — convenient for `bytes=start-end` formatters. */\n readonly start: number\n /** Inclusive byte offset where this range ends (`offset + length - 1`). */\n readonly end: number\n}\n\n/**\n * Lays out a sequence of contiguous, non-overlapping byte ranges over\n * `[0, totalSize)`. Every produced range is at most `chunkSize` bytes\n * long; the final range may be shorter if `totalSize` is not a multiple\n * of `chunkSize`.\n *\n * Replaces three near-identical hand-rolled loops in\n * `upload/large.ts`, `copy/large.ts`, and `download/parallel.ts`.\n *\n * @param totalSize - Total number of bytes to cover.\n * @param chunkSize - Target size of each range in bytes (last range may be smaller).\n *\n * @returns Ordered, non-overlapping range plans. Empty array when `totalSize === 0`.\n */\nexport function planRanges(totalSize: number, chunkSize: number): RangePlan[] {\n const plans: RangePlan[] = []\n let offset = 0\n let index = 0\n while (offset < totalSize) {\n const length = Math.min(chunkSize, totalSize - offset)\n const end = offset + length - 1\n plans.push({\n partNumber: index + 1,\n index,\n offset,\n length,\n start: offset,\n end,\n })\n offset += length\n index++\n }\n return plans\n}\n\n/**\n * Format an HTTP `Range:` request-header value covering the given\n * inclusive byte offsets. Centralises the `bytes=<start>-<end>` template\n * so the upload, copy, and download paths agree on syntax.\n *\n * @param start - Inclusive starting byte.\n * @param end - Inclusive ending byte.\n *\n * @returns The header value (e.g. `'bytes=0-99'`).\n */\nexport function byteRangeHeader(start: number, end: number): string {\n return `bytes=${start}-${end}`\n}\n"],"names":[],"mappings":";;AA4CO,SAAS,WAAW,WAAmB,WAAgC;AAC5E,QAAM,QAAqB,CAAA;AAC3B,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,SAAO,SAAS,WAAW;AACzB,UAAM,SAAS,KAAK,IAAI,WAAW,YAAY,MAAM;AACrD,UAAM,MAAM,SAAS,SAAS;AAC9B,UAAM,KAAK;AAAA,MACT,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,IAAA,CACD;AACD,cAAU;AACV;AAAA,EACF;AACA,SAAO;AACT;AAYO,SAAS,gBAAgB,OAAe,KAAqB;AAClE,SAAO,SAAS,KAAK,IAAI,GAAG;AAC9B;;;"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Inclusive byte range plan for a single chunk of a larger sequence.
3
+ *
4
+ * Carries every commonly-needed shape so the three call sites (multipart
5
+ * upload, server-side multipart copy, parallel-ranged download) can
6
+ * destructure the fields they want without re-deriving them:
7
+ *
8
+ * - `partNumber` is 1-based to match the B2 `b2_upload_part` /
9
+ * `b2_copy_part` wire format.
10
+ * - `index` is 0-based for callers that key into a `Map` or array slot.
11
+ * - `offset` + `length` are the upload-style framing (where in the
12
+ * source to read, how many bytes).
13
+ * - `start` + `end` (both inclusive) are the HTTP `Range:` /
14
+ * `Content-Range:` framing.
15
+ */
16
+ export interface RangePlan {
17
+ /** 1-based part number for B2 multipart endpoints. */
18
+ readonly partNumber: number;
19
+ /** 0-based slot index for in-memory bookkeeping. */
20
+ readonly index: number;
21
+ /** Inclusive byte offset where this range begins. */
22
+ readonly offset: number;
23
+ /** Number of bytes in this range. */
24
+ readonly length: number;
25
+ /** Alias for {@link offset} — convenient for `bytes=start-end` formatters. */
26
+ readonly start: number;
27
+ /** Inclusive byte offset where this range ends (`offset + length - 1`). */
28
+ readonly end: number;
29
+ }
30
+ /**
31
+ * Lays out a sequence of contiguous, non-overlapping byte ranges over
32
+ * `[0, totalSize)`. Every produced range is at most `chunkSize` bytes
33
+ * long; the final range may be shorter if `totalSize` is not a multiple
34
+ * of `chunkSize`.
35
+ *
36
+ * Replaces three near-identical hand-rolled loops in
37
+ * `upload/large.ts`, `copy/large.ts`, and `download/parallel.ts`.
38
+ *
39
+ * @param totalSize - Total number of bytes to cover.
40
+ * @param chunkSize - Target size of each range in bytes (last range may be smaller).
41
+ *
42
+ * @returns Ordered, non-overlapping range plans. Empty array when `totalSize === 0`.
43
+ */
44
+ export declare function planRanges(totalSize: number, chunkSize: number): RangePlan[];
45
+ /**
46
+ * Format an HTTP `Range:` request-header value covering the given
47
+ * inclusive byte offsets. Centralises the `bytes=<start>-<end>` template
48
+ * so the upload, copy, and download paths agree on syntax.
49
+ *
50
+ * @param start - Inclusive starting byte.
51
+ * @param end - Inclusive ending byte.
52
+ *
53
+ * @returns The header value (e.g. `'bytes=0-99'`).
54
+ */
55
+ export declare function byteRangeHeader(start: number, end: number): string;
56
+ //# sourceMappingURL=plan-ranges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ranges.d.ts","sourceRoot":"","sources":["../../src/util/plan-ranges.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAmB5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAElE"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Inclusive byte range plan for a single chunk of a larger sequence.
3
+ *
4
+ * Carries every commonly-needed shape so the three call sites (multipart
5
+ * upload, server-side multipart copy, parallel-ranged download) can
6
+ * destructure the fields they want without re-deriving them:
7
+ *
8
+ * - `partNumber` is 1-based to match the B2 `b2_upload_part` /
9
+ * `b2_copy_part` wire format.
10
+ * - `index` is 0-based for callers that key into a `Map` or array slot.
11
+ * - `offset` + `length` are the upload-style framing (where in the
12
+ * source to read, how many bytes).
13
+ * - `start` + `end` (both inclusive) are the HTTP `Range:` /
14
+ * `Content-Range:` framing.
15
+ */
16
+ export interface RangePlan {
17
+ /** 1-based part number for B2 multipart endpoints. */
18
+ readonly partNumber: number;
19
+ /** 0-based slot index for in-memory bookkeeping. */
20
+ readonly index: number;
21
+ /** Inclusive byte offset where this range begins. */
22
+ readonly offset: number;
23
+ /** Number of bytes in this range. */
24
+ readonly length: number;
25
+ /** Alias for {@link offset} — convenient for `bytes=start-end` formatters. */
26
+ readonly start: number;
27
+ /** Inclusive byte offset where this range ends (`offset + length - 1`). */
28
+ readonly end: number;
29
+ }
30
+ /**
31
+ * Lays out a sequence of contiguous, non-overlapping byte ranges over
32
+ * `[0, totalSize)`. Every produced range is at most `chunkSize` bytes
33
+ * long; the final range may be shorter if `totalSize` is not a multiple
34
+ * of `chunkSize`.
35
+ *
36
+ * Replaces three near-identical hand-rolled loops in
37
+ * `upload/large.ts`, `copy/large.ts`, and `download/parallel.ts`.
38
+ *
39
+ * @param totalSize - Total number of bytes to cover.
40
+ * @param chunkSize - Target size of each range in bytes (last range may be smaller).
41
+ *
42
+ * @returns Ordered, non-overlapping range plans. Empty array when `totalSize === 0`.
43
+ */
44
+ export declare function planRanges(totalSize: number, chunkSize: number): RangePlan[];
45
+ /**
46
+ * Format an HTTP `Range:` request-header value covering the given
47
+ * inclusive byte offsets. Centralises the `bytes=<start>-<end>` template
48
+ * so the upload, copy, and download paths agree on syntax.
49
+ *
50
+ * @param start - Inclusive starting byte.
51
+ * @param end - Inclusive ending byte.
52
+ *
53
+ * @returns The header value (e.g. `'bytes=0-99'`).
54
+ */
55
+ export declare function byteRangeHeader(start: number, end: number): string;
56
+ //# sourceMappingURL=plan-ranges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ranges.d.ts","sourceRoot":"","sources":["../../src/util/plan-ranges.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAmB5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAElE"}
@@ -0,0 +1,28 @@
1
+ function planRanges(totalSize, chunkSize) {
2
+ const plans = [];
3
+ let offset = 0;
4
+ let index = 0;
5
+ while (offset < totalSize) {
6
+ const length = Math.min(chunkSize, totalSize - offset);
7
+ const end = offset + length - 1;
8
+ plans.push({
9
+ partNumber: index + 1,
10
+ index,
11
+ offset,
12
+ length,
13
+ start: offset,
14
+ end
15
+ });
16
+ offset += length;
17
+ index++;
18
+ }
19
+ return plans;
20
+ }
21
+ function byteRangeHeader(start, end) {
22
+ return `bytes=${start}-${end}`;
23
+ }
24
+ export {
25
+ byteRangeHeader,
26
+ planRanges
27
+ };
28
+ //# sourceMappingURL=plan-ranges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ranges.js","sources":["../../src/util/plan-ranges.ts"],"sourcesContent":["/**\n * Inclusive byte range plan for a single chunk of a larger sequence.\n *\n * Carries every commonly-needed shape so the three call sites (multipart\n * upload, server-side multipart copy, parallel-ranged download) can\n * destructure the fields they want without re-deriving them:\n *\n * - `partNumber` is 1-based to match the B2 `b2_upload_part` /\n * `b2_copy_part` wire format.\n * - `index` is 0-based for callers that key into a `Map` or array slot.\n * - `offset` + `length` are the upload-style framing (where in the\n * source to read, how many bytes).\n * - `start` + `end` (both inclusive) are the HTTP `Range:` /\n * `Content-Range:` framing.\n */\nexport interface RangePlan {\n /** 1-based part number for B2 multipart endpoints. */\n readonly partNumber: number\n /** 0-based slot index for in-memory bookkeeping. */\n readonly index: number\n /** Inclusive byte offset where this range begins. */\n readonly offset: number\n /** Number of bytes in this range. */\n readonly length: number\n /** Alias for {@link offset} — convenient for `bytes=start-end` formatters. */\n readonly start: number\n /** Inclusive byte offset where this range ends (`offset + length - 1`). */\n readonly end: number\n}\n\n/**\n * Lays out a sequence of contiguous, non-overlapping byte ranges over\n * `[0, totalSize)`. Every produced range is at most `chunkSize` bytes\n * long; the final range may be shorter if `totalSize` is not a multiple\n * of `chunkSize`.\n *\n * Replaces three near-identical hand-rolled loops in\n * `upload/large.ts`, `copy/large.ts`, and `download/parallel.ts`.\n *\n * @param totalSize - Total number of bytes to cover.\n * @param chunkSize - Target size of each range in bytes (last range may be smaller).\n *\n * @returns Ordered, non-overlapping range plans. Empty array when `totalSize === 0`.\n */\nexport function planRanges(totalSize: number, chunkSize: number): RangePlan[] {\n const plans: RangePlan[] = []\n let offset = 0\n let index = 0\n while (offset < totalSize) {\n const length = Math.min(chunkSize, totalSize - offset)\n const end = offset + length - 1\n plans.push({\n partNumber: index + 1,\n index,\n offset,\n length,\n start: offset,\n end,\n })\n offset += length\n index++\n }\n return plans\n}\n\n/**\n * Format an HTTP `Range:` request-header value covering the given\n * inclusive byte offsets. Centralises the `bytes=<start>-<end>` template\n * so the upload, copy, and download paths agree on syntax.\n *\n * @param start - Inclusive starting byte.\n * @param end - Inclusive ending byte.\n *\n * @returns The header value (e.g. `'bytes=0-99'`).\n */\nexport function byteRangeHeader(start: number, end: number): string {\n return `bytes=${start}-${end}`\n}\n"],"names":[],"mappings":"AA4CO,SAAS,WAAW,WAAmB,WAAgC;AAC5E,QAAM,QAAqB,CAAA;AAC3B,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,SAAO,SAAS,WAAW;AACzB,UAAM,SAAS,KAAK,IAAI,WAAW,YAAY,MAAM;AACrD,UAAM,MAAM,SAAS,SAAS;AAC9B,UAAM,KAAK;AAAA,MACT,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,IAAA,CACD;AACD,cAAU;AACV;AAAA,EACF;AACA,SAAO;AACT;AAYO,SAAS,gBAAgB,OAAe,KAAqB;AAClE,SAAO,SAAS,KAAK,IAAI,GAAG;AAC9B;"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utf8Encoder = new TextEncoder();
4
+ const utf8Decoder = new TextDecoder();
5
+ exports.utf8Decoder = utf8Decoder;
6
+ exports.utf8Encoder = utf8Encoder;
7
+ //# sourceMappingURL=text-codec.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-codec.cjs","sources":["../../src/util/text-codec.ts"],"sourcesContent":["/**\n * Shared UTF-8 codec singletons.\n *\n * Every byte boundary in this SDK is UTF-8: JSON request and response bodies,\n * webhook payloads, simulator stream chunks, and B2 percent-encoding inputs.\n * Allocating a fresh `TextEncoder` / `TextDecoder` per call is wasteful and\n * makes the encoding assumption invisible. Importing these constants makes\n * \"we use UTF-8\" explicit at every call site and avoids the per-call\n * allocation entirely.\n *\n * Both classes are spec-defined as stateless across encode / decode calls,\n * so a process-wide singleton is safe.\n *\n * @packageDocumentation\n */\n\n/**\n * Process-wide UTF-8 `TextEncoder`. Use this instead of\n * `new TextEncoder()` for any string → bytes conversion in the SDK.\n */\nexport const utf8Encoder = new TextEncoder()\n\n/**\n * Process-wide UTF-8 `TextDecoder`. Use this instead of\n * `new TextDecoder()` for any bytes → string conversion in the SDK.\n */\nexport const utf8Decoder = new TextDecoder()\n"],"names":[],"mappings":";;AAoBO,MAAM,cAAc,IAAI,YAAA;AAMxB,MAAM,cAAc,IAAI,YAAA;;;"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared UTF-8 codec singletons.
3
+ *
4
+ * Every byte boundary in this SDK is UTF-8: JSON request and response bodies,
5
+ * webhook payloads, simulator stream chunks, and B2 percent-encoding inputs.
6
+ * Allocating a fresh `TextEncoder` / `TextDecoder` per call is wasteful and
7
+ * makes the encoding assumption invisible. Importing these constants makes
8
+ * "we use UTF-8" explicit at every call site and avoids the per-call
9
+ * allocation entirely.
10
+ *
11
+ * Both classes are spec-defined as stateless across encode / decode calls,
12
+ * so a process-wide singleton is safe.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ /**
17
+ * Process-wide UTF-8 `TextEncoder`. Use this instead of
18
+ * `new TextEncoder()` for any string → bytes conversion in the SDK.
19
+ */
20
+ export declare const utf8Encoder: TextEncoder;
21
+ /**
22
+ * Process-wide UTF-8 `TextDecoder`. Use this instead of
23
+ * `new TextDecoder()` for any bytes → string conversion in the SDK.
24
+ */
25
+ export declare const utf8Decoder: TextDecoder;
26
+ //# sourceMappingURL=text-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-codec.d.ts","sourceRoot":"","sources":["../../src/util/text-codec.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAoB,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAoB,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared UTF-8 codec singletons.
3
+ *
4
+ * Every byte boundary in this SDK is UTF-8: JSON request and response bodies,
5
+ * webhook payloads, simulator stream chunks, and B2 percent-encoding inputs.
6
+ * Allocating a fresh `TextEncoder` / `TextDecoder` per call is wasteful and
7
+ * makes the encoding assumption invisible. Importing these constants makes
8
+ * "we use UTF-8" explicit at every call site and avoids the per-call
9
+ * allocation entirely.
10
+ *
11
+ * Both classes are spec-defined as stateless across encode / decode calls,
12
+ * so a process-wide singleton is safe.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ /**
17
+ * Process-wide UTF-8 `TextEncoder`. Use this instead of
18
+ * `new TextEncoder()` for any string → bytes conversion in the SDK.
19
+ */
20
+ export declare const utf8Encoder: TextEncoder;
21
+ /**
22
+ * Process-wide UTF-8 `TextDecoder`. Use this instead of
23
+ * `new TextDecoder()` for any bytes → string conversion in the SDK.
24
+ */
25
+ export declare const utf8Decoder: TextDecoder;
26
+ //# sourceMappingURL=text-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-codec.d.ts","sourceRoot":"","sources":["../../src/util/text-codec.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAoB,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAoB,CAAA"}
@@ -0,0 +1,7 @@
1
+ const utf8Encoder = new TextEncoder();
2
+ const utf8Decoder = new TextDecoder();
3
+ export {
4
+ utf8Decoder,
5
+ utf8Encoder
6
+ };
7
+ //# sourceMappingURL=text-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-codec.js","sources":["../../src/util/text-codec.ts"],"sourcesContent":["/**\n * Shared UTF-8 codec singletons.\n *\n * Every byte boundary in this SDK is UTF-8: JSON request and response bodies,\n * webhook payloads, simulator stream chunks, and B2 percent-encoding inputs.\n * Allocating a fresh `TextEncoder` / `TextDecoder` per call is wasteful and\n * makes the encoding assumption invisible. Importing these constants makes\n * \"we use UTF-8\" explicit at every call site and avoids the per-call\n * allocation entirely.\n *\n * Both classes are spec-defined as stateless across encode / decode calls,\n * so a process-wide singleton is safe.\n *\n * @packageDocumentation\n */\n\n/**\n * Process-wide UTF-8 `TextEncoder`. Use this instead of\n * `new TextEncoder()` for any string → bytes conversion in the SDK.\n */\nexport const utf8Encoder = new TextEncoder()\n\n/**\n * Process-wide UTF-8 `TextDecoder`. Use this instead of\n * `new TextDecoder()` for any bytes → string conversion in the SDK.\n */\nexport const utf8Decoder = new TextDecoder()\n"],"names":[],"mappings":"AAoBO,MAAM,cAAc,IAAI,YAAA;AAMxB,MAAM,cAAc,IAAI,YAAA;"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function toError(value) {
4
+ return value instanceof Error ? value : new Error(String(value));
5
+ }
6
+ exports.toError = toError;
7
+ //# sourceMappingURL=to-error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.cjs","sources":["../../src/util/to-error.ts"],"sourcesContent":["/**\n * Coerce an unknown caught value to a real error instance.\n *\n * Existing error objects pass through unchanged so call sites preserve\n * the original stack and any subclass identity. Other values are\n * wrapped in a fresh Error whose message is `String(value)`. Centralises\n * the conditional that previously recurred at every async-boundary\n * catch site in the upload, copy, sync, and stream paths.\n *\n * @param value - Value caught from a `try`/`catch` or rejected promise.\n *\n * @returns An `Error` representing `value`.\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n"],"names":[],"mappings":";;AAaO,SAAS,QAAQ,OAAuB;AAC7C,SAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Coerce an unknown caught value to a real error instance.
3
+ *
4
+ * Existing error objects pass through unchanged so call sites preserve
5
+ * the original stack and any subclass identity. Other values are
6
+ * wrapped in a fresh Error whose message is `String(value)`. Centralises
7
+ * the conditional that previously recurred at every async-boundary
8
+ * catch site in the upload, copy, sync, and stream paths.
9
+ *
10
+ * @param value - Value caught from a `try`/`catch` or rejected promise.
11
+ *
12
+ * @returns An `Error` representing `value`.
13
+ */
14
+ export declare function toError(value: unknown): Error;
15
+ //# sourceMappingURL=to-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.d.ts","sourceRoot":"","sources":["../../src/util/to-error.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE7C"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Coerce an unknown caught value to a real error instance.
3
+ *
4
+ * Existing error objects pass through unchanged so call sites preserve
5
+ * the original stack and any subclass identity. Other values are
6
+ * wrapped in a fresh Error whose message is `String(value)`. Centralises
7
+ * the conditional that previously recurred at every async-boundary
8
+ * catch site in the upload, copy, sync, and stream paths.
9
+ *
10
+ * @param value - Value caught from a `try`/`catch` or rejected promise.
11
+ *
12
+ * @returns An `Error` representing `value`.
13
+ */
14
+ export declare function toError(value: unknown): Error;
15
+ //# sourceMappingURL=to-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.d.ts","sourceRoot":"","sources":["../../src/util/to-error.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE7C"}
@@ -0,0 +1,7 @@
1
+ function toError(value) {
2
+ return value instanceof Error ? value : new Error(String(value));
3
+ }
4
+ export {
5
+ toError
6
+ };
7
+ //# sourceMappingURL=to-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.js","sources":["../../src/util/to-error.ts"],"sourcesContent":["/**\n * Coerce an unknown caught value to a real error instance.\n *\n * Existing error objects pass through unchanged so call sites preserve\n * the original stack and any subclass identity. Other values are\n * wrapped in a fresh Error whose message is `String(value)`. Centralises\n * the conditional that previously recurred at every async-boundary\n * catch site in the upload, copy, sync, and stream paths.\n *\n * @param value - Value caught from a `try`/`catch` or rejected promise.\n *\n * @returns An `Error` representing `value`.\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n"],"names":[],"mappings":"AAaO,SAAS,QAAQ,OAAuB;AAC7C,SAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;"}