@backblaze-labs/b2-sdk 0.1.0 → 0.2.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.
- package/CHANGELOG.md +110 -5
- package/README.md +144 -33
- package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
- package/dist/_virtual/_b2-sdk-version-json.js +4 -0
- package/dist/auth/account-info.d.cts +32 -0
- package/dist/auth/account-info.d.cts.map +1 -1
- package/dist/auth/account-info.d.ts +32 -0
- package/dist/auth/account-info.d.ts.map +1 -1
- package/dist/auth/file.cjs +408 -207
- package/dist/auth/file.cjs.map +1 -1
- package/dist/auth/file.d.cts +77 -3
- package/dist/auth/file.d.cts.map +1 -1
- package/dist/auth/file.d.ts +77 -3
- package/dist/auth/file.d.ts.map +1 -1
- package/dist/auth/file.js +407 -207
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/in-memory.cjs +212 -183
- package/dist/auth/in-memory.cjs.map +1 -1
- package/dist/auth/in-memory.d.cts +8 -0
- package/dist/auth/in-memory.d.cts.map +1 -1
- package/dist/auth/in-memory.d.ts +8 -0
- package/dist/auth/in-memory.d.ts.map +1 -1
- package/dist/auth/in-memory.js +211 -182
- package/dist/auth/in-memory.js.map +1 -1
- package/dist/auth/index.cjs +7 -9
- package/dist/auth/index.d.cts +3 -2
- package/dist/auth/index.d.cts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -8
- package/dist/auth/realms.cjs +80 -7
- package/dist/auth/realms.cjs.map +1 -1
- package/dist/auth/realms.d.cts +27 -4
- package/dist/auth/realms.d.cts.map +1 -1
- package/dist/auth/realms.d.ts +27 -4
- package/dist/auth/realms.d.ts.map +1 -1
- package/dist/auth/realms.js +80 -9
- package/dist/auth/realms.js.map +1 -1
- package/dist/auth/upload-url-pool.cjs +55 -51
- package/dist/auth/upload-url-pool.cjs.map +1 -1
- package/dist/auth/upload-url-pool.js +55 -51
- package/dist/auth/upload-url-pool.js.map +1 -1
- package/dist/bucket.cjs +785 -787
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +35 -47
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +35 -47
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +780 -782
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +246 -228
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -17
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +25 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +243 -225
- package/dist/client.js.map +1 -1
- package/dist/copy/large.cjs +114 -71
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts +6 -0
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts +6 -0
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +112 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +89 -0
- package/dist/download/checksum.cjs.map +1 -0
- package/dist/download/checksum.d.cts +40 -0
- package/dist/download/checksum.d.cts.map +1 -0
- package/dist/download/checksum.d.ts +40 -0
- package/dist/download/checksum.d.ts.map +1 -0
- package/dist/download/checksum.js +87 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +214 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +5 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +5 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +212 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +188 -97
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +6 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +6 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +186 -98
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +699 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +285 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +285 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +678 -261
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +45 -28
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.d.cts +15 -2
- package/dist/http/retry.d.cts.map +1 -1
- package/dist/http/retry.d.ts +15 -2
- package/dist/http/retry.d.ts.map +1 -1
- package/dist/http/retry.js +46 -31
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +438 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +21 -2
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +21 -2
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +437 -140
- package/dist/http/transport.js.map +1 -1
- package/dist/http/url-guard.cjs +154 -89
- package/dist/http/url-guard.cjs.map +1 -1
- package/dist/http/url-guard.d.cts +25 -3
- package/dist/http/url-guard.d.cts.map +1 -1
- package/dist/http/url-guard.d.ts +25 -3
- package/dist/http/url-guard.d.ts.map +1 -1
- package/dist/http/url-guard.js +152 -90
- package/dist/http/url-guard.js.map +1 -1
- package/dist/http/user-agent.cjs +84 -44
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.js +84 -46
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +101 -77
- package/dist/index.d.cts +27 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -71
- package/dist/internal/b2-naming.cjs +66 -0
- package/dist/internal/b2-naming.cjs.map +1 -0
- package/dist/internal/b2-naming.d.cts +43 -0
- package/dist/internal/b2-naming.d.cts.map +1 -0
- package/dist/internal/b2-naming.d.ts +43 -0
- package/dist/internal/b2-naming.d.ts.map +1 -0
- package/dist/internal/b2-naming.js +60 -0
- package/dist/internal/b2-naming.js.map +1 -0
- package/dist/internal/upload-retry-options.cjs +21 -0
- package/dist/internal/upload-retry-options.cjs.map +1 -0
- package/dist/internal/upload-retry-options.d.cts +12 -0
- package/dist/internal/upload-retry-options.d.cts.map +1 -0
- package/dist/internal/upload-retry-options.d.ts +12 -0
- package/dist/internal/upload-retry-options.d.ts.map +1 -0
- package/dist/internal/upload-retry-options.js +21 -0
- package/dist/internal/upload-retry-options.js.map +1 -0
- package/dist/internal/url-redaction.cjs +31 -0
- package/dist/internal/url-redaction.cjs.map +1 -0
- package/dist/internal/url-redaction.d.cts +17 -0
- package/dist/internal/url-redaction.d.cts.map +1 -0
- package/dist/internal/url-redaction.d.ts +17 -0
- package/dist/internal/url-redaction.d.ts.map +1 -0
- package/dist/internal/url-redaction.js +31 -0
- package/dist/internal/url-redaction.js.map +1 -0
- package/dist/notifications/index.cjs +4 -6
- package/dist/notifications/index.d.cts +1 -1
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -6
- package/dist/notifications/webhook.cjs +195 -85
- package/dist/notifications/webhook.cjs.map +1 -1
- package/dist/notifications/webhook.d.cts.map +1 -1
- package/dist/notifications/webhook.d.ts.map +1 -1
- package/dist/notifications/webhook.js +195 -87
- package/dist/notifications/webhook.js.map +1 -1
- package/dist/object.cjs +253 -210
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +9 -55
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +9 -55
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- package/dist/raw/encoding.cjs +74 -35
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.js +74 -38
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +678 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +121 -18
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +121 -18
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +674 -589
- package/dist/raw/index.js.map +1 -1
- package/dist/s3/index.cjs +355 -18
- package/dist/s3/index.cjs.map +1 -1
- package/dist/s3/index.d.cts +233 -5
- package/dist/s3/index.d.cts.map +1 -1
- package/dist/s3/index.d.ts +233 -5
- package/dist/s3/index.d.ts.map +1 -1
- package/dist/s3/index.js +351 -22
- package/dist/s3/index.js.map +1 -1
- package/dist/s3/sigv4.cjs +149 -0
- package/dist/s3/sigv4.cjs.map +1 -0
- package/dist/s3/sigv4.d.cts +43 -0
- package/dist/s3/sigv4.d.cts.map +1 -0
- package/dist/s3/sigv4.d.ts +43 -0
- package/dist/s3/sigv4.d.ts.map +1 -0
- package/dist/s3/sigv4.js +148 -0
- package/dist/s3/sigv4.js.map +1 -0
- package/dist/s3/validation.cjs +69 -0
- package/dist/s3/validation.cjs.map +1 -0
- package/dist/s3/validation.d.cts +43 -0
- package/dist/s3/validation.d.cts.map +1 -0
- package/dist/s3/validation.d.ts +43 -0
- package/dist/s3/validation.d.ts.map +1 -0
- package/dist/s3/validation.js +66 -0
- package/dist/s3/validation.js.map +1 -0
- package/dist/simulator/capabilities.cjs +63 -48
- package/dist/simulator/capabilities.cjs.map +1 -1
- package/dist/simulator/capabilities.js +63 -49
- package/dist/simulator/capabilities.js.map +1 -1
- package/dist/simulator/index.cjs +2124 -1548
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +79 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +79 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2112 -1546
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/validation.cjs +191 -153
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +3 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +3 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +188 -162
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/collect.cjs +74 -24
- package/dist/streams/collect.cjs.map +1 -1
- package/dist/streams/collect.d.cts +14 -1
- package/dist/streams/collect.d.cts.map +1 -1
- package/dist/streams/collect.d.ts +14 -1
- package/dist/streams/collect.d.ts.map +1 -1
- package/dist/streams/collect.js +74 -25
- package/dist/streams/collect.js.map +1 -1
- package/dist/streams/file-source.cjs +287 -0
- package/dist/streams/file-source.cjs.map +1 -0
- package/dist/streams/file-source.d.cts +96 -0
- package/dist/streams/file-source.d.cts.map +1 -0
- package/dist/streams/file-source.d.ts +96 -0
- package/dist/streams/file-source.d.ts.map +1 -0
- package/dist/streams/file-source.js +286 -0
- package/dist/streams/file-source.js.map +1 -0
- package/dist/streams/hash.cjs +207 -115
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +5 -4
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +5 -4
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +208 -95
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +12 -12
- package/dist/streams/index.d.cts +3 -3
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +3 -3
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +2 -10
- package/dist/streams/progress.cjs +60 -46
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.js +60 -46
- package/dist/streams/progress.js.map +1 -1
- package/dist/streams/source.cjs +316 -146
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.d.cts +56 -18
- package/dist/streams/source.d.cts.map +1 -1
- package/dist/streams/source.d.ts +56 -18
- package/dist/streams/source.d.ts.map +1 -1
- package/dist/streams/source.js +312 -149
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/actions/index.cjs +236 -184
- package/dist/sync/actions/index.cjs.map +1 -1
- package/dist/sync/actions/index.d.cts +29 -21
- package/dist/sync/actions/index.d.cts.map +1 -1
- package/dist/sync/actions/index.d.ts +29 -21
- package/dist/sync/actions/index.d.ts.map +1 -1
- package/dist/sync/actions/index.js +236 -190
- package/dist/sync/actions/index.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +148 -0
- package/dist/sync/b2-sha1-reader.cjs.map +1 -0
- package/dist/sync/b2-sha1-reader.d.cts +58 -0
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
- package/dist/sync/b2-sha1-reader.d.ts +58 -0
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
- package/dist/sync/b2-sha1-reader.js +145 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +265 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +54 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +54 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +259 -0
- package/dist/sync/download-staging.js.map +1 -0
- package/dist/sync/filesystem-errors.cjs +32 -0
- package/dist/sync/filesystem-errors.cjs.map +1 -0
- package/dist/sync/filesystem-errors.d.cts +8 -0
- package/dist/sync/filesystem-errors.d.cts.map +1 -0
- package/dist/sync/filesystem-errors.d.ts +8 -0
- package/dist/sync/filesystem-errors.d.ts.map +1 -0
- package/dist/sync/filesystem-errors.js +32 -0
- package/dist/sync/filesystem-errors.js.map +1 -0
- package/dist/sync/filters.cjs +217 -0
- package/dist/sync/filters.cjs.map +1 -0
- package/dist/sync/filters.d.cts +51 -0
- package/dist/sync/filters.d.cts.map +1 -0
- package/dist/sync/filters.d.ts +51 -0
- package/dist/sync/filters.d.ts.map +1 -0
- package/dist/sync/filters.js +213 -0
- package/dist/sync/filters.js.map +1 -0
- package/dist/sync/index.cjs +39 -22
- package/dist/sync/index.d.cts +14 -9
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +14 -9
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -20
- package/dist/sync/local-file-identity.cjs +61 -0
- package/dist/sync/local-file-identity.cjs.map +1 -0
- package/dist/sync/local-file-identity.d.cts +37 -0
- package/dist/sync/local-file-identity.d.cts.map +1 -0
- package/dist/sync/local-file-identity.d.ts +37 -0
- package/dist/sync/local-file-identity.d.ts.map +1 -0
- package/dist/sync/local-file-identity.js +60 -0
- package/dist/sync/local-file-identity.js.map +1 -0
- package/dist/sync/local-file-io.cjs +364 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +75 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +75 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +360 -0
- package/dist/sync/local-file-io.js.map +1 -0
- package/dist/sync/local-filesystem-root.cjs +27 -0
- package/dist/sync/local-filesystem-root.cjs.map +1 -0
- package/dist/sync/local-filesystem-root.d.cts +18 -0
- package/dist/sync/local-filesystem-root.d.cts.map +1 -0
- package/dist/sync/local-filesystem-root.d.ts +18 -0
- package/dist/sync/local-filesystem-root.d.ts.map +1 -0
- package/dist/sync/local-filesystem-root.js +26 -0
- package/dist/sync/local-filesystem-root.js.map +1 -0
- package/dist/sync/local-sha1.cjs +119 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +39 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +39 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +117 -0
- package/dist/sync/local-sha1.js.map +1 -0
- package/dist/sync/pairing.cjs +118 -29
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.d.cts +7 -2
- package/dist/sync/pairing.d.cts.map +1 -1
- package/dist/sync/pairing.d.ts +7 -2
- package/dist/sync/pairing.d.ts.map +1 -1
- package/dist/sync/pairing.js +120 -31
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/path-order.cjs +30 -0
- package/dist/sync/path-order.cjs.map +1 -0
- package/dist/sync/path-order.d.cts +28 -0
- package/dist/sync/path-order.d.cts.map +1 -0
- package/dist/sync/path-order.d.ts +28 -0
- package/dist/sync/path-order.d.ts.map +1 -0
- package/dist/sync/path-order.js +29 -0
- package/dist/sync/path-order.js.map +1 -0
- package/dist/sync/path-safety.cjs +111 -0
- package/dist/sync/path-safety.cjs.map +1 -0
- package/dist/sync/path-safety.d.cts +78 -0
- package/dist/sync/path-safety.d.cts.map +1 -0
- package/dist/sync/path-safety.d.ts +78 -0
- package/dist/sync/path-safety.d.ts.map +1 -0
- package/dist/sync/path-safety.js +105 -0
- package/dist/sync/path-safety.js.map +1 -0
- package/dist/sync/paths.d.cts +19 -0
- package/dist/sync/paths.d.cts.map +1 -0
- package/dist/sync/paths.d.ts +19 -0
- package/dist/sync/paths.d.ts.map +1 -0
- package/dist/sync/policies/compare.cjs +389 -11
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts +100 -2
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts +100 -2
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +387 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +76 -65
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.d.cts +35 -6
- package/dist/sync/policies/index.d.cts.map +1 -1
- package/dist/sync/policies/index.d.ts +35 -6
- package/dist/sync/policies/index.d.ts.map +1 -1
- package/dist/sync/policies/index.js +76 -65
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/prefix.cjs +96 -0
- package/dist/sync/prefix.cjs.map +1 -0
- package/dist/sync/prefix.d.cts +55 -0
- package/dist/sync/prefix.d.cts.map +1 -0
- package/dist/sync/prefix.d.ts +55 -0
- package/dist/sync/prefix.d.ts.map +1 -0
- package/dist/sync/prefix.js +92 -0
- package/dist/sync/prefix.js.map +1 -0
- package/dist/sync/regexp-safety.cjs +192 -0
- package/dist/sync/regexp-safety.cjs.map +1 -0
- package/dist/sync/regexp-safety.d.cts +29 -0
- package/dist/sync/regexp-safety.d.cts.map +1 -0
- package/dist/sync/regexp-safety.d.ts +29 -0
- package/dist/sync/regexp-safety.d.ts.map +1 -0
- package/dist/sync/regexp-safety.js +190 -0
- package/dist/sync/regexp-safety.js.map +1 -0
- package/dist/sync/scan-events.cjs +33 -0
- package/dist/sync/scan-events.cjs.map +1 -0
- package/dist/sync/scan-events.d.cts +17 -0
- package/dist/sync/scan-events.d.cts.map +1 -0
- package/dist/sync/scan-events.d.ts +17 -0
- package/dist/sync/scan-events.d.ts.map +1 -0
- package/dist/sync/scan-events.js +32 -0
- package/dist/sync/scan-events.js.map +1 -0
- package/dist/sync/scan-limit.cjs +33 -0
- package/dist/sync/scan-limit.cjs.map +1 -0
- package/dist/sync/scan-limit.d.cts +21 -0
- package/dist/sync/scan-limit.d.cts.map +1 -0
- package/dist/sync/scan-limit.d.ts +21 -0
- package/dist/sync/scan-limit.d.ts.map +1 -0
- package/dist/sync/scan-limit.js +31 -0
- package/dist/sync/scan-limit.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +239 -55
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts +26 -7
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts +26 -7
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +239 -55
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +215 -56
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +22 -7
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +22 -7
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +216 -57
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/sha1-metadata.cjs +94 -0
- package/dist/sync/sha1-metadata.cjs.map +1 -0
- package/dist/sync/sha1-metadata.d.cts +82 -0
- package/dist/sync/sha1-metadata.d.cts.map +1 -0
- package/dist/sync/sha1-metadata.d.ts +82 -0
- package/dist/sync/sha1-metadata.d.ts.map +1 -0
- package/dist/sync/sha1-metadata.js +89 -0
- package/dist/sync/sha1-metadata.js.map +1 -0
- package/dist/sync/sha1-options.cjs +23 -0
- package/dist/sync/sha1-options.cjs.map +1 -0
- package/dist/sync/sha1-options.d.cts +14 -0
- package/dist/sync/sha1-options.d.cts.map +1 -0
- package/dist/sync/sha1-options.d.ts +14 -0
- package/dist/sync/sha1-options.d.ts.map +1 -0
- package/dist/sync/sha1-options.js +21 -0
- package/dist/sync/sha1-options.js.map +1 -0
- package/dist/sync/synchronizer.cjs +782 -197
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +47 -1
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +47 -1
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +779 -173
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +208 -16
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +208 -16
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/auth.cjs +76 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +67 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +67 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +77 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/encryption.cjs +364 -327
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +16 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +16 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +364 -310
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +47 -0
- package/dist/types/errors.cjs.map +1 -0
- package/dist/types/errors.d.cts +13 -4
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +47 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/file.cjs +36 -19
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +2 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +37 -21
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +53 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.js +54 -15
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +12 -11
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +44 -8
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +44 -8
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/lock.cjs +33 -13
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.js +34 -15
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +44 -22
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/upload.d.cts +39 -5
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +39 -5
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +91 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +48 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +48 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +88 -0
- package/dist/upload/abort-scope.js.map +1 -0
- package/dist/upload/cancel.cjs +183 -8
- package/dist/upload/cancel.cjs.map +1 -1
- package/dist/upload/cancel.d.cts +110 -2
- package/dist/upload/cancel.d.cts.map +1 -1
- package/dist/upload/cancel.d.ts +110 -2
- package/dist/upload/cancel.d.ts.map +1 -1
- package/dist/upload/cancel.js +178 -9
- package/dist/upload/cancel.js.map +1 -1
- package/dist/upload/concurrency.cjs +79 -52
- package/dist/upload/concurrency.cjs.map +1 -1
- package/dist/upload/concurrency.js +79 -53
- package/dist/upload/concurrency.js.map +1 -1
- package/dist/upload/finish.cjs +59 -0
- package/dist/upload/finish.cjs.map +1 -0
- package/dist/upload/finish.d.cts +26 -0
- package/dist/upload/finish.d.cts.map +1 -0
- package/dist/upload/finish.d.ts +26 -0
- package/dist/upload/finish.d.ts.map +1 -0
- package/dist/upload/finish.js +59 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +301 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +76 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +76 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +301 -218
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs +28 -0
- package/dist/upload/options.cjs.map +1 -0
- package/dist/upload/options.d.cts +104 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +104 -0
- package/dist/upload/options.d.ts.map +1 -0
- package/dist/upload/options.js +27 -0
- package/dist/upload/options.js.map +1 -0
- package/dist/upload/resume.cjs +333 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +82 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +82 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +330 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +186 -0
- package/dist/upload/retry.cjs.map +1 -0
- package/dist/upload/retry.d.cts +127 -0
- package/dist/upload/retry.d.cts.map +1 -0
- package/dist/upload/retry.d.ts +127 -0
- package/dist/upload/retry.d.ts.map +1 -0
- package/dist/upload/retry.js +182 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +68 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +2 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +2 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +68 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +317 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +3 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +3 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +316 -192
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/best-effort.cjs +42 -8
- package/dist/util/best-effort.cjs.map +1 -1
- package/dist/util/best-effort.d.cts +2 -1
- package/dist/util/best-effort.d.cts.map +1 -1
- package/dist/util/best-effort.d.ts +2 -1
- package/dist/util/best-effort.d.ts.map +1 -1
- package/dist/util/best-effort.js +43 -9
- package/dist/util/best-effort.js.map +1 -1
- package/dist/util/bytes.cjs +23 -0
- package/dist/util/bytes.cjs.map +1 -0
- package/dist/util/bytes.d.cts +15 -0
- package/dist/util/bytes.d.cts.map +1 -0
- package/dist/util/bytes.d.ts +15 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +23 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/crypto.cjs +68 -0
- package/dist/util/crypto.cjs.map +1 -0
- package/dist/util/crypto.d.cts +26 -0
- package/dist/util/crypto.d.cts.map +1 -0
- package/dist/util/crypto.d.ts +26 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +66 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/defaults.cjs +25 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.js +26 -11
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/error-reason.cjs +41 -0
- package/dist/util/error-reason.cjs.map +1 -0
- package/dist/util/error-reason.d.cts +9 -0
- package/dist/util/error-reason.d.cts.map +1 -0
- package/dist/util/error-reason.d.ts +9 -0
- package/dist/util/error-reason.d.ts.map +1 -0
- package/dist/util/error-reason.js +41 -0
- package/dist/util/error-reason.js.map +1 -0
- package/dist/util/http.cjs +23 -0
- package/dist/util/http.cjs.map +1 -0
- package/dist/util/http.d.cts +13 -0
- package/dist/util/http.d.cts.map +1 -0
- package/dist/util/http.d.ts +13 -0
- package/dist/util/http.d.ts.map +1 -0
- package/dist/util/http.js +23 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +63 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.js +64 -16
- package/dist/util/paginator.js.map +1 -1
- package/dist/util/plan-ranges.cjs +47 -22
- package/dist/util/plan-ranges.cjs.map +1 -1
- package/dist/util/plan-ranges.js +48 -24
- package/dist/util/plan-ranges.js.map +1 -1
- package/dist/util/sha1.cjs +27 -0
- package/dist/util/sha1.cjs.map +1 -0
- package/dist/util/sha1.d.cts +17 -0
- package/dist/util/sha1.d.cts.map +1 -0
- package/dist/util/sha1.d.ts +17 -0
- package/dist/util/sha1.d.ts.map +1 -0
- package/dist/util/sha1.js +26 -0
- package/dist/util/sha1.js.map +1 -0
- package/dist/util/text-codec.cjs +29 -5
- package/dist/util/text-codec.cjs.map +1 -1
- package/dist/util/text-codec.js +30 -7
- package/dist/util/text-codec.js.map +1 -1
- package/dist/util/to-error.cjs +18 -4
- package/dist/util/to-error.cjs.map +1 -1
- package/dist/util/to-error.js +19 -5
- package/dist/util/to-error.js.map +1 -1
- package/dist/version.cjs +17 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -3
- package/dist/version.d.ts +3 -3
- package/dist/version.js +19 -6
- package/dist/version.js.map +1 -1
- package/package.json +19 -16
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications/index.cjs.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/package.json.cjs +0 -9
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -9
- package/dist/package.json.js.map +0 -1
- package/dist/streams/index.cjs.map +0 -1
- package/dist/streams/index.js.map +0 -1
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const require_to_error = require("./to-error.cjs");
|
|
2
|
+
//#region src/util/error-reason.ts
|
|
3
|
+
/**
|
|
4
|
+
* Formats an unknown error for public diagnostics without leaking filesystem paths.
|
|
5
|
+
*
|
|
6
|
+
* @param err - Unknown thrown value.
|
|
7
|
+
*
|
|
8
|
+
* @returns A stable, sanitized reason.
|
|
9
|
+
*/
|
|
10
|
+
function sanitizeErrorReason(err) {
|
|
11
|
+
const error = require_to_error.toError(err);
|
|
12
|
+
const code = error.code;
|
|
13
|
+
if (typeof code === "string" && code.length > 0) {
|
|
14
|
+
const reason = cleanReason(code);
|
|
15
|
+
if (reason.length > 0) return reason;
|
|
16
|
+
}
|
|
17
|
+
const message = cleanReason(error.message);
|
|
18
|
+
if (message.length > 0 && !/[\\/]/.test(message)) return message;
|
|
19
|
+
const name = cleanReason(error.name);
|
|
20
|
+
if (name.length > 0) return name;
|
|
21
|
+
return "Error";
|
|
22
|
+
}
|
|
23
|
+
function cleanReason(value) {
|
|
24
|
+
let cleaned = "";
|
|
25
|
+
let sawNonWhitespace = false;
|
|
26
|
+
for (const char of value) {
|
|
27
|
+
const code = char.charCodeAt(0);
|
|
28
|
+
if (code < 32 || code === 127) continue;
|
|
29
|
+
if (!sawNonWhitespace) {
|
|
30
|
+
if (char.trim().length === 0) continue;
|
|
31
|
+
sawNonWhitespace = true;
|
|
32
|
+
}
|
|
33
|
+
cleaned += char;
|
|
34
|
+
if (cleaned.length >= 200) break;
|
|
35
|
+
}
|
|
36
|
+
return cleaned.trimEnd();
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.sanitizeErrorReason = sanitizeErrorReason;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=error-reason.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-reason.cjs","names":[],"sources":["../../src/util/error-reason.ts"],"sourcesContent":["import { toError } from './to-error.ts'\n\n/**\n * Formats an unknown error for public diagnostics without leaking filesystem paths.\n *\n * @param err - Unknown thrown value.\n *\n * @returns A stable, sanitized reason.\n */\nexport function sanitizeErrorReason(err: unknown): string {\n const error = toError(err)\n const code = (error as { readonly code?: unknown }).code\n if (typeof code === 'string' && code.length > 0) {\n const reason = cleanReason(code)\n if (reason.length > 0) return reason\n }\n const message = cleanReason(error.message)\n if (message.length > 0 && !/[\\\\/]/.test(message)) return message\n const name = cleanReason(error.name)\n if (name.length > 0) return name\n return 'Error'\n}\n\nfunction cleanReason(value: string): string {\n let cleaned = ''\n let sawNonWhitespace = false\n for (const char of value) {\n const code = char.charCodeAt(0)\n if (code < 0x20 || code === 0x7f) continue\n if (!sawNonWhitespace) {\n if (char.trim().length === 0) continue\n sawNonWhitespace = true\n }\n cleaned += char\n if (cleaned.length >= 200) break\n }\n return cleaned.trimEnd()\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAoB,KAAsB;CACxD,MAAM,QAAQ,iBAAA,QAAQ,GAAG;CACzB,MAAM,OAAQ,MAAsC;CACpD,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAAG;EAC/C,MAAM,SAAS,YAAY,IAAI;EAC/B,IAAI,OAAO,SAAS,GAAG,OAAO;CAChC;CACA,MAAM,UAAU,YAAY,MAAM,OAAO;CACzC,IAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,KAAK,OAAO,GAAG,OAAO;CACzD,MAAM,OAAO,YAAY,MAAM,IAAI;CACnC,IAAI,KAAK,SAAS,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,SAAS,YAAY,OAAuB;CAC1C,IAAI,UAAU;CACd,IAAI,mBAAmB;CACvB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,WAAW,CAAC;EAC9B,IAAI,OAAO,MAAQ,SAAS,KAAM;EAClC,IAAI,CAAC,kBAAkB;GACrB,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG;GAC9B,mBAAmB;EACrB;EACA,WAAW;EACX,IAAI,QAAQ,UAAU,KAAK;CAC7B;CACA,OAAO,QAAQ,QAAQ;AACzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats an unknown error for public diagnostics without leaking filesystem paths.
|
|
3
|
+
*
|
|
4
|
+
* @param err - Unknown thrown value.
|
|
5
|
+
*
|
|
6
|
+
* @returns A stable, sanitized reason.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sanitizeErrorReason(err: unknown): string;
|
|
9
|
+
//# sourceMappingURL=error-reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-reason.d.ts","sourceRoot":"","sources":["../../src/util/error-reason.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAYxD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats an unknown error for public diagnostics without leaking filesystem paths.
|
|
3
|
+
*
|
|
4
|
+
* @param err - Unknown thrown value.
|
|
5
|
+
*
|
|
6
|
+
* @returns A stable, sanitized reason.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sanitizeErrorReason(err: unknown): string;
|
|
9
|
+
//# sourceMappingURL=error-reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-reason.d.ts","sourceRoot":"","sources":["../../src/util/error-reason.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAYxD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { toError } from "./to-error.js";
|
|
2
|
+
//#region src/util/error-reason.ts
|
|
3
|
+
/**
|
|
4
|
+
* Formats an unknown error for public diagnostics without leaking filesystem paths.
|
|
5
|
+
*
|
|
6
|
+
* @param err - Unknown thrown value.
|
|
7
|
+
*
|
|
8
|
+
* @returns A stable, sanitized reason.
|
|
9
|
+
*/
|
|
10
|
+
function sanitizeErrorReason(err) {
|
|
11
|
+
const error = toError(err);
|
|
12
|
+
const code = error.code;
|
|
13
|
+
if (typeof code === "string" && code.length > 0) {
|
|
14
|
+
const reason = cleanReason(code);
|
|
15
|
+
if (reason.length > 0) return reason;
|
|
16
|
+
}
|
|
17
|
+
const message = cleanReason(error.message);
|
|
18
|
+
if (message.length > 0 && !/[\\/]/.test(message)) return message;
|
|
19
|
+
const name = cleanReason(error.name);
|
|
20
|
+
if (name.length > 0) return name;
|
|
21
|
+
return "Error";
|
|
22
|
+
}
|
|
23
|
+
function cleanReason(value) {
|
|
24
|
+
let cleaned = "";
|
|
25
|
+
let sawNonWhitespace = false;
|
|
26
|
+
for (const char of value) {
|
|
27
|
+
const code = char.charCodeAt(0);
|
|
28
|
+
if (code < 32 || code === 127) continue;
|
|
29
|
+
if (!sawNonWhitespace) {
|
|
30
|
+
if (char.trim().length === 0) continue;
|
|
31
|
+
sawNonWhitespace = true;
|
|
32
|
+
}
|
|
33
|
+
cleaned += char;
|
|
34
|
+
if (cleaned.length >= 200) break;
|
|
35
|
+
}
|
|
36
|
+
return cleaned.trimEnd();
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { sanitizeErrorReason };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=error-reason.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-reason.js","names":[],"sources":["../../src/util/error-reason.ts"],"sourcesContent":["import { toError } from './to-error.ts'\n\n/**\n * Formats an unknown error for public diagnostics without leaking filesystem paths.\n *\n * @param err - Unknown thrown value.\n *\n * @returns A stable, sanitized reason.\n */\nexport function sanitizeErrorReason(err: unknown): string {\n const error = toError(err)\n const code = (error as { readonly code?: unknown }).code\n if (typeof code === 'string' && code.length > 0) {\n const reason = cleanReason(code)\n if (reason.length > 0) return reason\n }\n const message = cleanReason(error.message)\n if (message.length > 0 && !/[\\\\/]/.test(message)) return message\n const name = cleanReason(error.name)\n if (name.length > 0) return name\n return 'Error'\n}\n\nfunction cleanReason(value: string): string {\n let cleaned = ''\n let sawNonWhitespace = false\n for (const char of value) {\n const code = char.charCodeAt(0)\n if (code < 0x20 || code === 0x7f) continue\n if (!sawNonWhitespace) {\n if (char.trim().length === 0) continue\n sawNonWhitespace = true\n }\n cleaned += char\n if (cleaned.length >= 200) break\n }\n return cleaned.trimEnd()\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAoB,KAAsB;CACxD,MAAM,QAAQ,QAAQ,GAAG;CACzB,MAAM,OAAQ,MAAsC;CACpD,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAAG;EAC/C,MAAM,SAAS,YAAY,IAAI;EAC/B,IAAI,OAAO,SAAS,GAAG,OAAO;CAChC;CACA,MAAM,UAAU,YAAY,MAAM,OAAO;CACzC,IAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,KAAK,OAAO,GAAG,OAAO;CACzD,MAAM,OAAO,YAAY,MAAM,IAAI;CACnC,IAAI,KAAK,SAAS,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,SAAS,YAAY,OAAuB;CAC1C,IAAI,UAAU;CACd,IAAI,mBAAmB;CACvB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,WAAW,CAAC;EAC9B,IAAI,OAAO,MAAQ,SAAS,KAAM;EAClC,IAAI,CAAC,kBAAkB;GACrB,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG;GAC9B,mBAAmB;EACrB;EACA,WAAW;EACX,IAAI,QAAQ,UAAU,KAAK;CAC7B;CACA,OAAO,QAAQ,QAAQ;AACzB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/util/http.ts
|
|
2
|
+
/**
|
|
3
|
+
* Detect HTTP header value control characters.
|
|
4
|
+
*
|
|
5
|
+
* Header values used by this SDK must not contain C0 controls or DEL. Rejecting
|
|
6
|
+
* them before signing avoids relying on later whitespace normalization to
|
|
7
|
+
* neutralize CR/LF header injection.
|
|
8
|
+
*
|
|
9
|
+
* @param value - Header value to inspect.
|
|
10
|
+
*
|
|
11
|
+
* @returns `true` when the value contains a disallowed control character.
|
|
12
|
+
*/
|
|
13
|
+
function hasHttpHeaderControlCharacter(value) {
|
|
14
|
+
for (let i = 0; i < value.length; i++) {
|
|
15
|
+
const code = value.charCodeAt(i);
|
|
16
|
+
if (code <= 31 || code === 127) return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.hasHttpHeaderControlCharacter = hasHttpHeaderControlCharacter;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=http.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.cjs","names":[],"sources":["../../src/util/http.ts"],"sourcesContent":["/**\n * Detect HTTP header value control characters.\n *\n * Header values used by this SDK must not contain C0 controls or DEL. Rejecting\n * them before signing avoids relying on later whitespace normalization to\n * neutralize CR/LF header injection.\n *\n * @param value - Header value to inspect.\n *\n * @returns `true` when the value contains a disallowed control character.\n */\nexport function hasHttpHeaderControlCharacter(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i)\n if (code <= 0x1f || code === 0x7f) return true\n }\n\n return false\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,8BAA8B,OAAwB;CACpE,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,CAAC;EAC/B,IAAI,QAAQ,MAAQ,SAAS,KAAM,OAAO;CAC5C;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect HTTP header value control characters.
|
|
3
|
+
*
|
|
4
|
+
* Header values used by this SDK must not contain C0 controls or DEL. Rejecting
|
|
5
|
+
* them before signing avoids relying on later whitespace normalization to
|
|
6
|
+
* neutralize CR/LF header injection.
|
|
7
|
+
*
|
|
8
|
+
* @param value - Header value to inspect.
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` when the value contains a disallowed control character.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasHttpHeaderControlCharacter(value: string): boolean;
|
|
13
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/util/http.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect HTTP header value control characters.
|
|
3
|
+
*
|
|
4
|
+
* Header values used by this SDK must not contain C0 controls or DEL. Rejecting
|
|
5
|
+
* them before signing avoids relying on later whitespace normalization to
|
|
6
|
+
* neutralize CR/LF header injection.
|
|
7
|
+
*
|
|
8
|
+
* @param value - Header value to inspect.
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` when the value contains a disallowed control character.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasHttpHeaderControlCharacter(value: string): boolean;
|
|
13
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/util/http.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/util/http.ts
|
|
2
|
+
/**
|
|
3
|
+
* Detect HTTP header value control characters.
|
|
4
|
+
*
|
|
5
|
+
* Header values used by this SDK must not contain C0 controls or DEL. Rejecting
|
|
6
|
+
* them before signing avoids relying on later whitespace normalization to
|
|
7
|
+
* neutralize CR/LF header injection.
|
|
8
|
+
*
|
|
9
|
+
* @param value - Header value to inspect.
|
|
10
|
+
*
|
|
11
|
+
* @returns `true` when the value contains a disallowed control character.
|
|
12
|
+
*/
|
|
13
|
+
function hasHttpHeaderControlCharacter(value) {
|
|
14
|
+
for (let i = 0; i < value.length; i++) {
|
|
15
|
+
const code = value.charCodeAt(i);
|
|
16
|
+
if (code <= 31 || code === 127) return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { hasHttpHeaderControlCharacter };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","names":[],"sources":["../../src/util/http.ts"],"sourcesContent":["/**\n * Detect HTTP header value control characters.\n *\n * Header values used by this SDK must not contain C0 controls or DEL. Rejecting\n * them before signing avoids relying on later whitespace normalization to\n * neutralize CR/LF header injection.\n *\n * @param value - Header value to inspect.\n *\n * @returns `true` when the value contains a disallowed control character.\n */\nexport function hasHttpHeaderControlCharacter(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i)\n if (code <= 0x1f || code === 0x7f) return true\n }\n\n return false\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,8BAA8B,OAAwB;CACpE,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,CAAC;EAC/B,IAAI,QAAQ,MAAQ,SAAS,KAAM,OAAO;CAC5C;CAEA,OAAO;AACT"}
|
package/dist/util/normalize.cjs
CHANGED
|
@@ -1,16 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/util/normalize.ts
|
|
2
|
+
/**
|
|
3
|
+
* Wire-shape → SDK-shape normalization helpers.
|
|
4
|
+
*
|
|
5
|
+
* B2 occasionally uses sentinel strings on the wire where a missing
|
|
6
|
+
* value would be more idiomatic in TypeScript. The biggest offender is
|
|
7
|
+
* `contentSha1: 'none'` on files completed via `b2_finish_large_file`
|
|
8
|
+
* (multipart-finished files don't have a whole-file SHA-1; B2 sends the
|
|
9
|
+
* literal three-letter string). The SDK's `FileVersion.contentSha1` is
|
|
10
|
+
* typed `string | null` to signal that absence — this module collapses
|
|
11
|
+
* the wire sentinel to `null` so callers can write
|
|
12
|
+
* `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.
|
|
13
|
+
*
|
|
14
|
+
* Normalization happens at the RawClient boundary so every SDK consumer
|
|
15
|
+
* (RawClient direct users, the high-level facade, the simulator-driven
|
|
16
|
+
* tests, generated docs) sees the same `null` value.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for
|
|
22
|
+
* SHA-1-shaped fields. Any other string passes through unchanged.
|
|
23
|
+
*
|
|
24
|
+
* @param raw - SHA-1 string from the wire, or `null`/`undefined`.
|
|
25
|
+
*
|
|
26
|
+
* @returns A hex SHA-1 string, or `null` when the wire said "no hash".
|
|
27
|
+
*/
|
|
3
28
|
function normalizeSha1(raw) {
|
|
4
|
-
|
|
5
|
-
|
|
29
|
+
if (raw === null || raw === void 0 || raw === "none") return null;
|
|
30
|
+
return raw;
|
|
6
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns a new file-version-shaped object with the `contentSha1: 'none'`
|
|
34
|
+
* sentinel collapsed to `null`. Pass-through when the value is already
|
|
35
|
+
* `null` or a real hash. The object reference is preserved if no
|
|
36
|
+
* substitution was needed, so callers paying for change detection
|
|
37
|
+
* (e.g. React memo) see referential stability.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam T - Any object with a `contentSha1: string | null` field.
|
|
40
|
+
*
|
|
41
|
+
* @param fv - The wire-shape file-version object.
|
|
42
|
+
*
|
|
43
|
+
* @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
|
|
44
|
+
*/
|
|
7
45
|
function normalizeFileVersionSha1(fv) {
|
|
8
|
-
|
|
46
|
+
return fv.contentSha1 === "none" ? {
|
|
47
|
+
...fv,
|
|
48
|
+
contentSha1: null
|
|
49
|
+
} : fv;
|
|
9
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns a new list-response object with `normalizeFileVersionSha1`
|
|
53
|
+
* applied to every entry in `files`. Used at the `b2_list_file_names` /
|
|
54
|
+
* `b2_list_file_versions` boundary so list output shares the same
|
|
55
|
+
* SHA-1 semantics as the singular endpoints.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam F - Any object with a `contentSha1: string | null` field.
|
|
58
|
+
* @typeParam R - The list-response shape (must have a `files` array of `F`).
|
|
59
|
+
*
|
|
60
|
+
* @param resp - The wire-shape list response.
|
|
61
|
+
*
|
|
62
|
+
* @returns A response with normalized `files`. `resp.files` is a new array.
|
|
63
|
+
*/
|
|
10
64
|
function normalizeFileVersionListSha1(resp) {
|
|
11
|
-
|
|
65
|
+
return {
|
|
66
|
+
...resp,
|
|
67
|
+
files: resp.files.map(normalizeFileVersionSha1)
|
|
68
|
+
};
|
|
12
69
|
}
|
|
70
|
+
//#endregion
|
|
13
71
|
exports.normalizeFileVersionListSha1 = normalizeFileVersionListSha1;
|
|
14
72
|
exports.normalizeFileVersionSha1 = normalizeFileVersionSha1;
|
|
15
73
|
exports.normalizeSha1 = normalizeSha1;
|
|
16
|
-
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=normalize.cjs.map
|
|
@@ -1 +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"],"
|
|
1
|
+
{"version":3,"file":"normalize.cjs","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,KAA+C;CAC3E,IAAI,QAAQ,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,OAAO;CAChE,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,yBACd,IACG;CACH,OAAO,GAAG,gBAAgB,SAAS;EAAE,GAAG;EAAI,aAAa;CAAK,IAAI;AACpE;;;;;;;;;;;;;;AAeA,SAAgB,6BAGd,MAAY;CACZ,OAAO;EAAE,GAAG;EAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB;CAAE;AACpE"}
|
package/dist/util/normalize.js
CHANGED
|
@@ -1,16 +1,73 @@
|
|
|
1
|
+
//#region src/util/normalize.ts
|
|
2
|
+
/**
|
|
3
|
+
* Wire-shape → SDK-shape normalization helpers.
|
|
4
|
+
*
|
|
5
|
+
* B2 occasionally uses sentinel strings on the wire where a missing
|
|
6
|
+
* value would be more idiomatic in TypeScript. The biggest offender is
|
|
7
|
+
* `contentSha1: 'none'` on files completed via `b2_finish_large_file`
|
|
8
|
+
* (multipart-finished files don't have a whole-file SHA-1; B2 sends the
|
|
9
|
+
* literal three-letter string). The SDK's `FileVersion.contentSha1` is
|
|
10
|
+
* typed `string | null` to signal that absence — this module collapses
|
|
11
|
+
* the wire sentinel to `null` so callers can write
|
|
12
|
+
* `if (fv.contentSha1) { ... }` without an extra `=== 'none'` guard.
|
|
13
|
+
*
|
|
14
|
+
* Normalization happens at the RawClient boundary so every SDK consumer
|
|
15
|
+
* (RawClient direct users, the high-level facade, the simulator-driven
|
|
16
|
+
* tests, generated docs) sees the same `null` value.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Collapses the B2 wire sentinel `'none'` (and `undefined`) to `null` for
|
|
22
|
+
* SHA-1-shaped fields. Any other string passes through unchanged.
|
|
23
|
+
*
|
|
24
|
+
* @param raw - SHA-1 string from the wire, or `null`/`undefined`.
|
|
25
|
+
*
|
|
26
|
+
* @returns A hex SHA-1 string, or `null` when the wire said "no hash".
|
|
27
|
+
*/
|
|
1
28
|
function normalizeSha1(raw) {
|
|
2
|
-
|
|
3
|
-
|
|
29
|
+
if (raw === null || raw === void 0 || raw === "none") return null;
|
|
30
|
+
return raw;
|
|
4
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns a new file-version-shaped object with the `contentSha1: 'none'`
|
|
34
|
+
* sentinel collapsed to `null`. Pass-through when the value is already
|
|
35
|
+
* `null` or a real hash. The object reference is preserved if no
|
|
36
|
+
* substitution was needed, so callers paying for change detection
|
|
37
|
+
* (e.g. React memo) see referential stability.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam T - Any object with a `contentSha1: string | null` field.
|
|
40
|
+
*
|
|
41
|
+
* @param fv - The wire-shape file-version object.
|
|
42
|
+
*
|
|
43
|
+
* @returns Either `fv` unchanged or a shallow copy with `contentSha1: null`.
|
|
44
|
+
*/
|
|
5
45
|
function normalizeFileVersionSha1(fv) {
|
|
6
|
-
|
|
46
|
+
return fv.contentSha1 === "none" ? {
|
|
47
|
+
...fv,
|
|
48
|
+
contentSha1: null
|
|
49
|
+
} : fv;
|
|
7
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns a new list-response object with `normalizeFileVersionSha1`
|
|
53
|
+
* applied to every entry in `files`. Used at the `b2_list_file_names` /
|
|
54
|
+
* `b2_list_file_versions` boundary so list output shares the same
|
|
55
|
+
* SHA-1 semantics as the singular endpoints.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam F - Any object with a `contentSha1: string | null` field.
|
|
58
|
+
* @typeParam R - The list-response shape (must have a `files` array of `F`).
|
|
59
|
+
*
|
|
60
|
+
* @param resp - The wire-shape list response.
|
|
61
|
+
*
|
|
62
|
+
* @returns A response with normalized `files`. `resp.files` is a new array.
|
|
63
|
+
*/
|
|
8
64
|
function normalizeFileVersionListSha1(resp) {
|
|
9
|
-
|
|
65
|
+
return {
|
|
66
|
+
...resp,
|
|
67
|
+
files: resp.files.map(normalizeFileVersionSha1)
|
|
68
|
+
};
|
|
10
69
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=normalize.js.map
|
|
70
|
+
//#endregion
|
|
71
|
+
export { normalizeFileVersionListSha1, normalizeFileVersionSha1, normalizeSha1 };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +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"],"
|
|
1
|
+
{"version":3,"file":"normalize.js","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc,KAA+C;CAC3E,IAAI,QAAQ,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,OAAO;CAChE,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,yBACd,IACG;CACH,OAAO,GAAG,gBAAgB,SAAS;EAAE,GAAG;EAAI,aAAa;CAAK,IAAI;AACpE;;;;;;;;;;;;;;AAeA,SAAgB,6BAGd,MAAY;CACZ,OAAO;EAAE,GAAG;EAAM,OAAO,KAAK,MAAM,IAAI,wBAAwB;CAAE;AACpE"}
|
package/dist/util/paginator.cjs
CHANGED
|
@@ -1,20 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/util/paginator.ts
|
|
2
|
+
/**
|
|
3
|
+
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
4
|
+
* `nextCursor: undefined`.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Page - The per-page response shape.
|
|
7
|
+
* @typeParam Cursor - The cursor type used to request the next page.
|
|
8
|
+
*
|
|
9
|
+
* @param fetcher - Function that fetches one page given the current cursor.
|
|
10
|
+
* @param signal - Optional abort signal. Checked before each fetch.
|
|
11
|
+
*
|
|
12
|
+
* @returns An async iterable of pages.
|
|
13
|
+
*
|
|
14
|
+
* @throws DOMException When `signal` is aborted between fetches.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* for await (const page of paginatePages(
|
|
19
|
+
* async (cursor) => {
|
|
20
|
+
* const resp = await bucket.listFileNames({ startFileName: cursor })
|
|
21
|
+
* return { page: resp, nextCursor: resp.nextFileName ?? undefined }
|
|
22
|
+
* },
|
|
23
|
+
* abortSignal,
|
|
24
|
+
* )) {
|
|
25
|
+
* for (const file of page.files) { ... }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
3
29
|
async function* paginatePages(fetcher, signal) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
30
|
+
let cursor;
|
|
31
|
+
while (true) {
|
|
32
|
+
signal?.throwIfAborted();
|
|
33
|
+
const { page, nextCursor } = await fetcher(cursor);
|
|
34
|
+
yield page;
|
|
35
|
+
if (nextCursor === void 0) return;
|
|
36
|
+
cursor = nextCursor;
|
|
37
|
+
}
|
|
12
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Async-iterates items by flattening pages. The `extractItems` function
|
|
41
|
+
* pulls the relevant array out of each page (e.g. `page.files`,
|
|
42
|
+
* `page.keys`, `page.parts`). Each item is yielded individually so the
|
|
43
|
+
* caller can `for await (const item of paginator)` rather than nest loops.
|
|
44
|
+
*
|
|
45
|
+
* Aborts between **pages**, not between items: if `signal` is aborted while
|
|
46
|
+
* the caller is processing the items of page N, the iterator will still
|
|
47
|
+
* yield all of page N's remaining items before checking the signal before
|
|
48
|
+
* fetching page N+1.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam Page - The per-page response shape.
|
|
51
|
+
* @typeParam Cursor - The cursor type used to request the next page.
|
|
52
|
+
* @typeParam Item - The item type the caller wants to iterate.
|
|
53
|
+
*
|
|
54
|
+
* @param fetcher - Function that fetches one page given the current cursor.
|
|
55
|
+
* @param extractItems - Pulls the iterable items out of a page.
|
|
56
|
+
* @param signal - Optional abort signal. Checked before each fetch.
|
|
57
|
+
*
|
|
58
|
+
* @returns An async iterable of individual items.
|
|
59
|
+
*
|
|
60
|
+
* @throws DOMException When `signal` is aborted between fetches.
|
|
61
|
+
*/
|
|
13
62
|
async function* paginateItems(fetcher, extractItems, signal) {
|
|
14
|
-
|
|
15
|
-
yield* extractItems(page);
|
|
16
|
-
}
|
|
63
|
+
for await (const page of paginatePages(fetcher, signal)) yield* extractItems(page);
|
|
17
64
|
}
|
|
65
|
+
//#endregion
|
|
18
66
|
exports.paginateItems = paginateItems;
|
|
19
67
|
exports.paginatePages = paginatePages;
|
|
20
|
-
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=paginator.cjs.map
|
|
@@ -1 +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"],"
|
|
1
|
+
{"version":3,"file":"paginator.cjs","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,gBAAuB,cACrB,SACA,QAC6B;CAC7B,IAAI;CACJ,OAAO,MAAM;EACX,QAAQ,eAAe;EACvB,MAAM,EAAE,MAAM,eAAe,MAAM,QAAQ,MAAM;EACjD,MAAM;EACN,IAAI,eAAe,KAAA,GAAW;EAC9B,SAAS;CACX;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,gBAAuB,cACrB,SACA,cACA,QAC6B;CAC7B,WAAW,MAAM,QAAQ,cAAc,SAAS,MAAM,GACpD,OAAO,aAAa,IAAI;AAE5B"}
|
package/dist/util/paginator.js
CHANGED
|
@@ -1,20 +1,68 @@
|
|
|
1
|
+
//#region src/util/paginator.ts
|
|
2
|
+
/**
|
|
3
|
+
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
4
|
+
* `nextCursor: undefined`.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Page - The per-page response shape.
|
|
7
|
+
* @typeParam Cursor - The cursor type used to request the next page.
|
|
8
|
+
*
|
|
9
|
+
* @param fetcher - Function that fetches one page given the current cursor.
|
|
10
|
+
* @param signal - Optional abort signal. Checked before each fetch.
|
|
11
|
+
*
|
|
12
|
+
* @returns An async iterable of pages.
|
|
13
|
+
*
|
|
14
|
+
* @throws DOMException When `signal` is aborted between fetches.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* for await (const page of paginatePages(
|
|
19
|
+
* async (cursor) => {
|
|
20
|
+
* const resp = await bucket.listFileNames({ startFileName: cursor })
|
|
21
|
+
* return { page: resp, nextCursor: resp.nextFileName ?? undefined }
|
|
22
|
+
* },
|
|
23
|
+
* abortSignal,
|
|
24
|
+
* )) {
|
|
25
|
+
* for (const file of page.files) { ... }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
1
29
|
async function* paginatePages(fetcher, signal) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
let cursor;
|
|
31
|
+
while (true) {
|
|
32
|
+
signal?.throwIfAborted();
|
|
33
|
+
const { page, nextCursor } = await fetcher(cursor);
|
|
34
|
+
yield page;
|
|
35
|
+
if (nextCursor === void 0) return;
|
|
36
|
+
cursor = nextCursor;
|
|
37
|
+
}
|
|
10
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Async-iterates items by flattening pages. The `extractItems` function
|
|
41
|
+
* pulls the relevant array out of each page (e.g. `page.files`,
|
|
42
|
+
* `page.keys`, `page.parts`). Each item is yielded individually so the
|
|
43
|
+
* caller can `for await (const item of paginator)` rather than nest loops.
|
|
44
|
+
*
|
|
45
|
+
* Aborts between **pages**, not between items: if `signal` is aborted while
|
|
46
|
+
* the caller is processing the items of page N, the iterator will still
|
|
47
|
+
* yield all of page N's remaining items before checking the signal before
|
|
48
|
+
* fetching page N+1.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam Page - The per-page response shape.
|
|
51
|
+
* @typeParam Cursor - The cursor type used to request the next page.
|
|
52
|
+
* @typeParam Item - The item type the caller wants to iterate.
|
|
53
|
+
*
|
|
54
|
+
* @param fetcher - Function that fetches one page given the current cursor.
|
|
55
|
+
* @param extractItems - Pulls the iterable items out of a page.
|
|
56
|
+
* @param signal - Optional abort signal. Checked before each fetch.
|
|
57
|
+
*
|
|
58
|
+
* @returns An async iterable of individual items.
|
|
59
|
+
*
|
|
60
|
+
* @throws DOMException When `signal` is aborted between fetches.
|
|
61
|
+
*/
|
|
11
62
|
async function* paginateItems(fetcher, extractItems, signal) {
|
|
12
|
-
|
|
13
|
-
yield* extractItems(page);
|
|
14
|
-
}
|
|
63
|
+
for await (const page of paginatePages(fetcher, signal)) yield* extractItems(page);
|
|
15
64
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=paginator.js.map
|
|
65
|
+
//#endregion
|
|
66
|
+
export { paginateItems, paginatePages };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=paginator.js.map
|