@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,241 @@
|
|
|
1
|
+
const require_changelog_schema = require('./changelog-schema.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/local-changelog.ts
|
|
4
|
+
/**
|
|
5
|
+
* LocalChangelog — Phase 3 Task 3.4 (G6)
|
|
6
|
+
*
|
|
7
|
+
* Read-side + GC companion to the `changelog` writes produced by
|
|
8
|
+
* MetadataDB / D1TreeIndex / SQLiteTreeIndex. Used exclusively by the
|
|
9
|
+
* local SyncEngine (desktop + mobile); has NO counterpart inside the
|
|
10
|
+
* CloudflareDIDSpace Worker — the server IS the cloud changelog, it has
|
|
11
|
+
* no notion of "unpushed local rows".
|
|
12
|
+
*
|
|
13
|
+
* Responsibilities:
|
|
14
|
+
*
|
|
15
|
+
* 1. `getUnpushed(sinceSeq, limit?)`
|
|
16
|
+
* Return changelog rows written by THIS device (`device_id == self`)
|
|
17
|
+
* whose `seq > sinceSeq`, ordered by seq ascending. SyncEngine pages
|
|
18
|
+
* through these on the push leg of each sync round.
|
|
19
|
+
*
|
|
20
|
+
* 2. `markPushed(upToSeq)`
|
|
21
|
+
* Advance `sync_state['{scope}:local_seq']` to record that all self-
|
|
22
|
+
* written rows up to `upToSeq` have been accepted by the server. Does
|
|
23
|
+
* NOT delete anything — row retention is owned by `gc()`. The watermark
|
|
24
|
+
* is strictly monotonic (setting a lower value is a no-op).
|
|
25
|
+
*
|
|
26
|
+
* 3. `gc()`
|
|
27
|
+
* Single atomic DELETE that removes:
|
|
28
|
+
* (a) rows from THIS device with seq ≤ local_seq (pushed, no longer
|
|
29
|
+
* needed for resume) AND
|
|
30
|
+
* (b) rows from OTHER devices with seq ≤ cloud_seq (pulled + applied,
|
|
31
|
+
* no longer needed for replay).
|
|
32
|
+
* Called by SyncEngine AFTER a successful sync round. The gc contract
|
|
33
|
+
* is called-by-engine — gc() itself makes no assumption about timing.
|
|
34
|
+
*
|
|
35
|
+
* 4. `getLocalSeq` / `getCloudSeq` / `setCloudSeq`
|
|
36
|
+
* Helpers for SyncEngine and tests. Task 3.5 introduces a richer
|
|
37
|
+
* `SyncStateStore` that owns these KV lookups with Keychain/Keystore
|
|
38
|
+
* backing; for Task 3.4 we keep the reads/writes inside LocalChangelog
|
|
39
|
+
* so the module is self-contained and pre-3.5 integration tests work.
|
|
40
|
+
*
|
|
41
|
+
* The `sync_state` KV table is created by `ensureTable()` — idempotent —
|
|
42
|
+
* and must be present before any of the methods above are called. The DDL
|
|
43
|
+
* lives in `changelog-schema.ts` and is byte-identical across TypeScript,
|
|
44
|
+
* Swift, and Kotlin (Task 3.5 will add a parity check once the schema
|
|
45
|
+
* extends with Keychain-backed keys).
|
|
46
|
+
*
|
|
47
|
+
* Scope isolation: every SQL statement inside LocalChangelog includes a
|
|
48
|
+
* `scope = ?` bind. Cross-scope leaks would regress Task 2.1's scope-
|
|
49
|
+
* scoped changelog design, so both gc() and getUnpushed() carry the scope
|
|
50
|
+
* through explicitly.
|
|
51
|
+
*/
|
|
52
|
+
/** Default `limit` applied by `getUnpushed` when none is specified. */
|
|
53
|
+
const LOCAL_CHANGELOG_DEFAULT_LIMIT = 1e3;
|
|
54
|
+
/** Maximum `limit` accepted by `getUnpushed`; larger values are clamped. */
|
|
55
|
+
const LOCAL_CHANGELOG_MAX_LIMIT = 1e4;
|
|
56
|
+
function toChangelogEntry(row) {
|
|
57
|
+
const r = row;
|
|
58
|
+
return {
|
|
59
|
+
seq: Number(r.seq),
|
|
60
|
+
scope: r.scope,
|
|
61
|
+
path: r.path,
|
|
62
|
+
op: r.op,
|
|
63
|
+
cid: r.cid ?? null,
|
|
64
|
+
old_cid: r.old_cid ?? null,
|
|
65
|
+
size: r.size === null || r.size === void 0 ? null : Number(r.size),
|
|
66
|
+
mtime: Number(r.mtime),
|
|
67
|
+
device_id: r.device_id
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var LocalChangelog = class {
|
|
71
|
+
client;
|
|
72
|
+
scope;
|
|
73
|
+
deviceId;
|
|
74
|
+
constructor(opts) {
|
|
75
|
+
if (typeof opts.scope !== "string" || opts.scope.length === 0) throw new Error("LocalChangelog: scope must be a non-empty string");
|
|
76
|
+
if (typeof opts.deviceId !== "string" || opts.deviceId.length === 0) throw new Error("LocalChangelog: deviceId must be a non-empty string");
|
|
77
|
+
this.client = opts.client;
|
|
78
|
+
this.scope = opts.scope;
|
|
79
|
+
this.deviceId = opts.deviceId;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Idempotently create the `sync_state` table (and any future indices).
|
|
83
|
+
*
|
|
84
|
+
* MetadataDB.open() calls this on desktop; mobile runtimes run the DDL
|
|
85
|
+
* inline from their own migrate(). Safe to call from tests that
|
|
86
|
+
* construct LocalChangelog directly on a raw libsql client.
|
|
87
|
+
*/
|
|
88
|
+
static async ensureTable(client) {
|
|
89
|
+
await client.execute(require_changelog_schema.SYNC_STATE_TABLE_SQL);
|
|
90
|
+
for (const sql of require_changelog_schema.SYNC_STATE_INDEX_SQL) await client.execute(sql);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Read the `local_seq` watermark — highest changelog.seq that the current
|
|
94
|
+
* device has acknowledged as pushed. Returns 0 when the key is missing
|
|
95
|
+
* (nothing pushed yet).
|
|
96
|
+
*/
|
|
97
|
+
async getLocalSeq() {
|
|
98
|
+
return this.readSeqKey(`${this.scope}:local_seq`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Read the `cloud_seq` watermark — highest changelog.seq from OTHER
|
|
102
|
+
* devices that the current device has applied locally. Task 3.4 does
|
|
103
|
+
* not write this key itself; Task 3.5's SyncEngine will advance it as
|
|
104
|
+
* part of the pull leg. Returns 0 as the "nothing pulled yet" sentinel.
|
|
105
|
+
*/
|
|
106
|
+
async getCloudSeq() {
|
|
107
|
+
return this.readSeqKey(`${this.scope}:cloud_seq`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Test / SyncEngine helper to advance the cloud_seq watermark.
|
|
111
|
+
*
|
|
112
|
+
* Monotonic: a caller passing a lower value than the stored watermark
|
|
113
|
+
* is a no-op. This matches Task 3.5's eventual API contract and keeps
|
|
114
|
+
* LocalChangelog's GC branch for "other devices" safe under retries.
|
|
115
|
+
*/
|
|
116
|
+
async setCloudSeq(seq) {
|
|
117
|
+
await this.writeSeqKeyMonotonic(`${this.scope}:cloud_seq`, seq);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Low-level SELECT for a `sync_state` integer key. Returns 0 when the
|
|
121
|
+
* key is missing. Throws on non-numeric values (corrupt state).
|
|
122
|
+
*/
|
|
123
|
+
async readSeqKey(key) {
|
|
124
|
+
const result = await this.client.execute({
|
|
125
|
+
sql: "SELECT value FROM ds_sync_state WHERE key = ?",
|
|
126
|
+
args: [key]
|
|
127
|
+
});
|
|
128
|
+
if (result.rows.length === 0) return 0;
|
|
129
|
+
const raw = result.rows[0][0];
|
|
130
|
+
if (raw === null || raw === void 0) return 0;
|
|
131
|
+
const value = typeof raw === "string" ? raw : String(raw);
|
|
132
|
+
const parsed = Number(value);
|
|
133
|
+
if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) throw new Error(`LocalChangelog: corrupt sync_state value for key=${key}: ${value}`);
|
|
134
|
+
return parsed;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Monotonic INSERT-OR-REPLACE for a `sync_state` integer key. The CASE
|
|
138
|
+
* expression keeps the prior value when the incoming one is lower.
|
|
139
|
+
*
|
|
140
|
+
* Negative inputs are clamped to 0 so misbehaving callers cannot rewind
|
|
141
|
+
* the watermark below the "nothing synced yet" sentinel.
|
|
142
|
+
*/
|
|
143
|
+
async writeSeqKeyMonotonic(key, seq) {
|
|
144
|
+
const safe = Math.max(0, Math.floor(Number.isFinite(seq) ? seq : 0));
|
|
145
|
+
await this.client.execute({
|
|
146
|
+
sql: `INSERT INTO ds_sync_state (key, value) VALUES (?, ?)
|
|
147
|
+
ON CONFLICT(key) DO UPDATE SET
|
|
148
|
+
value = CASE
|
|
149
|
+
WHEN CAST(excluded.value AS INTEGER) > CAST(ds_sync_state.value AS INTEGER)
|
|
150
|
+
THEN excluded.value
|
|
151
|
+
ELSE ds_sync_state.value
|
|
152
|
+
END`,
|
|
153
|
+
args: [key, String(safe)]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Return self-written changelog rows with seq > sinceSeq, ordered by seq
|
|
158
|
+
* ascending. Rows from other devices are excluded at the SQL layer
|
|
159
|
+
* (device_id filter) so this function is cheap even on multi-device
|
|
160
|
+
* spaces with heavy pull traffic.
|
|
161
|
+
*
|
|
162
|
+
* Clamping rules (matches G5.a Worker endpoint for consistency):
|
|
163
|
+
* - sinceSeq < 0 → clamped to 0 (not rejected; caller is internal)
|
|
164
|
+
* - limit undefined → LOCAL_CHANGELOG_DEFAULT_LIMIT (1000)
|
|
165
|
+
* - limit === 0 → returns [] without hitting SQLite
|
|
166
|
+
* - limit > LOCAL_CHANGELOG_MAX_LIMIT → clamped to 10000
|
|
167
|
+
*/
|
|
168
|
+
async getUnpushed(sinceSeq, limit) {
|
|
169
|
+
const safeSince = Math.max(0, Math.floor(Number.isFinite(sinceSeq) ? sinceSeq : 0));
|
|
170
|
+
const requested = limit ?? LOCAL_CHANGELOG_DEFAULT_LIMIT;
|
|
171
|
+
if (requested === 0) return [];
|
|
172
|
+
const safeLimit = Math.min(LOCAL_CHANGELOG_MAX_LIMIT, Math.max(0, Math.floor(Number.isFinite(requested) ? requested : 0)));
|
|
173
|
+
if (safeLimit === 0) return [];
|
|
174
|
+
return (await this.client.execute({
|
|
175
|
+
sql: `SELECT seq, scope, path, op, cid, old_cid, size, mtime, device_id
|
|
176
|
+
FROM ds_changelog
|
|
177
|
+
WHERE scope = ? AND device_id = ? AND seq > ?
|
|
178
|
+
ORDER BY seq ASC
|
|
179
|
+
LIMIT ?`,
|
|
180
|
+
args: [
|
|
181
|
+
this.scope,
|
|
182
|
+
this.deviceId,
|
|
183
|
+
safeSince,
|
|
184
|
+
safeLimit
|
|
185
|
+
]
|
|
186
|
+
})).rows.map(toChangelogEntry);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Advance the `local_seq` watermark to `upToSeq`. Does NOT delete rows;
|
|
190
|
+
* `gc()` is the only path that removes data.
|
|
191
|
+
*
|
|
192
|
+
* Monotonic: calls with `upToSeq` less than or equal to the stored
|
|
193
|
+
* watermark become no-ops. This keeps the invariant that SyncEngine can
|
|
194
|
+
* safely retry pushes without rewinding progress.
|
|
195
|
+
*/
|
|
196
|
+
async markPushed(upToSeq) {
|
|
197
|
+
await this.writeSeqKeyMonotonic(`${this.scope}:local_seq`, upToSeq);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Atomically delete self-pushed rows (seq ≤ local_seq) AND other-device
|
|
201
|
+
* rows that have been applied locally (seq ≤ cloud_seq).
|
|
202
|
+
*
|
|
203
|
+
* Rows that do NOT match either branch — e.g. other-device rows above
|
|
204
|
+
* cloud_seq, or self rows above local_seq — remain untouched. This is
|
|
205
|
+
* the non-negotiable safety rule: GC must never remove a row whose
|
|
206
|
+
* application is still pending.
|
|
207
|
+
*
|
|
208
|
+
* Implementation note: we read local_seq + cloud_seq BEFORE issuing the
|
|
209
|
+
* DELETE and bake them into the WHERE clause. This keeps the DELETE a
|
|
210
|
+
* single statement (the spec mandates a single-shot DELETE, not a
|
|
211
|
+
* row-by-row loop) and makes the semantics easy to reason about under
|
|
212
|
+
* concurrent gc() invocations — each call operates on a point-in-time
|
|
213
|
+
* snapshot of the watermarks.
|
|
214
|
+
*/
|
|
215
|
+
async gc() {
|
|
216
|
+
const localSeq = await this.getLocalSeq();
|
|
217
|
+
const cloudSeq = await this.getCloudSeq();
|
|
218
|
+
const result = await this.client.execute({
|
|
219
|
+
sql: `DELETE FROM ds_changelog
|
|
220
|
+
WHERE scope = ?
|
|
221
|
+
AND (
|
|
222
|
+
(device_id = ? AND seq <= ?)
|
|
223
|
+
OR
|
|
224
|
+
(device_id != ? AND seq <= ?)
|
|
225
|
+
)`,
|
|
226
|
+
args: [
|
|
227
|
+
this.scope,
|
|
228
|
+
this.deviceId,
|
|
229
|
+
localSeq,
|
|
230
|
+
this.deviceId,
|
|
231
|
+
cloudSeq
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
return { deleted: Number(result.rowsAffected ?? 0) };
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
//#endregion
|
|
239
|
+
exports.LOCAL_CHANGELOG_DEFAULT_LIMIT = LOCAL_CHANGELOG_DEFAULT_LIMIT;
|
|
240
|
+
exports.LOCAL_CHANGELOG_MAX_LIMIT = LOCAL_CHANGELOG_MAX_LIMIT;
|
|
241
|
+
exports.LocalChangelog = LocalChangelog;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ChangelogEntry } from "./tree-index.cjs";
|
|
2
|
+
import * as _libsql_client0 from "@libsql/client";
|
|
3
|
+
|
|
4
|
+
//#region src/local-changelog.d.ts
|
|
5
|
+
/** Default `limit` applied by `getUnpushed` when none is specified. */
|
|
6
|
+
declare const LOCAL_CHANGELOG_DEFAULT_LIMIT = 1000;
|
|
7
|
+
/** Maximum `limit` accepted by `getUnpushed`; larger values are clamped. */
|
|
8
|
+
declare const LOCAL_CHANGELOG_MAX_LIMIT = 10000;
|
|
9
|
+
interface LocalChangelogOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Already-opened libsql client sharing the same DB file as the TreeIndex.
|
|
12
|
+
* LocalChangelog does NOT own the client lifecycle — callers (typically
|
|
13
|
+
* `DIDSpaceProvider` construction) remain responsible for close().
|
|
14
|
+
*/
|
|
15
|
+
client: _libsql_client0.Client;
|
|
16
|
+
/** Scope string written into `changelog` and used to partition `sync_state` keys. */
|
|
17
|
+
scope: string;
|
|
18
|
+
/**
|
|
19
|
+
* Device identifier of the current process. Used BOTH as the `self` filter
|
|
20
|
+
* for `getUnpushed` AND as the branch discriminator in `gc()`.
|
|
21
|
+
*
|
|
22
|
+
* Task 3.4 takes this via constructor injection. Task 3.5 will wire the
|
|
23
|
+
* argument to a Keychain/Keystore-backed SyncStateStore without changing
|
|
24
|
+
* LocalChangelog's public surface.
|
|
25
|
+
*/
|
|
26
|
+
deviceId: string;
|
|
27
|
+
}
|
|
28
|
+
declare class LocalChangelog {
|
|
29
|
+
private readonly client;
|
|
30
|
+
private readonly scope;
|
|
31
|
+
private readonly deviceId;
|
|
32
|
+
constructor(opts: LocalChangelogOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Idempotently create the `sync_state` table (and any future indices).
|
|
35
|
+
*
|
|
36
|
+
* MetadataDB.open() calls this on desktop; mobile runtimes run the DDL
|
|
37
|
+
* inline from their own migrate(). Safe to call from tests that
|
|
38
|
+
* construct LocalChangelog directly on a raw libsql client.
|
|
39
|
+
*/
|
|
40
|
+
static ensureTable(client: _libsql_client0.Client): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Read the `local_seq` watermark — highest changelog.seq that the current
|
|
43
|
+
* device has acknowledged as pushed. Returns 0 when the key is missing
|
|
44
|
+
* (nothing pushed yet).
|
|
45
|
+
*/
|
|
46
|
+
getLocalSeq(): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Read the `cloud_seq` watermark — highest changelog.seq from OTHER
|
|
49
|
+
* devices that the current device has applied locally. Task 3.4 does
|
|
50
|
+
* not write this key itself; Task 3.5's SyncEngine will advance it as
|
|
51
|
+
* part of the pull leg. Returns 0 as the "nothing pulled yet" sentinel.
|
|
52
|
+
*/
|
|
53
|
+
getCloudSeq(): Promise<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Test / SyncEngine helper to advance the cloud_seq watermark.
|
|
56
|
+
*
|
|
57
|
+
* Monotonic: a caller passing a lower value than the stored watermark
|
|
58
|
+
* is a no-op. This matches Task 3.5's eventual API contract and keeps
|
|
59
|
+
* LocalChangelog's GC branch for "other devices" safe under retries.
|
|
60
|
+
*/
|
|
61
|
+
setCloudSeq(seq: number): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Low-level SELECT for a `sync_state` integer key. Returns 0 when the
|
|
64
|
+
* key is missing. Throws on non-numeric values (corrupt state).
|
|
65
|
+
*/
|
|
66
|
+
private readSeqKey;
|
|
67
|
+
/**
|
|
68
|
+
* Monotonic INSERT-OR-REPLACE for a `sync_state` integer key. The CASE
|
|
69
|
+
* expression keeps the prior value when the incoming one is lower.
|
|
70
|
+
*
|
|
71
|
+
* Negative inputs are clamped to 0 so misbehaving callers cannot rewind
|
|
72
|
+
* the watermark below the "nothing synced yet" sentinel.
|
|
73
|
+
*/
|
|
74
|
+
private writeSeqKeyMonotonic;
|
|
75
|
+
/**
|
|
76
|
+
* Return self-written changelog rows with seq > sinceSeq, ordered by seq
|
|
77
|
+
* ascending. Rows from other devices are excluded at the SQL layer
|
|
78
|
+
* (device_id filter) so this function is cheap even on multi-device
|
|
79
|
+
* spaces with heavy pull traffic.
|
|
80
|
+
*
|
|
81
|
+
* Clamping rules (matches G5.a Worker endpoint for consistency):
|
|
82
|
+
* - sinceSeq < 0 → clamped to 0 (not rejected; caller is internal)
|
|
83
|
+
* - limit undefined → LOCAL_CHANGELOG_DEFAULT_LIMIT (1000)
|
|
84
|
+
* - limit === 0 → returns [] without hitting SQLite
|
|
85
|
+
* - limit > LOCAL_CHANGELOG_MAX_LIMIT → clamped to 10000
|
|
86
|
+
*/
|
|
87
|
+
getUnpushed(sinceSeq: number, limit?: number): Promise<ChangelogEntry[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Advance the `local_seq` watermark to `upToSeq`. Does NOT delete rows;
|
|
90
|
+
* `gc()` is the only path that removes data.
|
|
91
|
+
*
|
|
92
|
+
* Monotonic: calls with `upToSeq` less than or equal to the stored
|
|
93
|
+
* watermark become no-ops. This keeps the invariant that SyncEngine can
|
|
94
|
+
* safely retry pushes without rewinding progress.
|
|
95
|
+
*/
|
|
96
|
+
markPushed(upToSeq: number): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Atomically delete self-pushed rows (seq ≤ local_seq) AND other-device
|
|
99
|
+
* rows that have been applied locally (seq ≤ cloud_seq).
|
|
100
|
+
*
|
|
101
|
+
* Rows that do NOT match either branch — e.g. other-device rows above
|
|
102
|
+
* cloud_seq, or self rows above local_seq — remain untouched. This is
|
|
103
|
+
* the non-negotiable safety rule: GC must never remove a row whose
|
|
104
|
+
* application is still pending.
|
|
105
|
+
*
|
|
106
|
+
* Implementation note: we read local_seq + cloud_seq BEFORE issuing the
|
|
107
|
+
* DELETE and bake them into the WHERE clause. This keeps the DELETE a
|
|
108
|
+
* single statement (the spec mandates a single-shot DELETE, not a
|
|
109
|
+
* row-by-row loop) and makes the semantics easy to reason about under
|
|
110
|
+
* concurrent gc() invocations — each call operates on a point-in-time
|
|
111
|
+
* snapshot of the watermarks.
|
|
112
|
+
*/
|
|
113
|
+
gc(): Promise<{
|
|
114
|
+
deleted: number;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { LOCAL_CHANGELOG_DEFAULT_LIMIT, LOCAL_CHANGELOG_MAX_LIMIT, LocalChangelog, LocalChangelogOptions };
|
|
119
|
+
//# sourceMappingURL=local-changelog.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-changelog.d.cts","names":[],"sources":["../src/local-changelog.ts"],"mappings":";;;;;cAqDa,6BAAA;;cAGA,yBAAA;AAAA,UAEI,qBAAA;EA6GG;;;;;EAvGlB,MAAA,EANoC,eAAA,CAMH,MAAA;EAkKG;EA/JpC,KAAA;EA+J6D;;;;;;;;EArJ7D,QAAA;AAAA;AAAA,cA+BW,cAAA;EAAA,iBACM,MAAA;EAAA,iBACA,KAAA;EAAA,iBACA,QAAA;cAEL,IAAA,EAAM,qBAAA;;;;;;;;SAmBL,WAAA,CAAY,MAAA,EAnBc,eAAA,CAmBmB,MAAA,GAAS,OAAA;;;;;;EAc7D,WAAA,CAAA,GAAe,OAAA;;;;;;;EAUf,WAAA,CAAA,GAAe,OAAA;;;;;;;;EAWf,WAAA,CAAY,GAAA,WAAc,OAAA;;;;;UAQlB,UAAA;;;;;;;;UAuBA,oBAAA;;;;;;;;;;;;;EA4BR,WAAA,CAAY,QAAA,UAAkB,KAAA,YAAiB,OAAA,CAAQ,cAAA;;;;;;;;;EA6BvD,UAAA,CAAW,OAAA,WAAkB,OAAA;;;;;;;;;;;;;;;;;EAoB7B,EAAA,CAAA,GAAM,OAAA;IAAU,OAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ChangelogEntry } from "./tree-index.mjs";
|
|
2
|
+
import * as _libsql_client0 from "@libsql/client";
|
|
3
|
+
|
|
4
|
+
//#region src/local-changelog.d.ts
|
|
5
|
+
/** Default `limit` applied by `getUnpushed` when none is specified. */
|
|
6
|
+
declare const LOCAL_CHANGELOG_DEFAULT_LIMIT = 1000;
|
|
7
|
+
/** Maximum `limit` accepted by `getUnpushed`; larger values are clamped. */
|
|
8
|
+
declare const LOCAL_CHANGELOG_MAX_LIMIT = 10000;
|
|
9
|
+
interface LocalChangelogOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Already-opened libsql client sharing the same DB file as the TreeIndex.
|
|
12
|
+
* LocalChangelog does NOT own the client lifecycle — callers (typically
|
|
13
|
+
* `DIDSpaceProvider` construction) remain responsible for close().
|
|
14
|
+
*/
|
|
15
|
+
client: _libsql_client0.Client;
|
|
16
|
+
/** Scope string written into `changelog` and used to partition `sync_state` keys. */
|
|
17
|
+
scope: string;
|
|
18
|
+
/**
|
|
19
|
+
* Device identifier of the current process. Used BOTH as the `self` filter
|
|
20
|
+
* for `getUnpushed` AND as the branch discriminator in `gc()`.
|
|
21
|
+
*
|
|
22
|
+
* Task 3.4 takes this via constructor injection. Task 3.5 will wire the
|
|
23
|
+
* argument to a Keychain/Keystore-backed SyncStateStore without changing
|
|
24
|
+
* LocalChangelog's public surface.
|
|
25
|
+
*/
|
|
26
|
+
deviceId: string;
|
|
27
|
+
}
|
|
28
|
+
declare class LocalChangelog {
|
|
29
|
+
private readonly client;
|
|
30
|
+
private readonly scope;
|
|
31
|
+
private readonly deviceId;
|
|
32
|
+
constructor(opts: LocalChangelogOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Idempotently create the `sync_state` table (and any future indices).
|
|
35
|
+
*
|
|
36
|
+
* MetadataDB.open() calls this on desktop; mobile runtimes run the DDL
|
|
37
|
+
* inline from their own migrate(). Safe to call from tests that
|
|
38
|
+
* construct LocalChangelog directly on a raw libsql client.
|
|
39
|
+
*/
|
|
40
|
+
static ensureTable(client: _libsql_client0.Client): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Read the `local_seq` watermark — highest changelog.seq that the current
|
|
43
|
+
* device has acknowledged as pushed. Returns 0 when the key is missing
|
|
44
|
+
* (nothing pushed yet).
|
|
45
|
+
*/
|
|
46
|
+
getLocalSeq(): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Read the `cloud_seq` watermark — highest changelog.seq from OTHER
|
|
49
|
+
* devices that the current device has applied locally. Task 3.4 does
|
|
50
|
+
* not write this key itself; Task 3.5's SyncEngine will advance it as
|
|
51
|
+
* part of the pull leg. Returns 0 as the "nothing pulled yet" sentinel.
|
|
52
|
+
*/
|
|
53
|
+
getCloudSeq(): Promise<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Test / SyncEngine helper to advance the cloud_seq watermark.
|
|
56
|
+
*
|
|
57
|
+
* Monotonic: a caller passing a lower value than the stored watermark
|
|
58
|
+
* is a no-op. This matches Task 3.5's eventual API contract and keeps
|
|
59
|
+
* LocalChangelog's GC branch for "other devices" safe under retries.
|
|
60
|
+
*/
|
|
61
|
+
setCloudSeq(seq: number): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Low-level SELECT for a `sync_state` integer key. Returns 0 when the
|
|
64
|
+
* key is missing. Throws on non-numeric values (corrupt state).
|
|
65
|
+
*/
|
|
66
|
+
private readSeqKey;
|
|
67
|
+
/**
|
|
68
|
+
* Monotonic INSERT-OR-REPLACE for a `sync_state` integer key. The CASE
|
|
69
|
+
* expression keeps the prior value when the incoming one is lower.
|
|
70
|
+
*
|
|
71
|
+
* Negative inputs are clamped to 0 so misbehaving callers cannot rewind
|
|
72
|
+
* the watermark below the "nothing synced yet" sentinel.
|
|
73
|
+
*/
|
|
74
|
+
private writeSeqKeyMonotonic;
|
|
75
|
+
/**
|
|
76
|
+
* Return self-written changelog rows with seq > sinceSeq, ordered by seq
|
|
77
|
+
* ascending. Rows from other devices are excluded at the SQL layer
|
|
78
|
+
* (device_id filter) so this function is cheap even on multi-device
|
|
79
|
+
* spaces with heavy pull traffic.
|
|
80
|
+
*
|
|
81
|
+
* Clamping rules (matches G5.a Worker endpoint for consistency):
|
|
82
|
+
* - sinceSeq < 0 → clamped to 0 (not rejected; caller is internal)
|
|
83
|
+
* - limit undefined → LOCAL_CHANGELOG_DEFAULT_LIMIT (1000)
|
|
84
|
+
* - limit === 0 → returns [] without hitting SQLite
|
|
85
|
+
* - limit > LOCAL_CHANGELOG_MAX_LIMIT → clamped to 10000
|
|
86
|
+
*/
|
|
87
|
+
getUnpushed(sinceSeq: number, limit?: number): Promise<ChangelogEntry[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Advance the `local_seq` watermark to `upToSeq`. Does NOT delete rows;
|
|
90
|
+
* `gc()` is the only path that removes data.
|
|
91
|
+
*
|
|
92
|
+
* Monotonic: calls with `upToSeq` less than or equal to the stored
|
|
93
|
+
* watermark become no-ops. This keeps the invariant that SyncEngine can
|
|
94
|
+
* safely retry pushes without rewinding progress.
|
|
95
|
+
*/
|
|
96
|
+
markPushed(upToSeq: number): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Atomically delete self-pushed rows (seq ≤ local_seq) AND other-device
|
|
99
|
+
* rows that have been applied locally (seq ≤ cloud_seq).
|
|
100
|
+
*
|
|
101
|
+
* Rows that do NOT match either branch — e.g. other-device rows above
|
|
102
|
+
* cloud_seq, or self rows above local_seq — remain untouched. This is
|
|
103
|
+
* the non-negotiable safety rule: GC must never remove a row whose
|
|
104
|
+
* application is still pending.
|
|
105
|
+
*
|
|
106
|
+
* Implementation note: we read local_seq + cloud_seq BEFORE issuing the
|
|
107
|
+
* DELETE and bake them into the WHERE clause. This keeps the DELETE a
|
|
108
|
+
* single statement (the spec mandates a single-shot DELETE, not a
|
|
109
|
+
* row-by-row loop) and makes the semantics easy to reason about under
|
|
110
|
+
* concurrent gc() invocations — each call operates on a point-in-time
|
|
111
|
+
* snapshot of the watermarks.
|
|
112
|
+
*/
|
|
113
|
+
gc(): Promise<{
|
|
114
|
+
deleted: number;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { LOCAL_CHANGELOG_DEFAULT_LIMIT, LOCAL_CHANGELOG_MAX_LIMIT, LocalChangelog, LocalChangelogOptions };
|
|
119
|
+
//# sourceMappingURL=local-changelog.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-changelog.d.mts","names":[],"sources":["../src/local-changelog.ts"],"mappings":";;;;;cAqDa,6BAAA;;cAGA,yBAAA;AAAA,UAEI,qBAAA;EA6GG;;;;;EAvGlB,MAAA,EANoC,eAAA,CAMH,MAAA;EAkKG;EA/JpC,KAAA;EA+J6D;;;;;;;;EArJ7D,QAAA;AAAA;AAAA,cA+BW,cAAA;EAAA,iBACM,MAAA;EAAA,iBACA,KAAA;EAAA,iBACA,QAAA;cAEL,IAAA,EAAM,qBAAA;;;;;;;;SAmBL,WAAA,CAAY,MAAA,EAnBc,eAAA,CAmBmB,MAAA,GAAS,OAAA;;;;;;EAc7D,WAAA,CAAA,GAAe,OAAA;;;;;;;EAUf,WAAA,CAAA,GAAe,OAAA;;;;;;;;EAWf,WAAA,CAAY,GAAA,WAAc,OAAA;;;;;UAQlB,UAAA;;;;;;;;UAuBA,oBAAA;;;;;;;;;;;;;EA4BR,WAAA,CAAY,QAAA,UAAkB,KAAA,YAAiB,OAAA,CAAQ,cAAA;;;;;;;;;EA6BvD,UAAA,CAAW,OAAA,WAAkB,OAAA;;;;;;;;;;;;;;;;;EAoB7B,EAAA,CAAA,GAAM,OAAA;IAAU,OAAA;EAAA;AAAA"}
|