@earendil-works/chord 1.4.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 +41 -0
- package/README.md +79 -14
- 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 +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/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 +1 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +4 -2
- package/dist/output.js.map +1 -1
- package/dist/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 +2 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -1
- package/dist/sqlite/cloudflare.js +10 -0
- package/dist/sqlite/cloudflare.js.map +1 -1
- package/dist/sqlite/database.d.ts +5 -2
- package/dist/sqlite/database.d.ts.map +1 -1
- package/dist/sqlite/database.js.map +1 -1
- package/dist/sqlite/node.d.ts +4 -1
- package/dist/sqlite/node.d.ts.map +1 -1
- package/dist/sqlite/node.js +22 -5
- package/dist/sqlite/node.js.map +1 -1
- 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 +22 -6
- package/src/delta/README.md +69 -0
package/dist/wire.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Value } from "typebox/value";
|
|
1
|
+
import { arr, bool, compile, int, lit, map, num, obj, oneOf, opt, str, union, unknown, } from "@earendil-works/pi-schema";
|
|
3
2
|
import { DescriptionSchema } from "./contract.js";
|
|
4
3
|
import { CHORD_ERROR_CODES, ChordError } from "./errors.js";
|
|
5
4
|
// JSON frames between two hosts (or a host and a client). Ids are chosen by the side that creates the hold, call or
|
|
@@ -20,46 +19,48 @@ import { CHORD_ERROR_CODES, ChordError } from "./errors.js";
|
|
|
20
19
|
* (`LinkOptions.onProtocolMismatch`).
|
|
21
20
|
*/
|
|
22
21
|
export const PROTOCOL_VERSION = 4;
|
|
23
|
-
const Id =
|
|
24
|
-
const Name =
|
|
25
|
-
const Reload =
|
|
26
|
-
/** Arrays a sender may pass as readonly. */
|
|
27
|
-
const List = (item) =>
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
const Id = int({ minimum: 1 });
|
|
23
|
+
const Name = str({ minLength: 1 });
|
|
24
|
+
const Reload = int({ minimum: 1 });
|
|
25
|
+
/** Arrays a sender may pass as readonly: the same schema, a readonly type. */
|
|
26
|
+
const List = (item) => arr(item);
|
|
27
|
+
/** An object that admits fields it does not name (a newer peer's), as every frame does. */
|
|
28
|
+
const Open = (properties) => obj(properties, { open: true });
|
|
29
|
+
const RootRefSchema = Open({ rootId: Name, codeVersion: int({ minimum: 1 }) });
|
|
30
|
+
const WireErrorSchema = Open({
|
|
31
|
+
code: oneOf(CHORD_ERROR_CODES),
|
|
32
|
+
message: str(),
|
|
33
|
+
reason: opt(str()),
|
|
33
34
|
});
|
|
34
|
-
const WireReloadOptionsSchema =
|
|
35
|
-
remove:
|
|
36
|
-
gateDeadline:
|
|
37
|
-
retireDeadline:
|
|
35
|
+
const WireReloadOptionsSchema = Open({
|
|
36
|
+
remove: opt(List(str())),
|
|
37
|
+
gateDeadline: opt(num()),
|
|
38
|
+
retireDeadline: opt(num()),
|
|
38
39
|
});
|
|
39
40
|
/** A child's prepared reload, sent with its vote (same fields as `ReloadReport`, without children). */
|
|
40
|
-
const WireReloadReportSchema =
|
|
41
|
-
codeVersion:
|
|
42
|
-
previous:
|
|
43
|
-
changed: List(
|
|
44
|
-
removed: List(
|
|
45
|
-
prepared: List(
|
|
46
|
-
gated: List(
|
|
41
|
+
const WireReloadReportSchema = Open({
|
|
42
|
+
codeVersion: int(),
|
|
43
|
+
previous: int(),
|
|
44
|
+
changed: List(str()),
|
|
45
|
+
removed: List(str()),
|
|
46
|
+
prepared: List(str()),
|
|
47
|
+
gated: List(str()),
|
|
47
48
|
});
|
|
48
|
-
const FrameSchema =
|
|
49
|
-
|
|
50
|
-
t:
|
|
49
|
+
const FrameSchema = union([
|
|
50
|
+
Open({
|
|
51
|
+
t: lit("hello"),
|
|
51
52
|
/** The link protocol version (`PROTOCOL_VERSION`; absent: 1). Peers of another version close the link. */
|
|
52
|
-
protocol:
|
|
53
|
+
protocol: opt(int({ minimum: 1 })),
|
|
53
54
|
name: Name,
|
|
54
|
-
kind:
|
|
55
|
-
codeVersion:
|
|
55
|
+
kind: union([lit("host"), lit("client")]),
|
|
56
|
+
codeVersion: int({ minimum: 0 }),
|
|
56
57
|
/** The sender acknowledges what it receives (`ack`). Flow control applies only when both hellos say so. */
|
|
57
|
-
acks:
|
|
58
|
+
acks: opt(bool()),
|
|
58
59
|
}),
|
|
59
60
|
/** Every frame received so far except `ack` frames, counted from the link's start, once processed. */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
t:
|
|
61
|
+
Open({ t: lit("ack"), n: int({ minimum: 1 }) }),
|
|
62
|
+
Open({
|
|
63
|
+
t: lit("hold"),
|
|
63
64
|
id: Id,
|
|
64
65
|
/**
|
|
65
66
|
* Target host name, resolved by the consumer from the token's `host` and `input`. Relays route on it after
|
|
@@ -69,90 +70,90 @@ const FrameSchema = Type.Union([
|
|
|
69
70
|
/** The consumer's contract token; the provider checks that it covers it. Remote tokens carry `host`. */
|
|
70
71
|
token: DescriptionSchema,
|
|
71
72
|
/** Normalized with the consumer's contract. */
|
|
72
|
-
input:
|
|
73
|
+
input: unknown(),
|
|
73
74
|
/** A forwarded principal. Honored only on frames from the parent link. */
|
|
74
|
-
principal:
|
|
75
|
+
principal: opt(unknown()),
|
|
75
76
|
/**
|
|
76
77
|
* The client connection the hold comes from: an opaque id the server assigned to it, forwarded by relays. Honored
|
|
77
78
|
* only on frames from the parent link; present means the hold is a client's (not a reload participant).
|
|
78
79
|
*/
|
|
79
|
-
origin:
|
|
80
|
+
origin: opt(Name),
|
|
80
81
|
/** False: no state for this hold until `sub` (a method-only binding). */
|
|
81
|
-
state:
|
|
82
|
+
state: opt(lit(false)),
|
|
82
83
|
/** The consumer already has values (a re-hold after a link loss): its unit is not urgent. */
|
|
83
|
-
again:
|
|
84
|
+
again: opt(lit(true)),
|
|
84
85
|
}),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
t:
|
|
86
|
+
Open({ t: lit("release"), id: Id }),
|
|
87
|
+
Open({
|
|
88
|
+
t: lit("shape"),
|
|
88
89
|
id: Id,
|
|
89
|
-
variant:
|
|
90
|
-
members: List(
|
|
91
|
-
contract:
|
|
90
|
+
variant: opt(str()),
|
|
91
|
+
members: List(str()),
|
|
92
|
+
contract: str(),
|
|
92
93
|
/** The state members whose snapshots follow this frame; the consumer applies the shape once they are here. */
|
|
93
94
|
state: List(Name),
|
|
94
95
|
}),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
t:
|
|
96
|
+
Open({ t: lit("gone"), id: Id, error: WireErrorSchema }),
|
|
97
|
+
Open({
|
|
98
|
+
t: lit("call"),
|
|
98
99
|
id: Id,
|
|
99
100
|
hold: Id,
|
|
100
101
|
member: Name,
|
|
101
|
-
args:
|
|
102
|
+
args: opt(unknown()),
|
|
102
103
|
/** Absent: the receiving host starts a root (browsers never carry roots). */
|
|
103
|
-
root:
|
|
104
|
+
root: opt(RootRefSchema),
|
|
104
105
|
}),
|
|
105
|
-
|
|
106
|
-
t:
|
|
106
|
+
Open({
|
|
107
|
+
t: lit("result"),
|
|
107
108
|
id: Id,
|
|
108
|
-
value:
|
|
109
|
-
error:
|
|
109
|
+
value: opt(unknown()),
|
|
110
|
+
error: opt(WireErrorSchema),
|
|
110
111
|
}),
|
|
111
|
-
|
|
112
|
+
Open({ t: lit("cancel"), id: Id }),
|
|
112
113
|
/** Starts the state of a hold opened with `state: false` (answered with a unit). */
|
|
113
|
-
|
|
114
|
+
Open({ t: lit("sub"), hold: Id }),
|
|
114
115
|
/** Stops the state of a hold. */
|
|
115
|
-
|
|
116
|
+
Open({ t: lit("unsub"), hold: Id }),
|
|
116
117
|
/** Sends member `m` again as a reset (a relay that had to drop what waited for it). */
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
t:
|
|
118
|
+
Open({ t: lit("resync"), hold: Id, m: Name }),
|
|
119
|
+
Open({
|
|
120
|
+
t: lit("state"),
|
|
120
121
|
hold: Id,
|
|
121
122
|
m: Name,
|
|
122
123
|
/** `snap`/`reset` without `value`: the value is `undefined`. */
|
|
123
|
-
as:
|
|
124
|
-
value:
|
|
124
|
+
as: union([lit("snap"), lit("reset"), lit("ops"), lit("error")]),
|
|
125
|
+
value: opt(unknown()),
|
|
125
126
|
/** Encoded with the stream's delta encoder; the decoder validates each op. */
|
|
126
|
-
ops:
|
|
127
|
-
error:
|
|
127
|
+
ops: opt(List(List(unknown()))),
|
|
128
|
+
error: opt(WireErrorSchema),
|
|
128
129
|
}),
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
Open({ t: lit("ping"), n: int() }),
|
|
131
|
+
Open({ t: lit("pong"), n: int() }),
|
|
131
132
|
/** Ends the link (consumed by the link itself). `reason: "protocol-version <n>"`: the sender speaks version n. */
|
|
132
|
-
|
|
133
|
+
Open({ t: lit("bye"), reason: opt(str()) }),
|
|
133
134
|
/** The root ended at its origin: its leases on objects end (sent on every link the root's calls used). */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
t:
|
|
135
|
+
Open({ t: lit("root_end"), rootId: Name }),
|
|
136
|
+
Open({ t: lit("invalidate"), pattern: map(unknown()) }),
|
|
137
|
+
Open({
|
|
138
|
+
t: lit("prepare"),
|
|
138
139
|
reload: Reload,
|
|
139
|
-
codeVersion:
|
|
140
|
-
plugins: List(
|
|
140
|
+
codeVersion: int({ minimum: 1 }),
|
|
141
|
+
plugins: List(str()),
|
|
141
142
|
options: WireReloadOptionsSchema,
|
|
142
143
|
}),
|
|
143
|
-
|
|
144
|
-
t:
|
|
144
|
+
Open({
|
|
145
|
+
t: lit("vote"),
|
|
145
146
|
reload: Reload,
|
|
146
|
-
error:
|
|
147
|
-
report:
|
|
147
|
+
error: opt(WireErrorSchema),
|
|
148
|
+
report: opt(WireReloadReportSchema),
|
|
148
149
|
}),
|
|
149
|
-
|
|
150
|
+
Open({ t: lit("commit"), reload: Reload }),
|
|
150
151
|
/** The parent dropped `codeVersion`: roots of it may still come from there no longer. */
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
Open({ t: lit("retire"), codeVersion: int({ minimum: 1 }) }),
|
|
153
|
+
Open({ t: lit("abort"), reload: Reload }),
|
|
153
154
|
]);
|
|
154
155
|
/** A frame that passes validation; anything else is a protocol violation. */
|
|
155
|
-
export const isFrame = (
|
|
156
|
+
export const isFrame = compile(FrameSchema).check;
|
|
156
157
|
export function toWireError(error) {
|
|
157
158
|
if (error instanceof ChordError) {
|
|
158
159
|
return error.reason === undefined
|
package/dist/wire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D,oHAAoH;AACpH,0EAA0E;AAC1E,yEAAyE;AACzE,oDAAoD;AACpD,uHAAuH;AACvH,iEAAiE;AACjE,6GAA6G;AAC7G,yBAAyB;AACzB,EAAE;AACF,wHAAwH;AACxH,mHAAmH;AACnH,mFAAmF;AAEnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AACxC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3C,MAAM,MAAM,G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EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACjG,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAc,EAAE,CAC7D,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC","sourcesContent":["import { type Static, type TSchema, Type } from \"typebox\";\nimport { Value } from \"typebox/value\";\nimport { DescriptionSchema } from \"./contract.ts\";\nimport { CHORD_ERROR_CODES, ChordError } from \"./errors.ts\";\n\n// JSON frames between two hosts (or a host and a client). Ids are chosen by the side that creates the hold, call or\n// subscription; every frame type has one direction, so ids never collide:\n// consumer → provider: hold, release, call, cancel, sub, unsub, resync\n// provider → consumer: shape, gone, result, state\n// State is addressed by (hold id, member): a hold implies the state of its variant, sent as units (a shape followed by\n// a snapshot of each member the consumer lacks; see Connection).\n// both: hello, ping, pong, bye, root_end, ack; parent → child: invalidate, prepare, commit, abort, retire;\n// child → parent: vote\n//\n// Each frame is declared once, as the schema every received frame is checked against (`isFrame`); the types are derived\n// from it. Payloads (hold inputs, call args, results, snapshots) stay `unknown`: they are validated where they are\n// used, against the contract. State ops are checked op by op by the delta decoder.\n\n/**\n * The link protocol version, announced in `hello`. Peers of different versions do not talk: the side that notices\n * closes the link with reason `protocol-version <its version>`, so the other side learns it too\n * (`LinkOptions.onProtocolMismatch`).\n */\nexport const PROTOCOL_VERSION = 4;\n\nconst Id = Type.Integer({ minimum: 1 });\nconst Name = Type.String({ minLength: 1 });\nconst Reload = Type.Integer({ minimum: 1 });\n/** Arrays a sender may pass as readonly. */\nconst List = <T extends TSchema>(item: T) => Type.Immutable(Type.Array(item));\n\nconst RootRefSchema = Type.Object({ rootId: Name, codeVersion: Type.Integer({ minimum: 1 }) });\nexport type RootRef = Static<typeof RootRefSchema>;\n\nconst WireErrorSchema = Type.Object({\n\tcode: Type.Enum(CHORD_ERROR_CODES),\n\tmessage: Type.String(),\n\treason: Type.Optional(Type.String()),\n});\nexport type WireError = Static<typeof WireErrorSchema>;\n\nconst WireReloadOptionsSchema = Type.Object({\n\tremove: Type.Optional(List(Type.String())),\n\tgateDeadline: Type.Optional(Type.Number()),\n\tretireDeadline: Type.Optional(Type.Number()),\n});\nexport type WireReloadOptions = Static<typeof WireReloadOptionsSchema>;\n\n/** A child's prepared reload, sent with its vote (same fields as `ReloadReport`, without children). */\nconst WireReloadReportSchema = Type.Object({\n\tcodeVersion: Type.Integer(),\n\tprevious: Type.Integer(),\n\tchanged: List(Type.String()),\n\tremoved: List(Type.String()),\n\tprepared: List(Type.String()),\n\tgated: List(Type.String()),\n});\nexport type WireReloadReport = Static<typeof WireReloadReportSchema>;\n\nconst FrameSchema = Type.Union([\n\tType.Object({\n\t\tt: Type.Literal(\"hello\"),\n\t\t/** The link protocol version (`PROTOCOL_VERSION`; absent: 1). Peers of another version close the link. */\n\t\tprotocol: Type.Optional(Type.Integer({ minimum: 1 })),\n\t\tname: Name,\n\t\tkind: Type.Union([Type.Literal(\"host\"), Type.Literal(\"client\")]),\n\t\tcodeVersion: Type.Integer({ minimum: 0 }),\n\t\t/** The sender acknowledges what it receives (`ack`). Flow control applies only when both hellos say so. */\n\t\tacks: Type.Optional(Type.Boolean()),\n\t}),\n\t/** Every frame received so far except `ack` frames, counted from the link's start, once processed. */\n\tType.Object({ t: Type.Literal(\"ack\"), n: Type.Integer({ minimum: 1 }) }),\n\tType.Object({\n\t\tt: Type.Literal(\"hold\"),\n\t\tid: Id,\n\t\t/**\n\t\t * Target host name, resolved by the consumer from the token's `host` and `input`. Relays route on it after\n\t\t * checking it against both; the target refuses an input its own contract places elsewhere.\n\t\t */\n\t\tat: Name,\n\t\t/** The consumer's contract token; the provider checks that it covers it. Remote tokens carry `host`. */\n\t\ttoken: DescriptionSchema,\n\t\t/** Normalized with the consumer's contract. */\n\t\tinput: Type.Unknown(),\n\t\t/** A forwarded principal. Honored only on frames from the parent link. */\n\t\tprincipal: Type.Optional(Type.Unknown()),\n\t\t/**\n\t\t * The client connection the hold comes from: an opaque id the server assigned to it, forwarded by relays. Honored\n\t\t * only on frames from the parent link; present means the hold is a client's (not a reload participant).\n\t\t */\n\t\torigin: Type.Optional(Name),\n\t\t/** False: no state for this hold until `sub` (a method-only binding). */\n\t\tstate: Type.Optional(Type.Literal(false)),\n\t\t/** The consumer already has values (a re-hold after a link loss): its unit is not urgent. */\n\t\tagain: Type.Optional(Type.Literal(true)),\n\t}),\n\tType.Object({ t: Type.Literal(\"release\"), id: Id }),\n\tType.Object({\n\t\tt: Type.Literal(\"shape\"),\n\t\tid: Id,\n\t\tvariant: Type.Optional(Type.String()),\n\t\tmembers: List(Type.String()),\n\t\tcontract: Type.String(),\n\t\t/** The state members whose snapshots follow this frame; the consumer applies the shape once they are here. */\n\t\tstate: List(Name),\n\t}),\n\tType.Object({ t: Type.Literal(\"gone\"), id: Id, error: WireErrorSchema }),\n\tType.Object({\n\t\tt: Type.Literal(\"call\"),\n\t\tid: Id,\n\t\thold: Id,\n\t\tmember: Name,\n\t\targs: Type.Optional(Type.Unknown()),\n\t\t/** Absent: the receiving host starts a root (browsers never carry roots). */\n\t\troot: Type.Optional(RootRefSchema),\n\t}),\n\tType.Object({\n\t\tt: Type.Literal(\"result\"),\n\t\tid: Id,\n\t\tvalue: Type.Optional(Type.Unknown()),\n\t\terror: Type.Optional(WireErrorSchema),\n\t}),\n\tType.Object({ t: Type.Literal(\"cancel\"), id: Id }),\n\t/** Starts the state of a hold opened with `state: false` (answered with a unit). */\n\tType.Object({ t: Type.Literal(\"sub\"), hold: Id }),\n\t/** Stops the state of a hold. */\n\tType.Object({ t: Type.Literal(\"unsub\"), hold: Id }),\n\t/** Sends member `m` again as a reset (a relay that had to drop what waited for it). */\n\tType.Object({ t: Type.Literal(\"resync\"), hold: Id, m: Name }),\n\tType.Object({\n\t\tt: Type.Literal(\"state\"),\n\t\thold: Id,\n\t\tm: Name,\n\t\t/** `snap`/`reset` without `value`: the value is `undefined`. */\n\t\tas: Type.Union([Type.Literal(\"snap\"), Type.Literal(\"reset\"), Type.Literal(\"ops\"), Type.Literal(\"error\")]),\n\t\tvalue: Type.Optional(Type.Unknown()),\n\t\t/** Encoded with the stream's delta encoder; the decoder validates each op. */\n\t\tops: Type.Optional(List(List(Type.Unknown()))),\n\t\terror: Type.Optional(WireErrorSchema),\n\t}),\n\tType.Object({ t: Type.Literal(\"ping\"), n: Type.Integer() }),\n\tType.Object({ t: Type.Literal(\"pong\"), n: Type.Integer() }),\n\t/** Ends the link (consumed by the link itself). `reason: \"protocol-version <n>\"`: the sender speaks version n. */\n\tType.Object({ t: Type.Literal(\"bye\"), reason: Type.Optional(Type.String()) }),\n\t/** The root ended at its origin: its leases on objects end (sent on every link the root's calls used). */\n\tType.Object({ t: Type.Literal(\"root_end\"), rootId: Name }),\n\tType.Object({ t: Type.Literal(\"invalidate\"), pattern: Type.Record(Type.String(), Type.Unknown()) }),\n\tType.Object({\n\t\tt: Type.Literal(\"prepare\"),\n\t\treload: Reload,\n\t\tcodeVersion: Type.Integer({ minimum: 1 }),\n\t\tplugins: List(Type.String()),\n\t\toptions: WireReloadOptionsSchema,\n\t}),\n\tType.Object({\n\t\tt: Type.Literal(\"vote\"),\n\t\treload: Reload,\n\t\terror: Type.Optional(WireErrorSchema),\n\t\treport: Type.Optional(WireReloadReportSchema),\n\t}),\n\tType.Object({ t: Type.Literal(\"commit\"), reload: Reload }),\n\t/** The parent dropped `codeVersion`: roots of it may still come from there no longer. */\n\tType.Object({ t: Type.Literal(\"retire\"), codeVersion: Type.Integer({ minimum: 1 }) }),\n\tType.Object({ t: Type.Literal(\"abort\"), reload: Reload }),\n]);\nexport type Frame = Static<typeof FrameSchema>;\n\n/** A frame that passes validation; anything else is a protocol violation. */\nexport const isFrame = (value: unknown): value is Frame => Value.Check(FrameSchema, value);\n\nexport function toWireError(error: unknown): WireError {\n\tif (error instanceof ChordError) {\n\t\treturn error.reason === undefined\n\t\t\t? { code: error.code, message: error.message }\n\t\t\t: { code: error.code, message: error.message, reason: error.reason };\n\t}\n\treturn { code: \"unavailable\", message: error instanceof Error ? error.message : String(error) };\n}\n\nexport const fromWireError = (error: WireError): ChordError =>\n\tnew ChordError(error.code, error.message.replace(/^[a-z_]+(\\/[a-z_]+)?: /, \"\"), { reason: error.reason });\n"]}
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EACH,IAAI,EACJ,OAAO,EACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,KAAK,EACL,GAAG,EAIH,GAAG,EACH,KAAK,EACL,OAAO,GACP,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D,oHAAoH;AACpH,0EAA0E;AAC1E,yEAAyE;AACzE,oDAAoD;AACpD,uHAAuH;AACvH,iEAAiE;AACjE,6GAA6G;AAC7G,yBAAyB;AACzB,EAAE;AACF,wHAAwH;AACxH,mHAAmH;AACnH,mFAAmF;AAEnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AACnC,8EAA8E;A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AAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC","sourcesContent":["import {\n\tarr,\n\tbool,\n\tcompile,\n\tint,\n\tlit,\n\tmap,\n\tnum,\n\tobj,\n\toneOf,\n\topt,\n\ttype Properties,\n\ttype Schema,\n\ttype Static,\n\tstr,\n\tunion,\n\tunknown,\n} from \"@earendil-works/pi-schema\";\nimport { DescriptionSchema } from \"./contract.ts\";\nimport { CHORD_ERROR_CODES, ChordError } from \"./errors.ts\";\n\n// JSON frames between two hosts (or a host and a client). Ids are chosen by the side that creates the hold, call or\n// subscription; every frame type has one direction, so ids never collide:\n// consumer → provider: hold, release, call, cancel, sub, unsub, resync\n// provider → consumer: shape, gone, result, state\n// State is addressed by (hold id, member): a hold implies the state of its variant, sent as units (a shape followed by\n// a snapshot of each member the consumer lacks; see Connection).\n// both: hello, ping, pong, bye, root_end, ack; parent → child: invalidate, prepare, commit, abort, retire;\n// child → parent: vote\n//\n// Each frame is declared once, as the schema every received frame is checked against (`isFrame`); the types are derived\n// from it. Payloads (hold inputs, call args, results, snapshots) stay `unknown`: they are validated where they are\n// used, against the contract. State ops are checked op by op by the delta decoder.\n\n/**\n * The link protocol version, announced in `hello`. Peers of different versions do not talk: the side that notices\n * closes the link with reason `protocol-version <its version>`, so the other side learns it too\n * (`LinkOptions.onProtocolMismatch`).\n */\nexport const PROTOCOL_VERSION = 4;\n\nconst Id = int({ minimum: 1 });\nconst Name = str({ minLength: 1 });\nconst Reload = int({ minimum: 1 });\n/** Arrays a sender may pass as readonly: the same schema, a readonly type. */\nconst List = <T>(item: Schema<T>) => arr(item) as Schema<readonly T[]>;\n/** An object that admits fields it does not name (a newer peer's), as every frame does. */\nconst Open = <const P extends Properties>(properties: P) => obj(properties, { open: true });\n\nconst RootRefSchema = Open({ rootId: Name, codeVersion: int({ minimum: 1 }) });\nexport type RootRef = Static<typeof RootRefSchema>;\n\nconst WireErrorSchema = Open({\n\tcode: oneOf(CHORD_ERROR_CODES),\n\tmessage: str(),\n\treason: opt(str()),\n});\nexport type WireError = Static<typeof WireErrorSchema>;\n\nconst WireReloadOptionsSchema = Open({\n\tremove: opt(List(str())),\n\tgateDeadline: opt(num()),\n\tretireDeadline: opt(num()),\n});\nexport type WireReloadOptions = Static<typeof WireReloadOptionsSchema>;\n\n/** A child's prepared reload, sent with its vote (same fields as `ReloadReport`, without children). */\nconst WireReloadReportSchema = Open({\n\tcodeVersion: int(),\n\tprevious: int(),\n\tchanged: List(str()),\n\tremoved: List(str()),\n\tprepared: List(str()),\n\tgated: List(str()),\n});\nexport type WireReloadReport = Static<typeof WireReloadReportSchema>;\n\nconst FrameSchema = union([\n\tOpen({\n\t\tt: lit(\"hello\"),\n\t\t/** The link protocol version (`PROTOCOL_VERSION`; absent: 1). Peers of another version close the link. */\n\t\tprotocol: opt(int({ minimum: 1 })),\n\t\tname: Name,\n\t\tkind: union([lit(\"host\"), lit(\"client\")]),\n\t\tcodeVersion: int({ minimum: 0 }),\n\t\t/** The sender acknowledges what it receives (`ack`). Flow control applies only when both hellos say so. */\n\t\tacks: opt(bool()),\n\t}),\n\t/** Every frame received so far except `ack` frames, counted from the link's start, once processed. */\n\tOpen({ t: lit(\"ack\"), n: int({ minimum: 1 }) }),\n\tOpen({\n\t\tt: lit(\"hold\"),\n\t\tid: Id,\n\t\t/**\n\t\t * Target host name, resolved by the consumer from the token's `host` and `input`. Relays route on it after\n\t\t * checking it against both; the target refuses an input its own contract places elsewhere.\n\t\t */\n\t\tat: Name,\n\t\t/** The consumer's contract token; the provider checks that it covers it. Remote tokens carry `host`. */\n\t\ttoken: DescriptionSchema,\n\t\t/** Normalized with the consumer's contract. */\n\t\tinput: unknown(),\n\t\t/** A forwarded principal. Honored only on frames from the parent link. */\n\t\tprincipal: opt(unknown()),\n\t\t/**\n\t\t * The client connection the hold comes from: an opaque id the server assigned to it, forwarded by relays. Honored\n\t\t * only on frames from the parent link; present means the hold is a client's (not a reload participant).\n\t\t */\n\t\torigin: opt(Name),\n\t\t/** False: no state for this hold until `sub` (a method-only binding). */\n\t\tstate: opt(lit(false)),\n\t\t/** The consumer already has values (a re-hold after a link loss): its unit is not urgent. */\n\t\tagain: opt(lit(true)),\n\t}),\n\tOpen({ t: lit(\"release\"), id: Id }),\n\tOpen({\n\t\tt: lit(\"shape\"),\n\t\tid: Id,\n\t\tvariant: opt(str()),\n\t\tmembers: List(str()),\n\t\tcontract: str(),\n\t\t/** The state members whose snapshots follow this frame; the consumer applies the shape once they are here. */\n\t\tstate: List(Name),\n\t}),\n\tOpen({ t: lit(\"gone\"), id: Id, error: WireErrorSchema }),\n\tOpen({\n\t\tt: lit(\"call\"),\n\t\tid: Id,\n\t\thold: Id,\n\t\tmember: Name,\n\t\targs: opt(unknown()),\n\t\t/** Absent: the receiving host starts a root (browsers never carry roots). */\n\t\troot: opt(RootRefSchema),\n\t}),\n\tOpen({\n\t\tt: lit(\"result\"),\n\t\tid: Id,\n\t\tvalue: opt(unknown()),\n\t\terror: opt(WireErrorSchema),\n\t}),\n\tOpen({ t: lit(\"cancel\"), id: Id }),\n\t/** Starts the state of a hold opened with `state: false` (answered with a unit). */\n\tOpen({ t: lit(\"sub\"), hold: Id }),\n\t/** Stops the state of a hold. */\n\tOpen({ t: lit(\"unsub\"), hold: Id }),\n\t/** Sends member `m` again as a reset (a relay that had to drop what waited for it). */\n\tOpen({ t: lit(\"resync\"), hold: Id, m: Name }),\n\tOpen({\n\t\tt: lit(\"state\"),\n\t\thold: Id,\n\t\tm: Name,\n\t\t/** `snap`/`reset` without `value`: the value is `undefined`. */\n\t\tas: union([lit(\"snap\"), lit(\"reset\"), lit(\"ops\"), lit(\"error\")]),\n\t\tvalue: opt(unknown()),\n\t\t/** Encoded with the stream's delta encoder; the decoder validates each op. */\n\t\tops: opt(List(List(unknown()))),\n\t\terror: opt(WireErrorSchema),\n\t}),\n\tOpen({ t: lit(\"ping\"), n: int() }),\n\tOpen({ t: lit(\"pong\"), n: int() }),\n\t/** Ends the link (consumed by the link itself). `reason: \"protocol-version <n>\"`: the sender speaks version n. */\n\tOpen({ t: lit(\"bye\"), reason: opt(str()) }),\n\t/** The root ended at its origin: its leases on objects end (sent on every link the root's calls used). */\n\tOpen({ t: lit(\"root_end\"), rootId: Name }),\n\tOpen({ t: lit(\"invalidate\"), pattern: map(unknown()) }),\n\tOpen({\n\t\tt: lit(\"prepare\"),\n\t\treload: Reload,\n\t\tcodeVersion: int({ minimum: 1 }),\n\t\tplugins: List(str()),\n\t\toptions: WireReloadOptionsSchema,\n\t}),\n\tOpen({\n\t\tt: lit(\"vote\"),\n\t\treload: Reload,\n\t\terror: opt(WireErrorSchema),\n\t\treport: opt(WireReloadReportSchema),\n\t}),\n\tOpen({ t: lit(\"commit\"), reload: Reload }),\n\t/** The parent dropped `codeVersion`: roots of it may still come from there no longer. */\n\tOpen({ t: lit(\"retire\"), codeVersion: int({ minimum: 1 }) }),\n\tOpen({ t: lit(\"abort\"), reload: Reload }),\n]);\nexport type Frame = Static<typeof FrameSchema>;\n\n/** A frame that passes validation; anything else is a protocol violation. */\nexport const isFrame: (value: unknown) => value is Frame = compile(FrameSchema).check;\n\nexport function toWireError(error: unknown): WireError {\n\tif (error instanceof ChordError) {\n\t\treturn error.reason === undefined\n\t\t\t? { code: error.code, message: error.message }\n\t\t\t: { code: error.code, message: error.message, reason: error.reason };\n\t}\n\treturn { code: \"unavailable\", message: error instanceof Error ? error.message : String(error) };\n}\n\nexport const fromWireError = (error: WireError): ChordError =>\n\tnew ChordError(error.code, error.message.replace(/^[a-z_]+(\\/[a-z_]+)?: /, \"\"), { reason: error.reason });\n"]}
|
package/docs/guide.md
CHANGED
|
@@ -36,17 +36,17 @@ Chord builds applications out of **objects** that live in several processes (a s
|
|
|
36
36
|
## Quick start
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import {
|
|
39
|
+
import { num, obj, str } from "@earendil-works/pi-schema";
|
|
40
40
|
import { createHost, method, remote } from "@earendil-works/chord";
|
|
41
41
|
|
|
42
42
|
// contract.ts: shared by provider and consumers
|
|
43
43
|
export const Counter = remote("demo.counter", {
|
|
44
44
|
version: 1,
|
|
45
|
-
input:
|
|
45
|
+
input: obj({ name: str() }),
|
|
46
46
|
variants: {
|
|
47
47
|
default: {
|
|
48
|
-
state: { count:
|
|
49
|
-
methods: { increment: method(
|
|
48
|
+
state: { count: num() },
|
|
49
|
+
methods: { increment: method(obj({ by: num() })) },
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
});
|
|
@@ -54,7 +54,7 @@ export const Counter = remote("demo.counter", {
|
|
|
54
54
|
const host = createHost({ name: "server", self: { kind: "server" } });
|
|
55
55
|
|
|
56
56
|
host.serve(Counter, ({ name }, _principal, self) => {
|
|
57
|
-
const count = self.state("count",
|
|
57
|
+
const count = self.state("count", num(), 0);
|
|
58
58
|
return {
|
|
59
59
|
variant: "default",
|
|
60
60
|
count,
|
|
@@ -82,7 +82,7 @@ Remote types can be reached from other hosts. Everything that crosses the wire h
|
|
|
82
82
|
```ts
|
|
83
83
|
export const Chat = remote("pi.chat", {
|
|
84
84
|
version: 1,
|
|
85
|
-
input:
|
|
85
|
+
input: obj({ session: str(), conversation: num() }),
|
|
86
86
|
host: hostFamily("session:", "session"), // lives on `session:S1` for `{ session: "S1", … }`
|
|
87
87
|
variants: {
|
|
88
88
|
viewer: {
|
|
@@ -91,7 +91,7 @@ export const Chat = remote("pi.chat", {
|
|
|
91
91
|
participant: {
|
|
92
92
|
state: { view: ConversationViewSchema },
|
|
93
93
|
methods: {
|
|
94
|
-
send: method(SendInputSchema,
|
|
94
|
+
send: method(SendInputSchema, obj({ submissionId: num() })),
|
|
95
95
|
stop: method(), // no arguments, no result: `chat.stop(ctx)`
|
|
96
96
|
},
|
|
97
97
|
},
|
|
@@ -119,10 +119,10 @@ Local types are reachable only inside their host. Their members may be anything:
|
|
|
119
119
|
```ts
|
|
120
120
|
export const Index = local("pi.index", {
|
|
121
121
|
version: 1,
|
|
122
|
-
input:
|
|
122
|
+
input: obj({ session: str() }),
|
|
123
123
|
members: {
|
|
124
|
-
search: method(
|
|
125
|
-
onChange: method(
|
|
124
|
+
search: method(obj({ query: str() }), arr(HitSchema)),
|
|
125
|
+
onChange: method({ type: "function", parameters: [ChangeSchema], returnType: { type: "void" } }, UnsubscribeSchema),
|
|
126
126
|
harness: opaque("pi.durable-harness@1"),
|
|
127
127
|
},
|
|
128
128
|
});
|
|
@@ -181,7 +181,7 @@ A reload runs the factory again over the same object. Declarations that keep som
|
|
|
181
181
|
```ts
|
|
182
182
|
host.serve(StatusStore, ({ session }, _host, self) => {
|
|
183
183
|
const status = self.state("status", StatusSchema, { running: false, tasks: 0 });
|
|
184
|
-
const errors = self.state("errors",
|
|
184
|
+
const errors = self.state("errors", arr(str()), []);
|
|
185
185
|
const catalog = self.get(Catalog, {});
|
|
186
186
|
const db = self.resource("db", {
|
|
187
187
|
version: 1,
|
|
@@ -230,7 +230,7 @@ host.serve(Visits, (_, _p, self) => {
|
|
|
230
230
|
|
|
231
231
|
// right
|
|
232
232
|
host.serve(Visits, (_, _p, self) => {
|
|
233
|
-
const visits = self.state("visits",
|
|
233
|
+
const visits = self.state("visits", num(), 0);
|
|
234
234
|
return {
|
|
235
235
|
hit: async (ctx) => {
|
|
236
236
|
visits.change(ctx, (n) => n + 1);
|
|
@@ -240,7 +240,7 @@ host.serve(Visits, (_, _p, self) => {
|
|
|
240
240
|
});
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
**Methods** are declared with `method(args?, result?)` in the contract. Without `args` a method takes none: callers write `ref.hit(ctx)` (or `ref.hit()`), and its implementation is `(ctx) => …`. Without `result` it returns nothing: the implementation returns nothing, and callers get `undefined`. `method(undefined,
|
|
243
|
+
**Methods** are declared with `method(args?, result?)` in the contract. Without `args` a method takes none: callers write `ref.hit(ctx)` (or `ref.hit()`), and its implementation is `(ctx) => …`. Without `result` it returns nothing: the implementation returns nothing, and callers get `undefined`. `method(undefined, num())` takes no arguments and returns a number.
|
|
244
244
|
|
|
245
245
|
## Activation
|
|
246
246
|
|
|
@@ -428,7 +428,7 @@ chat.release();
|
|
|
428
428
|
## State
|
|
429
429
|
|
|
430
430
|
```ts
|
|
431
|
-
const todos = self.state("todos",
|
|
431
|
+
const todos = self.state("todos", arr(TodoSchema), []);
|
|
432
432
|
|
|
433
433
|
todos.change(ctx, (draft) => {
|
|
434
434
|
draft.push({ id: "t1", text: "Write docs", done: false });
|
|
@@ -457,7 +457,7 @@ view.replace(ctx, rebuilt, { diff: true }); // always diff
|
|
|
457
457
|
|
|
458
458
|
```ts
|
|
459
459
|
const db = self.resource("db", { version: 1, open: () => openSqlite(path), close: (db) => db.close() });
|
|
460
|
-
const notes = self.state("notes",
|
|
460
|
+
const notes = self.state("notes", arr(NoteSchema), { init: () => db.value.all("SELECT * FROM notes") });
|
|
461
461
|
```
|
|
462
462
|
|
|
463
463
|
`init(ctx)` runs once the resources are open and the references live, before the object goes live, so no method,
|