@aigne/afs-did-space 1.12.0-beta.5
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/LICENSE.md +26 -0
- package/README.md +129 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/afs-metadata-context.cjs +20 -0
- package/dist/afs-metadata-context.d.cts +21 -0
- package/dist/afs-metadata-context.d.cts.map +1 -0
- package/dist/afs-metadata-context.d.mts +21 -0
- package/dist/afs-metadata-context.d.mts.map +1 -0
- package/dist/afs-metadata-context.mjs +18 -0
- package/dist/afs-metadata-context.mjs.map +1 -0
- package/dist/blocklet-hook.cjs +180 -0
- package/dist/blocklet-hook.d.cts +29 -0
- package/dist/blocklet-hook.d.cts.map +1 -0
- package/dist/blocklet-hook.d.mts +29 -0
- package/dist/blocklet-hook.d.mts.map +1 -0
- package/dist/blocklet-hook.mjs +178 -0
- package/dist/blocklet-hook.mjs.map +1 -0
- package/dist/changelog-schema.cjs +603 -0
- package/dist/changelog-schema.d.cts +395 -0
- package/dist/changelog-schema.d.cts.map +1 -0
- package/dist/changelog-schema.d.mts +395 -0
- package/dist/changelog-schema.d.mts.map +1 -0
- package/dist/changelog-schema.mjs +570 -0
- package/dist/changelog-schema.mjs.map +1 -0
- package/dist/changelog-write.cjs +80 -0
- package/dist/changelog-write.d.cts +70 -0
- package/dist/changelog-write.d.cts.map +1 -0
- package/dist/changelog-write.d.mts +70 -0
- package/dist/changelog-write.d.mts.map +1 -0
- package/dist/changelog-write.mjs +77 -0
- package/dist/changelog-write.mjs.map +1 -0
- package/dist/cid-byte-cache.cjs +126 -0
- package/dist/cid-byte-cache.d.cts +46 -0
- package/dist/cid-byte-cache.d.cts.map +1 -0
- package/dist/cid-byte-cache.d.mts +47 -0
- package/dist/cid-byte-cache.d.mts.map +1 -0
- package/dist/cid-byte-cache.mjs +125 -0
- package/dist/cid-byte-cache.mjs.map +1 -0
- package/dist/cid.cjs +68 -0
- package/dist/cid.d.cts +22 -0
- package/dist/cid.d.cts.map +1 -0
- package/dist/cid.d.mts +22 -0
- package/dist/cid.d.mts.map +1 -0
- package/dist/cid.mjs +65 -0
- package/dist/cid.mjs.map +1 -0
- package/dist/client.cjs +221 -0
- package/dist/client.d.cts +72 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +72 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +220 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare.cjs +510 -0
- package/dist/cloudflare.d.cts +307 -0
- package/dist/cloudflare.d.cts.map +1 -0
- package/dist/cloudflare.d.mts +308 -0
- package/dist/cloudflare.d.mts.map +1 -0
- package/dist/cloudflare.mjs +507 -0
- package/dist/cloudflare.mjs.map +1 -0
- package/dist/ctime-backfill.cjs +272 -0
- package/dist/ctime-backfill.d.cts +169 -0
- package/dist/ctime-backfill.d.cts.map +1 -0
- package/dist/ctime-backfill.d.mts +169 -0
- package/dist/ctime-backfill.d.mts.map +1 -0
- package/dist/ctime-backfill.mjs +267 -0
- package/dist/ctime-backfill.mjs.map +1 -0
- package/dist/d1-gc-queue.cjs +80 -0
- package/dist/d1-gc-queue.d.cts +59 -0
- package/dist/d1-gc-queue.d.cts.map +1 -0
- package/dist/d1-gc-queue.d.mts +59 -0
- package/dist/d1-gc-queue.d.mts.map +1 -0
- package/dist/d1-gc-queue.mjs +81 -0
- package/dist/d1-gc-queue.mjs.map +1 -0
- package/dist/d1-resolve-store.cjs +189 -0
- package/dist/d1-resolve-store.d.cts +93 -0
- package/dist/d1-resolve-store.d.cts.map +1 -0
- package/dist/d1-resolve-store.d.mts +93 -0
- package/dist/d1-resolve-store.d.mts.map +1 -0
- package/dist/d1-resolve-store.mjs +190 -0
- package/dist/d1-resolve-store.mjs.map +1 -0
- package/dist/d1-schema.cjs +361 -0
- package/dist/d1-schema.d.cts +237 -0
- package/dist/d1-schema.d.cts.map +1 -0
- package/dist/d1-schema.d.mts +237 -0
- package/dist/d1-schema.d.mts.map +1 -0
- package/dist/d1-schema.mjs +341 -0
- package/dist/d1-schema.mjs.map +1 -0
- package/dist/d1-share-store.cjs +0 -0
- package/dist/d1-share-store.d.cts +53 -0
- package/dist/d1-share-store.d.cts.map +1 -0
- package/dist/d1-share-store.d.mts +53 -0
- package/dist/d1-share-store.d.mts.map +1 -0
- package/dist/d1-share-store.mjs +0 -0
- package/dist/d1-share-store.mjs.map +1 -0
- package/dist/d1-tree-index.cjs +1098 -0
- package/dist/d1-tree-index.d.cts +203 -0
- package/dist/d1-tree-index.d.cts.map +1 -0
- package/dist/d1-tree-index.d.mts +203 -0
- package/dist/d1-tree-index.d.mts.map +1 -0
- package/dist/d1-tree-index.mjs +1094 -0
- package/dist/d1-tree-index.mjs.map +1 -0
- package/dist/data-backend.cjs +147 -0
- package/dist/data-backend.d.cts +30 -0
- package/dist/data-backend.d.cts.map +1 -0
- package/dist/data-backend.d.mts +30 -0
- package/dist/data-backend.d.mts.map +1 -0
- package/dist/data-backend.mjs +148 -0
- package/dist/data-backend.mjs.map +1 -0
- package/dist/dedup-backfill.cjs +278 -0
- package/dist/dedup-backfill.d.cts +165 -0
- package/dist/dedup-backfill.d.cts.map +1 -0
- package/dist/dedup-backfill.d.mts +165 -0
- package/dist/dedup-backfill.d.mts.map +1 -0
- package/dist/dedup-backfill.mjs +273 -0
- package/dist/dedup-backfill.mjs.map +1 -0
- package/dist/did-space-like.d.cts +2 -0
- package/dist/did-space-like.d.mts +2 -0
- package/dist/did-utils.cjs +44 -0
- package/dist/did-utils.d.cts +25 -0
- package/dist/did-utils.d.cts.map +1 -0
- package/dist/did-utils.d.mts +25 -0
- package/dist/did-utils.d.mts.map +1 -0
- package/dist/did-utils.mjs +43 -0
- package/dist/did-utils.mjs.map +1 -0
- package/dist/dirty-path-queue.cjs +31 -0
- package/dist/dirty-path-queue.d.cts +104 -0
- package/dist/dirty-path-queue.d.cts.map +1 -0
- package/dist/dirty-path-queue.d.mts +104 -0
- package/dist/dirty-path-queue.d.mts.map +1 -0
- package/dist/dirty-path-queue.mjs +31 -0
- package/dist/dirty-path-queue.mjs.map +1 -0
- package/dist/dirty-path-schema.cjs +142 -0
- package/dist/dirty-path-schema.d.cts +90 -0
- package/dist/dirty-path-schema.d.cts.map +1 -0
- package/dist/dirty-path-schema.d.mts +90 -0
- package/dist/dirty-path-schema.d.mts.map +1 -0
- package/dist/dirty-path-schema.mjs +136 -0
- package/dist/dirty-path-schema.mjs.map +1 -0
- package/dist/download-actions.cjs +43 -0
- package/dist/download-actions.mjs +40 -0
- package/dist/download-actions.mjs.map +1 -0
- package/dist/fs-object-store.cjs +153 -0
- package/dist/fs-object-store.d.cts +21 -0
- package/dist/fs-object-store.d.cts.map +1 -0
- package/dist/fs-object-store.d.mts +22 -0
- package/dist/fs-object-store.d.mts.map +1 -0
- package/dist/fs-object-store.mjs +153 -0
- package/dist/fs-object-store.mjs.map +1 -0
- package/dist/gc-queue.d.cts +43 -0
- package/dist/gc-queue.d.cts.map +1 -0
- package/dist/gc-queue.d.mts +43 -0
- package/dist/gc-queue.d.mts.map +1 -0
- package/dist/index.cjs +2712 -0
- package/dist/index.d.cts +504 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +505 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2537 -0
- package/dist/index.mjs.map +1 -0
- package/dist/inline-content-migration.cjs +212 -0
- package/dist/inline-content-migration.d.cts +110 -0
- package/dist/inline-content-migration.d.cts.map +1 -0
- package/dist/inline-content-migration.d.mts +111 -0
- package/dist/inline-content-migration.d.mts.map +1 -0
- package/dist/inline-content-migration.mjs +207 -0
- package/dist/inline-content-migration.mjs.map +1 -0
- package/dist/inline-content.cjs +145 -0
- package/dist/inline-content.d.cts +98 -0
- package/dist/inline-content.d.cts.map +1 -0
- package/dist/inline-content.d.mts +98 -0
- package/dist/inline-content.d.mts.map +1 -0
- package/dist/inline-content.mjs +137 -0
- package/dist/inline-content.mjs.map +1 -0
- package/dist/local-changelog.cjs +241 -0
- package/dist/local-changelog.d.cts +119 -0
- package/dist/local-changelog.d.cts.map +1 -0
- package/dist/local-changelog.d.mts +119 -0
- package/dist/local-changelog.d.mts.map +1 -0
- package/dist/local-changelog.mjs +240 -0
- package/dist/local-changelog.mjs.map +1 -0
- package/dist/local.cjs +435 -0
- package/dist/local.d.cts +254 -0
- package/dist/local.d.cts.map +1 -0
- package/dist/local.d.mts +254 -0
- package/dist/local.d.mts.map +1 -0
- package/dist/local.mjs +427 -0
- package/dist/local.mjs.map +1 -0
- package/dist/memory-gc-queue.cjs +36 -0
- package/dist/memory-gc-queue.d.cts +22 -0
- package/dist/memory-gc-queue.d.cts.map +1 -0
- package/dist/memory-gc-queue.d.mts +22 -0
- package/dist/memory-gc-queue.d.mts.map +1 -0
- package/dist/memory-gc-queue.mjs +36 -0
- package/dist/memory-gc-queue.mjs.map +1 -0
- package/dist/memory-tree-index.cjs +734 -0
- package/dist/memory-tree-index.d.cts +159 -0
- package/dist/memory-tree-index.d.cts.map +1 -0
- package/dist/memory-tree-index.d.mts +159 -0
- package/dist/memory-tree-index.d.mts.map +1 -0
- package/dist/memory-tree-index.mjs +735 -0
- package/dist/memory-tree-index.mjs.map +1 -0
- package/dist/metadata-db.cjs +562 -0
- package/dist/metadata-db.d.cts +102 -0
- package/dist/metadata-db.d.cts.map +1 -0
- package/dist/metadata-db.d.mts +102 -0
- package/dist/metadata-db.d.mts.map +1 -0
- package/dist/metadata-db.mjs +562 -0
- package/dist/metadata-db.mjs.map +1 -0
- package/dist/mime-utils.cjs +2 -0
- package/dist/mime-utils.d.cts +2 -0
- package/dist/mime-utils.d.mts +2 -0
- package/dist/mime-utils.mjs +3 -0
- package/dist/object-key.cjs +41 -0
- package/dist/object-key.d.cts +25 -0
- package/dist/object-key.d.cts.map +1 -0
- package/dist/object-key.d.mts +25 -0
- package/dist/object-key.d.mts.map +1 -0
- package/dist/object-key.mjs +40 -0
- package/dist/object-key.mjs.map +1 -0
- package/dist/packages/session/dist/index.cjs +788 -0
- package/dist/packages/session/dist/index.mjs +782 -0
- package/dist/packages/session/dist/index.mjs.map +1 -0
- package/dist/platform/r2/dist/types.d.cts +49 -0
- package/dist/platform/r2/dist/types.d.cts.map +1 -0
- package/dist/prefix-range.cjs +33 -0
- package/dist/prefix-range.d.cts +29 -0
- package/dist/prefix-range.d.cts.map +1 -0
- package/dist/prefix-range.d.mts +29 -0
- package/dist/prefix-range.d.mts.map +1 -0
- package/dist/prefix-range.mjs +33 -0
- package/dist/prefix-range.mjs.map +1 -0
- package/dist/prefixed-tree-index.cjs +238 -0
- package/dist/prefixed-tree-index.d.cts +85 -0
- package/dist/prefixed-tree-index.d.cts.map +1 -0
- package/dist/prefixed-tree-index.d.mts +85 -0
- package/dist/prefixed-tree-index.d.mts.map +1 -0
- package/dist/prefixed-tree-index.mjs +239 -0
- package/dist/prefixed-tree-index.mjs.map +1 -0
- package/dist/presign-signer.cjs +7 -0
- package/dist/presign-signer.d.cts +99 -0
- package/dist/presign-signer.d.cts.map +1 -0
- package/dist/presign-signer.d.mts +99 -0
- package/dist/presign-signer.d.mts.map +1 -0
- package/dist/presign-signer.mjs +7 -0
- package/dist/presign-signer.mjs.map +1 -0
- package/dist/providers/platform/r2/dist/index.d.mts +3 -0
- package/dist/providers/platform/r2/dist/types.d.mts +49 -0
- package/dist/providers/platform/r2/dist/types.d.mts.map +1 -0
- package/dist/reconcile.cjs +184 -0
- package/dist/reconcile.d.cts +26 -0
- package/dist/reconcile.d.cts.map +1 -0
- package/dist/reconcile.d.mts +26 -0
- package/dist/reconcile.d.mts.map +1 -0
- package/dist/reconcile.mjs +184 -0
- package/dist/reconcile.mjs.map +1 -0
- package/dist/reference-check.cjs +49 -0
- package/dist/reference-check.d.cts +10 -0
- package/dist/reference-check.d.cts.map +1 -0
- package/dist/reference-check.d.mts +10 -0
- package/dist/reference-check.d.mts.map +1 -0
- package/dist/reference-check.mjs +48 -0
- package/dist/reference-check.mjs.map +1 -0
- package/dist/remote-afs.cjs +681 -0
- package/dist/remote-afs.d.cts +236 -0
- package/dist/remote-afs.d.cts.map +1 -0
- package/dist/remote-afs.d.mts +236 -0
- package/dist/remote-afs.d.mts.map +1 -0
- package/dist/remote-afs.mjs +676 -0
- package/dist/remote-afs.mjs.map +1 -0
- package/dist/rename-guard.cjs +18 -0
- package/dist/rename-guard.mjs +18 -0
- package/dist/rename-guard.mjs.map +1 -0
- package/dist/resolve.cjs +260 -0
- package/dist/resolve.d.cts +113 -0
- package/dist/resolve.d.cts.map +1 -0
- package/dist/resolve.d.mts +113 -0
- package/dist/resolve.d.mts.map +1 -0
- package/dist/resolve.mjs +260 -0
- package/dist/resolve.mjs.map +1 -0
- package/dist/rsync-content.cjs +33 -0
- package/dist/rsync-content.mjs +33 -0
- package/dist/rsync-content.mjs.map +1 -0
- package/dist/rsync.cjs +400 -0
- package/dist/rsync.d.cts +157 -0
- package/dist/rsync.d.cts.map +1 -0
- package/dist/rsync.d.mts +157 -0
- package/dist/rsync.d.mts.map +1 -0
- package/dist/rsync.mjs +397 -0
- package/dist/rsync.mjs.map +1 -0
- package/dist/run-gc.cjs +57 -0
- package/dist/run-gc.d.cts +40 -0
- package/dist/run-gc.d.cts.map +1 -0
- package/dist/run-gc.d.mts +41 -0
- package/dist/run-gc.d.mts.map +1 -0
- package/dist/run-gc.mjs +57 -0
- package/dist/run-gc.mjs.map +1 -0
- package/dist/scope-id.cjs +70 -0
- package/dist/scope-id.d.cts +35 -0
- package/dist/scope-id.d.cts.map +1 -0
- package/dist/scope-id.d.mts +35 -0
- package/dist/scope-id.d.mts.map +1 -0
- package/dist/scope-id.mjs +68 -0
- package/dist/scope-id.mjs.map +1 -0
- package/dist/scope-migration-node.cjs +172 -0
- package/dist/scope-migration-node.d.cts +44 -0
- package/dist/scope-migration-node.d.cts.map +1 -0
- package/dist/scope-migration-node.d.mts +44 -0
- package/dist/scope-migration-node.d.mts.map +1 -0
- package/dist/scope-migration-node.mjs +171 -0
- package/dist/scope-migration-node.mjs.map +1 -0
- package/dist/scope-migration.cjs +155 -0
- package/dist/scope-migration.d.cts +65 -0
- package/dist/scope-migration.d.cts.map +1 -0
- package/dist/scope-migration.d.mts +65 -0
- package/dist/scope-migration.d.mts.map +1 -0
- package/dist/scope-migration.mjs +154 -0
- package/dist/scope-migration.mjs.map +1 -0
- package/dist/share-declaration.cjs +225 -0
- package/dist/share-declaration.d.cts +30 -0
- package/dist/share-declaration.d.cts.map +1 -0
- package/dist/share-declaration.d.mts +32 -0
- package/dist/share-declaration.d.mts.map +1 -0
- package/dist/share-declaration.mjs +221 -0
- package/dist/share-declaration.mjs.map +1 -0
- package/dist/share-hook.cjs +63 -0
- package/dist/share-hook.mjs +62 -0
- package/dist/share-hook.mjs.map +1 -0
- package/dist/share-resolve.cjs +176 -0
- package/dist/share-resolve.d.cts +36 -0
- package/dist/share-resolve.d.cts.map +1 -0
- package/dist/share-resolve.d.mts +36 -0
- package/dist/share-resolve.d.mts.map +1 -0
- package/dist/share-resolve.mjs +177 -0
- package/dist/share-resolve.mjs.map +1 -0
- package/dist/share-serve.cjs +145 -0
- package/dist/share-serve.d.cts +30 -0
- package/dist/share-serve.d.cts.map +1 -0
- package/dist/share-serve.d.mts +30 -0
- package/dist/share-serve.d.mts.map +1 -0
- package/dist/share-serve.mjs +144 -0
- package/dist/share-serve.mjs.map +1 -0
- package/dist/share-store.cjs +25 -0
- package/dist/share-store.d.cts +65 -0
- package/dist/share-store.d.cts.map +1 -0
- package/dist/share-store.d.mts +65 -0
- package/dist/share-store.d.mts.map +1 -0
- package/dist/share-store.mjs +25 -0
- package/dist/share-store.mjs.map +1 -0
- package/dist/share-virtual-path.cjs +102 -0
- package/dist/share-virtual-path.mjs +101 -0
- package/dist/share-virtual-path.mjs.map +1 -0
- package/dist/space-resolver.cjs +54 -0
- package/dist/space-resolver.d.cts +34 -0
- package/dist/space-resolver.d.cts.map +1 -0
- package/dist/space-resolver.d.mts +34 -0
- package/dist/space-resolver.d.mts.map +1 -0
- package/dist/space-resolver.mjs +55 -0
- package/dist/space-resolver.mjs.map +1 -0
- package/dist/sqlite-gc-queue.cjs +51 -0
- package/dist/sqlite-gc-queue.d.cts +22 -0
- package/dist/sqlite-gc-queue.d.cts.map +1 -0
- package/dist/sqlite-gc-queue.d.mts +22 -0
- package/dist/sqlite-gc-queue.d.mts.map +1 -0
- package/dist/sqlite-gc-queue.mjs +52 -0
- package/dist/sqlite-gc-queue.mjs.map +1 -0
- package/dist/sqlite-resolve-store.cjs +163 -0
- package/dist/sqlite-resolve-store.d.cts +50 -0
- package/dist/sqlite-resolve-store.d.cts.map +1 -0
- package/dist/sqlite-resolve-store.d.mts +50 -0
- package/dist/sqlite-resolve-store.d.mts.map +1 -0
- package/dist/sqlite-resolve-store.mjs +164 -0
- package/dist/sqlite-resolve-store.mjs.map +1 -0
- package/dist/sqlite-share-store.cjs +157 -0
- package/dist/sqlite-share-store.d.cts +31 -0
- package/dist/sqlite-share-store.d.cts.map +1 -0
- package/dist/sqlite-share-store.d.mts +31 -0
- package/dist/sqlite-share-store.d.mts.map +1 -0
- package/dist/sqlite-share-store.mjs +157 -0
- package/dist/sqlite-share-store.mjs.map +1 -0
- package/dist/sqlite-tree-index.cjs +901 -0
- package/dist/sqlite-tree-index.d.cts +107 -0
- package/dist/sqlite-tree-index.d.cts.map +1 -0
- package/dist/sqlite-tree-index.d.mts +107 -0
- package/dist/sqlite-tree-index.d.mts.map +1 -0
- package/dist/sqlite-tree-index.mjs +902 -0
- package/dist/sqlite-tree-index.mjs.map +1 -0
- package/dist/sync-engine.cjs +1324 -0
- package/dist/sync-engine.d.cts +473 -0
- package/dist/sync-engine.d.cts.map +1 -0
- package/dist/sync-engine.d.mts +473 -0
- package/dist/sync-engine.d.mts.map +1 -0
- package/dist/sync-engine.mjs +1315 -0
- package/dist/sync-engine.mjs.map +1 -0
- package/dist/sync-state.cjs +303 -0
- package/dist/sync-state.d.cts +224 -0
- package/dist/sync-state.d.cts.map +1 -0
- package/dist/sync-state.d.mts +224 -0
- package/dist/sync-state.d.mts.map +1 -0
- package/dist/sync-state.mjs +297 -0
- package/dist/sync-state.mjs.map +1 -0
- package/dist/timestamp.cjs +92 -0
- package/dist/timestamp.mjs +91 -0
- package/dist/timestamp.mjs.map +1 -0
- package/dist/transports/http.cjs +54 -0
- package/dist/transports/http.d.cts +26 -0
- package/dist/transports/http.d.cts.map +1 -0
- package/dist/transports/http.d.mts +26 -0
- package/dist/transports/http.d.mts.map +1 -0
- package/dist/transports/http.mjs +54 -0
- package/dist/transports/http.mjs.map +1 -0
- package/dist/transports/static.cjs +55 -0
- package/dist/transports/static.d.cts +28 -0
- package/dist/transports/static.d.cts.map +1 -0
- package/dist/transports/static.d.mts +28 -0
- package/dist/transports/static.d.mts.map +1 -0
- package/dist/transports/static.mjs +55 -0
- package/dist/transports/static.mjs.map +1 -0
- package/dist/transports/types.cjs +13 -0
- package/dist/transports/types.d.cts +72 -0
- package/dist/transports/types.d.cts.map +1 -0
- package/dist/transports/types.d.mts +72 -0
- package/dist/transports/types.d.mts.map +1 -0
- package/dist/transports/types.mjs +13 -0
- package/dist/transports/types.mjs.map +1 -0
- package/dist/transports/ws.cjs +207 -0
- package/dist/transports/ws.d.cts +47 -0
- package/dist/transports/ws.d.cts.map +1 -0
- package/dist/transports/ws.d.mts +47 -0
- package/dist/transports/ws.d.mts.map +1 -0
- package/dist/transports/ws.mjs +206 -0
- package/dist/transports/ws.mjs.map +1 -0
- package/dist/tree-index.cjs +333 -0
- package/dist/tree-index.d.cts +524 -0
- package/dist/tree-index.d.cts.map +1 -0
- package/dist/tree-index.d.mts +524 -0
- package/dist/tree-index.d.mts.map +1 -0
- package/dist/tree-index.mjs +322 -0
- package/dist/tree-index.mjs.map +1 -0
- package/dist/tree-query.cjs +655 -0
- package/dist/tree-query.d.cts +70 -0
- package/dist/tree-query.d.cts.map +1 -0
- package/dist/tree-query.d.mts +70 -0
- package/dist/tree-query.d.mts.map +1 -0
- package/dist/tree-query.mjs +648 -0
- package/dist/tree-query.mjs.map +1 -0
- package/dist/upload-actions.cjs +97 -0
- package/dist/upload-actions.d.cts +19 -0
- package/dist/upload-actions.d.cts.map +1 -0
- package/dist/upload-actions.d.mts +21 -0
- package/dist/upload-actions.d.mts.map +1 -0
- package/dist/upload-actions.mjs +90 -0
- package/dist/upload-actions.mjs.map +1 -0
- package/dist/upload-session-store.cjs +185 -0
- package/dist/upload-session-store.d.cts +99 -0
- package/dist/upload-session-store.d.cts.map +1 -0
- package/dist/upload-session-store.d.mts +99 -0
- package/dist/upload-session-store.d.mts.map +1 -0
- package/dist/upload-session-store.mjs +184 -0
- package/dist/upload-session-store.mjs.map +1 -0
- package/dist/url-normalize.cjs +61 -0
- package/dist/url-normalize.d.cts +33 -0
- package/dist/url-normalize.d.cts.map +1 -0
- package/dist/url-normalize.d.mts +33 -0
- package/dist/url-normalize.d.mts.map +1 -0
- package/dist/url-normalize.mjs +61 -0
- package/dist/url-normalize.mjs.map +1 -0
- package/dist/versioned-content-backends.cjs +155 -0
- package/dist/versioned-content-backends.d.cts +49 -0
- package/dist/versioned-content-backends.d.cts.map +1 -0
- package/dist/versioned-content-backends.d.mts +49 -0
- package/dist/versioned-content-backends.d.mts.map +1 -0
- package/dist/versioned-content-backends.mjs +154 -0
- package/dist/versioned-content-backends.mjs.map +1 -0
- package/dist/versioned-content-index.cjs +102 -0
- package/dist/versioned-content-index.d.cts +46 -0
- package/dist/versioned-content-index.d.cts.map +1 -0
- package/dist/versioned-content-index.d.mts +46 -0
- package/dist/versioned-content-index.d.mts.map +1 -0
- package/dist/versioned-content-index.mjs +103 -0
- package/dist/versioned-content-index.mjs.map +1 -0
- package/dist/versioned-content-store.cjs +121 -0
- package/dist/versioned-content-store.d.cts +90 -0
- package/dist/versioned-content-store.d.cts.map +1 -0
- package/dist/versioned-content-store.d.mts +90 -0
- package/dist/versioned-content-store.d.mts.map +1 -0
- package/dist/versioned-content-store.mjs +122 -0
- package/dist/versioned-content-store.mjs.map +1 -0
- package/dist/versioned-scope.cjs +39 -0
- package/dist/versioned-scope.d.cts +57 -0
- package/dist/versioned-scope.d.cts.map +1 -0
- package/dist/versioned-scope.d.mts +57 -0
- package/dist/versioned-scope.d.mts.map +1 -0
- package/dist/versioned-scope.mjs +37 -0
- package/dist/versioned-scope.mjs.map +1 -0
- package/migrations/0001_tree_entries.sql +17 -0
- package/migrations/0002_resolve_entries.sql +7 -0
- package/migrations/0003_entries_v2.sql +38 -0
- package/migrations/0004_gc_queue.sql +5 -0
- package/migrations/0006_resolve_enhance.sql +14 -0
- package/migrations/0007_resolve_created_at.sql +10 -0
- package/migrations/0008_changelog.sql +34 -0
- package/migrations/0009_device_sync_state.sql +29 -0
- package/migrations/0010_scope_meta.sql +33 -0
- package/migrations/0011_shares.sql +25 -0
- package/migrations/0012_scope_meta_file_count.sql +41 -0
- package/migrations/0013_scope_meta_total_bytes.sql +47 -0
- package/migrations/0014_rename_tables.sql +62 -0
- package/package.json +102 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { ChangelogEntry } from "./tree-index.mjs";
|
|
2
|
+
import { LocalChangelog } from "./local-changelog.mjs";
|
|
3
|
+
import { CommitUploadEntryInput, DownloadGrant, PrepareDownloadEntryInput, PrepareDownloadResult, PrepareUploadEntryInput, PrepareUploadResult, RpcBatchResult, UploadGrant } from "./remote-afs.mjs";
|
|
4
|
+
import { SyncStateStore } from "./sync-state.mjs";
|
|
5
|
+
import { AFSBatchDeleteEntry, AFSBatchWriteEntry, AFSDeleteOptions, AFSDeleteResult, AFSListOptions, AFSListResult, AFSReadOptions, AFSReadResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
|
|
6
|
+
|
|
7
|
+
//#region src/sync-engine.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Narrow AFS surface consumed by SyncEngine. Production wires this to a
|
|
10
|
+
* full `AFS` instance (which structurally satisfies the four methods);
|
|
11
|
+
* tests wire it to {@link InMemoryCloudProvider} so the engine never
|
|
12
|
+
* speaks to a real HTTP transport.
|
|
13
|
+
*
|
|
14
|
+
* Restricting the type to four methods keeps the test surface tractable
|
|
15
|
+
* (the AFS root has ~20 methods, most irrelevant to sync) and keeps the
|
|
16
|
+
* "this is the only I/O surface SyncEngine touches" contract visible
|
|
17
|
+
* at the type level.
|
|
18
|
+
*/
|
|
19
|
+
interface SyncCloudAFS {
|
|
20
|
+
list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
|
|
21
|
+
read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
|
|
22
|
+
write(path: string, payload: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>;
|
|
23
|
+
delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
|
|
24
|
+
batchWrite?(entries: AFSBatchWriteEntry[]): Promise<RpcBatchResult>;
|
|
25
|
+
batchDelete?(entries: AFSBatchDeleteEntry[]): Promise<RpcBatchResult>;
|
|
26
|
+
batchRead?(entries: Array<{
|
|
27
|
+
path: string;
|
|
28
|
+
optional?: boolean;
|
|
29
|
+
}>): Promise<RpcBatchResult>;
|
|
30
|
+
uploadGrantCapability?(): Promise<boolean>;
|
|
31
|
+
prepareUpload?(entries: PrepareUploadEntryInput[]): Promise<PrepareUploadResult>;
|
|
32
|
+
commitUpload?(sessionId: string, entries: CommitUploadEntryInput[]): Promise<RpcBatchResult>;
|
|
33
|
+
/** Out-of-band PUT of object bytes via a grant; returns the HTTP status. */
|
|
34
|
+
uploadObject?(grant: UploadGrant, bytes: Uint8Array): Promise<number>;
|
|
35
|
+
downloadGrantCapability?(): Promise<boolean>;
|
|
36
|
+
prepareDownload?(entries: PrepareDownloadEntryInput[]): Promise<PrepareDownloadResult>;
|
|
37
|
+
/** Out-of-band GET of object bytes via a grant; returns the raw bytes. */
|
|
38
|
+
downloadObject?(grant: DownloadGrant): Promise<Uint8Array>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Push batch size. Each round, push() fetches up to this many unpushed
|
|
42
|
+
* changelog rows in a single SQLite query and uploads them one by one.
|
|
43
|
+
* Lower than PULL_BATCH_LIMIT because each row is a separate PUT/DELETE
|
|
44
|
+
* round-trip (vs. PULL which fetches many change rows in a single call).
|
|
45
|
+
*/
|
|
46
|
+
declare const PUSH_BATCH_LIMIT = 100;
|
|
47
|
+
/**
|
|
48
|
+
* Flush local_seq to SQLite every N successful pushes. Trade-off: lower
|
|
49
|
+
* = less progress lost on crash, higher = fewer DB writes. 10 is the
|
|
50
|
+
* round-trip frequency Task 3.6 spec mandates.
|
|
51
|
+
*/
|
|
52
|
+
declare const PUSH_PROGRESS_FLUSH_INTERVAL = 10;
|
|
53
|
+
/**
|
|
54
|
+
* Pull batch size. Each `.changelog` cursor list call fetches up to this
|
|
55
|
+
* many rows. Matches the server's MAX_LIMIT hard cap
|
|
56
|
+
* (`services/arc-computer/src/handlers/space-api.ts` — .changelog list
|
|
57
|
+
* branch inside `_createSpaceHandler`).
|
|
58
|
+
*/
|
|
59
|
+
declare const PULL_BATCH_LIMIT = 1000;
|
|
60
|
+
/**
|
|
61
|
+
* Concurrency cap for `.objects/{cid}` reads inside pull(). Higher = faster
|
|
62
|
+
* under large pulls, but risks server-side rate limits and memory
|
|
63
|
+
* pressure on the client. 4 is the spec default.
|
|
64
|
+
*/
|
|
65
|
+
declare const PULL_FETCH_CONCURRENCY = 4;
|
|
66
|
+
/**
|
|
67
|
+
* Wall-clock budget for a single sync() call. Protects against runaway
|
|
68
|
+
* pulls on wildly out-of-date clients. pull() checks Date.now() against
|
|
69
|
+
* the deadline at the top of every batch loop iteration.
|
|
70
|
+
*/
|
|
71
|
+
declare const SYNC_WALL_CLOCK_BUDGET_MS = 25000;
|
|
72
|
+
/**
|
|
73
|
+
* Narrow provider interface consumed by SyncEngine.
|
|
74
|
+
*
|
|
75
|
+
* The production mobile runtimes implement this directly on
|
|
76
|
+
* DIDSpaceProvider; tests use a mock. Only `internalWrite`,
|
|
77
|
+
* `internalDelete`, and `readBytes` are exercised — SyncEngine does
|
|
78
|
+
* NOT need list/stat/search.
|
|
79
|
+
*
|
|
80
|
+
* `readBytes` is the push-side counterpart: SyncEngine needs the raw
|
|
81
|
+
* bytes of a locally-stored cid so it can upload them via
|
|
82
|
+
* `cloudAfs.write`. Tests wire this to an in-memory map.
|
|
83
|
+
*/
|
|
84
|
+
interface SyncEngineProviderHandle {
|
|
85
|
+
internalWrite(path: string, opts: {
|
|
86
|
+
content: Uint8Array;
|
|
87
|
+
deviceId: string;
|
|
88
|
+
mtime?: number;
|
|
89
|
+
mimeType?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Application metadata (e.g. `createdAt`) the SyncEngine derived from the
|
|
92
|
+
* bytes via `readApplicationMetadata` BEFORE calling internalWrite
|
|
93
|
+
* (feed-sort §5.1). The provider stamps the local-copy ctime from
|
|
94
|
+
* `metadata.createdAt` (Rule R1/R2) and persists it — it NEVER parses the
|
|
95
|
+
* bytes itself. Absent ⇒ ctime falls back to the write time.
|
|
96
|
+
*/
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
internalDelete(path: string, opts: {
|
|
100
|
+
deviceId: string;
|
|
101
|
+
mtime?: number;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Fetch the raw bytes for a locally stored path. Used by push() to
|
|
105
|
+
* upload the file content referenced by a `put` changelog row.
|
|
106
|
+
*
|
|
107
|
+
* Returning `null` signals "the file is no longer on disk" (e.g. the
|
|
108
|
+
* user deleted it after the changelog row was written but before the
|
|
109
|
+
* sync picked it up). push() treats null as "skip this row,
|
|
110
|
+
* advance cursor" because the DELETE row that will follow is what
|
|
111
|
+
* the cloud needs to see.
|
|
112
|
+
*/
|
|
113
|
+
readBytes(path: string): Promise<Uint8Array | null>;
|
|
114
|
+
/**
|
|
115
|
+
* List all currently-stored file paths for the scope. Only used by
|
|
116
|
+
* fullResync() to diff the cloud manifest against local state. Paths
|
|
117
|
+
* returned here are NOT slash-prefixed (they match the internal
|
|
118
|
+
* entries table shape); SyncEngine normalises before calling
|
|
119
|
+
* internalDelete.
|
|
120
|
+
*/
|
|
121
|
+
listAllPaths(): Promise<string[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Derive application metadata (e.g. Aside's `createdAt`) from a file's own
|
|
124
|
+
* bytes (did-space-metadata G3). The engine is format-agnostic, so the
|
|
125
|
+
* provider decides how to extract it (parse the record JSON). Attached to the
|
|
126
|
+
* push wire — top-level `meta` on the batchWrite leg (afs-rpc `wireMeta` lifts
|
|
127
|
+
* it onto `payload.meta`), `metadata` on the upload-plane commit leg.
|
|
128
|
+
*
|
|
129
|
+
* OPTIONAL: providers that expose no application metadata omit it, and the
|
|
130
|
+
* engine emits no metadata — preserving the pre-G3 wire contract byte-for-byte.
|
|
131
|
+
* Mirrors Swift's `readApplicationMetadata` + Kotlin's equivalent (P1 lockstep).
|
|
132
|
+
*/
|
|
133
|
+
readApplicationMetadata?(path: string, bytes: Uint8Array): Promise<Record<string, unknown>>;
|
|
134
|
+
}
|
|
135
|
+
/** Outcome of a {@link SyncEngine.sync} call. */
|
|
136
|
+
interface SyncResult {
|
|
137
|
+
/** Whether the sync completed all three legs (push, pull, gc) normally. */
|
|
138
|
+
ok: boolean;
|
|
139
|
+
/** Whether abortSignal fired before the engine reached its happy path. */
|
|
140
|
+
aborted: boolean;
|
|
141
|
+
/** Number of rows successfully pushed in the push leg. */
|
|
142
|
+
pushed: number;
|
|
143
|
+
/** Number of rows successfully applied in the pull leg. */
|
|
144
|
+
pulled: number;
|
|
145
|
+
/** Number of changelog rows GC'd at the end of the run. */
|
|
146
|
+
gcDeleted: number;
|
|
147
|
+
/** True when fullResync was taken (first-sync or 409 Compacted). */
|
|
148
|
+
fullResynced: boolean;
|
|
149
|
+
/** When the run ended, Date.now() in millis. */
|
|
150
|
+
endedAt: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Thrown by {@link SyncEngine.resolveConflict} when the server's 409
|
|
154
|
+
* conflict response is missing required fields (notably `currentMtime`).
|
|
155
|
+
* The LWW decision needs both timestamps, so a malformed response is
|
|
156
|
+
* treated as fatal to the in-flight push leg.
|
|
157
|
+
*
|
|
158
|
+
* Phase 5 Task 5.1 (G11): replaced the Task 3.6 `ConflictTODOError`
|
|
159
|
+
* stub with the real LWW resolver. The resolver handles every well-formed
|
|
160
|
+
* conflict shape inline; this error class only fires on protocol breakage.
|
|
161
|
+
*/
|
|
162
|
+
declare class ConflictResolutionError extends Error {
|
|
163
|
+
readonly change: ChangelogEntry;
|
|
164
|
+
readonly reason: string;
|
|
165
|
+
constructor(change: ChangelogEntry, reason: string);
|
|
166
|
+
}
|
|
167
|
+
/** Where a current-cid 404 surfaced. */
|
|
168
|
+
type CurrentObjectSource = "manifest" | "latest-put" | "conflict";
|
|
169
|
+
/**
|
|
170
|
+
* Thrown when an object read returns 404 for a cid that is the **current**
|
|
171
|
+
* state of a path — design §4.7.2, the GC-go-live safety contract. Enabling
|
|
172
|
+
* object GC makes a current-cid 404 possible (a GC bug or the residual
|
|
173
|
+
* re-reference race); it MUST be a loud, hard error — NEVER silently treated as
|
|
174
|
+
* convergence. The cursor must stay pinned (do not advance past the failing
|
|
175
|
+
* change) so the next sync revisits it once the object is restored/re-pushed.
|
|
176
|
+
*
|
|
177
|
+
* Distinct from a **superseded**-cid 404 (an old changelog row a later same-path
|
|
178
|
+
* row supersedes), which is benign — skip + advance (the Path-Y offline
|
|
179
|
+
* tradeoff, §0.2). Classification: see {@link classifyMissingObject}.
|
|
180
|
+
*/
|
|
181
|
+
declare class CurrentObjectMissingError extends Error {
|
|
182
|
+
readonly path: string;
|
|
183
|
+
readonly cid: string;
|
|
184
|
+
readonly source: CurrentObjectSource;
|
|
185
|
+
constructor(path: string, cid: string, source: CurrentObjectSource);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Classify an object-read 404 during incremental apply (design §4.7.2).
|
|
189
|
+
*
|
|
190
|
+
* `lastCidForPath` maps each path in the batch to the cid of its LAST row
|
|
191
|
+
* (max seq) — `null` if that last row is a delete. Fail-closed:
|
|
192
|
+
* - cid === the path's last-row cid ⇒ "current" (this cid is the path's
|
|
193
|
+
* final state in the batch) ⇒ hard error.
|
|
194
|
+
* - path absent from the map (unknown cid, not in this batch) ⇒ "current"
|
|
195
|
+
* (fail closed — never benign-skip something we can't prove superseded).
|
|
196
|
+
* - otherwise a later same-path row supersedes this cid ⇒ "superseded" ⇒ skip.
|
|
197
|
+
*/
|
|
198
|
+
declare function classifyMissingObject(path: string, cid: string, lastCidForPath: Map<string, string | null>): "current" | "superseded";
|
|
199
|
+
/**
|
|
200
|
+
* Conflict response shape consumed by {@link SyncEngine.resolveConflict}.
|
|
201
|
+
* Mirrors the 409 body returned by Task 3.3's PUT/DELETE handlers.
|
|
202
|
+
*
|
|
203
|
+
* `currentCid === null` AND `currentMtime !== null` means "the cloud has
|
|
204
|
+
* deleted this path at currentMtime"; both null means the server returned
|
|
205
|
+
* a malformed response and the resolver throws ConflictResolutionError.
|
|
206
|
+
*/
|
|
207
|
+
interface ConflictResponse {
|
|
208
|
+
/** Server's current CID for the path (null if cloud has deleted it). */
|
|
209
|
+
currentCid: string | null;
|
|
210
|
+
/** Server's current mtime for the path (required for LWW comparison). */
|
|
211
|
+
currentMtime: number | null;
|
|
212
|
+
/** Origin device id for the cloud entry. Used for echo-loop Layer II. */
|
|
213
|
+
currentDeviceId: string | null;
|
|
214
|
+
}
|
|
215
|
+
interface SyncEngineOptions {
|
|
216
|
+
localChangelog: LocalChangelog;
|
|
217
|
+
syncStateStore: SyncStateStore;
|
|
218
|
+
cloudAfs: SyncCloudAFS;
|
|
219
|
+
provider: SyncEngineProviderHandle;
|
|
220
|
+
/** Self deviceId: written into changelog rows (options.meta.deviceId) and used
|
|
221
|
+
/// as the self filter. */
|
|
222
|
+
deviceId: string;
|
|
223
|
+
/**
|
|
224
|
+
* Override wall-clock budget in tests. Falls back to the module-level
|
|
225
|
+
* constant when not provided.
|
|
226
|
+
*/
|
|
227
|
+
wallClockBudgetMs?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Local push + pull + GC orchestrator. One instance per DIDSpaceProvider /
|
|
231
|
+
* per userDid. Instances are NOT thread-safe at the data level — the
|
|
232
|
+
* internal mutex only serialises `sync()` calls; callers that mutate
|
|
233
|
+
* local state while a sync is in flight are expected to do so via
|
|
234
|
+
* `provider.internalWrite/Delete` so the changelog row is visible to the
|
|
235
|
+
* next push batch.
|
|
236
|
+
*/
|
|
237
|
+
declare class SyncEngine {
|
|
238
|
+
private readonly localChangelog;
|
|
239
|
+
private readonly syncStateStore;
|
|
240
|
+
private readonly cloudAfs;
|
|
241
|
+
private readonly provider;
|
|
242
|
+
private readonly selfDeviceId;
|
|
243
|
+
private readonly wallClockBudgetMs;
|
|
244
|
+
private readonly mutex;
|
|
245
|
+
/**
|
|
246
|
+
* Per-INSTANCE capability-fallback memory (design §7.1): set the first
|
|
247
|
+
* time the server answers a batch envelope with the exact
|
|
248
|
+
* "Unsupported op 'batch…'" 400. Never set by any other 400 (e.g.
|
|
249
|
+
* BATCH_OVER_BUDGET halves and retries instead).
|
|
250
|
+
*/
|
|
251
|
+
private batchFallback;
|
|
252
|
+
/**
|
|
253
|
+
* Per-INSTANCE upload-plane capability memory (design §7.1, mirrors
|
|
254
|
+
* batchFallback). null = not yet probed; set on the first `push()` that
|
|
255
|
+
* reaches the threshold. `false` (Node / old server / signer-less) keeps the
|
|
256
|
+
* engine on batchWrite forever for this instance.
|
|
257
|
+
*/
|
|
258
|
+
private uploadPlaneCapable;
|
|
259
|
+
/** Set per-push() when this push routes large put-chunks through the upload plane. */
|
|
260
|
+
private uploadPlaneActive;
|
|
261
|
+
/**
|
|
262
|
+
* Per-INSTANCE download-plane capability memory (design §7.3, mirrors
|
|
263
|
+
* uploadPlaneCapable). null = not yet probed. `false` (Node / old server /
|
|
264
|
+
* signer-less) keeps the engine on batchRead forever for this instance — it is
|
|
265
|
+
* NOT reset per session (unlike {@link downloadFallback}): a server that never
|
|
266
|
+
* advertised the capability won't start mid-process, so re-probing every sync
|
|
267
|
+
* would just waste a `/.actions` list. A server UPGRADE needs a client restart.
|
|
268
|
+
*/
|
|
269
|
+
private downloadPlaneCapable;
|
|
270
|
+
/**
|
|
271
|
+
* Runtime fallback-on-403 latch (design §7.3): set when a presigned GET is
|
|
272
|
+
* rejected 401/403 (token lacks GetObject / bad signature). Once set, the whole
|
|
273
|
+
* sync SESSION reverts to batchRead and never re-tries the plane — so a misconfig
|
|
274
|
+
* costs at most ONE 403 per object before the first hit flips it, then nothing.
|
|
275
|
+
* Reset at the start of each sync() so a fixed token recovers without restart.
|
|
276
|
+
*/
|
|
277
|
+
private downloadFallback;
|
|
278
|
+
/** Resolved once per instance — the out-of-band GET fan-out (env-overridable). */
|
|
279
|
+
private readonly downloadGetConcurrency;
|
|
280
|
+
constructor(opts: SyncEngineOptions);
|
|
281
|
+
/**
|
|
282
|
+
* Run a single sync round — push → pull → gc. Concurrent sync() calls
|
|
283
|
+
* on the same instance are serialised by the internal mutex. Always
|
|
284
|
+
* returns a {@link SyncResult}; throws only on unhandled errors from
|
|
285
|
+
* the underlying store/network layers.
|
|
286
|
+
*/
|
|
287
|
+
sync(opts?: {
|
|
288
|
+
signal?: AbortSignal;
|
|
289
|
+
}): Promise<SyncResult>;
|
|
290
|
+
/**
|
|
291
|
+
* Upload unpushed local changes to the cloud, advancing local_seq in
|
|
292
|
+
* SQLite every `PUSH_PROGRESS_FLUSH_INTERVAL` rows. On any error
|
|
293
|
+
* mid-batch, flush the already-advanced cursor before re-throwing so
|
|
294
|
+
* the next sync() resumes where this one left off.
|
|
295
|
+
*
|
|
296
|
+
* Per-row semantics:
|
|
297
|
+
* - `put` row → `cloudAfs.write(path, content, {...})`
|
|
298
|
+
* - `delete` row → `cloudAfs.delete(path, {...})`
|
|
299
|
+
* - `put` row whose file has been deleted locally since the row was
|
|
300
|
+
* written → skip (cursor advances; the following delete row will
|
|
301
|
+
* tell the cloud what happened).
|
|
302
|
+
* - 409 conflict → delegate to {@link SyncEngine.resolveConflict}
|
|
303
|
+
* (LWW + tiebreak — see G11 in native-sync-design.md).
|
|
304
|
+
*/
|
|
305
|
+
push(opts: {
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
deadline: number;
|
|
308
|
+
}): Promise<{
|
|
309
|
+
pushed: number;
|
|
310
|
+
}>;
|
|
311
|
+
/**
|
|
312
|
+
* Batch push leg (P4, design §7.2): split the changelog window into
|
|
313
|
+
* MAXIMAL same-op runs in seq order (op type never mixes inside a run —
|
|
314
|
+
* put(a)→delete(a) is two runs, so same-path cross-op order rides the
|
|
315
|
+
* sequential awaits); pack each run by maxEntries + Σ-decoded-bytes +
|
|
316
|
+
* UNIQUE-path-per-chunk (a duplicate path cuts the chunk so the server's
|
|
317
|
+
* one-shot preread stays serial-equivalent — and the SECOND chunk's
|
|
318
|
+
* ifMatch sees the first chunk's result); consume results strictly in
|
|
319
|
+
* order. Returns the advanced cursor; `stop` = abort/deadline/tail-skip.
|
|
320
|
+
*/
|
|
321
|
+
private pushBatchLeg;
|
|
322
|
+
/**
|
|
323
|
+
* Send one packed chunk, halving on envelope over-budget (down to 1 entry
|
|
324
|
+
* = pushOne, the literal old behavior — bounded recursion by construction:
|
|
325
|
+
* each level halves a strictly smaller chunk).
|
|
326
|
+
*/
|
|
327
|
+
private sendPushChunk;
|
|
328
|
+
/**
|
|
329
|
+
* Decide whether THIS push routes large put-chunks through the upload plane
|
|
330
|
+
* (design §6.1 / decision 4). True only when (a) the adapter has the
|
|
331
|
+
* prepare/commit/uploadObject surface, (b) the server advertises grant
|
|
332
|
+
* capability (memoized per instance — Node/old-server/signer-less → false →
|
|
333
|
+
* never), and (c) the put backlog meets the conservative threshold
|
|
334
|
+
* (≥ MIN_ENTRIES puts, or ≥ MIN_BYTES) via a cheap bounded peek.
|
|
335
|
+
*/
|
|
336
|
+
private shouldUseUploadPlane;
|
|
337
|
+
/**
|
|
338
|
+
* Upload-plane transport for one put chunk (design §6.1 / §8). Mirrors a
|
|
339
|
+
* `batchWrite` call but moves content OUT of the worker:
|
|
340
|
+
* 1. prepare-upload (reuses each row's local `cid` — never re-hashed);
|
|
341
|
+
* 2. out-of-band PUT each grant (bounded concurrency);
|
|
342
|
+
* 3. commit-upload ONLY the entries whose PUT returned 200 (commit-after-
|
|
343
|
+
* 200, decision 2 — the sole dangling defense). PUT-failed entries get a
|
|
344
|
+
* per-entry failure so the cursor pins there for retry next round.
|
|
345
|
+
* Returns the SAME `RpcBatchResult` shape `sendPushChunk` consumes. If a grant
|
|
346
|
+
* is unexpectedly absent (capability was advertised but a row got none), bail
|
|
347
|
+
* via `BatchUnsupportedError` → the engine reverts to the legacy path.
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* Application metadata for a push entry, derived from its own bytes via the
|
|
351
|
+
* optional provider hook (did-space-metadata G3). Returns undefined when the
|
|
352
|
+
* provider exposes none — so the engine emits no metadata and the wire stays
|
|
353
|
+
* pre-G3 byte-identical.
|
|
354
|
+
*/
|
|
355
|
+
private readAppMeta;
|
|
356
|
+
private uploadPlaneWriteChunk;
|
|
357
|
+
/** Run `fn(0..n-1)` with at most `limit` in flight (push-side PUT fan-out). */
|
|
358
|
+
private boundedAll;
|
|
359
|
+
/**
|
|
360
|
+
* Upload a single change row. Split from push() so both the normal
|
|
361
|
+
* loop and future retry paths can call it.
|
|
362
|
+
*
|
|
363
|
+
* On 409 conflict, delegates to {@link resolveConflict}, which decides
|
|
364
|
+
* by LWW + tiebreak whether to force-overwrite the cloud or adopt the
|
|
365
|
+
* cloud's version locally. Either way, after resolveConflict returns,
|
|
366
|
+
* the row is considered "handled" and the push cursor advances past it.
|
|
367
|
+
*/
|
|
368
|
+
private pushOne;
|
|
369
|
+
/**
|
|
370
|
+
* Resolve a push-side 409 conflict via Last-Write-Wins (LWW).
|
|
371
|
+
*
|
|
372
|
+
* Decision matrix (see `native-sync-design.md` G11 for the full 7-row
|
|
373
|
+
* matrix and rationale):
|
|
374
|
+
*
|
|
375
|
+
* 1. `localMtime > cloudMtime` → **local wins**: force-overwrite the
|
|
376
|
+
* cloud (resend without `If-Match`). The server still validates
|
|
377
|
+
* `X-Content-CID`, so a corrupted upload still fails.
|
|
378
|
+
*
|
|
379
|
+
* 2. `localMtime < cloudMtime` → **cloud wins**: adopt the cloud's
|
|
380
|
+
* version locally via `provider.internalWrite/Delete` with the
|
|
381
|
+
* ORIGIN deviceId from the conflict response. Echo-loop Layer II.
|
|
382
|
+
*
|
|
383
|
+
* 3. `localMtime === cloudMtime` → **tiebreak by CID lexicographic
|
|
384
|
+
* order** (round 7 decision). The larger cid wins. delete ops
|
|
385
|
+
* treat their cid as the empty string, so a `put` with non-empty
|
|
386
|
+
* cid always beats a `delete` at the same mtime.
|
|
387
|
+
*
|
|
388
|
+
* Special cases handled here:
|
|
389
|
+
* - delete vs delete (both null cid) → idempotent no-op (defensive;
|
|
390
|
+
* in practice the server's delete handler turns DELETE 404 into
|
|
391
|
+
* success and the conflict never reaches here).
|
|
392
|
+
* - same mtime + same cid → idempotent natural convergence (the
|
|
393
|
+
* local-wins path is taken but the resend produces the same cid
|
|
394
|
+
* the cloud already has).
|
|
395
|
+
*
|
|
396
|
+
* mtime skew defense: G5.c (Task 3.3) rejects writes with
|
|
397
|
+
* `mtime > serverNow + 5min` at the header layer, so a single device
|
|
398
|
+
* with a wildly bad clock cannot poison the LWW decision globally.
|
|
399
|
+
*/
|
|
400
|
+
resolveConflict(change: ChangelogEntry, resp: ConflictResponse): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* Fetch and apply incoming changes from the cloud. Loops until either
|
|
403
|
+
* the server reports `hasMore === false`, the deadline passes, or the
|
|
404
|
+
* abort signal fires. On 409 Compacted, delegates to fullResync().
|
|
405
|
+
*
|
|
406
|
+
* Apply order: sequential in seq order within a batch (SQLite
|
|
407
|
+
* integrity + single origin-deviceId per row). Content fetching is
|
|
408
|
+
* parallel up to `PULL_FETCH_CONCURRENCY`.
|
|
409
|
+
*/
|
|
410
|
+
pull(opts: {
|
|
411
|
+
signal?: AbortSignal;
|
|
412
|
+
deadline: number;
|
|
413
|
+
}): Promise<{
|
|
414
|
+
pulled: number;
|
|
415
|
+
fullResynced: boolean;
|
|
416
|
+
}>;
|
|
417
|
+
/**
|
|
418
|
+
* Fetch content bytes for a batch of `put` rows in parallel, bounded
|
|
419
|
+
* by {@link PULL_FETCH_CONCURRENCY}. Results land in `cidMap`;
|
|
420
|
+
* individual fetch failures (404, cid mismatch) are logged and the
|
|
421
|
+
* offending cid is omitted so the caller's serial apply pass can
|
|
422
|
+
* detect the gap and skip.
|
|
423
|
+
*/
|
|
424
|
+
/**
|
|
425
|
+
* Content fetch dispatcher (P4): chunked `batchRead(optional:true)` when
|
|
426
|
+
* the adapter has it (≤20 cids and ≤2MB ESTIMATED bytes per chunk — size
|
|
427
|
+
* from the changelog rows), single concurrent reads otherwise. Tail-
|
|
428
|
+
* skipped cids are simply re-queued for the next chunk (they were never
|
|
429
|
+
* read); `missing:true` cids stay out of the map so the apply loop's
|
|
430
|
+
* §4.7.2 current/superseded classification is untouched.
|
|
431
|
+
*/
|
|
432
|
+
private fetchContent;
|
|
433
|
+
/** Single `.objects/{cid}` read with the same soft-failure semantics. */
|
|
434
|
+
private fetchOneObject;
|
|
435
|
+
private fetchContentConcurrent;
|
|
436
|
+
/**
|
|
437
|
+
* Whether the download plane can be used RIGHT NOW: the adapter speaks the
|
|
438
|
+
* methods, the server advertised the INDEPENDENT capability (memoized per
|
|
439
|
+
* instance, §7.3), and this session hasn't latched a 401/403 fallback.
|
|
440
|
+
*/
|
|
441
|
+
private downloadPlaneAvailable;
|
|
442
|
+
/**
|
|
443
|
+
* Fetch LARGE objects (size ≥ {@link DOWNLOAD_PLANE_MIN_BYTES}) via the
|
|
444
|
+
* download plane — prepare-download → bounded-concurrency direct R2 GET →
|
|
445
|
+
* computeCID → `bytesMap`. Bytes leave R2 directly (never through the worker /
|
|
446
|
+
* base64). Returns the SET of cids it satisfied; the caller routes the rest
|
|
447
|
+
* (small objects, Node `grant:null`, forbidden, 404, post-fallback) through
|
|
448
|
+
* batchRead — so a true miss still raises the existing fail-closed path.
|
|
449
|
+
*
|
|
450
|
+
* fail-closed: a byte string whose `computeCID` ≠ the requested cid (R2 served
|
|
451
|
+
* tampered/other bytes) is DROPPED, never written (§8.1). A 401/403 latches
|
|
452
|
+
* `downloadFallback` for the whole session — at most one wall-bang (§7.3).
|
|
453
|
+
*/
|
|
454
|
+
private fillBytesViaDownloadPlane;
|
|
455
|
+
/**
|
|
456
|
+
* First-sync / post-compaction recovery path. Fetches the full manifest
|
|
457
|
+
* and reconciles the local store against it, skipping paths the local
|
|
458
|
+
* changelog still has unpushed changes for (invariant I1).
|
|
459
|
+
*
|
|
460
|
+
* ORDERING IS CRITICAL — `pendingPaths` MUST be collected BEFORE the
|
|
461
|
+
* manifest fetch so a delete written between pendingPaths collection
|
|
462
|
+
* and apply does not get reverted by the manifest restoration.
|
|
463
|
+
*/
|
|
464
|
+
fullResync(opts: {
|
|
465
|
+
signal?: AbortSignal;
|
|
466
|
+
deadline: number;
|
|
467
|
+
}): Promise<{
|
|
468
|
+
pulled: number;
|
|
469
|
+
}>;
|
|
470
|
+
}
|
|
471
|
+
//#endregion
|
|
472
|
+
export { ConflictResolutionError, ConflictResponse, CurrentObjectMissingError, CurrentObjectSource, PULL_BATCH_LIMIT, PULL_FETCH_CONCURRENCY, PUSH_BATCH_LIMIT, PUSH_PROGRESS_FLUSH_INTERVAL, SYNC_WALL_CLOCK_BUDGET_MS, SyncCloudAFS, SyncEngine, SyncEngineOptions, SyncEngineProviderHandle, SyncResult, classifyMissingObject };
|
|
473
|
+
//# sourceMappingURL=sync-engine.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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