@earendil-works/chord 1.3.0 → 1.5.0
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 +54 -0
- package/README.md +129 -10
- package/dist/cell.d.ts +7 -7
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js.map +1 -1
- package/dist/context/index.d.ts +8 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +15 -0
- package/dist/context/index.js.map +1 -1
- package/dist/contract.d.ts +51 -52
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +19 -24
- package/dist/contract.js.map +1 -1
- package/dist/delta/apply-immutable-trusted.js +3 -4
- package/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/dist/delta/diff.d.ts.map +1 -1
- package/dist/delta/diff.js +5 -3
- package/dist/delta/diff.js.map +1 -1
- package/dist/delta/index.d.ts +9 -1
- package/dist/delta/index.d.ts.map +1 -1
- package/dist/delta/index.js +15 -11
- package/dist/delta/index.js.map +1 -1
- package/dist/delta/pending.d.ts +36 -0
- package/dist/delta/pending.d.ts.map +1 -0
- package/dist/delta/pending.js +143 -0
- package/dist/delta/pending.js.map +1 -0
- package/dist/delta/tracker.d.ts +12 -0
- package/dist/delta/tracker.d.ts.map +1 -1
- package/dist/delta/tracker.js +109 -39
- package/dist/delta/tracker.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +9 -7
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/next/contracts/accepts.d.ts +81 -0
- package/dist/next/contracts/accepts.d.ts.map +1 -0
- package/dist/next/contracts/accepts.js +123 -0
- package/dist/next/contracts/accepts.js.map +1 -0
- package/dist/next/contracts/contract.d.ts +121 -0
- package/dist/next/contracts/contract.d.ts.map +1 -0
- package/dist/next/contracts/contract.js +50 -0
- package/dist/next/contracts/contract.js.map +1 -0
- package/dist/next/contracts/declare.d.ts +107 -0
- package/dist/next/contracts/declare.d.ts.map +1 -0
- package/dist/next/contracts/declare.js +136 -0
- package/dist/next/contracts/declare.js.map +1 -0
- package/dist/next/contracts/evolve.d.ts +92 -0
- package/dist/next/contracts/evolve.d.ts.map +1 -0
- package/dist/next/contracts/evolve.js +179 -0
- package/dist/next/contracts/evolve.js.map +1 -0
- package/dist/next/contracts/fingerprint.d.ts +16 -0
- package/dist/next/contracts/fingerprint.d.ts.map +1 -0
- package/dist/next/contracts/fingerprint.js +50 -0
- package/dist/next/contracts/fingerprint.js.map +1 -0
- package/dist/next/contracts/history.d.ts +71 -0
- package/dist/next/contracts/history.d.ts.map +1 -0
- package/dist/next/contracts/history.js +3 -0
- package/dist/next/contracts/history.js.map +1 -0
- package/dist/next/contracts/host-kind.d.ts +40 -0
- package/dist/next/contracts/host-kind.d.ts.map +1 -0
- package/dist/next/contracts/host-kind.js +37 -0
- package/dist/next/contracts/host-kind.js.map +1 -0
- package/dist/next/contracts/index.d.ts +7 -0
- package/dist/next/contracts/index.d.ts.map +1 -0
- package/dist/next/contracts/index.js +6 -0
- package/dist/next/contracts/index.js.map +1 -0
- package/dist/next/contracts/internal.d.ts +10 -0
- package/dist/next/contracts/internal.d.ts.map +1 -0
- package/dist/next/contracts/internal.js +9 -0
- package/dist/next/contracts/internal.js.map +1 -0
- package/dist/next/contracts/names.d.ts +3 -0
- package/dist/next/contracts/names.d.ts.map +1 -0
- package/dist/next/contracts/names.js +13 -0
- package/dist/next/contracts/names.js.map +1 -0
- package/dist/next/contracts/params.d.ts +28 -0
- package/dist/next/contracts/params.d.ts.map +1 -0
- package/dist/next/contracts/params.js +50 -0
- package/dist/next/contracts/params.js.map +1 -0
- package/dist/next/contracts/schema.d.ts +102 -0
- package/dist/next/contracts/schema.d.ts.map +1 -0
- package/dist/next/contracts/schema.js +103 -0
- package/dist/next/contracts/schema.js.map +1 -0
- package/dist/next/contracts/snapshot.d.ts +16 -0
- package/dist/next/contracts/snapshot.d.ts.map +1 -0
- package/dist/next/contracts/snapshot.js +167 -0
- package/dist/next/contracts/snapshot.js.map +1 -0
- package/dist/next/data/args.d.ts +50 -0
- package/dist/next/data/args.d.ts.map +1 -0
- package/dist/next/data/args.js +83 -0
- package/dist/next/data/args.js.map +1 -0
- package/dist/next/data/errors.d.ts +73 -0
- package/dist/next/data/errors.d.ts.map +1 -0
- package/dist/next/data/errors.js +107 -0
- package/dist/next/data/errors.js.map +1 -0
- package/dist/next/data/failure.d.ts +26 -0
- package/dist/next/data/failure.d.ts.map +1 -0
- package/dist/next/data/failure.js +72 -0
- package/dist/next/data/failure.js.map +1 -0
- package/dist/next/data/index.d.ts +4 -0
- package/dist/next/data/index.d.ts.map +1 -0
- package/dist/next/data/index.js +4 -0
- package/dist/next/data/index.js.map +1 -0
- package/dist/next/data/internal.d.ts +7 -0
- package/dist/next/data/internal.d.ts.map +1 -0
- package/dist/next/data/internal.js +8 -0
- package/dist/next/data/internal.js.map +1 -0
- package/dist/next/data/params.d.ts +20 -0
- package/dist/next/data/params.d.ts.map +1 -0
- package/dist/next/data/params.js +31 -0
- package/dist/next/data/params.js.map +1 -0
- package/dist/next/data/principal.d.ts +17 -0
- package/dist/next/data/principal.d.ts.map +1 -0
- package/dist/next/data/principal.js +41 -0
- package/dist/next/data/principal.js.map +1 -0
- package/dist/next/data/validator.d.ts +12 -0
- package/dist/next/data/validator.d.ts.map +1 -0
- package/dist/next/data/validator.js +34 -0
- package/dist/next/data/validator.js.map +1 -0
- package/dist/next/documents/address-source.d.ts +20 -0
- package/dist/next/documents/address-source.d.ts.map +1 -0
- package/dist/next/documents/address-source.js +44 -0
- package/dist/next/documents/address-source.js.map +1 -0
- package/dist/next/documents/definition.d.ts +84 -0
- package/dist/next/documents/definition.d.ts.map +1 -0
- package/dist/next/documents/definition.js +73 -0
- package/dist/next/documents/definition.js.map +1 -0
- package/dist/next/documents/documents.d.ts +106 -0
- package/dist/next/documents/documents.d.ts.map +1 -0
- package/dist/next/documents/documents.js +224 -0
- package/dist/next/documents/documents.js.map +1 -0
- package/dist/next/documents/fence.d.ts +9 -0
- package/dist/next/documents/fence.d.ts.map +1 -0
- package/dist/next/documents/fence.js +15 -0
- package/dist/next/documents/fence.js.map +1 -0
- package/dist/next/documents/handles.d.ts +76 -0
- package/dist/next/documents/handles.d.ts.map +1 -0
- package/dist/next/documents/handles.js +66 -0
- package/dist/next/documents/handles.js.map +1 -0
- package/dist/next/documents/index.d.ts +4 -0
- package/dist/next/documents/index.d.ts.map +1 -0
- package/dist/next/documents/index.js +3 -0
- package/dist/next/documents/index.js.map +1 -0
- package/dist/next/documents/internal.d.ts +9 -0
- package/dist/next/documents/internal.d.ts.map +1 -0
- package/dist/next/documents/internal.js +9 -0
- package/dist/next/documents/internal.js.map +1 -0
- package/dist/next/documents/keyed-slot.d.ts +103 -0
- package/dist/next/documents/keyed-slot.d.ts.map +1 -0
- package/dist/next/documents/keyed-slot.js +395 -0
- package/dist/next/documents/keyed-slot.js.map +1 -0
- package/dist/next/documents/line.d.ts +7 -0
- package/dist/next/documents/line.d.ts.map +1 -0
- package/dist/next/documents/line.js +14 -0
- package/dist/next/documents/line.js.map +1 -0
- package/dist/next/documents/persistence.d.ts +104 -0
- package/dist/next/documents/persistence.d.ts.map +1 -0
- package/dist/next/documents/persistence.js +128 -0
- package/dist/next/documents/persistence.js.map +1 -0
- package/dist/next/documents/residency.d.ts +31 -0
- package/dist/next/documents/residency.d.ts.map +1 -0
- package/dist/next/documents/residency.js +93 -0
- package/dist/next/documents/residency.js.map +1 -0
- package/dist/next/documents/slot.d.ts +109 -0
- package/dist/next/documents/slot.d.ts.map +1 -0
- package/dist/next/documents/slot.js +181 -0
- package/dist/next/documents/slot.js.map +1 -0
- package/dist/next/documents/transaction.d.ts +133 -0
- package/dist/next/documents/transaction.d.ts.map +1 -0
- package/dist/next/documents/transaction.js +409 -0
- package/dist/next/documents/transaction.js.map +1 -0
- package/dist/next/host/activity.d.ts +31 -0
- package/dist/next/host/activity.d.ts.map +1 -0
- package/dist/next/host/activity.js +40 -0
- package/dist/next/host/activity.js.map +1 -0
- package/dist/next/host/adapted.d.ts +49 -0
- package/dist/next/host/adapted.d.ts.map +1 -0
- package/dist/next/host/adapted.js +214 -0
- package/dist/next/host/adapted.js.map +1 -0
- package/dist/next/host/attempt.d.ts +278 -0
- package/dist/next/host/attempt.d.ts.map +1 -0
- package/dist/next/host/attempt.js +1072 -0
- package/dist/next/host/attempt.js.map +1 -0
- package/dist/next/host/backoff.d.ts +29 -0
- package/dist/next/host/backoff.d.ts.map +1 -0
- package/dist/next/host/backoff.js +69 -0
- package/dist/next/host/backoff.js.map +1 -0
- package/dist/next/host/ctx.d.ts +47 -0
- package/dist/next/host/ctx.d.ts.map +1 -0
- package/dist/next/host/ctx.js +108 -0
- package/dist/next/host/ctx.js.map +1 -0
- package/dist/next/host/deadline.d.ts +12 -0
- package/dist/next/host/deadline.d.ts.map +1 -0
- package/dist/next/host/deadline.js +40 -0
- package/dist/next/host/deadline.js.map +1 -0
- package/dist/next/host/dependencies.d.ts +65 -0
- package/dist/next/host/dependencies.d.ts.map +1 -0
- package/dist/next/host/dependencies.js +115 -0
- package/dist/next/host/dependencies.js.map +1 -0
- package/dist/next/host/destination.d.ts +48 -0
- package/dist/next/host/destination.d.ts.map +1 -0
- package/dist/next/host/destination.js +101 -0
- package/dist/next/host/destination.js.map +1 -0
- package/dist/next/host/facet.d.ts +79 -0
- package/dist/next/host/facet.d.ts.map +1 -0
- package/dist/next/host/facet.js +55 -0
- package/dist/next/host/facet.js.map +1 -0
- package/dist/next/host/follow.d.ts +52 -0
- package/dist/next/host/follow.d.ts.map +1 -0
- package/dist/next/host/follow.js +207 -0
- package/dist/next/host/follow.js.map +1 -0
- package/dist/next/host/host.d.ts +495 -0
- package/dist/next/host/host.d.ts.map +1 -0
- package/dist/next/host/host.js +1075 -0
- package/dist/next/host/host.js.map +1 -0
- package/dist/next/host/index.d.ts +17 -0
- package/dist/next/host/index.d.ts.map +1 -0
- package/dist/next/host/index.js +6 -0
- package/dist/next/host/index.js.map +1 -0
- package/dist/next/host/internal.d.ts +10 -0
- package/dist/next/host/internal.d.ts.map +1 -0
- package/dist/next/host/internal.js +8 -0
- package/dist/next/host/internal.js.map +1 -0
- package/dist/next/host/members.d.ts +50 -0
- package/dist/next/host/members.d.ts.map +1 -0
- package/dist/next/host/members.js +107 -0
- package/dist/next/host/members.js.map +1 -0
- package/dist/next/host/native.d.ts +55 -0
- package/dist/next/host/native.d.ts.map +1 -0
- package/dist/next/host/native.js +92 -0
- package/dist/next/host/native.js.map +1 -0
- package/dist/next/host/object.d.ts +290 -0
- package/dist/next/host/object.d.ts.map +1 -0
- package/dist/next/host/object.js +1127 -0
- package/dist/next/host/object.js.map +1 -0
- package/dist/next/host/parked.d.ts +23 -0
- package/dist/next/host/parked.d.ts.map +1 -0
- package/dist/next/host/parked.js +79 -0
- package/dist/next/host/parked.js.map +1 -0
- package/dist/next/host/presence.d.ts +34 -0
- package/dist/next/host/presence.d.ts.map +1 -0
- package/dist/next/host/presence.js +117 -0
- package/dist/next/host/presence.js.map +1 -0
- package/dist/next/host/ref-state.d.ts +53 -0
- package/dist/next/host/ref-state.d.ts.map +1 -0
- package/dist/next/host/ref-state.js +83 -0
- package/dist/next/host/ref-state.js.map +1 -0
- package/dist/next/host/reference-keys.d.ts +36 -0
- package/dist/next/host/reference-keys.d.ts.map +1 -0
- package/dist/next/host/reference-keys.js +168 -0
- package/dist/next/host/reference-keys.js.map +1 -0
- package/dist/next/host/reference-source.d.ts +65 -0
- package/dist/next/host/reference-source.d.ts.map +1 -0
- package/dist/next/host/reference-source.js +285 -0
- package/dist/next/host/reference-source.js.map +1 -0
- package/dist/next/host/reference.d.ts +308 -0
- package/dist/next/host/reference.d.ts.map +1 -0
- package/dist/next/host/reference.js +775 -0
- package/dist/next/host/reference.js.map +1 -0
- package/dist/next/host/retry-on.d.ts +28 -0
- package/dist/next/host/retry-on.d.ts.map +1 -0
- package/dist/next/host/retry-on.js +52 -0
- package/dist/next/host/retry-on.js.map +1 -0
- package/dist/next/host/revocation.d.ts +16 -0
- package/dist/next/host/revocation.d.ts.map +1 -0
- package/dist/next/host/revocation.js +27 -0
- package/dist/next/host/revocation.js.map +1 -0
- package/dist/next/host/root.d.ts +27 -0
- package/dist/next/host/root.d.ts.map +1 -0
- package/dist/next/host/root.js +68 -0
- package/dist/next/host/root.js.map +1 -0
- package/dist/next/host/route.d.ts +64 -0
- package/dist/next/host/route.d.ts.map +1 -0
- package/dist/next/host/route.js +190 -0
- package/dist/next/host/route.js.map +1 -0
- package/dist/next/host/routines.d.ts +76 -0
- package/dist/next/host/routines.d.ts.map +1 -0
- package/dist/next/host/routines.js +350 -0
- package/dist/next/host/routines.js.map +1 -0
- package/dist/next/host/sleep.d.ts +9 -0
- package/dist/next/host/sleep.d.ts.map +1 -0
- package/dist/next/host/sleep.js +40 -0
- package/dist/next/host/sleep.js.map +1 -0
- package/dist/next/host/staging.d.ts +94 -0
- package/dist/next/host/staging.d.ts.map +1 -0
- package/dist/next/host/staging.js +302 -0
- package/dist/next/host/staging.js.map +1 -0
- package/dist/next/host/unbound.d.ts +30 -0
- package/dist/next/host/unbound.d.ts.map +1 -0
- package/dist/next/host/unbound.js +67 -0
- package/dist/next/host/unbound.js.map +1 -0
- package/dist/next/host/uuid.d.ts +3 -0
- package/dist/next/host/uuid.d.ts.map +1 -0
- package/dist/next/host/uuid.js +38 -0
- package/dist/next/host/uuid.js.map +1 -0
- package/dist/next/index.d.ts +28 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +18 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/jobs/definition.d.ts +96 -0
- package/dist/next/jobs/definition.d.ts.map +1 -0
- package/dist/next/jobs/definition.js +83 -0
- package/dist/next/jobs/definition.js.map +1 -0
- package/dist/next/jobs/index.d.ts +5 -0
- package/dist/next/jobs/index.d.ts.map +1 -0
- package/dist/next/jobs/index.js +3 -0
- package/dist/next/jobs/index.js.map +1 -0
- package/dist/next/jobs/internal.d.ts +3 -0
- package/dist/next/jobs/internal.d.ts.map +1 -0
- package/dist/next/jobs/internal.js +4 -0
- package/dist/next/jobs/internal.js.map +1 -0
- package/dist/next/jobs/job.d.ts +152 -0
- package/dist/next/jobs/job.d.ts.map +1 -0
- package/dist/next/jobs/job.js +320 -0
- package/dist/next/jobs/job.js.map +1 -0
- package/dist/next/jobs/persisted.d.ts +38 -0
- package/dist/next/jobs/persisted.d.ts.map +1 -0
- package/dist/next/jobs/persisted.js +95 -0
- package/dist/next/jobs/persisted.js.map +1 -0
- package/dist/next/jobs/records.d.ts +231 -0
- package/dist/next/jobs/records.d.ts.map +1 -0
- package/dist/next/jobs/records.js +869 -0
- package/dist/next/jobs/records.js.map +1 -0
- package/dist/next/jobs/run-states.d.ts +69 -0
- package/dist/next/jobs/run-states.d.ts.map +1 -0
- package/dist/next/jobs/run-states.js +228 -0
- package/dist/next/jobs/run-states.js.map +1 -0
- package/dist/next/jobs/run.d.ts +113 -0
- package/dist/next/jobs/run.d.ts.map +1 -0
- package/dist/next/jobs/run.js +200 -0
- package/dist/next/jobs/run.js.map +1 -0
- package/dist/next/jobs/running.d.ts +44 -0
- package/dist/next/jobs/running.d.ts.map +1 -0
- package/dist/next/jobs/running.js +117 -0
- package/dist/next/jobs/running.js.map +1 -0
- package/dist/next/jobs/stored.d.ts +63 -0
- package/dist/next/jobs/stored.d.ts.map +1 -0
- package/dist/next/jobs/stored.js +55 -0
- package/dist/next/jobs/stored.js.map +1 -0
- package/dist/next/link/binary.d.ts +4 -0
- package/dist/next/link/binary.d.ts.map +1 -0
- package/dist/next/link/binary.js +534 -0
- package/dist/next/link/binary.js.map +1 -0
- package/dist/next/link/channel.d.ts +63 -0
- package/dist/next/link/channel.d.ts.map +1 -0
- package/dist/next/link/channel.js +202 -0
- package/dist/next/link/channel.js.map +1 -0
- package/dist/next/link/errors.d.ts +7 -0
- package/dist/next/link/errors.d.ts.map +1 -0
- package/dist/next/link/errors.js +21 -0
- package/dist/next/link/errors.js.map +1 -0
- package/dist/next/link/index.d.ts +8 -0
- package/dist/next/link/index.d.ts.map +1 -0
- package/dist/next/link/index.js +8 -0
- package/dist/next/link/index.js.map +1 -0
- package/dist/next/link/internal.d.ts +9 -0
- package/dist/next/link/internal.d.ts.map +1 -0
- package/dist/next/link/internal.js +10 -0
- package/dist/next/link/internal.js.map +1 -0
- package/dist/next/link/ipc.d.ts +22 -0
- package/dist/next/link/ipc.d.ts.map +1 -0
- package/dist/next/link/ipc.js +64 -0
- package/dist/next/link/ipc.js.map +1 -0
- package/dist/next/link/link.d.ts +34 -0
- package/dist/next/link/link.d.ts.map +1 -0
- package/dist/next/link/link.js +87 -0
- package/dist/next/link/link.js.map +1 -0
- package/dist/next/link/message.d.ts +249 -0
- package/dist/next/link/message.d.ts.map +1 -0
- package/dist/next/link/message.js +123 -0
- package/dist/next/link/message.js.map +1 -0
- package/dist/next/link/part.d.ts +80 -0
- package/dist/next/link/part.d.ts.map +1 -0
- package/dist/next/link/part.js +164 -0
- package/dist/next/link/part.js.map +1 -0
- package/dist/next/link/text.d.ts +6 -0
- package/dist/next/link/text.d.ts.map +1 -0
- package/dist/next/link/text.js +335 -0
- package/dist/next/link/text.js.map +1 -0
- package/dist/next/link/values.d.ts +40 -0
- package/dist/next/link/values.d.ts.map +1 -0
- package/dist/next/link/values.js +117 -0
- package/dist/next/link/values.js.map +1 -0
- package/dist/next/link/websocket.d.ts +26 -0
- package/dist/next/link/websocket.d.ts.map +1 -0
- package/dist/next/link/websocket.js +91 -0
- package/dist/next/link/websocket.js.map +1 -0
- package/dist/next/registries/contribution.d.ts +50 -0
- package/dist/next/registries/contribution.d.ts.map +1 -0
- package/dist/next/registries/contribution.js +129 -0
- package/dist/next/registries/contribution.js.map +1 -0
- package/dist/next/registries/entries.d.ts +18 -0
- package/dist/next/registries/entries.d.ts.map +1 -0
- package/dist/next/registries/entries.js +42 -0
- package/dist/next/registries/entries.js.map +1 -0
- package/dist/next/registries/index.d.ts +3 -0
- package/dist/next/registries/index.d.ts.map +1 -0
- package/dist/next/registries/index.js +5 -0
- package/dist/next/registries/index.js.map +1 -0
- package/dist/next/registries/internal.d.ts +4 -0
- package/dist/next/registries/internal.d.ts.map +1 -0
- package/dist/next/registries/internal.js +5 -0
- package/dist/next/registries/internal.js.map +1 -0
- package/dist/next/registries/record.d.ts +94 -0
- package/dist/next/registries/record.d.ts.map +1 -0
- package/dist/next/registries/record.js +253 -0
- package/dist/next/registries/record.js.map +1 -0
- package/dist/next/registries/registry.d.ts +74 -0
- package/dist/next/registries/registry.d.ts.map +1 -0
- package/dist/next/registries/registry.js +14 -0
- package/dist/next/registries/registry.js.map +1 -0
- package/dist/next/registries/value.d.ts +48 -0
- package/dist/next/registries/value.d.ts.map +1 -0
- package/dist/next/registries/value.js +199 -0
- package/dist/next/registries/value.js.map +1 -0
- package/dist/next/remote/calls.d.ts +25 -0
- package/dist/next/remote/calls.d.ts.map +1 -0
- package/dist/next/remote/calls.js +62 -0
- package/dist/next/remote/calls.js.map +1 -0
- package/dist/next/remote/consumer.d.ts +42 -0
- package/dist/next/remote/consumer.d.ts.map +1 -0
- package/dist/next/remote/consumer.js +343 -0
- package/dist/next/remote/consumer.js.map +1 -0
- package/dist/next/remote/hold.d.ts +130 -0
- package/dist/next/remote/hold.d.ts.map +1 -0
- package/dist/next/remote/hold.js +537 -0
- package/dist/next/remote/hold.js.map +1 -0
- package/dist/next/remote/host-link.d.ts +77 -0
- package/dist/next/remote/host-link.d.ts.map +1 -0
- package/dist/next/remote/host-link.js +182 -0
- package/dist/next/remote/host-link.js.map +1 -0
- package/dist/next/remote/internal.d.ts +6 -0
- package/dist/next/remote/internal.d.ts.map +1 -0
- package/dist/next/remote/internal.js +6 -0
- package/dist/next/remote/internal.js.map +1 -0
- package/dist/next/remote/path.d.ts +46 -0
- package/dist/next/remote/path.d.ts.map +1 -0
- package/dist/next/remote/path.js +73 -0
- package/dist/next/remote/path.js.map +1 -0
- package/dist/next/remote/provider.d.ts +76 -0
- package/dist/next/remote/provider.d.ts.map +1 -0
- package/dist/next/remote/provider.js +506 -0
- package/dist/next/remote/provider.js.map +1 -0
- package/dist/next/remote/relay.d.ts +58 -0
- package/dist/next/remote/relay.d.ts.map +1 -0
- package/dist/next/remote/relay.js +117 -0
- package/dist/next/remote/relay.js.map +1 -0
- package/dist/next/remote/remote-object.d.ts +133 -0
- package/dist/next/remote/remote-object.d.ts.map +1 -0
- package/dist/next/remote/remote-object.js +411 -0
- package/dist/next/remote/remote-object.js.map +1 -0
- package/dist/next/remote/replica.d.ts +59 -0
- package/dist/next/remote/replica.d.ts.map +1 -0
- package/dist/next/remote/replica.js +125 -0
- package/dist/next/remote/replica.js.map +1 -0
- package/dist/next/state/batch.d.ts +64 -0
- package/dist/next/state/batch.d.ts.map +1 -0
- package/dist/next/state/batch.js +163 -0
- package/dist/next/state/batch.js.map +1 -0
- package/dist/next/state/derive.d.ts +52 -0
- package/dist/next/state/derive.d.ts.map +1 -0
- package/dist/next/state/derive.js +182 -0
- package/dist/next/state/derive.js.map +1 -0
- package/dist/next/state/index.d.ts +6 -0
- package/dist/next/state/index.d.ts.map +1 -0
- package/dist/next/state/index.js +4 -0
- package/dist/next/state/index.js.map +1 -0
- package/dist/next/state/internal.d.ts +6 -0
- package/dist/next/state/internal.d.ts.map +1 -0
- package/dist/next/state/internal.js +8 -0
- package/dist/next/state/internal.js.map +1 -0
- package/dist/next/state/native-source.d.ts +106 -0
- package/dist/next/state/native-source.d.ts.map +1 -0
- package/dist/next/state/native-source.js +240 -0
- package/dist/next/state/native-source.js.map +1 -0
- package/dist/next/state/watchable.d.ts +114 -0
- package/dist/next/state/watchable.d.ts.map +1 -0
- package/dist/next/state/watchable.js +156 -0
- package/dist/next/state/watchable.js.map +1 -0
- package/dist/next/state/writable.d.ts +32 -0
- package/dist/next/state/writable.d.ts.map +1 -0
- package/dist/next/state/writable.js +49 -0
- package/dist/next/state/writable.js.map +1 -0
- package/dist/next/store/adapter.d.ts +67 -0
- package/dist/next/store/adapter.d.ts.map +1 -0
- package/dist/next/store/adapter.js +118 -0
- package/dist/next/store/adapter.js.map +1 -0
- package/dist/next/store/allocator.d.ts +17 -0
- package/dist/next/store/allocator.d.ts.map +1 -0
- package/dist/next/store/allocator.js +30 -0
- package/dist/next/store/allocator.js.map +1 -0
- package/dist/next/store/applier.d.ts +8 -0
- package/dist/next/store/applier.d.ts.map +1 -0
- package/dist/next/store/applier.js +375 -0
- package/dist/next/store/applier.js.map +1 -0
- package/dist/next/store/apply-batch.d.ts +12 -0
- package/dist/next/store/apply-batch.d.ts.map +1 -0
- package/dist/next/store/apply-batch.js +83 -0
- package/dist/next/store/apply-batch.js.map +1 -0
- package/dist/next/store/archive.d.ts +32 -0
- package/dist/next/store/archive.d.ts.map +1 -0
- package/dist/next/store/archive.js +129 -0
- package/dist/next/store/archive.js.map +1 -0
- package/dist/next/store/backend.d.ts +10 -0
- package/dist/next/store/backend.d.ts.map +1 -0
- package/dist/next/store/backend.js +15 -0
- package/dist/next/store/backend.js.map +1 -0
- package/dist/next/store/catalog.d.ts +24 -0
- package/dist/next/store/catalog.d.ts.map +1 -0
- package/dist/next/store/catalog.js +17 -0
- package/dist/next/store/catalog.js.map +1 -0
- package/dist/next/store/claims.d.ts +23 -0
- package/dist/next/store/claims.d.ts.map +1 -0
- package/dist/next/store/claims.js +65 -0
- package/dist/next/store/claims.js.map +1 -0
- package/dist/next/store/columns.d.ts +77 -0
- package/dist/next/store/columns.d.ts.map +1 -0
- package/dist/next/store/columns.js +77 -0
- package/dist/next/store/columns.js.map +1 -0
- package/dist/next/store/engine.d.ts +176 -0
- package/dist/next/store/engine.d.ts.map +1 -0
- package/dist/next/store/engine.js +283 -0
- package/dist/next/store/engine.js.map +1 -0
- package/dist/next/store/evaluate.d.ts +17 -0
- package/dist/next/store/evaluate.d.ts.map +1 -0
- package/dist/next/store/evaluate.js +128 -0
- package/dist/next/store/evaluate.js.map +1 -0
- package/dist/next/store/export.d.ts +17 -0
- package/dist/next/store/export.d.ts.map +1 -0
- package/dist/next/store/export.js +200 -0
- package/dist/next/store/export.js.map +1 -0
- package/dist/next/store/expression.d.ts +150 -0
- package/dist/next/store/expression.d.ts.map +1 -0
- package/dist/next/store/expression.js +268 -0
- package/dist/next/store/expression.js.map +1 -0
- package/dist/next/store/import.d.ts +10 -0
- package/dist/next/store/import.d.ts.map +1 -0
- package/dist/next/store/import.js +276 -0
- package/dist/next/store/import.js.map +1 -0
- package/dist/next/store/index.d.ts +16 -0
- package/dist/next/store/index.d.ts.map +1 -0
- package/dist/next/store/index.js +13 -0
- package/dist/next/store/index.js.map +1 -0
- package/dist/next/store/json-column.d.ts +33 -0
- package/dist/next/store/json-column.d.ts.map +1 -0
- package/dist/next/store/json-column.js +61 -0
- package/dist/next/store/json-column.js.map +1 -0
- package/dist/next/store/jsonl.d.ts +9 -0
- package/dist/next/store/jsonl.d.ts.map +1 -0
- package/dist/next/store/jsonl.js +61 -0
- package/dist/next/store/jsonl.js.map +1 -0
- package/dist/next/store/outbox.d.ts +26 -0
- package/dist/next/store/outbox.d.ts.map +1 -0
- package/dist/next/store/outbox.js +80 -0
- package/dist/next/store/outbox.js.map +1 -0
- package/dist/next/store/query.d.ts +39 -0
- package/dist/next/store/query.d.ts.map +1 -0
- package/dist/next/store/query.js +97 -0
- package/dist/next/store/query.js.map +1 -0
- package/dist/next/store/refusal.d.ts +15 -0
- package/dist/next/store/refusal.d.ts.map +1 -0
- package/dist/next/store/refusal.js +36 -0
- package/dist/next/store/refusal.js.map +1 -0
- package/dist/next/store/rows.d.ts +80 -0
- package/dist/next/store/rows.d.ts.map +1 -0
- package/dist/next/store/rows.js +183 -0
- package/dist/next/store/rows.js.map +1 -0
- package/dist/next/store/schema.d.ts +25 -0
- package/dist/next/store/schema.d.ts.map +1 -0
- package/dist/next/store/schema.js +115 -0
- package/dist/next/store/schema.js.map +1 -0
- package/dist/next/store/sql.d.ts +73 -0
- package/dist/next/store/sql.d.ts.map +1 -0
- package/dist/next/store/sql.js +234 -0
- package/dist/next/store/sql.js.map +1 -0
- package/dist/next/store/step.d.ts +48 -0
- package/dist/next/store/step.d.ts.map +1 -0
- package/dist/next/store/step.js +50 -0
- package/dist/next/store/step.js.map +1 -0
- package/dist/next/store/store.d.ts +161 -0
- package/dist/next/store/store.d.ts.map +1 -0
- package/dist/next/store/store.js +627 -0
- package/dist/next/store/store.js.map +1 -0
- package/dist/next/store/table-changes.d.ts +29 -0
- package/dist/next/store/table-changes.d.ts.map +1 -0
- package/dist/next/store/table-changes.js +102 -0
- package/dist/next/store/table-changes.js.map +1 -0
- package/dist/next/store/table-evolve.d.ts +74 -0
- package/dist/next/store/table-evolve.d.ts.map +1 -0
- package/dist/next/store/table-evolve.js +201 -0
- package/dist/next/store/table-evolve.js.map +1 -0
- package/dist/next/store/table-handle.d.ts +67 -0
- package/dist/next/store/table-handle.d.ts.map +1 -0
- package/dist/next/store/table-handle.js +101 -0
- package/dist/next/store/table-handle.js.map +1 -0
- package/dist/next/store/table-history.d.ts +75 -0
- package/dist/next/store/table-history.d.ts.map +1 -0
- package/dist/next/store/table-history.js +42 -0
- package/dist/next/store/table-history.js.map +1 -0
- package/dist/next/store/table-migration.d.ts +16 -0
- package/dist/next/store/table-migration.d.ts.map +1 -0
- package/dist/next/store/table-migration.js +202 -0
- package/dist/next/store/table-migration.js.map +1 -0
- package/dist/next/store/table-writes.d.ts +125 -0
- package/dist/next/store/table-writes.d.ts.map +1 -0
- package/dist/next/store/table-writes.js +165 -0
- package/dist/next/store/table-writes.js.map +1 -0
- package/dist/next/store/table.d.ts +80 -0
- package/dist/next/store/table.d.ts.map +1 -0
- package/dist/next/store/table.js +103 -0
- package/dist/next/store/table.js.map +1 -0
- package/dist/next/store/text.d.ts +14 -0
- package/dist/next/store/text.d.ts.map +1 -0
- package/dist/next/store/text.js +51 -0
- package/dist/next/store/text.js.map +1 -0
- package/dist/next/store/writes.d.ts +5 -0
- package/dist/next/store/writes.d.ts.map +1 -0
- package/dist/next/store/writes.js +4 -0
- package/dist/next/store/writes.js.map +1 -0
- package/dist/next-node/compression.d.ts +7 -0
- package/dist/next-node/compression.d.ts.map +1 -0
- package/dist/next-node/compression.js +24 -0
- package/dist/next-node/compression.js.map +1 -0
- package/dist/next-node/http/admission.d.ts +63 -0
- package/dist/next-node/http/admission.d.ts.map +1 -0
- package/dist/next-node/http/admission.js +134 -0
- package/dist/next-node/http/admission.js.map +1 -0
- package/dist/next-node/http/authenticate.d.ts +21 -0
- package/dist/next-node/http/authenticate.d.ts.map +1 -0
- package/dist/next-node/http/authenticate.js +34 -0
- package/dist/next-node/http/authenticate.js.map +1 -0
- package/dist/next-node/http/cookies.d.ts +24 -0
- package/dist/next-node/http/cookies.d.ts.map +1 -0
- package/dist/next-node/http/cookies.js +62 -0
- package/dist/next-node/http/cookies.js.map +1 -0
- package/dist/next-node/http/file.d.ts +23 -0
- package/dist/next-node/http/file.d.ts.map +1 -0
- package/dist/next-node/http/file.js +94 -0
- package/dist/next-node/http/file.js.map +1 -0
- package/dist/next-node/http/headers.d.ts +37 -0
- package/dist/next-node/http/headers.d.ts.map +1 -0
- package/dist/next-node/http/headers.js +129 -0
- package/dist/next-node/http/headers.js.map +1 -0
- package/dist/next-node/http/http.d.ts +100 -0
- package/dist/next-node/http/http.d.ts.map +1 -0
- package/dist/next-node/http/http.js +462 -0
- package/dist/next-node/http/http.js.map +1 -0
- package/dist/next-node/http/incoming.d.ts +19 -0
- package/dist/next-node/http/incoming.d.ts.map +1 -0
- package/dist/next-node/http/incoming.js +31 -0
- package/dist/next-node/http/incoming.js.map +1 -0
- package/dist/next-node/http/index.d.ts +11 -0
- package/dist/next-node/http/index.d.ts.map +1 -0
- package/dist/next-node/http/index.js +12 -0
- package/dist/next-node/http/index.js.map +1 -0
- package/dist/next-node/http/node.d.ts +78 -0
- package/dist/next-node/http/node.d.ts.map +1 -0
- package/dist/next-node/http/node.js +291 -0
- package/dist/next-node/http/node.js.map +1 -0
- package/dist/next-node/http/request.d.ts +54 -0
- package/dist/next-node/http/request.d.ts.map +1 -0
- package/dist/next-node/http/request.js +116 -0
- package/dist/next-node/http/request.js.map +1 -0
- package/dist/next-node/http/response.d.ts +63 -0
- package/dist/next-node/http/response.d.ts.map +1 -0
- package/dist/next-node/http/response.js +202 -0
- package/dist/next-node/http/response.js.map +1 -0
- package/dist/next-node/http/router.d.ts +114 -0
- package/dist/next-node/http/router.d.ts.map +1 -0
- package/dist/next-node/http/router.js +261 -0
- package/dist/next-node/http/router.js.map +1 -0
- package/dist/next-node/http/upgrades.d.ts +58 -0
- package/dist/next-node/http/upgrades.d.ts.map +1 -0
- package/dist/next-node/http/upgrades.js +184 -0
- package/dist/next-node/http/upgrades.js.map +1 -0
- package/dist/next-node/plugins/build.d.ts +57 -0
- package/dist/next-node/plugins/build.d.ts.map +1 -0
- package/dist/next-node/plugins/build.js +334 -0
- package/dist/next-node/plugins/build.js.map +1 -0
- package/dist/next-node/plugins/discover.d.ts +36 -0
- package/dist/next-node/plugins/discover.d.ts.map +1 -0
- package/dist/next-node/plugins/discover.js +91 -0
- package/dist/next-node/plugins/discover.js.map +1 -0
- package/dist/next-node/plugins/evaluate.d.ts +33 -0
- package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
- package/dist/next-node/plugins/evaluate.js +98 -0
- package/dist/next-node/plugins/evaluate.js.map +1 -0
- package/dist/next-node/plugins/index.d.ts +9 -0
- package/dist/next-node/plugins/index.d.ts.map +1 -0
- package/dist/next-node/plugins/index.js +11 -0
- package/dist/next-node/plugins/index.js.map +1 -0
- package/dist/next-node/plugins/install.d.ts +13 -0
- package/dist/next-node/plugins/install.d.ts.map +1 -0
- package/dist/next-node/plugins/install.js +37 -0
- package/dist/next-node/plugins/install.js.map +1 -0
- package/dist/next-node/plugins/plugins.d.ts +135 -0
- package/dist/next-node/plugins/plugins.d.ts.map +1 -0
- package/dist/next-node/plugins/plugins.js +206 -0
- package/dist/next-node/plugins/plugins.js.map +1 -0
- package/dist/next-node/plugins/runtime.d.ts +41 -0
- package/dist/next-node/plugins/runtime.d.ts.map +1 -0
- package/dist/next-node/plugins/runtime.js +136 -0
- package/dist/next-node/plugins/runtime.js.map +1 -0
- package/dist/next-node/plugins/stack.d.ts +16 -0
- package/dist/next-node/plugins/stack.d.ts.map +1 -0
- package/dist/next-node/plugins/stack.js +61 -0
- package/dist/next-node/plugins/stack.js.map +1 -0
- package/dist/next-node/plugins/watcher.d.ts +58 -0
- package/dist/next-node/plugins/watcher.d.ts.map +1 -0
- package/dist/next-node/plugins/watcher.js +281 -0
- package/dist/next-node/plugins/watcher.js.map +1 -0
- package/dist/next-node/workers/control.d.ts +83 -0
- package/dist/next-node/workers/control.d.ts.map +1 -0
- package/dist/next-node/workers/control.js +77 -0
- package/dist/next-node/workers/control.js.map +1 -0
- package/dist/next-node/workers/index.d.ts +5 -0
- package/dist/next-node/workers/index.d.ts.map +1 -0
- package/dist/next-node/workers/index.js +7 -0
- package/dist/next-node/workers/index.js.map +1 -0
- package/dist/next-node/workers/lock.d.ts +21 -0
- package/dist/next-node/workers/lock.d.ts.map +1 -0
- package/dist/next-node/workers/lock.js +137 -0
- package/dist/next-node/workers/lock.js.map +1 -0
- package/dist/next-node/workers/main.d.ts +46 -0
- package/dist/next-node/workers/main.d.ts.map +1 -0
- package/dist/next-node/workers/main.js +230 -0
- package/dist/next-node/workers/main.js.map +1 -0
- package/dist/next-node/workers/process.d.ts +42 -0
- package/dist/next-node/workers/process.d.ts.map +1 -0
- package/dist/next-node/workers/process.js +125 -0
- package/dist/next-node/workers/process.js.map +1 -0
- package/dist/next-node/workers/workers.d.ts +80 -0
- package/dist/next-node/workers/workers.d.ts.map +1 -0
- package/dist/next-node/workers/workers.js +572 -0
- package/dist/next-node/workers/workers.js.map +1 -0
- package/dist/object.d.ts +4 -4
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +3 -4
- package/dist/object.js.map +1 -1
- package/dist/output.d.ts +9 -3
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +21 -9
- package/dist/output.js.map +1 -1
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +2 -2
- package/dist/remote.js.map +1 -1
- package/dist/schema.d.ts +8 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +180 -5
- package/dist/schema.js.map +1 -1
- 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 +41 -0
- package/dist/sqlite/node.d.ts.map +1 -0
- package/dist/sqlite/node.js +191 -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/telemetry-sqlite/index.d.ts +24 -0
- package/dist/telemetry-sqlite/index.d.ts.map +1 -0
- package/dist/telemetry-sqlite/index.js +273 -0
- package/dist/telemetry-sqlite/index.js.map +1 -0
- package/dist/telemetry-sqlite/store.d.ts +9 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -0
- package/dist/telemetry-sqlite/store.js +110 -0
- package/dist/telemetry-sqlite/store.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/wire.d.ts +174 -193
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +81 -80
- package/dist/wire.js.map +1 -1
- package/docs/guide.md +15 -15
- package/docs/next/benchmarks.md +959 -0
- package/docs/next/decisions.md +2957 -0
- package/docs/next/dependencies/book.md +1671 -0
- package/docs/next/dependencies/index.html +2641 -0
- package/docs/next/dependencies/model.md +330 -0
- package/docs/next/design.md +2554 -0
- package/docs/next/durable-observers/book.md +432 -0
- package/docs/next/durable-observers/index.html +517 -0
- package/docs/next/flow-control/book.md +333 -0
- package/docs/next/flow-control/fold/index.html +265 -0
- package/docs/next/flow-control/index.html +548 -0
- package/docs/next/flow-control/window/index.html +228 -0
- package/docs/next/guide-plugins-hosts/book.md +607 -0
- package/docs/next/guide-plugins-hosts/index.html +652 -0
- package/docs/next/http-workers/book.md +378 -0
- package/docs/next/http-workers/index.html +515 -0
- package/docs/next/layer-1.md +311 -0
- package/docs/next/layer-2.md +216 -0
- package/docs/next/plugin-model/book.md +186 -0
- package/docs/next/plugin-model/index.html +310 -0
- package/docs/next/plugin-primer/book.md +273 -0
- package/docs/next/plugin-primer/index.html +430 -0
- package/docs/next/slice-1.md +236 -0
- package/docs/next/slice-10.md +285 -0
- package/docs/next/slice-11.md +93 -0
- package/docs/next/slice-2.md +174 -0
- package/docs/next/slice-3a.md +296 -0
- package/docs/next/slice-3b.md +197 -0
- package/docs/next/slice-4.md +146 -0
- package/docs/next/slice-4a.md +418 -0
- package/docs/next/slice-4b.md +208 -0
- package/docs/next/slice-5.md +281 -0
- package/docs/next/slice-6a.md +676 -0
- package/docs/next/slice-6b.md +332 -0
- package/docs/next/slice-7a.md +130 -0
- package/docs/next/slice-7b/book.md +608 -0
- package/docs/next/slice-7b/index.html +842 -0
- package/docs/next/slice-7b.md +255 -0
- package/docs/next/slice-7c.md +165 -0
- package/docs/next/slice-8.md +194 -0
- package/docs/next/slices.md +230 -0
- package/docs/next/store/book.md +665 -0
- package/docs/next/store/index.html +861 -0
- package/docs/next/store/walkthrough.md +193 -0
- package/docs/spec.md +9 -9
- package/docs/tutorial.md +26 -25
- package/package.json +42 -5
- package/src/delta/README.md +69 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// Transactions (§9, R12, R13): drafts of an object's documents, prepared and adopted in one batch, with Chord's own
|
|
2
|
+
// staged changes (job runs, §15), fenced by the token they run under; they run on the object's line (`line.ts`).
|
|
3
|
+
import { withoutAbortSignal } from "../../context/index.js";
|
|
4
|
+
import { track } from "../../delta/index.js";
|
|
5
|
+
import { ChordError } from "../data/index.js";
|
|
6
|
+
import { asChordError } from "../data/internal.js";
|
|
7
|
+
import { refusalOf } from "../store/refusal.js";
|
|
8
|
+
import { TableChanges } from "../store/table-changes.js";
|
|
9
|
+
import { ROWS_PAGE, TableHandle } from "../store/table-handle.js";
|
|
10
|
+
import { checkReadable } from "./persistence.js";
|
|
11
|
+
const IMMEDIATE = { kind: "immediate" };
|
|
12
|
+
/**
|
|
13
|
+
* One transaction of an object, under the seal token of whoever runs it (an attempt, a job run's invocation, the
|
|
14
|
+
* object). Commit prepares every draft (Delta records ops and checks only placed values) and adopts the changed
|
|
15
|
+
* documents and the staged changes in one batch; drafts are revoked once it settles. Cut at its token's seal, it
|
|
16
|
+
* discards everything, releases the line and refuses every later use.
|
|
17
|
+
*/
|
|
18
|
+
export class Transaction {
|
|
19
|
+
#documents;
|
|
20
|
+
token;
|
|
21
|
+
#release;
|
|
22
|
+
#context;
|
|
23
|
+
#entries = new Map();
|
|
24
|
+
/** Chord's own staged changes, by their owner (a job); made by the first. */
|
|
25
|
+
#staged;
|
|
26
|
+
/**
|
|
27
|
+
* The store writes, in staging order, and the store they commit to; made by the first (the flag that sends the
|
|
28
|
+
* commit through the store's step, W12).
|
|
29
|
+
*/
|
|
30
|
+
#writes;
|
|
31
|
+
/** The tables written, each with its writes and overlay. */
|
|
32
|
+
#tables;
|
|
33
|
+
/** `tx.*` reads underway: a callback settling with one is refused (rule 3, as Durable's). */
|
|
34
|
+
#pending = 0;
|
|
35
|
+
/** When its commit reaches the store (a run state's deferred change, D8). */
|
|
36
|
+
#persistence;
|
|
37
|
+
#state = "open";
|
|
38
|
+
/** Rejected by `cut` while the commit waits in the store's queue: its caller is told at once (rule 3). */
|
|
39
|
+
#queued;
|
|
40
|
+
constructor(documents, token, release, context, persistence = IMMEDIATE) {
|
|
41
|
+
this.#documents = documents;
|
|
42
|
+
this.token = token;
|
|
43
|
+
this.#release = release;
|
|
44
|
+
this.#context = context;
|
|
45
|
+
this.#persistence = persistence;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The store writes of this transaction, which `write`s join (Chord's own documents: a job's run records): made by the
|
|
49
|
+
* first, which sends the commit through `store`'s step.
|
|
50
|
+
*/
|
|
51
|
+
stageStore(store) {
|
|
52
|
+
this.#writes ??= { store, staged: [] };
|
|
53
|
+
return this.#writes.staged;
|
|
54
|
+
}
|
|
55
|
+
/** The object whose transaction this is. */
|
|
56
|
+
get documents() {
|
|
57
|
+
return this.#documents;
|
|
58
|
+
}
|
|
59
|
+
draft(handle, key = "") {
|
|
60
|
+
// Not `async`: the draft's promise is returned as it is, without another promise around it (the in-memory path
|
|
61
|
+
// stays as cheap as before the store); a throw still reaches the caller as a rejection.
|
|
62
|
+
let slot;
|
|
63
|
+
let at;
|
|
64
|
+
// Keyed keys follow the text rules (`KeyedSlot.key`); a singleton's key is always "".
|
|
65
|
+
try {
|
|
66
|
+
slot = this.#slotOf(handle);
|
|
67
|
+
at = key === "" ? key : slot.key(key);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return Promise.reject(error);
|
|
71
|
+
}
|
|
72
|
+
// The entry is made for this handle's slot, whose documents are `T`.
|
|
73
|
+
return this.draftSlot(slot, at);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The draft of the document at `key` of `slot` (Chord's own slots, a job's run states). A cold persisted document
|
|
77
|
+
* is loaded first, inside the transaction (it holds the line); the draft counts as pending until it settles (rule
|
|
78
|
+
* 3). A warm draft settles at once.
|
|
79
|
+
*/
|
|
80
|
+
async draftSlot(slot, key) {
|
|
81
|
+
const entry = this.#entry(slot, key);
|
|
82
|
+
const persisted = slot.persisted;
|
|
83
|
+
if (entry.draft !== undefined || entry.retire || persisted?.cold(key) !== true)
|
|
84
|
+
return this.#begin(entry);
|
|
85
|
+
this.#pending++;
|
|
86
|
+
try {
|
|
87
|
+
await persisted.load(key, this.#context, this.token);
|
|
88
|
+
this.#assertOpen();
|
|
89
|
+
return this.#begin(entry);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.#pending--;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async retire(handle, key = "") {
|
|
96
|
+
const slot = this.#slotOf(handle);
|
|
97
|
+
const at = key === "" ? key : slot.key(key);
|
|
98
|
+
const entry = this.retireSlot(slot, at);
|
|
99
|
+
const persisted = slot.persisted;
|
|
100
|
+
// A cold persisted document is found, not loaded (one read; absent: a no-op, R13); a version or fingerprint
|
|
101
|
+
// the code cannot read fails the owner as a load would (R15): a retirement of it is no exception.
|
|
102
|
+
if (entry.found === undefined && persisted?.cold(at)) {
|
|
103
|
+
const found = await this.#track(persisted.persistence.find(at, this.#context));
|
|
104
|
+
// Cut meanwhile: its attempt was sealed, and failing the owner now would fail its successor.
|
|
105
|
+
this.#assertOpen();
|
|
106
|
+
if (found !== undefined)
|
|
107
|
+
checkFound(found, persisted, slot);
|
|
108
|
+
entry.found = found?.stored;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Retires the document at `key` of `slot` when the transaction commits. */
|
|
112
|
+
retireSlot(slot, key) {
|
|
113
|
+
const entry = this.#entry(slot, key);
|
|
114
|
+
entry.draft?.change.abort();
|
|
115
|
+
entry.draft = undefined;
|
|
116
|
+
entry.retire = true;
|
|
117
|
+
return entry;
|
|
118
|
+
}
|
|
119
|
+
start(job, args, options = {}) {
|
|
120
|
+
// Job handles are Chord's own: `self.job` made them.
|
|
121
|
+
return job.stage(this, args, this.#context, options);
|
|
122
|
+
}
|
|
123
|
+
get(table, key) {
|
|
124
|
+
const handle = this.#handle(table);
|
|
125
|
+
const changes = this.#tables?.get(handle);
|
|
126
|
+
const read = changes === undefined ? handle.get(key, this.#context) : changes.get(key, this.#context);
|
|
127
|
+
// The handle's rows are the table's, typed by `C`.
|
|
128
|
+
return this.#track(read);
|
|
129
|
+
}
|
|
130
|
+
page(table, q, limit, options = {}) {
|
|
131
|
+
// As in `get`; the query's table is checked against the handle's.
|
|
132
|
+
const read = this.#handle(table).page(q, limit, this.#context, options);
|
|
133
|
+
return this.#track(read);
|
|
134
|
+
}
|
|
135
|
+
async *rows(table, q) {
|
|
136
|
+
let after;
|
|
137
|
+
do {
|
|
138
|
+
const page = await this.page(table, q, ROWS_PAGE, after === undefined ? {} : { after });
|
|
139
|
+
yield* page.items;
|
|
140
|
+
after = page.next;
|
|
141
|
+
} while (after !== undefined);
|
|
142
|
+
}
|
|
143
|
+
put(table, row) {
|
|
144
|
+
this.#changes(table).put(row);
|
|
145
|
+
}
|
|
146
|
+
update(table, key, set) {
|
|
147
|
+
this.#changes(table).update(key, set);
|
|
148
|
+
}
|
|
149
|
+
delete(table, key) {
|
|
150
|
+
this.#changes(table).delete(key);
|
|
151
|
+
}
|
|
152
|
+
updateWhere(table, where, set) {
|
|
153
|
+
this.#changes(table).updateWhere(where, set);
|
|
154
|
+
}
|
|
155
|
+
deleteWhere(table, where) {
|
|
156
|
+
this.#changes(table).deleteWhere(where);
|
|
157
|
+
}
|
|
158
|
+
/** The changes `owner` staged in this transaction, made by `make` on its first use. */
|
|
159
|
+
stage(owner, make) {
|
|
160
|
+
this.#assertOpen();
|
|
161
|
+
this.#staged ??= new Map();
|
|
162
|
+
let staged = this.#staged.get(owner);
|
|
163
|
+
if (staged === undefined) {
|
|
164
|
+
staged = make();
|
|
165
|
+
this.#staged.set(owner, staged);
|
|
166
|
+
}
|
|
167
|
+
// Each owner stages one kind of change, the one its `make` returns.
|
|
168
|
+
return staged;
|
|
169
|
+
}
|
|
170
|
+
/** The changes `owner` staged in this transaction so far, if any. */
|
|
171
|
+
staged(owner) {
|
|
172
|
+
// As in `stage`: the owner's own kind.
|
|
173
|
+
return this.#staged?.get(owner);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Prepares every draft and adopts what changed, and the staged changes, in one batch; nothing when nothing changed.
|
|
177
|
+
* A document retired and drafted anew is removed, then adopted: its frame carries the retirement. Persisted
|
|
178
|
+
* documents stage their writes here (rule 8), which sends the commit through the store's step.
|
|
179
|
+
*/
|
|
180
|
+
commit() {
|
|
181
|
+
this.#assertOpen();
|
|
182
|
+
if (this.#pending > 0)
|
|
183
|
+
throw new Error(`${this.#documents.label}: the callback settled before its pending tx operations`);
|
|
184
|
+
this.#state = "committing";
|
|
185
|
+
this.#context.abortSignal?.throwIfAborted();
|
|
186
|
+
const adoptions = [];
|
|
187
|
+
for (const entries of this.#entries.values()) {
|
|
188
|
+
for (const entry of entries.values()) {
|
|
189
|
+
let prepared = entry.draft?.change.prepare();
|
|
190
|
+
if (prepared !== undefined && prepared.ops.length === 0) {
|
|
191
|
+
prepared.abort();
|
|
192
|
+
prepared = undefined;
|
|
193
|
+
}
|
|
194
|
+
const { slot, key } = entry;
|
|
195
|
+
const retires = entry.retire && (slot.current(key) !== undefined || entry.found !== undefined);
|
|
196
|
+
if (prepared === undefined && !retires)
|
|
197
|
+
continue;
|
|
198
|
+
const persisted = slot.persisted;
|
|
199
|
+
let stored;
|
|
200
|
+
if (persisted !== undefined) {
|
|
201
|
+
const writes = this.stageStore(persisted.persistence.store);
|
|
202
|
+
const was = persisted.stored(key) ?? entry.found;
|
|
203
|
+
stored = persisted.stage(key, { prepared, retires }, was, writes, this.#persistence);
|
|
204
|
+
}
|
|
205
|
+
adoptions.push({ entry, prepared, retires, stored });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const writes = this.#writes;
|
|
209
|
+
if (writes === undefined) {
|
|
210
|
+
this.#adopt(adoptions);
|
|
211
|
+
this.#state = "committed";
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return this.#step(writes.store, writes.staged, adoptions);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Commits through the store's step (§3): admitted while neither cut nor sealed (else `released`, nothing written),
|
|
218
|
+
* then the documents and staged changes adopted inside the step. Once queued, the caller's abort no longer counts;
|
|
219
|
+
* a cut while queued rejects `released` at once (the queue drops the entry at its admission, writing nothing).
|
|
220
|
+
*/
|
|
221
|
+
async #step(store, staged, adoptions) {
|
|
222
|
+
const fence = {
|
|
223
|
+
admit: () => {
|
|
224
|
+
if (this.#state !== "committing" || this.token.sealed)
|
|
225
|
+
return false;
|
|
226
|
+
this.#state = "stepping";
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
adopt: () => this.#adopt(adoptions),
|
|
230
|
+
};
|
|
231
|
+
this.#queued = Promise.withResolvers();
|
|
232
|
+
try {
|
|
233
|
+
// The race handles the commit's own later rejection too.
|
|
234
|
+
await Promise.race([store.commit(staged, fence, withoutAbortSignal(this.#context)), this.#queued.promise]);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
if (this.#state === "cut")
|
|
238
|
+
throw this.#cutError();
|
|
239
|
+
throw this.#refused(error);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
this.#queued = undefined;
|
|
243
|
+
}
|
|
244
|
+
this.#state = "committed";
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The error a commit the store rejected rejects with (D4): the store's own (`released`, `storage_failed`) as it
|
|
248
|
+
* is; a refused step classified, an `int` `CHECK` failing only this transaction (`invalid/args`), any other refusal
|
|
249
|
+
* failing the live object `broken` too (memory and disk disagree).
|
|
250
|
+
*/
|
|
251
|
+
#refused(error) {
|
|
252
|
+
const refusal = refusalOf(error, this.#documents.label);
|
|
253
|
+
if (refusal === undefined)
|
|
254
|
+
return error;
|
|
255
|
+
if (refusal.kind === "broken")
|
|
256
|
+
this.#documents.fail(refusal.error);
|
|
257
|
+
return refusal.error;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Adopts the changed documents (persisted ones with what the commit stored of them) and the staged changes in one
|
|
261
|
+
* batch; nothing when nothing changed.
|
|
262
|
+
*/
|
|
263
|
+
#adopt(adoptions) {
|
|
264
|
+
const staged = this.#staged;
|
|
265
|
+
if (adoptions.length === 0 && staged === undefined)
|
|
266
|
+
return;
|
|
267
|
+
this.#documents.batch.commit(() => {
|
|
268
|
+
for (const { entry, prepared, retires, stored } of adoptions) {
|
|
269
|
+
if (retires)
|
|
270
|
+
entry.slot.retire(entry.key);
|
|
271
|
+
if (prepared === undefined)
|
|
272
|
+
continue;
|
|
273
|
+
entry.slot.adopt(entry.key, entry.draft.tracker, prepared, stored);
|
|
274
|
+
}
|
|
275
|
+
for (const each of staged?.values() ?? [])
|
|
276
|
+
each.adopt();
|
|
277
|
+
}, this.#context);
|
|
278
|
+
}
|
|
279
|
+
/** Aborts every draft and prepared change. */
|
|
280
|
+
discard() {
|
|
281
|
+
if (this.#state === "cut")
|
|
282
|
+
return;
|
|
283
|
+
this.#state = "discarded";
|
|
284
|
+
this.#abortDrafts();
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Its token was sealed while it held the line: every draft is aborted, the line released, and every later use,
|
|
288
|
+
* its commit included, throws `released`.
|
|
289
|
+
*/
|
|
290
|
+
cut() {
|
|
291
|
+
// A commit admitted to the step runs to its end; one still queued is refused at admission.
|
|
292
|
+
if (this.#state !== "open" && this.#state !== "committing")
|
|
293
|
+
return;
|
|
294
|
+
this.#state = "cut";
|
|
295
|
+
this.#abortDrafts();
|
|
296
|
+
this.#release();
|
|
297
|
+
this.#queued?.reject(this.#cutError());
|
|
298
|
+
}
|
|
299
|
+
/** Tells the staged changes how the transaction ended; runs once the object's line is free. */
|
|
300
|
+
settle() {
|
|
301
|
+
if (this.#staged === undefined)
|
|
302
|
+
return;
|
|
303
|
+
const committed = this.#state === "committed";
|
|
304
|
+
for (const staged of this.#staged.values()) {
|
|
305
|
+
if (committed)
|
|
306
|
+
staged.committed();
|
|
307
|
+
else
|
|
308
|
+
staged.discarded();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
#abortDrafts() {
|
|
312
|
+
for (const entries of this.#entries.values())
|
|
313
|
+
for (const entry of entries.values())
|
|
314
|
+
entry.draft?.change.abort();
|
|
315
|
+
}
|
|
316
|
+
/** The slot behind a handle of this object, after the handle's version fence (R15). */
|
|
317
|
+
#slotOf(handle) {
|
|
318
|
+
// Handles are Chord's own: `self.state` made them.
|
|
319
|
+
const { slot, version } = handle;
|
|
320
|
+
slot.definition.assertVersion(version);
|
|
321
|
+
return slot;
|
|
322
|
+
}
|
|
323
|
+
#entry(slot, key) {
|
|
324
|
+
this.#assertOpen();
|
|
325
|
+
if (slot.owner !== this.#documents) {
|
|
326
|
+
throw new Error(`${this.#documents.label}: a transaction drafts only its own object's documents`);
|
|
327
|
+
}
|
|
328
|
+
let entries = this.#entries.get(slot);
|
|
329
|
+
if (entries === undefined) {
|
|
330
|
+
entries = new Map();
|
|
331
|
+
this.#entries.set(slot, entries);
|
|
332
|
+
}
|
|
333
|
+
let entry = entries.get(key);
|
|
334
|
+
if (entry === undefined) {
|
|
335
|
+
entry = { slot, key, draft: undefined, retire: false, found: undefined };
|
|
336
|
+
entries.set(key, entry);
|
|
337
|
+
}
|
|
338
|
+
return entry;
|
|
339
|
+
}
|
|
340
|
+
#assertOpen() {
|
|
341
|
+
if (this.#state === "open")
|
|
342
|
+
return;
|
|
343
|
+
if (this.#state === "cut")
|
|
344
|
+
throw this.#cutError();
|
|
345
|
+
throw new Error(`${this.#documents.label}: the transaction has settled`);
|
|
346
|
+
}
|
|
347
|
+
#cutError() {
|
|
348
|
+
return new ChordError({
|
|
349
|
+
code: "released",
|
|
350
|
+
reason: "discarded",
|
|
351
|
+
message: `${this.#documents.label}: the transaction was discarded at the seal`,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/** The handle behind `table`, one of this object's tables (another object's is refused). */
|
|
355
|
+
#handle(table) {
|
|
356
|
+
this.#assertOpen();
|
|
357
|
+
// Plugin code may pass any table: only this object's handles are taken.
|
|
358
|
+
const handle = table;
|
|
359
|
+
if (!(handle instanceof TableHandle) || handle.owner.scope !== this.#documents) {
|
|
360
|
+
throw new Error(`${this.#documents.label}: a transaction writes only its own object's tables`);
|
|
361
|
+
}
|
|
362
|
+
handle.assertVersion();
|
|
363
|
+
return handle;
|
|
364
|
+
}
|
|
365
|
+
/** The writes to `table` in this transaction, made by the first. */
|
|
366
|
+
#changes(table) {
|
|
367
|
+
const handle = this.#handle(table);
|
|
368
|
+
this.#tables ??= new Map();
|
|
369
|
+
let changes = this.#tables.get(handle);
|
|
370
|
+
if (changes === undefined) {
|
|
371
|
+
this.#writes ??= { store: handle.store, staged: [] };
|
|
372
|
+
changes = new TableChanges(handle, this.#writes.staged);
|
|
373
|
+
this.#tables.set(handle, changes);
|
|
374
|
+
}
|
|
375
|
+
return changes;
|
|
376
|
+
}
|
|
377
|
+
/** Counts `read` as pending until the operation's promise settles (rule 3). */
|
|
378
|
+
async #track(read) {
|
|
379
|
+
this.#pending++;
|
|
380
|
+
try {
|
|
381
|
+
return await read;
|
|
382
|
+
}
|
|
383
|
+
finally {
|
|
384
|
+
this.#pending--;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/** The entry's draft, begun on the current document (or a fresh `initial()`) by the first use. */
|
|
388
|
+
#begin(entry) {
|
|
389
|
+
if (entry.draft === undefined) {
|
|
390
|
+
const { slot, key } = entry;
|
|
391
|
+
const current = entry.retire ? undefined : slot.current(key);
|
|
392
|
+
const tracker = current ?? track(slot.initial(this.#context));
|
|
393
|
+
entry.draft = { tracker, change: tracker.beginChange() };
|
|
394
|
+
}
|
|
395
|
+
return entry.draft.change.state;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** Throws, failing `slot`'s owner `broken`, when its definition cannot read the cold document `found` (R15). */
|
|
399
|
+
function checkFound(found, persisted, slot) {
|
|
400
|
+
try {
|
|
401
|
+
checkReadable({ version: found.stored.version, fingerprint: found.fingerprint }, persisted.definition.current);
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
const failure = asChordError(error, slot.owner.label);
|
|
405
|
+
slot.owner.fail(failure);
|
|
406
|
+
throw failure;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/next/documents/transaction.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,iHAAiH;AAEjH,OAAO,EAAgB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAwD,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAA+B,SAAS,EAAc,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM3G,OAAO,EAAE,aAAa,EAAsD,MAAM,kBAAkB,CAAC;AA+ErG,MAAM,SAAS,GAAsB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAa3D;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACd,UAAU,CAAY;IACtB,KAAK,CAAY;IACjB,QAAQ,CAAa;IACrB,QAAQ,CAAU;IAClB,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;IAChE,6EAA6E;IAC7E,OAAO,CAAkC;IACzC;;;OAGG;IACH,OAAO,CAA6E;IACpF,4DAA4D;IAC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I,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;IACF,CAAC;IAED,kGAAkG;IAClG,MAAM,CAAC,KAAY;QAClB,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;YAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9D,KAAK,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IACjC,CAAC;CACD;AAED,gHAAgH;AAChH,SAAS,UAAU,CAAC,KAAoB,EAAE,SAAwB,EAAE,IAAkB;IACrF,IAAI,CAAC;QACJ,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAChH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,MAAM,OAAO,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["// Transactions (§9, R12, R13): drafts of an object's documents, prepared and adopted in one batch, with Chord's own\n// staged changes (job runs, §15), fenced by the token they run under; they run on the object's line (`line.ts`).\n\nimport { type Context, withoutAbortSignal } from \"../../context/index.ts\";\nimport { type Change, type Draft, type Prepared, type Tracker, track } from \"../../delta/index.ts\";\nimport { ChordError } from \"../data/index.ts\";\nimport { asChordError } from \"../data/internal.ts\";\nimport type { JobHandle, Outcome, Run, StartOptions } from \"../jobs/index.ts\";\nimport type { Job } from \"../jobs/internal.ts\";\nimport type { Columns, PutRowOf, RowOf } from \"../store/columns.ts\";\nimport type { Condition, SetOf } from \"../store/expression.ts\";\nimport type { ColumnRefs, Query } from \"../store/query.ts\";\nimport { refusalOf } from \"../store/refusal.ts\";\nimport type { StagedWrite } from \"../store/step.ts\";\nimport type { ChordStore } from \"../store/store.ts\";\nimport type { KeyOf } from \"../store/table.ts\";\nimport { TableChanges } from \"../store/table-changes.ts\";\nimport { type Page, type PageOptions, ROWS_PAGE, type Table, TableHandle } from \"../store/table-handle.ts\";\nimport type { CommitPersistence, JsonObject } from \"./definition.ts\";\nimport type { Documents } from \"./documents.ts\";\nimport type { SealToken } from \"./fence.ts\";\nimport type { Keyed, KeyedHandle, Singleton, SingletonHandle } from \"./handles.ts\";\nimport type { KeyedSlot } from \"./keyed-slot.ts\";\nimport { checkReadable, type FoundDocument, type Stored, type StoredChange } from \"./persistence.ts\";\nimport type { DocumentSlot, PersistedSlot, SingletonSlot } from \"./slot.ts\";\n\n/** What `self.tx` gives its callback. Inside it: only `await tx.*`, no other `self.tx`, no calls to other objects. */\nexport interface Tx {\n\t/** The document's draft: the same one for the same document within one transaction. */\n\tdraft<T extends JsonObject>(handle: SingletonHandle<T>): Promise<Draft<T>>;\n\tdraft<T extends JsonObject>(handle: KeyedHandle<T>, key: string): Promise<Draft<T>>;\n\t/** Retires the document when the transaction commits (its address reads `initial()` again); a no-op when it is absent. */\n\tretire(handle: SingletonHandle<JsonObject>): Promise<void>;\n\tretire(handle: KeyedHandle<JsonObject>, key: string): Promise<void>;\n\t/**\n\t * Starts a run of `job`, one of this object's jobs, with this transaction's other writes (§15): both commit or\n\t * neither. Returns its `Run` at once; a discarded transaction's `Run` rejects `released` from `outcome`. A key of an\n\t * unsettled run (one started earlier in this transaction too) returns that run.\n\t */\n\tstart<A, R, S>(job: JobHandle<A, R, S>, args: A, options?: StartOptions): Run<Outcome<A, R, S>>;\n\t/** The row with `key` as this transaction leaves it (its own `put`, `update`, `delete` overlaid; W10). */\n\tget<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tkey: KeyOf<C, K>,\n\t): Promise<RowOf<C> | undefined>;\n\t/** A page of committed rows, stable for the transaction (without its own writes). */\n\tpage<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tq: Query<C, K>,\n\t\tlimit: number,\n\t\toptions?: PageOptions,\n\t): Promise<Page<RowOf<C>>>;\n\t/** Every committed row of `q`, as `page`. */\n\trows<C extends Columns, K extends readonly string[]>(table: Table<C, K>, q: Query<C, K>): AsyncIterable<RowOf<C>>;\n\t/** Writes `row` when the transaction commits (an upsert: the whole row replaced). */\n\tput<C extends Columns, K extends readonly string[]>(table: Table<C, K>, row: PutRowOf<C>): void;\n\t/** Changes the row with `key` when the transaction commits; an absent key changes nothing. */\n\tupdate<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tkey: KeyOf<C, K>,\n\t\tset: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>),\n\t): void;\n\t/** Deletes the row with `key` when the transaction commits. */\n\tdelete<C extends Columns, K extends readonly string[]>(table: Table<C, K>, key: KeyOf<C, K>): void;\n\t/** Changes every row matching `where` when the transaction commits (one statement, its count recorded). */\n\tupdateWhere<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\twhere: (row: ColumnRefs<C>) => Condition,\n\t\tset: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>),\n\t): void;\n\t/** Deletes every row matching `where` when the transaction commits. */\n\tdeleteWhere<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\twhere: (row: ColumnRefs<C>) => Condition,\n\t): void;\n}\n\n/**\n * Chord's own changes staged in a transaction (a job's run records): adopted in its commit step with the documents,\n * then told how the transaction ended, once the owner's line is free.\n */\nexport interface Staged {\n\t/** Adopts the changes, inside the commit's batch. */\n\tadopt(): void;\n\t/** The transaction committed: the actions after the commit (a run starts, waiters settle). */\n\tcommitted(): void;\n\t/** The transaction was discarded: nothing was adopted. */\n\tdiscarded(): void;\n}\n\n/**\n * What one transaction does with one document: a draft, a retirement, or both (retired, then drafted anew); `found`\n * is what is stored of a cold persisted document it retires without loading (R13).\n */\ntype Entry = {\n\treadonly slot: DocumentSlot;\n\treadonly key: string;\n\tdraft: { readonly tracker: Tracker<JsonObject>; readonly change: Change<JsonObject> } | undefined;\n\tretire: boolean;\n\tfound: Stored | undefined;\n};\n\nconst IMMEDIATE: CommitPersistence = { kind: \"immediate\" };\n\n/**\n * One document change a commit adopts: a removal, a draft's prepared change, or both; and for a persisted document\n * what the commit stores of it.\n */\ntype Adoption = {\n\treadonly entry: Entry;\n\treadonly prepared: Prepared<JsonObject> | undefined;\n\treadonly retires: boolean;\n\treadonly stored: StoredChange | undefined;\n};\n\n/**\n * One transaction of an object, under the seal token of whoever runs it (an attempt, a job run's invocation, the\n * object). Commit prepares every draft (Delta records ops and checks only placed values) and adopts the changed\n * documents and the staged changes in one batch; drafts are revoked once it settles. Cut at its token's seal, it\n * discards everything, releases the line and refuses every later use.\n */\nexport class Transaction implements Tx {\n\treadonly #documents: Documents;\n\treadonly token: SealToken;\n\treadonly #release: () => void;\n\treadonly #context: Context;\n\treadonly #entries = new Map<DocumentSlot, Map<string, Entry>>();\n\t/** Chord's own staged changes, by their owner (a job); made by the first. */\n\t#staged: Map<object, Staged> | undefined;\n\t/**\n\t * The store writes, in staging order, and the store they commit to; made by the first (the flag that sends the\n\t * commit through the store's step, W12).\n\t */\n\t#writes: { readonly store: ChordStore; readonly staged: StagedWrite[] } | undefined;\n\t/** The tables written, each with its writes and overlay. */\n\t#tables: Map<TableHandle, TableChanges> | undefined;\n\t/** `tx.*` reads underway: a callback settling with one is refused (rule 3, as Durable's). */\n\t#pending = 0;\n\t/** When its commit reaches the store (a run state's deferred change, D8). */\n\treadonly #persistence: CommitPersistence;\n\t#state: \"open\" | \"committing\" | \"stepping\" | \"committed\" | \"discarded\" | \"cut\" = \"open\";\n\t/** Rejected by `cut` while the commit waits in the store's queue: its caller is told at once (rule 3). */\n\t#queued: PromiseWithResolvers<never> | undefined;\n\n\tconstructor(\n\t\tdocuments: Documents,\n\t\ttoken: SealToken,\n\t\trelease: () => void,\n\t\tcontext: Context,\n\t\tpersistence: CommitPersistence = IMMEDIATE,\n\t) {\n\t\tthis.#documents = documents;\n\t\tthis.token = token;\n\t\tthis.#release = release;\n\t\tthis.#context = context;\n\t\tthis.#persistence = persistence;\n\t}\n\n\t/**\n\t * The store writes of this transaction, which `write`s join (Chord's own documents: a job's run records): made by the\n\t * first, which sends the commit through `store`'s step.\n\t */\n\tstageStore(store: ChordStore): StagedWrite[] {\n\t\tthis.#writes ??= { store, staged: [] };\n\t\treturn this.#writes.staged;\n\t}\n\n\t/** The object whose transaction this is. */\n\tget documents(): Documents {\n\t\treturn this.#documents;\n\t}\n\n\tdraft<T extends JsonObject>(handle: SingletonHandle<T>): Promise<Draft<T>>;\n\tdraft<T extends JsonObject>(handle: KeyedHandle<T>, key: string): Promise<Draft<T>>;\n\tdraft<T extends JsonObject>(handle: SingletonHandle<T> | KeyedHandle<T>, key = \"\"): Promise<Draft<T>> {\n\t\t// Not `async`: the draft's promise is returned as it is, without another promise around it (the in-memory path\n\t\t// stays as cheap as before the store); a throw still reaches the caller as a rejection.\n\t\tlet slot: SingletonSlot | KeyedSlot;\n\t\tlet at: string;\n\t\t// Keyed keys follow the text rules (`KeyedSlot.key`); a singleton's key is always \"\".\n\t\ttry {\n\t\t\tslot = this.#slotOf(handle);\n\t\t\tat = key === \"\" ? key : slot.key(key);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\t// The entry is made for this handle's slot, whose documents are `T`.\n\t\treturn this.draftSlot(slot, at) as Promise<Draft<T>>;\n\t}\n\n\t/**\n\t * The draft of the document at `key` of `slot` (Chord's own slots, a job's run states). A cold persisted document\n\t * is loaded first, inside the transaction (it holds the line); the draft counts as pending until it settles (rule\n\t * 3). A warm draft settles at once.\n\t */\n\tasync draftSlot(slot: DocumentSlot, key: string): Promise<Draft<JsonObject>> {\n\t\tconst entry = this.#entry(slot, key);\n\t\tconst persisted = slot.persisted;\n\t\tif (entry.draft !== undefined || entry.retire || persisted?.cold(key) !== true) return this.#begin(entry);\n\t\tthis.#pending++;\n\t\ttry {\n\t\t\tawait persisted.load(key, this.#context, this.token);\n\t\t\tthis.#assertOpen();\n\t\t\treturn this.#begin(entry);\n\t\t} finally {\n\t\t\tthis.#pending--;\n\t\t}\n\t}\n\n\tretire(handle: SingletonHandle<JsonObject>): Promise<void>;\n\tretire(handle: KeyedHandle<JsonObject>, key: string): Promise<void>;\n\tasync retire(handle: SingletonHandle<JsonObject> | KeyedHandle<JsonObject>, key = \"\"): Promise<void> {\n\t\tconst slot = this.#slotOf(handle);\n\t\tconst at = key === \"\" ? key : slot.key(key);\n\t\tconst entry = this.retireSlot(slot, at);\n\t\tconst persisted = slot.persisted;\n\t\t// A cold persisted document is found, not loaded (one read; absent: a no-op, R13); a version or fingerprint\n\t\t// the code cannot read fails the owner as a load would (R15): a retirement of it is no exception.\n\t\tif (entry.found === undefined && persisted?.cold(at)) {\n\t\t\tconst found = await this.#track(persisted.persistence.find(at, this.#context));\n\t\t\t// Cut meanwhile: its attempt was sealed, and failing the owner now would fail its successor.\n\t\t\tthis.#assertOpen();\n\t\t\tif (found !== undefined) checkFound(found, persisted, slot);\n\t\t\tentry.found = found?.stored;\n\t\t}\n\t}\n\n\t/** Retires the document at `key` of `slot` when the transaction commits. */\n\tretireSlot(slot: DocumentSlot, key: string): Entry {\n\t\tconst entry = this.#entry(slot, key);\n\t\tentry.draft?.change.abort();\n\t\tentry.draft = undefined;\n\t\tentry.retire = true;\n\t\treturn entry;\n\t}\n\n\tstart<A, R, S>(job: JobHandle<A, R, S>, args: A, options: StartOptions = {}): Run<Outcome<A, R, S>> {\n\t\t// Job handles are Chord's own: `self.job` made them.\n\t\treturn (job as unknown as Job).stage(this, args, this.#context, options) as Run<Outcome<A, R, S>>;\n\t}\n\n\tget<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tkey: KeyOf<C, K>,\n\t): Promise<RowOf<C> | undefined> {\n\t\tconst handle = this.#handle(table);\n\t\tconst changes = this.#tables?.get(handle);\n\t\tconst read = changes === undefined ? handle.get(key, this.#context) : changes.get(key, this.#context);\n\t\t// The handle's rows are the table's, typed by `C`.\n\t\treturn this.#track(read) as Promise<RowOf<C> | undefined>;\n\t}\n\n\tpage<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tq: Query<C, K>,\n\t\tlimit: number,\n\t\toptions: PageOptions = {},\n\t): Promise<Page<RowOf<C>>> {\n\t\t// As in `get`; the query's table is checked against the handle's.\n\t\tconst read = this.#handle(table).page(q as unknown as Query, limit, this.#context, options);\n\t\treturn this.#track(read) as Promise<Page<RowOf<C>>>;\n\t}\n\n\tasync *rows<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tq: Query<C, K>,\n\t): AsyncIterable<RowOf<C>> {\n\t\tlet after: string | undefined;\n\t\tdo {\n\t\t\tconst page = await this.page(table, q, ROWS_PAGE, after === undefined ? {} : { after });\n\t\t\tyield* page.items;\n\t\t\tafter = page.next;\n\t\t} while (after !== undefined);\n\t}\n\n\tput<C extends Columns, K extends readonly string[]>(table: Table<C, K>, row: PutRowOf<C>): void {\n\t\tthis.#changes(table).put(row);\n\t}\n\n\tupdate<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\tkey: KeyOf<C, K>,\n\t\tset: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>),\n\t): void {\n\t\tthis.#changes(table).update(key, set);\n\t}\n\n\tdelete<C extends Columns, K extends readonly string[]>(table: Table<C, K>, key: KeyOf<C, K>): void {\n\t\tthis.#changes(table).delete(key);\n\t}\n\n\tupdateWhere<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\twhere: (row: ColumnRefs<C>) => Condition,\n\t\tset: SetOf<C, K> | ((row: ColumnRefs<C>) => SetOf<C, K>),\n\t): void {\n\t\tthis.#changes(table).updateWhere(where, set);\n\t}\n\n\tdeleteWhere<C extends Columns, K extends readonly string[]>(\n\t\ttable: Table<C, K>,\n\t\twhere: (row: ColumnRefs<C>) => Condition,\n\t): void {\n\t\tthis.#changes(table).deleteWhere(where);\n\t}\n\n\t/** The changes `owner` staged in this transaction, made by `make` on its first use. */\n\tstage<S extends Staged>(owner: object, make: () => S): S {\n\t\tthis.#assertOpen();\n\t\tthis.#staged ??= new Map();\n\t\tlet staged = this.#staged.get(owner);\n\t\tif (staged === undefined) {\n\t\t\tstaged = make();\n\t\t\tthis.#staged.set(owner, staged);\n\t\t}\n\t\t// Each owner stages one kind of change, the one its `make` returns.\n\t\treturn staged as S;\n\t}\n\n\t/** The changes `owner` staged in this transaction so far, if any. */\n\tstaged<S extends Staged>(owner: object): S | undefined {\n\t\t// As in `stage`: the owner's own kind.\n\t\treturn this.#staged?.get(owner) as S | undefined;\n\t}\n\n\t/**\n\t * Prepares every draft and adopts what changed, and the staged changes, in one batch; nothing when nothing changed.\n\t * A document retired and drafted anew is removed, then adopted: its frame carries the retirement. Persisted\n\t * documents stage their writes here (rule 8), which sends the commit through the store's step.\n\t */\n\tcommit(): void | Promise<void> {\n\t\tthis.#assertOpen();\n\t\tif (this.#pending > 0)\n\t\t\tthrow new Error(`${this.#documents.label}: the callback settled before its pending tx operations`);\n\t\tthis.#state = \"committing\";\n\t\tthis.#context.abortSignal?.throwIfAborted();\n\t\tconst adoptions: Adoption[] = [];\n\t\tfor (const entries of this.#entries.values()) {\n\t\t\tfor (const entry of entries.values()) {\n\t\t\t\tlet prepared = entry.draft?.change.prepare();\n\t\t\t\tif (prepared !== undefined && prepared.ops.length === 0) {\n\t\t\t\t\tprepared.abort();\n\t\t\t\t\tprepared = undefined;\n\t\t\t\t}\n\t\t\t\tconst { slot, key } = entry;\n\t\t\t\tconst retires = entry.retire && (slot.current(key) !== undefined || entry.found !== undefined);\n\t\t\t\tif (prepared === undefined && !retires) continue;\n\t\t\t\tconst persisted = slot.persisted;\n\t\t\t\tlet stored: StoredChange | undefined;\n\t\t\t\tif (persisted !== undefined) {\n\t\t\t\t\tconst writes = this.stageStore(persisted.persistence.store);\n\t\t\t\t\tconst was = persisted.stored(key) ?? entry.found;\n\t\t\t\t\tstored = persisted.stage(key, { prepared, retires }, was, writes, this.#persistence);\n\t\t\t\t}\n\t\t\t\tadoptions.push({ entry, prepared, retires, stored });\n\t\t\t}\n\t\t}\n\t\tconst writes = this.#writes;\n\t\tif (writes === undefined) {\n\t\t\tthis.#adopt(adoptions);\n\t\t\tthis.#state = \"committed\";\n\t\t\treturn;\n\t\t}\n\t\treturn this.#step(writes.store, writes.staged, adoptions);\n\t}\n\n\t/**\n\t * Commits through the store's step (§3): admitted while neither cut nor sealed (else `released`, nothing written),\n\t * then the documents and staged changes adopted inside the step. Once queued, the caller's abort no longer counts;\n\t * a cut while queued rejects `released` at once (the queue drops the entry at its admission, writing nothing).\n\t */\n\tasync #step(store: ChordStore, staged: readonly StagedWrite[], adoptions: readonly Adoption[]): Promise<void> {\n\t\tconst fence = {\n\t\t\tadmit: () => {\n\t\t\t\tif (this.#state !== \"committing\" || this.token.sealed) return false;\n\t\t\t\tthis.#state = \"stepping\";\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tadopt: () => this.#adopt(adoptions),\n\t\t};\n\t\tthis.#queued = Promise.withResolvers<never>();\n\t\ttry {\n\t\t\t// The race handles the commit's own later rejection too.\n\t\t\tawait Promise.race([store.commit(staged, fence, withoutAbortSignal(this.#context)), this.#queued.promise]);\n\t\t} catch (error) {\n\t\t\tif (this.#state === \"cut\") throw this.#cutError();\n\t\t\tthrow this.#refused(error);\n\t\t} finally {\n\t\t\tthis.#queued = undefined;\n\t\t}\n\t\tthis.#state = \"committed\";\n\t}\n\n\t/**\n\t * The error a commit the store rejected rejects with (D4): the store's own (`released`, `storage_failed`) as it\n\t * is; a refused step classified, an `int` `CHECK` failing only this transaction (`invalid/args`), any other refusal\n\t * failing the live object `broken` too (memory and disk disagree).\n\t */\n\t#refused(error: unknown): unknown {\n\t\tconst refusal = refusalOf(error, this.#documents.label);\n\t\tif (refusal === undefined) return error;\n\t\tif (refusal.kind === \"broken\") this.#documents.fail(refusal.error);\n\t\treturn refusal.error;\n\t}\n\n\t/**\n\t * Adopts the changed documents (persisted ones with what the commit stored of them) and the staged changes in one\n\t * batch; nothing when nothing changed.\n\t */\n\t#adopt(adoptions: readonly Adoption[]): void {\n\t\tconst staged = this.#staged;\n\t\tif (adoptions.length === 0 && staged === undefined) return;\n\t\tthis.#documents.batch.commit(() => {\n\t\t\tfor (const { entry, prepared, retires, stored } of adoptions) {\n\t\t\t\tif (retires) entry.slot.retire(entry.key);\n\t\t\t\tif (prepared === undefined) continue;\n\t\t\t\tentry.slot.adopt(entry.key, entry.draft!.tracker, prepared, stored);\n\t\t\t}\n\t\t\tfor (const each of staged?.values() ?? []) each.adopt();\n\t\t}, this.#context);\n\t}\n\n\t/** Aborts every draft and prepared change. */\n\tdiscard(): void {\n\t\tif (this.#state === \"cut\") return;\n\t\tthis.#state = \"discarded\";\n\t\tthis.#abortDrafts();\n\t}\n\n\t/**\n\t * Its token was sealed while it held the line: every draft is aborted, the line released, and every later use,\n\t * its commit included, throws `released`.\n\t */\n\tcut(): void {\n\t\t// A commit admitted to the step runs to its end; one still queued is refused at admission.\n\t\tif (this.#state !== \"open\" && this.#state !== \"committing\") return;\n\t\tthis.#state = \"cut\";\n\t\tthis.#abortDrafts();\n\t\tthis.#release();\n\t\tthis.#queued?.reject(this.#cutError());\n\t}\n\n\t/** Tells the staged changes how the transaction ended; runs once the object's line is free. */\n\tsettle(): void {\n\t\tif (this.#staged === undefined) return;\n\t\tconst committed = this.#state === \"committed\";\n\t\tfor (const staged of this.#staged.values()) {\n\t\t\tif (committed) staged.committed();\n\t\t\telse staged.discarded();\n\t\t}\n\t}\n\n\t#abortDrafts(): void {\n\t\tfor (const entries of this.#entries.values()) for (const entry of entries.values()) entry.draft?.change.abort();\n\t}\n\n\t/** The slot behind a handle of this object, after the handle's version fence (R15). */\n\t#slotOf(handle: SingletonHandle<JsonObject> | KeyedHandle<JsonObject>): SingletonSlot | KeyedSlot {\n\t\t// Handles are Chord's own: `self.state` made them.\n\t\tconst { slot, version } = handle as Singleton | Keyed;\n\t\tslot.definition.assertVersion(version);\n\t\treturn slot;\n\t}\n\n\t#entry(slot: DocumentSlot, key: string): Entry {\n\t\tthis.#assertOpen();\n\t\tif (slot.owner !== this.#documents) {\n\t\t\tthrow new Error(`${this.#documents.label}: a transaction drafts only its own object's documents`);\n\t\t}\n\t\tlet entries = this.#entries.get(slot);\n\t\tif (entries === undefined) {\n\t\t\tentries = new Map();\n\t\t\tthis.#entries.set(slot, entries);\n\t\t}\n\t\tlet entry = entries.get(key);\n\t\tif (entry === undefined) {\n\t\t\tentry = { slot, key, draft: undefined, retire: false, found: undefined };\n\t\t\tentries.set(key, entry);\n\t\t}\n\t\treturn entry;\n\t}\n\n\t#assertOpen(): void {\n\t\tif (this.#state === \"open\") return;\n\t\tif (this.#state === \"cut\") throw this.#cutError();\n\t\tthrow new Error(`${this.#documents.label}: the transaction has settled`);\n\t}\n\n\t#cutError(): ChordError {\n\t\treturn new ChordError({\n\t\t\tcode: \"released\",\n\t\t\treason: \"discarded\",\n\t\t\tmessage: `${this.#documents.label}: the transaction was discarded at the seal`,\n\t\t});\n\t}\n\n\t/** The handle behind `table`, one of this object's tables (another object's is refused). */\n\t#handle(table: object): TableHandle {\n\t\tthis.#assertOpen();\n\t\t// Plugin code may pass any table: only this object's handles are taken.\n\t\tconst handle = table;\n\t\tif (!(handle instanceof TableHandle) || handle.owner.scope !== this.#documents) {\n\t\t\tthrow new Error(`${this.#documents.label}: a transaction writes only its own object's tables`);\n\t\t}\n\t\thandle.assertVersion();\n\t\treturn handle;\n\t}\n\n\t/** The writes to `table` in this transaction, made by the first. */\n\t#changes(table: object): TableChanges {\n\t\tconst handle = this.#handle(table);\n\t\tthis.#tables ??= new Map();\n\t\tlet changes = this.#tables.get(handle);\n\t\tif (changes === undefined) {\n\t\t\tthis.#writes ??= { store: handle.store, staged: [] };\n\t\t\tchanges = new TableChanges(handle, this.#writes.staged);\n\t\t\tthis.#tables.set(handle, changes);\n\t\t}\n\t\treturn changes;\n\t}\n\n\t/** Counts `read` as pending until the operation's promise settles (rule 3). */\n\tasync #track<T>(read: Promise<T>): Promise<T> {\n\t\tthis.#pending++;\n\t\ttry {\n\t\t\treturn await read;\n\t\t} finally {\n\t\t\tthis.#pending--;\n\t\t}\n\t}\n\n\t/** The entry's draft, begun on the current document (or a fresh `initial()`) by the first use. */\n\t#begin(entry: Entry): Draft<JsonObject> {\n\t\tif (entry.draft === undefined) {\n\t\t\tconst { slot, key } = entry;\n\t\t\tconst current = entry.retire ? undefined : slot.current(key);\n\t\t\tconst tracker = current ?? track(slot.initial(this.#context));\n\t\t\tentry.draft = { tracker, change: tracker.beginChange() };\n\t\t}\n\t\treturn entry.draft.change.state;\n\t}\n}\n\n/** Throws, failing `slot`'s owner `broken`, when its definition cannot read the cold document `found` (R15). */\nfunction checkFound(found: FoundDocument, persisted: PersistedSlot, slot: DocumentSlot): void {\n\ttry {\n\t\tcheckReadable({ version: found.stored.version, fingerprint: found.fingerprint }, persisted.definition.current);\n\t} catch (error) {\n\t\tconst failure = asChordError(error, slot.owner.label);\n\t\tslot.owner.fail(failure);\n\t\tthrow failure;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Context } from "../../context/index.ts";
|
|
2
|
+
import type { JsonValue } from "../../json.ts";
|
|
3
|
+
import { Source } from "../state/internal.ts";
|
|
4
|
+
/** What `host.activity` counts. */
|
|
5
|
+
export type ActivityCounts = {
|
|
6
|
+
/** Holds arriving over links and served here. */
|
|
7
|
+
readonly references: number;
|
|
8
|
+
/** Method calls running on this host, local and remote. */
|
|
9
|
+
readonly calls: number;
|
|
10
|
+
/** Running jobs (slice 5). */
|
|
11
|
+
readonly jobs: number;
|
|
12
|
+
/** Objects kept live by their type's `linger` after their last reference. */
|
|
13
|
+
readonly lingering: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* `host.activity`. A count marks it changed; while it is watched or derived from, the first change of a microtask turn
|
|
17
|
+
* schedules one publication, a batch that gives its watches the counts as they are then (`[["r", counts]]`: a slow
|
|
18
|
+
* watch gets the newest counts) and marks derives over it. Its value is built from the counters when read or
|
|
19
|
+
* published.
|
|
20
|
+
*/
|
|
21
|
+
export declare class Activity extends Source {
|
|
22
|
+
#private;
|
|
23
|
+
get value(): JsonValue;
|
|
24
|
+
/**
|
|
25
|
+
* Adds `delta` to the count of `kind`; published with the turn's other changes. Nothing is scheduled while nobody
|
|
26
|
+
* watches or derives from it: a later watch or derive reads the counts as they are then.
|
|
27
|
+
*/
|
|
28
|
+
count(kind: keyof ActivityCounts, delta: number): void;
|
|
29
|
+
deliver(context: Context): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=activity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/next/host/activity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,mCAAmC;AACnC,MAAM,MAAM,cAAc,GAAG;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,MAAM;;IAMnC,IAAI,KAAK,IAAI,SAAS,CAGrB;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CASrD;IAED,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAG9B;CACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Keep-alive counts (§3, R26): `host.activity`, a JSON watchable of the work keeping a host busy, for the app's
|
|
2
|
+
// supervisor. Counters are kept where the work happens; their changes in one microtask turn are one publication.
|
|
3
|
+
import { BACKGROUND_CONTEXT } from "../../context/index.js";
|
|
4
|
+
import { Source } from "../state/internal.js";
|
|
5
|
+
/**
|
|
6
|
+
* `host.activity`. A count marks it changed; while it is watched or derived from, the first change of a microtask turn
|
|
7
|
+
* schedules one publication, a batch that gives its watches the counts as they are then (`[["r", counts]]`: a slow
|
|
8
|
+
* watch gets the newest counts) and marks derives over it. Its value is built from the counters when read or
|
|
9
|
+
* published.
|
|
10
|
+
*/
|
|
11
|
+
export class Activity extends Source {
|
|
12
|
+
#counts = { references: 0, calls: 0, jobs: 0, lingering: 0 };
|
|
13
|
+
/** The counts as last read, until the next change. */
|
|
14
|
+
#value;
|
|
15
|
+
#scheduled = false;
|
|
16
|
+
get value() {
|
|
17
|
+
this.#value ??= { ...this.#counts };
|
|
18
|
+
return this.#value;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Adds `delta` to the count of `kind`; published with the turn's other changes. Nothing is scheduled while nobody
|
|
22
|
+
* watches or derives from it: a later watch or derive reads the counts as they are then.
|
|
23
|
+
*/
|
|
24
|
+
count(kind, delta) {
|
|
25
|
+
this.#counts[kind] += delta;
|
|
26
|
+
this.#value = undefined;
|
|
27
|
+
if (this.#scheduled || (!this.watched && this.dependents.size === 0))
|
|
28
|
+
return;
|
|
29
|
+
this.#scheduled = true;
|
|
30
|
+
queueMicrotask(() => {
|
|
31
|
+
this.#scheduled = false;
|
|
32
|
+
this.batch.within(() => this.changed(), BACKGROUND_CONTEXT);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
deliver(context) {
|
|
36
|
+
const value = this.value;
|
|
37
|
+
this.publish(value, [["r", value]], false, context);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../src/next/host/activity.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,iHAAiH;AAEjH,OAAO,EAAE,kBAAkB,EAAgB,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAc9C;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,MAAM;IAC1B,OAAO,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACtE,sDAAsD;IACtD,MAAM,CAA6B;IACnC,UAAU,GAAG,KAAK,CAAC;IAEnB,IAAI,KAAK;QACR,IAAI,CAAC,MAAM,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAA0B,EAAE,KAAa;QAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC;YAAE,OAAO;QAC7E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,cAAc,CAAC,GAAG,EAAE;YACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,kBAAkB,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,OAAgB;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;CACD","sourcesContent":["// Keep-alive counts (§3, R26): `host.activity`, a JSON watchable of the work keeping a host busy, for the app's\n// supervisor. Counters are kept where the work happens; their changes in one microtask turn are one publication.\n\nimport { BACKGROUND_CONTEXT, type Context } from \"../../context/index.ts\";\nimport type { JsonValue } from \"../../json.ts\";\nimport { Source } from \"../state/internal.ts\";\n\n/** What `host.activity` counts. */\nexport type ActivityCounts = {\n\t/** Holds arriving over links and served here. */\n\treadonly references: number;\n\t/** Method calls running on this host, local and remote. */\n\treadonly calls: number;\n\t/** Running jobs (slice 5). */\n\treadonly jobs: number;\n\t/** Objects kept live by their type's `linger` after their last reference. */\n\treadonly lingering: number;\n};\n\n/**\n * `host.activity`. A count marks it changed; while it is watched or derived from, the first change of a microtask turn\n * schedules one publication, a batch that gives its watches the counts as they are then (`[[\"r\", counts]]`: a slow\n * watch gets the newest counts) and marks derives over it. Its value is built from the counters when read or\n * published.\n */\nexport class Activity extends Source {\n\treadonly #counts = { references: 0, calls: 0, jobs: 0, lingering: 0 };\n\t/** The counts as last read, until the next change. */\n\t#value: ActivityCounts | undefined;\n\t#scheduled = false;\n\n\tget value(): JsonValue {\n\t\tthis.#value ??= { ...this.#counts };\n\t\treturn this.#value;\n\t}\n\n\t/**\n\t * Adds `delta` to the count of `kind`; published with the turn's other changes. Nothing is scheduled while nobody\n\t * watches or derives from it: a later watch or derive reads the counts as they are then.\n\t */\n\tcount(kind: keyof ActivityCounts, delta: number): void {\n\t\tthis.#counts[kind] += delta;\n\t\tthis.#value = undefined;\n\t\tif (this.#scheduled || (!this.watched && this.dependents.size === 0)) return;\n\t\tthis.#scheduled = true;\n\t\tqueueMicrotask(() => {\n\t\t\tthis.#scheduled = false;\n\t\t\tthis.batch.within(() => this.changed(), BACKGROUND_CONTEXT);\n\t\t});\n\t}\n\n\tdeliver(context: Context): void {\n\t\tconst value = this.value;\n\t\tthis.publish(value, [[\"r\", value]], false, context);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { JsonValue } from "../../json.ts";
|
|
2
|
+
import { ChordError } from "../data/index.ts";
|
|
3
|
+
import type { Batch } from "../state/batch.ts";
|
|
4
|
+
import { type DeriveSource } from "../state/internal.ts";
|
|
5
|
+
import type { Served } from "./object.ts";
|
|
6
|
+
/** What the mappings of one instance read: its provider, its variant, its own members, its host's batch and reports. */
|
|
7
|
+
export type AdaptedInstance = {
|
|
8
|
+
readonly served: Served;
|
|
9
|
+
readonly variant: string | undefined;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly batch: Batch;
|
|
12
|
+
/** The instance's state member `member` (`invalid/member` when its variant has none). */
|
|
13
|
+
member(member: string): DeriveSource;
|
|
14
|
+
/** Reports a mapping derive's failure (`derive_failed`). */
|
|
15
|
+
report(member: string, error: unknown): void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Why consumers of the older `version` cannot bind to `served`'s `variant`: a version it does not accept, or a member
|
|
19
|
+
* of it the provider refuses (`contract_mismatch`); `undefined` when they can.
|
|
20
|
+
*/
|
|
21
|
+
export declare function refusal(served: Served, version: number, variant: string | undefined): ChordError | undefined;
|
|
22
|
+
/** One instance's members as the consumers of one older version read them. */
|
|
23
|
+
export declare class AdaptedMembers {
|
|
24
|
+
#private;
|
|
25
|
+
readonly version: number;
|
|
26
|
+
constructor(instance: AdaptedInstance, version: number);
|
|
27
|
+
/**
|
|
28
|
+
* State member `member` as this version reads it, made by the first use; `contract_mismatch` when the provider
|
|
29
|
+
* refuses it or does not accept this version.
|
|
30
|
+
*/
|
|
31
|
+
member(member: string): DeriveSource;
|
|
32
|
+
/**
|
|
33
|
+
* The document `document` at a key of keyed member `member` as this version reads it: the document itself when
|
|
34
|
+
* unchanged, else a derive of it through the mapping, shared by its holders; `release` (once per call) lets the last
|
|
35
|
+
* holder's go. `contract_mismatch` when the provider refuses the member.
|
|
36
|
+
*/
|
|
37
|
+
key(member: string, document: DeriveSource): {
|
|
38
|
+
readonly source: DeriveSource;
|
|
39
|
+
release(): void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The provider's mapping of keyed member `member`'s documents to this version's shape (`undefined`: unchanged),
|
|
43
|
+
* counted; throws `contract_mismatch` when the provider refuses it.
|
|
44
|
+
*/
|
|
45
|
+
keyed(member: string): ((current: JsonValue) => JsonValue) | undefined;
|
|
46
|
+
/** Its instance ended, or the version's last reference left: its derives go (their watches end with `error`). */
|
|
47
|
+
detach(error: Error): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=adapted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapted.d.ts","sourceRoot":"","sources":["../../../src/next/host/adapted.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB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