@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,224 @@
|
|
|
1
|
+
import * as _libsql_client1 from "@libsql/client";
|
|
2
|
+
|
|
3
|
+
//#region src/sync-state.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* SyncStateStore — Phase 3 Task 3.5 (G7)
|
|
6
|
+
*
|
|
7
|
+
* Typed key-value façade over the `sync_state` table introduced by
|
|
8
|
+
* Task 3.4. Where {@link LocalChangelog} owns the bare minimum of the
|
|
9
|
+
* `{scope}:local_seq` and `{scope}:cloud_seq` keys for changelog GC,
|
|
10
|
+
* SyncStateStore exposes the FULL set of progress fields the local
|
|
11
|
+
* SyncEngine needs:
|
|
12
|
+
*
|
|
13
|
+
* - device_id (per-user, NOT scope-prefixed)
|
|
14
|
+
* - {scope}:local_seq
|
|
15
|
+
* - {scope}:cloud_seq
|
|
16
|
+
* - {scope}:last_sync_at
|
|
17
|
+
* - {scope}:sync_status
|
|
18
|
+
*
|
|
19
|
+
* The class is intentionally a sibling of LocalChangelog rather than a
|
|
20
|
+
* refactor of it. Both operate on the same SQLite `sync_state` table and
|
|
21
|
+
* share monotonic semantics for `local_seq` / `cloud_seq`; cross-class
|
|
22
|
+
* parity is asserted by tests so the SyncEngine can mix the two without
|
|
23
|
+
* surprises. Refactoring LocalChangelog into a thin wrapper around
|
|
24
|
+
* SyncStateStore is a future optimisation that Task 3.6 (SyncEngine) can
|
|
25
|
+
* decide to make if it becomes ergonomic.
|
|
26
|
+
*
|
|
27
|
+
* Platform notes:
|
|
28
|
+
* - TypeScript / desktop: device_id is stored ONLY in this SQLite table.
|
|
29
|
+
* There is no Keychain equivalent on desktop, so the file IS the SoT.
|
|
30
|
+
* - Swift / iOS: Keychain is the SoT; this SQLite cache is rebuilt
|
|
31
|
+
* on startup.
|
|
32
|
+
* - Kotlin / Android: AndroidKeystore + EncryptedSharedPreferences is
|
|
33
|
+
* the SoT; SQLite is again the cache.
|
|
34
|
+
*
|
|
35
|
+
* The two mobile runtimes implement their own SyncStateStore + DeviceIDStore
|
|
36
|
+
* pair under `swift/Sources/AFSDIDSpace/` and
|
|
37
|
+
* `kotlin/afs-didspace/.../io/aigne/afs/didspace/`. The TypeScript class
|
|
38
|
+
* here matches their public surface as closely as the language allows.
|
|
39
|
+
*/
|
|
40
|
+
/** Discriminated union shape of `sync_status`. */
|
|
41
|
+
type SyncStatus = {
|
|
42
|
+
kind: "idle";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "syncing";
|
|
45
|
+
} | {
|
|
46
|
+
kind: "active";
|
|
47
|
+
} | {
|
|
48
|
+
kind: "error";
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Full snapshot of the per-scope sync state. Returned by {@link SyncStateStore.load}.
|
|
53
|
+
*
|
|
54
|
+
* `deviceId` is per-USER-DID (stable across all scopes for the same install)
|
|
55
|
+
* and is therefore stored under the bare key `device_id` — NOT scope-prefixed.
|
|
56
|
+
* Every other field is scope-prefixed internally so multiple scopes sharing
|
|
57
|
+
* the same SQLite file stay isolated.
|
|
58
|
+
*/
|
|
59
|
+
interface AppState {
|
|
60
|
+
/** Stable device identifier. Generated on first load() if missing. */
|
|
61
|
+
deviceId: string;
|
|
62
|
+
/** Highest changelog.seq pulled+applied from other devices. */
|
|
63
|
+
cloudSeq: number;
|
|
64
|
+
/** Highest changelog.seq this device has pushed to cloud. */
|
|
65
|
+
localSeq: number;
|
|
66
|
+
/** Unix millis of the last successful sync round (any leg). */
|
|
67
|
+
lastSyncAt: number;
|
|
68
|
+
/** Current sync state machine value. */
|
|
69
|
+
syncStatus: SyncStatus;
|
|
70
|
+
}
|
|
71
|
+
/** Default `AppState` returned by load() when nothing is persisted yet. */
|
|
72
|
+
declare function defaultAppState(): AppState;
|
|
73
|
+
/**
|
|
74
|
+
* Registry of the raw `sync_state` keys this class manages. Exported so
|
|
75
|
+
* tests and the eventual SyncEngine can introspect the wire format without
|
|
76
|
+
* hard-coding strings.
|
|
77
|
+
*
|
|
78
|
+
* Keys marked `scoped` are written as `{scope}:{name}`. The `device_id`
|
|
79
|
+
* key is unique among the registry — it is per-user and intentionally NOT
|
|
80
|
+
* scope-prefixed so a single device sharing two DID Space scopes still
|
|
81
|
+
* presents the same identity to both.
|
|
82
|
+
*/
|
|
83
|
+
declare const SYNC_STATE_KEYS: {
|
|
84
|
+
readonly deviceId: {
|
|
85
|
+
readonly name: "device_id";
|
|
86
|
+
readonly scoped: false;
|
|
87
|
+
};
|
|
88
|
+
readonly localSeq: {
|
|
89
|
+
readonly name: "local_seq";
|
|
90
|
+
readonly scoped: true;
|
|
91
|
+
};
|
|
92
|
+
readonly cloudSeq: {
|
|
93
|
+
readonly name: "cloud_seq";
|
|
94
|
+
readonly scoped: true;
|
|
95
|
+
};
|
|
96
|
+
readonly lastSyncAt: {
|
|
97
|
+
readonly name: "last_sync_at";
|
|
98
|
+
readonly scoped: true;
|
|
99
|
+
};
|
|
100
|
+
readonly syncStatus: {
|
|
101
|
+
readonly name: "sync_status";
|
|
102
|
+
readonly scoped: true;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
interface SyncStateStoreOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Already-opened libsql client sharing the same DB file as the TreeIndex.
|
|
108
|
+
* SyncStateStore does NOT own the client lifecycle — callers (typically
|
|
109
|
+
* `DIDSpaceProvider` construction) remain responsible for close().
|
|
110
|
+
*/
|
|
111
|
+
client: _libsql_client1.Client;
|
|
112
|
+
/** Scope string used to prefix per-scope keys. Must be non-empty. */
|
|
113
|
+
scope: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Serialise a {@link SyncStatus} to its on-disk string form.
|
|
117
|
+
*
|
|
118
|
+
* Format (matches the spec acceptance criteria):
|
|
119
|
+
* - `idle` → `"idle"`
|
|
120
|
+
* - `syncing` → `"syncing"`
|
|
121
|
+
* - `active` → `"active"`
|
|
122
|
+
* - `error:{message}` → `"error:{message}"`
|
|
123
|
+
*
|
|
124
|
+
* The `error` branch preserves the full message verbatim. Newlines and
|
|
125
|
+
* colons inside the message are tolerated; parsing is greedy on the prefix
|
|
126
|
+
* `error:` so the remainder of the string is the message regardless of
|
|
127
|
+
* what punctuation it contains.
|
|
128
|
+
*/
|
|
129
|
+
declare function serializeSyncStatus(status: SyncStatus): string;
|
|
130
|
+
/**
|
|
131
|
+
* Parse a `sync_status` string back into a {@link SyncStatus}. Throws on
|
|
132
|
+
* unrecognised forms — this matches LocalChangelog's "corrupt value =
|
|
133
|
+
* surface the bug" stance from Task 3.4.
|
|
134
|
+
*/
|
|
135
|
+
declare function parseSyncStatus(raw: string): SyncStatus;
|
|
136
|
+
/**
|
|
137
|
+
* Strict device_id format regex. Must match the server-side validator in
|
|
138
|
+
* `services/arc-computer/src/handlers/validate-headers.ts` so locally
|
|
139
|
+
* generated identifiers round-trip through the cloud sync endpoints
|
|
140
|
+
* unchanged. Format: `<class>:<platform>:<suffix>`.
|
|
141
|
+
*
|
|
142
|
+
* Duplicated locally so this module has zero cross-package imports — the
|
|
143
|
+
* source of truth lives in `validate-headers.ts` and any change there must
|
|
144
|
+
* be mirrored here AND in the Swift/Kotlin equivalents.
|
|
145
|
+
*/
|
|
146
|
+
declare const DEVICE_ID_FORMAT_RE: RegExp;
|
|
147
|
+
/** Validate a device_id string. Returns true on match. */
|
|
148
|
+
declare function isValidDeviceId(deviceId: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Generate a fresh device_id for the current TypeScript desktop runtime.
|
|
151
|
+
* Format: `desktop:ts:<uuid v4>`. Tests can pass an injected UUID to
|
|
152
|
+
* keep generation deterministic.
|
|
153
|
+
*/
|
|
154
|
+
declare function generateDesktopDeviceId(uuid?: string): string;
|
|
155
|
+
declare class SyncStateStore {
|
|
156
|
+
private readonly client;
|
|
157
|
+
private readonly scope;
|
|
158
|
+
constructor(opts: SyncStateStoreOptions);
|
|
159
|
+
/**
|
|
160
|
+
* Idempotently create the `sync_state` table. MetadataDB.open() and the
|
|
161
|
+
* Swift/Kotlin SQLiteTreeIndex.migrate() already create it; this static
|
|
162
|
+
* helper exists for test fixtures that build a SyncStateStore on a raw
|
|
163
|
+
* libsql client. Reuses the canonical DDL from `changelog-schema.ts` so
|
|
164
|
+
* three-runtime parity is preserved.
|
|
165
|
+
*/
|
|
166
|
+
static ensureTable(client: _libsql_client1.Client): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Build the on-disk key for a given AppState field. Per-scope fields
|
|
169
|
+
* are prefixed with `{scope}:`; the per-user `device_id` field is the
|
|
170
|
+
* raw bare name. Exposed as a private helper (rather than inlined) so
|
|
171
|
+
* the parity tests can introspect the rule via SYNC_STATE_KEYS.
|
|
172
|
+
*/
|
|
173
|
+
private keyFor;
|
|
174
|
+
/**
|
|
175
|
+
* Read the full {@link AppState} for this scope. Missing fields fall
|
|
176
|
+
* back to the defaults from {@link defaultAppState}.
|
|
177
|
+
*
|
|
178
|
+
* If `device_id` is absent, this method generates a fresh one using
|
|
179
|
+
* {@link generateDesktopDeviceId} and persists it back to the same
|
|
180
|
+
* SQLite cache before returning. Subsequent loads will see the same
|
|
181
|
+
* value (this is the "TS desktop has no Keychain — file IS the SoT"
|
|
182
|
+
* branch from the spec).
|
|
183
|
+
*
|
|
184
|
+
* Corrupt values throw — corrupt `cloud_seq` / `local_seq` / `last_sync_at`
|
|
185
|
+
* non-numeric, corrupt `sync_status` not in the recognised set, corrupt
|
|
186
|
+
* `device_id` failing the strict regex.
|
|
187
|
+
*/
|
|
188
|
+
load(): Promise<AppState>;
|
|
189
|
+
/**
|
|
190
|
+
* Persist a partial update to the {@link AppState}. Each field is
|
|
191
|
+
* written via INSERT OR REPLACE on its individual key; concurrent
|
|
192
|
+
* save() calls touching disjoint fields cannot lose data.
|
|
193
|
+
*
|
|
194
|
+
* Monotonic fields:
|
|
195
|
+
* - `cloudSeq` and `localSeq` use the same CASE expression as
|
|
196
|
+
* {@link LocalChangelog.markPushed}, so a save() with a lower value
|
|
197
|
+
* than the current watermark is silently ignored. This keeps a
|
|
198
|
+
* SyncEngine + LocalChangelog mixed-write path safe.
|
|
199
|
+
*
|
|
200
|
+
* Non-monotonic fields:
|
|
201
|
+
* - `lastSyncAt`, `syncStatus`, `deviceId` are written as-is. The
|
|
202
|
+
* state machine (`idle → syncing → active → idle` etc.) and the
|
|
203
|
+
* `last_sync_at` clock have valid backwards transitions in some
|
|
204
|
+
* edge cases (test reset, manual rollback) and we must not block
|
|
205
|
+
* them.
|
|
206
|
+
*
|
|
207
|
+
* Unknown fields are caught at compile time by `Partial<AppState>`.
|
|
208
|
+
* Defense-in-depth: at runtime we iterate the explicit list of fields
|
|
209
|
+
* we know how to serialise rather than `Object.keys(update)`.
|
|
210
|
+
*/
|
|
211
|
+
save(update: Partial<AppState>): Promise<void>;
|
|
212
|
+
/** Plain INSERT OR REPLACE for non-monotonic keys. */
|
|
213
|
+
private writeKey;
|
|
214
|
+
/**
|
|
215
|
+
* Monotonic INSERT OR REPLACE for integer keys. Mirror of the helper in
|
|
216
|
+
* {@link LocalChangelog.writeSeqKeyMonotonic} so the two classes converge
|
|
217
|
+
* on the same on-disk representation regardless of which one performs
|
|
218
|
+
* the write.
|
|
219
|
+
*/
|
|
220
|
+
private writeKeyMonotonic;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { AppState, DEVICE_ID_FORMAT_RE, SYNC_STATE_KEYS, SyncStateStore, SyncStateStoreOptions, SyncStatus, defaultAppState, generateDesktopDeviceId, isValidDeviceId, parseSyncStatus, serializeSyncStatus };
|
|
224
|
+
//# sourceMappingURL=sync-state.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-state.d.cts","names":[],"sources":["../src/sync-state.ts"],"mappings":";;;;;;AAwCA;;;;;;;;;;;AAcA;;;;;;;;;;;;AAcA;;;;;AAoBA;;;;;;KAhDY,UAAA;EACN,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;EAAe,OAAA;AAAA;;;;;;AAoDrB;;;UA1CiB,QAAA;EAgDf;EA9CA,QAAA;EAgDA;EA9CA,QAAA;EA8CK;EA5CL,QAAA;EA6DiC;EA3DjC,UAAA;EA2D0C;EAzD1C,UAAA,EAAY,UAAA;AAAA;;iBAIE,eAAA,CAAA,GAAmB,QAAA;;;AA2FnC;;;;;AAGA;;;cA1Ea,eAAA;EAAA;;;;;;;;;;;;;;;;;;;;;UAQI,qBAAA;EAoFG;;;;;EA9ElB,MAAA,EANoC,eAAA,CAMH,MAAA;EA4GzB;EA1GR,KAAA;AAAA;;;;;;;;;;;;;;;iBAiBc,mBAAA,CAAoB,MAAA,EAAQ,UAAA;;;;;;iBAkB5B,eAAA,CAAgB,GAAA,WAAc,UAAA;;;;;;;;;;;cAoBjC,mBAAA,EAAmB,MAAA;;iBAGhB,eAAA,CAAgB,QAAA;;;;;;iBAShB,uBAAA,CAAwB,IAAA;AAAA,cAK3B,cAAA;EAAA,iBACM,MAAA;EAAA,iBACA,KAAA;cAEL,IAAA,EAAM,qBAAA;;;;;;;;SAeL,WAAA,CAAY,MAAA,EAfc,eAAA,CAemB,MAAA,GAAS,OAAA;;;;;;;UAe3D,MAAA;;;;;;;;;;;;;;;EAqBF,IAAA,CAAA,GAAQ,OAAA,CAAQ,QAAA;;;;;;;;;;;;;;;;;;;;;;;EA2EhB,IAAA,CAAK,MAAA,EAAQ,OAAA,CAAQ,QAAA,IAAY,OAAA;;UA4BzB,QAAA;;;;;;;UAcA,iBAAA;AAAA"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as _libsql_client2 from "@libsql/client";
|
|
2
|
+
|
|
3
|
+
//#region src/sync-state.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* SyncStateStore — Phase 3 Task 3.5 (G7)
|
|
6
|
+
*
|
|
7
|
+
* Typed key-value façade over the `sync_state` table introduced by
|
|
8
|
+
* Task 3.4. Where {@link LocalChangelog} owns the bare minimum of the
|
|
9
|
+
* `{scope}:local_seq` and `{scope}:cloud_seq` keys for changelog GC,
|
|
10
|
+
* SyncStateStore exposes the FULL set of progress fields the local
|
|
11
|
+
* SyncEngine needs:
|
|
12
|
+
*
|
|
13
|
+
* - device_id (per-user, NOT scope-prefixed)
|
|
14
|
+
* - {scope}:local_seq
|
|
15
|
+
* - {scope}:cloud_seq
|
|
16
|
+
* - {scope}:last_sync_at
|
|
17
|
+
* - {scope}:sync_status
|
|
18
|
+
*
|
|
19
|
+
* The class is intentionally a sibling of LocalChangelog rather than a
|
|
20
|
+
* refactor of it. Both operate on the same SQLite `sync_state` table and
|
|
21
|
+
* share monotonic semantics for `local_seq` / `cloud_seq`; cross-class
|
|
22
|
+
* parity is asserted by tests so the SyncEngine can mix the two without
|
|
23
|
+
* surprises. Refactoring LocalChangelog into a thin wrapper around
|
|
24
|
+
* SyncStateStore is a future optimisation that Task 3.6 (SyncEngine) can
|
|
25
|
+
* decide to make if it becomes ergonomic.
|
|
26
|
+
*
|
|
27
|
+
* Platform notes:
|
|
28
|
+
* - TypeScript / desktop: device_id is stored ONLY in this SQLite table.
|
|
29
|
+
* There is no Keychain equivalent on desktop, so the file IS the SoT.
|
|
30
|
+
* - Swift / iOS: Keychain is the SoT; this SQLite cache is rebuilt
|
|
31
|
+
* on startup.
|
|
32
|
+
* - Kotlin / Android: AndroidKeystore + EncryptedSharedPreferences is
|
|
33
|
+
* the SoT; SQLite is again the cache.
|
|
34
|
+
*
|
|
35
|
+
* The two mobile runtimes implement their own SyncStateStore + DeviceIDStore
|
|
36
|
+
* pair under `swift/Sources/AFSDIDSpace/` and
|
|
37
|
+
* `kotlin/afs-didspace/.../io/aigne/afs/didspace/`. The TypeScript class
|
|
38
|
+
* here matches their public surface as closely as the language allows.
|
|
39
|
+
*/
|
|
40
|
+
/** Discriminated union shape of `sync_status`. */
|
|
41
|
+
type SyncStatus = {
|
|
42
|
+
kind: "idle";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "syncing";
|
|
45
|
+
} | {
|
|
46
|
+
kind: "active";
|
|
47
|
+
} | {
|
|
48
|
+
kind: "error";
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Full snapshot of the per-scope sync state. Returned by {@link SyncStateStore.load}.
|
|
53
|
+
*
|
|
54
|
+
* `deviceId` is per-USER-DID (stable across all scopes for the same install)
|
|
55
|
+
* and is therefore stored under the bare key `device_id` — NOT scope-prefixed.
|
|
56
|
+
* Every other field is scope-prefixed internally so multiple scopes sharing
|
|
57
|
+
* the same SQLite file stay isolated.
|
|
58
|
+
*/
|
|
59
|
+
interface AppState {
|
|
60
|
+
/** Stable device identifier. Generated on first load() if missing. */
|
|
61
|
+
deviceId: string;
|
|
62
|
+
/** Highest changelog.seq pulled+applied from other devices. */
|
|
63
|
+
cloudSeq: number;
|
|
64
|
+
/** Highest changelog.seq this device has pushed to cloud. */
|
|
65
|
+
localSeq: number;
|
|
66
|
+
/** Unix millis of the last successful sync round (any leg). */
|
|
67
|
+
lastSyncAt: number;
|
|
68
|
+
/** Current sync state machine value. */
|
|
69
|
+
syncStatus: SyncStatus;
|
|
70
|
+
}
|
|
71
|
+
/** Default `AppState` returned by load() when nothing is persisted yet. */
|
|
72
|
+
declare function defaultAppState(): AppState;
|
|
73
|
+
/**
|
|
74
|
+
* Registry of the raw `sync_state` keys this class manages. Exported so
|
|
75
|
+
* tests and the eventual SyncEngine can introspect the wire format without
|
|
76
|
+
* hard-coding strings.
|
|
77
|
+
*
|
|
78
|
+
* Keys marked `scoped` are written as `{scope}:{name}`. The `device_id`
|
|
79
|
+
* key is unique among the registry — it is per-user and intentionally NOT
|
|
80
|
+
* scope-prefixed so a single device sharing two DID Space scopes still
|
|
81
|
+
* presents the same identity to both.
|
|
82
|
+
*/
|
|
83
|
+
declare const SYNC_STATE_KEYS: {
|
|
84
|
+
readonly deviceId: {
|
|
85
|
+
readonly name: "device_id";
|
|
86
|
+
readonly scoped: false;
|
|
87
|
+
};
|
|
88
|
+
readonly localSeq: {
|
|
89
|
+
readonly name: "local_seq";
|
|
90
|
+
readonly scoped: true;
|
|
91
|
+
};
|
|
92
|
+
readonly cloudSeq: {
|
|
93
|
+
readonly name: "cloud_seq";
|
|
94
|
+
readonly scoped: true;
|
|
95
|
+
};
|
|
96
|
+
readonly lastSyncAt: {
|
|
97
|
+
readonly name: "last_sync_at";
|
|
98
|
+
readonly scoped: true;
|
|
99
|
+
};
|
|
100
|
+
readonly syncStatus: {
|
|
101
|
+
readonly name: "sync_status";
|
|
102
|
+
readonly scoped: true;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
interface SyncStateStoreOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Already-opened libsql client sharing the same DB file as the TreeIndex.
|
|
108
|
+
* SyncStateStore does NOT own the client lifecycle — callers (typically
|
|
109
|
+
* `DIDSpaceProvider` construction) remain responsible for close().
|
|
110
|
+
*/
|
|
111
|
+
client: _libsql_client2.Client;
|
|
112
|
+
/** Scope string used to prefix per-scope keys. Must be non-empty. */
|
|
113
|
+
scope: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Serialise a {@link SyncStatus} to its on-disk string form.
|
|
117
|
+
*
|
|
118
|
+
* Format (matches the spec acceptance criteria):
|
|
119
|
+
* - `idle` → `"idle"`
|
|
120
|
+
* - `syncing` → `"syncing"`
|
|
121
|
+
* - `active` → `"active"`
|
|
122
|
+
* - `error:{message}` → `"error:{message}"`
|
|
123
|
+
*
|
|
124
|
+
* The `error` branch preserves the full message verbatim. Newlines and
|
|
125
|
+
* colons inside the message are tolerated; parsing is greedy on the prefix
|
|
126
|
+
* `error:` so the remainder of the string is the message regardless of
|
|
127
|
+
* what punctuation it contains.
|
|
128
|
+
*/
|
|
129
|
+
declare function serializeSyncStatus(status: SyncStatus): string;
|
|
130
|
+
/**
|
|
131
|
+
* Parse a `sync_status` string back into a {@link SyncStatus}. Throws on
|
|
132
|
+
* unrecognised forms — this matches LocalChangelog's "corrupt value =
|
|
133
|
+
* surface the bug" stance from Task 3.4.
|
|
134
|
+
*/
|
|
135
|
+
declare function parseSyncStatus(raw: string): SyncStatus;
|
|
136
|
+
/**
|
|
137
|
+
* Strict device_id format regex. Must match the server-side validator in
|
|
138
|
+
* `services/arc-computer/src/handlers/validate-headers.ts` so locally
|
|
139
|
+
* generated identifiers round-trip through the cloud sync endpoints
|
|
140
|
+
* unchanged. Format: `<class>:<platform>:<suffix>`.
|
|
141
|
+
*
|
|
142
|
+
* Duplicated locally so this module has zero cross-package imports — the
|
|
143
|
+
* source of truth lives in `validate-headers.ts` and any change there must
|
|
144
|
+
* be mirrored here AND in the Swift/Kotlin equivalents.
|
|
145
|
+
*/
|
|
146
|
+
declare const DEVICE_ID_FORMAT_RE: RegExp;
|
|
147
|
+
/** Validate a device_id string. Returns true on match. */
|
|
148
|
+
declare function isValidDeviceId(deviceId: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Generate a fresh device_id for the current TypeScript desktop runtime.
|
|
151
|
+
* Format: `desktop:ts:<uuid v4>`. Tests can pass an injected UUID to
|
|
152
|
+
* keep generation deterministic.
|
|
153
|
+
*/
|
|
154
|
+
declare function generateDesktopDeviceId(uuid?: string): string;
|
|
155
|
+
declare class SyncStateStore {
|
|
156
|
+
private readonly client;
|
|
157
|
+
private readonly scope;
|
|
158
|
+
constructor(opts: SyncStateStoreOptions);
|
|
159
|
+
/**
|
|
160
|
+
* Idempotently create the `sync_state` table. MetadataDB.open() and the
|
|
161
|
+
* Swift/Kotlin SQLiteTreeIndex.migrate() already create it; this static
|
|
162
|
+
* helper exists for test fixtures that build a SyncStateStore on a raw
|
|
163
|
+
* libsql client. Reuses the canonical DDL from `changelog-schema.ts` so
|
|
164
|
+
* three-runtime parity is preserved.
|
|
165
|
+
*/
|
|
166
|
+
static ensureTable(client: _libsql_client2.Client): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Build the on-disk key for a given AppState field. Per-scope fields
|
|
169
|
+
* are prefixed with `{scope}:`; the per-user `device_id` field is the
|
|
170
|
+
* raw bare name. Exposed as a private helper (rather than inlined) so
|
|
171
|
+
* the parity tests can introspect the rule via SYNC_STATE_KEYS.
|
|
172
|
+
*/
|
|
173
|
+
private keyFor;
|
|
174
|
+
/**
|
|
175
|
+
* Read the full {@link AppState} for this scope. Missing fields fall
|
|
176
|
+
* back to the defaults from {@link defaultAppState}.
|
|
177
|
+
*
|
|
178
|
+
* If `device_id` is absent, this method generates a fresh one using
|
|
179
|
+
* {@link generateDesktopDeviceId} and persists it back to the same
|
|
180
|
+
* SQLite cache before returning. Subsequent loads will see the same
|
|
181
|
+
* value (this is the "TS desktop has no Keychain — file IS the SoT"
|
|
182
|
+
* branch from the spec).
|
|
183
|
+
*
|
|
184
|
+
* Corrupt values throw — corrupt `cloud_seq` / `local_seq` / `last_sync_at`
|
|
185
|
+
* non-numeric, corrupt `sync_status` not in the recognised set, corrupt
|
|
186
|
+
* `device_id` failing the strict regex.
|
|
187
|
+
*/
|
|
188
|
+
load(): Promise<AppState>;
|
|
189
|
+
/**
|
|
190
|
+
* Persist a partial update to the {@link AppState}. Each field is
|
|
191
|
+
* written via INSERT OR REPLACE on its individual key; concurrent
|
|
192
|
+
* save() calls touching disjoint fields cannot lose data.
|
|
193
|
+
*
|
|
194
|
+
* Monotonic fields:
|
|
195
|
+
* - `cloudSeq` and `localSeq` use the same CASE expression as
|
|
196
|
+
* {@link LocalChangelog.markPushed}, so a save() with a lower value
|
|
197
|
+
* than the current watermark is silently ignored. This keeps a
|
|
198
|
+
* SyncEngine + LocalChangelog mixed-write path safe.
|
|
199
|
+
*
|
|
200
|
+
* Non-monotonic fields:
|
|
201
|
+
* - `lastSyncAt`, `syncStatus`, `deviceId` are written as-is. The
|
|
202
|
+
* state machine (`idle → syncing → active → idle` etc.) and the
|
|
203
|
+
* `last_sync_at` clock have valid backwards transitions in some
|
|
204
|
+
* edge cases (test reset, manual rollback) and we must not block
|
|
205
|
+
* them.
|
|
206
|
+
*
|
|
207
|
+
* Unknown fields are caught at compile time by `Partial<AppState>`.
|
|
208
|
+
* Defense-in-depth: at runtime we iterate the explicit list of fields
|
|
209
|
+
* we know how to serialise rather than `Object.keys(update)`.
|
|
210
|
+
*/
|
|
211
|
+
save(update: Partial<AppState>): Promise<void>;
|
|
212
|
+
/** Plain INSERT OR REPLACE for non-monotonic keys. */
|
|
213
|
+
private writeKey;
|
|
214
|
+
/**
|
|
215
|
+
* Monotonic INSERT OR REPLACE for integer keys. Mirror of the helper in
|
|
216
|
+
* {@link LocalChangelog.writeSeqKeyMonotonic} so the two classes converge
|
|
217
|
+
* on the same on-disk representation regardless of which one performs
|
|
218
|
+
* the write.
|
|
219
|
+
*/
|
|
220
|
+
private writeKeyMonotonic;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { AppState, DEVICE_ID_FORMAT_RE, SYNC_STATE_KEYS, SyncStateStore, SyncStateStoreOptions, SyncStatus, defaultAppState, generateDesktopDeviceId, isValidDeviceId, parseSyncStatus, serializeSyncStatus };
|
|
224
|
+
//# sourceMappingURL=sync-state.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-state.d.mts","names":[],"sources":["../src/sync-state.ts"],"mappings":";;;;;;AAwCA;;;;;;;;;;;AAcA;;;;;;;;;;;;AAcA;;;;;AAoBA;;;;;;KAhDY,UAAA;EACN,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;EAAe,OAAA;AAAA;;;;;;AAoDrB;;;UA1CiB,QAAA;EAgDf;EA9CA,QAAA;EAgDA;EA9CA,QAAA;EA8CK;EA5CL,QAAA;EA6DiC;EA3DjC,UAAA;EA2D0C;EAzD1C,UAAA,EAAY,UAAA;AAAA;;iBAIE,eAAA,CAAA,GAAmB,QAAA;;;AA2FnC;;;;;AAGA;;;cA1Ea,eAAA;EAAA;;;;;;;;;;;;;;;;;;;;;UAQI,qBAAA;EAoFG;;;;;EA9ElB,MAAA,EANoC,eAAA,CAMH,MAAA;EA4GzB;EA1GR,KAAA;AAAA;;;;;;;;;;;;;;;iBAiBc,mBAAA,CAAoB,MAAA,EAAQ,UAAA;;;;;;iBAkB5B,eAAA,CAAgB,GAAA,WAAc,UAAA;;;;;;;;;;;cAoBjC,mBAAA,EAAmB,MAAA;;iBAGhB,eAAA,CAAgB,QAAA;;;;;;iBAShB,uBAAA,CAAwB,IAAA;AAAA,cAK3B,cAAA;EAAA,iBACM,MAAA;EAAA,iBACA,KAAA;cAEL,IAAA,EAAM,qBAAA;;;;;;;;SAeL,WAAA,CAAY,MAAA,EAfc,eAAA,CAemB,MAAA,GAAS,OAAA;;;;;;;UAe3D,MAAA;;;;;;;;;;;;;;;EAqBF,IAAA,CAAA,GAAQ,OAAA,CAAQ,QAAA;;;;;;;;;;;;;;;;;;;;;;;EA2EhB,IAAA,CAAK,MAAA,EAAQ,OAAA,CAAQ,QAAA,IAAY,OAAA;;UA4BzB,QAAA;;;;;;;UAcA,iBAAA;AAAA"}
|