@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,268 @@
|
|
|
1
|
+
// The table expression language (slice 6a §6, §7; rules 10, 13, 14, 16; decision "Nullable columns and the `set`
|
|
2
|
+
// form"): the builders plugins write `where` and `set` with, and their compilation at staging into one data-only
|
|
3
|
+
// vocabulary (what the outbox and archives carry; `evaluate.ts` runs it in JavaScript, `sql.ts` renders it).
|
|
4
|
+
import { invalid } from "../data/internal.js";
|
|
5
|
+
import { checkScalar, encodeCell } from "./rows.js";
|
|
6
|
+
/** A value expression as a plugin builds it: `T` is its value, `K` its column type. Compiled when staged. */
|
|
7
|
+
export class Expression {
|
|
8
|
+
op;
|
|
9
|
+
args;
|
|
10
|
+
constructor(op, args) {
|
|
11
|
+
this.op = op;
|
|
12
|
+
this.args = args;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** A reference to a column of the row, as `(t) => …` callbacks get them. */
|
|
16
|
+
export class ColumnRef extends Expression {
|
|
17
|
+
column;
|
|
18
|
+
constructor(column) {
|
|
19
|
+
super("col", [column]);
|
|
20
|
+
this.column = column;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** A condition as a plugin builds it; compiled when staged or run. */
|
|
24
|
+
export class Condition {
|
|
25
|
+
op;
|
|
26
|
+
args;
|
|
27
|
+
constructor(op, args) {
|
|
28
|
+
this.op = op;
|
|
29
|
+
this.args = args;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** The column equals `value` (`NULL` never matches). */
|
|
33
|
+
export function eq(column, value) {
|
|
34
|
+
return new Condition("eq", [column, value]);
|
|
35
|
+
}
|
|
36
|
+
/** The column differs from `value` (`NULL` never matches). */
|
|
37
|
+
export function ne(column, value) {
|
|
38
|
+
return new Condition("ne", [column, value]);
|
|
39
|
+
}
|
|
40
|
+
/** The column is below `value`. */
|
|
41
|
+
export function lt(column, value) {
|
|
42
|
+
return new Condition("lt", [column, value]);
|
|
43
|
+
}
|
|
44
|
+
/** The column is at most `value`. */
|
|
45
|
+
export function lte(column, value) {
|
|
46
|
+
return new Condition("lte", [column, value]);
|
|
47
|
+
}
|
|
48
|
+
/** The column is above `value`. */
|
|
49
|
+
export function gt(column, value) {
|
|
50
|
+
return new Condition("gt", [column, value]);
|
|
51
|
+
}
|
|
52
|
+
/** The column is at least `value`. */
|
|
53
|
+
export function gte(column, value) {
|
|
54
|
+
return new Condition("gte", [column, value]);
|
|
55
|
+
}
|
|
56
|
+
/** The column equals one of `values` (`[]` matches nothing). */
|
|
57
|
+
export function inArray(column, values) {
|
|
58
|
+
return new Condition("inArray", [column, values]);
|
|
59
|
+
}
|
|
60
|
+
/** The column is `NULL` (an `opt(...)` column without a value). */
|
|
61
|
+
export function isNull(column) {
|
|
62
|
+
return new Condition("isNull", [column]);
|
|
63
|
+
}
|
|
64
|
+
/** The text column starts with `prefix`, compared by code point (`""` matches every value). */
|
|
65
|
+
export function prefix(column, prefix) {
|
|
66
|
+
return new Condition("prefix", [column, prefix]);
|
|
67
|
+
}
|
|
68
|
+
/** Every condition holds (`and()` always does). */
|
|
69
|
+
export function and(...conditions) {
|
|
70
|
+
return new Condition("and", conditions);
|
|
71
|
+
}
|
|
72
|
+
/** Some condition holds (`or()` never does). */
|
|
73
|
+
export function or(...conditions) {
|
|
74
|
+
return new Condition("or", conditions);
|
|
75
|
+
}
|
|
76
|
+
/** The condition does not hold (`NULL` stays `NULL`: it never matches). */
|
|
77
|
+
export function not(condition) {
|
|
78
|
+
return new Condition("not", [condition]);
|
|
79
|
+
}
|
|
80
|
+
/** `a + b` over integers; a result outside ±(2^53 - 1) fails (rule 10). */
|
|
81
|
+
export function add(a, b) {
|
|
82
|
+
return new Expression("add", [a, b]);
|
|
83
|
+
}
|
|
84
|
+
/** `a - b` over integers; a result outside ±(2^53 - 1) fails (rule 10). */
|
|
85
|
+
export function sub(a, b) {
|
|
86
|
+
return new Expression("sub", [a, b]);
|
|
87
|
+
}
|
|
88
|
+
/** The larger of `a` and b` (`int` or `num`). */
|
|
89
|
+
export function max(a, b) {
|
|
90
|
+
return new Expression("max", [a, b]);
|
|
91
|
+
}
|
|
92
|
+
/** The smaller of `a` and `b` (`int` or `num`). */
|
|
93
|
+
export function min(a, b) {
|
|
94
|
+
return new Expression("min", [a, b]);
|
|
95
|
+
}
|
|
96
|
+
/** `a` followed by `b`. */
|
|
97
|
+
export function concat(a, b) {
|
|
98
|
+
return new Expression("concat", [a, b]);
|
|
99
|
+
}
|
|
100
|
+
/** `value` with its prefix `from` replaced by `to`; a value without the prefix stays as it is. */
|
|
101
|
+
export function replacePrefix(value, from, to) {
|
|
102
|
+
return new Expression("replacePrefix", [value, from, to]);
|
|
103
|
+
}
|
|
104
|
+
/** `a` unless it is `NULL`, else `b`. */
|
|
105
|
+
export function coalesce(a, b) {
|
|
106
|
+
return new Expression("coalesce", [a, b]);
|
|
107
|
+
}
|
|
108
|
+
/** `a` where `condition` holds for the row, else `b`. */
|
|
109
|
+
export function when(condition, a, b) {
|
|
110
|
+
return new Expression("when", [condition, a, b]);
|
|
111
|
+
}
|
|
112
|
+
/** One `ColumnRef` per column of `definition`, for its `(t) => …` callbacks. */
|
|
113
|
+
export function columnRefs(columns) {
|
|
114
|
+
return Object.fromEntries(columns.map(({ name }) => [name, new ColumnRef(name)]));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Compiles a plugin's condition over `table`'s columns (a trust boundary: plugin values): known scalar columns,
|
|
118
|
+
* operands of their type made storable (`invalid/args` otherwise, `undefined` included: ask with `isNull`, rule 16).
|
|
119
|
+
*/
|
|
120
|
+
export function compileWhere(table, condition, what) {
|
|
121
|
+
if (!(condition instanceof Condition))
|
|
122
|
+
throw invalid("args", `${table.name}: ${what}: expected a condition`);
|
|
123
|
+
const { op, args } = condition;
|
|
124
|
+
switch (op) {
|
|
125
|
+
case "and":
|
|
126
|
+
case "or": {
|
|
127
|
+
const nodes = args.map((each) => compileWhere(table, each, what));
|
|
128
|
+
return op === "and" ? { and: nodes } : { or: nodes };
|
|
129
|
+
}
|
|
130
|
+
case "not":
|
|
131
|
+
return { not: compileWhere(table, args[0], what) };
|
|
132
|
+
case "isNull":
|
|
133
|
+
return { isNull: scalarColumn(table, args[0], what).name };
|
|
134
|
+
case "prefix": {
|
|
135
|
+
const column = scalarColumn(table, args[0], what);
|
|
136
|
+
if (column.type !== "str")
|
|
137
|
+
throw invalid("args", `${table.name}: ${what}: prefix needs a str() column`);
|
|
138
|
+
return { prefix: [column.name, operand(column, args[1], what)] };
|
|
139
|
+
}
|
|
140
|
+
case "inArray": {
|
|
141
|
+
const column = scalarColumn(table, args[0], what);
|
|
142
|
+
const values = args[1];
|
|
143
|
+
if (!Array.isArray(values))
|
|
144
|
+
throw invalid("args", `${table.name}: ${what}: inArray needs an array`);
|
|
145
|
+
return { inArray: [column.name, values.map((value) => operand(column, value, what))] };
|
|
146
|
+
}
|
|
147
|
+
default: {
|
|
148
|
+
const column = scalarColumn(table, args[0], what);
|
|
149
|
+
// One of the six comparisons: the node's shape is `{ [op]: [column, value] }`.
|
|
150
|
+
return { [op]: [column.name, operand(column, args[1], what)] };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Compiles a plugin's `set` (plain values or a callback's result) for `table` (a trust boundary): known non-key
|
|
156
|
+
* columns (rule 13), at least one (rule 14), `undefined` clearing an `opt(...)` column as the explicit `null` (a
|
|
157
|
+
* `null` value is a `json(...)` cell's JSON `null`, refused for other columns), an
|
|
158
|
+
* expression whose result may be `NULL` only for an `opt(...)` column; integer arithmetic only on `int` columns.
|
|
159
|
+
*/
|
|
160
|
+
export function compileSet(table, set, what) {
|
|
161
|
+
if (typeof set !== "object" || set === null || Array.isArray(set)) {
|
|
162
|
+
throw invalid("args", `${table.name}: ${what}: expected an object of column values`);
|
|
163
|
+
}
|
|
164
|
+
const entries = Object.entries(set);
|
|
165
|
+
if (entries.length === 0)
|
|
166
|
+
throw invalid("args", `${table.name}: ${what}: the set is empty`);
|
|
167
|
+
const node = {};
|
|
168
|
+
for (const [name, value] of entries) {
|
|
169
|
+
const column = table.byName.get(name);
|
|
170
|
+
if (column === undefined)
|
|
171
|
+
throw invalid("args", `${table.name}: ${what}: no column "${name}"`);
|
|
172
|
+
if (table.key.includes(name)) {
|
|
173
|
+
throw invalid("args", `${table.name}: ${what}: key column "${name}" cannot change (delete and put)`);
|
|
174
|
+
}
|
|
175
|
+
const where = `${what}: column "${name}"`;
|
|
176
|
+
if (value === undefined) {
|
|
177
|
+
if (!column.optional)
|
|
178
|
+
throw invalid("args", `${table.name}: ${where} is not opt(...) and cannot be cleared`);
|
|
179
|
+
node[name] = null;
|
|
180
|
+
}
|
|
181
|
+
else if (value === null && column.type !== "json") {
|
|
182
|
+
// A row never holds an explicit `null` (decision "Nullable columns and the set form"); a JSON `null` is a value.
|
|
183
|
+
throw invalid("args", `${table.name}: ${where}: null is no ${column.type} value (undefined clears)`);
|
|
184
|
+
}
|
|
185
|
+
else if (value instanceof Expression) {
|
|
186
|
+
if (column.type === "json")
|
|
187
|
+
throw invalid("args", `${table.name}: ${where}: json(...) columns take plain values`);
|
|
188
|
+
const compiled = compileExpr(table, value, column.type, where);
|
|
189
|
+
if (compiled.nullable && !column.optional) {
|
|
190
|
+
throw invalid("args", `${table.name}: ${where}: the expression may be NULL; the column is not opt(...)`);
|
|
191
|
+
}
|
|
192
|
+
node[name] = compiled.node;
|
|
193
|
+
}
|
|
194
|
+
else if (column.type === "json") {
|
|
195
|
+
node[name] = { json: encodeCell(column, value, `${table.name}: ${where}`).stored };
|
|
196
|
+
}
|
|
197
|
+
else
|
|
198
|
+
node[name] = checkScalar(column.type, value, `${table.name}: ${where}`);
|
|
199
|
+
}
|
|
200
|
+
return node;
|
|
201
|
+
}
|
|
202
|
+
function compileExpr(table, value, type, what) {
|
|
203
|
+
if (!(value instanceof Expression)) {
|
|
204
|
+
if (value === undefined || value === null)
|
|
205
|
+
return { node: null, nullable: true };
|
|
206
|
+
return { node: checkScalar(type, value, `${table.name}: ${what}`), nullable: false };
|
|
207
|
+
}
|
|
208
|
+
const { op, args } = value;
|
|
209
|
+
const refuse = (message) => {
|
|
210
|
+
throw invalid("args", `${table.name}: ${what}: ${message}`);
|
|
211
|
+
};
|
|
212
|
+
switch (op) {
|
|
213
|
+
case "col": {
|
|
214
|
+
const column = table.byName.get(args[0]) ?? refuse(`no column "${String(args[0])}"`);
|
|
215
|
+
if (column.type !== type)
|
|
216
|
+
refuse(`column "${column.name}" is ${column.type}, not ${type}`);
|
|
217
|
+
return { node: { col: column.name }, nullable: column.optional };
|
|
218
|
+
}
|
|
219
|
+
case "add":
|
|
220
|
+
case "sub":
|
|
221
|
+
case "max":
|
|
222
|
+
case "min":
|
|
223
|
+
case "concat": {
|
|
224
|
+
const types = op === "concat" ? ["str"] : op === "add" || op === "sub" ? ["int"] : ["int", "num"];
|
|
225
|
+
if (!types.includes(type))
|
|
226
|
+
refuse(`${op} gives ${types.join(" or ")}, the column is ${type}`);
|
|
227
|
+
const [a, b] = [compileExpr(table, args[0], type, what), compileExpr(table, args[1], type, what)];
|
|
228
|
+
// The operation's shape is `{ [op]: [a, b] }`.
|
|
229
|
+
return { node: { [op]: [a.node, b.node] }, nullable: a.nullable || b.nullable };
|
|
230
|
+
}
|
|
231
|
+
case "coalesce": {
|
|
232
|
+
const [a, b] = [compileExpr(table, args[0], type, what), compileExpr(table, args[1], type, what)];
|
|
233
|
+
return { node: { coalesce: [a.node, b.node] }, nullable: a.nullable && b.nullable };
|
|
234
|
+
}
|
|
235
|
+
case "replacePrefix": {
|
|
236
|
+
if (type !== "str")
|
|
237
|
+
refuse(`replacePrefix gives str, the column is ${type}`);
|
|
238
|
+
const subject = compileExpr(table, args[0], type, what);
|
|
239
|
+
const [from, to] = [args[1], args[2]].map((each) => checkScalar("str", each, `${table.name}: ${what}`));
|
|
240
|
+
return { node: { replacePrefix: [subject.node, from, to] }, nullable: subject.nullable };
|
|
241
|
+
}
|
|
242
|
+
case "when": {
|
|
243
|
+
const condition = compileWhere(table, args[0], what);
|
|
244
|
+
const [a, b] = [compileExpr(table, args[1], type, what), compileExpr(table, args[2], type, what)];
|
|
245
|
+
return { node: { when: [condition, a.node, b.node] }, nullable: a.nullable || b.nullable };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** The column a condition compares: a reference to a known scalar column. */
|
|
250
|
+
function scalarColumn(table, ref, what) {
|
|
251
|
+
if (!(ref instanceof ColumnRef))
|
|
252
|
+
throw invalid("args", `${table.name}: ${what}: expected a column reference`);
|
|
253
|
+
const column = table.byName.get(ref.column);
|
|
254
|
+
if (column === undefined)
|
|
255
|
+
throw invalid("args", `${table.name}: ${what}: no column "${ref.column}"`);
|
|
256
|
+
if (column.type === "json")
|
|
257
|
+
throw invalid("args", `${table.name}: ${what}: json(...) column "${ref.column}" is not queryable`);
|
|
258
|
+
return column;
|
|
259
|
+
}
|
|
260
|
+
/** An operand compared with `column`, made storable; `undefined` and `null` are refused (rule 16). */
|
|
261
|
+
function operand(column, value, what) {
|
|
262
|
+
if (value === undefined || value === null) {
|
|
263
|
+
throw invalid("args", `${what}: column "${column.name}" compared with ${String(value)}; ask with isNull`);
|
|
264
|
+
}
|
|
265
|
+
// `scalarColumn` refused json columns.
|
|
266
|
+
return checkScalar(column.type, value, `${what}: column "${column.name}"`);
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../src/store/expression.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,iHAAiH;AACjH,6GAA6G;AAG7G,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAe,MAAM,WAAW,CAAC;AA0CjE,6GAA6G;AAC7G,MAAM,OAAO,UAAU;IACb,EAAE,CAAoB;IACtB,IAAI,CAAqB;IAKlC,YAAY,EAAqB,EAAE,IAAwB;QAC1D,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,4EAA4E;AAC5E,MAAM,OAAO,SAA0D,SAAQ,UAAgB;IACrF,MAAM,CAAS;IAExB,YAAY,MAAc;QACzB,KAAK,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAA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AI,+BAA+B,CAAC,CAAC;IAC9G,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,KAAK,IAAI,gBAAgB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IACrG,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;QACzB,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,KAAK,IAAI,uBAAuB,GAAG,CAAC,MAAM,oBAAoB,CAAC,CAAC;IACpG,OAAO,MAAM,CAAC;AACf,CAAC;AAED,sGAAsG;AACtG,SAAS,OAAO,CAAC,MAAc,EAAE,KAAc,EAAE,IAAY;IAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3C,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,aAAa,MAAM,CAAC,IAAI,mBAAmB,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC3G,CAAC;IACD,uCAAuC;IACvC,OAAO,WAAW,CAAC,MAAM,CAAC,IAAkB,EAAE,KAAK,EAAE,GAAG,IAAI,aAAa,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["// The table expression language (slice 6a §6, §7; rules 10, 13, 14, 16; decision \"Nullable columns and the `set`\n// form\"): the builders plugins write `where` and `set` with, and their compilation at staging into one data-only\n// vocabulary (what the outbox and archives carry; `evaluate.ts` runs it in JavaScript, `sql.ts` renders it).\n\nimport type { Optional } from \"../contracts/index.ts\";\nimport { invalid } from \"../data/internal.ts\";\nimport type { JsonValue } from \"../json.ts\";\nimport type { Column, Columns, ColumnType, ColumnTypeOf, ValueOf } from \"./columns.ts\";\nimport { checkScalar, encodeCell, type Scalar } from \"./rows.ts\";\nimport type { TableDefinition } from \"./table.ts\";\n\n/** A compiled condition: column comparisons with checked operands, combined by `and`, `or`, `not`. */\nexport type WhereNode =\n\t| { readonly eq: readonly [string, Scalar] }\n\t| { readonly ne: readonly [string, Scalar] }\n\t| { readonly lt: readonly [string, Scalar] }\n\t| { readonly lte: readonly [string, Scalar] }\n\t| { readonly gt: readonly [string, Scalar] }\n\t| { readonly gte: readonly [string, Scalar] }\n\t| { readonly inArray: readonly [string, readonly Scalar[]] }\n\t| { readonly isNull: string }\n\t| { readonly prefix: readonly [string, string] }\n\t| { readonly and: readonly WhereNode[] }\n\t| { readonly or: readonly WhereNode[] }\n\t| { readonly not: WhereNode };\n\n/** A compiled value expression: a literal (`null` clears), a column, a `json(...)` cell, or an operation. */\nexport type ExprNode =\n\t| Scalar\n\t| null\n\t| { readonly col: string }\n\t| { readonly json: JsonValue }\n\t| { readonly add: readonly [ExprNode, ExprNode] }\n\t| { readonly sub: readonly [ExprNode, ExprNode] }\n\t| { readonly max: readonly [ExprNode, ExprNode] }\n\t| { readonly min: readonly [ExprNode, ExprNode] }\n\t| { readonly concat: readonly [ExprNode, ExprNode] }\n\t| { readonly coalesce: readonly [ExprNode, ExprNode] }\n\t| { readonly replacePrefix: readonly [ExprNode, string, string] }\n\t| { readonly when: readonly [WhereNode, ExprNode, ExprNode] };\n\n/** A compiled `set`: the new value of each changed column, every right side evaluated against the row before. */\nexport type SetNode = { readonly [column: string]: ExprNode };\n\n/** The comparison operators of a `WhereNode`. */\nexport type Comparison = \"eq\" | \"ne\" | \"lt\" | \"lte\" | \"gt\" | \"gte\";\n\n/** The operations of an `ExprNode`. */\nexport type Operation = \"add\" | \"sub\" | \"max\" | \"min\" | \"concat\" | \"coalesce\" | \"replacePrefix\" | \"when\";\n\n/** A value expression as a plugin builds it: `T` is its value, `K` its column type. Compiled when staged. */\nexport class Expression<T = unknown, K extends ColumnType = ColumnType> {\n\treadonly op: Operation | \"col\";\n\treadonly args: readonly unknown[];\n\t/** Type only. */\n\tdeclare readonly \"~value\"?: T;\n\tdeclare readonly \"~type\"?: K;\n\n\tconstructor(op: Operation | \"col\", args: readonly unknown[]) {\n\t\tthis.op = op;\n\t\tthis.args = args;\n\t}\n}\n\n/** A reference to a column of the row, as `(t) => …` callbacks get them. */\nexport class ColumnRef<T = unknown, K extends ColumnType = ColumnType> extends Expression<T, K> {\n\treadonly column: string;\n\n\tconstructor(column: string) {\n\t\tsuper(\"col\", [column]);\n\t\tthis.column = column;\n\t}\n}\n\n/** A condition as a plugin builds it; compiled when staged or run. */\nexport class Condition {\n\treadonly op: Comparison | \"inArray\" | \"isNull\" | \"prefix\" | \"and\" | \"or\" | \"not\";\n\treadonly args: readonly unknown[];\n\n\tconstructor(op: Condition[\"op\"], args: readonly unknown[]) {\n\t\tthis.op = op;\n\t\tthis.args = args;\n\t}\n}\n\n/**\n * A `set` of a table with columns `C` and key `K`: new values of non-key columns, each a value or an expression of\n * the column's type; `undefined` clears an `opt(...)` column.\n */\nexport type SetOf<C extends Columns, K extends readonly string[]> = {\n\treadonly [P in Exclude<keyof C & string, K[number]>]?: C[P] extends Optional\n\t\t? ValueOf<C[P]> | Expression<ValueOf<C[P]>, ColumnTypeOf<C[P]>> | undefined\n\t\t: ValueOf<C[P]> | Expression<ValueOf<C[P]>, ColumnTypeOf<C[P]>>;\n};\n\n/** A scalar column type. */\ntype ScalarType = Exclude<ColumnType, \"json\">;\n\n/** An operand of type `T` and column type `K`: an expression or a plain value. */\ntype Operand<T, K extends ColumnType> = Expression<T, K> | T;\n\n/** The column equals `value` (`NULL` never matches). */\nexport function eq<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"eq\", [column, value]);\n}\n\n/** The column differs from `value` (`NULL` never matches). */\nexport function ne<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"ne\", [column, value]);\n}\n\n/** The column is below `value`. */\nexport function lt<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"lt\", [column, value]);\n}\n\n/** The column is at most `value`. */\nexport function lte<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"lte\", [column, value]);\n}\n\n/** The column is above `value`. */\nexport function gt<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"gt\", [column, value]);\n}\n\n/** The column is at least `value`. */\nexport function gte<T extends Scalar>(column: ColumnRef<T, ScalarType>, value: T): Condition {\n\treturn new Condition(\"gte\", [column, value]);\n}\n\n/** The column equals one of `values` (`[]` matches nothing). */\nexport function inArray<T extends Scalar>(column: ColumnRef<T, ScalarType>, values: readonly T[]): Condition {\n\treturn new Condition(\"inArray\", [column, values]);\n}\n\n/** The column is `NULL` (an `opt(...)` column without a value). */\nexport function isNull(column: ColumnRef<unknown, ScalarType>): Condition {\n\treturn new Condition(\"isNull\", [column]);\n}\n\n/** The text column starts with `prefix`, compared by code point (`\"\"` matches every value). */\nexport function prefix(column: ColumnRef<string, \"str\">, prefix: string): Condition {\n\treturn new Condition(\"prefix\", [column, prefix]);\n}\n\n/** Every condition holds (`and()` always does). */\nexport function and(...conditions: Condition[]): Condition {\n\treturn new Condition(\"and\", conditions);\n}\n\n/** Some condition holds (`or()` never does). */\nexport function or(...conditions: Condition[]): Condition {\n\treturn new Condition(\"or\", conditions);\n}\n\n/** The condition does not hold (`NULL` stays `NULL`: it never matches). */\nexport function not(condition: Condition): Condition {\n\treturn new Condition(\"not\", [condition]);\n}\n\n/** `a + b` over integers; a result outside ±(2^53 - 1) fails (rule 10). */\nexport function add(a: Operand<number, \"int\">, b: Operand<number, \"int\">): Expression<number, \"int\"> {\n\treturn new Expression(\"add\", [a, b]);\n}\n\n/** `a - b` over integers; a result outside ±(2^53 - 1) fails (rule 10). */\nexport function sub(a: Operand<number, \"int\">, b: Operand<number, \"int\">): Expression<number, \"int\"> {\n\treturn new Expression(\"sub\", [a, b]);\n}\n\n/** The larger of `a` and b` (`int` or `num`). */\nexport function max<K extends \"int\" | \"num\">(a: Operand<number, K>, b: Operand<number, K>): Expression<number, K> {\n\treturn new Expression(\"max\", [a, b]);\n}\n\n/** The smaller of `a` and `b` (`int` or `num`). */\nexport function min<K extends \"int\" | \"num\">(a: Operand<number, K>, b: Operand<number, K>): Expression<number, K> {\n\treturn new Expression(\"min\", [a, b]);\n}\n\n/** `a` followed by `b`. */\nexport function concat(a: Operand<string, \"str\">, b: Operand<string, \"str\">): Expression<string, \"str\"> {\n\treturn new Expression(\"concat\", [a, b]);\n}\n\n/** `value` with its prefix `from` replaced by `to`; a value without the prefix stays as it is. */\nexport function replacePrefix(value: Operand<string, \"str\">, from: string, to: string): Expression<string, \"str\"> {\n\treturn new Expression(\"replacePrefix\", [value, from, to]);\n}\n\n/** `a` unless it is `NULL`, else `b`. */\nexport function coalesce<T, K extends ScalarType>(a: Expression<T, K>, b: Operand<T, K>): Expression<T, K> {\n\treturn new Expression(\"coalesce\", [a, b]);\n}\n\n/** `a` where `condition` holds for the row, else `b`. */\nexport function when<T, K extends ScalarType>(\n\tcondition: Condition,\n\ta: Operand<T, K>,\n\tb: Operand<T, K>,\n): Expression<T, K> {\n\treturn new Expression(\"when\", [condition, a, b]);\n}\n\n/** One `ColumnRef` per column of `definition`, for its `(t) => …` callbacks. */\nexport function columnRefs(columns: readonly Column[]): { readonly [column: string]: ColumnRef } {\n\treturn Object.fromEntries(columns.map(({ name }) => [name, new ColumnRef(name)]));\n}\n\n/**\n * Compiles a plugin's condition over `table`'s columns (a trust boundary: plugin values): known scalar columns,\n * operands of their type made storable (`invalid/args` otherwise, `undefined` included: ask with `isNull`, rule 16).\n */\nexport function compileWhere(table: TableDefinition, condition: unknown, what: string): WhereNode {\n\tif (!(condition instanceof Condition)) throw invalid(\"args\", `${table.name}: ${what}: expected a condition`);\n\tconst { op, args } = condition;\n\tswitch (op) {\n\t\tcase \"and\":\n\t\tcase \"or\": {\n\t\t\tconst nodes = args.map((each) => compileWhere(table, each, what));\n\t\t\treturn op === \"and\" ? { and: nodes } : { or: nodes };\n\t\t}\n\t\tcase \"not\":\n\t\t\treturn { not: compileWhere(table, args[0], what) };\n\t\tcase \"isNull\":\n\t\t\treturn { isNull: scalarColumn(table, args[0], what).name };\n\t\tcase \"prefix\": {\n\t\t\tconst column = scalarColumn(table, args[0], what);\n\t\t\tif (column.type !== \"str\") throw invalid(\"args\", `${table.name}: ${what}: prefix needs a str() column`);\n\t\t\treturn { prefix: [column.name, operand(column, args[1], what) as string] };\n\t\t}\n\t\tcase \"inArray\": {\n\t\t\tconst column = scalarColumn(table, args[0], what);\n\t\t\tconst values = args[1];\n\t\t\tif (!Array.isArray(values)) throw invalid(\"args\", `${table.name}: ${what}: inArray needs an array`);\n\t\t\treturn { inArray: [column.name, values.map((value) => operand(column, value, what))] };\n\t\t}\n\t\tdefault: {\n\t\t\tconst column = scalarColumn(table, args[0], what);\n\t\t\t// One of the six comparisons: the node's shape is `{ [op]: [column, value] }`.\n\t\t\treturn { [op]: [column.name, operand(column, args[1], what)] as const } as WhereNode;\n\t\t}\n\t}\n}\n\n/**\n * Compiles a plugin's `set` (plain values or a callback's result) for `table` (a trust boundary): known non-key\n * columns (rule 13), at least one (rule 14), `undefined` clearing an `opt(...)` column as the explicit `null` (a\n * `null` value is a `json(...)` cell's JSON `null`, refused for other columns), an\n * expression whose result may be `NULL` only for an `opt(...)` column; integer arithmetic only on `int` columns.\n */\nexport function compileSet(table: TableDefinition, set: unknown, what: string): SetNode {\n\tif (typeof set !== \"object\" || set === null || Array.isArray(set)) {\n\t\tthrow invalid(\"args\", `${table.name}: ${what}: expected an object of column values`);\n\t}\n\tconst entries = Object.entries(set);\n\tif (entries.length === 0) throw invalid(\"args\", `${table.name}: ${what}: the set is empty`);\n\tconst node: { [column: string]: ExprNode } = {};\n\tfor (const [name, value] of entries) {\n\t\tconst column = table.byName.get(name);\n\t\tif (column === undefined) throw invalid(\"args\", `${table.name}: ${what}: no column \"${name}\"`);\n\t\tif (table.key.includes(name)) {\n\t\t\tthrow invalid(\"args\", `${table.name}: ${what}: key column \"${name}\" cannot change (delete and put)`);\n\t\t}\n\t\tconst where = `${what}: column \"${name}\"`;\n\t\tif (value === undefined) {\n\t\t\tif (!column.optional) throw invalid(\"args\", `${table.name}: ${where} is not opt(...) and cannot be cleared`);\n\t\t\tnode[name] = null;\n\t\t} else if (value === null && column.type !== \"json\") {\n\t\t\t// A row never holds an explicit `null` (decision \"Nullable columns and the set form\"); a JSON `null` is a value.\n\t\t\tthrow invalid(\"args\", `${table.name}: ${where}: null is no ${column.type} value (undefined clears)`);\n\t\t} else if (value instanceof Expression) {\n\t\t\tif (column.type === \"json\")\n\t\t\t\tthrow invalid(\"args\", `${table.name}: ${where}: json(...) columns take plain values`);\n\t\t\tconst compiled = compileExpr(table, value, column.type, where);\n\t\t\tif (compiled.nullable && !column.optional) {\n\t\t\t\tthrow invalid(\"args\", `${table.name}: ${where}: the expression may be NULL; the column is not opt(...)`);\n\t\t\t}\n\t\t\tnode[name] = compiled.node;\n\t\t} else if (column.type === \"json\") {\n\t\t\tnode[name] = { json: encodeCell(column, value, `${table.name}: ${where}`).stored };\n\t\t} else node[name] = checkScalar(column.type, value, `${table.name}: ${where}`);\n\t}\n\treturn node;\n}\n\n/** A compiled expression and whether its result may be `NULL`. */\ntype Compiled = { readonly node: ExprNode; readonly nullable: boolean };\n\nfunction compileExpr(table: TableDefinition, value: unknown, type: ScalarType, what: string): Compiled {\n\tif (!(value instanceof Expression)) {\n\t\tif (value === undefined || value === null) return { node: null, nullable: true };\n\t\treturn { node: checkScalar(type, value, `${table.name}: ${what}`), nullable: false };\n\t}\n\tconst { op, args } = value;\n\tconst refuse = (message: string): never => {\n\t\tthrow invalid(\"args\", `${table.name}: ${what}: ${message}`);\n\t};\n\tswitch (op) {\n\t\tcase \"col\": {\n\t\t\tconst column = table.byName.get(args[0] as string) ?? refuse(`no column \"${String(args[0])}\"`);\n\t\t\tif (column.type !== type) refuse(`column \"${column.name}\" is ${column.type}, not ${type}`);\n\t\t\treturn { node: { col: column.name }, nullable: column.optional };\n\t\t}\n\t\tcase \"add\":\n\t\tcase \"sub\":\n\t\tcase \"max\":\n\t\tcase \"min\":\n\t\tcase \"concat\": {\n\t\t\tconst types: readonly ScalarType[] =\n\t\t\t\top === \"concat\" ? [\"str\"] : op === \"add\" || op === \"sub\" ? [\"int\"] : [\"int\", \"num\"];\n\t\t\tif (!types.includes(type)) refuse(`${op} gives ${types.join(\" or \")}, the column is ${type}`);\n\t\t\tconst [a, b] = [compileExpr(table, args[0], type, what), compileExpr(table, args[1], type, what)];\n\t\t\t// The operation's shape is `{ [op]: [a, b] }`.\n\t\t\treturn { node: { [op]: [a.node, b.node] } as ExprNode, nullable: a.nullable || b.nullable };\n\t\t}\n\t\tcase \"coalesce\": {\n\t\t\tconst [a, b] = [compileExpr(table, args[0], type, what), compileExpr(table, args[1], type, what)];\n\t\t\treturn { node: { coalesce: [a.node, b.node] }, nullable: a.nullable && b.nullable };\n\t\t}\n\t\tcase \"replacePrefix\": {\n\t\t\tif (type !== \"str\") refuse(`replacePrefix gives str, the column is ${type}`);\n\t\t\tconst subject = compileExpr(table, args[0], type, what);\n\t\t\tconst [from, to] = [args[1], args[2]].map(\n\t\t\t\t(each) => checkScalar(\"str\", each, `${table.name}: ${what}`) as string,\n\t\t\t);\n\t\t\treturn { node: { replacePrefix: [subject.node, from!, to!] }, nullable: subject.nullable };\n\t\t}\n\t\tcase \"when\": {\n\t\t\tconst condition = compileWhere(table, args[0], what);\n\t\t\tconst [a, b] = [compileExpr(table, args[1], type, what), compileExpr(table, args[2], type, what)];\n\t\t\treturn { node: { when: [condition, a.node, b.node] }, nullable: a.nullable || b.nullable };\n\t\t}\n\t}\n}\n\n/** The column a condition compares: a reference to a known scalar column. */\nfunction scalarColumn(table: TableDefinition, ref: unknown, what: string): Column {\n\tif (!(ref instanceof ColumnRef)) throw invalid(\"args\", `${table.name}: ${what}: expected a column reference`);\n\tconst column = table.byName.get(ref.column);\n\tif (column === undefined) throw invalid(\"args\", `${table.name}: ${what}: no column \"${ref.column}\"`);\n\tif (column.type === \"json\")\n\t\tthrow invalid(\"args\", `${table.name}: ${what}: json(...) column \"${ref.column}\" is not queryable`);\n\treturn column;\n}\n\n/** An operand compared with `column`, made storable; `undefined` and `null` are refused (rule 16). */\nfunction operand(column: Column, value: unknown, what: string): Scalar {\n\tif (value === undefined || value === null) {\n\t\tthrow invalid(\"args\", `${what}: column \"${column.name}\" compared with ${String(value)}; ask with isNull`);\n\t}\n\t// `scalarColumn` refused json columns.\n\treturn checkScalar(column.type as ScalarType, value, `${what}: column \"${column.name}\"`);\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Context } from "../context/index.ts";
|
|
2
|
+
import type { Backend } from "./backend.ts";
|
|
3
|
+
import { type Store, type StoreOptions } from "./store.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A store holding the archive `parts` on `backend`, which must not hold a store yet: at the manifest's `lastSeq`, its
|
|
6
|
+
* outbox (when `options.outbox`) starting after it. A refused archive, a stalled input cancelled by `context` or a
|
|
7
|
+
* backend error rejects; the backend is closed then (rule 12).
|
|
8
|
+
*/
|
|
9
|
+
export declare function importStore(backend: Backend, parts: AsyncIterable<unknown> | Iterable<unknown>, context: Context, options?: StoreOptions): Promise<Store>;
|
|
10
|
+
//# sourceMappingURL=import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/store/import.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAOrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,OAAO,EAAc,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAGvE;;;;GAIG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EACjD,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,YAAiB,GACxB,OAAO,CAAC,KAAK,CAAC,CAqBhB"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// `importStore(backend, parts, ctx, { outbox? })` (slice 6a §13, rules 12, 24, 25): a store made from an archive, a
|
|
2
|
+
// trust boundary. Every part is checked against the archive schema, its place in the archive's order and its content
|
|
3
|
+
// (names, rows against their table's recorded columns, ids and seqs, lifetimes at one address never overlapping,
|
|
4
|
+
// revisions in seq order from a base, versions, duplicates, the `end` count, the manifest); everything is applied in
|
|
5
|
+
// one backend transaction with the applier, so a refused import leaves the backend as it was. An input that stalls is
|
|
6
|
+
// cancelled by `ctx`.
|
|
7
|
+
import { awaitWithContext } from "../context/index.js";
|
|
8
|
+
import { ChordError } from "../data/index.js";
|
|
9
|
+
import { invalid } from "../data/internal.js";
|
|
10
|
+
import { IdAllocator } from "./allocator.js";
|
|
11
|
+
import { applyWrite } from "./applier.js";
|
|
12
|
+
import { ARCHIVE_FORMAT, checkPart } from "./archive.js";
|
|
13
|
+
import { readCatalog, writeCatalog } from "./catalog.js";
|
|
14
|
+
import { applyStoreSchema, STORE_SCHEMA, TABLES } from "./schema.js";
|
|
15
|
+
import { Step } from "./step.js";
|
|
16
|
+
import { ChordStore } from "./store.js";
|
|
17
|
+
import { storedText } from "./text.js";
|
|
18
|
+
/**
|
|
19
|
+
* A store holding the archive `parts` on `backend`, which must not hold a store yet: at the manifest's `lastSeq`, its
|
|
20
|
+
* outbox (when `options.outbox`) starting after it. A refused archive, a stalled input cancelled by `context` or a
|
|
21
|
+
* backend error rejects; the backend is closed then (rule 12).
|
|
22
|
+
*/
|
|
23
|
+
export async function importStore(backend, parts, context, options = {}) {
|
|
24
|
+
const { db } = backend;
|
|
25
|
+
try {
|
|
26
|
+
context.abortSignal?.throwIfAborted();
|
|
27
|
+
const existing = await db.get(`SELECT name FROM sqlite_master WHERE name = ?`, TABLES.meta);
|
|
28
|
+
if (existing !== undefined)
|
|
29
|
+
throw invalid("args", "import: the backend holds a store already");
|
|
30
|
+
const meta = await db.transaction(async (executor) => {
|
|
31
|
+
const meta = await applyStoreSchema(inTransaction(executor));
|
|
32
|
+
const archive = new ArchiveImport(executor, context);
|
|
33
|
+
await each(parts, context, (part) => archive.take(part));
|
|
34
|
+
return archive.finish(meta, options.outbox === true);
|
|
35
|
+
});
|
|
36
|
+
return new ChordStore(db, meta, await readCatalog(db));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
try {
|
|
40
|
+
await db.close();
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// The import's own failure is the one to report.
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** The store's schema migrations run inside the import's backend transaction (they open none of their own). */
|
|
49
|
+
function inTransaction(executor) {
|
|
50
|
+
return {
|
|
51
|
+
exec: (sql) => executor.exec(sql),
|
|
52
|
+
run: (sql, ...params) => executor.run(sql, ...params),
|
|
53
|
+
runCounted: (sql, ...params) => executor.runCounted(sql, ...params),
|
|
54
|
+
get: (sql, ...params) => executor.get(sql, ...params),
|
|
55
|
+
all: (sql, ...params) => executor.all(sql, ...params),
|
|
56
|
+
transaction: (callback) => callback(executor),
|
|
57
|
+
close: () => Promise.reject(new Error("import: the backend closes after the import")),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One archive being imported: the place reached in its order (the manifest, then table groups of a `table` write, its
|
|
62
|
+
* `put`s and its `index` writes, then the documents, then `end`), what was seen (tables, ids, live addresses, the
|
|
63
|
+
* write count) and the step its writes are applied in.
|
|
64
|
+
*/
|
|
65
|
+
class ArchiveImport {
|
|
66
|
+
#executor;
|
|
67
|
+
#context;
|
|
68
|
+
#position = 0;
|
|
69
|
+
#manifest;
|
|
70
|
+
#step;
|
|
71
|
+
/** Where the next part may go. */
|
|
72
|
+
#place = "manifest";
|
|
73
|
+
/** The table whose group is open. */
|
|
74
|
+
#table;
|
|
75
|
+
#tables = new Set();
|
|
76
|
+
#ids = new Set();
|
|
77
|
+
/** The lifetimes seen at each address, `[createdAt, retiredAt)` (`Infinity` while live). */
|
|
78
|
+
#lifetimes = new Map();
|
|
79
|
+
/** The record whose revisions may follow, with the last revision's seq and its base's version. */
|
|
80
|
+
#document;
|
|
81
|
+
#writes = 0;
|
|
82
|
+
constructor(executor, context) {
|
|
83
|
+
this.#executor = executor;
|
|
84
|
+
this.#context = context;
|
|
85
|
+
}
|
|
86
|
+
/** Checks the next part and applies it. */
|
|
87
|
+
async take(value) {
|
|
88
|
+
const position = this.#position++;
|
|
89
|
+
const part = checkPart(value, position, this.#context);
|
|
90
|
+
const what = `import: part ${position} (${part.kind})`;
|
|
91
|
+
if (this.#place === "ended")
|
|
92
|
+
throw invalid("args", `${what}: after the end`);
|
|
93
|
+
if (part.kind === "manifest" || this.#step === undefined) {
|
|
94
|
+
this.#start(part, what);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (part.kind === "end") {
|
|
98
|
+
if (part.writes !== this.#writes) {
|
|
99
|
+
throw invalid("args", `${what}: counts ${part.writes} writes, the archive has ${this.#writes}`);
|
|
100
|
+
}
|
|
101
|
+
this.#endDocument(what);
|
|
102
|
+
this.#place = "ended";
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.#place = this.#placeOf(part, what);
|
|
106
|
+
this.#writes++;
|
|
107
|
+
await applyWrite(this.#step, part, what);
|
|
108
|
+
}
|
|
109
|
+
/** The stored metadata once the archive ended: its `lastSeq`, the allocator's next id and the outbox setting. */
|
|
110
|
+
async finish(meta, outbox) {
|
|
111
|
+
if (this.#place !== "ended" || this.#step === undefined || this.#manifest === undefined) {
|
|
112
|
+
throw invalid("args", "import: the archive has no end part");
|
|
113
|
+
}
|
|
114
|
+
const { lastSeq, nextId } = this.#manifest;
|
|
115
|
+
await writeCatalog(this.#step);
|
|
116
|
+
await this.#executor.run(`UPDATE ${TABLES.meta} SET last_seq = ?, next_id = ?, outbox = ?, outbox_floor = ? WHERE singleton = 1`, lastSeq, nextId, outbox ? 1 : 0, lastSeq);
|
|
117
|
+
return {
|
|
118
|
+
...meta,
|
|
119
|
+
last_seq: lastSeq,
|
|
120
|
+
next_id: nextId,
|
|
121
|
+
outbox: outbox ? 1 : 0,
|
|
122
|
+
outbox_floor: lastSeq,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** The manifest, first: a format and schema this code reads. */
|
|
126
|
+
#start(part, what) {
|
|
127
|
+
if (part.kind !== "manifest" || this.#step !== undefined)
|
|
128
|
+
throw invalid("args", `${what}: the manifest comes first, once`);
|
|
129
|
+
if (part.format !== ARCHIVE_FORMAT)
|
|
130
|
+
throw invalid("args", `${what}: format ${part.format} is not ${ARCHIVE_FORMAT}`);
|
|
131
|
+
if (part.schema > STORE_SCHEMA)
|
|
132
|
+
throw invalid("args", `${what}: schema ${part.schema} is newer than ${STORE_SCHEMA}`);
|
|
133
|
+
this.#manifest = part;
|
|
134
|
+
this.#step = new Step(this.#executor, part.lastSeq, new IdAllocator(part.nextId), new Map());
|
|
135
|
+
}
|
|
136
|
+
/** Where `part` puts the archive, refused when out of order, a duplicate, or outside the manifest's ranges. */
|
|
137
|
+
#placeOf(part, what) {
|
|
138
|
+
const place = this.#place;
|
|
139
|
+
switch (part.kind) {
|
|
140
|
+
case "table":
|
|
141
|
+
if (place === "documents")
|
|
142
|
+
throw invalid("args", `${what}: tables come before the documents`);
|
|
143
|
+
if (this.#tables.has(part.table))
|
|
144
|
+
throw invalid("args", `${what}: table ${part.table} occurs twice`);
|
|
145
|
+
this.#tables.add(part.table);
|
|
146
|
+
this.#table = part.table;
|
|
147
|
+
return "puts";
|
|
148
|
+
case "put":
|
|
149
|
+
if (place !== "puts" || part.table !== this.#table) {
|
|
150
|
+
throw invalid("args", `${what}: a put follows its table's table write, before its indexes`);
|
|
151
|
+
}
|
|
152
|
+
return "puts";
|
|
153
|
+
case "index":
|
|
154
|
+
if ((place !== "puts" && place !== "indexes") || part.table !== this.#table) {
|
|
155
|
+
throw invalid("args", `${what}: an index follows its table's table write and puts`);
|
|
156
|
+
}
|
|
157
|
+
return "indexes";
|
|
158
|
+
case "document.create":
|
|
159
|
+
this.#checkDocument(part, what);
|
|
160
|
+
return "documents";
|
|
161
|
+
case "document.revision":
|
|
162
|
+
this.#checkRevision(part, what);
|
|
163
|
+
return "documents";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A record within the manifest's ids and seqs (an id equal to a saturated `nextId` too), unique, its lifetime
|
|
168
|
+
* overlapping no other at its address; its address and meta well-formed text without NUL (SQLite would cut a NUL off,
|
|
169
|
+
* slice 6a §8). The record before it must have ended well (`#endDocument`).
|
|
170
|
+
*/
|
|
171
|
+
#checkDocument(part, what) {
|
|
172
|
+
this.#endDocument(what);
|
|
173
|
+
const { record } = part;
|
|
174
|
+
const { lastSeq, nextId } = this.#manifest;
|
|
175
|
+
const saturated = nextId === Number.MAX_SAFE_INTEGER && record.id === nextId;
|
|
176
|
+
if (record.id >= nextId && !saturated)
|
|
177
|
+
throw invalid("args", `${what}: id ${record.id} is not below ${nextId}`);
|
|
178
|
+
if (this.#ids.has(record.id))
|
|
179
|
+
throw invalid("args", `${what}: id ${record.id} occurs twice`);
|
|
180
|
+
const { createdAt, retiredAt } = record;
|
|
181
|
+
if (createdAt > lastSeq || (retiredAt !== undefined && (retiredAt < createdAt || retiredAt > lastSeq))) {
|
|
182
|
+
throw invalid("args", `${what}: a lifetime outside the manifest's lastSeq`);
|
|
183
|
+
}
|
|
184
|
+
const { namespace, owner, kind, meta } = record;
|
|
185
|
+
// A singleton's record has no key; its column keeps `""`.
|
|
186
|
+
const key = record.key ?? "";
|
|
187
|
+
for (const text of [namespace, owner, kind, key]) {
|
|
188
|
+
if (storedText(text, what) !== text)
|
|
189
|
+
throw invalid("args", `${what}: an address is not well-formed text`);
|
|
190
|
+
}
|
|
191
|
+
if (meta !== undefined && storedText(meta, what) !== meta) {
|
|
192
|
+
throw invalid("args", `${what}: the meta is not well-formed text`);
|
|
193
|
+
}
|
|
194
|
+
const address = JSON.stringify([owner, namespace, kind, key]);
|
|
195
|
+
const lifetime = [createdAt, retiredAt ?? Number.POSITIVE_INFINITY];
|
|
196
|
+
const lifetimes = this.#lifetimes.get(address) ?? [];
|
|
197
|
+
// Two live records are two infinite lifetimes, which overlap; an empty one (`createdAt = retiredAt`) overlaps none.
|
|
198
|
+
if (lifetime[0] < lifetime[1] && lifetimes.some(([from, to]) => from < lifetime[1] && lifetime[0] < to)) {
|
|
199
|
+
throw invalid("args", `${what}: a second record at one address for an overlapping lifetime`);
|
|
200
|
+
}
|
|
201
|
+
lifetimes.push(lifetime);
|
|
202
|
+
this.#lifetimes.set(address, lifetimes);
|
|
203
|
+
this.#ids.add(record.id);
|
|
204
|
+
this.#document = { record, seq: 0, base: undefined };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A revision of the record before it, in seq order within its lifetime, from a base, each delta at its base's
|
|
208
|
+
* version.
|
|
209
|
+
*/
|
|
210
|
+
#checkRevision(part, what) {
|
|
211
|
+
const document = this.#document;
|
|
212
|
+
if (document === undefined || document.record.id !== part.id) {
|
|
213
|
+
throw invalid("args", `${what}: a revision follows its record's create`);
|
|
214
|
+
}
|
|
215
|
+
const { record } = document;
|
|
216
|
+
if (record.retiredAt !== undefined && record.history !== "rewindable") {
|
|
217
|
+
throw invalid("args", `${what}: a retired ${record.history} record keeps no revisions`);
|
|
218
|
+
}
|
|
219
|
+
if (part.seq <= document.seq ||
|
|
220
|
+
part.seq < record.createdAt ||
|
|
221
|
+
part.seq > (record.retiredAt ?? this.#manifest.lastSeq)) {
|
|
222
|
+
throw invalid("args", `${what}: a revision out of seq order or outside its lifetime`);
|
|
223
|
+
}
|
|
224
|
+
const { content } = part;
|
|
225
|
+
if (content.kind === "base")
|
|
226
|
+
document.base = content.version;
|
|
227
|
+
else if (document.base !== content.version) {
|
|
228
|
+
throw invalid("args", `${what}: a delta without a base at its version`);
|
|
229
|
+
}
|
|
230
|
+
document.seq = part.seq;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The record before ends well: its last base is at the record's version; only a retired `latest` record has none
|
|
234
|
+
* (its content was dropped at retirement; a retired `rewindable` one keeps its history).
|
|
235
|
+
*/
|
|
236
|
+
#endDocument(what) {
|
|
237
|
+
const document = this.#document;
|
|
238
|
+
this.#document = undefined;
|
|
239
|
+
if (document === undefined)
|
|
240
|
+
return;
|
|
241
|
+
const { record, base } = document;
|
|
242
|
+
const contentless = record.retiredAt !== undefined && record.history === "latest";
|
|
243
|
+
if (base === undefined ? !contentless : base !== record.version) {
|
|
244
|
+
throw invalid("args", `${what}: record ${record.id} has no base at its version`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** Runs `take` on each part in turn; a wait for the next part ends when `context` aborts (the input is closed). */
|
|
249
|
+
async function each(parts, context, take) {
|
|
250
|
+
const iterator = Symbol.asyncIterator in parts ? parts[Symbol.asyncIterator]() : parts[Symbol.iterator]();
|
|
251
|
+
let done = false;
|
|
252
|
+
try {
|
|
253
|
+
for (;;) {
|
|
254
|
+
let result;
|
|
255
|
+
try {
|
|
256
|
+
result = await awaitWithContext(Promise.resolve(iterator.next()), context);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (!context.abortSignal?.aborted)
|
|
260
|
+
throw error;
|
|
261
|
+
throw new ChordError({ code: "aborted", message: "import: aborted" }, { cause: context.abortSignal.reason });
|
|
262
|
+
}
|
|
263
|
+
if (result.done) {
|
|
264
|
+
done = true;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
await take(result.value);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
// A stalled input is not awaited: the backend transaction ends now.
|
|
272
|
+
if (!done)
|
|
273
|
+
void Promise.resolve(iterator.return?.()).catch(() => { });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=import.js.map
|