@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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync engine for mirroring files between local folders and B2 buckets.
|
|
3
|
+
*
|
|
4
|
+
* The pipeline is: scan folders, pair files by relative path, generate actions
|
|
5
|
+
* based on comparison and keep policies, then execute with bounded concurrency.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { LocalFolder } from './scanners/local.js';
|
|
10
|
+
export { B2Folder } from './scanners/b2.js';
|
|
11
|
+
export { zipFolders } from './pairing.js';
|
|
12
|
+
export { generateActions } from './policies/index.js';
|
|
13
|
+
export { filesAreDifferent } from './policies/compare.js';
|
|
14
|
+
export { synchronize } from './synchronizer.js';
|
|
15
|
+
export type { SyncAction, SyncActionType, } from './actions/index.js';
|
|
16
|
+
export { UploadAction, DownloadAction, CopyAction, HideAction, DeleteRemoteAction, DeleteLocalAction, SkipAction, } from './actions/index.js';
|
|
17
|
+
export type { CompareMode, KeepMode, SyncDirection, SyncPath, LocalSyncPath, B2SyncPath, SyncEvent, SyncEventType, SyncActionEvent, SyncActionEventType, SyncSkipEvent, SyncErrorEvent, SyncOptions, SyncEncryptionProvider, SyncFolder, } from './types.js';
|
|
18
|
+
export type { ActionFactory } from './policies/index.js';
|
|
19
|
+
export type { SyncPair } from './pairing.js';
|
|
20
|
+
export type { SynchronizerConfig, SynchronizerUpConfig, SynchronizerDownConfig, LocalSyncFolder, B2SyncFolder, } from './synchronizer.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EACV,UAAU,EACV,cAAc,GACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,aAAa,EACb,UAAU,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,UAAU,GACX,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,YAAY,GACb,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LocalFolder } from "./scanners/local.js";
|
|
2
|
+
import { B2Folder } from "./scanners/b2.js";
|
|
3
|
+
import { zipFolders } from "./pairing.js";
|
|
4
|
+
import { generateActions } from "./policies/index.js";
|
|
5
|
+
import { filesAreDifferent } from "./policies/compare.js";
|
|
6
|
+
import { synchronize } from "./synchronizer.js";
|
|
7
|
+
import { CopyAction, DeleteLocalAction, DeleteRemoteAction, DownloadAction, HideAction, SkipAction, UploadAction } from "./actions/index.js";
|
|
8
|
+
export {
|
|
9
|
+
B2Folder,
|
|
10
|
+
CopyAction,
|
|
11
|
+
DeleteLocalAction,
|
|
12
|
+
DeleteRemoteAction,
|
|
13
|
+
DownloadAction,
|
|
14
|
+
HideAction,
|
|
15
|
+
LocalFolder,
|
|
16
|
+
SkipAction,
|
|
17
|
+
UploadAction,
|
|
18
|
+
filesAreDifferent,
|
|
19
|
+
generateActions,
|
|
20
|
+
synchronize,
|
|
21
|
+
zipFolders
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
async function* zipFolders(source, dest) {
|
|
4
|
+
const sourceIter = source.scan()[Symbol.asyncIterator]();
|
|
5
|
+
const destIter = dest.scan()[Symbol.asyncIterator]();
|
|
6
|
+
let sourceResult = await sourceIter.next();
|
|
7
|
+
let destResult = await destIter.next();
|
|
8
|
+
while (!sourceResult.done || !destResult.done) {
|
|
9
|
+
const s = sourceResult.done ? null : sourceResult.value;
|
|
10
|
+
const d = destResult.done ? null : destResult.value;
|
|
11
|
+
if (s === null) {
|
|
12
|
+
yield [null, d];
|
|
13
|
+
destResult = await destIter.next();
|
|
14
|
+
} else if (d === null) {
|
|
15
|
+
yield [s, null];
|
|
16
|
+
sourceResult = await sourceIter.next();
|
|
17
|
+
} else if (s.relativePath < d.relativePath) {
|
|
18
|
+
yield [s, null];
|
|
19
|
+
sourceResult = await sourceIter.next();
|
|
20
|
+
} else if (d.relativePath < s.relativePath) {
|
|
21
|
+
yield [null, d];
|
|
22
|
+
destResult = await destIter.next();
|
|
23
|
+
} else {
|
|
24
|
+
yield [s, d];
|
|
25
|
+
sourceResult = await sourceIter.next();
|
|
26
|
+
destResult = await destIter.next();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.zipFolders = zipFolders;
|
|
31
|
+
//# sourceMappingURL=pairing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.cjs","sources":["../../src/sync/pairing.ts"],"sourcesContent":["import type { SyncFolder, SyncPath } from './types.ts'\n\n/** A paired tuple of source and destination files. Either side may be null if the file is absent. */\nexport type SyncPair = readonly [SyncPath | null, SyncPath | null]\n\n/**\n * Merge-joins two sorted folder scans by relative path, yielding paired tuples.\n * Files present only in source yield `[source, null]`, only in dest yield `[null, dest]`,\n * and files in both yield `[source, dest]`.\n *\n * @param source - The source folder to scan.\n * @param dest - The destination folder to scan.\n */\nexport async function* zipFolders(source: SyncFolder, dest: SyncFolder): AsyncGenerator<SyncPair> {\n const sourceIter = source.scan()[Symbol.asyncIterator]()\n const destIter = dest.scan()[Symbol.asyncIterator]()\n\n let sourceResult = await sourceIter.next()\n let destResult = await destIter.next()\n\n while (!sourceResult.done || !destResult.done) {\n const s = sourceResult.done ? null : sourceResult.value\n const d = destResult.done ? null : destResult.value\n\n if (s === null) {\n yield [null, d]\n destResult = await destIter.next()\n } else if (d === null) {\n yield [s, null]\n sourceResult = await sourceIter.next()\n } else if (s.relativePath < d.relativePath) {\n yield [s, null]\n sourceResult = await sourceIter.next()\n } else if (d.relativePath < s.relativePath) {\n yield [null, d]\n destResult = await destIter.next()\n } else {\n yield [s, d]\n sourceResult = await sourceIter.next()\n destResult = await destIter.next()\n }\n }\n}\n"],"names":[],"mappings":";;AAaA,gBAAuB,WAAW,QAAoB,MAA4C;AAChG,QAAM,aAAa,OAAO,KAAA,EAAO,OAAO,aAAa,EAAA;AACrD,QAAM,WAAW,KAAK,KAAA,EAAO,OAAO,aAAa,EAAA;AAEjD,MAAI,eAAe,MAAM,WAAW,KAAA;AACpC,MAAI,aAAa,MAAM,SAAS,KAAA;AAEhC,SAAO,CAAC,aAAa,QAAQ,CAAC,WAAW,MAAM;AAC7C,UAAM,IAAI,aAAa,OAAO,OAAO,aAAa;AAClD,UAAM,IAAI,WAAW,OAAO,OAAO,WAAW;AAE9C,QAAI,MAAM,MAAM;AACd,YAAM,CAAC,MAAM,CAAC;AACd,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B,WAAW,MAAM,MAAM;AACrB,YAAM,CAAC,GAAG,IAAI;AACd,qBAAe,MAAM,WAAW,KAAA;AAAA,IAClC,WAAW,EAAE,eAAe,EAAE,cAAc;AAC1C,YAAM,CAAC,GAAG,IAAI;AACd,qBAAe,MAAM,WAAW,KAAA;AAAA,IAClC,WAAW,EAAE,eAAe,EAAE,cAAc;AAC1C,YAAM,CAAC,MAAM,CAAC;AACd,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B,OAAO;AACL,YAAM,CAAC,GAAG,CAAC;AACX,qBAAe,MAAM,WAAW,KAAA;AAChC,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B;AAAA,EACF;AACF;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyncFolder, SyncPath } from './types.js';
|
|
2
|
+
/** A paired tuple of source and destination files. Either side may be null if the file is absent. */
|
|
3
|
+
export type SyncPair = readonly [SyncPath | null, SyncPath | null];
|
|
4
|
+
/**
|
|
5
|
+
* Merge-joins two sorted folder scans by relative path, yielding paired tuples.
|
|
6
|
+
* Files present only in source yield `[source, null]`, only in dest yield `[null, dest]`,
|
|
7
|
+
* and files in both yield `[source, dest]`.
|
|
8
|
+
*
|
|
9
|
+
* @param source - The source folder to scan.
|
|
10
|
+
* @param dest - The destination folder to scan.
|
|
11
|
+
*/
|
|
12
|
+
export declare function zipFolders(source: SyncFolder, dest: SyncFolder): AsyncGenerator<SyncPair>;
|
|
13
|
+
//# sourceMappingURL=pairing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../../src/sync/pairing.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEtD,qGAAqG;AACrG,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAA;AAElE;;;;;;;GAOG;AACH,wBAAuB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CA6BhG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyncFolder, SyncPath } from './types.js';
|
|
2
|
+
/** A paired tuple of source and destination files. Either side may be null if the file is absent. */
|
|
3
|
+
export type SyncPair = readonly [SyncPath | null, SyncPath | null];
|
|
4
|
+
/**
|
|
5
|
+
* Merge-joins two sorted folder scans by relative path, yielding paired tuples.
|
|
6
|
+
* Files present only in source yield `[source, null]`, only in dest yield `[null, dest]`,
|
|
7
|
+
* and files in both yield `[source, dest]`.
|
|
8
|
+
*
|
|
9
|
+
* @param source - The source folder to scan.
|
|
10
|
+
* @param dest - The destination folder to scan.
|
|
11
|
+
*/
|
|
12
|
+
export declare function zipFolders(source: SyncFolder, dest: SyncFolder): AsyncGenerator<SyncPair>;
|
|
13
|
+
//# sourceMappingURL=pairing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../../src/sync/pairing.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEtD,qGAAqG;AACrG,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAA;AAElE;;;;;;;GAOG;AACH,wBAAuB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CA6BhG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
async function* zipFolders(source, dest) {
|
|
2
|
+
const sourceIter = source.scan()[Symbol.asyncIterator]();
|
|
3
|
+
const destIter = dest.scan()[Symbol.asyncIterator]();
|
|
4
|
+
let sourceResult = await sourceIter.next();
|
|
5
|
+
let destResult = await destIter.next();
|
|
6
|
+
while (!sourceResult.done || !destResult.done) {
|
|
7
|
+
const s = sourceResult.done ? null : sourceResult.value;
|
|
8
|
+
const d = destResult.done ? null : destResult.value;
|
|
9
|
+
if (s === null) {
|
|
10
|
+
yield [null, d];
|
|
11
|
+
destResult = await destIter.next();
|
|
12
|
+
} else if (d === null) {
|
|
13
|
+
yield [s, null];
|
|
14
|
+
sourceResult = await sourceIter.next();
|
|
15
|
+
} else if (s.relativePath < d.relativePath) {
|
|
16
|
+
yield [s, null];
|
|
17
|
+
sourceResult = await sourceIter.next();
|
|
18
|
+
} else if (d.relativePath < s.relativePath) {
|
|
19
|
+
yield [null, d];
|
|
20
|
+
destResult = await destIter.next();
|
|
21
|
+
} else {
|
|
22
|
+
yield [s, d];
|
|
23
|
+
sourceResult = await sourceIter.next();
|
|
24
|
+
destResult = await destIter.next();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
zipFolders
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=pairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.js","sources":["../../src/sync/pairing.ts"],"sourcesContent":["import type { SyncFolder, SyncPath } from './types.ts'\n\n/** A paired tuple of source and destination files. Either side may be null if the file is absent. */\nexport type SyncPair = readonly [SyncPath | null, SyncPath | null]\n\n/**\n * Merge-joins two sorted folder scans by relative path, yielding paired tuples.\n * Files present only in source yield `[source, null]`, only in dest yield `[null, dest]`,\n * and files in both yield `[source, dest]`.\n *\n * @param source - The source folder to scan.\n * @param dest - The destination folder to scan.\n */\nexport async function* zipFolders(source: SyncFolder, dest: SyncFolder): AsyncGenerator<SyncPair> {\n const sourceIter = source.scan()[Symbol.asyncIterator]()\n const destIter = dest.scan()[Symbol.asyncIterator]()\n\n let sourceResult = await sourceIter.next()\n let destResult = await destIter.next()\n\n while (!sourceResult.done || !destResult.done) {\n const s = sourceResult.done ? null : sourceResult.value\n const d = destResult.done ? null : destResult.value\n\n if (s === null) {\n yield [null, d]\n destResult = await destIter.next()\n } else if (d === null) {\n yield [s, null]\n sourceResult = await sourceIter.next()\n } else if (s.relativePath < d.relativePath) {\n yield [s, null]\n sourceResult = await sourceIter.next()\n } else if (d.relativePath < s.relativePath) {\n yield [null, d]\n destResult = await destIter.next()\n } else {\n yield [s, d]\n sourceResult = await sourceIter.next()\n destResult = await destIter.next()\n }\n }\n}\n"],"names":[],"mappings":"AAaA,gBAAuB,WAAW,QAAoB,MAA4C;AAChG,QAAM,aAAa,OAAO,KAAA,EAAO,OAAO,aAAa,EAAA;AACrD,QAAM,WAAW,KAAK,KAAA,EAAO,OAAO,aAAa,EAAA;AAEjD,MAAI,eAAe,MAAM,WAAW,KAAA;AACpC,MAAI,aAAa,MAAM,SAAS,KAAA;AAEhC,SAAO,CAAC,aAAa,QAAQ,CAAC,WAAW,MAAM;AAC7C,UAAM,IAAI,aAAa,OAAO,OAAO,aAAa;AAClD,UAAM,IAAI,WAAW,OAAO,OAAO,WAAW;AAE9C,QAAI,MAAM,MAAM;AACd,YAAM,CAAC,MAAM,CAAC;AACd,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B,WAAW,MAAM,MAAM;AACrB,YAAM,CAAC,GAAG,IAAI;AACd,qBAAe,MAAM,WAAW,KAAA;AAAA,IAClC,WAAW,EAAE,eAAe,EAAE,cAAc;AAC1C,YAAM,CAAC,GAAG,IAAI;AACd,qBAAe,MAAM,WAAW,KAAA;AAAA,IAClC,WAAW,EAAE,eAAe,EAAE,cAAc;AAC1C,YAAM,CAAC,MAAM,CAAC;AACd,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B,OAAO;AACL,YAAM,CAAC,GAAG,CAAC;AACX,qBAAe,MAAM,WAAW,KAAA;AAChC,mBAAa,MAAM,SAAS,KAAA;AAAA,IAC9B;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function filesAreDifferent(source, dest, compareMode, threshold = 0) {
|
|
4
|
+
switch (compareMode) {
|
|
5
|
+
case "none":
|
|
6
|
+
return false;
|
|
7
|
+
case "size":
|
|
8
|
+
return Math.abs(source.size - dest.size) > threshold;
|
|
9
|
+
case "modtime":
|
|
10
|
+
return Math.abs(source.modTimeMillis - dest.modTimeMillis) > threshold;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.filesAreDifferent = filesAreDifferent;
|
|
14
|
+
//# sourceMappingURL=compare.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.cjs","sources":["../../../src/sync/policies/compare.ts"],"sourcesContent":["import type { CompareMode, SyncPath } from '../types.ts'\n\n/**\n * Determines whether two files should be considered different based on the compare mode.\n *\n * @param source - The source file metadata.\n * @param dest - The destination file metadata.\n * @param compareMode - The comparison strategy: 'modtime', 'size', or 'none'.\n * @param threshold - Tolerance for the comparison (bytes for size, milliseconds for modtime).\n *\n * @returns `true` if the files are considered different.\n */\nexport function filesAreDifferent(\n source: SyncPath,\n dest: SyncPath,\n compareMode: CompareMode,\n threshold = 0,\n): boolean {\n switch (compareMode) {\n case 'none':\n return false\n case 'size':\n return Math.abs(source.size - dest.size) > threshold\n case 'modtime':\n return Math.abs(source.modTimeMillis - dest.modTimeMillis) > threshold\n }\n}\n"],"names":[],"mappings":";;AAYO,SAAS,kBACd,QACA,MACA,aACA,YAAY,GACH;AACT,UAAQ,aAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,KAAK,IAAI,OAAO,OAAO,KAAK,IAAI,IAAI;AAAA,IAC7C,KAAK;AACH,aAAO,KAAK,IAAI,OAAO,gBAAgB,KAAK,aAAa,IAAI;AAAA,EAAA;AAEnE;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CompareMode, SyncPath } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether two files should be considered different based on the compare mode.
|
|
4
|
+
*
|
|
5
|
+
* @param source - The source file metadata.
|
|
6
|
+
* @param dest - The destination file metadata.
|
|
7
|
+
* @param compareMode - The comparison strategy: 'modtime', 'size', or 'none'.
|
|
8
|
+
* @param threshold - Tolerance for the comparison (bytes for size, milliseconds for modtime).
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` if the files are considered different.
|
|
11
|
+
*/
|
|
12
|
+
export declare function filesAreDifferent(source: SyncPath, dest: SyncPath, compareMode: CompareMode, threshold?: number): boolean;
|
|
13
|
+
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/compare.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,SAAI,GACZ,OAAO,CAST"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CompareMode, SyncPath } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether two files should be considered different based on the compare mode.
|
|
4
|
+
*
|
|
5
|
+
* @param source - The source file metadata.
|
|
6
|
+
* @param dest - The destination file metadata.
|
|
7
|
+
* @param compareMode - The comparison strategy: 'modtime', 'size', or 'none'.
|
|
8
|
+
* @param threshold - Tolerance for the comparison (bytes for size, milliseconds for modtime).
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` if the files are considered different.
|
|
11
|
+
*/
|
|
12
|
+
export declare function filesAreDifferent(source: SyncPath, dest: SyncPath, compareMode: CompareMode, threshold?: number): boolean;
|
|
13
|
+
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/compare.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,SAAI,GACZ,OAAO,CAST"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function filesAreDifferent(source, dest, compareMode, threshold = 0) {
|
|
2
|
+
switch (compareMode) {
|
|
3
|
+
case "none":
|
|
4
|
+
return false;
|
|
5
|
+
case "size":
|
|
6
|
+
return Math.abs(source.size - dest.size) > threshold;
|
|
7
|
+
case "modtime":
|
|
8
|
+
return Math.abs(source.modTimeMillis - dest.modTimeMillis) > threshold;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
filesAreDifferent
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.js","sources":["../../../src/sync/policies/compare.ts"],"sourcesContent":["import type { CompareMode, SyncPath } from '../types.ts'\n\n/**\n * Determines whether two files should be considered different based on the compare mode.\n *\n * @param source - The source file metadata.\n * @param dest - The destination file metadata.\n * @param compareMode - The comparison strategy: 'modtime', 'size', or 'none'.\n * @param threshold - Tolerance for the comparison (bytes for size, milliseconds for modtime).\n *\n * @returns `true` if the files are considered different.\n */\nexport function filesAreDifferent(\n source: SyncPath,\n dest: SyncPath,\n compareMode: CompareMode,\n threshold = 0,\n): boolean {\n switch (compareMode) {\n case 'none':\n return false\n case 'size':\n return Math.abs(source.size - dest.size) > threshold\n case 'modtime':\n return Math.abs(source.modTimeMillis - dest.modTimeMillis) > threshold\n }\n}\n"],"names":[],"mappings":"AAYO,SAAS,kBACd,QACA,MACA,aACA,YAAY,GACH;AACT,UAAQ,aAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,KAAK,IAAI,OAAO,OAAO,KAAK,IAAI,IAAI;AAAA,IAC7C,KAAK;AACH,aAAO,KAAK,IAAI,OAAO,gBAAgB,KAAK,aAAa,IAAI;AAAA,EAAA;AAEnE;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("../actions/index.cjs");
|
|
4
|
+
const compare = require("./compare.cjs");
|
|
5
|
+
function* generateActions(pair, direction, compareMode, keepMode, keepDays, nowMillis, factory, compareThreshold) {
|
|
6
|
+
const [source, dest] = pair;
|
|
7
|
+
if (source !== null && dest === null) {
|
|
8
|
+
yield* actionsForSourceOnly(source, direction, factory);
|
|
9
|
+
} else if (source === null && dest !== null) {
|
|
10
|
+
yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory);
|
|
11
|
+
} else if (source !== null && dest !== null) {
|
|
12
|
+
yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function* actionsForSourceOnly(source, direction, factory) {
|
|
16
|
+
switch (direction) {
|
|
17
|
+
case "local-to-b2":
|
|
18
|
+
yield factory.upload(source);
|
|
19
|
+
break;
|
|
20
|
+
case "b2-to-local":
|
|
21
|
+
yield factory.download(source);
|
|
22
|
+
break;
|
|
23
|
+
case "b2-to-b2":
|
|
24
|
+
yield factory.copy(source, source.relativePath);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory) {
|
|
29
|
+
if (keepMode === "no-delete") {
|
|
30
|
+
yield new index.SkipAction(dest.relativePath, "not in source, keep-mode is no-delete");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (keepMode === "keep-days") {
|
|
34
|
+
const ageMillis = nowMillis - dest.modTimeMillis;
|
|
35
|
+
const ageDays = ageMillis / (24 * 60 * 60 * 1e3);
|
|
36
|
+
if (ageDays < keepDays) {
|
|
37
|
+
yield new index.SkipAction(
|
|
38
|
+
dest.relativePath,
|
|
39
|
+
`not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`
|
|
40
|
+
);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
switch (direction) {
|
|
45
|
+
case "local-to-b2":
|
|
46
|
+
yield factory.removeOrphan(dest);
|
|
47
|
+
break;
|
|
48
|
+
case "b2-to-local":
|
|
49
|
+
yield factory.deleteLocal(dest);
|
|
50
|
+
break;
|
|
51
|
+
case "b2-to-b2":
|
|
52
|
+
yield factory.removeOrphan(dest);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory) {
|
|
57
|
+
if (!compare.filesAreDifferent(source, dest, compareMode, compareThreshold)) {
|
|
58
|
+
yield new index.SkipAction(source.relativePath, "files are the same");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
switch (direction) {
|
|
62
|
+
case "local-to-b2":
|
|
63
|
+
yield factory.upload(source);
|
|
64
|
+
break;
|
|
65
|
+
case "b2-to-local":
|
|
66
|
+
yield factory.download(source);
|
|
67
|
+
break;
|
|
68
|
+
case "b2-to-b2":
|
|
69
|
+
yield factory.copy(source, dest.relativePath);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.generateActions = generateActions;
|
|
74
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/sync/policies/index.ts"],"sourcesContent":["import type { SyncAction } from '../actions/index.ts'\nimport { SkipAction } from '../actions/index.ts'\nimport type { SyncPair } from '../pairing.ts'\nimport type {\n B2SyncPath,\n CompareMode,\n KeepMode,\n LocalSyncPath,\n SyncDirection,\n SyncPath,\n} from '../types.ts'\nimport { filesAreDifferent } from './compare.ts'\n\n/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */\nexport interface ActionFactory {\n /** Creates an action to upload a local file to B2. */\n upload(source: LocalSyncPath): SyncAction\n /** Creates an action to download a B2 file to the local filesystem. */\n download(source: B2SyncPath): SyncAction\n /** Creates an action to server-side copy a B2 file to a new destination path. */\n copy(source: B2SyncPath, destPath: string): SyncAction\n /** Creates an action to hide a file in B2 (soft delete). */\n hide(path: string): SyncAction\n /** Creates an action to permanently delete a remote B2 file version. */\n deleteRemote(path: B2SyncPath): SyncAction\n /** Creates an action to delete a local file. */\n deleteLocal(path: LocalSyncPath): SyncAction\n /**\n * Creates the right \"remove this orphan from B2\" action for the bucket's\n * configuration: a hide on a file-lock-enabled bucket (where direct\n * delete may be blocked or stack hide markers), a plain\n * delete-file-version on a vanilla bucket. Used by `actionsForDestOnly`\n * to avoid yielding both a hide AND a delete when only one of them is\n * the correct semantic for the destination bucket.\n */\n removeOrphan(dest: B2SyncPath): SyncAction\n}\n\n/**\n * Converts a paired source/dest tuple into zero or more sync actions based on the\n * sync direction, compare mode, and keep policy.\n *\n * @param pair - The source/dest file pair from {@link zipFolders}.\n * @param direction - The sync direction.\n * @param compareMode - How to compare files for differences.\n * @param keepMode - Policy for destination-only files.\n * @param keepDays - Retention period when keepMode is 'keep-days'.\n * @param nowMillis - Current time in milliseconds, used for keep-days calculation.\n * @param factory - Factory to create the concrete action objects.\n * @param compareThreshold - Tolerance for the comparison.\n */\nexport function* generateActions(\n pair: SyncPair,\n direction: SyncDirection,\n compareMode: CompareMode,\n keepMode: KeepMode,\n keepDays: number,\n nowMillis: number,\n factory: ActionFactory,\n compareThreshold: number,\n): Generator<SyncAction> {\n const [source, dest] = pair\n\n if (source !== null && dest === null) {\n yield* actionsForSourceOnly(source, direction, factory)\n } else if (source === null && dest !== null) {\n yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory)\n } else if (source !== null && dest !== null) {\n yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory)\n }\n}\n\nfunction* actionsForSourceOnly(\n source: SyncPath,\n direction: SyncDirection,\n factory: ActionFactory,\n): Generator<SyncAction> {\n switch (direction) {\n case 'local-to-b2':\n yield factory.upload(source as LocalSyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath)\n break\n case 'b2-to-b2':\n yield factory.copy(source as B2SyncPath, source.relativePath)\n break\n }\n}\n\nfunction* actionsForDestOnly(\n dest: SyncPath,\n direction: SyncDirection,\n keepMode: KeepMode,\n keepDays: number,\n nowMillis: number,\n factory: ActionFactory,\n): Generator<SyncAction> {\n if (keepMode === 'no-delete') {\n yield new SkipAction(dest.relativePath, 'not in source, keep-mode is no-delete')\n return\n }\n\n if (keepMode === 'keep-days') {\n const ageMillis = nowMillis - dest.modTimeMillis\n const ageDays = ageMillis / (24 * 60 * 60 * 1000)\n if (ageDays < keepDays) {\n yield new SkipAction(\n dest.relativePath,\n `not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`,\n )\n return\n }\n }\n\n switch (direction) {\n case 'local-to-b2':\n // Single action — `removeOrphan` picks hide vs delete based on\n // the destination bucket's `fileLockEnabled` state. The previous\n // \"yield both\" behaviour stacked hide markers on vanilla buckets\n // even though the delete that followed made them redundant.\n yield factory.removeOrphan(dest as B2SyncPath)\n break\n case 'b2-to-local':\n yield factory.deleteLocal(dest as LocalSyncPath)\n break\n case 'b2-to-b2':\n yield factory.removeOrphan(dest as B2SyncPath)\n break\n }\n}\n\nfunction* actionsForBoth(\n source: SyncPath,\n dest: SyncPath,\n direction: SyncDirection,\n compareMode: CompareMode,\n compareThreshold: number,\n factory: ActionFactory,\n): Generator<SyncAction> {\n if (!filesAreDifferent(source, dest, compareMode, compareThreshold)) {\n yield new SkipAction(source.relativePath, 'files are the same')\n return\n }\n\n switch (direction) {\n case 'local-to-b2':\n yield factory.upload(source as LocalSyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath)\n break\n case 'b2-to-b2':\n yield factory.copy(source as B2SyncPath, dest.relativePath)\n break\n }\n}\n"],"names":["SkipAction","filesAreDifferent"],"mappings":";;;;AAmDO,UAAU,gBACf,MACA,WACA,aACA,UACA,UACA,WACA,SACA,kBACuB;AACvB,QAAM,CAAC,QAAQ,IAAI,IAAI;AAEvB,MAAI,WAAW,QAAQ,SAAS,MAAM;AACpC,WAAO,qBAAqB,QAAQ,WAAW,OAAO;AAAA,EACxD,WAAW,WAAW,QAAQ,SAAS,MAAM;AAC3C,WAAO,mBAAmB,MAAM,WAAW,UAAU,UAAU,WAAW,OAAO;AAAA,EACnF,WAAW,WAAW,QAAQ,SAAS,MAAM;AAC3C,WAAO,eAAe,QAAQ,MAAM,WAAW,aAAa,kBAAkB,OAAO;AAAA,EACvF;AACF;AAEA,UAAU,qBACR,QACA,WACA,SACuB;AACvB,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,YAAM,QAAQ,OAAO,MAAuB;AAC5C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,SAAS,MAAoB;AAC3C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,KAAK,QAAsB,OAAO,YAAY;AAC5D;AAAA,EAAA;AAEN;AAEA,UAAU,mBACR,MACA,WACA,UACA,UACA,WACA,SACuB;AACvB,MAAI,aAAa,aAAa;AAC5B,UAAM,IAAIA,MAAAA,WAAW,KAAK,cAAc,uCAAuC;AAC/E;AAAA,EACF;AAEA,MAAI,aAAa,aAAa;AAC5B,UAAM,YAAY,YAAY,KAAK;AACnC,UAAM,UAAU,aAAa,KAAK,KAAK,KAAK;AAC5C,QAAI,UAAU,UAAU;AACtB,YAAM,IAAIA,MAAAA;AAAAA,QACR,KAAK;AAAA,QACL,8BAA8B,KAAK,KAAK,WAAW,OAAO,CAAC;AAAA,MAAA;AAE7D;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,WAAA;AAAA,IACN,KAAK;AAKH,YAAM,QAAQ,aAAa,IAAkB;AAC7C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,YAAY,IAAqB;AAC/C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,aAAa,IAAkB;AAC7C;AAAA,EAAA;AAEN;AAEA,UAAU,eACR,QACA,MACA,WACA,aACA,kBACA,SACuB;AACvB,MAAI,CAACC,QAAAA,kBAAkB,QAAQ,MAAM,aAAa,gBAAgB,GAAG;AACnE,UAAM,IAAID,MAAAA,WAAW,OAAO,cAAc,oBAAoB;AAC9D;AAAA,EACF;AAEA,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,YAAM,QAAQ,OAAO,MAAuB;AAC5C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,SAAS,MAAoB;AAC3C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,KAAK,QAAsB,KAAK,YAAY;AAC1D;AAAA,EAAA;AAEN;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SyncAction } from '../actions/index.js';
|
|
2
|
+
import { SyncPair } from '../pairing.js';
|
|
3
|
+
import { B2SyncPath, CompareMode, KeepMode, LocalSyncPath, SyncDirection } from '../types.js';
|
|
4
|
+
/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */
|
|
5
|
+
export interface ActionFactory {
|
|
6
|
+
/** Creates an action to upload a local file to B2. */
|
|
7
|
+
upload(source: LocalSyncPath): SyncAction;
|
|
8
|
+
/** Creates an action to download a B2 file to the local filesystem. */
|
|
9
|
+
download(source: B2SyncPath): SyncAction;
|
|
10
|
+
/** Creates an action to server-side copy a B2 file to a new destination path. */
|
|
11
|
+
copy(source: B2SyncPath, destPath: string): SyncAction;
|
|
12
|
+
/** Creates an action to hide a file in B2 (soft delete). */
|
|
13
|
+
hide(path: string): SyncAction;
|
|
14
|
+
/** Creates an action to permanently delete a remote B2 file version. */
|
|
15
|
+
deleteRemote(path: B2SyncPath): SyncAction;
|
|
16
|
+
/** Creates an action to delete a local file. */
|
|
17
|
+
deleteLocal(path: LocalSyncPath): SyncAction;
|
|
18
|
+
/**
|
|
19
|
+
* Creates the right "remove this orphan from B2" action for the bucket's
|
|
20
|
+
* configuration: a hide on a file-lock-enabled bucket (where direct
|
|
21
|
+
* delete may be blocked or stack hide markers), a plain
|
|
22
|
+
* delete-file-version on a vanilla bucket. Used by `actionsForDestOnly`
|
|
23
|
+
* to avoid yielding both a hide AND a delete when only one of them is
|
|
24
|
+
* the correct semantic for the destination bucket.
|
|
25
|
+
*/
|
|
26
|
+
removeOrphan(dest: B2SyncPath): SyncAction;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
30
|
+
* sync direction, compare mode, and keep policy.
|
|
31
|
+
*
|
|
32
|
+
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
33
|
+
* @param direction - The sync direction.
|
|
34
|
+
* @param compareMode - How to compare files for differences.
|
|
35
|
+
* @param keepMode - Policy for destination-only files.
|
|
36
|
+
* @param keepDays - Retention period when keepMode is 'keep-days'.
|
|
37
|
+
* @param nowMillis - Current time in milliseconds, used for keep-days calculation.
|
|
38
|
+
* @param factory - Factory to create the concrete action objects.
|
|
39
|
+
* @param compareThreshold - Tolerance for the comparison.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateActions(pair: SyncPair, direction: SyncDirection, compareMode: CompareMode, keepMode: KeepMode, keepDays: number, nowMillis: number, factory: ActionFactory, compareThreshold: number): Generator<SyncAction>;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/index.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EAEd,MAAM,aAAa,CAAA;AAGpB,qHAAqH;AACrH,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAA;IACzC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAA;IACxC,iFAAiF;IACjF,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IACtD,4DAA4D;IAC5D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wEAAwE;IACxE,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;IAC1C,gDAAgD;IAChD,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAAA;IAC5C;;;;;;;OAOG;IACH,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAiB,eAAe,CAC9B,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE,MAAM,GACvB,SAAS,CAAC,UAAU,CAAC,CAUvB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SyncAction } from '../actions/index.js';
|
|
2
|
+
import { SyncPair } from '../pairing.js';
|
|
3
|
+
import { B2SyncPath, CompareMode, KeepMode, LocalSyncPath, SyncDirection } from '../types.js';
|
|
4
|
+
/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */
|
|
5
|
+
export interface ActionFactory {
|
|
6
|
+
/** Creates an action to upload a local file to B2. */
|
|
7
|
+
upload(source: LocalSyncPath): SyncAction;
|
|
8
|
+
/** Creates an action to download a B2 file to the local filesystem. */
|
|
9
|
+
download(source: B2SyncPath): SyncAction;
|
|
10
|
+
/** Creates an action to server-side copy a B2 file to a new destination path. */
|
|
11
|
+
copy(source: B2SyncPath, destPath: string): SyncAction;
|
|
12
|
+
/** Creates an action to hide a file in B2 (soft delete). */
|
|
13
|
+
hide(path: string): SyncAction;
|
|
14
|
+
/** Creates an action to permanently delete a remote B2 file version. */
|
|
15
|
+
deleteRemote(path: B2SyncPath): SyncAction;
|
|
16
|
+
/** Creates an action to delete a local file. */
|
|
17
|
+
deleteLocal(path: LocalSyncPath): SyncAction;
|
|
18
|
+
/**
|
|
19
|
+
* Creates the right "remove this orphan from B2" action for the bucket's
|
|
20
|
+
* configuration: a hide on a file-lock-enabled bucket (where direct
|
|
21
|
+
* delete may be blocked or stack hide markers), a plain
|
|
22
|
+
* delete-file-version on a vanilla bucket. Used by `actionsForDestOnly`
|
|
23
|
+
* to avoid yielding both a hide AND a delete when only one of them is
|
|
24
|
+
* the correct semantic for the destination bucket.
|
|
25
|
+
*/
|
|
26
|
+
removeOrphan(dest: B2SyncPath): SyncAction;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
30
|
+
* sync direction, compare mode, and keep policy.
|
|
31
|
+
*
|
|
32
|
+
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
33
|
+
* @param direction - The sync direction.
|
|
34
|
+
* @param compareMode - How to compare files for differences.
|
|
35
|
+
* @param keepMode - Policy for destination-only files.
|
|
36
|
+
* @param keepDays - Retention period when keepMode is 'keep-days'.
|
|
37
|
+
* @param nowMillis - Current time in milliseconds, used for keep-days calculation.
|
|
38
|
+
* @param factory - Factory to create the concrete action objects.
|
|
39
|
+
* @param compareThreshold - Tolerance for the comparison.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateActions(pair: SyncPair, direction: SyncDirection, compareMode: CompareMode, keepMode: KeepMode, keepDays: number, nowMillis: number, factory: ActionFactory, compareThreshold: number): Generator<SyncAction>;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/index.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EAEd,MAAM,aAAa,CAAA;AAGpB,qHAAqH;AACrH,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAA;IACzC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAA;IACxC,iFAAiF;IACjF,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IACtD,4DAA4D;IAC5D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wEAAwE;IACxE,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;IAC1C,gDAAgD;IAChD,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAAA;IAC5C;;;;;;;OAOG;IACH,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAiB,eAAe,CAC9B,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE,MAAM,GACvB,SAAS,CAAC,UAAU,CAAC,CAUvB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SkipAction } from "../actions/index.js";
|
|
2
|
+
import { filesAreDifferent } from "./compare.js";
|
|
3
|
+
function* generateActions(pair, direction, compareMode, keepMode, keepDays, nowMillis, factory, compareThreshold) {
|
|
4
|
+
const [source, dest] = pair;
|
|
5
|
+
if (source !== null && dest === null) {
|
|
6
|
+
yield* actionsForSourceOnly(source, direction, factory);
|
|
7
|
+
} else if (source === null && dest !== null) {
|
|
8
|
+
yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory);
|
|
9
|
+
} else if (source !== null && dest !== null) {
|
|
10
|
+
yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function* actionsForSourceOnly(source, direction, factory) {
|
|
14
|
+
switch (direction) {
|
|
15
|
+
case "local-to-b2":
|
|
16
|
+
yield factory.upload(source);
|
|
17
|
+
break;
|
|
18
|
+
case "b2-to-local":
|
|
19
|
+
yield factory.download(source);
|
|
20
|
+
break;
|
|
21
|
+
case "b2-to-b2":
|
|
22
|
+
yield factory.copy(source, source.relativePath);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory) {
|
|
27
|
+
if (keepMode === "no-delete") {
|
|
28
|
+
yield new SkipAction(dest.relativePath, "not in source, keep-mode is no-delete");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (keepMode === "keep-days") {
|
|
32
|
+
const ageMillis = nowMillis - dest.modTimeMillis;
|
|
33
|
+
const ageDays = ageMillis / (24 * 60 * 60 * 1e3);
|
|
34
|
+
if (ageDays < keepDays) {
|
|
35
|
+
yield new SkipAction(
|
|
36
|
+
dest.relativePath,
|
|
37
|
+
`not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`
|
|
38
|
+
);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
switch (direction) {
|
|
43
|
+
case "local-to-b2":
|
|
44
|
+
yield factory.removeOrphan(dest);
|
|
45
|
+
break;
|
|
46
|
+
case "b2-to-local":
|
|
47
|
+
yield factory.deleteLocal(dest);
|
|
48
|
+
break;
|
|
49
|
+
case "b2-to-b2":
|
|
50
|
+
yield factory.removeOrphan(dest);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory) {
|
|
55
|
+
if (!filesAreDifferent(source, dest, compareMode, compareThreshold)) {
|
|
56
|
+
yield new SkipAction(source.relativePath, "files are the same");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
switch (direction) {
|
|
60
|
+
case "local-to-b2":
|
|
61
|
+
yield factory.upload(source);
|
|
62
|
+
break;
|
|
63
|
+
case "b2-to-local":
|
|
64
|
+
yield factory.download(source);
|
|
65
|
+
break;
|
|
66
|
+
case "b2-to-b2":
|
|
67
|
+
yield factory.copy(source, dest.relativePath);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
generateActions
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/sync/policies/index.ts"],"sourcesContent":["import type { SyncAction } from '../actions/index.ts'\nimport { SkipAction } from '../actions/index.ts'\nimport type { SyncPair } from '../pairing.ts'\nimport type {\n B2SyncPath,\n CompareMode,\n KeepMode,\n LocalSyncPath,\n SyncDirection,\n SyncPath,\n} from '../types.ts'\nimport { filesAreDifferent } from './compare.ts'\n\n/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */\nexport interface ActionFactory {\n /** Creates an action to upload a local file to B2. */\n upload(source: LocalSyncPath): SyncAction\n /** Creates an action to download a B2 file to the local filesystem. */\n download(source: B2SyncPath): SyncAction\n /** Creates an action to server-side copy a B2 file to a new destination path. */\n copy(source: B2SyncPath, destPath: string): SyncAction\n /** Creates an action to hide a file in B2 (soft delete). */\n hide(path: string): SyncAction\n /** Creates an action to permanently delete a remote B2 file version. */\n deleteRemote(path: B2SyncPath): SyncAction\n /** Creates an action to delete a local file. */\n deleteLocal(path: LocalSyncPath): SyncAction\n /**\n * Creates the right \"remove this orphan from B2\" action for the bucket's\n * configuration: a hide on a file-lock-enabled bucket (where direct\n * delete may be blocked or stack hide markers), a plain\n * delete-file-version on a vanilla bucket. Used by `actionsForDestOnly`\n * to avoid yielding both a hide AND a delete when only one of them is\n * the correct semantic for the destination bucket.\n */\n removeOrphan(dest: B2SyncPath): SyncAction\n}\n\n/**\n * Converts a paired source/dest tuple into zero or more sync actions based on the\n * sync direction, compare mode, and keep policy.\n *\n * @param pair - The source/dest file pair from {@link zipFolders}.\n * @param direction - The sync direction.\n * @param compareMode - How to compare files for differences.\n * @param keepMode - Policy for destination-only files.\n * @param keepDays - Retention period when keepMode is 'keep-days'.\n * @param nowMillis - Current time in milliseconds, used for keep-days calculation.\n * @param factory - Factory to create the concrete action objects.\n * @param compareThreshold - Tolerance for the comparison.\n */\nexport function* generateActions(\n pair: SyncPair,\n direction: SyncDirection,\n compareMode: CompareMode,\n keepMode: KeepMode,\n keepDays: number,\n nowMillis: number,\n factory: ActionFactory,\n compareThreshold: number,\n): Generator<SyncAction> {\n const [source, dest] = pair\n\n if (source !== null && dest === null) {\n yield* actionsForSourceOnly(source, direction, factory)\n } else if (source === null && dest !== null) {\n yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory)\n } else if (source !== null && dest !== null) {\n yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory)\n }\n}\n\nfunction* actionsForSourceOnly(\n source: SyncPath,\n direction: SyncDirection,\n factory: ActionFactory,\n): Generator<SyncAction> {\n switch (direction) {\n case 'local-to-b2':\n yield factory.upload(source as LocalSyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath)\n break\n case 'b2-to-b2':\n yield factory.copy(source as B2SyncPath, source.relativePath)\n break\n }\n}\n\nfunction* actionsForDestOnly(\n dest: SyncPath,\n direction: SyncDirection,\n keepMode: KeepMode,\n keepDays: number,\n nowMillis: number,\n factory: ActionFactory,\n): Generator<SyncAction> {\n if (keepMode === 'no-delete') {\n yield new SkipAction(dest.relativePath, 'not in source, keep-mode is no-delete')\n return\n }\n\n if (keepMode === 'keep-days') {\n const ageMillis = nowMillis - dest.modTimeMillis\n const ageDays = ageMillis / (24 * 60 * 60 * 1000)\n if (ageDays < keepDays) {\n yield new SkipAction(\n dest.relativePath,\n `not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`,\n )\n return\n }\n }\n\n switch (direction) {\n case 'local-to-b2':\n // Single action — `removeOrphan` picks hide vs delete based on\n // the destination bucket's `fileLockEnabled` state. The previous\n // \"yield both\" behaviour stacked hide markers on vanilla buckets\n // even though the delete that followed made them redundant.\n yield factory.removeOrphan(dest as B2SyncPath)\n break\n case 'b2-to-local':\n yield factory.deleteLocal(dest as LocalSyncPath)\n break\n case 'b2-to-b2':\n yield factory.removeOrphan(dest as B2SyncPath)\n break\n }\n}\n\nfunction* actionsForBoth(\n source: SyncPath,\n dest: SyncPath,\n direction: SyncDirection,\n compareMode: CompareMode,\n compareThreshold: number,\n factory: ActionFactory,\n): Generator<SyncAction> {\n if (!filesAreDifferent(source, dest, compareMode, compareThreshold)) {\n yield new SkipAction(source.relativePath, 'files are the same')\n return\n }\n\n switch (direction) {\n case 'local-to-b2':\n yield factory.upload(source as LocalSyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath)\n break\n case 'b2-to-b2':\n yield factory.copy(source as B2SyncPath, dest.relativePath)\n break\n }\n}\n"],"names":[],"mappings":";;AAmDO,UAAU,gBACf,MACA,WACA,aACA,UACA,UACA,WACA,SACA,kBACuB;AACvB,QAAM,CAAC,QAAQ,IAAI,IAAI;AAEvB,MAAI,WAAW,QAAQ,SAAS,MAAM;AACpC,WAAO,qBAAqB,QAAQ,WAAW,OAAO;AAAA,EACxD,WAAW,WAAW,QAAQ,SAAS,MAAM;AAC3C,WAAO,mBAAmB,MAAM,WAAW,UAAU,UAAU,WAAW,OAAO;AAAA,EACnF,WAAW,WAAW,QAAQ,SAAS,MAAM;AAC3C,WAAO,eAAe,QAAQ,MAAM,WAAW,aAAa,kBAAkB,OAAO;AAAA,EACvF;AACF;AAEA,UAAU,qBACR,QACA,WACA,SACuB;AACvB,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,YAAM,QAAQ,OAAO,MAAuB;AAC5C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,SAAS,MAAoB;AAC3C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,KAAK,QAAsB,OAAO,YAAY;AAC5D;AAAA,EAAA;AAEN;AAEA,UAAU,mBACR,MACA,WACA,UACA,UACA,WACA,SACuB;AACvB,MAAI,aAAa,aAAa;AAC5B,UAAM,IAAI,WAAW,KAAK,cAAc,uCAAuC;AAC/E;AAAA,EACF;AAEA,MAAI,aAAa,aAAa;AAC5B,UAAM,YAAY,YAAY,KAAK;AACnC,UAAM,UAAU,aAAa,KAAK,KAAK,KAAK;AAC5C,QAAI,UAAU,UAAU;AACtB,YAAM,IAAI;AAAA,QACR,KAAK;AAAA,QACL,8BAA8B,KAAK,KAAK,WAAW,OAAO,CAAC;AAAA,MAAA;AAE7D;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,WAAA;AAAA,IACN,KAAK;AAKH,YAAM,QAAQ,aAAa,IAAkB;AAC7C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,YAAY,IAAqB;AAC/C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,aAAa,IAAkB;AAC7C;AAAA,EAAA;AAEN;AAEA,UAAU,eACR,QACA,MACA,WACA,aACA,kBACA,SACuB;AACvB,MAAI,CAAC,kBAAkB,QAAQ,MAAM,aAAa,gBAAgB,GAAG;AACnE,UAAM,IAAI,WAAW,OAAO,cAAc,oBAAoB;AAC9D;AAAA,EACF;AAEA,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,YAAM,QAAQ,OAAO,MAAuB;AAC5C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,SAAS,MAAoB;AAC3C;AAAA,IACF,KAAK;AACH,YAAM,QAAQ,KAAK,QAAsB,KAAK,YAAY;AAC1D;AAAA,EAAA;AAEN;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const file = require("../../types/file.cjs");
|
|
4
|
+
class B2Folder {
|
|
5
|
+
type = "b2";
|
|
6
|
+
bucket;
|
|
7
|
+
prefix;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new B2Folder for the given bucket and optional prefix.
|
|
10
|
+
* @param bucket - The B2 bucket to scan.
|
|
11
|
+
* @param prefix - Optional key prefix to restrict the scan scope.
|
|
12
|
+
*/
|
|
13
|
+
constructor(bucket, prefix = "") {
|
|
14
|
+
this.bucket = bucket;
|
|
15
|
+
this.prefix = prefix;
|
|
16
|
+
}
|
|
17
|
+
/** Lists all file versions in the bucket, groups by name, and yields the latest visible version. */
|
|
18
|
+
async *scan() {
|
|
19
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
20
|
+
let startFileName;
|
|
21
|
+
let startFileId;
|
|
22
|
+
while (true) {
|
|
23
|
+
const listing = await this.bucket.listFileVersions({
|
|
24
|
+
...this.prefix !== "" ? { prefix: this.prefix } : {},
|
|
25
|
+
...startFileName !== void 0 ? { startFileName } : {},
|
|
26
|
+
...startFileId !== void 0 ? { startFileId } : {}
|
|
27
|
+
});
|
|
28
|
+
for (const fv of listing.files) {
|
|
29
|
+
const existing = grouped.get(fv.fileName);
|
|
30
|
+
if (existing) {
|
|
31
|
+
existing.push(fv);
|
|
32
|
+
} else {
|
|
33
|
+
grouped.set(fv.fileName, [fv]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!listing.nextFileName) break;
|
|
37
|
+
startFileName = listing.nextFileName;
|
|
38
|
+
startFileId = listing.nextFileId;
|
|
39
|
+
}
|
|
40
|
+
const sorted = [...grouped.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
|
41
|
+
for (const [fileName, versions] of sorted) {
|
|
42
|
+
versions.sort((a, b) => b.uploadTimestamp - a.uploadTimestamp);
|
|
43
|
+
const selected = versions[0];
|
|
44
|
+
if (!selected || selected.action === file.FileAction.Hide) continue;
|
|
45
|
+
const relativePath = this.prefix !== "" ? fileName.slice(this.prefix.length) : fileName;
|
|
46
|
+
yield {
|
|
47
|
+
relativePath,
|
|
48
|
+
modTimeMillis: selected.uploadTimestamp,
|
|
49
|
+
size: selected.contentLength,
|
|
50
|
+
selectedVersion: selected,
|
|
51
|
+
allVersions: versions
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.B2Folder = B2Folder;
|
|
57
|
+
//# sourceMappingURL=b2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2.cjs","sources":["../../../src/sync/scanners/b2.ts"],"sourcesContent":["import type { Bucket } from '../../bucket.ts'\nimport { FileAction, type FileVersion } from '../../types/file.ts'\nimport type { B2SyncPath, SyncFolder } from '../types.ts'\n\n/**\n * Scans a B2 bucket (optionally filtered by prefix) and yields {@link B2SyncPath} entries\n * sorted by file name. Hidden files are excluded. All versions are fetched and grouped.\n */\nexport class B2Folder implements SyncFolder {\n readonly type = 'b2' as const\n private readonly bucket: Bucket\n private readonly prefix: string\n\n /**\n * Creates a new B2Folder for the given bucket and optional prefix.\n * @param bucket - The B2 bucket to scan.\n * @param prefix - Optional key prefix to restrict the scan scope.\n */\n constructor(bucket: Bucket, prefix = '') {\n this.bucket = bucket\n this.prefix = prefix\n }\n\n /** Lists all file versions in the bucket, groups by name, and yields the latest visible version. */\n async *scan(): AsyncGenerator<B2SyncPath> {\n const grouped = new Map<string, FileVersion[]>()\n\n let startFileName: string | undefined\n let startFileId: string | undefined\n\n while (true) {\n const listing = await this.bucket.listFileVersions({\n ...(this.prefix !== '' ? { prefix: this.prefix } : {}),\n ...(startFileName !== undefined ? { startFileName } : {}),\n ...(startFileId !== undefined\n ? { startFileId: startFileId as import('../../types/ids.ts').FileId }\n : {}),\n })\n\n for (const fv of listing.files) {\n const existing = grouped.get(fv.fileName)\n if (existing) {\n existing.push(fv)\n } else {\n grouped.set(fv.fileName, [fv])\n }\n }\n\n if (!listing.nextFileName) break\n startFileName = listing.nextFileName\n startFileId = listing.nextFileId as string | undefined\n }\n\n const sorted = [...grouped.entries()].sort((a, b) => a[0].localeCompare(b[0]))\n\n for (const [fileName, versions] of sorted) {\n versions.sort((a, b) => b.uploadTimestamp - a.uploadTimestamp)\n const selected = versions[0]\n if (!selected || selected.action === FileAction.Hide) continue\n\n const relativePath = this.prefix !== '' ? fileName.slice(this.prefix.length) : fileName\n\n yield {\n relativePath,\n modTimeMillis: selected.uploadTimestamp,\n size: selected.contentLength,\n selectedVersion: selected,\n allVersions: versions,\n }\n }\n }\n}\n"],"names":["FileAction"],"mappings":";;;AAQO,MAAM,SAA+B;AAAA,EACjC,OAAO;AAAA,EACC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjB,YAAY,QAAgB,SAAS,IAAI;AACvC,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA,EAGA,OAAO,OAAmC;AACxC,UAAM,8BAAc,IAAA;AAEpB,QAAI;AACJ,QAAI;AAEJ,WAAO,MAAM;AACX,YAAM,UAAU,MAAM,KAAK,OAAO,iBAAiB;AAAA,QACjD,GAAI,KAAK,WAAW,KAAK,EAAE,QAAQ,KAAK,OAAA,IAAW,CAAA;AAAA,QACnD,GAAI,kBAAkB,SAAY,EAAE,cAAA,IAAkB,CAAA;AAAA,QACtD,GAAI,gBAAgB,SAChB,EAAE,gBACF,CAAA;AAAA,MAAC,CACN;AAED,iBAAW,MAAM,QAAQ,OAAO;AAC9B,cAAM,WAAW,QAAQ,IAAI,GAAG,QAAQ;AACxC,YAAI,UAAU;AACZ,mBAAS,KAAK,EAAE;AAAA,QAClB,OAAO;AACL,kBAAQ,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC;AAAA,QAC/B;AAAA,MACF;AAEA,UAAI,CAAC,QAAQ,aAAc;AAC3B,sBAAgB,QAAQ;AACxB,oBAAc,QAAQ;AAAA,IACxB;AAEA,UAAM,SAAS,CAAC,GAAG,QAAQ,QAAA,CAAS,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;AAE7E,eAAW,CAAC,UAAU,QAAQ,KAAK,QAAQ;AACzC,eAAS,KAAK,CAAC,GAAG,MAAM,EAAE,kBAAkB,EAAE,eAAe;AAC7D,YAAM,WAAW,SAAS,CAAC;AAC3B,UAAI,CAAC,YAAY,SAAS,WAAWA,KAAAA,WAAW,KAAM;AAEtD,YAAM,eAAe,KAAK,WAAW,KAAK,SAAS,MAAM,KAAK,OAAO,MAAM,IAAI;AAE/E,YAAM;AAAA,QACJ;AAAA,QACA,eAAe,SAAS;AAAA,QACxB,MAAM,SAAS;AAAA,QACf,iBAAiB;AAAA,QACjB,aAAa;AAAA,MAAA;AAAA,IAEjB;AAAA,EACF;AACF;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Bucket } from '../../bucket.js';
|
|
2
|
+
import { B2SyncPath, SyncFolder } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Scans a B2 bucket (optionally filtered by prefix) and yields {@link B2SyncPath} entries
|
|
5
|
+
* sorted by file name. Hidden files are excluded. All versions are fetched and grouped.
|
|
6
|
+
*/
|
|
7
|
+
export declare class B2Folder implements SyncFolder {
|
|
8
|
+
readonly type: "b2";
|
|
9
|
+
private readonly bucket;
|
|
10
|
+
private readonly prefix;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new B2Folder for the given bucket and optional prefix.
|
|
13
|
+
* @param bucket - The B2 bucket to scan.
|
|
14
|
+
* @param prefix - Optional key prefix to restrict the scan scope.
|
|
15
|
+
*/
|
|
16
|
+
constructor(bucket: Bucket, prefix?: string);
|
|
17
|
+
/** Lists all file versions in the bucket, groups by name, and yields the latest visible version. */
|
|
18
|
+
scan(): AsyncGenerator<B2SyncPath>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=b2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2.d.ts","sourceRoot":"","sources":["../../../src/sync/scanners/b2.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEzD;;;GAGG;AACH,qBAAa,QAAS,YAAW,UAAU;IACzC,QAAQ,CAAC,IAAI,EAAG,IAAI,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAE/B;;;;OAIG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,SAAK;IAKvC,oGAAoG;IAC7F,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC;CA+C1C"}
|