@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,208 @@
|
|
|
1
|
+
// `evolveTable(previous, (t) => t…)` (slice 6a §9; decision "Second spec review: the majority"): the next version of a
|
|
2
|
+
// table from the edits of one migration. The editor's types order the edits (`rename`, `add` and `json` before the
|
|
3
|
+
// data step, `drop`, `index` and `dropIndex` after it) and track the columns and key through the chain; at runtime one
|
|
4
|
+
// editor records the edits, checks each as it is made, and materializes the new version at the end.
|
|
5
|
+
import { opt } from "../contracts/index.js";
|
|
6
|
+
import { editWith } from "../contracts/internal.js";
|
|
7
|
+
import { isOptional } from "../contracts/schema.js";
|
|
8
|
+
import { checkColumnName, columnRecord, describeColumns, } from "./columns.js";
|
|
9
|
+
import { compileSet, compileWhere } from "./expression.js";
|
|
10
|
+
import { INDEX_NAME, orderColumns, TableDefinition } from "./table.js";
|
|
11
|
+
/**
|
|
12
|
+
* Appends the next version (`previous.version + 1`) with the edits `edit` makes; `edit` must return the editor it was
|
|
13
|
+
* given. Every version is materialized and fingerprinted here; the object serves the newest, and its activation
|
|
14
|
+
* migrates a store at an older version through each one.
|
|
15
|
+
*/
|
|
16
|
+
export function evolveTable(previous, edit, options = {}) {
|
|
17
|
+
// The runtime editor works on untyped definitions; the types live in the editor interfaces.
|
|
18
|
+
const editor = new Editor(previous, options);
|
|
19
|
+
// The editor interfaces track the edits in the types; at runtime every edit returns the same editor.
|
|
20
|
+
editWith(editor, edit, `${previous.name}: evolveTable`);
|
|
21
|
+
return editor.finish();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The editor at runtime: the columns, key and indexes as the edits leave them, the edits before and after the data
|
|
25
|
+
* step, and the step. Each edit is checked as it is made (declaration policy: JavaScript callers reach the checks).
|
|
26
|
+
*/
|
|
27
|
+
class Editor {
|
|
28
|
+
#previous;
|
|
29
|
+
#what;
|
|
30
|
+
#schemas;
|
|
31
|
+
#key;
|
|
32
|
+
#indexes;
|
|
33
|
+
/** `before` until the data step or the first `drop`, `index` or `dropIndex`. */
|
|
34
|
+
#phase = "before";
|
|
35
|
+
#before = [];
|
|
36
|
+
#step;
|
|
37
|
+
#after = [];
|
|
38
|
+
/** The set the finished version exposes; the versions a data step reads expose none. */
|
|
39
|
+
#exposes;
|
|
40
|
+
constructor(previous, options) {
|
|
41
|
+
this.#previous = previous;
|
|
42
|
+
this.#exposes = options.exposes === "none" ? undefined : (options.exposes ?? previous.exposes);
|
|
43
|
+
this.#what = `${previous.name} version ${previous.version + 1}`;
|
|
44
|
+
this.#schemas = { ...previous.schemas };
|
|
45
|
+
this.#key = [...previous.key];
|
|
46
|
+
this.#indexes = new Map(previous.indexes);
|
|
47
|
+
}
|
|
48
|
+
rename(from, to) {
|
|
49
|
+
this.#assertBefore("rename");
|
|
50
|
+
this.#assertColumn(from, "rename");
|
|
51
|
+
// Checked here, not by the final definition: a later edit may rename it again, but this one runs as DDL.
|
|
52
|
+
checkColumnName(to, `${this.#what}: rename`);
|
|
53
|
+
this.#assertNewName(to, "rename", from);
|
|
54
|
+
const rename = (column) => (column === from ? to : column);
|
|
55
|
+
this.#schemas = Object.fromEntries(Object.entries(this.#schemas).map(([name, schema]) => [rename(name), schema]));
|
|
56
|
+
this.#key = this.#key.map(rename);
|
|
57
|
+
for (const [name, columns] of this.#indexes)
|
|
58
|
+
this.#indexes.set(name, columns.map(rename));
|
|
59
|
+
this.#before.push({ kind: "rename", from, to });
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
add(name, column) {
|
|
63
|
+
this.#assertBefore("add");
|
|
64
|
+
this.#assertNewName(name, "add");
|
|
65
|
+
const [described] = describeColumns({ [name]: column }, `${this.#what}: add`);
|
|
66
|
+
if (!described.optional && (described.type === "json" || described.default === undefined)) {
|
|
67
|
+
throw new Error(`${this.#what}: add: column "${name}" needs opt(...) or a default (existing rows get it)`);
|
|
68
|
+
}
|
|
69
|
+
this.#schemas[name] = column;
|
|
70
|
+
this.#before.push({ kind: "add", name, column: columnRecord(described) });
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
json(name, column) {
|
|
74
|
+
this.#assertBefore("json");
|
|
75
|
+
const existing = describeColumns({ [name]: this.#assertColumn(name, "json") }, this.#what)[0];
|
|
76
|
+
if (existing.type !== "json")
|
|
77
|
+
throw new Error(`${this.#what}: json: column "${name}" is not a json(...) column`);
|
|
78
|
+
if (isOptional(column)) {
|
|
79
|
+
throw new Error(`${this.#what}: json: pass json(...) itself; the column keeps its nullability`);
|
|
80
|
+
}
|
|
81
|
+
// A host(...) column is no json(...) one: `describeColumns` below refuses it either way.
|
|
82
|
+
const schema = existing.optional
|
|
83
|
+
? opt(column)
|
|
84
|
+
: column;
|
|
85
|
+
const described = describeColumns({ [name]: schema }, `${this.#what}: json`)[0];
|
|
86
|
+
if (described.type !== "json")
|
|
87
|
+
throw new Error(`${this.#what}: json: expected a json(...) column`);
|
|
88
|
+
const [before, after] = [existing.json, described.json];
|
|
89
|
+
// D9 across table versions: a cell's version says which schema it was written with.
|
|
90
|
+
if (after.version < before.version) {
|
|
91
|
+
throw new Error(`${this.#what}: json: column "${name}" goes back from version ${before.version}`);
|
|
92
|
+
}
|
|
93
|
+
if (after.version === before.version && after.fingerprint !== before.fingerprint) {
|
|
94
|
+
throw new Error(`${this.#what}: json: column "${name}" changes its schema at version ${before.version} (raise its version)`);
|
|
95
|
+
}
|
|
96
|
+
this.#schemas[name] = schema;
|
|
97
|
+
this.#before.push({ kind: "json", name, column: columnRecord(described) });
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
rows(patch) {
|
|
101
|
+
this.#assertBefore("rows");
|
|
102
|
+
if (typeof patch !== "function")
|
|
103
|
+
throw new Error(`${this.#what}: rows: expected a function`);
|
|
104
|
+
this.#step = { kind: "rows", table: this.#current(), patch };
|
|
105
|
+
this.#phase = "after";
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
update(step) {
|
|
109
|
+
this.#assertBefore("update");
|
|
110
|
+
const table = this.#current();
|
|
111
|
+
const what = `version ${table.version} update`;
|
|
112
|
+
const where = typeof step.where === "function" ? step.where(table.refs) : step.where;
|
|
113
|
+
const set = typeof step.set === "function" ? step.set(table.refs) : step.set;
|
|
114
|
+
this.#step = {
|
|
115
|
+
kind: "update",
|
|
116
|
+
table,
|
|
117
|
+
where: where === undefined ? undefined : compileWhere(table, where, what),
|
|
118
|
+
set: compileSet(table, set, what),
|
|
119
|
+
};
|
|
120
|
+
this.#phase = "after";
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
drop(name) {
|
|
124
|
+
this.#phase = "after";
|
|
125
|
+
this.#assertColumn(name, "drop");
|
|
126
|
+
if (this.#key.includes(name))
|
|
127
|
+
throw new Error(`${this.#what}: drop: "${name}" is a key column`);
|
|
128
|
+
for (const [index, columns] of this.#indexes) {
|
|
129
|
+
if (!columns.includes(name))
|
|
130
|
+
continue;
|
|
131
|
+
this.#indexes.delete(index);
|
|
132
|
+
this.#after.push({ kind: "dropIndex", name: index });
|
|
133
|
+
}
|
|
134
|
+
const { [name]: _dropped, ...schemas } = this.#schemas;
|
|
135
|
+
this.#schemas = schemas;
|
|
136
|
+
this.#after.push({ kind: "drop", name });
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
index(name, columns) {
|
|
140
|
+
this.#phase = "after";
|
|
141
|
+
const what = `${this.#what}: index "${name}"`;
|
|
142
|
+
if (!INDEX_NAME.test(name))
|
|
143
|
+
throw new Error(`${what}: expected [a-z0-9_]+`);
|
|
144
|
+
if (this.#indexes.has(name))
|
|
145
|
+
throw new Error(`${what} exists`);
|
|
146
|
+
// Checked against the columns at this edit: the migration creates the index here, whatever later edits do.
|
|
147
|
+
const byName = new Map(describeColumns(this.#schemas, this.#what).map((column) => [column.name, column]));
|
|
148
|
+
const checked = orderColumns(byName, columns, what);
|
|
149
|
+
this.#indexes.set(name, checked);
|
|
150
|
+
this.#after.push({ kind: "index", name, columns: checked });
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
dropIndex(name) {
|
|
154
|
+
this.#phase = "after";
|
|
155
|
+
if (!this.#indexes.delete(name))
|
|
156
|
+
throw new Error(`${this.#what}: dropIndex: no index "${name}"`);
|
|
157
|
+
this.#after.push({ kind: "dropIndex", name });
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
/** The new version, materialized and fingerprinted, linked to the previous one and the migration from it. */
|
|
161
|
+
finish() {
|
|
162
|
+
const migration = { before: this.#before, step: this.#step, after: this.#after };
|
|
163
|
+
const options = { ...this.#options(), ...(this.#exposes === undefined ? {} : { exposes: this.#exposes }) };
|
|
164
|
+
return new TableDefinition(this.#previous.name, options, { previous: this.#previous, migration });
|
|
165
|
+
}
|
|
166
|
+
/** The table as the edits so far leave it, at the new version: what a data step reads and writes. */
|
|
167
|
+
#current() {
|
|
168
|
+
return new TableDefinition(this.#previous.name, this.#options());
|
|
169
|
+
}
|
|
170
|
+
#options() {
|
|
171
|
+
const version = this.#previous.version + 1;
|
|
172
|
+
const options = {
|
|
173
|
+
version,
|
|
174
|
+
columns: { ...this.#schemas },
|
|
175
|
+
key: [...this.#key],
|
|
176
|
+
indexes: Object.fromEntries(this.#indexes),
|
|
177
|
+
};
|
|
178
|
+
// The key and indexes are names the edits kept; the constructor checks them as it checks a base's.
|
|
179
|
+
return options;
|
|
180
|
+
}
|
|
181
|
+
#assertBefore(edit) {
|
|
182
|
+
if (this.#phase === "after") {
|
|
183
|
+
throw new Error(`${this.#what}: ${edit} comes before the data step and before drop, index and dropIndex`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* `name` names no column yet, also ignoring ASCII case (SQLite's column names do): checked per edit, since a later
|
|
188
|
+
* `drop` cannot take back an `add` the migration runs first. A rename may change only the case of `from`.
|
|
189
|
+
*/
|
|
190
|
+
#assertNewName(name, edit, from) {
|
|
191
|
+
const folded = foldAscii(name);
|
|
192
|
+
for (const existing of Object.keys(this.#schemas)) {
|
|
193
|
+
if (existing !== from && foldAscii(existing) === folded) {
|
|
194
|
+
throw new Error(`${this.#what}: ${edit}: column "${existing}" exists (names differing only in case collide)`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
#assertColumn(name, edit) {
|
|
199
|
+
if (!Object.hasOwn(this.#schemas, name))
|
|
200
|
+
throw new Error(`${this.#what}: ${edit}: no column "${name}"`);
|
|
201
|
+
return this.#schemas[name];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** `name` with ASCII letters lowercased and nothing else changed, as SQLite folds identifiers. */
|
|
205
|
+
function foldAscii(name) {
|
|
206
|
+
return name.replace(/[A-Z]+/g, (letters) => letters.toLowerCase());
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=table-evolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-evolve.js","sourceRoot":"","sources":["../../src/store/table-evolve.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,mHAAmH;AACnH,uHAAuH;AACvH,oGAAoG;AAEpG,OAAO,EAAkB,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAkB,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAiB,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAIN,eAAe,EACf,YAAY,EACZ,eAAe,GAIf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAkB,UAAU,EAAE,YAAY,EAAc,MAAM,iBAAiB,CAAC;AAGvF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAqB,MAAM,YAAY,CAAC;AAkF1F;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAM1B,QAAkC,EAClC,IAAiC,EACjC,OAAO,GAAkB,EAAE;IAE3B,4FAA4F;IAC5F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,QAAsC,EAAE,OAAO,CAAC,CAAC;IAC3E,qGAAqG;IACrG,QAAQ,CAAC,MAAsC,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,eAAe,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,MAAM,EAA6F,CAAC;AACnH,CAAC;AAED;;;GAGG;AACH,MAAM,MAAM;IACF,SAAS,CAAkB;IAC3B,KAAK,CAAS;IACvB,QAAQ,CAAmC;IAC3C,IAAI,CAAW;IACN,QAAQ,CAAiC;I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CAAC,CAAC;AACpE,CAAC","sourcesContent":["// `evolveTable(previous, (t) => t…)` (slice 6a §9; decision \"Second spec review: the majority\"): the next version of a\n// table from the edits of one migration. The editor's types order the edits (`rename`, `add` and `json` before the\n// data step, `drop`, `index` and `dropIndex` after it) and track the columns and key through the chain; at runtime one\n// editor records the edits, checks each as it is made, and materializes the new version at the end.\n\nimport { type KindShape, opt } from \"../contracts/index.ts\";\nimport { editWith, type Increment } from \"../contracts/internal.ts\";\nimport { isOptional, type Optional } from \"../contracts/schema.ts\";\nimport type { ColumnSet } from \"./column-set.ts\";\nimport {\n\ttype ColumnSchema,\n\ttype Columns,\n\ttype ColumnTypeOf,\n\tcheckColumnName,\n\tcolumnRecord,\n\tdescribeColumns,\n\ttype OrderColumn,\n\ttype RowOf,\n\ttype ValueOf,\n} from \"./columns.ts\";\nimport { type Condition, compileSet, compileWhere, type SetOf } from \"./expression.ts\";\nimport type { HostColumnSchema } from \"./host-column.ts\";\nimport type { ColumnRefs } from \"./query.ts\";\nimport { INDEX_NAME, orderColumns, TableDefinition, type TableOptions } from \"./table.ts\";\nimport type { DataStep, TableEdit } from \"./table-history.ts\";\n\n/** The edits after the data step: `drop`, `index` and `dropIndex`; `C` and `K` are the columns and key so far. */\nexport interface TableTailEditor<C extends Columns, K extends readonly string[]> {\n\t/** Drops a non-key column; its indexes are dropped first, in the same commit. */\n\tdrop<N extends Exclude<keyof C & string, K[number]>>(name: N): TableTailEditor<Without<C, N>, K>;\n\t/** Adds an index (`[a-z0-9_]+`) over non-`opt` `str` or `int` columns; it ends with the key. */\n\tindex(name: string, columns: readonly OrderColumn<C>[]): TableTailEditor<C, K>;\n\t/** Drops an index. */\n\tdropIndex(name: string): TableTailEditor<C, K>;\n\t/** Type only: the columns and key so far. */\n\treadonly \"~columns\"?: C;\n\treadonly \"~key\"?: K;\n}\n\n/** The editor `evolveTable`'s edit gets: every edit; the column edits only before the data step. */\nexport interface TableEditor<C extends Columns, K extends readonly string[]> extends TableTailEditor<C, K> {\n\t/** Renames a column; the key, the indexes and a `json(...)` column's version column follow. */\n\trename<F extends keyof C & string, T extends string>(\n\t\tfrom: F,\n\t\tto: T,\n\t): TableEditor<Renamed<C, F, T>, RenamedKey<K, F, T>>;\n\t/** Adds a column: `opt(...)`, or a scalar one with a `default` (existing rows get it). */\n\tadd<N extends string, S extends AddedColumn>(name: N, column: S): TableEditor<With<C, N, S>, K>;\n\t/** A `json(...)` column's new version (its nullability kept): no DDL, no data step, cells migrate on access. */\n\tjson<N extends JsonNames<C>, S extends ColumnSchema>(name: N, column: S): TableEditor<WithJson<C, N, S>, K>;\n\t/**\n\t * The data step: `patch` gets each row as the columns stand here and returns new values of non-key columns (`{}`\n\t * stamps the row only); synchronous and pure, run in chunks of 100 in key order.\n\t */\n\trows(patch: (row: RowOf<C>) => PatchOf<C, K>): TableTailEditor<C, K>;\n\t/** The data step as one `updateWhere` over the rows not migrated yet. */\n\tupdate(step: {\n\t\treadonly where?: (row: ColumnRefs<C>) => Condition;\n\t\treadonly set: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>);\n\t}): TableTailEditor<C, K>;\n}\n\n/** What `evolveTable` takes besides the edits. */\nexport type EvolveOptions = {\n\t/** The column set the new version exposes: the previous version's when left out, none for `\"none\"`. */\n\treadonly exposes?: ColumnSet | \"none\";\n};\n\n/** A column `add` takes: `opt(...)` or one with a `default`. */\nexport type AddedColumn = ColumnSchema & (Optional | { readonly default: unknown });\n\n/** A `rows` patch: new values of non-key columns; `undefined` clears an `opt(...)` one. */\nexport type PatchOf<C extends Columns, K extends readonly string[]> = {\n\treadonly [P in Exclude<keyof C & string, K[number]>]?: ValueOf<C[P]>;\n};\n\ntype Renamed<C extends Columns, F extends keyof C, T extends string> = {\n\treadonly [P in keyof C as P extends F ? T : P]: C[P];\n};\n\ntype RenamedKey<K extends readonly string[], F, T extends string> = {\n\treadonly [I in keyof K]: K[I] extends F ? T : K[I];\n};\n\ntype With<C extends Columns, N extends string, S extends ColumnSchema> = {\n\treadonly [P in keyof C | N]: P extends N ? S : C[P & keyof C];\n};\n\ntype Without<C extends Columns, N extends keyof C> = { readonly [P in Exclude<keyof C, N>]: C[P] };\n\ntype JsonNames<C extends Columns> = { [P in keyof C]: ColumnTypeOf<C[P]> extends \"json\" ? P : never }[keyof C] & string;\n\ntype WithJson<C extends Columns, N extends keyof C & string, S extends ColumnSchema> = With<\n\tC,\n\tN,\n\tC[N] extends Optional ? Optional<Exclude<S, Optional | HostColumnSchema<KindShape>>> : S\n>;\n\n/** `V + 1` for a literal version (contracts' `Increment<N>`); `number` stays `number`. */\ntype Next<V extends number> = number extends V\n\t? number\n\t: `${Increment<`${V}`>}` extends `${infer N extends number}`\n\t\t? N\n\t\t: number;\n\n/**\n * Appends the next version (`previous.version + 1`) with the edits `edit` makes; `edit` must return the editor it was\n * given. Every version is materialized and fingerprinted here; the object serves the newest, and its activation\n * migrates a store at an older version through each one.\n */\nexport function evolveTable<\n\tC extends Columns,\n\tK extends readonly string[],\n\tV extends number,\n\tE extends { readonly \"~columns\"?: Columns; readonly \"~key\"?: readonly string[] },\n>(\n\tprevious: TableDefinition<C, K, V>,\n\tedit: (t: TableEditor<C, K>) => E,\n\toptions: EvolveOptions = {},\n): TableDefinition<NonNullable<E[\"~columns\"]>, NonNullable<E[\"~key\"]>, Next<V>> {\n\t// The runtime editor works on untyped definitions; the types live in the editor interfaces.\n\tconst editor = new Editor(previous as unknown as TableDefinition, options);\n\t// The editor interfaces track the edits in the types; at runtime every edit returns the same editor.\n\teditWith(editor as unknown as TableEditor<C, K>, edit, `${previous.name}: evolveTable`);\n\treturn editor.finish() as unknown as TableDefinition<NonNullable<E[\"~columns\"]>, NonNullable<E[\"~key\"]>, Next<V>>;\n}\n\n/**\n * The editor at runtime: the columns, key and indexes as the edits leave them, the edits before and after the data\n * step, and the step. Each edit is checked as it is made (declaration policy: JavaScript callers reach the checks).\n */\nclass Editor {\n\treadonly #previous: TableDefinition;\n\treadonly #what: string;\n\t#schemas: { [name: string]: ColumnSchema };\n\t#key: string[];\n\treadonly #indexes: Map<string, readonly string[]>;\n\t/** `before` until the data step or the first `drop`, `index` or `dropIndex`. */\n\t#phase: \"before\" | \"after\" = \"before\";\n\treadonly #before: TableEdit[] = [];\n\t#step: DataStep | undefined;\n\treadonly #after: TableEdit[] = [];\n\t/** The set the finished version exposes; the versions a data step reads expose none. */\n\treadonly #exposes: ColumnSet | undefined;\n\n\tconstructor(previous: TableDefinition, options: EvolveOptions) {\n\t\tthis.#previous = previous;\n\t\tthis.#exposes = options.exposes === \"none\" ? undefined : (options.exposes ?? previous.exposes);\n\t\tthis.#what = `${previous.name} version ${previous.version + 1}`;\n\t\tthis.#schemas = { ...previous.schemas };\n\t\tthis.#key = [...previous.key];\n\t\tthis.#indexes = new Map(previous.indexes);\n\t}\n\n\trename(from: string, to: string): this {\n\t\tthis.#assertBefore(\"rename\");\n\t\tthis.#assertColumn(from, \"rename\");\n\t\t// Checked here, not by the final definition: a later edit may rename it again, but this one runs as DDL.\n\t\tcheckColumnName(to, `${this.#what}: rename`);\n\t\tthis.#assertNewName(to, \"rename\", from);\n\t\tconst rename = (column: string): string => (column === from ? to : column);\n\t\tthis.#schemas = Object.fromEntries(Object.entries(this.#schemas).map(([name, schema]) => [rename(name), schema]));\n\t\tthis.#key = this.#key.map(rename);\n\t\tfor (const [name, columns] of this.#indexes) this.#indexes.set(name, columns.map(rename));\n\t\tthis.#before.push({ kind: \"rename\", from, to });\n\t\treturn this;\n\t}\n\n\tadd(name: string, column: ColumnSchema): this {\n\t\tthis.#assertBefore(\"add\");\n\t\tthis.#assertNewName(name, \"add\");\n\t\tconst [described] = describeColumns({ [name]: column }, `${this.#what}: add`);\n\t\tif (!described!.optional && (described!.type === \"json\" || described!.default === undefined)) {\n\t\t\tthrow new Error(`${this.#what}: add: column \"${name}\" needs opt(...) or a default (existing rows get it)`);\n\t\t}\n\t\tthis.#schemas[name] = column;\n\t\tthis.#before.push({ kind: \"add\", name, column: columnRecord(described!) });\n\t\treturn this;\n\t}\n\n\tjson(name: string, column: ColumnSchema): this {\n\t\tthis.#assertBefore(\"json\");\n\t\tconst existing = describeColumns({ [name]: this.#assertColumn(name, \"json\") }, this.#what)[0]!;\n\t\tif (existing.type !== \"json\") throw new Error(`${this.#what}: json: column \"${name}\" is not a json(...) column`);\n\t\tif (isOptional(column)) {\n\t\t\tthrow new Error(`${this.#what}: json: pass json(...) itself; the column keeps its nullability`);\n\t\t}\n\t\t// A host(...) column is no json(...) one: `describeColumns` below refuses it either way.\n\t\tconst schema: ColumnSchema = existing.optional\n\t\t\t? opt(column as Exclude<ColumnSchema, Optional | HostColumnSchema<KindShape>>)\n\t\t\t: column;\n\t\tconst described = describeColumns({ [name]: schema }, `${this.#what}: json`)[0]!;\n\t\tif (described.type !== \"json\") throw new Error(`${this.#what}: json: expected a json(...) column`);\n\t\tconst [before, after] = [existing.json, described.json];\n\t\t// D9 across table versions: a cell's version says which schema it was written with.\n\t\tif (after.version < before.version) {\n\t\t\tthrow new Error(`${this.#what}: json: column \"${name}\" goes back from version ${before.version}`);\n\t\t}\n\t\tif (after.version === before.version && after.fingerprint !== before.fingerprint) {\n\t\t\tthrow new Error(\n\t\t\t\t`${this.#what}: json: column \"${name}\" changes its schema at version ${before.version} (raise its version)`,\n\t\t\t);\n\t\t}\n\t\tthis.#schemas[name] = schema;\n\t\tthis.#before.push({ kind: \"json\", name, column: columnRecord(described) });\n\t\treturn this;\n\t}\n\n\trows(patch: (row: { readonly [column: string]: unknown }) => unknown): this {\n\t\tthis.#assertBefore(\"rows\");\n\t\tif (typeof patch !== \"function\") throw new Error(`${this.#what}: rows: expected a function`);\n\t\tthis.#step = { kind: \"rows\", table: this.#current(), patch };\n\t\tthis.#phase = \"after\";\n\t\treturn this;\n\t}\n\n\tupdate(step: { readonly where?: unknown; readonly set: unknown }): this {\n\t\tthis.#assertBefore(\"update\");\n\t\tconst table = this.#current();\n\t\tconst what = `version ${table.version} update`;\n\t\tconst where = typeof step.where === \"function\" ? step.where(table.refs) : step.where;\n\t\tconst set = typeof step.set === \"function\" ? step.set(table.refs) : step.set;\n\t\tthis.#step = {\n\t\t\tkind: \"update\",\n\t\t\ttable,\n\t\t\twhere: where === undefined ? undefined : compileWhere(table, where, what),\n\t\t\tset: compileSet(table, set, what),\n\t\t};\n\t\tthis.#phase = \"after\";\n\t\treturn this;\n\t}\n\n\tdrop(name: string): this {\n\t\tthis.#phase = \"after\";\n\t\tthis.#assertColumn(name, \"drop\");\n\t\tif (this.#key.includes(name)) throw new Error(`${this.#what}: drop: \"${name}\" is a key column`);\n\t\tfor (const [index, columns] of this.#indexes) {\n\t\t\tif (!columns.includes(name)) continue;\n\t\t\tthis.#indexes.delete(index);\n\t\t\tthis.#after.push({ kind: \"dropIndex\", name: index });\n\t\t}\n\t\tconst { [name]: _dropped, ...schemas } = this.#schemas;\n\t\tthis.#schemas = schemas;\n\t\tthis.#after.push({ kind: \"drop\", name });\n\t\treturn this;\n\t}\n\n\tindex(name: string, columns: readonly string[]): this {\n\t\tthis.#phase = \"after\";\n\t\tconst what = `${this.#what}: index \"${name}\"`;\n\t\tif (!INDEX_NAME.test(name)) throw new Error(`${what}: expected [a-z0-9_]+`);\n\t\tif (this.#indexes.has(name)) throw new Error(`${what} exists`);\n\t\t// Checked against the columns at this edit: the migration creates the index here, whatever later edits do.\n\t\tconst byName = new Map(describeColumns(this.#schemas, this.#what).map((column) => [column.name, column]));\n\t\tconst checked = orderColumns(byName, columns, what);\n\t\tthis.#indexes.set(name, checked);\n\t\tthis.#after.push({ kind: \"index\", name, columns: checked });\n\t\treturn this;\n\t}\n\n\tdropIndex(name: string): this {\n\t\tthis.#phase = \"after\";\n\t\tif (!this.#indexes.delete(name)) throw new Error(`${this.#what}: dropIndex: no index \"${name}\"`);\n\t\tthis.#after.push({ kind: \"dropIndex\", name });\n\t\treturn this;\n\t}\n\n\t/** The new version, materialized and fingerprinted, linked to the previous one and the migration from it. */\n\tfinish(): TableDefinition {\n\t\tconst migration = { before: this.#before, step: this.#step, after: this.#after };\n\t\tconst options = { ...this.#options(), ...(this.#exposes === undefined ? {} : { exposes: this.#exposes }) };\n\t\treturn new TableDefinition(this.#previous.name, options, { previous: this.#previous, migration });\n\t}\n\n\t/** The table as the edits so far leave it, at the new version: what a data step reads and writes. */\n\t#current(): TableDefinition {\n\t\treturn new TableDefinition(this.#previous.name, this.#options());\n\t}\n\n\t#options(): TableOptions<Columns, readonly never[]> {\n\t\tconst version = this.#previous.version + 1;\n\t\tconst options = {\n\t\t\tversion,\n\t\t\tcolumns: { ...this.#schemas },\n\t\t\tkey: [...this.#key],\n\t\t\tindexes: Object.fromEntries(this.#indexes),\n\t\t};\n\t\t// The key and indexes are names the edits kept; the constructor checks them as it checks a base's.\n\t\treturn options as unknown as TableOptions<Columns, readonly never[]>;\n\t}\n\n\t#assertBefore(edit: string): void {\n\t\tif (this.#phase === \"after\") {\n\t\t\tthrow new Error(`${this.#what}: ${edit} comes before the data step and before drop, index and dropIndex`);\n\t\t}\n\t}\n\n\t/**\n\t * `name` names no column yet, also ignoring ASCII case (SQLite's column names do): checked per edit, since a later\n\t * `drop` cannot take back an `add` the migration runs first. A rename may change only the case of `from`.\n\t */\n\t#assertNewName(name: string, edit: string, from?: string): void {\n\t\tconst folded = foldAscii(name);\n\t\tfor (const existing of Object.keys(this.#schemas)) {\n\t\t\tif (existing !== from && foldAscii(existing) === folded) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${this.#what}: ${edit}: column \"${existing}\" exists (names differing only in case collide)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#assertColumn(name: string, edit: string): ColumnSchema {\n\t\tif (!Object.hasOwn(this.#schemas, name)) throw new Error(`${this.#what}: ${edit}: no column \"${name}\"`);\n\t\treturn this.#schemas[name]!;\n\t}\n}\n\n/** `name` with ASCII letters lowercased and nothing else changed, as SQLite folds identifiers. */\nfunction foldAscii(name: string): string {\n\treturn name.replace(/[A-Z]+/g, (letters) => letters.toLowerCase());\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import { ChordError } from "../data/index.ts";
|
|
3
|
+
import type { SqliteValue } from "../sqlite/index.ts";
|
|
4
|
+
import type { Columns, RowOf } from "./columns.ts";
|
|
5
|
+
import type { Query } from "./query.ts";
|
|
6
|
+
import { TableSql } from "./sql.ts";
|
|
7
|
+
import type { ChordStore } from "./store.ts";
|
|
8
|
+
import type { KeyOf, TableDefinition } from "./table.ts";
|
|
9
|
+
/** One page of rows (`items`, as Durable's pages) and, when more follow, the cursor to continue after it. */
|
|
10
|
+
export type Page<T> = {
|
|
11
|
+
readonly items: T[];
|
|
12
|
+
readonly next?: string;
|
|
13
|
+
};
|
|
14
|
+
/** What `page` takes besides the query, the limit and the context. */
|
|
15
|
+
export type PageOptions = {
|
|
16
|
+
/** A cursor from an earlier page of the same order. */
|
|
17
|
+
readonly after?: string;
|
|
18
|
+
};
|
|
19
|
+
/** A table of this object: reads of committed state, the context last. Writes go through `self.tx`. */
|
|
20
|
+
export interface Table<C extends Columns, K extends readonly string[]> {
|
|
21
|
+
/** Up to `limit` rows of `q` (after `options.after`), and the cursor of the next page when there is one. */
|
|
22
|
+
page(q: Query<C, K>, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<C>>>;
|
|
23
|
+
/** Every row of `q`, read a page of 100 at a time. */
|
|
24
|
+
rows(q: Query<C, K>, context: Context): AsyncIterable<RowOf<C>>;
|
|
25
|
+
/** The row with `key`, `undefined` when absent. */
|
|
26
|
+
get(key: KeyOf<C, K>, context: Context): Promise<RowOf<C> | undefined>;
|
|
27
|
+
/** The number of rows of `q`. */
|
|
28
|
+
count(q: Query<C, K>, context: Context): Promise<number>;
|
|
29
|
+
}
|
|
30
|
+
/** The handle type of table definition `D`: what `self.table(D)` returns. */
|
|
31
|
+
export type TableOf<D> = D extends TableDefinition<infer C, infer K> ? Table<C, K> : never;
|
|
32
|
+
/**
|
|
33
|
+
* Who owns a table handle: its object (whose transactions alone write it), its liveness check and live failure.
|
|
34
|
+
*/
|
|
35
|
+
export type TableOwner = {
|
|
36
|
+
readonly label: string;
|
|
37
|
+
/** The object's documents: a transaction of another object refuses the handle. */
|
|
38
|
+
readonly scope: object;
|
|
39
|
+
/** Throws `released` once the object ended. */
|
|
40
|
+
assertLive(): void;
|
|
41
|
+
/** A row the code cannot read (a `json(...)` cell, slice 6a §9) fails the owner `broken` (§1.4). */
|
|
42
|
+
fail(error: ChordError): void;
|
|
43
|
+
};
|
|
44
|
+
/** The rows `rows()` reads per page (rule 17). */
|
|
45
|
+
export declare const ROWS_PAGE = 100;
|
|
46
|
+
/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */
|
|
47
|
+
export declare class TableHandle implements Table<Columns, readonly string[]> {
|
|
48
|
+
#private;
|
|
49
|
+
readonly definition: TableDefinition;
|
|
50
|
+
readonly sql: TableSql;
|
|
51
|
+
readonly store: ChordStore;
|
|
52
|
+
readonly owner: TableOwner;
|
|
53
|
+
constructor(definition: TableDefinition, sqlName: string, store: ChordStore, owner: TableOwner);
|
|
54
|
+
page(q: Query, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<Columns>>>;
|
|
55
|
+
rows(q: Query, context: Context): AsyncIterable<RowOf<Columns>>;
|
|
56
|
+
get(key: unknown, context: Context): Promise<RowOf<Columns> | undefined>;
|
|
57
|
+
count(q: Query, context: Context): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* The version fence of old table handles (R15): once the store's table is at a newer version than this handle's
|
|
60
|
+
* definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads
|
|
61
|
+
* and writes it no more (`released/version`), so it never issues SQL for a dropped column.
|
|
62
|
+
*/
|
|
63
|
+
assertVersion(): void;
|
|
64
|
+
/** A stored row as reads return it; one the code cannot read fails the owner and throws. */
|
|
65
|
+
decode(stored: {
|
|
66
|
+
readonly [column: string]: SqliteValue;
|
|
67
|
+
}, context: Context): RowOf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AC,KAAK,EAAE,UAAU,CAAC;IAE3B,YAAY,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAK7F;IAEK,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAI9G;IAEM,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAOrE;IAEK,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAS7E;IAEK,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAOvD;IAsBD;;;;OAIG;IACH,aAAa,IAAI,IAAI,CAMpB;IAED,4FAA4F;IAC5F,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAY3F;CACD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Table handles (slice 6a §6; decision "Query runner"): what `self.table(Def)` returns, one per attempt and table: reads
|
|
2
|
+
// of committed rows (`page`, `rows`, `get`, `count`) through the store's guarded reads, and what a transaction's
|
|
3
|
+
// writes to the table are staged with; a handle of an older version than the stored table is refused (R15, slice 7b).
|
|
4
|
+
import { ChordError } from "../data/index.js";
|
|
5
|
+
import { invalid } from "../data/internal.js";
|
|
6
|
+
import { readPage } from "./page.js";
|
|
7
|
+
import { ReadPlan } from "./read-plan.js";
|
|
8
|
+
import { TableSql } from "./sql.js";
|
|
9
|
+
/** The rows `rows()` reads per page (rule 17). */
|
|
10
|
+
export const ROWS_PAGE = 100;
|
|
11
|
+
/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */
|
|
12
|
+
export class TableHandle {
|
|
13
|
+
definition;
|
|
14
|
+
sql;
|
|
15
|
+
store;
|
|
16
|
+
owner;
|
|
17
|
+
constructor(definition, sqlName, store, owner) {
|
|
18
|
+
this.definition = definition;
|
|
19
|
+
this.sql = new TableSql(sqlName, definition.columns, definition.rows.physical, definition.key);
|
|
20
|
+
this.store = store;
|
|
21
|
+
this.owner = owner;
|
|
22
|
+
}
|
|
23
|
+
async page(q, limit, context, options = {}) {
|
|
24
|
+
const page = await readPage(this.store, this.#plan(q, "rows"), limit, options.after, context);
|
|
25
|
+
const items = page.stored.map((row) => this.decode(row, context));
|
|
26
|
+
return page.next === undefined ? { items } : { items, next: page.next };
|
|
27
|
+
}
|
|
28
|
+
async *rows(q, context) {
|
|
29
|
+
let after;
|
|
30
|
+
do {
|
|
31
|
+
const page = await this.page(q, ROWS_PAGE, context, after === undefined ? {} : { after });
|
|
32
|
+
yield* page.items;
|
|
33
|
+
after = page.next;
|
|
34
|
+
} while (after !== undefined);
|
|
35
|
+
}
|
|
36
|
+
async get(key, context) {
|
|
37
|
+
this.owner.assertLive();
|
|
38
|
+
this.assertVersion();
|
|
39
|
+
const encoded = this.definition.rows.key(key, "get");
|
|
40
|
+
const stored = await this.store.read((executor) => executor.get(this.sql.get, ...encoded.params), context);
|
|
41
|
+
return stored === undefined ? undefined : this.decode(stored, context);
|
|
42
|
+
}
|
|
43
|
+
async count(q, context) {
|
|
44
|
+
const statement = this.#plan(q, "count").count();
|
|
45
|
+
const row = await this.store.read((executor) => executor.get(statement.sql, ...statement.params), context);
|
|
46
|
+
return row?.count ?? 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The plan of a read of `q` through this handle, checked: the object is live, the handle's version is the store's,
|
|
50
|
+
* the query is of this table and joins nothing (a handle reads its own table's rows; a joined query is a named
|
|
51
|
+
* query's, which maps the pair). Its `exists` are compiled against the store's bindings.
|
|
52
|
+
*/
|
|
53
|
+
#plan(q, shape) {
|
|
54
|
+
this.owner.assertLive();
|
|
55
|
+
this.assertVersion();
|
|
56
|
+
if (q.table !== this.definition) {
|
|
57
|
+
throw invalid("args", `${this.owner.label}: a query of table "${q.table.name}" run on "${this.definition.name}"`);
|
|
58
|
+
}
|
|
59
|
+
if (q.joined !== undefined) {
|
|
60
|
+
throw invalid("args", `${this.owner.label}: a joined query is read as a named query, not through a table`);
|
|
61
|
+
}
|
|
62
|
+
return new ReadPlan(q, this.sql.table, {}, shape, this.store.reads);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The version fence of old table handles (R15): once the store's table is at a newer version than this handle's
|
|
66
|
+
* definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads
|
|
67
|
+
* and writes it no more (`released/version`), so it never issues SQL for a dropped column.
|
|
68
|
+
*/
|
|
69
|
+
assertVersion() {
|
|
70
|
+
const stored = this.store.tableVersion(this.sql.table);
|
|
71
|
+
if (stored === undefined || stored <= this.definition.version)
|
|
72
|
+
return;
|
|
73
|
+
const { name, version } = this.definition;
|
|
74
|
+
const message = `${this.owner.label}: table "${name}" of version ${version}; the store has version ${stored}`;
|
|
75
|
+
throw new ChordError({ code: "released", reason: "version", message });
|
|
76
|
+
}
|
|
77
|
+
/** A stored row as reads return it; one the code cannot read fails the owner and throws. */
|
|
78
|
+
decode(stored, context) {
|
|
79
|
+
try {
|
|
80
|
+
// The codec decodes by the definition's columns: a row of them.
|
|
81
|
+
return this.definition.rows.decode(stored, context);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const failure = error instanceof ChordError
|
|
85
|
+
? error
|
|
86
|
+
: new ChordError({ code: "unavailable", message: String(error) }, { cause: error });
|
|
87
|
+
this.owner.fail(failure);
|
|
88
|
+
throw failure;
|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C;IACrE,CAAC;IAED;;;;OAIG;IACH,aAAa;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE,OAAO;QACtE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QAC1C,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,YAAY,IAAI,gBAAgB,OAAO,2BAA2B,MAAM,EAAE,CAAC;QAC9G,MAAM,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,4FAA4F;IAC5F,MAAM,CAAC,MAAkD,EAAE,OAAgB;QAC1E,IAAI,CAAC;YACJ,gEAAgE;YAChE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAmB,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GACZ,KAAK,YAAY,UAAU;gBAC1B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACtF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,MAAM,OAAO,CAAC;QACf,CAAC;IACF,CAAC;CACD","sourcesContent":["// Table handles (slice 6a §6; decision \"Query runner\"): what `self.table(Def)` returns, one per attempt and table: reads\n// of committed rows (`page`, `rows`, `get`, `count`) through the store's guarded reads, and what a transaction's\n// writes to the table are staged with; a handle of an older version than the stored table is refused (R15, slice 7b).\n\nimport type { Context } from \"../context/index.ts\";\nimport { ChordError } from \"../data/index.ts\";\nimport { invalid } from \"../data/internal.ts\";\nimport type { SqliteValue } from \"../sqlite/index.ts\";\nimport type { Columns, RowOf } from \"./columns.ts\";\nimport { readPage } from \"./page.ts\";\nimport type { Query } from \"./query.ts\";\nimport { ReadPlan } from \"./read-plan.ts\";\nimport { TableSql } from \"./sql.ts\";\nimport type { ChordStore } from \"./store.ts\";\nimport type { KeyOf, TableDefinition } from \"./table.ts\";\n\n/** One page of rows (`items`, as Durable's pages) and, when more follow, the cursor to continue after it. */\nexport type Page<T> = { readonly items: T[]; readonly next?: string };\n\n/** What `page` takes besides the query, the limit and the context. */\nexport type PageOptions = {\n\t/** A cursor from an earlier page of the same order. */\n\treadonly after?: string;\n};\n\n/** A table of this object: reads of committed state, the context last. Writes go through `self.tx`. */\nexport interface Table<C extends Columns, K extends readonly string[]> {\n\t/** Up to `limit` rows of `q` (after `options.after`), and the cursor of the next page when there is one. */\n\tpage(q: Query<C, K>, limit: number, context: Context, options?: PageOptions): Promise<Page<RowOf<C>>>;\n\t/** Every row of `q`, read a page of 100 at a time. */\n\trows(q: Query<C, K>, context: Context): AsyncIterable<RowOf<C>>;\n\t/** The row with `key`, `undefined` when absent. */\n\tget(key: KeyOf<C, K>, context: Context): Promise<RowOf<C> | undefined>;\n\t/** The number of rows of `q`. */\n\tcount(q: Query<C, K>, context: Context): Promise<number>;\n}\n\n/** The handle type of table definition `D`: what `self.table(D)` returns. */\nexport type TableOf<D> = D extends TableDefinition<infer C, infer K> ? Table<C, K> : never;\n\n/**\n * Who owns a table handle: its object (whose transactions alone write it), its liveness check and live failure.\n */\nexport type TableOwner = {\n\treadonly label: string;\n\t/** The object's documents: a transaction of another object refuses the handle. */\n\treadonly scope: object;\n\t/** Throws `released` once the object ended. */\n\tassertLive(): void;\n\t/** A row the code cannot read (a `json(...)` cell, slice 6a §9) fails the owner `broken` (§1.4). */\n\tfail(error: ChordError): void;\n};\n\n/** The rows `rows()` reads per page (rule 17). */\nexport const ROWS_PAGE = 100;\n\n/** A table handle: the definition the attempt declared, the table's SQL name and statements, the store. */\nexport class TableHandle implements Table<Columns, readonly string[]> {\n\treadonly definition: TableDefinition;\n\treadonly sql: TableSql;\n\treadonly store: ChordStore;\n\treadonly owner: TableOwner;\n\n\tconstructor(definition: TableDefinition, sqlName: string, store: ChordStore, owner: TableOwner) {\n\t\tthis.definition = definition;\n\t\tthis.sql = new TableSql(sqlName, definition.columns, definition.rows.physical, definition.key);\n\t\tthis.store = store;\n\t\tthis.owner = owner;\n\t}\n\n\tasync page(q: Query, limit: number, context: Context, options: PageOptions = {}): Promise<Page<RowOf<Columns>>> {\n\t\tconst page = await readPage(this.store, this.#plan(q, \"rows\"), limit, options.after, context);\n\t\tconst items = page.stored.map((row) => this.decode(row, context));\n\t\treturn page.next === undefined ? { items } : { items, next: page.next };\n\t}\n\n\tasync *rows(q: Query, context: Context): AsyncIterable<RowOf<Columns>> {\n\t\tlet after: string | undefined;\n\t\tdo {\n\t\t\tconst page = await this.page(q, ROWS_PAGE, context, after === undefined ? {} : { after });\n\t\t\tyield* page.items;\n\t\t\tafter = page.next;\n\t\t} while (after !== undefined);\n\t}\n\n\tasync get(key: unknown, context: Context): Promise<RowOf<Columns> | undefined> {\n\t\tthis.owner.assertLive();\n\t\tthis.assertVersion();\n\t\tconst encoded = this.definition.rows.key(key, \"get\");\n\t\tconst stored = await this.store.read(\n\t\t\t(executor) => executor.get<{ [column: string]: SqliteValue }>(this.sql.get, ...encoded.params),\n\t\t\tcontext,\n\t\t);\n\t\treturn stored === undefined ? undefined : this.decode(stored, context);\n\t}\n\n\tasync count(q: Query, context: Context): Promise<number> {\n\t\tconst statement = this.#plan(q, \"count\").count();\n\t\tconst row = await this.store.read(\n\t\t\t(executor) => executor.get<{ readonly count: number }>(statement.sql, ...statement.params),\n\t\t\tcontext,\n\t\t);\n\t\treturn row?.count ?? 0;\n\t}\n\n\t/**\n\t * The plan of a read of `q` through this handle, checked: the object is live, the handle's version is the store's,\n\t * the query is of this table and joins nothing (a handle reads its own table's rows; a joined query is a named\n\t * query's, which maps the pair). Its `exists` are compiled against the store's bindings.\n\t */\n\t#plan(q: Query, shape: \"rows\" | \"count\"): ReadPlan {\n\t\tthis.owner.assertLive();\n\t\tthis.assertVersion();\n\t\tif (q.table !== this.definition) {\n\t\t\tthrow invalid(\n\t\t\t\t\"args\",\n\t\t\t\t`${this.owner.label}: a query of table \"${q.table.name}\" run on \"${this.definition.name}\"`,\n\t\t\t);\n\t\t}\n\t\tif (q.joined !== undefined) {\n\t\t\tthrow invalid(\"args\", `${this.owner.label}: a joined query is read as a named query, not through a table`);\n\t\t}\n\t\treturn new ReadPlan(q, this.sql.table, {}, shape, this.store.reads);\n\t}\n\n\t/**\n\t * The version fence of old table handles (R15): once the store's table is at a newer version than this handle's\n\t * definition (a reload's new code migrated it), old code still running (a call cut off at its restart's seal) reads\n\t * and writes it no more (`released/version`), so it never issues SQL for a dropped column.\n\t */\n\tassertVersion(): void {\n\t\tconst stored = this.store.tableVersion(this.sql.table);\n\t\tif (stored === undefined || stored <= this.definition.version) return;\n\t\tconst { name, version } = this.definition;\n\t\tconst message = `${this.owner.label}: table \"${name}\" of version ${version}; the store has version ${stored}`;\n\t\tthrow new ChordError({ code: \"released\", reason: \"version\", message });\n\t}\n\n\t/** A stored row as reads return it; one the code cannot read fails the owner and throws. */\n\tdecode(stored: { readonly [column: string]: SqliteValue }, context: Context): RowOf<Columns> {\n\t\ttry {\n\t\t\t// The codec decodes by the definition's columns: a row of them.\n\t\t\treturn this.definition.rows.decode(stored, context) as RowOf<Columns>;\n\t\t} catch (error) {\n\t\t\tconst failure =\n\t\t\t\terror instanceof ChordError\n\t\t\t\t\t? error\n\t\t\t\t\t: new ChordError({ code: \"unavailable\", message: String(error) }, { cause: error });\n\t\t\tthis.owner.fail(failure);\n\t\t\tthrow failure;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { TableRecord } from "./catalog.ts";
|
|
2
|
+
import type { ColumnRecord } from "./columns.ts";
|
|
3
|
+
import type { SetNode, WhereNode } from "./expression.ts";
|
|
4
|
+
import type { TableDefinition } from "./table.ts";
|
|
5
|
+
/** One edit of a migration as its writes record it (`alter`, `index`, `dropIndex`); the table is named when applied. */
|
|
6
|
+
export type TableEdit = {
|
|
7
|
+
readonly kind: "rename";
|
|
8
|
+
readonly from: string;
|
|
9
|
+
readonly to: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "add";
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly column: ColumnRecord;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "drop";
|
|
16
|
+
readonly name: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "json";
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly column: ColumnRecord;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "index";
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly columns: readonly string[];
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "dropIndex";
|
|
27
|
+
readonly name: string;
|
|
28
|
+
};
|
|
29
|
+
/** The column edits an `alter` write records. */
|
|
30
|
+
export type AlterEdit = Extract<TableEdit, {
|
|
31
|
+
readonly kind: "rename" | "add" | "drop" | "json";
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* A version's data step over `table`, the columns between the edits before it and after it: `rows` patches each row
|
|
35
|
+
* (synchronous and pure), `update` is one `updateWhere`.
|
|
36
|
+
*/
|
|
37
|
+
export type DataStep = {
|
|
38
|
+
readonly kind: "rows";
|
|
39
|
+
readonly table: TableDefinition;
|
|
40
|
+
readonly patch: (row: {
|
|
41
|
+
readonly [column: string]: unknown;
|
|
42
|
+
}) => unknown;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "update";
|
|
45
|
+
readonly table: TableDefinition;
|
|
46
|
+
readonly where: WhereNode | undefined;
|
|
47
|
+
readonly set: SetNode;
|
|
48
|
+
};
|
|
49
|
+
/** What one `evolveTable` changed: the edits before the data step, the step, the edits after it. */
|
|
50
|
+
export type Migration = {
|
|
51
|
+
readonly before: readonly TableEdit[];
|
|
52
|
+
readonly step: DataStep | undefined;
|
|
53
|
+
readonly after: readonly TableEdit[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* What an activation does with a declared table: create it at the newest version, use it as recorded, or migrate it
|
|
57
|
+
* through `versions` (oldest first), the first one from its start (`begin`) or, recorded `migrating`, after its (A)
|
|
58
|
+
* commit (`resume`).
|
|
59
|
+
*/
|
|
60
|
+
export type TablePlan = {
|
|
61
|
+
readonly kind: "create";
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "ready";
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "migrate";
|
|
66
|
+
readonly versions: readonly TableDefinition[];
|
|
67
|
+
readonly first: "begin" | "resume";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,
|
|
71
|
+
* older than the history's base, or the same version with another fingerprint (a history edited in place) throws:
|
|
72
|
+
* the object fails `broken`, the data stays.
|
|
73
|
+
*/
|
|
74
|
+
export declare function planTable(definition: TableDefinition, recorded: TableRecord | undefined, what: string): TablePlan;
|
|
75
|
+
/** Every version of `definition`'s history, the base first. */
|
|
76
|
+
/** The versions of `definition`'s history, oldest (its base) first. */
|
|
77
|
+
export declare function historyOf(definition: TableDefinition): TableDefinition[];
|
|
78
|
+
//# sourceMappingURL=table-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-history.d.ts","sourceRoot":"","sources":["../../src/store/table-history.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OA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defineTable` through each `evolveTable`, the migration each version recorded, and what an activation does with the
|
|
3
|
+
// version the store recorded: create the table, use it, migrate it from there, or refuse it.
|
|
4
|
+
/**
|
|
5
|
+
* The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,
|
|
6
|
+
* older than the history's base, or the same version with another fingerprint (a history edited in place) throws:
|
|
7
|
+
* the object fails `broken`, the data stays.
|
|
8
|
+
*/
|
|
9
|
+
export function planTable(definition, recorded, what) {
|
|
10
|
+
if (recorded === undefined)
|
|
11
|
+
return { kind: "create" };
|
|
12
|
+
const { version, state, fingerprint } = recorded;
|
|
13
|
+
if (version > definition.version) {
|
|
14
|
+
throw new Error(`${what}: the store has version ${version}, newer than the code's ${definition.version}`);
|
|
15
|
+
}
|
|
16
|
+
const versions = historyOf(definition);
|
|
17
|
+
const at = versions.find((each) => each.version === version);
|
|
18
|
+
if (at === undefined) {
|
|
19
|
+
throw new Error(`${what}: the store has version ${version}, older than the history's base ${versions[0].version}`);
|
|
20
|
+
}
|
|
21
|
+
if (at.fingerprint !== fingerprint) {
|
|
22
|
+
throw new Error(`${what}: version ${version} is recorded with another definition (a history edited in place)`);
|
|
23
|
+
}
|
|
24
|
+
if (state === "ready" && version === definition.version)
|
|
25
|
+
return { kind: "ready" };
|
|
26
|
+
if (state === "migrating" && at.evolution?.migration.step === undefined) {
|
|
27
|
+
throw new Error(`${what}: version ${version} is recorded migrating, but has no data step to resume`);
|
|
28
|
+
}
|
|
29
|
+
if (state === "migrating") {
|
|
30
|
+
return { kind: "migrate", versions: versions.filter((each) => each.version >= version), first: "resume" };
|
|
31
|
+
}
|
|
32
|
+
return { kind: "migrate", versions: versions.filter((each) => each.version > version), first: "begin" };
|
|
33
|
+
}
|
|
34
|
+
/** Every version of `definition`'s history, the base first. */
|
|
35
|
+
/** The versions of `definition`'s history, oldest (its base) first. */
|
|
36
|
+
export function historyOf(definition) {
|
|
37
|
+
const versions = [];
|
|
38
|
+
for (let at = definition; at !== undefined; at = at.evolution?.previous) {
|
|
39
|
+
versions.unshift(at);
|
|
40
|
+
}
|
|
41
|
+
return versions;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=table-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-history.js","sourceRoot":"","sources":["../../src/store/table-history.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,sHAAsH;AACtH,6FAA6F;AAyD7F;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,UAA2B,EAAE,QAAiC,EAAE,IAAY;IACrG,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACtD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IACjD,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,2BAA2B,OAAO,2BAA2B,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;IAC7D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACd,GAAG,IAAI,2BAA2B,OAAO,mCAAmC,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE,CAClG,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,aAAa,OAAO,kEAAkE,CAAC,CAAC;IAChH,CAAC;IACD,IAAI,KAAK,KAAK,OAAO,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAClF,IAAI,KAAK,KAAK,WAAW,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,aAAa,OAAO,wDAAwD,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,KAAK,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC3G,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACzG,CAAC;AAED,+DAA+D;AAC/D,uEAAuE;AACvE,MAAM,UAAU,SAAS,CAAC,UAA2B;IACpD,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,IAAI,EAAE,GAAgC,UAAU,EAAE,EAAE,KAAK,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["// A table's history (slice 6a §9; decision \"Second spec review: the majority\"): the versions from a base\n// `defineTable` through each `evolveTable`, the migration each version recorded, and what an activation does with the\n// version the store recorded: create the table, use it, migrate it from there, or refuse it.\n\nimport type { TableRecord } from \"./catalog.ts\";\nimport type { ColumnRecord } from \"./columns.ts\";\nimport type { SetNode, WhereNode } from \"./expression.ts\";\nimport type { TableDefinition } from \"./table.ts\";\n\n/** One edit of a migration as its writes record it (`alter`, `index`, `dropIndex`); the table is named when applied. */\nexport type TableEdit =\n\t| { readonly kind: \"rename\"; readonly from: string; readonly to: string }\n\t| { readonly kind: \"add\"; readonly name: string; readonly column: ColumnRecord }\n\t| { readonly kind: \"drop\"; readonly name: string }\n\t| { readonly kind: \"json\"; readonly name: string; readonly column: ColumnRecord }\n\t| { readonly kind: \"index\"; readonly name: string; readonly columns: readonly string[] }\n\t| { readonly kind: \"dropIndex\"; readonly name: string };\n\n/** The column edits an `alter` write records. */\nexport type AlterEdit = Extract<TableEdit, { readonly kind: \"rename\" | \"add\" | \"drop\" | \"json\" }>;\n\n/**\n * A version's data step over `table`, the columns between the edits before it and after it: `rows` patches each row\n * (synchronous and pure), `update` is one `updateWhere`.\n */\nexport type DataStep =\n\t| {\n\t\t\treadonly kind: \"rows\";\n\t\t\treadonly table: TableDefinition;\n\t\t\treadonly patch: (row: { readonly [column: string]: unknown }) => unknown;\n\t }\n\t| {\n\t\t\treadonly kind: \"update\";\n\t\t\treadonly table: TableDefinition;\n\t\t\treadonly where: WhereNode | undefined;\n\t\t\treadonly set: SetNode;\n\t };\n\n/** What one `evolveTable` changed: the edits before the data step, the step, the edits after it. */\nexport type Migration = {\n\treadonly before: readonly TableEdit[];\n\treadonly step: DataStep | undefined;\n\treadonly after: readonly TableEdit[];\n};\n\n/**\n * What an activation does with a declared table: create it at the newest version, use it as recorded, or migrate it\n * through `versions` (oldest first), the first one from its start (`begin`) or, recorded `migrating`, after its (A)\n * commit (`resume`).\n */\nexport type TablePlan =\n\t| { readonly kind: \"create\" }\n\t| { readonly kind: \"ready\" }\n\t| {\n\t\t\treadonly kind: \"migrate\";\n\t\t\treadonly versions: readonly TableDefinition[];\n\t\t\treadonly first: \"begin\" | \"resume\";\n\t };\n\n/**\n * The plan for `definition` (the code's newest version) against `recorded`. A recorded version newer than the newest,\n * older than the history's base, or the same version with another fingerprint (a history edited in place) throws:\n * the object fails `broken`, the data stays.\n */\nexport function planTable(definition: TableDefinition, recorded: TableRecord | undefined, what: string): TablePlan {\n\tif (recorded === undefined) return { kind: \"create\" };\n\tconst { version, state, fingerprint } = recorded;\n\tif (version > definition.version) {\n\t\tthrow new Error(`${what}: the store has version ${version}, newer than the code's ${definition.version}`);\n\t}\n\tconst versions = historyOf(definition);\n\tconst at = versions.find((each) => each.version === version);\n\tif (at === undefined) {\n\t\tthrow new Error(\n\t\t\t`${what}: the store has version ${version}, older than the history's base ${versions[0]!.version}`,\n\t\t);\n\t}\n\tif (at.fingerprint !== fingerprint) {\n\t\tthrow new Error(`${what}: version ${version} is recorded with another definition (a history edited in place)`);\n\t}\n\tif (state === \"ready\" && version === definition.version) return { kind: \"ready\" };\n\tif (state === \"migrating\" && at.evolution?.migration.step === undefined) {\n\t\tthrow new Error(`${what}: version ${version} is recorded migrating, but has no data step to resume`);\n\t}\n\tif (state === \"migrating\") {\n\t\treturn { kind: \"migrate\", versions: versions.filter((each) => each.version >= version), first: \"resume\" };\n\t}\n\treturn { kind: \"migrate\", versions: versions.filter((each) => each.version > version), first: \"begin\" };\n}\n\n/** Every version of `definition`'s history, the base first. */\n/** The versions of `definition`'s history, oldest (its base) first. */\nexport function historyOf(definition: TableDefinition): TableDefinition[] {\n\tconst versions: TableDefinition[] = [];\n\tfor (let at: TableDefinition | undefined = definition; at !== undefined; at = at.evolution?.previous) {\n\t\tversions.unshift(at);\n\t}\n\treturn versions;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Context } from "../context/index.ts";
|
|
2
|
+
import type { SetNode } from "./expression.ts";
|
|
3
|
+
import type { ChordStore, CommitFence } from "./store.ts";
|
|
4
|
+
import type { TableDefinition } from "./table.ts";
|
|
5
|
+
import { type DataStep } from "./table-history.ts";
|
|
6
|
+
/** A declared table: its newest definition and its SQL name. */
|
|
7
|
+
export type DeclaredTable = {
|
|
8
|
+
readonly definition: TableDefinition;
|
|
9
|
+
readonly table: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Brings `tables` to their definitions: the ones the store does not have created in one commit, then each older one
|
|
13
|
+
* migrated. A table the code cannot use (see `planTable`) throws before anything is written; `what` names the owner.
|
|
14
|
+
*/
|
|
15
|
+
export declare function prepareTables(tables: readonly DeclaredTable[], store: ChordStore, fence: CommitFence, what: string, context: Context): Promise<void>;
|
|
16
|
+
/** The size of a `rows` chunk: one commit each. */
|
|
17
|
+
export declare const MIGRATION_CHUNK = 100;
|
|
18
|
+
/**
|
|
19
|
+
* The `set` of `step`'s patch of one decoded row (of the step's table) at version `v`: the patch run, its result
|
|
20
|
+
* checked (an object of non-key columns of the version, values of their types). Throws for a patch the version cannot
|
|
21
|
+
* take. Shared by the eager migration and the migration of imported rows (`host-data.ts`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function patchSet(step: Extract<DataStep, {
|
|
24
|
+
readonly kind: "rows";
|
|
25
|
+
}>, row: {
|
|
26
|
+
readonly [column: string]: unknown;
|
|
27
|
+
}, v: number): SetNode;
|
|
28
|
+
//# sourceMappingURL=table-migration.d.ts.map
|