@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BarrelTree, type RootedBarrel } from './discovery-roots.js';
|
|
1
2
|
import type { WorkflowEngine } from './engine.js';
|
|
2
3
|
import { type WorkflowMeta } from './workflow-ref.js';
|
|
3
4
|
/**
|
|
@@ -16,6 +17,8 @@ export type DiscoveredWorkflowClass = new () => {
|
|
|
16
17
|
export interface DiscoveredWorkflow {
|
|
17
18
|
meta: WorkflowMeta;
|
|
18
19
|
cls: DiscoveredWorkflowClass;
|
|
20
|
+
/** The module it was found in: an absolute path for a directory scan, the key for a barrel. */
|
|
21
|
+
file: string;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* A factory that instantiates a workflow class. When provided, it replaces the default `new Ctor()` —
|
|
@@ -37,57 +40,45 @@ export type WorkflowClassFactory = (ctor: DiscoveredWorkflowClass) => Discovered
|
|
|
37
40
|
* (the Adonis container's `make` resolves async), so this function is async.
|
|
38
41
|
*/
|
|
39
42
|
export declare function registerWorkflowClass(engine: WorkflowEngine, cls: unknown, factory?: WorkflowClassFactory): Promise<boolean>;
|
|
43
|
+
/** Re-exported from its shared home so existing `pickModuleExt` imports keep working. */
|
|
44
|
+
export { pickModuleExt } from './discovery-roots.js';
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
+
* Scan one directory — or several — RECURSIVELY for modules and collect every exported workflow
|
|
47
|
+
* class — a `BaseWorkflow` subclass (the default export and any named export are considered) — so
|
|
48
|
+
* nested conventions like `app/workflows/billing/charge_workflow.ts` are found, matching
|
|
49
|
+
* `make:workflow`'s nested-path scaffolding. Only the extension present in each directory is
|
|
50
|
+
* imported (see {@link pickModuleExt}), and each module path is visited once, so a built `.js` and a
|
|
51
|
+
* dev `.ts` of the same module never both register. Missing directory → nothing from it (the
|
|
52
|
+
* convention is opt-in: no `app/workflows`, nothing to register).
|
|
46
53
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* 3. Otherwise, if any entry ends in `.js`, the scan imports `.js` files.
|
|
51
|
-
* 4. If neither is present, returns `null` (the scan registers nothing).
|
|
52
|
-
*
|
|
53
|
-
* This preserves the original de-duplication intent: a directory containing both a built `foo.js`
|
|
54
|
-
* and its source `foo.ts` resolves to `.ts` only, so the same module is never registered twice.
|
|
55
|
-
* Shared with {@link import('./step-discovery.js').registerStepsFromDir} so the two scanners can't
|
|
56
|
-
* drift apart again.
|
|
57
|
-
*/
|
|
58
|
-
export declare function pickModuleExt(entries: readonly string[]): '.ts' | '.js' | null;
|
|
59
|
-
/**
|
|
60
|
-
* Scan a directory RECURSIVELY for modules and collect every exported workflow class — a
|
|
61
|
-
* `BaseWorkflow` subclass (the default export and any named export are considered) — so nested
|
|
62
|
-
* conventions like
|
|
63
|
-
* `app/workflows/billing/charge_workflow.ts` are found, matching `make:workflow`'s nested-path
|
|
64
|
-
* scaffolding. Only the extension present in `dir` is imported (see {@link pickModuleExt}), and
|
|
65
|
-
* each module path is visited once, so a built `.js` and a dev `.ts` of the same module never both
|
|
66
|
-
* register. Missing directory → empty list (the convention is opt-in: no `app/workflows`, nothing to
|
|
67
|
-
* register).
|
|
54
|
+
* With several directories (a modular app: `['app/orders/flows', 'app/billing/flows']`) every root
|
|
55
|
+
* is walked in order, and the same workflow name + version defined by different classes in two
|
|
56
|
+
* roots throws a {@link DuplicateDiscoveryError} naming both files.
|
|
68
57
|
*/
|
|
69
|
-
export declare function discoverWorkflows(dir: string): Promise<DiscoveredWorkflow[]>;
|
|
58
|
+
export declare function discoverWorkflows(dir: string | readonly string[]): Promise<DiscoveredWorkflow[]>;
|
|
70
59
|
/**
|
|
71
|
-
* Discover every workflow class (`BaseWorkflow` subclass) under `dir`
|
|
72
|
-
*
|
|
73
|
-
* Best-effort over a missing directory
|
|
60
|
+
* Discover every workflow class (`BaseWorkflow` subclass) under `dir` — one directory or several,
|
|
61
|
+
* see {@link discoverWorkflows} — and register each on the engine. Returns the registered metadata
|
|
62
|
+
* so the caller can log what was wired. Best-effort over a missing directory; throws a
|
|
63
|
+
* {@link DuplicateDiscoveryError} (registering nothing) on a cross-directory name clash.
|
|
74
64
|
*/
|
|
75
|
-
export declare function registerWorkflowsFromDir(engine: WorkflowEngine, dir: string, factory?: WorkflowClassFactory): Promise<WorkflowMeta[]>;
|
|
65
|
+
export declare function registerWorkflowsFromDir(engine: WorkflowEngine, dir: string | readonly string[], factory?: WorkflowClassFactory): Promise<WorkflowMeta[]>;
|
|
76
66
|
/**
|
|
77
67
|
* The shape of the build-time barrel generated by the Assembler `init` hook
|
|
78
68
|
* (`@adonis-agora/durable/hooks/workflows`): a map of stable key → lazy module import, e.g.
|
|
79
|
-
* `{ Charge: () => import('#workflows/charge_workflow') }
|
|
80
|
-
*
|
|
81
|
-
* scan.
|
|
69
|
+
* `{ Charge: () => import('#workflows/charge_workflow') }`, nested one level per sub-directory
|
|
70
|
+
* (`{ billing: { Refund: () => import(...) } }`). The exact key is irrelevant here — we register
|
|
71
|
+
* every workflow export of every module (`BaseWorkflow` subclass), identical to the runtime scan.
|
|
72
|
+
* When the hook's `source` lists several directories it writes a {@link RootedBarrel} array instead.
|
|
82
73
|
*/
|
|
83
|
-
export type WorkflowsBarrel =
|
|
74
|
+
export type WorkflowsBarrel = BarrelTree;
|
|
84
75
|
/**
|
|
85
76
|
* Register every workflow class reachable from a generated {@link WorkflowsBarrel} (`BaseWorkflow`
|
|
86
|
-
* subclass)
|
|
87
|
-
* workflow export
|
|
88
|
-
* `readdir`. Each module is imported once and each class registered once (deduped),
|
|
89
|
-
* re-exported from several modules is safe.
|
|
90
|
-
* what was wired.
|
|
77
|
+
* subclass) — or from the multi-root {@link RootedBarrel} array — by awaiting each lazy module import
|
|
78
|
+
* and registering each workflow export: the build-time equivalent of {@link registerWorkflowsFromDir},
|
|
79
|
+
* with no runtime `readdir`. Each module is imported once and each class registered once (deduped),
|
|
80
|
+
* so a class re-exported from several modules is safe. Same cross-root duplicate rule as the scan.
|
|
81
|
+
* Returns the registered metadata so the caller can log what was wired.
|
|
91
82
|
*/
|
|
92
|
-
export declare function registerWorkflowsFromBarrel(engine: WorkflowEngine, barrel: WorkflowsBarrel, factory?: WorkflowClassFactory): Promise<WorkflowMeta[]>;
|
|
83
|
+
export declare function registerWorkflowsFromBarrel(engine: WorkflowEngine, barrel: WorkflowsBarrel | readonly RootedBarrel[], factory?: WorkflowClassFactory): Promise<WorkflowMeta[]>;
|
|
93
84
|
//# sourceMappingURL=workflow-discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-discovery.d.ts","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow-discovery.d.ts","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,YAAY,EAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU;IAC9C,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CA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'node:path';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
1
|
+
import { barrelModules, DuplicateDiscoveryError, scanDirsModules, } from './discovery-roots.js';
|
|
4
2
|
import { eventTriggerCanonicalName, workflowEvents } from './workflow-events.js';
|
|
5
3
|
import { onErrorRoutesOf, workflowMeta, workflowSchedules, } from './workflow-ref.js';
|
|
6
4
|
function defaultWorkflowFactory(ctor) {
|
|
@@ -32,7 +30,19 @@ export async function registerWorkflowClass(engine, cls, factory = defaultWorkfl
|
|
|
32
30
|
const exactNames = events
|
|
33
31
|
.map(eventTriggerCanonicalName)
|
|
34
32
|
.filter((name) => name !== null);
|
|
33
|
+
// Inline dead-letter handler: a `deadLetter(ctx, dead)` method becomes the workflow `<name>.dlq`.
|
|
34
|
+
const inlineDeadLetter = instance.deadLetter;
|
|
35
|
+
let deadLetterWorkflow = meta.deadLetterWorkflow;
|
|
36
|
+
if (typeof inlineDeadLetter === 'function') {
|
|
37
|
+
if (meta.deadLetterWorkflow !== undefined) {
|
|
38
|
+
throw new Error(`workflow ${meta.name} declares both a deadLetter() method and a deadLetterWorkflow option. Use one: the inline handler, or the reference.`);
|
|
39
|
+
}
|
|
40
|
+
const dlqName = `${meta.name}.dlq`;
|
|
41
|
+
engine.register(dlqName, meta.version, (ctx, input) => Promise.resolve(inlineDeadLetter.call(instance, ctx, input)), meta.origin ? { origin: meta.origin } : undefined);
|
|
42
|
+
deadLetterWorkflow = dlqName;
|
|
43
|
+
}
|
|
35
44
|
engine.register(meta.name, meta.version, (ctx, input) => Promise.resolve(instance.run(ctx, input)), {
|
|
45
|
+
...(deadLetterWorkflow !== undefined ? { deadLetterWorkflow } : {}),
|
|
36
46
|
...(meta.tags ? { tags: meta.tags } : {}),
|
|
37
47
|
...(meta.executionTimeout !== undefined ? { executionTimeout: meta.executionTimeout } : {}),
|
|
38
48
|
...(meta.onEvent || exactNames.length > 0
|
|
@@ -42,6 +52,8 @@ export async function registerWorkflowClass(engine, cls, factory = defaultWorkfl
|
|
|
42
52
|
...(meta.concurrency ? { concurrency: meta.concurrency } : {}),
|
|
43
53
|
...(meta.origin ? { origin: meta.origin } : {}),
|
|
44
54
|
...(meta.onError?.length ? { onError: onErrorRoutesOf(meta) } : {}),
|
|
55
|
+
...(meta.inputSchema ? { inputSchema: meta.inputSchema } : {}),
|
|
56
|
+
...(meta.searchAttributes ? { searchAttributesSchema: meta.searchAttributes } : {}),
|
|
45
57
|
});
|
|
46
58
|
// Collect any colocated `static schedule` on the class so the worker loop can fire it alongside the
|
|
47
59
|
// config schedules. Both discovery paths (dir scan + generated barrel) funnel through here, so this
|
|
@@ -51,87 +63,64 @@ export async function registerWorkflowClass(engine, cls, factory = defaultWorkfl
|
|
|
51
63
|
engine.registerSchedules(schedules);
|
|
52
64
|
return true;
|
|
53
65
|
}
|
|
66
|
+
/** Re-exported from its shared home so existing `pickModuleExt` imports keep working. */
|
|
67
|
+
export { pickModuleExt } from './discovery-roots.js';
|
|
54
68
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* extension from `import.meta.url` (the old bug) always picked `.js` in that setup and silently
|
|
59
|
-
* discovered nothing, because every entry was then skipped.
|
|
69
|
+
* Collect every workflow class reachable from `modules`, in order: each export is considered
|
|
70
|
+
* (default and named), and a class seen twice (re-exported from several modules, or reachable from
|
|
71
|
+
* two overlapping roots) is kept once.
|
|
60
72
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* 4. If neither is present, returns `null` (the scan registers nothing).
|
|
66
|
-
*
|
|
67
|
-
* This preserves the original de-duplication intent: a directory containing both a built `foo.js`
|
|
68
|
-
* and its source `foo.ts` resolves to `.ts` only, so the same module is never registered twice.
|
|
69
|
-
* Shared with {@link import('./step-discovery.js').registerStepsFromDir} so the two scanners can't
|
|
70
|
-
* drift apart again.
|
|
71
|
-
*/
|
|
72
|
-
export function pickModuleExt(entries) {
|
|
73
|
-
let hasTs = false;
|
|
74
|
-
let hasJs = false;
|
|
75
|
-
for (const entry of entries) {
|
|
76
|
-
if (entry.endsWith('.d.ts'))
|
|
77
|
-
continue;
|
|
78
|
-
const ext = extname(entry);
|
|
79
|
-
if (ext === '.ts')
|
|
80
|
-
hasTs = true;
|
|
81
|
-
else if (ext === '.js')
|
|
82
|
-
hasJs = true;
|
|
83
|
-
}
|
|
84
|
-
if (hasTs)
|
|
85
|
-
return '.ts';
|
|
86
|
-
if (hasJs)
|
|
87
|
-
return '.js';
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Scan a directory RECURSIVELY for modules and collect every exported workflow class — a
|
|
92
|
-
* `BaseWorkflow` subclass (the default export and any named export are considered) — so nested
|
|
93
|
-
* conventions like
|
|
94
|
-
* `app/workflows/billing/charge_workflow.ts` are found, matching `make:workflow`'s nested-path
|
|
95
|
-
* scaffolding. Only the extension present in `dir` is imported (see {@link pickModuleExt}), and
|
|
96
|
-
* each module path is visited once, so a built `.js` and a dev `.ts` of the same module never both
|
|
97
|
-
* register. Missing directory → empty list (the convention is opt-in: no `app/workflows`, nothing to
|
|
98
|
-
* register).
|
|
73
|
+
* Two DIFFERENT classes claiming the same name + version from two different roots throw a
|
|
74
|
+
* {@link DuplicateDiscoveryError} quoting both files — before anything is registered. Within a single
|
|
75
|
+
* root nothing changes from the single-directory behaviour (both are kept; the later registration
|
|
76
|
+
* wins on the engine).
|
|
99
77
|
*/
|
|
100
|
-
|
|
101
|
-
let entries;
|
|
102
|
-
try {
|
|
103
|
-
entries = await readdir(dir, { recursive: true });
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
if (err.code === 'ENOENT')
|
|
107
|
-
return [];
|
|
108
|
-
throw err;
|
|
109
|
-
}
|
|
110
|
-
const moduleExt = pickModuleExt(entries);
|
|
78
|
+
async function collectWorkflows(modules) {
|
|
111
79
|
const found = [];
|
|
112
|
-
if (moduleExt === null)
|
|
113
|
-
return found;
|
|
114
80
|
const seen = new Set();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const mod = (await import(pathToFileURL(join(dir, entry)).href));
|
|
81
|
+
const owners = new Map();
|
|
82
|
+
for (const { root, file, load } of modules) {
|
|
83
|
+
const mod = await load();
|
|
119
84
|
for (const exported of Object.values(mod)) {
|
|
120
85
|
if (seen.has(exported))
|
|
121
86
|
continue;
|
|
122
87
|
const meta = workflowMeta(exported);
|
|
123
88
|
if (!meta)
|
|
124
89
|
continue;
|
|
90
|
+
const id = `${meta.name}@${meta.version}`;
|
|
91
|
+
const owner = owners.get(id);
|
|
92
|
+
if (owner && owner.root !== root) {
|
|
93
|
+
throw new DuplicateDiscoveryError('workflow', id, [owner.file, file]);
|
|
94
|
+
}
|
|
95
|
+
if (!owner)
|
|
96
|
+
owners.set(id, { root, file });
|
|
125
97
|
seen.add(exported);
|
|
126
|
-
found.push({ meta, cls: exported });
|
|
98
|
+
found.push({ meta, cls: exported, file });
|
|
127
99
|
}
|
|
128
100
|
}
|
|
129
101
|
return found;
|
|
130
102
|
}
|
|
131
103
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
104
|
+
* Scan one directory — or several — RECURSIVELY for modules and collect every exported workflow
|
|
105
|
+
* class — a `BaseWorkflow` subclass (the default export and any named export are considered) — so
|
|
106
|
+
* nested conventions like `app/workflows/billing/charge_workflow.ts` are found, matching
|
|
107
|
+
* `make:workflow`'s nested-path scaffolding. Only the extension present in each directory is
|
|
108
|
+
* imported (see {@link pickModuleExt}), and each module path is visited once, so a built `.js` and a
|
|
109
|
+
* dev `.ts` of the same module never both register. Missing directory → nothing from it (the
|
|
110
|
+
* convention is opt-in: no `app/workflows`, nothing to register).
|
|
111
|
+
*
|
|
112
|
+
* With several directories (a modular app: `['app/orders/flows', 'app/billing/flows']`) every root
|
|
113
|
+
* is walked in order, and the same workflow name + version defined by different classes in two
|
|
114
|
+
* roots throws a {@link DuplicateDiscoveryError} naming both files.
|
|
115
|
+
*/
|
|
116
|
+
export async function discoverWorkflows(dir) {
|
|
117
|
+
return collectWorkflows(await scanDirsModules(typeof dir === 'string' ? [dir] : dir));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Discover every workflow class (`BaseWorkflow` subclass) under `dir` — one directory or several,
|
|
121
|
+
* see {@link discoverWorkflows} — and register each on the engine. Returns the registered metadata
|
|
122
|
+
* so the caller can log what was wired. Best-effort over a missing directory; throws a
|
|
123
|
+
* {@link DuplicateDiscoveryError} (registering nothing) on a cross-directory name clash.
|
|
135
124
|
*/
|
|
136
125
|
export async function registerWorkflowsFromDir(engine, dir, factory) {
|
|
137
126
|
const discovered = await discoverWorkflows(dir);
|
|
@@ -141,28 +130,16 @@ export async function registerWorkflowsFromDir(engine, dir, factory) {
|
|
|
141
130
|
}
|
|
142
131
|
/**
|
|
143
132
|
* Register every workflow class reachable from a generated {@link WorkflowsBarrel} (`BaseWorkflow`
|
|
144
|
-
* subclass)
|
|
145
|
-
* workflow export
|
|
146
|
-
* `readdir`. Each module is imported once and each class registered once (deduped),
|
|
147
|
-
* re-exported from several modules is safe.
|
|
148
|
-
* what was wired.
|
|
133
|
+
* subclass) — or from the multi-root {@link RootedBarrel} array — by awaiting each lazy module import
|
|
134
|
+
* and registering each workflow export: the build-time equivalent of {@link registerWorkflowsFromDir},
|
|
135
|
+
* with no runtime `readdir`. Each module is imported once and each class registered once (deduped),
|
|
136
|
+
* so a class re-exported from several modules is safe. Same cross-root duplicate rule as the scan.
|
|
137
|
+
* Returns the registered metadata so the caller can log what was wired.
|
|
149
138
|
*/
|
|
150
139
|
export async function registerWorkflowsFromBarrel(engine, barrel, factory) {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
for (const exported of Object.values(mod)) {
|
|
156
|
-
if (seen.has(exported))
|
|
157
|
-
continue;
|
|
158
|
-
const meta = workflowMeta(exported);
|
|
159
|
-
if (!meta)
|
|
160
|
-
continue;
|
|
161
|
-
seen.add(exported);
|
|
162
|
-
await registerWorkflowClass(engine, exported, factory);
|
|
163
|
-
registered.push(meta);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return registered;
|
|
140
|
+
const discovered = await collectWorkflows(barrelModules(barrel));
|
|
141
|
+
for (const { cls } of discovered)
|
|
142
|
+
await registerWorkflowClass(engine, cls, factory);
|
|
143
|
+
return discovered.map((d) => d.meta);
|
|
167
144
|
}
|
|
168
145
|
//# sourceMappingURL=workflow-discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-discovery.js","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"workflow-discovery.js","sourceRoot":"","sources":["../../src/workflow-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,uBAAuB,EAEvB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EACL,eAAe,EAEf,YAAY,EACZ,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAkC3B,SAAS,sBAAsB,CAC7B,IAA6B;IAE7B,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAsB,EACtB,GAAY,EACZ,OAAO,GAAyB,sBAAsB;IAEtD,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,IAAI,GAAG,GAA8B,CAAC;IAC5C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,sFAAsF;IACtF,kFAAkF;IAClF,mFAAmF;IACnF,MAAM,MAAM,GAAG,cAAc,CA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AAK,MAAM,EAAE,GAAG,EAAE,IAAI,UAAU;QAAE,MAAM,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpF,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ConcurrencyConfig } from './concurrency.js';
|
|
9
9
|
import type { SingletonConfig } from './engine.js';
|
|
10
|
+
import type { SearchAttributesSchema } from './interfaces.js';
|
|
10
11
|
import type { ScheduledWorkflow, WorkflowScheduleConfig } from './scheduler.js';
|
|
12
|
+
import type { StandardSchemaV1 } from './standard-schema.js';
|
|
11
13
|
/** Options for a workflow's `static workflow = { name, version, … }` config (see {@link BaseWorkflow}). */
|
|
12
14
|
export interface WorkflowOptions {
|
|
13
15
|
/** The registered workflow name (the cross-runtime identity, e.g. `order`). */
|
|
@@ -57,6 +59,28 @@ export interface WorkflowOptions {
|
|
|
57
59
|
};
|
|
58
60
|
workflow: WorkflowRef;
|
|
59
61
|
}[];
|
|
62
|
+
/**
|
|
63
|
+
* Where a run of this workflow that goes `dead` (past `maxRecoveryAttempts`) is handed: the engine
|
|
64
|
+
* starts this workflow with a `DeadLetter` input (`{ deadRunId, workflow, input, error }`) under
|
|
65
|
+
* the run id `dlq:<deadRunId>`, in the dead run's namespace. Overrides the config-level
|
|
66
|
+
* `deadLetterWorkflow`. A class can instead define a `deadLetter(ctx, dead)` method (registered as
|
|
67
|
+
* `<name>.dlq`); declaring both is an error at boot.
|
|
68
|
+
*/
|
|
69
|
+
deadLetterWorkflow?: WorkflowRef;
|
|
70
|
+
/**
|
|
71
|
+
* Validate the run input at start against any Standard Schema (zod, valibot, arktype, …). A bad
|
|
72
|
+
* payload throws a `SchemaValidationError` from `start` and no run is created (an `onEvent`
|
|
73
|
+
* trigger with a rejected payload simply doesn't start this workflow). The schema's OUTPUT value
|
|
74
|
+
* (parsed / coerced / defaulted) is what the run stores and `run(ctx, input)` receives.
|
|
75
|
+
*/
|
|
76
|
+
inputSchema?: StandardSchemaV1;
|
|
77
|
+
/**
|
|
78
|
+
* The run's typed search-attributes shape (a {@link SearchAttributesSchema}): every
|
|
79
|
+
* `ctx.upsertSearchAttributes` validates the merged attributes against it and rejects a
|
|
80
|
+
* non-conforming write. Pair with `run(ctx: WorkflowCtx<InferSearchAttributes<typeof schema>>)`
|
|
81
|
+
* for compile-time typing, and read them back typed with `attributesOf(WorkflowClass, run)`.
|
|
82
|
+
*/
|
|
83
|
+
searchAttributes?: SearchAttributesSchema;
|
|
60
84
|
}
|
|
61
85
|
/** The metadata read off a workflow class's `static workflow` config for discovery + registration. */
|
|
62
86
|
export interface WorkflowMeta extends WorkflowOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-ref.d.ts","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,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AAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,GACrF,SAAS,CAQZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"workflow-ref.js","sourceRoot":"","sources":["../../src/workflow-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiFH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,MAAM,GAAI,MAAyC,CAAC,QAAQ,CAAC;IACnE,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5E,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,GAAG,GAAI,MAA2E,CAAC,QAAQ,CAAC;IAClG,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAA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AAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,eAAe,CAAC,IAAqB;IACnD,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QACvD,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpF,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;KACjC,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAe;IAIf,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,CAAC;AACJ,CAAC"}
|
|
@@ -50,6 +50,12 @@ export default defineConfig({
|
|
|
50
50
|
// remoteRedispatchMs: 5 * 60 * 1000,
|
|
51
51
|
// remoteRedispatchMax: 10,
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Liveness window of a remote (polyglot) workflow turn: with no decision and no run-scoped
|
|
55
|
+
* heartbeat for this long, the turn is re-driven instead of waiting forever. Heartbeats rearm it.
|
|
56
|
+
*/
|
|
57
|
+
// remoteAdvanceSilenceMs: 2 * 60 * 1000,
|
|
58
|
+
|
|
53
59
|
/**
|
|
54
60
|
* Recurring workflows fired by the \`durable:work\` worker loop on every tick. Each window starts
|
|
55
61
|
* exactly once even with several worker instances racing (idempotent by the schedule's time-bucket
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
exports({ to: app.configPath('durable_dashboard.ts') })
|
|
3
3
|
}}}
|
|
4
4
|
import { defineConfig } from '@adonis-agora/durable/dashboard'
|
|
5
|
+
// Used by the commented-out dashboardAuth example below.
|
|
6
|
+
// import env from '#start/env'
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Configuration for the @adonis-agora/durable dashboard.
|
|
8
10
|
*
|
|
9
|
-
* By default the dashboard
|
|
10
|
-
*
|
|
11
|
-
* Replace \`authorize\` with your own guard (session,
|
|
11
|
+
* By default the dashboard FAILS CLOSED in every environment: it requires a
|
|
12
|
+
* bearer token equal to \`DURABLE_DASHBOARD_TOKEN\`, and denies everything when
|
|
13
|
+
* that env var is unset. Replace \`authorize\` with your own guard (session,
|
|
14
|
+
* role, IP allow-list, …), or set \`allowUnauthenticated: true\` for a trusted
|
|
15
|
+
* local network only.
|
|
12
16
|
*
|
|
13
17
|
* \`dashboardAuth\` is an ADDITIVE, optional session gate on top of \`authorize\` —
|
|
14
18
|
* a signed cookie minted via a built-in login page (Mode B: \`login\`) and/or a
|
|
@@ -7,7 +7,8 @@ import { createDurableTables, dropDurableTables } from '@adonis-agora/durable'
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Durable workflow tables for the @adonis-agora/durable \`lucid\` state store: runs, step checkpoints,
|
|
10
|
-
* the search-attribute side-table, signal waiters, buffered signals
|
|
10
|
+
* the search-attribute side-table, signal waiters, buffered signals, buffered events and persisted
|
|
11
|
+
* schedules (seven tables, plus the one-row \`durable_schema_meta\` marker).
|
|
11
12
|
*
|
|
12
13
|
* This migration DELEGATES to the library instead of reproducing its DDL. The schema belongs to the
|
|
13
14
|
* library — \`LucidStateStore\` decides what columns it reads and writes — so a hand-copied snapshot
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_durable_transport_messages.ts`) })
|
|
3
|
+
}}}
|
|
4
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The message channel of the @adonis-agora/durable \`db\` transport: remote-workflow decisions and step
|
|
8
|
+
* events, and the store-less (tenant pod) protocol's start-run, run-request, run-reply and tenant-event
|
|
9
|
+
* rows. Also adds the \`kind\` column (\`step\` / \`workflow\`) to \`durable_transport_tasks\` when an
|
|
10
|
+
* older migration created that table without it. Only needed when you select the \`db\` transport in
|
|
11
|
+
* config/durable.ts.
|
|
12
|
+
*/
|
|
13
|
+
export default class extends BaseSchema {
|
|
14
|
+
async up() {
|
|
15
|
+
this.schema.createTable('durable_transport_messages', (table) => {
|
|
16
|
+
table.increments('id').primary()
|
|
17
|
+
table.string('kind', 32).notNullable()
|
|
18
|
+
table.string('namespace').notNullable().defaultTo('default')
|
|
19
|
+
table.string('recipient').notNullable().defaultTo('')
|
|
20
|
+
table.string('reply_to')
|
|
21
|
+
table.text('payload', 'longtext').notNullable()
|
|
22
|
+
table.string('claimed_by')
|
|
23
|
+
table.bigInteger('claimed_at')
|
|
24
|
+
table.bigInteger('created_at').notNullable()
|
|
25
|
+
table.index(['namespace', 'kind', 'recipient', 'claimed_at', 'id'], 'durable_transport_messages_idx')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Upgrading: a tasks table from an earlier release has no kind column. (A fresh install creates
|
|
29
|
+
// it with one, whichever of the two migrations runs first.)
|
|
30
|
+
// Each check takes a fresh schema builder: a Knex schema builder is stateful.
|
|
31
|
+
this.defer(async (db) => {
|
|
32
|
+
if (!(await db.schema.hasTable('durable_transport_tasks'))) return
|
|
33
|
+
if (await db.schema.hasColumn('durable_transport_tasks', 'kind')) return
|
|
34
|
+
await db.schema.alterTable('durable_transport_tasks', (table) => {
|
|
35
|
+
table.string('kind', 16).notNullable().defaultTo('step')
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async down() {
|
|
41
|
+
this.schema.dropTableIfExists('durable_transport_messages')
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -6,9 +6,9 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
6
6
|
/**
|
|
7
7
|
* Transport tables for the @adonis-agora/durable \`db\` transport: the point-to-point work channels (tasks /
|
|
8
8
|
* results / heartbeats / control) that let durable remote steps run cross-process over the database
|
|
9
|
-
* alone. JSON payloads are stored as
|
|
10
|
-
* epoch-ms integers, so the schema is portable across
|
|
11
|
-
* select the \`db\` transport in config/durable.ts.
|
|
9
|
+
* alone. JSON payloads are stored as text (the transport (de)serializes them) — \`longtext\` on MySQL,
|
|
10
|
+
* where \`text\` stops at 64KB — and timestamps as epoch-ms integers, so the schema is portable across
|
|
11
|
+
* SQLite / Postgres / MySQL. Only needed when you select the \`db\` transport in config/durable.ts.
|
|
12
12
|
*/
|
|
13
13
|
export default class extends BaseSchema {
|
|
14
14
|
async up() {
|
|
@@ -19,11 +19,14 @@ export default class extends BaseSchema {
|
|
|
19
19
|
table.string('name').notNullable()
|
|
20
20
|
table.string('grp').notNullable()
|
|
21
21
|
table.string('namespace').notNullable().defaultTo('default')
|
|
22
|
-
table.text('input')
|
|
22
|
+
table.text('input', 'longtext')
|
|
23
23
|
table.string('traceparent')
|
|
24
|
-
table.text('context')
|
|
24
|
+
table.text('context', 'longtext')
|
|
25
25
|
table.string('transport')
|
|
26
26
|
table.integer('attempt').notNullable()
|
|
27
|
+
table.integer('reclaims').notNullable().defaultTo(0)
|
|
28
|
+
table.integer('priority').notNullable().defaultTo(0)
|
|
29
|
+
table.string('kind', 16).notNullable().defaultTo('step')
|
|
27
30
|
table.string('claimed_by')
|
|
28
31
|
table.bigInteger('claimed_at')
|
|
29
32
|
table.bigInteger('created_at').notNullable()
|
|
@@ -36,10 +39,10 @@ export default class extends BaseSchema {
|
|
|
36
39
|
table.integer('seq').notNullable()
|
|
37
40
|
table.string('status').notNullable()
|
|
38
41
|
table.string('namespace').notNullable().defaultTo('default')
|
|
39
|
-
table.text('output')
|
|
40
|
-
table.text('error')
|
|
42
|
+
table.text('output', 'longtext')
|
|
43
|
+
table.text('error', 'longtext')
|
|
41
44
|
table.bigInteger('started_at')
|
|
42
|
-
table.text('events')
|
|
45
|
+
table.text('events', 'longtext')
|
|
43
46
|
table.string('claimed_by')
|
|
44
47
|
table.bigInteger('claimed_at')
|
|
45
48
|
table.bigInteger('created_at').notNullable()
|
|
@@ -61,7 +64,7 @@ export default class extends BaseSchema {
|
|
|
61
64
|
|
|
62
65
|
this.schema.createTable('durable_transport_control', (table) => {
|
|
63
66
|
table.increments('id').primary()
|
|
64
|
-
table.text('payload').notNullable()
|
|
67
|
+
table.text('payload', 'longtext').notNullable()
|
|
65
68
|
table.string('namespace').notNullable().defaultTo('default')
|
|
66
69
|
table.string('claimed_by')
|
|
67
70
|
table.bigInteger('claimed_at')
|
|
@@ -12,7 +12,7 @@ export default class extends BaseSchema {
|
|
|
12
12
|
async up() {
|
|
13
13
|
this.schema.createTable('durable_transport_worker_keys', (table) => {
|
|
14
14
|
table.string('key', 512).primary()
|
|
15
|
-
table.text('value').notNullable()
|
|
15
|
+
table.text('value', 'longtext').notNullable()
|
|
16
16
|
table.bigInteger('expires_at').notNullable()
|
|
17
17
|
table.index(['expires_at'], 'durable_transport_worker_keys_expires_idx')
|
|
18
18
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{{#var workflowName = string(entity.name).pascalCase().toString()}}
|
|
1
|
+
{{#var workflowName = string(entity.name).snakeCase().removeSuffix('workflow').pascalCase().toString()}}
|
|
2
2
|
{{#var workflowFileName = string(entity.name).snakeCase().removeSuffix('workflow').toString() + '_workflow'}}
|
|
3
3
|
{{#var registeredName = string(entity.name).snakeCase().removeSuffix('workflow').toString()}}
|
|
4
4
|
{{{
|