@backblaze-labs/b2-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -5
- package/README.md +144 -33
- package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
- package/dist/_virtual/_b2-sdk-version-json.js +4 -0
- package/dist/auth/account-info.d.cts +32 -0
- package/dist/auth/account-info.d.cts.map +1 -1
- package/dist/auth/account-info.d.ts +32 -0
- package/dist/auth/account-info.d.ts.map +1 -1
- package/dist/auth/file.cjs +408 -207
- package/dist/auth/file.cjs.map +1 -1
- package/dist/auth/file.d.cts +77 -3
- package/dist/auth/file.d.cts.map +1 -1
- package/dist/auth/file.d.ts +77 -3
- package/dist/auth/file.d.ts.map +1 -1
- package/dist/auth/file.js +407 -207
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/in-memory.cjs +212 -183
- package/dist/auth/in-memory.cjs.map +1 -1
- package/dist/auth/in-memory.d.cts +8 -0
- package/dist/auth/in-memory.d.cts.map +1 -1
- package/dist/auth/in-memory.d.ts +8 -0
- package/dist/auth/in-memory.d.ts.map +1 -1
- package/dist/auth/in-memory.js +211 -182
- package/dist/auth/in-memory.js.map +1 -1
- package/dist/auth/index.cjs +7 -9
- package/dist/auth/index.d.cts +3 -2
- package/dist/auth/index.d.cts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -8
- package/dist/auth/realms.cjs +80 -7
- package/dist/auth/realms.cjs.map +1 -1
- package/dist/auth/realms.d.cts +27 -4
- package/dist/auth/realms.d.cts.map +1 -1
- package/dist/auth/realms.d.ts +27 -4
- package/dist/auth/realms.d.ts.map +1 -1
- package/dist/auth/realms.js +80 -9
- package/dist/auth/realms.js.map +1 -1
- package/dist/auth/upload-url-pool.cjs +55 -51
- package/dist/auth/upload-url-pool.cjs.map +1 -1
- package/dist/auth/upload-url-pool.js +55 -51
- package/dist/auth/upload-url-pool.js.map +1 -1
- package/dist/bucket.cjs +785 -787
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +35 -47
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +35 -47
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +780 -782
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +246 -228
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -17
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +25 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +243 -225
- package/dist/client.js.map +1 -1
- package/dist/copy/large.cjs +114 -71
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts +6 -0
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts +6 -0
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +112 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +89 -0
- package/dist/download/checksum.cjs.map +1 -0
- package/dist/download/checksum.d.cts +40 -0
- package/dist/download/checksum.d.cts.map +1 -0
- package/dist/download/checksum.d.ts +40 -0
- package/dist/download/checksum.d.ts.map +1 -0
- package/dist/download/checksum.js +87 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +214 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +5 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +5 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +212 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +188 -97
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +6 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +6 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +186 -98
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +699 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +285 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +285 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +678 -261
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +45 -28
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.d.cts +15 -2
- package/dist/http/retry.d.cts.map +1 -1
- package/dist/http/retry.d.ts +15 -2
- package/dist/http/retry.d.ts.map +1 -1
- package/dist/http/retry.js +46 -31
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +438 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +21 -2
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +21 -2
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +437 -140
- package/dist/http/transport.js.map +1 -1
- package/dist/http/url-guard.cjs +154 -89
- package/dist/http/url-guard.cjs.map +1 -1
- package/dist/http/url-guard.d.cts +25 -3
- package/dist/http/url-guard.d.cts.map +1 -1
- package/dist/http/url-guard.d.ts +25 -3
- package/dist/http/url-guard.d.ts.map +1 -1
- package/dist/http/url-guard.js +152 -90
- package/dist/http/url-guard.js.map +1 -1
- package/dist/http/user-agent.cjs +84 -44
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.js +84 -46
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +101 -77
- package/dist/index.d.cts +27 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -71
- package/dist/internal/b2-naming.cjs +66 -0
- package/dist/internal/b2-naming.cjs.map +1 -0
- package/dist/internal/b2-naming.d.cts +43 -0
- package/dist/internal/b2-naming.d.cts.map +1 -0
- package/dist/internal/b2-naming.d.ts +43 -0
- package/dist/internal/b2-naming.d.ts.map +1 -0
- package/dist/internal/b2-naming.js +60 -0
- package/dist/internal/b2-naming.js.map +1 -0
- package/dist/internal/upload-retry-options.cjs +21 -0
- package/dist/internal/upload-retry-options.cjs.map +1 -0
- package/dist/internal/upload-retry-options.d.cts +12 -0
- package/dist/internal/upload-retry-options.d.cts.map +1 -0
- package/dist/internal/upload-retry-options.d.ts +12 -0
- package/dist/internal/upload-retry-options.d.ts.map +1 -0
- package/dist/internal/upload-retry-options.js +21 -0
- package/dist/internal/upload-retry-options.js.map +1 -0
- package/dist/internal/url-redaction.cjs +31 -0
- package/dist/internal/url-redaction.cjs.map +1 -0
- package/dist/internal/url-redaction.d.cts +17 -0
- package/dist/internal/url-redaction.d.cts.map +1 -0
- package/dist/internal/url-redaction.d.ts +17 -0
- package/dist/internal/url-redaction.d.ts.map +1 -0
- package/dist/internal/url-redaction.js +31 -0
- package/dist/internal/url-redaction.js.map +1 -0
- package/dist/notifications/index.cjs +4 -6
- package/dist/notifications/index.d.cts +1 -1
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -6
- package/dist/notifications/webhook.cjs +195 -85
- package/dist/notifications/webhook.cjs.map +1 -1
- package/dist/notifications/webhook.d.cts.map +1 -1
- package/dist/notifications/webhook.d.ts.map +1 -1
- package/dist/notifications/webhook.js +195 -87
- package/dist/notifications/webhook.js.map +1 -1
- package/dist/object.cjs +253 -210
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +9 -55
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +9 -55
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- package/dist/raw/encoding.cjs +74 -35
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.js +74 -38
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +678 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +121 -18
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +121 -18
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +674 -589
- package/dist/raw/index.js.map +1 -1
- package/dist/s3/index.cjs +355 -18
- package/dist/s3/index.cjs.map +1 -1
- package/dist/s3/index.d.cts +233 -5
- package/dist/s3/index.d.cts.map +1 -1
- package/dist/s3/index.d.ts +233 -5
- package/dist/s3/index.d.ts.map +1 -1
- package/dist/s3/index.js +351 -22
- package/dist/s3/index.js.map +1 -1
- package/dist/s3/sigv4.cjs +149 -0
- package/dist/s3/sigv4.cjs.map +1 -0
- package/dist/s3/sigv4.d.cts +43 -0
- package/dist/s3/sigv4.d.cts.map +1 -0
- package/dist/s3/sigv4.d.ts +43 -0
- package/dist/s3/sigv4.d.ts.map +1 -0
- package/dist/s3/sigv4.js +148 -0
- package/dist/s3/sigv4.js.map +1 -0
- package/dist/s3/validation.cjs +69 -0
- package/dist/s3/validation.cjs.map +1 -0
- package/dist/s3/validation.d.cts +43 -0
- package/dist/s3/validation.d.cts.map +1 -0
- package/dist/s3/validation.d.ts +43 -0
- package/dist/s3/validation.d.ts.map +1 -0
- package/dist/s3/validation.js +66 -0
- package/dist/s3/validation.js.map +1 -0
- package/dist/simulator/capabilities.cjs +63 -48
- package/dist/simulator/capabilities.cjs.map +1 -1
- package/dist/simulator/capabilities.js +63 -49
- package/dist/simulator/capabilities.js.map +1 -1
- package/dist/simulator/index.cjs +2124 -1548
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +79 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +79 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2112 -1546
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/validation.cjs +191 -153
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +3 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +3 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +188 -162
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/collect.cjs +74 -24
- package/dist/streams/collect.cjs.map +1 -1
- package/dist/streams/collect.d.cts +14 -1
- package/dist/streams/collect.d.cts.map +1 -1
- package/dist/streams/collect.d.ts +14 -1
- package/dist/streams/collect.d.ts.map +1 -1
- package/dist/streams/collect.js +74 -25
- package/dist/streams/collect.js.map +1 -1
- package/dist/streams/file-source.cjs +287 -0
- package/dist/streams/file-source.cjs.map +1 -0
- package/dist/streams/file-source.d.cts +96 -0
- package/dist/streams/file-source.d.cts.map +1 -0
- package/dist/streams/file-source.d.ts +96 -0
- package/dist/streams/file-source.d.ts.map +1 -0
- package/dist/streams/file-source.js +286 -0
- package/dist/streams/file-source.js.map +1 -0
- package/dist/streams/hash.cjs +207 -115
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +5 -4
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +5 -4
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +208 -95
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +12 -12
- package/dist/streams/index.d.cts +3 -3
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +3 -3
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +2 -10
- package/dist/streams/progress.cjs +60 -46
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.js +60 -46
- package/dist/streams/progress.js.map +1 -1
- package/dist/streams/source.cjs +316 -146
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.d.cts +56 -18
- package/dist/streams/source.d.cts.map +1 -1
- package/dist/streams/source.d.ts +56 -18
- package/dist/streams/source.d.ts.map +1 -1
- package/dist/streams/source.js +312 -149
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/actions/index.cjs +236 -184
- package/dist/sync/actions/index.cjs.map +1 -1
- package/dist/sync/actions/index.d.cts +29 -21
- package/dist/sync/actions/index.d.cts.map +1 -1
- package/dist/sync/actions/index.d.ts +29 -21
- package/dist/sync/actions/index.d.ts.map +1 -1
- package/dist/sync/actions/index.js +236 -190
- package/dist/sync/actions/index.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +148 -0
- package/dist/sync/b2-sha1-reader.cjs.map +1 -0
- package/dist/sync/b2-sha1-reader.d.cts +58 -0
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
- package/dist/sync/b2-sha1-reader.d.ts +58 -0
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
- package/dist/sync/b2-sha1-reader.js +145 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +265 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +54 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +54 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +259 -0
- package/dist/sync/download-staging.js.map +1 -0
- package/dist/sync/filesystem-errors.cjs +32 -0
- package/dist/sync/filesystem-errors.cjs.map +1 -0
- package/dist/sync/filesystem-errors.d.cts +8 -0
- package/dist/sync/filesystem-errors.d.cts.map +1 -0
- package/dist/sync/filesystem-errors.d.ts +8 -0
- package/dist/sync/filesystem-errors.d.ts.map +1 -0
- package/dist/sync/filesystem-errors.js +32 -0
- package/dist/sync/filesystem-errors.js.map +1 -0
- package/dist/sync/filters.cjs +217 -0
- package/dist/sync/filters.cjs.map +1 -0
- package/dist/sync/filters.d.cts +51 -0
- package/dist/sync/filters.d.cts.map +1 -0
- package/dist/sync/filters.d.ts +51 -0
- package/dist/sync/filters.d.ts.map +1 -0
- package/dist/sync/filters.js +213 -0
- package/dist/sync/filters.js.map +1 -0
- package/dist/sync/index.cjs +39 -22
- package/dist/sync/index.d.cts +14 -9
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +14 -9
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -20
- package/dist/sync/local-file-identity.cjs +61 -0
- package/dist/sync/local-file-identity.cjs.map +1 -0
- package/dist/sync/local-file-identity.d.cts +37 -0
- package/dist/sync/local-file-identity.d.cts.map +1 -0
- package/dist/sync/local-file-identity.d.ts +37 -0
- package/dist/sync/local-file-identity.d.ts.map +1 -0
- package/dist/sync/local-file-identity.js +60 -0
- package/dist/sync/local-file-identity.js.map +1 -0
- package/dist/sync/local-file-io.cjs +364 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +75 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +75 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +360 -0
- package/dist/sync/local-file-io.js.map +1 -0
- package/dist/sync/local-filesystem-root.cjs +27 -0
- package/dist/sync/local-filesystem-root.cjs.map +1 -0
- package/dist/sync/local-filesystem-root.d.cts +18 -0
- package/dist/sync/local-filesystem-root.d.cts.map +1 -0
- package/dist/sync/local-filesystem-root.d.ts +18 -0
- package/dist/sync/local-filesystem-root.d.ts.map +1 -0
- package/dist/sync/local-filesystem-root.js +26 -0
- package/dist/sync/local-filesystem-root.js.map +1 -0
- package/dist/sync/local-sha1.cjs +119 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +39 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +39 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +117 -0
- package/dist/sync/local-sha1.js.map +1 -0
- package/dist/sync/pairing.cjs +118 -29
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.d.cts +7 -2
- package/dist/sync/pairing.d.cts.map +1 -1
- package/dist/sync/pairing.d.ts +7 -2
- package/dist/sync/pairing.d.ts.map +1 -1
- package/dist/sync/pairing.js +120 -31
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/path-order.cjs +30 -0
- package/dist/sync/path-order.cjs.map +1 -0
- package/dist/sync/path-order.d.cts +28 -0
- package/dist/sync/path-order.d.cts.map +1 -0
- package/dist/sync/path-order.d.ts +28 -0
- package/dist/sync/path-order.d.ts.map +1 -0
- package/dist/sync/path-order.js +29 -0
- package/dist/sync/path-order.js.map +1 -0
- package/dist/sync/path-safety.cjs +111 -0
- package/dist/sync/path-safety.cjs.map +1 -0
- package/dist/sync/path-safety.d.cts +78 -0
- package/dist/sync/path-safety.d.cts.map +1 -0
- package/dist/sync/path-safety.d.ts +78 -0
- package/dist/sync/path-safety.d.ts.map +1 -0
- package/dist/sync/path-safety.js +105 -0
- package/dist/sync/path-safety.js.map +1 -0
- package/dist/sync/paths.d.cts +19 -0
- package/dist/sync/paths.d.cts.map +1 -0
- package/dist/sync/paths.d.ts +19 -0
- package/dist/sync/paths.d.ts.map +1 -0
- package/dist/sync/policies/compare.cjs +389 -11
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts +100 -2
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts +100 -2
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +387 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +76 -65
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.d.cts +35 -6
- package/dist/sync/policies/index.d.cts.map +1 -1
- package/dist/sync/policies/index.d.ts +35 -6
- package/dist/sync/policies/index.d.ts.map +1 -1
- package/dist/sync/policies/index.js +76 -65
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/prefix.cjs +96 -0
- package/dist/sync/prefix.cjs.map +1 -0
- package/dist/sync/prefix.d.cts +55 -0
- package/dist/sync/prefix.d.cts.map +1 -0
- package/dist/sync/prefix.d.ts +55 -0
- package/dist/sync/prefix.d.ts.map +1 -0
- package/dist/sync/prefix.js +92 -0
- package/dist/sync/prefix.js.map +1 -0
- package/dist/sync/regexp-safety.cjs +192 -0
- package/dist/sync/regexp-safety.cjs.map +1 -0
- package/dist/sync/regexp-safety.d.cts +29 -0
- package/dist/sync/regexp-safety.d.cts.map +1 -0
- package/dist/sync/regexp-safety.d.ts +29 -0
- package/dist/sync/regexp-safety.d.ts.map +1 -0
- package/dist/sync/regexp-safety.js +190 -0
- package/dist/sync/regexp-safety.js.map +1 -0
- package/dist/sync/scan-events.cjs +33 -0
- package/dist/sync/scan-events.cjs.map +1 -0
- package/dist/sync/scan-events.d.cts +17 -0
- package/dist/sync/scan-events.d.cts.map +1 -0
- package/dist/sync/scan-events.d.ts +17 -0
- package/dist/sync/scan-events.d.ts.map +1 -0
- package/dist/sync/scan-events.js +32 -0
- package/dist/sync/scan-events.js.map +1 -0
- package/dist/sync/scan-limit.cjs +33 -0
- package/dist/sync/scan-limit.cjs.map +1 -0
- package/dist/sync/scan-limit.d.cts +21 -0
- package/dist/sync/scan-limit.d.cts.map +1 -0
- package/dist/sync/scan-limit.d.ts +21 -0
- package/dist/sync/scan-limit.d.ts.map +1 -0
- package/dist/sync/scan-limit.js +31 -0
- package/dist/sync/scan-limit.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +239 -55
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts +26 -7
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts +26 -7
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +239 -55
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +215 -56
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +22 -7
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +22 -7
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +216 -57
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/sha1-metadata.cjs +94 -0
- package/dist/sync/sha1-metadata.cjs.map +1 -0
- package/dist/sync/sha1-metadata.d.cts +82 -0
- package/dist/sync/sha1-metadata.d.cts.map +1 -0
- package/dist/sync/sha1-metadata.d.ts +82 -0
- package/dist/sync/sha1-metadata.d.ts.map +1 -0
- package/dist/sync/sha1-metadata.js +89 -0
- package/dist/sync/sha1-metadata.js.map +1 -0
- package/dist/sync/sha1-options.cjs +23 -0
- package/dist/sync/sha1-options.cjs.map +1 -0
- package/dist/sync/sha1-options.d.cts +14 -0
- package/dist/sync/sha1-options.d.cts.map +1 -0
- package/dist/sync/sha1-options.d.ts +14 -0
- package/dist/sync/sha1-options.d.ts.map +1 -0
- package/dist/sync/sha1-options.js +21 -0
- package/dist/sync/sha1-options.js.map +1 -0
- package/dist/sync/synchronizer.cjs +782 -197
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +47 -1
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +47 -1
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +779 -173
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +208 -16
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +208 -16
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/auth.cjs +76 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +67 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +67 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +77 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/encryption.cjs +364 -327
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +16 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +16 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +364 -310
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +47 -0
- package/dist/types/errors.cjs.map +1 -0
- package/dist/types/errors.d.cts +13 -4
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +47 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/file.cjs +36 -19
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +2 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +37 -21
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +53 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.js +54 -15
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +12 -11
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +44 -8
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +44 -8
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/lock.cjs +33 -13
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.js +34 -15
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +44 -22
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/upload.d.cts +39 -5
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +39 -5
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +91 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +48 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +48 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +88 -0
- package/dist/upload/abort-scope.js.map +1 -0
- package/dist/upload/cancel.cjs +183 -8
- package/dist/upload/cancel.cjs.map +1 -1
- package/dist/upload/cancel.d.cts +110 -2
- package/dist/upload/cancel.d.cts.map +1 -1
- package/dist/upload/cancel.d.ts +110 -2
- package/dist/upload/cancel.d.ts.map +1 -1
- package/dist/upload/cancel.js +178 -9
- package/dist/upload/cancel.js.map +1 -1
- package/dist/upload/concurrency.cjs +79 -52
- package/dist/upload/concurrency.cjs.map +1 -1
- package/dist/upload/concurrency.js +79 -53
- package/dist/upload/concurrency.js.map +1 -1
- package/dist/upload/finish.cjs +59 -0
- package/dist/upload/finish.cjs.map +1 -0
- package/dist/upload/finish.d.cts +26 -0
- package/dist/upload/finish.d.cts.map +1 -0
- package/dist/upload/finish.d.ts +26 -0
- package/dist/upload/finish.d.ts.map +1 -0
- package/dist/upload/finish.js +59 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +301 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +76 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +76 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +301 -218
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs +28 -0
- package/dist/upload/options.cjs.map +1 -0
- package/dist/upload/options.d.cts +104 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +104 -0
- package/dist/upload/options.d.ts.map +1 -0
- package/dist/upload/options.js +27 -0
- package/dist/upload/options.js.map +1 -0
- package/dist/upload/resume.cjs +333 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +82 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +82 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +330 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +186 -0
- package/dist/upload/retry.cjs.map +1 -0
- package/dist/upload/retry.d.cts +127 -0
- package/dist/upload/retry.d.cts.map +1 -0
- package/dist/upload/retry.d.ts +127 -0
- package/dist/upload/retry.d.ts.map +1 -0
- package/dist/upload/retry.js +182 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +68 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +2 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +2 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +68 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +317 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +3 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +3 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +316 -192
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/best-effort.cjs +42 -8
- package/dist/util/best-effort.cjs.map +1 -1
- package/dist/util/best-effort.d.cts +2 -1
- package/dist/util/best-effort.d.cts.map +1 -1
- package/dist/util/best-effort.d.ts +2 -1
- package/dist/util/best-effort.d.ts.map +1 -1
- package/dist/util/best-effort.js +43 -9
- package/dist/util/best-effort.js.map +1 -1
- package/dist/util/bytes.cjs +23 -0
- package/dist/util/bytes.cjs.map +1 -0
- package/dist/util/bytes.d.cts +15 -0
- package/dist/util/bytes.d.cts.map +1 -0
- package/dist/util/bytes.d.ts +15 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +23 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/crypto.cjs +68 -0
- package/dist/util/crypto.cjs.map +1 -0
- package/dist/util/crypto.d.cts +26 -0
- package/dist/util/crypto.d.cts.map +1 -0
- package/dist/util/crypto.d.ts +26 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +66 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/defaults.cjs +25 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.js +26 -11
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/error-reason.cjs +41 -0
- package/dist/util/error-reason.cjs.map +1 -0
- package/dist/util/error-reason.d.cts +9 -0
- package/dist/util/error-reason.d.cts.map +1 -0
- package/dist/util/error-reason.d.ts +9 -0
- package/dist/util/error-reason.d.ts.map +1 -0
- package/dist/util/error-reason.js +41 -0
- package/dist/util/error-reason.js.map +1 -0
- package/dist/util/http.cjs +23 -0
- package/dist/util/http.cjs.map +1 -0
- package/dist/util/http.d.cts +13 -0
- package/dist/util/http.d.cts.map +1 -0
- package/dist/util/http.d.ts +13 -0
- package/dist/util/http.d.ts.map +1 -0
- package/dist/util/http.js +23 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +63 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.js +64 -16
- package/dist/util/paginator.js.map +1 -1
- package/dist/util/plan-ranges.cjs +47 -22
- package/dist/util/plan-ranges.cjs.map +1 -1
- package/dist/util/plan-ranges.js +48 -24
- package/dist/util/plan-ranges.js.map +1 -1
- package/dist/util/sha1.cjs +27 -0
- package/dist/util/sha1.cjs.map +1 -0
- package/dist/util/sha1.d.cts +17 -0
- package/dist/util/sha1.d.cts.map +1 -0
- package/dist/util/sha1.d.ts +17 -0
- package/dist/util/sha1.d.ts.map +1 -0
- package/dist/util/sha1.js +26 -0
- package/dist/util/sha1.js.map +1 -0
- package/dist/util/text-codec.cjs +29 -5
- package/dist/util/text-codec.cjs.map +1 -1
- package/dist/util/text-codec.js +30 -7
- package/dist/util/text-codec.js.map +1 -1
- package/dist/util/to-error.cjs +18 -4
- package/dist/util/to-error.cjs.map +1 -1
- package/dist/util/to-error.js +19 -5
- package/dist/util/to-error.js.map +1 -1
- package/dist/version.cjs +17 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -3
- package/dist/version.d.ts +3 -3
- package/dist/version.js +19 -6
- package/dist/version.js.map +1 -1
- package/package.json +19 -16
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications/index.cjs.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/package.json.cjs +0 -9
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -9
- package/dist/package.json.js.map +0 -1
- package/dist/streams/index.cjs.map +0 -1
- package/dist/streams/index.js.map +0 -1
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.js.map +0 -1
|
@@ -1 +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;"}
|
|
1
|
+
{"version":3,"file":"compare.js","names":[],"sources":["../../../src/sync/policies/compare.ts"],"sourcesContent":["import { mapConcurrent } from '../../upload/concurrency.ts'\nimport { normalizeVerifiableSha1 } from '../../util/sha1.ts'\nimport { toError } from '../../util/to-error.ts'\nimport { formatHashError, isAbortError, type LocalSha1Reader } from '../local-sha1.ts'\nimport type { SyncPair } from '../pairing.ts'\nimport { selectB2ComparableSha1, syncSha1StateOf } from '../sha1-metadata.ts'\nimport type {\n B2SyncPath,\n CompareMode,\n LocalSyncPath,\n SyncEvent,\n SyncPath,\n SyncSkipEvent,\n} from '../types.ts'\n\nexport { selectB2ComparableSha1 } from '../sha1-metadata.ts'\n\n/** Result from a B2 SHA-1 verification read. */\nexport interface B2Sha1ReadResult {\n /** SHA-1 digest of the selected B2 bytes, or null when unavailable. */\n readonly contentSha1: string | null\n /** Number of B2 bytes downloaded and hashed while verifying. */\n readonly bytesRead: number\n}\n\n/** Reads a B2 file and returns the SHA-1 digest of its actual bytes, or null when unavailable. */\nexport type B2Sha1Reader = (\n path: B2SyncPath,\n signal?: AbortSignal,\n) => Promise<string | null | B2Sha1ReadResult>\n\n/** Options for preparing a file pair before comparison. */\nexport interface PreparePairForCompareOptions {\n /** Signal used to abort local file hashing. */\n readonly signal?: AbortSignal\n /** Optional idle/no-progress timeout for local SHA-1 reads. */\n readonly sha1ReadTimeoutMillis?: number\n /** Optional local hashing override for tests or custom runtimes. */\n readonly readLocalSha1?: LocalSha1Reader\n /** Optional B2 hashing override used to verify metadata matches before skipping. */\n readonly readB2Sha1?: B2Sha1Reader\n}\n\n/** Options for preparing multiple file pairs before comparison. */\nexport interface PreparePairsForCompareOptions extends PreparePairForCompareOptions {\n /** Maximum number of file pairs to prepare concurrently. */\n readonly concurrency?: number\n}\n\n/** Result of preparing a file pair before policy comparison. */\nexport interface ComparePreparationResult {\n /** The pair with compare-mode metadata populated where possible. */\n readonly pair: SyncPair\n /** Events surfaced while preparing the pair, such as per-file hash errors or skips. */\n readonly events: readonly SyncEvent[]\n /** Errors surfaced while preparing the pair. These contribute to the final summary. */\n readonly errors: readonly Error[]\n /** Local file bytes read for hashing while preparing this pair. */\n readonly bytesHashed: number\n /** B2 bytes read for untrusted metadata verification while preparing this pair. */\n readonly bytesVerified: number\n /** Whether action generation should be skipped for this pair. */\n readonly skipActionGeneration: boolean\n /** Whether preparation stopped because the abort signal fired. */\n readonly aborted: boolean\n}\n\n/** A prepared pair result with the original pair retained for event context. */\nexport interface PreparedComparePair {\n /** Original pair from {@link zipFolders}. */\n readonly originalPair: SyncPair\n /** Preparation result for the original pair. */\n readonly prepared: ComparePreparationResult\n}\n\n/**\n * Determines whether two files should be considered different based on the compare mode.\n * For `sha1`, callers that use the low-level policy helpers should first prepare the pair so\n * local hashes and comparable B2 hashes are populated.\n *\n * @param source - The source file metadata.\n * @param dest - The destination file metadata.\n * @param compareMode - The comparison strategy: 'modtime', 'size', 'sha1', 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 *\n * @throws When `compareMode` is not one of the supported compare modes.\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 'sha1':\n return sha1ValuesAreDifferent(source, dest)\n case 'modtime':\n return Math.abs(source.modTimeMillis - dest.modTimeMillis) > threshold\n default:\n throw new Error(`Unsupported compare mode: ${String(compareMode)}`)\n }\n}\n\n/**\n * Throws when a runtime compare mode value is unsupported.\n *\n * @param compareMode - User-supplied compare mode.\n *\n * @throws When `compareMode` is not one of the supported values.\n */\nexport function assertSupportedCompareMode(\n compareMode: unknown,\n): asserts compareMode is CompareMode {\n switch (compareMode) {\n case 'none':\n case 'size':\n case 'sha1':\n case 'modtime':\n return\n default:\n throw new Error(`Unsupported compare mode: ${String(compareMode)}`)\n }\n}\n\nfunction sha1ValuesAreDifferent(source: SyncPath, dest: SyncPath): boolean {\n if (source.size !== dest.size) return true\n\n const sourceSha1 = comparableSha1(source)\n const destSha1 = comparableSha1(dest)\n if (sourceSha1.kind === 'untrusted' || destSha1.kind === 'untrusted') return true\n if (sourceSha1.kind === 'unavailable' || destSha1.kind === 'unavailable') return true\n return sourceSha1.value !== destSha1.value\n}\n\n/**\n * Prepares a pair for the selected compare mode.\n *\n * For `sha1`, this fills missing B2 hashes from comparable metadata and, when an explicit local\n * reader is supplied, hashes the local side only when size cannot already prove a difference.\n * Reader failures are converted into per-file sync events instead of aborting the whole run.\n *\n * @param pair - Source/destination pair from {@link zipFolders}.\n * @param compareMode - The comparison strategy.\n * @param options - Optional hashing dependencies and cancellation signal.\n *\n * @returns The prepared pair plus any preparation events.\n */\nexport async function preparePairForCompare(\n pair: SyncPair,\n compareMode: CompareMode,\n options: PreparePairForCompareOptions = {},\n): Promise<ComparePreparationResult> {\n assertSupportedCompareMode(compareMode)\n if (compareMode !== 'sha1') return readyComparePair(pair)\n\n const [source, dest] = pair\n if (source === null || dest === null) return readyComparePair(pair)\n if (source.size !== dest.size) return readyComparePair(pair)\n\n const metadataPair: SyncPair = [withB2ContentSha1(source), withB2ContentSha1(dest)]\n if (hasUnavailableB2Sha1(metadataPair)) {\n return skipped(metadataPair, unavailableSha1Event(metadataPair))\n }\n if (\n options.readB2Sha1 === undefined &&\n hasUntrustedSha1(metadataPair) &&\n !hasVerifiableUntrustedSha1(metadataPair)\n ) {\n return readyComparePair(metadataPair)\n }\n\n const [metadataSource, metadataDest] = metadataPair\n if (metadataSource === null || metadataDest === null) return readyComparePair(metadataPair)\n\n const sourceResult = await prepareLocalPathSha1(metadataSource, options)\n if (sourceResult.aborted) return aborted(metadataPair)\n if (sourceResult.event) {\n return skipped(metadataPair, sourceResult.event, sourceResult.error, sourceResult.bytesHashed)\n }\n\n const destResult = await prepareLocalPathSha1(metadataDest, options)\n if (destResult.aborted) return aborted([sourceResult.path, destResult.path])\n if (destResult.event) {\n return skipped(\n [sourceResult.path, destResult.path],\n destResult.event,\n destResult.error,\n sourceResult.bytesHashed,\n )\n }\n\n const preparedPair: SyncPair = [sourceResult.path, destResult.path]\n const sourceState = comparableSha1(sourceResult.path)\n const destState = comparableSha1(destResult.path)\n const bytesHashed = sourceResult.bytesHashed + destResult.bytesHashed\n\n if (sourceState.kind === 'unavailable' || destState.kind === 'unavailable') {\n return skipped(preparedPair, unavailableSha1Event(preparedPair), undefined, bytesHashed)\n }\n\n const shouldVerifyB2Bytes = untrustedSha1CouldSuppressTransfer(sourceState, destState)\n const readB2Sha1 = options.readB2Sha1\n if (shouldVerifyB2Bytes && hasB2Path(preparedPair) && readB2Sha1 !== undefined) {\n return verifyB2Sha1Bytes(preparedPair, { ...options, readB2Sha1 }, bytesHashed)\n }\n\n return readyComparePair(preparedPair, bytesHashed)\n}\n\n/**\n * Prepares a list of pairs for the selected compare mode with bounded concurrency.\n *\n * @param pairs - Source/destination pairs from {@link zipFolders}.\n * @param compareMode - The comparison strategy.\n * @param options - Optional hashing dependencies, cancellation signal, and concurrency.\n *\n * @returns Prepared results in the same order as the input pairs.\n */\nexport async function preparePairsForCompare(\n pairs: readonly SyncPair[],\n compareMode: CompareMode,\n options: PreparePairsForCompareOptions = {},\n): Promise<PreparedComparePair[]> {\n assertSupportedCompareMode(compareMode)\n if (compareMode !== 'sha1') {\n return pairs.map((pair) => ({ originalPair: pair, prepared: readyComparePair(pair) }))\n }\n\n const concurrency = normalizeConcurrency(options.concurrency)\n return mapConcurrent(pairs, concurrency, async (pair): Promise<PreparedComparePair> => {\n if (options.signal?.aborted) return { originalPair: pair, prepared: aborted(pair) }\n return {\n originalPair: pair,\n prepared: await preparePairForCompare(pair, compareMode, options),\n }\n })\n}\n\ntype Sha1State =\n | { readonly kind: 'verified'; readonly value: string }\n | { readonly kind: 'untrusted'; readonly value: string | null }\n | { readonly kind: 'unavailable' }\n\ninterface PreparedPath {\n readonly path: SyncPath\n readonly bytesHashed: number\n readonly bytesVerified: number\n readonly event?: SyncEvent\n readonly error?: Error\n readonly aborted: boolean\n}\n\nasync function prepareLocalPathSha1(\n path: SyncPath,\n options: PreparePairForCompareOptions,\n): Promise<PreparedPath> {\n if (!isLocalSyncPath(path)) {\n return { path, bytesHashed: 0, bytesVerified: 0, aborted: false }\n }\n\n if (options.signal?.aborted) return { path, bytesHashed: 0, bytesVerified: 0, aborted: true }\n\n try {\n const state = syncSha1StateOf(path)\n if (state.kind === 'verified') {\n return {\n path: { ...path, contentSha1: state.value },\n bytesHashed: 0,\n bytesVerified: 0,\n aborted: false,\n }\n }\n if (state.kind === 'unavailable') {\n return {\n path: { ...path, contentSha1: null },\n bytesHashed: 0,\n bytesVerified: 0,\n aborted: false,\n }\n }\n\n const readLocalSha1 = options.readLocalSha1\n if (readLocalSha1 === undefined) {\n return {\n path: { ...path, contentSha1: path.contentSha1 ?? null },\n bytesHashed: 0,\n bytesVerified: 0,\n aborted: false,\n }\n }\n const contentSha1 = await readLocalSha1(path, options.signal, {\n ...(options.sha1ReadTimeoutMillis !== undefined\n ? { timeoutMillis: options.sha1ReadTimeoutMillis }\n : {}),\n })\n return {\n path: {\n ...path,\n contentSha1,\n },\n bytesHashed: normalizeVerifiableSha1(contentSha1) === null ? 0 : path.size,\n bytesVerified: 0,\n aborted: false,\n }\n } catch (err) {\n if (options.signal?.aborted || isAbortError(err)) {\n return { path, bytesHashed: 0, bytesVerified: 0, aborted: true }\n }\n const error = toError(err)\n return {\n path,\n bytesHashed: 0,\n event: {\n type: 'error',\n path: path.relativePath,\n size: 0,\n message: `failed to hash local file for sha1 comparison: ${formatHashError(error)}`,\n },\n error,\n bytesVerified: 0,\n aborted: false,\n }\n }\n}\n\nasync function verifyB2Sha1Bytes(\n pair: SyncPair,\n options: PreparePairForCompareOptions & { readonly readB2Sha1: B2Sha1Reader },\n bytesHashed: number,\n): Promise<ComparePreparationResult> {\n const [source, dest] = pair\n /* v8 ignore next -- callers only verify B2 bytes for paired compare results */\n if (source === null || dest === null) return readyComparePair(pair, bytesHashed)\n\n const sourceResult = await prepareUntrustedB2PathSha1(source, options)\n const sourceBytesVerified = sourceResult.bytesVerified\n if (sourceResult.aborted) return aborted(pair)\n if (sourceResult.event) {\n return skipped(\n [sourceResult.path, dest],\n sourceResult.event,\n sourceResult.error,\n bytesHashed,\n sourceBytesVerified,\n )\n }\n\n const destResult = await prepareUntrustedB2PathSha1(dest, options)\n const bytesVerified = sourceBytesVerified + destResult.bytesVerified\n /* v8 ignore next -- destination abort mirrors the covered source abort path */\n if (destResult.aborted) return aborted([sourceResult.path, destResult.path])\n if (destResult.event) {\n return skipped(\n [sourceResult.path, destResult.path],\n destResult.event,\n destResult.error,\n bytesHashed,\n bytesVerified,\n )\n }\n\n return readyComparePair([sourceResult.path, destResult.path], bytesHashed, bytesVerified)\n}\n\nasync function prepareUntrustedB2PathSha1(\n path: SyncPath,\n options: PreparePairForCompareOptions & { readonly readB2Sha1: B2Sha1Reader },\n): Promise<PreparedPath> {\n if (!isB2SyncPath(path) || comparableSha1(path).kind !== 'untrusted') {\n return { path, bytesHashed: 0, bytesVerified: 0, aborted: false }\n }\n return prepareB2PathSha1(path, options)\n}\n\nasync function prepareB2PathSha1(\n path: B2SyncPath,\n options: PreparePairForCompareOptions & { readonly readB2Sha1: B2Sha1Reader },\n): Promise<PreparedPath> {\n /* v8 ignore next -- pre-aborted B2 reads are covered at pair level */\n if (options.signal?.aborted) return { path, bytesHashed: 0, bytesVerified: 0, aborted: true }\n\n try {\n const result = await options.readB2Sha1(path, options.signal)\n const contentSha1 = typeof result === 'object' && result !== null ? result.contentSha1 : result\n const bytesVerified =\n typeof result === 'object' && result !== null ? Math.max(0, result.bytesRead) : 0\n const preparedPath = {\n ...path,\n contentSha1,\n contentSha1State: syncSha1StateOf({ contentSha1 }),\n }\n if (contentSha1 === null) {\n return {\n path: preparedPath,\n bytesHashed: 0,\n bytesVerified,\n event: unavailableSha1PathEvent(path),\n aborted: false,\n }\n }\n return {\n path: preparedPath,\n bytesHashed: 0,\n bytesVerified,\n aborted: false,\n }\n } catch (err) {\n if (options.signal?.aborted || isAbortError(err)) {\n return { path, bytesHashed: 0, bytesVerified: 0, aborted: true }\n }\n const error = toError(err)\n return {\n path,\n bytesHashed: 0,\n bytesVerified: 0,\n event: {\n type: 'skip',\n path: path.relativePath,\n size: 0,\n message: `sha1 comparison skipped because B2 verification failed: ${formatHashError(error)}`,\n },\n aborted: false,\n }\n }\n}\n\nfunction comparableSha1(path: SyncPath): Sha1State {\n const state = syncSha1StateOf(path)\n if (state.kind === 'verified') return { kind: 'verified', value: state.value }\n if (state.kind === 'untrusted') return { kind: 'untrusted', value: state.value }\n return { kind: 'unavailable' }\n}\n\nfunction untrustedSha1CouldSuppressTransfer(source: Sha1State, dest: Sha1State): boolean {\n if (source.kind === 'untrusted' && dest.kind === 'verified') return source.value === dest.value\n if (dest.kind === 'untrusted' && source.kind === 'verified') return dest.value === source.value\n if (source.kind === 'untrusted' && dest.kind === 'untrusted') {\n return source.value !== null && source.value === dest.value\n }\n return false\n}\n\nfunction withB2ContentSha1(path: SyncPath): SyncPath {\n if (\n !isB2SyncPath(path) ||\n path.contentSha1 !== undefined ||\n path.contentSha1State !== undefined\n ) {\n return path\n }\n const contentSha1 = selectB2ComparableSha1(path.selectedVersion)\n return { ...path, contentSha1, contentSha1State: syncSha1StateOf({ contentSha1 }) }\n}\n\nfunction hasUnavailableB2Sha1(pair: SyncPair): boolean {\n const [source, dest] = pair\n return (\n (source !== null && isB2SyncPath(source) && comparableSha1(source).kind === 'unavailable') ||\n (dest !== null && isB2SyncPath(dest) && comparableSha1(dest).kind === 'unavailable')\n )\n}\n\nfunction hasUntrustedSha1(pair: SyncPair): boolean {\n const [source, dest] = pair\n return (\n (source !== null && comparableSha1(source).kind === 'untrusted') ||\n (dest !== null && comparableSha1(dest).kind === 'untrusted')\n )\n}\n\nfunction hasVerifiableUntrustedSha1(pair: SyncPair): boolean {\n const [source, dest] = pair\n return (\n (source !== null && verifiableUntrustedSha1(source)) ||\n (dest !== null && verifiableUntrustedSha1(dest))\n )\n}\n\nfunction verifiableUntrustedSha1(path: SyncPath): boolean {\n const state = comparableSha1(path)\n return state.kind === 'untrusted' && state.value !== null\n}\n\nfunction hasB2Path(pair: SyncPair): boolean {\n const [source, dest] = pair\n return (source !== null && isB2SyncPath(source)) || (dest !== null && isB2SyncPath(dest))\n}\n\nfunction isB2SyncPath(path: SyncPath): path is B2SyncPath {\n return 'selectedVersion' in path\n}\n\nfunction isLocalSyncPath(path: SyncPath): path is LocalSyncPath {\n return 'absolutePath' in path\n}\n\n/**\n * Creates a successful no-op compare preparation result for a pair.\n *\n * @param pair - Source/destination pair from {@link zipFolders}.\n * @param bytesHashed - Local file bytes read while preparing the pair.\n * @param bytesVerified - B2 bytes read while verifying untrusted SHA-1 metadata.\n *\n * @returns A ready preparation result that allows action generation.\n */\nexport function readyComparePair(\n pair: SyncPair,\n bytesHashed = 0,\n bytesVerified = 0,\n): ComparePreparationResult {\n return {\n pair,\n events: [],\n errors: [],\n bytesHashed,\n bytesVerified,\n skipActionGeneration: false,\n aborted: false,\n }\n}\n\nfunction skipped(\n pair: SyncPair,\n event: SyncEvent,\n error?: Error,\n bytesHashed = 0,\n bytesVerified = 0,\n): ComparePreparationResult {\n return {\n pair,\n events: [event],\n errors: error !== undefined ? [error] : [],\n bytesHashed,\n bytesVerified,\n skipActionGeneration: true,\n aborted: false,\n }\n}\n\nfunction aborted(pair: SyncPair): ComparePreparationResult {\n return {\n pair,\n events: [],\n errors: [],\n bytesHashed: 0,\n bytesVerified: 0,\n skipActionGeneration: true,\n aborted: true,\n }\n}\n\nfunction unavailableSha1Event(pair: SyncPair): SyncSkipEvent {\n /* v8 ignore next -- unavailable SHA-1 events always have at least one side */\n const path = (pair[0] ?? pair[1])?.relativePath ?? ''\n return unavailableSha1PathEvent({ relativePath: path })\n}\n\nfunction unavailableSha1PathEvent(path: Pick<SyncPath, 'relativePath'>): SyncSkipEvent {\n return {\n type: 'skip',\n path: path.relativePath,\n size: 0,\n message: 'sha1 comparison skipped because a verifiable SHA-1 is unavailable',\n }\n}\n\nfunction normalizeConcurrency(value: number | undefined): number {\n if (value === undefined || !Number.isFinite(value) || value < 1) return 1\n return Math.max(1, Math.floor(value))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyFA,SAAgB,kBACd,QACA,MACA,aACA,YAAY,GACH;CACT,QAAQ,aAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO,KAAK,IAAI,OAAO,OAAO,KAAK,IAAI,IAAI;EAC7C,KAAK,QACH,OAAO,uBAAuB,QAAQ,IAAI;EAC5C,KAAK,WACH,OAAO,KAAK,IAAI,OAAO,gBAAgB,KAAK,aAAa,IAAI;EAC/D,SACE,MAAM,IAAI,MAAM,6BAA6B,OAAO,WAAW,GAAG;CACtE;AACF;;;;;;;;AASA,SAAgB,2BACd,aACoC;CACpC,QAAQ,aAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH;EACF,SACE,MAAM,IAAI,MAAM,6BAA6B,OAAO,WAAW,GAAG;CACtE;AACF;AAEA,SAAS,uBAAuB,QAAkB,MAAyB;CACzE,IAAI,OAAO,SAAS,KAAK,MAAM,OAAO;CAEtC,MAAM,aAAa,eAAe,MAAM;CACxC,MAAM,WAAW,eAAe,IAAI;CACpC,IAAI,WAAW,SAAS,eAAe,SAAS,SAAS,aAAa,OAAO;CAC7E,IAAI,WAAW,SAAS,iBAAiB,SAAS,SAAS,eAAe,OAAO;CACjF,OAAO,WAAW,UAAU,SAAS;AACvC;;;;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,KAAK,MAAM,KAAK,CAAC;AACtC"}
|
|
@@ -1,74 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_index = require("../actions/index.cjs");
|
|
2
|
+
const require_compare = require("./compare.cjs");
|
|
3
|
+
//#region src/sync/policies/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
6
|
+
* sync direction, compare mode, and keep policy.
|
|
7
|
+
* For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local
|
|
8
|
+
* file hashes and comparable B2 hashes are prepared before actions are generated.
|
|
9
|
+
* Low-level callers must pass pairs with local `contentSha1` values already
|
|
10
|
+
* computed and B2 `contentSha1` values containing any comparable metadata fallback.
|
|
11
|
+
*
|
|
12
|
+
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
13
|
+
* @param direction - The sync direction.
|
|
14
|
+
* @param compareMode - How to compare files for differences.
|
|
15
|
+
* @param keepMode - Policy for destination-only files.
|
|
16
|
+
* @param keepDays - Retention period when keepMode is 'keep-days'.
|
|
17
|
+
* @param nowMillis - Current time in milliseconds, used for keep-days calculation.
|
|
18
|
+
* @param factory - Factory to create the concrete action objects.
|
|
19
|
+
* @param compareThreshold - Tolerance for the comparison.
|
|
20
|
+
*/
|
|
5
21
|
function* generateActions(pair, direction, compareMode, keepMode, keepDays, nowMillis, factory, compareThreshold) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else if (source !== null && dest !== null) {
|
|
12
|
-
yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
13
|
-
}
|
|
22
|
+
require_compare.assertSupportedCompareMode(compareMode);
|
|
23
|
+
const [source, dest] = pair;
|
|
24
|
+
if (source !== null && dest === null) yield* actionsForSourceOnly(source, direction, factory);
|
|
25
|
+
else if (source === null && dest !== null) yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory);
|
|
26
|
+
else if (source !== null && dest !== null) yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
14
27
|
}
|
|
15
28
|
function* actionsForSourceOnly(source, direction, factory) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
switch (direction) {
|
|
30
|
+
case "local-to-b2":
|
|
31
|
+
yield factory.upload(source);
|
|
32
|
+
break;
|
|
33
|
+
case "b2-to-local":
|
|
34
|
+
yield factory.download(source, null);
|
|
35
|
+
break;
|
|
36
|
+
case "b2-to-b2":
|
|
37
|
+
yield factory.copy(source, source.relativePath);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
41
|
function* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case "b2-to-b2":
|
|
52
|
-
yield factory.removeOrphan(dest);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
42
|
+
if (keepMode === "no-delete") {
|
|
43
|
+
yield new require_index.SkipAction(dest.relativePath, "not in source, keep-mode is no-delete");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (keepMode === "keep-days") {
|
|
47
|
+
const ageDays = (nowMillis - dest.modTimeMillis) / (1440 * 60 * 1e3);
|
|
48
|
+
if (ageDays < keepDays) {
|
|
49
|
+
yield new require_index.SkipAction(dest.relativePath, `not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
switch (direction) {
|
|
54
|
+
case "local-to-b2":
|
|
55
|
+
yield factory.removeOrphan(dest);
|
|
56
|
+
break;
|
|
57
|
+
case "b2-to-local":
|
|
58
|
+
yield factory.deleteLocal(dest);
|
|
59
|
+
break;
|
|
60
|
+
case "b2-to-b2":
|
|
61
|
+
yield factory.removeOrphan(dest);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
function* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
if (!require_compare.filesAreDifferent(source, dest, compareMode, compareThreshold)) {
|
|
67
|
+
yield new require_index.SkipAction(source.relativePath, "files are the same");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
switch (direction) {
|
|
71
|
+
case "local-to-b2":
|
|
72
|
+
yield factory.upload(source, dest);
|
|
73
|
+
break;
|
|
74
|
+
case "b2-to-local":
|
|
75
|
+
yield factory.download(source, dest);
|
|
76
|
+
break;
|
|
77
|
+
case "b2-to-b2":
|
|
78
|
+
yield factory.copyB2Path?.(source, dest) ?? factory.copy(source, dest.relativePath);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
72
81
|
}
|
|
82
|
+
//#endregion
|
|
73
83
|
exports.generateActions = generateActions;
|
|
74
|
-
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"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 { assertSupportedCompareMode, 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, dest?: B2SyncPath): SyncAction\n /**\n * Creates an action to download a B2 file to the local filesystem.\n *\n * `generateActions` passes `null` when the B2 source has no scanned local\n * destination, a `LocalSyncPath` when the download replaces an existing\n * scanned destination file, and leaves the value `undefined` only for\n * callers that invoke a factory without destination scan context.\n */\n download(source: B2SyncPath, scannedDest?: LocalSyncPath | null): SyncAction\n /**\n * Creates an action to server-side copy a B2 file to a sync-relative destination path.\n * Kept for compatibility with custom factories that accept a sync-relative string.\n */\n copy(source: B2SyncPath, destRelativePath: string): SyncAction\n /**\n * Creates an action to server-side copy a B2 file using full destination path metadata.\n * Implementations can use `dest.selectedVersion.fileName` when a raw B2 prefix or normalized\n * sync path differs from the stored object key.\n */\n copyB2Path?(source: B2SyncPath, dest: B2SyncPath): SyncAction\n /**\n * Creates an action to hide a file in B2 (soft delete).\n * Kept for compatibility with custom factories that accept a sync-relative string.\n */\n hide(path: string): SyncAction\n /**\n * Creates an action to hide a B2 file using its full scanned path metadata.\n * Implementations can use `selectedVersion.fileName` when a raw B2 prefix or normalized sync path\n * differs from the stored object key.\n */\n hideB2Path?(path: B2SyncPath): 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 * For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local\n * file hashes and comparable B2 hashes are prepared before actions are generated.\n * Low-level callers must pass pairs with local `contentSha1` values already\n * computed and B2 `contentSha1` values containing any comparable metadata fallback.\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 assertSupportedCompareMode(compareMode)\n\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, null)\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, dest as B2SyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath, dest as LocalSyncPath)\n break\n case 'b2-to-b2': {\n const action =\n factory.copyB2Path?.(source as B2SyncPath, dest as B2SyncPath) ??\n factory.copy(source as B2SyncPath, dest.relativePath)\n yield action\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgFA,UAAiB,gBACf,MACA,WACA,aACA,UACA,UACA,WACA,SACA,kBACuB;CACvB,gBAAA,2BAA2B,WAAW;CAEtC,MAAM,CAAC,QAAQ,QAAQ;CAEvB,IAAI,WAAW,QAAQ,SAAS,MAC9B,OAAO,qBAAqB,QAAQ,WAAW,OAAO;MACjD,IAAI,WAAW,QAAQ,SAAS,MACrC,OAAO,mBAAmB,MAAM,WAAW,UAAU,UAAU,WAAW,OAAO;MAC5E,IAAI,WAAW,QAAQ,SAAS,MACrC,OAAO,eAAe,QAAQ,MAAM,WAAW,aAAa,kBAAkB,OAAO;AAEzF;AAEA,UAAU,qBACR,QACA,WACA,SACuB;CACvB,QAAQ,WAAR;EACE,KAAK;GACH,MAAM,QAAQ,OAAO,MAAuB;GAC5C;EACF,KAAK;GACH,MAAM,QAAQ,SAAS,QAAsB,IAAI;GACjD;EACF,KAAK;GACH,MAAM,QAAQ,KAAK,QAAsB,OAAO,YAAY;GAC5D;CACJ;AACF;AAEA,UAAU,mBACR,MACA,WACA,UACA,UACA,WACA,SACuB;CACvB,IAAI,aAAa,aAAa;EAC5B,MAAM,IAAI,cAAA,WAAW,KAAK,cAAc,uCAAuC;EAC/E;CACF;CAEA,IAAI,aAAa,aAAa;EAE5B,MAAM,WADY,YAAY,KAAK,kBACN,OAAU,KAAK;EAC5C,IAAI,UAAU,UAAU;GACtB,MAAM,IAAI,cAAA,WACR,KAAK,cACL,8BAA8B,KAAK,KAAK,WAAW,OAAO,EAAE,WAC9D;GACA;EACF;CACF;CAEA,QAAQ,WAAR;EACE,KAAK;GAKH,MAAM,QAAQ,aAAa,IAAkB;GAC7C;EACF,KAAK;GACH,MAAM,QAAQ,YAAY,IAAqB;GAC/C;EACF,KAAK;GACH,MAAM,QAAQ,aAAa,IAAkB;GAC7C;CACJ;AACF;AAEA,UAAU,eACR,QACA,MACA,WACA,aACA,kBACA,SACuB;CACvB,IAAI,CAAC,gBAAA,kBAAkB,QAAQ,MAAM,aAAa,gBAAgB,GAAG;EACnE,MAAM,IAAI,cAAA,WAAW,OAAO,cAAc,oBAAoB;EAC9D;CACF;CAEA,QAAQ,WAAR;EACE,KAAK;GACH,MAAM,QAAQ,OAAO,QAAyB,IAAkB;GAChE;EACF,KAAK;GACH,MAAM,QAAQ,SAAS,QAAsB,IAAqB;GAClE;EACF,KAAK;GAIH,MAFE,QAAQ,aAAa,QAAsB,IAAkB,KAC7D,QAAQ,KAAK,QAAsB,KAAK,YAAY;GAEtD;CAEJ;AACF"}
|
|
@@ -4,13 +4,38 @@ import { B2SyncPath, CompareMode, KeepMode, LocalSyncPath, SyncDirection } from
|
|
|
4
4
|
/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */
|
|
5
5
|
export interface ActionFactory {
|
|
6
6
|
/** Creates an action to upload a local file to B2. */
|
|
7
|
-
upload(source: LocalSyncPath): SyncAction;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
upload(source: LocalSyncPath, dest?: B2SyncPath): SyncAction;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an action to download a B2 file to the local filesystem.
|
|
10
|
+
*
|
|
11
|
+
* `generateActions` passes `null` when the B2 source has no scanned local
|
|
12
|
+
* destination, a `LocalSyncPath` when the download replaces an existing
|
|
13
|
+
* scanned destination file, and leaves the value `undefined` only for
|
|
14
|
+
* callers that invoke a factory without destination scan context.
|
|
15
|
+
*/
|
|
16
|
+
download(source: B2SyncPath, scannedDest?: LocalSyncPath | null): SyncAction;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an action to server-side copy a B2 file to a sync-relative destination path.
|
|
19
|
+
* Kept for compatibility with custom factories that accept a sync-relative string.
|
|
20
|
+
*/
|
|
21
|
+
copy(source: B2SyncPath, destRelativePath: string): SyncAction;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an action to server-side copy a B2 file using full destination path metadata.
|
|
24
|
+
* Implementations can use `dest.selectedVersion.fileName` when a raw B2 prefix or normalized
|
|
25
|
+
* sync path differs from the stored object key.
|
|
26
|
+
*/
|
|
27
|
+
copyB2Path?(source: B2SyncPath, dest: B2SyncPath): SyncAction;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an action to hide a file in B2 (soft delete).
|
|
30
|
+
* Kept for compatibility with custom factories that accept a sync-relative string.
|
|
31
|
+
*/
|
|
13
32
|
hide(path: string): SyncAction;
|
|
33
|
+
/**
|
|
34
|
+
* Creates an action to hide a B2 file using its full scanned path metadata.
|
|
35
|
+
* Implementations can use `selectedVersion.fileName` when a raw B2 prefix or normalized sync path
|
|
36
|
+
* differs from the stored object key.
|
|
37
|
+
*/
|
|
38
|
+
hideB2Path?(path: B2SyncPath): SyncAction;
|
|
14
39
|
/** Creates an action to permanently delete a remote B2 file version. */
|
|
15
40
|
deleteRemote(path: B2SyncPath): SyncAction;
|
|
16
41
|
/** Creates an action to delete a local file. */
|
|
@@ -28,6 +53,10 @@ export interface ActionFactory {
|
|
|
28
53
|
/**
|
|
29
54
|
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
30
55
|
* sync direction, compare mode, and keep policy.
|
|
56
|
+
* For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local
|
|
57
|
+
* file hashes and comparable B2 hashes are prepared before actions are generated.
|
|
58
|
+
* Low-level callers must pass pairs with local `contentSha1` values already
|
|
59
|
+
* computed and B2 `contentSha1` values containing any comparable metadata fallback.
|
|
31
60
|
*
|
|
32
61
|
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
33
62
|
* @param direction - The sync direction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/index.js"],"names":[],"mappings":"AAAA,OAAO,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I,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;;;;;;;;;;;;;;;;GAgBG;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,CAYvB"}
|
|
@@ -4,13 +4,38 @@ import { B2SyncPath, CompareMode, KeepMode, LocalSyncPath, SyncDirection } from
|
|
|
4
4
|
/** Factory for creating concrete sync actions. Used by {@link generateActions} to decouple policy from execution. */
|
|
5
5
|
export interface ActionFactory {
|
|
6
6
|
/** Creates an action to upload a local file to B2. */
|
|
7
|
-
upload(source: LocalSyncPath): SyncAction;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
upload(source: LocalSyncPath, dest?: B2SyncPath): SyncAction;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an action to download a B2 file to the local filesystem.
|
|
10
|
+
*
|
|
11
|
+
* `generateActions` passes `null` when the B2 source has no scanned local
|
|
12
|
+
* destination, a `LocalSyncPath` when the download replaces an existing
|
|
13
|
+
* scanned destination file, and leaves the value `undefined` only for
|
|
14
|
+
* callers that invoke a factory without destination scan context.
|
|
15
|
+
*/
|
|
16
|
+
download(source: B2SyncPath, scannedDest?: LocalSyncPath | null): SyncAction;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an action to server-side copy a B2 file to a sync-relative destination path.
|
|
19
|
+
* Kept for compatibility with custom factories that accept a sync-relative string.
|
|
20
|
+
*/
|
|
21
|
+
copy(source: B2SyncPath, destRelativePath: string): SyncAction;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an action to server-side copy a B2 file using full destination path metadata.
|
|
24
|
+
* Implementations can use `dest.selectedVersion.fileName` when a raw B2 prefix or normalized
|
|
25
|
+
* sync path differs from the stored object key.
|
|
26
|
+
*/
|
|
27
|
+
copyB2Path?(source: B2SyncPath, dest: B2SyncPath): SyncAction;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an action to hide a file in B2 (soft delete).
|
|
30
|
+
* Kept for compatibility with custom factories that accept a sync-relative string.
|
|
31
|
+
*/
|
|
13
32
|
hide(path: string): SyncAction;
|
|
33
|
+
/**
|
|
34
|
+
* Creates an action to hide a B2 file using its full scanned path metadata.
|
|
35
|
+
* Implementations can use `selectedVersion.fileName` when a raw B2 prefix or normalized sync path
|
|
36
|
+
* differs from the stored object key.
|
|
37
|
+
*/
|
|
38
|
+
hideB2Path?(path: B2SyncPath): SyncAction;
|
|
14
39
|
/** Creates an action to permanently delete a remote B2 file version. */
|
|
15
40
|
deleteRemote(path: B2SyncPath): SyncAction;
|
|
16
41
|
/** Creates an action to delete a local file. */
|
|
@@ -28,6 +53,10 @@ export interface ActionFactory {
|
|
|
28
53
|
/**
|
|
29
54
|
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
30
55
|
* sync direction, compare mode, and keep policy.
|
|
56
|
+
* For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local
|
|
57
|
+
* file hashes and comparable B2 hashes are prepared before actions are generated.
|
|
58
|
+
* Low-level callers must pass pairs with local `contentSha1` values already
|
|
59
|
+
* computed and B2 `contentSha1` values containing any comparable metadata fallback.
|
|
31
60
|
*
|
|
32
61
|
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
33
62
|
* @param direction - The sync direction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/policies/index.js"],"names":[],"mappings":"AA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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;;;;;;;;;;;;;;;;GAgBG;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,CAYvB"}
|
|
@@ -1,74 +1,85 @@
|
|
|
1
1
|
import { SkipAction } from "../actions/index.js";
|
|
2
|
-
import { filesAreDifferent } from "./compare.js";
|
|
2
|
+
import { assertSupportedCompareMode, filesAreDifferent } from "./compare.js";
|
|
3
|
+
//#region src/sync/policies/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a paired source/dest tuple into zero or more sync actions based on the
|
|
6
|
+
* sync direction, compare mode, and keep policy.
|
|
7
|
+
* For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local
|
|
8
|
+
* file hashes and comparable B2 hashes are prepared before actions are generated.
|
|
9
|
+
* Low-level callers must pass pairs with local `contentSha1` values already
|
|
10
|
+
* computed and B2 `contentSha1` values containing any comparable metadata fallback.
|
|
11
|
+
*
|
|
12
|
+
* @param pair - The source/dest file pair from {@link zipFolders}.
|
|
13
|
+
* @param direction - The sync direction.
|
|
14
|
+
* @param compareMode - How to compare files for differences.
|
|
15
|
+
* @param keepMode - Policy for destination-only files.
|
|
16
|
+
* @param keepDays - Retention period when keepMode is 'keep-days'.
|
|
17
|
+
* @param nowMillis - Current time in milliseconds, used for keep-days calculation.
|
|
18
|
+
* @param factory - Factory to create the concrete action objects.
|
|
19
|
+
* @param compareThreshold - Tolerance for the comparison.
|
|
20
|
+
*/
|
|
3
21
|
function* generateActions(pair, direction, compareMode, keepMode, keepDays, nowMillis, factory, compareThreshold) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} else if (source !== null && dest !== null) {
|
|
10
|
-
yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
11
|
-
}
|
|
22
|
+
assertSupportedCompareMode(compareMode);
|
|
23
|
+
const [source, dest] = pair;
|
|
24
|
+
if (source !== null && dest === null) yield* actionsForSourceOnly(source, direction, factory);
|
|
25
|
+
else if (source === null && dest !== null) yield* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory);
|
|
26
|
+
else if (source !== null && dest !== null) yield* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory);
|
|
12
27
|
}
|
|
13
28
|
function* actionsForSourceOnly(source, direction, factory) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
switch (direction) {
|
|
30
|
+
case "local-to-b2":
|
|
31
|
+
yield factory.upload(source);
|
|
32
|
+
break;
|
|
33
|
+
case "b2-to-local":
|
|
34
|
+
yield factory.download(source, null);
|
|
35
|
+
break;
|
|
36
|
+
case "b2-to-b2":
|
|
37
|
+
yield factory.copy(source, source.relativePath);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
25
40
|
}
|
|
26
41
|
function* actionsForDestOnly(dest, direction, keepMode, keepDays, nowMillis, factory) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
case "b2-to-b2":
|
|
50
|
-
yield factory.removeOrphan(dest);
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
42
|
+
if (keepMode === "no-delete") {
|
|
43
|
+
yield new SkipAction(dest.relativePath, "not in source, keep-mode is no-delete");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (keepMode === "keep-days") {
|
|
47
|
+
const ageDays = (nowMillis - dest.modTimeMillis) / (1440 * 60 * 1e3);
|
|
48
|
+
if (ageDays < keepDays) {
|
|
49
|
+
yield new SkipAction(dest.relativePath, `not in source, keeping for ${Math.ceil(keepDays - ageDays)} more days`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
switch (direction) {
|
|
54
|
+
case "local-to-b2":
|
|
55
|
+
yield factory.removeOrphan(dest);
|
|
56
|
+
break;
|
|
57
|
+
case "b2-to-local":
|
|
58
|
+
yield factory.deleteLocal(dest);
|
|
59
|
+
break;
|
|
60
|
+
case "b2-to-b2":
|
|
61
|
+
yield factory.removeOrphan(dest);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
53
64
|
}
|
|
54
65
|
function* actionsForBoth(source, dest, direction, compareMode, compareThreshold, factory) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
if (!filesAreDifferent(source, dest, compareMode, compareThreshold)) {
|
|
67
|
+
yield new SkipAction(source.relativePath, "files are the same");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
switch (direction) {
|
|
71
|
+
case "local-to-b2":
|
|
72
|
+
yield factory.upload(source, dest);
|
|
73
|
+
break;
|
|
74
|
+
case "b2-to-local":
|
|
75
|
+
yield factory.download(source, dest);
|
|
76
|
+
break;
|
|
77
|
+
case "b2-to-b2":
|
|
78
|
+
yield factory.copyB2Path?.(source, dest) ?? factory.copy(source, dest.relativePath);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
82
|
+
//#endregion
|
|
83
|
+
export { generateActions };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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 { assertSupportedCompareMode, 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, dest?: B2SyncPath): SyncAction\n /**\n * Creates an action to download a B2 file to the local filesystem.\n *\n * `generateActions` passes `null` when the B2 source has no scanned local\n * destination, a `LocalSyncPath` when the download replaces an existing\n * scanned destination file, and leaves the value `undefined` only for\n * callers that invoke a factory without destination scan context.\n */\n download(source: B2SyncPath, scannedDest?: LocalSyncPath | null): SyncAction\n /**\n * Creates an action to server-side copy a B2 file to a sync-relative destination path.\n * Kept for compatibility with custom factories that accept a sync-relative string.\n */\n copy(source: B2SyncPath, destRelativePath: string): SyncAction\n /**\n * Creates an action to server-side copy a B2 file using full destination path metadata.\n * Implementations can use `dest.selectedVersion.fileName` when a raw B2 prefix or normalized\n * sync path differs from the stored object key.\n */\n copyB2Path?(source: B2SyncPath, dest: B2SyncPath): SyncAction\n /**\n * Creates an action to hide a file in B2 (soft delete).\n * Kept for compatibility with custom factories that accept a sync-relative string.\n */\n hide(path: string): SyncAction\n /**\n * Creates an action to hide a B2 file using its full scanned path metadata.\n * Implementations can use `selectedVersion.fileName` when a raw B2 prefix or normalized sync path\n * differs from the stored object key.\n */\n hideB2Path?(path: B2SyncPath): 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 * For `compareMode: 'sha1'`, prefer the high-level `synchronize()` API so local\n * file hashes and comparable B2 hashes are prepared before actions are generated.\n * Low-level callers must pass pairs with local `contentSha1` values already\n * computed and B2 `contentSha1` values containing any comparable metadata fallback.\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 assertSupportedCompareMode(compareMode)\n\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, null)\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, dest as B2SyncPath)\n break\n case 'b2-to-local':\n yield factory.download(source as B2SyncPath, dest as LocalSyncPath)\n break\n case 'b2-to-b2': {\n const action =\n factory.copyB2Path?.(source as B2SyncPath, dest as B2SyncPath) ??\n factory.copy(source as B2SyncPath, dest.relativePath)\n yield action\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgFA,UAAiB,gBACf,MACA,WACA,aACA,UACA,UACA,WACA,SACA,kBACuB;CACvB,2BAA2B,WAAW;CAEtC,MAAM,CAAC,QAAQ,QAAQ;CAEvB,IAAI,WAAW,QAAQ,SAAS,MAC9B,OAAO,qBAAqB,QAAQ,WAAW,OAAO;MACjD,IAAI,WAAW,QAAQ,SAAS,MACrC,OAAO,mBAAmB,MAAM,WAAW,UAAU,UAAU,WAAW,OAAO;MAC5E,IAAI,WAAW,QAAQ,SAAS,MACrC,OAAO,eAAe,QAAQ,MAAM,WAAW,aAAa,kBAAkB,OAAO;AAEzF;AAEA,UAAU,qBACR,QACA,WACA,SACuB;CACvB,QAAQ,WAAR;EACE,KAAK;GACH,MAAM,QAAQ,OAAO,MAAuB;GAC5C;EACF,KAAK;GACH,MAAM,QAAQ,SAAS,QAAsB,IAAI;GACjD;EACF,KAAK;GACH,MAAM,QAAQ,KAAK,QAAsB,OAAO,YAAY;GAC5D;CACJ;AACF;AAEA,U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