@rikalabs/akter 0.1.0-alpha.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 +15 -0
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +116 -0
- package/dist/actor/codecs.d.ts +77 -0
- package/dist/actor/codecs.js +87 -0
- package/dist/actor/connections.d.ts +34 -0
- package/dist/actor/connections.js +145 -0
- package/dist/actor/definition.d.ts +893 -0
- package/dist/actor/definition.js +147 -0
- package/dist/actor/descriptor.d.ts +172 -0
- package/dist/actor/descriptor.js +367 -0
- package/dist/actor/handles.d.ts +77 -0
- package/dist/actor/handles.js +265 -0
- package/dist/actor/jobs.d.ts +10 -0
- package/dist/actor/jobs.js +137 -0
- package/dist/actor/layers.d.ts +41 -0
- package/dist/actor/layers.js +177 -0
- package/dist/actor/reads.d.ts +47 -0
- package/dist/actor/reads.js +224 -0
- package/dist/actor/served.d.ts +120 -0
- package/dist/actor/served.js +72 -0
- package/dist/actor/turns.d.ts +13 -0
- package/dist/actor/turns.js +332 -0
- package/dist/actor/workflows.d.ts +16 -0
- package/dist/actor/workflows.js +37 -0
- package/dist/client/calls.d.ts +47 -0
- package/dist/client/calls.js +425 -0
- package/dist/client/clock.d.ts +56 -0
- package/dist/client/clock.js +119 -0
- package/dist/client/fleet-page.d.ts +15 -0
- package/dist/client/fleet-page.js +13 -0
- package/dist/client/fleet.d.ts +29 -0
- package/dist/client/fleet.js +51 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.js +6 -0
- package/dist/client/make.d.ts +157 -0
- package/dist/client/make.js +221 -0
- package/dist/client/offline/queue.d.ts +118 -0
- package/dist/client/offline/queue.js +292 -0
- package/dist/client/offline/store.d.ts +74 -0
- package/dist/client/offline/store.js +78 -0
- package/dist/client/optimistic.d.ts +57 -0
- package/dist/client/optimistic.js +136 -0
- package/dist/client/report.d.ts +2 -0
- package/dist/client/report.js +8 -0
- package/dist/client/sessions/connection.d.ts +118 -0
- package/dist/client/sessions/connection.js +162 -0
- package/dist/client/sessions/feed.d.ts +42 -0
- package/dist/client/sessions/feed.js +43 -0
- package/dist/client/sessions/sse.d.ts +47 -0
- package/dist/client/sessions/sse.js +112 -0
- package/dist/client/sessions/stream.d.ts +28 -0
- package/dist/client/sessions/stream.js +35 -0
- package/dist/client/sessions/watch.d.ts +34 -0
- package/dist/client/sessions/watch.js +40 -0
- package/dist/client/transport.d.ts +37 -0
- package/dist/client/transport.js +66 -0
- package/dist/contexts/command.d.ts +132 -0
- package/dist/contexts/command.js +20 -0
- package/dist/contexts/connection.d.ts +68 -0
- package/dist/contexts/connection.js +0 -0
- package/dist/contexts/job.d.ts +49 -0
- package/dist/contexts/job.js +0 -0
- package/dist/contexts/workflow.d.ts +147 -0
- package/dist/contexts/workflow.js +22 -0
- package/dist/errors/actor.d.ts +200 -0
- package/dist/errors/actor.js +271 -0
- package/dist/errors/content.d.ts +19 -0
- package/dist/errors/content.js +14 -0
- package/dist/errors/database.d.ts +22 -0
- package/dist/errors/database.js +23 -0
- package/dist/errors/events.d.ts +17 -0
- package/dist/errors/events.js +14 -0
- package/dist/errors/subscription.d.ts +12 -0
- package/dist/errors/subscription.js +8 -0
- package/dist/errors/workflow.d.ts +28 -0
- package/dist/errors/workflow.js +17 -0
- package/dist/handles/actors.d.ts +17 -0
- package/dist/handles/actors.js +7 -0
- package/dist/handles/content.d.ts +59 -0
- package/dist/handles/content.js +36 -0
- package/dist/handles/intents.d.ts +164 -0
- package/dist/handles/intents.js +214 -0
- package/dist/handles/run.d.ts +31 -0
- package/dist/handles/run.js +21 -0
- package/dist/handles/workflow.d.ts +27 -0
- package/dist/handles/workflow.js +23 -0
- package/dist/identity/caller.d.ts +105 -0
- package/dist/identity/caller.js +68 -0
- package/dist/identity/child.d.ts +18 -0
- package/dist/identity/child.js +39 -0
- package/dist/identity/command.d.ts +19 -0
- package/dist/identity/command.js +21 -0
- package/dist/identity/connection.d.ts +24 -0
- package/dist/identity/connection.js +29 -0
- package/dist/identity/content.d.ts +18 -0
- package/dist/identity/content.js +12 -0
- package/dist/identity/digest.d.ts +4 -0
- package/dist/identity/digest.js +5 -0
- package/dist/identity/execution.d.ts +32 -0
- package/dist/identity/execution.js +63 -0
- package/dist/identity/mint.d.ts +51 -0
- package/dist/identity/mint.js +76 -0
- package/dist/identity/version.d.ts +2 -0
- package/dist/identity/version.js +3 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +97 -0
- package/dist/members/blob.d.ts +43 -0
- package/dist/members/blob.js +29 -0
- package/dist/members/command.d.ts +109 -0
- package/dist/members/command.js +61 -0
- package/dist/members/connection.d.ts +55 -0
- package/dist/members/connection.js +49 -0
- package/dist/members/event.d.ts +36 -0
- package/dist/members/event.js +24 -0
- package/dist/members/job.d.ts +157 -0
- package/dist/members/job.js +67 -0
- package/dist/members/payload.d.ts +93 -0
- package/dist/members/payload.js +145 -0
- package/dist/members/reducer.d.ts +64 -0
- package/dist/members/reducer.js +27 -0
- package/dist/members/stream.d.ts +36 -0
- package/dist/members/stream.js +14 -0
- package/dist/members/subscription.d.ts +182 -0
- package/dist/members/subscription.js +91 -0
- package/dist/members/workflow.d.ts +99 -0
- package/dist/members/workflow.js +2 -0
- package/dist/policies/access.d.ts +35 -0
- package/dist/policies/access.js +6 -0
- package/dist/policies/command.d.ts +127 -0
- package/dist/policies/command.js +45 -0
- package/dist/policies/job.d.ts +28 -0
- package/dist/policies/job.js +60 -0
- package/dist/policies/schedules.d.ts +33 -0
- package/dist/policies/schedules.js +131 -0
- package/dist/protocol/frames.d.ts +66 -0
- package/dist/protocol/frames.js +55 -0
- package/dist/protocol/inspection.d.ts +807 -0
- package/dist/protocol/inspection.js +243 -0
- package/dist/protocol/wire.d.ts +184 -0
- package/dist/protocol/wire.js +150 -0
- package/dist/runtime/actors.d.ts +155 -0
- package/dist/runtime/actors.js +4 -0
- package/dist/runtime/admission.d.ts +34 -0
- package/dist/runtime/admission.js +72 -0
- package/dist/runtime/adoption/backfill.d.ts +27 -0
- package/dist/runtime/adoption/backfill.js +144 -0
- package/dist/runtime/adoption/enforce.d.ts +55 -0
- package/dist/runtime/adoption/enforce.js +241 -0
- package/dist/runtime/adoption/observe.d.ts +43 -0
- package/dist/runtime/adoption/observe.js +139 -0
- package/dist/runtime/adoption/plan.d.ts +45 -0
- package/dist/runtime/adoption/plan.js +192 -0
- package/dist/runtime/adoption/startup.d.ts +32 -0
- package/dist/runtime/adoption/startup.js +76 -0
- package/dist/runtime/adoption/status.d.ts +23 -0
- package/dist/runtime/adoption/status.js +47 -0
- package/dist/runtime/adoption/target.d.ts +33 -0
- package/dist/runtime/adoption/target.js +49 -0
- package/dist/runtime/connections/holder.d.ts +221 -0
- package/dist/runtime/connections/holder.js +816 -0
- package/dist/runtime/connections/owner.d.ts +263 -0
- package/dist/runtime/connections/owner.js +896 -0
- package/dist/runtime/connections/protocol.d.ts +441 -0
- package/dist/runtime/connections/protocol.js +222 -0
- package/dist/runtime/connections/reads.d.ts +24 -0
- package/dist/runtime/connections/reads.js +19 -0
- package/dist/runtime/connections/streams.d.ts +62 -0
- package/dist/runtime/connections/streams.js +128 -0
- package/dist/runtime/connections/transport.d.ts +40 -0
- package/dist/runtime/connections/transport.js +68 -0
- package/dist/runtime/connections/watch.d.ts +52 -0
- package/dist/runtime/connections/watch.js +159 -0
- package/dist/runtime/content/grant.d.ts +34 -0
- package/dist/runtime/content/grant.js +58 -0
- package/dist/runtime/content/store.d.ts +63 -0
- package/dist/runtime/content/store.js +294 -0
- package/dist/runtime/cron/key.d.ts +2 -0
- package/dist/runtime/cron/key.js +2 -0
- package/dist/runtime/cron/schedule.d.ts +69 -0
- package/dist/runtime/cron/schedule.js +144 -0
- package/dist/runtime/database/bounded.d.ts +43 -0
- package/dist/runtime/database/bounded.js +108 -0
- package/dist/runtime/database/connection.d.ts +8 -0
- package/dist/runtime/database/connection.js +18 -0
- package/dist/runtime/database/coordination.d.ts +19 -0
- package/dist/runtime/database/coordination.js +72 -0
- package/dist/runtime/database/flock.d.ts +10 -0
- package/dist/runtime/database/flock.js +60 -0
- package/dist/runtime/database/gate.d.ts +26 -0
- package/dist/runtime/database/gate.js +54 -0
- package/dist/runtime/database/keepalive.d.ts +11 -0
- package/dist/runtime/database/keepalive.js +22 -0
- package/dist/runtime/database/migrations.d.ts +177 -0
- package/dist/runtime/database/migrations.js +1018 -0
- package/dist/runtime/database/neki/migrations.d.ts +31 -0
- package/dist/runtime/database/neki/migrations.js +276 -0
- package/dist/runtime/database/neki/session.d.ts +23 -0
- package/dist/runtime/database/neki/session.js +31 -0
- package/dist/runtime/database/pglite.d.ts +21 -0
- package/dist/runtime/database/pglite.js +74 -0
- package/dist/runtime/database/replica.d.ts +41 -0
- package/dist/runtime/database/replica.js +51 -0
- package/dist/runtime/database/shards.d.ts +21 -0
- package/dist/runtime/database/shards.js +37 -0
- package/dist/runtime/database/snapshot.d.ts +7 -0
- package/dist/runtime/database/snapshot.js +7 -0
- package/dist/runtime/database/tenancy.d.ts +69 -0
- package/dist/runtime/database/tenancy.js +145 -0
- package/dist/runtime/database/transient.d.ts +10 -0
- package/dist/runtime/database/transient.js +25 -0
- package/dist/runtime/drain.d.ts +132 -0
- package/dist/runtime/drain.js +109 -0
- package/dist/runtime/entity/mailbox.d.ts +86 -0
- package/dist/runtime/entity/mailbox.js +121 -0
- package/dist/runtime/entity/register.d.ts +424 -0
- package/dist/runtime/entity/register.js +669 -0
- package/dist/runtime/events/append.d.ts +192 -0
- package/dist/runtime/events/append.js +128 -0
- package/dist/runtime/events/cursor.d.ts +2 -0
- package/dist/runtime/events/cursor.js +5 -0
- package/dist/runtime/events/replay.d.ts +20 -0
- package/dist/runtime/events/replay.js +45 -0
- package/dist/runtime/feeds.d.ts +26 -0
- package/dist/runtime/feeds.js +100 -0
- package/dist/runtime/fleet/checks.d.ts +17 -0
- package/dist/runtime/fleet/checks.js +106 -0
- package/dist/runtime/fleet/maintainer.d.ts +38 -0
- package/dist/runtime/fleet/maintainer.js +383 -0
- package/dist/runtime/fleet/pgoutput.d.ts +41 -0
- package/dist/runtime/fleet/pgoutput.js +102 -0
- package/dist/runtime/fleet/setup.d.ts +36 -0
- package/dist/runtime/fleet/setup.js +58 -0
- package/dist/runtime/fleet/subscribe.d.ts +42 -0
- package/dist/runtime/fleet/subscribe.js +147 -0
- package/dist/runtime/index.d.ts +66 -0
- package/dist/runtime/index.js +37 -0
- package/dist/runtime/inspector/http.d.ts +19 -0
- package/dist/runtime/inspector/http.js +36 -0
- package/dist/runtime/inspector/layer.d.ts +46 -0
- package/dist/runtime/inspector/layer.js +180 -0
- package/dist/runtime/inspector/queries.d.ts +711 -0
- package/dist/runtime/inspector/queries.js +494 -0
- package/dist/runtime/jobs/attempt.d.ts +254 -0
- package/dist/runtime/jobs/attempt.js +413 -0
- package/dist/runtime/jobs/isolation.d.ts +20 -0
- package/dist/runtime/jobs/isolation.js +10 -0
- package/dist/runtime/jobs/progress.d.ts +95 -0
- package/dist/runtime/jobs/progress.js +144 -0
- package/dist/runtime/layer.d.ts +260 -0
- package/dist/runtime/layer.js +876 -0
- package/dist/runtime/members.d.ts +381 -0
- package/dist/runtime/members.js +8 -0
- package/dist/runtime/operators/audit.d.ts +64 -0
- package/dist/runtime/operators/audit.js +56 -0
- package/dist/runtime/operators/auth.d.ts +29 -0
- package/dist/runtime/operators/auth.js +42 -0
- package/dist/runtime/operators/export.d.ts +68 -0
- package/dist/runtime/operators/export.js +137 -0
- package/dist/runtime/operators/grants.d.ts +45 -0
- package/dist/runtime/operators/grants.js +40 -0
- package/dist/runtime/operators/repair.d.ts +206 -0
- package/dist/runtime/operators/repair.js +226 -0
- package/dist/runtime/operators/routes.d.ts +35 -0
- package/dist/runtime/operators/routes.js +190 -0
- package/dist/runtime/operators/seed.d.ts +123 -0
- package/dist/runtime/operators/seed.js +123 -0
- package/dist/runtime/payloads/versions.d.ts +65 -0
- package/dist/runtime/payloads/versions.js +240 -0
- package/dist/runtime/peering/authority.d.ts +42 -0
- package/dist/runtime/peering/authority.js +132 -0
- package/dist/runtime/peering/credentials.d.ts +21 -0
- package/dist/runtime/peering/credentials.js +13 -0
- package/dist/runtime/peering/transport.d.ts +51 -0
- package/dist/runtime/peering/transport.js +175 -0
- package/dist/runtime/queries.d.ts +18 -0
- package/dist/runtime/queries.js +169 -0
- package/dist/runtime/readiness.d.ts +36 -0
- package/dist/runtime/readiness.js +44 -0
- package/dist/runtime/registration.d.ts +58 -0
- package/dist/runtime/registration.js +186 -0
- package/dist/runtime/request.d.ts +158 -0
- package/dist/runtime/request.js +102 -0
- package/dist/runtime/retry.d.ts +8 -0
- package/dist/runtime/retry.js +11 -0
- package/dist/runtime/runner.d.ts +93 -0
- package/dist/runtime/runner.js +122 -0
- package/dist/runtime/storage/codec.d.ts +39 -0
- package/dist/runtime/storage/codec.js +41 -0
- package/dist/runtime/storage/generation.d.ts +69 -0
- package/dist/runtime/storage/generation.js +49 -0
- package/dist/runtime/storage/placements.d.ts +15 -0
- package/dist/runtime/storage/placements.js +38 -0
- package/dist/runtime/storage/platform.d.ts +6 -0
- package/dist/runtime/storage/platform.js +9 -0
- package/dist/runtime/storage/retention.d.ts +73 -0
- package/dist/runtime/storage/retention.js +158 -0
- package/dist/runtime/subscriptions/identity.d.ts +31 -0
- package/dist/runtime/subscriptions/identity.js +45 -0
- package/dist/runtime/subscriptions/relay.d.ts +175 -0
- package/dist/runtime/subscriptions/relay.js +763 -0
- package/dist/runtime/subscriptions/storage.d.ts +40 -0
- package/dist/runtime/subscriptions/storage.js +98 -0
- package/dist/runtime/sweeps.d.ts +39 -0
- package/dist/runtime/sweeps.js +54 -0
- package/dist/runtime/telemetry/defects.d.ts +57 -0
- package/dist/runtime/telemetry/defects.js +43 -0
- package/dist/runtime/telemetry/metrics.d.ts +52 -0
- package/dist/runtime/telemetry/metrics.js +138 -0
- package/dist/runtime/telemetry/routes.d.ts +19 -0
- package/dist/runtime/telemetry/routes.js +18 -0
- package/dist/runtime/telemetry/sampler.d.ts +26 -0
- package/dist/runtime/telemetry/sampler.js +101 -0
- package/dist/runtime/telemetry/spans.d.ts +38 -0
- package/dist/runtime/telemetry/spans.js +44 -0
- package/dist/runtime/telemetry/usage.d.ts +52 -0
- package/dist/runtime/telemetry/usage.js +30 -0
- package/dist/runtime/topology/admission.d.ts +13 -0
- package/dist/runtime/topology/admission.js +36 -0
- package/dist/runtime/topology/locks.d.ts +56 -0
- package/dist/runtime/topology/locks.js +81 -0
- package/dist/runtime/topology/messages.d.ts +15 -0
- package/dist/runtime/topology/messages.js +32 -0
- package/dist/runtime/turn/admission.d.ts +22 -0
- package/dist/runtime/turn/admission.js +41 -0
- package/dist/runtime/turn/blobs.d.ts +38 -0
- package/dist/runtime/turn/blobs.js +215 -0
- package/dist/runtime/turn/execute.d.ts +208 -0
- package/dist/runtime/turn/execute.js +972 -0
- package/dist/runtime/turn/group.d.ts +165 -0
- package/dist/runtime/turn/group.js +326 -0
- package/dist/runtime/turn/hooks.d.ts +44 -0
- package/dist/runtime/turn/hooks.js +28 -0
- package/dist/runtime/turn/outbox.d.ts +159 -0
- package/dist/runtime/turn/outbox.js +269 -0
- package/dist/runtime/turn/pipeline.d.ts +68 -0
- package/dist/runtime/turn/pipeline.js +83 -0
- package/dist/runtime/turn/receipt.d.ts +81 -0
- package/dist/runtime/turn/receipt.js +32 -0
- package/dist/runtime/turn/relay.d.ts +179 -0
- package/dist/runtime/turn/relay.js +685 -0
- package/dist/runtime/turn/rows.d.ts +43 -0
- package/dist/runtime/turn/rows.js +592 -0
- package/dist/runtime/workflows/compatibility.d.ts +125 -0
- package/dist/runtime/workflows/compatibility.js +285 -0
- package/dist/runtime/workflows/engine.d.ts +107 -0
- package/dist/runtime/workflows/engine.js +826 -0
- package/dist/runtime/workflows/manifest.d.ts +34 -0
- package/dist/runtime/workflows/manifest.js +39 -0
- package/dist/runtime/workflows/steps.d.ts +33 -0
- package/dist/runtime/workflows/steps.js +152 -0
- package/dist/serve/api.d.ts +99 -0
- package/dist/serve/api.js +403 -0
- package/dist/serve/assertion/binding.d.ts +41 -0
- package/dist/serve/assertion/binding.js +92 -0
- package/dist/serve/assertion/verify.d.ts +93 -0
- package/dist/serve/assertion/verify.js +189 -0
- package/dist/serve/auth.d.ts +200 -0
- package/dist/serve/auth.js +92 -0
- package/dist/serve/clock.d.ts +10 -0
- package/dist/serve/clock.js +25 -0
- package/dist/serve/jwt.d.ts +65 -0
- package/dist/serve/jwt.js +202 -0
- package/dist/serve/layer.d.ts +98 -0
- package/dist/serve/layer.js +809 -0
- package/dist/serve/mcp/endpoint.d.ts +39 -0
- package/dist/serve/mcp/endpoint.js +187 -0
- package/dist/serve/mcp/tools.d.ts +37 -0
- package/dist/serve/mcp/tools.js +125 -0
- package/dist/serve/origin.d.ts +6 -0
- package/dist/serve/origin.js +21 -0
- package/dist/serve/sessions/feed.d.ts +79 -0
- package/dist/serve/sessions/feed.js +115 -0
- package/dist/serve/sessions/socket.d.ts +56 -0
- package/dist/serve/sessions/socket.js +212 -0
- package/dist/serve/sessions/sse.d.ts +27 -0
- package/dist/serve/sessions/sse.js +26 -0
- package/dist/serve/sessions/stream.d.ts +9 -0
- package/dist/serve/sessions/stream.js +9 -0
- package/dist/serve/sessions/watch.d.ts +12 -0
- package/dist/serve/sessions/watch.js +11 -0
- package/dist/serve/wire.d.ts +16 -0
- package/dist/serve/wire.js +50 -0
- package/dist/state/blob.d.ts +71 -0
- package/dist/state/blob.js +0 -0
- package/dist/state/migration.d.ts +53 -0
- package/dist/state/migration.js +29 -0
- package/dist/tables/fleet.d.ts +170 -0
- package/dist/tables/fleet.js +214 -0
- package/dist/tables/owned.d.ts +250 -0
- package/dist/tables/owned.js +233 -0
- package/dist/testing/actor-test.d.ts +360 -0
- package/dist/testing/actor-test.js +337 -0
- package/dist/testing/cluster.d.ts +93 -0
- package/dist/testing/cluster.js +296 -0
- package/dist/testing/conformance/access.d.ts +5 -0
- package/dist/testing/conformance/access.js +531 -0
- package/dist/testing/conformance/admission.d.ts +11 -0
- package/dist/testing/conformance/admission.js +182 -0
- package/dist/testing/conformance/adoption.d.ts +2 -0
- package/dist/testing/conformance/adoption.js +1019 -0
- package/dist/testing/conformance/assertions.d.ts +202 -0
- package/dist/testing/conformance/assertions.js +849 -0
- package/dist/testing/conformance/batches.d.ts +41 -0
- package/dist/testing/conformance/batches.js +388 -0
- package/dist/testing/conformance/blobs.d.ts +14 -0
- package/dist/testing/conformance/blobs.js +405 -0
- package/dist/testing/conformance/capacity.d.ts +8 -0
- package/dist/testing/conformance/capacity.js +433 -0
- package/dist/testing/conformance/client.d.ts +5 -0
- package/dist/testing/conformance/client.js +719 -0
- package/dist/testing/conformance/cold-serve.d.ts +16 -0
- package/dist/testing/conformance/cold-serve.js +254 -0
- package/dist/testing/conformance/connections/actors.d.ts +1143 -0
- package/dist/testing/conformance/connections/actors.js +180 -0
- package/dist/testing/conformance/connections/harness.d.ts +1754 -0
- package/dist/testing/conformance/connections/harness.js +142 -0
- package/dist/testing/conformance/connections/holders.d.ts +4 -0
- package/dist/testing/conformance/connections/holders.js +165 -0
- package/dist/testing/conformance/connections/lifecycle.d.ts +4 -0
- package/dist/testing/conformance/connections/lifecycle.js +113 -0
- package/dist/testing/conformance/connections/limits.d.ts +4 -0
- package/dist/testing/conformance/connections/limits.js +127 -0
- package/dist/testing/conformance/connections/reauthorization.d.ts +4 -0
- package/dist/testing/conformance/connections/reauthorization.js +170 -0
- package/dist/testing/conformance/connections/resync.d.ts +4 -0
- package/dist/testing/conformance/connections/resync.js +360 -0
- package/dist/testing/conformance/connections/takeover.d.ts +4 -0
- package/dist/testing/conformance/connections/takeover.js +287 -0
- package/dist/testing/conformance/connections.d.ts +4 -0
- package/dist/testing/conformance/connections.js +15 -0
- package/dist/testing/conformance/content-blobs.d.ts +16 -0
- package/dist/testing/conformance/content-blobs.js +534 -0
- package/dist/testing/conformance/counter.d.ts +16 -0
- package/dist/testing/conformance/counter.js +813 -0
- package/dist/testing/conformance/cron.d.ts +5 -0
- package/dist/testing/conformance/cron.js +665 -0
- package/dist/testing/conformance/drain.d.ts +26 -0
- package/dist/testing/conformance/drain.js +540 -0
- package/dist/testing/conformance/effect-control.d.ts +38 -0
- package/dist/testing/conformance/effect-control.js +1059 -0
- package/dist/testing/conformance/effects.d.ts +23 -0
- package/dist/testing/conformance/effects.js +432 -0
- package/dist/testing/conformance/events.d.ts +28 -0
- package/dist/testing/conformance/events.js +335 -0
- package/dist/testing/conformance/export.d.ts +2 -0
- package/dist/testing/conformance/export.js +368 -0
- package/dist/testing/conformance/fleet.d.ts +444 -0
- package/dist/testing/conformance/fleet.js +1009 -0
- package/dist/testing/conformance/groups.d.ts +7 -0
- package/dist/testing/conformance/groups.js +353 -0
- package/dist/testing/conformance/heap.d.ts +3 -0
- package/dist/testing/conformance/heap.js +149 -0
- package/dist/testing/conformance/http.d.ts +2809 -0
- package/dist/testing/conformance/http.js +1234 -0
- package/dist/testing/conformance/inspection-views.d.ts +8 -0
- package/dist/testing/conformance/inspection-views.js +272 -0
- package/dist/testing/conformance/inspector.d.ts +7 -0
- package/dist/testing/conformance/inspector.js +650 -0
- package/dist/testing/conformance/mint.d.ts +58 -0
- package/dist/testing/conformance/mint.js +692 -0
- package/dist/testing/conformance/multi-runner.d.ts +8 -0
- package/dist/testing/conformance/multi-runner.js +403 -0
- package/dist/testing/conformance/neki/plan.d.ts +19 -0
- package/dist/testing/conformance/neki/plan.js +30 -0
- package/dist/testing/conformance/observability.d.ts +3 -0
- package/dist/testing/conformance/observability.js +343 -0
- package/dist/testing/conformance/offline.d.ts +4 -0
- package/dist/testing/conformance/offline.js +474 -0
- package/dist/testing/conformance/operator-harness.d.ts +57 -0
- package/dist/testing/conformance/operator-harness.js +78 -0
- package/dist/testing/conformance/operator.d.ts +3 -0
- package/dist/testing/conformance/operator.js +379 -0
- package/dist/testing/conformance/outbox-cross-shard.d.ts +14 -0
- package/dist/testing/conformance/outbox-cross-shard.js +160 -0
- package/dist/testing/conformance/outbox.d.ts +36 -0
- package/dist/testing/conformance/outbox.js +437 -0
- package/dist/testing/conformance/payload-migrations.d.ts +3 -0
- package/dist/testing/conformance/payload-migrations.js +612 -0
- package/dist/testing/conformance/pipeline.d.ts +3 -0
- package/dist/testing/conformance/pipeline.js +1040 -0
- package/dist/testing/conformance/placement.d.ts +22 -0
- package/dist/testing/conformance/placement.js +539 -0
- package/dist/testing/conformance/platform.d.ts +40 -0
- package/dist/testing/conformance/platform.js +101 -0
- package/dist/testing/conformance/progress.d.ts +39 -0
- package/dist/testing/conformance/progress.js +666 -0
- package/dist/testing/conformance/properties.d.ts +6 -0
- package/dist/testing/conformance/properties.js +295 -0
- package/dist/testing/conformance/protocols.d.ts +4 -0
- package/dist/testing/conformance/protocols.js +618 -0
- package/dist/testing/conformance/provider/advertise.d.ts +21 -0
- package/dist/testing/conformance/provider/advertise.js +44 -0
- package/dist/testing/conformance/read-your-writes.d.ts +20 -0
- package/dist/testing/conformance/read-your-writes.js +192 -0
- package/dist/testing/conformance/reducers.d.ts +8 -0
- package/dist/testing/conformance/reducers.js +258 -0
- package/dist/testing/conformance/relay.d.ts +42 -0
- package/dist/testing/conformance/relay.js +1115 -0
- package/dist/testing/conformance/restore.d.ts +43 -0
- package/dist/testing/conformance/restore.js +341 -0
- package/dist/testing/conformance/retention.d.ts +14 -0
- package/dist/testing/conformance/retention.js +463 -0
- package/dist/testing/conformance/rls.d.ts +24 -0
- package/dist/testing/conformance/rls.js +576 -0
- package/dist/testing/conformance/simulation.d.ts +31 -0
- package/dist/testing/conformance/simulation.js +167 -0
- package/dist/testing/conformance/single-shard.d.ts +2 -0
- package/dist/testing/conformance/single-shard.js +125 -0
- package/dist/testing/conformance/singleton.d.ts +3 -0
- package/dist/testing/conformance/singleton.js +293 -0
- package/dist/testing/conformance/statements.d.ts +60 -0
- package/dist/testing/conformance/statements.js +108 -0
- package/dist/testing/conformance/streams.d.ts +7 -0
- package/dist/testing/conformance/streams.js +280 -0
- package/dist/testing/conformance/subscriptions/access.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/access.js +98 -0
- package/dist/testing/conformance/subscriptions/actors.d.ts +4910 -0
- package/dist/testing/conformance/subscriptions/actors.js +372 -0
- package/dist/testing/conformance/subscriptions/cluster.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/cluster.js +89 -0
- package/dist/testing/conformance/subscriptions/delivery.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/delivery.js +253 -0
- package/dist/testing/conformance/subscriptions/deploys.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/deploys.js +162 -0
- package/dist/testing/conformance/subscriptions/epochs.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/epochs.js +169 -0
- package/dist/testing/conformance/subscriptions/failures.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/failures.js +108 -0
- package/dist/testing/conformance/subscriptions/feeds.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/feeds.js +218 -0
- package/dist/testing/conformance/subscriptions/harness.d.ts +124 -0
- package/dist/testing/conformance/subscriptions/harness.js +143 -0
- package/dist/testing/conformance/subscriptions/operator.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/operator.js +128 -0
- package/dist/testing/conformance/subscriptions/retention.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/retention.js +288 -0
- package/dist/testing/conformance/subscriptions/routing.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/routing.js +179 -0
- package/dist/testing/conformance/subscriptions.d.ts +4 -0
- package/dist/testing/conformance/subscriptions.js +19 -0
- package/dist/testing/conformance/tables.d.ts +125 -0
- package/dist/testing/conformance/tables.js +664 -0
- package/dist/testing/conformance/transports/actors.d.ts +1907 -0
- package/dist/testing/conformance/transports/actors.js +163 -0
- package/dist/testing/conformance/transports/client.d.ts +3 -0
- package/dist/testing/conformance/transports/client.js +237 -0
- package/dist/testing/conformance/transports/feeds.d.ts +3 -0
- package/dist/testing/conformance/transports/feeds.js +232 -0
- package/dist/testing/conformance/transports/harness.d.ts +93 -0
- package/dist/testing/conformance/transports/harness.js +84 -0
- package/dist/testing/conformance/transports/streams.d.ts +3 -0
- package/dist/testing/conformance/transports/streams.js +96 -0
- package/dist/testing/conformance/transports/websocket.d.ts +3 -0
- package/dist/testing/conformance/transports/websocket.js +384 -0
- package/dist/testing/conformance/transports/wire.d.ts +141 -0
- package/dist/testing/conformance/transports/wire.js +204 -0
- package/dist/testing/conformance/transports.d.ts +3 -0
- package/dist/testing/conformance/transports.js +11 -0
- package/dist/testing/conformance/watch.d.ts +59 -0
- package/dist/testing/conformance/watch.js +879 -0
- package/dist/testing/conformance/workflow-engine.d.ts +97 -0
- package/dist/testing/conformance/workflow-engine.js +253 -0
- package/dist/testing/conformance/workflow-versions.d.ts +3 -0
- package/dist/testing/conformance/workflow-versions.js +545 -0
- package/dist/testing/conformance/workflows/access.d.ts +4 -0
- package/dist/testing/conformance/workflows/access.js +147 -0
- package/dist/testing/conformance/workflows/actors.d.ts +2317 -0
- package/dist/testing/conformance/workflows/actors.js +305 -0
- package/dist/testing/conformance/workflows/basics.d.ts +4 -0
- package/dist/testing/conformance/workflows/basics.js +144 -0
- package/dist/testing/conformance/workflows/engine.d.ts +4 -0
- package/dist/testing/conformance/workflows/engine.js +80 -0
- package/dist/testing/conformance/workflows/guards.d.ts +4 -0
- package/dist/testing/conformance/workflows/guards.js +172 -0
- package/dist/testing/conformance/workflows/harness.d.ts +14 -0
- package/dist/testing/conformance/workflows/harness.js +44 -0
- package/dist/testing/conformance/workflows/recovery.d.ts +4 -0
- package/dist/testing/conformance/workflows/recovery.js +181 -0
- package/dist/testing/conformance/workflows/starts.d.ts +4 -0
- package/dist/testing/conformance/workflows/starts.js +57 -0
- package/dist/testing/conformance/workflows/suspension.d.ts +4 -0
- package/dist/testing/conformance/workflows/suspension.js +106 -0
- package/dist/testing/conformance/workflows/waits.d.ts +4 -0
- package/dist/testing/conformance/workflows/waits.js +284 -0
- package/dist/testing/conformance/workflows.d.ts +4 -0
- package/dist/testing/conformance/workflows.js +19 -0
- package/dist/testing/conformance.d.ts +330 -0
- package/dist/testing/conformance.js +364 -0
- package/dist/testing/database.d.ts +31 -0
- package/dist/testing/database.js +70 -0
- package/dist/testing/foundation.d.ts +41 -0
- package/dist/testing/foundation.js +517 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +12 -0
- package/dist/testing/property.d.ts +40 -0
- package/dist/testing/property.js +95 -0
- package/dist/testing/simulate-cluster.d.ts +112 -0
- package/dist/testing/simulate-cluster.js +257 -0
- package/dist/testing/simulate.d.ts +90 -0
- package/dist/testing/simulate.js +127 -0
- package/package.json +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Effect, Option, Predicate, Schema, Stream } from "effect";
|
|
2
|
+
import { FLEET_PAGE_DEFAULT, FleetPageJson, fleetFilterText } from "./fleet-page.js";
|
|
3
|
+
import { joinUrl } from "./calls.js";
|
|
4
|
+
import { networkFailure, undecodableFailure } from "./transport.js";
|
|
5
|
+
import { watchStream } from "./sessions/watch.js";
|
|
6
|
+
const decodePage = Schema.decodeUnknownEffect(FleetPageJson);
|
|
7
|
+
/**
|
|
8
|
+
* The Promise client of `options.views`, served by `Actor.serve({ fleet })`. Each
|
|
9
|
+
* `subscribe` is an `AsyncIterable` of pages for the tenant the server
|
|
10
|
+
* authenticates, over `GET /fleet/{View}`: the current page first, then a page
|
|
11
|
+
* whenever the view changed. A dropped connection reopens after a growing,
|
|
12
|
+
* jittered delay, and its first page is the current state. It fails with the
|
|
13
|
+
* `ActorError` that ended it when a retry cannot help, and retries an expired
|
|
14
|
+
* credential once. `options.headers` is read for every attempt.
|
|
15
|
+
*/
|
|
16
|
+
export const fleetClient = (options) => {
|
|
17
|
+
const views = options.views;
|
|
18
|
+
const fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
19
|
+
const provided = Effect.suspend(() => {
|
|
20
|
+
const headers = options.headers;
|
|
21
|
+
return Predicate.isFunction(headers)
|
|
22
|
+
? Effect.promise(() => Promise.resolve(headers()))
|
|
23
|
+
: Effect.succeed(headers);
|
|
24
|
+
});
|
|
25
|
+
const view = (declared) => ({
|
|
26
|
+
subscribe: (filter = {}, subscribe = {}) => {
|
|
27
|
+
const query = new URLSearchParams(fleetFilterText(filter));
|
|
28
|
+
query.set("limit", String(subscribe.limit ?? FLEET_PAGE_DEFAULT));
|
|
29
|
+
const url = joinUrl({
|
|
30
|
+
baseUrl: options.baseUrl,
|
|
31
|
+
path: `/fleet/${declared.name}?${query.toString()}`,
|
|
32
|
+
});
|
|
33
|
+
return Stream.toAsyncIterable(watchStream({
|
|
34
|
+
decode: (json) => decodePage(json).pipe(Effect.mapError(undecodableFailure)),
|
|
35
|
+
declared: () => Option.none(),
|
|
36
|
+
token: () => undefined,
|
|
37
|
+
options: subscribe,
|
|
38
|
+
open: (_version, signal) => Effect.gen(function* () {
|
|
39
|
+
const headers = new Headers(yield* provided);
|
|
40
|
+
headers.set("accept", "text/event-stream");
|
|
41
|
+
headers.set("durable-protocol", "1");
|
|
42
|
+
return yield* Effect.tryPromise({
|
|
43
|
+
try: () => fetch(url, { method: "GET", headers, signal }),
|
|
44
|
+
catch: networkFailure,
|
|
45
|
+
});
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return Object.fromEntries(views.map((declared) => [declared.name, view(declared)]));
|
|
51
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as Inspection from "../protocol/inspection.ts";
|
|
2
|
+
export type { ActorClient, ClientHandle, ClientOptions, ClientState, CommandOptions, ConnectionClient, StreamCall, WatchCall, HeadersProvider, QueryOptions, } from "./make.ts";
|
|
3
|
+
export type { PendingInput } from "./optimistic.ts";
|
|
4
|
+
export type { OfflineQueue, PendingCommand } from "./offline/queue.ts";
|
|
5
|
+
export { Offline, OfflineStoreError } from "./offline/store.ts";
|
|
6
|
+
export type { OfflineStore, QueuedCommand } from "./offline/store.ts";
|
|
7
|
+
export type { ClientConnection, ConnectionMessage, ConnectOptions, ProgressMessage, ProgressOfConnection, ProgressUpdate, } from "./sessions/connection.ts";
|
|
8
|
+
export type { FeedEntry, FeedOptions } from "./sessions/feed.ts";
|
|
9
|
+
export type { StreamOptions } from "./sessions/stream.ts";
|
|
10
|
+
export type { WatchOptions } from "./sessions/watch.ts";
|
|
11
|
+
export { fleetClient } from "./fleet.ts";
|
|
12
|
+
export type { FleetClient, FleetSubscribeOptions, FleetViewClient } from "./fleet.ts";
|
|
13
|
+
export type { FleetFilter, FleetPage, FleetRow } from "../tables/fleet.ts";
|
|
14
|
+
export type { Failure } from "./transport.ts";
|
|
15
|
+
export { ActorError, ActorUnavailable, CommandConflict, CommandExpired, InvalidCommandId, InvalidInput, MailboxFull, NotCreated, RunnerAtCapacity, QuotaExceeded, SpendLimitExceeded, ConnectionLimitExceeded, StorageQuotaExceeded, SessionEnded, Timeout, TransportError, Unauthorized, } from "../errors/actor.ts";
|
|
16
|
+
export { RetentionGap, UnknownCursor } from "../errors/events.ts";
|
|
17
|
+
export { Inspection };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Inspection from "../protocol/inspection.js";
|
|
2
|
+
export { Offline, OfflineStoreError } from "./offline/store.js";
|
|
3
|
+
export { fleetClient } from "./fleet.js";
|
|
4
|
+
export { ActorError, ActorUnavailable, CommandConflict, CommandExpired, InvalidCommandId, InvalidInput, MailboxFull, NotCreated, RunnerAtCapacity, QuotaExceeded, SpendLimitExceeded, ConnectionLimitExceeded, StorageQuotaExceeded, SessionEnded, Timeout, TransportError, Unauthorized, } from "../errors/actor.js";
|
|
5
|
+
export { RetentionGap, UnknownCursor } from "../errors/events.js";
|
|
6
|
+
export { Inspection };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { ServedDefinition } from "../actor/served.ts";
|
|
2
|
+
import type { AnyMember, MemberRecord } from "../members/command.ts";
|
|
3
|
+
import type { AnyConnection } from "../members/connection.ts";
|
|
4
|
+
import type { AnyStream } from "../members/stream.ts";
|
|
5
|
+
import type { EventClass } from "../members/event.ts";
|
|
6
|
+
import { type ClientConnection, type ConnectOptions, type ProgressOfConnection } from "./sessions/connection.ts";
|
|
7
|
+
import { type FeedEntry, type FeedOptions } from "./sessions/feed.ts";
|
|
8
|
+
import { type StreamOptions } from "./sessions/stream.ts";
|
|
9
|
+
import { type WatchOptions } from "./sessions/watch.ts";
|
|
10
|
+
import type { OfflineQueue } from "./offline/queue.ts";
|
|
11
|
+
import type { OfflineStore } from "./offline/store.ts";
|
|
12
|
+
import { type PendingInput } from "./optimistic.ts";
|
|
13
|
+
type HeadersValue = Readonly<Record<string, string>> | Headers | Array<[string, string]>;
|
|
14
|
+
/** Headers sent with every attempt; a function is called again for each attempt, including retries. */
|
|
15
|
+
export type HeadersProvider = HeadersValue | (() => HeadersValue | Promise<HeadersValue>);
|
|
16
|
+
/** Options of `X.client`. */
|
|
17
|
+
export interface ClientOptions {
|
|
18
|
+
/** Where `Actor.serve` is mounted, absolute or relative to the page. */
|
|
19
|
+
readonly baseUrl: string;
|
|
20
|
+
/**
|
|
21
|
+
* Headers for every request. A connection sends the `authorization` header
|
|
22
|
+
* in `hello` instead, because browsers can't set headers on a WebSocket.
|
|
23
|
+
*/
|
|
24
|
+
readonly headers?: HeadersProvider;
|
|
25
|
+
/** How long one call, retries included, may wait. Defaults to 60,000. */
|
|
26
|
+
readonly timeoutInMs?: number;
|
|
27
|
+
/** Defaults to the global `fetch`. */
|
|
28
|
+
readonly fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
29
|
+
/**
|
|
30
|
+
* `client` (default) mints ids from the database clock learned through
|
|
31
|
+
* `/protocol`; `server` asks `/command-ids` for each one.
|
|
32
|
+
*/
|
|
33
|
+
readonly commandIds?: "client" | "server";
|
|
34
|
+
/**
|
|
35
|
+
* Saves every command before its first attempt and delivers it in order per
|
|
36
|
+
* actor under its original id, across outages and reloads; see
|
|
37
|
+
* `ActorClient.offline`. Queries and streams are unaffected.
|
|
38
|
+
*/
|
|
39
|
+
readonly offline?: OfflineStore;
|
|
40
|
+
/**
|
|
41
|
+
* A stable key for who the client runs as, such as the signed-in user's id,
|
|
42
|
+
* read before each offline command is saved and before each attempt. The
|
|
43
|
+
* offline queue sends only the commands saved under the current key and
|
|
44
|
+
* holds the rest. Never a credential. Without it, the key is the `iss` and
|
|
45
|
+
* `sub` of an `authorization: Bearer` JWT, and an offline client with
|
|
46
|
+
* neither refuses to queue commands.
|
|
47
|
+
*/
|
|
48
|
+
readonly identity?: () => string | Promise<string>;
|
|
49
|
+
}
|
|
50
|
+
/** Options of one query call. */
|
|
51
|
+
export interface QueryOptions {
|
|
52
|
+
/** Stops waiting; server work already accepted is not cancelled. */
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
/** Overrides `ClientOptions.timeoutInMs` for this call. */
|
|
55
|
+
readonly timeoutInMs?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Options of one command call. */
|
|
58
|
+
export interface CommandOptions extends QueryOptions {
|
|
59
|
+
/** Sent as `Idempotency-Key` on every attempt; minted once when omitted. */
|
|
60
|
+
readonly commandId?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The `watch` of a query declared `watch: true`: an `AsyncIterable` of the
|
|
64
|
+
* query's current result and then its newest result after each change. It is
|
|
65
|
+
* state, not history: intermediate results are skipped and a reconnect sends the
|
|
66
|
+
* current result first, never one older than one already delivered.
|
|
67
|
+
*/
|
|
68
|
+
export type WatchCall<M extends AnyMember> = (...args: M["payload"]["Type"] extends void ? [options?: WatchOptions] : [input: M["payload"]["Type"], options?: WatchOptions]) => AsyncIterable<M["success"]["Type"]>;
|
|
69
|
+
type Call<M extends AnyMember> = (M["payload"]["Type"] extends void ? (options?: M["kind"] extends "query" ? QueryOptions : CommandOptions) => Promise<M["success"]["Type"]> : (input: M["payload"]["Type"], options?: M["kind"] extends "query" ? QueryOptions : CommandOptions) => Promise<M["success"]["Type"]>) & (M extends {
|
|
70
|
+
readonly watch: true;
|
|
71
|
+
} ? {
|
|
72
|
+
readonly watch: WatchCall<M>;
|
|
73
|
+
} : unknown);
|
|
74
|
+
/**
|
|
75
|
+
* A handle's view of its actor's state: the committed state it last learned,
|
|
76
|
+
* from a reducer's reply or `reconcile`, with its pending reducer inputs applied.
|
|
77
|
+
* Reducer calls send one at a time, so each reply is the committed state
|
|
78
|
+
* before every later pending input. The view has settled before the caller's
|
|
79
|
+
* own callbacks run, and a listener that calls another reducer queues it
|
|
80
|
+
* behind the current one.
|
|
81
|
+
*/
|
|
82
|
+
export interface ClientState<State> {
|
|
83
|
+
/** Committed state plus pending inputs; undefined until committed state is known. */
|
|
84
|
+
readonly current: State | undefined;
|
|
85
|
+
/** Reducer inputs applied ahead of their receipts, in call order. */
|
|
86
|
+
readonly pending: ReadonlyArray<PendingInput>;
|
|
87
|
+
/** Calls `listener` with `current` after each change; returns the unsubscribe. */
|
|
88
|
+
readonly subscribe: (listener: (state: State | undefined) => void) => () => void;
|
|
89
|
+
/** Replaces the committed state, e.g. with one a query read, and reapplies pending inputs. */
|
|
90
|
+
readonly reconcile: (committed: State) => void;
|
|
91
|
+
}
|
|
92
|
+
/** A connection member: `connect` opens one session over WebSocket. */
|
|
93
|
+
export interface ConnectionClient<M extends AnyConnection> {
|
|
94
|
+
/** Opens a session; the `authorization` header from `headers` travels in `hello`. */
|
|
95
|
+
readonly connect: (...args: M["payload"]["Type"] extends void ? [params?: M["payload"]["Type"], options?: ConnectOptions] : [params: M["payload"]["Type"], options?: ConnectOptions]) => Promise<ClientConnection<M["server"]["Type"], M["client"]["Type"], ProgressOfConnection<M>>>;
|
|
96
|
+
}
|
|
97
|
+
/** A stream member: each call subscribes once, as an `AsyncIterable` of its elements. */
|
|
98
|
+
export type StreamCall<M extends AnyStream> = (...args: M["payload"]["Type"] extends void ? [options?: StreamOptions] : [input: M["payload"]["Type"], options?: StreamOptions]) => AsyncIterable<M["success"]["Type"]>;
|
|
99
|
+
/** One actor over HTTP: each public member as a Promise-returning method, connections as `connect`. */
|
|
100
|
+
export type ClientHandle<Members extends MemberRecord, Id = string, State = unknown, Events extends EventClass = never> = {
|
|
101
|
+
readonly [K in keyof Members]: Members[K] extends AnyConnection ? ConnectionClient<Members[K]> : Members[K] extends AnyStream ? StreamCall<Members[K]> : Call<Members[K]>;
|
|
102
|
+
} & {
|
|
103
|
+
/** The actor type's name and this handle's id. */
|
|
104
|
+
readonly ref: {
|
|
105
|
+
readonly actor: string;
|
|
106
|
+
readonly id: Id;
|
|
107
|
+
};
|
|
108
|
+
/** The handle's committed and optimistic state. */
|
|
109
|
+
readonly state: ClientState<State>;
|
|
110
|
+
/**
|
|
111
|
+
* The actor's committed `event`s after `options.after`, over its event feed,
|
|
112
|
+
* as they commit. Only events the actor type lists in `feeds` are served.
|
|
113
|
+
*/
|
|
114
|
+
readonly events: <E extends Events>(event: E, options?: FeedOptions) => AsyncIterable<FeedEntry<E["Type"]>>;
|
|
115
|
+
};
|
|
116
|
+
/** The client of one actor type: `get` (and `create` for minted ids) return handles. */
|
|
117
|
+
export type ActorClient<Members extends MemberRecord, Kind extends ServedDefinition["key"], Id, State = unknown, Events extends EventClass = never> = {
|
|
118
|
+
/** A fresh command id, for a caller that saves it before sending the command. */
|
|
119
|
+
readonly commandId: () => Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* The persisted command queue when `ClientOptions.offline` is set, else
|
|
122
|
+
* `undefined`. A command call then resolves with its output once the server
|
|
123
|
+
* answers, and rejects with `Timeout` carrying the command's id if the
|
|
124
|
+
* call's own timeout or signal ends the wait first; the command stays
|
|
125
|
+
* queued and is still delivered under that id.
|
|
126
|
+
*/
|
|
127
|
+
readonly offline: OfflineQueue | undefined;
|
|
128
|
+
} & (Kind extends "singleton" ? {
|
|
129
|
+
readonly get: () => ClientHandle<Members, string, State, Events>;
|
|
130
|
+
} : Kind extends "minted" ? {
|
|
131
|
+
readonly get: (id: Id) => ClientHandle<Members, Id, State, Events>;
|
|
132
|
+
/** A handle to a new actor whose UUIDv7 id is minted here; it exists once a command reaches it. */
|
|
133
|
+
readonly create: () => ClientHandle<Members, Id, State, Events>;
|
|
134
|
+
} : {
|
|
135
|
+
readonly get: (id: Id) => ClientHandle<Members, Id, State, Events>;
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* A connection's WebSocket URL from its route's URL, resolved against the page
|
|
139
|
+
* when relative: `wss:` for `https:` or `wss:`, and `ws:` otherwise.
|
|
140
|
+
*/
|
|
141
|
+
export declare const socketUrl: (route: string) => string;
|
|
142
|
+
/**
|
|
143
|
+
* The Promise client of one served actor type, typed by its caller.
|
|
144
|
+
*
|
|
145
|
+
* Every response carries `durable-now`, so each round trip refreshes the
|
|
146
|
+
* database clock, except a 504, which waited out a deadline and says little
|
|
147
|
+
* about when it was stamped. `/protocol` is read again when no recent clock
|
|
148
|
+
* sample remains, since the offset may have drifted, and a `window` rejection
|
|
149
|
+
* clears the cached window because a deployment at this URL may have changed
|
|
150
|
+
* it. Without a usable clock sample, such as after a slow `/protocol`, the
|
|
151
|
+
* server mints the id instead. An unanswered command's outcome is unknown, so
|
|
152
|
+
* its `Timeout` carries the id a caller retries later. Past 1,024 handles the
|
|
153
|
+
* least recently used other handle with nothing pending and no listener is
|
|
154
|
+
* dropped.
|
|
155
|
+
*/
|
|
156
|
+
export declare const clientOf: <Client>(definition: ServedDefinition) => (options: ClientOptions) => Client;
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { Effect, Exit, Option, Schema, SchemaAST, Stream } from "effect";
|
|
2
|
+
import { ActorError, InvalidInput, Timeout } from "../errors/actor.js";
|
|
3
|
+
import { callsOf, declaredDecoder, joinUrl, uuid } from "./calls.js";
|
|
4
|
+
import { connect, } from "./sessions/connection.js";
|
|
5
|
+
import { feedStream } from "./sessions/feed.js";
|
|
6
|
+
import { subscription } from "./sessions/stream.js";
|
|
7
|
+
import { watchStream } from "./sessions/watch.js";
|
|
8
|
+
import { Optimistic } from "./optimistic.js";
|
|
9
|
+
import { undecodableFailure } from "./transport.js";
|
|
10
|
+
/** Handles kept per client. */
|
|
11
|
+
const HANDLE_LIMIT = 1_024;
|
|
12
|
+
const encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Json));
|
|
13
|
+
const invalid = () => ActorError.make({ reason: InvalidInput.make({ code: "decode" }) });
|
|
14
|
+
/**
|
|
15
|
+
* A connection's WebSocket URL from its route's URL, resolved against the page
|
|
16
|
+
* when relative: `wss:` for `https:` or `wss:`, and `ws:` otherwise.
|
|
17
|
+
*/
|
|
18
|
+
export const socketUrl = (route) => {
|
|
19
|
+
const url = new URL(route, "location" in globalThis ? globalThis.location.href : undefined);
|
|
20
|
+
url.protocol = url.protocol === "https:" || url.protocol === "wss:" ? "wss:" : "ws:";
|
|
21
|
+
return url.href;
|
|
22
|
+
};
|
|
23
|
+
const decodeInputCopy = (member) => Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.toCodecJson(member.input)));
|
|
24
|
+
const isVoidInput = (member) => SchemaAST.isVoid(member.input.ast) || SchemaAST.isUndefined(member.input.ast);
|
|
25
|
+
/**
|
|
26
|
+
* The Promise client of one served actor type, typed by its caller.
|
|
27
|
+
*
|
|
28
|
+
* Every response carries `durable-now`, so each round trip refreshes the
|
|
29
|
+
* database clock, except a 504, which waited out a deadline and says little
|
|
30
|
+
* about when it was stamped. `/protocol` is read again when no recent clock
|
|
31
|
+
* sample remains, since the offset may have drifted, and a `window` rejection
|
|
32
|
+
* clears the cached window because a deployment at this URL may have changed
|
|
33
|
+
* it. Without a usable clock sample, such as after a slow `/protocol`, the
|
|
34
|
+
* server mints the id instead. An unanswered command's outcome is unknown, so
|
|
35
|
+
* its `Timeout` carries the id a caller retries later. Past 1,024 handles the
|
|
36
|
+
* least recently used other handle with nothing pending and no listener is
|
|
37
|
+
* dropped.
|
|
38
|
+
*/
|
|
39
|
+
export const clientOf = (definition) => (options) => {
|
|
40
|
+
const { authorization, token, openEvents, mint, waiting, withRetries, asAttempt, poster, queue, commandId: mintCommandId, } = callsOf({ definition, options });
|
|
41
|
+
/**
|
|
42
|
+
* Encodes one call's input now, so every attempt under one id sends the same
|
|
43
|
+
* bytes, and returns what sends it, with a decoded copy of that input.
|
|
44
|
+
*/
|
|
45
|
+
const prepare = (member, segment, args) => {
|
|
46
|
+
const isVoid = isVoidInput(member);
|
|
47
|
+
const call = (isVoid ? args[0] : args[1]) ?? {};
|
|
48
|
+
const isQuery = member.kind === "query";
|
|
49
|
+
let commandId = isQuery ? undefined : call.commandId;
|
|
50
|
+
const body = Effect.runSyncExit(Schema.encodeUnknownEffect(Schema.toCodecJson(member.input))(isVoid ? undefined : args[0]).pipe(Effect.flatMap((json) => json === undefined ? Effect.succeedNone : Effect.asSome(encodeJson(json))), Effect.mapError(invalid)));
|
|
51
|
+
const post = poster(member);
|
|
52
|
+
const attempt = Effect.gen(function* () {
|
|
53
|
+
const path = `/actors/${definition.name}${yield* segment}/${member.tag}`;
|
|
54
|
+
const payload = Option.getOrUndefined(yield* body);
|
|
55
|
+
if (!isQuery && commandId === undefined)
|
|
56
|
+
commandId = yield* mint;
|
|
57
|
+
return yield* post(path, payload, commandId);
|
|
58
|
+
}).pipe(Effect.mapError((error) => asAttempt(commandId)(error)));
|
|
59
|
+
const input = Exit.isSuccess(body)
|
|
60
|
+
? Option.getOrUndefined(Exit.getSuccess(Effect.runSyncExit(Option.match(body.value, {
|
|
61
|
+
onNone: () => Effect.void,
|
|
62
|
+
onSome: (json) => decodeInputCopy(member)(json),
|
|
63
|
+
}))))
|
|
64
|
+
: undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Saves this command in the offline queue, minting its id first when the
|
|
67
|
+
* caller gave none, and reports when it is delivered. `call` is the
|
|
68
|
+
* caller's view, bounded by its timeout and signal; `delivered` outlives
|
|
69
|
+
* both, so state that follows the command follows its real outcome.
|
|
70
|
+
*/
|
|
71
|
+
const enqueue = queue === undefined || isQuery
|
|
72
|
+
? undefined
|
|
73
|
+
: () => {
|
|
74
|
+
const make = Effect.gen(function* () {
|
|
75
|
+
const target = `/actors/${definition.name}${yield* segment}`;
|
|
76
|
+
const payload = Option.getOrUndefined(yield* body);
|
|
77
|
+
commandId ??= yield* mint;
|
|
78
|
+
return { commandId, target, member: member.tag, body: payload };
|
|
79
|
+
});
|
|
80
|
+
const delivered = queue.submit(make, call.signal).then((delivery) => delivery === undefined
|
|
81
|
+
? Promise.reject(ActorError.make({
|
|
82
|
+
reason: Timeout.make(commandId === undefined ? {} : { commandId }),
|
|
83
|
+
}))
|
|
84
|
+
: Effect.runPromise(delivery.settled));
|
|
85
|
+
return {
|
|
86
|
+
delivered,
|
|
87
|
+
call: waiting(Effect.tryPromise({
|
|
88
|
+
try: () => delivered,
|
|
89
|
+
catch: (thrown) => thrown,
|
|
90
|
+
}), call, () => commandId),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
input: Exit.isSuccess(body) ? Option.some(input) : Option.none(),
|
|
95
|
+
send: (after) => withRetries(attempt, call, () => commandId, after),
|
|
96
|
+
enqueue,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const method = (member, segment, store) => (...args) => {
|
|
100
|
+
const { input, send, enqueue } = prepare(member, segment, args);
|
|
101
|
+
const reducer = member.reducer;
|
|
102
|
+
if (reducer === undefined || Option.isNone(input))
|
|
103
|
+
return enqueue === undefined ? send() : enqueue().call;
|
|
104
|
+
const entry = { member: member.tag, input: input.value, reducer };
|
|
105
|
+
if (enqueue === undefined)
|
|
106
|
+
return store.sendInOrder(entry, send);
|
|
107
|
+
const { call, delivered } = enqueue();
|
|
108
|
+
store.follow(entry, delivered);
|
|
109
|
+
return call;
|
|
110
|
+
};
|
|
111
|
+
const handles = new Map();
|
|
112
|
+
const stores = new Map();
|
|
113
|
+
const handle = (id, segment) => {
|
|
114
|
+
const existing = handles.get(id);
|
|
115
|
+
const existingStore = stores.get(id);
|
|
116
|
+
if (existing !== undefined && existingStore !== undefined) {
|
|
117
|
+
handles.delete(id);
|
|
118
|
+
handles.set(id, existing);
|
|
119
|
+
return existing;
|
|
120
|
+
}
|
|
121
|
+
const store = new Optimistic(definition.members.find((member) => member.reducer !== undefined)?.reducer);
|
|
122
|
+
const path = (member) => segment.pipe(Effect.map((encoded) => `/actors/${definition.name}${encoded}/${member}`));
|
|
123
|
+
const watching = (member) => (...args) => {
|
|
124
|
+
const isVoid = isVoidInput(member);
|
|
125
|
+
const watchOptions = (isVoid ? args[0] : args[1]) ?? {};
|
|
126
|
+
const body = Schema.encodeUnknownEffect(Schema.toCodecJson(member.input))(isVoid ? undefined : args[0]).pipe(Effect.flatMap((json) => json === undefined ? Effect.succeedNone : Effect.asSome(encodeJson(json))), Effect.map(Option.getOrUndefined), Effect.mapError(invalid));
|
|
127
|
+
return Stream.toAsyncIterable(watchStream({
|
|
128
|
+
decode: (json) => Schema.decodeEffect(Schema.toCodecJson(member.output))(json).pipe(Effect.mapError(undecodableFailure)),
|
|
129
|
+
declared: declaredDecoder(member),
|
|
130
|
+
options: watchOptions,
|
|
131
|
+
token: () => token.value,
|
|
132
|
+
open: (version, signal) => Effect.gen(function* () {
|
|
133
|
+
const payload = yield* body;
|
|
134
|
+
const headers = {};
|
|
135
|
+
if (payload !== undefined)
|
|
136
|
+
headers["content-type"] = "application/json";
|
|
137
|
+
if (version !== undefined)
|
|
138
|
+
headers["durable-min-version"] = version;
|
|
139
|
+
return yield* openEvents(path(member.tag).pipe(Effect.map((query) => `${query}/watch`)), signal, { method: "POST", body: payload, headers });
|
|
140
|
+
}),
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
const created = {
|
|
144
|
+
...Object.fromEntries(definition.members.map((member) => [
|
|
145
|
+
member.tag,
|
|
146
|
+
member.watch
|
|
147
|
+
? Object.assign(method(member, segment, store), { watch: watching(member) })
|
|
148
|
+
: method(member, segment, store),
|
|
149
|
+
])),
|
|
150
|
+
...Object.fromEntries(definition.connections.map((member) => [
|
|
151
|
+
member.tag,
|
|
152
|
+
{
|
|
153
|
+
connect: (params, connectOptions) => Effect.runPromise(path(member.tag)).then((memberPath) => connect({
|
|
154
|
+
member,
|
|
155
|
+
url: socketUrl(joinUrl({ baseUrl: options.baseUrl, path: memberPath })),
|
|
156
|
+
authorization,
|
|
157
|
+
params,
|
|
158
|
+
options: connectOptions ?? {},
|
|
159
|
+
})),
|
|
160
|
+
},
|
|
161
|
+
])),
|
|
162
|
+
...Object.fromEntries(definition.streams.map((member) => [
|
|
163
|
+
member.tag,
|
|
164
|
+
(...args) => {
|
|
165
|
+
const isVoid = isVoidInput(member);
|
|
166
|
+
const streamOptions = (isVoid ? args[0] : args[1]) ?? {};
|
|
167
|
+
const body = Schema.encodeUnknownEffect(Schema.toCodecJson(member.input))(isVoid ? undefined : args[0]).pipe(Effect.flatMap((json) => json === undefined ? Effect.succeedNone : Effect.asSome(encodeJson(json))), Effect.map(Option.getOrUndefined), Effect.mapError(invalid));
|
|
168
|
+
return Stream.toAsyncIterable(subscription({
|
|
169
|
+
member,
|
|
170
|
+
declared: declaredDecoder(member),
|
|
171
|
+
options: streamOptions,
|
|
172
|
+
open: (signal) => Effect.gen(function* () {
|
|
173
|
+
const payload = yield* body;
|
|
174
|
+
return yield* openEvents(path(member.tag), signal, {
|
|
175
|
+
method: "POST",
|
|
176
|
+
body: payload,
|
|
177
|
+
headers: payload === undefined ? {} : { "content-type": "application/json" },
|
|
178
|
+
});
|
|
179
|
+
}),
|
|
180
|
+
}));
|
|
181
|
+
},
|
|
182
|
+
])),
|
|
183
|
+
events: (event, feedOptions) => Stream.toAsyncIterable(feedStream({
|
|
184
|
+
event,
|
|
185
|
+
options: feedOptions ?? {},
|
|
186
|
+
open: (cursor, signal) => openEvents(path("events").pipe(Effect.map((events) => `${events}?${new URLSearchParams({ event: event.identifier })}`)), signal, { headers: cursor === undefined ? {} : { "last-event-id": cursor } }),
|
|
187
|
+
})),
|
|
188
|
+
ref: { actor: definition.name, id },
|
|
189
|
+
state: {
|
|
190
|
+
get current() {
|
|
191
|
+
return store.state;
|
|
192
|
+
},
|
|
193
|
+
get pending() {
|
|
194
|
+
return store.pending;
|
|
195
|
+
},
|
|
196
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
197
|
+
reconcile: (committed) => store.reconcile(committed),
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
handles.set(id, created);
|
|
201
|
+
stores.set(id, store);
|
|
202
|
+
if (handles.size > HANDLE_LIMIT)
|
|
203
|
+
for (const key of handles.keys())
|
|
204
|
+
if (key !== id && stores.get(key)?.isIdle === true) {
|
|
205
|
+
handles.delete(key);
|
|
206
|
+
stores.delete(key);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
return created;
|
|
210
|
+
};
|
|
211
|
+
const keyed = (id) => handle(id, definition.encodeId(id).pipe(Effect.map((encoded) => `/${encodeURIComponent(encoded)}`), Effect.mapError(invalid)));
|
|
212
|
+
const client = {
|
|
213
|
+
offline: queue,
|
|
214
|
+
commandId: mintCommandId,
|
|
215
|
+
get: definition.key === "singleton"
|
|
216
|
+
? () => handle("singleton", Effect.succeed(""))
|
|
217
|
+
: (id) => keyed(id),
|
|
218
|
+
create: definition.key === "minted" ? () => keyed(Effect.runSync(uuid(7))) : undefined,
|
|
219
|
+
};
|
|
220
|
+
return client;
|
|
221
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Effect, Option, Schema } from "effect";
|
|
2
|
+
import type { Failure } from "../transport.ts";
|
|
3
|
+
import { type OfflineStore, type QueuedCommand } from "./store.ts";
|
|
4
|
+
/** A queued command as an application sees it. */
|
|
5
|
+
export interface PendingCommand {
|
|
6
|
+
readonly commandId: string;
|
|
7
|
+
/** The actor's route under the client's `baseUrl`. */
|
|
8
|
+
readonly target: string;
|
|
9
|
+
readonly member: string;
|
|
10
|
+
/** The JSON the command was called with, as sent. */
|
|
11
|
+
readonly input: Schema.Json | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* `queued` is still being delivered; `held` was queued under another
|
|
14
|
+
* principal and waits until that principal signs back in or the application
|
|
15
|
+
* discards it; `expired` and `failed` wait for the application to `discard` them.
|
|
16
|
+
*/
|
|
17
|
+
readonly status: QueuedCommand["status"] | "held";
|
|
18
|
+
/**
|
|
19
|
+
* While `queued`, the last answer that did not settle the command, such as a
|
|
20
|
+
* network failure or a rejected credential. For `expired`, its
|
|
21
|
+
* `CommandExpired`; for `failed`, the failure the server answered with.
|
|
22
|
+
*/
|
|
23
|
+
readonly failure: Failure | undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A client's persisted command queue. Every command is saved before its first
|
|
27
|
+
* attempt and sent under the id it was saved with until the server answers or
|
|
28
|
+
* the id expires; nothing here ever mints a replacement id.
|
|
29
|
+
*/
|
|
30
|
+
export interface OfflineQueue {
|
|
31
|
+
/** Settles once saved commands are read; rejects with `OfflineStoreError` when the store cannot be read. */
|
|
32
|
+
readonly ready: Promise<void>;
|
|
33
|
+
/** Every command not yet removed, in queue order. Empty until `ready`. */
|
|
34
|
+
readonly pending: ReadonlyArray<PendingCommand>;
|
|
35
|
+
/** Calls `listener` with `pending` after each change; returns the unsubscribe. */
|
|
36
|
+
readonly subscribe: (listener: (pending: ReadonlyArray<PendingCommand>) => void) => () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Tries again now: skips any wait between attempts and resumes an actor
|
|
39
|
+
* whose commands stopped on a rejected credential. It also runs when the
|
|
40
|
+
* browser reports it is back online.
|
|
41
|
+
*/
|
|
42
|
+
readonly flush: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Forgets a command and never sends it again; a command already sent may
|
|
45
|
+
* have been applied. It settles a caller still waiting with `Timeout`.
|
|
46
|
+
* The only way to resolve an `expired`, `failed`, or `held` command.
|
|
47
|
+
*/
|
|
48
|
+
readonly discard: (commandId: string) => Promise<void>;
|
|
49
|
+
/** Stops delivering. Saved commands stay saved for the next session. */
|
|
50
|
+
readonly close: () => void;
|
|
51
|
+
}
|
|
52
|
+
/** What a client asks the queue to save; the queue adds its position, base URL, principal and status. */
|
|
53
|
+
type NewCommand = Pick<QueuedCommand, "commandId" | "target" | "member" | "body">;
|
|
54
|
+
/** One answered attempt that did not settle the command, with when to try again if the client knows. */
|
|
55
|
+
export interface Refused {
|
|
56
|
+
readonly failure: Failure;
|
|
57
|
+
readonly retryAfterMs: Option.Option<number>;
|
|
58
|
+
readonly answer: QueuedCommand["answer"];
|
|
59
|
+
}
|
|
60
|
+
export interface QueueOptions<Output> {
|
|
61
|
+
readonly store: OfflineStore;
|
|
62
|
+
/** Only commands saved under this base URL are delivered. */
|
|
63
|
+
readonly baseUrl: string;
|
|
64
|
+
/** Only commands of this actor type are delivered. */
|
|
65
|
+
readonly actor: string;
|
|
66
|
+
/**
|
|
67
|
+
* The principal the client runs as now, read before each command is saved
|
|
68
|
+
* and before each attempt; only commands saved under it are sent.
|
|
69
|
+
*/
|
|
70
|
+
readonly principal: Effect.Effect<string>;
|
|
71
|
+
/** The estimated database time, for judging a command's expiry. */
|
|
72
|
+
readonly now: () => number;
|
|
73
|
+
/**
|
|
74
|
+
* Starts one command's delivery and returns one attempt at it, which may be
|
|
75
|
+
* run again. It succeeds with the decoded output or fails with why it did
|
|
76
|
+
* not settle.
|
|
77
|
+
*/
|
|
78
|
+
readonly begin: (command: QueuedCommand) => Effect.Effect<Output, Refused>;
|
|
79
|
+
/** The failure a saved `failed` command's answer decodes to. */
|
|
80
|
+
readonly failureOf: (command: QueuedCommand) => Failure;
|
|
81
|
+
/** Learns the retry window and the database clock while the network is up, so commands can be minted offline. */
|
|
82
|
+
readonly warm: Effect.Effect<void>;
|
|
83
|
+
}
|
|
84
|
+
/** What the queue hands back for a saved command. */
|
|
85
|
+
export interface Delivery<Output> {
|
|
86
|
+
/** Succeeds with the command's output once the server answers; fails with the terminal failure. */
|
|
87
|
+
readonly settled: Effect.Effect<Output, Failure>;
|
|
88
|
+
}
|
|
89
|
+
/** The queue a client drives: what an application sees, plus saving commands. */
|
|
90
|
+
export interface CommandQueue<Output> extends OfflineQueue {
|
|
91
|
+
/**
|
|
92
|
+
* Saves the command `make` builds, then delivers it. Calls are taken one at
|
|
93
|
+
* a time in the order they were made, so an id that takes longer to mint
|
|
94
|
+
* still queues in front of a later call. Resolves to nothing when `signal`
|
|
95
|
+
* aborted before the command was saved, in which case nothing was queued.
|
|
96
|
+
* Rejects with `OfflineStoreError` when the command could not be saved, and
|
|
97
|
+
* then nothing was sent.
|
|
98
|
+
*/
|
|
99
|
+
readonly submit: (make: Effect.Effect<NewCommand, Failure>, signal: AbortSignal | undefined) => Promise<Delivery<Output> | undefined>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The queue behind a client's `offline` option. It keeps each actor's commands
|
|
103
|
+
* in the order they were called and sends one at a time, so a later command
|
|
104
|
+
* never overtakes an earlier one that is still waiting for the network;
|
|
105
|
+
* different actors are delivered independently. A command that expires or is
|
|
106
|
+
* rejected for good does not hold back those after it.
|
|
107
|
+
*
|
|
108
|
+
* Each command is saved under the principal the client ran as, and only
|
|
109
|
+
* commands of the current principal are sent: another's are `held`, so a
|
|
110
|
+
* shared store never sends one user's commands with another's credential.
|
|
111
|
+
*
|
|
112
|
+
* Ids are minted by the caller and stored with the command, so a replay after
|
|
113
|
+
* a lost reply, a reload, or a second tab is a retry the receipt answers, never
|
|
114
|
+
* a second execution. Tabs sharing one store each deliver what they read, and
|
|
115
|
+
* only the order within a tab is kept.
|
|
116
|
+
*/
|
|
117
|
+
export declare const openCommandQueue: <Output>(options: QueueOptions<Output>) => CommandQueue<Output>;
|
|
118
|
+
export {};
|