@adonis-agora/durable 0.49.0 → 0.50.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 +261 -0
- package/README.md +53 -22
- package/dist/assets/spa/assets/index-DupjrK7N.js +16 -0
- package/dist/assets/spa/assets/index-DupjrK7N.js.map +1 -0
- package/dist/assets/spa/index.html +1 -1
- package/dist/commands/durable_worker.d.ts.map +1 -1
- package/dist/commands/durable_worker.js +9 -8
- package/dist/commands/durable_worker.js.map +1 -1
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +1 -0
- package/dist/configure.js.map +1 -1
- package/dist/providers/dashboard_provider.d.ts +2 -0
- package/dist/providers/dashboard_provider.d.ts.map +1 -1
- package/dist/providers/dashboard_provider.js +50 -6
- package/dist/providers/dashboard_provider.js.map +1 -1
- package/dist/providers/durable_provider.d.ts.map +1 -1
- package/dist/providers/durable_provider.js +143 -34
- package/dist/providers/durable_provider.js.map +1 -1
- package/dist/src/admission-redis/redis-admission-backend.d.ts.map +1 -1
- package/dist/src/admission-redis/redis-admission-backend.js +3 -1
- package/dist/src/admission-redis/redis-admission-backend.js.map +1 -1
- package/dist/src/ambient-step.d.ts +24 -0
- package/dist/src/ambient-step.d.ts.map +1 -0
- package/dist/src/ambient-step.js +42 -0
- package/dist/src/ambient-step.js.map +1 -0
- package/dist/src/base-workflow.d.ts +10 -1
- package/dist/src/base-workflow.d.ts.map +1 -1
- package/dist/src/base-workflow.js.map +1 -1
- package/dist/src/codec-state-store.d.ts +28 -2
- package/dist/src/codec-state-store.d.ts.map +1 -1
- package/dist/src/codec-state-store.js +61 -3
- package/dist/src/codec-state-store.js.map +1 -1
- package/dist/src/commands/worker.d.ts +4 -1
- package/dist/src/commands/worker.d.ts.map +1 -1
- package/dist/src/commands/worker.js +27 -3
- package/dist/src/commands/worker.js.map +1 -1
- package/dist/src/config_types.d.ts +6 -0
- package/dist/src/config_types.d.ts.map +1 -1
- package/dist/src/control-plane-redis/redis-control-plane.d.ts.map +1 -1
- package/dist/src/control-plane-redis/redis-control-plane.js +22 -6
- package/dist/src/control-plane-redis/redis-control-plane.js.map +1 -1
- package/dist/src/control-planes/factory.d.ts +6 -0
- package/dist/src/control-planes/factory.d.ts.map +1 -1
- package/dist/src/control-planes/factory.js +1 -0
- package/dist/src/control-planes/factory.js.map +1 -1
- package/dist/src/dashboard/gateway-adapter.d.ts +15 -5
- package/dist/src/dashboard/gateway-adapter.d.ts.map +1 -1
- package/dist/src/dashboard/gateway-adapter.js +71 -7
- package/dist/src/dashboard/gateway-adapter.js.map +1 -1
- package/dist/src/dashboard/handlers.d.ts +53 -1
- package/dist/src/dashboard/handlers.d.ts.map +1 -1
- package/dist/src/dashboard/handlers.js +200 -20
- package/dist/src/dashboard/handlers.js.map +1 -1
- package/dist/src/dashboard/index.d.ts +2 -2
- package/dist/src/dashboard/index.d.ts.map +1 -1
- package/dist/src/dashboard/index.js +2 -2
- package/dist/src/dashboard/index.js.map +1 -1
- package/dist/src/dashboard/openapi.d.ts.map +1 -1
- package/dist/src/dashboard/openapi.js +71 -1
- package/dist/src/dashboard/openapi.js.map +1 -1
- package/dist/src/define_config.d.ts +122 -8
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/diagnostics-bridge.d.ts +16 -3
- package/dist/src/diagnostics-bridge.d.ts.map +1 -1
- package/dist/src/diagnostics-bridge.js +9 -3
- package/dist/src/diagnostics-bridge.js.map +1 -1
- package/dist/src/discovery-roots.d.ts +92 -0
- package/dist/src/discovery-roots.d.ts.map +1 -0
- package/dist/src/discovery-roots.js +150 -0
- package/dist/src/discovery-roots.js.map +1 -0
- package/dist/src/engine.d.ts +418 -20
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/engine.js +1523 -159
- package/dist/src/engine.js.map +1 -1
- package/dist/src/entities.d.ts +36 -1
- package/dist/src/entities.d.ts.map +1 -1
- package/dist/src/entities.js +65 -4
- package/dist/src/entities.js.map +1 -1
- package/dist/src/errors.d.ts +36 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +44 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/event-trigger-bridge.d.ts +8 -0
- package/dist/src/event-trigger-bridge.d.ts.map +1 -1
- package/dist/src/event-trigger-bridge.js +24 -3
- package/dist/src/event-trigger-bridge.js.map +1 -1
- package/dist/src/handshake/announced.d.ts +27 -0
- package/dist/src/handshake/announced.d.ts.map +1 -1
- package/dist/src/handshake/announced.js +62 -0
- package/dist/src/handshake/announced.js.map +1 -1
- package/dist/src/handshake/directory.d.ts +92 -0
- package/dist/src/handshake/directory.d.ts.map +1 -0
- package/dist/src/handshake/directory.js +139 -0
- package/dist/src/handshake/directory.js.map +1 -0
- package/dist/src/hooks/barrel-sources.d.ts +28 -0
- package/dist/src/hooks/barrel-sources.d.ts.map +1 -0
- package/dist/src/hooks/barrel-sources.js +92 -0
- package/dist/src/hooks/barrel-sources.js.map +1 -0
- package/dist/src/hooks/steps.d.ts +12 -3
- package/dist/src/hooks/steps.d.ts.map +1 -1
- package/dist/src/hooks/steps.js +7 -11
- package/dist/src/hooks/steps.js.map +1 -1
- package/dist/src/hooks/workflows.d.ts +12 -3
- package/dist/src/hooks/workflows.d.ts.map +1 -1
- package/dist/src/hooks/workflows.js +7 -13
- package/dist/src/hooks/workflows.js.map +1 -1
- package/dist/src/index.d.ts +12 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces.d.ts +309 -21
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/interfaces.js +10 -0
- package/dist/src/interfaces.js.map +1 -1
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/metrics.js +5 -0
- package/dist/src/metrics.js.map +1 -1
- package/dist/src/namespaces.d.ts +17 -0
- package/dist/src/namespaces.d.ts.map +1 -0
- package/dist/src/namespaces.js +24 -0
- package/dist/src/namespaces.js.map +1 -0
- package/dist/src/otel/durable-metrics.d.ts.map +1 -1
- package/dist/src/otel/durable-metrics.js +5 -0
- package/dist/src/otel/durable-metrics.js.map +1 -1
- package/dist/src/otel/durable-otel.d.ts.map +1 -1
- package/dist/src/otel/durable-otel.js +5 -0
- package/dist/src/otel/durable-otel.js.map +1 -1
- package/dist/src/pollers.d.ts +10 -1
- package/dist/src/pollers.d.ts.map +1 -1
- package/dist/src/pollers.js +15 -5
- package/dist/src/pollers.js.map +1 -1
- package/dist/src/protocol.d.ts +12 -0
- package/dist/src/protocol.d.ts.map +1 -1
- package/dist/src/protocol.js +27 -1
- package/dist/src/protocol.js.map +1 -1
- package/dist/src/remote-event.d.ts +6 -0
- package/dist/src/remote-event.d.ts.map +1 -0
- package/dist/src/remote-event.js +19 -0
- package/dist/src/remote-event.js.map +1 -0
- package/dist/src/remote-workflow-executor.d.ts +34 -12
- package/dist/src/remote-workflow-executor.d.ts.map +1 -1
- package/dist/src/remote-workflow-executor.js +42 -40
- package/dist/src/remote-workflow-executor.js.map +1 -1
- package/dist/src/run-detail-summary.d.ts +90 -3
- package/dist/src/run-detail-summary.d.ts.map +1 -1
- package/dist/src/run-detail-summary.js +360 -2
- package/dist/src/run-detail-summary.js.map +1 -1
- package/dist/src/run-facets.d.ts +48 -0
- package/dist/src/run-facets.d.ts.map +1 -0
- package/dist/src/run-facets.js +100 -0
- package/dist/src/run-facets.js.map +1 -0
- package/dist/src/run-gateway/interface.d.ts +27 -1
- package/dist/src/run-gateway/interface.d.ts.map +1 -1
- package/dist/src/run-gateway/proxy-run-gateway.d.ts +32 -4
- package/dist/src/run-gateway/proxy-run-gateway.d.ts.map +1 -1
- package/dist/src/run-gateway/proxy-run-gateway.js +101 -5
- package/dist/src/run-gateway/proxy-run-gateway.js.map +1 -1
- package/dist/src/run-gateway/run-request-responder.d.ts +18 -5
- package/dist/src/run-gateway/run-request-responder.d.ts.map +1 -1
- package/dist/src/run-gateway/run-request-responder.js +155 -32
- package/dist/src/run-gateway/run-request-responder.js.map +1 -1
- package/dist/src/run-gateway/store-run-gateway.d.ts +23 -1
- package/dist/src/run-gateway/store-run-gateway.d.ts.map +1 -1
- package/dist/src/run-gateway/store-run-gateway.js +38 -0
- package/dist/src/run-gateway/store-run-gateway.js.map +1 -1
- package/dist/src/search-attributes-schema.d.ts +44 -0
- package/dist/src/search-attributes-schema.d.ts.map +1 -0
- package/dist/src/search-attributes-schema.js +51 -0
- package/dist/src/search-attributes-schema.js.map +1 -0
- package/dist/src/singleton-admission.d.ts +75 -0
- package/dist/src/singleton-admission.d.ts.map +1 -0
- package/dist/src/singleton-admission.js +156 -0
- package/dist/src/singleton-admission.js.map +1 -0
- package/dist/src/singleton-gate.d.ts +23 -8
- package/dist/src/singleton-gate.d.ts.map +1 -1
- package/dist/src/singleton-gate.js +59 -12
- package/dist/src/singleton-gate.js.map +1 -1
- package/dist/src/standard-schema.d.ts +83 -0
- package/dist/src/standard-schema.d.ts.map +1 -0
- package/dist/src/standard-schema.js +31 -0
- package/dist/src/standard-schema.js.map +1 -0
- package/dist/src/step-discovery.d.ts +21 -11
- package/dist/src/step-discovery.d.ts.map +1 -1
- package/dist/src/step-discovery.js +86 -45
- package/dist/src/step-discovery.js.map +1 -1
- package/dist/src/step-ref.d.ts +38 -12
- package/dist/src/step-ref.d.ts.map +1 -1
- package/dist/src/step-ref.js +5 -13
- package/dist/src/step-ref.js.map +1 -1
- package/dist/src/stores/factory.d.ts +6 -0
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +4 -1
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/stores/lucid-helpers.d.ts +2 -0
- package/dist/src/stores/lucid-helpers.d.ts.map +1 -1
- package/dist/src/stores/lucid-helpers.js +7 -0
- package/dist/src/stores/lucid-helpers.js.map +1 -1
- package/dist/src/stores/lucid-mappers.d.ts +25 -0
- package/dist/src/stores/lucid-mappers.d.ts.map +1 -1
- package/dist/src/stores/lucid-mappers.js +81 -18
- package/dist/src/stores/lucid-mappers.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts +59 -1
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +271 -25
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +61 -2
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +346 -41
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/telescope/dashboard.d.ts.map +1 -1
- package/dist/src/telescope/dashboard.js +30 -1
- package/dist/src/telescope/dashboard.js.map +1 -1
- package/dist/src/telescope/data-providers.d.ts +19 -1
- package/dist/src/telescope/data-providers.d.ts.map +1 -1
- package/dist/src/telescope/data-providers.js +119 -3
- package/dist/src/telescope/data-providers.js.map +1 -1
- package/dist/src/telescope/extension.d.ts.map +1 -1
- package/dist/src/telescope/extension.js +2 -1
- package/dist/src/telescope/extension.js.map +1 -1
- package/dist/src/telescope/index.d.ts +1 -1
- package/dist/src/telescope/index.d.ts.map +1 -1
- package/dist/src/telescope/index.js +1 -1
- package/dist/src/telescope/index.js.map +1 -1
- package/dist/src/testing/in-memory-state-store.d.ts +44 -15
- package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-state-store.js +204 -41
- package/dist/src/testing/in-memory-state-store.js.map +1 -1
- package/dist/src/testing-kit/checkpoint-aggregation-contract.d.ts +16 -0
- package/dist/src/testing-kit/checkpoint-aggregation-contract.d.ts.map +1 -0
- package/dist/src/testing-kit/checkpoint-aggregation-contract.js +228 -0
- package/dist/src/testing-kit/checkpoint-aggregation-contract.js.map +1 -0
- package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
- package/dist/src/testing-kit/state-store-conformance.js +355 -3
- package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
- package/dist/src/transport-pool.d.ts +15 -1
- package/dist/src/transport-pool.d.ts.map +1 -1
- package/dist/src/transport-pool.js +50 -4
- package/dist/src/transport-pool.js.map +1 -1
- package/dist/src/transports/adaptive-concurrency.d.ts +168 -0
- package/dist/src/transports/adaptive-concurrency.d.ts.map +1 -0
- package/dist/src/transports/adaptive-concurrency.js +353 -0
- package/dist/src/transports/adaptive-concurrency.js.map +1 -0
- package/dist/src/transports/bullmq/adaptive-concurrency.d.ts +1 -143
- package/dist/src/transports/bullmq/adaptive-concurrency.d.ts.map +1 -1
- package/dist/src/transports/bullmq/adaptive-concurrency.js +3 -311
- package/dist/src/transports/bullmq/adaptive-concurrency.js.map +1 -1
- package/dist/src/transports/bullmq/bullmq-transport.d.ts +49 -1
- package/dist/src/transports/bullmq/bullmq-transport.d.ts.map +1 -1
- package/dist/src/transports/bullmq/bullmq-transport.js +330 -38
- package/dist/src/transports/bullmq/bullmq-transport.js.map +1 -1
- package/dist/src/transports/bullmq/deps.d.ts +18 -2
- package/dist/src/transports/bullmq/deps.d.ts.map +1 -1
- package/dist/src/transports/bullmq/deps.js +44 -2
- package/dist/src/transports/bullmq/deps.js.map +1 -1
- package/dist/src/transports/db-helpers.d.ts +39 -0
- package/dist/src/transports/db-helpers.d.ts.map +1 -1
- package/dist/src/transports/db-helpers.js +73 -0
- package/dist/src/transports/db-helpers.js.map +1 -1
- package/dist/src/transports/db-remote.d.ts +53 -0
- package/dist/src/transports/db-remote.d.ts.map +1 -0
- package/dist/src/transports/db-remote.js +147 -0
- package/dist/src/transports/db-remote.js.map +1 -0
- package/dist/src/transports/db-schema.d.ts +44 -1
- package/dist/src/transports/db-schema.d.ts.map +1 -1
- package/dist/src/transports/db-schema.js +227 -88
- package/dist/src/transports/db-schema.js.map +1 -1
- package/dist/src/transports/db.d.ts +189 -6
- package/dist/src/transports/db.d.ts.map +1 -1
- package/dist/src/transports/db.js +1291 -137
- package/dist/src/transports/db.js.map +1 -1
- package/dist/src/transports/event-emitter.d.ts +8 -0
- package/dist/src/transports/event-emitter.d.ts.map +1 -1
- package/dist/src/transports/event-emitter.js +36 -3
- package/dist/src/transports/event-emitter.js.map +1 -1
- package/dist/src/transports/factory.d.ts +110 -5
- package/dist/src/transports/factory.d.ts.map +1 -1
- package/dist/src/transports/factory.js +56 -9
- package/dist/src/transports/factory.js.map +1 -1
- package/dist/src/transports/queue-mock-adapter.d.ts +7 -2
- package/dist/src/transports/queue-mock-adapter.d.ts.map +1 -1
- package/dist/src/transports/queue-mock-adapter.js +18 -2
- package/dist/src/transports/queue-mock-adapter.js.map +1 -1
- package/dist/src/transports/queue-remote.d.ts +146 -0
- package/dist/src/transports/queue-remote.d.ts.map +1 -0
- package/dist/src/transports/queue-remote.js +398 -0
- package/dist/src/transports/queue-remote.js.map +1 -0
- package/dist/src/transports/queue.d.ts +159 -6
- package/dist/src/transports/queue.d.ts.map +1 -1
- package/dist/src/transports/queue.js +747 -37
- package/dist/src/transports/queue.js.map +1 -1
- package/dist/src/transports/task-failure.d.ts +31 -0
- package/dist/src/transports/task-failure.d.ts.map +1 -0
- package/dist/src/transports/task-failure.js +50 -0
- package/dist/src/transports/task-failure.js.map +1 -0
- package/dist/src/workflow-als.d.ts +1 -1
- package/dist/src/workflow-als.d.ts.map +1 -1
- package/dist/src/workflow-ctx.d.ts +10 -0
- package/dist/src/workflow-ctx.d.ts.map +1 -1
- package/dist/src/workflow-ctx.js +97 -15
- package/dist/src/workflow-ctx.js.map +1 -1
- package/dist/src/workflow-discovery.d.ts +32 -41
- package/dist/src/workflow-discovery.d.ts.map +1 -1
- package/dist/src/workflow-discovery.js +65 -88
- package/dist/src/workflow-discovery.js.map +1 -1
- package/dist/src/workflow-ref.d.ts +24 -0
- package/dist/src/workflow-ref.d.ts.map +1 -1
- package/dist/src/workflow-ref.js.map +1 -1
- package/dist/stubs/config/durable.stub +6 -0
- package/dist/stubs/config/durable_dashboard.stub +7 -3
- package/dist/stubs/database/migrations/create_durable_tables.stub +2 -1
- package/dist/stubs/database/migrations/create_durable_transport_messages.stub +43 -0
- package/dist/stubs/database/migrations/create_durable_transport_tables.stub +12 -9
- package/dist/stubs/database/migrations/create_durable_transport_worker_keys.stub +1 -1
- package/dist/stubs/make/workflow/main.stub +1 -1
- package/package.json +6 -4
- package/skills/durable-cluster/SKILL.md +80 -11
- package/skills/durable-determinism/SKILL.md +11 -5
- package/skills/durable-reliability/SKILL.md +77 -37
- package/skills/durable-setup/SKILL.md +51 -22
- package/skills/durable-transports-stores/SKILL.md +130 -19
- package/skills/durable-workflows/SKILL.md +71 -18
- package/dist/assets/spa/assets/index-DdB9zxuX.js +0 -16
- package/dist/assets/spa/assets/index-DdB9zxuX.js.map +0 -1
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.50.0';
|
|
3
3
|
// Re-export the configure hook from the package root so `node ace configure` finds it.
|
|
4
4
|
// AdonisJS imports the package MAIN and reads `configure` off the module namespace —
|
|
5
5
|
// the `./configure` subpath alone is never consulted.
|
|
@@ -8,6 +8,7 @@ export { configure } from '../configure.js';
|
|
|
8
8
|
export * from './admission.js';
|
|
9
9
|
// --- config-driven admission drivers ----------------------------------------
|
|
10
10
|
export { admissions } from './admissions/factory.js';
|
|
11
|
+
export { currentStep } from './ambient-step.js';
|
|
11
12
|
export { BaseWorkflow, setWorkflowEngineResolver, } from './base-workflow.js';
|
|
12
13
|
export * from './codec-state-store.js';
|
|
13
14
|
// --- ace command building blocks --------------------------------------------
|
|
@@ -22,6 +23,7 @@ export { controlPlanes } from './control-planes/factory.js';
|
|
|
22
23
|
// --- AdonisJS integration ---------------------------------------------------
|
|
23
24
|
export { defineConfig } from './define_config.js';
|
|
24
25
|
export * from './diagnostics-bridge.js';
|
|
26
|
+
export { DuplicateDiscoveryError, } from './discovery-roots.js';
|
|
25
27
|
export * from './dispatch-routing.js';
|
|
26
28
|
export * from './duration.js';
|
|
27
29
|
export * from './engine.js';
|
|
@@ -34,6 +36,7 @@ export { childIdsOf, parentRunIdOf } from './fan-join.js';
|
|
|
34
36
|
// --- store-less cluster: handshake & capability negotiation -----------------
|
|
35
37
|
export * from './handshake/announced.js';
|
|
36
38
|
export * from './handshake/descriptor.js';
|
|
39
|
+
export * from './handshake/directory.js';
|
|
37
40
|
export * from './handshake/negotiate.js';
|
|
38
41
|
export * from './handshake/routing.js';
|
|
39
42
|
export * from './interfaces.js';
|
|
@@ -43,10 +46,12 @@ export * from './on-error.js';
|
|
|
43
46
|
export * from './pollers.js';
|
|
44
47
|
export * from './protocol.js';
|
|
45
48
|
export * from './queue.js';
|
|
49
|
+
export { isRemoteEvent } from './remote-event.js';
|
|
46
50
|
export * from './remote-workflow-executor.js';
|
|
47
51
|
export * from './run-detail-summary.js';
|
|
52
|
+
export * from './run-facets.js';
|
|
48
53
|
export { ProxyRunGateway, } from './run-gateway/proxy-run-gateway.js';
|
|
49
|
-
export { RunRequestResponder, } from './run-gateway/run-request-responder.js';
|
|
54
|
+
export { RunRequestResponder, UNSUPPORTED_RUN_REQUEST, } from './run-gateway/run-request-responder.js';
|
|
50
55
|
export { StoreRunGateway, } from './run-gateway/store-run-gateway.js';
|
|
51
56
|
export { hmacTenantVerifier, signTenantToken } from './run-gateway/tenant-auth.js';
|
|
52
57
|
export * from './run-pagination.js';
|
|
@@ -55,13 +60,17 @@ export * from './run-waiting.js';
|
|
|
55
60
|
export * from './scheduler.js';
|
|
56
61
|
export * from './schedules.js';
|
|
57
62
|
export * from './search-attributes.js';
|
|
63
|
+
export * from './search-attributes-schema.js';
|
|
64
|
+
export * from './singleton-admission.js';
|
|
65
|
+
export * from './standard-schema.js';
|
|
58
66
|
export * from './step-discovery.js';
|
|
59
67
|
export { DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, stepConfigOf, stepNameOf, } from './step-name-symbol.js';
|
|
60
68
|
export * from './step-ref.js';
|
|
61
69
|
// --- config-driven state-store drivers --------------------------------------
|
|
62
70
|
export { stores } from './stores/factory.js';
|
|
63
71
|
export { LucidStateStore } from './stores/lucid.js';
|
|
64
|
-
export {
|
|
72
|
+
export { onCorruptJsonColumn, } from './stores/lucid-mappers.js';
|
|
73
|
+
export { createDurableTables, DURABLE_JSON_COLUMNS, DURABLE_SCHEMA_META_TABLE, DURABLE_SCHEMA_REVISION, DURABLE_TABLES, dropDurableTables, } from './stores/lucid-schema.js';
|
|
65
74
|
export * from './tenant-group.js';
|
|
66
75
|
export { InMemoryStateStore } from './testing/in-memory-state-store.js';
|
|
67
76
|
export { InMemoryTransport } from './testing/in-memory-transport.js';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,uFAAuF;AACvF,qFAAqF;AACrF,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,+EAA+E;AAC/E,cAAc,gBAAgB,CAAC;AAM/B,+EAA+E;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,yBAAyB,GAG1B,MAAM,oBAAoB,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,+EAA+E;AAC/E,sGAAsG;AACtG,wFAAwF;AACxF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,WAAW,EAEX,QAAQ,EACR,eAAe,EAGf,eAAe,EACf,QAAQ,EACR,OAAO,EACP,aAAa,EAEb,SAAS,GAKV,MAAM,qBAAqB,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAQjC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAIL,iBAAiB,GAGlB,MAAM,8CAA8C,CAAC;AAMtD,+EAA+E;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,+EAA+E;AAC/E,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/src/interfaces.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
1
|
import type { DispatchDiagnostics } from './dispatch-routing.js';
|
|
3
2
|
import type { WorkerDescriptor } from './handshake/descriptor.js';
|
|
4
3
|
import type { FanPageQuery, RunDetailOptions } from './run-detail-summary.js';
|
|
4
|
+
import type { StandardSchemaV1 } from './standard-schema.js';
|
|
5
5
|
import type { StepRef } from './step-name-symbol.js';
|
|
6
6
|
import type { WorkflowClass, WorkflowInputOf, WorkflowOutputOf } from './workflow-ref.js';
|
|
7
7
|
/**
|
|
@@ -73,6 +73,17 @@ export interface WorkflowRun {
|
|
|
73
73
|
* durable state required for correctness — a transport without priority support ignores it.
|
|
74
74
|
*/
|
|
75
75
|
priority?: number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* REMOTE workflow turn awaiting a decision: the globally unique `taskId` of the turn the engine
|
|
78
|
+
* dispatched to a workflow worker and then SUSPENDED on. Written BEFORE the turn is enqueued (and the
|
|
79
|
+
* run lease released), matched by the engine's decision handler so ONLY the decision for the
|
|
80
|
+
* currently-awaited turn is applied (a stale / duplicate / foreign decision is dropped), and cleared
|
|
81
|
+
* the moment that decision is applied. This is what makes a workflow-turn decision multi-instance
|
|
82
|
+
* safe: whichever engine replica consumes the decision looks the run up by `decision.runId` and
|
|
83
|
+
* applies it durably, instead of resolving an in-memory promise only the dispatching replica held.
|
|
84
|
+
* Absent on non-remote runs and on runs not currently awaiting a turn.
|
|
85
|
+
*/
|
|
86
|
+
awaitingDecisionTaskId?: string | undefined;
|
|
76
87
|
createdAt: Date;
|
|
77
88
|
updatedAt: Date;
|
|
78
89
|
}
|
|
@@ -298,6 +309,26 @@ export interface StateStore {
|
|
|
298
309
|
* outcome was still being computed from a now-stale run snapshot.
|
|
299
310
|
*/
|
|
300
311
|
updateRunIf(runId: string, expectedStatuses: RunStatus[], patch: Partial<WorkflowRun>): Promise<boolean>;
|
|
312
|
+
/**
|
|
313
|
+
* Atomically claim a singleton slot for `runId` — the store half of the `singleton` gate. Required
|
|
314
|
+
* for ATOMIC singleton admission; without it the engine falls back to a non-atomic scan and warns once.
|
|
315
|
+
*
|
|
316
|
+
* Inside ONE critical section that serializes competing claims BEFORE it reads (a transaction with
|
|
317
|
+
* `SELECT … FOR UPDATE`, or a write lock taken first; a plain list-then-update is unsafe across
|
|
318
|
+
* engine instances): read the active (`pending`/`running`/`suspended`/`blocked`) runs of `workflow`
|
|
319
|
+
* carrying `tag`, then decide with {@link singletonAdmissionTags} — runs already carrying the
|
|
320
|
+
* reserved `durable:singleton:admitted` tag keep their slots, and the free ones go to the oldest
|
|
321
|
+
* unadmitted waiters by `(createdAt, id)`. On admission persist the returned tags and return `true`
|
|
322
|
+
* (also `true`, without a write, when the run already holds a slot).
|
|
323
|
+
*
|
|
324
|
+
* On denial, when `retryWakeAt` is given, park the candidate `suspended` with that `wakeAt` under the
|
|
325
|
+
* same locks ({@link singletonAdmissionDenialPatch}), and never write a run that is no longer active
|
|
326
|
+
* (a concurrent cancel must not be resurrected). Return `false` for a missing or inactive run.
|
|
327
|
+
*
|
|
328
|
+
* The slot is released by the terminal settle: `updateRun`/`updateRunIf` writing a terminal status
|
|
329
|
+
* must drop the reserved tag. An expired execution lease never releases it.
|
|
330
|
+
*/
|
|
331
|
+
tryAdmitSingleton?(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
|
|
301
332
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
302
333
|
/**
|
|
303
334
|
* Hard-delete a run and everything tied to it (its checkpoints, signal waiters, and search-attribute
|
|
@@ -305,6 +336,15 @@ export interface StateStore {
|
|
|
305
336
|
* engine's {@link WorkflowEngine.deleteRun} handles the child-subtree cascade.
|
|
306
337
|
*/
|
|
307
338
|
deleteRun(runId: string): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* {@link deleteRun} for a batch of runs: every id's checkpoints, signal waiters, attribute rows and
|
|
341
|
+
* run row, as a few `IN (...)` statements in one transaction instead of four statements per run.
|
|
342
|
+
* Unknown ids are ignored. Like {@link deleteRun} it removes exactly the listed runs; the engine's
|
|
343
|
+
* `purgeRuns` and retention sweep walk the child edges first.
|
|
344
|
+
*
|
|
345
|
+
* Optional: a store that omits it gets one {@link deleteRun} per id.
|
|
346
|
+
*/
|
|
347
|
+
deleteRuns?(runIds: string[]): Promise<void>;
|
|
308
348
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
309
349
|
/**
|
|
310
350
|
* Persist a checkpoint and advance the run atomically. Durable semantics depend on this
|
|
@@ -321,6 +361,16 @@ export interface StateStore {
|
|
|
321
361
|
* Optional: a store that omits it falls back to {@link saveCheckpoint}, which keeps that race.
|
|
322
362
|
*/
|
|
323
363
|
saveCheckpointIfPending?(checkpoint: StepCheckpoint): Promise<boolean>;
|
|
364
|
+
/**
|
|
365
|
+
* {@link saveCheckpointIfPending} for many checkpoints in one call: resolves, per entry and in
|
|
366
|
+
* input order, whether it wrote. Same result as calling it on each entry in turn (a later entry for
|
|
367
|
+
* the same `(runId, seq)` is compared against the earlier one's write), with each row's
|
|
368
|
+
* compare-and-set still atomic. The call as a whole is atomic too: if it rejects, nothing was
|
|
369
|
+
* written. The engine settles a batch of one run's step results through it, one call per batch.
|
|
370
|
+
*
|
|
371
|
+
* Optional: a store that omits it gets one {@link saveCheckpointIfPending} per entry.
|
|
372
|
+
*/
|
|
373
|
+
saveCheckpointsIfPending?(checkpoints: StepCheckpoint[]): Promise<boolean[]>;
|
|
324
374
|
/**
|
|
325
375
|
* Used by recovery on boot to find runs to resume (crashed, left `running`). When `namespace` is
|
|
326
376
|
* given, restrict to runs in that worker-pool partition (ANDed); omit it to return all (back-compat).
|
|
@@ -332,8 +382,15 @@ export interface StateStore {
|
|
|
332
382
|
* without it the engine falls back to {@link listIncompleteRuns} and filters in process, which on
|
|
333
383
|
* a busy fleet fetches (and lock-probes) every healthy running run once per tick per worker. When
|
|
334
384
|
* `namespace` is given, restrict to that worker-pool partition (ANDed).
|
|
385
|
+
*
|
|
386
|
+
* When `owner` is given, ALSO return `running` runs whose lease is still live but held by `owner`
|
|
387
|
+
* (`locked_by = owner`, ORed with the free/expired predicate). The engine passes its own
|
|
388
|
+
* `instanceId` for one lease window after boot, so an instance that restarts under a stable id
|
|
389
|
+
* (a pod name) after a crash reclaims the leases its previous incarnation left behind at once,
|
|
390
|
+
* instead of waiting up to `leaseMs` for them to expire; the engine itself filters out the runs
|
|
391
|
+
* the live process is executing. A store that ignores `owner` keeps the expiry-only behaviour.
|
|
335
392
|
*/
|
|
336
|
-
listOrphanedRuns?(nowMs: number, limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
393
|
+
listOrphanedRuns?(nowMs: number, limit: number, namespace?: string, owner?: string): Promise<WorkflowRun[]>;
|
|
337
394
|
/**
|
|
338
395
|
* The oldest `pending` runs awaiting dispatch (FIFO, by `createdAt`), capped at `limit`. When
|
|
339
396
|
* `namespace` is given, restrict to runs in that worker-pool partition (ANDed); omit it for all.
|
|
@@ -435,6 +492,13 @@ export interface StateStore {
|
|
|
435
492
|
takeBufferedSignal(token: string): Promise<{
|
|
436
493
|
payload: unknown;
|
|
437
494
|
} | null>;
|
|
495
|
+
/**
|
|
496
|
+
* Up to `limit` distinct tokens starting with `prefix` that have at least one buffered signal.
|
|
497
|
+
* Reads no payload and consumes nothing. Optional: the entity lost-wake reconcile
|
|
498
|
+
* (`engine.reconcileEntityWakes`) uses it to find entity ops buffered while no wake reached their
|
|
499
|
+
* entity; without it that reconcile is a no-op.
|
|
500
|
+
*/
|
|
501
|
+
listBufferedSignalTokens?(prefix: string, limit: number): Promise<string[]>;
|
|
438
502
|
/**
|
|
439
503
|
* Buffer a published event that matched NO live waiter, so a LATER `ctx.waitForEvent(name, { match })`
|
|
440
504
|
* still consumes it instead of it being silently dropped — the events analog of {@link bufferSignal}'s
|
|
@@ -468,6 +532,15 @@ export interface StateStore {
|
|
|
468
532
|
* returns `true` is the one that gets to deliver the payload; every other caller backs off.
|
|
469
533
|
*/
|
|
470
534
|
removeBufferedEvent(id: string): Promise<boolean>;
|
|
535
|
+
/**
|
|
536
|
+
* Delete up to `limit` buffered events published before `publishedBefore` (epoch ms), oldest
|
|
537
|
+
* first, across every name; resolves how many it deleted. What the engine's `eventBufferTtlMs`
|
|
538
|
+
* prune calls, so an event nobody ever waits for does not stay in the table forever.
|
|
539
|
+
*
|
|
540
|
+
* Optional: without it the prune has no way to enumerate names, and expired events are only skipped
|
|
541
|
+
* (and removed) when a `waitForEvent` for their name scans them.
|
|
542
|
+
*/
|
|
543
|
+
pruneBufferedEvents?(publishedBefore: number, limit: number): Promise<number>;
|
|
471
544
|
/**
|
|
472
545
|
* Run `work` in a SINGLE store transaction — giving it the store-native transaction handle (`raw`)
|
|
473
546
|
* for the caller's own DB writes plus a `saveCheckpoint` that commits IN THE SAME transaction, so a
|
|
@@ -483,6 +556,15 @@ export interface StateStore {
|
|
|
483
556
|
* Optional: without it the engine counts a {@link listRuns} result.
|
|
484
557
|
*/
|
|
485
558
|
countRuns?(query: Omit<RunQuery, 'page' | 'size'>): Promise<number>;
|
|
559
|
+
/**
|
|
560
|
+
* Count the runs matching `query`, grouped by `(status, origin)`: the totals behind a console's
|
|
561
|
+
* status and origin chips in ONE aggregate, instead of a listing counted in memory. Cells with a
|
|
562
|
+
* zero count are absent; a run with no (or a blank) origin counts under `origin: null`.
|
|
563
|
+
*
|
|
564
|
+
* Optional: without it `runFacetsOf` counts a {@link listRuns} result, which is correct but
|
|
565
|
+
* unbounded.
|
|
566
|
+
*/
|
|
567
|
+
runFacets?(query: RunFacetQuery): Promise<RunFacetRow[]>;
|
|
486
568
|
/** Insert or fully replace the schedule `record.id`. */
|
|
487
569
|
saveSchedule?(record: ScheduleRecord): Promise<void>;
|
|
488
570
|
/** The schedule `id`, or null. */
|
|
@@ -554,9 +636,115 @@ export interface StateStore {
|
|
|
554
636
|
* and counts in JS, which loads the whole run on every result of a fan.
|
|
555
637
|
*/
|
|
556
638
|
countCheckpoints?(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
|
|
639
|
+
/**
|
|
640
|
+
* The run's checkpoints aggregated into {@link CheckpointStat} buckets — one per
|
|
641
|
+
* `(parallelGroup, status, nameKind)` present — with `opts.group` narrowing it to one group. A
|
|
642
|
+
* `GROUP BY`, not a load: it is what lets a run detail draw a 40,000-member fan from a few rows.
|
|
643
|
+
* Ungrouped checkpoints come back under `group: null`. Bucket order is unspecified.
|
|
644
|
+
*
|
|
645
|
+
* Optional: a store that omits it still works — the run detail then loads every checkpoint and
|
|
646
|
+
* summarizes it in JS (`summarizeTimeline`), which is the same answer read the expensive way. A
|
|
647
|
+
* store that implements it must implement {@link queryCheckpoints} too.
|
|
648
|
+
*/
|
|
649
|
+
checkpointStats?(runId: string, opts?: {
|
|
650
|
+
group?: string | undefined;
|
|
651
|
+
}): Promise<CheckpointStat[]>;
|
|
652
|
+
/**
|
|
653
|
+
* The run's checkpoints that match `query`, in `seq` order (the order of {@link listCheckpoints}),
|
|
654
|
+
* paged by `offset`/`limit`. Every filter is optional; an absent one does not narrow. An EMPTY
|
|
655
|
+
* `statuses` or `namePrefixes` matches nothing; an empty `excludeGroups` excludes nothing.
|
|
656
|
+
*
|
|
657
|
+
* Optional, paired with {@link checkpointStats}: the run detail reads a fan's failures, its folded
|
|
658
|
+
* checkpoints and one page of its members through it, instead of the run's whole history.
|
|
659
|
+
*/
|
|
660
|
+
queryCheckpoints?(runId: string, query: CheckpointQuery): Promise<StepCheckpoint[]>;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* How a checkpoint's name classifies it, for {@link CheckpointStat}: an awaited child's
|
|
664
|
+
* `signal:child:` checkpoint, a folded `fan:` checkpoint standing for many children, a `spawn:`
|
|
665
|
+
* edge to a fire-and-forget child, or any other step.
|
|
666
|
+
*/
|
|
667
|
+
export type CheckpointNameKind = 'child' | 'folded' | 'spawn' | 'step';
|
|
668
|
+
/** The {@link CheckpointNameKind} of a checkpoint name — what a store's SQL `CASE` must agree with. */
|
|
669
|
+
export declare function checkpointNameKind(name: string): CheckpointNameKind;
|
|
670
|
+
/**
|
|
671
|
+
* One bucket of {@link StateStore.checkpointStats}: the checkpoints of one run sharing a
|
|
672
|
+
* `parallelGroup`, a `status` and a {@link CheckpointNameKind}, reduced to aggregates.
|
|
673
|
+
*/
|
|
674
|
+
export interface CheckpointStat {
|
|
675
|
+
/** The bucket's `parallelGroup`, or `null` for ungrouped checkpoints. */
|
|
676
|
+
group: string | null;
|
|
677
|
+
status: StepCheckpoint['status'];
|
|
678
|
+
nameKind: CheckpointNameKind;
|
|
679
|
+
/** Rows in the bucket (at least 1). */
|
|
680
|
+
count: number;
|
|
681
|
+
minSeq: number;
|
|
682
|
+
maxSeq: number;
|
|
683
|
+
/** Smallest and largest `name`, by the database's string order. Equal when every row shares one. */
|
|
684
|
+
minName: string;
|
|
685
|
+
maxName: string;
|
|
686
|
+
/** Earliest `enqueuedAt`, read as {@link StateStore.listCheckpoints} reads it (falling back to `startedAt`). */
|
|
687
|
+
minEnqueuedAt: Date;
|
|
688
|
+
minStartedAt: Date;
|
|
689
|
+
maxStartedAt: Date;
|
|
690
|
+
maxFinishedAt: Date;
|
|
691
|
+
/** Sum of `attempts` — moves when a step is retried in place, so a change marker sees it. */
|
|
692
|
+
sumAttempts: number;
|
|
693
|
+
}
|
|
694
|
+
/** What {@link StateStore.queryCheckpoints} selects. */
|
|
695
|
+
export interface CheckpointQuery {
|
|
696
|
+
/** Only this `parallelGroup`'s checkpoints. */
|
|
697
|
+
group?: string | undefined;
|
|
698
|
+
/** Leave out these groups' checkpoints (ungrouped checkpoints are kept). */
|
|
699
|
+
excludeGroups?: string[] | undefined;
|
|
700
|
+
statuses?: StepCheckpoint['status'][] | undefined;
|
|
701
|
+
/** Only names starting with one of these. */
|
|
702
|
+
namePrefixes?: string[] | undefined;
|
|
703
|
+
offset?: number | undefined;
|
|
704
|
+
limit?: number | undefined;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* One `(status, origin)` cell of {@link StateStore.runFacets} — a `GROUP BY` row, not a page of runs.
|
|
708
|
+
* `origin` is `null` for runs carrying none (absent or blank).
|
|
709
|
+
*/
|
|
710
|
+
export interface RunFacetRow {
|
|
711
|
+
status: RunStatus;
|
|
712
|
+
origin: string | null;
|
|
713
|
+
count: number;
|
|
557
714
|
}
|
|
558
715
|
/** Typed, queryable per-run data — exact values for `eq`/`ne`, numbers/strings for range ops. */
|
|
559
716
|
export type SearchAttributes = Record<string, string | number | boolean>;
|
|
717
|
+
/**
|
|
718
|
+
* A Standard Schema (https://standardschema.dev — zod, valibot, arktype, …) whose validated OUTPUT is
|
|
719
|
+
* search-attribute-shaped: flat `string`/`number`/`boolean` values only. Declared via
|
|
720
|
+
* `static workflow = { searchAttributes }` (or `register(..., { searchAttributesSchema })`), it makes
|
|
721
|
+
* `ctx.upsertSearchAttributes` validate the MERGED attributes and reject a non-conforming write with a
|
|
722
|
+
* `SchemaValidationError`. The `Output extends SearchAttributes` bound is enforced at the declaration
|
|
723
|
+
* site — a schema whose output has a nested object/array value is a compile-time error. Its
|
|
724
|
+
* `validate` must be synchronous (an async refinement could make replay nondeterministic).
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* ```ts
|
|
728
|
+
* const orderAttrs = z.object({ tier: z.enum(['free', 'pro']), amount: z.number() })
|
|
729
|
+
*
|
|
730
|
+
* export default class CheckoutWorkflow extends BaseWorkflow {
|
|
731
|
+
* static workflow = { name: 'checkout', searchAttributes: orderAttrs }
|
|
732
|
+
* async run(ctx: WorkflowCtx<InferSearchAttributes<typeof orderAttrs>>, input: Order) {
|
|
733
|
+
* await ctx.upsertSearchAttributes({ tier: input.tier, amount: input.total })
|
|
734
|
+
* }
|
|
735
|
+
* }
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
export type SearchAttributesSchema<A extends SearchAttributesShape = SearchAttributesShape> = StandardSchemaV1<unknown, A>;
|
|
739
|
+
/**
|
|
740
|
+
* The bound a TYPED search-attributes shape must satisfy: {@link SearchAttributes} whose values may
|
|
741
|
+
* also be `undefined` — so an optional key (`v.optional(v.number())`, `z.number().optional()`), which
|
|
742
|
+
* infers as `key?: number | undefined`, still type-checks under `exactOptionalPropertyTypes`.
|
|
743
|
+
*/
|
|
744
|
+
export type SearchAttributesShape = Record<string, string | number | boolean | undefined>;
|
|
745
|
+
/** Infer the validated OUTPUT shape of a {@link SearchAttributesSchema} — feed it to
|
|
746
|
+
* `WorkflowCtx<A>`: `WorkflowCtx<InferSearchAttributes<typeof mySchema>>`. */
|
|
747
|
+
export type InferSearchAttributes<S extends StandardSchemaV1<unknown, SearchAttributesShape>> = StandardSchemaV1.InferOutput<S>;
|
|
560
748
|
export type AttributeOp = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in';
|
|
561
749
|
/** One value a search attribute can hold, and so one operand a predicate compares against. */
|
|
562
750
|
export type AttributeValue = string | number | boolean;
|
|
@@ -684,17 +872,36 @@ export type RunFacetQuery = Omit<RunQuery, 'status' | 'statuses' | 'page' | 'siz
|
|
|
684
872
|
export type RunScope = Pick<RunQuery, 'workflow' | 'workflows' | 'tag' | 'tags' | 'namespace' | 'namespaces' | 'attributes'>;
|
|
685
873
|
/** True when `scope` sets at least one predicate — a bulk delete refuses an empty (match-all) scope. */
|
|
686
874
|
export declare function isNonEmptyRunScope(scope: RunScope | undefined): boolean;
|
|
875
|
+
/**
|
|
876
|
+
* The input a dead-letter workflow is started with when a run goes `dead` (see the engine's
|
|
877
|
+
* `deadLetterWorkflow` and a workflow's own `deadLetterWorkflow` / `deadLetter()` method): which run
|
|
878
|
+
* died, of which workflow, with what input, and why (`max_recovery_attempts`). The handler run's id is
|
|
879
|
+
* `dlq:<deadRunId>`.
|
|
880
|
+
*/
|
|
881
|
+
export interface DeadLetter<TInput = unknown> {
|
|
882
|
+
deadRunId: string;
|
|
883
|
+
workflow: string;
|
|
884
|
+
input: TInput;
|
|
885
|
+
error?: StepError | undefined;
|
|
886
|
+
}
|
|
687
887
|
/** The terminal run statuses — the only ones retention may delete. */
|
|
688
888
|
export type TerminalRunStatus = 'completed' | 'failed' | 'cancelled' | 'dead';
|
|
689
889
|
export declare const TERMINAL_RUN_STATUSES: readonly TerminalRunStatus[];
|
|
690
890
|
/**
|
|
691
891
|
* A retention rule confined to a {@link RunScope}: terminal runs in `statuses` matching `scope` are
|
|
692
|
-
* hard-deleted once their last activity is older than `maxAgeMs
|
|
693
|
-
* `retention` ages, so e.g. chat turns can age out
|
|
892
|
+
* hard-deleted once their last activity is older than `maxAgeMs`, and/or once more than `maxCount`
|
|
893
|
+
* newer ones exist. Sits next to the per-status `retention` ages, so e.g. chat turns can age out
|
|
894
|
+
* after a day while everything else keeps 30.
|
|
895
|
+
*
|
|
896
|
+
* `maxCount` keeps the `maxCount` newest runs (by start time, `createdAt`) of the whole status set
|
|
897
|
+
* WITHIN the scope — "keep acme's newest 100" counts acme's runs only — and deletes the older ones.
|
|
898
|
+
* With both bounds the most restrictive wins: a run goes once it is past either. At least one of the
|
|
899
|
+
* two must be set.
|
|
694
900
|
*/
|
|
695
901
|
export interface ScopedRetentionPolicy {
|
|
696
902
|
statuses: TerminalRunStatus[];
|
|
697
|
-
maxAgeMs
|
|
903
|
+
maxAgeMs?: number | undefined;
|
|
904
|
+
maxCount?: number | undefined;
|
|
698
905
|
scope: RunScope;
|
|
699
906
|
}
|
|
700
907
|
/**
|
|
@@ -875,7 +1082,13 @@ export interface StepResult {
|
|
|
875
1082
|
export interface Heartbeat {
|
|
876
1083
|
runId: string;
|
|
877
1084
|
seq: number;
|
|
878
|
-
|
|
1085
|
+
/**
|
|
1086
|
+
* The in-flight step this beat keeps alive. ABSENT (or `''`) for a RUN-scoped (workflow-turn)
|
|
1087
|
+
* heartbeat: a worker replaying a long workflow turn beats for its `runId` so the engine pushes the
|
|
1088
|
+
* awaited turn's re-drive deadline forward (see `WorkflowEngineDeps.remoteAdvanceSilenceMs`). The
|
|
1089
|
+
* Python `durable-worker` sends `{ runId, seq: 0, group }` with no `stepId` for exactly this.
|
|
1090
|
+
*/
|
|
1091
|
+
stepId?: string | undefined;
|
|
879
1092
|
group: string;
|
|
880
1093
|
/** Worker-side emission time (epoch ms). Optional on the wire for back-compat with 0.17-era workers. */
|
|
881
1094
|
at?: number | undefined;
|
|
@@ -1023,7 +1236,34 @@ export interface WorkflowStepEvent {
|
|
|
1023
1236
|
* concerns, identical for in-process and remote workflows.
|
|
1024
1237
|
*/
|
|
1025
1238
|
export interface WorkflowExecutor {
|
|
1026
|
-
|
|
1239
|
+
/**
|
|
1240
|
+
* INLINE replay: advance the turn and RETURN its decision (e.g. `LocalWorkflowTurnExecutor`
|
|
1241
|
+
* runs the turn body in-process). The engine awaits this under the run's lease, so it is
|
|
1242
|
+
* single-instance by nature. Provide this OR {@link dispatch}; when both exist the engine uses
|
|
1243
|
+
* `dispatch`.
|
|
1244
|
+
*/
|
|
1245
|
+
advance?(run: WorkflowRun, history: HistoryEvent[], pendingSignals?: WorkflowTask['pendingSignals']): Promise<WorkflowDecision>;
|
|
1246
|
+
/**
|
|
1247
|
+
* DISPATCH-AND-SUSPEND (broker-backed, multi-instance safe): enqueue the turn to a worker under the
|
|
1248
|
+
* ENGINE-SUPPLIED, globally unique `taskId`, WITHOUT awaiting the decision. Before calling this the
|
|
1249
|
+
* engine has already recorded `taskId` on the run ({@link WorkflowRun.awaitingDecisionTaskId}),
|
|
1250
|
+
* suspended it and released its lease, so the worker's {@link WorkflowDecision} — delivered over
|
|
1251
|
+
* {@link Transport.onDecision} to WHICHEVER engine replica consumes it — always finds its marker and
|
|
1252
|
+
* a free lease. This method only enqueues; a throw fails the run.
|
|
1253
|
+
*/
|
|
1254
|
+
dispatch?(run: WorkflowRun, history: HistoryEvent[], taskId: string, pendingSignals?: WorkflowTask['pendingSignals']): Promise<void>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Subscribe the engine's decision handler to the transport this executor dispatches over. Called
|
|
1257
|
+
* once per registration with the SAME handler function, so a transport that keeps a handler set
|
|
1258
|
+
* (bullmq, queue, db) dedupes it across executors. Required for {@link dispatch} to make progress.
|
|
1259
|
+
*/
|
|
1260
|
+
subscribeDecisions?(handler: (decision: WorkflowDecision) => Promise<void>): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Optional per-workflow liveness window (ms) for a dispatched turn: with no decision and no
|
|
1263
|
+
* run-scoped heartbeat for this long, the turn is re-driven (re-dispatched under a fresh `taskId`).
|
|
1264
|
+
* Combined with the engine's `remoteAdvanceSilenceMs` (the shorter wins). Heartbeats rearm it.
|
|
1265
|
+
*/
|
|
1266
|
+
readonly decisionTimeoutMs?: number | undefined;
|
|
1027
1267
|
}
|
|
1028
1268
|
/**
|
|
1029
1269
|
* A transport in an ordered pool, identified by `id`. The engine dispatches on the first by default
|
|
@@ -1080,10 +1320,11 @@ export interface RunRequest {
|
|
|
1080
1320
|
}
|
|
1081
1321
|
/**
|
|
1082
1322
|
* The discriminated verb + args of a {@link RunRequest}. Mirrors THIS package's tenant-facing
|
|
1083
|
-
* {@link RunGateway}
|
|
1084
|
-
* `
|
|
1085
|
-
* `
|
|
1086
|
-
* `
|
|
1323
|
+
* {@link RunGateway}: aviary's whole verb set in aviary's EXACT shapes (`getRunDetail`,
|
|
1324
|
+
* `getFanMembers`, `listRuns`, `runFacets`, `runValueFacets`, `workerHealth`, `cancel`, `retry`,
|
|
1325
|
+
* `continue`, `retryWithInput`, `redispatch`, `waitingFor`), plus this package's own
|
|
1326
|
+
* `getRun`/`getCheckpoints`/`getRunChildren`/`getSearchAttributes`/`signal`. The request/reply
|
|
1327
|
+
* ENVELOPE stays byte-compatible.
|
|
1087
1328
|
* `start` and `subscribe` are NOT here — they ride `${P}-start-run` and `${P}-tenant-events-<tenant>`
|
|
1088
1329
|
* respectively.
|
|
1089
1330
|
*/
|
|
@@ -1127,6 +1368,27 @@ export type RunRequestKind = {
|
|
|
1127
1368
|
} | {
|
|
1128
1369
|
kind: 'redispatch';
|
|
1129
1370
|
runId: string;
|
|
1371
|
+
} | {
|
|
1372
|
+
kind: 'runFacets';
|
|
1373
|
+
query: RunFacetQuery;
|
|
1374
|
+
} | {
|
|
1375
|
+
kind: 'runValueFacets';
|
|
1376
|
+
axis: RunValueAxis;
|
|
1377
|
+
query: RunFacetQuery;
|
|
1378
|
+
opts?: RunValueFacetOptions | undefined;
|
|
1379
|
+
} | {
|
|
1380
|
+
kind: 'retry';
|
|
1381
|
+
runId: string;
|
|
1382
|
+
} | {
|
|
1383
|
+
kind: 'continue';
|
|
1384
|
+
runId: string;
|
|
1385
|
+
} | {
|
|
1386
|
+
kind: 'retryWithInput';
|
|
1387
|
+
runId: string;
|
|
1388
|
+
input: unknown;
|
|
1389
|
+
} | {
|
|
1390
|
+
kind: 'waitingFor';
|
|
1391
|
+
runIds: string[];
|
|
1130
1392
|
};
|
|
1131
1393
|
/** The control plane's answer to a {@link RunRequest} (or to a start-run, correlated by the minted
|
|
1132
1394
|
* runId), keyed by `requestId`. Byte-compatible with aviary's `RunReply`. */
|
|
@@ -1183,12 +1445,17 @@ export interface Transport {
|
|
|
1183
1445
|
/** Start every consumer subscription parked by {@link Transport.deferConsumers} — the explicit
|
|
1184
1446
|
* "this process IS a worker" declaration. Idempotent; a no-op when nothing was deferred. */
|
|
1185
1447
|
startConsumers?(): void;
|
|
1448
|
+
/** Called by the provider when this transport backs a store-less `tenant` pod, before anything is
|
|
1449
|
+
* registered on it. Optional — a transport whose behaviour does not depend on the role omits it (the
|
|
1450
|
+
* queue transport uses it to forward worker advertisement to the control plane when it has no key
|
|
1451
|
+
* store of its own). */
|
|
1452
|
+
useTenantRole?(): void;
|
|
1186
1453
|
/** Release the transport's resources (broker workers, queues, connections) for a clean shutdown.
|
|
1187
1454
|
* Optional — an in-process transport has nothing to close. Called on `onApplicationShutdown`
|
|
1188
1455
|
* after the engine drains, so a deploy hands off instead of leaving the broker to time out. */
|
|
1189
1456
|
close?(): Promise<void>;
|
|
1190
1457
|
/** engine → workflow worker: dispatch a {@link WorkflowTask} (the polyglot-workflow path). Optional
|
|
1191
|
-
* — only transports that carry workflow tasks (BullMQ) implement it; the {@link RemoteWorkflowExecutor}
|
|
1458
|
+
* — only transports that carry workflow tasks (BullMQ, queue, db) implement it; the {@link RemoteWorkflowExecutor}
|
|
1192
1459
|
* uses it + {@link onDecision} to advance a remote workflow over the broker. */
|
|
1193
1460
|
dispatchWorkflowTask?(task: WorkflowTask): Promise<void>;
|
|
1194
1461
|
/** workflow worker → engine: a replayed turn's {@link WorkflowDecision}. Pair with dispatchWorkflowTask. */
|
|
@@ -1200,8 +1467,8 @@ export interface Transport {
|
|
|
1200
1467
|
/** engine ← workflow worker: consume streamed {@link WorkflowStepEvent}s. Pair with dispatchStepEvent. */
|
|
1201
1468
|
onStepEvent?(handler: (event: WorkflowStepEvent) => Promise<void>): void;
|
|
1202
1469
|
/** Worker-health for a group: queue backlog + live worker heartbeats. Optional — only broker
|
|
1203
|
-
* transports (BullMQ) that can introspect the task queue and the worker-heartbeat keys
|
|
1204
|
-
* it. The engine aggregates this across its groups in {@link WorkflowEngine.workerHealth}. */
|
|
1470
|
+
* transports (BullMQ, queue, db) that can introspect the task queue and the worker-heartbeat keys
|
|
1471
|
+
* implement it. The engine aggregates this across its groups in {@link WorkflowEngine.workerHealth}. */
|
|
1205
1472
|
groupHealth?(group: string): Promise<GroupHealth>;
|
|
1206
1473
|
/** Distinct groups that currently have a live worker heartbeat — discovered from the heartbeat
|
|
1207
1474
|
* keyspace, so a group with workers but no engine-side registration (e.g. a local-step group)
|
|
@@ -1218,6 +1485,17 @@ export interface Transport {
|
|
|
1218
1485
|
* `[]` (never throw) when the keyspace is empty or unreadable. Pairs with {@link listWorkerGroups}.
|
|
1219
1486
|
*/
|
|
1220
1487
|
listWorkerDescriptors?(token: string): Promise<WorkerDescriptor[]>;
|
|
1488
|
+
/**
|
|
1489
|
+
* EVERY live worker descriptor, across all routing tokens — the fleet-wide read behind
|
|
1490
|
+
* {@link WorkflowEngine.workflowDirectory}. Optional, and MUST degrade to `[]` when unreadable.
|
|
1491
|
+
*/
|
|
1492
|
+
readAllWorkerDescriptors?(): Promise<WorkerDescriptor[]>;
|
|
1493
|
+
/**
|
|
1494
|
+
* EVERY live worker heartbeat, across all routing tokens — the liveness floor of
|
|
1495
|
+
* {@link WorkflowEngine.workflowDirectory}, which is how a worker too old to publish a descriptor
|
|
1496
|
+
* still shows up. Optional, same as {@link readAllWorkerDescriptors}.
|
|
1497
|
+
*/
|
|
1498
|
+
readAllWorkerHeartbeats?(): Promise<WorkerHeartbeat[]>;
|
|
1221
1499
|
/** tenant → control plane: publish a {@link StartRunMessage} on `${P}-start-run` (queue, job
|
|
1222
1500
|
* `startRun`) requesting a new run. Pair with {@link onStartRun}. */
|
|
1223
1501
|
dispatchStartRun?(msg: StartRunMessage): Promise<void>;
|
|
@@ -1291,7 +1569,9 @@ export interface WorkerHeartbeat {
|
|
|
1291
1569
|
* consumer (exactly the failure where a worker is "alive but not consuming"). */
|
|
1292
1570
|
export interface GroupHealth {
|
|
1293
1571
|
group: string;
|
|
1294
|
-
/** Outstanding jobs in the group's task queue (waiting + active + delayed + prioritized
|
|
1572
|
+
/** Outstanding jobs in the group's task queue (waiting + active + delayed + prioritized on BullMQ;
|
|
1573
|
+
* pending only on the queue transport, whose adapter contract counts nothing else; pending +
|
|
1574
|
+
* claimed task rows on the db transport). */
|
|
1295
1575
|
depth: number;
|
|
1296
1576
|
/** Workers with a non-expired heartbeat for this group. */
|
|
1297
1577
|
liveWorkers: WorkerHeartbeat[];
|
|
@@ -1396,7 +1676,8 @@ export interface StepOptions {
|
|
|
1396
1676
|
* name (a worker subscribes per registered handler name, not a hand-declared group). There is no
|
|
1397
1677
|
* public factory for this anymore — `ctx.step(ref, input)` builds one internally from the
|
|
1398
1678
|
* `@Step`-stamped name (see {@link StepRef}/`stepNameOf`) and a `ctx.step(name, input)` from the
|
|
1399
|
-
* literal string. `input`/`output` are OPTIONAL runtime
|
|
1679
|
+
* literal string. `input`/`output` are OPTIONAL runtime Standard Schemas (zod, valibot, arktype, …)
|
|
1680
|
+
* an authoring layer MAY attach
|
|
1400
1681
|
* (e.g. `@Step({ input, output })`) for validation at the dispatch boundary — a bare `@Step()`
|
|
1401
1682
|
* carries neither, and the engine skips validation when they're absent. The `StepOptions` fields
|
|
1402
1683
|
* (retries/backoff/timeoutMs …) carry the merged per-call/def dispatch policy.
|
|
@@ -1406,8 +1687,8 @@ export interface StepDef<TInput = unknown, TOutput = unknown> extends StepOption
|
|
|
1406
1687
|
/** Optional isolation partition; routing is by `name`. Suffixes the routing token as
|
|
1407
1688
|
* `<name>@<partition>` (via `tenantGroup`) — omit to route by the bare (sanitized) `name`. */
|
|
1408
1689
|
partition?: string | undefined;
|
|
1409
|
-
input?:
|
|
1410
|
-
output?:
|
|
1690
|
+
input?: StandardSchemaV1<unknown, TInput> | undefined;
|
|
1691
|
+
output?: StandardSchemaV1<unknown, TOutput> | undefined;
|
|
1411
1692
|
}
|
|
1412
1693
|
/**
|
|
1413
1694
|
* Options for a dispatched {@link WorkflowCtx.step} call. `retries`/`backoff`/`backoffMs`/
|
|
@@ -1494,8 +1775,13 @@ export interface DurableWebhook<TPayload = unknown> {
|
|
|
1494
1775
|
/**
|
|
1495
1776
|
* The context handed to a workflow function. Every interaction with the outside world goes
|
|
1496
1777
|
* through it so the engine can checkpoint — the workflow body itself stays deterministic.
|
|
1778
|
+
*
|
|
1779
|
+
* Generic over `A`, the run's {@link SearchAttributes} shape — narrows {@link upsertSearchAttributes}
|
|
1780
|
+
* to a `Partial<A>` (pair it with a {@link SearchAttributesSchema}: annotate `run`'s ctx as
|
|
1781
|
+
* `WorkflowCtx<InferSearchAttributes<typeof mySchema>>`). Defaults to the untyped bag, so a bare
|
|
1782
|
+
* `WorkflowCtx` behaves exactly as before.
|
|
1497
1783
|
*/
|
|
1498
|
-
export interface WorkflowCtx {
|
|
1784
|
+
export interface WorkflowCtx<A extends SearchAttributesShape = SearchAttributes> {
|
|
1499
1785
|
readonly runId: string;
|
|
1500
1786
|
/**
|
|
1501
1787
|
* Run a durable step — always dispatched, always engine-scheduled: the ONE step primitive (no
|
|
@@ -1718,8 +2004,10 @@ export interface WorkflowCtx {
|
|
|
1718
2004
|
* exactly-once — recorded at this position on the first run and SKIPPED on replay, so it does one
|
|
1719
2005
|
* write, not one per turn. Use this instead of injecting the {@link StateStore} to mutate the run
|
|
1720
2006
|
* you're executing (`store.updateRun(ctx.runId, …)` becomes `ctx.upsertSearchAttributes(…)`).
|
|
2007
|
+
* With a declared {@link SearchAttributesSchema}, the merged result is validated first and a
|
|
2008
|
+
* non-conforming write throws a `SchemaValidationError` (nothing is written or recorded).
|
|
1721
2009
|
*/
|
|
1722
|
-
upsertSearchAttributes(attrs:
|
|
2010
|
+
upsertSearchAttributes(attrs: Partial<A>): Promise<void>;
|
|
1723
2011
|
}
|
|
1724
2012
|
/**
|
|
1725
2013
|
* {@link WorkflowCtx} with ONE signature per method: the string-addressed forms of the five overloaded
|
|
@@ -1737,7 +2025,7 @@ export interface WorkflowCtx {
|
|
|
1737
2025
|
*
|
|
1738
2026
|
* Every `WorkflowCtx` is assignable to it (guarded by `test/types/dynamic-workflow-ctx.ts`).
|
|
1739
2027
|
*/
|
|
1740
|
-
export interface DynamicWorkflowCtx extends Omit<WorkflowCtx
|
|
2028
|
+
export interface DynamicWorkflowCtx<A extends SearchAttributesShape = SearchAttributes> extends Omit<WorkflowCtx<A>, 'step' | 'child' | 'startChild' | 'all' | 'allSettled'> {
|
|
1741
2029
|
/** {@link WorkflowCtx.step} by step name. */
|
|
1742
2030
|
step<TOutput = unknown>(name: string, input: unknown, opts?: StepDispatchOpts & {
|
|
1743
2031
|
compensate?: string;
|