@earendil-works/chord 1.4.0 → 1.5.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/CHANGELOG.md +92 -0
- package/README.md +115 -90
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/contracts/accepts.d.ts +81 -0
- package/dist/contracts/accepts.d.ts.map +1 -0
- package/dist/contracts/accepts.js +123 -0
- package/dist/contracts/accepts.js.map +1 -0
- package/dist/contracts/contract.d.ts +121 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +50 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/declare.d.ts +107 -0
- package/dist/contracts/declare.d.ts.map +1 -0
- package/dist/contracts/declare.js +136 -0
- package/dist/contracts/declare.js.map +1 -0
- package/dist/contracts/evolve.d.ts +92 -0
- package/dist/contracts/evolve.d.ts.map +1 -0
- package/dist/contracts/evolve.js +179 -0
- package/dist/contracts/evolve.js.map +1 -0
- package/dist/contracts/fingerprint.d.ts +16 -0
- package/dist/contracts/fingerprint.d.ts.map +1 -0
- package/dist/contracts/fingerprint.js +50 -0
- package/dist/contracts/fingerprint.js.map +1 -0
- package/dist/contracts/history.d.ts +71 -0
- package/dist/contracts/history.d.ts.map +1 -0
- package/dist/contracts/history.js +3 -0
- package/dist/contracts/history.js.map +1 -0
- package/dist/contracts/host-kind.d.ts +40 -0
- package/dist/contracts/host-kind.d.ts.map +1 -0
- package/dist/contracts/host-kind.js +37 -0
- package/dist/contracts/host-kind.js.map +1 -0
- package/dist/contracts/index.d.ts +7 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +6 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/internal.d.ts +10 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/internal.js +9 -0
- package/dist/contracts/internal.js.map +1 -0
- package/dist/contracts/names.d.ts +3 -0
- package/dist/contracts/names.d.ts.map +1 -0
- package/dist/contracts/names.js +13 -0
- package/dist/contracts/names.js.map +1 -0
- package/dist/contracts/params.d.ts +28 -0
- package/dist/contracts/params.d.ts.map +1 -0
- package/dist/contracts/params.js +50 -0
- package/dist/contracts/params.js.map +1 -0
- package/dist/contracts/schema.d.ts +102 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +103 -0
- package/dist/contracts/schema.js.map +1 -0
- package/dist/contracts/snapshot.d.ts +16 -0
- package/dist/contracts/snapshot.d.ts.map +1 -0
- package/dist/contracts/snapshot.js +167 -0
- package/dist/contracts/snapshot.js.map +1 -0
- package/dist/data/args.d.ts +50 -0
- package/dist/data/args.d.ts.map +1 -0
- package/dist/data/args.js +83 -0
- package/dist/data/args.js.map +1 -0
- package/dist/data/errors.d.ts +80 -0
- package/dist/data/errors.d.ts.map +1 -0
- package/dist/data/errors.js +116 -0
- package/dist/data/errors.js.map +1 -0
- package/dist/data/failure.d.ts +26 -0
- package/dist/data/failure.d.ts.map +1 -0
- package/dist/data/failure.js +77 -0
- package/dist/data/failure.js.map +1 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +5 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/internal.d.ts +7 -0
- package/dist/data/internal.d.ts.map +1 -0
- package/dist/data/internal.js +8 -0
- package/dist/data/internal.js.map +1 -0
- package/dist/data/params.d.ts +20 -0
- package/dist/data/params.d.ts.map +1 -0
- package/dist/data/params.js +31 -0
- package/dist/data/params.js.map +1 -0
- package/dist/data/principal.d.ts +22 -0
- package/dist/data/principal.d.ts.map +1 -0
- package/dist/data/principal.js +49 -0
- package/dist/data/principal.js.map +1 -0
- package/dist/data/validator.d.ts +12 -0
- package/dist/data/validator.d.ts.map +1 -0
- package/dist/data/validator.js +35 -0
- package/dist/data/validator.js.map +1 -0
- package/dist/delta/apply-immutable-trusted.js +3 -4
- package/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/dist/delta/diff.d.ts.map +1 -1
- package/dist/delta/diff.js +5 -3
- package/dist/delta/diff.js.map +1 -1
- package/dist/delta/index.d.ts +9 -1
- package/dist/delta/index.d.ts.map +1 -1
- package/dist/delta/index.js +15 -11
- package/dist/delta/index.js.map +1 -1
- package/dist/delta/pending.d.ts +36 -0
- package/dist/delta/pending.d.ts.map +1 -0
- package/dist/delta/pending.js +143 -0
- package/dist/delta/pending.js.map +1 -0
- package/dist/delta/tracker.d.ts +12 -0
- package/dist/delta/tracker.d.ts.map +1 -1
- package/dist/delta/tracker.js +109 -39
- package/dist/delta/tracker.js.map +1 -1
- package/dist/documents/address-source.d.ts +20 -0
- package/dist/documents/address-source.d.ts.map +1 -0
- package/dist/documents/address-source.js +44 -0
- package/dist/documents/address-source.js.map +1 -0
- package/dist/documents/definition.d.ts +84 -0
- package/dist/documents/definition.d.ts.map +1 -0
- package/dist/documents/definition.js +74 -0
- package/dist/documents/definition.js.map +1 -0
- package/dist/documents/documents.d.ts +126 -0
- package/dist/documents/documents.d.ts.map +1 -0
- package/dist/documents/documents.js +248 -0
- package/dist/documents/documents.js.map +1 -0
- package/dist/documents/fence.d.ts +9 -0
- package/dist/documents/fence.d.ts.map +1 -0
- package/dist/documents/fence.js +15 -0
- package/dist/documents/fence.js.map +1 -0
- package/dist/documents/handles.d.ts +76 -0
- package/dist/documents/handles.d.ts.map +1 -0
- package/dist/documents/handles.js +66 -0
- package/dist/documents/handles.js.map +1 -0
- package/dist/documents/index.d.ts +4 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +3 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/internal.d.ts +9 -0
- package/dist/documents/internal.d.ts.map +1 -0
- package/dist/documents/internal.js +9 -0
- package/dist/documents/internal.js.map +1 -0
- package/dist/documents/keyed-slot.d.ts +103 -0
- package/dist/documents/keyed-slot.d.ts.map +1 -0
- package/dist/documents/keyed-slot.js +395 -0
- package/dist/documents/keyed-slot.js.map +1 -0
- package/dist/documents/line.d.ts +7 -0
- package/dist/documents/line.d.ts.map +1 -0
- package/dist/documents/line.js +14 -0
- package/dist/documents/line.js.map +1 -0
- package/dist/documents/persistence.d.ts +104 -0
- package/dist/documents/persistence.d.ts.map +1 -0
- package/dist/documents/persistence.js +129 -0
- package/dist/documents/persistence.js.map +1 -0
- package/dist/documents/residency.d.ts +31 -0
- package/dist/documents/residency.d.ts.map +1 -0
- package/dist/documents/residency.js +93 -0
- package/dist/documents/residency.js.map +1 -0
- package/dist/documents/slot.d.ts +109 -0
- package/dist/documents/slot.d.ts.map +1 -0
- package/dist/documents/slot.js +181 -0
- package/dist/documents/slot.js.map +1 -0
- package/dist/documents/transaction.d.ts +143 -0
- package/dist/documents/transaction.d.ts.map +1 -0
- package/dist/documents/transaction.js +442 -0
- package/dist/documents/transaction.js.map +1 -0
- package/dist/host/activity.d.ts +31 -0
- package/dist/host/activity.d.ts.map +1 -0
- package/dist/host/activity.js +40 -0
- package/dist/host/activity.js.map +1 -0
- package/dist/host/adapted.d.ts +49 -0
- package/dist/host/adapted.d.ts.map +1 -0
- package/dist/host/adapted.js +214 -0
- package/dist/host/adapted.js.map +1 -0
- package/dist/host/attempt.d.ts +308 -0
- package/dist/host/attempt.d.ts.map +1 -0
- package/dist/host/attempt.js +1199 -0
- package/dist/host/attempt.js.map +1 -0
- package/dist/host/backoff.d.ts +29 -0
- package/dist/host/backoff.d.ts.map +1 -0
- package/dist/host/backoff.js +69 -0
- package/dist/host/backoff.js.map +1 -0
- package/dist/host/ctx.d.ts +94 -0
- package/dist/host/ctx.d.ts.map +1 -0
- package/dist/host/ctx.js +200 -0
- package/dist/host/ctx.js.map +1 -0
- package/dist/host/deadline.d.ts +12 -0
- package/dist/host/deadline.d.ts.map +1 -0
- package/dist/host/deadline.js +40 -0
- package/dist/host/deadline.js.map +1 -0
- package/dist/host/dependencies.d.ts +65 -0
- package/dist/host/dependencies.d.ts.map +1 -0
- package/dist/host/dependencies.js +115 -0
- package/dist/host/dependencies.js.map +1 -0
- package/dist/host/destination.d.ts +48 -0
- package/dist/host/destination.d.ts.map +1 -0
- package/dist/host/destination.js +101 -0
- package/dist/host/destination.js.map +1 -0
- package/dist/host/facet.d.ts +84 -0
- package/dist/host/facet.d.ts.map +1 -0
- package/dist/host/facet.js +55 -0
- package/dist/host/facet.js.map +1 -0
- package/dist/host/follow.d.ts +52 -0
- package/dist/host/follow.d.ts.map +1 -0
- package/dist/host/follow.js +207 -0
- package/dist/host/follow.js.map +1 -0
- package/dist/host/host.d.ts +571 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +1318 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +17 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +6 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/internal.d.ts +11 -0
- package/dist/host/internal.d.ts.map +1 -0
- package/dist/host/internal.js +9 -0
- package/dist/host/internal.js.map +1 -0
- package/dist/host/members.d.ts +50 -0
- package/dist/host/members.d.ts.map +1 -0
- package/dist/host/members.js +107 -0
- package/dist/host/members.js.map +1 -0
- package/dist/host/native.d.ts +64 -0
- package/dist/host/native.d.ts.map +1 -0
- package/dist/host/native.js +126 -0
- package/dist/host/native.js.map +1 -0
- package/dist/host/object.d.ts +331 -0
- package/dist/host/object.d.ts.map +1 -0
- package/dist/host/object.js +1296 -0
- package/dist/host/object.js.map +1 -0
- package/dist/host/old-work.d.ts +34 -0
- package/dist/host/old-work.d.ts.map +1 -0
- package/dist/host/old-work.js +52 -0
- package/dist/host/old-work.js.map +1 -0
- package/dist/host/parked.d.ts +23 -0
- package/dist/host/parked.d.ts.map +1 -0
- package/dist/host/parked.js +79 -0
- package/dist/host/parked.js.map +1 -0
- package/dist/host/presence.d.ts +34 -0
- package/dist/host/presence.d.ts.map +1 -0
- package/dist/host/presence.js +117 -0
- package/dist/host/presence.js.map +1 -0
- package/dist/host/readiness.d.ts +27 -0
- package/dist/host/readiness.d.ts.map +1 -0
- package/dist/host/readiness.js +134 -0
- package/dist/host/readiness.js.map +1 -0
- package/dist/host/ref-state.d.ts +53 -0
- package/dist/host/ref-state.d.ts.map +1 -0
- package/dist/host/ref-state.js +83 -0
- package/dist/host/ref-state.js.map +1 -0
- package/dist/host/reference-keys.d.ts +36 -0
- package/dist/host/reference-keys.d.ts.map +1 -0
- package/dist/host/reference-keys.js +168 -0
- package/dist/host/reference-keys.js.map +1 -0
- package/dist/host/reference-source.d.ts +65 -0
- package/dist/host/reference-source.d.ts.map +1 -0
- package/dist/host/reference-source.js +285 -0
- package/dist/host/reference-source.js.map +1 -0
- package/dist/host/reference.d.ts +321 -0
- package/dist/host/reference.d.ts.map +1 -0
- package/dist/host/reference.js +797 -0
- package/dist/host/reference.js.map +1 -0
- package/dist/host/reload-cycle.d.ts +16 -0
- package/dist/host/reload-cycle.d.ts.map +1 -0
- package/dist/host/reload-cycle.js +81 -0
- package/dist/host/reload-cycle.js.map +1 -0
- package/dist/host/retry-on.d.ts +28 -0
- package/dist/host/retry-on.d.ts.map +1 -0
- package/dist/host/retry-on.js +52 -0
- package/dist/host/retry-on.js.map +1 -0
- package/dist/host/revocation.d.ts +16 -0
- package/dist/host/revocation.d.ts.map +1 -0
- package/dist/host/revocation.js +27 -0
- package/dist/host/revocation.js.map +1 -0
- package/dist/host/root.d.ts +37 -0
- package/dist/host/root.d.ts.map +1 -0
- package/dist/host/root.js +68 -0
- package/dist/host/root.js.map +1 -0
- package/dist/host/route.d.ts +64 -0
- package/dist/host/route.d.ts.map +1 -0
- package/dist/host/route.js +227 -0
- package/dist/host/route.js.map +1 -0
- package/dist/host/routines.d.ts +78 -0
- package/dist/host/routines.d.ts.map +1 -0
- package/dist/host/routines.js +398 -0
- package/dist/host/routines.js.map +1 -0
- package/dist/host/sleep.d.ts +9 -0
- package/dist/host/sleep.d.ts.map +1 -0
- package/dist/host/sleep.js +40 -0
- package/dist/host/sleep.js.map +1 -0
- package/dist/host/staging.d.ts +94 -0
- package/dist/host/staging.d.ts.map +1 -0
- package/dist/host/staging.js +304 -0
- package/dist/host/staging.js.map +1 -0
- package/dist/host/unbound-clock.d.ts +23 -0
- package/dist/host/unbound-clock.d.ts.map +1 -0
- package/dist/host/unbound-clock.js +58 -0
- package/dist/host/unbound-clock.js.map +1 -0
- package/dist/host/unbound.d.ts +37 -0
- package/dist/host/unbound.d.ts.map +1 -0
- package/dist/host/unbound.js +88 -0
- package/dist/host/unbound.js.map +1 -0
- package/dist/host/uuid.d.ts +3 -0
- package/dist/host/uuid.d.ts.map +1 -0
- package/dist/host/uuid.js +38 -0
- package/dist/host/uuid.js.map +1 -0
- package/dist/index.d.ts +29 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/jobs/definition.d.ts +96 -0
- package/dist/jobs/definition.d.ts.map +1 -0
- package/dist/jobs/definition.js +83 -0
- package/dist/jobs/definition.js.map +1 -0
- package/dist/jobs/index.d.ts +5 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +3 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/internal.d.ts +3 -0
- package/dist/jobs/internal.d.ts.map +1 -0
- package/dist/jobs/internal.js +4 -0
- package/dist/jobs/internal.js.map +1 -0
- package/dist/jobs/job.d.ts +149 -0
- package/dist/jobs/job.d.ts.map +1 -0
- package/dist/jobs/job.js +387 -0
- package/dist/jobs/job.js.map +1 -0
- package/dist/jobs/persisted.d.ts +38 -0
- package/dist/jobs/persisted.d.ts.map +1 -0
- package/dist/jobs/persisted.js +95 -0
- package/dist/jobs/persisted.js.map +1 -0
- package/dist/jobs/records.d.ts +231 -0
- package/dist/jobs/records.d.ts.map +1 -0
- package/dist/jobs/records.js +871 -0
- package/dist/jobs/records.js.map +1 -0
- package/dist/jobs/run-states.d.ts +69 -0
- package/dist/jobs/run-states.d.ts.map +1 -0
- package/dist/jobs/run-states.js +228 -0
- package/dist/jobs/run-states.js.map +1 -0
- package/dist/jobs/run.d.ts +117 -0
- package/dist/jobs/run.d.ts.map +1 -0
- package/dist/jobs/run.js +204 -0
- package/dist/jobs/run.js.map +1 -0
- package/dist/jobs/running.d.ts +44 -0
- package/dist/jobs/running.d.ts.map +1 -0
- package/dist/jobs/running.js +117 -0
- package/dist/jobs/running.js.map +1 -0
- package/dist/jobs/stored.d.ts +63 -0
- package/dist/jobs/stored.d.ts.map +1 -0
- package/dist/jobs/stored.js +55 -0
- package/dist/jobs/stored.js.map +1 -0
- package/dist/link/binary.d.ts +4 -0
- package/dist/link/binary.d.ts.map +1 -0
- package/dist/link/binary.js +544 -0
- package/dist/link/binary.js.map +1 -0
- package/dist/link/channel.d.ts +68 -0
- package/dist/link/channel.d.ts.map +1 -0
- package/dist/link/channel.js +215 -0
- package/dist/link/channel.js.map +1 -0
- package/dist/link/errors.d.ts +7 -0
- package/dist/link/errors.d.ts.map +1 -0
- package/dist/link/errors.js +21 -0
- package/dist/link/errors.js.map +1 -0
- package/dist/link/index.d.ts +8 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +8 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/internal.d.ts +9 -0
- package/dist/link/internal.d.ts.map +1 -0
- package/dist/link/internal.js +10 -0
- package/dist/link/internal.js.map +1 -0
- package/dist/link/ipc.d.ts +22 -0
- package/dist/link/ipc.d.ts.map +1 -0
- package/dist/link/ipc.js +64 -0
- package/dist/link/ipc.js.map +1 -0
- package/dist/link/link.d.ts +34 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +87 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/message.d.ts +262 -0
- package/dist/link/message.d.ts.map +1 -0
- package/dist/link/message.js +156 -0
- package/dist/link/message.js.map +1 -0
- package/dist/link/part.d.ts +80 -0
- package/dist/link/part.d.ts.map +1 -0
- package/dist/link/part.js +165 -0
- package/dist/link/part.js.map +1 -0
- package/dist/link/text.d.ts +6 -0
- package/dist/link/text.d.ts.map +1 -0
- package/dist/link/text.js +355 -0
- package/dist/link/text.js.map +1 -0
- package/dist/link/values.d.ts +40 -0
- package/dist/link/values.d.ts.map +1 -0
- package/dist/link/values.js +121 -0
- package/dist/link/values.js.map +1 -0
- package/dist/link/websocket.d.ts +26 -0
- package/dist/link/websocket.d.ts.map +1 -0
- package/dist/link/websocket.js +91 -0
- package/dist/link/websocket.js.map +1 -0
- package/dist/node/app/app.d.ts +269 -0
- package/dist/node/app/app.d.ts.map +1 -0
- package/dist/node/app/app.js +513 -0
- package/dist/node/app/app.js.map +1 -0
- package/dist/node/app/archive.d.ts +37 -0
- package/dist/node/app/archive.d.ts.map +1 -0
- package/dist/node/app/archive.js +204 -0
- package/dist/node/app/archive.js.map +1 -0
- package/dist/node/app/blobs.d.ts +23 -0
- package/dist/node/app/blobs.d.ts.map +1 -0
- package/dist/node/app/blobs.js +64 -0
- package/dist/node/app/blobs.js.map +1 -0
- package/dist/node/app/data.d.ts +35 -0
- package/dist/node/app/data.d.ts.map +1 -0
- package/dist/node/app/data.js +44 -0
- package/dist/node/app/data.js.map +1 -0
- package/dist/node/app/ephemeral-sessions.d.ts +20 -0
- package/dist/node/app/ephemeral-sessions.d.ts.map +1 -0
- package/dist/node/app/ephemeral-sessions.js +69 -0
- package/dist/node/app/ephemeral-sessions.js.map +1 -0
- package/dist/node/app/ephemeral.d.ts +11 -0
- package/dist/node/app/ephemeral.d.ts.map +1 -0
- package/dist/node/app/ephemeral.js +34 -0
- package/dist/node/app/ephemeral.js.map +1 -0
- package/dist/node/app/files-copy.d.ts +13 -0
- package/dist/node/app/files-copy.d.ts.map +1 -0
- package/dist/node/app/files-copy.js +86 -0
- package/dist/node/app/files-copy.js.map +1 -0
- package/dist/node/app/files-entry.d.ts +4 -0
- package/dist/node/app/files-entry.d.ts.map +1 -0
- package/dist/node/app/files-entry.js +7 -0
- package/dist/node/app/files-entry.js.map +1 -0
- package/dist/node/app/files-index.d.ts +180 -0
- package/dist/node/app/files-index.d.ts.map +1 -0
- package/dist/node/app/files-index.js +535 -0
- package/dist/node/app/files-index.js.map +1 -0
- package/dist/node/app/files.d.ts +363 -0
- package/dist/node/app/files.d.ts.map +1 -0
- package/dist/node/app/files.js +368 -0
- package/dist/node/app/files.js.map +1 -0
- package/dist/node/app/folder-views.d.ts +21 -0
- package/dist/node/app/folder-views.d.ts.map +1 -0
- package/dist/node/app/folder-views.js +55 -0
- package/dist/node/app/folder-views.js.map +1 -0
- package/dist/node/app/index.d.ts +12 -0
- package/dist/node/app/index.d.ts.map +1 -0
- package/dist/node/app/index.js +15 -0
- package/dist/node/app/index.js.map +1 -0
- package/dist/node/app/info.d.ts +66 -0
- package/dist/node/app/info.d.ts.map +1 -0
- package/dist/node/app/info.js +37 -0
- package/dist/node/app/info.js.map +1 -0
- package/dist/node/app/invite.d.ts +5 -0
- package/dist/node/app/invite.d.ts.map +1 -0
- package/dist/node/app/invite.js +64 -0
- package/dist/node/app/invite.js.map +1 -0
- package/dist/node/app/layout.d.ts +36 -0
- package/dist/node/app/layout.d.ts.map +1 -0
- package/dist/node/app/layout.js +87 -0
- package/dist/node/app/layout.js.map +1 -0
- package/dist/node/app/owner.d.ts +31 -0
- package/dist/node/app/owner.d.ts.map +1 -0
- package/dist/node/app/owner.js +104 -0
- package/dist/node/app/owner.js.map +1 -0
- package/dist/node/app/pairing.d.ts +55 -0
- package/dist/node/app/pairing.d.ts.map +1 -0
- package/dist/node/app/pairing.js +183 -0
- package/dist/node/app/pairing.js.map +1 -0
- package/dist/node/app/secrets.d.ts +16 -0
- package/dist/node/app/secrets.d.ts.map +1 -0
- package/dist/node/app/secrets.js +72 -0
- package/dist/node/app/secrets.js.map +1 -0
- package/dist/node/app/sessions.d.ts +72 -0
- package/dist/node/app/sessions.d.ts.map +1 -0
- package/dist/node/app/sessions.js +222 -0
- package/dist/node/app/sessions.js.map +1 -0
- package/dist/node/app/tar.d.ts +24 -0
- package/dist/node/app/tar.d.ts.map +1 -0
- package/dist/node/app/tar.js +167 -0
- package/dist/node/app/tar.js.map +1 -0
- package/dist/node/app/uploads.d.ts +37 -0
- package/dist/node/app/uploads.d.ts.map +1 -0
- package/dist/node/app/uploads.js +157 -0
- package/dist/node/app/uploads.js.map +1 -0
- package/dist/node/app/users.d.ts +37 -0
- package/dist/node/app/users.d.ts.map +1 -0
- package/dist/node/app/users.js +62 -0
- package/dist/node/app/users.js.map +1 -0
- package/dist/node/app/worker.d.ts +18 -0
- package/dist/node/app/worker.d.ts.map +1 -0
- package/dist/node/app/worker.js +84 -0
- package/dist/node/app/worker.js.map +1 -0
- package/dist/node/compression.d.ts +7 -0
- package/dist/node/compression.d.ts.map +1 -0
- package/dist/node/compression.js +25 -0
- package/dist/node/compression.js.map +1 -0
- package/dist/node/http/admission.d.ts +63 -0
- package/dist/node/http/admission.d.ts.map +1 -0
- package/dist/node/http/admission.js +134 -0
- package/dist/node/http/admission.js.map +1 -0
- package/dist/node/http/authenticate.d.ts +21 -0
- package/dist/node/http/authenticate.d.ts.map +1 -0
- package/dist/node/http/authenticate.js +34 -0
- package/dist/node/http/authenticate.js.map +1 -0
- package/dist/node/http/cookies.d.ts +32 -0
- package/dist/node/http/cookies.d.ts.map +1 -0
- package/dist/node/http/cookies.js +70 -0
- package/dist/node/http/cookies.js.map +1 -0
- package/dist/node/http/file.d.ts +23 -0
- package/dist/node/http/file.d.ts.map +1 -0
- package/dist/node/http/file.js +94 -0
- package/dist/node/http/file.js.map +1 -0
- package/dist/node/http/headers.d.ts +37 -0
- package/dist/node/http/headers.d.ts.map +1 -0
- package/dist/node/http/headers.js +136 -0
- package/dist/node/http/headers.js.map +1 -0
- package/dist/node/http/http.d.ts +111 -0
- package/dist/node/http/http.d.ts.map +1 -0
- package/dist/node/http/http.js +524 -0
- package/dist/node/http/http.js.map +1 -0
- package/dist/node/http/incoming.d.ts +19 -0
- package/dist/node/http/incoming.d.ts.map +1 -0
- package/dist/node/http/incoming.js +31 -0
- package/dist/node/http/incoming.js.map +1 -0
- package/dist/node/http/index.d.ts +11 -0
- package/dist/node/http/index.d.ts.map +1 -0
- package/dist/node/http/index.js +12 -0
- package/dist/node/http/index.js.map +1 -0
- package/dist/node/http/node.d.ts +78 -0
- package/dist/node/http/node.d.ts.map +1 -0
- package/dist/node/http/node.js +291 -0
- package/dist/node/http/node.js.map +1 -0
- package/dist/node/http/request.d.ts +60 -0
- package/dist/node/http/request.d.ts.map +1 -0
- package/dist/node/http/request.js +118 -0
- package/dist/node/http/request.js.map +1 -0
- package/dist/node/http/response.d.ts +63 -0
- package/dist/node/http/response.d.ts.map +1 -0
- package/dist/node/http/response.js +202 -0
- package/dist/node/http/response.js.map +1 -0
- package/dist/node/http/router.d.ts +132 -0
- package/dist/node/http/router.d.ts.map +1 -0
- package/dist/node/http/router.js +267 -0
- package/dist/node/http/router.js.map +1 -0
- package/dist/node/http/upgrades.d.ts +61 -0
- package/dist/node/http/upgrades.d.ts.map +1 -0
- package/dist/node/http/upgrades.js +192 -0
- package/dist/node/http/upgrades.js.map +1 -0
- package/dist/node/plugins/base-inputs.d.ts +14 -0
- package/dist/node/plugins/base-inputs.d.ts.map +1 -0
- package/dist/node/plugins/base-inputs.js +33 -0
- package/dist/node/plugins/base-inputs.js.map +1 -0
- package/dist/node/plugins/build.d.ts +77 -0
- package/dist/node/plugins/build.d.ts.map +1 -0
- package/dist/node/plugins/build.js +576 -0
- package/dist/node/plugins/build.js.map +1 -0
- package/dist/node/plugins/css-modules.d.ts +13 -0
- package/dist/node/plugins/css-modules.d.ts.map +1 -0
- package/dist/node/plugins/css-modules.js +58 -0
- package/dist/node/plugins/css-modules.js.map +1 -0
- package/dist/node/plugins/discover.d.ts +67 -0
- package/dist/node/plugins/discover.d.ts.map +1 -0
- package/dist/node/plugins/discover.js +369 -0
- package/dist/node/plugins/discover.js.map +1 -0
- package/dist/node/plugins/evaluate.d.ts +33 -0
- package/dist/node/plugins/evaluate.d.ts.map +1 -0
- package/dist/node/plugins/evaluate.js +121 -0
- package/dist/node/plugins/evaluate.js.map +1 -0
- package/dist/node/plugins/index.d.ts +11 -0
- package/dist/node/plugins/index.d.ts.map +1 -0
- package/dist/node/plugins/index.js +13 -0
- package/dist/node/plugins/index.js.map +1 -0
- package/dist/node/plugins/install.d.ts +38 -0
- package/dist/node/plugins/install.d.ts.map +1 -0
- package/dist/node/plugins/install.js +213 -0
- package/dist/node/plugins/install.js.map +1 -0
- package/dist/node/plugins/plugins.d.ts +162 -0
- package/dist/node/plugins/plugins.d.ts.map +1 -0
- package/dist/node/plugins/plugins.js +244 -0
- package/dist/node/plugins/plugins.js.map +1 -0
- package/dist/node/plugins/runtime.d.ts +57 -0
- package/dist/node/plugins/runtime.d.ts.map +1 -0
- package/dist/node/plugins/runtime.js +92 -0
- package/dist/node/plugins/runtime.js.map +1 -0
- package/dist/node/plugins/stack.d.ts +16 -0
- package/dist/node/plugins/stack.d.ts.map +1 -0
- package/dist/node/plugins/stack.js +61 -0
- package/dist/node/plugins/stack.js.map +1 -0
- package/dist/node/plugins/testing.d.ts +58 -0
- package/dist/node/plugins/testing.d.ts.map +1 -0
- package/dist/node/plugins/testing.js +210 -0
- package/dist/node/plugins/testing.js.map +1 -0
- package/dist/node/plugins/watcher.d.ts +69 -0
- package/dist/node/plugins/watcher.d.ts.map +1 -0
- package/dist/node/plugins/watcher.js +622 -0
- package/dist/node/plugins/watcher.js.map +1 -0
- package/dist/node/surfaces/bundle.d.ts +31 -0
- package/dist/node/surfaces/bundle.d.ts.map +1 -0
- package/dist/node/surfaces/bundle.js +118 -0
- package/dist/node/surfaces/bundle.js.map +1 -0
- package/dist/node/surfaces/current.d.ts +17 -0
- package/dist/node/surfaces/current.d.ts.map +1 -0
- package/dist/node/surfaces/current.js +54 -0
- package/dist/node/surfaces/current.js.map +1 -0
- package/dist/node/surfaces/index.d.ts +6 -0
- package/dist/node/surfaces/index.d.ts.map +1 -0
- package/dist/node/surfaces/index.js +6 -0
- package/dist/node/surfaces/index.js.map +1 -0
- package/dist/node/surfaces/published.d.ts +27 -0
- package/dist/node/surfaces/published.d.ts.map +1 -0
- package/dist/node/surfaces/published.js +142 -0
- package/dist/node/surfaces/published.js.map +1 -0
- package/dist/node/surfaces/served.d.ts +15 -0
- package/dist/node/surfaces/served.d.ts.map +1 -0
- package/dist/node/surfaces/served.js +42 -0
- package/dist/node/surfaces/served.js.map +1 -0
- package/dist/node/surfaces/surface-build.d.ts +53 -0
- package/dist/node/surfaces/surface-build.d.ts.map +1 -0
- package/dist/node/surfaces/surface-build.js +105 -0
- package/dist/node/surfaces/surface-build.js.map +1 -0
- package/dist/node/surfaces/tui.d.ts +40 -0
- package/dist/node/surfaces/tui.d.ts.map +1 -0
- package/dist/node/surfaces/tui.js +55 -0
- package/dist/node/surfaces/tui.js.map +1 -0
- package/dist/node/surfaces/web.d.ts +56 -0
- package/dist/node/surfaces/web.d.ts.map +1 -0
- package/dist/node/surfaces/web.js +108 -0
- package/dist/node/surfaces/web.js.map +1 -0
- package/dist/node/tui/actions.d.ts +49 -0
- package/dist/node/tui/actions.d.ts.map +1 -0
- package/dist/node/tui/actions.js +195 -0
- package/dist/node/tui/actions.js.map +1 -0
- package/dist/node/tui/credentials.d.ts +17 -0
- package/dist/node/tui/credentials.d.ts.map +1 -0
- package/dist/node/tui/credentials.js +54 -0
- package/dist/node/tui/credentials.js.map +1 -0
- package/dist/node/tui/filter.d.ts +5 -0
- package/dist/node/tui/filter.d.ts.map +1 -0
- package/dist/node/tui/filter.js +79 -0
- package/dist/node/tui/filter.js.map +1 -0
- package/dist/node/tui/index.d.ts +6 -0
- package/dist/node/tui/index.d.ts.map +1 -0
- package/dist/node/tui/index.js +6 -0
- package/dist/node/tui/index.js.map +1 -0
- package/dist/node/tui/launcher.d.ts +40 -0
- package/dist/node/tui/launcher.d.ts.map +1 -0
- package/dist/node/tui/launcher.js +439 -0
- package/dist/node/tui/launcher.js.map +1 -0
- package/dist/node/tui/pipe.d.ts +18 -0
- package/dist/node/tui/pipe.d.ts.map +1 -0
- package/dist/node/tui/pipe.js +134 -0
- package/dist/node/tui/pipe.js.map +1 -0
- package/dist/node/tui/sandbox.d.ts +54 -0
- package/dist/node/tui/sandbox.d.ts.map +1 -0
- package/dist/node/tui/sandbox.js +431 -0
- package/dist/node/tui/sandbox.js.map +1 -0
- package/dist/node/workers/base.d.ts +30 -0
- package/dist/node/workers/base.d.ts.map +1 -0
- package/dist/node/workers/base.js +255 -0
- package/dist/node/workers/base.js.map +1 -0
- package/dist/node/workers/child.d.ts +4 -0
- package/dist/node/workers/child.d.ts.map +1 -0
- package/dist/node/workers/child.js +6 -0
- package/dist/node/workers/child.js.map +1 -0
- package/dist/node/workers/control.d.ts +83 -0
- package/dist/node/workers/control.d.ts.map +1 -0
- package/dist/node/workers/control.js +77 -0
- package/dist/node/workers/control.js.map +1 -0
- package/dist/node/workers/index.d.ts +4 -0
- package/dist/node/workers/index.d.ts.map +1 -0
- package/dist/node/workers/index.js +7 -0
- package/dist/node/workers/index.js.map +1 -0
- package/dist/node/workers/lock.d.ts +30 -0
- package/dist/node/workers/lock.d.ts.map +1 -0
- package/dist/node/workers/lock.js +180 -0
- package/dist/node/workers/lock.js.map +1 -0
- package/dist/node/workers/main.d.ts +46 -0
- package/dist/node/workers/main.d.ts.map +1 -0
- package/dist/node/workers/main.js +230 -0
- package/dist/node/workers/main.js.map +1 -0
- package/dist/node/workers/process.d.ts +42 -0
- package/dist/node/workers/process.d.ts.map +1 -0
- package/dist/node/workers/process.js +125 -0
- package/dist/node/workers/process.js.map +1 -0
- package/dist/node/workers/workers.d.ts +122 -0
- package/dist/node/workers/workers.d.ts.map +1 -0
- package/dist/node/workers/workers.js +677 -0
- package/dist/node/workers/workers.js.map +1 -0
- package/dist/output.d.ts +1 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +4 -2
- package/dist/output.js.map +1 -1
- package/dist/react/hooks.d.ts +43 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +82 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +4 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/stores.d.ts +9 -0
- package/dist/react/stores.d.ts.map +1 -0
- package/dist/react/stores.js +37 -0
- package/dist/react/stores.js.map +1 -0
- package/dist/registries/contribution.d.ts +50 -0
- package/dist/registries/contribution.d.ts.map +1 -0
- package/dist/registries/contribution.js +129 -0
- package/dist/registries/contribution.js.map +1 -0
- package/dist/registries/entries.d.ts +18 -0
- package/dist/registries/entries.d.ts.map +1 -0
- package/dist/registries/entries.js +42 -0
- package/dist/registries/entries.js.map +1 -0
- package/dist/registries/index.d.ts +3 -0
- package/dist/registries/index.d.ts.map +1 -0
- package/dist/registries/index.js +5 -0
- package/dist/registries/index.js.map +1 -0
- package/dist/registries/internal.d.ts +4 -0
- package/dist/registries/internal.d.ts.map +1 -0
- package/dist/registries/internal.js +5 -0
- package/dist/registries/internal.js.map +1 -0
- package/dist/registries/record.d.ts +115 -0
- package/dist/registries/record.d.ts.map +1 -0
- package/dist/registries/record.js +283 -0
- package/dist/registries/record.js.map +1 -0
- package/dist/registries/registry.d.ts +74 -0
- package/dist/registries/registry.d.ts.map +1 -0
- package/dist/registries/registry.js +14 -0
- package/dist/registries/registry.js.map +1 -0
- package/dist/registries/value.d.ts +48 -0
- package/dist/registries/value.d.ts.map +1 -0
- package/dist/registries/value.js +224 -0
- package/dist/registries/value.js.map +1 -0
- package/dist/remote/calls.d.ts +25 -0
- package/dist/remote/calls.d.ts.map +1 -0
- package/dist/remote/calls.js +62 -0
- package/dist/remote/calls.js.map +1 -0
- package/dist/remote/consumer.d.ts +43 -0
- package/dist/remote/consumer.d.ts.map +1 -0
- package/dist/remote/consumer.js +350 -0
- package/dist/remote/consumer.js.map +1 -0
- package/dist/remote/hold.d.ts +141 -0
- package/dist/remote/hold.d.ts.map +1 -0
- package/dist/remote/hold.js +579 -0
- package/dist/remote/hold.js.map +1 -0
- package/dist/remote/host-link.d.ts +77 -0
- package/dist/remote/host-link.d.ts.map +1 -0
- package/dist/remote/host-link.js +184 -0
- package/dist/remote/host-link.js.map +1 -0
- package/dist/remote/internal.d.ts +6 -0
- package/dist/remote/internal.d.ts.map +1 -0
- package/dist/remote/internal.js +6 -0
- package/dist/remote/internal.js.map +1 -0
- package/dist/remote/path.d.ts +46 -0
- package/dist/remote/path.d.ts.map +1 -0
- package/dist/remote/path.js +73 -0
- package/dist/remote/path.js.map +1 -0
- package/dist/remote/provider.d.ts +89 -0
- package/dist/remote/provider.d.ts.map +1 -0
- package/dist/remote/provider.js +597 -0
- package/dist/remote/provider.js.map +1 -0
- package/dist/remote/relay.d.ts +69 -0
- package/dist/remote/relay.d.ts.map +1 -0
- package/dist/remote/relay.js +219 -0
- package/dist/remote/relay.js.map +1 -0
- package/dist/remote/remote-object.d.ts +138 -0
- package/dist/remote/remote-object.d.ts.map +1 -0
- package/dist/remote/remote-object.js +492 -0
- package/dist/remote/remote-object.js.map +1 -0
- package/dist/remote/replica.d.ts +59 -0
- package/dist/remote/replica.d.ts.map +1 -0
- package/dist/remote/replica.js +125 -0
- package/dist/remote/replica.js.map +1 -0
- package/dist/sqlite/cloudflare.d.ts +2 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -1
- package/dist/sqlite/cloudflare.js +10 -0
- package/dist/sqlite/cloudflare.js.map +1 -1
- package/dist/sqlite/database.d.ts +5 -2
- package/dist/sqlite/database.d.ts.map +1 -1
- package/dist/sqlite/database.js.map +1 -1
- package/dist/sqlite/node.d.ts +13 -2
- package/dist/sqlite/node.d.ts.map +1 -1
- package/dist/sqlite/node.js +31 -8
- package/dist/sqlite/node.js.map +1 -1
- package/dist/state/batch.d.ts +64 -0
- package/dist/state/batch.d.ts.map +1 -0
- package/dist/state/batch.js +164 -0
- package/dist/state/batch.js.map +1 -0
- package/dist/state/derive.d.ts +52 -0
- package/dist/state/derive.d.ts.map +1 -0
- package/dist/state/derive.js +182 -0
- package/dist/state/derive.js.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/internal.d.ts +6 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +8 -0
- package/dist/state/internal.js.map +1 -0
- package/dist/state/native-source.d.ts +106 -0
- package/dist/state/native-source.d.ts.map +1 -0
- package/dist/state/native-source.js +240 -0
- package/dist/state/native-source.js.map +1 -0
- package/dist/state/watchable.d.ts +114 -0
- package/dist/state/watchable.d.ts.map +1 -0
- package/dist/state/watchable.js +156 -0
- package/dist/state/watchable.js.map +1 -0
- package/dist/state/writable.d.ts +32 -0
- package/dist/state/writable.d.ts.map +1 -0
- package/dist/state/writable.js +49 -0
- package/dist/state/writable.js.map +1 -0
- package/dist/store/adapter.d.ts +67 -0
- package/dist/store/adapter.d.ts.map +1 -0
- package/dist/store/adapter.js +118 -0
- package/dist/store/adapter.js.map +1 -0
- package/dist/store/allocator.d.ts +17 -0
- package/dist/store/allocator.d.ts.map +1 -0
- package/dist/store/allocator.js +30 -0
- package/dist/store/allocator.js.map +1 -0
- package/dist/store/applier.d.ts +8 -0
- package/dist/store/applier.d.ts.map +1 -0
- package/dist/store/applier.js +375 -0
- package/dist/store/applier.js.map +1 -0
- package/dist/store/apply-batch.d.ts +12 -0
- package/dist/store/apply-batch.d.ts.map +1 -0
- package/dist/store/apply-batch.js +83 -0
- package/dist/store/apply-batch.js.map +1 -0
- package/dist/store/archive.d.ts +32 -0
- package/dist/store/archive.d.ts.map +1 -0
- package/dist/store/archive.js +130 -0
- package/dist/store/archive.js.map +1 -0
- package/dist/store/backend.d.ts +10 -0
- package/dist/store/backend.d.ts.map +1 -0
- package/dist/store/backend.js +15 -0
- package/dist/store/backend.js.map +1 -0
- package/dist/store/catalog.d.ts +24 -0
- package/dist/store/catalog.d.ts.map +1 -0
- package/dist/store/catalog.js +17 -0
- package/dist/store/catalog.js.map +1 -0
- package/dist/store/claims.d.ts +23 -0
- package/dist/store/claims.d.ts.map +1 -0
- package/dist/store/claims.js +65 -0
- package/dist/store/claims.js.map +1 -0
- package/dist/store/columns.d.ts +77 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +77 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/engine.d.ts +176 -0
- package/dist/store/engine.d.ts.map +1 -0
- package/dist/store/engine.js +283 -0
- package/dist/store/engine.js.map +1 -0
- package/dist/store/evaluate.d.ts +17 -0
- package/dist/store/evaluate.d.ts.map +1 -0
- package/dist/store/evaluate.js +128 -0
- package/dist/store/evaluate.js.map +1 -0
- package/dist/store/export.d.ts +17 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/export.js +200 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/expression.d.ts +150 -0
- package/dist/store/expression.d.ts.map +1 -0
- package/dist/store/expression.js +268 -0
- package/dist/store/expression.js.map +1 -0
- package/dist/store/import.d.ts +10 -0
- package/dist/store/import.d.ts.map +1 -0
- package/dist/store/import.js +276 -0
- package/dist/store/import.js.map +1 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +13 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/json-column.d.ts +33 -0
- package/dist/store/json-column.d.ts.map +1 -0
- package/dist/store/json-column.js +62 -0
- package/dist/store/json-column.js.map +1 -0
- package/dist/store/jsonl.d.ts +9 -0
- package/dist/store/jsonl.d.ts.map +1 -0
- package/dist/store/jsonl.js +61 -0
- package/dist/store/jsonl.js.map +1 -0
- package/dist/store/live-query.d.ts +108 -0
- package/dist/store/live-query.d.ts.map +1 -0
- package/dist/store/live-query.js +254 -0
- package/dist/store/live-query.js.map +1 -0
- package/dist/store/outbox.d.ts +26 -0
- package/dist/store/outbox.d.ts.map +1 -0
- package/dist/store/outbox.js +80 -0
- package/dist/store/outbox.js.map +1 -0
- package/dist/store/query.d.ts +39 -0
- package/dist/store/query.d.ts.map +1 -0
- package/dist/store/query.js +97 -0
- package/dist/store/query.js.map +1 -0
- package/dist/store/refusal.d.ts +15 -0
- package/dist/store/refusal.d.ts.map +1 -0
- package/dist/store/refusal.js +36 -0
- package/dist/store/refusal.js.map +1 -0
- package/dist/store/rows.d.ts +80 -0
- package/dist/store/rows.d.ts.map +1 -0
- package/dist/store/rows.js +183 -0
- package/dist/store/rows.js.map +1 -0
- package/dist/store/schema.d.ts +25 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +115 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/sql.d.ts +73 -0
- package/dist/store/sql.d.ts.map +1 -0
- package/dist/store/sql.js +234 -0
- package/dist/store/sql.js.map +1 -0
- package/dist/store/step.d.ts +50 -0
- package/dist/store/step.d.ts.map +1 -0
- package/dist/store/step.js +52 -0
- package/dist/store/step.js.map +1 -0
- package/dist/store/store.d.ts +171 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +818 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/table-changes.d.ts +29 -0
- package/dist/store/table-changes.d.ts.map +1 -0
- package/dist/store/table-changes.js +102 -0
- package/dist/store/table-changes.js.map +1 -0
- package/dist/store/table-evolve.d.ts +74 -0
- package/dist/store/table-evolve.d.ts.map +1 -0
- package/dist/store/table-evolve.js +201 -0
- package/dist/store/table-evolve.js.map +1 -0
- package/dist/store/table-handle.d.ts +73 -0
- package/dist/store/table-handle.d.ts.map +1 -0
- package/dist/store/table-handle.js +101 -0
- package/dist/store/table-handle.js.map +1 -0
- package/dist/store/table-history.d.ts +75 -0
- package/dist/store/table-history.d.ts.map +1 -0
- package/dist/store/table-history.js +42 -0
- package/dist/store/table-history.js.map +1 -0
- package/dist/store/table-migration.d.ts +16 -0
- package/dist/store/table-migration.d.ts.map +1 -0
- package/dist/store/table-migration.js +202 -0
- package/dist/store/table-migration.js.map +1 -0
- package/dist/store/table-writes.d.ts +125 -0
- package/dist/store/table-writes.d.ts.map +1 -0
- package/dist/store/table-writes.js +170 -0
- package/dist/store/table-writes.js.map +1 -0
- package/dist/store/table.d.ts +80 -0
- package/dist/store/table.d.ts.map +1 -0
- package/dist/store/table.js +103 -0
- package/dist/store/table.js.map +1 -0
- package/dist/store/text.d.ts +14 -0
- package/dist/store/text.d.ts.map +1 -0
- package/dist/store/text.js +51 -0
- package/dist/store/text.js.map +1 -0
- package/dist/store/writes.d.ts +5 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +4 -0
- package/dist/store/writes.js.map +1 -0
- package/dist/surfaces/active-language.d.ts +20 -0
- package/dist/surfaces/active-language.d.ts.map +1 -0
- package/dist/surfaces/active-language.js +78 -0
- package/dist/surfaces/active-language.js.map +1 -0
- package/dist/surfaces/active-theme.d.ts +16 -0
- package/dist/surfaces/active-theme.d.ts.map +1 -0
- package/dist/surfaces/active-theme.js +47 -0
- package/dist/surfaces/active-theme.js.map +1 -0
- package/dist/surfaces/client.d.ts +96 -0
- package/dist/surfaces/client.d.ts.map +1 -0
- package/dist/surfaces/client.js +264 -0
- package/dist/surfaces/client.js.map +1 -0
- package/dist/surfaces/connection.d.ts +49 -0
- package/dist/surfaces/connection.d.ts.map +1 -0
- package/dist/surfaces/connection.js +142 -0
- package/dist/surfaces/connection.js.map +1 -0
- package/dist/surfaces/format.d.ts +5 -0
- package/dist/surfaces/format.d.ts.map +1 -0
- package/dist/surfaces/format.js +37 -0
- package/dist/surfaces/format.js.map +1 -0
- package/dist/surfaces/index.d.ts +15 -0
- package/dist/surfaces/index.d.ts.map +1 -0
- package/dist/surfaces/index.js +18 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/language.d.ts +53 -0
- package/dist/surfaces/language.d.ts.map +1 -0
- package/dist/surfaces/language.js +74 -0
- package/dist/surfaces/language.js.map +1 -0
- package/dist/surfaces/loaded.d.ts +42 -0
- package/dist/surfaces/loaded.d.ts.map +1 -0
- package/dist/surfaces/loaded.js +116 -0
- package/dist/surfaces/loaded.js.map +1 -0
- package/dist/surfaces/locale-choice.d.ts +25 -0
- package/dist/surfaces/locale-choice.d.ts.map +1 -0
- package/dist/surfaces/locale-choice.js +14 -0
- package/dist/surfaces/locale-choice.js.map +1 -0
- package/dist/surfaces/messages.d.ts +67 -0
- package/dist/surfaces/messages.d.ts.map +1 -0
- package/dist/surfaces/messages.js +112 -0
- package/dist/surfaces/messages.js.map +1 -0
- package/dist/surfaces/page-state.d.ts +14 -0
- package/dist/surfaces/page-state.d.ts.map +1 -0
- package/dist/surfaces/page-state.js +43 -0
- package/dist/surfaces/page-state.js.map +1 -0
- package/dist/surfaces/preference.d.ts +32 -0
- package/dist/surfaces/preference.d.ts.map +1 -0
- package/dist/surfaces/preference.js +72 -0
- package/dist/surfaces/preference.js.map +1 -0
- package/dist/surfaces/registered.d.ts +33 -0
- package/dist/surfaces/registered.d.ts.map +1 -0
- package/dist/surfaces/registered.js +51 -0
- package/dist/surfaces/registered.js.map +1 -0
- package/dist/surfaces/scripts.d.ts +84 -0
- package/dist/surfaces/scripts.d.ts.map +1 -0
- package/dist/surfaces/scripts.js +28 -0
- package/dist/surfaces/scripts.js.map +1 -0
- package/dist/surfaces/theme-choice.d.ts +31 -0
- package/dist/surfaces/theme-choice.d.ts.map +1 -0
- package/dist/surfaces/theme-choice.js +18 -0
- package/dist/surfaces/theme-choice.js.map +1 -0
- package/dist/surfaces/themes.d.ts +43 -0
- package/dist/surfaces/themes.d.ts.map +1 -0
- package/dist/surfaces/themes.js +110 -0
- package/dist/surfaces/themes.js.map +1 -0
- package/dist/surfaces/translations.d.ts +29 -0
- package/dist/surfaces/translations.d.ts.map +1 -0
- package/dist/surfaces/translations.js +57 -0
- package/dist/surfaces/translations.js.map +1 -0
- package/dist/sync/batch.d.ts +18 -0
- package/dist/sync/batch.d.ts.map +1 -0
- package/dist/sync/batch.js +125 -0
- package/dist/sync/batch.js.map +1 -0
- package/dist/sync/client.d.ts +166 -0
- package/dist/sync/client.d.ts.map +1 -0
- package/dist/sync/client.js +438 -0
- package/dist/sync/client.js.map +1 -0
- package/dist/sync/files.d.ts +46 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +13 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/filesystem.d.ts +37 -0
- package/dist/sync/filesystem.d.ts.map +1 -0
- package/dist/sync/filesystem.js +185 -0
- package/dist/sync/filesystem.js.map +1 -0
- package/dist/sync/index.d.ts +8 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +9 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/lines.d.ts +18 -0
- package/dist/sync/lines.d.ts.map +1 -0
- package/dist/sync/lines.js +46 -0
- package/dist/sync/lines.js.map +1 -0
- package/dist/sync/remote.d.ts +130 -0
- package/dist/sync/remote.d.ts.map +1 -0
- package/dist/sync/remote.js +46 -0
- package/dist/sync/remote.js.map +1 -0
- package/dist/sync/state.d.ts +17 -0
- package/dist/sync/state.d.ts.map +1 -0
- package/dist/sync/state.js +40 -0
- package/dist/sync/state.js.map +1 -0
- package/dist/telemetry-ingest/batch.d.ts +70 -0
- package/dist/telemetry-ingest/batch.d.ts.map +1 -0
- package/dist/telemetry-ingest/batch.js +110 -0
- package/dist/telemetry-ingest/batch.js.map +1 -0
- package/dist/telemetry-ingest/facet.d.ts +21 -0
- package/dist/telemetry-ingest/facet.d.ts.map +1 -0
- package/dist/telemetry-ingest/facet.js +96 -0
- package/dist/telemetry-ingest/facet.js.map +1 -0
- package/dist/telemetry-ingest/index.d.ts +5 -0
- package/dist/telemetry-ingest/index.d.ts.map +1 -0
- package/dist/telemetry-ingest/index.js +8 -0
- package/dist/telemetry-ingest/index.js.map +1 -0
- package/dist/telemetry-ingest/recorder.d.ts +50 -0
- package/dist/telemetry-ingest/recorder.d.ts.map +1 -0
- package/dist/telemetry-ingest/recorder.js +298 -0
- package/dist/telemetry-ingest/recorder.js.map +1 -0
- package/dist/telemetry-ingest/sender.d.ts +14 -0
- package/dist/telemetry-ingest/sender.d.ts.map +1 -0
- package/dist/telemetry-ingest/sender.js +64 -0
- package/dist/telemetry-ingest/sender.js.map +1 -0
- package/dist/telemetry-sqlite/index.d.ts +13 -4
- package/dist/telemetry-sqlite/index.d.ts.map +1 -1
- package/dist/telemetry-sqlite/index.js +81 -241
- package/dist/telemetry-sqlite/index.js.map +1 -1
- package/dist/telemetry-sqlite/node.d.ts +13 -0
- package/dist/telemetry-sqlite/node.d.ts.map +1 -0
- package/dist/telemetry-sqlite/node.js +27 -0
- package/dist/telemetry-sqlite/node.js.map +1 -0
- package/dist/telemetry-sqlite/schema.d.ts +9 -0
- package/dist/telemetry-sqlite/schema.d.ts.map +1 -0
- package/dist/telemetry-sqlite/schema.js +61 -0
- package/dist/telemetry-sqlite/schema.js.map +1 -0
- package/dist/telemetry-sqlite/store.d.ts +3 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -1
- package/dist/telemetry-sqlite/store.js +24 -13
- package/dist/telemetry-sqlite/store.js.map +1 -1
- package/dist/telemetry.d.ts +937 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +470 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tui/bridge.d.ts +112 -0
- package/dist/tui/bridge.d.ts.map +1 -0
- package/dist/tui/bridge.js +9 -0
- package/dist/tui/bridge.js.map +1 -0
- package/dist/tui/channel.d.ts +44 -0
- package/dist/tui/channel.d.ts.map +1 -0
- package/dist/tui/channel.js +150 -0
- package/dist/tui/channel.js.map +1 -0
- package/dist/tui/frames.d.ts +5 -0
- package/dist/tui/frames.d.ts.map +1 -0
- package/dist/tui/frames.js +52 -0
- package/dist/tui/frames.js.map +1 -0
- package/dist/tui/index.d.ts +7 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/runtime.d.ts +46 -0
- package/dist/tui/runtime.d.ts.map +1 -0
- package/dist/tui/runtime.js +101 -0
- package/dist/tui/runtime.js.map +1 -0
- package/dist/tui/scope.d.ts +46 -0
- package/dist/tui/scope.d.ts.map +1 -0
- package/dist/tui/scope.js +141 -0
- package/dist/tui/scope.js.map +1 -0
- package/dist/tui/terminal.d.ts +15 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +37 -0
- package/dist/tui/terminal.js.map +1 -0
- package/dist/tui/theme.d.ts +17 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +38 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/watch.d.ts +194 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +383 -0
- package/dist/watch.js.map +1 -0
- package/dist/web/environment.d.ts +4 -0
- package/dist/web/environment.d.ts.map +1 -0
- package/dist/web/environment.js +37 -0
- package/dist/web/environment.js.map +1 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +7 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/language.d.ts +7 -0
- package/dist/web/language.d.ts.map +1 -0
- package/dist/web/language.js +21 -0
- package/dist/web/language.js.map +1 -0
- package/dist/web/page.d.ts +29 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +92 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/scripts.d.ts +23 -0
- package/dist/web/scripts.d.ts.map +1 -0
- package/dist/web/scripts.js +50 -0
- package/dist/web/scripts.js.map +1 -0
- package/dist/web/styles.d.ts +17 -0
- package/dist/web/styles.d.ts.map +1 -0
- package/dist/web/styles.js +218 -0
- package/dist/web/styles.js.map +1 -0
- package/dist/web/themes.d.ts +6 -0
- package/dist/web/themes.d.ts.map +1 -0
- package/dist/web/themes.js +31 -0
- package/dist/web/themes.js.map +1 -0
- package/docs/benchmarks.md +1036 -0
- package/docs/decisions.md +3436 -0
- package/docs/dependencies/book.md +1671 -0
- package/docs/dependencies/index.html +2641 -0
- package/docs/dependencies/model.md +330 -0
- package/docs/design.md +3065 -0
- package/docs/durable-observers/book.md +432 -0
- package/docs/durable-observers/index.html +517 -0
- package/docs/flow-control/book.md +333 -0
- package/docs/flow-control/fold/index.html +265 -0
- package/docs/flow-control/index.html +548 -0
- package/docs/flow-control/window/index.html +228 -0
- package/docs/guide-plugins-hosts/book.md +957 -0
- package/docs/guide-plugins-hosts/index.html +952 -0
- package/docs/http-workers/book.md +378 -0
- package/docs/http-workers/index.html +515 -0
- package/docs/i18n/book.md +217 -0
- package/docs/i18n/index.html +344 -0
- package/docs/layer-1.md +311 -0
- package/docs/layer-2.md +216 -0
- package/docs/p3-features/README.md +6 -0
- package/docs/p3-features/book.md +478 -0
- package/docs/plugin-authoring.md +276 -0
- package/docs/plugin-model/book.md +186 -0
- package/docs/plugin-model/index.html +310 -0
- package/docs/plugin-primer/book.md +273 -0
- package/docs/plugin-primer/index.html +430 -0
- package/docs/slice-1.md +236 -0
- package/docs/slice-10.md +288 -0
- package/docs/slice-11.md +114 -0
- package/docs/slice-12.md +132 -0
- package/docs/slice-13.md +121 -0
- package/docs/slice-2.md +174 -0
- package/docs/slice-3a.md +296 -0
- package/docs/slice-3b.md +197 -0
- package/docs/slice-4.md +146 -0
- package/docs/slice-4a.md +418 -0
- package/docs/slice-4b.md +208 -0
- package/docs/slice-5.md +281 -0
- package/docs/slice-6a.md +676 -0
- package/docs/slice-6b.md +332 -0
- package/docs/slice-7a.md +130 -0
- package/docs/slice-7b/book.md +608 -0
- package/docs/slice-7b/index.html +842 -0
- package/docs/slice-7b.md +255 -0
- package/docs/slice-7c.md +165 -0
- package/docs/slice-8.md +194 -0
- package/docs/slice-9.md +110 -0
- package/docs/slices.md +241 -0
- package/docs/store/book.md +670 -0
- package/docs/store/index.html +861 -0
- package/docs/store/walkthrough.md +193 -0
- package/docs/theming/book.md +223 -0
- package/docs/theming/index.html +371 -0
- package/docs/tutorial/book.md +2169 -0
- package/docs/tutorial/index.html +2112 -0
- package/docs/tutorial/screens/click-after.png +0 -0
- package/docs/tutorial/screens/click-before.png +0 -0
- package/docs/tutorial/screens/edited.png +0 -0
- package/docs/tutorial/screens/french.png +0 -0
- package/docs/tutorial/screens/harbor.png +0 -0
- package/docs/tutorial/screens/page.png +0 -0
- package/docs/tutorial/screens/traces-ada.png +0 -0
- package/docs/tutorial/screens/traces.png +0 -0
- package/package.json +114 -20
- package/src/delta/README.md +69 -0
- package/dist/cell.d.ts +0 -122
- package/dist/cell.d.ts.map +0 -1
- package/dist/cell.js +0 -356
- package/dist/cell.js.map +0 -1
- package/dist/cluster.d.ts +0 -27
- package/dist/cluster.d.ts.map +0 -1
- package/dist/cluster.js +0 -230
- package/dist/cluster.js.map +0 -1
- package/dist/connection.d.ts +0 -270
- package/dist/connection.d.ts.map +0 -1
- package/dist/connection.js +0 -1216
- package/dist/connection.js.map +0 -1
- package/dist/contract.d.ts +0 -208
- package/dist/contract.d.ts.map +0 -1
- package/dist/contract.js +0 -246
- package/dist/contract.js.map +0 -1
- package/dist/declare.d.ts +0 -33
- package/dist/declare.d.ts.map +0 -1
- package/dist/declare.js +0 -2
- package/dist/declare.js.map +0 -1
- package/dist/errors.d.ts +0 -28
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -59
- package/dist/errors.js.map +0 -1
- package/dist/host.d.ts +0 -348
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -1000
- package/dist/host.js.map +0 -1
- package/dist/link.d.ts +0 -107
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js +0 -355
- package/dist/link.js.map +0 -1
- package/dist/loader.d.ts +0 -4
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -73
- package/dist/loader.js.map +0 -1
- package/dist/manager.d.ts +0 -115
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -345
- package/dist/manager.js.map +0 -1
- package/dist/node.d.ts +0 -4
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -4
- package/dist/node.js.map +0 -1
- package/dist/object.d.ts +0 -438
- package/dist/object.d.ts.map +0 -1
- package/dist/object.js +0 -1571
- package/dist/object.js.map +0 -1
- package/dist/publish.d.ts +0 -5
- package/dist/publish.d.ts.map +0 -1
- package/dist/publish.js +0 -40
- package/dist/publish.js.map +0 -1
- package/dist/registry.d.ts +0 -25
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -6
- package/dist/registry.js.map +0 -1
- package/dist/reload.d.ts +0 -126
- package/dist/reload.d.ts.map +0 -1
- package/dist/reload.js +0 -653
- package/dist/reload.js.map +0 -1
- package/dist/remote.d.ts +0 -165
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -612
- package/dist/remote.js.map +0 -1
- package/dist/schema.d.ts +0 -21
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -228
- package/dist/schema.js.map +0 -1
- package/dist/state.d.ts +0 -92
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -287
- package/dist/state.js.map +0 -1
- package/dist/types.d.ts +0 -88
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/websocket.d.ts +0 -15
- package/dist/websocket.d.ts.map +0 -1
- package/dist/websocket.js +0 -16
- package/dist/websocket.js.map +0 -1
- package/dist/wire.d.ts +0 -216
- package/dist/wire.d.ts.map +0 -1
- package/dist/wire.js +0 -165
- package/dist/wire.js.map +0 -1
- package/docs/guide.md +0 -814
- package/docs/spec.md +0 -288
- package/docs/tutorial.md +0 -931
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-evolve.js","sourceRoot":"","sources":["../../src/store/table-evolve.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,mHAAmH;AACnH,uHAAuH;AACvH,oGAAoG;AAEpG,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAkB,MAAM,0BAA0B,CAAC;AACpE,OAA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gBAAgB,IAAI,GAAG,CAAC,CAAC;QACxG,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC;IAC7B,CAAC;CACD;AAED,kGAAkG;AAClG,SAAS,SAAS,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AACpE,CAAC","sourcesContent":["// `evolveTable(previous, (t) => t…)` (slice 6a §9; decision \"Second spec review: the majority\"): the next version of a\n// table from the edits of one migration. The editor's types order the edits (`rename`, `add` and `json` before the\n// data step, `drop`, `index` and `dropIndex` after it) and track the columns and key through the chain; at runtime one\n// editor records the edits, checks each as it is made, and materializes the new version at the end.\n\nimport { opt } from \"../contracts/index.ts\";\nimport { editWith, type Increment } from \"../contracts/internal.ts\";\nimport { isOptional, type Optional } from \"../contracts/schema.ts\";\nimport {\n\ttype ColumnSchema,\n\ttype Columns,\n\ttype ColumnTypeOf,\n\tcheckColumnName,\n\tcolumnRecord,\n\tdescribeColumns,\n\ttype OrderColumn,\n\ttype RowOf,\n\ttype ValueOf,\n} from \"./columns.ts\";\nimport { type Condition, compileSet, compileWhere, type SetOf } from \"./expression.ts\";\nimport type { ColumnRefs } from \"./query.ts\";\nimport { INDEX_NAME, orderColumns, TableDefinition, type TableOptions } from \"./table.ts\";\nimport type { DataStep, TableEdit } from \"./table-history.ts\";\n\n/** The edits after the data step: `drop`, `index` and `dropIndex`; `C` and `K` are the columns and key so far. */\nexport interface TableTailEditor<C extends Columns, K extends readonly string[]> {\n\t/** Drops a non-key column; its indexes are dropped first, in the same commit. */\n\tdrop<N extends Exclude<keyof C & string, K[number]>>(name: N): TableTailEditor<Without<C, N>, K>;\n\t/** Adds an index (`[a-z0-9_]+`) over non-`opt` `str` or `int` columns; it ends with the key. */\n\tindex(name: string, columns: readonly OrderColumn<C>[]): TableTailEditor<C, K>;\n\t/** Drops an index. */\n\tdropIndex(name: string): TableTailEditor<C, K>;\n\t/** Type only: the columns and key so far. */\n\treadonly \"~columns\"?: C;\n\treadonly \"~key\"?: K;\n}\n\n/** The editor `evolveTable`'s edit gets: every edit; the column edits only before the data step. */\nexport interface TableEditor<C extends Columns, K extends readonly string[]> extends TableTailEditor<C, K> {\n\t/** Renames a column; the key, the indexes and a `json(...)` column's version column follow. */\n\trename<F extends keyof C & string, T extends string>(\n\t\tfrom: F,\n\t\tto: T,\n\t): TableEditor<Renamed<C, F, T>, RenamedKey<K, F, T>>;\n\t/** Adds a column: `opt(...)`, or a scalar one with a `default` (existing rows get it). */\n\tadd<N extends string, S extends AddedColumn>(name: N, column: S): TableEditor<With<C, N, S>, K>;\n\t/** A `json(...)` column's new version (its nullability kept): no DDL, no data step, cells migrate on access. */\n\tjson<N extends JsonNames<C>, S extends ColumnSchema>(name: N, column: S): TableEditor<WithJson<C, N, S>, K>;\n\t/**\n\t * The data step: `patch` gets each row as the columns stand here and returns new values of non-key columns (`{}`\n\t * stamps the row only); synchronous and pure, run in chunks of 100 in key order.\n\t */\n\trows(patch: (row: RowOf<C>) => PatchOf<C, K>): TableTailEditor<C, K>;\n\t/** The data step as one `updateWhere` over the rows not migrated yet. */\n\tupdate(step: {\n\t\treadonly where?: (row: ColumnRefs<C>) => Condition;\n\t\treadonly set: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>);\n\t}): TableTailEditor<C, K>;\n}\n\n/** A column `add` takes: `opt(...)` or one with a `default`. */\nexport type AddedColumn = ColumnSchema & (Optional | { readonly default: unknown });\n\n/** A `rows` patch: new values of non-key columns; `undefined` clears an `opt(...)` one. */\nexport type PatchOf<C extends Columns, K extends readonly string[]> = {\n\treadonly [P in Exclude<keyof C & string, K[number]>]?: ValueOf<C[P]>;\n};\n\ntype Renamed<C extends Columns, F extends keyof C, T extends string> = {\n\treadonly [P in keyof C as P extends F ? T : P]: C[P];\n};\n\ntype RenamedKey<K extends readonly string[], F, T extends string> = {\n\treadonly [I in keyof K]: K[I] extends F ? T : K[I];\n};\n\ntype With<C extends Columns, N extends string, S extends ColumnSchema> = {\n\treadonly [P in keyof C | N]: P extends N ? S : C[P & keyof C];\n};\n\ntype Without<C extends Columns, N extends keyof C> = { readonly [P in Exclude<keyof C, N>]: C[P] };\n\ntype JsonNames<C extends Columns> = { [P in keyof C]: ColumnTypeOf<C[P]> extends \"json\" ? P : never }[keyof C] & string;\n\ntype WithJson<C extends Columns, N extends keyof C & string, S extends ColumnSchema> = With<\n\tC,\n\tN,\n\tC[N] extends Optional ? Optional<Exclude<S, Optional>> : S\n>;\n\n/** `V + 1` for a literal version (contracts' `Increment<N>`); `number` stays `number`. */\ntype Next<V extends number> = number extends V\n\t? number\n\t: `${Increment<`${V}`>}` extends `${infer N extends number}`\n\t\t? N\n\t\t: number;\n\n/**\n * Appends the next version (`previous.version + 1`) with the edits `edit` makes; `edit` must return the editor it was\n * given. Every version is materialized and fingerprinted here; the object serves the newest, and its activation\n * migrates a store at an older version through each one.\n */\nexport function evolveTable<\n\tC extends Columns,\n\tK extends readonly string[],\n\tV extends number,\n\tE extends { readonly \"~columns\"?: Columns; readonly \"~key\"?: readonly string[] },\n>(\n\tprevious: TableDefinition<C, K, V>,\n\tedit: (t: TableEditor<C, K>) => E,\n): TableDefinition<NonNullable<E[\"~columns\"]>, NonNullable<E[\"~key\"]>, Next<V>> {\n\t// The runtime editor works on untyped definitions; the types live in the editor interfaces.\n\tconst editor = new Editor(previous as unknown as TableDefinition);\n\t// The editor interfaces track the edits in the types; at runtime every edit returns the same editor.\n\teditWith(editor as unknown as TableEditor<C, K>, edit, `${previous.name}: evolveTable`);\n\treturn editor.finish() as unknown as TableDefinition<NonNullable<E[\"~columns\"]>, NonNullable<E[\"~key\"]>, Next<V>>;\n}\n\n/**\n * The editor at runtime: the columns, key and indexes as the edits leave them, the edits before and after the data\n * step, and the step. Each edit is checked as it is made (declaration policy: JavaScript callers reach the checks).\n */\nclass Editor {\n\treadonly #previous: TableDefinition;\n\treadonly #what: string;\n\t#schemas: { [name: string]: ColumnSchema };\n\t#key: string[];\n\treadonly #indexes: Map<string, readonly string[]>;\n\t/** `before` until the data step or the first `drop`, `index` or `dropIndex`. */\n\t#phase: \"before\" | \"after\" = \"before\";\n\treadonly #before: TableEdit[] = [];\n\t#step: DataStep | undefined;\n\treadonly #after: TableEdit[] = [];\n\n\tconstructor(previous: TableDefinition) {\n\t\tthis.#previous = previous;\n\t\tthis.#what = `${previous.name} version ${previous.version + 1}`;\n\t\tthis.#schemas = { ...previous.schemas };\n\t\tthis.#key = [...previous.key];\n\t\tthis.#indexes = new Map(previous.indexes);\n\t}\n\n\trename(from: string, to: string): this {\n\t\tthis.#assertBefore(\"rename\");\n\t\tthis.#assertColumn(from, \"rename\");\n\t\t// Checked here, not by the final definition: a later edit may rename it again, but this one runs as DDL.\n\t\tcheckColumnName(to, `${this.#what}: rename`);\n\t\tthis.#assertNewName(to, \"rename\", from);\n\t\tconst rename = (column: string): string => (column === from ? to : column);\n\t\tthis.#schemas = Object.fromEntries(Object.entries(this.#schemas).map(([name, schema]) => [rename(name), schema]));\n\t\tthis.#key = this.#key.map(rename);\n\t\tfor (const [name, columns] of this.#indexes) this.#indexes.set(name, columns.map(rename));\n\t\tthis.#before.push({ kind: \"rename\", from, to });\n\t\treturn this;\n\t}\n\n\tadd(name: string, column: ColumnSchema): this {\n\t\tthis.#assertBefore(\"add\");\n\t\tthis.#assertNewName(name, \"add\");\n\t\tconst [described] = describeColumns({ [name]: column }, `${this.#what}: add`);\n\t\tif (!described!.optional && (described!.type === \"json\" || described!.default === undefined)) {\n\t\t\tthrow new Error(`${this.#what}: add: column \"${name}\" needs opt(...) or a default (existing rows get it)`);\n\t\t}\n\t\tthis.#schemas[name] = column;\n\t\tthis.#before.push({ kind: \"add\", name, column: columnRecord(described!) });\n\t\treturn this;\n\t}\n\n\tjson(name: string, column: ColumnSchema): this {\n\t\tthis.#assertBefore(\"json\");\n\t\tconst existing = describeColumns({ [name]: this.#assertColumn(name, \"json\") }, this.#what)[0]!;\n\t\tif (existing.type !== \"json\") throw new Error(`${this.#what}: json: column \"${name}\" is not a json(...) column`);\n\t\tif (isOptional(column)) {\n\t\t\tthrow new Error(`${this.#what}: json: pass json(...) itself; the column keeps its nullability`);\n\t\t}\n\t\tconst schema = existing.optional ? opt(column) : column;\n\t\tconst described = describeColumns({ [name]: schema }, `${this.#what}: json`)[0]!;\n\t\tif (described.type !== \"json\") throw new Error(`${this.#what}: json: expected a json(...) column`);\n\t\tconst [before, after] = [existing.json, described.json];\n\t\t// D9 across table versions: a cell's version says which schema it was written with.\n\t\tif (after.version < before.version) {\n\t\t\tthrow new Error(`${this.#what}: json: column \"${name}\" goes back from version ${before.version}`);\n\t\t}\n\t\tif (after.version === before.version && after.fingerprint !== before.fingerprint) {\n\t\t\tthrow new Error(\n\t\t\t\t`${this.#what}: json: column \"${name}\" changes its schema at version ${before.version} (raise its version)`,\n\t\t\t);\n\t\t}\n\t\tthis.#schemas[name] = schema;\n\t\tthis.#before.push({ kind: \"json\", name, column: columnRecord(described) });\n\t\treturn this;\n\t}\n\n\trows(patch: (row: { readonly [column: string]: unknown }) => unknown): this {\n\t\tthis.#assertBefore(\"rows\");\n\t\tif (typeof patch !== \"function\") throw new Error(`${this.#what}: rows: expected a function`);\n\t\tthis.#step = { kind: \"rows\", table: this.#current(), patch };\n\t\tthis.#phase = \"after\";\n\t\treturn this;\n\t}\n\n\tupdate(step: { readonly where?: unknown; readonly set: unknown }): this {\n\t\tthis.#assertBefore(\"update\");\n\t\tconst table = this.#current();\n\t\tconst what = `version ${table.version} update`;\n\t\tconst where = typeof step.where === \"function\" ? step.where(table.refs) : step.where;\n\t\tconst set = typeof step.set === \"function\" ? step.set(table.refs) : step.set;\n\t\tthis.#step = {\n\t\t\tkind: \"update\",\n\t\t\ttable,\n\t\t\twhere: where === undefined ? undefined : compileWhere(table, where, what),\n\t\t\tset: compileSet(table, set, what),\n\t\t};\n\t\tthis.#phase = \"after\";\n\t\treturn this;\n\t}\n\n\tdrop(name: string): this {\n\t\tthis.#phase = \"after\";\n\t\tthis.#assertColumn(name, \"drop\");\n\t\tif (this.#key.includes(name)) throw new Error(`${this.#what}: drop: \"${name}\" is a key column`);\n\t\tfor (const [index, columns] of this.#indexes) {\n\t\t\tif (!columns.includes(name)) continue;\n\t\t\tthis.#indexes.delete(index);\n\t\t\tthis.#after.push({ kind: \"dropIndex\", name: index });\n\t\t}\n\t\tconst { [name]: _dropped, ...schemas } = this.#schemas;\n\t\tthis.#schemas = schemas;\n\t\tthis.#after.push({ kind: \"drop\", name });\n\t\treturn this;\n\t}\n\n\tindex(name: string, columns: readonly string[]): this {\n\t\tthis.#phase = \"after\";\n\t\tconst what = `${this.#what}: index \"${name}\"`;\n\t\tif (!INDEX_NAME.test(name)) throw new Error(`${what}: expected [a-z0-9_]+`);\n\t\tif (this.#indexes.has(name)) throw new Error(`${what} exists`);\n\t\t// Checked against the columns at this edit: the migration creates the index here, whatever later edits do.\n\t\tconst byName = new Map(describeColumns(this.#schemas, this.#what).map((column) => [column.name, column]));\n\t\tconst checked = orderColumns(byName, columns, what);\n\t\tthis.#indexes.set(name, checked);\n\t\tthis.#after.push({ kind: \"index\", name, columns: checked });\n\t\treturn this;\n\t}\n\n\tdropIndex(name: string): this {\n\t\tthis.#phase = \"after\";\n\t\tif (!this.#indexes.delete(name)) throw new Error(`${this.#what}: dropIndex: no index \"${name}\"`);\n\t\tthis.#after.push({ kind: \"dropIndex\", name });\n\t\treturn this;\n\t}\n\n\t/** The new version, materialized and fingerprinted, linked to the previous one and the migration from it. */\n\tfinish(): TableDefinition {\n\t\tconst migration = { before: this.#before, step: this.#step, after: this.#after };\n\t\treturn new TableDefinition(this.#previous.name, this.#options(), { previous: this.#previous, migration });\n\t}\n\n\t/** The table as the edits so far leave it, at the new version: what a data step reads and writes. */\n\t#current(): TableDefinition {\n\t\treturn new TableDefinition(this.#previous.name, this.#options());\n\t}\n\n\t#options(): TableOptions<Columns, readonly never[]> {\n\t\tconst version = this.#previous.version + 1;\n\t\tconst options = {\n\t\t\tversion,\n\t\t\tcolumns: { ...this.#schemas },\n\t\t\tkey: [...this.#key],\n\t\t\tindexes: Object.fromEntries(this.#indexes),\n\t\t};\n\t\t// The key and indexes are names the edits kept; the constructor checks them as it checks a base's.\n\t\treturn options as unknown as TableOptions<Columns, readonly never[]>;\n\t}\n\n\t#assertBefore(edit: string): void {\n\t\tif (this.#phase === \"after\") {\n\t\t\tthrow new Error(`${this.#what}: ${edit} comes before the data step and before drop, index and dropIndex`);\n\t\t}\n\t}\n\n\t/**\n\t * `name` names no column yet, also ignoring ASCII case (SQLite's column names do): checked per edit, since a later\n\t * `drop` cannot take back an `add` the migration runs first. A rename may change only the case of `from`.\n\t */\n\t#assertNewName(name: string, edit: string, from?: string): void {\n\t\tconst folded = foldAscii(name);\n\t\tfor (const existing of Object.keys(this.#schemas)) {\n\t\t\tif (existing !== from && foldAscii(existing) === folded) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${this.#what}: ${edit}: column \"${existing}\" exists (names differing only in case collide)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#assertColumn(name: string, edit: string): ColumnSchema {\n\t\tif (!Object.hasOwn(this.#schemas, name)) throw new Error(`${this.#what}: ${edit}: no column \"${name}\"`);\n\t\treturn this.#schemas[name]!;\n\t}\n}\n\n/** `name` with ASCII letters lowercased and nothing else changed, as SQLite folds identifiers. */\nfunction foldAscii(name: string): string {\n\treturn name.replace(/[A-Z]+/g, (letters) => letters.toLowerCase());\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import { ChordError } from "../data/index.ts";
|
|
3
|
+
import type { SqliteValue } from "../sqlite/index.ts";
|
|
4
|
+
import type { Columns, RowOf } from "./columns.ts";
|
|
5
|
+
import type { LiveQueries } from "./live-query.ts";
|
|
6
|
+
import { type Query } from "./query.ts";
|
|
7
|
+
import { TableSql } from "./sql.ts";
|
|
8
|
+
import type { ChordStore } from "./store.ts";
|
|
9
|
+
import type { KeyOf, TableDefinition } from "./table.ts";
|
|
10
|
+
/** One page of rows (`items`, as Durable's pages) and, when more follow, the cursor to continue after it. */
|
|
11
|
+
export type Page<T> = {
|
|
12
|
+
readonly items: T[];
|
|
13
|
+
readonly next?: string;
|
|
14
|
+
};
|
|
15
|
+
/** What `page` takes besides the query, the limit and the context. */
|
|
16
|
+
export type PageOptions = {
|
|
17
|
+
/** A cursor from an earlier page of the same order. */
|
|
18
|
+
readonly after?: string;
|
|
19
|
+
};
|
|
20
|
+
/** A table of this object: reads of committed state, the context last. Writes go through `self.tx`. */
|
|
21
|
+
export interface Table<C extends Columns, K extends readonly string[]> {
|
|
22
|
+
/** Up to `limit` rows of `q` (after `options.after`), and the cursor of the next page when there is one. */
|
|
23
|
+
page(q: Query<C, K>, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<C>>>;
|
|
24
|
+
/** Every row of `q`, read a page of 100 at a time. */
|
|
25
|
+
rows(q: Query<C, K>, context: Context): AsyncIterable<RowOf<C>>;
|
|
26
|
+
/** The row with `key`, `undefined` when absent. */
|
|
27
|
+
get(key: KeyOf<C, K>, context: Context): Promise<RowOf<C> | undefined>;
|
|
28
|
+
/** The number of rows of `q`. */
|
|
29
|
+
count(q: Query<C, K>, context: Context): Promise<number>;
|
|
30
|
+
}
|
|
31
|
+
/** The handle type of table definition `D`: what `self.table(D)` returns. */
|
|
32
|
+
export type TableOf<D> = D extends TableDefinition<infer C, infer K> ? Table<C, K> : never;
|
|
33
|
+
/**
|
|
34
|
+
* Who owns a table handle: its object (whose transactions alone write it), its live queries, liveness check and live
|
|
35
|
+
* failure.
|
|
36
|
+
*/
|
|
37
|
+
export type TableOwner = {
|
|
38
|
+
readonly label: string;
|
|
39
|
+
/** The object's documents: a transaction of another object refuses the handle. */
|
|
40
|
+
readonly scope: object;
|
|
41
|
+
/** The object's live queries, across its attempts: what a commit writing the table re-runs. */
|
|
42
|
+
readonly queries: LiveQueries;
|
|
43
|
+
/** Throws `released` once the object ended. */
|
|
44
|
+
assertLive(): void;
|
|
45
|
+
/** A row the code cannot read (a `json(...)` cell, slice 6a §9) fails the owner `broken` (§1.4). */
|
|
46
|
+
fail(error: ChordError): void;
|
|
47
|
+
};
|
|
48
|
+
/** The rows `rows()` reads per page (rule 17). */
|
|
49
|
+
export declare const ROWS_PAGE = 100;
|
|
50
|
+
/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */
|
|
51
|
+
export declare class TableHandle implements Table<Columns, readonly string[]> {
|
|
52
|
+
#private;
|
|
53
|
+
readonly definition: TableDefinition;
|
|
54
|
+
readonly sql: TableSql;
|
|
55
|
+
readonly store: ChordStore;
|
|
56
|
+
readonly owner: TableOwner;
|
|
57
|
+
constructor(definition: TableDefinition, sqlName: string, store: ChordStore, owner: TableOwner);
|
|
58
|
+
page(q: Query, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<Columns>>>;
|
|
59
|
+
rows(q: Query, context: Context): AsyncIterable<RowOf<Columns>>;
|
|
60
|
+
get(key: unknown, context: Context): Promise<RowOf<Columns> | undefined>;
|
|
61
|
+
count(q: Query, context: Context): Promise<number>;
|
|
62
|
+
/**
|
|
63
|
+
* The version fence of old table handles (R15): once the store's table is at a newer version than this handle's
|
|
64
|
+
* definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads
|
|
65
|
+
* and writes it no more (`released/version`), so it never issues SQL for a dropped column.
|
|
66
|
+
*/
|
|
67
|
+
assertVersion(): void;
|
|
68
|
+
/** A stored row as reads return it; one the code cannot read fails the owner and throws. */
|
|
69
|
+
decode(stored: {
|
|
70
|
+
readonly [column: string]: SqliteValue;
|
|
71
|
+
}, context: Context): RowOf<Columns>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=table-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-handle.d.ts","sourceRoot":"","sources":["../../src/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C;IAE3B,YAAY,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAK7F;IAEK,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CA2B9G;IAEM,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAOrE;IAEK,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAS7E;IAEK,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAUvD;IAED;;;;OAIG;IACH,aAAa,IAAI,IAAI,CAMpB;IAED,4FAA4F;IAC5F,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAY3F;CAWD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Table handles (slice 6a §6; decision "Query runner"): what `self.table(Def)` returns, one per attempt and table: reads
|
|
2
|
+
// of committed rows (`page`, `rows`, `get`, `count`) through the store's guarded reads, and what a transaction's
|
|
3
|
+
// writes to the table are staged with; a handle of an older version than the stored table is refused (R15, slice 7b).
|
|
4
|
+
import { ChordError } from "../data/index.js";
|
|
5
|
+
import { invalid } from "../data/internal.js";
|
|
6
|
+
import { decodeCursor, encodeCursor } from "./query.js";
|
|
7
|
+
import { TableSql } from "./sql.js";
|
|
8
|
+
/** The rows `rows()` reads per page (rule 17). */
|
|
9
|
+
export const ROWS_PAGE = 100;
|
|
10
|
+
/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */
|
|
11
|
+
export class TableHandle {
|
|
12
|
+
definition;
|
|
13
|
+
sql;
|
|
14
|
+
store;
|
|
15
|
+
owner;
|
|
16
|
+
constructor(definition, sqlName, store, owner) {
|
|
17
|
+
this.definition = definition;
|
|
18
|
+
this.sql = new TableSql(sqlName, definition.columns, definition.rows.physical, definition.key);
|
|
19
|
+
this.store = store;
|
|
20
|
+
this.owner = owner;
|
|
21
|
+
}
|
|
22
|
+
async page(q, limit, context, options = {}) {
|
|
23
|
+
this.owner.assertLive();
|
|
24
|
+
this.assertVersion();
|
|
25
|
+
this.#assertQuery(q);
|
|
26
|
+
if (!Number.isSafeInteger(limit) || limit < 1)
|
|
27
|
+
throw invalid("args", `${this.definition.name}: limit is a positive integer`);
|
|
28
|
+
const order = q.order;
|
|
29
|
+
const after = options.after === undefined ? undefined : decodeCursor(this.definition, this.sql.table, order, options.after);
|
|
30
|
+
const statement = this.sql.select(q.condition, order, after, limit + 1);
|
|
31
|
+
const stored = await this.store.read((executor) => executor.all(statement.sql, ...statement.params), context);
|
|
32
|
+
const more = stored.length > limit;
|
|
33
|
+
if (more)
|
|
34
|
+
stored.length = limit;
|
|
35
|
+
const items = stored.map((row) => this.decode(row, context));
|
|
36
|
+
if (!more)
|
|
37
|
+
return { items };
|
|
38
|
+
const last = stored[limit - 1];
|
|
39
|
+
return {
|
|
40
|
+
items,
|
|
41
|
+
next: encodeCursor(this.sql.table, order, order.columns.map((column) => last[column])),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async *rows(q, context) {
|
|
45
|
+
let after;
|
|
46
|
+
do {
|
|
47
|
+
const page = await this.page(q, ROWS_PAGE, context, after === undefined ? {} : { after });
|
|
48
|
+
yield* page.items;
|
|
49
|
+
after = page.next;
|
|
50
|
+
} while (after !== undefined);
|
|
51
|
+
}
|
|
52
|
+
async get(key, context) {
|
|
53
|
+
this.owner.assertLive();
|
|
54
|
+
this.assertVersion();
|
|
55
|
+
const encoded = this.definition.rows.key(key, "get");
|
|
56
|
+
const stored = await this.store.read((executor) => executor.get(this.sql.get, ...encoded.params), context);
|
|
57
|
+
return stored === undefined ? undefined : this.decode(stored, context);
|
|
58
|
+
}
|
|
59
|
+
async count(q, context) {
|
|
60
|
+
this.owner.assertLive();
|
|
61
|
+
this.assertVersion();
|
|
62
|
+
this.#assertQuery(q);
|
|
63
|
+
const statement = this.sql.count(q.condition);
|
|
64
|
+
const row = await this.store.read((executor) => executor.get(statement.sql, ...statement.params), context);
|
|
65
|
+
return row?.count ?? 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The version fence of old table handles (R15): once the store's table is at a newer version than this handle's
|
|
69
|
+
* definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads
|
|
70
|
+
* and writes it no more (`released/version`), so it never issues SQL for a dropped column.
|
|
71
|
+
*/
|
|
72
|
+
assertVersion() {
|
|
73
|
+
const stored = this.store.tableVersion(this.sql.table);
|
|
74
|
+
if (stored === undefined || stored <= this.definition.version)
|
|
75
|
+
return;
|
|
76
|
+
const { name, version } = this.definition;
|
|
77
|
+
const message = `${this.owner.label}: table "${name}" of version ${version}; the store has version ${stored}`;
|
|
78
|
+
throw new ChordError({ code: "released", reason: "version", message });
|
|
79
|
+
}
|
|
80
|
+
/** A stored row as reads return it; one the code cannot read fails the owner and throws. */
|
|
81
|
+
decode(stored, context) {
|
|
82
|
+
try {
|
|
83
|
+
// The codec decodes by the definition's columns: a row of them.
|
|
84
|
+
return this.definition.rows.decode(stored, context);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const failure = error instanceof ChordError
|
|
88
|
+
? error
|
|
89
|
+
: new ChordError({ code: "unavailable", message: String(error) }, { cause: error });
|
|
90
|
+
this.owner.fail(failure);
|
|
91
|
+
throw failure;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** A query of another table is refused (`invalid/args`). */
|
|
95
|
+
#assertQuery(q) {
|
|
96
|
+
if (q.table !== this.definition) {
|
|
97
|
+
throw invalid("args", `${this.owner.label}: a query of table "${q.table.name}" run on "${this.definition.name}"`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=table-handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-handle.js","sourceRoot":"","sources":["../../src/store/table-handle.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,iHAAiH;AACjH,sHAAsH;AAGtH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA4CpC,kDAAkD;AAClD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B,2GAA2G;AAC3G,MAAM,OAAO,WAAW;IACd,UAAU,CAAkB;IAC5B,GAAG,CAAW;IACd,KAAK,CAAa;IAClB,KAAK,CAAa;IAE3B,YAAY,UAA2B,EAAE,OAAe,EAAE,KAAiB,EAAE,KAAiB;QAC7F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;QAC/F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAQ,EAAE,KAAa,EAAE,OAAgB,EAAE,OAAO,GAAgB,EAAE;QAC9E,IAAI,CA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AI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAmB,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GACZ,KAAK,YAAY,UAAU;gBAC1B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACtF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,MAAM,OAAO,CAAC;QACf,CAAC;IACF,CAAC;IAED,4DAA4D;IAC5D,YAAY,CAAC,CAAQ;QACpB,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,OAAO,CACZ,MAAM,EACN,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,uBAAuB,CAAC,CAAC,KAAK,CAAC,IAAI,aAAa,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAC1F,CAAC;QACH,CAAC;IACF,CAAC;CACD","sourcesContent":["// Table handles (slice 6a §6; decision \"Query runner\"): what `self.table(Def)` returns, one per attempt and table: reads\n// of committed rows (`page`, `rows`, `get`, `count`) through the store's guarded reads, and what a transaction's\n// writes to the table are staged with; a handle of an older version than the stored table is refused (R15, slice 7b).\n\nimport type { Context } from \"../context/index.ts\";\nimport { ChordError } from \"../data/index.ts\";\nimport { invalid } from \"../data/internal.ts\";\nimport type { SqliteValue } from \"../sqlite/index.ts\";\nimport type { Columns, RowOf } from \"./columns.ts\";\nimport type { LiveQueries } from \"./live-query.ts\";\nimport { decodeCursor, encodeCursor, type Query } from \"./query.ts\";\nimport { TableSql } from \"./sql.ts\";\nimport type { ChordStore } from \"./store.ts\";\nimport type { KeyOf, TableDefinition } from \"./table.ts\";\n\n/** One page of rows (`items`, as Durable's pages) and, when more follow, the cursor to continue after it. */\nexport type Page<T> = { readonly items: T[]; readonly next?: string };\n\n/** What `page` takes besides the query, the limit and the context. */\nexport type PageOptions = {\n\t/** A cursor from an earlier page of the same order. */\n\treadonly after?: string;\n};\n\n/** A table of this object: reads of committed state, the context last. Writes go through `self.tx`. */\nexport interface Table<C extends Columns, K extends readonly string[]> {\n\t/** Up to `limit` rows of `q` (after `options.after`), and the cursor of the next page when there is one. */\n\tpage(q: Query<C, K>, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<C>>>;\n\t/** Every row of `q`, read a page of 100 at a time. */\n\trows(q: Query<C, K>, context: Context): AsyncIterable<RowOf<C>>;\n\t/** The row with `key`, `undefined` when absent. */\n\tget(key: KeyOf<C, K>, context: Context): Promise<RowOf<C> | undefined>;\n\t/** The number of rows of `q`. */\n\tcount(q: Query<C, K>, context: Context): Promise<number>;\n}\n\n/** The handle type of table definition `D`: what `self.table(D)` returns. */\nexport type TableOf<D> = D extends TableDefinition<infer C, infer K> ? Table<C, K> : never;\n\n/**\n * Who owns a table handle: its object (whose transactions alone write it), its live queries, liveness check and live\n * failure.\n */\nexport type TableOwner = {\n\treadonly label: string;\n\t/** The object's documents: a transaction of another object refuses the handle. */\n\treadonly scope: object;\n\t/** The object's live queries, across its attempts: what a commit writing the table re-runs. */\n\treadonly queries: LiveQueries;\n\t/** Throws `released` once the object ended. */\n\tassertLive(): void;\n\t/** A row the code cannot read (a `json(...)` cell, slice 6a §9) fails the owner `broken` (§1.4). */\n\tfail(error: ChordError): void;\n};\n\n/** The rows `rows()` reads per page (rule 17). */\nexport const ROWS_PAGE = 100;\n\n/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */\nexport class TableHandle implements Table<Columns, readonly string[]> {\n\treadonly definition: TableDefinition;\n\treadonly sql: TableSql;\n\treadonly store: ChordStore;\n\treadonly owner: TableOwner;\n\n\tconstructor(definition: TableDefinition, sqlName: string, store: ChordStore, owner: TableOwner) {\n\t\tthis.definition = definition;\n\t\tthis.sql = new TableSql(sqlName, definition.columns, definition.rows.physical, definition.key);\n\t\tthis.store = store;\n\t\tthis.owner = owner;\n\t}\n\n\tasync page(q: Query, limit: number, context: Context, options: PageOptions = {}): Promise<Page<RowOf<Columns>>> {\n\t\tthis.owner.assertLive();\n\t\tthis.assertVersion();\n\t\tthis.#assertQuery(q);\n\t\tif (!Number.isSafeInteger(limit) || limit < 1)\n\t\t\tthrow invalid(\"args\", `${this.definition.name}: limit is a positive integer`);\n\t\tconst order = q.order;\n\t\tconst after =\n\t\t\toptions.after === undefined ? undefined : decodeCursor(this.definition, this.sql.table, order, options.after);\n\t\tconst statement = this.sql.select(q.condition, order, after, limit + 1);\n\t\tconst stored = await this.store.read(\n\t\t\t(executor) => executor.all<{ [column: string]: SqliteValue }>(statement.sql, ...statement.params),\n\t\t\tcontext,\n\t\t);\n\t\tconst more = stored.length > limit;\n\t\tif (more) stored.length = limit;\n\t\tconst items = stored.map((row) => this.decode(row, context));\n\t\tif (!more) return { items };\n\t\tconst last = stored[limit - 1]!;\n\t\treturn {\n\t\t\titems,\n\t\t\tnext: encodeCursor(\n\t\t\t\tthis.sql.table,\n\t\t\t\torder,\n\t\t\t\torder.columns.map((column) => last[column]!),\n\t\t\t),\n\t\t};\n\t}\n\n\tasync *rows(q: Query, context: Context): AsyncIterable<RowOf<Columns>> {\n\t\tlet after: string | undefined;\n\t\tdo {\n\t\t\tconst page = await this.page(q, ROWS_PAGE, context, after === undefined ? {} : { after });\n\t\t\tyield* page.items;\n\t\t\tafter = page.next;\n\t\t} while (after !== undefined);\n\t}\n\n\tasync get(key: unknown, context: Context): Promise<RowOf<Columns> | undefined> {\n\t\tthis.owner.assertLive();\n\t\tthis.assertVersion();\n\t\tconst encoded = this.definition.rows.key(key, \"get\");\n\t\tconst stored = await this.store.read(\n\t\t\t(executor) => executor.get<{ [column: string]: SqliteValue }>(this.sql.get, ...encoded.params),\n\t\t\tcontext,\n\t\t);\n\t\treturn stored === undefined ? undefined : this.decode(stored, context);\n\t}\n\n\tasync count(q: Query, context: Context): Promise<number> {\n\t\tthis.owner.assertLive();\n\t\tthis.assertVersion();\n\t\tthis.#assertQuery(q);\n\t\tconst statement = this.sql.count(q.condition);\n\t\tconst row = await this.store.read(\n\t\t\t(executor) => executor.get<{ readonly count: number }>(statement.sql, ...statement.params),\n\t\t\tcontext,\n\t\t);\n\t\treturn row?.count ?? 0;\n\t}\n\n\t/**\n\t * The version fence of old table handles (R15): once the store's table is at a newer version than this handle's\n\t * definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads\n\t * and writes it no more (`released/version`), so it never issues SQL for a dropped column.\n\t */\n\tassertVersion(): void {\n\t\tconst stored = this.store.tableVersion(this.sql.table);\n\t\tif (stored === undefined || stored <= this.definition.version) return;\n\t\tconst { name, version } = this.definition;\n\t\tconst message = `${this.owner.label}: table \"${name}\" of version ${version}; the store has version ${stored}`;\n\t\tthrow new ChordError({ code: \"released\", reason: \"version\", message });\n\t}\n\n\t/** A stored row as reads return it; one the code cannot read fails the owner and throws. */\n\tdecode(stored: { readonly [column: string]: SqliteValue }, context: Context): RowOf<Columns> {\n\t\ttry {\n\t\t\t// The codec decodes by the definition's columns: a row of them.\n\t\t\treturn this.definition.rows.decode(stored, context) as RowOf<Columns>;\n\t\t} catch (error) {\n\t\t\tconst failure =\n\t\t\t\terror instanceof ChordError\n\t\t\t\t\t? error\n\t\t\t\t\t: new ChordError({ code: \"unavailable\", message: String(error) }, { cause: error });\n\t\t\tthis.owner.fail(failure);\n\t\t\tthrow failure;\n\t\t}\n\t}\n\n\t/** A query of another table is refused (`invalid/args`). */\n\t#assertQuery(q: Query): void {\n\t\tif (q.table !== this.definition) {\n\t\t\tthrow invalid(\n\t\t\t\t\"args\",\n\t\t\t\t`${this.owner.label}: a query of table \"${q.table.name}\" run on \"${this.definition.name}\"`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { TableRecord } from "./catalog.ts";
|
|
2
|
+
import type { ColumnRecord } from "./columns.ts";
|
|
3
|
+
import type { SetNode, WhereNode } from "./expression.ts";
|
|
4
|
+
import type { TableDefinition } from "./table.ts";
|
|
5
|
+
/** One edit of a migration as its writes record it (`alter`, `index`, `dropIndex`); the table is named when applied. */
|
|
6
|
+
export type TableEdit = {
|
|
7
|
+
readonly kind: "rename";
|
|
8
|
+
readonly from: string;
|
|
9
|
+
readonly to: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "add";
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly column: ColumnRecord;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "drop";
|
|
16
|
+
readonly name: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "json";
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly column: ColumnRecord;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "index";
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly columns: readonly string[];
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "dropIndex";
|
|
27
|
+
readonly name: string;
|
|
28
|
+
};
|
|
29
|
+
/** The column edits an `alter` write records. */
|
|
30
|
+
export type AlterEdit = Extract<TableEdit, {
|
|
31
|
+
readonly kind: "rename" | "add" | "drop" | "json";
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* A version's data step over `table`, the columns between the edits before it and after it: `rows` patches each row
|
|
35
|
+
* (synchronous and pure), `update` is one `updateWhere`.
|
|
36
|
+
*/
|
|
37
|
+
export type DataStep = {
|
|
38
|
+
readonly kind: "rows";
|
|
39
|
+
readonly table: TableDefinition;
|
|
40
|
+
readonly patch: (row: {
|
|
41
|
+
readonly [column: string]: unknown;
|
|
42
|
+
}) => unknown;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "update";
|
|
45
|
+
readonly table: TableDefinition;
|
|
46
|
+
readonly where: WhereNode | undefined;
|
|
47
|
+
readonly set: SetNode;
|
|
48
|
+
};
|
|
49
|
+
/** What one `evolveTable` changed: the edits before the data step, the step, the edits after it. */
|
|
50
|
+
export type Migration = {
|
|
51
|
+
readonly before: readonly TableEdit[];
|
|
52
|
+
readonly step: DataStep | undefined;
|
|
53
|
+
readonly after: readonly TableEdit[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* What an activation does with a declared table: create it at the newest version, use it as recorded, or migrate it
|
|
57
|
+
* through `versions` (oldest first), the first one from its start (`begin`) or, recorded `migrating`, after its (A)
|
|
58
|
+
* commit (`resume`).
|
|
59
|
+
*/
|
|
60
|
+
export type TablePlan = {
|
|
61
|
+
readonly kind: "create";
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "ready";
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "migrate";
|
|
66
|
+
readonly versions: readonly TableDefinition[];
|
|
67
|
+
readonly first: "begin" | "resume";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,
|
|
71
|
+
* older than the history's base, or the same version with another fingerprint (a history edited in place) throws:
|
|
72
|
+
* the object fails `broken`, the data stays.
|
|
73
|
+
*/
|
|
74
|
+
export declare function planTable(definition: TableDefinition, recorded: TableRecord | undefined, what: string): TablePlan;
|
|
75
|
+
//# sourceMappingURL=table-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-history.d.ts","sourceRoot":"","sources":["../../src/store/table-history.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wHAAwH;AACxH,MAAM,MAAM,SAAS,GAClB;IAAE,QAAQ,CAAC,IAAI,E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AC;IACxB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACrB,CAAC;AAEL,oGAAoG;AACpG,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACrC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEL;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAwBjH"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// A table's history (slice 6a §9; decision "Second spec review: the majority"): the versions from a base
|
|
2
|
+
// `defineTable` through each `evolveTable`, the migration each version recorded, and what an activation does with the
|
|
3
|
+
// version the store recorded: create the table, use it, migrate it from there, or refuse it.
|
|
4
|
+
/**
|
|
5
|
+
* The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,
|
|
6
|
+
* older than the history's base, or the same version with another fingerprint (a history edited in place) throws:
|
|
7
|
+
* the object fails `broken`, the data stays.
|
|
8
|
+
*/
|
|
9
|
+
export function planTable(definition, recorded, what) {
|
|
10
|
+
if (recorded === undefined)
|
|
11
|
+
return { kind: "create" };
|
|
12
|
+
const { version, state, fingerprint } = recorded;
|
|
13
|
+
if (version > definition.version) {
|
|
14
|
+
throw new Error(`${what}: the store has version ${version}, newer than the code's ${definition.version}`);
|
|
15
|
+
}
|
|
16
|
+
const versions = historyOf(definition);
|
|
17
|
+
const at = versions.find((each) => each.version === version);
|
|
18
|
+
if (at === undefined) {
|
|
19
|
+
throw new Error(`${what}: the store has version ${version}, older than the history's base ${versions[0].version}`);
|
|
20
|
+
}
|
|
21
|
+
if (at.fingerprint !== fingerprint) {
|
|
22
|
+
throw new Error(`${what}: version ${version} is recorded with another definition (a history edited in place)`);
|
|
23
|
+
}
|
|
24
|
+
if (state === "ready" && version === definition.version)
|
|
25
|
+
return { kind: "ready" };
|
|
26
|
+
if (state === "migrating" && at.evolution?.migration.step === undefined) {
|
|
27
|
+
throw new Error(`${what}: version ${version} is recorded migrating, but has no data step to resume`);
|
|
28
|
+
}
|
|
29
|
+
if (state === "migrating") {
|
|
30
|
+
return { kind: "migrate", versions: versions.filter((each) => each.version >= version), first: "resume" };
|
|
31
|
+
}
|
|
32
|
+
return { kind: "migrate", versions: versions.filter((each) => each.version > version), first: "begin" };
|
|
33
|
+
}
|
|
34
|
+
/** Every version of `definition`'s history, the base first. */
|
|
35
|
+
function historyOf(definition) {
|
|
36
|
+
const versions = [];
|
|
37
|
+
for (let at = definition; at !== undefined; at = at.evolution?.previous) {
|
|
38
|
+
versions.unshift(at);
|
|
39
|
+
}
|
|
40
|
+
return versions;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=table-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-history.js","sourceRoot":"","sources":["../../src/store/table-history.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,sHAAsH;AACtH,6FAA6F;AAyD7F;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,UAA2B,EAAE,QAAiC,EAAE,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AM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC3G,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACzG,CAAC;AAED,+DAA+D;AAC/D,SAAS,SAAS,CAAC,UAA2B;IAC7C,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,IAAI,EAAE,GAAgC,UAAU,EAAE,EAAE,KAAK,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["// A table's history (slice 6a §9; decision \"Second spec review: the majority\"): the versions from a base\n// `defineTable` through each `evolveTable`, the migration each version recorded, and what an activation does with the\n// version the store recorded: create the table, use it, migrate it from there, or refuse it.\n\nimport type { TableRecord } from \"./catalog.ts\";\nimport type { ColumnRecord } from \"./columns.ts\";\nimport type { SetNode, WhereNode } from \"./expression.ts\";\nimport type { TableDefinition } from \"./table.ts\";\n\n/** One edit of a migration as its writes record it (`alter`, `index`, `dropIndex`); the table is named when applied. */\nexport type TableEdit =\n\t| { readonly kind: \"rename\"; readonly from: string; readonly to: string }\n\t| { readonly kind: \"add\"; readonly name: string; readonly column: ColumnRecord }\n\t| { readonly kind: \"drop\"; readonly name: string }\n\t| { readonly kind: \"json\"; readonly name: string; readonly column: ColumnRecord }\n\t| { readonly kind: \"index\"; readonly name: string; readonly columns: readonly string[] }\n\t| { readonly kind: \"dropIndex\"; readonly name: string };\n\n/** The column edits an `alter` write records. */\nexport type AlterEdit = Extract<TableEdit, { readonly kind: \"rename\" | \"add\" | \"drop\" | \"json\" }>;\n\n/**\n * A version's data step over `table`, the columns between the edits before it and after it: `rows` patches each row\n * (synchronous and pure), `update` is one `updateWhere`.\n */\nexport type DataStep =\n\t| {\n\t\t\treadonly kind: \"rows\";\n\t\t\treadonly table: TableDefinition;\n\t\t\treadonly patch: (row: { readonly [column: string]: unknown }) => unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"update\";\n\t\t\treadonly table: TableDefinition;\n\t\t\treadonly where: WhereNode | undefined;\n\t\t\treadonly set: SetNode;\n\t };\n\n/** What one `evolveTable` changed: the edits before the data step, the step, the edits after it. */\nexport type Migration = {\n\treadonly before: readonly TableEdit[];\n\treadonly step: DataStep | undefined;\n\treadonly after: readonly TableEdit[];\n};\n\n/**\n * What an activation does with a declared table: create it at the newest version, use it as recorded, or migrate it\n * through `versions` (oldest first), the first one from its start (`begin`) or, recorded `migrating`, after its (A)\n * commit (`resume`).\n */\nexport type TablePlan =\n\t| { readonly kind: \"create\" }\n\t| { readonly kind: \"ready\" }\n\t| {\n\t\t\treadonly kind: \"migrate\";\n\t\t\treadonly versions: readonly TableDefinition[];\n\t\t\treadonly first: \"begin\" | \"resume\";\n\t };\n\n/**\n * The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,\n * older than the history's base, or the same version with another fingerprint (a history edited in place) throws:\n * the object fails `broken`, the data stays.\n */\nexport function planTable(definition: TableDefinition, recorded: TableRecord | undefined, what: string): TablePlan {\n\tif (recorded === undefined) return { kind: \"create\" };\n\tconst { version, state, fingerprint } = recorded;\n\tif (version > definition.version) {\n\t\tthrow new Error(`${what}: the store has version ${version}, newer than the code's ${definition.version}`);\n\t}\n\tconst versions = historyOf(definition);\n\tconst at = versions.find((each) => each.version === version);\n\tif (at === undefined) {\n\t\tthrow new Error(\n\t\t\t`${what}: the store has version ${version}, older than the history's base ${versions[0]!.version}`,\n\t\t);\n\t}\n\tif (at.fingerprint !== fingerprint) {\n\t\tthrow new Error(`${what}: version ${version} is recorded with another definition (a history edited in place)`);\n\t}\n\tif (state === \"ready\" && version === definition.version) return { kind: \"ready\" };\n\tif (state === \"migrating\" && at.evolution?.migration.step === undefined) {\n\t\tthrow new Error(`${what}: version ${version} is recorded migrating, but has no data step to resume`);\n\t}\n\tif (state === \"migrating\") {\n\t\treturn { kind: \"migrate\", versions: versions.filter((each) => each.version >= version), first: \"resume\" };\n\t}\n\treturn { kind: \"migrate\", versions: versions.filter((each) => each.version > version), first: \"begin\" };\n}\n\n/** Every version of `definition`'s history, the base first. */\nfunction historyOf(definition: TableDefinition): TableDefinition[] {\n\tconst versions: TableDefinition[] = [];\n\tfor (let at: TableDefinition | undefined = definition; at !== undefined; at = at.evolution?.previous) {\n\t\tversions.unshift(at);\n\t}\n\treturn versions;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Context } from "../context/index.ts";
|
|
2
|
+
import type { ChordStore, CommitFence } from "./store.ts";
|
|
3
|
+
import type { TableDefinition } from "./table.ts";
|
|
4
|
+
/** A declared table: its newest definition and its SQL name. */
|
|
5
|
+
export type DeclaredTable = {
|
|
6
|
+
readonly definition: TableDefinition;
|
|
7
|
+
readonly table: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Brings `tables` to their definitions: the ones the store does not have created in one commit, then each older one
|
|
11
|
+
* migrated. A table the code cannot use (see `planTable`) throws before anything is written; `what` names the owner.
|
|
12
|
+
*/
|
|
13
|
+
export declare function prepareTables(tables: readonly DeclaredTable[], store: ChordStore, fence: CommitFence, what: string, context: Context): Promise<void>;
|
|
14
|
+
/** The size of a `rows` chunk: one commit each. */
|
|
15
|
+
export declare const MIGRATION_CHUNK = 100;
|
|
16
|
+
//# sourceMappingURL=table-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-migration.d.ts","sourceRoot":"","sources":["../../src/store/table-migration.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,qBAAqB,CAAC;AAOvE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAYlD,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAK7F;;;GAGG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAYf;AA2BD,mDAAmD;AACnD,eAAO,MAAM,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// Declared tables brought to their version at activation (slice 6a §9): a table the store does not have is created at
|
|
2
|
+
// the newest version with its indexes (no replay); an older one is migrated eagerly, one version at a time, in its
|
|
3
|
+
// commits. Per version N: (A) the edits before the data step and `table { version: N, state: "migrating" }`; the data
|
|
4
|
+
// step's chunks; (Z) the last chunk (or the `update`) with the edits after the step and `state: "ready"`. Without a
|
|
5
|
+
// data step (A) and (Z) are one commit. A version recorded `migrating` resumes after (A), skipping the rows already
|
|
6
|
+
// stamped `$v >= N`. Its record holds the columns during the step but version N's fingerprint, not the fingerprint of
|
|
7
|
+
// those columns: the fingerprint names the version being reached, which resume, export and import check.
|
|
8
|
+
import { withoutAbortSignal } from "../context/index.js";
|
|
9
|
+
import { encodeCell, ROW_VERSION } from "./rows.js";
|
|
10
|
+
import { TableSql } from "./sql.js";
|
|
11
|
+
import { planTable } from "./table-history.js";
|
|
12
|
+
import { jsonVersions, recordedVersions, stageEdit, stageIndex, stageTable, stageUpdate, stageUpdateWhere, } from "./table-writes.js";
|
|
13
|
+
/**
|
|
14
|
+
* Brings `tables` to their definitions: the ones the store does not have created in one commit, then each older one
|
|
15
|
+
* migrated. A table the code cannot use (see `planTable`) throws before anything is written; `what` names the owner.
|
|
16
|
+
*/
|
|
17
|
+
export async function prepareTables(tables, store, fence, what, context) {
|
|
18
|
+
const created = [];
|
|
19
|
+
const migrations = [];
|
|
20
|
+
for (const { definition, table } of tables) {
|
|
21
|
+
const plan = planTable(definition, store.table(table), `${what}: table "${definition.name}"`);
|
|
22
|
+
if (plan.kind === "create")
|
|
23
|
+
created.push(...creation(definition, table));
|
|
24
|
+
else if (plan.kind === "migrate")
|
|
25
|
+
migrations.push({ table, plan });
|
|
26
|
+
}
|
|
27
|
+
if (created.length > 0)
|
|
28
|
+
await commit(created, { store, fence }, context);
|
|
29
|
+
for (const { table, plan } of migrations) {
|
|
30
|
+
await migrateTable(plan, { store, table, fence }, context);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The writes creating `definition` fresh as `table`: at its version, `ready`, with its indexes. */
|
|
34
|
+
function creation(definition, table) {
|
|
35
|
+
const { version, record: columns, key, fingerprint } = definition;
|
|
36
|
+
return [
|
|
37
|
+
stageTable({ kind: "table", table, version, state: "ready", columns, key, fingerprint }),
|
|
38
|
+
...[...definition.indexes].map(([name, columns]) => stageIndex({ kind: "index", table, name, columns })),
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Migrates the table through the plan's versions (oldest first, each with its migration), the first resumed after its
|
|
43
|
+
* (A) commit when the plan says so. `context`'s abort is checked between chunks (a chunk admitted to the step completes); a data
|
|
44
|
+
* step that throws, or returns a patch the version cannot take, rejects: the table stays `migrating` and the committed
|
|
45
|
+
* chunks stay.
|
|
46
|
+
*/
|
|
47
|
+
async function migrateTable(plan, target, context) {
|
|
48
|
+
for (const [index, version] of plan.versions.entries()) {
|
|
49
|
+
await migrateVersion(version, index === 0 ? plan.first : "begin", target, context);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** The size of a `rows` chunk: one commit each. */
|
|
53
|
+
export const MIGRATION_CHUNK = 100;
|
|
54
|
+
/** Migrates to `definition`'s version from its (A) commit (`begin`) or after it (`resume`). */
|
|
55
|
+
async function migrateVersion(definition, from, target, context) {
|
|
56
|
+
const { table } = target;
|
|
57
|
+
// Old handles are refused from now on: their SQL must never queue behind this version's DDL.
|
|
58
|
+
const withdraw = target.store.announceTable(table, definition.version);
|
|
59
|
+
try {
|
|
60
|
+
await migrateSteps(definition, from, target, context);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
withdraw();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** The commits of `migrateVersion`. */
|
|
67
|
+
async function migrateSteps(definition, from, target, context) {
|
|
68
|
+
const { before, step, after } = definition.evolution.migration;
|
|
69
|
+
const { table } = target;
|
|
70
|
+
const edits = (list) => list.map((edit) => stageEdit(table, definition.version, edit));
|
|
71
|
+
const ready = [...edits(after), recordOf(definition, definition, "ready", table)];
|
|
72
|
+
if (step === undefined)
|
|
73
|
+
return commit([...edits(before), ...ready], target, context);
|
|
74
|
+
if (from === "begin")
|
|
75
|
+
await commit([...edits(before), recordOf(step.table, definition, "migrating", table)], target, context);
|
|
76
|
+
if (step.kind === "update")
|
|
77
|
+
return commit([updateStep(step, definition.version, table), ...ready], target, context);
|
|
78
|
+
await rowsStep(step, definition.version, ready, target, context);
|
|
79
|
+
}
|
|
80
|
+
/** The `table` write of `table`'s columns and key, with `definition`'s version and fingerprint, in `state`. */
|
|
81
|
+
function recordOf(columns, definition, state, table) {
|
|
82
|
+
const { version, fingerprint } = definition;
|
|
83
|
+
return stageTable({ kind: "table", table, version, state, columns: columns.record, key: columns.key, fingerprint });
|
|
84
|
+
}
|
|
85
|
+
/** The `update` step: one `updateWhere` over the rows below version `v`, stamping it, so it never applies twice. */
|
|
86
|
+
function updateStep(step, v, table) {
|
|
87
|
+
const sql = sqlOf(step.table, table);
|
|
88
|
+
const below = { lt: [ROW_VERSION, v] };
|
|
89
|
+
const where = step.where === undefined ? below : { and: [step.where, below] };
|
|
90
|
+
const versions = jsonVersions(step.table, step.set);
|
|
91
|
+
const statement = sql.updateWhere(where, { ...step.set, [ROW_VERSION]: v }, versions);
|
|
92
|
+
return stageUpdateWhere(statement, table, where, step.set, recordedVersions(step.set, versions), v);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The `rows` step: chunks of `MIGRATION_CHUNK` rows below version `v` in key order, paging forward by the last key;
|
|
96
|
+
* each patched row stamped `v`; the last chunk commits with `ready`.
|
|
97
|
+
*/
|
|
98
|
+
async function rowsStep(step, v, ready, target, context) {
|
|
99
|
+
const { table: columns } = step;
|
|
100
|
+
const sql = sqlOf(columns, target.table);
|
|
101
|
+
const order = { columns: columns.key, direction: "asc" };
|
|
102
|
+
const below = { lt: [ROW_VERSION, v] };
|
|
103
|
+
let after;
|
|
104
|
+
// The fallback yield between chunks (`macrotask`), made by the first yield that needs it, closed at the end.
|
|
105
|
+
let channel;
|
|
106
|
+
try {
|
|
107
|
+
for (;;) {
|
|
108
|
+
const statement = sql.select(below, order, after, MIGRATION_CHUNK + 1);
|
|
109
|
+
const stored = await target.store.read((executor) => executor.all(statement.sql, ...statement.params), context);
|
|
110
|
+
const last = stored.length <= MIGRATION_CHUNK;
|
|
111
|
+
if (!last)
|
|
112
|
+
stored.length = MIGRATION_CHUNK;
|
|
113
|
+
const writes = stored.map((row) => patchRow(step, row, v, sql, target.table, context));
|
|
114
|
+
if (last)
|
|
115
|
+
return await commit([...writes, ...ready], target, context);
|
|
116
|
+
await commit(writes, target, context);
|
|
117
|
+
after = columns.key.map((name) => stored[MIGRATION_CHUNK - 1][name]);
|
|
118
|
+
await macrotask(() => {
|
|
119
|
+
channel ??= new MessageChannel();
|
|
120
|
+
return channel;
|
|
121
|
+
});
|
|
122
|
+
// An abandoned activation stops here.
|
|
123
|
+
context.abortSignal?.throwIfAborted();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
channel?.port1.close();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Resolves after one macrotask (other commits and timers run between chunks) without the 1 ms clamp of
|
|
132
|
+
* `setTimeout(0)`: `setImmediate` where the runtime has it (Node), else a message through the channel `channel()`
|
|
133
|
+
* gives (browsers, Workers). In Node a message costs 0.27 ms per yield against `setImmediate`'s 13 µs (the 10k-row
|
|
134
|
+
* migration bench: 100 ms against 70 ms).
|
|
135
|
+
*/
|
|
136
|
+
function macrotask(channel) {
|
|
137
|
+
return new Promise((resolve) => {
|
|
138
|
+
// A runtime feature check: Workers and browsers have no `setImmediate`. Read once from the global, and called only
|
|
139
|
+
// when it is a function: a check by name (`in`) and a later lookup could disagree.
|
|
140
|
+
const immediate = globalThis.setImmediate;
|
|
141
|
+
if (typeof immediate === "function") {
|
|
142
|
+
immediate(resolve);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const { port1, port2 } = channel();
|
|
146
|
+
port1.addEventListener("message", () => resolve(), { once: true });
|
|
147
|
+
// A port listened to with `addEventListener` delivers only once started (browsers, Workers).
|
|
148
|
+
port1.start();
|
|
149
|
+
port2.postMessage(null);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The write of one row's patch: `patch` run on the decoded row, its result checked (an object of non-key columns of
|
|
154
|
+
* the version, values of their types) and stamped `v` through the internal form of `update`.
|
|
155
|
+
*/
|
|
156
|
+
function patchRow(step, stored, v, sql, table, context) {
|
|
157
|
+
const { table: definition } = step;
|
|
158
|
+
const patch = step.patch(definition.rows.decode(stored, context));
|
|
159
|
+
const what = `${definition.name} version ${v}: rows`;
|
|
160
|
+
if (typeof patch !== "object" || patch === null || Array.isArray(patch)) {
|
|
161
|
+
throw new Error(`${what}: expected an object of column values`);
|
|
162
|
+
}
|
|
163
|
+
const set = {};
|
|
164
|
+
for (const [name, value] of Object.entries(patch)) {
|
|
165
|
+
const column = definition.byName.get(name);
|
|
166
|
+
if (column === undefined)
|
|
167
|
+
throw new Error(`${what}: no column "${name}"`);
|
|
168
|
+
if (definition.key.includes(name))
|
|
169
|
+
throw new Error(`${what}: key column "${name}" cannot change`);
|
|
170
|
+
set[name] = cellOf(column, value, `${what}: column "${name}"`);
|
|
171
|
+
}
|
|
172
|
+
const key = {};
|
|
173
|
+
// Key columns are non-opt `str` or `int`: stored scalars.
|
|
174
|
+
for (const name of definition.key)
|
|
175
|
+
key[name] = stored[name];
|
|
176
|
+
const versions = jsonVersions(definition, set);
|
|
177
|
+
const params = definition.key.map((name) => stored[name]);
|
|
178
|
+
const statement = sql.update({ ...set, [ROW_VERSION]: v }, params, versions);
|
|
179
|
+
return stageUpdate(statement, table, key, set, recordedVersions(set, versions), v);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A patch value as a `set` node: `undefined` clears an `opt(...)` column, `json(...)` cells as JSON literals (a JSON
|
|
183
|
+
* `null` too); a scalar `null` is refused by `encodeCell`.
|
|
184
|
+
*/
|
|
185
|
+
function cellOf(column, value, what) {
|
|
186
|
+
if (value === undefined) {
|
|
187
|
+
if (!column.optional)
|
|
188
|
+
throw new Error(`${what} is not opt(...) and cannot be cleared`);
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const cell = encodeCell(column, value, what);
|
|
192
|
+
// `encodeCell` returns a scalar for a scalar column.
|
|
193
|
+
return column.type === "json" ? { json: cell.stored } : cell.stored;
|
|
194
|
+
}
|
|
195
|
+
function sqlOf(definition, table) {
|
|
196
|
+
return new TableSql(table, definition.columns, definition.rows.physical, definition.key);
|
|
197
|
+
}
|
|
198
|
+
/** Commits `writes` without the activation's abort: a commit admitted to the step completes (the fence refuses one). */
|
|
199
|
+
async function commit(writes, target, context) {
|
|
200
|
+
await target.store.commit(writes, target.fence, withoutAbortSignal(context));
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=table-migration.js.map
|