@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":"synchronizer.js","sources":["../../src/sync/synchronizer.ts"],"sourcesContent":["import type { Bucket } from '../bucket.ts'\nimport { BufferSource } from '../streams/source.ts'\nimport { fileId as fileIdOf } from '../types/ids.ts'\nimport { Semaphore } from '../upload/concurrency.ts'\nimport { DEFAULT_TRANSFER_CONCURRENCY } from '../util/defaults.ts'\nimport { toError } from '../util/to-error.ts'\nimport type { SyncAction } from './actions/index.ts'\nimport {\n CopyAction,\n DeleteLocalAction,\n DeleteRemoteAction,\n DownloadAction,\n HideAction,\n UploadAction,\n} from './actions/index.ts'\nimport { zipFolders } from './pairing.ts'\nimport type { ActionFactory } from './policies/index.ts'\nimport { generateActions } from './policies/index.ts'\nimport type {\n B2SyncPath,\n LocalSyncPath,\n SyncDirection,\n SyncEvent,\n SyncFolder,\n SyncOptions,\n} from './types.ts'\n\n/** Base configuration for a sync operation. */\nexport interface SynchronizerConfig {\n /** The folder to read files from. */\n readonly source: SyncFolder\n /** The folder to write files to. */\n readonly dest: SyncFolder\n /** Options controlling comparison, deletion policy, and concurrency. */\n readonly options: SyncOptions\n}\n\n/** A sync folder constrained to the local filesystem. */\nexport interface LocalSyncFolder extends SyncFolder {\n /** Discriminant identifying a local folder. */\n readonly type: 'local'\n /** Absolute filesystem path to the local root directory. */\n readonly root: string\n}\n\n/** A sync folder constrained to a B2 bucket prefix. */\nexport interface B2SyncFolder extends SyncFolder {\n /** Discriminant identifying a B2 folder. */\n readonly type: 'b2'\n}\n\n/** Configuration for a local-to-B2 sync (upload direction). */\nexport interface SynchronizerUpConfig extends SynchronizerConfig {\n /** Local source folder. */\n readonly source: LocalSyncFolder\n /** B2 destination folder. */\n readonly dest: B2SyncFolder\n /** The target B2 bucket. */\n readonly bucket: Bucket\n /** Key prefix for uploaded files in the bucket. */\n readonly prefix: string\n}\n\n/** Configuration for a B2-to-local sync (download direction). */\nexport interface SynchronizerDownConfig extends SynchronizerConfig {\n /** B2 source folder. */\n readonly source: B2SyncFolder\n /** Local destination folder. */\n readonly dest: LocalSyncFolder\n /** The source B2 bucket. */\n readonly bucket: Bucket\n}\n\n/**\n * Infers the sync direction from the source and destination folder types.\n * @param source - The folder to read files from.\n * @param dest - The folder to write files to.\n *\n * @returns The resolved sync direction based on folder types.\n *\n * @throws When the source and destination folder types form an unsupported combination.\n */\nfunction resolveDirection(source: SyncFolder, dest: SyncFolder): SyncDirection {\n if (source.type === 'local' && dest.type === 'b2') return 'local-to-b2'\n if (source.type === 'b2' && dest.type === 'local') return 'b2-to-local'\n if (source.type === 'b2' && dest.type === 'b2') return 'b2-to-b2'\n throw new Error(`Unsupported sync direction: ${source.type} to ${dest.type}`)\n}\n\n/**\n * Runs a full sync operation: scans both folders, pairs files, generates actions,\n * and executes them with bounded concurrency. Yields {@link SyncEvent} entries for\n * each comparison and action result.\n *\n * @param config - The synchronizer configuration (source, dest, options, and optional bucket).\n */\nexport async function* synchronize(config: SynchronizerConfig): AsyncGenerator<SyncEvent> {\n const { source, dest, options } = config\n const direction = resolveDirection(source, dest)\n const dryRun = options.dryRun ?? false\n const concurrency = options.concurrency ?? DEFAULT_TRANSFER_CONCURRENCY\n const keepDays = options.keepDays ?? 0\n const compareThreshold = options.compareThreshold ?? 0\n const nowMillis = Date.now()\n\n const factory = createActionFactory(config)\n\n const actions: SyncAction[] = []\n\n for await (const pair of zipFolders(source, dest)) {\n if (options.signal?.aborted) return\n\n for (const action of generateActions(\n pair,\n direction,\n options.compareMode,\n options.keepMode,\n keepDays,\n nowMillis,\n factory,\n compareThreshold,\n )) {\n actions.push(action)\n }\n\n yield { type: 'compare', path: (pair[0] ?? pair[1])?.relativePath ?? '', size: 0 }\n }\n\n const sem = new Semaphore(concurrency)\n const results: SyncEvent[] = []\n const errors: Error[] = []\n\n const promises = actions.map(async (action) => {\n await sem.acquire()\n try {\n if (options.signal?.aborted) return\n const event = await action.execute(dryRun)\n results.push(event)\n } catch (err) {\n const errorValue = toError(err)\n errors.push(errorValue)\n results.push({\n type: 'error',\n path: action.relativePath,\n size: 0,\n message: errorValue.message,\n })\n } finally {\n sem.release()\n }\n })\n\n await Promise.all(promises)\n\n for (const event of results) {\n yield event\n }\n\n if (errors.length > 0) {\n yield {\n type: 'error',\n path: '',\n size: 0,\n message: `${errors.length} action(s) failed`,\n }\n }\n}\n\n/**\n * Narrowing assertion that a `Bucket` is present for an action that requires\n * it. Throws with a consistent, context-tagged message when the configured\n * direction did not supply one (e.g. `b2-to-local` direction asking for an\n * upload action).\n *\n * Uses TypeScript's `asserts` signature so call-site flow narrows\n * `bucket` from `Bucket | undefined` to `Bucket` after the check, without\n * requiring a separate `if (!bucket) throw ...` line per action factory.\n *\n * @param bucket - The (possibly missing) bucket reference.\n * @param context - Short verb describing the action being constructed\n * (e.g. `'upload'`, `'download'`). Surfaced in the error message.\n *\n * @throws `Error` when `bucket` is `undefined` or `null`.\n */\nfunction assertBucket(bucket: Bucket | undefined, context: string): asserts bucket is Bucket {\n if (!bucket) throw new Error(`Bucket required for ${context} actions`)\n}\n\n/**\n * Creates a configured sync engine wired to the bucket and paths in the given config.\n *\n * For sync operations that may need to remove destination-only files (the\n * `keepMode: 'delete'` policy), the factory reads the destination\n * bucket's cached `fileLockConfiguration` once so `removeOrphan` can\n * dispatch to either `hide` (locked buckets) or `deleteFileVersion`\n * (vanilla buckets) without a per-file branch. The cache is whatever\n * `client.listBuckets()` or `client.createBucket()` returned — callers\n * who flipped lock state mid-sync (rare) should refresh before\n * synchronize().\n *\n * @param config - The synchronizer configuration containing source, destination, and options.\n *\n * @returns An action factory bound to the provided configuration.\n */\nfunction createActionFactory(config: SynchronizerConfig): ActionFactory {\n const upConfig = config as Partial<SynchronizerUpConfig>\n const downConfig = config as Partial<SynchronizerDownConfig>\n\n const destBucket = upConfig.bucket ?? downConfig.bucket\n // Defensive optional chain on `info`: synchronizer tests use Bucket\n // mocks that don't populate this field. Real `Bucket` instances always\n // do (constructor parameter).\n const bucketIsLocked = destBucket?.info?.fileLockConfiguration?.value?.isFileLockEnabled ?? false\n\n const factory: ActionFactory = {\n upload(source: LocalSyncPath): SyncAction {\n const bucket = upConfig.bucket\n const prefix = upConfig.prefix ?? ''\n assertBucket(bucket, 'upload')\n\n return new UploadAction(\n source.relativePath,\n source.absolutePath,\n source.size,\n async (absPath, relPath) => {\n const { readFile } = await import('node:fs/promises')\n const data = await readFile(absPath)\n await bucket.upload({\n fileName: `${prefix}${relPath}`,\n source: new BufferSource(new Uint8Array(data)),\n })\n },\n )\n },\n\n download(source: B2SyncPath): SyncAction {\n const bucket = downConfig.bucket\n const root =\n downConfig.dest?.type === 'local' ? (downConfig.dest as { root: string }).root : ''\n assertBucket(bucket, 'download')\n\n return new DownloadAction(source.relativePath, source.size, async (relPath) => {\n const result = await bucket.download(source.selectedVersion.fileName)\n const reader = result.body.getReader()\n let combined: Uint8Array\n try {\n const chunks: Uint8Array[] = []\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n chunks.push(value)\n }\n let total = 0\n for (const c of chunks) total += c.byteLength\n combined = new Uint8Array(total)\n let offset = 0\n for (const c of chunks) {\n combined.set(c, offset)\n offset += c.byteLength\n }\n } finally {\n // Release the body stream's reader lock so a downstream\n // writeFile failure doesn't strand the response stream half-\n // open with the upstream HTTP connection still pumping.\n reader.releaseLock()\n }\n\n const { mkdir, writeFile } = await import('node:fs/promises')\n const { dirname, join } = await import('node:path')\n const destPath = join(root, relPath)\n await mkdir(dirname(destPath), { recursive: true })\n await writeFile(destPath, combined)\n })\n },\n\n copy(source: B2SyncPath, destPath: string): SyncAction {\n const bucket = upConfig.bucket\n assertBucket(bucket, 'copy')\n\n return new CopyAction(source.relativePath, source.size, async () => {\n await bucket.copyFile({\n sourceFileId: source.selectedVersion.fileId,\n fileName: destPath,\n })\n })\n },\n\n hide(path: string): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'hide')\n\n return new HideAction(path, async (relPath) => {\n const prefix = upConfig.prefix ?? ''\n await bucket.hideFile(`${prefix}${relPath}`)\n })\n },\n\n deleteRemote(path: B2SyncPath): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'delete')\n\n // Bug fix: `DeleteRemoteAction` invokes the closure with\n // `relativePath` (the scanner-stripped name relative to the sync\n // prefix), but B2 stores files under the FULL name including the\n // prefix. Use the FileVersion's authoritative `fileName` — the\n // actual B2 key — rather than reconstructing it via prefix\n // concat. Without this, syncs with a non-empty destination\n // prefix (e.g. `'site/'`) failed orphan deletion with\n // `file_not_present`.\n const b2FileName = path.selectedVersion.fileName\n return new DeleteRemoteAction(\n path.relativePath,\n path.selectedVersion.fileId as string,\n async (fileId) => {\n await bucket.deleteFileVersion(b2FileName, fileIdOf(fileId))\n },\n )\n },\n\n deleteLocal(path: LocalSyncPath): SyncAction {\n return new DeleteLocalAction(path.relativePath, path.absolutePath, async (absPath) => {\n const { unlink } = await import('node:fs/promises')\n await unlink(absPath)\n })\n },\n\n removeOrphan(dest: B2SyncPath): SyncAction {\n // Locked buckets: `b2_delete_file_version` is blocked or stacks\n // hide markers under retention; a hide is the safe choice.\n // Vanilla buckets: plain delete is the right move — hide markers\n // would just litter the version history.\n return bucketIsLocked ? factory.hide(dest.relativePath) : factory.deleteRemote(dest)\n },\n }\n\n return factory\n}\n"],"names":["fileId","fileIdOf"],"mappings":";;;;;;;;AAkFA,SAAS,iBAAiB,QAAoB,MAAiC;AAC7E,MAAI,OAAO,SAAS,WAAW,KAAK,SAAS,KAAM,QAAO;AAC1D,MAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,QAAS,QAAO;AAC1D,MAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,KAAM,QAAO;AACvD,QAAM,IAAI,MAAM,+BAA+B,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE;AAC9E;AASA,gBAAuB,YAAY,QAAuD;AACxF,QAAM,EAAE,QAAQ,MAAM,QAAA,IAAY;AAClC,QAAM,YAAY,iBAAiB,QAAQ,IAAI;AAC/C,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,mBAAmB,QAAQ,oBAAoB;AACrD,QAAM,YAAY,KAAK,IAAA;AAEvB,QAAM,UAAU,oBAAoB,MAAM;AAE1C,QAAM,UAAwB,CAAA;AAE9B,mBAAiB,QAAQ,WAAW,QAAQ,IAAI,GAAG;AACjD,QAAI,QAAQ,QAAQ,QAAS;AAE7B,eAAW,UAAU;AAAA,MACnB;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GACC;AACD,cAAQ,KAAK,MAAM;AAAA,IACrB;AAEA,UAAM,EAAE,MAAM,WAAW,OAAO,KAAK,CAAC,KAA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
|
|
1
|
+
{"version":3,"file":"synchronizer.js","names":[],"sources":["../../src/sync/synchronizer.ts"],"sourcesContent":["import type { Bucket } from '../bucket.ts'\nimport type { SseCDownloadKey } from '../raw/index.ts'\nimport { type ContentSource, FileSource } from '../streams/source.ts'\nimport type { EncryptionSetting } from '../types/encryption.ts'\nimport { fileId as fileIdOf } from '../types/ids.ts'\nimport { DEFAULT_TRANSFER_CONCURRENCY } from '../util/defaults.ts'\nimport { sanitizeErrorReason } from '../util/error-reason.ts'\nimport type { SyncAction } from './actions/index.ts'\nimport {\n CopyAction,\n DeleteLocalAction,\n DeleteRemoteAction,\n DownloadAction,\n HideAction,\n SkipAction,\n UploadAction,\n} from './actions/index.ts'\nimport {\n hashReadableStreamSha1,\n normalizeSha1VerificationMaxBytes,\n withSha1VerificationDeadline,\n} from './b2-sha1-reader.ts'\nimport { localFilesystemErrorReason } from './filesystem-errors.ts'\nimport {\n deleteLocalFileInsideRoot,\n validateScannedLocalFile,\n writeLocalStreamInsideRoot,\n} from './local-file-io.ts'\nimport { isLocalFilesystemRoot } from './local-filesystem-root.ts'\nimport { readLocalSha1File } from './local-sha1.ts'\nimport { type SyncPair, zipFolders } from './pairing.ts'\nimport { safeRelativePathSegments } from './path-safety.ts'\nimport {\n assertSupportedCompareMode,\n type B2Sha1Reader,\n type ComparePreparationResult,\n preparePairsForCompare,\n readyComparePair,\n} from './policies/compare.ts'\nimport type { ActionFactory } from './policies/index.ts'\nimport { generateActions } from './policies/index.ts'\nimport { asRawB2KeyPrefix, b2KeyToRelativePathUnderPrefix } from './prefix.ts'\nimport {\n DEFAULT_SHA1_VERIFICATION_TIMEOUT_MILLIS,\n normalizeSha1TimeoutMillis,\n} from './sha1-options.ts'\nimport type {\n B2SyncPath,\n LocalSyncPath,\n SyncDirection,\n SyncEvent,\n SyncFolder,\n SyncOptions,\n SyncPath,\n SyncScanOptions,\n SyncSkipEvent,\n} from './types.ts'\n\nconst MAX_BUFFERED_SCAN_EVENTS = 100\nconst MAX_AGGREGATE_FAILED_PATHS = 100\nconst DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MILLIS = 60_000\n\ninterface ScanEventBuffer {\n readonly events: SyncEvent[]\n fatalFilesystemErrorMessage?: string\n sourceInventoryIncompleteMessage?: string\n dropped: number\n}\n\n/**\n * Test hooks for bounded planning behavior.\n *\n * @internal\n */\nexport const synchronizerTestHooks: {\n afterNonSha1PlanBatch?: (batchSize: number) => void\n} = {}\n\n/** Base configuration for a sync operation. */\nexport interface SynchronizerConfig {\n /** The folder to read files from. */\n readonly source: SyncFolder\n /** The folder to write files to. */\n readonly dest: SyncFolder\n /** Options controlling comparison, deletion policy, and concurrency. */\n readonly options: SyncOptions\n}\n\n/** A sync folder constrained to the local filesystem. */\nexport interface LocalSyncFolder extends SyncFolder {\n /** Discriminant identifying a local folder. */\n readonly type: 'local'\n /** Absolute filesystem path to the local root directory. */\n readonly root: string\n}\n\n/** A sync folder constrained to a B2 bucket prefix. */\nexport interface B2SyncFolder extends SyncFolder {\n /** Discriminant identifying a B2 folder. */\n readonly type: 'b2'\n /** Raw B2 key prefix represented by this folder when known. */\n readonly rawPrefix?: string\n}\n\n/** Configuration for a local-to-B2 sync (upload direction). */\nexport interface SynchronizerUpConfig extends SynchronizerConfig {\n /** Local source folder. */\n readonly source: LocalSyncFolder\n /** B2 destination folder. */\n readonly dest: B2SyncFolder\n /** The target B2 bucket. */\n readonly bucket: Bucket\n /**\n * Raw B2 key prefix for uploaded files in the bucket.\n * Backslashes are preserved as raw B2 key characters.\n */\n readonly prefix: string\n}\n\n/** Configuration for a B2-to-local sync (download direction). */\nexport interface SynchronizerDownConfig extends SynchronizerConfig {\n /** B2 source folder. */\n readonly source: B2SyncFolder\n /** Local destination folder. */\n readonly dest: LocalSyncFolder\n /** The source B2 bucket. */\n readonly bucket: Bucket\n}\n\n/** Configuration for a B2-to-B2 sync (copy direction). */\nexport interface SynchronizerB2Config extends SynchronizerConfig {\n /** B2 source folder. */\n readonly source: B2SyncFolder\n /** B2 destination folder. */\n readonly dest: B2SyncFolder\n /** The B2 bucket used for copy, hide, and delete operations. */\n readonly bucket: Bucket\n /**\n * Key prefix for destination-side copy, hide, and delete mutations.\n *\n * When omitted, the synchronizer uses `dest.rawPrefix` when the destination\n * folder exposes one. Set this explicitly for custom B2 folders that do not\n * expose their raw prefix.\n */\n readonly prefix?: string\n}\n\n/** Concrete sync configurations supported by {@link synchronize}. */\nexport type SupportedSynchronizerConfig =\n | SynchronizerUpConfig\n | SynchronizerDownConfig\n | SynchronizerB2Config\n\ninterface PreparedActionPlan {\n readonly event: SyncEvent\n readonly actions: readonly SyncAction[]\n}\n\ninterface LocalRootIdentity {\n readonly deviceId: number | bigint\n readonly inode: number | bigint\n}\n\ninterface LocalRootContext {\n readonly root: string\n readonly realPath: string\n readonly identity?: LocalRootIdentity\n}\n\ninterface LocalRootContexts {\n readonly source?: LocalRootContext\n readonly dest?: LocalRootContext\n}\n\n/**\n * Infers the sync direction from the source and destination folder types.\n * @param source - The folder to read files from.\n * @param dest - The folder to write files to.\n *\n * @returns The resolved sync direction based on folder types.\n *\n * @throws When the source and destination folder types form an unsupported combination.\n */\nfunction resolveDirection(source: SyncFolder, dest: SyncFolder): SyncDirection {\n if (source.type === 'local' && dest.type === 'b2') return 'local-to-b2'\n if (source.type === 'b2' && dest.type === 'local') return 'b2-to-local'\n if (source.type === 'b2' && dest.type === 'b2') return 'b2-to-b2'\n throw new Error(`Unsupported sync direction: ${source.type} to ${dest.type}`)\n}\n\n/**\n * Runs a full sync operation: scans both folders, pairs files, generates actions,\n * and executes them with bounded concurrency. Yields {@link SyncEvent} entries for\n * each comparison and action result.\n *\n * @param config - The synchronizer configuration (source, dest, options, and optional bucket).\n *\n * @returns An async generator that yields comparison and action events.\n */\nexport function synchronize(config: SupportedSynchronizerConfig): AsyncGenerator<SyncEvent>\n/**\n * Legacy overload for broad custom synchronizer configurations.\n *\n * @param config - The synchronizer configuration.\n *\n * @returns An async generator that yields comparison and action events.\n *\n * @deprecated Use {@link SupportedSynchronizerConfig}. This legacy overload\n * accepts broad custom configurations for source compatibility, but the\n * supported union is the public contract for built-in sync directions.\n */\nexport function synchronize(config: SynchronizerConfig): AsyncGenerator<SyncEvent>\nexport async function* synchronize(config: SynchronizerConfig): AsyncGenerator<SyncEvent> {\n const { source, dest, options } = config\n assertSupportedCompareMode(options.compareMode)\n const direction = resolveDirection(source, dest)\n const dryRun = options.dryRun ?? false\n const concurrency = normalizeSyncConcurrency(options.concurrency)\n const keepDays = options.keepDays ?? 0\n const compareThreshold = options.compareThreshold ?? 0\n const nowMillis = Date.now()\n const localRootContexts = await resolveLocalRootContexts(config)\n const queuedEvents: SyncEvent[] = []\n const failedPaths: string[] = []\n const failedPathSet = new Set<string>()\n let errorCount = 0\n let failedPathOmittedCount = 0\n let scanHadError = false\n const runningActions = new Set<Promise<void>>()\n const scanEvents: ScanEventBuffer = { events: [], dropped: 0 }\n const scanOptions: SyncScanOptions = {\n ...(options.include !== undefined ? { include: options.include } : {}),\n ...(options.exclude !== undefined ? { exclude: options.exclude } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n ...(options.maxScanEntries !== undefined ? { maxScanEntries: options.maxScanEntries } : {}),\n ...(direction === 'b2-to-local' ? { requireLocalSafePaths: true } : {}),\n onError: (event) => {\n scanHadError = true\n recordSyncError(event)\n queueEvent(event)\n },\n }\n\n const factory = createActionFactory(config, localRootContexts)\n const readB2Sha1 = dryRun ? undefined : createB2Sha1Reader(config)\n const actionAbortController = new AbortController()\n const removeAbortForwarder = forwardAbortSignal(options.signal, actionAbortController)\n let completed = false\n\n async function* finishAfterAbort(): AsyncGenerator<SyncEvent> {\n await drainActions()\n yield* emitQueuedEvents()\n }\n\n try {\n let pairs: SyncPair[]\n try {\n pairs = await collectPairs()\n } catch (err) {\n await drainActions()\n if (options.signal?.aborted) {\n yield* finishAfterAbort()\n return\n }\n if (!scanHadError) {\n yield* emitQueuedEvents()\n throw err\n }\n\n yield* emitQueuedEvents()\n yield aggregateErrorEvent()\n completed = true\n return\n }\n\n yield* emitQueuedEvents()\n const filesystemError = scanFilesystemError(scanEvents)\n if (filesystemError !== undefined) throw filesystemError\n\n if (options.signal?.aborted) {\n yield* finishAfterAbort()\n return\n }\n\n if (scanHadError) {\n if (errorCount > 0) yield aggregateErrorEvent()\n completed = true\n return\n }\n\n if (options.compareMode === 'sha1') {\n const compareBatchSize = concurrency\n for (let index = 0; index < pairs.length; index += compareBatchSize) {\n if (yield* emitSha1Batch(pairs.slice(index, index + compareBatchSize))) return\n }\n } else {\n for (let index = 0; index < pairs.length; index += concurrency) {\n const items = pairs\n .slice(index, index + concurrency)\n .map((pair) => planPreparedPair(pair, readyComparePair(pair)))\n synchronizerTestHooks.afterNonSha1PlanBatch?.(items.length)\n if (yield* emitPreparedItems(items)) return\n }\n }\n\n await drainActions()\n yield* emitQueuedEvents()\n\n if (errorCount > 0) {\n yield aggregateErrorEvent()\n }\n completed = true\n } finally {\n if (!completed) {\n abortActionController(\n actionAbortController,\n new DOMException('Sync iterator closed', 'AbortError'),\n )\n }\n removeAbortForwarder()\n await drainActions()\n }\n\n async function collectPairs(): Promise<SyncPair[]> {\n const pairs: SyncPair[] = []\n for await (const pair of zipFolders(source, dest, scanOptions, {\n onSourceSkip(event) {\n bufferScanEvent(scanEvents, event, direction, 'source')\n },\n onDestSkip(event) {\n bufferScanEvent(scanEvents, event, direction, 'dest')\n },\n })) {\n if (options.signal?.aborted) return pairs\n validateB2SourcePairPrefix(pair, config)\n pairs.push(pair)\n }\n return pairs\n }\n\n async function* emitSha1Batch(batch: readonly SyncPair[]): AsyncGenerator<SyncEvent, boolean> {\n if (batch.length === 0) return false\n\n // Keep SHA-1 hashing / B2 verification and transfer actions under one effective\n // concurrency ceiling. This intentionally creates a batch barrier instead of\n // overlapping compare reads with prior transfers.\n await drainActions()\n yield* emitQueuedEvents()\n\n const preparedBatch = await processPreparedBatch(batch)\n if (yield* emitPreparedItems(preparedBatch.items)) return true\n if (preparedBatch.aborted || options.signal?.aborted) {\n yield* finishAfterAbort()\n return true\n }\n return false\n }\n\n async function* emitPreparedItems(\n items: readonly PreparedActionPlan[],\n ): AsyncGenerator<SyncEvent, boolean> {\n for (const item of items) {\n yield* emitQueuedEvents()\n yield item.event\n yield* emitQueuedEvents()\n /* v8 ignore next -- abort between compare yield and scheduling is timing-dependent */\n if (options.signal?.aborted) {\n yield* finishAfterAbort()\n return true\n }\n for (const action of item.actions) {\n await scheduleAction(action)\n yield* emitQueuedEvents()\n }\n }\n return false\n }\n\n async function processPreparedBatch(\n batch: readonly SyncPair[],\n ): Promise<{ readonly items: readonly PreparedActionPlan[]; readonly aborted: boolean }> {\n if (batch.length === 0) return { items: [], aborted: false }\n const preparedPairs = await preparePairsForCompare(batch, 'sha1', {\n concurrency,\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n ...(options.sha1ReadTimeoutMillis !== undefined\n ? { sha1ReadTimeoutMillis: options.sha1ReadTimeoutMillis }\n : {}),\n readLocalSha1: readLocalSha1File,\n ...(readB2Sha1 !== undefined ? { readB2Sha1 } : {}),\n })\n\n const items: PreparedActionPlan[] = []\n for (const { originalPair, prepared } of preparedPairs) {\n if (prepared.aborted || options.signal?.aborted) return { items, aborted: true }\n items.push(planPreparedPair(originalPair, prepared))\n }\n return { items, aborted: false }\n }\n\n function planPreparedPair(\n pair: SyncPair,\n prepared: ComparePreparationResult,\n ): PreparedActionPlan {\n const event: SyncEvent = {\n type: 'compare',\n path: (pair[0] ?? pair[1])?.relativePath ?? '',\n size: 0,\n bytesHashed: prepared.bytesHashed,\n ...(prepared.bytesVerified > 0 ? { bytesVerified: prepared.bytesVerified } : {}),\n }\n\n let preparedErrorEventCount = 0\n for (const preparedEvent of prepared.events) {\n queueEvent(preparedEvent)\n if (preparedEvent.type === 'error') {\n preparedErrorEventCount++\n recordFailurePath(preparedEvent.path)\n }\n }\n errorCount += prepared.errors.length\n for (let index = preparedErrorEventCount; index < prepared.errors.length; index++) {\n recordFailurePath(event.path)\n }\n if (prepared.skipActionGeneration) return { event, actions: [] }\n if (\n (scanHadError || scanHadFilesystemError(scanEvents)) &&\n prepared.pair[0] === null &&\n prepared.pair[1] !== null\n ) {\n return {\n event,\n actions: [\n new SkipAction(prepared.pair[1].relativePath, 'not removed because scan errors occurred'),\n ],\n }\n }\n if (\n sourceInventoryIncomplete(scanEvents) &&\n prepared.pair[0] === null &&\n prepared.pair[1] !== null\n ) {\n return {\n event,\n actions: [\n new SkipAction(\n prepared.pair[1].relativePath,\n scanEvents.sourceInventoryIncompleteMessage ??\n 'not removed because the source scan skipped unsafe B2 names',\n ),\n ],\n }\n }\n\n const actions = [\n ...generateActions(\n prepared.pair,\n direction,\n options.compareMode,\n options.keepMode,\n keepDays,\n nowMillis,\n factory,\n compareThreshold,\n ),\n ]\n\n return { event, actions }\n }\n\n async function scheduleAction(action: SyncAction): Promise<void> {\n const task = executeAction(action).finally(() => {\n runningActions.delete(task)\n })\n runningActions.add(task)\n if (runningActions.size >= concurrency) await Promise.race(runningActions)\n }\n\n async function executeAction(action: SyncAction): Promise<void> {\n try {\n if (actionAbortController.signal.aborted) return\n const event = await action.execute(dryRun, actionAbortController.signal)\n queueEvent(event)\n } catch (err) {\n const event: SyncEvent = {\n type: 'error',\n path: action.relativePath,\n size: 0,\n message: sanitizeErrorReason(err),\n }\n recordSyncError(event)\n queueEvent(event)\n }\n }\n\n function recordSyncError(event: SyncEvent): void {\n errorCount += 1\n recordFailurePath(event.path)\n }\n\n function recordFailurePath(path: string): void {\n if (path === '') return\n if (failedPathSet.has(path)) return\n failedPathSet.add(path)\n if (failedPaths.length < MAX_AGGREGATE_FAILED_PATHS) {\n failedPaths.push(path)\n } else {\n failedPathOmittedCount++\n }\n }\n\n function aggregateErrorEvent(): SyncEvent {\n return {\n type: 'error',\n path: '',\n size: 0,\n message: `${errorCount} sync error(s) occurred`,\n failureCount: errorCount,\n failedPaths: [...failedPaths],\n ...(failedPathOmittedCount > 0 ? { failedPathOmittedCount } : {}),\n }\n }\n\n function queueEvent(event: SyncEvent): void {\n queuedEvents.push(event)\n }\n\n async function* emitQueuedEvents(): AsyncGenerator<SyncEvent> {\n yield* drainScanEvents(scanEvents)\n for (const event of queuedEvents.splice(0)) yield event\n }\n\n async function drainActions(): Promise<void> {\n while (runningActions.size > 0) {\n await Promise.race(runningActions)\n }\n }\n}\n\n/**\n * Normalizes user-provided sync concurrency before it controls compare batches and transfers.\n *\n * @param value - Optional concurrency value from sync options.\n *\n * @returns A positive integer concurrency value.\n *\n * @throws When the configured concurrency is not a positive integer.\n */\nfunction normalizeSyncConcurrency(value: number | undefined): number {\n const candidate = value ?? DEFAULT_TRANSFER_CONCURRENCY\n if (!Number.isInteger(candidate) || candidate < 1) {\n throw new RangeError('Sync concurrency must be a positive integer')\n }\n return candidate\n}\n\nfunction normalizeDownloadIdleTimeoutMillis(value: number | undefined): number {\n if (value === undefined) return DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MILLIS\n if (value === Number.POSITIVE_INFINITY) return value\n if (!Number.isFinite(value) || value < 1) {\n throw new RangeError('downloadIdleTimeoutMillis must be a positive finite number or Infinity')\n }\n return Math.floor(value)\n}\n\nfunction assertValidB2ContentLength(contentLength: number): number {\n if (!Number.isSafeInteger(contentLength) || contentLength < 0) {\n throw new Error('B2 contentLength must be a non-negative safe integer')\n }\n return contentLength\n}\n\nfunction createB2Sha1Reader(config: SynchronizerConfig): B2Sha1Reader | undefined {\n const upConfig = config as Partial<SynchronizerUpConfig>\n const downConfig = config as Partial<SynchronizerDownConfig>\n const bucket = upConfig.bucket ?? downConfig.bucket\n if (bucket === undefined) return undefined\n const readablePrefixes = b2ReadableRawPrefixes(config)\n const idleTimeoutMillis = normalizeSha1TimeoutMillis(config.options.sha1ReadTimeoutMillis)\n const verificationTimeoutMillis = normalizeSha1TimeoutMillis(\n config.options.sha1VerificationTimeoutMillis,\n DEFAULT_SHA1_VERIFICATION_TIMEOUT_MILLIS,\n )\n\n return async (path, signal) => {\n const expectedBytes = assertValidB2ContentLength(path.selectedVersion.contentLength)\n const maxBytes = normalizeSha1VerificationMaxBytes(\n expectedBytes,\n config.options.sha1VerificationMaxBytes,\n )\n return withSha1VerificationDeadline(\n signal,\n verificationTimeoutMillis,\n async (deadlineSignal) => {\n deadlineSignal.throwIfAborted()\n if (maxBytes < expectedBytes) {\n throw new Error(\n `sha1 B2 verification skipped because contentLength ${expectedBytes} exceeds ${maxBytes} byte verification budget`,\n )\n }\n const serverSideEncryption = toSseCDownloadKey(\n config.options.encryptionProvider?.getSettingForDownload(path.selectedVersion),\n )\n const fileName = validateB2SyncPathInAnyPrefix(readablePrefixes, path, 'read')\n const result = await bucket.file(fileName).downloadById(path.selectedVersion.fileId, {\n ...(serverSideEncryption !== undefined ? { serverSideEncryption } : {}),\n signal: deadlineSignal,\n })\n const verified = await hashReadableStreamSha1(result.body, deadlineSignal, {\n idleTimeoutMillis,\n maxBytes,\n expectedBytes,\n })\n return { contentSha1: verified.contentSha1, bytesRead: verified.bytesRead }\n },\n )\n }\n}\n\nfunction forwardAbortSignal(\n source: AbortSignal | undefined,\n controller: AbortController,\n): () => void {\n if (source === undefined) return () => undefined\n if (source.aborted) {\n abortActionController(controller, source.reason)\n return () => undefined\n }\n\n const abort = () => abortActionController(controller, source.reason)\n source.addEventListener('abort', abort, { once: true })\n return () => source.removeEventListener('abort', abort)\n}\n\nfunction abortActionController(controller: AbortController, reason: unknown): void {\n if (!controller.signal.aborted) {\n controller.abort(reason)\n }\n}\n\n/**\n * Narrowing assertion that a `Bucket` is present for an action that requires\n * it. Throws with a consistent, context-tagged message when the configured\n * direction did not supply one (e.g. `b2-to-local` direction asking for an\n * upload action).\n *\n * Uses TypeScript's `asserts` signature so call-site flow narrows\n * `bucket` from `Bucket | undefined` to `Bucket` after the check, without\n * requiring a separate `if (!bucket) throw ...` line per action factory.\n *\n * @param bucket - The (possibly missing) bucket reference.\n * @param context - Short verb describing the action being constructed\n * (e.g. `'upload'`, `'download'`). Surfaced in the error message.\n *\n * @throws `Error` when `bucket` is `undefined` or `null`.\n */\nfunction assertBucket(bucket: Bucket | undefined, context: string): asserts bucket is Bucket {\n if (!bucket) throw new Error(`Bucket required for ${context} actions`)\n}\n\n/**\n * Returns the root for a local sync folder required by an action.\n *\n * @param folder - The configured folder to validate.\n * @param role - Whether the local folder is the source or destination.\n * @param context - Short verb describing the action being constructed.\n *\n * @returns The local filesystem root.\n *\n * @throws `Error` when the folder is not local or has no root.\n */\nfunction requireLocalRoot(\n folder: SyncFolder | undefined,\n role: 'source' | 'destination',\n context: string,\n): string {\n const root = folder?.type === 'local' ? (folder as Partial<LocalSyncFolder>).root : undefined\n if (typeof root !== 'string' || root === '') {\n throw new Error(`Local ${role} root required for ${context} actions`)\n }\n return root\n}\n\nasync function resolveLocalRootContexts(config: SynchronizerConfig): Promise<LocalRootContexts> {\n const sourceIsLocalFilesystem = isLocalFilesystemFolder(config.source)\n const destIsLocalFilesystem = isLocalFilesystemFolder(config.dest)\n if (!sourceIsLocalFilesystem && !destIsLocalFilesystem) return {}\n\n const sourceContext = config.dest.type === 'b2' ? 'upload' : 'sync'\n const destContext = config.source.type === 'b2' ? 'download' : 'sync'\n return {\n ...(sourceIsLocalFilesystem\n ? {\n source: await resolveLocalRootContext(\n requireLocalRoot(config.source, 'source', sourceContext),\n ),\n }\n : {}),\n ...(destIsLocalFilesystem\n ? {\n dest: await resolveLocalRootContext(\n requireLocalRoot(config.dest, 'destination', destContext),\n ),\n }\n : {}),\n }\n}\n\nasync function resolveLocalRootContext(root: string): Promise<LocalRootContext> {\n const { realpath, stat } = await import('node:fs/promises')\n const { resolve } = await import('node:path')\n const safeRoot = resolve(root)\n const realPath = await realpath(safeRoot).catch((err: unknown) => {\n if (isNotFoundError(err)) return safeRoot\n throw err\n })\n const stats = await stat(realPath).catch((err: unknown) => {\n if (isNotFoundError(err)) return undefined\n throw err\n })\n if (stats !== undefined && !stats.isDirectory()) {\n throw new Error('Local sync root is not a directory')\n }\n return {\n root: safeRoot,\n realPath,\n ...(stats === undefined\n ? {}\n : { identity: { deviceId: stats.dev, inode: stats.ino } satisfies LocalRootIdentity }),\n }\n}\n\nfunction isLocalFilesystemFolder(folder: SyncFolder | undefined): folder is LocalSyncFolder {\n return folder?.type === 'local' && isLocalFilesystemRoot(folder)\n}\n/**\n * Narrows a setting to SSE-C; non-SSE-C source settings need no key on read.\n *\n * @param setting - Provider-supplied encryption setting, or undefined.\n *\n * @returns The SSE-C setting when one is provided; otherwise undefined.\n */\nfunction toSseCEncryptionSetting(\n setting: EncryptionSetting | undefined,\n): Extract<EncryptionSetting, { readonly mode: 'SSE-C' }> | undefined {\n if (setting?.mode !== 'SSE-C') return undefined\n return setting\n}\n\n/**\n * Returns a download key from SSE-C settings; non-SSE-C downloads need no key.\n *\n * @param setting - Provider-supplied encryption setting, or undefined.\n *\n * @returns A download key for SSE-C files; otherwise undefined.\n */\nfunction toSseCDownloadKey(setting: EncryptionSetting | undefined): SseCDownloadKey | undefined {\n return toSseCEncryptionSetting(setting)\n}\n\n/**\n * Creates a configured sync engine wired to the bucket and paths in the given config.\n *\n * For sync operations that may need to remove destination-only files (the\n * `keepMode: 'delete'` policy), the factory reads the destination\n * bucket's cached `fileLockConfiguration` once so `removeOrphan` can\n * dispatch to either `hide` (locked buckets) or `deleteFileVersion`\n * (vanilla buckets) without a per-file branch. The cache is whatever\n * `client.listBuckets()` or `client.createBucket()` returned — callers\n * who flipped lock state mid-sync (rare) should refresh before\n * synchronize().\n *\n * @param config - Synchronizer configuration containing source, destination, and options.\n * @param localRootContexts - Resolved filesystem roots captured before action creation.\n *\n * @returns An action factory bound to the provided configuration.\n */\nfunction createActionFactory(\n config: SynchronizerConfig,\n localRootContexts: LocalRootContexts,\n): ActionFactory {\n const upConfig = config as Partial<SynchronizerUpConfig>\n const downConfig = config as Partial<SynchronizerDownConfig>\n const uploadPrefix = asRawB2KeyPrefix(upConfig.prefix ?? b2FolderRawPrefix(config.dest) ?? '')\n const sourceB2Prefix = b2FolderRawPrefix(config.source)\n\n const destBucket = upConfig.bucket ?? downConfig.bucket\n // Defensive optional chain on `info`: synchronizer tests use Bucket\n // mocks that don't populate this field. Real `Bucket` instances always\n // do (constructor parameter).\n const bucketIsLocked = destBucket?.info?.fileLockConfiguration?.value?.isFileLockEnabled ?? false\n\n const factory: ActionFactory = {\n upload(source: LocalSyncPath, dest?: B2SyncPath): SyncAction {\n const bucket = upConfig.bucket\n assertBucket(bucket, 'upload')\n\n return new UploadAction(\n source.relativePath,\n source.absolutePath,\n source.size,\n async (absPath, relPath, signal) => {\n const rootContext = localRootContexts.source\n const root = rootContext?.root ?? (upConfig.source as Partial<LocalSyncFolder>).root ?? ''\n const fileName =\n dest !== undefined\n ? validateB2SyncPathInPrefix(uploadPrefix, dest)\n : `${uploadPrefix}${relPath}`\n if (rootContext !== undefined) {\n await assertLocalRootContextCurrent(rootContext, relPath, { allowSymlinkRoot: true })\n }\n const targetPath =\n rootContext === undefined\n ? await resolveContainedLocalPath(root, source.relativePath, absPath)\n : await resolveContainedLocalPath(rootContext.realPath, source.relativePath)\n throwIfAborted(signal)\n // FileSource avoids whole-file buffering and rejects path swaps on a\n // best-effort basis. On Windows, callers that need tamper-resistant\n // same-size rewrite detection should use compareMode: 'sha1' or an\n // independent digest because restored modification times can hide\n // local rewrites.\n const fileSource = await createValidatedUploadFileSource(source, targetPath)\n throwIfAborted(signal)\n const serverSideEncryption = config.options.encryptionProvider?.getSettingForUpload(\n fileName,\n fileSource.size,\n )\n await bucket.upload({\n fileName,\n source: fileSource,\n ...(serverSideEncryption !== undefined ? { serverSideEncryption } : {}),\n ...(signal !== undefined ? { signal } : {}),\n })\n },\n )\n },\n\n download(source: B2SyncPath, scannedDest?: LocalSyncPath | null): SyncAction {\n const bucket = downConfig.bucket\n assertBucket(bucket, 'download')\n\n return new DownloadAction(source.relativePath, source.size, async (relPath, signal) => {\n const rootContext = localRootContexts.dest\n const root = rootContext?.root ?? (downConfig.dest as Partial<LocalSyncFolder>).root ?? ''\n safeRelativePathSegments(relPath)\n const b2FileName =\n sourceB2Prefix === undefined\n ? source.selectedVersion.fileName\n : validateB2SyncPathInPrefix(sourceB2Prefix, source, 'read')\n const idleTimeoutMillis = normalizeDownloadIdleTimeoutMillis(\n config.options.downloadIdleTimeoutMillis,\n )\n const expectedBytes = assertValidB2ContentLength(source.selectedVersion.contentLength)\n if (rootContext !== undefined) {\n await assertLocalRootContextCurrent(rootContext, relPath, { allowSymlinkRoot: false })\n }\n await ensureLocalSyncRootDirectory(root, relPath)\n const serverSideEncryption = toSseCDownloadKey(\n config.options.encryptionProvider?.getSettingForDownload(source.selectedVersion),\n )\n const result = await bucket.file(b2FileName).downloadById(source.selectedVersion.fileId, {\n ...(serverSideEncryption !== undefined ? { serverSideEncryption } : {}),\n ...(signal !== undefined ? { signal } : {}),\n })\n try {\n await writeLocalStreamInsideRoot(root, relPath, result.body, {\n expectedBytes,\n ...(scannedDest !== undefined ? { expectedDestination: scannedDest } : {}),\n idleTimeoutMillis,\n ...(signal !== undefined ? { signal } : {}),\n })\n } catch (err) {\n await cancelReadableStreamBody(result.body, err)\n throw err\n }\n })\n },\n\n copy(source: B2SyncPath, destRelativePath: string): SyncAction {\n return copyToB2Key(source, `${uploadPrefix}${destRelativePath}`)\n },\n\n copyB2Path(source: B2SyncPath, dest: B2SyncPath): SyncAction {\n return copyToB2Key(source, validateB2SyncPathInPrefix(uploadPrefix, dest))\n },\n\n hide(path: string): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'hide')\n\n return new HideAction(path, async (_relPath, signal) => {\n await bucket.hideFile(\n `${uploadPrefix}${path}`,\n signal === undefined ? undefined : { signal },\n )\n })\n },\n\n hideB2Path(path: B2SyncPath): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'hide')\n const b2FileName = validateB2SyncPathInPrefix(uploadPrefix, path)\n\n return new HideAction(path.relativePath, async (_relPath, signal) => {\n await bucket.hideFile(b2FileName, signal === undefined ? undefined : { signal })\n })\n },\n\n deleteRemote(path: B2SyncPath): SyncAction {\n const bucket = upConfig.bucket ?? downConfig.bucket\n assertBucket(bucket, 'delete')\n\n // Bug fix: `DeleteRemoteAction` invokes the closure with\n // `relativePath` (the scanner-stripped name relative to the sync\n // prefix), but B2 stores files under the FULL name including the\n // prefix. Use the FileVersion's authoritative `fileName` — the\n // actual B2 key — rather than reconstructing it via prefix\n // concat. Without this, syncs with a non-empty destination\n // prefix (e.g. `'site/'`) failed orphan deletion with\n // `file_not_present`.\n const b2FileName = validateB2SyncPathInPrefix(uploadPrefix, path)\n return new DeleteRemoteAction(\n path.relativePath,\n path.selectedVersion.fileId as string,\n async (fileId, _fileName, signal) => {\n await bucket.deleteFileVersion(\n b2FileName,\n fileIdOf(fileId),\n signal === undefined ? undefined : { signal },\n )\n },\n )\n },\n\n deleteLocal(path: LocalSyncPath): SyncAction {\n const rootContext = localRootContexts.dest\n const root = rootContext?.root ?? localSyncRoot(downConfig.dest)\n return new DeleteLocalAction(\n path.relativePath,\n path.absolutePath,\n async (absPath, signal) => {\n signal?.throwIfAborted()\n if (absPath !== path.absolutePath) {\n throw new Error(`Refusing to delete outside sync root: ${path.relativePath}`)\n }\n signal?.throwIfAborted()\n try {\n if (rootContext !== undefined) {\n await assertLocalRootContextCurrent(rootContext, path.relativePath, {\n allowSymlinkRoot: false,\n })\n }\n await deleteLocalFileInsideRoot(root, path)\n } catch (err) {\n if (isLocalDeleteSafetyError(err)) throw err\n throw new Error(`failed to delete local file: ${localFilesystemErrorReason(err)}`)\n }\n },\n )\n },\n\n removeOrphan(dest: B2SyncPath): SyncAction {\n // Locked buckets: `b2_delete_file_version` is blocked or stacks\n // hide markers under retention; a hide is the safe choice.\n // Vanilla buckets: plain delete is the right move — hide markers\n // would just litter the version history.\n return bucketIsLocked\n ? (factory.hideB2Path?.(dest) ?? factory.hide(dest.relativePath))\n : factory.deleteRemote(dest)\n },\n }\n\n function copyToB2Key(source: B2SyncPath, targetPath: string): SyncAction {\n const bucket = upConfig.bucket\n assertBucket(bucket, 'copy')\n\n return new CopyAction(source.relativePath, source.size, async (_relPath, signal) => {\n if (sourceB2Prefix !== undefined) validateB2SyncPathInPrefix(sourceB2Prefix, source, 'read')\n const destinationServerSideEncryption =\n config.options.encryptionProvider?.getSettingForUpload(targetPath, source.size)\n const sourceServerSideEncryption = toSseCEncryptionSetting(\n config.options.encryptionProvider?.getSettingForDownload(source.selectedVersion),\n )\n await bucket.copyFile({\n sourceFileId: source.selectedVersion.fileId,\n fileName: targetPath,\n ...(destinationServerSideEncryption !== undefined\n ? { destinationServerSideEncryption }\n : {}),\n ...(sourceServerSideEncryption !== undefined ? { sourceServerSideEncryption } : {}),\n ...(signal !== undefined ? { signal } : {}),\n })\n })\n }\n\n return factory\n}\n\nasync function createValidatedUploadFileSource(\n source: LocalSyncPath,\n absolutePath: string,\n): Promise<ContentSource> {\n try {\n const fileSource = await FileSource.fromPath(absolutePath)\n await validateScannedLocalFile({ ...source, absolutePath })\n return fileSource\n } catch (err) {\n throw normalizeLocalUploadSourceError(err)\n }\n}\n\nfunction normalizeLocalUploadSourceError(err: unknown): Error {\n if (err instanceof Error && err.message.startsWith('local file changed before upload')) {\n return err\n }\n const message = err instanceof Error ? err.message : String(err)\n if (message.includes('not a regular file')) {\n return new Error('local file changed before upload: not a regular file')\n }\n if (message.includes('changed') || message.includes('modified')) {\n return new Error('local file changed before upload')\n }\n return new Error(`local file changed before upload: ${sanitizeErrorReason(err)}`)\n}\n\nfunction localSyncRoot(folder: LocalSyncFolder | undefined): string {\n return folder?.type === 'local' ? folder.root : ''\n}\n\nfunction b2FolderRawPrefix(folder: SyncFolder | undefined): string | undefined {\n if (folder?.type !== 'b2') return undefined\n const rawPrefix = (folder as B2SyncFolder).rawPrefix\n return typeof rawPrefix === 'string' ? rawPrefix : undefined\n}\n\nfunction validateB2SourcePairPrefix(pair: SyncPair, config: SynchronizerConfig): void {\n const [source] = pair\n if (config.source.type !== 'b2' || source === null || !isB2SyncPath(source)) return\n const sourcePrefix = b2FolderRawPrefix(config.source)\n if (sourcePrefix === undefined) return\n validateB2SyncPathInPrefix(sourcePrefix, source, 'read')\n}\n\nfunction b2ReadableRawPrefixes(config: SynchronizerConfig): readonly string[] {\n const prefixes: string[] = []\n const sourcePrefix = b2FolderRawPrefix(config.source)\n if (config.source.type === 'b2') prefixes.push(sourcePrefix ?? '')\n\n const upConfig = config as Partial<SynchronizerUpConfig>\n if (config.dest.type === 'b2') {\n prefixes.push(upConfig.prefix ?? b2FolderRawPrefix(config.dest) ?? '')\n }\n\n return [...new Set(prefixes.map((prefix) => asRawB2KeyPrefix(prefix)))]\n}\n\nfunction validateB2SyncPathInAnyPrefix(\n prefixes: readonly string[],\n path: B2SyncPath,\n operation: string,\n): string {\n let firstError = new Error(`Refusing to ${operation} B2 key: ${path.relativePath}`)\n for (const prefix of prefixes) {\n try {\n return validateB2SyncPathInPrefix(prefix, path, operation)\n } catch (err) {\n if (err instanceof Error) firstError = err\n }\n }\n throw firstError\n}\n\nfunction validateB2SyncPathInPrefix(\n prefix: string,\n path: B2SyncPath,\n operation = 'mutate',\n): string {\n const fileName = path.selectedVersion.fileName\n if (!fileName.startsWith(prefix)) {\n throw new Error(\n `Refusing to ${operation} B2 key outside configured prefix: ${path.relativePath}`,\n )\n }\n\n const relativePath = b2KeyToRelativePathUnderPrefix(prefix, fileName)\n if (relativePath !== path.relativePath) {\n throw new Error(\n `Refusing to ${operation} mismatched B2 key for sync path: ${path.relativePath}`,\n )\n }\n\n return fileName\n}\n\nfunction isB2SyncPath(path: SyncPath): path is B2SyncPath {\n return 'selectedVersion' in path\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted === true) {\n throw signal.reason ?? new DOMException('Aborted', 'AbortError')\n }\n}\n\nasync function cancelReadableStreamBody(\n body: ReadableStream<Uint8Array>,\n reason: unknown,\n): Promise<void> {\n if (body.locked) return\n try {\n await body.cancel(reason)\n } catch {\n // Best-effort response cleanup must not mask the setup or write failure.\n }\n}\n\nasync function assertLocalRootContextCurrent(\n context: LocalRootContext,\n relativePath: string,\n options: { readonly allowSymlinkRoot: boolean },\n): Promise<void> {\n if (context.identity === undefined) return\n\n const { lstat, realpath, stat } = await import('node:fs/promises')\n let currentRealPath: string\n try {\n const rootLinkStats = await lstat(context.root)\n if (!options.allowSymlinkRoot && rootLinkStats.isSymbolicLink()) {\n throw new Error(`Refusing to access sync root through symlink: ${relativePath}`)\n }\n currentRealPath = await realpath(context.root)\n } catch (err) {\n if (err instanceof Error && err.message.startsWith('Refusing to access sync root')) throw err\n throw new Error(`Local sync root changed before filesystem action: ${relativePath}`)\n }\n\n if (currentRealPath !== context.realPath) {\n throw new Error(`Local sync root changed before filesystem action: ${relativePath}`)\n }\n\n let currentStats: Awaited<ReturnType<typeof stat>>\n try {\n currentStats = await stat(context.realPath)\n } catch {\n throw new Error(`Local sync root changed before filesystem action: ${relativePath}`)\n }\n\n if (\n !currentStats.isDirectory() ||\n currentStats.dev !== context.identity.deviceId ||\n currentStats.ino !== context.identity.inode\n ) {\n throw new Error(`Local sync root changed before filesystem action: ${relativePath}`)\n }\n}\n\nasync function ensureLocalSyncRootDirectory(root: string, relativePath: string): Promise<void> {\n if (root === '') {\n throw new Error('Local sync root required for filesystem mutation')\n }\n\n const { lstat, mkdir } = await import('node:fs/promises')\n const { resolve } = await import('node:path')\n const safeRoot = resolve(root)\n\n try {\n const stats = await lstat(safeRoot)\n if (stats.isSymbolicLink()) {\n throw new Error(`Refusing to access sync root through symlink: ${relativePath}`)\n }\n if (!stats.isDirectory()) {\n throw new Error(`Local sync root is not a directory: ${relativePath}`)\n }\n return\n } catch (error) {\n if (!isNotFoundError(error)) throw error\n }\n\n await mkdir(safeRoot, { recursive: true })\n await assertLocalRootHasNoSymlink(safeRoot, relativePath)\n}\n\nfunction bufferScanEvent(\n buffer: ScanEventBuffer,\n event: SyncEvent,\n direction: SyncDirection,\n scanSide: 'source' | 'dest',\n): void {\n if (event.type === 'skip' && event.reason === 'filesystem-error') {\n buffer.fatalFilesystemErrorMessage ??= event.message\n }\n if (sourceSkipMakesInventoryIncomplete(event, direction, scanSide)) {\n buffer.sourceInventoryIncompleteMessage ??= sourceInventoryIncompleteMessage(direction)\n }\n if (buffer.events.length < MAX_BUFFERED_SCAN_EVENTS) {\n buffer.events.push(event)\n } else {\n buffer.dropped++\n }\n}\n\nfunction* drainScanEvents(buffer: ScanEventBuffer): Generator<SyncEvent> {\n while (buffer.events.length > 0) {\n const event = buffer.events.shift()\n if (event) yield event\n }\n\n if (buffer.dropped > 0) {\n yield {\n type: 'skip',\n path: '',\n size: 0,\n reason: 'scan-skip-overflow',\n message: `${buffer.dropped} scanner skip event(s) were omitted after ${MAX_BUFFERED_SCAN_EVENTS} buffered diagnostics`,\n }\n buffer.dropped = 0\n }\n}\n\nfunction scanHadFilesystemError(scanEvents: ScanEventBuffer): boolean {\n return scanEvents.fatalFilesystemErrorMessage !== undefined\n}\n\nfunction sourceInventoryIncomplete(scanEvents: ScanEventBuffer): boolean {\n return scanEvents.sourceInventoryIncompleteMessage !== undefined\n}\n\nfunction scanFilesystemError(scanEvents: ScanEventBuffer): Error | undefined {\n return scanEvents.fatalFilesystemErrorMessage === undefined\n ? undefined\n : new Error(scanEvents.fatalFilesystemErrorMessage)\n}\n\nfunction sourceSkipMakesInventoryIncomplete(\n event: SyncEvent,\n direction: SyncDirection,\n scanSide: 'source' | 'dest',\n): event is SyncSkipEvent {\n if (scanSide !== 'source' || event.type !== 'skip') return false\n\n if (direction === 'local-to-b2') {\n return (\n event.reason === 'unsafe-name' ||\n event.reason === 'stale-download-partial' ||\n event.reason === 'path-too-long-for-regexp'\n )\n }\n\n if (direction === 'b2-to-local' || direction === 'b2-to-b2') {\n return (\n event.reason === 'unsafe-name' ||\n event.reason === 'local-unsafe-name' ||\n event.reason === 'relative-path-collision' ||\n event.reason === 'local-path-collision' ||\n event.reason === 'path-too-long-for-regexp'\n )\n }\n\n return false\n}\n\nfunction sourceInventoryIncompleteMessage(direction: SyncDirection): string {\n return direction === 'local-to-b2'\n ? 'not removed because the source scan skipped local paths'\n : 'not removed because the source scan skipped unsafe B2 names'\n}\n\nfunction isLocalDeleteSafetyError(err: unknown): boolean {\n if (!(err instanceof Error)) return false\n return (\n err.message === 'Local sync root required for filesystem mutation' ||\n err.message.startsWith('Local sync root changed before filesystem action: ') ||\n err.message.startsWith('Refusing to ') ||\n err.message.startsWith('Local sync root is not a directory: ') ||\n err.message.startsWith('unsafe local delete path: ')\n )\n}\n\nasync function resolveContainedLocalPath(\n root: string,\n relativePath: string,\n absolutePath?: string,\n): Promise<string> {\n if (root === '') {\n throw new Error('Local sync root required for filesystem mutation')\n }\n\n const { isAbsolute, relative, resolve, sep } = await import('node:path')\n const safeRoot = resolve(root)\n const target =\n absolutePath === undefined ? resolve(safeRoot, relativePath) : resolve(absolutePath)\n const pathFromRoot = relative(safeRoot, target)\n const escapesRoot =\n pathFromRoot === '..' || pathFromRoot.startsWith(`..${sep}`) || isAbsolute(pathFromRoot)\n\n /* v8 ignore next -- defense-in-depth after prior no-follow and symlink checks. */\n if (escapesRoot) {\n throw new Error(`Refusing to access path outside sync root: ${relativePath}`)\n }\n\n await assertLocalRootHasNoSymlink(safeRoot, relativePath)\n await assertPathHasNoSymlinkComponents(safeRoot, pathFromRoot, relativePath)\n\n return target\n}\n\nasync function assertLocalRootHasNoSymlink(safeRoot: string, relativePath: string): Promise<void> {\n const { lstat } = await import('node:fs/promises')\n try {\n const stats = await lstat(safeRoot)\n if (stats.isSymbolicLink()) {\n throw new Error(`Refusing to access sync root through symlink: ${relativePath}`)\n }\n } catch (error) {\n if (isNotFoundError(error)) return\n throw error\n }\n}\n\nasync function assertPathHasNoSymlinkComponents(\n safeRoot: string,\n pathFromRoot: string,\n relativePath: string,\n): Promise<void> {\n if (pathFromRoot === '') return\n\n const { lstat } = await import('node:fs/promises')\n const { join, sep } = await import('node:path')\n let current = safeRoot\n\n for (const segment of pathFromRoot.split(sep)) {\n current = join(current, segment)\n let stats: Awaited<ReturnType<typeof lstat>>\n try {\n stats = await lstat(current)\n } catch (error) {\n if (isNotFoundError(error)) return\n throw error\n }\n if (stats.isSymbolicLink()) {\n throw new Error(`Refusing to access path through symlink: ${relativePath}`)\n }\n }\n}\n\nfunction isNotFoundError(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n (error as { readonly code?: unknown }).code === 'ENOENT'\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0DA,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,uCAAuC;;;;;;AAc7C,IAAa,wBAET,CAAC;;;;;;;;;;AA2GL,SAAS,iBAAiB,QAAoB,MAAiC;CAC7E,IAAI,OAAO,SAAS,WAAW,KAAK,SAAS,MAAM,OAAO;CAC1D,IAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,SAAS,OAAO;CAC1D,IAAI,OAAO,SAAS,QAAQ,KAAK,SAAS,MAAM,OAAO;CACvD,MAAM,IAAI,MAAM,+BAA+B,OAAO,KAAK,MAAM,KAAK,MAAM;AAC9E;AAwBA,gBAAuB,YAAY,QAAuD;CACxF,MAAM,EAAE,QAAQ,MAAM,YAAY;CAClC,2BAA2B,QAAQ,WAAW;CAC9C,MAAM,YAAY,iBAAiB,QAAQ,IAAI;CAC/C,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,cAAc,yBAAyB,QAAQ,WAAW;CAChE,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,oBAAoB,MAAM,yBAAyB,MAAM;CAC/D,MAAM,eAA4B,CAAC;CACnC,MAAM,cAAwB,CAAC;CAC/B,MAAM,gCAAgB,IAAI,IAAY;CACtC,IAAI,aAAa;CACjB,IAAI,yBAAyB;CAC7B,IAAI,eAAe;CACnB,MAAM,iCAAiB,IAAI,IAAmB;CAC9C,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AG,GAAG;EAC7C,UAAU,KAAK,SAAS,OAAO;EAC/B,IAAI;EACJ,IAAI;GACF,QAAQ,MAAM,MAAM,OAAO;EAC7B,SAAS,OAAO;GACd,IAAI,gBAAgB,KAAK,GAAG;GAC5B,MAAM;EACR;EACA,IAAI,MAAM,eAAe,GACvB,MAAM,IAAI,MAAM,4CAA4C,cAAc;CAE9E;AACF;AAEA,SAAS,gBAAgB,OAAyB;CAChD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAAsC,SAAS;AAEpD"}
|
package/dist/sync/types.d.cts
CHANGED
|
@@ -1,11 +1,97 @@
|
|
|
1
1
|
import { EncryptionSetting } from '../types/encryption.js';
|
|
2
2
|
import { FileVersion } from '../types/file.js';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { SyncSha1State } from './sha1-metadata.js';
|
|
4
|
+
/**
|
|
5
|
+
* Strategy for comparing source and destination files.
|
|
6
|
+
*
|
|
7
|
+
* The `sha1` mode compares 40-character hexadecimal SHA-1 digests as a practical drift
|
|
8
|
+
* detector. Digest case is normalized before comparison. Missing, null, unavailable, or
|
|
9
|
+
* non-verifiable metadata cannot prove equality: the high-level synchronizer either transfers
|
|
10
|
+
* conservatively for untrusted metadata or skips action generation with a surfaced event when a
|
|
11
|
+
* B2 file has no comparable digest. Untrusted B2 metadata may require downloading the selected
|
|
12
|
+
* B2 version to hash its bytes before equality can be trusted. This is not a cryptographic
|
|
13
|
+
* integrity or tamper-proofing guarantee, because SHA-1 collisions are possible.
|
|
14
|
+
*/
|
|
15
|
+
export type CompareMode = 'modtime' | 'size' | 'sha1' | 'none';
|
|
5
16
|
/** Strategy for handling destination files not present in the source. */
|
|
6
17
|
export type KeepMode = 'no-delete' | 'delete' | 'keep-days';
|
|
7
18
|
/** Direction of a sync operation. */
|
|
8
19
|
export type SyncDirection = 'local-to-b2' | 'b2-to-local' | 'b2-to-b2';
|
|
20
|
+
/**
|
|
21
|
+
* Glob string or regular expression used to include or exclude sync paths.
|
|
22
|
+
*
|
|
23
|
+
* Glob strings use a small SDK-defined dialect against folder-relative paths with forward
|
|
24
|
+
* slashes: `*` and `?` match within one path segment, and a path segment that is exactly `**`
|
|
25
|
+
* matches across directory boundaries. Character classes, brace expansion, extglobs, and
|
|
26
|
+
* backslash escaping are not supported. Slash-less globs use basename-style matching at any
|
|
27
|
+
* directory depth, so `*.tmp` matches `nested/file.tmp` and `readme.md` matches both `readme.md`
|
|
28
|
+
* and `docs/readme.md`. They also match ancestor directory names, so `node_modules` matches every
|
|
29
|
+
* file under a `node_modules` directory. Exclude filters win over include filters.
|
|
30
|
+
*
|
|
31
|
+
* Regular expressions are matched against the full relative path. Global and sticky flags are
|
|
32
|
+
* ignored so matching does not mutate `lastIndex`. RegExp acceptance is a best-effort safety
|
|
33
|
+
* heuristic for synchronous matching, and the exact accepted subset may change as the SDK tightens
|
|
34
|
+
* protection. Current guards reject overly long sources, backreferences, multiple unbounded
|
|
35
|
+
* quantifiers, large or excessive bounded quantifiers, and quantified groups whose subtree
|
|
36
|
+
* contains a quantifier or alternation.
|
|
37
|
+
* When any RegExp filter is configured, paths longer than the SDK's RegExp input guard are skipped
|
|
38
|
+
* instead of being fed to the JavaScript RegExp engine. This is fail-closed for deny-lists: an
|
|
39
|
+
* untestable long path is not allowed through an exclude RegExp filter.
|
|
40
|
+
*/
|
|
41
|
+
export type SyncFilterPattern = string | RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* Include/exclude filters applied to sync paths relative to each folder root.
|
|
44
|
+
*
|
|
45
|
+
* `SyncOptions.include` and `SyncOptions.exclude` are the canonical filters for
|
|
46
|
+
* {@link synchronize}; they are passed down into folder scans and then enforced again during
|
|
47
|
+
* pairing as the SDK policy boundary. Calling
|
|
48
|
+
* {@link SyncFolder.scan} directly can pass the same filter object for standalone scans.
|
|
49
|
+
*/
|
|
50
|
+
export interface SyncFilterOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Optional allow-list. When present, only paths matching at least one pattern are scanned.
|
|
53
|
+
* B2 scans can push down only the safe literal prefix from slash-containing glob includes;
|
|
54
|
+
* other include filtering is client-side.
|
|
55
|
+
*/
|
|
56
|
+
readonly include?: readonly SyncFilterPattern[];
|
|
57
|
+
/**
|
|
58
|
+
* Optional deny-list. Paths matching any exclude pattern are skipped even when they also match
|
|
59
|
+
* an include pattern. Excludes are client-side filters; they do not reduce B2 list API calls or
|
|
60
|
+
* the B2 scanner's version grouping and sort memory.
|
|
61
|
+
*/
|
|
62
|
+
readonly exclude?: readonly SyncFilterPattern[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options accepted by {@link SyncFolder.scan}. Includes filters plus an optional scan-level
|
|
66
|
+
* callback for paths the scanner cannot safely represent or test.
|
|
67
|
+
*/
|
|
68
|
+
export interface SyncScanOptions extends SyncFilterOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Optional signal checked by built-in scanners while enumerating. Aborting stops local traversal
|
|
71
|
+
* promptly and stops B2 scans before requesting the next page.
|
|
72
|
+
*/
|
|
73
|
+
readonly signal?: AbortSignal;
|
|
74
|
+
/**
|
|
75
|
+
* Receives scan diagnostics. Built-in scanners may continue after recoverable per-path
|
|
76
|
+
* diagnostics, such as unreadable local children, but fatal scan failures still abort.
|
|
77
|
+
*/
|
|
78
|
+
readonly onError?: (event: SyncErrorEvent) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Receives scanner skip diagnostics. Built-in scans isolate callback errors so diagnostics
|
|
81
|
+
* handlers cannot abort the scan.
|
|
82
|
+
*/
|
|
83
|
+
readonly onSkip?: (event: SyncSkipEvent) => void;
|
|
84
|
+
/**
|
|
85
|
+
* When true, B2 scanners skip names that cannot be written safely to a local filesystem
|
|
86
|
+
* destination and reject case/Unicode-canonical local path collisions.
|
|
87
|
+
*/
|
|
88
|
+
readonly requireLocalSafePaths?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Maximum number of entries a scanner may retain before failing with a defined error instead of
|
|
91
|
+
* continuing toward unbounded heap growth. Defaults to the SDK scan limit.
|
|
92
|
+
*/
|
|
93
|
+
readonly maxScanEntries?: number;
|
|
94
|
+
}
|
|
9
95
|
/** Common metadata for a file discovered during a folder scan. */
|
|
10
96
|
export interface SyncPath {
|
|
11
97
|
/** Path relative to the sync folder root, using forward slashes. */
|
|
@@ -14,11 +100,51 @@ export interface SyncPath {
|
|
|
14
100
|
readonly modTimeMillis: number;
|
|
15
101
|
/** File size in bytes. */
|
|
16
102
|
readonly size: number;
|
|
103
|
+
/**
|
|
104
|
+
* SHA-1 checksum state for compare modes that need content hashes.
|
|
105
|
+
*
|
|
106
|
+
* - `undefined`: not computed yet; the synchronizer may hash local files before comparing.
|
|
107
|
+
* - `null`: known to be unavailable; `sha1` sync skips the pair with a surfaced event.
|
|
108
|
+
* - 40-character hex string: known verifiable digest.
|
|
109
|
+
* - other string: untrusted provider metadata such as B2's `unverified:<hex>` sentinel;
|
|
110
|
+
* consumers must not treat it as proof that bytes match. The `sha1` synchronizer must
|
|
111
|
+
* verify untrusted B2 bytes before using them for equality, or transfer conservatively.
|
|
112
|
+
*
|
|
113
|
+
* Use `parseSyncContentSha1`, `selectB2ComparableSha1`, and `untrustedSha1` from the sync
|
|
114
|
+
* entrypoint to construct or inspect this field without depending on sentinel strings.
|
|
115
|
+
*/
|
|
116
|
+
readonly contentSha1?: string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Explicit SHA-1 trust and availability state. Prefer this field for custom
|
|
119
|
+
* scanners that can distinguish verified digests from untrusted provider
|
|
120
|
+
* metadata without relying on `contentSha1` sentinel strings. When omitted,
|
|
121
|
+
* the synchronizer derives the state from `contentSha1` for compatibility.
|
|
122
|
+
*/
|
|
123
|
+
readonly contentSha1State?: SyncSha1State;
|
|
124
|
+
}
|
|
125
|
+
/** Filesystem identity captured while scanning a local file. */
|
|
126
|
+
export interface LocalFileIdentity {
|
|
127
|
+
/** Device ID from the local filesystem. */
|
|
128
|
+
readonly deviceId: number;
|
|
129
|
+
/** Inode number from the local filesystem. */
|
|
130
|
+
readonly inode: number;
|
|
131
|
+
/** Size observed during the scan. */
|
|
132
|
+
readonly size: number;
|
|
133
|
+
/** Modification time observed during the scan, floored to milliseconds. */
|
|
134
|
+
readonly modTimeMillis: number;
|
|
135
|
+
/**
|
|
136
|
+
* Node `Stats.ctimeMs` observed during the scan, floored to milliseconds.
|
|
137
|
+
* This is inode-change time on POSIX and may be creation time on Windows.
|
|
138
|
+
* Built-in local scans populate this; custom scanners may omit it.
|
|
139
|
+
*/
|
|
140
|
+
readonly changeTimeMillis?: number;
|
|
17
141
|
}
|
|
18
142
|
/** A file on the local filesystem discovered during a scan. */
|
|
19
143
|
export interface LocalSyncPath extends SyncPath {
|
|
20
144
|
/** Absolute filesystem path to the file. */
|
|
21
145
|
readonly absolutePath: string;
|
|
146
|
+
/** Optional filesystem identity used to reject scan-to-read races. */
|
|
147
|
+
readonly fileIdentity?: LocalFileIdentity;
|
|
22
148
|
}
|
|
23
149
|
/** A file in a B2 bucket discovered during a scan. */
|
|
24
150
|
export interface B2SyncPath extends SyncPath {
|
|
@@ -30,13 +156,15 @@ export interface B2SyncPath extends SyncPath {
|
|
|
30
156
|
/** Discriminated event types emitted during synchronization. */
|
|
31
157
|
export type SyncEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local' | 'skip' | 'error' | 'compare';
|
|
32
158
|
/**
|
|
33
|
-
* Action event types: per-file
|
|
34
|
-
*
|
|
35
|
-
*
|
|
159
|
+
* Action event types: per-file transfer or metadata-change outcomes that
|
|
160
|
+
* always carry a `path` and a `size`. Skips are reported separately as
|
|
161
|
+
* {@link SyncSkipEvent} because they carry a diagnostic `message`.
|
|
36
162
|
*/
|
|
37
|
-
export type SyncActionEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local'
|
|
163
|
+
export type SyncActionEventType = 'upload-start' | 'upload-done' | 'download-start' | 'download-done' | 'copy-start' | 'copy-done' | 'hide' | 'delete-remote' | 'delete-local';
|
|
164
|
+
/** Machine-readable reasons emitted with scanner and diagnostic skip events. */
|
|
165
|
+
export type SyncSkipReason = 'outside-prefix' | 'unsafe-name' | 'local-unsafe-name' | 'relative-path-collision' | 'local-path-collision' | 'filesystem-error' | 'path-too-long-for-regexp' | 'scan-skip-overflow' | 'stale-download-partial';
|
|
38
166
|
/**
|
|
39
|
-
* Per-action progress event (transfer
|
|
167
|
+
* Per-action progress event (transfer or metadata change). All
|
|
40
168
|
* action-event variants share the same shape; the `type` tag distinguishes
|
|
41
169
|
* them.
|
|
42
170
|
*/
|
|
@@ -45,9 +173,22 @@ export interface SyncActionEvent {
|
|
|
45
173
|
readonly type: SyncActionEventType;
|
|
46
174
|
/** Relative path of the file this event concerns. */
|
|
47
175
|
readonly path: string;
|
|
48
|
-
/** Size in bytes of the file involved, or 0 for metadata-only
|
|
176
|
+
/** Size in bytes of the file involved, or `0` for metadata-only actions. */
|
|
49
177
|
readonly size: number;
|
|
50
178
|
}
|
|
179
|
+
/** Per-file comparison progress event. */
|
|
180
|
+
export interface SyncCompareEvent {
|
|
181
|
+
/** Discriminant tag (always the literal string `'compare'`). */
|
|
182
|
+
readonly type: 'compare';
|
|
183
|
+
/** Relative path of the compared file. */
|
|
184
|
+
readonly path: string;
|
|
185
|
+
/** Reserved for compatibility with earlier metadata-only compare events. */
|
|
186
|
+
readonly size: 0;
|
|
187
|
+
/** Local file bytes hashed while preparing this comparison, if any. */
|
|
188
|
+
readonly bytesHashed?: number;
|
|
189
|
+
/** B2 bytes downloaded and hashed while verifying untrusted SHA-1 metadata, if any. */
|
|
190
|
+
readonly bytesVerified?: number;
|
|
191
|
+
}
|
|
51
192
|
/**
|
|
52
193
|
* `skip` event — a destination-only file that policy decided to keep, or
|
|
53
194
|
* a same-on-both file that didn't need transfer. Always carries a
|
|
@@ -56,12 +197,16 @@ export interface SyncActionEvent {
|
|
|
56
197
|
export interface SyncSkipEvent {
|
|
57
198
|
/** Discriminant tag (always the literal string `'skip'`). */
|
|
58
199
|
readonly type: 'skip';
|
|
59
|
-
/** Relative path of the skipped file. */
|
|
200
|
+
/** Relative path of the skipped file, or the raw B2 key when no safe relative path exists. */
|
|
60
201
|
readonly path: string;
|
|
61
202
|
/** Size in bytes of the file involved, always 0 for skip events. */
|
|
62
203
|
readonly size: number;
|
|
63
204
|
/** Human-readable reason for skipping this file. */
|
|
64
205
|
readonly message: string;
|
|
206
|
+
/** Machine-readable skip reason when emitted by a scanner or diagnostic buffer. */
|
|
207
|
+
readonly reason?: SyncSkipReason;
|
|
208
|
+
/** Original B2 key when the skip came from a B2 scan. */
|
|
209
|
+
readonly b2FileName?: string;
|
|
65
210
|
}
|
|
66
211
|
/**
|
|
67
212
|
* `error` event — an action threw or the engine encountered a fatal
|
|
@@ -77,6 +222,12 @@ export interface SyncErrorEvent {
|
|
|
77
222
|
readonly size: number;
|
|
78
223
|
/** Human-readable error message; never empty. */
|
|
79
224
|
readonly message: string;
|
|
225
|
+
/** Number of failed actions represented by an aggregate run-level error event. */
|
|
226
|
+
readonly failureCount?: number;
|
|
227
|
+
/** Bounded distinct relative paths of failed actions represented by an aggregate error event. */
|
|
228
|
+
readonly failedPaths?: readonly string[];
|
|
229
|
+
/** Number of failed action paths omitted from a bounded aggregate error event. */
|
|
230
|
+
readonly failedPathOmittedCount?: number;
|
|
80
231
|
}
|
|
81
232
|
/**
|
|
82
233
|
* An event emitted by the sync engine to report progress, skip
|
|
@@ -84,23 +235,45 @@ export interface SyncErrorEvent {
|
|
|
84
235
|
* `case 'error':` (or `'skip':`) to narrow into a variant with `message`
|
|
85
236
|
* guaranteed non-optional.
|
|
86
237
|
*/
|
|
87
|
-
export type SyncEvent = SyncActionEvent | SyncSkipEvent | SyncErrorEvent;
|
|
238
|
+
export type SyncEvent = SyncActionEvent | SyncCompareEvent | SyncSkipEvent | SyncErrorEvent;
|
|
88
239
|
/** Configuration options for a sync operation. */
|
|
89
|
-
export interface SyncOptions {
|
|
240
|
+
export interface SyncOptions extends SyncFilterOptions {
|
|
90
241
|
/** How to decide whether two files differ. */
|
|
91
242
|
readonly compareMode: CompareMode;
|
|
92
243
|
/** What to do with destination files absent from the source. */
|
|
93
244
|
readonly keepMode: KeepMode;
|
|
94
245
|
/** Number of days to retain orphaned destination files when keepMode is 'keep-days'. */
|
|
95
246
|
readonly keepDays?: number;
|
|
96
|
-
/** Maximum number of concurrent transfer actions. Defaults to 4. */
|
|
247
|
+
/** Maximum number of concurrent transfer actions. Must be a positive integer. Defaults to 4. */
|
|
97
248
|
readonly concurrency?: number;
|
|
98
249
|
/** When true, actions are generated but not executed. */
|
|
99
250
|
readonly dryRun?: boolean;
|
|
100
251
|
/** Tolerance for comparison (bytes for size, milliseconds for modtime). */
|
|
101
252
|
readonly compareThreshold?: number;
|
|
102
|
-
/** Signal to abort the sync operation. */
|
|
253
|
+
/** Signal to abort the sync operation, including scans and in-progress SHA-1 reads. */
|
|
103
254
|
readonly signal?: AbortSignal;
|
|
255
|
+
/** Optional idle/no-progress timeout in milliseconds for SHA-1 reads in `sha1` mode. */
|
|
256
|
+
readonly sha1ReadTimeoutMillis?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Optional absolute deadline in milliseconds for untrusted B2 SHA-1 verification reads.
|
|
259
|
+
* Objects that cannot be fully verified before this deadline are skipped for that run.
|
|
260
|
+
*/
|
|
261
|
+
readonly sha1VerificationTimeoutMillis?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Optional per-file byte ceiling for untrusted B2 SHA-1 verification reads.
|
|
264
|
+
*
|
|
265
|
+
* By default, verifying untrusted B2 metadata may download the selected version's full
|
|
266
|
+
* `contentLength` each run. Set this to a lower value to skip objects above the per-file
|
|
267
|
+
* budget before they can be treated as equal.
|
|
268
|
+
*/
|
|
269
|
+
readonly sha1VerificationMaxBytes?: number;
|
|
270
|
+
/**
|
|
271
|
+
* Idle timeout in milliseconds for B2-to-local download body reads. Must be positive, or
|
|
272
|
+
* `Infinity` to disable the timeout. Defaults to 60 seconds.
|
|
273
|
+
*/
|
|
274
|
+
readonly downloadIdleTimeoutMillis?: number;
|
|
275
|
+
/** Maximum scanner entries retained before failing with a defined scan-limit error. */
|
|
276
|
+
readonly maxScanEntries?: number;
|
|
104
277
|
/** Optional provider for per-file encryption settings. */
|
|
105
278
|
readonly encryptionProvider?: SyncEncryptionProvider;
|
|
106
279
|
}
|
|
@@ -111,11 +284,30 @@ export interface SyncEncryptionProvider {
|
|
|
111
284
|
/** Returns the encryption setting to use when downloading a file, or undefined for default. */
|
|
112
285
|
getSettingForDownload(fileVersion: FileVersion): EncryptionSetting | undefined;
|
|
113
286
|
}
|
|
114
|
-
/**
|
|
287
|
+
/**
|
|
288
|
+
* A scannable folder (local or B2) that yields files relative to its sync root.
|
|
289
|
+
*
|
|
290
|
+
* Built-in scanners currently sort before yielding. Large local trees or B2 prefixes may therefore
|
|
291
|
+
* require memory proportional to the scanned entries; B2 scans also group listed versions before
|
|
292
|
+
* yielding. For B2, `maxScanEntries` counts every listed file version before prefix, safety, and
|
|
293
|
+
* filter checks, and exclude filters or non-literal includes do not bound B2 listing calls.
|
|
294
|
+
*/
|
|
115
295
|
export interface SyncFolder {
|
|
116
296
|
/** Whether this folder is local or in B2. */
|
|
117
297
|
readonly type: 'local' | 'b2';
|
|
118
|
-
/**
|
|
119
|
-
|
|
298
|
+
/**
|
|
299
|
+
* True when `scan(filters)` already enforces include/exclude filters itself as an optimization.
|
|
300
|
+
* The synchronizer still reapplies filters after custom scanner output as the SDK policy
|
|
301
|
+
* boundary. Custom folders that set this should use the exported filter helpers from
|
|
302
|
+
* `@backblaze-labs/b2-sdk/sync` to stay aligned with the SDK glob and RegExp dialect.
|
|
303
|
+
*/
|
|
304
|
+
readonly appliesScanFilters?: true;
|
|
305
|
+
/**
|
|
306
|
+
* True when `scan(filters)` already yields entries in `compareSyncRelativePaths` order.
|
|
307
|
+
* Custom folders that omit this are sorted by `synchronize()` before pairing.
|
|
308
|
+
*/
|
|
309
|
+
readonly appliesScanSorting?: true;
|
|
310
|
+
/** Scans the folder and yields files relative to the folder root. */
|
|
311
|
+
scan(options?: SyncScanOptions): AsyncIterable<SyncPath>;
|
|
120
312
|
}
|
|
121
313
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9D,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE3D,qCAAqC;AACrC,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,CAAA;AAEtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAA;AAE/C;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAChD;AA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