@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
package/dist/object.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Bucket } from './bucket.js';
|
|
2
2
|
import { B2Client } from './client.js';
|
|
3
3
|
import { DownloadResult, HeadResult } from './download/single.js';
|
|
4
|
+
import { RetryOptions } from './http/retry.js';
|
|
4
5
|
import { SseCDownloadKey } from './raw/index.js';
|
|
5
6
|
import { ProgressListener } from './streams/progress.js';
|
|
6
|
-
import { ContentSource } from './streams/source.js';
|
|
7
|
-
import { EncryptionSetting } from './types/encryption.js';
|
|
8
7
|
import { FileVersion } from './types/file.js';
|
|
9
|
-
import { FileId
|
|
8
|
+
import { FileId } from './types/ids.js';
|
|
10
9
|
import { FileRetentionValue, LegalHoldValue } from './types/lock.js';
|
|
10
|
+
import { B2ObjectUploadOptions, B2ObjectWriteStreamOptions } from './upload/options.js';
|
|
11
11
|
import { UploadWriteHandle } from './upload/stream.js';
|
|
12
12
|
/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */
|
|
13
13
|
export interface DownloadCallOptions {
|
|
@@ -72,55 +72,24 @@ export declare class B2Object {
|
|
|
72
72
|
readonly fileName: string;
|
|
73
73
|
private readonly client;
|
|
74
74
|
private readonly bucket;
|
|
75
|
+
private readonly uploadRetryOptions;
|
|
75
76
|
/**
|
|
76
77
|
* @param client - The parent B2Client instance.
|
|
77
78
|
* @param bucket - The parent Bucket this object belongs to.
|
|
78
79
|
* @param fileName - The file path within the bucket.
|
|
80
|
+
* @param uploadRetryOptions - Resolved client upload retry defaults.
|
|
79
81
|
*
|
|
80
82
|
* @internal
|
|
81
83
|
*/
|
|
82
|
-
constructor(client: B2Client, bucket: Bucket, fileName: string);
|
|
84
|
+
constructor(client: B2Client, bucket: Bucket, fileName: string, uploadRetryOptions: RetryOptions);
|
|
83
85
|
/**
|
|
84
86
|
* Uploads data to this file name. Automatically uses multipart upload for large files.
|
|
85
87
|
* @param options - Upload configuration including data source and optional settings.
|
|
86
88
|
*
|
|
87
89
|
* @returns Metadata for the uploaded file version.
|
|
88
90
|
*/
|
|
89
|
-
upload(options:
|
|
90
|
-
|
|
91
|
-
source: ContentSource;
|
|
92
|
-
/** MIME type. Defaults to auto-detection by B2. */
|
|
93
|
-
contentType?: string;
|
|
94
|
-
/** Custom key-value metadata stored with the file. */
|
|
95
|
-
fileInfo?: Record<string, string>;
|
|
96
|
-
/** Server-side encryption settings. */
|
|
97
|
-
serverSideEncryption?: EncryptionSetting;
|
|
98
|
-
/** File retention policy (requires file lock). */
|
|
99
|
-
fileRetention?: FileRetentionValue;
|
|
100
|
-
/** Legal hold status. */
|
|
101
|
-
legalHold?: LegalHoldValue;
|
|
102
|
-
/** Last-modified timestamp in milliseconds since epoch. */
|
|
103
|
-
lastModifiedMillis?: number;
|
|
104
|
-
/** Part size override for multipart uploads, in bytes. */
|
|
105
|
-
partSize?: number;
|
|
106
|
-
/** Number of concurrent part uploads for large files. */
|
|
107
|
-
concurrency?: number;
|
|
108
|
-
/** Callback invoked with upload progress events. */
|
|
109
|
-
onProgress?: ProgressListener;
|
|
110
|
-
/** Abort signal for cancelling the upload. */
|
|
111
|
-
signal?: AbortSignal;
|
|
112
|
-
/**
|
|
113
|
-
* Resume an unfinished multipart upload for this file name when one
|
|
114
|
-
* exists. Only meaningful on the large-file path. Ignored on the
|
|
115
|
-
* small-file path.
|
|
116
|
-
*/
|
|
117
|
-
resume?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Resume into a specific large-file ID, bypassing discovery.
|
|
120
|
-
* Overrides the `resume` discovery path.
|
|
121
|
-
*/
|
|
122
|
-
resumeFileId?: LargeFileId;
|
|
123
|
-
}): Promise<FileVersion>;
|
|
91
|
+
upload(options: B2ObjectUploadOptions): Promise<FileVersion>;
|
|
92
|
+
private fetchFreshBucketInfo;
|
|
124
93
|
/**
|
|
125
94
|
* Downloads this file by name. Pass `method: 'HEAD'` to fetch only the
|
|
126
95
|
* response headers (file metadata) without streaming the body.
|
|
@@ -191,22 +160,7 @@ export declare class B2Object {
|
|
|
191
160
|
*
|
|
192
161
|
* @returns A handle with the writable sink and a completion promise.
|
|
193
162
|
*/
|
|
194
|
-
createWriteStream(options?:
|
|
195
|
-
/** MIME type. Defaults to `b2/x-auto`. */
|
|
196
|
-
contentType?: string;
|
|
197
|
-
/** Custom key-value metadata stored with the file. */
|
|
198
|
-
fileInfo?: Record<string, string>;
|
|
199
|
-
/** Server-side encryption applied to each part. */
|
|
200
|
-
serverSideEncryption?: EncryptionSetting;
|
|
201
|
-
/** Target part size in bytes. Defaults to the account's recommended part size. */
|
|
202
|
-
partSize?: number;
|
|
203
|
-
/** Maximum number of parts uploaded in parallel. Defaults to 4. */
|
|
204
|
-
concurrency?: number;
|
|
205
|
-
/** Callback invoked with upload progress events. */
|
|
206
|
-
onProgress?: ProgressListener;
|
|
207
|
-
/** Abort signal that cancels the upload and the unfinished large file. */
|
|
208
|
-
signal?: AbortSignal;
|
|
209
|
-
}): UploadWriteHandle;
|
|
163
|
+
createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle;
|
|
210
164
|
/**
|
|
211
165
|
* Retrieves metadata for a specific file version.
|
|
212
166
|
* @param fileId - The file version ID to look up.
|
package/dist/object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEzE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAGhC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAsB9E,uFAAuF;AACvF,MAAM,WAAW,mB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AE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE;IAK1C;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc;CAG7D"}
|
package/dist/object.js
CHANGED
|
@@ -1,212 +1,255 @@
|
|
|
1
|
+
import { downloadById, downloadByName, headById, headByName } from "./download/single.js";
|
|
2
|
+
import { mergeUploadRetryOptions } from "./internal/upload-retry-options.js";
|
|
1
3
|
import { createParallelDownloadStream } from "./download/parallel.js";
|
|
2
|
-
import { downloadByName, headByName, downloadById, headById } from "./download/single.js";
|
|
3
4
|
import { uploadLargeFile } from "./upload/large.js";
|
|
5
|
+
import { rejectSmallResumeFileId, stripResumeOnlyOptions } from "./upload/options.js";
|
|
4
6
|
import { uploadSmallFile } from "./upload/single.js";
|
|
5
7
|
import { createWriteStream } from "./upload/stream.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
constructor(client, bucket, fileName) {
|
|
19
|
-
this.client = client;
|
|
20
|
-
this.bucket = bucket;
|
|
21
|
-
this.fileName = fileName;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Uploads data to this file name. Automatically uses multipart upload for large files.
|
|
25
|
-
* @param options - Upload configuration including data source and optional settings.
|
|
26
|
-
*
|
|
27
|
-
* @returns Metadata for the uploaded file version.
|
|
28
|
-
*/
|
|
29
|
-
async upload(options) {
|
|
30
|
-
const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize();
|
|
31
|
-
const isLarge = options.source.size > recommendedPartSize;
|
|
32
|
-
if (isLarge) {
|
|
33
|
-
return uploadLargeFile(this.client.raw, this.client.accountInfo, {
|
|
34
|
-
bucketId: this.bucket.id,
|
|
35
|
-
fileName: this.fileName,
|
|
36
|
-
...options
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const { resume: _resume, resumeFileId: _resumeFileId, ...smallOptions } = options;
|
|
40
|
-
return uploadSmallFile(this.client.raw, this.client.accountInfo, {
|
|
41
|
-
bucketId: this.bucket.id,
|
|
42
|
-
fileName: this.fileName,
|
|
43
|
-
...smallOptions
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Downloads this file by name. Pass `method: 'HEAD'` to fetch only the
|
|
48
|
-
* response headers (file metadata) without streaming the body.
|
|
49
|
-
* @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.
|
|
50
|
-
*
|
|
51
|
-
* @returns The download result with response headers and body stream.
|
|
52
|
-
*/
|
|
53
|
-
async download(options) {
|
|
54
|
-
return downloadByName(this.client.raw, this.client.accountInfo, {
|
|
55
|
-
bucketName: this.bucket.name,
|
|
56
|
-
fileName: this.fileName,
|
|
57
|
-
...options
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Fetches response headers for this file via HTTP HEAD. Returns a
|
|
62
|
-
* body-less result so callers never have to drain the (logically
|
|
63
|
-
* empty) HEAD body themselves.
|
|
64
|
-
*
|
|
65
|
-
* @param options - Optional range, SSE-C decryption, response-header
|
|
66
|
-
* overrides, and abort signal. Same shape as {@link B2Object.download}'s
|
|
67
|
-
* options minus `method` (always HEAD) and `onProgress` (no body).
|
|
68
|
-
*
|
|
69
|
-
* @returns Parsed download headers (content type, SHA-1, file info, etc.).
|
|
70
|
-
*/
|
|
71
|
-
async head(options) {
|
|
72
|
-
return headByName(this.client.raw, this.client.accountInfo, {
|
|
73
|
-
bucketName: this.bucket.name,
|
|
74
|
-
fileName: this.fileName,
|
|
75
|
-
...options
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Downloads a specific version of this file by ID. Pass `method: 'HEAD'`
|
|
80
|
-
* to fetch only the response headers (file metadata) without streaming the body.
|
|
81
|
-
* @param fileId - The file version ID to download.
|
|
82
|
-
* @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.
|
|
83
|
-
*
|
|
84
|
-
* @returns The download result with response headers and body stream.
|
|
85
|
-
*/
|
|
86
|
-
async downloadById(fileId, options) {
|
|
87
|
-
return downloadById(this.client.raw, this.client.accountInfo, {
|
|
88
|
-
fileId,
|
|
89
|
-
...options
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Fetches response headers for a specific version of this file by ID
|
|
94
|
-
* via HTTP HEAD. Returns a body-less result so callers never have to
|
|
95
|
-
* drain the (logically empty) HEAD body themselves.
|
|
96
|
-
*
|
|
97
|
-
* @param fileId - The file version ID to inspect.
|
|
98
|
-
* @param options - Optional range, SSE-C decryption, response-header
|
|
99
|
-
* overrides, and abort signal.
|
|
100
|
-
*
|
|
101
|
-
* @returns Parsed download headers.
|
|
102
|
-
*/
|
|
103
|
-
async headById(fileId, options) {
|
|
104
|
-
return headById(this.client.raw, this.client.accountInfo, {
|
|
105
|
-
fileId,
|
|
106
|
-
...options
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
|
|
111
|
-
* @param fileId - The file version ID to download.
|
|
112
|
-
* @param totalSize - Total file size in bytes (needed to compute range boundaries).
|
|
113
|
-
* @param options - Concurrency, range size, and abort signal.
|
|
114
|
-
*
|
|
115
|
-
* @returns A Web ReadableStream of file data in sequential order.
|
|
116
|
-
*/
|
|
117
|
-
createReadStream(fileId, totalSize, options) {
|
|
118
|
-
return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {
|
|
119
|
-
fileId,
|
|
120
|
-
totalSize,
|
|
121
|
-
...options
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Creates a Web `WritableStream` that uploads streamed data into this file
|
|
126
|
-
* using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the
|
|
127
|
-
* returned `writable` and await `done` to get the final {@link FileVersion}.
|
|
128
|
-
*
|
|
129
|
-
* Note: streaming uploads do not support resume because the size and per-part
|
|
130
|
-
* hashes are not known in advance. Use {@link upload} with a buffered source
|
|
131
|
-
* when resume is required.
|
|
132
|
-
*
|
|
133
|
-
* @param options - Streaming upload parameters (part size, concurrency, encryption).
|
|
134
|
-
*
|
|
135
|
-
* @returns A handle with the writable sink and a completion promise.
|
|
136
|
-
*/
|
|
137
|
-
createWriteStream(options) {
|
|
138
|
-
return createWriteStream(this.client.raw, this.client.accountInfo, {
|
|
139
|
-
bucketId: this.bucket.id,
|
|
140
|
-
fileName: this.fileName,
|
|
141
|
-
...options ?? {}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Retrieves metadata for a specific file version.
|
|
146
|
-
* @param fileId - The file version ID to look up.
|
|
147
|
-
*
|
|
148
|
-
* @returns The file version metadata.
|
|
149
|
-
*/
|
|
150
|
-
async getFileInfo(fileId) {
|
|
151
|
-
return this.client.raw.getFileInfo(
|
|
152
|
-
this.client.accountInfo.getApiUrl(),
|
|
153
|
-
this.client.accountInfo.getAuthToken(),
|
|
154
|
-
{ fileId }
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Hides this file by creating a hide marker at this file name.
|
|
159
|
-
*
|
|
160
|
-
* @returns Metadata for the newly created hide marker.
|
|
161
|
-
*/
|
|
162
|
-
async hide() {
|
|
163
|
-
return this.bucket.hideFile(this.fileName);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Permanently deletes a specific version of this file.
|
|
167
|
-
* @param fileId - The unique identifier of the file version to delete.
|
|
168
|
-
*/
|
|
169
|
-
async deleteVersion(fileId) {
|
|
170
|
-
await this.bucket.deleteFileVersion(this.fileName, fileId);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Sets or updates the Object Lock retention policy on a specific file
|
|
174
|
-
* version of this file.
|
|
175
|
-
*
|
|
176
|
-
* The bucket must have Object Lock enabled (`fileLockEnabled: true` at
|
|
177
|
-
* creation time). Governance-mode retention can be shortened or removed
|
|
178
|
-
* by passing `bypassGovernance: true` together with an application key
|
|
179
|
-
* that carries the `bypassGovernance` capability; compliance-mode
|
|
180
|
-
* retention cannot be shortened by anyone until the
|
|
181
|
-
* `retainUntilTimestamp` elapses.
|
|
182
|
-
*
|
|
183
|
-
* @param fileId - The file version to apply the policy to.
|
|
184
|
-
* @param retention - The retention policy to apply.
|
|
185
|
-
* @param options - Optional flag for shortening governance-mode retention.
|
|
186
|
-
*
|
|
187
|
-
* @returns Metadata for the updated file version.
|
|
188
|
-
*/
|
|
189
|
-
async setRetention(fileId, retention, options) {
|
|
190
|
-
return this.bucket.updateFileRetention(this.fileName, fileId, retention, options);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Toggles the legal hold flag on a specific file version of this file.
|
|
194
|
-
*
|
|
195
|
-
* Legal hold is independent of retention: a file can be on legal hold
|
|
196
|
-
* without any retention policy, and vice versa. The bucket must have
|
|
197
|
-
* Object Lock enabled, and any caller must hold the `writeFileLegalHolds`
|
|
198
|
-
* capability.
|
|
199
|
-
*
|
|
200
|
-
* @param fileId - The file version to apply the flag to.
|
|
201
|
-
* @param legalHold - `'on'` to apply the hold, `'off'` to remove it.
|
|
202
|
-
*
|
|
203
|
-
* @returns Metadata for the updated file version.
|
|
204
|
-
*/
|
|
205
|
-
async setLegalHold(fileId, legalHold) {
|
|
206
|
-
return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold);
|
|
207
|
-
}
|
|
8
|
+
//#region src/object.ts
|
|
9
|
+
function bucketDefaultRetentionSnapshot(info) {
|
|
10
|
+
const fileLock = info.fileLockConfiguration;
|
|
11
|
+
if (!fileLock.isClientAuthorizedToRead) return { unreadable: true };
|
|
12
|
+
if (fileLock.value === null) return { unreadable: false };
|
|
13
|
+
return {
|
|
14
|
+
retention: fileLock.value.defaultRetention,
|
|
15
|
+
unreadable: false
|
|
16
|
+
};
|
|
208
17
|
}
|
|
209
|
-
|
|
210
|
-
|
|
18
|
+
function resumeNeedsFreshBucketDefaults(options) {
|
|
19
|
+
return (options.resume === true || options.resumeFileId !== void 0) && (options.serverSideEncryption === void 0 || options.fileRetention === void 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Handle to a specific file (by name) within a B2 bucket.
|
|
23
|
+
*
|
|
24
|
+
* Provides file-scoped upload, download, and management operations.
|
|
25
|
+
* Obtained via {@link Bucket.file}.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const obj = bucket.file('photos/2026/sunset.jpg')
|
|
30
|
+
* await obj.upload({ source: new BufferSource(data) })
|
|
31
|
+
* const result = await obj.download()
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
var B2Object = class {
|
|
35
|
+
/** The file name (path) within the bucket. */
|
|
36
|
+
fileName;
|
|
37
|
+
client;
|
|
38
|
+
bucket;
|
|
39
|
+
uploadRetryOptions;
|
|
40
|
+
/**
|
|
41
|
+
* @param client - The parent B2Client instance.
|
|
42
|
+
* @param bucket - The parent Bucket this object belongs to.
|
|
43
|
+
* @param fileName - The file path within the bucket.
|
|
44
|
+
* @param uploadRetryOptions - Resolved client upload retry defaults.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
constructor(client, bucket, fileName, uploadRetryOptions) {
|
|
49
|
+
this.client = client;
|
|
50
|
+
this.bucket = bucket;
|
|
51
|
+
this.fileName = fileName;
|
|
52
|
+
this.uploadRetryOptions = uploadRetryOptions;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Uploads data to this file name. Automatically uses multipart upload for large files.
|
|
56
|
+
* @param options - Upload configuration including data source and optional settings.
|
|
57
|
+
*
|
|
58
|
+
* @returns Metadata for the uploaded file version.
|
|
59
|
+
*/
|
|
60
|
+
async upload(options) {
|
|
61
|
+
const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize();
|
|
62
|
+
const isLarge = options.source.size > recommendedPartSize;
|
|
63
|
+
const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry);
|
|
64
|
+
if (isLarge) {
|
|
65
|
+
const bucketInfo = resumeNeedsFreshBucketDefaults(options) ? await this.fetchFreshBucketInfo() : this.bucket.info;
|
|
66
|
+
const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo);
|
|
67
|
+
return uploadLargeFile(this.client.raw, this.client.accountInfo, {
|
|
68
|
+
...options,
|
|
69
|
+
bucketId: this.bucket.id,
|
|
70
|
+
fileName: this.fileName,
|
|
71
|
+
retry: uploadRetryOptions,
|
|
72
|
+
bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,
|
|
73
|
+
...bucketDefaultRetention.retention !== void 0 ? { bucketDefaultRetention: bucketDefaultRetention.retention } : {},
|
|
74
|
+
...bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
rejectSmallResumeFileId(options, "B2Object.upload");
|
|
78
|
+
const smallOptions = stripResumeOnlyOptions(options);
|
|
79
|
+
return uploadSmallFile(this.client.raw, this.client.accountInfo, {
|
|
80
|
+
...smallOptions,
|
|
81
|
+
bucketId: this.bucket.id,
|
|
82
|
+
fileName: this.fileName,
|
|
83
|
+
retry: uploadRetryOptions
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async fetchFreshBucketInfo() {
|
|
87
|
+
const found = (await this.client.listBuckets({ bucketId: this.bucket.id }))[0];
|
|
88
|
+
if (!found) throw new Error(`Bucket ${this.bucket.id} not found`);
|
|
89
|
+
return found.info;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Downloads this file by name. Pass `method: 'HEAD'` to fetch only the
|
|
93
|
+
* response headers (file metadata) without streaming the body.
|
|
94
|
+
* @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.
|
|
95
|
+
*
|
|
96
|
+
* @returns The download result with response headers and body stream.
|
|
97
|
+
*/
|
|
98
|
+
async download(options) {
|
|
99
|
+
return downloadByName(this.client.raw, this.client.accountInfo, {
|
|
100
|
+
bucketName: this.bucket.name,
|
|
101
|
+
fileName: this.fileName,
|
|
102
|
+
...options
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Fetches response headers for this file via HTTP HEAD. Returns a
|
|
107
|
+
* body-less result so callers never have to drain the (logically
|
|
108
|
+
* empty) HEAD body themselves.
|
|
109
|
+
*
|
|
110
|
+
* @param options - Optional range, SSE-C decryption, response-header
|
|
111
|
+
* overrides, and abort signal. Same shape as {@link B2Object.download}'s
|
|
112
|
+
* options minus `method` (always HEAD) and `onProgress` (no body).
|
|
113
|
+
*
|
|
114
|
+
* @returns Parsed download headers (content type, SHA-1, file info, etc.).
|
|
115
|
+
*/
|
|
116
|
+
async head(options) {
|
|
117
|
+
return headByName(this.client.raw, this.client.accountInfo, {
|
|
118
|
+
bucketName: this.bucket.name,
|
|
119
|
+
fileName: this.fileName,
|
|
120
|
+
...options
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Downloads a specific version of this file by ID. Pass `method: 'HEAD'`
|
|
125
|
+
* to fetch only the response headers (file metadata) without streaming the body.
|
|
126
|
+
* @param fileId - The file version ID to download.
|
|
127
|
+
* @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.
|
|
128
|
+
*
|
|
129
|
+
* @returns The download result with response headers and body stream.
|
|
130
|
+
*/
|
|
131
|
+
async downloadById(fileId, options) {
|
|
132
|
+
return downloadById(this.client.raw, this.client.accountInfo, {
|
|
133
|
+
fileId,
|
|
134
|
+
...options
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetches response headers for a specific version of this file by ID
|
|
139
|
+
* via HTTP HEAD. Returns a body-less result so callers never have to
|
|
140
|
+
* drain the (logically empty) HEAD body themselves.
|
|
141
|
+
*
|
|
142
|
+
* @param fileId - The file version ID to inspect.
|
|
143
|
+
* @param options - Optional range, SSE-C decryption, response-header
|
|
144
|
+
* overrides, and abort signal.
|
|
145
|
+
*
|
|
146
|
+
* @returns Parsed download headers.
|
|
147
|
+
*/
|
|
148
|
+
async headById(fileId, options) {
|
|
149
|
+
return headById(this.client.raw, this.client.accountInfo, {
|
|
150
|
+
fileId,
|
|
151
|
+
...options
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
|
|
156
|
+
* @param fileId - The file version ID to download.
|
|
157
|
+
* @param totalSize - Total file size in bytes (needed to compute range boundaries).
|
|
158
|
+
* @param options - Concurrency, range size, and abort signal.
|
|
159
|
+
*
|
|
160
|
+
* @returns A Web ReadableStream of file data in sequential order.
|
|
161
|
+
*/
|
|
162
|
+
createReadStream(fileId, totalSize, options) {
|
|
163
|
+
return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {
|
|
164
|
+
fileId,
|
|
165
|
+
totalSize,
|
|
166
|
+
...options
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Creates a Web `WritableStream` that uploads streamed data into this file
|
|
171
|
+
* using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the
|
|
172
|
+
* returned `writable` and await `done` to get the final {@link FileVersion}.
|
|
173
|
+
*
|
|
174
|
+
* Note: streaming uploads do not support resume because the size and per-part
|
|
175
|
+
* hashes are not known in advance. Use {@link upload} with a buffered source
|
|
176
|
+
* when resume is required.
|
|
177
|
+
*
|
|
178
|
+
* @param options - Streaming upload parameters (part size, concurrency, encryption).
|
|
179
|
+
*
|
|
180
|
+
* @returns A handle with the writable sink and a completion promise.
|
|
181
|
+
*/
|
|
182
|
+
createWriteStream(options) {
|
|
183
|
+
const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry);
|
|
184
|
+
return createWriteStream(this.client.raw, this.client.accountInfo, {
|
|
185
|
+
...options ?? {},
|
|
186
|
+
bucketId: this.bucket.id,
|
|
187
|
+
fileName: this.fileName,
|
|
188
|
+
retry: uploadRetryOptions
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Retrieves metadata for a specific file version.
|
|
193
|
+
* @param fileId - The file version ID to look up.
|
|
194
|
+
*
|
|
195
|
+
* @returns The file version metadata.
|
|
196
|
+
*/
|
|
197
|
+
async getFileInfo(fileId) {
|
|
198
|
+
return this.client.raw.getFileInfo(this.client.accountInfo.getApiUrl(), this.client.accountInfo.getAuthToken(), { fileId });
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Hides this file by creating a hide marker at this file name.
|
|
202
|
+
*
|
|
203
|
+
* @returns Metadata for the newly created hide marker.
|
|
204
|
+
*/
|
|
205
|
+
async hide() {
|
|
206
|
+
return this.bucket.hideFile(this.fileName);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Permanently deletes a specific version of this file.
|
|
210
|
+
* @param fileId - The unique identifier of the file version to delete.
|
|
211
|
+
*/
|
|
212
|
+
async deleteVersion(fileId) {
|
|
213
|
+
await this.bucket.deleteFileVersion(this.fileName, fileId);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Sets or updates the Object Lock retention policy on a specific file
|
|
217
|
+
* version of this file.
|
|
218
|
+
*
|
|
219
|
+
* The bucket must have Object Lock enabled (`fileLockEnabled: true` at
|
|
220
|
+
* creation time). Governance-mode retention can be shortened or removed
|
|
221
|
+
* by passing `bypassGovernance: true` together with an application key
|
|
222
|
+
* that carries the `bypassGovernance` capability; compliance-mode
|
|
223
|
+
* retention cannot be shortened by anyone until the
|
|
224
|
+
* `retainUntilTimestamp` elapses.
|
|
225
|
+
*
|
|
226
|
+
* @param fileId - The file version to apply the policy to.
|
|
227
|
+
* @param retention - The retention policy to apply.
|
|
228
|
+
* @param options - Optional flag for shortening governance-mode retention.
|
|
229
|
+
*
|
|
230
|
+
* @returns Metadata for the updated file version.
|
|
231
|
+
*/
|
|
232
|
+
async setRetention(fileId, retention, options) {
|
|
233
|
+
return this.bucket.updateFileRetention(this.fileName, fileId, retention, options);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Toggles the legal hold flag on a specific file version of this file.
|
|
237
|
+
*
|
|
238
|
+
* Legal hold is independent of retention: a file can be on legal hold
|
|
239
|
+
* without any retention policy, and vice versa. The bucket must have
|
|
240
|
+
* Object Lock enabled, and any caller must hold the `writeFileLegalHolds`
|
|
241
|
+
* capability.
|
|
242
|
+
*
|
|
243
|
+
* @param fileId - The file version to apply the flag to.
|
|
244
|
+
* @param legalHold - `'on'` to apply the hold, `'off'` to remove it.
|
|
245
|
+
*
|
|
246
|
+
* @returns Metadata for the updated file version.
|
|
247
|
+
*/
|
|
248
|
+
async setLegalHold(fileId, legalHold) {
|
|
249
|
+
return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold);
|
|
250
|
+
}
|
|
211
251
|
};
|
|
212
|
-
//#
|
|
252
|
+
//#endregion
|
|
253
|
+
export { B2Object };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=object.js.map
|
package/dist/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport { type DownloadResult, downloadByName } from './download/single.ts'\nimport { type HeadResult, downloadById, headById, headByName } from './download/single.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { ContentSource } from './streams/source.ts'\nimport type { EncryptionSetting } from './types/encryption.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId, LargeFileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { type UploadWriteHandle, createWriteStream } from './upload/stream.ts'\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n *\n * @internal\n */\n constructor(client: B2Client, bucket: Bucket, fileName: string) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: {\n /** Data source to upload. */\n source: ContentSource\n /** MIME type. Defaults to auto-detection by B2. */\n contentType?: string\n /** Custom key-value metadata stored with the file. */\n fileInfo?: Record<string, string>\n /** Server-side encryption settings. */\n serverSideEncryption?: EncryptionSetting\n /** File retention policy (requires file lock). */\n fileRetention?: FileRetentionValue\n /** Legal hold status. */\n legalHold?: LegalHoldValue\n /** Last-modified timestamp in milliseconds since epoch. */\n lastModifiedMillis?: number\n /** Part size override for multipart uploads, in bytes. */\n partSize?: number\n /** Number of concurrent part uploads for large files. */\n concurrency?: number\n /** Callback invoked with upload progress events. */\n onProgress?: ProgressListener\n /** Abort signal for cancelling the upload. */\n signal?: AbortSignal\n /**\n * Resume an unfinished multipart upload for this file name when one\n * exists. Only meaningful on the large-file path. Ignored on the\n * small-file path.\n */\n resume?: boolean\n /**\n * Resume into a specific large-file ID, bypassing discovery.\n * Overrides the `resume` discovery path.\n */\n resumeFileId?: LargeFileId\n }): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n\n if (isLarge) {\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...options,\n })\n }\n\n // Small-file path doesn't accept resume options.\n const { resume: _resume, resumeFileId: _resumeFileId, ...smallOptions } = options\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...smallOptions,\n })\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 8 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: {\n /** MIME type. Defaults to `b2/x-auto`. */\n contentType?: string\n /** Custom key-value metadata stored with the file. */\n fileInfo?: Record<string, string>\n /** Server-side encryption applied to each part. */\n serverSideEncryption?: EncryptionSetting\n /** Target part size in bytes. Defaults to the account's recommended part size. */\n partSize?: number\n /** Maximum number of parts uploaded in parallel. Defaults to 4. */\n concurrency?: number\n /** Callback invoked with upload progress events. */\n onProgress?: ProgressListener\n /** Abort signal that cancels the upload and the unfinished large file. */\n signal?: AbortSignal\n }): UploadWriteHandle {\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n bucketId: this.bucket.id,\n fileName: this.fileName,\n ...(options ?? {}),\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"names":[],"mappings":";;;;;AA4EO,MAAM,SAAS;AAAA;AAAA,EAEX;AAAA,EACQ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,YAAY,QA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,MAAM,aACJ,QACA,WACA,SACA;AACA,WAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,WAAW,OAAO;AAAA,EAClF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,aAAa,QAAgB,WAA2B;AAC5D,WAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,SAAS;AAAA,EACzE;AACF;"}
|
|
1
|
+
{"version":3,"file":"object.js","names":[],"sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 8 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YA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