@opendatalabs/personal-server-ts-core 1.37.0 → 1.38.1
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/contracts/host-contract.json +115 -0
- package/contracts/raw-end.json +2360 -0
- package/contracts/replace-conformance.json +729 -0
- package/contracts/routes.json +349 -0
- package/contracts/run-finish-plan.json +3238 -0
- package/contracts/run-saved.json +1308 -0
- package/contracts/scope-delete-receipt.json +616 -0
- package/dist/api/account-storage-mode.d.ts +77 -0
- package/dist/api/account-storage-mode.d.ts.map +1 -0
- package/dist/api/account-storage-mode.js +72 -0
- package/dist/api/account-storage-mode.js.map +1 -0
- package/dist/api/index.d.ts +139 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +973 -191
- package/dist/api/index.js.map +1 -1
- package/dist/api/legacy-write-gate.d.ts +51 -0
- package/dist/api/legacy-write-gate.d.ts.map +1 -0
- package/dist/api/legacy-write-gate.js +88 -0
- package/dist/api/legacy-write-gate.js.map +1 -0
- package/dist/api/owner-connector-delete.d.ts +103 -0
- package/dist/api/owner-connector-delete.d.ts.map +1 -0
- package/dist/api/owner-connector-delete.js +158 -0
- package/dist/api/owner-connector-delete.js.map +1 -0
- package/dist/api/pdpp-record-query.d.ts +25 -0
- package/dist/api/pdpp-record-query.d.ts.map +1 -0
- package/dist/api/pdpp-record-query.js +72 -0
- package/dist/api/pdpp-record-query.js.map +1 -0
- package/dist/api/pdpp-records-list.d.ts +133 -0
- package/dist/api/pdpp-records-list.d.ts.map +1 -0
- package/dist/api/pdpp-records-list.js +380 -0
- package/dist/api/pdpp-records-list.js.map +1 -0
- package/dist/api/scope-delete-verdict.d.ts +107 -0
- package/dist/api/scope-delete-verdict.d.ts.map +1 -0
- package/dist/api/scope-delete-verdict.js +92 -0
- package/dist/api/scope-delete-verdict.js.map +1 -0
- package/dist/api/switched-delete-refusal.d.ts +16 -0
- package/dist/api/switched-delete-refusal.d.ts.map +1 -0
- package/dist/api/switched-delete-refusal.js +30 -0
- package/dist/api/switched-delete-refusal.js.map +1 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +34 -2
- package/dist/client.js.map +1 -1
- package/dist/contracts/access-logs.d.ts +1 -0
- package/dist/contracts/access-logs.d.ts.map +1 -1
- package/dist/contracts/access-logs.js +7 -1
- package/dist/contracts/access-logs.js.map +1 -1
- package/dist/contracts/data.d.ts +12 -0
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +30 -1
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +9 -0
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/sync.d.ts +9 -1
- package/dist/contracts/sync.d.ts.map +1 -1
- package/dist/contracts/sync.js +6 -2
- package/dist/contracts/sync.js.map +1 -1
- package/dist/derivatives/compute.d.ts.map +1 -1
- package/dist/derivatives/compute.js +19 -0
- package/dist/derivatives/compute.js.map +1 -1
- package/dist/encoding/base64url.d.ts +6 -0
- package/dist/encoding/base64url.d.ts.map +1 -0
- package/dist/encoding/base64url.js +29 -0
- package/dist/encoding/base64url.js.map +1 -0
- package/dist/errors/pdpp-catalog.d.ts +1 -1
- package/dist/errors/pdpp-catalog.d.ts.map +1 -1
- package/dist/errors/pdpp-catalog.js +6 -0
- package/dist/errors/pdpp-catalog.js.map +1 -1
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -0
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/owner-master-key.d.ts +37 -0
- package/dist/keys/owner-master-key.d.ts.map +1 -0
- package/dist/keys/owner-master-key.js +45 -0
- package/dist/keys/owner-master-key.js.map +1 -0
- package/dist/legacy-projection/bindings.d.ts.map +1 -1
- package/dist/legacy-projection/bindings.js +10 -4
- package/dist/legacy-projection/bindings.js.map +1 -1
- package/dist/legacy-projection/erase-connector.d.ts +18 -0
- package/dist/legacy-projection/erase-connector.d.ts.map +1 -0
- package/dist/legacy-projection/erase-connector.js +29 -0
- package/dist/legacy-projection/erase-connector.js.map +1 -0
- package/dist/legacy-projection/index.d.ts +17 -0
- package/dist/legacy-projection/index.d.ts.map +1 -1
- package/dist/legacy-projection/index.js +41 -0
- package/dist/legacy-projection/index.js.map +1 -1
- package/dist/legacy-projection/types.d.ts +12 -2
- package/dist/legacy-projection/types.d.ts.map +1 -1
- package/dist/lineage/gateway.d.ts +3 -1
- package/dist/lineage/gateway.d.ts.map +1 -1
- package/dist/lineage/gateway.js +2 -1
- package/dist/lineage/gateway.js.map +1 -1
- package/dist/localdb/admit.d.ts +138 -0
- package/dist/localdb/admit.d.ts.map +1 -0
- package/dist/localdb/admit.js +344 -0
- package/dist/localdb/admit.js.map +1 -0
- package/dist/localdb/apply-meter.d.ts +14 -0
- package/dist/localdb/apply-meter.d.ts.map +1 -0
- package/dist/localdb/apply-meter.js +31 -0
- package/dist/localdb/apply-meter.js.map +1 -0
- package/dist/localdb/apply-progress.d.ts +10 -0
- package/dist/localdb/apply-progress.d.ts.map +1 -0
- package/dist/localdb/apply-progress.js +39 -0
- package/dist/localdb/apply-progress.js.map +1 -0
- package/dist/localdb/apply.d.ts +17 -0
- package/dist/localdb/apply.d.ts.map +1 -0
- package/dist/localdb/apply.js +291 -0
- package/dist/localdb/apply.js.map +1 -0
- package/dist/localdb/batch-commit.d.ts +70 -0
- package/dist/localdb/batch-commit.d.ts.map +1 -0
- package/dist/localdb/batch-commit.js +91 -0
- package/dist/localdb/batch-commit.js.map +1 -0
- package/dist/localdb/batch-contract.d.ts +19 -0
- package/dist/localdb/batch-contract.d.ts.map +1 -0
- package/dist/localdb/batch-contract.js +24 -0
- package/dist/localdb/batch-contract.js.map +1 -0
- package/dist/localdb/blobs.d.ts +71 -0
- package/dist/localdb/blobs.d.ts.map +1 -0
- package/dist/localdb/blobs.js +306 -0
- package/dist/localdb/blobs.js.map +1 -0
- package/dist/localdb/bootstrap-copy.d.ts +6 -0
- package/dist/localdb/bootstrap-copy.d.ts.map +1 -0
- package/dist/localdb/bootstrap-copy.js +79 -0
- package/dist/localdb/bootstrap-copy.js.map +1 -0
- package/dist/localdb/bootstrap-keys.d.ts +33 -0
- package/dist/localdb/bootstrap-keys.d.ts.map +1 -0
- package/dist/localdb/bootstrap-keys.js +89 -0
- package/dist/localdb/bootstrap-keys.js.map +1 -0
- package/dist/localdb/bootstrap-swap.d.ts +17 -0
- package/dist/localdb/bootstrap-swap.d.ts.map +1 -0
- package/dist/localdb/bootstrap-swap.js +78 -0
- package/dist/localdb/bootstrap-swap.js.map +1 -0
- package/dist/localdb/bootstrap.d.ts +55 -0
- package/dist/localdb/bootstrap.d.ts.map +1 -0
- package/dist/localdb/bootstrap.js +195 -0
- package/dist/localdb/bootstrap.js.map +1 -0
- package/dist/localdb/complete-read.d.ts +77 -0
- package/dist/localdb/complete-read.d.ts.map +1 -0
- package/dist/localdb/complete-read.js +136 -0
- package/dist/localdb/complete-read.js.map +1 -0
- package/dist/localdb/connection-link.d.ts +12 -0
- package/dist/localdb/connection-link.d.ts.map +1 -0
- package/dist/localdb/connection-link.js +79 -0
- package/dist/localdb/connection-link.js.map +1 -0
- package/dist/localdb/cursor.d.ts +61 -0
- package/dist/localdb/cursor.d.ts.map +1 -0
- package/dist/localdb/cursor.js +178 -0
- package/dist/localdb/cursor.js.map +1 -0
- package/dist/localdb/cycle.d.ts +69 -0
- package/dist/localdb/cycle.d.ts.map +1 -0
- package/dist/localdb/cycle.js +189 -0
- package/dist/localdb/cycle.js.map +1 -0
- package/dist/localdb/delete-batch.d.ts +29 -0
- package/dist/localdb/delete-batch.d.ts.map +1 -0
- package/dist/localdb/delete-batch.js +84 -0
- package/dist/localdb/delete-batch.js.map +1 -0
- package/dist/localdb/delete-lifetime.d.ts +24 -0
- package/dist/localdb/delete-lifetime.d.ts.map +1 -0
- package/dist/localdb/delete-lifetime.js +83 -0
- package/dist/localdb/delete-lifetime.js.map +1 -0
- package/dist/localdb/delete.d.ts +88 -0
- package/dist/localdb/delete.d.ts.map +1 -0
- package/dist/localdb/delete.js +521 -0
- package/dist/localdb/delete.js.map +1 -0
- package/dist/localdb/delta-apply.d.ts +4 -0
- package/dist/localdb/delta-apply.d.ts.map +1 -0
- package/dist/localdb/delta-apply.js +253 -0
- package/dist/localdb/delta-apply.js.map +1 -0
- package/dist/localdb/deps.d.ts +87 -0
- package/dist/localdb/deps.d.ts.map +1 -0
- package/dist/localdb/deps.js +10 -0
- package/dist/localdb/deps.js.map +1 -0
- package/dist/localdb/driver.d.ts +51 -0
- package/dist/localdb/driver.d.ts.map +1 -0
- package/dist/localdb/driver.js +3 -0
- package/dist/localdb/driver.js.map +1 -0
- package/dist/localdb/fence.d.ts +31 -0
- package/dist/localdb/fence.d.ts.map +1 -0
- package/dist/localdb/fence.js +69 -0
- package/dist/localdb/fence.js.map +1 -0
- package/dist/localdb/history.d.ts +76 -0
- package/dist/localdb/history.d.ts.map +1 -0
- package/dist/localdb/history.js +256 -0
- package/dist/localdb/history.js.map +1 -0
- package/dist/localdb/import-fingerprint.d.ts +8 -0
- package/dist/localdb/import-fingerprint.d.ts.map +1 -0
- package/dist/localdb/import-fingerprint.js +35 -0
- package/dist/localdb/import-fingerprint.js.map +1 -0
- package/dist/localdb/import-ledger.d.ts +27 -0
- package/dist/localdb/import-ledger.d.ts.map +1 -0
- package/dist/localdb/import-ledger.js +197 -0
- package/dist/localdb/import-ledger.js.map +1 -0
- package/dist/localdb/import-readback.d.ts +8 -0
- package/dist/localdb/import-readback.d.ts.map +1 -0
- package/dist/localdb/import-readback.js +69 -0
- package/dist/localdb/import-readback.js.map +1 -0
- package/dist/localdb/import-snapshot.d.ts +21 -0
- package/dist/localdb/import-snapshot.d.ts.map +1 -0
- package/dist/localdb/import-snapshot.js +94 -0
- package/dist/localdb/import-snapshot.js.map +1 -0
- package/dist/localdb/index.d.ts +42 -0
- package/dist/localdb/index.d.ts.map +1 -0
- package/dist/localdb/index.js +40 -0
- package/dist/localdb/index.js.map +1 -0
- package/dist/localdb/legacy-import-types.d.ts +112 -0
- package/dist/localdb/legacy-import-types.d.ts.map +1 -0
- package/dist/localdb/legacy-import-types.js +2 -0
- package/dist/localdb/legacy-import-types.js.map +1 -0
- package/dist/localdb/legacy-import.d.ts +67 -0
- package/dist/localdb/legacy-import.d.ts.map +1 -0
- package/dist/localdb/legacy-import.js +320 -0
- package/dist/localdb/legacy-import.js.map +1 -0
- package/dist/localdb/legacy-retire.d.ts +26 -0
- package/dist/localdb/legacy-retire.d.ts.map +1 -0
- package/dist/localdb/legacy-retire.js +93 -0
- package/dist/localdb/legacy-retire.js.map +1 -0
- package/dist/localdb/lifetime.d.ts +29 -0
- package/dist/localdb/lifetime.d.ts.map +1 -0
- package/dist/localdb/lifetime.js +64 -0
- package/dist/localdb/lifetime.js.map +1 -0
- package/dist/localdb/listing.d.ts +70 -0
- package/dist/localdb/listing.d.ts.map +1 -0
- package/dist/localdb/listing.js +345 -0
- package/dist/localdb/listing.js.map +1 -0
- package/dist/localdb/log-apply.d.ts +46 -0
- package/dist/localdb/log-apply.d.ts.map +1 -0
- package/dist/localdb/log-apply.js +827 -0
- package/dist/localdb/log-apply.js.map +1 -0
- package/dist/localdb/log-batch.d.ts +204 -0
- package/dist/localdb/log-batch.d.ts.map +1 -0
- package/dist/localdb/log-batch.js +418 -0
- package/dist/localdb/log-batch.js.map +1 -0
- package/dist/localdb/log-bodies.d.ts +27 -0
- package/dist/localdb/log-bodies.d.ts.map +1 -0
- package/dist/localdb/log-bodies.js +142 -0
- package/dist/localdb/log-bodies.js.map +1 -0
- package/dist/localdb/log-bootstrap-stage.d.ts +5 -0
- package/dist/localdb/log-bootstrap-stage.d.ts.map +1 -0
- package/dist/localdb/log-bootstrap-stage.js +60 -0
- package/dist/localdb/log-bootstrap-stage.js.map +1 -0
- package/dist/localdb/log-bootstrap.d.ts +23 -0
- package/dist/localdb/log-bootstrap.d.ts.map +1 -0
- package/dist/localdb/log-bootstrap.js +399 -0
- package/dist/localdb/log-bootstrap.js.map +1 -0
- package/dist/localdb/log-compact.d.ts +28 -0
- package/dist/localdb/log-compact.d.ts.map +1 -0
- package/dist/localdb/log-compact.js +83 -0
- package/dist/localdb/log-compact.js.map +1 -0
- package/dist/localdb/log-keyed.d.ts +118 -0
- package/dist/localdb/log-keyed.d.ts.map +1 -0
- package/dist/localdb/log-keyed.js +640 -0
- package/dist/localdb/log-keyed.js.map +1 -0
- package/dist/localdb/log-progressive.d.ts +18 -0
- package/dist/localdb/log-progressive.d.ts.map +1 -0
- package/dist/localdb/log-progressive.js +58 -0
- package/dist/localdb/log-progressive.js.map +1 -0
- package/dist/localdb/log-publish-phases.d.ts +31 -0
- package/dist/localdb/log-publish-phases.d.ts.map +1 -0
- package/dist/localdb/log-publish-phases.js +40 -0
- package/dist/localdb/log-publish-phases.js.map +1 -0
- package/dist/localdb/log-publish.d.ts +16 -0
- package/dist/localdb/log-publish.d.ts.map +1 -0
- package/dist/localdb/log-publish.js +1745 -0
- package/dist/localdb/log-publish.js.map +1 -0
- package/dist/localdb/log-rebase.d.ts +12 -0
- package/dist/localdb/log-rebase.d.ts.map +1 -0
- package/dist/localdb/log-rebase.js +74 -0
- package/dist/localdb/log-rebase.js.map +1 -0
- package/dist/localdb/log-recommit.d.ts +15 -0
- package/dist/localdb/log-recommit.d.ts.map +1 -0
- package/dist/localdb/log-recommit.js +88 -0
- package/dist/localdb/log-recommit.js.map +1 -0
- package/dist/localdb/log-seed.d.ts +25 -0
- package/dist/localdb/log-seed.d.ts.map +1 -0
- package/dist/localdb/log-seed.js +129 -0
- package/dist/localdb/log-seed.js.map +1 -0
- package/dist/localdb/log-state.d.ts +34 -0
- package/dist/localdb/log-state.d.ts.map +1 -0
- package/dist/localdb/log-state.js +79 -0
- package/dist/localdb/log-state.js.map +1 -0
- package/dist/localdb/merge.d.ts +122 -0
- package/dist/localdb/merge.d.ts.map +1 -0
- package/dist/localdb/merge.js +339 -0
- package/dist/localdb/merge.js.map +1 -0
- package/dist/localdb/migrate.d.ts +10 -0
- package/dist/localdb/migrate.d.ts.map +1 -0
- package/dist/localdb/migrate.js +27 -0
- package/dist/localdb/migrate.js.map +1 -0
- package/dist/localdb/name.d.ts +10 -0
- package/dist/localdb/name.d.ts.map +1 -0
- package/dist/localdb/name.js +15 -0
- package/dist/localdb/name.js.map +1 -0
- package/dist/localdb/open.d.ts +33 -0
- package/dist/localdb/open.d.ts.map +1 -0
- package/dist/localdb/open.js +46 -0
- package/dist/localdb/open.js.map +1 -0
- package/dist/localdb/part-layout.d.ts +6 -0
- package/dist/localdb/part-layout.d.ts.map +1 -0
- package/dist/localdb/part-layout.js +6 -0
- package/dist/localdb/part-layout.js.map +1 -0
- package/dist/localdb/part-readahead.d.ts +87 -0
- package/dist/localdb/part-readahead.d.ts.map +1 -0
- package/dist/localdb/part-readahead.js +130 -0
- package/dist/localdb/part-readahead.js.map +1 -0
- package/dist/localdb/partial-load.d.ts +42 -0
- package/dist/localdb/partial-load.d.ts.map +1 -0
- package/dist/localdb/partial-load.js +120 -0
- package/dist/localdb/partial-load.js.map +1 -0
- package/dist/localdb/partial-read.d.ts +64 -0
- package/dist/localdb/partial-read.d.ts.map +1 -0
- package/dist/localdb/partial-read.js +110 -0
- package/dist/localdb/partial-read.js.map +1 -0
- package/dist/localdb/plan-inputs.d.ts +31 -0
- package/dist/localdb/plan-inputs.d.ts.map +1 -0
- package/dist/localdb/plan-inputs.js +26 -0
- package/dist/localdb/plan-inputs.js.map +1 -0
- package/dist/localdb/publication-work.d.ts +20 -0
- package/dist/localdb/publication-work.d.ts.map +1 -0
- package/dist/localdb/publication-work.js +60 -0
- package/dist/localdb/publication-work.js.map +1 -0
- package/dist/localdb/publish-meter.d.ts +32 -0
- package/dist/localdb/publish-meter.d.ts.map +1 -0
- package/dist/localdb/publish-meter.js +36 -0
- package/dist/localdb/publish-meter.js.map +1 -0
- package/dist/localdb/publish.d.ts +153 -0
- package/dist/localdb/publish.d.ts.map +1 -0
- package/dist/localdb/publish.js +329 -0
- package/dist/localdb/publish.js.map +1 -0
- package/dist/localdb/purge.d.ts +40 -0
- package/dist/localdb/purge.d.ts.map +1 -0
- package/dist/localdb/purge.js +159 -0
- package/dist/localdb/purge.js.map +1 -0
- package/dist/localdb/query.d.ts +77 -0
- package/dist/localdb/query.d.ts.map +1 -0
- package/dist/localdb/query.js +330 -0
- package/dist/localdb/query.js.map +1 -0
- package/dist/localdb/queue.d.ts +10 -0
- package/dist/localdb/queue.d.ts.map +1 -0
- package/dist/localdb/queue.js +31 -0
- package/dist/localdb/queue.js.map +1 -0
- package/dist/localdb/raw-end-evidence.d.ts +16 -0
- package/dist/localdb/raw-end-evidence.d.ts.map +1 -0
- package/dist/localdb/raw-end-evidence.js +27 -0
- package/dist/localdb/raw-end-evidence.js.map +1 -0
- package/dist/localdb/read-selection.d.ts +182 -0
- package/dist/localdb/read-selection.d.ts.map +1 -0
- package/dist/localdb/read-selection.js +290 -0
- package/dist/localdb/read-selection.js.map +1 -0
- package/dist/localdb/registered-read.d.ts +15 -0
- package/dist/localdb/registered-read.d.ts.map +1 -0
- package/dist/localdb/registered-read.js +62 -0
- package/dist/localdb/registered-read.js.map +1 -0
- package/dist/localdb/replace.d.ts +33 -0
- package/dist/localdb/replace.d.ts.map +1 -0
- package/dist/localdb/replace.js +22 -0
- package/dist/localdb/replace.js.map +1 -0
- package/dist/localdb/requirements.d.ts +35 -0
- package/dist/localdb/requirements.d.ts.map +1 -0
- package/dist/localdb/requirements.js +66 -0
- package/dist/localdb/requirements.js.map +1 -0
- package/dist/localdb/resolve.d.ts +69 -0
- package/dist/localdb/resolve.d.ts.map +1 -0
- package/dist/localdb/resolve.js +436 -0
- package/dist/localdb/resolve.js.map +1 -0
- package/dist/localdb/run-end.d.ts +35 -0
- package/dist/localdb/run-end.d.ts.map +1 -0
- package/dist/localdb/run-end.js +520 -0
- package/dist/localdb/run-end.js.map +1 -0
- package/dist/localdb/run-intake.d.ts +17 -0
- package/dist/localdb/run-intake.d.ts.map +1 -0
- package/dist/localdb/run-intake.js +662 -0
- package/dist/localdb/run-intake.js.map +1 -0
- package/dist/localdb/run-receipts.d.ts +19 -0
- package/dist/localdb/run-receipts.d.ts.map +1 -0
- package/dist/localdb/run-receipts.js +151 -0
- package/dist/localdb/run-receipts.js.map +1 -0
- package/dist/localdb/schema.d.ts +7 -0
- package/dist/localdb/schema.d.ts.map +1 -0
- package/dist/localdb/schema.js +686 -0
- package/dist/localdb/schema.js.map +1 -0
- package/dist/localdb/seed.d.ts +39 -0
- package/dist/localdb/seed.d.ts.map +1 -0
- package/dist/localdb/seed.js +188 -0
- package/dist/localdb/seed.js.map +1 -0
- package/dist/localdb/slot.d.ts +9 -0
- package/dist/localdb/slot.d.ts.map +1 -0
- package/dist/localdb/slot.js +15 -0
- package/dist/localdb/slot.js.map +1 -0
- package/dist/localdb/stream-digest.d.ts +35 -0
- package/dist/localdb/stream-digest.d.ts.map +1 -0
- package/dist/localdb/stream-digest.js +50 -0
- package/dist/localdb/stream-digest.js.map +1 -0
- package/dist/localdb/sync.d.ts +75 -0
- package/dist/localdb/sync.d.ts.map +1 -0
- package/dist/localdb/sync.js +339 -0
- package/dist/localdb/sync.js.map +1 -0
- package/dist/localdb/system-stream-descriptor.d.ts +22 -0
- package/dist/localdb/system-stream-descriptor.d.ts.map +1 -0
- package/dist/localdb/system-stream-descriptor.js +24 -0
- package/dist/localdb/system-stream-descriptor.js.map +1 -0
- package/dist/localdb/system-stream-page.d.ts +15 -0
- package/dist/localdb/system-stream-page.d.ts.map +1 -0
- package/dist/localdb/system-stream-page.js +98 -0
- package/dist/localdb/system-stream-page.js.map +1 -0
- package/dist/localdb/system-streams.d.ts +35 -0
- package/dist/localdb/system-streams.d.ts.map +1 -0
- package/dist/localdb/system-streams.js +350 -0
- package/dist/localdb/system-streams.js.map +1 -0
- package/dist/localdb/transfer-memory.d.ts +17 -0
- package/dist/localdb/transfer-memory.d.ts.map +1 -0
- package/dist/localdb/transfer-memory.js +17 -0
- package/dist/localdb/transfer-memory.js.map +1 -0
- package/dist/localdb/unwrite.d.ts +28 -0
- package/dist/localdb/unwrite.d.ts.map +1 -0
- package/dist/localdb/unwrite.js +62 -0
- package/dist/localdb/unwrite.js.map +1 -0
- package/dist/localdb/update-required.d.ts +10 -0
- package/dist/localdb/update-required.d.ts.map +1 -0
- package/dist/localdb/update-required.js +27 -0
- package/dist/localdb/update-required.js.map +1 -0
- package/dist/localdb/view-changes.d.ts +58 -0
- package/dist/localdb/view-changes.d.ts.map +1 -0
- package/dist/localdb/view-changes.js +174 -0
- package/dist/localdb/view-changes.js.map +1 -0
- package/dist/logging/access-log.d.ts +2 -2
- package/dist/logging/access-log.d.ts.map +1 -1
- package/dist/logging/access-reader.d.ts +4 -1
- package/dist/logging/access-reader.d.ts.map +1 -1
- package/dist/logging/activity-stream.d.ts +37 -0
- package/dist/logging/activity-stream.d.ts.map +1 -0
- package/dist/logging/activity-stream.js +86 -0
- package/dist/logging/activity-stream.js.map +1 -0
- package/dist/mcp/approval-url.d.ts +32 -0
- package/dist/mcp/approval-url.d.ts.map +1 -1
- package/dist/mcp/approval-url.js +76 -0
- package/dist/mcp/approval-url.js.map +1 -1
- package/dist/mcp/connection-api.d.ts +54 -27
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +267 -77
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/grant-registration.d.ts +15 -0
- package/dist/mcp/grant-registration.d.ts.map +1 -0
- package/dist/mcp/grant-registration.js +44 -0
- package/dist/mcp/grant-registration.js.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/read-client.d.ts +32 -10
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +299 -15
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts +3 -1
- package/dist/mcp/resources.d.ts.map +1 -1
- package/dist/mcp/resources.js +11 -2
- package/dist/mcp/resources.js.map +1 -1
- package/dist/mcp/server.d.ts +17 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +54 -7
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +2 -0
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +41 -8
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/store.d.ts +14 -1
- package/dist/mcp/store.d.ts.map +1 -1
- package/dist/mcp/store.js +31 -2
- package/dist/mcp/store.js.map +1 -1
- package/dist/mcp/tools.d.ts +62 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +186 -64
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +3 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/oura/index.d.ts +1 -1
- package/dist/oura/index.d.ts.map +1 -1
- package/dist/oura/index.js +15 -0
- package/dist/oura/index.js.map +1 -1
- package/dist/payment/x402.d.ts +6 -3
- package/dist/payment/x402.d.ts.map +1 -1
- package/dist/payment/x402.js +35 -0
- package/dist/payment/x402.js.map +1 -1
- package/dist/pdpp/pkce.d.ts +1 -22
- package/dist/pdpp/pkce.d.ts.map +1 -1
- package/dist/pdpp/pkce.js +3 -2
- package/dist/pdpp/pkce.js.map +1 -1
- package/dist/policy/reserved-scopes.d.ts +3 -0
- package/dist/policy/reserved-scopes.d.ts.map +1 -1
- package/dist/policy/reserved-scopes.js +12 -1
- package/dist/policy/reserved-scopes.js.map +1 -1
- package/dist/ports/index.d.ts +61 -9
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js.map +1 -1
- package/dist/publication/publish.d.ts +31 -1
- package/dist/publication/publish.d.ts.map +1 -1
- package/dist/publication/publish.js +30 -14
- package/dist/publication/publish.js.map +1 -1
- package/dist/replication/copies.d.ts +1 -1
- package/dist/replication/dpv2.d.ts.map +1 -1
- package/dist/replication/dpv2.js +33 -0
- package/dist/replication/dpv2.js.map +1 -1
- package/dist/schemas/server-config.d.ts +16 -0
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +49 -0
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +12 -2
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/interface.js.map +1 -1
- package/dist/storage/adapters/rate-limit-policy.d.ts +71 -0
- package/dist/storage/adapters/rate-limit-policy.d.ts.map +1 -0
- package/dist/storage/adapters/rate-limit-policy.js +107 -0
- package/dist/storage/adapters/rate-limit-policy.js.map +1 -0
- package/dist/storage/adapters/sdk.d.ts +7 -0
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +12 -6
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/throttle.d.ts +30 -0
- package/dist/storage/adapters/throttle.d.ts.map +1 -0
- package/dist/storage/adapters/throttle.js +94 -0
- package/dist/storage/adapters/throttle.js.map +1 -0
- package/dist/storage/adapters/vana-audience.d.ts +4 -1
- package/dist/storage/adapters/vana-audience.d.ts.map +1 -1
- package/dist/storage/adapters/vana-audience.js +23 -11
- package/dist/storage/adapters/vana-audience.js.map +1 -1
- package/dist/storage/adapters/vana.d.ts +5 -0
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +82 -18
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/blocks/cursor.d.ts.map +1 -1
- package/dist/storage/blocks/cursor.js +3 -13
- package/dist/storage/blocks/cursor.js.map +1 -1
- package/dist/storage/canonical-legacy-projection.d.ts +13 -1
- package/dist/storage/canonical-legacy-projection.d.ts.map +1 -1
- package/dist/storage/canonical-legacy-projection.js +92 -24
- package/dist/storage/canonical-legacy-projection.js.map +1 -1
- package/dist/storage/hierarchy/paths.d.ts.map +1 -1
- package/dist/storage/hierarchy/paths.js +9 -2
- package/dist/storage/hierarchy/paths.js.map +1 -1
- package/dist/storage/index/manager.d.ts +19 -5
- package/dist/storage/index/manager.d.ts.map +1 -1
- package/dist/storage/legacy-scope-view.d.ts +4 -6
- package/dist/storage/legacy-scope-view.d.ts.map +1 -1
- package/dist/storage/legacy-scope-view.js +50 -57
- package/dist/storage/legacy-scope-view.js.map +1 -1
- package/dist/storage/legacy-write-seal.d.ts +73 -0
- package/dist/storage/legacy-write-seal.d.ts.map +1 -0
- package/dist/storage/legacy-write-seal.js +74 -0
- package/dist/storage/legacy-write-seal.js.map +1 -0
- package/dist/storage/pdpp-records/cursor.d.ts.map +1 -1
- package/dist/storage/pdpp-records/cursor.js +3 -29
- package/dist/storage/pdpp-records/cursor.js.map +1 -1
- package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -1
- package/dist/storage/pdpp-records/declaration-witness.js +4 -3
- package/dist/storage/pdpp-records/declaration-witness.js.map +1 -1
- package/dist/storage/pdpp-records/types.d.ts +2 -0
- package/dist/storage/pdpp-records/types.d.ts.map +1 -1
- package/dist/storage/pdpp-records/types.js.map +1 -1
- package/dist/stream-sync/artifacts.d.ts +38 -0
- package/dist/stream-sync/artifacts.d.ts.map +1 -0
- package/dist/stream-sync/artifacts.js +179 -0
- package/dist/stream-sync/artifacts.js.map +1 -0
- package/dist/stream-sync/blobs.d.ts +18 -0
- package/dist/stream-sync/blobs.d.ts.map +1 -0
- package/dist/stream-sync/blobs.js +83 -0
- package/dist/stream-sync/blobs.js.map +1 -0
- package/dist/stream-sync/crypto-port.d.ts +30 -0
- package/dist/stream-sync/crypto-port.d.ts.map +1 -0
- package/dist/stream-sync/crypto-port.js +29 -0
- package/dist/stream-sync/crypto-port.js.map +1 -0
- package/dist/stream-sync/crypto.d.ts +27 -0
- package/dist/stream-sync/crypto.d.ts.map +1 -0
- package/dist/stream-sync/crypto.js +67 -0
- package/dist/stream-sync/crypto.js.map +1 -0
- package/dist/stream-sync/delete-metadata.d.ts +23 -0
- package/dist/stream-sync/delete-metadata.d.ts.map +1 -0
- package/dist/stream-sync/delete-metadata.js +40 -0
- package/dist/stream-sync/delete-metadata.js.map +1 -0
- package/dist/stream-sync/design-flags.d.ts +31 -0
- package/dist/stream-sync/design-flags.d.ts.map +1 -0
- package/dist/stream-sync/design-flags.js +44 -0
- package/dist/stream-sync/design-flags.js.map +1 -0
- package/dist/stream-sync/host-contract.d.ts +50 -0
- package/dist/stream-sync/host-contract.d.ts.map +1 -0
- package/dist/stream-sync/host-contract.js +80 -0
- package/dist/stream-sync/host-contract.js.map +1 -0
- package/dist/stream-sync/index.d.ts +19 -0
- package/dist/stream-sync/index.d.ts.map +1 -0
- package/dist/stream-sync/index.js +19 -0
- package/dist/stream-sync/index.js.map +1 -0
- package/dist/stream-sync/intake.d.ts +319 -0
- package/dist/stream-sync/intake.d.ts.map +1 -0
- package/dist/stream-sync/intake.js +62 -0
- package/dist/stream-sync/intake.js.map +1 -0
- package/dist/stream-sync/memory-registry.d.ts +85 -0
- package/dist/stream-sync/memory-registry.d.ts.map +1 -0
- package/dist/stream-sync/memory-registry.js +293 -0
- package/dist/stream-sync/memory-registry.js.map +1 -0
- package/dist/stream-sync/normalize-raw-end.d.ts +25 -0
- package/dist/stream-sync/normalize-raw-end.d.ts.map +1 -0
- package/dist/stream-sync/normalize-raw-end.js +177 -0
- package/dist/stream-sync/normalize-raw-end.js.map +1 -0
- package/dist/stream-sync/ports.d.ts +486 -0
- package/dist/stream-sync/ports.d.ts.map +1 -0
- package/dist/stream-sync/ports.js +91 -0
- package/dist/stream-sync/ports.js.map +1 -0
- package/dist/stream-sync/publish-plan.d.ts +129 -0
- package/dist/stream-sync/publish-plan.d.ts.map +1 -0
- package/dist/stream-sync/publish-plan.js +134 -0
- package/dist/stream-sync/publish-plan.js.map +1 -0
- package/dist/stream-sync/raw-end.d.ts +59 -0
- package/dist/stream-sync/raw-end.d.ts.map +1 -0
- package/dist/stream-sync/raw-end.js +113 -0
- package/dist/stream-sync/raw-end.js.map +1 -0
- package/dist/stream-sync/registry.d.ts +31 -0
- package/dist/stream-sync/registry.d.ts.map +1 -0
- package/dist/stream-sync/registry.js +645 -0
- package/dist/stream-sync/registry.js.map +1 -0
- package/dist/stream-sync/run-finish-plan.d.ts +61 -0
- package/dist/stream-sync/run-finish-plan.d.ts.map +1 -0
- package/dist/stream-sync/run-finish-plan.js +373 -0
- package/dist/stream-sync/run-finish-plan.js.map +1 -0
- package/dist/stream-sync/run-saved.d.ts +51 -0
- package/dist/stream-sync/run-saved.d.ts.map +1 -0
- package/dist/stream-sync/run-saved.js +83 -0
- package/dist/stream-sync/run-saved.js.map +1 -0
- package/dist/stream-sync/scope-routing.d.ts +17 -0
- package/dist/stream-sync/scope-routing.d.ts.map +1 -0
- package/dist/stream-sync/scope-routing.js +24 -0
- package/dist/stream-sync/scope-routing.js.map +1 -0
- package/dist/stream-sync/seed-staging.d.ts +85 -0
- package/dist/stream-sync/seed-staging.d.ts.map +1 -0
- package/dist/stream-sync/seed-staging.js +325 -0
- package/dist/stream-sync/seed-staging.js.map +1 -0
- package/dist/stream-sync/semver.d.ts +3 -0
- package/dist/stream-sync/semver.d.ts.map +1 -0
- package/dist/stream-sync/semver.js +49 -0
- package/dist/stream-sync/semver.js.map +1 -0
- package/dist/stream-sync/send-gate.d.ts +149 -0
- package/dist/stream-sync/send-gate.d.ts.map +1 -0
- package/dist/stream-sync/send-gate.js +382 -0
- package/dist/stream-sync/send-gate.js.map +1 -0
- package/dist/stream-sync/storage-retry.d.ts +216 -0
- package/dist/stream-sync/storage-retry.d.ts.map +1 -0
- package/dist/stream-sync/storage-retry.js +315 -0
- package/dist/stream-sync/storage-retry.js.map +1 -0
- package/dist/stream-sync/stream-aead.d.ts +33 -0
- package/dist/stream-sync/stream-aead.d.ts.map +1 -0
- package/dist/stream-sync/stream-aead.js +183 -0
- package/dist/stream-sync/stream-aead.js.map +1 -0
- package/dist/stream-sync/timer.d.ts +3 -0
- package/dist/stream-sync/timer.d.ts.map +1 -0
- package/dist/stream-sync/timer.js +3 -0
- package/dist/stream-sync/timer.js.map +1 -0
- package/dist/stream-sync-read/index.d.ts +4 -0
- package/dist/stream-sync-read/index.d.ts.map +1 -0
- package/dist/stream-sync-read/index.js +3 -0
- package/dist/stream-sync-read/index.js.map +1 -0
- package/dist/stream-sync-read/routing.d.ts +27 -0
- package/dist/stream-sync-read/routing.d.ts.map +1 -0
- package/dist/stream-sync-read/routing.js +49 -0
- package/dist/stream-sync-read/routing.js.map +1 -0
- package/dist/stream-sync-read/service.d.ts +281 -0
- package/dist/stream-sync-read/service.d.ts.map +1 -0
- package/dist/stream-sync-read/service.js +18 -0
- package/dist/stream-sync-read/service.js.map +1 -0
- package/dist/sync/account-mode/authority.d.ts +121 -0
- package/dist/sync/account-mode/authority.d.ts.map +1 -0
- package/dist/sync/account-mode/authority.js +446 -0
- package/dist/sync/account-mode/authority.js.map +1 -0
- package/dist/sync/account-mode/evidence-wire.d.ts +42 -0
- package/dist/sync/account-mode/evidence-wire.d.ts.map +1 -0
- package/dist/sync/account-mode/evidence-wire.js +76 -0
- package/dist/sync/account-mode/evidence-wire.js.map +1 -0
- package/dist/sync/account-mode/import-waker.d.ts +36 -0
- package/dist/sync/account-mode/import-waker.d.ts.map +1 -0
- package/dist/sync/account-mode/import-waker.js +55 -0
- package/dist/sync/account-mode/import-waker.js.map +1 -0
- package/dist/sync/account-mode/index.d.ts +10 -0
- package/dist/sync/account-mode/index.d.ts.map +1 -0
- package/dist/sync/account-mode/index.js +10 -0
- package/dist/sync/account-mode/index.js.map +1 -0
- package/dist/sync/account-mode/port.d.ts +11 -0
- package/dist/sync/account-mode/port.d.ts.map +1 -0
- package/dist/sync/account-mode/port.js +21 -0
- package/dist/sync/account-mode/port.js.map +1 -0
- package/dist/sync/account-mode/record.d.ts +54 -0
- package/dist/sync/account-mode/record.d.ts.map +1 -0
- package/dist/sync/account-mode/record.js +62 -0
- package/dist/sync/account-mode/record.js.map +1 -0
- package/dist/sync/account-mode/rw-lock.d.ts +14 -0
- package/dist/sync/account-mode/rw-lock.d.ts.map +1 -0
- package/dist/sync/account-mode/rw-lock.js +59 -0
- package/dist/sync/account-mode/rw-lock.js.map +1 -0
- package/dist/sync/cancellable-gateway.d.ts +25 -0
- package/dist/sync/cancellable-gateway.d.ts.map +1 -0
- package/dist/sync/cancellable-gateway.js +64 -0
- package/dist/sync/cancellable-gateway.js.map +1 -0
- package/dist/sync/engine/change-probe.d.ts +49 -0
- package/dist/sync/engine/change-probe.d.ts.map +1 -0
- package/dist/sync/engine/change-probe.js +84 -0
- package/dist/sync/engine/change-probe.js.map +1 -0
- package/dist/sync/engine/change-push.d.ts +56 -0
- package/dist/sync/engine/change-push.d.ts.map +1 -0
- package/dist/sync/engine/change-push.js +176 -0
- package/dist/sync/engine/change-push.js.map +1 -0
- package/dist/sync/engine/sync-manager.d.ts +208 -1
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +1005 -34
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +6 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +5 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/pdpp-import.d.ts +12 -2
- package/dist/sync/pdpp-import.d.ts.map +1 -1
- package/dist/sync/pdpp-import.js +32 -7
- package/dist/sync/pdpp-import.js.map +1 -1
- package/dist/sync/tombstone-resubmits.d.ts +7 -4
- package/dist/sync/tombstone-resubmits.d.ts.map +1 -1
- package/dist/sync/tombstone-resubmits.js.map +1 -1
- package/dist/sync/types.d.ts +29 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/upload-attempts.d.ts +244 -0
- package/dist/sync/upload-attempts.d.ts.map +1 -0
- package/dist/sync/upload-attempts.js +548 -0
- package/dist/sync/upload-attempts.js.map +1 -0
- package/dist/sync/upload-state.d.ts +163 -0
- package/dist/sync/upload-state.d.ts.map +1 -0
- package/dist/sync/upload-state.js +239 -0
- package/dist/sync/upload-state.js.map +1 -0
- package/dist/sync/workers/delete.d.ts +33 -1
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +83 -11
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts +3 -0
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +67 -12
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/upload.d.ts +70 -2
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +354 -23
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-support/memory-oracle.calibration.d.ts +16 -0
- package/dist/test-support/memory-oracle.calibration.d.ts.map +1 -0
- package/dist/test-support/memory-oracle.calibration.js +43 -0
- package/dist/test-support/memory-oracle.calibration.js.map +1 -0
- package/dist/test-support/memory-oracle.d.ts +82 -0
- package/dist/test-support/memory-oracle.d.ts.map +1 -0
- package/dist/test-support/memory-oracle.js +104 -0
- package/dist/test-support/memory-oracle.js.map +1 -0
- package/dist/test-utils/account-mode.d.ts +36 -0
- package/dist/test-utils/account-mode.d.ts.map +1 -0
- package/dist/test-utils/account-mode.js +78 -0
- package/dist/test-utils/account-mode.js.map +1 -0
- package/dist/test-utils/index.d.ts +3 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +3 -0
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/legacy-write-seal.d.ts +16 -0
- package/dist/test-utils/legacy-write-seal.d.ts.map +1 -0
- package/dist/test-utils/legacy-write-seal.js +20 -0
- package/dist/test-utils/legacy-write-seal.js.map +1 -0
- package/dist/test-utils/live-grants.d.ts +24 -0
- package/dist/test-utils/live-grants.d.ts.map +1 -0
- package/dist/test-utils/live-grants.js +6 -0
- package/dist/test-utils/live-grants.js.map +1 -0
- package/dist/test-utils/memory-storage.d.ts +17 -1
- package/dist/test-utils/memory-storage.d.ts.map +1 -1
- package/dist/test-utils/memory-storage.js +94 -46
- package/dist/test-utils/memory-storage.js.map +1 -1
- package/dist/test-utils/run-end.d.ts +27 -0
- package/dist/test-utils/run-end.d.ts.map +1 -0
- package/dist/test-utils/run-end.js +44 -0
- package/dist/test-utils/run-end.js.map +1 -0
- package/dist/test-utils/wallet.d.ts +0 -4
- package/dist/test-utils/wallet.d.ts.map +1 -1
- package/dist/test-utils/wallet.js +3 -12
- package/dist/test-utils/wallet.js.map +1 -1
- package/dist/write/attribution.d.ts.map +1 -1
- package/dist/write/attribution.js +2 -4
- package/dist/write/attribution.js.map +1 -1
- package/dist-test/localdb/conformance.d.ts +13 -0
- package/dist-test/localdb/conformance.d.ts.map +1 -0
- package/dist-test/localdb/conformance.js +372 -0
- package/dist-test/localdb/conformance.js.map +1 -0
- package/dist-test/tsconfig.tsbuildinfo +1 -0
- package/package.json +60 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const quote = (name) => `"${name.replaceAll('"', '""')}"`;
|
|
2
|
+
/** Refuse a swap if another schema object could be redirected or broken. */
|
|
3
|
+
export async function bootstrapSchema(db, checkReferences = true) {
|
|
4
|
+
const tables = await db.query("SELECT name,sql FROM sqlite_master WHERE type='table'");
|
|
5
|
+
const records = tables.find((t) => t.name === "records");
|
|
6
|
+
if (!records)
|
|
7
|
+
throw new Error("bootstrap: records table missing");
|
|
8
|
+
if (checkReferences)
|
|
9
|
+
for (const table of tables) {
|
|
10
|
+
const refs = await db.query(`PRAGMA foreign_key_list(${quote(table.name)})`);
|
|
11
|
+
if (refs.some((ref) => ref.table === "records"))
|
|
12
|
+
throw new Error("bootstrap: external records foreign key");
|
|
13
|
+
}
|
|
14
|
+
if (checkReferences)
|
|
15
|
+
for (const schema of ["sqlite_master", "sqlite_temp_master"]) {
|
|
16
|
+
const objects = await db.query(`SELECT name,tbl_name,sql FROM ${schema} WHERE type IN ('trigger','view')`);
|
|
17
|
+
if (objects.some((o) => o.tbl_name !== "records" && /\brecords\b/i.test(o.sql)))
|
|
18
|
+
throw new Error("bootstrap: external records view or trigger");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
table: `CREATE TABLE bootstrap_records ${records.sql.slice(records.sql.indexOf("("))}`,
|
|
22
|
+
indexes: await db.query("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='records' AND sql IS NOT NULL"),
|
|
23
|
+
triggers: await db.query("SELECT name,sql FROM sqlite_master WHERE type='trigger' AND tbl_name='records'"),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** No body copy: replace the preview, then build indexes from their exact SQL. */
|
|
27
|
+
export function swapBootstrapRecords(schema, connectionId) {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
sql: `INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
31
|
+
SELECT r.connection_id,r.stream,r.pk_hash,r.record_key,'remove',r.stamp_o,r.stamp_r,'remote'
|
|
32
|
+
FROM records r WHERE r.connection_id=? AND NOT EXISTS(SELECT 1 FROM bootstrap_records b
|
|
33
|
+
WHERE b.connection_id=r.connection_id AND b.stream=r.stream AND b.pk_hash=r.pk_hash)`,
|
|
34
|
+
params: [connectionId],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
sql: `DELETE FROM blob_refs WHERE connection_id=? AND NOT EXISTS(SELECT 1 FROM bootstrap_records b
|
|
38
|
+
WHERE b.connection_id=blob_refs.connection_id AND b.stream=blob_refs.stream AND b.pk_hash=blob_refs.pk_hash)`,
|
|
39
|
+
params: [connectionId],
|
|
40
|
+
},
|
|
41
|
+
// A fresh replica still owes record-level readers the newly installed keys.
|
|
42
|
+
// This sorts metadata only; neither SELECT nor ORDER BY includes the body.
|
|
43
|
+
{
|
|
44
|
+
sql: `INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
45
|
+
SELECT b.connection_id,b.stream,b.pk_hash,b.record_key,'upsert',b.stamp_o,b.stamp_r,'remote'
|
|
46
|
+
FROM bootstrap_records b WHERE NOT EXISTS(SELECT 1 FROM records r
|
|
47
|
+
WHERE r.connection_id=b.connection_id AND r.stream=b.stream AND r.pk_hash=b.pk_hash
|
|
48
|
+
AND r.body_sha256=b.body_sha256 AND r.stamp_o=b.stamp_o AND r.stamp_r=b.stamp_r AND r.stamp_n=b.stamp_n)
|
|
49
|
+
ORDER BY b.connection_id,b.stream,b.pk_hash`,
|
|
50
|
+
},
|
|
51
|
+
// The replacement table was filled without records' triggers. Preserve
|
|
52
|
+
// reserved-stream projection work in the same transaction as its swap;
|
|
53
|
+
// record_changes may be compacted before a consumer projects the bodies.
|
|
54
|
+
{
|
|
55
|
+
sql: `INSERT INTO system_stream_changes(connection_id,stream,record_id,body)
|
|
56
|
+
SELECT r.connection_id,r.stream,r.record_key,NULL FROM records r
|
|
57
|
+
WHERE r.connection_id=? AND r.connection_id GLOB 'pdpp.vana-system-*~*'
|
|
58
|
+
AND NOT EXISTS(SELECT 1 FROM bootstrap_records b WHERE b.connection_id=r.connection_id AND b.stream=r.stream AND b.pk_hash=r.pk_hash)`,
|
|
59
|
+
params: [connectionId],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
sql: `INSERT INTO system_stream_changes(connection_id,stream,record_id,body)
|
|
63
|
+
SELECT b.connection_id,b.stream,b.record_key,b.body FROM bootstrap_records b
|
|
64
|
+
WHERE b.connection_id GLOB 'pdpp.vana-system-*~*' AND NOT EXISTS(SELECT 1 FROM records r
|
|
65
|
+
WHERE r.connection_id=b.connection_id AND r.stream=b.stream AND r.pk_hash=b.pk_hash
|
|
66
|
+
AND r.body_sha256=b.body_sha256 AND r.stamp_o=b.stamp_o AND r.stamp_r=b.stamp_r AND r.stamp_n=b.stamp_n)`,
|
|
67
|
+
},
|
|
68
|
+
// DROP removes only the preview table's own triggers. Never rename it:
|
|
69
|
+
// modern SQLite would rewrite external references to the retired name.
|
|
70
|
+
{ sql: "DROP TABLE records" },
|
|
71
|
+
{ sql: "ALTER TABLE bootstrap_records RENAME TO records" },
|
|
72
|
+
// Recreate from the exact captured SQL after the rename. Creating on the
|
|
73
|
+
// temporary name first would make ALTER rewrite the index SQL text.
|
|
74
|
+
...schema.indexes.map((index) => ({ sql: index.sql })),
|
|
75
|
+
...schema.triggers.map((t) => ({ sql: t.sql })),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=bootstrap-swap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-swap.js","sourceRoot":"","sources":["../../src/localdb/bootstrap-swap.ts"],"names":[],"mappings":"AAOA,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAElE,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAa,EACb,eAAe,GAAG,IAAI;IAEtB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,KAAK,CAC3B,uDAAuD,CACxD,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClE,IAAI,eAAe;QACjB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CACzB,2BAA2B,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAChD,CAAC;YACF,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC;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E;QACvE,EAAE,GAAG,EAAE,oBAAoB,EAAE;QAC7B,EAAE,GAAG,EAAE,iDAAiD,EAAE;QAC1D,yEAAyE;QACzE,oEAAoE;QACpE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACtD,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ControlRead, type ControlHashes, type ControlState } from "@opendatalabs/personal-server-ts-stream-sync";
|
|
2
|
+
import type { ConnectionRow, LocalSyncDeps } from "./deps.js";
|
|
3
|
+
export declare function saveControl(deps: LocalSyncDeps, connector: string, ns: string, read: ControlRead, control: ControlHashes): Promise<ConnectionRow>;
|
|
4
|
+
/** Rows of one owner listing (`StreamSyncRegistry.listOwnerRows`). */
|
|
5
|
+
export type OwnerRows = readonly {
|
|
6
|
+
readonly scope: string;
|
|
7
|
+
readonly read: ControlRead;
|
|
8
|
+
}[];
|
|
9
|
+
/**
|
|
10
|
+
* C.0 step 1: list the registry's control rows and upsert one `connections`
|
|
11
|
+
* row per control scope (classification is `classifyControl`). A deleted
|
|
12
|
+
* control row whose connection still has rows, a checkpoint or this device's
|
|
13
|
+
* participation row runs the local purge (F.5).
|
|
14
|
+
* Returns the connections now known. Spec: C.0.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bootstrapConnections(deps: LocalSyncDeps,
|
|
17
|
+
/** The owner's rows, when the caller already listed them (`listOwnerRows`). */
|
|
18
|
+
listed?: OwnerRows): Promise<readonly ConnectionRow[]>;
|
|
19
|
+
/**
|
|
20
|
+
* The connections this device already knows to be active, from its own table.
|
|
21
|
+
* Reads nothing from the registry: a host that wants to publish before it
|
|
22
|
+
* learns anything uses it to name what to publish.
|
|
23
|
+
*/
|
|
24
|
+
export declare function knownActiveConnections(deps: LocalSyncDeps): Promise<readonly ConnectionRow[]>;
|
|
25
|
+
/**
|
|
26
|
+
* A connection this device has only ever seen absent, at its first generation,
|
|
27
|
+
* and that holds streams: the first save of a new connection. Its control row
|
|
28
|
+
* is the one the first publish creates, so the registry has nothing for the
|
|
29
|
+
* publish to wait for. Reads nothing from the registry.
|
|
30
|
+
*/
|
|
31
|
+
export declare function newConnectionsWithStreams(deps: LocalSyncDeps): Promise<readonly ConnectionRow[]>;
|
|
32
|
+
/** Every connection that holds streams, whatever its control state. */
|
|
33
|
+
export declare function connectionsWithStreams(deps: LocalSyncDeps): Promise<readonly ConnectionRow[]>;
|
|
34
|
+
/**
|
|
35
|
+
* C.0 step 2, inside the connection queue and before any row is staged:
|
|
36
|
+
* read the control row, then apply the connection's log up to the position
|
|
37
|
+
* the registry holds. `unreachable` = the registry did not answer (C.0
|
|
38
|
+
* step 3); a caller with no connection stages `generation_unbound`.
|
|
39
|
+
*
|
|
40
|
+
* `control` is the control row as the registry answered, classified for this
|
|
41
|
+
* owner's key (`null` when the registry did not answer). A row under another
|
|
42
|
+
* key (`foreign`) is saved like any other, which later fences (a legacy
|
|
43
|
+
* import, a seed) read; `foreign: "report"` returns it and writes nothing,
|
|
44
|
+
* for a caller that refuses the connection before any local write (`begin`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function syncBeforeBegin(deps: LocalSyncDeps, connector: string, options?: {
|
|
47
|
+
readonly foreign?: "save" | "report";
|
|
48
|
+
/** A successful reconnect write, used instead of reading control again. */
|
|
49
|
+
readonly committedControl?: ControlRead;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
readonly connection: ConnectionRow | null;
|
|
52
|
+
readonly control: ControlState | null;
|
|
53
|
+
readonly unreachable: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@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,EAAE,MAAM,GAAG,QAAQ,CAAC;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC;CACpC,GACL,OAAO,CAAC;IACT,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC,CAoED"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { classifyControl, controlHashes, controlScope, deriveKeyCheck, IDENTITYLESS_NS, parseScope, } from "@opendatalabs/personal-server-ts-stream-sync";
|
|
2
|
+
import { streamSyncHashes } from "../stream-sync/crypto.js";
|
|
3
|
+
import { RegistryUnavailableBeforeWriteError, RegistryUnavailableError, } from "../stream-sync/ports.js";
|
|
4
|
+
import { applyConnection } from "./apply.js";
|
|
5
|
+
import { installControl } from "./lifetime.js";
|
|
6
|
+
import { purgeConnection } from "./purge.js";
|
|
7
|
+
import { insideQueue } from "./slot.js";
|
|
8
|
+
import { UpdateRequiredError } from "./update-required.js";
|
|
9
|
+
// A connection id is its canonical control scope: pdpp.<connector>~<ns>.
|
|
10
|
+
function connectionId(connector, ns) {
|
|
11
|
+
return controlScope(connector, ns);
|
|
12
|
+
}
|
|
13
|
+
const SELECT_CONNECTIONS = `SELECT connection_id AS connectionId, connector, ns,
|
|
14
|
+
generation, control_state AS controlState, control_version AS controlVersion
|
|
15
|
+
FROM connections`;
|
|
16
|
+
const HAS_STREAMS = `EXISTS (SELECT 1 FROM stream_state s WHERE s.connection_id = connections.connection_id)`;
|
|
17
|
+
async function cachedConnection(deps, id) {
|
|
18
|
+
const [row] = await deps.db.query(`${SELECT_CONNECTIONS} WHERE connection_id = ?`, [id]);
|
|
19
|
+
return row ?? null;
|
|
20
|
+
}
|
|
21
|
+
async function hashes(deps) {
|
|
22
|
+
const keyCheck = await deriveKeyCheck((message) => deps.keys.namespaceHmac(message));
|
|
23
|
+
return controlHashes(streamSyncHashes.keccak256, keyCheck);
|
|
24
|
+
}
|
|
25
|
+
export async function saveControl(deps, connector, ns, read, control) {
|
|
26
|
+
const id = connectionId(connector, ns);
|
|
27
|
+
const state = classifyControl(read, control);
|
|
28
|
+
const version = read.found ? read.version : 0;
|
|
29
|
+
const generation = state.kind === "active" ? state.generation : 1;
|
|
30
|
+
await deps.db.batch([
|
|
31
|
+
{
|
|
32
|
+
sql: `INSERT OR IGNORE INTO connections
|
|
33
|
+
(connection_id, connector, ns, generation, control_state, control_version)
|
|
34
|
+
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
35
|
+
params: [id, connector, ns, generation, state.kind, version],
|
|
36
|
+
},
|
|
37
|
+
...installControl(id, state, version),
|
|
38
|
+
]);
|
|
39
|
+
return (await cachedConnection(deps, id));
|
|
40
|
+
}
|
|
41
|
+
async function partiallyApplied(deps, id) {
|
|
42
|
+
const rows = await deps.db.query("SELECT 1 FROM connections WHERE connection_id = ? AND apply_partial = 1", [id]);
|
|
43
|
+
return rows.length > 0;
|
|
44
|
+
}
|
|
45
|
+
async function purgeDeleted(deps, row) {
|
|
46
|
+
if (row.controlState !== "deleted")
|
|
47
|
+
return;
|
|
48
|
+
const present = await deps.db.query(`SELECT 1 AS present
|
|
49
|
+
WHERE EXISTS (SELECT 1 FROM records WHERE connection_id = ?)
|
|
50
|
+
OR EXISTS (SELECT 1 FROM run_rows rr JOIN runs r ON r.run_id = rr.run_id
|
|
51
|
+
WHERE r.connection_id = ?)
|
|
52
|
+
OR EXISTS (SELECT 1 FROM blob_refs WHERE connection_id = ?)
|
|
53
|
+
OR EXISTS (SELECT 1 FROM connections
|
|
54
|
+
WHERE connection_id = ? AND checkpoint IS NOT NULL)
|
|
55
|
+
OR EXISTS (SELECT 1 FROM connection_participation WHERE connection_id = ?)`, Array(5).fill(row.connectionId));
|
|
56
|
+
if (present.length > 0) {
|
|
57
|
+
await purgeConnection(deps, row.connectionId, {
|
|
58
|
+
controlVersion: row.controlVersion,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* C.0 step 1: list the registry's control rows and upsert one `connections`
|
|
64
|
+
* row per control scope (classification is `classifyControl`). A deleted
|
|
65
|
+
* control row whose connection still has rows, a checkpoint or this device's
|
|
66
|
+
* participation row runs the local purge (F.5).
|
|
67
|
+
* Returns the connections now known. Spec: C.0.
|
|
68
|
+
*/
|
|
69
|
+
export async function bootstrapConnections(deps,
|
|
70
|
+
/** The owner's rows, when the caller already listed them (`listOwnerRows`). */
|
|
71
|
+
listed) {
|
|
72
|
+
const control = await hashes(deps);
|
|
73
|
+
const rows = listed ?? (await deps.registry.listControlRows());
|
|
74
|
+
for (const row of rows) {
|
|
75
|
+
const parsed = parseScope(row.scope);
|
|
76
|
+
if (parsed?.kind !== "control")
|
|
77
|
+
continue;
|
|
78
|
+
const id = connectionId(parsed.connector, parsed.ns);
|
|
79
|
+
await deps.queue.run(id, "end", async () => {
|
|
80
|
+
const locked = insideQueue(deps, id);
|
|
81
|
+
const connection = await saveControl(locked, parsed.connector, parsed.ns, row.read, control);
|
|
82
|
+
await purgeDeleted(locked, connection);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return deps.db.query(`${SELECT_CONNECTIONS} ORDER BY connection_id`);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The connections this device already knows to be active, from its own table.
|
|
89
|
+
* Reads nothing from the registry: a host that wants to publish before it
|
|
90
|
+
* learns anything uses it to name what to publish.
|
|
91
|
+
*/
|
|
92
|
+
export async function knownActiveConnections(deps) {
|
|
93
|
+
return deps.db.query(`${SELECT_CONNECTIONS} WHERE control_state = 'active' ORDER BY connection_id`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A connection this device has only ever seen absent, at its first generation,
|
|
97
|
+
* and that holds streams: the first save of a new connection. Its control row
|
|
98
|
+
* is the one the first publish creates, so the registry has nothing for the
|
|
99
|
+
* publish to wait for. Reads nothing from the registry.
|
|
100
|
+
*/
|
|
101
|
+
export async function newConnectionsWithStreams(deps) {
|
|
102
|
+
return deps.db.query(`${SELECT_CONNECTIONS} WHERE control_state = 'absent' AND generation = 1
|
|
103
|
+
AND ${HAS_STREAMS}
|
|
104
|
+
ORDER BY connection_id`);
|
|
105
|
+
}
|
|
106
|
+
/** Every connection that holds streams, whatever its control state. */
|
|
107
|
+
export async function connectionsWithStreams(deps) {
|
|
108
|
+
return deps.db.query(`${SELECT_CONNECTIONS} WHERE ${HAS_STREAMS} ORDER BY connection_id`);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* C.0 step 2, inside the connection queue and before any row is staged:
|
|
112
|
+
* read the control row, then apply the connection's log up to the position
|
|
113
|
+
* the registry holds. `unreachable` = the registry did not answer (C.0
|
|
114
|
+
* step 3); a caller with no connection stages `generation_unbound`.
|
|
115
|
+
*
|
|
116
|
+
* `control` is the control row as the registry answered, classified for this
|
|
117
|
+
* owner's key (`null` when the registry did not answer). A row under another
|
|
118
|
+
* key (`foreign`) is saved like any other, which later fences (a legacy
|
|
119
|
+
* import, a seed) read; `foreign: "report"` returns it and writes nothing,
|
|
120
|
+
* for a caller that refuses the connection before any local write (`begin`).
|
|
121
|
+
*/
|
|
122
|
+
export async function syncBeforeBegin(deps, connector, options = {}) {
|
|
123
|
+
// The pinned intake contract has no account identity (R23).
|
|
124
|
+
const ns = IDENTITYLESS_NS;
|
|
125
|
+
const id = connectionId(connector, ns);
|
|
126
|
+
return deps.queue.run(id, "end", async () => {
|
|
127
|
+
const locked = insideQueue(deps, id);
|
|
128
|
+
const control = await hashes(locked);
|
|
129
|
+
let read;
|
|
130
|
+
try {
|
|
131
|
+
read =
|
|
132
|
+
options.committedControl ??
|
|
133
|
+
(await deps.registry.read(controlScope(connector, ns)));
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
// Only an unreachable registry goes on offline. A refusal (403), an
|
|
137
|
+
// unreadable answer or a control row of the wrong shape is not "offline".
|
|
138
|
+
if (!(error instanceof RegistryUnavailableError))
|
|
139
|
+
throw error;
|
|
140
|
+
// An earlier apply left this connection half applied. Going on offline
|
|
141
|
+
// would start a run on it, with no way to learn what it lacks.
|
|
142
|
+
if (await partiallyApplied(locked, id))
|
|
143
|
+
throw error;
|
|
144
|
+
return {
|
|
145
|
+
connection: await cachedConnection(locked, id),
|
|
146
|
+
control: null,
|
|
147
|
+
unreachable: true,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const state = classifyControl(read, control);
|
|
151
|
+
if (state.kind === "foreign" && options.foreign === "report")
|
|
152
|
+
return {
|
|
153
|
+
connection: await cachedConnection(locked, id),
|
|
154
|
+
control: state,
|
|
155
|
+
unreachable: false,
|
|
156
|
+
};
|
|
157
|
+
const connection = await saveControl(locked, connector, ns, read, control);
|
|
158
|
+
await purgeDeleted(locked, connection);
|
|
159
|
+
if (connection.controlState === "active") {
|
|
160
|
+
try {
|
|
161
|
+
// Reuse this call's control observation; apply still reads the log.
|
|
162
|
+
// Only an unreachable registry that apply met before its
|
|
163
|
+
// first local write, with no earlier apply left half done, goes on
|
|
164
|
+
// offline: nothing new was learned and nothing changed. Apply has no
|
|
165
|
+
// rollback, so an unavailable error after a write rejects, as do
|
|
166
|
+
// integrity, key and database failures.
|
|
167
|
+
await applyConnection(locked, id, undefined, read);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// A log this build cannot read stops this connection's apply, not the
|
|
171
|
+
// join: the cycle's pass for the connection applies again and reports
|
|
172
|
+
// `update_required` for it (`syncConnection`).
|
|
173
|
+
if (error instanceof UpdateRequiredError)
|
|
174
|
+
return {
|
|
175
|
+
connection: await cachedConnection(locked, id),
|
|
176
|
+
control: state,
|
|
177
|
+
unreachable: false,
|
|
178
|
+
};
|
|
179
|
+
if (!(error instanceof RegistryUnavailableBeforeWriteError))
|
|
180
|
+
throw error;
|
|
181
|
+
return {
|
|
182
|
+
connection: await cachedConnection(locked, id),
|
|
183
|
+
control: state,
|
|
184
|
+
unreachable: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
connection: await cachedConnection(locked, id),
|
|
190
|
+
control: state,
|
|
191
|
+
unreachable: false,
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/localdb/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,UAAU,GAIX,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,yEAAyE;AACzE,SAAS,YAAY,CAAC,SAAiB,EAAE,EAAU;IACjD,OAAO,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,kBAAkB,GAAG;;mBAER,CAAC;AACpB,MAAM,WAAW,GAAG,yFAAyF,CAAC;AAI9G,KAAK,UAAU,gBAAgB,CAAC,IAAmB,EAAE,EAAU;IAC7D,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAC/B,GAAG,kBAAkB,0BAA0B,EAC/C,CAAC,E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ACzD,mEAAmE;gBACnE,qEAAqE;gBACrE,iEAAiE;gBACjE,wCAAwC;gBACxC,MAAM,eAAe,CAAC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,sEAAsE;gBACtE,sEAAsE;gBACtE,+CAA+C;gBAC/C,IAAI,KAAK,YAAY,mBAAmB;oBACtC,OAAO;wBACL,UAAU,EAAE,MAAM,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;wBAC9C,OAAO,EAAE,KAAK;wBACd,WAAW,EAAE,KAAK;qBACnB,CAAC;gBACJ,IAAI,CAAC,CAAC,KAAK,YAAY,mCAAmC,CAAC;oBACzD,MAAM,KAAK,CAAC;gBACd,OAAO;oBACL,UAAU,EAAE,MAAM,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC9C,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,IAAI;iBAClB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,UAAU,EAAE,MAAM,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,KAAK;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type SqlDriver, type SqlReader } from "./driver.js";
|
|
2
|
+
import { type PartialHead } from "./partial-read.js";
|
|
3
|
+
/**
|
|
4
|
+
* Rows per page. A page is one statement on the reader, so the size trades
|
|
5
|
+
* statement overhead against how long one statement keeps the reader. 500
|
|
6
|
+
* rows read a 198k-row stream in the browser faster than the unpaged body did
|
|
7
|
+
* (3.7 s against 4.1 to 4.9 s); 100 rows were 13% slower.
|
|
8
|
+
*/
|
|
9
|
+
export declare const COMPLETE_PAGE_SIZE = 500;
|
|
10
|
+
/**
|
|
11
|
+
* Pins a stream for a body that is read a page at a time: the epoch of its
|
|
12
|
+
* change mark, taken so that any change after this returns moves the epoch.
|
|
13
|
+
*
|
|
14
|
+
* The mark (`stream_change_marks`) is written by the first change after its
|
|
15
|
+
* `dirty` flag was cleared, and that write counts a new epoch. Reading the
|
|
16
|
+
* epoch and then clearing the flag gives the guarantee: a change after the
|
|
17
|
+
* clear finds the flag clear and moves the epoch; a change between the read
|
|
18
|
+
* and the clear leaves the flag set but is already in the rows every page
|
|
19
|
+
* reads afterwards, and a pin that reads an epoch such a change moved only
|
|
20
|
+
* fails its first check, which is safe. Another reader clearing the flag
|
|
21
|
+
* later cannot hide a change from this pin: the change that set the flag
|
|
22
|
+
* moved the epoch first. A stream with no mark has epoch 0, and its first
|
|
23
|
+
* change creates the mark at epoch 1. Call it before the head is read.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pinStream(db: SqlDriver, connectionId: string, stream: string): Promise<number>;
|
|
26
|
+
/** What a stream's change mark says now (`pinStream`'s first step). */
|
|
27
|
+
export declare function readMark(db: SqlDriver, connectionId: string, stream: string): Promise<{
|
|
28
|
+
epoch: number;
|
|
29
|
+
dirty: number;
|
|
30
|
+
}>;
|
|
31
|
+
/** Clears the flag a mark was read with set, and returns its epoch (`pinStream`'s second step). */
|
|
32
|
+
export declare function clearMark(db: SqlDriver, connectionId: string, stream: string, read: {
|
|
33
|
+
epoch: number;
|
|
34
|
+
dirty: number;
|
|
35
|
+
}): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* The statement and parameters of one page of a complete body: the check, then
|
|
38
|
+
* the rows after `after` (the key hash the last page ended at; none for the
|
|
39
|
+
* first page).
|
|
40
|
+
*
|
|
41
|
+
* The rows come from their own subquery. Joined straight to the check's one
|
|
42
|
+
* row, the planner may pick an index in another order and sort the whole
|
|
43
|
+
* stream, which costs a page read per row in a browser. A subquery with a
|
|
44
|
+
* `LIMIT` is not merged into the join, so it reads the key index in order and
|
|
45
|
+
* stops after the page. SQL does not promise that the join keeps that order,
|
|
46
|
+
* and the reader takes the last row of a page as the next cursor, so the outer
|
|
47
|
+
* query sorts the page again: at most `PAGE_SIZE` rows, never the stream.
|
|
48
|
+
*
|
|
49
|
+
* The check is the rule `partialBody` applies to a head that completed: the
|
|
50
|
+
* stream's installed head (its version and data hash) is the one the read was
|
|
51
|
+
* decided on, and its connection is still active, of the same generation,
|
|
52
|
+
* with no delete intent. Both answer in the statement that reads the rows. A
|
|
53
|
+
* head that stopped being complete, or moved to another generation, has a
|
|
54
|
+
* version of its own, so the version names those too.
|
|
55
|
+
*
|
|
56
|
+
* One more clause, because of how a head replaces another. An apply writes the
|
|
57
|
+
* rows of a new head into the table in commits of its own, and moves the
|
|
58
|
+
* stream's head in its last one. For all of that time the head still names the
|
|
59
|
+
* old one, while the rows are a mix. So a complete body also needs the stream
|
|
60
|
+
* to have had no row written, changed or removed since it was pinned
|
|
61
|
+
* (`pinStream`): the epoch of the stream's change mark is still the pinned
|
|
62
|
+
* one. The mark is one primary-key row, so the check does not read what other
|
|
63
|
+
* streams and connections write meanwhile.
|
|
64
|
+
*/
|
|
65
|
+
export declare function completePage(head: PartialHead, pin: number, after: string | undefined): {
|
|
66
|
+
sql: string;
|
|
67
|
+
params: (string | number)[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The records of one stream's complete head, as the JSON body of a read, in
|
|
71
|
+
* primary-key hash order a page at a time. The body is the stream as it was
|
|
72
|
+
* when `pin` was taken or it ends in `PartialViewMoved`, which a reader
|
|
73
|
+
* answers by asking again: never a body of two states. Nothing is held between
|
|
74
|
+
* pages, so a body that is not read to its end costs nothing.
|
|
75
|
+
*/
|
|
76
|
+
export declare function completeBody(db: SqlReader, head: PartialHead, pin: number): AsyncGenerator<string>;
|
|
77
|
+
//# sourceMappingURL=complete-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete-read.d.ts","sourceRoot":"","sources":["../../src/localdb/complete-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK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|
|
3
|
+
/**
|
|
4
|
+
* Rows per page. A page is one statement on the reader, so the size trades
|
|
5
|
+
* statement overhead against how long one statement keeps the reader. 500
|
|
6
|
+
* rows read a 198k-row stream in the browser faster than the unpaged body did
|
|
7
|
+
* (3.7 s against 4.1 to 4.9 s); 100 rows were 13% slower.
|
|
8
|
+
*/
|
|
9
|
+
export const COMPLETE_PAGE_SIZE = 500;
|
|
10
|
+
const PAGE_SIZE = COMPLETE_PAGE_SIZE;
|
|
11
|
+
/**
|
|
12
|
+
* Pins a stream for a body that is read a page at a time: the epoch of its
|
|
13
|
+
* change mark, taken so that any change after this returns moves the epoch.
|
|
14
|
+
*
|
|
15
|
+
* The mark (`stream_change_marks`) is written by the first change after its
|
|
16
|
+
* `dirty` flag was cleared, and that write counts a new epoch. Reading the
|
|
17
|
+
* epoch and then clearing the flag gives the guarantee: a change after the
|
|
18
|
+
* clear finds the flag clear and moves the epoch; a change between the read
|
|
19
|
+
* and the clear leaves the flag set but is already in the rows every page
|
|
20
|
+
* reads afterwards, and a pin that reads an epoch such a change moved only
|
|
21
|
+
* fails its first check, which is safe. Another reader clearing the flag
|
|
22
|
+
* later cannot hide a change from this pin: the change that set the flag
|
|
23
|
+
* moved the epoch first. A stream with no mark has epoch 0, and its first
|
|
24
|
+
* change creates the mark at epoch 1. Call it before the head is read.
|
|
25
|
+
*/
|
|
26
|
+
export async function pinStream(db, connectionId, stream) {
|
|
27
|
+
return clearMark(db, connectionId, stream, await readMark(db, connectionId, stream));
|
|
28
|
+
}
|
|
29
|
+
/** What a stream's change mark says now (`pinStream`'s first step). */
|
|
30
|
+
export async function readMark(db, connectionId, stream) {
|
|
31
|
+
const [mark] = await readerOf(db).query("SELECT epoch, dirty FROM stream_change_marks WHERE connection_id = ? AND stream = ?", [connectionId, stream]);
|
|
32
|
+
return mark ?? { epoch: 0, dirty: 0 };
|
|
33
|
+
}
|
|
34
|
+
/** Clears the flag a mark was read with set, and returns its epoch (`pinStream`'s second step). */
|
|
35
|
+
export async function clearMark(db, connectionId, stream, read) {
|
|
36
|
+
if (read.dirty === 1) {
|
|
37
|
+
await db.batch([
|
|
38
|
+
{
|
|
39
|
+
sql: "UPDATE stream_change_marks SET dirty = 0 WHERE connection_id = ? AND stream = ?",
|
|
40
|
+
params: [connectionId, stream],
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
return read.epoch;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The statement and parameters of one page of a complete body: the check, then
|
|
48
|
+
* the rows after `after` (the key hash the last page ended at; none for the
|
|
49
|
+
* first page).
|
|
50
|
+
*
|
|
51
|
+
* The rows come from their own subquery. Joined straight to the check's one
|
|
52
|
+
* row, the planner may pick an index in another order and sort the whole
|
|
53
|
+
* stream, which costs a page read per row in a browser. A subquery with a
|
|
54
|
+
* `LIMIT` is not merged into the join, so it reads the key index in order and
|
|
55
|
+
* stops after the page. SQL does not promise that the join keeps that order,
|
|
56
|
+
* and the reader takes the last row of a page as the next cursor, so the outer
|
|
57
|
+
* query sorts the page again: at most `PAGE_SIZE` rows, never the stream.
|
|
58
|
+
*
|
|
59
|
+
* The check is the rule `partialBody` applies to a head that completed: the
|
|
60
|
+
* stream's installed head (its version and data hash) is the one the read was
|
|
61
|
+
* decided on, and its connection is still active, of the same generation,
|
|
62
|
+
* with no delete intent. Both answer in the statement that reads the rows. A
|
|
63
|
+
* head that stopped being complete, or moved to another generation, has a
|
|
64
|
+
* version of its own, so the version names those too.
|
|
65
|
+
*
|
|
66
|
+
* One more clause, because of how a head replaces another. An apply writes the
|
|
67
|
+
* rows of a new head into the table in commits of its own, and moves the
|
|
68
|
+
* stream's head in its last one. For all of that time the head still names the
|
|
69
|
+
* old one, while the rows are a mix. So a complete body also needs the stream
|
|
70
|
+
* to have had no row written, changed or removed since it was pinned
|
|
71
|
+
* (`pinStream`): the epoch of the stream's change mark is still the pinned
|
|
72
|
+
* one. The mark is one primary-key row, so the check does not read what other
|
|
73
|
+
* streams and connections write meanwhile.
|
|
74
|
+
*/
|
|
75
|
+
export function completePage(head, pin, after) {
|
|
76
|
+
return {
|
|
77
|
+
sql: `WITH g AS (SELECT (
|
|
78
|
+
EXISTS (SELECT 1 FROM stream_state s WHERE s.connection_id = ? AND s.stream = ?
|
|
79
|
+
AND s.head_version = ? AND s.head_data_hash = ?)
|
|
80
|
+
AND EXISTS (SELECT 1 FROM connections c WHERE c.connection_id = ? AND c.generation = ?
|
|
81
|
+
AND c.control_state = 'active' AND c.deleted_at IS NULL
|
|
82
|
+
AND NOT EXISTS (SELECT 1 FROM delete_intents d WHERE d.connector = c.connector))
|
|
83
|
+
AND COALESCE((SELECT m.epoch FROM stream_change_marks m
|
|
84
|
+
WHERE m.connection_id = ? AND m.stream = ?), 0) = ?) AS ok)
|
|
85
|
+
SELECT g.ok AS ok, r.pk_hash AS pk_hash, r.body AS body
|
|
86
|
+
FROM g LEFT JOIN (
|
|
87
|
+
SELECT pk_hash, body FROM records r
|
|
88
|
+
WHERE (SELECT ok FROM g) = 1 AND r.connection_id = ? AND r.stream = ?
|
|
89
|
+
${after === undefined ? "" : "AND r.pk_hash > ?"}
|
|
90
|
+
ORDER BY r.pk_hash LIMIT ?) r
|
|
91
|
+
ORDER BY r.pk_hash`,
|
|
92
|
+
params: [
|
|
93
|
+
head.connectionId,
|
|
94
|
+
head.stream,
|
|
95
|
+
head.version,
|
|
96
|
+
head.dataHash,
|
|
97
|
+
head.connectionId,
|
|
98
|
+
head.generation,
|
|
99
|
+
head.connectionId,
|
|
100
|
+
head.stream,
|
|
101
|
+
pin,
|
|
102
|
+
head.connectionId,
|
|
103
|
+
head.stream,
|
|
104
|
+
...(after === undefined ? [] : [after]),
|
|
105
|
+
PAGE_SIZE,
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The records of one stream's complete head, as the JSON body of a read, in
|
|
111
|
+
* primary-key hash order a page at a time. The body is the stream as it was
|
|
112
|
+
* when `pin` was taken or it ends in `PartialViewMoved`, which a reader
|
|
113
|
+
* answers by asking again: never a body of two states. Nothing is held between
|
|
114
|
+
* pages, so a body that is not read to its end costs nothing.
|
|
115
|
+
*/
|
|
116
|
+
export async function* completeBody(db, head, pin) {
|
|
117
|
+
yield '{"records":[';
|
|
118
|
+
let first = true;
|
|
119
|
+
let after;
|
|
120
|
+
for (;;) {
|
|
121
|
+
const { sql, params } = completePage(head, pin, after);
|
|
122
|
+
const page = await db.query(sql, params);
|
|
123
|
+
if (page[0]?.ok !== 1)
|
|
124
|
+
throw new PartialViewMoved();
|
|
125
|
+
const rows = page.filter((row) => row.pk_hash !== null);
|
|
126
|
+
for (const row of rows) {
|
|
127
|
+
yield (first ? "" : ",") + row.body;
|
|
128
|
+
first = false;
|
|
129
|
+
}
|
|
130
|
+
if (rows.length < PAGE_SIZE)
|
|
131
|
+
break;
|
|
132
|
+
after = rows[rows.length - 1].pk_hash;
|
|
133
|
+
}
|
|
134
|
+
yield "]}";
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=complete-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete-read.js","sourceRoot":"","sources":["../../src/localdb/complete-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkC,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAa,EACb,YAAoB,EACpB,MAAc;IAEd,OAAO,SAAS,CACd,EAAE,EACF,YAAY,EACZ,MAAM,EACN,MAAM,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,uEAAuE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C,CAAC,CAAC,KAAK,CAAC,CAAC;YACvC,SAAS;SACV;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CACjC,EAAa,EACb,IAAiB,EACjB,GAAW;IAEX,MAAM,cAAc,CAAC;IACrB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,KAAyB,CAAC;IAC9B,SAAS,CAAC;QACR,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAIxB,GAAG,EAAE,MAAM,CAAC,CAAC;QAChB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC;YAAE,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;QACxD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAK,CAAC;YACrC,KAAK,GAAG,KAAK,CAAC;QAChB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS;YAAE,MAAM;QACnC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,OAAQ,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SqlReader } from "./driver.js";
|
|
2
|
+
import { type RecordQuery } from "./query.js";
|
|
3
|
+
/** Host authority for one registered PDPP connection and declared stream.
|
|
4
|
+
* Null means unknown, deleted or unresolved; the database never infers a link.
|
|
5
|
+
*/
|
|
6
|
+
export type ConnectionLink = (instance: string, stream: string) => {
|
|
7
|
+
readonly connector: string;
|
|
8
|
+
readonly namespace: string;
|
|
9
|
+
} | null;
|
|
10
|
+
/** Apply the host's consent identity before querying the owner's current generation. */
|
|
11
|
+
export declare function createLinkedRecordQuery(db: SqlReader, link: ConnectionLink): RecordQuery;
|
|
12
|
+
//# sourceMappingURL=connection-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-link.d.ts","sourceRoot":"","sources":["../../src/localdb/connection-link.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,KACX;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GAAG,IAAI,CAAC;AAET,wFAAwF;AACxF,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,cAAc,GACnB,WAAW,CAmFb"}
|