@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,290 @@
|
|
|
1
|
+
// The documents engine (S13, slice 6a §8, slice 6b §1.5): one record per incarnation of an address, revisions made of
|
|
2
|
+
// bases and deltas, a history rule per record (R1); its writes inside the commit step, checked by the writes
|
|
3
|
+
// themselves (the partial unique index on the live address, the counted conditional `UPDATE` on the record's
|
|
4
|
+
// revision), and its reads, of the current state or at a point.
|
|
5
|
+
import { apply } from "../delta/index.js";
|
|
6
|
+
import { TABLES } from "./schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* Stages the creation of a Chord document at `address` (with `host` when it belongs to a host) with `base`; its id is
|
|
9
|
+
* taken from the allocator when it applies (a saturated allocator refuses the commit) and handed to `created` (its
|
|
10
|
+
* owner adopts it after `COMMIT`). `text` is the base's value serialized before the queue (rule 8).
|
|
11
|
+
*/
|
|
12
|
+
export function createDocument(address, base, text, created) {
|
|
13
|
+
return {
|
|
14
|
+
order: "create",
|
|
15
|
+
apply: async (step) => {
|
|
16
|
+
const id = step.ids.mint();
|
|
17
|
+
step.created.push(id);
|
|
18
|
+
created?.(id);
|
|
19
|
+
const { version, fingerprint } = base;
|
|
20
|
+
const record = {
|
|
21
|
+
id,
|
|
22
|
+
...address,
|
|
23
|
+
history: "none",
|
|
24
|
+
createdAt: step.seq,
|
|
25
|
+
revision: 1,
|
|
26
|
+
version,
|
|
27
|
+
fingerprint,
|
|
28
|
+
};
|
|
29
|
+
await insertDocument(step, record, text);
|
|
30
|
+
return [{ kind: "document.create", record, base }];
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Inserts `record` as it is (id, seqs and revision kept: a creation, an import, a batch), with its base at `createdAt`
|
|
36
|
+
* when `text` (the base's value serialized) is given; a record created retired (an empty lifetime) keeps what its
|
|
37
|
+
* history keeps.
|
|
38
|
+
*/
|
|
39
|
+
export async function insertDocument(step, record, text) {
|
|
40
|
+
const { id, namespace, owner, kind, key, history, createdAt, retiredAt, meta, host, revision, version, fingerprint, } = record;
|
|
41
|
+
await step.run(`INSERT INTO ${TABLES.documents}
|
|
42
|
+
(id, owner, namespace, kind, key, history, created_at, retired_at, meta, host, revision, version, fingerprint)
|
|
43
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, id, owner, namespace, kind, key ?? "", history, createdAt, retiredAt ?? null, meta ?? null, host ?? null, revision, version, fingerprint);
|
|
44
|
+
if (text !== undefined)
|
|
45
|
+
await insertRevision(step, id, createdAt, "base", version, text);
|
|
46
|
+
if (retiredAt !== undefined)
|
|
47
|
+
await dropRetired(step, id, history);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Stages a change of Chord document `id` prepared on `revision`: a delta on the current base's version, or a new base.
|
|
51
|
+
* `text` is the content serialized before the queue.
|
|
52
|
+
*/
|
|
53
|
+
export function changeDocument(id, revision, content, text) {
|
|
54
|
+
const write = { kind: "document.change", id, revision, content };
|
|
55
|
+
return {
|
|
56
|
+
order: "write",
|
|
57
|
+
apply: async (step) => {
|
|
58
|
+
await writeContent(step, id, "none", revision, content, text);
|
|
59
|
+
return [write];
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Writes `content` to document `id` (of `history`) prepared on `revision`, in the step's seq: its revision, the
|
|
65
|
+
* counted conditional `UPDATE` (a delta only on the base's version), and at a new base the older revisions a
|
|
66
|
+
* `none` or `latest` record drops. A record that is not live at `revision` throws (memory and disk disagree).
|
|
67
|
+
*/
|
|
68
|
+
export async function writeContent(step, id, history, revision, content, text) {
|
|
69
|
+
// As ids: a revision past the safe range would stop counting exactly.
|
|
70
|
+
if (revision >= Number.MAX_SAFE_INTEGER)
|
|
71
|
+
throw new Error(`document ${id}: no revision past the safe range`);
|
|
72
|
+
await insertRevision(step, id, step.seq, content.kind, content.version, text);
|
|
73
|
+
const changed = content.kind === "delta"
|
|
74
|
+
? await step.runCounted(`UPDATE ${TABLES.documents} SET revision = revision + 1
|
|
75
|
+
WHERE id = ? AND revision = ? AND version = ? AND retired_at IS NULL`, id, revision, content.version)
|
|
76
|
+
: await step.runCounted(`UPDATE ${TABLES.documents} SET revision = revision + 1, version = ?, fingerprint = ?
|
|
77
|
+
WHERE id = ? AND revision = ? AND retired_at IS NULL`, content.version, content.fingerprint, id, revision);
|
|
78
|
+
if (changed !== 1)
|
|
79
|
+
throw new Error(`document ${id}: not live at revision ${revision}`);
|
|
80
|
+
if (content.kind === "base" && history !== "rewindable") {
|
|
81
|
+
await step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ? AND seq < ?`, id, step.seq);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Stages the retirement of Chord document `id` (history `none`) at `revision`: its row and its revisions go. */
|
|
85
|
+
export function retireDocument(id, revision) {
|
|
86
|
+
const write = { kind: "document.retire", id, revision };
|
|
87
|
+
return {
|
|
88
|
+
order: "retire",
|
|
89
|
+
apply: async (step) => {
|
|
90
|
+
// A Chord document keeps no history (`none`): its row goes with a conditional, counted DELETE (6a's).
|
|
91
|
+
const deleted = await step.runCounted(`DELETE FROM ${TABLES.documents} WHERE id = ? AND revision = ? AND retired_at IS NULL`, id, revision);
|
|
92
|
+
if (deleted !== 1)
|
|
93
|
+
throw new Error(`document ${id}: not live at revision ${revision}`);
|
|
94
|
+
await step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ?`, id);
|
|
95
|
+
return [write];
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Retires live `record` in the step's seq by its history (R1): a `none` record's row and revisions go, a `latest` one
|
|
101
|
+
* keeps its row with `retired_at` and drops its revisions, a `rewindable` one keeps everything.
|
|
102
|
+
*/
|
|
103
|
+
export async function retireRecord(step, record) {
|
|
104
|
+
const { id, history } = record;
|
|
105
|
+
if (history !== "none")
|
|
106
|
+
await step.run(`UPDATE ${TABLES.documents} SET retired_at = ? WHERE id = ?`, step.seq, id);
|
|
107
|
+
await dropRetired(step, id, history);
|
|
108
|
+
}
|
|
109
|
+
/** What a retired record of `history` drops: a `none` row too, every revision unless `rewindable`. */
|
|
110
|
+
async function dropRetired(step, id, history) {
|
|
111
|
+
if (history === "rewindable")
|
|
112
|
+
return;
|
|
113
|
+
if (history === "none")
|
|
114
|
+
await step.run(`DELETE FROM ${TABLES.documents} WHERE id = ?`, id);
|
|
115
|
+
await step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ?`, id);
|
|
116
|
+
}
|
|
117
|
+
/** Inserts one revision of document `id` at `seq`, `text` its serialized content. */
|
|
118
|
+
export function insertRevision(step, id, seq, kind, version, text) {
|
|
119
|
+
return step.run(`INSERT INTO ${TABLES.revisions} (document_id, seq, kind, version, content) VALUES (?, ?, ?, ?, ?)`, id, seq, kind, version, text);
|
|
120
|
+
}
|
|
121
|
+
const RECORD_COLUMNS = "id, owner, namespace, kind, key, history, created_at, retired_at, meta, host, revision, version, fingerprint";
|
|
122
|
+
const READ = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE id = ?`;
|
|
123
|
+
/** The record with `id`, live or retired, if there is one. */
|
|
124
|
+
export async function readDocument(executor, id) {
|
|
125
|
+
const row = await executor.get(READ, id);
|
|
126
|
+
return row === undefined ? undefined : recordOf(row);
|
|
127
|
+
}
|
|
128
|
+
const FIND_CURRENT = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents}
|
|
129
|
+
WHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND retired_at IS NULL`;
|
|
130
|
+
const FIND_AT = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents}
|
|
131
|
+
WHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?)
|
|
132
|
+
ORDER BY created_at DESC LIMIT 1`;
|
|
133
|
+
/** The record at `address` live at `at` (the half-open lifetime `createdAt <= at < retiredAt`), if any. */
|
|
134
|
+
export async function findDocument(executor, address, at = "current") {
|
|
135
|
+
const { owner, namespace, kind } = address;
|
|
136
|
+
const key = address.key ?? "";
|
|
137
|
+
const row = at === "current"
|
|
138
|
+
? await executor.get(FIND_CURRENT, owner, namespace, kind, key)
|
|
139
|
+
: await executor.get(FIND_AT, owner, namespace, kind, key, at, at);
|
|
140
|
+
return row === undefined ? undefined : recordOf(row);
|
|
141
|
+
}
|
|
142
|
+
const READ_ENTRY = `SELECT meta, retired_at, owner, namespace, history FROM ${TABLES.documents} WHERE id = ?`;
|
|
143
|
+
/** The entry of the record with `id`, live or retired, with its owner, namespace and history; `undefined` if none. */
|
|
144
|
+
export function readDocumentEntry(executor, id) {
|
|
145
|
+
return executor.get(READ_ENTRY, id);
|
|
146
|
+
}
|
|
147
|
+
const FIND_ENTRY_CURRENT = `SELECT meta FROM ${TABLES.documents}
|
|
148
|
+
WHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND retired_at IS NULL`;
|
|
149
|
+
const FIND_ENTRY_AT = `SELECT meta, retired_at FROM ${TABLES.documents}
|
|
150
|
+
WHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?)
|
|
151
|
+
ORDER BY created_at DESC LIMIT 1`;
|
|
152
|
+
/** `findDocument` reading only what an adapter keeping its fields in `meta` needs (fewer columns, no record built). */
|
|
153
|
+
export function findDocumentEntry(executor, address, at) {
|
|
154
|
+
const { owner, namespace, kind } = address;
|
|
155
|
+
const key = address.key ?? "";
|
|
156
|
+
return at === "current"
|
|
157
|
+
? executor.get(FIND_ENTRY_CURRENT, owner, namespace, kind, key)
|
|
158
|
+
: executor.get(FIND_ENTRY_AT, owner, namespace, kind, key, at, at);
|
|
159
|
+
}
|
|
160
|
+
const LOAD = `SELECT seq, kind, version, content FROM ${TABLES.revisions} WHERE document_id = ? AND seq <= ? AND seq >= (
|
|
161
|
+
SELECT max(seq) FROM ${TABLES.revisions} WHERE document_id = ? AND kind = 'base' AND seq <= ?) ORDER BY seq`;
|
|
162
|
+
/**
|
|
163
|
+
* Loads `record` at `at`: its newest base at or below it and the deltas after that base up to it, applied once; the
|
|
164
|
+
* version is the base's. A record without such a base (one that keeps no history from there) throws.
|
|
165
|
+
*/
|
|
166
|
+
export async function loadDocument(executor, record, at = "current") {
|
|
167
|
+
return { record, ...(await loadContent(executor, record.id, at)) };
|
|
168
|
+
}
|
|
169
|
+
/** `loadDocument`'s content of document `id` at `at`, without its record (an adapter reads the fields it keeps). */
|
|
170
|
+
export async function loadContent(executor, id, at) {
|
|
171
|
+
const upper = at === "current" ? Number.MAX_SAFE_INTEGER : at;
|
|
172
|
+
const revisions = await executor.all(LOAD, id, upper, id, upper);
|
|
173
|
+
const [base, ...deltas] = revisions;
|
|
174
|
+
if (base === undefined || base.kind !== "base")
|
|
175
|
+
throw new Error(`document ${id}: no base`);
|
|
176
|
+
let value = JSON.parse(base.content);
|
|
177
|
+
for (const delta of deltas) {
|
|
178
|
+
if (delta.version !== base.version)
|
|
179
|
+
throw new Error(`document ${id}: a delta crosses a version`);
|
|
180
|
+
value = apply(value, JSON.parse(delta.content));
|
|
181
|
+
}
|
|
182
|
+
return { value, version: base.version, deltasSinceBase: deltas.length };
|
|
183
|
+
}
|
|
184
|
+
/** Up to `limit` keys of live documents of `kind` under `owner` after `after` (from the first), in code point order. */
|
|
185
|
+
export async function listDocumentKeys(executor, address, after, limit) {
|
|
186
|
+
// The first page has no lower bound: `""` is a key too.
|
|
187
|
+
const from = after === undefined ? "" : " AND key > ?";
|
|
188
|
+
const rows = await executor.all(`SELECT key FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND kind = ?${from}
|
|
189
|
+
AND retired_at IS NULL ORDER BY key LIMIT ?`, address.owner, address.namespace, address.kind, ...(after === undefined ? [] : [after]), limit);
|
|
190
|
+
return rows.map(({ key }) => key);
|
|
191
|
+
}
|
|
192
|
+
/** The statements of `listDocuments`, by its shape: with a kind or not, current or at a point. */
|
|
193
|
+
const LIST = (() => {
|
|
194
|
+
const from = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND id > ?`;
|
|
195
|
+
const current = " AND retired_at IS NULL ORDER BY id LIMIT ?";
|
|
196
|
+
const at = " AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?) ORDER BY id LIMIT ?";
|
|
197
|
+
return {
|
|
198
|
+
current: `${from}${current}`,
|
|
199
|
+
at: `${from}${at}`,
|
|
200
|
+
kindCurrent: `${from} AND kind = ?${current}`,
|
|
201
|
+
kindAt: `${from} AND kind = ?${at}`,
|
|
202
|
+
};
|
|
203
|
+
})();
|
|
204
|
+
/** Up to `limit` records of `scope` live at `at` with ids above `after`, by id. */
|
|
205
|
+
export async function listDocuments(executor, scope, at, after, limit) {
|
|
206
|
+
const { owner, namespace, kind } = scope;
|
|
207
|
+
let rows;
|
|
208
|
+
if (kind === undefined) {
|
|
209
|
+
rows =
|
|
210
|
+
at === "current"
|
|
211
|
+
? await executor.all(LIST.current, owner, namespace, after, limit)
|
|
212
|
+
: await executor.all(LIST.at, owner, namespace, after, at, at, limit);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
rows =
|
|
216
|
+
at === "current"
|
|
217
|
+
? await executor.all(LIST.kindCurrent, owner, namespace, after, kind, limit)
|
|
218
|
+
: await executor.all(LIST.kindAt, owner, namespace, after, kind, at, at, limit);
|
|
219
|
+
}
|
|
220
|
+
return rows.map(recordOf);
|
|
221
|
+
}
|
|
222
|
+
/** The statements of `listDocumentEntries`, by shape, as `LIST`'s. */
|
|
223
|
+
const LIST_ENTRIES = (() => {
|
|
224
|
+
const from = (columns) => `SELECT ${columns} FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND id > ?`;
|
|
225
|
+
const current = " AND retired_at IS NULL ORDER BY id LIMIT ?";
|
|
226
|
+
const at = " AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?) ORDER BY id LIMIT ?";
|
|
227
|
+
return {
|
|
228
|
+
current: `${from("meta")}${current}`,
|
|
229
|
+
at: `${from("meta, retired_at")}${at}`,
|
|
230
|
+
kindCurrent: `${from("meta")} AND kind = ?${current}`,
|
|
231
|
+
kindAt: `${from("meta, retired_at")} AND kind = ?${at}`,
|
|
232
|
+
};
|
|
233
|
+
})();
|
|
234
|
+
/** `listDocuments` reading only what an adapter keeping its fields in `meta` needs. */
|
|
235
|
+
export function listDocumentEntries(executor, scope, at, after, limit) {
|
|
236
|
+
const { owner, namespace, kind } = scope;
|
|
237
|
+
if (kind === undefined) {
|
|
238
|
+
return at === "current"
|
|
239
|
+
? executor.all(LIST_ENTRIES.current, owner, namespace, after, limit)
|
|
240
|
+
: executor.all(LIST_ENTRIES.at, owner, namespace, after, at, at, limit);
|
|
241
|
+
}
|
|
242
|
+
return at === "current"
|
|
243
|
+
? executor.all(LIST_ENTRIES.kindCurrent, owner, namespace, after, kind, limit)
|
|
244
|
+
: executor.all(LIST_ENTRIES.kindAt, owner, namespace, after, kind, at, at, limit);
|
|
245
|
+
}
|
|
246
|
+
/** Up to `limit` stored records, live and retired, with ids above `after`, by id (an export's pages). */
|
|
247
|
+
export async function listRecords(executor, after, limit) {
|
|
248
|
+
const rows = await executor.all(`SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE id > ? ORDER BY id LIMIT ?`, after, limit);
|
|
249
|
+
return rows.map(recordOf);
|
|
250
|
+
}
|
|
251
|
+
/** Up to `limit` live records belonging to the host with address key `host`, with ids above `after`, by id. */
|
|
252
|
+
export async function listHostRecords(executor, host, after, limit) {
|
|
253
|
+
const rows = await executor.all(`SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE host = ? AND id > ? AND retired_at IS NULL
|
|
254
|
+
ORDER BY id LIMIT ?`, host, after, limit);
|
|
255
|
+
return rows.map(recordOf);
|
|
256
|
+
}
|
|
257
|
+
/** Up to `limit` stored revisions of document `id` after seq `after`, in seq order (an export's page). */
|
|
258
|
+
export async function listRevisions(executor, id, after, limit) {
|
|
259
|
+
const rows = await executor.all(`SELECT seq, kind, version, content FROM ${TABLES.revisions} WHERE document_id = ? AND seq > ? ORDER BY seq LIMIT ?`, id, after, limit);
|
|
260
|
+
return rows.map(({ seq, kind, version, content }) => {
|
|
261
|
+
// Written by `insertRevision`: a base's value or a delta's ops, as JSON.
|
|
262
|
+
const parsed = JSON.parse(content);
|
|
263
|
+
return {
|
|
264
|
+
id,
|
|
265
|
+
seq,
|
|
266
|
+
content: kind === "base"
|
|
267
|
+
? { kind, version, value: parsed }
|
|
268
|
+
: { kind, version, ops: parsed },
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function recordOf(row) {
|
|
273
|
+
const { id, namespace, owner, kind, key, history, created_at, retired_at, meta, host, revision, version, fingerprint, } = row;
|
|
274
|
+
return {
|
|
275
|
+
id,
|
|
276
|
+
owner,
|
|
277
|
+
namespace,
|
|
278
|
+
kind,
|
|
279
|
+
...(key === "" ? {} : { key }),
|
|
280
|
+
history,
|
|
281
|
+
createdAt: created_at,
|
|
282
|
+
...(retired_at === null ? {} : { retiredAt: retired_at }),
|
|
283
|
+
...(meta === null ? {} : { meta }),
|
|
284
|
+
...(host === null ? {} : { host }),
|
|
285
|
+
revision,
|
|
286
|
+
version,
|
|
287
|
+
fingerprint,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/store/engine.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,6GAA6G;AAC7G,6GAA6G;AAC7G,gEAAgE;AAEhE,OAAO,EAAE,KAAK,EAAW,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqFrC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,OAAqD,EACrD,IAAkB,EAClB,IAAY,EACZ,OAA8B;IAE9B,OAAO;QACN,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACrB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtB,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;YAC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,MAAmB,EAAE;gBAC/C,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAuB,EAAE;SACnD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,GAAc;IAC/B,MAAM,EACL,EAAE,EACF,SAAS,EACT,KAAK,EACL,IAAI,EACJ,GAAG,EACH,OAAO,EACP,UAAU,EACV,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,GACX,GAAG,GAAG,CAAC;IACR,OAAO;QACN,EAAE;QACF,KAAK;QACL,SAAS;QACT,IAAI;QACJ,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QAC9B,OAAO;QACP,SAAS,EAAE,UAAU;QACrB,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QACzD,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAClC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAClC,QAAQ;QACR,OAAO;QACP,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["// The documents engine (S13, slice 6a §8, slice 6b §1.5): one record per incarnation of an address, revisions made of\n// bases and deltas, a history rule per record (R1); its writes inside the commit step, checked by the writes\n// themselves (the partial unique index on the live address, the counted conditional `UPDATE` on the record's\n// revision), and its reads, of the current state or at a point.\n\nimport { apply, type Op } from \"../delta/index.ts\";\nimport type { JsonValue } from \"../json.ts\";\nimport type { SqliteExecutor } from \"../sqlite/index.ts\";\nimport { TABLES } from \"./schema.ts\";\nimport type { StagedWrite, Step } from \"./step.ts\";\n\n/**\n * A document's address: the owner name, the adapter's namespace (claimed with the owner: Chord's `chord`, `chord.jobs`,\n * `chord.job-states`; Durable's scopes), the kind and, for a keyed document, its key; a singleton has none. The column\n * keeps `\"\"` for it, which a keyed document's empty key shares (its definition says which it is).\n */\nexport type DocumentAddress = {\n\treadonly owner: string;\n\treadonly namespace: string;\n\treadonly kind: string;\n\treadonly key?: string;\n};\n\n/**\n * What a record keeps (R1), applied at a new base and at retirement: `none` (Chord) drops older revisions at a new base\n * and the row and its revisions at retirement; `latest` drops older revisions at a new base and its revisions at\n * retirement, keeping the row; `rewindable` keeps everything.\n */\nexport type DocumentHistory = \"none\" | \"latest\" | \"rewindable\";\n\n/** A stored record: one incarnation of an address, live from `createdAt` until `retiredAt` (half-open). */\nexport type DocumentRecord = DocumentAddress & {\n\treadonly id: number;\n\treadonly history: DocumentHistory;\n\t/** The seq that created it. */\n\treadonly createdAt: number;\n\t/** The seq that retired it, once retired. */\n\treadonly retiredAt?: number;\n\t/** The adapter's details (Durable: its fork policy and history). */\n\treadonly meta?: string;\n\t/** The address key of the host it belongs to (Chord's host-keyed documents, schema 3); absent for others. */\n\treadonly host?: string;\n\t/** Counts its changes: a change names the revision it was prepared on. */\n\treadonly revision: number;\n\t/** The version and schema fingerprint of its current base. */\n\treadonly version: number;\n\treadonly fingerprint: string;\n};\n\n/** A base: a whole value at a version. */\nexport type DocumentBase = { readonly version: number; readonly fingerprint: string; readonly value: JsonValue };\n\n/** A change's content: a new base, or a delta on the current base's version. */\nexport type DocumentContent =\n\t| ({ readonly kind: \"base\" } & DocumentBase)\n\t| { readonly kind: \"delta\"; readonly version: number; readonly ops: readonly Op[] };\n\n/** A stored revision's content: a base's value or a delta's ops, at a version (a revision keeps no fingerprint). */\nexport type RevisionContent =\n\t| { readonly kind: \"base\"; readonly version: number; readonly value: JsonValue }\n\t| { readonly kind: \"delta\"; readonly version: number; readonly ops: readonly Op[] };\n\n/** One stored revision as archives carry it: its document, its seq, its content. */\nexport type DocumentRevision = { readonly id: number; readonly seq: number; readonly content: RevisionContent };\n\n/**\n * The engine's writes as the outbox and archives record them. A creation carries its base in a commit (stored at\n * `createdAt`); in an archive it has none and its `document.revision`s follow it.\n */\nexport type DocumentWrite =\n\t| { readonly kind: \"document.create\"; readonly record: DocumentRecord; readonly base?: DocumentBase }\n\t| {\n\t\t\treadonly kind: \"document.change\";\n\t\t\treadonly id: number;\n\t\t\treadonly revision: number;\n\t\t\treadonly content: DocumentContent;\n\t }\n\t| { readonly kind: \"document.retire\"; readonly id: number; readonly revision: number }\n\t| ({ readonly kind: \"document.revision\" } & DocumentRevision);\n\n/** A loaded document: its record and its value (a base plus deltas applied once) at a point. */\nexport type StoredDocument = {\n\treadonly record: DocumentRecord;\n\treadonly value: JsonValue;\n\t/** The version of the base the value was built from. */\n\treadonly version: number;\n\t/** The deltas applied after its base (what `checkpointWhen` sees). */\n\treadonly deltasSinceBase: number;\n};\n\n/** Where a read looks: the current state, or the state after a seq. */\nexport type DocumentPoint = number | \"current\";\n\n/**\n * Stages the creation of a Chord document at `address` (with `host` when it belongs to a host) with `base`; its id is\n * taken from the allocator when it applies (a saturated allocator refuses the commit) and handed to `created` (its\n * owner adopts it after `COMMIT`). `text` is the base's value serialized before the queue (rule 8).\n */\nexport function createDocument(\n\taddress: DocumentAddress & { readonly host?: string },\n\tbase: DocumentBase,\n\ttext: string,\n\tcreated?: (id: number) => void,\n): StagedWrite {\n\treturn {\n\t\torder: \"create\",\n\t\tapply: async (step) => {\n\t\t\tconst id = step.ids.mint();\n\t\t\tstep.created.push(id);\n\t\t\tcreated?.(id);\n\t\t\tconst { version, fingerprint } = base;\n\t\t\tconst record: DocumentRecord = {\n\t\t\t\tid,\n\t\t\t\t...address,\n\t\t\t\thistory: \"none\",\n\t\t\t\tcreatedAt: step.seq,\n\t\t\t\trevision: 1,\n\t\t\t\tversion,\n\t\t\t\tfingerprint,\n\t\t\t};\n\t\t\tawait insertDocument(step, record, text);\n\t\t\treturn [{ kind: \"document.create\", record, base }];\n\t\t},\n\t};\n}\n\n/**\n * Inserts `record` as it is (id, seqs and revision kept: a creation, an import, a batch), with its base at `createdAt`\n * when `text` (the base's value serialized) is given; a record created retired (an empty lifetime) keeps what its\n * history keeps.\n */\nexport async function insertDocument(step: Step, record: DocumentRecord, text: string | undefined): Promise<void> {\n\tconst {\n\t\tid,\n\t\tnamespace,\n\t\towner,\n\t\tkind,\n\t\tkey,\n\t\thistory,\n\t\tcreatedAt,\n\t\tretiredAt,\n\t\tmeta,\n\t\thost,\n\t\trevision,\n\t\tversion,\n\t\tfingerprint,\n\t} = record;\n\tawait step.run(\n\t\t`INSERT INTO ${TABLES.documents}\n\t\t\t(id, owner, namespace, kind, key, history, created_at, retired_at, meta, host, revision, version, fingerprint)\n\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n\t\tid,\n\t\towner,\n\t\tnamespace,\n\t\tkind,\n\t\tkey ?? \"\",\n\t\thistory,\n\t\tcreatedAt,\n\t\tretiredAt ?? null,\n\t\tmeta ?? null,\n\t\thost ?? null,\n\t\trevision,\n\t\tversion,\n\t\tfingerprint,\n\t);\n\tif (text !== undefined) await insertRevision(step, id, createdAt, \"base\", version, text);\n\tif (retiredAt !== undefined) await dropRetired(step, id, history);\n}\n\n/**\n * Stages a change of Chord document `id` prepared on `revision`: a delta on the current base's version, or a new base.\n * `text` is the content serialized before the queue.\n */\nexport function changeDocument(id: number, revision: number, content: DocumentContent, text: string): StagedWrite {\n\tconst write: DocumentWrite = { kind: \"document.change\", id, revision, content };\n\treturn {\n\t\torder: \"write\",\n\t\tapply: async (step) => {\n\t\t\tawait writeContent(step, id, \"none\", revision, content, text);\n\t\t\treturn [write];\n\t\t},\n\t};\n}\n\n/**\n * Writes `content` to document `id` (of `history`) prepared on `revision`, in the step's seq: its revision, the\n * counted conditional `UPDATE` (a delta only on the base's version), and at a new base the older revisions a\n * `none` or `latest` record drops. A record that is not live at `revision` throws (memory and disk disagree).\n */\nexport async function writeContent(\n\tstep: Step,\n\tid: number,\n\thistory: DocumentHistory,\n\trevision: number,\n\tcontent: DocumentContent,\n\ttext: string,\n): Promise<void> {\n\t// As ids: a revision past the safe range would stop counting exactly.\n\tif (revision >= Number.MAX_SAFE_INTEGER) throw new Error(`document ${id}: no revision past the safe range`);\n\tawait insertRevision(step, id, step.seq, content.kind, content.version, text);\n\tconst changed =\n\t\tcontent.kind === \"delta\"\n\t\t\t? await step.runCounted(\n\t\t\t\t\t`UPDATE ${TABLES.documents} SET revision = revision + 1\n\t\t\t\t\t\tWHERE id = ? AND revision = ? AND version = ? AND retired_at IS NULL`,\n\t\t\t\t\tid,\n\t\t\t\t\trevision,\n\t\t\t\t\tcontent.version,\n\t\t\t\t)\n\t\t\t: await step.runCounted(\n\t\t\t\t\t`UPDATE ${TABLES.documents} SET revision = revision + 1, version = ?, fingerprint = ?\n\t\t\t\t\t\tWHERE id = ? AND revision = ? AND retired_at IS NULL`,\n\t\t\t\t\tcontent.version,\n\t\t\t\t\tcontent.fingerprint,\n\t\t\t\t\tid,\n\t\t\t\t\trevision,\n\t\t\t\t);\n\tif (changed !== 1) throw new Error(`document ${id}: not live at revision ${revision}`);\n\tif (content.kind === \"base\" && history !== \"rewindable\") {\n\t\tawait step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ? AND seq < ?`, id, step.seq);\n\t}\n}\n\n/** Stages the retirement of Chord document `id` (history `none`) at `revision`: its row and its revisions go. */\nexport function retireDocument(id: number, revision: number): StagedWrite {\n\tconst write: DocumentWrite = { kind: \"document.retire\", id, revision };\n\treturn {\n\t\torder: \"retire\",\n\t\tapply: async (step) => {\n\t\t\t// A Chord document keeps no history (`none`): its row goes with a conditional, counted DELETE (6a's).\n\t\t\tconst deleted = await step.runCounted(\n\t\t\t\t`DELETE FROM ${TABLES.documents} WHERE id = ? AND revision = ? AND retired_at IS NULL`,\n\t\t\t\tid,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tif (deleted !== 1) throw new Error(`document ${id}: not live at revision ${revision}`);\n\t\t\tawait step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ?`, id);\n\t\t\treturn [write];\n\t\t},\n\t};\n}\n\n/**\n * Retires live `record` in the step's seq by its history (R1): a `none` record's row and revisions go, a `latest` one\n * keeps its row with `retired_at` and drops its revisions, a `rewindable` one keeps everything.\n */\nexport async function retireRecord(step: Step, record: DocumentRecord): Promise<void> {\n\tconst { id, history } = record;\n\tif (history !== \"none\") await step.run(`UPDATE ${TABLES.documents} SET retired_at = ? WHERE id = ?`, step.seq, id);\n\tawait dropRetired(step, id, history);\n}\n\n/** What a retired record of `history` drops: a `none` row too, every revision unless `rewindable`. */\nasync function dropRetired(step: Step, id: number, history: DocumentHistory): Promise<void> {\n\tif (history === \"rewindable\") return;\n\tif (history === \"none\") await step.run(`DELETE FROM ${TABLES.documents} WHERE id = ?`, id);\n\tawait step.run(`DELETE FROM ${TABLES.revisions} WHERE document_id = ?`, id);\n}\n\n/** Inserts one revision of document `id` at `seq`, `text` its serialized content. */\nexport function insertRevision(\n\tstep: Step,\n\tid: number,\n\tseq: number,\n\tkind: \"base\" | \"delta\",\n\tversion: number,\n\ttext: string,\n): Promise<void> {\n\treturn step.run(\n\t\t`INSERT INTO ${TABLES.revisions} (document_id, seq, kind, version, content) VALUES (?, ?, ?, ?, ?)`,\n\t\tid,\n\t\tseq,\n\t\tkind,\n\t\tversion,\n\t\ttext,\n\t);\n}\n\ntype RecordRow = {\n\treadonly id: number;\n\treadonly owner: string;\n\treadonly namespace: string;\n\treadonly kind: string;\n\treadonly key: string;\n\treadonly history: DocumentHistory;\n\treadonly created_at: number;\n\treadonly retired_at: number | null;\n\treadonly meta: string | null;\n\treadonly host: string | null;\n\treadonly revision: number;\n\treadonly version: number;\n\treadonly fingerprint: string;\n};\n\nconst RECORD_COLUMNS =\n\t\"id, owner, namespace, kind, key, history, created_at, retired_at, meta, host, revision, version, fingerprint\";\n\nconst READ = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE id = ?`;\n\n/** The record with `id`, live or retired, if there is one. */\nexport async function readDocument(\n\texecutor: Pick<SqliteExecutor, \"get\">,\n\tid: number,\n): Promise<DocumentRecord | undefined> {\n\tconst row = await executor.get<RecordRow>(READ, id);\n\treturn row === undefined ? undefined : recordOf(row);\n}\n\nconst FIND_CURRENT = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents}\n\tWHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND retired_at IS NULL`;\n\nconst FIND_AT = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents}\n\tWHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?)\n\tORDER BY created_at DESC LIMIT 1`;\n\n/** The record at `address` live at `at` (the half-open lifetime `createdAt <= at < retiredAt`), if any. */\nexport async function findDocument(\n\texecutor: Pick<SqliteExecutor, \"get\">,\n\taddress: DocumentAddress,\n\tat: DocumentPoint = \"current\",\n): Promise<DocumentRecord | undefined> {\n\tconst { owner, namespace, kind } = address;\n\tconst key = address.key ?? \"\";\n\tconst row =\n\t\tat === \"current\"\n\t\t\t? await executor.get<RecordRow>(FIND_CURRENT, owner, namespace, kind, key)\n\t\t\t: await executor.get<RecordRow>(FIND_AT, owner, namespace, kind, key, at, at);\n\treturn row === undefined ? undefined : recordOf(row);\n}\n\n/**\n * A record as an adapter that keeps its own fields in `meta` reads it: the meta, and, where a read can find retired\n * records (at a point, by id), when it was retired. One or two columns: each column a read returns costs.\n */\nexport type DocumentEntry = { readonly meta: string | null; readonly retired_at?: number | null };\n\n/** A document entry with what tells whose it is and what it keeps, as a read by id needs. */\nexport type OwnedDocumentEntry = DocumentEntry & {\n\treadonly owner: string;\n\treadonly namespace: string;\n\treadonly history: DocumentHistory;\n};\n\nconst READ_ENTRY = `SELECT meta, retired_at, owner, namespace, history FROM ${TABLES.documents} WHERE id = ?`;\n\n/** The entry of the record with `id`, live or retired, with its owner, namespace and history; `undefined` if none. */\nexport function readDocumentEntry(\n\texecutor: Pick<SqliteExecutor, \"get\">,\n\tid: number,\n): Promise<OwnedDocumentEntry | undefined> {\n\treturn executor.get<OwnedDocumentEntry>(READ_ENTRY, id);\n}\n\nconst FIND_ENTRY_CURRENT = `SELECT meta FROM ${TABLES.documents}\n\tWHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND retired_at IS NULL`;\n\nconst FIND_ENTRY_AT = `SELECT meta, retired_at FROM ${TABLES.documents}\n\tWHERE owner = ? AND namespace = ? AND kind = ? AND key = ? AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?)\n\tORDER BY created_at DESC LIMIT 1`;\n\n/** `findDocument` reading only what an adapter keeping its fields in `meta` needs (fewer columns, no record built). */\nexport function findDocumentEntry(\n\texecutor: Pick<SqliteExecutor, \"get\">,\n\taddress: DocumentAddress,\n\tat: DocumentPoint,\n): Promise<DocumentEntry | undefined> {\n\tconst { owner, namespace, kind } = address;\n\tconst key = address.key ?? \"\";\n\treturn at === \"current\"\n\t\t? executor.get<DocumentEntry>(FIND_ENTRY_CURRENT, owner, namespace, kind, key)\n\t\t: executor.get<DocumentEntry>(FIND_ENTRY_AT, owner, namespace, kind, key, at, at);\n}\n\ntype RevisionRow = {\n\treadonly seq: number;\n\treadonly kind: \"base\" | \"delta\";\n\treadonly version: number;\n\treadonly content: string;\n};\n\nconst LOAD = `SELECT seq, kind, version, content FROM ${TABLES.revisions} WHERE document_id = ? AND seq <= ? AND seq >= (\n\tSELECT max(seq) FROM ${TABLES.revisions} WHERE document_id = ? AND kind = 'base' AND seq <= ?) ORDER BY seq`;\n\n/**\n * Loads `record` at `at`: its newest base at or below it and the deltas after that base up to it, applied once; the\n * version is the base's. A record without such a base (one that keeps no history from there) throws.\n */\nexport async function loadDocument(\n\texecutor: Pick<SqliteExecutor, \"all\">,\n\trecord: DocumentRecord,\n\tat: DocumentPoint = \"current\",\n): Promise<StoredDocument> {\n\treturn { record, ...(await loadContent(executor, record.id, at)) };\n}\n\n/** `loadDocument`'s content of document `id` at `at`, without its record (an adapter reads the fields it keeps). */\nexport async function loadContent(\n\texecutor: Pick<SqliteExecutor, \"all\">,\n\tid: number,\n\tat: DocumentPoint,\n): Promise<Omit<StoredDocument, \"record\">> {\n\tconst upper = at === \"current\" ? Number.MAX_SAFE_INTEGER : at;\n\tconst revisions = await executor.all<RevisionRow>(LOAD, id, upper, id, upper);\n\tconst [base, ...deltas] = revisions;\n\tif (base === undefined || base.kind !== \"base\") throw new Error(`document ${id}: no base`);\n\tlet value = JSON.parse(base.content) as JsonValue;\n\tfor (const delta of deltas) {\n\t\tif (delta.version !== base.version) throw new Error(`document ${id}: a delta crosses a version`);\n\t\tvalue = apply(value, JSON.parse(delta.content) as Op[]);\n\t}\n\treturn { value, version: base.version, deltasSinceBase: deltas.length };\n}\n\n/** Up to `limit` keys of live documents of `kind` under `owner` after `after` (from the first), in code point order. */\nexport async function listDocumentKeys(\n\texecutor: SqliteExecutor,\n\taddress: Omit<DocumentAddress, \"key\">,\n\tafter: string | undefined,\n\tlimit: number,\n): Promise<string[]> {\n\t// The first page has no lower bound: `\"\"` is a key too.\n\tconst from = after === undefined ? \"\" : \" AND key > ?\";\n\tconst rows = await executor.all<{ readonly key: string }>(\n\t\t`SELECT key FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND kind = ?${from}\n\t\t\tAND retired_at IS NULL ORDER BY key LIMIT ?`,\n\t\taddress.owner,\n\t\taddress.namespace,\n\t\taddress.kind,\n\t\t...(after === undefined ? [] : [after]),\n\t\tlimit,\n\t);\n\treturn rows.map(({ key }) => key);\n}\n\n/** What `listDocuments` scans: one owner's namespace, optionally one kind. */\nexport type DocumentScope = { readonly owner: string; readonly namespace: string; readonly kind?: string };\n\n/** The statements of `listDocuments`, by its shape: with a kind or not, current or at a point. */\nconst LIST = (() => {\n\tconst from = `SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND id > ?`;\n\tconst current = \" AND retired_at IS NULL ORDER BY id LIMIT ?\";\n\tconst at = \" AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?) ORDER BY id LIMIT ?\";\n\treturn {\n\t\tcurrent: `${from}${current}`,\n\t\tat: `${from}${at}`,\n\t\tkindCurrent: `${from} AND kind = ?${current}`,\n\t\tkindAt: `${from} AND kind = ?${at}`,\n\t};\n})();\n\n/** Up to `limit` records of `scope` live at `at` with ids above `after`, by id. */\nexport async function listDocuments(\n\texecutor: Pick<SqliteExecutor, \"all\">,\n\tscope: DocumentScope,\n\tat: DocumentPoint,\n\tafter: number,\n\tlimit: number,\n): Promise<DocumentRecord[]> {\n\tconst { owner, namespace, kind } = scope;\n\tlet rows: RecordRow[];\n\tif (kind === undefined) {\n\t\trows =\n\t\t\tat === \"current\"\n\t\t\t\t? await executor.all<RecordRow>(LIST.current, owner, namespace, after, limit)\n\t\t\t\t: await executor.all<RecordRow>(LIST.at, owner, namespace, after, at, at, limit);\n\t} else {\n\t\trows =\n\t\t\tat === \"current\"\n\t\t\t\t? await executor.all<RecordRow>(LIST.kindCurrent, owner, namespace, after, kind, limit)\n\t\t\t\t: await executor.all<RecordRow>(LIST.kindAt, owner, namespace, after, kind, at, at, limit);\n\t}\n\treturn rows.map(recordOf);\n}\n\n/** The statements of `listDocumentEntries`, by shape, as `LIST`'s. */\nconst LIST_ENTRIES = (() => {\n\tconst from = (columns: string) =>\n\t\t`SELECT ${columns} FROM ${TABLES.documents} WHERE owner = ? AND namespace = ? AND id > ?`;\n\tconst current = \" AND retired_at IS NULL ORDER BY id LIMIT ?\";\n\tconst at = \" AND created_at <= ? AND (retired_at IS NULL OR retired_at > ?) ORDER BY id LIMIT ?\";\n\treturn {\n\t\tcurrent: `${from(\"meta\")}${current}`,\n\t\tat: `${from(\"meta, retired_at\")}${at}`,\n\t\tkindCurrent: `${from(\"meta\")} AND kind = ?${current}`,\n\t\tkindAt: `${from(\"meta, retired_at\")} AND kind = ?${at}`,\n\t};\n})();\n\n/** `listDocuments` reading only what an adapter keeping its fields in `meta` needs. */\nexport function listDocumentEntries(\n\texecutor: Pick<SqliteExecutor, \"all\">,\n\tscope: DocumentScope,\n\tat: DocumentPoint,\n\tafter: number,\n\tlimit: number,\n): Promise<DocumentEntry[]> {\n\tconst { owner, namespace, kind } = scope;\n\tif (kind === undefined) {\n\t\treturn at === \"current\"\n\t\t\t? executor.all<DocumentEntry>(LIST_ENTRIES.current, owner, namespace, after, limit)\n\t\t\t: executor.all<DocumentEntry>(LIST_ENTRIES.at, owner, namespace, after, at, at, limit);\n\t}\n\treturn at === \"current\"\n\t\t? executor.all<DocumentEntry>(LIST_ENTRIES.kindCurrent, owner, namespace, after, kind, limit)\n\t\t: executor.all<DocumentEntry>(LIST_ENTRIES.kindAt, owner, namespace, after, kind, at, at, limit);\n}\n\n/** Up to `limit` stored records, live and retired, with ids above `after`, by id (an export's pages). */\nexport async function listRecords(executor: SqliteExecutor, after: number, limit: number): Promise<DocumentRecord[]> {\n\tconst rows = await executor.all<RecordRow>(\n\t\t`SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE id > ? ORDER BY id LIMIT ?`,\n\t\tafter,\n\t\tlimit,\n\t);\n\treturn rows.map(recordOf);\n}\n\n/** Up to `limit` live records belonging to the host with address key `host`, with ids above `after`, by id. */\nexport async function listHostRecords(\n\texecutor: Pick<SqliteExecutor, \"all\">,\n\thost: string,\n\tafter: number,\n\tlimit: number,\n): Promise<DocumentRecord[]> {\n\tconst rows = await executor.all<RecordRow>(\n\t\t`SELECT ${RECORD_COLUMNS} FROM ${TABLES.documents} WHERE host = ? AND id > ? AND retired_at IS NULL\n\t\t\tORDER BY id LIMIT ?`,\n\t\thost,\n\t\tafter,\n\t\tlimit,\n\t);\n\treturn rows.map(recordOf);\n}\n\n/** Up to `limit` stored revisions of document `id` after seq `after`, in seq order (an export's page). */\nexport async function listRevisions(\n\texecutor: SqliteExecutor,\n\tid: number,\n\tafter: number,\n\tlimit: number,\n): Promise<DocumentRevision[]> {\n\tconst rows = await executor.all<RevisionRow>(\n\t\t`SELECT seq, kind, version, content FROM ${TABLES.revisions} WHERE document_id = ? AND seq > ? ORDER BY seq LIMIT ?`,\n\t\tid,\n\t\tafter,\n\t\tlimit,\n\t);\n\treturn rows.map(({ seq, kind, version, content }) => {\n\t\t// Written by `insertRevision`: a base's value or a delta's ops, as JSON.\n\t\tconst parsed = JSON.parse(content) as unknown;\n\t\treturn {\n\t\t\tid,\n\t\t\tseq,\n\t\t\tcontent:\n\t\t\t\tkind === \"base\"\n\t\t\t\t\t? { kind, version, value: parsed as JsonValue }\n\t\t\t\t\t: { kind, version, ops: parsed as readonly Op[] },\n\t\t};\n\t});\n}\n\nfunction recordOf(row: RecordRow): DocumentRecord {\n\tconst {\n\t\tid,\n\t\tnamespace,\n\t\towner,\n\t\tkind,\n\t\tkey,\n\t\thistory,\n\t\tcreated_at,\n\t\tretired_at,\n\t\tmeta,\n\t\thost,\n\t\trevision,\n\t\tversion,\n\t\tfingerprint,\n\t} = row;\n\treturn {\n\t\tid,\n\t\towner,\n\t\tnamespace,\n\t\tkind,\n\t\t...(key === \"\" ? {} : { key }),\n\t\thistory,\n\t\tcreatedAt: created_at,\n\t\t...(retired_at === null ? {} : { retiredAt: retired_at }),\n\t\t...(meta === null ? {} : { meta }),\n\t\t...(host === null ? {} : { host }),\n\t\trevision,\n\t\tversion,\n\t\tfingerprint,\n\t};\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JsonValue } from "../json.ts";
|
|
2
|
+
import type { SetNode, WhereNode } from "./expression.ts";
|
|
3
|
+
import type { Scalar } from "./rows.ts";
|
|
4
|
+
/** A row as the evaluator reads it: stored cells, an absent column being `NULL`. */
|
|
5
|
+
export type EvaluatedRow = {
|
|
6
|
+
readonly [column: string]: Scalar | JsonValue | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** Whether `row` matches `node` under SQL's rules: unknown (`NULL`) does not match. */
|
|
9
|
+
export declare function matches(node: WhereNode, row: EvaluatedRow): boolean;
|
|
10
|
+
/** Orders two cells of one column as SQLite does: text by code point, booleans as 0 and 1, numbers numerically. */
|
|
11
|
+
export declare function compareScalar(a: Scalar, b: Scalar): number;
|
|
12
|
+
/**
|
|
13
|
+
* `row` after `set`, every right side evaluated against `row` (simultaneous: `{ a: b, b: a }` swaps); an integer
|
|
14
|
+
* result outside ±(2^53 - 1) throws `invalid/args` (rule 10), as the column's `CHECK` fails the step.
|
|
15
|
+
*/
|
|
16
|
+
export declare function applySet(set: SetNode, row: EvaluatedRow, table: string): EvaluatedRow;
|
|
17
|
+
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/store/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAmC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;CAAE,CAAC;AAKzF,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAEnE;AAyDD,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG1D;AAID;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAQrF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// The JavaScript evaluator of the compiled table vocabulary (slice 6a §6; rule 10): the `tx.get` overlay matches
|
|
2
|
+
// `where` nodes and applies `set` nodes with SQL's three-valued `NULL` rules and code point text order, as the SQL
|
|
3
|
+
// that `sql.ts` renders from the same nodes does in SQLite.
|
|
4
|
+
import { invalid } from "../data/internal.js";
|
|
5
|
+
import { compareText } from "./text.js";
|
|
6
|
+
/** Whether `row` matches `node` under SQL's rules: unknown (`NULL`) does not match. */
|
|
7
|
+
export function matches(node, row) {
|
|
8
|
+
return truth(node, row) === true;
|
|
9
|
+
}
|
|
10
|
+
function truth(node, row) {
|
|
11
|
+
if ("and" in node)
|
|
12
|
+
return node.and.reduce((all, each) => (all === false ? false : both(all, truth(each, row))), true);
|
|
13
|
+
if ("or" in node)
|
|
14
|
+
return node.or.reduce((any, each) => (any === true ? true : either(any, truth(each, row))), false);
|
|
15
|
+
if ("not" in node) {
|
|
16
|
+
const inner = truth(node.not, row);
|
|
17
|
+
return inner === null ? null : !inner;
|
|
18
|
+
}
|
|
19
|
+
if ("isNull" in node)
|
|
20
|
+
return row[node.isNull] === undefined;
|
|
21
|
+
// Only a read's condition tests `exists`, and reads run in the database (slice 14 §3.3: no second evaluator).
|
|
22
|
+
if ("exists" in node)
|
|
23
|
+
throw new Error("exists is not evaluated in memory");
|
|
24
|
+
// The row is checked against the table the condition was compiled for: its columns hold scalars.
|
|
25
|
+
if ("inArray" in node) {
|
|
26
|
+
const [column, values] = node.inArray;
|
|
27
|
+
// SQL: `x IN ()` is false, for a `NULL` x too.
|
|
28
|
+
if (values.length === 0)
|
|
29
|
+
return false;
|
|
30
|
+
const value = row[column];
|
|
31
|
+
return value === undefined ? null : values.some((each) => compareScalar(value, each) === 0);
|
|
32
|
+
}
|
|
33
|
+
if ("prefix" in node) {
|
|
34
|
+
const value = row[node.prefix[0]];
|
|
35
|
+
return value === undefined ? null : value.startsWith(node.prefix[1]);
|
|
36
|
+
}
|
|
37
|
+
// The remaining nodes are the comparisons, one entry each; `Object.entries` loses that.
|
|
38
|
+
const [op, [column, operand]] = Object.entries(node)[0];
|
|
39
|
+
const value = row[column];
|
|
40
|
+
if (value === undefined)
|
|
41
|
+
return null;
|
|
42
|
+
const order = compareScalar(value, operand);
|
|
43
|
+
switch (op) {
|
|
44
|
+
case "eq":
|
|
45
|
+
return order === 0;
|
|
46
|
+
case "ne":
|
|
47
|
+
return order !== 0;
|
|
48
|
+
case "lt":
|
|
49
|
+
return order < 0;
|
|
50
|
+
case "lte":
|
|
51
|
+
return order <= 0;
|
|
52
|
+
case "gt":
|
|
53
|
+
return order > 0;
|
|
54
|
+
case "gte":
|
|
55
|
+
return order >= 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function both(a, b) {
|
|
59
|
+
if (a === false || b === false)
|
|
60
|
+
return false;
|
|
61
|
+
return a === null || b === null ? null : true;
|
|
62
|
+
}
|
|
63
|
+
function either(a, b) {
|
|
64
|
+
if (a === true || b === true)
|
|
65
|
+
return true;
|
|
66
|
+
return a === null || b === null ? null : false;
|
|
67
|
+
}
|
|
68
|
+
/** Orders two cells of one column as SQLite does: text by code point, booleans as 0 and 1, numbers numerically. */
|
|
69
|
+
export function compareScalar(a, b) {
|
|
70
|
+
if (typeof a === "string")
|
|
71
|
+
return compareText(a, b);
|
|
72
|
+
return Number(a) - Number(b);
|
|
73
|
+
}
|
|
74
|
+
const SAFE = Number.MAX_SAFE_INTEGER;
|
|
75
|
+
/**
|
|
76
|
+
* `row` after `set`, every right side evaluated against `row` (simultaneous: `{ a: b, b: a }` swaps); an integer
|
|
77
|
+
* result outside ±(2^53 - 1) throws `invalid/args` (rule 10), as the column's `CHECK` fails the step.
|
|
78
|
+
*/
|
|
79
|
+
export function applySet(set, row, table) {
|
|
80
|
+
const next = { ...row };
|
|
81
|
+
for (const [column, node] of Object.entries(set)) {
|
|
82
|
+
const value = evaluate(node, row, table);
|
|
83
|
+
if (value === undefined)
|
|
84
|
+
delete next[column];
|
|
85
|
+
else
|
|
86
|
+
next[column] = value;
|
|
87
|
+
}
|
|
88
|
+
return next;
|
|
89
|
+
}
|
|
90
|
+
function evaluate(node, row, table) {
|
|
91
|
+
if (node === null)
|
|
92
|
+
return undefined;
|
|
93
|
+
if (typeof node !== "object")
|
|
94
|
+
return node;
|
|
95
|
+
if ("col" in node)
|
|
96
|
+
return row[node.col];
|
|
97
|
+
if ("json" in node)
|
|
98
|
+
return node.json;
|
|
99
|
+
if ("when" in node) {
|
|
100
|
+
const [condition, a, b] = node.when;
|
|
101
|
+
return evaluate(matches(condition, row) ? a : b, row, table);
|
|
102
|
+
}
|
|
103
|
+
if ("coalesce" in node)
|
|
104
|
+
return evaluate(node.coalesce[0], row, table) ?? evaluate(node.coalesce[1], row, table);
|
|
105
|
+
if ("replacePrefix" in node) {
|
|
106
|
+
const [subject, from, to] = node.replacePrefix;
|
|
107
|
+
const value = evaluate(subject, row, table);
|
|
108
|
+
return value === undefined || !value.startsWith(from) ? value : to + value.slice(from.length);
|
|
109
|
+
}
|
|
110
|
+
// The remaining nodes are the arithmetic and text operations, one entry each, over scalar operands (compiled so).
|
|
111
|
+
const [op, [x, y]] = Object.entries(node)[0];
|
|
112
|
+
const a = evaluate(x, row, table);
|
|
113
|
+
const b = evaluate(y, row, table);
|
|
114
|
+
if (a === undefined || b === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
switch (op) {
|
|
117
|
+
case "concat":
|
|
118
|
+
return a + b;
|
|
119
|
+
case "max":
|
|
120
|
+
return compareScalar(a, b) >= 0 ? a : b;
|
|
121
|
+
case "min":
|
|
122
|
+
return compareScalar(a, b) <= 0 ? a : b;
|
|
123
|
+
default: {
|
|
124
|
+
const result = op === "add" ? a + b : a - b;
|
|
125
|
+
if (result > SAFE || result < -SAFE)
|
|
126
|
+
throw invalid("args", `${table}: ${op} gives ${result}, outside ±(2^53 - 1)`);
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=evaluate.js.map
|
|
@@ -0,0 +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,GAAI,CAAY,CAAC,CAAC,CAAE,CAAY,GAAI,CAAY,CAAC;YAC5F,IAAI,MAAM,GAAG,IAAI,IAAI,MAAM,GAAG,CAAC,IAAI;gBAClC,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,KAAK,EAAE,UAAU,MAAM,uBAAuB,CAAC,CAAC;YAC/E,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// The JavaScript evaluator of the compiled table vocabulary (slice 6a §6; rule 10): the `tx.get` overlay matches\n// `where` nodes and applies `set` nodes with SQL's three-valued `NULL` rules and code point text order, as the SQL\n// that `sql.ts` renders from the same nodes does in SQLite.\n\nimport { invalid } from \"../data/internal.ts\";\nimport type { JsonValue } from \"../json.ts\";\nimport type { Comparison, ExprNode, Operation, SetNode, WhereNode } from \"./expression.ts\";\nimport type { Scalar } from \"./rows.ts\";\nimport { compareText } from \"./text.ts\";\n\n/** A row as the evaluator reads it: stored cells, an absent column being `NULL`. */\nexport type EvaluatedRow = { readonly [column: string]: Scalar | JsonValue | undefined };\n\n/** SQL's three-valued truth: `null` is unknown (a comparison with `NULL`). */\ntype Truth = boolean | null;\n\n/** Whether `row` matches `node` under SQL's rules: unknown (`NULL`) does not match. */\nexport function matches(node: WhereNode, row: EvaluatedRow): boolean {\n\treturn truth(node, row) === true;\n}\n\nfunction truth(node: WhereNode, row: EvaluatedRow): Truth {\n\tif (\"and\" in node)\n\t\treturn node.and.reduce<Truth>((all, each) => (all === false ? false : both(all, truth(each, row))), true);\n\tif (\"or\" in node)\n\t\treturn node.or.reduce<Truth>((any, each) => (any === true ? true : either(any, truth(each, row))), false);\n\tif (\"not\" in node) {\n\t\tconst inner = truth(node.not, row);\n\t\treturn inner === null ? null : !inner;\n\t}\n\tif (\"isNull\" in node) return row[node.isNull] === undefined;\n\t// Only a read's condition tests `exists`, and reads run in the database (slice 14 §3.3: no second evaluator).\n\tif (\"exists\" in node) throw new Error(\"exists is not evaluated in memory\");\n\t// The row is checked against the table the condition was compiled for: its columns hold scalars.\n\tif (\"inArray\" in node) {\n\t\tconst [column, values] = node.inArray;\n\t\t// SQL: `x IN ()` is false, for a `NULL` x too.\n\t\tif (values.length === 0) return false;\n\t\tconst value = row[column] as Scalar | undefined;\n\t\treturn value === undefined ? null : values.some((each) => compareScalar(value, each) === 0);\n\t}\n\tif (\"prefix\" in node) {\n\t\tconst value = row[node.prefix[0]] as string | undefined;\n\t\treturn value === undefined ? null : value.startsWith(node.prefix[1]);\n\t}\n\t// The remaining nodes are the comparisons, one entry each; `Object.entries` loses that.\n\tconst [op, [column, operand]] = Object.entries(node)[0] as [Comparison, readonly [string, Scalar]];\n\tconst value = row[column] as Scalar | undefined;\n\tif (value === undefined) return null;\n\tconst order = compareScalar(value, operand);\n\tswitch (op) {\n\t\tcase \"eq\":\n\t\t\treturn order === 0;\n\t\tcase \"ne\":\n\t\t\treturn order !== 0;\n\t\tcase \"lt\":\n\t\t\treturn order < 0;\n\t\tcase \"lte\":\n\t\t\treturn order <= 0;\n\t\tcase \"gt\":\n\t\t\treturn order > 0;\n\t\tcase \"gte\":\n\t\t\treturn order >= 0;\n\t}\n}\n\nfunction both(a: Truth, b: Truth): Truth {\n\tif (a === false || b === false) return false;\n\treturn a === null || b === null ? null : true;\n}\n\nfunction either(a: Truth, b: Truth): Truth {\n\tif (a === true || b === true) return true;\n\treturn a === null || b === null ? null : false;\n}\n\n/** Orders two cells of one column as SQLite does: text by code point, booleans as 0 and 1, numbers numerically. */\nexport function compareScalar(a: Scalar, b: Scalar): number {\n\tif (typeof a === \"string\") return compareText(a, b as string);\n\treturn Number(a) - Number(b);\n}\n\nconst SAFE = Number.MAX_SAFE_INTEGER;\n\n/**\n * `row` after `set`, every right side evaluated against `row` (simultaneous: `{ a: b, b: a }` swaps); an integer\n * result outside ±(2^53 - 1) throws `invalid/args` (rule 10), as the column's `CHECK` fails the step.\n */\nexport function applySet(set: SetNode, row: EvaluatedRow, table: string): EvaluatedRow {\n\tconst next: { [column: string]: Scalar | JsonValue | undefined } = { ...row };\n\tfor (const [column, node] of Object.entries(set)) {\n\t\tconst value = evaluate(node, row, table);\n\t\tif (value === undefined) delete next[column];\n\t\telse next[column] = value;\n\t}\n\treturn next;\n}\n\nfunction evaluate(node: ExprNode, row: EvaluatedRow, table: string): Scalar | JsonValue | undefined {\n\tif (node === null) return undefined;\n\tif (typeof node !== \"object\") return node;\n\tif (\"col\" in node) return row[node.col];\n\tif (\"json\" in node) return node.json;\n\tif (\"when\" in node) {\n\t\tconst [condition, a, b] = node.when;\n\t\treturn evaluate(matches(condition, row) ? a : b, row, table);\n\t}\n\tif (\"coalesce\" in node) return evaluate(node.coalesce[0], row, table) ?? evaluate(node.coalesce[1], row, table);\n\tif (\"replacePrefix\" in node) {\n\t\tconst [subject, from, to] = node.replacePrefix;\n\t\tconst value = evaluate(subject, row, table) as string | undefined;\n\t\treturn value === undefined || !value.startsWith(from) ? value : to + value.slice(from.length);\n\t}\n\t// The remaining nodes are the arithmetic and text operations, one entry each, over scalar operands (compiled so).\n\tconst [op, [x, y]] = Object.entries(node)[0] as [Operation, readonly [ExprNode, ExprNode]];\n\tconst a = evaluate(x, row, table) as Scalar | undefined;\n\tconst b = evaluate(y, row, table) as Scalar | undefined;\n\tif (a === undefined || b === undefined) return undefined;\n\tswitch (op) {\n\t\tcase \"concat\":\n\t\t\treturn (a as string) + (b as string);\n\t\tcase \"max\":\n\t\t\treturn compareScalar(a, b) >= 0 ? a : b;\n\t\tcase \"min\":\n\t\t\treturn compareScalar(a, b) <= 0 ? a : b;\n\t\tdefault: {\n\t\t\tconst result = op === \"add\" ? (a as number) + (b as number) : (a as number) - (b as number);\n\t\t\tif (result > SAFE || result < -SAFE)\n\t\t\t\tthrow invalid(\"args\", `${table}: ${op} gives ${result}, outside ±(2^53 - 1)`);\n\t\t\treturn result;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Context } from "../context/index.ts";
|
|
2
|
+
import { type ArchivePart } from "./archive.ts";
|
|
3
|
+
import type { TableRecord } from "./catalog.ts";
|
|
4
|
+
import type { ChordStore } from "./store.ts";
|
|
5
|
+
/** The rows and documents an export reads per page. */
|
|
6
|
+
export declare const EXPORT_PAGE = 100;
|
|
7
|
+
/**
|
|
8
|
+
* What an export holds: the whole store, or the data belonging to the host with address key `key` (the tables with a
|
|
9
|
+
* `host(...)` column of its kind, only its rows; the records whose `host` is the key).
|
|
10
|
+
*/
|
|
11
|
+
export type ExportSelection = {
|
|
12
|
+
readonly kind: "all";
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "host";
|
|
15
|
+
readonly key: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* An export of `store` (of `selection`, the whole store by default) under `context`: an async iterator of its parts.
|
|
19
|
+
* One pass; after an abort `next()` rejects `aborted`, after the store closed `released`.
|
|
20
|
+
*/
|
|
21
|
+
export declare class StoreExport implements AsyncIterableIterator<ArchivePart> {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(store: ChordStore, context: Context, selection?: ExportSelection);
|
|
24
|
+
[Symbol.asyncIterator](): this;
|
|
25
|
+
next(): Promise<IteratorResult<ArchivePart>>;
|
|
26
|
+
return(): Promise<IteratorResult<ArchivePart>>;
|
|
27
|
+
}
|
|
28
|
+
/** The name of a recorded table's `host(...)` column of host kind `kind`, if it has one. */
|
|
29
|
+
export declare function hostColumn(record: Pick<TableRecord, "columns">, kind: string): string | undefined;
|
|
30
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/store/export.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKrE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,uDAAuD;AACvD,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAIzG;;;GAGG;AACH,qBAAa,WAAY,YAAW,qBAAqB,CAAC,WAAW,CAAC;;IASrE,YAAY,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,GAAE,eAAqB,EAIhF;IAED,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,CAE7B;IAEK,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAmBjD;IAEK,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAGnD;CA6BD;AAoDD,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjG"}
|