@backblaze-labs/b2-sdk 0.2.0 → 0.3.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 +42 -1
- package/README.md +20 -2
- package/dist/_virtual/_b2-sdk-version-json.cjs +1 -1
- package/dist/_virtual/_b2-sdk-version-json.js +1 -1
- package/dist/auth/file.cjs.map +1 -1
- package/dist/backup/client.cjs +206 -0
- package/dist/backup/client.cjs.map +1 -0
- package/dist/backup/client.d.cts +238 -0
- package/dist/backup/client.d.cts.map +1 -0
- package/dist/backup/client.d.ts +238 -0
- package/dist/backup/client.d.ts.map +1 -0
- package/dist/backup/client.js +206 -0
- package/dist/backup/client.js.map +1 -0
- package/dist/backup/index.cjs +15 -0
- package/dist/backup/index.d.cts +22 -0
- package/dist/backup/index.d.cts.map +1 -0
- package/dist/backup/index.d.ts +22 -0
- package/dist/backup/index.d.ts.map +1 -0
- package/dist/backup/index.js +7 -0
- package/dist/backup/raw.cjs +146 -0
- package/dist/backup/raw.cjs.map +1 -0
- package/dist/backup/raw.d.cts +122 -0
- package/dist/backup/raw.d.cts.map +1 -0
- package/dist/backup/raw.d.ts +122 -0
- package/dist/backup/raw.d.ts.map +1 -0
- package/dist/backup/raw.js +146 -0
- package/dist/backup/raw.js.map +1 -0
- package/dist/bucket.cjs +2 -1
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.js +2 -1
- package/dist/bucket.js.map +1 -1
- package/dist/copy/large.cjs +5 -3
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +5 -3
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +6 -2
- package/dist/download/checksum.cjs.map +1 -1
- package/dist/download/checksum.js +6 -2
- package/dist/download/checksum.js.map +1 -1
- package/dist/download/parallel.cjs +52 -15
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +8 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +8 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +52 -15
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +141 -6
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +141 -6
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +173 -3
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +119 -0
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +119 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +161 -4
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +1 -1
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.js +1 -1
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +61 -23
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +25 -3
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +25 -3
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +59 -22
- package/dist/http/transport.js.map +1 -1
- package/dist/index.cjs +25 -2
- package/dist/index.d.cts +6 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/object.cjs +1 -1
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +4 -2
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +4 -2
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +1 -1
- package/dist/object.js.map +1 -1
- package/dist/partner/account-info.d.cts +43 -0
- package/dist/partner/account-info.d.cts.map +1 -0
- package/dist/partner/account-info.d.ts +43 -0
- package/dist/partner/account-info.d.ts.map +1 -0
- package/dist/partner/auth-clone.cjs +64 -0
- package/dist/partner/auth-clone.cjs.map +1 -0
- package/dist/partner/auth-clone.d.cts +27 -0
- package/dist/partner/auth-clone.d.cts.map +1 -0
- package/dist/partner/auth-clone.d.ts +27 -0
- package/dist/partner/auth-clone.d.ts.map +1 -0
- package/dist/partner/auth-clone.js +63 -0
- package/dist/partner/auth-clone.js.map +1 -0
- package/dist/partner/auth-core.cjs +175 -0
- package/dist/partner/auth-core.cjs.map +1 -0
- package/dist/partner/auth-core.d.cts +111 -0
- package/dist/partner/auth-core.d.cts.map +1 -0
- package/dist/partner/auth-core.d.ts +111 -0
- package/dist/partner/auth-core.d.ts.map +1 -0
- package/dist/partner/auth-core.js +175 -0
- package/dist/partner/auth-core.js.map +1 -0
- package/dist/partner/auth-shape.cjs +36 -0
- package/dist/partner/auth-shape.cjs.map +1 -0
- package/dist/partner/auth-shape.d.cts +12 -0
- package/dist/partner/auth-shape.d.cts.map +1 -0
- package/dist/partner/auth-shape.d.ts +12 -0
- package/dist/partner/auth-shape.d.ts.map +1 -0
- package/dist/partner/auth-shape.js +36 -0
- package/dist/partner/auth-shape.js.map +1 -0
- package/dist/partner/client.cjs +255 -0
- package/dist/partner/client.cjs.map +1 -0
- package/dist/partner/client.d.cts +335 -0
- package/dist/partner/client.d.cts.map +1 -0
- package/dist/partner/client.d.ts +335 -0
- package/dist/partner/client.d.ts.map +1 -0
- package/dist/partner/client.js +255 -0
- package/dist/partner/client.js.map +1 -0
- package/dist/partner/endpoint-url.cjs +108 -0
- package/dist/partner/endpoint-url.cjs.map +1 -0
- package/dist/partner/endpoint-url.d.cts +72 -0
- package/dist/partner/endpoint-url.d.cts.map +1 -0
- package/dist/partner/endpoint-url.d.ts +72 -0
- package/dist/partner/endpoint-url.d.ts.map +1 -0
- package/dist/partner/endpoint-url.js +105 -0
- package/dist/partner/endpoint-url.js.map +1 -0
- package/dist/partner/in-memory.cjs +135 -0
- package/dist/partner/in-memory.cjs.map +1 -0
- package/dist/partner/in-memory.d.cts +99 -0
- package/dist/partner/in-memory.d.cts.map +1 -0
- package/dist/partner/in-memory.d.ts +99 -0
- package/dist/partner/in-memory.d.ts.map +1 -0
- package/dist/partner/in-memory.js +135 -0
- package/dist/partner/in-memory.js.map +1 -0
- package/dist/partner/index.cjs +18 -0
- package/dist/partner/index.d.cts +23 -0
- package/dist/partner/index.d.cts.map +1 -0
- package/dist/partner/index.d.ts +23 -0
- package/dist/partner/index.d.ts.map +1 -0
- package/dist/partner/index.js +7 -0
- package/dist/partner/raw.cjs +392 -0
- package/dist/partner/raw.cjs.map +1 -0
- package/dist/partner/raw.d.cts +223 -0
- package/dist/partner/raw.d.cts.map +1 -0
- package/dist/partner/raw.d.ts +223 -0
- package/dist/partner/raw.d.ts.map +1 -0
- package/dist/partner/raw.js +390 -0
- package/dist/partner/raw.js.map +1 -0
- package/dist/partner/redaction-placeholders.cjs +10 -0
- package/dist/partner/redaction-placeholders.cjs.map +1 -0
- package/dist/partner/redaction-placeholders.d.cts +5 -0
- package/dist/partner/redaction-placeholders.d.cts.map +1 -0
- package/dist/partner/redaction-placeholders.d.ts +5 -0
- package/dist/partner/redaction-placeholders.d.ts.map +1 -0
- package/dist/partner/redaction-placeholders.js +9 -0
- package/dist/partner/redaction-placeholders.js.map +1 -0
- package/dist/partner/redaction.cjs +267 -0
- package/dist/partner/redaction.cjs.map +1 -0
- package/dist/partner/redaction.d.cts +124 -0
- package/dist/partner/redaction.d.cts.map +1 -0
- package/dist/partner/redaction.d.ts +124 -0
- package/dist/partner/redaction.d.ts.map +1 -0
- package/dist/partner/redaction.js +257 -0
- package/dist/partner/redaction.js.map +1 -0
- package/dist/raw/index.cjs +81 -19
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +6 -2
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +6 -2
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +81 -19
- package/dist/raw/index.js.map +1 -1
- package/dist/raw/url.cjs +111 -0
- package/dist/raw/url.cjs.map +1 -0
- package/dist/raw/url.d.cts +41 -0
- package/dist/raw/url.d.cts.map +1 -0
- package/dist/raw/url.d.ts +41 -0
- package/dist/raw/url.d.ts.map +1 -0
- package/dist/raw/url.js +110 -0
- package/dist/raw/url.js.map +1 -0
- package/dist/s3/sigv4.cjs +15 -10
- package/dist/s3/sigv4.cjs.map +1 -1
- package/dist/s3/sigv4.js +15 -10
- package/dist/s3/sigv4.js.map +1 -1
- package/dist/simulator/index.cjs +1197 -206
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +109 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +109 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +1196 -209
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/partner.cjs +719 -0
- package/dist/simulator/partner.cjs.map +1 -0
- package/dist/simulator/partner.d.cts +183 -0
- package/dist/simulator/partner.d.cts.map +1 -0
- package/dist/simulator/partner.d.ts +183 -0
- package/dist/simulator/partner.d.ts.map +1 -0
- package/dist/simulator/partner.js +718 -0
- package/dist/simulator/partner.js.map +1 -0
- package/dist/simulator/validation.cjs +577 -0
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +117 -0
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +117 -0
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +563 -1
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/file-source.cjs +1 -1
- package/dist/streams/file-source.cjs.map +1 -1
- package/dist/streams/file-source.js +1 -1
- package/dist/streams/file-source.js.map +1 -1
- package/dist/streams/index.cjs +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/streams/source.cjs +2 -1
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.js +2 -1
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +6 -2
- package/dist/sync/b2-sha1-reader.cjs.map +1 -1
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -1
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -1
- package/dist/sync/b2-sha1-reader.js +6 -2
- package/dist/sync/b2-sha1-reader.js.map +1 -1
- package/dist/sync/download-staging.cjs +11 -10
- package/dist/sync/download-staging.cjs.map +1 -1
- package/dist/sync/download-staging.d.cts +2 -1
- package/dist/sync/download-staging.d.cts.map +1 -1
- package/dist/sync/download-staging.d.ts +2 -1
- package/dist/sync/download-staging.d.ts.map +1 -1
- package/dist/sync/download-staging.js +11 -10
- package/dist/sync/download-staging.js.map +1 -1
- package/dist/sync/filters.cjs.map +1 -1
- package/dist/sync/filters.js.map +1 -1
- package/dist/sync/local-file-io.cjs +11 -6
- package/dist/sync/local-file-io.cjs.map +1 -1
- package/dist/sync/local-file-io.d.cts +1 -0
- package/dist/sync/local-file-io.d.cts.map +1 -1
- package/dist/sync/local-file-io.d.ts +1 -0
- package/dist/sync/local-file-io.d.ts.map +1 -1
- package/dist/sync/local-file-io.js +11 -6
- package/dist/sync/local-file-io.js.map +1 -1
- package/dist/sync/local-sha1.cjs +6 -15
- package/dist/sync/local-sha1.cjs.map +1 -1
- package/dist/sync/local-sha1.d.cts +0 -8
- package/dist/sync/local-sha1.d.cts.map +1 -1
- package/dist/sync/local-sha1.d.ts +0 -8
- package/dist/sync/local-sha1.d.ts.map +1 -1
- package/dist/sync/local-sha1.js +7 -15
- package/dist/sync/local-sha1.js.map +1 -1
- package/dist/sync/policies/compare.cjs +5 -3
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +6 -4
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +4 -10
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.js +4 -10
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/scanners/b2.cjs +2 -2
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.js +2 -2
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/synchronizer.cjs +3 -2
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.js +3 -2
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/types/auth.cjs +4 -0
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +4 -0
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +4 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +4 -0
- package/dist/types/auth.js.map +1 -1
- package/dist/types/backup.d.cts +80 -0
- package/dist/types/backup.d.cts.map +1 -0
- package/dist/types/backup.d.ts +80 -0
- package/dist/types/backup.d.ts.map +1 -0
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.d.cts +4 -2
- package/dist/types/bucket.d.cts.map +1 -1
- package/dist/types/bucket.d.ts +4 -2
- package/dist/types/bucket.d.ts.map +1 -1
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/download.cjs +62 -0
- package/dist/types/download.cjs.map +1 -0
- package/dist/types/download.d.cts +98 -0
- package/dist/types/download.d.cts.map +1 -1
- package/dist/types/download.d.ts +98 -0
- package/dist/types/download.d.ts.map +1 -1
- package/dist/types/download.js +61 -0
- package/dist/types/download.js.map +1 -0
- package/dist/types/encryption.cjs +58 -229
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +32 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +32 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +56 -229
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +9 -0
- package/dist/types/errors.cjs.map +1 -1
- package/dist/types/errors.d.cts +1 -1
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +9 -0
- package/dist/types/errors.js.map +1 -1
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +15 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +15 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +30 -0
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.d.cts +32 -0
- package/dist/types/ids.d.cts.map +1 -1
- package/dist/types/ids.d.ts +32 -0
- package/dist/types/ids.d.ts.map +1 -1
- package/dist/types/ids.js +28 -1
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +10 -6
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +10 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.d.cts +14 -0
- package/dist/types/lock.d.cts.map +1 -1
- package/dist/types/lock.d.ts +14 -0
- package/dist/types/lock.d.ts.map +1 -1
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +1 -1
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.d.cts +5 -3
- package/dist/types/notifications.d.cts.map +1 -1
- package/dist/types/notifications.d.ts +5 -3
- package/dist/types/notifications.d.ts.map +1 -1
- package/dist/types/notifications.js +1 -1
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/partner.cjs +32 -0
- package/dist/types/partner.cjs.map +1 -0
- package/dist/types/partner.d.cts +394 -0
- package/dist/types/partner.d.cts.map +1 -0
- package/dist/types/partner.d.ts +394 -0
- package/dist/types/partner.d.ts.map +1 -0
- package/dist/types/partner.js +29 -0
- package/dist/types/partner.js.map +1 -0
- package/dist/types/upload.d.cts +31 -18
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +31 -18
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +0 -45
- package/dist/upload/abort-scope.cjs.map +1 -1
- package/dist/upload/abort-scope.d.cts +0 -22
- package/dist/upload/abort-scope.d.cts.map +1 -1
- package/dist/upload/abort-scope.d.ts +0 -22
- package/dist/upload/abort-scope.d.ts.map +1 -1
- package/dist/upload/abort-scope.js +1 -44
- package/dist/upload/abort-scope.js.map +1 -1
- package/dist/upload/finish.cjs +3 -8
- package/dist/upload/finish.cjs.map +1 -1
- package/dist/upload/finish.d.cts.map +1 -1
- package/dist/upload/finish.d.ts.map +1 -1
- package/dist/upload/finish.js +1 -6
- package/dist/upload/finish.js.map +1 -1
- package/dist/upload/large.cjs +5 -1
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +16 -2
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +16 -2
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +5 -1
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs.map +1 -1
- package/dist/upload/options.d.cts +12 -0
- package/dist/upload/options.d.cts.map +1 -1
- package/dist/upload/options.d.ts +12 -0
- package/dist/upload/options.d.ts.map +1 -1
- package/dist/upload/options.js.map +1 -1
- package/dist/upload/resume.cjs +2 -1
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +3 -1
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +3 -1
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +2 -1
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +8 -3
- package/dist/upload/retry.cjs.map +1 -1
- package/dist/upload/retry.js +8 -3
- package/dist/upload/retry.js.map +1 -1
- package/dist/upload/single.cjs +2 -1
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +6 -0
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +6 -0
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +2 -1
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +6 -4
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +6 -0
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +6 -0
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +3 -1
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/abort.cjs +114 -0
- package/dist/util/abort.cjs.map +1 -0
- package/dist/util/abort.d.cts +65 -0
- package/dist/util/abort.d.cts.map +1 -0
- package/dist/util/abort.d.ts +65 -0
- package/dist/util/abort.d.ts.map +1 -0
- package/dist/util/abort.js +109 -0
- package/dist/util/abort.js.map +1 -0
- package/dist/util/defaults.cjs +3 -0
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.d.cts +2 -0
- package/dist/util/defaults.d.cts.map +1 -1
- package/dist/util/defaults.d.ts +2 -0
- package/dist/util/defaults.d.ts.map +1 -1
- package/dist/util/defaults.js +3 -1
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/md5.cjs +211 -0
- package/dist/util/md5.cjs.map +1 -0
- package/dist/util/md5.d.cts +43 -0
- package/dist/util/md5.d.cts.map +1 -0
- package/dist/util/md5.d.ts +43 -0
- package/dist/util/md5.d.ts.map +1 -0
- package/dist/util/md5.js +209 -0
- package/dist/util/md5.js.map +1 -0
- package/dist/util/normalize.cjs +5 -5
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.d.cts +7 -7
- package/dist/util/normalize.d.cts.map +1 -1
- package/dist/util/normalize.d.ts +7 -7
- package/dist/util/normalize.d.ts.map +1 -1
- package/dist/util/normalize.js +5 -5
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +7 -1
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.d.cts +3 -1
- package/dist/util/paginator.d.cts.map +1 -1
- package/dist/util/paginator.d.ts +3 -1
- package/dist/util/paginator.d.ts.map +1 -1
- package/dist/util/paginator.js +7 -1
- package/dist/util/paginator.js.map +1 -1
- package/package.json +38 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/util/normalize.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACzF,EAAE,EAAE,CAAC,GACJ,CAAC,CAEH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAClD,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,EAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,CAEZ"}
|
package/dist/util/normalize.js
CHANGED
|
@@ -36,7 +36,7 @@ function normalizeSha1(raw) {
|
|
|
36
36
|
* substitution was needed, so callers paying for change detection
|
|
37
37
|
* (e.g. React memo) see referential stability.
|
|
38
38
|
*
|
|
39
|
-
* @typeParam T - Any object with a `contentSha1
|
|
39
|
+
* @typeParam T - Any object with a `contentSha1?: string | null` field.
|
|
40
40
|
*
|
|
41
41
|
* @param fv - The wire-shape file-version object.
|
|
42
42
|
*
|
|
@@ -50,11 +50,11 @@ function normalizeFileVersionSha1(fv) {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Returns a new list-response object with `normalizeFileVersionSha1`
|
|
53
|
-
* applied to every entry in `files`. Used at
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* applied to every entry in `files`. Used at file-version and unfinished
|
|
54
|
+
* large-file list boundaries so list output shares the same SHA-1 semantics
|
|
55
|
+
* as the singular endpoints.
|
|
56
56
|
*
|
|
57
|
-
* @typeParam F - Any object with a `contentSha1
|
|
57
|
+
* @typeParam F - Any object with a `contentSha1?: string | null` field.
|
|
58
58
|
* @typeParam R - The list-response shape (must have a `files` array of `F`).
|
|
59
59
|
*
|
|
60
60
|
* @param resp - The wire-shape list response.
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 file-version and unfinished\n * large-file list boundaries so list output shares the same SHA-1 semantics\n * 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,7 +1,12 @@
|
|
|
1
1
|
//#region src/util/paginator.ts
|
|
2
|
+
function isPrimitiveCursor(cursor) {
|
|
3
|
+
return cursor === null || typeof cursor !== "object" && typeof cursor !== "function";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
4
|
-
* `nextCursor: undefined
|
|
7
|
+
* `nextCursor: undefined` or a primitive cursor that is identical to the
|
|
8
|
+
* cursor just used, which prevents non-advancing server cursors from looping
|
|
9
|
+
* forever.
|
|
5
10
|
*
|
|
6
11
|
* @typeParam Page - The per-page response shape.
|
|
7
12
|
* @typeParam Cursor - The cursor type used to request the next page.
|
|
@@ -33,6 +38,7 @@ async function* paginatePages(fetcher, signal) {
|
|
|
33
38
|
const { page, nextCursor } = await fetcher(cursor);
|
|
34
39
|
yield page;
|
|
35
40
|
if (nextCursor === void 0) return;
|
|
41
|
+
if (cursor !== void 0 && isPrimitiveCursor(cursor) && isPrimitiveCursor(nextCursor) && Object.is(nextCursor, cursor)) return;
|
|
36
42
|
cursor = nextCursor;
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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\nfunction isPrimitiveCursor(cursor: unknown): boolean {\n return cursor === null || (typeof cursor !== 'object' && typeof cursor !== 'function')\n}\n\n/**\n * Async-iterates one page at a time. Stops when `fetcher` returns\n * `nextCursor: undefined` or a primitive cursor that is identical to the\n * cursor just used, which prevents non-advancing server cursors from looping\n * forever.\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 if (\n cursor !== undefined &&\n isPrimitiveCursor(cursor) &&\n isPrimitiveCursor(nextCursor) &&\n Object.is(nextCursor, cursor)\n ) {\n return\n }\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":";AAsEA,SAAS,kBAAkB,QAA0B;CACnD,OAAO,WAAW,QAAS,OAAO,WAAW,YAAY,OAAO,WAAW;AAC7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,IACE,WAAW,KAAA,KACX,kBAAkB,MAAM,KACxB,kBAAkB,UAAU,KAC5B,OAAO,GAAG,YAAY,MAAM,GAE5B;EAEF,SAAS;CACX;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,gBAAuB,cACrB,SACA,cACA,QAC6B;CAC7B,WAAW,MAAM,QAAQ,cAAc,SAAS,MAAM,GACpD,OAAO,aAAa,IAAI;AAE5B"}
|
|
@@ -67,7 +67,9 @@ export type PageFetcher<Page, Cursor> = (cursor: Cursor | undefined) => Promise<
|
|
|
67
67
|
}>;
|
|
68
68
|
/**
|
|
69
69
|
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
70
|
-
* `nextCursor: undefined
|
|
70
|
+
* `nextCursor: undefined` or a primitive cursor that is identical to the
|
|
71
|
+
* cursor just used, which prevents non-advancing server cursors from looping
|
|
72
|
+
* forever.
|
|
71
73
|
*
|
|
72
74
|
* @typeParam Page - The per-page response shape.
|
|
73
75
|
* @typeParam Cursor - The cursor type used to request the next page.
|
|
@@ -1 +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;
|
|
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;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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,CAiB7B;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"}
|
package/dist/util/paginator.d.ts
CHANGED
|
@@ -67,7 +67,9 @@ export type PageFetcher<Page, Cursor> = (cursor: Cursor | undefined) => Promise<
|
|
|
67
67
|
}>;
|
|
68
68
|
/**
|
|
69
69
|
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
70
|
-
* `nextCursor: undefined
|
|
70
|
+
* `nextCursor: undefined` or a primitive cursor that is identical to the
|
|
71
|
+
* cursor just used, which prevents non-advancing server cursors from looping
|
|
72
|
+
* forever.
|
|
71
73
|
*
|
|
72
74
|
* @typeParam Page - The per-page response shape.
|
|
73
75
|
* @typeParam Cursor - The cursor type used to request the next page.
|
|
@@ -1 +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;
|
|
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;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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,CAiB7B;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"}
|
package/dist/util/paginator.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
//#region src/util/paginator.ts
|
|
2
|
+
function isPrimitiveCursor(cursor) {
|
|
3
|
+
return cursor === null || typeof cursor !== "object" && typeof cursor !== "function";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Async-iterates one page at a time. Stops when `fetcher` returns
|
|
4
|
-
* `nextCursor: undefined
|
|
7
|
+
* `nextCursor: undefined` or a primitive cursor that is identical to the
|
|
8
|
+
* cursor just used, which prevents non-advancing server cursors from looping
|
|
9
|
+
* forever.
|
|
5
10
|
*
|
|
6
11
|
* @typeParam Page - The per-page response shape.
|
|
7
12
|
* @typeParam Cursor - The cursor type used to request the next page.
|
|
@@ -33,6 +38,7 @@ async function* paginatePages(fetcher, signal) {
|
|
|
33
38
|
const { page, nextCursor } = await fetcher(cursor);
|
|
34
39
|
yield page;
|
|
35
40
|
if (nextCursor === void 0) return;
|
|
41
|
+
if (cursor !== void 0 && isPrimitiveCursor(cursor) && isPrimitiveCursor(nextCursor) && Object.is(nextCursor, cursor)) return;
|
|
36
42
|
cursor = nextCursor;
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginator.js","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
|
|
1
|
+
{"version":3,"file":"paginator.js","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\nfunction isPrimitiveCursor(cursor: unknown): boolean {\n return cursor === null || (typeof cursor !== 'object' && typeof cursor !== 'function')\n}\n\n/**\n * Async-iterates one page at a time. Stops when `fetcher` returns\n * `nextCursor: undefined` or a primitive cursor that is identical to the\n * cursor just used, which prevents non-advancing server cursors from looping\n * forever.\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 if (\n cursor !== undefined &&\n isPrimitiveCursor(cursor) &&\n isPrimitiveCursor(nextCursor) &&\n Object.is(nextCursor, cursor)\n ) {\n return\n }\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":";AAsEA,SAAS,kBAAkB,QAA0B;CACnD,OAAO,WAAW,QAAS,OAAO,WAAW,YAAY,OAAO,WAAW;AAC7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,IACE,WAAW,KAAA,KACX,kBAAkB,MAAM,KACxB,kBAAkB,UAAU,KAC5B,OAAO,GAAG,YAAY,MAAM,GAE5B;EAEF,SAAS;CACX;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,gBAAuB,cACrB,SACA,cACA,QAC6B;CAC7B,WAAW,MAAM,QAAQ,cAAc,SAAS,MAAM,GACpD,OAAO,aAAa,IAAI;AAE5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backblaze-labs/b2-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The official Backblaze B2 Cloud Storage SDK for TypeScript and JavaScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -59,6 +59,26 @@
|
|
|
59
59
|
"default": "./dist/auth/file.cjs"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
+
"./partner": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./dist/partner/index.d.ts",
|
|
65
|
+
"default": "./dist/partner/index.js"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./dist/partner/index.d.cts",
|
|
69
|
+
"default": "./dist/partner/index.cjs"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"./backup": {
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./dist/backup/index.d.ts",
|
|
75
|
+
"default": "./dist/backup/index.js"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./dist/backup/index.d.cts",
|
|
79
|
+
"default": "./dist/backup/index.cjs"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
62
82
|
"./streams": {
|
|
63
83
|
"import": {
|
|
64
84
|
"types": "./dist/streams/index.d.ts",
|
|
@@ -120,24 +140,24 @@
|
|
|
120
140
|
"CHANGELOG.md"
|
|
121
141
|
],
|
|
122
142
|
"devDependencies": {
|
|
123
|
-
"@biomejs/biome": "^2.5.
|
|
143
|
+
"@biomejs/biome": "^2.5.8",
|
|
124
144
|
"@eslint/js": "^10.0.1",
|
|
125
145
|
"@microsoft/tsdoc-config": "^0.18.1",
|
|
126
|
-
"@types/node": "^26.
|
|
127
|
-
"@vitest/browser": "^4.1.
|
|
128
|
-
"@vitest/browser-playwright": "^4.1.
|
|
129
|
-
"@vitest/coverage-v8": "^4.1.
|
|
146
|
+
"@types/node": "^26.2.0",
|
|
147
|
+
"@vitest/browser": "^4.1.10",
|
|
148
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
149
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
130
150
|
"cspell": "^10.0.1",
|
|
131
|
-
"eslint": "^10.
|
|
132
|
-
"eslint-plugin-jsdoc": "^
|
|
151
|
+
"eslint": "^10.8.1",
|
|
152
|
+
"eslint-plugin-jsdoc": "^64.2.0",
|
|
133
153
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
134
|
-
"playwright": "^1.
|
|
135
|
-
"typedoc": "^0.28.
|
|
154
|
+
"playwright": "^1.62.1",
|
|
155
|
+
"typedoc": "^0.28.20",
|
|
136
156
|
"typescript": "^6.0.3",
|
|
137
|
-
"typescript-eslint": "^8.
|
|
138
|
-
"vite": "^8.1
|
|
157
|
+
"typescript-eslint": "^8.67.0",
|
|
158
|
+
"vite": "^8.2.1",
|
|
139
159
|
"vite-plugin-dts": "^5.0.3",
|
|
140
|
-
"vitest": "^4.1.
|
|
160
|
+
"vitest": "^4.1.10"
|
|
141
161
|
},
|
|
142
162
|
"peerDependencies": {
|
|
143
163
|
"@aws-sdk/client-s3": "^3.0.0"
|
|
@@ -161,7 +181,7 @@
|
|
|
161
181
|
],
|
|
162
182
|
"repository": {
|
|
163
183
|
"type": "git",
|
|
164
|
-
"url": "https://github.com/backblaze-labs/b2-sdk-typescript"
|
|
184
|
+
"url": "git+https://github.com/backblaze-labs/b2-sdk-typescript.git"
|
|
165
185
|
},
|
|
166
186
|
"author": "Backblaze, Inc.",
|
|
167
187
|
"homepage": "https://github.com/backblaze-labs/b2-sdk-typescript#readme",
|
|
@@ -185,17 +205,19 @@
|
|
|
185
205
|
"lint:fix": "biome check --write .",
|
|
186
206
|
"lint:docs": "eslint src/ --no-warn-ignored",
|
|
187
207
|
"lint:docs:fix": "eslint src/ --fix --no-warn-ignored",
|
|
188
|
-
"lint:spelling": "cspell --no-progress --gitignore \"src/**/*.ts\" \"examples/**/*.ts\" \"examples/**/*.md\" \"*.md\" \"CLAUDE.md\"",
|
|
208
|
+
"lint:spelling": "cspell --no-progress --gitignore \"src/**/*.ts\" \"examples/**/*.ts\" \"examples/**/*.md\" \"adr/**/*.md\" \"*.md\" \"CLAUDE.md\"",
|
|
189
209
|
"typecheck": "tsc --noEmit",
|
|
190
210
|
"typecheck:examples": "tsc --noEmit -p examples/tsconfig.json",
|
|
191
211
|
"docs": "typedoc",
|
|
192
212
|
"docs:watch": "typedoc --watch",
|
|
193
213
|
"clean": "rm -rf dist docs",
|
|
194
214
|
"version": "node scripts/cut-changelog.mjs && git add CHANGELOG.md",
|
|
195
|
-
"verify:metadata": "node scripts/verify-package-metadata.mjs",
|
|
215
|
+
"verify:metadata": "node --test scripts/verify-package-metadata.test.mjs && node scripts/verify-package-metadata.mjs",
|
|
196
216
|
"verify:release": "node scripts/verify-release-workflow.mjs",
|
|
197
217
|
"verify:exports": "node scripts/verify-package-exports.mjs",
|
|
198
218
|
"verify:release-workflow": "node scripts/verify-release-workflow.mjs",
|
|
219
|
+
"smoke:published": "node scripts/smoke-published-package.mjs",
|
|
220
|
+
"test:smoke-published": "node --test scripts/smoke-published-package.test.mjs",
|
|
199
221
|
"verify": "pnpm run lint && pnpm run lint:docs && pnpm run lint:spelling && pnpm run typecheck && pnpm run typecheck:examples && pnpm run test && pnpm run build && pnpm run docs && pnpm run verify:metadata && pnpm run verify:release && pnpm run verify:exports"
|
|
200
222
|
}
|
|
201
223
|
}
|