@backblaze-labs/b2-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -0
- package/LICENSE +21 -0
- package/README.md +664 -0
- package/dist/auth/account-info.d.cts +51 -0
- package/dist/auth/account-info.d.cts.map +1 -0
- package/dist/auth/account-info.d.ts +51 -0
- package/dist/auth/account-info.d.ts.map +1 -0
- package/dist/auth/file.cjs +210 -0
- package/dist/auth/file.cjs.map +1 -0
- package/dist/auth/file.d.cts +157 -0
- package/dist/auth/file.d.cts.map +1 -0
- package/dist/auth/file.d.ts +157 -0
- package/dist/auth/file.d.ts.map +1 -0
- package/dist/auth/file.js +210 -0
- package/dist/auth/file.js.map +1 -0
- package/dist/auth/in-memory.cjs +184 -0
- package/dist/auth/in-memory.cjs.map +1 -0
- package/dist/auth/in-memory.d.cts +147 -0
- package/dist/auth/in-memory.d.cts.map +1 -0
- package/dist/auth/in-memory.d.ts +147 -0
- package/dist/auth/in-memory.d.ts.map +1 -0
- package/dist/auth/in-memory.js +184 -0
- package/dist/auth/in-memory.js.map +1 -0
- package/dist/auth/index.cjs +10 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +6 -0
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/realms.cjs +12 -0
- package/dist/auth/realms.cjs.map +1 -0
- package/dist/auth/realms.d.cts +12 -0
- package/dist/auth/realms.d.cts.map +1 -0
- package/dist/auth/realms.d.ts +12 -0
- package/dist/auth/realms.d.ts.map +1 -0
- package/dist/auth/realms.js +12 -0
- package/dist/auth/realms.js.map +1 -0
- package/dist/auth/upload-url-pool.cjs +52 -0
- package/dist/auth/upload-url-pool.cjs.map +1 -0
- package/dist/auth/upload-url-pool.d.cts +35 -0
- package/dist/auth/upload-url-pool.d.cts.map +1 -0
- package/dist/auth/upload-url-pool.d.ts +35 -0
- package/dist/auth/upload-url-pool.d.ts.map +1 -0
- package/dist/auth/upload-url-pool.js +52 -0
- package/dist/auth/upload-url-pool.js.map +1 -0
- package/dist/bucket.cjs +789 -0
- package/dist/bucket.cjs.map +1 -0
- package/dist/bucket.d.cts +659 -0
- package/dist/bucket.d.cts.map +1 -0
- package/dist/bucket.d.ts +659 -0
- package/dist/bucket.d.ts.map +1 -0
- package/dist/bucket.js +789 -0
- package/dist/bucket.js.map +1 -0
- package/dist/client.cjs +230 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +222 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +222 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +230 -0
- package/dist/client.js.map +1 -0
- package/dist/copy/large.cjs +74 -0
- package/dist/copy/large.cjs.map +1 -0
- package/dist/copy/large.d.cts +53 -0
- package/dist/copy/large.d.cts.map +1 -0
- package/dist/copy/large.d.ts +53 -0
- package/dist/copy/large.d.ts.map +1 -0
- package/dist/copy/large.js +74 -0
- package/dist/copy/large.js.map +1 -0
- package/dist/download/parallel.cjs +122 -0
- package/dist/download/parallel.cjs.map +1 -0
- package/dist/download/parallel.d.cts +42 -0
- package/dist/download/parallel.d.cts.map +1 -0
- package/dist/download/parallel.d.ts +42 -0
- package/dist/download/parallel.d.ts.map +1 -0
- package/dist/download/parallel.js +122 -0
- package/dist/download/parallel.js.map +1 -0
- package/dist/download/single.cjs +117 -0
- package/dist/download/single.cjs.map +1 -0
- package/dist/download/single.d.cts +152 -0
- package/dist/download/single.d.cts.map +1 -0
- package/dist/download/single.d.ts +152 -0
- package/dist/download/single.d.ts.map +1 -0
- package/dist/download/single.js +117 -0
- package/dist/download/single.js.map +1 -0
- package/dist/errors/index.cjs +268 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +264 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +264 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +268 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/http/retry.cjs +36 -0
- package/dist/http/retry.cjs.map +1 -0
- package/dist/http/retry.d.cts +34 -0
- package/dist/http/retry.d.cts.map +1 -0
- package/dist/http/retry.d.ts +34 -0
- package/dist/http/retry.d.ts.map +1 -0
- package/dist/http/retry.js +36 -0
- package/dist/http/retry.js.map +1 -0
- package/dist/http/transport.cjs +143 -0
- package/dist/http/transport.cjs.map +1 -0
- package/dist/http/transport.d.cts +122 -0
- package/dist/http/transport.d.cts.map +1 -0
- package/dist/http/transport.d.ts +122 -0
- package/dist/http/transport.d.ts.map +1 -0
- package/dist/http/transport.js +143 -0
- package/dist/http/transport.js.map +1 -0
- package/dist/http/url-guard.cjs +97 -0
- package/dist/http/url-guard.cjs.map +1 -0
- package/dist/http/url-guard.d.cts +88 -0
- package/dist/http/url-guard.d.cts.map +1 -0
- package/dist/http/url-guard.d.ts +88 -0
- package/dist/http/url-guard.d.ts.map +1 -0
- package/dist/http/url-guard.js +97 -0
- package/dist/http/url-guard.js.map +1 -0
- package/dist/http/user-agent.cjs +51 -0
- package/dist/http/user-agent.cjs.map +1 -0
- package/dist/http/user-agent.d.cts +28 -0
- package/dist/http/user-agent.d.cts.map +1 -0
- package/dist/http/user-agent.d.ts +28 -0
- package/dist/http/user-agent.d.ts.map +1 -0
- package/dist/http/user-agent.js +51 -0
- package/dist/http/user-agent.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications/index.cjs +7 -0
- package/dist/notifications/index.cjs.map +1 -0
- package/dist/notifications/index.d.cts +3 -0
- package/dist/notifications/index.d.cts.map +1 -0
- package/dist/notifications/index.d.ts +3 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/webhook.cjs +106 -0
- package/dist/notifications/webhook.cjs.map +1 -0
- package/dist/notifications/webhook.d.cts +146 -0
- package/dist/notifications/webhook.d.cts.map +1 -0
- package/dist/notifications/webhook.d.ts +146 -0
- package/dist/notifications/webhook.d.ts.map +1 -0
- package/dist/notifications/webhook.js +106 -0
- package/dist/notifications/webhook.js.map +1 -0
- package/dist/object.cjs +212 -0
- package/dist/object.cjs.map +1 -0
- package/dist/object.d.cts +263 -0
- package/dist/object.d.cts.map +1 -0
- package/dist/object.d.ts +263 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +212 -0
- package/dist/object.js.map +1 -0
- package/dist/package.json.cjs +9 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +9 -0
- package/dist/package.json.js.map +1 -0
- package/dist/raw/encoding.cjs +47 -0
- package/dist/raw/encoding.cjs.map +1 -0
- package/dist/raw/encoding.d.cts +46 -0
- package/dist/raw/encoding.d.cts.map +1 -0
- package/dist/raw/encoding.d.ts +46 -0
- package/dist/raw/encoding.d.ts.map +1 -0
- package/dist/raw/encoding.js +47 -0
- package/dist/raw/encoding.js.map +1 -0
- package/dist/raw/index.cjs +600 -0
- package/dist/raw/index.cjs.map +1 -0
- package/dist/raw/index.d.cts +381 -0
- package/dist/raw/index.d.cts.map +1 -0
- package/dist/raw/index.d.ts +381 -0
- package/dist/raw/index.d.ts.map +1 -0
- package/dist/raw/index.js +601 -0
- package/dist/raw/index.js.map +1 -0
- package/dist/s3/index.cjs +23 -0
- package/dist/s3/index.cjs.map +1 -0
- package/dist/s3/index.d.cts +74 -0
- package/dist/s3/index.d.cts.map +1 -0
- package/dist/s3/index.d.ts +74 -0
- package/dist/s3/index.d.ts.map +1 -0
- package/dist/s3/index.js +23 -0
- package/dist/s3/index.js.map +1 -0
- package/dist/simulator/capabilities.cjs +53 -0
- package/dist/simulator/capabilities.cjs.map +1 -0
- package/dist/simulator/capabilities.d.cts +15 -0
- package/dist/simulator/capabilities.d.cts.map +1 -0
- package/dist/simulator/capabilities.d.ts +15 -0
- package/dist/simulator/capabilities.d.ts.map +1 -0
- package/dist/simulator/capabilities.js +53 -0
- package/dist/simulator/capabilities.js.map +1 -0
- package/dist/simulator/index.cjs +1559 -0
- package/dist/simulator/index.cjs.map +1 -0
- package/dist/simulator/index.d.cts +495 -0
- package/dist/simulator/index.d.cts.map +1 -0
- package/dist/simulator/index.d.ts +495 -0
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/simulator/index.js +1560 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/simulator/validation.cjs +174 -0
- package/dist/simulator/validation.cjs.map +1 -0
- package/dist/simulator/validation.d.cts +104 -0
- package/dist/simulator/validation.d.cts.map +1 -0
- package/dist/simulator/validation.d.ts +104 -0
- package/dist/simulator/validation.d.ts.map +1 -0
- package/dist/simulator/validation.js +174 -0
- package/dist/simulator/validation.js.map +1 -0
- package/dist/streams/collect.cjs +26 -0
- package/dist/streams/collect.cjs.map +1 -0
- package/dist/streams/collect.d.cts +18 -0
- package/dist/streams/collect.d.cts.map +1 -0
- package/dist/streams/collect.d.ts +18 -0
- package/dist/streams/collect.d.ts.map +1 -0
- package/dist/streams/collect.js +26 -0
- package/dist/streams/collect.js.map +1 -0
- package/dist/streams/hash.cjs +123 -0
- package/dist/streams/hash.cjs.map +1 -0
- package/dist/streams/hash.d.cts +42 -0
- package/dist/streams/hash.d.cts.map +1 -0
- package/dist/streams/hash.d.ts +42 -0
- package/dist/streams/hash.d.ts.map +1 -0
- package/dist/streams/hash.js +101 -0
- package/dist/streams/hash.js.map +1 -0
- package/dist/streams/index.cjs +13 -0
- package/dist/streams/index.cjs.map +1 -0
- package/dist/streams/index.d.cts +7 -0
- package/dist/streams/index.d.cts.map +1 -0
- package/dist/streams/index.d.ts +7 -0
- package/dist/streams/index.d.ts.map +1 -0
- package/dist/streams/index.js +13 -0
- package/dist/streams/index.js.map +1 -0
- package/dist/streams/progress.cjs +47 -0
- package/dist/streams/progress.cjs.map +1 -0
- package/dist/streams/progress.d.cts +53 -0
- package/dist/streams/progress.d.cts.map +1 -0
- package/dist/streams/progress.d.ts +53 -0
- package/dist/streams/progress.d.ts.map +1 -0
- package/dist/streams/progress.js +47 -0
- package/dist/streams/progress.js.map +1 -0
- package/dist/streams/source.cjs +155 -0
- package/dist/streams/source.cjs.map +1 -0
- package/dist/streams/source.d.cts +140 -0
- package/dist/streams/source.d.cts.map +1 -0
- package/dist/streams/source.d.ts +140 -0
- package/dist/streams/source.d.ts.map +1 -0
- package/dist/streams/source.js +155 -0
- package/dist/streams/source.js.map +1 -0
- package/dist/sync/actions/index.cjs +191 -0
- package/dist/sync/actions/index.cjs.map +1 -0
- package/dist/sync/actions/index.d.cts +167 -0
- package/dist/sync/actions/index.d.cts.map +1 -0
- package/dist/sync/actions/index.d.ts +167 -0
- package/dist/sync/actions/index.d.ts.map +1 -0
- package/dist/sync/actions/index.js +191 -0
- package/dist/sync/actions/index.js.map +1 -0
- package/dist/sync/index.cjs +23 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +21 -0
- package/dist/sync/index.d.cts.map +1 -0
- package/dist/sync/index.d.ts +21 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +23 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/pairing.cjs +31 -0
- package/dist/sync/pairing.cjs.map +1 -0
- package/dist/sync/pairing.d.cts +13 -0
- package/dist/sync/pairing.d.cts.map +1 -0
- package/dist/sync/pairing.d.ts +13 -0
- package/dist/sync/pairing.d.ts.map +1 -0
- package/dist/sync/pairing.js +31 -0
- package/dist/sync/pairing.js.map +1 -0
- package/dist/sync/policies/compare.cjs +14 -0
- package/dist/sync/policies/compare.cjs.map +1 -0
- package/dist/sync/policies/compare.d.cts +13 -0
- package/dist/sync/policies/compare.d.cts.map +1 -0
- package/dist/sync/policies/compare.d.ts +13 -0
- package/dist/sync/policies/compare.d.ts.map +1 -0
- package/dist/sync/policies/compare.js +14 -0
- package/dist/sync/policies/compare.js.map +1 -0
- package/dist/sync/policies/index.cjs +74 -0
- package/dist/sync/policies/index.cjs.map +1 -0
- package/dist/sync/policies/index.d.cts +42 -0
- package/dist/sync/policies/index.d.cts.map +1 -0
- package/dist/sync/policies/index.d.ts +42 -0
- package/dist/sync/policies/index.d.ts.map +1 -0
- package/dist/sync/policies/index.js +74 -0
- package/dist/sync/policies/index.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +57 -0
- package/dist/sync/scanners/b2.cjs.map +1 -0
- package/dist/sync/scanners/b2.d.cts +20 -0
- package/dist/sync/scanners/b2.d.cts.map +1 -0
- package/dist/sync/scanners/b2.d.ts +20 -0
- package/dist/sync/scanners/b2.d.ts.map +1 -0
- package/dist/sync/scanners/b2.js +57 -0
- package/dist/sync/scanners/b2.js.map +1 -0
- package/dist/sync/scanners/local.cjs +58 -0
- package/dist/sync/scanners/local.cjs.map +1 -0
- package/dist/sync/scanners/local.d.cts +24 -0
- package/dist/sync/scanners/local.d.cts.map +1 -0
- package/dist/sync/scanners/local.d.ts +24 -0
- package/dist/sync/scanners/local.d.ts.map +1 -0
- package/dist/sync/scanners/local.js +58 -0
- package/dist/sync/scanners/local.js.map +1 -0
- package/dist/sync/synchronizer.cjs +203 -0
- package/dist/sync/synchronizer.cjs.map +1 -0
- package/dist/sync/synchronizer.d.cts +52 -0
- package/dist/sync/synchronizer.d.cts.map +1 -0
- package/dist/sync/synchronizer.d.ts +52 -0
- package/dist/sync/synchronizer.d.ts.map +1 -0
- package/dist/sync/synchronizer.js +181 -0
- package/dist/sync/synchronizer.js.map +1 -0
- package/dist/sync/types.d.cts +121 -0
- package/dist/sync/types.d.cts.map +1 -0
- package/dist/sync/types.d.ts +121 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/types/auth.cjs +58 -0
- package/dist/types/auth.cjs.map +1 -0
- package/dist/types/auth.d.cts +150 -0
- package/dist/types/auth.d.cts.map +1 -0
- package/dist/types/auth.d.ts +150 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +58 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/bucket.cjs +44 -0
- package/dist/types/bucket.cjs.map +1 -0
- package/dist/types/bucket.d.cts +245 -0
- package/dist/types/bucket.d.cts.map +1 -0
- package/dist/types/bucket.d.ts +245 -0
- package/dist/types/bucket.d.ts.map +1 -0
- package/dist/types/bucket.js +44 -0
- package/dist/types/bucket.js.map +1 -0
- package/dist/types/download.d.cts +110 -0
- package/dist/types/download.d.cts.map +1 -0
- package/dist/types/download.d.ts +110 -0
- package/dist/types/download.d.ts.map +1 -0
- package/dist/types/encryption.cjs +343 -0
- package/dist/types/encryption.cjs.map +1 -0
- package/dist/types/encryption.d.cts +132 -0
- package/dist/types/encryption.d.cts.map +1 -0
- package/dist/types/encryption.d.ts +132 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/encryption.js +321 -0
- package/dist/types/encryption.js.map +1 -0
- package/dist/types/errors.d.cts +16 -0
- package/dist/types/errors.d.cts.map +1 -0
- package/dist/types/errors.d.ts +16 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/file.cjs +23 -0
- package/dist/types/file.cjs.map +1 -0
- package/dist/types/file.d.cts +220 -0
- package/dist/types/file.d.cts.map +1 -0
- package/dist/types/file.d.ts +220 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/file.js +23 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/ids.cjs +27 -0
- package/dist/types/ids.cjs.map +1 -0
- package/dist/types/ids.d.cts +84 -0
- package/dist/types/ids.d.cts.map +1 -0
- package/dist/types/ids.d.ts +84 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +27 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.d.cts +25 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/key.d.cts +84 -0
- package/dist/types/key.d.cts.map +1 -0
- package/dist/types/key.d.ts +84 -0
- package/dist/types/key.d.ts.map +1 -0
- package/dist/types/lock.cjs +17 -0
- package/dist/types/lock.cjs.map +1 -0
- package/dist/types/lock.d.cts +92 -0
- package/dist/types/lock.d.cts.map +1 -0
- package/dist/types/lock.d.ts +92 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +17 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/notifications.cjs +24 -0
- package/dist/types/notifications.cjs.map +1 -0
- package/dist/types/notifications.d.cts +97 -0
- package/dist/types/notifications.d.cts.map +1 -0
- package/dist/types/notifications.d.ts +97 -0
- package/dist/types/notifications.d.ts.map +1 -0
- package/dist/types/notifications.js +24 -0
- package/dist/types/notifications.js.map +1 -0
- package/dist/types/replication.d.cts +42 -0
- package/dist/types/replication.d.cts.map +1 -0
- package/dist/types/replication.d.ts +42 -0
- package/dist/types/replication.d.ts.map +1 -0
- package/dist/types/upload.d.cts +219 -0
- package/dist/types/upload.d.cts.map +1 -0
- package/dist/types/upload.d.ts +219 -0
- package/dist/types/upload.d.ts.map +1 -0
- package/dist/upload/cancel.cjs +10 -0
- package/dist/upload/cancel.cjs.map +1 -0
- package/dist/upload/cancel.d.cts +23 -0
- package/dist/upload/cancel.d.cts.map +1 -0
- package/dist/upload/cancel.d.ts +23 -0
- package/dist/upload/cancel.d.ts.map +1 -0
- package/dist/upload/cancel.js +10 -0
- package/dist/upload/cancel.js.map +1 -0
- package/dist/upload/concurrency.cjs +54 -0
- package/dist/upload/concurrency.cjs.map +1 -0
- package/dist/upload/concurrency.d.cts +46 -0
- package/dist/upload/concurrency.d.cts.map +1 -0
- package/dist/upload/concurrency.d.ts +46 -0
- package/dist/upload/concurrency.d.ts.map +1 -0
- package/dist/upload/concurrency.js +54 -0
- package/dist/upload/concurrency.js.map +1 -0
- package/dist/upload/large.cjs +222 -0
- package/dist/upload/large.cjs.map +1 -0
- package/dist/upload/large.d.cts +71 -0
- package/dist/upload/large.d.cts.map +1 -0
- package/dist/upload/large.d.ts +71 -0
- package/dist/upload/large.d.ts.map +1 -0
- package/dist/upload/large.js +222 -0
- package/dist/upload/large.js.map +1 -0
- package/dist/upload/resume.cjs +34 -0
- package/dist/upload/resume.cjs.map +1 -0
- package/dist/upload/resume.d.cts +33 -0
- package/dist/upload/resume.d.cts.map +1 -0
- package/dist/upload/resume.d.ts +33 -0
- package/dist/upload/resume.d.ts.map +1 -0
- package/dist/upload/resume.js +34 -0
- package/dist/upload/resume.js.map +1 -0
- package/dist/upload/single.cjs +47 -0
- package/dist/upload/single.cjs.map +1 -0
- package/dist/upload/single.d.cts +51 -0
- package/dist/upload/single.d.cts.map +1 -0
- package/dist/upload/single.d.ts +51 -0
- package/dist/upload/single.d.ts.map +1 -0
- package/dist/upload/single.js +47 -0
- package/dist/upload/single.js.map +1 -0
- package/dist/upload/stream.cjs +198 -0
- package/dist/upload/stream.cjs.map +1 -0
- package/dist/upload/stream.d.cts +61 -0
- package/dist/upload/stream.d.cts.map +1 -0
- package/dist/upload/stream.d.ts +61 -0
- package/dist/upload/stream.d.ts.map +1 -0
- package/dist/upload/stream.js +198 -0
- package/dist/upload/stream.js.map +1 -0
- package/dist/util/best-effort.cjs +10 -0
- package/dist/util/best-effort.cjs.map +1 -0
- package/dist/util/best-effort.d.cts +31 -0
- package/dist/util/best-effort.d.cts.map +1 -0
- package/dist/util/best-effort.d.ts +31 -0
- package/dist/util/best-effort.d.ts.map +1 -0
- package/dist/util/best-effort.js +10 -0
- package/dist/util/best-effort.js.map +1 -0
- package/dist/util/defaults.cjs +11 -0
- package/dist/util/defaults.cjs.map +1 -0
- package/dist/util/defaults.d.cts +54 -0
- package/dist/util/defaults.d.cts.map +1 -0
- package/dist/util/defaults.d.ts +54 -0
- package/dist/util/defaults.d.ts.map +1 -0
- package/dist/util/defaults.js +11 -0
- package/dist/util/defaults.js.map +1 -0
- package/dist/util/normalize.cjs +16 -0
- package/dist/util/normalize.cjs.map +1 -0
- package/dist/util/normalize.d.cts +62 -0
- package/dist/util/normalize.d.cts.map +1 -0
- package/dist/util/normalize.d.ts +62 -0
- package/dist/util/normalize.d.ts.map +1 -0
- package/dist/util/normalize.js +16 -0
- package/dist/util/normalize.js.map +1 -0
- package/dist/util/paginator.cjs +20 -0
- package/dist/util/paginator.cjs.map +1 -0
- package/dist/util/paginator.d.cts +120 -0
- package/dist/util/paginator.d.cts.map +1 -0
- package/dist/util/paginator.d.ts +120 -0
- package/dist/util/paginator.d.ts.map +1 -0
- package/dist/util/paginator.js +20 -0
- package/dist/util/paginator.js.map +1 -0
- package/dist/util/plan-ranges.cjs +28 -0
- package/dist/util/plan-ranges.cjs.map +1 -0
- package/dist/util/plan-ranges.d.cts +56 -0
- package/dist/util/plan-ranges.d.cts.map +1 -0
- package/dist/util/plan-ranges.d.ts +56 -0
- package/dist/util/plan-ranges.d.ts.map +1 -0
- package/dist/util/plan-ranges.js +28 -0
- package/dist/util/plan-ranges.js.map +1 -0
- package/dist/util/text-codec.cjs +7 -0
- package/dist/util/text-codec.cjs.map +1 -0
- package/dist/util/text-codec.d.cts +26 -0
- package/dist/util/text-codec.d.cts.map +1 -0
- package/dist/util/text-codec.d.ts +26 -0
- package/dist/util/text-codec.d.ts.map +1 -0
- package/dist/util/text-codec.js +7 -0
- package/dist/util/text-codec.js.map +1 -0
- package/dist/util/to-error.cjs +7 -0
- package/dist/util/to-error.cjs.map +1 -0
- package/dist/util/to-error.d.cts +15 -0
- package/dist/util/to-error.d.cts.map +1 -0
- package/dist/util/to-error.d.ts +15 -0
- package/dist/util/to-error.d.ts.map +1 -0
- package/dist/util/to-error.js +7 -0
- package/dist/util/to-error.js.map +1 -0
- package/dist/version.cjs +6 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +14 -0
- package/dist/version.d.cts.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +198 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { BufferSource } from "../streams/source.js";
|
|
2
|
+
import { fileId } from "../types/ids.js";
|
|
3
|
+
import { Semaphore } from "../upload/concurrency.js";
|
|
4
|
+
import { DEFAULT_TRANSFER_CONCURRENCY } from "../util/defaults.js";
|
|
5
|
+
import { toError } from "../util/to-error.js";
|
|
6
|
+
import { DeleteLocalAction, DeleteRemoteAction, HideAction, CopyAction, DownloadAction, UploadAction } from "./actions/index.js";
|
|
7
|
+
import { zipFolders } from "./pairing.js";
|
|
8
|
+
import { generateActions } from "./policies/index.js";
|
|
9
|
+
function resolveDirection(source, dest) {
|
|
10
|
+
if (source.type === "local" && dest.type === "b2") return "local-to-b2";
|
|
11
|
+
if (source.type === "b2" && dest.type === "local") return "b2-to-local";
|
|
12
|
+
if (source.type === "b2" && dest.type === "b2") return "b2-to-b2";
|
|
13
|
+
throw new Error(`Unsupported sync direction: ${source.type} to ${dest.type}`);
|
|
14
|
+
}
|
|
15
|
+
async function* synchronize(config) {
|
|
16
|
+
const { source, dest, options } = config;
|
|
17
|
+
const direction = resolveDirection(source, dest);
|
|
18
|
+
const dryRun = options.dryRun ?? false;
|
|
19
|
+
const concurrency = options.concurrency ?? DEFAULT_TRANSFER_CONCURRENCY;
|
|
20
|
+
const keepDays = options.keepDays ?? 0;
|
|
21
|
+
const compareThreshold = options.compareThreshold ?? 0;
|
|
22
|
+
const nowMillis = Date.now();
|
|
23
|
+
const factory = createActionFactory(config);
|
|
24
|
+
const actions = [];
|
|
25
|
+
for await (const pair of zipFolders(source, dest)) {
|
|
26
|
+
if (options.signal?.aborted) return;
|
|
27
|
+
for (const action of generateActions(
|
|
28
|
+
pair,
|
|
29
|
+
direction,
|
|
30
|
+
options.compareMode,
|
|
31
|
+
options.keepMode,
|
|
32
|
+
keepDays,
|
|
33
|
+
nowMillis,
|
|
34
|
+
factory,
|
|
35
|
+
compareThreshold
|
|
36
|
+
)) {
|
|
37
|
+
actions.push(action);
|
|
38
|
+
}
|
|
39
|
+
yield { type: "compare", path: (pair[0] ?? pair[1])?.relativePath ?? "", size: 0 };
|
|
40
|
+
}
|
|
41
|
+
const sem = new Semaphore(concurrency);
|
|
42
|
+
const results = [];
|
|
43
|
+
const errors = [];
|
|
44
|
+
const promises = actions.map(async (action) => {
|
|
45
|
+
await sem.acquire();
|
|
46
|
+
try {
|
|
47
|
+
if (options.signal?.aborted) return;
|
|
48
|
+
const event = await action.execute(dryRun);
|
|
49
|
+
results.push(event);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const errorValue = toError(err);
|
|
52
|
+
errors.push(errorValue);
|
|
53
|
+
results.push({
|
|
54
|
+
type: "error",
|
|
55
|
+
path: action.relativePath,
|
|
56
|
+
size: 0,
|
|
57
|
+
message: errorValue.message
|
|
58
|
+
});
|
|
59
|
+
} finally {
|
|
60
|
+
sem.release();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
await Promise.all(promises);
|
|
64
|
+
for (const event of results) {
|
|
65
|
+
yield event;
|
|
66
|
+
}
|
|
67
|
+
if (errors.length > 0) {
|
|
68
|
+
yield {
|
|
69
|
+
type: "error",
|
|
70
|
+
path: "",
|
|
71
|
+
size: 0,
|
|
72
|
+
message: `${errors.length} action(s) failed`
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function assertBucket(bucket, context) {
|
|
77
|
+
if (!bucket) throw new Error(`Bucket required for ${context} actions`);
|
|
78
|
+
}
|
|
79
|
+
function createActionFactory(config) {
|
|
80
|
+
const upConfig = config;
|
|
81
|
+
const downConfig = config;
|
|
82
|
+
const destBucket = upConfig.bucket ?? downConfig.bucket;
|
|
83
|
+
const bucketIsLocked = destBucket?.info?.fileLockConfiguration?.value?.isFileLockEnabled ?? false;
|
|
84
|
+
const factory = {
|
|
85
|
+
upload(source) {
|
|
86
|
+
const bucket = upConfig.bucket;
|
|
87
|
+
const prefix = upConfig.prefix ?? "";
|
|
88
|
+
assertBucket(bucket, "upload");
|
|
89
|
+
return new UploadAction(
|
|
90
|
+
source.relativePath,
|
|
91
|
+
source.absolutePath,
|
|
92
|
+
source.size,
|
|
93
|
+
async (absPath, relPath) => {
|
|
94
|
+
const { readFile } = await import("node:fs/promises");
|
|
95
|
+
const data = await readFile(absPath);
|
|
96
|
+
await bucket.upload({
|
|
97
|
+
fileName: `${prefix}${relPath}`,
|
|
98
|
+
source: new BufferSource(new Uint8Array(data))
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
download(source) {
|
|
104
|
+
const bucket = downConfig.bucket;
|
|
105
|
+
const root = downConfig.dest?.type === "local" ? downConfig.dest.root : "";
|
|
106
|
+
assertBucket(bucket, "download");
|
|
107
|
+
return new DownloadAction(source.relativePath, source.size, async (relPath) => {
|
|
108
|
+
const result = await bucket.download(source.selectedVersion.fileName);
|
|
109
|
+
const reader = result.body.getReader();
|
|
110
|
+
let combined;
|
|
111
|
+
try {
|
|
112
|
+
const chunks = [];
|
|
113
|
+
while (true) {
|
|
114
|
+
const { done, value } = await reader.read();
|
|
115
|
+
if (done) break;
|
|
116
|
+
chunks.push(value);
|
|
117
|
+
}
|
|
118
|
+
let total = 0;
|
|
119
|
+
for (const c of chunks) total += c.byteLength;
|
|
120
|
+
combined = new Uint8Array(total);
|
|
121
|
+
let offset = 0;
|
|
122
|
+
for (const c of chunks) {
|
|
123
|
+
combined.set(c, offset);
|
|
124
|
+
offset += c.byteLength;
|
|
125
|
+
}
|
|
126
|
+
} finally {
|
|
127
|
+
reader.releaseLock();
|
|
128
|
+
}
|
|
129
|
+
const { mkdir, writeFile } = await import("node:fs/promises");
|
|
130
|
+
const { dirname, join } = await import("node:path");
|
|
131
|
+
const destPath = join(root, relPath);
|
|
132
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
133
|
+
await writeFile(destPath, combined);
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
copy(source, destPath) {
|
|
137
|
+
const bucket = upConfig.bucket;
|
|
138
|
+
assertBucket(bucket, "copy");
|
|
139
|
+
return new CopyAction(source.relativePath, source.size, async () => {
|
|
140
|
+
await bucket.copyFile({
|
|
141
|
+
sourceFileId: source.selectedVersion.fileId,
|
|
142
|
+
fileName: destPath
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
hide(path) {
|
|
147
|
+
const bucket = upConfig.bucket ?? downConfig.bucket;
|
|
148
|
+
assertBucket(bucket, "hide");
|
|
149
|
+
return new HideAction(path, async (relPath) => {
|
|
150
|
+
const prefix = upConfig.prefix ?? "";
|
|
151
|
+
await bucket.hideFile(`${prefix}${relPath}`);
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
deleteRemote(path) {
|
|
155
|
+
const bucket = upConfig.bucket ?? downConfig.bucket;
|
|
156
|
+
assertBucket(bucket, "delete");
|
|
157
|
+
const b2FileName = path.selectedVersion.fileName;
|
|
158
|
+
return new DeleteRemoteAction(
|
|
159
|
+
path.relativePath,
|
|
160
|
+
path.selectedVersion.fileId,
|
|
161
|
+
async (fileId$1) => {
|
|
162
|
+
await bucket.deleteFileVersion(b2FileName, fileId(fileId$1));
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
deleteLocal(path) {
|
|
167
|
+
return new DeleteLocalAction(path.relativePath, path.absolutePath, async (absPath) => {
|
|
168
|
+
const { unlink } = await import("node:fs/promises");
|
|
169
|
+
await unlink(absPath);
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
removeOrphan(dest) {
|
|
173
|
+
return bucketIsLocked ? factory.hide(dest.relativePath) : factory.deleteRemote(dest);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return factory;
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
synchronize
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=synchronizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synchronizer.js","sources":["../../src/sync/synchronizer.ts"],"sourcesContent":["import type { Bucket } from '../bucket.ts'\nimport { BufferSource } from '../streams/source.ts'\nimport { fileId as fileIdOf } from '../types/ids.ts'\nimport { Semaphore } from '../upload/concurrency.ts'\nimport { DEFAULT_TRANSFER_CONCURRENCY } from '../util/defaults.ts'\nimport { toError } from '../util/to-error.ts'\nimport type { SyncAction } from './actions/index.ts'\nimport {\n CopyAction,\n DeleteLocalAction,\n DeleteRemoteAction,\n DownloadAction,\n HideAction,\n UploadAction,\n} from './actions/index.ts'\nimport { zipFolders } from './pairing.ts'\nimport type { ActionFactory } from './policies/index.ts'\nimport { generateActions } from './policies/index.ts'\nimport type {\n B2SyncPath,\n LocalSyncPath,\n SyncDirection,\n SyncEvent,\n SyncFolder,\n SyncOptions,\n} from './types.ts'\n\n/** Base configuration for a sync operation. */\nexport interface SynchronizerConfig {\n /** The folder to read files from. */\n readonly source: SyncFolder\n /** The folder to write files to. */\n readonly dest: SyncFolder\n /** Options controlling comparison, deletion policy, and concurrency. */\n readonly options: SyncOptions\n}\n\n/** A sync folder constrained to the local filesystem. */\nexport interface LocalSyncFolder extends SyncFolder {\n /** Discriminant identifying a local folder. */\n readonly type: 'local'\n /** Absolute filesystem path to the local root directory. */\n readonly root: string\n}\n\n/** A sync folder constrained to a B2 bucket prefix. */\nexport interface B2SyncFolder extends SyncFolder {\n /** Discriminant identifying a B2 folder. */\n readonly type: 'b2'\n}\n\n/** Configuration for a local-to-B2 sync (upload direction). */\nexport interface SynchronizerUpConfig extends SynchronizerConfig {\n /** Local source folder. */\n readonly source: LocalSyncFolder\n /** B2 destination folder. */\n readonly dest: B2SyncFolder\n /** The target B2 bucket. */\n readonly bucket: Bucket\n /** Key prefix for uploaded files in the bucket. */\n readonly prefix: string\n}\n\n/** Configuration for a B2-to-local sync (download direction). */\nexport interface SynchronizerDownConfig extends SynchronizerConfig {\n /** B2 source folder. */\n readonly source: B2SyncFolder\n /** Local destination folder. */\n readonly dest: LocalSyncFolder\n /** The source B2 bucket. */\n readonly bucket: Bucket\n}\n\n/**\n * Infers the sync direction from the source and destination folder types.\n * @param source - The folder to read files from.\n * @param dest - The folder to write files to.\n *\n * @returns The resolved sync direction based on folder types.\n *\n * @throws When the source and destination folder types form an unsupported combination.\n */\nfunction resolveDirection(source: SyncFolder, dest: SyncFolder): SyncDirection {\n if (source.type === 'local' && dest.type === 'b2') return 'local-to-b2'\n if (source.type === 'b2' && dest.type === 'local') return 'b2-to-local'\n if (source.type === 'b2' && dest.type === 'b2') return 'b2-to-b2'\n throw new Error(`Unsupported sync direction: ${source.type} to ${dest.type}`)\n}\n\n/**\n * Runs a full sync operation: scans both folders, pairs files, generates actions,\n * and executes them with bounded concurrency. Yields {@link SyncEvent} entries for\n * each comparison and action result.\n *\n * @param config - The synchronizer configuration (source, dest, options, and optional bucket).\n */\nexport async function* synchronize(config: SynchronizerConfig): AsyncGenerator<SyncEvent> {\n const { source, dest, options } = config\n const direction = resolveDirection(source, dest)\n const dryRun = options.dryRun ?? false\n const concurrency = options.concurrency ?? DEFAULT_TRANSFER_CONCURRENCY\n const keepDays = options.keepDays ?? 0\n const compareThreshold = options.compareThreshold ?? 0\n const nowMillis = Date.now()\n\n const factory = createActionFactory(config)\n\n const actions: SyncAction[] = []\n\n for await (const pair of zipFolders(source, dest)) {\n if (options.signal?.aborted) return\n\n for (const action of generateActions(\n pair,\n direction,\n options.compareMode,\n options.keepMode,\n keepDays,\n nowMillis,\n factory,\n compareThreshold,\n )) {\n actions.push(action)\n }\n\n yield { type: 'compare', path: (pair[0] ?? pair[1])?.relativePath ?? '', size: 0 }\n }\n\n const sem = new Semaphore(concurrency)\n const results: SyncEvent[] = []\n const errors: Error[] = []\n\n const promises = actions.map(async (action) => {\n await sem.acquire()\n try {\n if (options.signal?.aborted) return\n const event = await action.execute(dryRun)\n results.push(event)\n } catch (err) {\n const errorValue = toError(err)\n errors.push(errorValue)\n results.push({\n type: 'error',\n path: action.relativePath,\n size: 0,\n message: errorValue.message,\n })\n } finally {\n sem.release()\n }\n })\n\n await Promise.all(promises)\n\n for (const event of results) {\n yield event\n }\n\n if (errors.length > 0) {\n yield {\n type: 'error',\n path: '',\n size: 0,\n message: `${errors.length} action(s) failed`,\n }\n }\n}\n\n/**\n * Narrowing assertion that a `Bucket` is present for an action that requires\n * it. Throws with a consistent, context-tagged message when the configured\n * direction did not supply one (e.g. `b2-to-local` direction asking for an\n * upload action).\n *\n * Uses TypeScript's `asserts` signature so call-site flow narrows\n * `bucket` from `Bucket | undefined` to `Bucket` after the check, without\n * requiring a separate `if (!bucket) throw ...` line per action factory.\n *\n * @param bucket - The (possibly missing) bucket reference.\n * @param context - Short verb describing the action being constructed\n * (e.g. `'upload'`, `'download'`). Surfaced in the error message.\n *\n * @throws `Error` when `bucket` is `undefined` or `null`.\n */\nfunction assertBucket(bucket: Bucket | undefined, context: string): asserts bucket is Bucket {\n if (!bucket) throw new Error(`Bucket required for ${context} actions`)\n}\n\n/**\n * Creates a configured sync engine wired to the bucket and paths in the given config.\n *\n * For sync operations that may need to remove destination-only files (the\n * `keepMode: 'delete'` policy), the factory reads the destination\n * bucket's cached `fileLockConfiguration` once so `removeOrphan` can\n * dispatch to either `hide` (locked buckets) or `deleteFileVersion`\n * (vanilla buckets) without a per-file branch. The cache is whatever\n * `client.listBuckets()` or `client.createBucket()` returned — callers\n * who flipped lock state mid-sync (rare) should refresh before\n * synchronize().\n *\n * @param config - The synchronizer configuration containing source, destination, and options.\n *\n * @returns An action factory bound to the provided configuration.\n */\nfunction createActionFactory(config: SynchronizerConfig): ActionFactory {\n const upConfig = config as Partial<SynchronizerUpConfig>\n const downConfig = config as Partial<SynchronizerDownConfig>\n\n const destBucket = upConfig.bucket ?? downConfig.bucket\n // Defensive optional chain on `info`: synchronizer tests use Bucket\n // mocks that don't populate this field. Real `Bucket` instances always\n // do (constructor parameter).\n const bucketIsLocked = destBucket?.info?.fileLockConfiguration?.value?.isFileLockEnabled ?? false\n\n const factory: ActionFactory = {\n upload(source: LocalSyncPath): SyncAction {\n const bucket = upConfig.bucket\n const prefix = upConfig.prefix ?? ''\n assertBucket(bucket, 'upload')\n\n return new UploadAction(\n source.relativePath,\n source.absolutePath,\n source.size,\n async (absPath, relPath) => {\n const { readFile } = await import('node:fs/promises')\n const data = await readFile(absPath)\n await bucket.upload({\n fileName: `${prefix}${relPath}`,\n source: new BufferSource(new Uint8Array(data)),\n })\n },\n )\n },\n\n download(source: B2SyncPath): SyncAction {\n const bucket = downConfig.bucket\n const root =\n downConfig.dest?.type === 'local' ? (downConfig.dest as { root: string }).root : ''\n assertBucket(bucket, 'download')\n\n return new DownloadAction(source.relativePath, source.size, async (relPath) => {\n const result = await bucket.download(source.selectedVersion.fileName)\n const reader = result.body.getReader()\n let combined: Uint8Array\n try {\n const chunks: Uint8Array[] = []\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n chunks.push(value)\n }\n let total = 0\n for (const c of chunks) total += c.byteLength\n combined = new Uint8Array(total)\n let offset = 0\n for (const c of chunks) {\n combined.set(c, offset)\n offset += c.byteLength\n }\n } finally {\n // Release the body stream's reader lock so a downstream\n // writeFile failure doesn't strand the response stream half-\n // open with the upstream HTTP connection still pumping.\n reader.releaseLock()\n }\n\n const { mkdir, writeFile } = await import('node:fs/promises')\n const { dirname, join } = await import('node:path')\n const destPath = join(root, relPath)\n await mkdir(dirname(destPath), { recursive: true })\n await writeFile(destPath, combined)\n })\n },\n\n copy(source: B2SyncPath, destPath: string): SyncAction {\n const bucket = upConfig.bucket\n assertBucket(bucket, 'copy')\n\n return new CopyAction(source.relativePath, source.size, async () => {\n await bucket.copyFile({\n sourceFileId: source.selectedVersion.fileId,\n fileName: destPath,\n })\n })\n },\n\n hide(path: string): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'hide')\n\n return new HideAction(path, async (relPath) => {\n const prefix = upConfig.prefix ?? ''\n await bucket.hideFile(`${prefix}${relPath}`)\n })\n },\n\n deleteRemote(path: B2SyncPath): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'delete')\n\n // Bug fix: `DeleteRemoteAction` invokes the closure with\n // `relativePath` (the scanner-stripped name relative to the sync\n // prefix), but B2 stores files under the FULL name including the\n // prefix. Use the FileVersion's authoritative `fileName` — the\n // actual B2 key — rather than reconstructing it via prefix\n // concat. Without this, syncs with a non-empty destination\n // prefix (e.g. `'site/'`) failed orphan deletion with\n // `file_not_present`.\n const b2FileName = path.selectedVersion.fileName\n return new DeleteRemoteAction(\n path.relativePath,\n path.selectedVersion.fileId as string,\n async (fileId) => {\n await bucket.deleteFileVersion(b2FileName, fileIdOf(fileId))\n },\n )\n },\n\n deleteLocal(path: LocalSyncPath): SyncAction {\n return new DeleteLocalAction(path.relativePath, path.absolutePath, async (absPath) => {\n const { unlink } = await import('node:fs/promises')\n await unlink(absPath)\n })\n },\n\n removeOrphan(dest: B2SyncPath): SyncAction {\n // Locked buckets: `b2_delete_file_version` is blocked or stacks\n // hide markers under retention; a hide is the safe choice.\n // Vanilla buckets: plain delete is the right move — hide markers\n // would just litter the version history.\n return bucketIsLocked ? factory.hide(dest.relativePath) : factory.deleteRemote(dest)\n },\n }\n\n return factory\n}\n"],"names":["fileId","fileIdOf"],"mappings":";;;;;;;;AAkFA,SAAS,iBAAiB,QAAoB,MAAiC;AAC7E,MAAI,OAAO,SAAS,WAAW,KAAK,SAAS,KAAM,QAAO;AAC1D,MAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,QAAS,QAAO;AAC1D,MAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,KAAM,QAAO;AACvD,QAAM,IAAI,MAAM,+BAA+B,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE;AAC9E;AASA,gBAAuB,YAAY,QAAuD;AACxF,QAAM,EAAE,QAAQ,MAAM,QAAA,IAA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AC7C,mBAAa,QAAQ,QAAQ;AAU7B,YAAM,aAAa,KAAK,gBAAgB;AACxC,aAAO,IAAI;AAAA,QACT,KAAK;AAAA,QACL,KAAK,gBAAgB;AAAA,QACrB,OAAOA,aAAW;AAChB,gBAAM,OAAO,kBAAkB,YAAYC,OAASD,QAAM,CAAC;AAAA,QAC7D;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,YAAY,MAAiC;AAC3C,aAAO,IAAI,kBAAkB,KAAK,cAAc,KAAK,cAAc,OAAO,YAAY;AACpF,cAAM,EAAE,OAAA,IAAW,MAAM,OAAO,kBAAkB;AAClD,cAAM,OAAO,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAAA,IAEA,aAAa,MAA8B;AAKzC,aAAO,iBAAiB,QAAQ,KAAK,KAAK,YAAY,IAAI,QAAQ,aAAa,IAAI;AAAA,IACrF;AAAA,EAAA;AAGF,SAAO;AACT;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { EncryptionSetting } from '../types/encryption.js';
|
|
2
|
+
import { FileVersion } from '../types/file.js';
|
|
3
|
+
/** Strategy for comparing source and destination files: by modification time, size, or skip comparison. */
|
|
4
|
+
export type CompareMode = 'modtime' | 'size' | 'none';
|
|
5
|
+
/** Strategy for handling destination files not present in the source. */
|
|
6
|
+
export type KeepMode = 'no-delete' | 'delete' | 'keep-days';
|
|
7
|
+
/** Direction of a sync operation. */
|
|
8
|
+
export type SyncDirection = 'local-to-b2' | 'b2-to-local' | 'b2-to-b2';
|
|
9
|
+
/** Common metadata for a file discovered during a folder scan. */
|
|
10
|
+
export interface SyncPath {
|
|
11
|
+
/** Path relative to the sync folder root, using forward slashes. */
|
|
12
|
+
readonly relativePath: string;
|
|
13
|
+
/** Last modification time in milliseconds since epoch. */
|
|
14
|
+
readonly modTimeMillis: number;
|
|
15
|
+
/** File size in bytes. */
|
|
16
|
+
readonly size: number;
|
|
17
|
+
}
|
|
18
|
+
/** A file on the local filesystem discovered during a scan. */
|
|
19
|
+
export interface LocalSyncPath extends SyncPath {
|
|
20
|
+
/** Absolute filesystem path to the file. */
|
|
21
|
+
readonly absolutePath: string;
|
|
22
|
+
}
|
|
23
|
+
/** A file in a B2 bucket discovered during a scan. */
|
|
24
|
+
export interface B2SyncPath extends SyncPath {
|
|
25
|
+
/** The most recent visible file version. */
|
|
26
|
+
readonly selectedVersion: FileVersion;
|
|
27
|
+
/** All versions of this file, sorted newest first. */
|
|
28
|
+
readonly allVersions: FileVersion[];
|
|
29
|
+
}
|
|
30
|
+
/** Discriminated event types emitted during synchronization. */
|
|
31
|
+
export type SyncEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local' | 'skip' | 'error' | 'compare';
|
|
32
|
+
/**
|
|
33
|
+
* Action event types: per-file outcomes (transfer / metadata change /
|
|
34
|
+
* skip) that always carry a `path` and a `size`. These never carry a
|
|
35
|
+
* `message` because the type tag already says what happened.
|
|
36
|
+
*/
|
|
37
|
+
export type SyncActionEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local' | 'compare';
|
|
38
|
+
/**
|
|
39
|
+
* Per-action progress event (transfer, metadata change, comparison). All
|
|
40
|
+
* action-event variants share the same shape; the `type` tag distinguishes
|
|
41
|
+
* them.
|
|
42
|
+
*/
|
|
43
|
+
export interface SyncActionEvent {
|
|
44
|
+
/** Discriminant tag identifying which action this event reports. */
|
|
45
|
+
readonly type: SyncActionEventType;
|
|
46
|
+
/** Relative path of the file this event concerns. */
|
|
47
|
+
readonly path: string;
|
|
48
|
+
/** Size in bytes of the file involved, or 0 for metadata-only events. */
|
|
49
|
+
readonly size: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `skip` event — a destination-only file that policy decided to keep, or
|
|
53
|
+
* a same-on-both file that didn't need transfer. Always carries a
|
|
54
|
+
* non-empty `message` explaining why.
|
|
55
|
+
*/
|
|
56
|
+
export interface SyncSkipEvent {
|
|
57
|
+
/** Discriminant tag (always the literal string `'skip'`). */
|
|
58
|
+
readonly type: 'skip';
|
|
59
|
+
/** Relative path of the skipped file. */
|
|
60
|
+
readonly path: string;
|
|
61
|
+
/** Size in bytes of the file involved, always 0 for skip events. */
|
|
62
|
+
readonly size: number;
|
|
63
|
+
/** Human-readable reason for skipping this file. */
|
|
64
|
+
readonly message: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `error` event — an action threw or the engine encountered a fatal
|
|
68
|
+
* condition. Always carries a non-empty `message` describing the failure
|
|
69
|
+
* so consumers don't need a `message ?? 'unknown'` fallback.
|
|
70
|
+
*/
|
|
71
|
+
export interface SyncErrorEvent {
|
|
72
|
+
/** Discriminant tag (always the literal string `'error'`). */
|
|
73
|
+
readonly type: 'error';
|
|
74
|
+
/** Relative path of the file the failed action targeted, or `''` for engine-level errors. */
|
|
75
|
+
readonly path: string;
|
|
76
|
+
/** Size in bytes; always 0 for error events. */
|
|
77
|
+
readonly size: number;
|
|
78
|
+
/** Human-readable error message; never empty. */
|
|
79
|
+
readonly message: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* An event emitted by the sync engine to report progress, skip
|
|
83
|
+
* decisions, or errors. Discriminated by `type`: consumers can
|
|
84
|
+
* `case 'error':` (or `'skip':`) to narrow into a variant with `message`
|
|
85
|
+
* guaranteed non-optional.
|
|
86
|
+
*/
|
|
87
|
+
export type SyncEvent = SyncActionEvent | SyncSkipEvent | SyncErrorEvent;
|
|
88
|
+
/** Configuration options for a sync operation. */
|
|
89
|
+
export interface SyncOptions {
|
|
90
|
+
/** How to decide whether two files differ. */
|
|
91
|
+
readonly compareMode: CompareMode;
|
|
92
|
+
/** What to do with destination files absent from the source. */
|
|
93
|
+
readonly keepMode: KeepMode;
|
|
94
|
+
/** Number of days to retain orphaned destination files when keepMode is 'keep-days'. */
|
|
95
|
+
readonly keepDays?: number;
|
|
96
|
+
/** Maximum number of concurrent transfer actions. Defaults to 4. */
|
|
97
|
+
readonly concurrency?: number;
|
|
98
|
+
/** When true, actions are generated but not executed. */
|
|
99
|
+
readonly dryRun?: boolean;
|
|
100
|
+
/** Tolerance for comparison (bytes for size, milliseconds for modtime). */
|
|
101
|
+
readonly compareThreshold?: number;
|
|
102
|
+
/** Signal to abort the sync operation. */
|
|
103
|
+
readonly signal?: AbortSignal;
|
|
104
|
+
/** Optional provider for per-file encryption settings. */
|
|
105
|
+
readonly encryptionProvider?: SyncEncryptionProvider;
|
|
106
|
+
}
|
|
107
|
+
/** Supplies encryption settings on a per-file basis during sync. */
|
|
108
|
+
export interface SyncEncryptionProvider {
|
|
109
|
+
/** Returns the encryption setting to use when uploading a file, or undefined for default. */
|
|
110
|
+
getSettingForUpload(fileName: string, size: number): EncryptionSetting | undefined;
|
|
111
|
+
/** Returns the encryption setting to use when downloading a file, or undefined for default. */
|
|
112
|
+
getSettingForDownload(fileVersion: FileVersion): EncryptionSetting | undefined;
|
|
113
|
+
}
|
|
114
|
+
/** A scannable folder (local or B2) that yields files in sorted order. */
|
|
115
|
+
export interface SyncFolder {
|
|
116
|
+
/** Whether this folder is local or in B2. */
|
|
117
|
+
readonly type: 'local' | 'b2';
|
|
118
|
+
/** Scans the folder and yields files sorted by relative path. */
|
|
119
|
+
scan(): AsyncIterable<SyncPath>;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,2GAA2G;AAC3G,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;AAErD,yEAAyE;AACzE,MAAM,M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B;IACrC,6FAA6F;IAC7F,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAA;IAClF,+FAA+F;IAC/F,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,iBAAiB,GAAG,SAAS,CAAA;CAC/E;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B,iEAAiE;IACjE,IAAI,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;CAChC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { EncryptionSetting } from '../types/encryption.js';
|
|
2
|
+
import { FileVersion } from '../types/file.js';
|
|
3
|
+
/** Strategy for comparing source and destination files: by modification time, size, or skip comparison. */
|
|
4
|
+
export type CompareMode = 'modtime' | 'size' | 'none';
|
|
5
|
+
/** Strategy for handling destination files not present in the source. */
|
|
6
|
+
export type KeepMode = 'no-delete' | 'delete' | 'keep-days';
|
|
7
|
+
/** Direction of a sync operation. */
|
|
8
|
+
export type SyncDirection = 'local-to-b2' | 'b2-to-local' | 'b2-to-b2';
|
|
9
|
+
/** Common metadata for a file discovered during a folder scan. */
|
|
10
|
+
export interface SyncPath {
|
|
11
|
+
/** Path relative to the sync folder root, using forward slashes. */
|
|
12
|
+
readonly relativePath: string;
|
|
13
|
+
/** Last modification time in milliseconds since epoch. */
|
|
14
|
+
readonly modTimeMillis: number;
|
|
15
|
+
/** File size in bytes. */
|
|
16
|
+
readonly size: number;
|
|
17
|
+
}
|
|
18
|
+
/** A file on the local filesystem discovered during a scan. */
|
|
19
|
+
export interface LocalSyncPath extends SyncPath {
|
|
20
|
+
/** Absolute filesystem path to the file. */
|
|
21
|
+
readonly absolutePath: string;
|
|
22
|
+
}
|
|
23
|
+
/** A file in a B2 bucket discovered during a scan. */
|
|
24
|
+
export interface B2SyncPath extends SyncPath {
|
|
25
|
+
/** The most recent visible file version. */
|
|
26
|
+
readonly selectedVersion: FileVersion;
|
|
27
|
+
/** All versions of this file, sorted newest first. */
|
|
28
|
+
readonly allVersions: FileVersion[];
|
|
29
|
+
}
|
|
30
|
+
/** Discriminated event types emitted during synchronization. */
|
|
31
|
+
export type SyncEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local' | 'skip' | 'error' | 'compare';
|
|
32
|
+
/**
|
|
33
|
+
* Action event types: per-file outcomes (transfer / metadata change /
|
|
34
|
+
* skip) that always carry a `path` and a `size`. These never carry a
|
|
35
|
+
* `message` because the type tag already says what happened.
|
|
36
|
+
*/
|
|
37
|
+
export type SyncActionEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local' | 'compare';
|
|
38
|
+
/**
|
|
39
|
+
* Per-action progress event (transfer, metadata change, comparison). All
|
|
40
|
+
* action-event variants share the same shape; the `type` tag distinguishes
|
|
41
|
+
* them.
|
|
42
|
+
*/
|
|
43
|
+
export interface SyncActionEvent {
|
|
44
|
+
/** Discriminant tag identifying which action this event reports. */
|
|
45
|
+
readonly type: SyncActionEventType;
|
|
46
|
+
/** Relative path of the file this event concerns. */
|
|
47
|
+
readonly path: string;
|
|
48
|
+
/** Size in bytes of the file involved, or 0 for metadata-only events. */
|
|
49
|
+
readonly size: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `skip` event — a destination-only file that policy decided to keep, or
|
|
53
|
+
* a same-on-both file that didn't need transfer. Always carries a
|
|
54
|
+
* non-empty `message` explaining why.
|
|
55
|
+
*/
|
|
56
|
+
export interface SyncSkipEvent {
|
|
57
|
+
/** Discriminant tag (always the literal string `'skip'`). */
|
|
58
|
+
readonly type: 'skip';
|
|
59
|
+
/** Relative path of the skipped file. */
|
|
60
|
+
readonly path: string;
|
|
61
|
+
/** Size in bytes of the file involved, always 0 for skip events. */
|
|
62
|
+
readonly size: number;
|
|
63
|
+
/** Human-readable reason for skipping this file. */
|
|
64
|
+
readonly message: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `error` event — an action threw or the engine encountered a fatal
|
|
68
|
+
* condition. Always carries a non-empty `message` describing the failure
|
|
69
|
+
* so consumers don't need a `message ?? 'unknown'` fallback.
|
|
70
|
+
*/
|
|
71
|
+
export interface SyncErrorEvent {
|
|
72
|
+
/** Discriminant tag (always the literal string `'error'`). */
|
|
73
|
+
readonly type: 'error';
|
|
74
|
+
/** Relative path of the file the failed action targeted, or `''` for engine-level errors. */
|
|
75
|
+
readonly path: string;
|
|
76
|
+
/** Size in bytes; always 0 for error events. */
|
|
77
|
+
readonly size: number;
|
|
78
|
+
/** Human-readable error message; never empty. */
|
|
79
|
+
readonly message: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* An event emitted by the sync engine to report progress, skip
|
|
83
|
+
* decisions, or errors. Discriminated by `type`: consumers can
|
|
84
|
+
* `case 'error':` (or `'skip':`) to narrow into a variant with `message`
|
|
85
|
+
* guaranteed non-optional.
|
|
86
|
+
*/
|
|
87
|
+
export type SyncEvent = SyncActionEvent | SyncSkipEvent | SyncErrorEvent;
|
|
88
|
+
/** Configuration options for a sync operation. */
|
|
89
|
+
export interface SyncOptions {
|
|
90
|
+
/** How to decide whether two files differ. */
|
|
91
|
+
readonly compareMode: CompareMode;
|
|
92
|
+
/** What to do with destination files absent from the source. */
|
|
93
|
+
readonly keepMode: KeepMode;
|
|
94
|
+
/** Number of days to retain orphaned destination files when keepMode is 'keep-days'. */
|
|
95
|
+
readonly keepDays?: number;
|
|
96
|
+
/** Maximum number of concurrent transfer actions. Defaults to 4. */
|
|
97
|
+
readonly concurrency?: number;
|
|
98
|
+
/** When true, actions are generated but not executed. */
|
|
99
|
+
readonly dryRun?: boolean;
|
|
100
|
+
/** Tolerance for comparison (bytes for size, milliseconds for modtime). */
|
|
101
|
+
readonly compareThreshold?: number;
|
|
102
|
+
/** Signal to abort the sync operation. */
|
|
103
|
+
readonly signal?: AbortSignal;
|
|
104
|
+
/** Optional provider for per-file encryption settings. */
|
|
105
|
+
readonly encryptionProvider?: SyncEncryptionProvider;
|
|
106
|
+
}
|
|
107
|
+
/** Supplies encryption settings on a per-file basis during sync. */
|
|
108
|
+
export interface SyncEncryptionProvider {
|
|
109
|
+
/** Returns the encryption setting to use when uploading a file, or undefined for default. */
|
|
110
|
+
getSettingForUpload(fileName: string, size: number): EncryptionSetting | undefined;
|
|
111
|
+
/** Returns the encryption setting to use when downloading a file, or undefined for default. */
|
|
112
|
+
getSettingForDownload(fileVersion: FileVersion): EncryptionSetting | undefined;
|
|
113
|
+
}
|
|
114
|
+
/** A scannable folder (local or B2) that yields files in sorted order. */
|
|
115
|
+
export interface SyncFolder {
|
|
116
|
+
/** Whether this folder is local or in B2. */
|
|
117
|
+
readonly type: 'local' | 'b2';
|
|
118
|
+
/** Scans the folder and yields files sorted by relative path. */
|
|
119
|
+
scan(): AsyncIterable<SyncPath>;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,2GAA2G;AAC3G,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;AAErD,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE3D,qCAAqC;AACrC,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,CAAA;AAEtE,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACv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,GAAG,SAAS,CAAA;CAC/E;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B,iEAAiE;IACjE,IAAI,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;CAChC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Capability = {
|
|
4
|
+
/** List application keys. */
|
|
5
|
+
ListKeys: "listKeys",
|
|
6
|
+
/** Create new application keys. */
|
|
7
|
+
WriteKeys: "writeKeys",
|
|
8
|
+
/** Delete application keys. */
|
|
9
|
+
DeleteKeys: "deleteKeys",
|
|
10
|
+
/** List buckets (subject to key restrictions). */
|
|
11
|
+
ListBuckets: "listBuckets",
|
|
12
|
+
/** List bucket names without other metadata. */
|
|
13
|
+
ListAllBucketNames: "listAllBucketNames",
|
|
14
|
+
/** Read bucket settings. */
|
|
15
|
+
ReadBuckets: "readBuckets",
|
|
16
|
+
/** Create and update buckets. */
|
|
17
|
+
WriteBuckets: "writeBuckets",
|
|
18
|
+
/** Remove existing buckets from the account. */
|
|
19
|
+
DeleteBuckets: "deleteBuckets",
|
|
20
|
+
/** Read bucket-level Object Lock retention settings. */
|
|
21
|
+
ReadBucketRetentions: "readBucketRetentions",
|
|
22
|
+
/** Modify bucket-level Object Lock retention settings. */
|
|
23
|
+
WriteBucketRetentions: "writeBucketRetentions",
|
|
24
|
+
/** Read default bucket encryption settings. */
|
|
25
|
+
ReadBucketEncryption: "readBucketEncryption",
|
|
26
|
+
/** Modify default bucket encryption settings. */
|
|
27
|
+
WriteBucketEncryption: "writeBucketEncryption",
|
|
28
|
+
/** Read bucket replication configuration. */
|
|
29
|
+
ReadBucketReplications: "readBucketReplications",
|
|
30
|
+
/** Modify bucket replication configuration. */
|
|
31
|
+
WriteBucketReplications: "writeBucketReplications",
|
|
32
|
+
/** Read bucket event-notification rules. */
|
|
33
|
+
ReadBucketNotifications: "readBucketNotifications",
|
|
34
|
+
/** Modify bucket event-notification rules. */
|
|
35
|
+
WriteBucketNotifications: "writeBucketNotifications",
|
|
36
|
+
/** List file names and versions. */
|
|
37
|
+
ListFiles: "listFiles",
|
|
38
|
+
/** Download files. */
|
|
39
|
+
ReadFiles: "readFiles",
|
|
40
|
+
/** Mint download authorisation tokens. */
|
|
41
|
+
ShareFiles: "shareFiles",
|
|
42
|
+
/** Upload files. */
|
|
43
|
+
WriteFiles: "writeFiles",
|
|
44
|
+
/** Delete file versions. */
|
|
45
|
+
DeleteFiles: "deleteFiles",
|
|
46
|
+
/** Read per-file legal hold flags. */
|
|
47
|
+
ReadFileLegalHolds: "readFileLegalHolds",
|
|
48
|
+
/** Modify per-file legal hold flags. */
|
|
49
|
+
WriteFileLegalHolds: "writeFileLegalHolds",
|
|
50
|
+
/** Read per-file Object Lock retention settings. */
|
|
51
|
+
ReadFileRetentions: "readFileRetentions",
|
|
52
|
+
/** Modify per-file Object Lock retention settings. */
|
|
53
|
+
WriteFileRetentions: "writeFileRetentions",
|
|
54
|
+
/** Shorten governance-mode retention. */
|
|
55
|
+
BypassGovernance: "bypassGovernance"
|
|
56
|
+
};
|
|
57
|
+
exports.Capability = Capability;
|
|
58
|
+
//# sourceMappingURL=auth.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.cjs","sources":["../../src/types/auth.ts"],"sourcesContent":["import type { AccountId, AuthToken, BucketId } from './ids.ts'\n\n/**\n * Named constants for the B2 API capabilities that can be granted to an\n * application key. Each capability controls access to a specific set of\n * API operations.\n *\n * Use these when constructing the `capabilities` array for an application\n * key request, or when checking required capabilities via\n * `B2Client.hasCapabilities`.\n *\n * @example\n * ```ts\n * const check = client.hasCapabilities([Capability.WriteFiles, Capability.ReadFiles])\n * if (!check.ok) throw new Error(`missing: ${check.missing.join(', ')}`)\n * ```\n */\nexport const Capability = {\n /** List application keys. */\n ListKeys: 'listKeys',\n /** Create new application keys. */\n WriteKeys: 'writeKeys',\n /** Delete application keys. */\n DeleteKeys: 'deleteKeys',\n /** List buckets (subject to key restrictions). */\n ListBuckets: 'listBuckets',\n /** List bucket names without other metadata. */\n ListAllBucketNames: 'listAllBucketNames',\n /** Read bucket settings. */\n ReadBuckets: 'readBuckets',\n /** Create and update buckets. */\n WriteBuckets: 'writeBuckets',\n /** Remove existing buckets from the account. */\n DeleteBuckets: 'deleteBuckets',\n /** Read bucket-level Object Lock retention settings. */\n ReadBucketRetentions: 'readBucketRetentions',\n /** Modify bucket-level Object Lock retention settings. */\n WriteBucketRetentions: 'writeBucketRetentions',\n /** Read default bucket encryption settings. */\n ReadBucketEncryption: 'readBucketEncryption',\n /** Modify default bucket encryption settings. */\n WriteBucketEncryption: 'writeBucketEncryption',\n /** Read bucket replication configuration. */\n ReadBucketReplications: 'readBucketReplications',\n /** Modify bucket replication configuration. */\n WriteBucketReplications: 'writeBucketReplications',\n /** Read bucket event-notification rules. */\n ReadBucketNotifications: 'readBucketNotifications',\n /** Modify bucket event-notification rules. */\n WriteBucketNotifications: 'writeBucketNotifications',\n /** List file names and versions. */\n ListFiles: 'listFiles',\n /** Download files. */\n ReadFiles: 'readFiles',\n /** Mint download authorisation tokens. */\n ShareFiles: 'shareFiles',\n /** Upload files. */\n WriteFiles: 'writeFiles',\n /** Delete file versions. */\n DeleteFiles: 'deleteFiles',\n /** Read per-file legal hold flags. */\n ReadFileLegalHolds: 'readFileLegalHolds',\n /** Modify per-file legal hold flags. */\n WriteFileLegalHolds: 'writeFileLegalHolds',\n /** Read per-file Object Lock retention settings. */\n ReadFileRetentions: 'readFileRetentions',\n /** Modify per-file Object Lock retention settings. */\n WriteFileRetentions: 'writeFileRetentions',\n /** Shorten governance-mode retention. */\n BypassGovernance: 'bypassGovernance',\n} as const\n\n/**\n * A B2 API capability that can be granted to an application key. Derived\n * from {@link Capability}.\n */\nexport type Capability = (typeof Capability)[keyof typeof Capability]\n\n/** Describes the capabilities and scope restrictions of an authorized application key. */\nexport interface AllowedInfo {\n /** List of capabilities granted to this key. */\n readonly capabilities: readonly Capability[]\n /** Bucket ID this key is restricted to, or null if unrestricted. */\n readonly bucketId: BucketId | null\n /** Bucket name this key is restricted to, or null if unrestricted. */\n readonly bucketName: string | null\n /** File name prefix this key is restricted to, or null if unrestricted. */\n readonly namePrefix: string | null\n}\n\n/** Configuration for the B2 Cloud Storage API returned during authorization. */\nexport interface StorageApiInfo {\n /** Minimum allowed part size for large file uploads, in bytes. */\n readonly absoluteMinimumPartSize: number\n /** Base URL for B2 API calls. */\n readonly apiUrl: string\n /** Bucket ID this key is restricted to, or null if unrestricted. */\n readonly bucketId: BucketId | null\n /** Bucket name this key is restricted to, or null if unrestricted. */\n readonly bucketName: string | null\n /** Base URL for file downloads. */\n readonly downloadUrl: string\n /** Discriminator indicating this is storage API info. Always `'storageApi'`. */\n readonly infoType: 'storageApi'\n /** File name prefix this key is restricted to, or null if unrestricted. */\n readonly namePrefix: string | null\n /** Recommended part size for large file uploads, in bytes. */\n readonly recommendedPartSize: number\n /** Base URL for the S3-compatible API. */\n readonly s3ApiUrl: string\n /** Capabilities and scope of the authorized key. */\n readonly allowed: AllowedInfo\n}\n\n/** Configuration for the B2 Groups API returned during authorization. */\nexport interface GroupsApiInfo {\n /** Base URL for Groups API calls. */\n readonly groupsApiUrl: string\n /** Discriminator indicating this is groups API info. Always `'groupsApi'`. */\n readonly infoType: 'groupsApi'\n}\n\n/** Container for all API-specific configuration returned by `b2_authorize_account`. */\nexport interface ApiInfo {\n /** Storage API configuration (always present). */\n readonly storageApi: StorageApiInfo\n /** Groups API configuration (present only when the account has groups enabled). */\n readonly groupsApi?: GroupsApiInfo\n}\n\n/**\n * Response from the `b2_authorize_account` API call.\n * Contains the authorization token and API endpoint URLs needed for subsequent requests.\n */\nexport interface AuthorizeAccountResponse {\n /** The account ID for the authorized account. */\n readonly accountId: AccountId\n /** Authorization token to use in subsequent API calls. */\n readonly authorizationToken: AuthToken\n /** API-specific configuration including endpoint URLs and key scope. */\n readonly apiInfo: ApiInfo\n /** Expiration timestamp of the application key in milliseconds, or null if the key does not expire. */\n readonly applicationKeyExpirationTimestamp: number | null\n}\n\n/**\n * Request parameters for the `b2_authorize_account` API call.\n * Credentials are sent via HTTP Basic auth in the raw API, but represented here as fields.\n */\nexport interface AuthorizeAccountRequest {\n /** The application key ID (account ID or app key ID). */\n readonly applicationKeyId: string\n /** The application key secret. */\n readonly applicationKey: string\n /** Optional realm override (e.g., `'production'`, `'staging'`). Defaults to production. */\n readonly realm?: string\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,aAAa;AAAA;AAAA,EAExB,UAAU;AAAA;AAAA,EAEV,WAAW;AAAA;AAAA,EAEX,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,oBAAoB;AAAA;AAAA,EAEpB,aAAa;AAAA;AAAA,EAEb,cAAc;AAAA;AAAA,EAEd,eAAe;AAAA;AAAA,EAEf,sBAAsB;AAAA;AAAA,EAEtB,uBAAuB;AAAA;AAAA,EAEvB,sBAAsB;AAAA;AAAA,EAEtB,uBAAuB;AAAA;AAAA,EAEvB,wBAAwB;AAAA;AAAA,EAExB,yBAAyB;AAAA;AAAA,EAEzB,yBAAyB;AAAA;AAAA,EAEzB,0BAA0B;AAAA;AAAA,EAE1B,WAAW;AAAA;AAAA,EAEX,WAAW;AAAA;AAAA,EAEX,YAAY;AAAA;AAAA,EAEZ,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,oBAAoB;AAAA;AAAA,EAEpB,qBAAqB;AAAA;AAAA,EAErB,oBAAoB;AAAA;AAAA,EAEpB,qBAAqB;AAAA;AAAA,EAErB,kBAAkB;AACpB;;"}
|