@diffra-ai/chord 0.0.0-stage → 0.2.3
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 +237 -0
- package/README.md +227 -2
- package/dist/context/index.d.ts +43 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +112 -0
- package/dist/context/index.js.map +1 -0
- package/dist/contracts/accepts.d.ts +91 -0
- package/dist/contracts/accepts.d.ts.map +1 -0
- package/dist/contracts/accepts.js +145 -0
- package/dist/contracts/accepts.js.map +1 -0
- package/dist/contracts/contract.d.ts +238 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +69 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/declare.d.ts +144 -0
- package/dist/contracts/declare.d.ts.map +1 -0
- package/dist/contracts/declare.js +207 -0
- package/dist/contracts/declare.js.map +1 -0
- package/dist/contracts/evolve.d.ts +142 -0
- package/dist/contracts/evolve.d.ts.map +1 -0
- package/dist/contracts/evolve.js +216 -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 +61 -0
- package/dist/contracts/fingerprint.js.map +1 -0
- package/dist/contracts/history.d.ts +79 -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 +58 -0
- package/dist/contracts/host-kind.d.ts.map +1 -0
- package/dist/contracts/host-kind.js +122 -0
- package/dist/contracts/host-kind.js.map +1 -0
- package/dist/contracts/index.d.ts +8 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +7 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/internal.d.ts +12 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/internal.js +11 -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 +55 -0
- package/dist/contracts/params.js.map +1 -0
- package/dist/contracts/schema.d.ts +144 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +144 -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 +31 -0
- package/dist/data/failure.d.ts.map +1 -0
- package/dist/data/failure.js +78 -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 +28 -0
- package/dist/data/principal.d.ts.map +1 -0
- package/dist/data/principal.js +64 -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.d.ts +4 -0
- package/dist/delta/apply-immutable-trusted.d.ts.map +1 -0
- package/dist/delta/apply-immutable-trusted.js +126 -0
- package/dist/delta/apply-immutable-trusted.js.map +1 -0
- package/dist/delta/diff.d.ts +5 -0
- package/dist/delta/diff.d.ts.map +1 -0
- package/dist/delta/diff.js +435 -0
- package/dist/delta/diff.js.map +1 -0
- package/dist/delta/draft.d.ts +5 -0
- package/dist/delta/draft.d.ts.map +1 -0
- package/dist/delta/draft.js +2 -0
- package/dist/delta/draft.js.map +1 -0
- package/dist/delta/index.d.ts +120 -0
- package/dist/delta/index.d.ts.map +1 -0
- package/dist/delta/index.js +697 -0
- package/dist/delta/index.js.map +1 -0
- 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/revision-validator.d.ts +7 -0
- package/dist/delta/revision-validator.d.ts.map +1 -0
- package/dist/delta/revision-validator.js +71 -0
- package/dist/delta/revision-validator.js.map +1 -0
- package/dist/delta/tracker.d.ts +38 -0
- package/dist/delta/tracker.d.ts.map +1 -0
- package/dist/delta/tracker.js +2175 -0
- package/dist/delta/tracker.js.map +1 -0
- 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 +92 -0
- package/dist/documents/definition.d.ts.map +1 -0
- package/dist/documents/definition.js +81 -0
- package/dist/documents/definition.js.map +1 -0
- package/dist/documents/documents.d.ts +129 -0
- package/dist/documents/documents.d.ts.map +1 -0
- package/dist/documents/documents.js +258 -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 +81 -0
- package/dist/documents/handles.d.ts.map +1 -0
- package/dist/documents/handles.js +74 -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 +139 -0
- package/dist/documents/keyed-slot.d.ts.map +1 -0
- package/dist/documents/keyed-slot.js +478 -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 +120 -0
- package/dist/documents/persistence.d.ts.map +1 -0
- package/dist/documents/persistence.js +156 -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 +112 -0
- package/dist/documents/slot.d.ts.map +1 -0
- package/dist/documents/slot.js +190 -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 +445 -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 +63 -0
- package/dist/host/adapted.d.ts.map +1 -0
- package/dist/host/adapted.js +298 -0
- package/dist/host/adapted.js.map +1 -0
- package/dist/host/admission.d.ts +137 -0
- package/dist/host/admission.d.ts.map +1 -0
- package/dist/host/admission.js +290 -0
- package/dist/host/admission.js.map +1 -0
- package/dist/host/attempt.d.ts +417 -0
- package/dist/host/attempt.d.ts.map +1 -0
- package/dist/host/attempt.js +1490 -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 +97 -0
- package/dist/host/dependencies.d.ts.map +1 -0
- package/dist/host/dependencies.js +148 -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/events.d.ts +114 -0
- package/dist/host/events.d.ts.map +1 -0
- package/dist/host/events.js +191 -0
- package/dist/host/events.js.map +1 -0
- package/dist/host/facet.d.ts +106 -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-data.d.ts +62 -0
- package/dist/host/host-data.d.ts.map +1 -0
- package/dist/host/host-data.js +229 -0
- package/dist/host/host-data.js.map +1 -0
- package/dist/host/host.d.ts +641 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +1449 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +20 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +7 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/internal.d.ts +13 -0
- package/dist/host/internal.d.ts.map +1 -0
- package/dist/host/internal.js +11 -0
- package/dist/host/internal.js.map +1 -0
- package/dist/host/list.d.ts +52 -0
- package/dist/host/list.d.ts.map +1 -0
- package/dist/host/list.js +149 -0
- package/dist/host/list.js.map +1 -0
- package/dist/host/members.d.ts +58 -0
- package/dist/host/members.d.ts.map +1 -0
- package/dist/host/members.js +178 -0
- package/dist/host/members.js.map +1 -0
- package/dist/host/named-query.d.ts +67 -0
- package/dist/host/named-query.d.ts.map +1 -0
- package/dist/host/named-query.js +166 -0
- package/dist/host/named-query.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 +388 -0
- package/dist/host/object.d.ts.map +1 -0
- package/dist/host/object.js +1527 -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/query-reader.d.ts +80 -0
- package/dist/host/query-reader.d.ts.map +1 -0
- package/dist/host/query-reader.js +182 -0
- package/dist/host/query-reader.js.map +1 -0
- package/dist/host/read-declarations.d.ts +75 -0
- package/dist/host/read-declarations.d.ts.map +1 -0
- package/dist/host/read-declarations.js +152 -0
- package/dist/host/read-declarations.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-events.d.ts +51 -0
- package/dist/host/reference-events.d.ts.map +1 -0
- package/dist/host/reference-events.js +133 -0
- package/dist/host/reference-events.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 +77 -0
- package/dist/host/reference-source.d.ts.map +1 -0
- package/dist/host/reference-source.js +326 -0
- package/dist/host/reference-source.js.map +1 -0
- package/dist/host/reference.d.ts +377 -0
- package/dist/host/reference.d.ts.map +1 -0
- package/dist/host/reference.js +986 -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-admission.d.ts +24 -0
- package/dist/host/route-admission.d.ts.map +1 -0
- package/dist/host/route-admission.js +238 -0
- package/dist/host/route-admission.js.map +1 -0
- package/dist/host/route.d.ts +88 -0
- package/dist/host/route.d.ts.map +1 -0
- package/dist/host/route.js +247 -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 +100 -0
- package/dist/host/staging.d.ts.map +1 -0
- package/dist/host/staging.js +413 -0
- package/dist/host/staging.js.map +1 -0
- package/dist/host/tiling.d.ts +57 -0
- package/dist/host/tiling.d.ts.map +1 -0
- package/dist/host/tiling.js +269 -0
- package/dist/host/tiling.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 +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- 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/json.d.ts +18 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +124 -0
- package/dist/json.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 +574 -0
- package/dist/link/binary.js.map +1 -0
- package/dist/link/channel.d.ts +78 -0
- package/dist/link/channel.d.ts.map +1 -0
- package/dist/link/channel.js +252 -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 +278 -0
- package/dist/link/message.d.ts.map +1 -0
- package/dist/link/message.js +179 -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 +383 -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 +283 -0
- package/dist/node/app/app.d.ts.map +1 -0
- package/dist/node/app/app.js +598 -0
- package/dist/node/app/app.js.map +1 -0
- package/dist/node/app/archive.d.ts +44 -0
- package/dist/node/app/archive.d.ts.map +1 -0
- package/dist/node/app/archive.js +212 -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 +40 -0
- package/dist/node/app/data.d.ts.map +1 -0
- package/dist/node/app/data.js +47 -0
- package/dist/node/app/data.js.map +1 -0
- package/dist/node/app/ephemeral-sign-ins.d.ts +20 -0
- package/dist/node/app/ephemeral-sign-ins.d.ts.map +1 -0
- package/dist/node/app/ephemeral-sign-ins.js +69 -0
- package/dist/node/app/ephemeral-sign-ins.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 +388 -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 +70 -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/sign-ins.d.ts +74 -0
- package/dist/node/app/sign-ins.d.ts.map +1 -0
- package/dist/node/app/sign-ins.js +222 -0
- package/dist/node/app/sign-ins.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 +39 -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 +64 -0
- package/dist/node/http/admission.d.ts.map +1 -0
- package/dist/node/http/admission.js +137 -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 +114 -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 +62 -0
- package/dist/node/http/upgrades.d.ts.map +1 -0
- package/dist/node/http/upgrades.js +194 -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 +577 -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 +40 -0
- package/dist/node/plugins/install.d.ts.map +1 -0
- package/dist/node/plugins/install.js +215 -0
- package/dist/node/plugins/install.js.map +1 -0
- package/dist/node/plugins/plugins.d.ts +165 -0
- package/dist/node/plugins/plugins.d.ts.map +1 -0
- package/dist/node/plugins/plugins.js +268 -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 +70 -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 +40 -0
- package/dist/node/surfaces/bundle.d.ts.map +1 -0
- package/dist/node/surfaces/bundle.js +121 -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 +17 -0
- package/dist/node/surfaces/served.d.ts.map +1 -0
- package/dist/node/surfaces/served.js +44 -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 +42 -0
- package/dist/node/surfaces/tui.d.ts.map +1 -0
- package/dist/node/surfaces/tui.js +59 -0
- package/dist/node/surfaces/tui.js.map +1 -0
- package/dist/node/surfaces/web.d.ts +82 -0
- package/dist/node/surfaces/web.d.ts.map +1 -0
- package/dist/node/surfaces/web.js +122 -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 +260 -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 +43 -0
- package/dist/node/workers/process.d.ts.map +1 -0
- package/dist/node/workers/process.js +137 -0
- package/dist/node/workers/process.js.map +1 -0
- package/dist/node/workers/workers.d.ts +144 -0
- package/dist/node/workers/workers.d.ts.map +1 -0
- package/dist/node/workers/workers.js +723 -0
- package/dist/node/workers/workers.js.map +1 -0
- package/dist/output.d.ts +91 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +362 -0
- package/dist/output.js.map +1 -0
- package/dist/react/hooks.d.ts +61 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +119 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +4 -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 +34 -0
- package/dist/remote/calls.d.ts.map +1 -0
- package/dist/remote/calls.js +75 -0
- package/dist/remote/calls.js.map +1 -0
- package/dist/remote/consumer.d.ts +59 -0
- package/dist/remote/consumer.d.ts.map +1 -0
- package/dist/remote/consumer.js +468 -0
- package/dist/remote/consumer.js.map +1 -0
- package/dist/remote/hold.d.ts +147 -0
- package/dist/remote/hold.d.ts.map +1 -0
- package/dist/remote/hold.js +653 -0
- package/dist/remote/hold.js.map +1 -0
- package/dist/remote/host-link.d.ts +81 -0
- package/dist/remote/host-link.d.ts.map +1 -0
- package/dist/remote/host-link.js +198 -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 +105 -0
- package/dist/remote/path.d.ts.map +1 -0
- package/dist/remote/path.js +197 -0
- package/dist/remote/path.js.map +1 -0
- package/dist/remote/provider.d.ts +113 -0
- package/dist/remote/provider.d.ts.map +1 -0
- package/dist/remote/provider.js +787 -0
- package/dist/remote/provider.js.map +1 -0
- package/dist/remote/relay.d.ts +126 -0
- package/dist/remote/relay.d.ts.map +1 -0
- package/dist/remote/relay.js +334 -0
- package/dist/remote/relay.js.map +1 -0
- package/dist/remote/remote-object.d.ts +181 -0
- package/dist/remote/remote-object.d.ts.map +1 -0
- package/dist/remote/remote-object.js +683 -0
- package/dist/remote/remote-object.js.map +1 -0
- package/dist/remote/replica.d.ts +66 -0
- package/dist/remote/replica.d.ts.map +1 -0
- package/dist/remote/replica.js +148 -0
- package/dist/remote/replica.js.map +1 -0
- package/dist/sqlite/cloudflare.d.ts +54 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -0
- package/dist/sqlite/cloudflare.js +144 -0
- package/dist/sqlite/cloudflare.js.map +1 -0
- package/dist/sqlite/database.d.ts +40 -0
- package/dist/sqlite/database.d.ts.map +1 -0
- package/dist/sqlite/database.js +2 -0
- package/dist/sqlite/database.js.map +1 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +3 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite/migrations.d.ts +10 -0
- package/dist/sqlite/migrations.d.ts.map +1 -0
- package/dist/sqlite/migrations.js +33 -0
- package/dist/sqlite/migrations.js.map +1 -0
- package/dist/sqlite/node.d.ts +49 -0
- package/dist/sqlite/node.d.ts.map +1 -0
- package/dist/sqlite/node.js +197 -0
- package/dist/sqlite/node.js.map +1 -0
- package/dist/sqlite/schema.d.ts +3 -0
- package/dist/sqlite/schema.d.ts.map +1 -0
- package/dist/sqlite/schema.js +10 -0
- package/dist/sqlite/schema.js.map +1 -0
- 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 +56 -0
- package/dist/state/derive.d.ts.map +1 -0
- package/dist/state/derive.js +192 -0
- package/dist/state/derive.js.map +1 -0
- package/dist/state/framed.d.ts +43 -0
- package/dist/state/framed.d.ts.map +1 -0
- package/dist/state/framed.js +121 -0
- package/dist/state/framed.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 +7 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +9 -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 +390 -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 +36 -0
- package/dist/store/archive.d.ts.map +1 -0
- package/dist/store/archive.js +140 -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/column-set.d.ts +64 -0
- package/dist/store/column-set.d.ts.map +1 -0
- package/dist/store/column-set.js +96 -0
- package/dist/store/column-set.js.map +1 -0
- package/dist/store/columns.d.ts +93 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +87 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/engine.d.ts +182 -0
- package/dist/store/engine.d.ts.map +1 -0
- package/dist/store/engine.js +290 -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 +131 -0
- package/dist/store/evaluate.js.map +1 -0
- package/dist/store/export.d.ts +30 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/export.js +221 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/expression.d.ts +254 -0
- package/dist/store/expression.d.ts.map +1 -0
- package/dist/store/expression.js +577 -0
- package/dist/store/expression.js.map +1 -0
- package/dist/store/host-column.d.ts +22 -0
- package/dist/store/host-column.d.ts.map +1 -0
- package/dist/store/host-column.js +36 -0
- package/dist/store/host-column.js.map +1 -0
- package/dist/store/host-data.d.ts +100 -0
- package/dist/store/host-data.d.ts.map +1 -0
- package/dist/store/host-data.js +397 -0
- package/dist/store/host-data.js.map +1 -0
- package/dist/store/import-migration.d.ts +19 -0
- package/dist/store/import-migration.d.ts.map +1 -0
- package/dist/store/import-migration.js +124 -0
- package/dist/store/import-migration.js.map +1 -0
- package/dist/store/import.d.ts +12 -0
- package/dist/store/import.d.ts.map +1 -0
- package/dist/store/import.js +279 -0
- package/dist/store/import.js.map +1 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +16 -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 +72 -0
- package/dist/store/live-query.d.ts.map +1 -0
- package/dist/store/live-query.js +162 -0
- package/dist/store/live-query.js.map +1 -0
- package/dist/store/open-query.d.ts +90 -0
- package/dist/store/open-query.d.ts.map +1 -0
- package/dist/store/open-query.js +201 -0
- package/dist/store/open-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/page.d.ts +14 -0
- package/dist/store/page.d.ts.map +1 -0
- package/dist/store/page.js +26 -0
- package/dist/store/page.js.map +1 -0
- package/dist/store/query.d.ts +65 -0
- package/dist/store/query.d.ts.map +1 -0
- package/dist/store/query.js +193 -0
- package/dist/store/query.js.map +1 -0
- package/dist/store/read-plan.d.ts +74 -0
- package/dist/store/read-plan.d.ts.map +1 -0
- package/dist/store/read-plan.js +324 -0
- package/dist/store/read-plan.js.map +1 -0
- package/dist/store/read.d.ts +81 -0
- package/dist/store/read.d.ts.map +1 -0
- package/dist/store/read.js +113 -0
- package/dist/store/read.js.map +1 -0
- package/dist/store/reads.d.ts +79 -0
- package/dist/store/reads.d.ts.map +1 -0
- package/dist/store/reads.js +255 -0
- package/dist/store/reads.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 +96 -0
- package/dist/store/rows.d.ts.map +1 -0
- package/dist/store/rows.js +222 -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 +123 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/skip.d.ts +26 -0
- package/dist/store/skip.d.ts.map +1 -0
- package/dist/store/skip.js +66 -0
- package/dist/store/skip.js.map +1 -0
- package/dist/store/sql.d.ts +78 -0
- package/dist/store/sql.d.ts.map +1 -0
- package/dist/store/sql.js +244 -0
- package/dist/store/sql.js.map +1 -0
- package/dist/store/step.d.ts +52 -0
- package/dist/store/step.d.ts.map +1 -0
- package/dist/store/step.js +59 -0
- package/dist/store/step.js.map +1 -0
- package/dist/store/store.d.ts +192 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +863 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/table-changes.d.ts +35 -0
- package/dist/store/table-changes.d.ts.map +1 -0
- package/dist/store/table-changes.js +127 -0
- package/dist/store/table-changes.js.map +1 -0
- package/dist/store/table-evolve.d.ts +82 -0
- package/dist/store/table-evolve.d.ts.map +1 -0
- package/dist/store/table-evolve.js +208 -0
- package/dist/store/table-evolve.js.map +1 -0
- package/dist/store/table-handle.d.ts +69 -0
- package/dist/store/table-handle.d.ts.map +1 -0
- package/dist/store/table-handle.js +92 -0
- package/dist/store/table-handle.js.map +1 -0
- package/dist/store/table-history.d.ts +78 -0
- package/dist/store/table-history.d.ts.map +1 -0
- package/dist/store/table-history.js +43 -0
- package/dist/store/table-history.js.map +1 -0
- package/dist/store/table-migration.d.ts +28 -0
- package/dist/store/table-migration.d.ts.map +1 -0
- package/dist/store/table-migration.js +212 -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 +91 -0
- package/dist/store/table.d.ts.map +1 -0
- package/dist/store/table.js +133 -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 +106 -0
- package/dist/surfaces/client.d.ts.map +1 -0
- package/dist/surfaces/client.js +280 -0
- package/dist/surfaces/client.js.map +1 -0
- package/dist/surfaces/connection.d.ts +53 -0
- package/dist/surfaces/connection.d.ts.map +1 -0
- package/dist/surfaces/connection.js +161 -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 +26 -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 +33 -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 +86 -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 +32 -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/surfaces/variant.d.ts +23 -0
- package/dist/surfaces/variant.d.ts.map +1 -0
- package/dist/surfaces/variant.js +18 -0
- package/dist/surfaces/variant.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 +169 -0
- package/dist/sync/client.d.ts.map +1 -0
- package/dist/sync/client.js +459 -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 +205 -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 +145 -0
- package/dist/sync/remote.d.ts.map +1 -0
- package/dist/sync/remote.js +59 -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 +73 -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 +26 -0
- package/dist/telemetry-ingest/facet.d.ts.map +1 -0
- package/dist/telemetry-ingest/facet.js +100 -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 +33 -0
- package/dist/telemetry-sqlite/index.d.ts.map +1 -0
- package/dist/telemetry-sqlite/index.js +113 -0
- package/dist/telemetry-sqlite/index.js.map +1 -0
- 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 +12 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -0
- package/dist/telemetry-sqlite/store.js +121 -0
- package/dist/telemetry-sqlite/store.js.map +1 -0
- package/dist/telemetry.d.ts +1013 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +518 -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 +8 -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 +62 -0
- package/dist/tui/scope.d.ts.map +1 -0
- package/dist/tui/scope.js +173 -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 +42 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +96 -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/admission/design.md +178 -0
- package/docs/benchmarks.md +1182 -0
- package/docs/decisions.md +3760 -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 +3691 -0
- package/docs/durable-observers/book.md +432 -0
- package/docs/durable-observers/index.html +517 -0
- package/docs/events/spec.md +438 -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 +958 -0
- package/docs/guide-plugins-hosts/index.html +952 -0
- package/docs/host-keyed/spec.md +343 -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 +389 -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/shared-holds/design.md +339 -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-14-design.md +213 -0
- package/docs/slice-14.md +861 -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 +380 -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 +2170 -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 +200 -5
- package/src/delta/README.md +262 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// Rows (slice 6a §5 "Values at write", §9): one compiled codec per table version between a plugin's rows and keys
|
|
2
|
+
// (a trust boundary, checked closed) and what the store binds and reads; `json(...)` cells serialized at staging
|
|
3
|
+
// (rule 8), never walked (R9), and migrated on access when read.
|
|
4
|
+
import { invalid } from "../data/internal.js";
|
|
5
|
+
import { storedText } from "./text.js";
|
|
6
|
+
/** The physical name of a `json(...)` column's version column, and of the row's eager-step version. */
|
|
7
|
+
export function versionColumn(column) {
|
|
8
|
+
return `${column}$v`;
|
|
9
|
+
}
|
|
10
|
+
/** The row's eager-step version column (W11): set by `put` and eager migration steps only. */
|
|
11
|
+
export const ROW_VERSION = "$v";
|
|
12
|
+
/** The physical column order of a stored row: the declared columns, each `json(...)` column's version, then `$v`. */
|
|
13
|
+
export function physicalColumns(columns) {
|
|
14
|
+
return [
|
|
15
|
+
...columns.map(({ name }) => name),
|
|
16
|
+
...columns.filter(({ type }) => type === "json").map(({ name }) => versionColumn(name)),
|
|
17
|
+
ROW_VERSION,
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
/** A scalar as SQLite binds it: booleans as 0 and 1. */
|
|
21
|
+
export function toSqlite(scalar) {
|
|
22
|
+
return scalar === true ? 1 : scalar === false ? 0 : scalar;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A table version's codec: `put` rows and keys checked and encoded, stored rows decoded. `physical` is the column
|
|
26
|
+
* order of an encoded row (`physicalColumns`).
|
|
27
|
+
*/
|
|
28
|
+
export class RowCodec {
|
|
29
|
+
physical;
|
|
30
|
+
#columns;
|
|
31
|
+
#key;
|
|
32
|
+
#json;
|
|
33
|
+
/** The `host(...)` column, if the table has one: its cells are keys stored, addresses read. */
|
|
34
|
+
#host;
|
|
35
|
+
#names;
|
|
36
|
+
#keyNames;
|
|
37
|
+
/** The positions of the key columns in `physical`. */
|
|
38
|
+
#keyPositions;
|
|
39
|
+
#table;
|
|
40
|
+
constructor(columns, key, table) {
|
|
41
|
+
this.#columns = columns;
|
|
42
|
+
this.#key = key.map((name) => columns.find((column) => column.name === name));
|
|
43
|
+
this.#json = columns.filter((column) => column.type === "json");
|
|
44
|
+
this.#host = columns.find((column) => column.type === "str" && column.host !== undefined);
|
|
45
|
+
this.#names = new Set(columns.map(({ name }) => name));
|
|
46
|
+
this.#keyNames = new Set(key);
|
|
47
|
+
this.#keyPositions = key.map((name) => columns.findIndex((column) => column.name === name));
|
|
48
|
+
this.#table = table;
|
|
49
|
+
this.physical = physicalColumns(columns);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks and encodes a `put` row of table version `version` (a trust boundary): a plain object with every
|
|
53
|
+
* non-`opt` column (a defaulted one filled in) and no other field; `invalid/args` otherwise.
|
|
54
|
+
*/
|
|
55
|
+
put(row, version) {
|
|
56
|
+
const what = `${this.#table}: put`;
|
|
57
|
+
const fields = this.#closed(row, this.#names, what);
|
|
58
|
+
const params = [];
|
|
59
|
+
const stored = {};
|
|
60
|
+
const versions = {};
|
|
61
|
+
for (const column of this.#columns) {
|
|
62
|
+
let value = fields[column.name];
|
|
63
|
+
if (value === undefined && column.type !== "json")
|
|
64
|
+
value = column.default;
|
|
65
|
+
if (value === undefined) {
|
|
66
|
+
if (!column.optional)
|
|
67
|
+
throw invalid("args", `${what}: column "${column.name}" is missing`);
|
|
68
|
+
params.push(null);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const cell = encodeCell(column, value, `${what}: column "${column.name}"`);
|
|
72
|
+
params.push(cell.param);
|
|
73
|
+
stored[column.name] = cell.stored;
|
|
74
|
+
}
|
|
75
|
+
for (const column of this.#json) {
|
|
76
|
+
const present = Object.hasOwn(stored, column.name);
|
|
77
|
+
if (present)
|
|
78
|
+
versions[column.name] = column.json.version;
|
|
79
|
+
params.push(present ? column.json.version : null);
|
|
80
|
+
}
|
|
81
|
+
params.push(version);
|
|
82
|
+
const id = JSON.stringify(this.#keyPositions.map((position) => params[position]));
|
|
83
|
+
return { params, row: stored, columns: versions, id };
|
|
84
|
+
}
|
|
85
|
+
/** Checks and encodes a key (a trust boundary): an object with exactly the key columns; `invalid/args` otherwise. */
|
|
86
|
+
key(key, what) {
|
|
87
|
+
const fields = this.#closed(key, this.#keyNames, `${this.#table}: ${what}: the key`);
|
|
88
|
+
const params = [];
|
|
89
|
+
const stored = {};
|
|
90
|
+
for (const column of this.#key) {
|
|
91
|
+
const value = fields[column.name];
|
|
92
|
+
const where = `${this.#table}: ${what}: key column "${column.name}"`;
|
|
93
|
+
if (value === undefined)
|
|
94
|
+
throw invalid("args", `${where} is missing`);
|
|
95
|
+
const cell = encodeScalar(column, value, where);
|
|
96
|
+
params.push(cell);
|
|
97
|
+
stored[column.name] = cell;
|
|
98
|
+
}
|
|
99
|
+
return { params, key: stored, id: JSON.stringify(params) };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A stored row as reads return it: booleans from 0 and 1, `opt(...)` columns absent when `NULL`, `json(...)` cells
|
|
103
|
+
* parsed and migrated on access (a cell the code cannot read throws, see `JsonColumn.read`).
|
|
104
|
+
*/
|
|
105
|
+
decode(stored, context) {
|
|
106
|
+
const row = {};
|
|
107
|
+
for (const column of this.#columns) {
|
|
108
|
+
const value = stored[column.name];
|
|
109
|
+
if (value === null || value === undefined)
|
|
110
|
+
continue;
|
|
111
|
+
if (column.type === "json") {
|
|
112
|
+
const version = stored[versionColumn(column.name)];
|
|
113
|
+
row[column.name] = column.json.read(value, version, `${this.#table}.${column.name}`, context);
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
row[column.name] = decodeScalar(column, value);
|
|
117
|
+
}
|
|
118
|
+
return row;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A row as reads return it with its `host(...)` cell as stored (the address's key), for the evaluator, which
|
|
122
|
+
* compares stored values; the row itself without a host column.
|
|
123
|
+
*/
|
|
124
|
+
stored(row) {
|
|
125
|
+
const host = this.#host;
|
|
126
|
+
const cell = host === undefined ? undefined : row[host.name];
|
|
127
|
+
if (host === undefined || typeof cell !== "object" || cell === null)
|
|
128
|
+
return row;
|
|
129
|
+
// A read row's host cell is an address (`decode`).
|
|
130
|
+
return { ...row, [host.name]: cell.key };
|
|
131
|
+
}
|
|
132
|
+
/** A row with its `host(...)` cell as stored (a key) turned into the address reads return; `stored`'s inverse. */
|
|
133
|
+
addressed(row) {
|
|
134
|
+
const host = this.#host;
|
|
135
|
+
const cell = host === undefined ? undefined : row[host.name];
|
|
136
|
+
if (host === undefined || typeof cell !== "string")
|
|
137
|
+
return row;
|
|
138
|
+
return { ...row, [host.name]: host.host.address(cell) };
|
|
139
|
+
}
|
|
140
|
+
/** `value`'s own fields when it is a plain object with only fields of `names`; `invalid/args` otherwise. */
|
|
141
|
+
#closed(value, names, what) {
|
|
142
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
143
|
+
throw invalid("args", `${what}: expected an object`);
|
|
144
|
+
}
|
|
145
|
+
for (const field of Object.keys(value)) {
|
|
146
|
+
if (!names.has(field))
|
|
147
|
+
throw invalid("args", `${what}: unknown column "${field}"`);
|
|
148
|
+
}
|
|
149
|
+
// Checked above: a plain object with known fields.
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** A stored scalar cell (not `NULL`) as reads return it: a boolean from 0 and 1, an address from a `host(...)` key. */
|
|
154
|
+
export function decodeScalar(column, value) {
|
|
155
|
+
if (column.type === "bool")
|
|
156
|
+
return value === 1;
|
|
157
|
+
// A `host(...)` column holds the keys of addresses of its kind.
|
|
158
|
+
if (column.type === "str" && column.host !== undefined)
|
|
159
|
+
return column.host.address(value);
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Checks and encodes a value of `column`; a `json(...)` value is serialized, not walked (R9); a `host(...)` one is an
|
|
164
|
+
* address of its kind, stored as its key.
|
|
165
|
+
*/
|
|
166
|
+
export function encodeCell(column, value, what) {
|
|
167
|
+
if (column.type === "str" && column.host !== undefined) {
|
|
168
|
+
const key = column.host.key(value, what);
|
|
169
|
+
return { param: key, stored: key };
|
|
170
|
+
}
|
|
171
|
+
if (column.type !== "json") {
|
|
172
|
+
const stored = checkScalar(column.type, value, what);
|
|
173
|
+
return { param: toSqlite(stored), stored };
|
|
174
|
+
}
|
|
175
|
+
let text;
|
|
176
|
+
try {
|
|
177
|
+
text = JSON.stringify(value);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
throw invalid("args", `${what}: not JSON (${error instanceof Error ? error.message : String(error)})`);
|
|
181
|
+
}
|
|
182
|
+
if (text === undefined)
|
|
183
|
+
throw invalid("args", `${what}: not JSON`);
|
|
184
|
+
// `JSON.stringify` accepted it; the recorded value is the one serialized. It is kept, not copied or parsed back:
|
|
185
|
+
// same-host values are immutable by convention, so the outbox serializing it again in the step records this text
|
|
186
|
+
// (a plugin mutating a value after `tx.put` breaks that convention, as for any other value it hands over).
|
|
187
|
+
return { param: text, stored: value };
|
|
188
|
+
}
|
|
189
|
+
/** Checks a scalar value of `column` and returns what is bound (booleans as 0 and 1; an address as its key). */
|
|
190
|
+
function encodeScalar(column, value, what) {
|
|
191
|
+
if (column.type === "json")
|
|
192
|
+
throw invalid("args", `${what}: a json(...) column has no scalar value`);
|
|
193
|
+
if (column.host !== undefined)
|
|
194
|
+
return column.host.key(value, what);
|
|
195
|
+
return toSqlite(checkScalar(column.type, value, what));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A value of a scalar column type as the store keeps it (a trust boundary): `str` well-formed without NUL, `int` a
|
|
199
|
+
* safe integer, `num` finite, `bool` a boolean; `invalid/args` otherwise.
|
|
200
|
+
*/
|
|
201
|
+
export function checkScalar(type, value, what) {
|
|
202
|
+
switch (type) {
|
|
203
|
+
case "str":
|
|
204
|
+
if (typeof value === "string")
|
|
205
|
+
return storedText(value, what);
|
|
206
|
+
break;
|
|
207
|
+
case "int":
|
|
208
|
+
if (Number.isSafeInteger(value))
|
|
209
|
+
return value;
|
|
210
|
+
break;
|
|
211
|
+
case "num":
|
|
212
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
213
|
+
return value;
|
|
214
|
+
break;
|
|
215
|
+
case "bool":
|
|
216
|
+
if (typeof value === "boolean")
|
|
217
|
+
return value;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
throw invalid("args", `${what}: ${JSON.stringify(value) ?? String(value)} is not a ${type} value`);
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rows.js","sourceRoot":"","sources":["../../src/store/rows.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,iHAAiH;AACjH,iEAAiE;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA0BvC,uGAAuG;AACvG,MAAM,UAAU,aAAa,CAAC,MAAc;IAC3C,OAAO,GAAG,MAAM,IAAI,CAAC;AACtB,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEhC,qHAAqH;AACrH,MAAM,UAAU,eAAe,CAAC,OAAwE;IACvG,OAAO;QACN,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QAClC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACvF,WAAW;KACX,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,QAAQ,CAAC,MAAc;IACtC,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACX,QAAQ,CAAoB;IAC5B,QAAQ,CAAoB;IAC5B,IAAI,CAAoB;IACxB,KAAK,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IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,QAAQ,CAAC,CAAC;AACpG,CAAC","sourcesContent":["// Rows (slice 6a §5 \"Values at write\", §9): one compiled codec per table version between a plugin's rows and keys\n// (a trust boundary, checked closed) and what the store binds and reads; `json(...)` cells serialized at staging\n// (rule 8), never walked (R9), and migrated on access when read.\n\nimport type { Context } from \"../context/index.ts\";\nimport { invalid } from \"../data/internal.ts\";\nimport type { JsonValue } from \"../json.ts\";\nimport type { SqliteValue } from \"../sqlite/index.ts\";\nimport type { Column, ColumnType, HostColumnOf, ScalarColumn } from \"./columns.ts\";\nimport { storedText } from \"./text.ts\";\n\n/** A scalar cell as the store keeps it in rows, writes and operands: a well-formed string, a number or a boolean. */\nexport type Scalar = string | number | boolean;\n\n/** A row as the outbox records it: the stored values, `opt(...)` columns absent when `NULL`. */\nexport type StoredRow = { readonly [column: string]: Scalar | JsonValue };\n\n/** A `put` ready for the step: its parameters in `physical` order and its record. */\nexport type EncodedRow = {\n\treadonly params: readonly SqliteValue[];\n\treadonly row: StoredRow;\n\t/** Each written `json(...)` column's version. */\n\treadonly columns: { readonly [column: string]: number };\n\t/** The row's key identity, as `EncodedKey.id`. */\n\treadonly id: string;\n};\n\n/** A key ready for the store: its parameters in key order, its record and its identity within one table. */\nexport type EncodedKey = {\n\treadonly params: readonly SqliteValue[];\n\treadonly key: { readonly [column: string]: Scalar };\n\t/** `JSON.stringify` of the parameters: equal keys, equal ids. */\n\treadonly id: string;\n};\n\n/** The physical name of a `json(...)` column's version column, and of the row's eager-step version. */\nexport function versionColumn(column: string): string {\n\treturn `${column}$v`;\n}\n\n/** The row's eager-step version column (W11): set by `put` and eager migration steps only. */\nexport const ROW_VERSION = \"$v\";\n\n/** The physical column order of a stored row: the declared columns, each `json(...)` column's version, then `$v`. */\nexport function physicalColumns(columns: readonly { readonly name: string; readonly type: ColumnType }[]): string[] {\n\treturn [\n\t\t...columns.map(({ name }) => name),\n\t\t...columns.filter(({ type }) => type === \"json\").map(({ name }) => versionColumn(name)),\n\t\tROW_VERSION,\n\t];\n}\n\n/** A scalar as SQLite binds it: booleans as 0 and 1. */\nexport function toSqlite(scalar: Scalar): string | number {\n\treturn scalar === true ? 1 : scalar === false ? 0 : scalar;\n}\n\n/**\n * A table version's codec: `put` rows and keys checked and encoded, stored rows decoded. `physical` is the column\n * order of an encoded row (`physicalColumns`).\n */\nexport class RowCodec {\n\treadonly physical: readonly string[];\n\treadonly #columns: readonly Column[];\n\treadonly #key: readonly Column[];\n\treadonly #json: readonly Extract<Column, { readonly type: \"json\" }>[];\n\t/** The `host(...)` column, if the table has one: its cells are keys stored, addresses read. */\n\treadonly #host: HostColumnOf | undefined;\n\treadonly #names: ReadonlySet<string>;\n\treadonly #keyNames: ReadonlySet<string>;\n\t/** The positions of the key columns in `physical`. */\n\treadonly #keyPositions: readonly number[];\n\treadonly #table: string;\n\n\tconstructor(columns: readonly Column[], key: readonly string[], table: string) {\n\t\tthis.#columns = columns;\n\t\tthis.#key = key.map((name) => columns.find((column) => column.name === name)!);\n\t\tthis.#json = columns.filter(\n\t\t\t(column): column is Extract<Column, { readonly type: \"json\" }> => column.type === \"json\",\n\t\t);\n\t\tthis.#host = columns.find((column): column is HostColumnOf => column.type === \"str\" && column.host !== undefined);\n\t\tthis.#names = new Set(columns.map(({ name }) => name));\n\t\tthis.#keyNames = new Set(key);\n\t\tthis.#keyPositions = key.map((name) => columns.findIndex((column) => column.name === name));\n\t\tthis.#table = table;\n\t\tthis.physical = physicalColumns(columns);\n\t}\n\n\t/**\n\t * Checks and encodes a `put` row of table version `version` (a trust boundary): a plain object with every\n\t * non-`opt` column (a defaulted one filled in) and no other field; `invalid/args` otherwise.\n\t */\n\tput(row: unknown, version: number): EncodedRow {\n\t\tconst what = `${this.#table}: put`;\n\t\tconst fields = this.#closed(row, this.#names, what);\n\t\tconst params: SqliteValue[] = [];\n\t\tconst stored: { [column: string]: Scalar | JsonValue } = {};\n\t\tconst versions: { [column: string]: number } = {};\n\t\tfor (const column of this.#columns) {\n\t\t\tlet value = fields[column.name];\n\t\t\tif (value === undefined && column.type !== \"json\") value = column.default;\n\t\t\tif (value === undefined) {\n\t\t\t\tif (!column.optional) throw invalid(\"args\", `${what}: column \"${column.name}\" is missing`);\n\t\t\t\tparams.push(null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst cell = encodeCell(column, value, `${what}: column \"${column.name}\"`);\n\t\t\tparams.push(cell.param);\n\t\t\tstored[column.name] = cell.stored;\n\t\t}\n\t\tfor (const column of this.#json) {\n\t\t\tconst present = Object.hasOwn(stored, column.name);\n\t\t\tif (present) versions[column.name] = column.json.version;\n\t\t\tparams.push(present ? column.json.version : null);\n\t\t}\n\t\tparams.push(version);\n\t\tconst id = JSON.stringify(this.#keyPositions.map((position) => params[position]));\n\t\treturn { params, row: stored, columns: versions, id };\n\t}\n\n\t/** Checks and encodes a key (a trust boundary): an object with exactly the key columns; `invalid/args` otherwise. */\n\tkey(key: unknown, what: string): EncodedKey {\n\t\tconst fields = this.#closed(key, this.#keyNames, `${this.#table}: ${what}: the key`);\n\t\tconst params: SqliteValue[] = [];\n\t\tconst stored: { [column: string]: Scalar } = {};\n\t\tfor (const column of this.#key) {\n\t\t\tconst value = fields[column.name];\n\t\t\tconst where = `${this.#table}: ${what}: key column \"${column.name}\"`;\n\t\t\tif (value === undefined) throw invalid(\"args\", `${where} is missing`);\n\t\t\tconst cell = encodeScalar(column, value, where);\n\t\t\tparams.push(cell);\n\t\t\tstored[column.name] = cell;\n\t\t}\n\t\treturn { params, key: stored, id: JSON.stringify(params) };\n\t}\n\n\t/**\n\t * A stored row as reads return it: booleans from 0 and 1, `opt(...)` columns absent when `NULL`, `json(...)` cells\n\t * parsed and migrated on access (a cell the code cannot read throws, see `JsonColumn.read`).\n\t */\n\tdecode(stored: { readonly [column: string]: SqliteValue }, context: Context): { [column: string]: unknown } {\n\t\tconst row: { [column: string]: unknown } = {};\n\t\tfor (const column of this.#columns) {\n\t\t\tconst value = stored[column.name];\n\t\t\tif (value === null || value === undefined) continue;\n\t\t\tif (column.type === \"json\") {\n\t\t\t\tconst version = stored[versionColumn(column.name)] as number;\n\t\t\t\trow[column.name] = column.json.read(value as string, version, `${this.#table}.${column.name}`, context);\n\t\t\t} else row[column.name] = decodeScalar(column, value);\n\t\t}\n\t\treturn row;\n\t}\n\n\t/**\n\t * A row as reads return it with its `host(...)` cell as stored (the address's key), for the evaluator, which\n\t * compares stored values; the row itself without a host column.\n\t */\n\tstored<R extends { readonly [column: string]: unknown }>(row: R): R {\n\t\tconst host = this.#host;\n\t\tconst cell = host === undefined ? undefined : row[host.name];\n\t\tif (host === undefined || typeof cell !== \"object\" || cell === null) return row;\n\t\t// A read row's host cell is an address (`decode`).\n\t\treturn { ...row, [host.name]: (cell as { readonly key: string }).key };\n\t}\n\n\t/** A row with its `host(...)` cell as stored (a key) turned into the address reads return; `stored`'s inverse. */\n\taddressed<R extends { readonly [column: string]: unknown }>(row: R): R {\n\t\tconst host = this.#host;\n\t\tconst cell = host === undefined ? undefined : row[host.name];\n\t\tif (host === undefined || typeof cell !== \"string\") return row;\n\t\treturn { ...row, [host.name]: host.host.address(cell) };\n\t}\n\n\t/** `value`'s own fields when it is a plain object with only fields of `names`; `invalid/args` otherwise. */\n\t#closed(value: unknown, names: ReadonlySet<string>, what: string): { readonly [field: string]: unknown } {\n\t\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\t\tthrow invalid(\"args\", `${what}: expected an object`);\n\t\t}\n\t\tfor (const field of Object.keys(value)) {\n\t\t\tif (!names.has(field)) throw invalid(\"args\", `${what}: unknown column \"${field}\"`);\n\t\t}\n\t\t// Checked above: a plain object with known fields.\n\t\treturn value as { readonly [field: string]: unknown };\n\t}\n}\n\n/** A stored scalar cell (not `NULL`) as reads return it: a boolean from 0 and 1, an address from a `host(...)` key. */\nexport function decodeScalar(column: ScalarColumn, value: SqliteValue): unknown {\n\tif (column.type === \"bool\") return value === 1;\n\t// A `host(...)` column holds the keys of addresses of its kind.\n\tif (column.type === \"str\" && column.host !== undefined) return column.host.address(value as string);\n\treturn value;\n}\n\n/** A checked cell: what is bound and what is recorded. */\ntype Cell = { readonly param: SqliteValue; readonly stored: Scalar | JsonValue };\n\n/**\n * Checks and encodes a value of `column`; a `json(...)` value is serialized, not walked (R9); a `host(...)` one is an\n * address of its kind, stored as its key.\n */\nexport function encodeCell(column: Column, value: unknown, what: string): Cell {\n\tif (column.type === \"str\" && column.host !== undefined) {\n\t\tconst key = column.host.key(value, what);\n\t\treturn { param: key, stored: key };\n\t}\n\tif (column.type !== \"json\") {\n\t\tconst stored = checkScalar(column.type, value, what);\n\t\treturn { param: toSqlite(stored), stored };\n\t}\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = JSON.stringify(value);\n\t} catch (error) {\n\t\tthrow invalid(\"args\", `${what}: not JSON (${error instanceof Error ? error.message : String(error)})`);\n\t}\n\tif (text === undefined) throw invalid(\"args\", `${what}: not JSON`);\n\t// `JSON.stringify` accepted it; the recorded value is the one serialized. It is kept, not copied or parsed back:\n\t// same-host values are immutable by convention, so the outbox serializing it again in the step records this text\n\t// (a plugin mutating a value after `tx.put` breaks that convention, as for any other value it hands over).\n\treturn { param: text, stored: value as JsonValue };\n}\n\n/** Checks a scalar value of `column` and returns what is bound (booleans as 0 and 1; an address as its key). */\nfunction encodeScalar(column: Column, value: unknown, what: string): string | number {\n\tif (column.type === \"json\") throw invalid(\"args\", `${what}: a json(...) column has no scalar value`);\n\tif (column.host !== undefined) return column.host.key(value, what);\n\treturn toSqlite(checkScalar(column.type, value, what));\n}\n\n/**\n * A value of a scalar column type as the store keeps it (a trust boundary): `str` well-formed without NUL, `int` a\n * safe integer, `num` finite, `bool` a boolean; `invalid/args` otherwise.\n */\nexport function checkScalar(type: \"str\" | \"int\" | \"num\" | \"bool\", value: unknown, what: string): Scalar {\n\tswitch (type) {\n\t\tcase \"str\":\n\t\t\tif (typeof value === \"string\") return storedText(value, what);\n\t\t\tbreak;\n\t\tcase \"int\":\n\t\t\tif (Number.isSafeInteger(value)) return value as number;\n\t\t\tbreak;\n\t\tcase \"num\":\n\t\t\tif (typeof value === \"number\" && Number.isFinite(value)) return value;\n\t\t\tbreak;\n\t\tcase \"bool\":\n\t\t\tif (typeof value === \"boolean\") return value;\n\t\t\tbreak;\n\t}\n\tthrow invalid(\"args\", `${what}: ${JSON.stringify(value) ?? String(value)} is not a ${type} value`);\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SqliteDatabase } from "../sqlite/index.ts";
|
|
2
|
+
/** The store's tables. */
|
|
3
|
+
export declare const TABLES: {
|
|
4
|
+
readonly meta: "chord_meta";
|
|
5
|
+
readonly tables: "chord_tables";
|
|
6
|
+
readonly documents: "chord_documents";
|
|
7
|
+
readonly revisions: "chord_revisions";
|
|
8
|
+
readonly outbox: "chord_outbox";
|
|
9
|
+
};
|
|
10
|
+
/** The store's schema version: the newest entry of its history (archives carry it). */
|
|
11
|
+
export declare const STORE_SCHEMA: number;
|
|
12
|
+
/** The store's metadata row, as `openStore` reads it once. */
|
|
13
|
+
export type MetaRow = {
|
|
14
|
+
readonly last_seq: number;
|
|
15
|
+
readonly next_id: number;
|
|
16
|
+
readonly outbox: number;
|
|
17
|
+
readonly outbox_floor: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Brings `db` to the store's newest schema (one transaction) and checks that it stores text as UTF-8 (the store
|
|
21
|
+
* compares text by its bytes); returns the metadata row. A store already there is read in one statement, without the
|
|
22
|
+
* migrations' write transaction (most opens: the cost of a reopen).
|
|
23
|
+
*/
|
|
24
|
+
export declare function applyStoreSchema(db: SqliteDatabase): Promise<MetaRow>;
|
|
25
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,cAAc,EAAwB,MAAM,oBAAoB,CAAC;AAEtG,0BAA0B;AAC1B,eAAO,MAAM,MAAM;aAClB,IAAI,EAAE,YAAY;aAClB,MAAM,EAAE,cAAc;aACtB,SAAS,EAAE,iBAAiB;aAC5B,SAAS,EAAE,iBAAiB;aAC5B,MAAM,EAAE,cAAc;CACb,CAAC;AA2EX,uFAAuF;AACvF,eAAO,MAAM,YAAY,QAA6B,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAY3E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// The store's own SQL schema (slice 6a §2): its metadata, the recorded table definitions, the documents engine's
|
|
2
|
+
// records and revisions, and the outbox; versioned by `applySqliteMigrations`. Declared tables are named
|
|
3
|
+
// `"<owner>:<table>"`, so no name here can meet one of them.
|
|
4
|
+
import { applySqliteMigrations } from "../sqlite/index.js";
|
|
5
|
+
/** The store's tables. */
|
|
6
|
+
export const TABLES = {
|
|
7
|
+
meta: "chord_meta",
|
|
8
|
+
tables: "chord_tables",
|
|
9
|
+
documents: "chord_documents",
|
|
10
|
+
revisions: "chord_revisions",
|
|
11
|
+
outbox: "chord_outbox",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The schema history; never change an entry, append one (nothing is deployed yet: slice 6b changed entry 1 in place).
|
|
15
|
+
* `chord_meta` is one row: `last_seq`, the allocator's next id (D3; from 2, id 1 is Durable's root conversation), and
|
|
16
|
+
* the outbox setting with its floor (the seq it starts after, advanced by `trim`). A document record keeps its
|
|
17
|
+
* history rule (R1), its current base's version and fingerprint and a `revision` counter for the conditional
|
|
18
|
+
* `UPDATE`; the partial unique index refuses two live records at one address. Entry 2 adds the indexes of reads at a
|
|
19
|
+
* point (slice 6b §1.5): an address's incarnations by creation, an owner's namespace by id, a document's bases (a
|
|
20
|
+
* partial index: deltas write no entry). Entry 3 adds `host`, the address key of the host a record belongs to (Chord's
|
|
21
|
+
* host-keyed documents; `NULL` for every other record), with a partial index: a host's data is found by it.
|
|
22
|
+
*/
|
|
23
|
+
const MIGRATIONS = [
|
|
24
|
+
{
|
|
25
|
+
version: 1,
|
|
26
|
+
statements: [
|
|
27
|
+
`CREATE TABLE ${TABLES.meta} (
|
|
28
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
29
|
+
last_seq INTEGER NOT NULL,
|
|
30
|
+
next_id INTEGER NOT NULL,
|
|
31
|
+
outbox INTEGER NOT NULL CHECK (outbox IN (0, 1)),
|
|
32
|
+
outbox_floor INTEGER NOT NULL
|
|
33
|
+
) STRICT`,
|
|
34
|
+
`INSERT INTO ${TABLES.meta} (singleton, last_seq, next_id, outbox, outbox_floor) VALUES (1, 0, 2, 0, 0)`,
|
|
35
|
+
`CREATE TABLE ${TABLES.tables} (name TEXT PRIMARY KEY, definition TEXT NOT NULL) STRICT, WITHOUT ROWID`,
|
|
36
|
+
`CREATE TABLE ${TABLES.documents} (
|
|
37
|
+
id INTEGER PRIMARY KEY,
|
|
38
|
+
owner TEXT NOT NULL,
|
|
39
|
+
namespace TEXT NOT NULL,
|
|
40
|
+
kind TEXT NOT NULL,
|
|
41
|
+
key TEXT NOT NULL,
|
|
42
|
+
history TEXT NOT NULL CHECK (history IN ('none', 'latest', 'rewindable')),
|
|
43
|
+
created_at INTEGER NOT NULL,
|
|
44
|
+
retired_at INTEGER,
|
|
45
|
+
meta TEXT,
|
|
46
|
+
revision INTEGER NOT NULL,
|
|
47
|
+
version INTEGER NOT NULL,
|
|
48
|
+
fingerprint TEXT NOT NULL
|
|
49
|
+
) STRICT`,
|
|
50
|
+
`CREATE UNIQUE INDEX chord_documents_live ON ${TABLES.documents} (owner, namespace, kind, key)
|
|
51
|
+
WHERE retired_at IS NULL`,
|
|
52
|
+
`CREATE TABLE ${TABLES.revisions} (
|
|
53
|
+
document_id INTEGER NOT NULL,
|
|
54
|
+
seq INTEGER NOT NULL,
|
|
55
|
+
kind TEXT NOT NULL CHECK (kind IN ('base', 'delta')),
|
|
56
|
+
version INTEGER NOT NULL,
|
|
57
|
+
content TEXT NOT NULL,
|
|
58
|
+
PRIMARY KEY (document_id, seq)
|
|
59
|
+
) STRICT, WITHOUT ROWID`,
|
|
60
|
+
`CREATE TABLE ${TABLES.outbox} (
|
|
61
|
+
seq INTEGER PRIMARY KEY,
|
|
62
|
+
format INTEGER NOT NULL,
|
|
63
|
+
next_id INTEGER NOT NULL,
|
|
64
|
+
writes TEXT NOT NULL
|
|
65
|
+
) STRICT`,
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
version: 2,
|
|
70
|
+
statements: [
|
|
71
|
+
`CREATE INDEX chord_documents_address ON ${TABLES.documents} (owner, namespace, kind, key, created_at)`,
|
|
72
|
+
`CREATE INDEX chord_documents_scope ON ${TABLES.documents} (owner, namespace, id)`,
|
|
73
|
+
// Only bases are looked up by it (a load's newest base at or below a point): deltas write no entry.
|
|
74
|
+
`CREATE INDEX chord_revisions_bases ON ${TABLES.revisions} (document_id, seq) WHERE kind = 'base'`,
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
version: 3,
|
|
79
|
+
statements: [
|
|
80
|
+
`ALTER TABLE ${TABLES.documents} ADD COLUMN host TEXT`,
|
|
81
|
+
`CREATE INDEX chord_documents_host ON ${TABLES.documents} (host) WHERE host IS NOT NULL`,
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
/** The store's schema version: the newest entry of its history (archives carry it). */
|
|
86
|
+
export const STORE_SCHEMA = MIGRATIONS.at(-1).version;
|
|
87
|
+
/**
|
|
88
|
+
* Brings `db` to the store's newest schema (one transaction) and checks that it stores text as UTF-8 (the store
|
|
89
|
+
* compares text by its bytes); returns the metadata row. A store already there is read in one statement, without the
|
|
90
|
+
* migrations' write transaction (most opens: the cost of a reopen).
|
|
91
|
+
*/
|
|
92
|
+
export async function applyStoreSchema(db) {
|
|
93
|
+
const current = await currentMeta(db);
|
|
94
|
+
if (current !== undefined)
|
|
95
|
+
return current;
|
|
96
|
+
const encoding = await db.get("PRAGMA encoding");
|
|
97
|
+
if (encoding?.encoding !== "UTF-8")
|
|
98
|
+
throw new Error(`store: the database encoding is ${encoding?.encoding}, not UTF-8`);
|
|
99
|
+
await applySqliteMigrations(db, MIGRATIONS, { table: "chord_store_schema" });
|
|
100
|
+
const meta = await db.get(`SELECT last_seq, next_id, outbox, outbox_floor FROM ${TABLES.meta} WHERE singleton = 1`);
|
|
101
|
+
if (meta === undefined)
|
|
102
|
+
throw new Error("store: the metadata row is missing");
|
|
103
|
+
return meta;
|
|
104
|
+
}
|
|
105
|
+
/** The schema version, the encoding and the metadata row of a store, in one read. */
|
|
106
|
+
const CURRENT_META = `SELECT s.version, e.encoding, m.last_seq, m.next_id, m.outbox, m.outbox_floor
|
|
107
|
+
FROM chord_store_schema s, pragma_encoding e, ${TABLES.meta} m WHERE s.singleton = 1 AND m.singleton = 1`;
|
|
108
|
+
/** The metadata row of a store at the newest schema in UTF-8; `undefined` for any other database. */
|
|
109
|
+
async function currentMeta(db) {
|
|
110
|
+
let row;
|
|
111
|
+
try {
|
|
112
|
+
row = await db.get(CURRENT_META);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// A database without the store's tables (new, or not a store) or a backend without `pragma_encoding`: the
|
|
116
|
+
// migrations' path creates, refuses or reads it.
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
if (row === undefined || row.version !== STORE_SCHEMA || row.encoding !== "UTF-8")
|
|
120
|
+
return undefined;
|
|
121
|
+
return { last_seq: row.last_seq, next_id: row.next_id, outbox: row.outbox, outbox_floor: row.outbox_floor };
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,yGAAyG;AACzG,6DAA6D;AAE7D,OAAO,EAAE,qBAAqB,EAA6C,MAAM,oBAAoB,CAAC;AAEtG,0BAA0B;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,cAAc;IACtB,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,cAAc;CACb,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,UAAU,GAA+B;IAC9C;QACC,OAAO,EAAE,CAAC;QACV,UAAU,EAAE;YACX,gBAAgB,MAAM,CAAC,IAAI;;;;;;YAMlB;YACT,eAAe,MAAM,CAAC,IAAI,8EAA8E;YACxG,gBAAgB,MAAM,CAAC,MAAM,0EAA0E;YACvG,gBAAgB,MAAM,CAAC,SAAS;;;;;;;;;;;;;YAavB;YACT,+CAA+C,MAAM,CAAC,SAAS;6BACrC;YAC1B,gBAAgB,MAAM,CAAC,SAAS;;;;;;;2BAOR;YACxB,gBAAgB,MAAM,CAAC,MAAM;;;;;YAKpB;SACT;KACD;IACD;QACC,OAAO,EAAE,CAAC;QACV,UAAU,EAAE;YACX,2CAA2C,MAAM,CAAC,SAAS,4CAA4C;YACvG,yCAAyC,MAAM,CAAC,SAAS,yBAAyB;YAClF,oGAAoG;YACpG,yCAAyC,MAAM,CAAC,SAAS,yCAAyC;SAClG;KACD;IACD;QACC,OAAO,EAAE,CAAC;QACV,UAAU,EAAE;YACX,eAAe,MAAM,CAAC,SAAS,uBAAuB;YACtD,wCAAwC,MAAM,CAAC,SAAS,gCAAgC;S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,GAAG,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACpG,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;AAC7G,CAAC","sourcesContent":["// The store's own SQL schema (slice 6a §2): its metadata, the recorded table definitions, the documents engine's\n// records and revisions, and the outbox; versioned by `applySqliteMigrations`. Declared tables are named\n// `\"<owner>:<table>\"`, so no name here can meet one of them.\n\nimport { applySqliteMigrations, type SqliteDatabase, type SqliteMigration } from \"../sqlite/index.ts\";\n\n/** The store's tables. */\nexport const TABLES = {\n\tmeta: \"chord_meta\",\n\ttables: \"chord_tables\",\n\tdocuments: \"chord_documents\",\n\trevisions: \"chord_revisions\",\n\toutbox: \"chord_outbox\",\n} as const;\n\n/**\n * The schema history; never change an entry, append one (nothing is deployed yet: slice 6b changed entry 1 in place).\n * `chord_meta` is one row: `last_seq`, the allocator's next id (D3; from 2, id 1 is Durable's root conversation), and\n * the outbox setting with its floor (the seq it starts after, advanced by `trim`). A document record keeps its\n * history rule (R1), its current base's version and fingerprint and a `revision` counter for the conditional\n * `UPDATE`; the partial unique index refuses two live records at one address. Entry 2 adds the indexes of reads at a\n * point (slice 6b §1.5): an address's incarnations by creation, an owner's namespace by id, a document's bases (a\n * partial index: deltas write no entry). Entry 3 adds `host`, the address key of the host a record belongs to (Chord's\n * host-keyed documents; `NULL` for every other record), with a partial index: a host's data is found by it.\n */\nconst MIGRATIONS: readonly SqliteMigration[] = [\n\t{\n\t\tversion: 1,\n\t\tstatements: [\n\t\t\t`CREATE TABLE ${TABLES.meta} (\n\t\t\t\tsingleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n\t\t\t\tlast_seq INTEGER NOT NULL,\n\t\t\t\tnext_id INTEGER NOT NULL,\n\t\t\t\toutbox INTEGER NOT NULL CHECK (outbox IN (0, 1)),\n\t\t\t\toutbox_floor INTEGER NOT NULL\n\t\t\t) STRICT`,\n\t\t\t`INSERT INTO ${TABLES.meta} (singleton, last_seq, next_id, outbox, outbox_floor) VALUES (1, 0, 2, 0, 0)`,\n\t\t\t`CREATE TABLE ${TABLES.tables} (name TEXT PRIMARY KEY, definition TEXT NOT NULL) STRICT, WITHOUT ROWID`,\n\t\t\t`CREATE TABLE ${TABLES.documents} (\n\t\t\t\tid INTEGER PRIMARY KEY,\n\t\t\t\towner TEXT NOT NULL,\n\t\t\t\tnamespace TEXT NOT NULL,\n\t\t\t\tkind TEXT NOT NULL,\n\t\t\t\tkey TEXT NOT NULL,\n\t\t\t\thistory TEXT NOT NULL CHECK (history IN ('none', 'latest', 'rewindable')),\n\t\t\t\tcreated_at INTEGER NOT NULL,\n\t\t\t\tretired_at INTEGER,\n\t\t\t\tmeta TEXT,\n\t\t\t\trevision INTEGER NOT NULL,\n\t\t\t\tversion INTEGER NOT NULL,\n\t\t\t\tfingerprint TEXT NOT NULL\n\t\t\t) STRICT`,\n\t\t\t`CREATE UNIQUE INDEX chord_documents_live ON ${TABLES.documents} (owner, namespace, kind, key)\n\t\t\t\tWHERE retired_at IS NULL`,\n\t\t\t`CREATE TABLE ${TABLES.revisions} (\n\t\t\t\tdocument_id INTEGER NOT NULL,\n\t\t\t\tseq INTEGER NOT NULL,\n\t\t\t\tkind TEXT NOT NULL CHECK (kind IN ('base', 'delta')),\n\t\t\t\tversion INTEGER NOT NULL,\n\t\t\t\tcontent TEXT NOT NULL,\n\t\t\t\tPRIMARY KEY (document_id, seq)\n\t\t\t) STRICT, WITHOUT ROWID`,\n\t\t\t`CREATE TABLE ${TABLES.outbox} (\n\t\t\t\tseq INTEGER PRIMARY KEY,\n\t\t\t\tformat INTEGER NOT NULL,\n\t\t\t\tnext_id INTEGER NOT NULL,\n\t\t\t\twrites TEXT NOT NULL\n\t\t\t) STRICT`,\n\t\t],\n\t},\n\t{\n\t\tversion: 2,\n\t\tstatements: [\n\t\t\t`CREATE INDEX chord_documents_address ON ${TABLES.documents} (owner, namespace, kind, key, created_at)`,\n\t\t\t`CREATE INDEX chord_documents_scope ON ${TABLES.documents} (owner, namespace, id)`,\n\t\t\t// Only bases are looked up by it (a load's newest base at or below a point): deltas write no entry.\n\t\t\t`CREATE INDEX chord_revisions_bases ON ${TABLES.revisions} (document_id, seq) WHERE kind = 'base'`,\n\t\t],\n\t},\n\t{\n\t\tversion: 3,\n\t\tstatements: [\n\t\t\t`ALTER TABLE ${TABLES.documents} ADD COLUMN host TEXT`,\n\t\t\t`CREATE INDEX chord_documents_host ON ${TABLES.documents} (host) WHERE host IS NOT NULL`,\n\t\t],\n\t},\n];\n\n/** The store's schema version: the newest entry of its history (archives carry it). */\nexport const STORE_SCHEMA = MIGRATIONS.at(-1)!.version;\n\n/** The store's metadata row, as `openStore` reads it once. */\nexport type MetaRow = {\n\treadonly last_seq: number;\n\treadonly next_id: number;\n\treadonly outbox: number;\n\treadonly outbox_floor: number;\n};\n\n/**\n * Brings `db` to the store's newest schema (one transaction) and checks that it stores text as UTF-8 (the store\n * compares text by its bytes); returns the metadata row. A store already there is read in one statement, without the\n * migrations' write transaction (most opens: the cost of a reopen).\n */\nexport async function applyStoreSchema(db: SqliteDatabase): Promise<MetaRow> {\n\tconst current = await currentMeta(db);\n\tif (current !== undefined) return current;\n\tconst encoding = await db.get<{ readonly encoding: string }>(\"PRAGMA encoding\");\n\tif (encoding?.encoding !== \"UTF-8\")\n\t\tthrow new Error(`store: the database encoding is ${encoding?.encoding}, not UTF-8`);\n\tawait applySqliteMigrations(db, MIGRATIONS, { table: \"chord_store_schema\" });\n\tconst meta = await db.get<MetaRow>(\n\t\t`SELECT last_seq, next_id, outbox, outbox_floor FROM ${TABLES.meta} WHERE singleton = 1`,\n\t);\n\tif (meta === undefined) throw new Error(\"store: the metadata row is missing\");\n\treturn meta;\n}\n\n/** The schema version, the encoding and the metadata row of a store, in one read. */\nconst CURRENT_META = `SELECT s.version, e.encoding, m.last_seq, m.next_id, m.outbox, m.outbox_floor\n\tFROM chord_store_schema s, pragma_encoding e, ${TABLES.meta} m WHERE s.singleton = 1 AND m.singleton = 1`;\n\n/** The metadata row of a store at the newest schema in UTF-8; `undefined` for any other database. */\nasync function currentMeta(db: SqliteDatabase): Promise<MetaRow | undefined> {\n\tlet row: (MetaRow & { readonly version: number; readonly encoding: string }) | undefined;\n\ttry {\n\t\trow = await db.get(CURRENT_META);\n\t} catch {\n\t\t// A database without the store's tables (new, or not a store) or a backend without `pragma_encoding`: the\n\t\t// migrations' path creates, refuses or reads it.\n\t\treturn undefined;\n\t}\n\tif (row === undefined || row.version !== STORE_SCHEMA || row.encoding !== \"UTF-8\") return undefined;\n\treturn { last_seq: row.last_seq, next_id: row.next_id, outbox: row.outbox, outbox_floor: row.outbox_floor };\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import type { SqliteValue } from "../sqlite/index.ts";
|
|
3
|
+
import { type Read } from "./read.ts";
|
|
4
|
+
import type { Step } from "./step.ts";
|
|
5
|
+
/**
|
|
6
|
+
* One write of a transaction as the skip test reads it. A single-key write names its key and, for an `update`, the
|
|
7
|
+
* columns it assigns; a bulk one the columns it assigns (`undefined`: it deletes rows).
|
|
8
|
+
*/
|
|
9
|
+
export type Change = {
|
|
10
|
+
readonly table: string;
|
|
11
|
+
readonly kind: "put" | "update" | "delete";
|
|
12
|
+
readonly key: {
|
|
13
|
+
readonly [column: string]: SqliteValue;
|
|
14
|
+
};
|
|
15
|
+
readonly assigned: readonly string[] | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
readonly table: string;
|
|
18
|
+
readonly kind: "bulk";
|
|
19
|
+
readonly assigned: readonly string[] | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Whether `changes` (the writes of one step, already applied) leave `read`'s result as it is: every change is
|
|
23
|
+
* skipped for every use of its table by the read. A read without a result (loading, failed) is never skipped.
|
|
24
|
+
*/
|
|
25
|
+
export declare function skips(read: Read, changes: readonly Change[], step: Step, context: Context): Promise<boolean>;
|
|
26
|
+
//# sourceMappingURL=skip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../src/store/skip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAc,KAAK,IAAI,EAAmB,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,MAAM,GACf;IACA,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC;IACzD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAChD,GACD;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAC;AASvG;;;GAGG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAYlH"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The skip test (slice 14 §3.3): whether a commit's writes can have changed a read's result. A skip proves the
|
|
2
|
+
// result unchanged by the row before the write (the keys and matched values the read kept of its last run) and by
|
|
3
|
+
// the row after it (the probe: the read's own statement, limited to the rows the written row pairs with). There is no
|
|
4
|
+
// second evaluator: the database decides with the real condition.
|
|
5
|
+
import { chordMetrics } from "../telemetry.js";
|
|
6
|
+
import { identityOf } from "./read.js";
|
|
7
|
+
/**
|
|
8
|
+
* How many probes one read may ask in one step before it runs instead. A probe costs a few microseconds and a run
|
|
9
|
+
* of a page a few hundred (`benchmarks.md`), so a transaction writing many rows (an import, a bulk `put`) must not
|
|
10
|
+
* probe a read once per row: past this many, running it is cheaper than asking on.
|
|
11
|
+
*/
|
|
12
|
+
const PROBES_PER_READ = 8;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `changes` (the writes of one step, already applied) leave `read`'s result as it is: every change is
|
|
15
|
+
* skipped for every use of its table by the read. A read without a result (loading, failed) is never skipped.
|
|
16
|
+
*/
|
|
17
|
+
export async function skips(read, changes, step, context) {
|
|
18
|
+
const latest = read.latest(step.executor);
|
|
19
|
+
if (latest === undefined || latest.kind === "failed")
|
|
20
|
+
return false;
|
|
21
|
+
const result = latest.kind === "rows" ? latest.result : undefined;
|
|
22
|
+
const budget = { probes: PROBES_PER_READ };
|
|
23
|
+
for (const change of changes) {
|
|
24
|
+
for (const use of read.plan.uses) {
|
|
25
|
+
if (use.table !== change.table)
|
|
26
|
+
continue;
|
|
27
|
+
if (!(await skipped(read, use, change, result, step, context, budget)))
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/** One change against one use of its table (the table of slice 14 §3.3, row by row). */
|
|
34
|
+
async function skipped(read, use, change, result, step, context, budget) {
|
|
35
|
+
const assigns = (columns) => change.assigned === undefined || change.assigned.some((name) => columns.has(name));
|
|
36
|
+
// "Any": an `update` (a bulk one too) that assigns none of the columns the read depends on in that table.
|
|
37
|
+
if (change.kind !== "put" && change.kind !== "delete" && !assigns(use.depends))
|
|
38
|
+
return true;
|
|
39
|
+
// A bulk write names no rows, and a count keeps none: nothing more can be proved.
|
|
40
|
+
if (change.kind === "bulk" || result === undefined)
|
|
41
|
+
return false;
|
|
42
|
+
// Where the value before is unknown and matters, the read runs: a matched column outside the key may have been
|
|
43
|
+
// re-pointed, and the rows it paired with before are unknown.
|
|
44
|
+
if (!use.stable)
|
|
45
|
+
return false;
|
|
46
|
+
const values = use.pairedBy.map((name) => change.key[name]);
|
|
47
|
+
const fetched = use.role === "own" ? result.keys : result.paired.get(use);
|
|
48
|
+
// Before: a fetched row the written row pairs with decided the result (unknown pairs count as one).
|
|
49
|
+
if (fetched === undefined || fetched.has(identityOf(values)))
|
|
50
|
+
return false;
|
|
51
|
+
// After. A row that was not in the result cannot enter it by leaving (its own delete, its partner's), nor by an
|
|
52
|
+
// `update` of columns that decide neither membership nor position. An `exists` row's delete or update can bring
|
|
53
|
+
// its own rows in (`not(exists(…))`): only the probe tells.
|
|
54
|
+
if (use.role !== "exists" && (change.kind === "delete" || (change.kind === "update" && !assigns(use.enters))))
|
|
55
|
+
return true;
|
|
56
|
+
if (!use.keyed || budget.probes-- === 0)
|
|
57
|
+
return false;
|
|
58
|
+
return !(await probe(read, use.pairs, values, result, step, context));
|
|
59
|
+
}
|
|
60
|
+
/** The probe: whether, after the step's writes, a row with `values` in `columns` is in the read's range. */
|
|
61
|
+
async function probe(read, columns, values, result, step, context) {
|
|
62
|
+
chordMetrics(context.telemetry.metrics).counter("chord.query.probes").add(1);
|
|
63
|
+
const { sql, params } = read.plan.probe(read.probed(result), columns, values);
|
|
64
|
+
return (await step.get(sql, ...params)) !== undefined;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=skip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../../src/store/skip.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,kHAAkH;AAClH,sHAAsH;AACtH,kEAAkE;AAIlE,OAAO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,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,4GAA4G;AAC5G,KAAK,UAAU,KAAK,CACnB,IAAU,EACV,OAA0B,EAC1B,MAA8B,EAC9B,MAAkB,EAClB,IAAU,EACV,OAAgB;IAEhB,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9E,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAA6B,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,KAAK,SAAS,CAAC;AACnF,CAAC","sourcesContent":["// The skip test (slice 14 §3.3): whether a commit's writes can have changed a read's result. A skip proves the\n// result unchanged by the row before the write (the keys and matched values the read kept of its last run) and by\n// the row after it (the probe: the read's own statement, limited to the rows the written row pairs with). There is no\n// second evaluator: the database decides with the real condition.\n\nimport type { Context } from \"../context/index.ts\";\nimport type { SqliteValue } from \"../sqlite/index.ts\";\nimport { chordMetrics } from \"../telemetry.ts\";\nimport { identityOf, type Read, type ReadResult } from \"./read.ts\";\nimport type { Use } from \"./read-plan.ts\";\nimport type { Step } from \"./step.ts\";\n\n/**\n * One write of a transaction as the skip test reads it. A single-key write names its key and, for an `update`, the\n * columns it assigns; a bulk one the columns it assigns (`undefined`: it deletes rows).\n */\nexport type Change =\n\t| {\n\t\t\treadonly table: string;\n\t\t\treadonly kind: \"put\" | \"update\" | \"delete\";\n\t\t\treadonly key: { readonly [column: string]: SqliteValue };\n\t\t\treadonly assigned: readonly string[] | undefined;\n\t }\n\t| { readonly table: string; readonly kind: \"bulk\"; readonly assigned: readonly string[] | undefined };\n\n/**\n * How many probes one read may ask in one step before it runs instead. A probe costs a few microseconds and a run\n * of a page a few hundred (`benchmarks.md`), so a transaction writing many rows (an import, a bulk `put`) must not\n * probe a read once per row: past this many, running it is cheaper than asking on.\n */\nconst PROBES_PER_READ = 8;\n\n/**\n * Whether `changes` (the writes of one step, already applied) leave `read`'s result as it is: every change is\n * skipped for every use of its table by the read. A read without a result (loading, failed) is never skipped.\n */\nexport async function skips(read: Read, changes: readonly Change[], step: Step, context: Context): Promise<boolean> {\n\tconst latest = read.latest(step.executor);\n\tif (latest === undefined || latest.kind === \"failed\") return false;\n\tconst result = latest.kind === \"rows\" ? latest.result : undefined;\n\tconst budget = { probes: PROBES_PER_READ };\n\tfor (const change of changes) {\n\t\tfor (const use of read.plan.uses) {\n\t\t\tif (use.table !== change.table) continue;\n\t\t\tif (!(await skipped(read, use, change, result, step, context, budget))) return false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/** One change against one use of its table (the table of slice 14 §3.3, row by row). */\nasync function skipped(\n\tread: Read,\n\tuse: Use,\n\tchange: Change,\n\tresult: ReadResult | undefined,\n\tstep: Step,\n\tcontext: Context,\n\tbudget: { probes: number },\n): Promise<boolean> {\n\tconst assigns = (columns: ReadonlySet<string>): boolean =>\n\t\tchange.assigned === undefined || change.assigned.some((name) => columns.has(name));\n\t// \"Any\": an `update` (a bulk one too) that assigns none of the columns the read depends on in that table.\n\tif (change.kind !== \"put\" && change.kind !== \"delete\" && !assigns(use.depends)) return true;\n\t// A bulk write names no rows, and a count keeps none: nothing more can be proved.\n\tif (change.kind === \"bulk\" || result === undefined) return false;\n\t// Where the value before is unknown and matters, the read runs: a matched column outside the key may have been\n\t// re-pointed, and the rows it paired with before are unknown.\n\tif (!use.stable) return false;\n\tconst values = use.pairedBy.map((name) => change.key[name]!);\n\tconst fetched = use.role === \"own\" ? result.keys : result.paired.get(use);\n\t// Before: a fetched row the written row pairs with decided the result (unknown pairs count as one).\n\tif (fetched === undefined || fetched.has(identityOf(values))) return false;\n\t// After. A row that was not in the result cannot enter it by leaving (its own delete, its partner's), nor by an\n\t// `update` of columns that decide neither membership nor position. An `exists` row's delete or update can bring\n\t// its own rows in (`not(exists(…))`): only the probe tells.\n\tif (use.role !== \"exists\" && (change.kind === \"delete\" || (change.kind === \"update\" && !assigns(use.enters))))\n\t\treturn true;\n\tif (!use.keyed || budget.probes-- === 0) return false;\n\treturn !(await probe(read, use.pairs!, values, result, step, context));\n}\n\n/** The probe: whether, after the step's writes, a row with `values` in `columns` is in the read's range. */\nasync function probe(\n\tread: Read,\n\tcolumns: readonly string[],\n\tvalues: readonly SqliteValue[],\n\tresult: ReadResult,\n\tstep: Step,\n\tcontext: Context,\n): Promise<boolean> {\n\tchordMetrics(context.telemetry.metrics).counter(\"chord.query.probes\").add(1);\n\tconst { sql, params } = read.plan.probe(read.probed(result), columns, values);\n\treturn (await step.get<{ readonly found: number }>(sql, ...params)) !== undefined;\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { SqliteValue } from "../sqlite/index.ts";
|
|
2
|
+
import type { Column, ColumnRecord } from "./columns.ts";
|
|
3
|
+
import type { ExistsNode, SetNode, WhereNode } from "./expression.ts";
|
|
4
|
+
/** A statement and its parameters. */
|
|
5
|
+
export type Statement = {
|
|
6
|
+
readonly sql: string;
|
|
7
|
+
readonly params: SqliteValue[];
|
|
8
|
+
};
|
|
9
|
+
/** An order of rows: the order columns (the key appended as the tie-break) and one direction. */
|
|
10
|
+
export type Order = {
|
|
11
|
+
readonly columns: readonly string[];
|
|
12
|
+
readonly direction: "asc" | "desc";
|
|
13
|
+
};
|
|
14
|
+
/** A quoted SQL identifier. */
|
|
15
|
+
export declare function quote(name: string): string;
|
|
16
|
+
/** The SQL name of an owner's table: `<owner>:<table>` (R2), injective since neither part contains `:`. */
|
|
17
|
+
export declare function tableSqlName(owner: string, table: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* `CREATE TABLE` for `columns` (as recorded) and `key`: `STRICT`, the key as primary key (`WITHOUT ROWID`, except
|
|
20
|
+
* for a single `int` key, which becomes the rowid: the fastest point lookups, and rows of any size), an `int`
|
|
21
|
+
* column checked within ±(2^53 - 1) (rule 10), a `bool` one within 0 and 1, a `json(...)` one as `TEXT` with its
|
|
22
|
+
* version column, and the row's `$v`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTableSql(table: string, columns: {
|
|
25
|
+
readonly [name: string]: ColumnRecord;
|
|
26
|
+
}, key: readonly string[]): string;
|
|
27
|
+
/** The definitions of one column: itself, and a `json(...)` column's version column. */
|
|
28
|
+
export declare function columnSql(name: string, column: ColumnRecord): string[];
|
|
29
|
+
/**
|
|
30
|
+
* The physical columns of a recorded table in the order `RowCodec.physical` uses (`physicalColumns`), and its
|
|
31
|
+
* whole-row `INSERT OR REPLACE` over them.
|
|
32
|
+
*/
|
|
33
|
+
export declare function recordedPut(table: string, columns: {
|
|
34
|
+
readonly [name: string]: ColumnRecord;
|
|
35
|
+
}): {
|
|
36
|
+
readonly physical: readonly string[];
|
|
37
|
+
readonly sql: string;
|
|
38
|
+
};
|
|
39
|
+
/** `CREATE INDEX` named `<table>:<index>` over `columns`, the key appended (every index ends with it). */
|
|
40
|
+
export declare function createIndexSql(table: string, index: string, columns: readonly string[], key: readonly string[]): string;
|
|
41
|
+
/** `DROP INDEX` of `<table>:<index>`. */
|
|
42
|
+
export declare function dropIndexSql(table: string, index: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* The statements of one table at one version, rendered once per table handle: the fixed ones as texts, the ones
|
|
45
|
+
* over compiled conditions and `set`s on demand.
|
|
46
|
+
*/
|
|
47
|
+
export declare class TableSql {
|
|
48
|
+
#private;
|
|
49
|
+
readonly table: string;
|
|
50
|
+
/** `INSERT OR REPLACE` of a whole row, in `RowCodec.physical`'s order (`put` is an upsert). */
|
|
51
|
+
readonly put: string;
|
|
52
|
+
readonly get: string;
|
|
53
|
+
readonly delete: string;
|
|
54
|
+
constructor(table: string, columns: readonly Pick<Column, "name" | "type">[], physical: readonly string[], key: readonly string[]);
|
|
55
|
+
/** `SELECT` of `columns` of one row by key: a point lookup, without the `ORDER BY` and `LIMIT` of a page. */
|
|
56
|
+
getColumns(columns: readonly string[]): string;
|
|
57
|
+
/** `UPDATE` of one row by key; `versions` gives each `json(...)` column's version to stamp. */
|
|
58
|
+
update(set: SetNode, key: readonly SqliteValue[], versions: ReadonlyMap<string, number>): Statement;
|
|
59
|
+
/** `UPDATE` of every row matching `where`. */
|
|
60
|
+
updateWhere(where: WhereNode, set: SetNode, versions: ReadonlyMap<string, number>): Statement;
|
|
61
|
+
/** `DELETE` of every row matching `where`. */
|
|
62
|
+
deleteWhere(where: WhereNode): Statement;
|
|
63
|
+
/**
|
|
64
|
+
* A page: rows matching `where` in `order`, after the order values `after` (row-value comparison; the key in the
|
|
65
|
+
* order makes it total), at most `limit` (bound); every column, or only `columns`.
|
|
66
|
+
*/
|
|
67
|
+
select(where: WhereNode | undefined, order: Order, after: readonly SqliteValue[] | undefined, limit: number, columns?: readonly string[]): Statement;
|
|
68
|
+
/** `count(*)` of the rows matching `where`. */
|
|
69
|
+
count(where: WhereNode | undefined): Statement;
|
|
70
|
+
}
|
|
71
|
+
/** How a condition's parts that depend on where it runs are rendered: a column's name, and an `exists`. */
|
|
72
|
+
export type ConditionSql = {
|
|
73
|
+
column(name: string): string;
|
|
74
|
+
exists(node: ExistsNode, params: SqliteValue[]): string;
|
|
75
|
+
};
|
|
76
|
+
/** A condition with its operands bound; SQL's `NULL` rules are the vocabulary's. */
|
|
77
|
+
export declare function whereSql(node: WhereNode, params: SqliteValue[], render?: ConditionSql): string;
|
|
78
|
+
//# sourceMappingURL=sql.d.ts.map
|