@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,686 @@
|
|
|
1
|
+
/** The statement every view trigger runs: add one to the connection's counter. */
|
|
2
|
+
const bumpView = (row) => `INSERT OR REPLACE INTO view_versions(connection_id, version) VALUES (${row}.connection_id, COALESCE((SELECT version FROM view_versions WHERE connection_id = ${row}.connection_id), 0) + 1);`;
|
|
3
|
+
/**
|
|
4
|
+
* The same bump for the connections of the intent's connector that a reader
|
|
5
|
+
* can reach: every read gate is `control_state = 'active'` and no intent. An
|
|
6
|
+
* intent changes what a reader sees only for such a connection. One that is
|
|
7
|
+
* deleted, as a purge leaves it and as the resolver marks it when it meets an
|
|
8
|
+
* intent, stays unreadable whether the intent exists or not.
|
|
9
|
+
*/
|
|
10
|
+
const bumpConnector = (row) => `INSERT OR REPLACE INTO view_versions(connection_id, version) SELECT c.connection_id, COALESCE(v.version, 0) + 1 FROM connections c LEFT JOIN view_versions v ON v.connection_id = c.connection_id WHERE c.connector = ${row}.connector AND c.control_state = 'active';`;
|
|
11
|
+
/**
|
|
12
|
+
* The triggers of `records` as the migrations up to the rowid rebuild left
|
|
13
|
+
* them (`records_key_type_conflict`, `records_ai/au/ad` from migration 1,
|
|
14
|
+
* `view_records_*` from the view migration), created again by that rebuild.
|
|
15
|
+
* A conformance test checks the rebuild keeps their text.
|
|
16
|
+
*/
|
|
17
|
+
const RECORDS_TRIGGERS = [
|
|
18
|
+
`CREATE TRIGGER records_key_type_conflict BEFORE INSERT ON records
|
|
19
|
+
WHEN (SELECT origin FROM write_ctx WHERE id = 1) <> 'remote'
|
|
20
|
+
AND EXISTS (SELECT 1 FROM records x WHERE x.connection_id = NEW.connection_id
|
|
21
|
+
AND x.stream = NEW.stream AND x.record_key = NEW.record_key AND x.pk_hash <> NEW.pk_hash)
|
|
22
|
+
BEGIN SELECT RAISE(ABORT, 'key_type_conflict'); END`,
|
|
23
|
+
`CREATE TRIGGER records_ai AFTER INSERT ON records BEGIN
|
|
24
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
25
|
+
VALUES (NEW.connection_id,NEW.stream,NEW.pk_hash,NEW.record_key,'upsert',NEW.stamp_o,NEW.stamp_r,
|
|
26
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
27
|
+
END`,
|
|
28
|
+
`CREATE TRIGGER records_au AFTER UPDATE OF stamp_o, stamp_r, body_sha256 ON records BEGIN
|
|
29
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
30
|
+
VALUES (NEW.connection_id,NEW.stream,NEW.pk_hash,NEW.record_key,'upsert',NEW.stamp_o,NEW.stamp_r,
|
|
31
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
32
|
+
END`,
|
|
33
|
+
`CREATE TRIGGER records_ad AFTER DELETE ON records BEGIN
|
|
34
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
35
|
+
VALUES (OLD.connection_id,OLD.stream,OLD.pk_hash,OLD.record_key,'remove',OLD.stamp_o,OLD.stamp_r,
|
|
36
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
37
|
+
DELETE FROM blob_refs WHERE connection_id = OLD.connection_id AND stream = OLD.stream AND pk_hash = OLD.pk_hash;
|
|
38
|
+
END`,
|
|
39
|
+
`CREATE TRIGGER view_records_ai AFTER INSERT ON records BEGIN
|
|
40
|
+
${bumpView("NEW")}
|
|
41
|
+
END`,
|
|
42
|
+
`CREATE TRIGGER view_records_au AFTER UPDATE OF stamp_o, stamp_r, body_sha256, seen_o, first_o ON records
|
|
43
|
+
WHEN OLD.stamp_o IS NOT NEW.stamp_o OR OLD.stamp_r IS NOT NEW.stamp_r OR OLD.body_sha256 IS NOT NEW.body_sha256
|
|
44
|
+
OR OLD.first_o IS NOT NEW.first_o OR COALESCE(OLD.seen_o, OLD.stamp_o) IS NOT COALESCE(NEW.seen_o, NEW.stamp_o) BEGIN
|
|
45
|
+
${bumpView("NEW")}
|
|
46
|
+
END`,
|
|
47
|
+
`CREATE TRIGGER view_records_ad AFTER DELETE ON records BEGIN
|
|
48
|
+
${bumpView("OLD")}
|
|
49
|
+
END`,
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Migration 1 of the local database, taken from the SQL proof. Shared SQL keeps
|
|
53
|
+
* to SQLite 3.22: no UPSERT, RETURNING, JSON1, window functions or STRICT.
|
|
54
|
+
* Each migration is one batch; `migrate` appends `PRAGMA user_version`.
|
|
55
|
+
*/
|
|
56
|
+
export const MIGRATIONS = [
|
|
57
|
+
[
|
|
58
|
+
`CREATE TABLE db_meta (
|
|
59
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
60
|
+
owner TEXT NOT NULL, network TEXT NOT NULL, device_id TEXT NOT NULL, created_at INTEGER NOT NULL);`,
|
|
61
|
+
`CREATE TABLE write_ctx (
|
|
62
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
63
|
+
origin TEXT NOT NULL CHECK (origin IN ('local','import','remote','refresh','purge')));`,
|
|
64
|
+
`INSERT INTO write_ctx VALUES (1, 'local');`,
|
|
65
|
+
`CREATE TABLE connections (
|
|
66
|
+
connection_id TEXT PRIMARY KEY, connector TEXT NOT NULL, ns TEXT NOT NULL,
|
|
67
|
+
generation INTEGER NOT NULL DEFAULT 1,
|
|
68
|
+
control_state TEXT NOT NULL DEFAULT 'absent' CHECK (control_state IN ('absent','active','deleted','foreign')),
|
|
69
|
+
control_version INTEGER NOT NULL DEFAULT 0,
|
|
70
|
+
checkpoint TEXT, label TEXT, deleted_at INTEGER);`,
|
|
71
|
+
`CREATE TABLE records (
|
|
72
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
73
|
+
record_key TEXT NOT NULL, stamp_o INTEGER NOT NULL, stamp_r TEXT NOT NULL,
|
|
74
|
+
body TEXT NOT NULL, body_sha256 TEXT NOT NULL, first_o INTEGER,
|
|
75
|
+
PRIMARY KEY (connection_id, stream, pk_hash)) WITHOUT ROWID;`,
|
|
76
|
+
`CREATE INDEX records_by_key ON records(connection_id, stream, record_key);`,
|
|
77
|
+
`CREATE INDEX records_by_first ON records(first_o) WHERE first_o IS NOT NULL;`,
|
|
78
|
+
`CREATE TABLE record_changes (
|
|
79
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
80
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL, record_key TEXT NOT NULL,
|
|
81
|
+
op TEXT NOT NULL CHECK (op IN ('upsert','remove')),
|
|
82
|
+
stamp_o INTEGER NOT NULL, stamp_r TEXT NOT NULL,
|
|
83
|
+
origin TEXT NOT NULL);`,
|
|
84
|
+
`CREATE INDEX record_changes_by_key ON record_changes(connection_id, stream, pk_hash, seq);`,
|
|
85
|
+
`CREATE TABLE stream_state (
|
|
86
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL,
|
|
87
|
+
primary_key TEXT NOT NULL, semantics TEXT NOT NULL, incremental INTEGER NOT NULL,
|
|
88
|
+
profile_key TEXT, profile_version TEXT,
|
|
89
|
+
complete INTEGER NOT NULL DEFAULT 0, needs_full INTEGER NOT NULL DEFAULT 0,
|
|
90
|
+
floor_version TEXT, floor_o INTEGER, floor_r TEXT,
|
|
91
|
+
last_delete_version INTEGER NOT NULL DEFAULT 0,
|
|
92
|
+
head_version INTEGER NOT NULL DEFAULT 0, head_generation INTEGER, head_data_hash TEXT, head_blob TEXT,
|
|
93
|
+
publish_watermark INTEGER NOT NULL DEFAULT 0,
|
|
94
|
+
PRIMARY KEY (connection_id, stream)) WITHOUT ROWID;`,
|
|
95
|
+
`CREATE TABLE stream_versions (
|
|
96
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, version INTEGER NOT NULL,
|
|
97
|
+
generation INTEGER NOT NULL, head_blob TEXT NOT NULL, head_format INTEGER NOT NULL,
|
|
98
|
+
record_count INTEGER NOT NULL, observed_at INTEGER NOT NULL, complete INTEGER NOT NULL,
|
|
99
|
+
kind TEXT NOT NULL CHECK (kind IN ('published','applied','delete')),
|
|
100
|
+
PRIMARY KEY (connection_id, stream, version)) WITHOUT ROWID;`,
|
|
101
|
+
`CREATE TABLE runs (
|
|
102
|
+
run_id TEXT PRIMARY KEY CHECK (run_id NOT GLOB '*[^A-Za-z0-9._-]*' AND length(run_id) BETWEEN 1 AND 128),
|
|
103
|
+
connection_id TEXT NOT NULL, o INTEGER NOT NULL, generation INTEGER,
|
|
104
|
+
artifact_version TEXT NOT NULL, collection_mode TEXT NOT NULL CHECK (collection_mode IN ('full_refresh','incremental')),
|
|
105
|
+
state TEXT NOT NULL CHECK (state IN ('collecting','ended')),
|
|
106
|
+
last_batch INTEGER NOT NULL DEFAULT -1);`,
|
|
107
|
+
`CREATE TABLE run_streams (
|
|
108
|
+
run_id TEXT NOT NULL, stream TEXT NOT NULL,
|
|
109
|
+
delete_snapshot INTEGER NOT NULL,
|
|
110
|
+
basis_version INTEGER, basis_generation INTEGER, basis_data_hash TEXT,
|
|
111
|
+
primary_key TEXT, profile_key TEXT, profile_version TEXT,
|
|
112
|
+
full_read INTEGER NOT NULL DEFAULT 0, foreign_checkpoint INTEGER NOT NULL DEFAULT 0,
|
|
113
|
+
seed TEXT NOT NULL DEFAULT 'none' CHECK (seed IN ('none','merged','unresolved')),
|
|
114
|
+
replace INTEGER NOT NULL DEFAULT 0,
|
|
115
|
+
decision TEXT CHECK (decision IN ('publish','noop','refused','deferred','discarded')), reason TEXT,
|
|
116
|
+
PRIMARY KEY (run_id, stream)) WITHOUT ROWID;`,
|
|
117
|
+
`CREATE TABLE run_rows (
|
|
118
|
+
run_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL, record_key TEXT NOT NULL,
|
|
119
|
+
body TEXT NOT NULL, body_sha256 TEXT NOT NULL,
|
|
120
|
+
PRIMARY KEY (run_id, stream, pk_hash)) WITHOUT ROWID;`,
|
|
121
|
+
`CREATE TABLE blobs (
|
|
122
|
+
blob_id TEXT PRIMARY KEY, mime_type TEXT NOT NULL, size_bytes INTEGER NOT NULL,
|
|
123
|
+
generation INTEGER, bytes BLOB);`,
|
|
124
|
+
`CREATE TABLE blob_refs (
|
|
125
|
+
blob_id TEXT NOT NULL, connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
126
|
+
PRIMARY KEY (blob_id, connection_id, stream, pk_hash)) WITHOUT ROWID;`,
|
|
127
|
+
`CREATE TABLE import_ledger (
|
|
128
|
+
source TEXT NOT NULL, connection_id TEXT NOT NULL, stream TEXT NOT NULL,
|
|
129
|
+
state TEXT NOT NULL CHECK (state IN ('imported','verified','retired','excluded')),
|
|
130
|
+
rows INTEGER NOT NULL, fingerprint TEXT NOT NULL, reason TEXT, at INTEGER NOT NULL,
|
|
131
|
+
PRIMARY KEY (source, connection_id, stream)) WITHOUT ROWID;`,
|
|
132
|
+
`CREATE TABLE delete_intents (
|
|
133
|
+
connector TEXT PRIMARY KEY, delete_id TEXT NOT NULL, intent TEXT NOT NULL);`,
|
|
134
|
+
`CREATE TRIGGER records_key_type_conflict BEFORE INSERT ON records
|
|
135
|
+
WHEN (SELECT origin FROM write_ctx WHERE id = 1) <> 'remote'
|
|
136
|
+
AND EXISTS (SELECT 1 FROM records x WHERE x.connection_id = NEW.connection_id
|
|
137
|
+
AND x.stream = NEW.stream AND x.record_key = NEW.record_key AND x.pk_hash <> NEW.pk_hash)
|
|
138
|
+
BEGIN SELECT RAISE(ABORT, 'key_type_conflict'); END;`,
|
|
139
|
+
`CREATE TRIGGER records_ai AFTER INSERT ON records BEGIN
|
|
140
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
141
|
+
VALUES (NEW.connection_id,NEW.stream,NEW.pk_hash,NEW.record_key,'upsert',NEW.stamp_o,NEW.stamp_r,
|
|
142
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
143
|
+
END;`,
|
|
144
|
+
`CREATE TRIGGER records_au AFTER UPDATE OF stamp_o, stamp_r, body_sha256 ON records BEGIN
|
|
145
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
146
|
+
VALUES (NEW.connection_id,NEW.stream,NEW.pk_hash,NEW.record_key,'upsert',NEW.stamp_o,NEW.stamp_r,
|
|
147
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
148
|
+
END;`,
|
|
149
|
+
`CREATE TRIGGER records_ad AFTER DELETE ON records BEGIN
|
|
150
|
+
INSERT INTO record_changes(connection_id,stream,pk_hash,record_key,op,stamp_o,stamp_r,origin)
|
|
151
|
+
VALUES (OLD.connection_id,OLD.stream,OLD.pk_hash,OLD.record_key,'remove',OLD.stamp_o,OLD.stamp_r,
|
|
152
|
+
(SELECT origin FROM write_ctx WHERE id = 1));
|
|
153
|
+
DELETE FROM blob_refs WHERE connection_id = OLD.connection_id AND stream = OLD.stream AND pk_hash = OLD.pk_hash;
|
|
154
|
+
END;`,
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
`ALTER TABLE import_ledger ADD COLUMN revision TEXT;`,
|
|
158
|
+
`ALTER TABLE import_ledger ADD COLUMN generation INTEGER;`,
|
|
159
|
+
`ALTER TABLE import_ledger ADD COLUMN highest_seq INTEGER;`,
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
`CREATE TABLE legacy_erase_intents (
|
|
163
|
+
copy_key TEXT PRIMARY KEY, descriptor TEXT NOT NULL, at INTEGER NOT NULL
|
|
164
|
+
) WITHOUT ROWID;`,
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
// A connection can compact newer events while another retains older ones.
|
|
168
|
+
// MIN(seq) alone cannot detect those holes. Retain only the deletion floor.
|
|
169
|
+
`ALTER TABLE db_meta ADD COLUMN change_floor INTEGER NOT NULL DEFAULT 0`,
|
|
170
|
+
`UPDATE db_meta SET change_floor=COALESCE((SELECT seq FROM sqlite_sequence WHERE name='record_changes'),0)`,
|
|
171
|
+
`CREATE TRIGGER record_changes_compacted AFTER DELETE ON record_changes BEGIN
|
|
172
|
+
UPDATE db_meta SET change_floor=MAX(change_floor,OLD.seq) WHERE id=1;
|
|
173
|
+
END`,
|
|
174
|
+
],
|
|
175
|
+
[`ALTER TABLE run_streams ADD COLUMN coverage_strategy TEXT`],
|
|
176
|
+
[
|
|
177
|
+
`ALTER TABLE run_rows ADD COLUMN op TEXT NOT NULL DEFAULT 'upsert' CHECK(op IN ('upsert','delete'))`,
|
|
178
|
+
`ALTER TABLE run_streams ADD COLUMN semantics TEXT`,
|
|
179
|
+
`UPDATE run_streams SET semantics=(SELECT s.semantics FROM stream_state s JOIN runs r ON r.connection_id=s.connection_id WHERE r.run_id=run_streams.run_id AND s.stream=run_streams.stream)`,
|
|
180
|
+
`ALTER TABLE record_changes ADD COLUMN explicit_delete INTEGER NOT NULL DEFAULT 0`,
|
|
181
|
+
],
|
|
182
|
+
[
|
|
183
|
+
`ALTER TABLE runs ADD COLUMN begin_control_version INTEGER`,
|
|
184
|
+
`ALTER TABLE runs ADD COLUMN begin_request TEXT`,
|
|
185
|
+
`ALTER TABLE runs ADD COLUMN begin_response TEXT`,
|
|
186
|
+
`ALTER TABLE runs ADD COLUMN end_response TEXT`,
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
// Staging checks every new row for a key conflict with rows already staged
|
|
190
|
+
// by the connection's runs. Without this index each check scans all staged
|
|
191
|
+
// rows, so a batch costs more than the one before it.
|
|
192
|
+
`CREATE INDEX run_rows_by_key ON run_rows(stream, record_key)`,
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
// Durable link from a run's stream to the publication that covered it.
|
|
196
|
+
// Existing rows stay 'unknown': no publication is inferred from a
|
|
197
|
+
// watermark, which counts local changes, not time. `published_watermark`
|
|
198
|
+
// is evidence only; never compare it with `runs.o`.
|
|
199
|
+
`ALTER TABLE run_streams ADD COLUMN publication_state TEXT NOT NULL DEFAULT 'unknown' CHECK (publication_state IN ('unknown','pending','published','superseded'))`,
|
|
200
|
+
`ALTER TABLE run_streams ADD COLUMN published_generation INTEGER`,
|
|
201
|
+
`ALTER TABLE run_streams ADD COLUMN published_version INTEGER`,
|
|
202
|
+
`ALTER TABLE run_streams ADD COLUMN published_data_hash TEXT`,
|
|
203
|
+
`ALTER TABLE run_streams ADD COLUMN published_watermark INTEGER`,
|
|
204
|
+
`ALTER TABLE run_streams ADD COLUMN publication_reason TEXT`,
|
|
205
|
+
],
|
|
206
|
+
// A table of the per-stream head path (`publish_spool`) was created here.
|
|
207
|
+
// The slot stays, so a database's version keeps its meaning.
|
|
208
|
+
[],
|
|
209
|
+
[
|
|
210
|
+
// The newest stamp of a run that observed this row's body, when that is
|
|
211
|
+
// newer than the stamp in the published bytes. Local only: never in a
|
|
212
|
+
// part, and not watched by `records_au`, so moving it logs no change. NULL
|
|
213
|
+
// means the row was last observed at its own stamp. Read it through
|
|
214
|
+
// `SEEN_O` and `SEEN_R` in merge.ts, never as the bare column.
|
|
215
|
+
`ALTER TABLE records ADD COLUMN seen_o INTEGER`,
|
|
216
|
+
`ALTER TABLE records ADD COLUMN seen_r TEXT`,
|
|
217
|
+
],
|
|
218
|
+
[
|
|
219
|
+
// "Rows last observed before run R" (a full refresh's replace) is a range
|
|
220
|
+
// on the effective observation. This holds it, in the same terms as
|
|
221
|
+
// `seenStamp` in merge.ts, so that read seeks and does not scan the stream.
|
|
222
|
+
`CREATE INDEX records_by_observation ON records(connection_id, stream, COALESCE(seen_o, stamp_o), COALESCE(seen_r, stamp_r))`,
|
|
223
|
+
],
|
|
224
|
+
[
|
|
225
|
+
// The bytes of `body`, set by `mergeIncoming` with the body. Local only:
|
|
226
|
+
// never in a part, and not watched by `records_au`. NULL means the row was
|
|
227
|
+
// written before this column existed; `bodySizes` in part-layout.ts
|
|
228
|
+
// measures the body for those rows.
|
|
229
|
+
`ALTER TABLE records ADD COLUMN body_bytes INTEGER`,
|
|
230
|
+
// The size alone, in an index. A column after `body` is stored behind the
|
|
231
|
+
// body's overflow pages, and a lookup in `records` reads a wide row page
|
|
232
|
+
// for each key, so the column by itself leaves the size reads as slow as
|
|
233
|
+
// measuring the body. This index answers them without touching `records`.
|
|
234
|
+
`CREATE INDEX records_size ON records(connection_id, stream, pk_hash, body_bytes)`,
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
// What a reader sees of a connection, as one counter per connection. A
|
|
238
|
+
// trigger bumps it in the same transaction as every change of a column the
|
|
239
|
+
// read path uses, and only when the value differs (`IS NOT`), so a write
|
|
240
|
+
// that keeps a value changes nothing and a listener that rewrites a value
|
|
241
|
+
// cannot cause an event. Watched:
|
|
242
|
+
// records: the body hash, the stamp, the first-seen time and the
|
|
243
|
+
// effective seen time `COALESCE(seen_o, stamp_o)` (a run that saw the
|
|
244
|
+
// same body moves it, and so does un-writing that run);
|
|
245
|
+
// stream_state: the primary key and profile binding, completeness, the
|
|
246
|
+
// delete version and the installed head (version, generation, data
|
|
247
|
+
// hash, blob);
|
|
248
|
+
// stream_versions: a version row inserted, changed or deleted, which is
|
|
249
|
+
// what picks the head, its completeness and its observation time, and
|
|
250
|
+
// what a version listing reports (`record_count`) and a historical
|
|
251
|
+
// read checks (`head_format`);
|
|
252
|
+
// delete_intents: a connector's intent starting or ending to exist, which
|
|
253
|
+
// hides or restores the active connections of that connector to a
|
|
254
|
+
// reader (a deleted one is unreadable with or without the intent);
|
|
255
|
+
// replacing one intent with another of the same connector is
|
|
256
|
+
// bookkeeping and stays silent;
|
|
257
|
+
// connections: identity and control state.
|
|
258
|
+
// Not watched: publish and apply bookkeeping no read shows (watermarks,
|
|
259
|
+
// floors, `needs_full`, checkpoints, labels). Nothing prunes the counter,
|
|
260
|
+
// unlike `record_changes`, so a compaction cannot erase a change. Local
|
|
261
|
+
// only: never in a part.
|
|
262
|
+
`CREATE TABLE view_versions (
|
|
263
|
+
connection_id TEXT PRIMARY KEY, version INTEGER NOT NULL) WITHOUT ROWID`,
|
|
264
|
+
`CREATE TRIGGER view_records_ai AFTER INSERT ON records BEGIN
|
|
265
|
+
${bumpView("NEW")}
|
|
266
|
+
END`,
|
|
267
|
+
`CREATE TRIGGER view_records_au AFTER UPDATE OF stamp_o, stamp_r, body_sha256, seen_o, first_o ON records
|
|
268
|
+
WHEN OLD.stamp_o IS NOT NEW.stamp_o OR OLD.stamp_r IS NOT NEW.stamp_r OR OLD.body_sha256 IS NOT NEW.body_sha256
|
|
269
|
+
OR OLD.first_o IS NOT NEW.first_o OR COALESCE(OLD.seen_o, OLD.stamp_o) IS NOT COALESCE(NEW.seen_o, NEW.stamp_o) BEGIN
|
|
270
|
+
${bumpView("NEW")}
|
|
271
|
+
END`,
|
|
272
|
+
`CREATE TRIGGER view_records_ad AFTER DELETE ON records BEGIN
|
|
273
|
+
${bumpView("OLD")}
|
|
274
|
+
END`,
|
|
275
|
+
`CREATE TRIGGER view_connections_ai AFTER INSERT ON connections BEGIN
|
|
276
|
+
${bumpView("NEW")}
|
|
277
|
+
END`,
|
|
278
|
+
`CREATE TRIGGER view_connections_ad AFTER DELETE ON connections BEGIN
|
|
279
|
+
${bumpView("OLD")}
|
|
280
|
+
END`,
|
|
281
|
+
`CREATE TRIGGER view_connections_au AFTER UPDATE OF generation, control_state, control_version, deleted_at ON connections
|
|
282
|
+
WHEN OLD.generation IS NOT NEW.generation OR OLD.control_state IS NOT NEW.control_state OR OLD.control_version IS NOT NEW.control_version OR OLD.deleted_at IS NOT NEW.deleted_at BEGIN
|
|
283
|
+
${bumpView("NEW")}
|
|
284
|
+
END`,
|
|
285
|
+
`CREATE TRIGGER view_streams_ai AFTER INSERT ON stream_state BEGIN
|
|
286
|
+
${bumpView("NEW")}
|
|
287
|
+
END`,
|
|
288
|
+
`CREATE TRIGGER view_streams_ad AFTER DELETE ON stream_state BEGIN
|
|
289
|
+
${bumpView("OLD")}
|
|
290
|
+
END`,
|
|
291
|
+
`CREATE TRIGGER view_streams_au AFTER UPDATE OF primary_key, profile_key, profile_version, complete, last_delete_version, head_version, head_generation, head_data_hash, head_blob ON stream_state
|
|
292
|
+
WHEN OLD.primary_key IS NOT NEW.primary_key OR OLD.profile_key IS NOT NEW.profile_key OR OLD.profile_version IS NOT NEW.profile_version
|
|
293
|
+
OR OLD.complete IS NOT NEW.complete OR OLD.last_delete_version IS NOT NEW.last_delete_version
|
|
294
|
+
OR OLD.head_version IS NOT NEW.head_version OR OLD.head_generation IS NOT NEW.head_generation
|
|
295
|
+
OR OLD.head_data_hash IS NOT NEW.head_data_hash OR OLD.head_blob IS NOT NEW.head_blob BEGIN
|
|
296
|
+
${bumpView("NEW")}
|
|
297
|
+
END`,
|
|
298
|
+
// `INSERT OR REPLACE` removes a replaced row without firing a delete
|
|
299
|
+
// trigger (recursive triggers are off), and an AFTER trigger cannot tell
|
|
300
|
+
// the row it replaced. A BEFORE trigger sees the stored row, so it bumps
|
|
301
|
+
// unless an identical row is already there.
|
|
302
|
+
`CREATE TRIGGER view_versions_bi BEFORE INSERT ON stream_versions
|
|
303
|
+
WHEN NOT EXISTS (SELECT 1 FROM stream_versions o WHERE o.connection_id = NEW.connection_id AND o.stream = NEW.stream AND o.version = NEW.version
|
|
304
|
+
AND o.generation IS NEW.generation AND o.head_blob IS NEW.head_blob AND o.head_format IS NEW.head_format AND o.record_count IS NEW.record_count
|
|
305
|
+
AND o.complete IS NEW.complete AND o.observed_at IS NEW.observed_at AND o.kind IS NEW.kind) BEGIN
|
|
306
|
+
${bumpView("NEW")}
|
|
307
|
+
END`,
|
|
308
|
+
`CREATE TRIGGER view_versions_au AFTER UPDATE OF generation, head_blob, head_format, record_count, complete, observed_at, kind ON stream_versions
|
|
309
|
+
WHEN OLD.generation IS NOT NEW.generation OR OLD.head_blob IS NOT NEW.head_blob OR OLD.head_format IS NOT NEW.head_format
|
|
310
|
+
OR OLD.record_count IS NOT NEW.record_count OR OLD.complete IS NOT NEW.complete
|
|
311
|
+
OR OLD.observed_at IS NOT NEW.observed_at OR OLD.kind IS NOT NEW.kind BEGIN
|
|
312
|
+
${bumpView("NEW")}
|
|
313
|
+
END`,
|
|
314
|
+
`CREATE TRIGGER view_versions_ad AFTER DELETE ON stream_versions BEGIN
|
|
315
|
+
${bumpView("OLD")}
|
|
316
|
+
END`,
|
|
317
|
+
// Every read of a connection hides it while its connector has an intent,
|
|
318
|
+
// so the intent existing is part of the view. `INSERT OR REPLACE` of an
|
|
319
|
+
// existing connector's intent fires no delete trigger (recursive triggers
|
|
320
|
+
// are off), and an AFTER INSERT trigger cannot tell it from a first
|
|
321
|
+
// insert, so a BEFORE trigger bumps only when no intent is stored yet.
|
|
322
|
+
`CREATE TRIGGER view_intents_bi BEFORE INSERT ON delete_intents
|
|
323
|
+
WHEN NOT EXISTS (SELECT 1 FROM delete_intents o WHERE o.connector = NEW.connector) BEGIN
|
|
324
|
+
${bumpConnector("NEW")}
|
|
325
|
+
END`,
|
|
326
|
+
`CREATE TRIGGER view_intents_ad AFTER DELETE ON delete_intents BEGIN
|
|
327
|
+
${bumpConnector("OLD")}
|
|
328
|
+
END`,
|
|
329
|
+
],
|
|
330
|
+
[
|
|
331
|
+
// Apply has no rollback. Set before an apply's first write to a
|
|
332
|
+
// connection, cleared when an apply of the whole connection completes. A
|
|
333
|
+
// begin never goes on offline while it is set: the registry cannot say
|
|
334
|
+
// what the half-applied local data lacks.
|
|
335
|
+
`ALTER TABLE connections ADD COLUMN apply_partial INTEGER NOT NULL DEFAULT 0`,
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
// The stream-sync log (stream-sync/src/log.ts). `log_state` is one row per
|
|
339
|
+
// connection: the position this device has applied, the position the log
|
|
340
|
+
// began after (`base`), the refs of positions base+1..position as JSON,
|
|
341
|
+
// which is what the next segment this device writes lists, and the snapshot
|
|
342
|
+
// pointer the log rests on (JSON, null before the first compaction).
|
|
343
|
+
// `log_tombstones`
|
|
344
|
+
// keeps the stamp of every delete and omission the log carried, and
|
|
345
|
+
// its rank (an omission's cutoff 0, an explicit delete 2; an observation is
|
|
346
|
+
// 1), so a reordered or repeated upsert cannot bring a deleted record back
|
|
347
|
+
// and an observation at an omission's cutoff is not refused. Both
|
|
348
|
+
// are local only, and empty until a connection runs with the log flag.
|
|
349
|
+
`CREATE TABLE log_state (
|
|
350
|
+
connection_id TEXT PRIMARY KEY, position INTEGER NOT NULL, base INTEGER NOT NULL,
|
|
351
|
+
refs TEXT NOT NULL, snapshot TEXT) WITHOUT ROWID;`,
|
|
352
|
+
`CREATE TABLE log_tombstones (
|
|
353
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
354
|
+
stamp_o INTEGER NOT NULL, stamp_r TEXT NOT NULL, rank INTEGER NOT NULL,
|
|
355
|
+
PRIMARY KEY (connection_id, stream, pk_hash)) WITHOUT ROWID;`,
|
|
356
|
+
],
|
|
357
|
+
[
|
|
358
|
+
// Publish while collecting (flag `publishWhileCollecting`). A run's batch
|
|
359
|
+
// is admitted into `records` as it arrives, so an older run can admit a row
|
|
360
|
+
// after a newer run deleted it. This remembers each delete by the stamp of
|
|
361
|
+
// the run that made it (never the stamp of the row it removed), so admission
|
|
362
|
+
// skips an upsert that an equal-or-newer delete already covers. Local only:
|
|
363
|
+
// never published or applied. A tombstone is kept only while a collecting run
|
|
364
|
+
// older than it exists (`compactTombstones` in admit.ts); with none open,
|
|
365
|
+
// every later run starts later and carries a newer stamp.
|
|
366
|
+
`CREATE TABLE record_tombstones (
|
|
367
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
368
|
+
stamp_o INTEGER NOT NULL, stamp_r TEXT NOT NULL,
|
|
369
|
+
PRIMARY KEY (connection_id, stream, pk_hash)) WITHOUT ROWID;`,
|
|
370
|
+
// 1 = the run's batches were admitted into `records` as they arrived, so
|
|
371
|
+
// run end does not merge its upserts again. Fixed at begin from the flag.
|
|
372
|
+
`ALTER TABLE runs ADD COLUMN admitting INTEGER NOT NULL DEFAULT 0`,
|
|
373
|
+
// The highest tombstone stamp compaction ever dropped for the connection.
|
|
374
|
+
// A run that begins later takes an `o` that puts its stamp above it
|
|
375
|
+
// (`clampRunStart` in admit.ts), so "a later run has a newer stamp" holds
|
|
376
|
+
// even when the caller passes an old `observedAt`.
|
|
377
|
+
`ALTER TABLE connections ADD COLUMN tombstone_wm_o INTEGER`,
|
|
378
|
+
`ALTER TABLE connections ADD COLUMN tombstone_wm_r TEXT`,
|
|
379
|
+
// 1 = some upserts of this stream were staged in `run_rows` and not
|
|
380
|
+
// admitted (the connector check blocked them, or the stream's head or floor
|
|
381
|
+
// changed between that check and the batch commit). Run end merges them.
|
|
382
|
+
`ALTER TABLE run_streams ADD COLUMN unadmitted INTEGER NOT NULL DEFAULT 0`,
|
|
383
|
+
],
|
|
384
|
+
[
|
|
385
|
+
// A stream's first load, while its parts are still being applied. One row
|
|
386
|
+
// per stream, written by apply in the same transaction as each part's
|
|
387
|
+
// rows, so a reader that sees rows of the load sees the row that names
|
|
388
|
+
// their head. It names the head (`version`, `generation`, `data_hash`) the
|
|
389
|
+
// rows belong to and how many of its parts are applied. `failed` and
|
|
390
|
+
// `last_error` say the apply stopped before the last part, and why; the
|
|
391
|
+
// next part clears them. Completion, purge and a tombstone delete the row.
|
|
392
|
+
// Local only: never in a part. A reader serves it only when asked to
|
|
393
|
+
// (`progressiveFirstLoad`).
|
|
394
|
+
`CREATE TABLE stream_partial (
|
|
395
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL,
|
|
396
|
+
version INTEGER NOT NULL, generation INTEGER NOT NULL, data_hash TEXT NOT NULL, head_blob TEXT NOT NULL,
|
|
397
|
+
observed_at INTEGER NOT NULL,
|
|
398
|
+
parts_applied INTEGER NOT NULL, parts_total INTEGER NOT NULL, records_total INTEGER NOT NULL,
|
|
399
|
+
failed INTEGER NOT NULL DEFAULT 0, last_error TEXT,
|
|
400
|
+
PRIMARY KEY (connection_id, stream)) WITHOUT ROWID`,
|
|
401
|
+
// The rows a stream held when its load began, which the load has not yet
|
|
402
|
+
// matched with a part: rows of an earlier head, and local rows the
|
|
403
|
+
// complete state keeps. They stay stored, because only the complete state
|
|
404
|
+
// knows which go, and a partial view leaves them out until a part holds
|
|
405
|
+
// their key. Gone with the row of `stream_partial` they belong to.
|
|
406
|
+
`CREATE TABLE partial_hidden (
|
|
407
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
408
|
+
PRIMARY KEY (connection_id, stream, pk_hash)) WITHOUT ROWID`,
|
|
409
|
+
`CREATE TRIGGER partial_hidden_ad AFTER DELETE ON stream_partial BEGIN
|
|
410
|
+
DELETE FROM partial_hidden WHERE connection_id = OLD.connection_id AND stream = OLD.stream;
|
|
411
|
+
END`,
|
|
412
|
+
// Each part moves the row, and a screen shows the progress, so any change
|
|
413
|
+
// of it is a change of the view. `INSERT OR REPLACE` fires no delete
|
|
414
|
+
// trigger, so a BEFORE trigger bumps unless an identical row is stored.
|
|
415
|
+
// A stream that reads as complete has no first load: whichever path
|
|
416
|
+
// completes it (a head's last part, the log's apply) ends its row here, so
|
|
417
|
+
// none of them has to remember to.
|
|
418
|
+
`CREATE TRIGGER partial_complete_au AFTER UPDATE ON stream_state
|
|
419
|
+
WHEN NEW.complete = 1 BEGIN
|
|
420
|
+
DELETE FROM stream_partial WHERE connection_id = NEW.connection_id AND stream = NEW.stream;
|
|
421
|
+
END`,
|
|
422
|
+
`CREATE TRIGGER view_partial_bi BEFORE INSERT ON stream_partial
|
|
423
|
+
WHEN NOT EXISTS (SELECT 1 FROM stream_partial o WHERE o.connection_id = NEW.connection_id AND o.stream = NEW.stream
|
|
424
|
+
AND o.version = NEW.version AND o.generation = NEW.generation AND o.data_hash = NEW.data_hash AND o.head_blob = NEW.head_blob
|
|
425
|
+
AND o.observed_at = NEW.observed_at AND o.parts_applied = NEW.parts_applied AND o.parts_total = NEW.parts_total
|
|
426
|
+
AND o.records_total = NEW.records_total AND o.failed = NEW.failed AND o.last_error IS NEW.last_error) BEGIN
|
|
427
|
+
${bumpView("NEW")}
|
|
428
|
+
END`,
|
|
429
|
+
`CREATE TRIGGER view_partial_au AFTER UPDATE ON stream_partial BEGIN
|
|
430
|
+
${bumpView("NEW")}
|
|
431
|
+
END`,
|
|
432
|
+
`CREATE TRIGGER view_partial_ad AFTER DELETE ON stream_partial BEGIN
|
|
433
|
+
${bumpView("OLD")}
|
|
434
|
+
END`,
|
|
435
|
+
],
|
|
436
|
+
[
|
|
437
|
+
// A log tombstone also keeps the canonical record key of the deletion it
|
|
438
|
+
// records (log format 2): the key a record-level reader needs for a key it
|
|
439
|
+
// never held, which the hash cannot give back. Local only. NULL only for a
|
|
440
|
+
// tombstone written before the column; format 1 wrote none that shipped.
|
|
441
|
+
`ALTER TABLE log_tombstones ADD COLUMN record_key TEXT`,
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
// A deletion in the log names its key as the typed primary-key values its
|
|
445
|
+
// pk hash is computed from (log format 2). A run row holds the record's
|
|
446
|
+
// data, which run end purges, and a change keeps only the lossy string
|
|
447
|
+
// `record_key`; so an explicit delete keeps the values themselves, as
|
|
448
|
+
// canonical JSON, from the run row that made it. NULL for a change made
|
|
449
|
+
// before the column: its typed key is gone, and the log never carried it.
|
|
450
|
+
`ALTER TABLE run_rows ADD COLUMN pk_values TEXT`,
|
|
451
|
+
`ALTER TABLE record_changes ADD COLUMN pk_values TEXT`,
|
|
452
|
+
// The types the stream's schema declares for its key fields (JSON array of
|
|
453
|
+
// type names or null), from the latest run's declarations. With the record
|
|
454
|
+
// key they give a delete made before `pk_values` its typed key back.
|
|
455
|
+
`ALTER TABLE stream_state ADD COLUMN key_types TEXT`,
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
// The intake batch ordinal of the run that observed a record's body: the
|
|
459
|
+
// order between two bodies of one key at one stamp (`mergeIncoming`). A run
|
|
460
|
+
// that publishes while collecting can admit a key again in a later batch
|
|
461
|
+
// with a changed body, at the same stamp; the later batch is the fresher
|
|
462
|
+
// observation. 0 for a row from before the column and for a run's first batch.
|
|
463
|
+
`ALTER TABLE records ADD COLUMN stamp_n INTEGER NOT NULL DEFAULT 0`,
|
|
464
|
+
],
|
|
465
|
+
[
|
|
466
|
+
// A key-ordered first load of the log (log-keyed.ts) writes its rows one
|
|
467
|
+
// key range at a time and moves `log_state` in the last commit. Between
|
|
468
|
+
// them the rows are in `records` and `log_tombstones` with no stream
|
|
469
|
+
// version. This keeps, per connection, the position and refs that load
|
|
470
|
+
// means to publish, written with its first range and deleted with its
|
|
471
|
+
// last, so a retry that holds a shorter prefix cannot publish over those
|
|
472
|
+
// rows. Local only.
|
|
473
|
+
`CREATE TABLE log_keyed_pending (
|
|
474
|
+
connection_id TEXT PRIMARY KEY, position INTEGER NOT NULL, base INTEGER NOT NULL,
|
|
475
|
+
refs TEXT NOT NULL) WITHOUT ROWID`,
|
|
476
|
+
],
|
|
477
|
+
[
|
|
478
|
+
// `records` becomes a rowid table with a unique key. A WITHOUT ROWID
|
|
479
|
+
// table keeps each row in the b-tree of its key, and a row here is a few
|
|
480
|
+
// KB (`body`), more than 1/20 of a page, which SQLite's guidance
|
|
481
|
+
// (withoutrowid.html) puts outside what that layout suits. `pk_hash` is a
|
|
482
|
+
// hash, so a load that does not arrive in key order puts every insert on
|
|
483
|
+
// a random leaf of a tree as large as the table, and the page cache holds
|
|
484
|
+
// a small part of it. Even an insert at the end of the key order rewrites
|
|
485
|
+
// two neighbours of the leaf it fills: SQLite moves an append to a new
|
|
486
|
+
// page (`balance_quick`) only in a rowid table. A rowid table appends each
|
|
487
|
+
// row in insert order whatever its key, and the key's random inserts land
|
|
488
|
+
// in `records_key`, whose entries hold no body. Every index and trigger is
|
|
489
|
+
// created again with the same columns: dropping the table drops them.
|
|
490
|
+
// Their entries now end with the rowid where they ended with the key.
|
|
491
|
+
// Naming `pk_hash` in them would keep ties in key order, but it makes
|
|
492
|
+
// every load insert at random places in two more indexes, and with the
|
|
493
|
+
// key index they no longer fit the page cache of a browser's first load:
|
|
494
|
+
// the write count of that load triples. A tie on `record_key` is sorted
|
|
495
|
+
// at read time instead, and the hashes a replacement omits are found
|
|
496
|
+
// through the table, one row each.
|
|
497
|
+
`CREATE TABLE records_rowid (
|
|
498
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL, pk_hash TEXT NOT NULL,
|
|
499
|
+
record_key TEXT NOT NULL, stamp_o INTEGER NOT NULL, stamp_r TEXT NOT NULL,
|
|
500
|
+
body TEXT NOT NULL, body_sha256 TEXT NOT NULL, first_o INTEGER, seen_o INTEGER, seen_r TEXT, body_bytes INTEGER, stamp_n INTEGER NOT NULL DEFAULT 0)`,
|
|
501
|
+
`INSERT INTO records_rowid (connection_id, stream, pk_hash, record_key, stamp_o, stamp_r, body, body_sha256, first_o, seen_o, seen_r, body_bytes, stamp_n)
|
|
502
|
+
SELECT connection_id, stream, pk_hash, record_key, stamp_o, stamp_r, body, body_sha256, first_o, seen_o, seen_r, body_bytes, stamp_n FROM records ORDER BY connection_id, stream, pk_hash`,
|
|
503
|
+
`DROP TABLE records`,
|
|
504
|
+
`ALTER TABLE records_rowid RENAME TO records`,
|
|
505
|
+
`CREATE UNIQUE INDEX records_key ON records(connection_id, stream, pk_hash)`,
|
|
506
|
+
`CREATE INDEX records_by_key ON records(connection_id, stream, record_key)`,
|
|
507
|
+
`CREATE INDEX records_by_first ON records(first_o) WHERE first_o IS NOT NULL`,
|
|
508
|
+
`CREATE INDEX records_by_observation ON records(connection_id, stream, COALESCE(seen_o, stamp_o), COALESCE(seen_r, stamp_r))`,
|
|
509
|
+
`CREATE INDEX records_size ON records(connection_id, stream, pk_hash, body_bytes)`,
|
|
510
|
+
...RECORDS_TRIGGERS,
|
|
511
|
+
],
|
|
512
|
+
[
|
|
513
|
+
// The tables of the per-stream head path, on a database created before
|
|
514
|
+
// the migrations above stopped creating them. The `consumed_*` columns of
|
|
515
|
+
// `stream_state` such a database has stay: nothing reads them, and
|
|
516
|
+
// SQLite before 3.35 (a phone's 3.22) cannot drop a column.
|
|
517
|
+
`DROP TABLE IF EXISTS head_parts`,
|
|
518
|
+
`DROP TABLE IF EXISTS log_replay`,
|
|
519
|
+
`DROP TABLE IF EXISTS publish_spool`,
|
|
520
|
+
],
|
|
521
|
+
[
|
|
522
|
+
// The stream meta the log said at each local version, beside its
|
|
523
|
+
// `complete`. A run's end writes its own meta into `stream_state` before
|
|
524
|
+
// its publish, so the publish compares the run with these. Every writer
|
|
525
|
+
// of a version row sets them.
|
|
526
|
+
`ALTER TABLE stream_versions ADD COLUMN primary_key TEXT`,
|
|
527
|
+
`ALTER TABLE stream_versions ADD COLUMN profile_key TEXT`,
|
|
528
|
+
`ALTER TABLE stream_versions ADD COLUMN profile_version TEXT`,
|
|
529
|
+
],
|
|
530
|
+
[
|
|
531
|
+
// A version row written before those columns gets the stream's own meta,
|
|
532
|
+
// so the publish can read every row's meta from the row itself.
|
|
533
|
+
`UPDATE stream_versions SET
|
|
534
|
+
primary_key = (SELECT s.primary_key FROM stream_state s
|
|
535
|
+
WHERE s.connection_id = stream_versions.connection_id
|
|
536
|
+
AND s.stream = stream_versions.stream),
|
|
537
|
+
profile_key = (SELECT s.profile_key FROM stream_state s
|
|
538
|
+
WHERE s.connection_id = stream_versions.connection_id
|
|
539
|
+
AND s.stream = stream_versions.stream),
|
|
540
|
+
profile_version = (SELECT s.profile_version FROM stream_state s
|
|
541
|
+
WHERE s.connection_id = stream_versions.connection_id
|
|
542
|
+
AND s.stream = stream_versions.stream)
|
|
543
|
+
WHERE primary_key IS NULL`,
|
|
544
|
+
],
|
|
545
|
+
[
|
|
546
|
+
// Whether a stream's rows changed after a reader looked, which each page of
|
|
547
|
+
// a complete read asks (complete-read.ts). Every write of a row leaves an
|
|
548
|
+
// entry in `record_changes`, so a trigger on that table sees them all. It
|
|
549
|
+
// writes the mark only for the first change after a reader cleared it:
|
|
550
|
+
// `dirty` says a change came since, `epoch` counts those first changes. A
|
|
551
|
+
// trigger that wrote on every row would cost every record write; this one
|
|
552
|
+
// reads one primary-key row.
|
|
553
|
+
`CREATE TABLE stream_change_marks (
|
|
554
|
+
connection_id TEXT NOT NULL, stream TEXT NOT NULL,
|
|
555
|
+
epoch INTEGER NOT NULL, dirty INTEGER NOT NULL,
|
|
556
|
+
PRIMARY KEY (connection_id, stream)) WITHOUT ROWID`,
|
|
557
|
+
`CREATE TRIGGER stream_change_marks_ai AFTER INSERT ON record_changes
|
|
558
|
+
WHEN NOT EXISTS (SELECT 1 FROM stream_change_marks m
|
|
559
|
+
WHERE m.connection_id = NEW.connection_id AND m.stream = NEW.stream AND m.dirty = 1)
|
|
560
|
+
BEGIN
|
|
561
|
+
INSERT OR REPLACE INTO stream_change_marks(connection_id, stream, epoch, dirty)
|
|
562
|
+
VALUES (NEW.connection_id, NEW.stream,
|
|
563
|
+
COALESCE((SELECT epoch FROM stream_change_marks
|
|
564
|
+
WHERE connection_id = NEW.connection_id AND stream = NEW.stream), 0) + 1, 1);
|
|
565
|
+
END`,
|
|
566
|
+
],
|
|
567
|
+
[
|
|
568
|
+
// Why eligible work is still waiting. Completion reads this only while work remains.
|
|
569
|
+
`ALTER TABLE record_changes ADD COLUMN publish_blocked_reason TEXT CHECK (publish_blocked_reason IN ('deferred','backoff','discarded','purged','refused'))`,
|
|
570
|
+
`ALTER TABLE run_streams ADD COLUMN publish_blocked_reason TEXT CHECK (publish_blocked_reason IN ('deferred','backoff','discarded','purged','refused'))`,
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
`CREATE TABLE bootstrap_load(id INTEGER PRIMARY KEY CHECK(id=1),connection_id TEXT NOT NULL,generation INTEGER NOT NULL,base INTEGER NOT NULL,preview_done INTEGER NOT NULL DEFAULT 0)`,
|
|
574
|
+
`CREATE TABLE bootstrap_segments(position INTEGER PRIMARY KEY,data_hash TEXT NOT NULL,first_row INTEGER NOT NULL,last_row INTEGER NOT NULL,observed_at INTEGER NOT NULL,metas TEXT NOT NULL,removes INTEGER NOT NULL)`,
|
|
575
|
+
`CREATE TABLE bootstrap_deletions(connection_id TEXT NOT NULL,stream TEXT NOT NULL,pk_hash TEXT NOT NULL,record_key TEXT NOT NULL,stamp_o INTEGER NOT NULL,stamp_r TEXT NOT NULL,rank INTEGER NOT NULL,position INTEGER NOT NULL,entry_order INTEGER NOT NULL)`,
|
|
576
|
+
`CREATE TABLE bootstrap_preview(connection_id TEXT NOT NULL,stream TEXT NOT NULL,pk_hash TEXT NOT NULL,PRIMARY KEY(connection_id,stream,pk_hash)) WITHOUT ROWID`,
|
|
577
|
+
...["INSERT", "UPDATE", "DELETE"].map((event) => `CREATE TRIGGER records_bootstrap_${event.toLowerCase()} BEFORE ${event} ON records
|
|
578
|
+
WHEN EXISTS(SELECT 1 FROM bootstrap_load b WHERE b.connection_id <> ${event === "INSERT" ? "NEW" : "OLD"}.connection_id
|
|
579
|
+
${event === "UPDATE" ? "OR b.connection_id <> NEW.connection_id" : ""}
|
|
580
|
+
OR (SELECT origin FROM write_ctx WHERE id=1) IS NOT 'remote')
|
|
581
|
+
BEGIN SELECT RAISE(ABORT,'bootstrap_busy'); END`),
|
|
582
|
+
],
|
|
583
|
+
[
|
|
584
|
+
// Selection is independent of declaration/scope data. Old runs stay legacy.
|
|
585
|
+
`ALTER TABLE runs ADD COLUMN selected_streams TEXT`,
|
|
586
|
+
`CREATE TABLE run_record_evidence (
|
|
587
|
+
run_id TEXT NOT NULL REFERENCES runs(run_id) ON DELETE CASCADE,
|
|
588
|
+
stream TEXT NOT NULL, pk_hash TEXT NOT NULL, pk_values TEXT NOT NULL,
|
|
589
|
+
ever_deleted INTEGER NOT NULL, upsert_events INTEGER NOT NULL, delete_events INTEGER NOT NULL,
|
|
590
|
+
PRIMARY KEY(run_id,stream,pk_hash)) WITHOUT ROWID`,
|
|
591
|
+
// AFTER INSERT sees each accepted event, including REPLACE of a final row.
|
|
592
|
+
// It shares the intake transaction, key checks and last-batch replay guard.
|
|
593
|
+
`CREATE TRIGGER run_rows_evidence AFTER INSERT ON run_rows WHEN NEW.pk_values IS NOT NULL
|
|
594
|
+
BEGIN
|
|
595
|
+
INSERT OR REPLACE INTO run_record_evidence(run_id,stream,pk_hash,pk_values,ever_deleted,upsert_events,delete_events)
|
|
596
|
+
VALUES(NEW.run_id,NEW.stream,NEW.pk_hash,NEW.pk_values,
|
|
597
|
+
MAX(NEW.op='delete',COALESCE((SELECT ever_deleted FROM run_record_evidence WHERE run_id=NEW.run_id AND stream=NEW.stream AND pk_hash=NEW.pk_hash),0)),
|
|
598
|
+
(NEW.op='upsert')+COALESCE((SELECT upsert_events FROM run_record_evidence WHERE run_id=NEW.run_id AND stream=NEW.stream AND pk_hash=NEW.pk_hash),0),
|
|
599
|
+
(NEW.op='delete')+COALESCE((SELECT delete_events FROM run_record_evidence WHERE run_id=NEW.run_id AND stream=NEW.stream AND pk_hash=NEW.pk_hash),0));
|
|
600
|
+
END`,
|
|
601
|
+
],
|
|
602
|
+
[`ALTER TABLE runs ADD COLUMN raw_end TEXT`],
|
|
603
|
+
[
|
|
604
|
+
`CREATE TABLE system_stream_instance(id INTEGER PRIMARY KEY CHECK(id=1), instance_id TEXT NOT NULL)`,
|
|
605
|
+
`CREATE TABLE system_stream_outbox(connection_id TEXT NOT NULL,stream TEXT NOT NULL,record_id TEXT NOT NULL,body TEXT NOT NULL,sort_at TEXT NOT NULL,run_id TEXT NOT NULL,observed_at INTEGER NOT NULL,PRIMARY KEY(connection_id,stream,record_id)) WITHOUT ROWID`,
|
|
606
|
+
`CREATE TABLE system_stream_projection(connection_id TEXT NOT NULL,stream TEXT NOT NULL,record_id TEXT NOT NULL,sort_at TEXT NOT NULL,body TEXT NOT NULL,PRIMARY KEY(connection_id,stream,record_id)) WITHOUT ROWID`,
|
|
607
|
+
`CREATE INDEX system_stream_page ON system_stream_projection(connection_id,stream,sort_at DESC,record_id DESC)`,
|
|
608
|
+
`CREATE TABLE system_stream_checkpoint(connection_id TEXT NOT NULL,stream TEXT NOT NULL,seq INTEGER NOT NULL,PRIMARY KEY(connection_id,stream)) WITHOUT ROWID`,
|
|
609
|
+
`CREATE TABLE system_stream_quarantine(connection_id TEXT NOT NULL,stream TEXT NOT NULL,record_id TEXT NOT NULL,body TEXT NOT NULL,PRIMARY KEY(connection_id,stream,record_id,body)) WITHOUT ROWID`,
|
|
610
|
+
`CREATE TRIGGER system_stream_outbox_capacity BEFORE INSERT ON system_stream_outbox
|
|
611
|
+
WHEN NOT EXISTS(SELECT 1 FROM system_stream_outbox WHERE connection_id=NEW.connection_id AND stream=NEW.stream AND record_id=NEW.record_id)
|
|
612
|
+
AND ((SELECT count(*) FROM system_stream_outbox)>=100000 OR (SELECT COALESCE(sum(length(CAST(body AS BLOB))),0) FROM system_stream_outbox)+length(CAST(NEW.body AS BLOB))>104857600)
|
|
613
|
+
BEGIN SELECT RAISE(ABORT,'system_stream_outbox_full'); END`,
|
|
614
|
+
],
|
|
615
|
+
[
|
|
616
|
+
// A projection must survive publisher compaction of record_changes. This
|
|
617
|
+
// inbox is committed with each canonical change and consumed atomically.
|
|
618
|
+
`CREATE TABLE system_stream_changes(seq INTEGER PRIMARY KEY AUTOINCREMENT,connection_id TEXT NOT NULL,stream TEXT NOT NULL,record_id TEXT NOT NULL,body TEXT)`,
|
|
619
|
+
`CREATE INDEX system_stream_changes_by_stream ON system_stream_changes(connection_id,stream,seq)`,
|
|
620
|
+
// Table-local triggers survive the bootstrap table swap through its schema
|
|
621
|
+
// capture. An external trigger referencing records would refuse that swap.
|
|
622
|
+
...["INSERT", "UPDATE", "DELETE"].map((event) => {
|
|
623
|
+
const row = event === "DELETE" ? "OLD" : "NEW";
|
|
624
|
+
return `CREATE TRIGGER system_stream_records_${event.toLowerCase()} AFTER ${event === "UPDATE" ? "UPDATE OF stamp_o,stamp_r,body_sha256" : event} ON records
|
|
625
|
+
WHEN ${row}.connection_id GLOB 'pdpp.vana-system-*~*'
|
|
626
|
+
BEGIN INSERT INTO system_stream_changes(connection_id,stream,record_id,body)
|
|
627
|
+
VALUES (${row}.connection_id,${row}.stream,${row}.record_key,${event === "DELETE" ? "NULL" : "NEW.body"}); END`;
|
|
628
|
+
}),
|
|
629
|
+
],
|
|
630
|
+
[
|
|
631
|
+
// A device-local fact, never published: this device collected, or was
|
|
632
|
+
// asked and accepted, the connection. Begin asks before a first run of a
|
|
633
|
+
// connection that already exists. A device with a checkpoint or a run for
|
|
634
|
+
// a connection already collects it.
|
|
635
|
+
`CREATE TABLE connection_participation (
|
|
636
|
+
connection_id TEXT PRIMARY KEY, joined_at INTEGER NOT NULL) WITHOUT ROWID`,
|
|
637
|
+
`INSERT INTO connection_participation(connection_id, joined_at)
|
|
638
|
+
SELECT connection_id, CAST(strftime('%s','now') AS INTEGER) * 1000 FROM (
|
|
639
|
+
SELECT connection_id FROM runs
|
|
640
|
+
UNION SELECT connection_id FROM connections WHERE checkpoint IS NOT NULL)`,
|
|
641
|
+
],
|
|
642
|
+
[
|
|
643
|
+
// A stream's connector cursor travels in the log with the rows it covers.
|
|
644
|
+
// cursor_unpublished: the stream's checkpoint entry a run end saved and
|
|
645
|
+
// no segment has carried yet, as {state, connectorVersion}.
|
|
646
|
+
// cursor_seq: the stream's last record_changes seq when it was saved; a
|
|
647
|
+
// segment that closes the stream through that seq may carry it.
|
|
648
|
+
// cursor_children: the streams whose rows the cursor also claims (its
|
|
649
|
+
// state descendants, read through it), as a JSON array; the cursor
|
|
650
|
+
// travels only in a segment that closes them too.
|
|
651
|
+
// cursor_version: the connector version that wrote the stream's local
|
|
652
|
+
// checkpoint entry, here or on the device whose segment set it.
|
|
653
|
+
// cursor_applied: the cursor of the last segment applied (or published
|
|
654
|
+
// here) that carried one, as {state, connectorVersion}, until it is
|
|
655
|
+
// folded into `connections.checkpoint` (cursor.ts). It is written in
|
|
656
|
+
// the batch of the rows it covers; the fold is a JSON merge, done in JS.
|
|
657
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_unpublished TEXT`,
|
|
658
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_seq INTEGER`,
|
|
659
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_children TEXT`,
|
|
660
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_version TEXT`,
|
|
661
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_applied TEXT`,
|
|
662
|
+
// Every path that drops the local checkpoint (a discarded or fenced run, a
|
|
663
|
+
// purge, a deleted connection) drops the cursors with it, so none of them
|
|
664
|
+
// can publish a cursor the device no longer resumes from.
|
|
665
|
+
`CREATE TRIGGER connections_checkpoint_cleared AFTER UPDATE OF checkpoint ON connections
|
|
666
|
+
WHEN NEW.checkpoint IS NULL BEGIN
|
|
667
|
+
UPDATE stream_state SET cursor_unpublished = NULL, cursor_seq = NULL, cursor_children = NULL, cursor_version = NULL, cursor_applied = NULL
|
|
668
|
+
WHERE connection_id = NEW.connection_id;
|
|
669
|
+
END`,
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
// Counts the writes of `cursor_unpublished`, never reset. A run end can
|
|
673
|
+
// write the same cursor again (its entry moved away and back), with more
|
|
674
|
+
// rows under it, while a segment that carried the earlier write waits to
|
|
675
|
+
// be acknowledged; the acknowledgement clears only the write it carried.
|
|
676
|
+
`ALTER TABLE stream_state ADD COLUMN cursor_write INTEGER NOT NULL DEFAULT 0`,
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
// The newest stamp (`o`, then `r`) a connection's log tombstones hold, which a run's start
|
|
680
|
+
// stamp is raised above (`clampRunStart` in admit.ts). The tombstones of a
|
|
681
|
+
// connection are kept until it is purged, so without this the read is a
|
|
682
|
+
// scan of all of them at every begin.
|
|
683
|
+
`CREATE INDEX log_tombstones_by_stamp ON log_tombstones(connection_id, stamp_o, stamp_r)`,
|
|
684
|
+
],
|
|
685
|
+
];
|
|
686
|
+
//# sourceMappingURL=schema.js.map
|