@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,494 @@
|
|
|
1
|
+
import { Effect, Option, Predicate, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { inReadOnlySnapshot } from "../database/snapshot.js";
|
|
4
|
+
import { decompress } from "../storage/codec.js";
|
|
5
|
+
const parseJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Json));
|
|
6
|
+
/** Decodes a JSON `text` column such as a payload, caller, or outcome. */
|
|
7
|
+
export const decodeText = (text) => {
|
|
8
|
+
if (text === null)
|
|
9
|
+
return null;
|
|
10
|
+
return Option.match(parseJson(text), {
|
|
11
|
+
onNone: () => ({ undecodable: "not JSON" }),
|
|
12
|
+
onSome: (json) => ({ json }),
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
/** Decodes a zstd-compressed JSON `bytea` column such as state, an event, or a step exit. */
|
|
16
|
+
export const decodeBytes = (bytes) => {
|
|
17
|
+
if (bytes === null)
|
|
18
|
+
return null;
|
|
19
|
+
let text;
|
|
20
|
+
try {
|
|
21
|
+
text = decompress(bytes);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return { undecodable: "not zstd" };
|
|
25
|
+
}
|
|
26
|
+
return decodeText(text);
|
|
27
|
+
};
|
|
28
|
+
/** The widest page any list returns. */
|
|
29
|
+
export const MAX_LIMIT = 500;
|
|
30
|
+
/**
|
|
31
|
+
* Runs `effect` in a read-only snapshot that names `tenant`, so when
|
|
32
|
+
* row-level security owns the views they return no other tenant's rows,
|
|
33
|
+
* whatever a read's own filter says.
|
|
34
|
+
*/
|
|
35
|
+
export const readOnly = (tenant) => (effect) => Effect.flatMap(SqlClient.SqlClient, (sql) => sql `SELECT set_config('durable.tenant', ${tenant}, true)`).pipe(Effect.andThen(effect), inReadOnlySnapshot);
|
|
36
|
+
/** The view catalog and the tenant's row count in each view, from one snapshot. */
|
|
37
|
+
export const overview = ({ tenant }) => Effect.gen(function* () {
|
|
38
|
+
const sql = yield* SqlClient.SqlClient;
|
|
39
|
+
const views = yield* sql `
|
|
40
|
+
SELECT view_name AS view, version::int AS version FROM durable.views
|
|
41
|
+
ORDER BY view_name COLLATE "C"`;
|
|
42
|
+
const [counts] = yield* sql `
|
|
43
|
+
SELECT
|
|
44
|
+
(SELECT count(*)::int FROM durable.actors WHERE tenant_id = ${tenant}) AS actors,
|
|
45
|
+
(SELECT count(*)::int FROM durable.receipts WHERE tenant_id = ${tenant}) AS receipts,
|
|
46
|
+
(SELECT count(*)::int FROM durable.events WHERE tenant_id = ${tenant}) AS events,
|
|
47
|
+
(SELECT count(*)::int FROM durable.outbox WHERE tenant_id = ${tenant}) AS outbox,
|
|
48
|
+
(SELECT count(*)::int FROM durable.timers WHERE tenant_id = ${tenant}) AS timers,
|
|
49
|
+
(SELECT count(*)::int FROM durable.jobs WHERE tenant_id = ${tenant}) AS jobs,
|
|
50
|
+
(SELECT count(*)::int FROM durable.dead_letters WHERE tenant_id = ${tenant}) AS "deadLetters",
|
|
51
|
+
(SELECT count(*)::int FROM durable.workflows WHERE tenant_id = ${tenant}) AS workflows,
|
|
52
|
+
(SELECT count(*)::int FROM durable.workflows
|
|
53
|
+
WHERE tenant_id = ${tenant} AND status <> 'finished') AS "openWorkflows"`;
|
|
54
|
+
const [timer] = yield* sql `
|
|
55
|
+
SELECT min(due_at_ms)::float8 AS "dueAtMs" FROM durable.timers WHERE tenant_id = ${tenant}`;
|
|
56
|
+
return {
|
|
57
|
+
tenant,
|
|
58
|
+
views,
|
|
59
|
+
counts: counts,
|
|
60
|
+
nextTimerDueAtMs: timer?.dueAtMs ?? null,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* The tenant's actors in `(actor_type, actor_id)` order, one page after `after`. The cursor
|
|
65
|
+
* comparison uses the same `C` collation as the ORDER BY, or a cursor could skip or repeat actors.
|
|
66
|
+
* A prefix that names a whole type, `type/` and more, matches that type's ids by their own prefix,
|
|
67
|
+
* so it reads one type rather than every actor of the tenant.
|
|
68
|
+
*/
|
|
69
|
+
export const actors = (page) => Effect.gen(function* () {
|
|
70
|
+
const sql = yield* SqlClient.SqlClient;
|
|
71
|
+
const byType = page.actorType === undefined ? sql `TRUE` : sql `actor_type = ${page.actorType}`;
|
|
72
|
+
const slash = page.prefix?.indexOf("/") ?? -1;
|
|
73
|
+
const byPrefix = page.prefix === undefined
|
|
74
|
+
? sql `TRUE`
|
|
75
|
+
: slash === -1
|
|
76
|
+
? sql `starts_with(actor_type, ${page.prefix})`
|
|
77
|
+
: sql `actor_type = ${page.prefix.slice(0, slash)}
|
|
78
|
+
AND starts_with(actor_id, ${page.prefix.slice(slash + 1)})`;
|
|
79
|
+
const after = page.after === undefined
|
|
80
|
+
? sql `TRUE`
|
|
81
|
+
: sql `(actor_type COLLATE "C", actor_id COLLATE "C") > (${page.after.actorType}, ${page.after.actorId})`;
|
|
82
|
+
const rows = yield* sql `
|
|
83
|
+
SELECT actor_type AS "actorType", actor_id AS "actorId", placement,
|
|
84
|
+
generation::float8 AS generation, created,
|
|
85
|
+
last_event_sequence::float8 AS "lastEventSequence"
|
|
86
|
+
FROM durable.actors
|
|
87
|
+
WHERE tenant_id = ${page.tenant} AND ${byType} AND ${byPrefix} AND ${after}
|
|
88
|
+
ORDER BY actor_type COLLATE "C", actor_id COLLATE "C"
|
|
89
|
+
LIMIT ${page.limit + 1}`;
|
|
90
|
+
const more = rows.length > page.limit;
|
|
91
|
+
const items = more ? rows.slice(0, page.limit) : rows;
|
|
92
|
+
const last = items.at(-1);
|
|
93
|
+
return {
|
|
94
|
+
actors: items,
|
|
95
|
+
next: more && last !== undefined ? { actorType: last.actorType, actorId: last.actorId } : null,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
const findActor = ({ tenant, actorType, actorId }) => Effect.gen(function* () {
|
|
99
|
+
const sql = yield* SqlClient.SqlClient;
|
|
100
|
+
const [row] = yield* sql `
|
|
101
|
+
SELECT actor_type AS "actorType", actor_id AS "actorId", routing_key::text AS "routingKey",
|
|
102
|
+
placement, generation::float8 AS generation, created,
|
|
103
|
+
last_event_sequence::float8 AS "lastEventSequence"
|
|
104
|
+
FROM durable.actors
|
|
105
|
+
WHERE tenant_id = ${tenant} AND actor_type = ${actorType} AND actor_id = ${actorId}`;
|
|
106
|
+
return Option.fromNullishOr(row);
|
|
107
|
+
});
|
|
108
|
+
const outboxOf = (row) => ({
|
|
109
|
+
...row,
|
|
110
|
+
payload: decodeText(row.payload),
|
|
111
|
+
caller: decodeText(row.caller),
|
|
112
|
+
});
|
|
113
|
+
const jobOf = (row) => ({
|
|
114
|
+
...row,
|
|
115
|
+
payload: decodeText(row.payload),
|
|
116
|
+
caller: decodeText(row.caller),
|
|
117
|
+
});
|
|
118
|
+
const deadLetterOf = (row) => ({ ...row, payload: decodeText(row.payload) });
|
|
119
|
+
const receiptOf = ({ events, callerKey, outcome, ...receipt }) => ({
|
|
120
|
+
...receipt,
|
|
121
|
+
callerKey: decodeText(callerKey),
|
|
122
|
+
outcome: decodeText(outcome),
|
|
123
|
+
events: events === null ? [] : events.split(",").map(Number),
|
|
124
|
+
});
|
|
125
|
+
const stepOf = (row) => ({
|
|
126
|
+
step: row.step,
|
|
127
|
+
attempt: row.attempt,
|
|
128
|
+
kind: row.kind,
|
|
129
|
+
exit: decodeBytes(row.exit),
|
|
130
|
+
waitEvent: row.waitEvent,
|
|
131
|
+
version: row.version,
|
|
132
|
+
dueAtMs: row.dueAtMs,
|
|
133
|
+
startedAtMs: row.startedAtMs,
|
|
134
|
+
settledAtMs: row.settledAtMs,
|
|
135
|
+
});
|
|
136
|
+
const workflowOf = (row, steps) => ({
|
|
137
|
+
...row,
|
|
138
|
+
caller: decodeText(row.caller),
|
|
139
|
+
payload: decodeBytes(row.payload),
|
|
140
|
+
result: decodeBytes(row.result),
|
|
141
|
+
steps: steps.flatMap((step) => (step.executionId === row.executionId ? [stepOf(step)] : [])),
|
|
142
|
+
});
|
|
143
|
+
/** Columns shared by every per-row select: the actor the row belongs to. */
|
|
144
|
+
const IDENTITY = `actor_type AS "actorType", actor_id AS "actorId"`;
|
|
145
|
+
const OUTBOX_COLUMNS = `${IDENTITY}, intent_id AS "intentId", timer_key AS "timerKey",
|
|
146
|
+
target_type AS "targetType", target_id AS "targetId", command, payload, caller,
|
|
147
|
+
attempts::int AS attempts, last_error AS "lastError", due_at_ms::float8 AS "dueAtMs"`;
|
|
148
|
+
const JOB_COLUMNS = `${IDENTITY}, job_id AS "jobId", job, payload, caller,
|
|
149
|
+
attempts::int AS attempts, last_error AS "lastError", ambiguous, due_at_ms::float8 AS "dueAtMs"`;
|
|
150
|
+
const DEAD_LETTER_COLUMNS = `${IDENTITY}, job_id AS "jobId", job, payload,
|
|
151
|
+
attempts::int AS attempts, cause, ambiguous, dead_at_ms::float8 AS "deadAtMs"`;
|
|
152
|
+
const WORKFLOW_COLUMNS = `${IDENTITY}, execution_id AS "executionId", workflow,
|
|
153
|
+
workflow_key AS "workflowKey", manifest_hash AS "manifestHash", status, interrupt, caller,
|
|
154
|
+
payload, payload_bytes::int AS "payloadBytes", result, result_bytes::int AS "resultBytes",
|
|
155
|
+
started_at_ms::float8 AS "startedAtMs", finished_at_ms::float8 AS "finishedAtMs"`;
|
|
156
|
+
const STEP_COLUMNS = `execution_id AS "executionId", step, attempt::int AS attempt, kind, exit,
|
|
157
|
+
wait_event AS "waitEvent", version::int AS version, due_at_ms::float8 AS "dueAtMs",
|
|
158
|
+
started_at_ms::float8 AS "startedAtMs", settled_at_ms::float8 AS "settledAtMs"`;
|
|
159
|
+
/**
|
|
160
|
+
* One actor as the inspector shows it, read through the actor's routing key:
|
|
161
|
+
* its generation, decoded state, newest receipts with the events each
|
|
162
|
+
* committed, newest events, pending outbox rows and jobs, dead letters, and
|
|
163
|
+
* workflow executions with their recorded steps. `None` when the tenant has
|
|
164
|
+
* no such actor. Every runtime index leads with `routing_key`, so each read is
|
|
165
|
+
* a key lookup, and the steps read for the same page of executions give each
|
|
166
|
+
* listed execution all its steps.
|
|
167
|
+
*/
|
|
168
|
+
export const actor = (page) => Effect.gen(function* () {
|
|
169
|
+
const found = yield* findActor(page);
|
|
170
|
+
if (Option.isNone(found))
|
|
171
|
+
return Option.none();
|
|
172
|
+
const sql = yield* SqlClient.SqlClient;
|
|
173
|
+
const { routingKey, ...row } = found.value;
|
|
174
|
+
const owned = sql `routing_key = ${routingKey}::int8 AND tenant_id = ${page.tenant}
|
|
175
|
+
AND actor_type = ${page.actorType} AND actor_id = ${page.actorId}`;
|
|
176
|
+
const state = yield* sql `
|
|
177
|
+
SELECT key, value, value_bytes::int AS bytes FROM durable.state
|
|
178
|
+
WHERE ${owned} ORDER BY key COLLATE "C"`;
|
|
179
|
+
const receipts = yield* sql `
|
|
180
|
+
SELECT r.command_id AS "commandId", r.command, r.caller_key AS "callerKey",
|
|
181
|
+
r.outcome_tag AS "outcomeTag", r.outcome, r.expires_at_ms::float8 AS "expiresAtMs",
|
|
182
|
+
(SELECT string_agg(e.sequence::text, ',' ORDER BY e.sequence) FROM durable.events e
|
|
183
|
+
WHERE e.routing_key = r.routing_key AND e.tenant_id = r.tenant_id
|
|
184
|
+
AND e.actor_type = r.actor_type AND e.actor_id = r.actor_id
|
|
185
|
+
AND e.command_id = r.command_id) AS events
|
|
186
|
+
FROM durable.receipts r
|
|
187
|
+
WHERE ${owned}
|
|
188
|
+
ORDER BY r.expires_at_ms DESC, r.command_id COLLATE "C"
|
|
189
|
+
LIMIT ${page.limit}`;
|
|
190
|
+
const events = yield* sql `
|
|
191
|
+
SELECT sequence::float8 AS sequence, event, command_id AS "commandId", value,
|
|
192
|
+
value_bytes::int AS bytes, emitted_at_ms::float8 AS "emittedAtMs"
|
|
193
|
+
FROM durable.events
|
|
194
|
+
WHERE ${owned} ORDER BY sequence DESC LIMIT ${page.limit}`;
|
|
195
|
+
const outbox = yield* sql.unsafe(`SELECT ${OUTBOX_COLUMNS} FROM durable.outbox
|
|
196
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
197
|
+
ORDER BY due_at_ms, intent_id COLLATE "C" LIMIT $5`, [routingKey, page.tenant, page.actorType, page.actorId, page.limit]);
|
|
198
|
+
const jobs = yield* sql.unsafe(`SELECT ${JOB_COLUMNS} FROM durable.jobs
|
|
199
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
200
|
+
ORDER BY due_at_ms, job_id COLLATE "C" LIMIT $5`, [routingKey, page.tenant, page.actorType, page.actorId, page.limit]);
|
|
201
|
+
const deadLetters = yield* sql.unsafe(`SELECT ${DEAD_LETTER_COLUMNS} FROM durable.dead_letters
|
|
202
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
203
|
+
ORDER BY dead_at_ms DESC, job_id COLLATE "C" LIMIT $5`, [routingKey, page.tenant, page.actorType, page.actorId, page.limit]);
|
|
204
|
+
const workflows = yield* sql.unsafe(`SELECT ${WORKFLOW_COLUMNS} FROM durable.workflows
|
|
205
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
206
|
+
ORDER BY started_at_ms DESC, execution_id COLLATE "C" LIMIT $5`, [routingKey, page.tenant, page.actorType, page.actorId, page.limit]);
|
|
207
|
+
const steps = yield* sql.unsafe(`SELECT ${STEP_COLUMNS} FROM durable.workflow_steps
|
|
208
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
209
|
+
AND execution_id IN (SELECT execution_id FROM durable.workflows
|
|
210
|
+
WHERE routing_key = $1::int8 AND tenant_id = $2 AND actor_type = $3 AND actor_id = $4
|
|
211
|
+
ORDER BY started_at_ms DESC, execution_id COLLATE "C" LIMIT $5)
|
|
212
|
+
ORDER BY started_at_ms, step COLLATE "C", attempt`, [routingKey, page.tenant, page.actorType, page.actorId, page.limit]);
|
|
213
|
+
const [totals] = yield* sql `
|
|
214
|
+
SELECT
|
|
215
|
+
(SELECT count(*)::int FROM durable.receipts WHERE ${owned}) AS receipts,
|
|
216
|
+
(SELECT count(*)::int FROM durable.events WHERE ${owned}) AS events,
|
|
217
|
+
(SELECT count(*)::int FROM durable.outbox WHERE ${owned}) AS outbox,
|
|
218
|
+
(SELECT count(*)::int FROM durable.jobs WHERE ${owned}) AS jobs,
|
|
219
|
+
(SELECT count(*)::int FROM durable.dead_letters WHERE ${owned}) AS "deadLetters",
|
|
220
|
+
(SELECT count(*)::int FROM durable.workflows WHERE ${owned}) AS workflows`;
|
|
221
|
+
return Option.some({
|
|
222
|
+
actor: row,
|
|
223
|
+
state: state.map(({ key, value, bytes }) => ({ key, bytes, value: decodeBytes(value) })),
|
|
224
|
+
receipts: receipts.map(receiptOf),
|
|
225
|
+
events: events.map(({ value, ...event }) => ({ ...event, value: decodeBytes(value) })),
|
|
226
|
+
outbox: outbox.map(outboxOf),
|
|
227
|
+
jobs: jobs.map(jobOf),
|
|
228
|
+
deadLetters: deadLetters.map(deadLetterOf),
|
|
229
|
+
workflows: workflows.map((workflow) => workflowOf(workflow, steps)),
|
|
230
|
+
totals: totals,
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
/** The tenant's pending intents and timers, soonest first. */
|
|
234
|
+
export const outbox = ({ tenant, limit }) => Effect.gen(function* () {
|
|
235
|
+
const sql = yield* SqlClient.SqlClient;
|
|
236
|
+
const rows = yield* sql.unsafe(`SELECT ${OUTBOX_COLUMNS} FROM durable.outbox WHERE tenant_id = $1
|
|
237
|
+
ORDER BY due_at_ms, intent_id COLLATE "C" LIMIT $2`, [tenant, limit]);
|
|
238
|
+
return { outbox: rows.map(outboxOf) };
|
|
239
|
+
});
|
|
240
|
+
/** The tenant's enqueued jobs not yet settled, soonest first. */
|
|
241
|
+
export const jobs = ({ tenant, limit }) => Effect.gen(function* () {
|
|
242
|
+
const sql = yield* SqlClient.SqlClient;
|
|
243
|
+
const rows = yield* sql.unsafe(`SELECT ${JOB_COLUMNS} FROM durable.jobs WHERE tenant_id = $1
|
|
244
|
+
ORDER BY due_at_ms, job_id COLLATE "C" LIMIT $2`, [tenant, limit]);
|
|
245
|
+
return { jobs: rows.map(jobOf) };
|
|
246
|
+
});
|
|
247
|
+
/** The tenant's dead letters, newest first, one page after `after`. */
|
|
248
|
+
export const deadLetters = ({ tenant, limit, after }) => Effect.gen(function* () {
|
|
249
|
+
const sql = yield* SqlClient.SqlClient;
|
|
250
|
+
const rows = yield* sql.unsafe(`SELECT ${DEAD_LETTER_COLUMNS} FROM durable.dead_letters WHERE tenant_id = $1
|
|
251
|
+
AND ($2::int8 IS NULL OR dead_at_ms < $2::int8
|
|
252
|
+
OR (dead_at_ms = $2::int8 AND job_id COLLATE "C" > $3))
|
|
253
|
+
ORDER BY dead_at_ms DESC, job_id COLLATE "C" LIMIT $4`, [tenant, after?.deadAtMs ?? null, after?.jobId ?? "", limit + 1]);
|
|
254
|
+
const items = rows.slice(0, limit);
|
|
255
|
+
const last = items.at(-1);
|
|
256
|
+
return {
|
|
257
|
+
deadLetters: items.map(deadLetterOf),
|
|
258
|
+
next: rows.length > limit && last !== undefined
|
|
259
|
+
? { deadAtMs: last.deadAtMs, jobId: last.jobId }
|
|
260
|
+
: null,
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
/** Whether a finished execution's stored result is a success, or `undefined` when it does not decode. */
|
|
264
|
+
const succeeded = (row) => {
|
|
265
|
+
const result = decodeBytes(row.result);
|
|
266
|
+
if (result === null || !("json" in result) || !isTaggedJson(result.json))
|
|
267
|
+
return undefined;
|
|
268
|
+
return Predicate.isTagged(result.json, "Success");
|
|
269
|
+
};
|
|
270
|
+
const isTaggedJson = Schema.is(Schema.Struct({ _tag: Schema.String }));
|
|
271
|
+
/**
|
|
272
|
+
* The tenant's workflow executions, newest first, one page after `after`, each
|
|
273
|
+
* with its recorded steps. The steps are read for the same page of executions,
|
|
274
|
+
* so each listed execution has all its steps. A finished execution's result
|
|
275
|
+
* is compressed, so `completed` and `failed` read finished executions
|
|
276
|
+
* `MAX_LIMIT` at a time and keep those whose result matches until the page is
|
|
277
|
+
* full; a result that does not decode matches neither.
|
|
278
|
+
*/
|
|
279
|
+
export const workflows = ({ tenant, limit, status, after }) => Effect.gen(function* () {
|
|
280
|
+
const sql = yield* SqlClient.SqlClient;
|
|
281
|
+
const stored = status === "completed" || status === "failed" ? "finished" : status;
|
|
282
|
+
const page = `tenant_id = $1
|
|
283
|
+
AND ($2 = 'all' OR ($2 = 'open' AND status <> 'finished') OR status = $2)
|
|
284
|
+
AND ($3::int8 IS NULL OR started_at_ms < $3::int8
|
|
285
|
+
OR (started_at_ms = $3::int8 AND execution_id COLLATE "C" > $4))`;
|
|
286
|
+
const read = (from, size) => sql.unsafe(`SELECT ${WORKFLOW_COLUMNS} FROM durable.workflows WHERE ${page}
|
|
287
|
+
ORDER BY started_at_ms DESC, execution_id COLLATE "C" LIMIT $5`, [tenant, stored, from?.startedAtMs ?? null, from?.executionId ?? "", size]);
|
|
288
|
+
const rows = [];
|
|
289
|
+
if (stored === status)
|
|
290
|
+
rows.push(...(yield* read(after, limit + 1)));
|
|
291
|
+
else {
|
|
292
|
+
let from = after;
|
|
293
|
+
while (rows.length <= limit) {
|
|
294
|
+
const batch = yield* read(from, MAX_LIMIT);
|
|
295
|
+
rows.push(...batch.filter((row) => succeeded(row) === (status === "completed")));
|
|
296
|
+
const last = batch.at(-1);
|
|
297
|
+
if (batch.length < MAX_LIMIT || last === undefined)
|
|
298
|
+
break;
|
|
299
|
+
from = { startedAtMs: last.startedAtMs, executionId: last.executionId };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const items = rows.slice(0, limit);
|
|
303
|
+
const last = items.at(-1);
|
|
304
|
+
const steps = items.length === 0
|
|
305
|
+
? []
|
|
306
|
+
: yield* sql.unsafe(`SELECT ${STEP_COLUMNS} FROM durable.workflow_steps
|
|
307
|
+
WHERE tenant_id = $1 AND execution_id IN (${items.map((_, index) => `$${String(index + 2)}`).join(", ")})
|
|
308
|
+
ORDER BY started_at_ms, step COLLATE "C", attempt`, [tenant, ...items.map((row) => row.executionId)]);
|
|
309
|
+
return {
|
|
310
|
+
workflows: items.map((row) => workflowOf(row, steps)),
|
|
311
|
+
next: rows.length > limit && last !== undefined
|
|
312
|
+
? { startedAtMs: last.startedAtMs, executionId: last.executionId }
|
|
313
|
+
: null,
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
/** The tenant's actor types by name, each with how many actors it has, one page after `after`. */
|
|
317
|
+
export const actorTypes = ({ tenant, limit, name, prefix, after }) => Effect.gen(function* () {
|
|
318
|
+
const sql = yield* SqlClient.SqlClient;
|
|
319
|
+
const rows = yield* sql `
|
|
320
|
+
SELECT actor_type AS "actorType", count(*)::int AS actors
|
|
321
|
+
FROM durable.actors
|
|
322
|
+
WHERE tenant_id = ${tenant}
|
|
323
|
+
AND ${name === undefined ? sql `TRUE` : sql `actor_type = ${name}`}
|
|
324
|
+
AND ${prefix === undefined ? sql `TRUE` : sql `starts_with(actor_type, ${prefix})`}
|
|
325
|
+
AND ${after === undefined ? sql `TRUE` : sql `actor_type COLLATE "C" > ${after}`}
|
|
326
|
+
GROUP BY actor_type
|
|
327
|
+
ORDER BY actor_type COLLATE "C"
|
|
328
|
+
LIMIT ${limit + 1}`;
|
|
329
|
+
const items = rows.slice(0, limit);
|
|
330
|
+
return {
|
|
331
|
+
actorTypes: items,
|
|
332
|
+
next: rows.length > limit ? (items.at(-1)?.actorType ?? null) : null,
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
/**
|
|
336
|
+
* The tenant's job names, each with its pending jobs split by whether an
|
|
337
|
+
* attempt has failed, and its dead letters, one page after `after`.
|
|
338
|
+
*/
|
|
339
|
+
export const jobTypes = ({ tenant, limit, after }) => Effect.gen(function* () {
|
|
340
|
+
const sql = yield* SqlClient.SqlClient;
|
|
341
|
+
const rows = yield* sql `
|
|
342
|
+
SELECT job, sum(queued)::int AS queued, sum(retrying)::int AS retrying,
|
|
343
|
+
sum(dead)::int AS "deadLetters"
|
|
344
|
+
FROM (
|
|
345
|
+
SELECT job, count(*) FILTER (WHERE attempts = 0) AS queued,
|
|
346
|
+
count(*) FILTER (WHERE attempts > 0) AS retrying, 0 AS dead
|
|
347
|
+
FROM durable.jobs WHERE tenant_id = ${tenant} GROUP BY job
|
|
348
|
+
UNION ALL
|
|
349
|
+
SELECT job, 0, 0, count(*) FROM durable.dead_letters WHERE tenant_id = ${tenant} GROUP BY job
|
|
350
|
+
) named
|
|
351
|
+
WHERE ${after === undefined ? sql `TRUE` : sql `job COLLATE "C" > ${after}`}
|
|
352
|
+
GROUP BY job
|
|
353
|
+
ORDER BY job COLLATE "C"
|
|
354
|
+
LIMIT ${limit + 1}`;
|
|
355
|
+
const items = rows.slice(0, limit);
|
|
356
|
+
return {
|
|
357
|
+
jobTypes: items,
|
|
358
|
+
next: rows.length > limit ? (items.at(-1)?.job ?? null) : null,
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
/**
|
|
362
|
+
* Receipts, the latest expiry first, one page after `after`, each with the
|
|
363
|
+
* events it committed. A receipt's expiry is the one its command id carries,
|
|
364
|
+
* so this is the order the command ids were issued in, not the order the
|
|
365
|
+
* turns committed. `None` when the page names one actor the tenant does not
|
|
366
|
+
* have.
|
|
367
|
+
*/
|
|
368
|
+
export const receipts = (page) => Effect.gen(function* () {
|
|
369
|
+
const sql = yield* SqlClient.SqlClient;
|
|
370
|
+
let scope = sql `TRUE`;
|
|
371
|
+
if (page.actorType !== undefined && page.actorId !== undefined) {
|
|
372
|
+
const found = yield* findActor({ ...page, actorType: page.actorType, actorId: page.actorId });
|
|
373
|
+
if (Option.isNone(found))
|
|
374
|
+
return Option.none();
|
|
375
|
+
scope = sql `r.routing_key = ${found.value.routingKey}::int8
|
|
376
|
+
AND r.actor_type = ${page.actorType} AND r.actor_id = ${page.actorId}`;
|
|
377
|
+
}
|
|
378
|
+
else if (page.actorType !== undefined)
|
|
379
|
+
scope = sql `r.actor_type = ${page.actorType}`;
|
|
380
|
+
const after = page.after === undefined
|
|
381
|
+
? sql `TRUE`
|
|
382
|
+
: sql `(r.expires_at_ms < ${page.after.expiresAtMs}::int8
|
|
383
|
+
OR (r.expires_at_ms = ${page.after.expiresAtMs}::int8
|
|
384
|
+
AND (r.actor_type COLLATE "C", r.actor_id COLLATE "C", r.command_id COLLATE "C")
|
|
385
|
+
> (${page.after.actorType}, ${page.after.actorId}, ${page.after.commandId})))`;
|
|
386
|
+
const rows = yield* sql `
|
|
387
|
+
SELECT r.actor_type AS "actorType", r.actor_id AS "actorId",
|
|
388
|
+
r.command_id AS "commandId", r.command, r.caller_key AS "callerKey",
|
|
389
|
+
r.outcome_tag AS "outcomeTag", r.outcome, r.expires_at_ms::float8 AS "expiresAtMs",
|
|
390
|
+
(SELECT string_agg(e.sequence::text, ',' ORDER BY e.sequence) FROM durable.events e
|
|
391
|
+
WHERE e.routing_key = r.routing_key AND e.tenant_id = r.tenant_id
|
|
392
|
+
AND e.actor_type = r.actor_type AND e.actor_id = r.actor_id
|
|
393
|
+
AND e.command_id = r.command_id) AS events
|
|
394
|
+
FROM durable.receipts r
|
|
395
|
+
WHERE r.tenant_id = ${page.tenant} AND ${scope} AND ${after}
|
|
396
|
+
AND ${page.outcomeTag === undefined ? sql `TRUE` : sql `r.outcome_tag = ${page.outcomeTag}`}
|
|
397
|
+
ORDER BY r.expires_at_ms DESC, r.actor_type COLLATE "C", r.actor_id COLLATE "C",
|
|
398
|
+
r.command_id COLLATE "C"
|
|
399
|
+
LIMIT ${page.limit + 1}`;
|
|
400
|
+
const items = rows.slice(0, page.limit);
|
|
401
|
+
const last = items.at(-1);
|
|
402
|
+
return Option.some({
|
|
403
|
+
receipts: items.map(receiptOf),
|
|
404
|
+
next: rows.length > page.limit && last !== undefined
|
|
405
|
+
? {
|
|
406
|
+
actorType: last.actorType,
|
|
407
|
+
actorId: last.actorId,
|
|
408
|
+
expiresAtMs: last.expiresAtMs,
|
|
409
|
+
commandId: last.commandId,
|
|
410
|
+
}
|
|
411
|
+
: null,
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
/**
|
|
415
|
+
* The newest retained event of each name one actor emitted, by name, one page
|
|
416
|
+
* after `after`. `None` when the tenant has no such actor.
|
|
417
|
+
*/
|
|
418
|
+
export const latestEvents = (page) => Effect.gen(function* () {
|
|
419
|
+
const found = yield* findActor(page);
|
|
420
|
+
if (Option.isNone(found))
|
|
421
|
+
return Option.none();
|
|
422
|
+
const sql = yield* SqlClient.SqlClient;
|
|
423
|
+
const rows = yield* sql `
|
|
424
|
+
SELECT event, sequence, "emittedAtMs" FROM (
|
|
425
|
+
SELECT DISTINCT ON (event) event, sequence::float8 AS sequence,
|
|
426
|
+
emitted_at_ms::float8 AS "emittedAtMs"
|
|
427
|
+
FROM durable.events
|
|
428
|
+
WHERE routing_key = ${found.value.routingKey}::int8 AND tenant_id = ${page.tenant}
|
|
429
|
+
AND actor_type = ${page.actorType} AND actor_id = ${page.actorId}
|
|
430
|
+
AND ${page.after === undefined ? sql `TRUE` : sql `event COLLATE "C" > ${page.after}`}
|
|
431
|
+
ORDER BY event, sequence DESC
|
|
432
|
+
) latest
|
|
433
|
+
ORDER BY event COLLATE "C"
|
|
434
|
+
LIMIT ${page.limit + 1}`;
|
|
435
|
+
const items = rows.slice(0, page.limit);
|
|
436
|
+
return Option.some({
|
|
437
|
+
events: items,
|
|
438
|
+
next: rows.length > page.limit ? (items.at(-1)?.event ?? null) : null,
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
/**
|
|
442
|
+
* One actor's timeline, newest first, one page after `before`: every retained
|
|
443
|
+
* event at its emission time, and every retained receipt whose turn emitted
|
|
444
|
+
* events, at that turn's emission time and placed after its own events. A
|
|
445
|
+
* receipt whose turn emitted nothing has no recorded time, so it is not on the
|
|
446
|
+
* timeline. Event sequences only grow, so they order the timeline exactly.
|
|
447
|
+
* `None` when the tenant has no such actor.
|
|
448
|
+
*/
|
|
449
|
+
export const timeline = (page) => Effect.gen(function* () {
|
|
450
|
+
const found = yield* findActor(page);
|
|
451
|
+
if (Option.isNone(found))
|
|
452
|
+
return Option.none();
|
|
453
|
+
const sql = yield* SqlClient.SqlClient;
|
|
454
|
+
const owned = (alias) => sql `${sql(alias)}.routing_key = ${found.value.routingKey}::int8
|
|
455
|
+
AND ${sql(alias)}.tenant_id = ${page.tenant}
|
|
456
|
+
AND ${sql(alias)}.actor_type = ${page.actorType} AND ${sql(alias)}.actor_id = ${page.actorId}`;
|
|
457
|
+
const before = page.before === undefined
|
|
458
|
+
? sql `TRUE`
|
|
459
|
+
: sql `(sequence, rank) < (${page.before.sequence}::float8, ${page.before.kind === "event" ? 1 : 0})`;
|
|
460
|
+
const rows = yield* sql `
|
|
461
|
+
SELECT kind, sequence, name, "commandId", "callerKey", "atMs" FROM (
|
|
462
|
+
SELECT 'event' AS kind, 1 AS rank, e.sequence::float8 AS sequence, e.event AS name,
|
|
463
|
+
e.command_id AS "commandId", r.caller_key AS "callerKey",
|
|
464
|
+
e.emitted_at_ms::float8 AS "atMs"
|
|
465
|
+
FROM durable.events e
|
|
466
|
+
LEFT JOIN durable.receipts r ON r.routing_key = e.routing_key
|
|
467
|
+
AND r.tenant_id = e.tenant_id AND r.actor_type = e.actor_type
|
|
468
|
+
AND r.actor_id = e.actor_id AND r.command_id = e.command_id
|
|
469
|
+
WHERE ${owned("e")}
|
|
470
|
+
UNION ALL
|
|
471
|
+
SELECT 'command', 0, min(e.sequence)::float8, r.command, r.command_id, r.caller_key,
|
|
472
|
+
min(e.emitted_at_ms)::float8
|
|
473
|
+
FROM durable.receipts r
|
|
474
|
+
JOIN durable.events e ON e.routing_key = r.routing_key
|
|
475
|
+
AND e.tenant_id = r.tenant_id AND e.actor_type = r.actor_type
|
|
476
|
+
AND e.actor_id = r.actor_id AND e.command_id = r.command_id
|
|
477
|
+
WHERE ${owned("r")}
|
|
478
|
+
GROUP BY r.command_id, r.command, r.caller_key
|
|
479
|
+
) entries
|
|
480
|
+
WHERE ${before}
|
|
481
|
+
ORDER BY sequence DESC, rank DESC
|
|
482
|
+
LIMIT ${page.limit + 1}`;
|
|
483
|
+
const items = rows.slice(0, page.limit);
|
|
484
|
+
const last = items.at(-1);
|
|
485
|
+
return Option.some({
|
|
486
|
+
entries: items.map(({ callerKey, ...entry }) => ({
|
|
487
|
+
...entry,
|
|
488
|
+
callerKey: decodeText(callerKey),
|
|
489
|
+
})),
|
|
490
|
+
next: rows.length > page.limit && last !== undefined
|
|
491
|
+
? { sequence: last.sequence, kind: last.kind }
|
|
492
|
+
: null,
|
|
493
|
+
});
|
|
494
|
+
});
|