@adonis-agora/durable 0.1.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/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/assets/dashboard.html +446 -0
- package/dist/commands/main.d.ts +15 -0
- package/dist/commands/main.d.ts.map +1 -0
- package/dist/commands/main.js +15 -0
- package/dist/commands/main.js.map +1 -0
- package/dist/commands/retry.d.ts +16 -0
- package/dist/commands/retry.d.ts.map +1 -0
- package/dist/commands/retry.js +34 -0
- package/dist/commands/retry.js.map +1 -0
- package/dist/commands/runs.d.ts +17 -0
- package/dist/commands/runs.d.ts.map +1 -0
- package/dist/commands/runs.js +40 -0
- package/dist/commands/runs.js.map +1 -0
- package/dist/commands/work.d.ts +18 -0
- package/dist/commands/work.d.ts.map +1 -0
- package/dist/commands/work.js +58 -0
- package/dist/commands/work.js.map +1 -0
- package/dist/configure.d.ts +15 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +26 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/dashboard_provider.d.ts +27 -0
- package/dist/providers/dashboard_provider.d.ts.map +1 -0
- package/dist/providers/dashboard_provider.js +94 -0
- package/dist/providers/dashboard_provider.js.map +1 -0
- package/dist/providers/durable_provider.d.ts +36 -0
- package/dist/providers/durable_provider.d.ts.map +1 -0
- package/dist/providers/durable_provider.js +113 -0
- package/dist/providers/durable_provider.js.map +1 -0
- package/dist/src/admission-redis/index.d.ts +2 -0
- package/dist/src/admission-redis/index.d.ts.map +1 -0
- package/dist/src/admission-redis/index.js +2 -0
- package/dist/src/admission-redis/index.js.map +1 -0
- package/dist/src/admission-redis/redis-admission-backend.d.ts +83 -0
- package/dist/src/admission-redis/redis-admission-backend.d.ts.map +1 -0
- package/dist/src/admission-redis/redis-admission-backend.js +200 -0
- package/dist/src/admission-redis/redis-admission-backend.js.map +1 -0
- package/dist/src/admission.d.ts +49 -0
- package/dist/src/admission.d.ts.map +1 -0
- package/dist/src/admission.js +30 -0
- package/dist/src/admission.js.map +1 -0
- package/dist/src/backoff.d.ts +5 -0
- package/dist/src/backoff.d.ts.map +1 -0
- package/dist/src/backoff.js +11 -0
- package/dist/src/backoff.js.map +1 -0
- package/dist/src/checkpoints.d.ts +42 -0
- package/dist/src/checkpoints.d.ts.map +1 -0
- package/dist/src/checkpoints.js +57 -0
- package/dist/src/checkpoints.js.map +1 -0
- package/dist/src/codec-state-store.d.ts +60 -0
- package/dist/src/codec-state-store.d.ts.map +1 -0
- package/dist/src/codec-state-store.js +129 -0
- package/dist/src/codec-state-store.js.map +1 -0
- package/dist/src/commands/index.d.ts +3 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +3 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/runs.d.ts +24 -0
- package/dist/src/commands/runs.d.ts.map +1 -0
- package/dist/src/commands/runs.js +39 -0
- package/dist/src/commands/runs.js.map +1 -0
- package/dist/src/commands/worker.d.ts +61 -0
- package/dist/src/commands/worker.d.ts.map +1 -0
- package/dist/src/commands/worker.js +74 -0
- package/dist/src/commands/worker.js.map +1 -0
- package/dist/src/completion.d.ts +15 -0
- package/dist/src/completion.d.ts.map +1 -0
- package/dist/src/completion.js +10 -0
- package/dist/src/completion.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +48 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -0
- package/dist/src/dashboard/define_config.js +57 -0
- package/dist/src/dashboard/define_config.js.map +1 -0
- package/dist/src/dashboard/handlers.d.ts +47 -0
- package/dist/src/dashboard/handlers.d.ts.map +1 -0
- package/dist/src/dashboard/handlers.js +163 -0
- package/dist/src/dashboard/handlers.js.map +1 -0
- package/dist/src/dashboard/html.d.ts +7 -0
- package/dist/src/dashboard/html.d.ts.map +1 -0
- package/dist/src/dashboard/html.js +24 -0
- package/dist/src/dashboard/html.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +8 -0
- package/dist/src/dashboard/index.d.ts.map +1 -0
- package/dist/src/dashboard/index.js +6 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/define_config.d.ts +72 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +8 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/diagnostics-bridge.d.ts +22 -0
- package/dist/src/diagnostics-bridge.d.ts.map +1 -0
- package/dist/src/diagnostics-bridge.js +25 -0
- package/dist/src/diagnostics-bridge.js.map +1 -0
- package/dist/src/duration.d.ts +6 -0
- package/dist/src/duration.d.ts.map +1 -0
- package/dist/src/duration.js +39 -0
- package/dist/src/duration.js.map +1 -0
- package/dist/src/engine.d.ts +583 -0
- package/dist/src/engine.d.ts.map +1 -0
- package/dist/src/engine.js +1894 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/entities.d.ts +44 -0
- package/dist/src/entities.d.ts.map +1 -0
- package/dist/src/entities.js +64 -0
- package/dist/src/entities.js.map +1 -0
- package/dist/src/errors.d.ts +68 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +102 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/event-accumulators.d.ts +39 -0
- package/dist/src/event-accumulators.d.ts.map +1 -0
- package/dist/src/event-accumulators.js +70 -0
- package/dist/src/event-accumulators.js.map +1 -0
- package/dist/src/events.d.ts +9 -0
- package/dist/src/events.d.ts.map +1 -0
- package/dist/src/events.js +35 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces.d.ts +909 -0
- package/dist/src/interfaces.d.ts.map +1 -0
- package/dist/src/interfaces.js +2 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/src/metrics.d.ts +44 -0
- package/dist/src/metrics.d.ts.map +1 -0
- package/dist/src/metrics.js +78 -0
- package/dist/src/metrics.js.map +1 -0
- package/dist/src/otel/durable-metrics.d.ts +42 -0
- package/dist/src/otel/durable-metrics.d.ts.map +1 -0
- package/dist/src/otel/durable-metrics.js +75 -0
- package/dist/src/otel/durable-metrics.js.map +1 -0
- package/dist/src/otel/durable-otel.d.ts +20 -0
- package/dist/src/otel/durable-otel.d.ts.map +1 -0
- package/dist/src/otel/durable-otel.js +74 -0
- package/dist/src/otel/durable-otel.js.map +1 -0
- package/dist/src/otel/index.d.ts +4 -0
- package/dist/src/otel/index.d.ts.map +1 -0
- package/dist/src/otel/index.js +4 -0
- package/dist/src/otel/index.js.map +1 -0
- package/dist/src/otel/traceparent.d.ts +17 -0
- package/dist/src/otel/traceparent.d.ts.map +1 -0
- package/dist/src/otel/traceparent.js +21 -0
- package/dist/src/otel/traceparent.js.map +1 -0
- package/dist/src/pollers.d.ts +33 -0
- package/dist/src/pollers.d.ts.map +1 -0
- package/dist/src/pollers.js +76 -0
- package/dist/src/pollers.js.map +1 -0
- package/dist/src/protocol.d.ts +17 -0
- package/dist/src/protocol.d.ts.map +1 -0
- package/dist/src/protocol.js +47 -0
- package/dist/src/protocol.js.map +1 -0
- package/dist/src/queue.d.ts +113 -0
- package/dist/src/queue.d.ts.map +1 -0
- package/dist/src/queue.js +128 -0
- package/dist/src/queue.js.map +1 -0
- package/dist/src/remote-step-factory.d.ts +15 -0
- package/dist/src/remote-step-factory.d.ts.map +1 -0
- package/dist/src/remote-step-factory.js +12 -0
- package/dist/src/remote-step-factory.js.map +1 -0
- package/dist/src/remote-workflow-executor.d.ts +24 -0
- package/dist/src/remote-workflow-executor.d.ts.map +1 -0
- package/dist/src/remote-workflow-executor.js +70 -0
- package/dist/src/remote-workflow-executor.js.map +1 -0
- package/dist/src/scheduler.d.ts +67 -0
- package/dist/src/scheduler.d.ts.map +1 -0
- package/dist/src/scheduler.js +111 -0
- package/dist/src/scheduler.js.map +1 -0
- package/dist/src/search-attributes.d.ts +48 -0
- package/dist/src/search-attributes.d.ts.map +1 -0
- package/dist/src/search-attributes.js +98 -0
- package/dist/src/search-attributes.js.map +1 -0
- package/dist/src/singleton-gate.d.ts +44 -0
- package/dist/src/singleton-gate.d.ts.map +1 -0
- package/dist/src/singleton-gate.js +90 -0
- package/dist/src/singleton-gate.js.map +1 -0
- package/dist/src/step-logger.d.ts +9 -0
- package/dist/src/step-logger.d.ts.map +1 -0
- package/dist/src/step-logger.js +89 -0
- package/dist/src/step-logger.js.map +1 -0
- package/dist/src/stores/factory.d.ts +42 -0
- package/dist/src/stores/factory.d.ts.map +1 -0
- package/dist/src/stores/factory.js +29 -0
- package/dist/src/stores/factory.js.map +1 -0
- package/dist/src/stores/lucid-helpers.d.ts +11 -0
- package/dist/src/stores/lucid-helpers.d.ts.map +1 -0
- package/dist/src/stores/lucid-helpers.js +38 -0
- package/dist/src/stores/lucid-helpers.js.map +1 -0
- package/dist/src/stores/lucid-mappers.d.ts +58 -0
- package/dist/src/stores/lucid-mappers.d.ts.map +1 -0
- package/dist/src/stores/lucid-mappers.js +174 -0
- package/dist/src/stores/lucid-mappers.js.map +1 -0
- package/dist/src/stores/lucid-schema.d.ts +28 -0
- package/dist/src/stores/lucid-schema.d.ts.map +1 -0
- package/dist/src/stores/lucid-schema.js +115 -0
- package/dist/src/stores/lucid-schema.js.map +1 -0
- package/dist/src/stores/lucid.d.ts +69 -0
- package/dist/src/stores/lucid.d.ts.map +1 -0
- package/dist/src/stores/lucid.js +342 -0
- package/dist/src/stores/lucid.js.map +1 -0
- package/dist/src/telescope/dashboard.d.ts +15 -0
- package/dist/src/telescope/dashboard.d.ts.map +1 -0
- package/dist/src/telescope/dashboard.js +113 -0
- package/dist/src/telescope/dashboard.js.map +1 -0
- package/dist/src/telescope/data-providers.d.ts +20 -0
- package/dist/src/telescope/data-providers.d.ts.map +1 -0
- package/dist/src/telescope/data-providers.js +322 -0
- package/dist/src/telescope/data-providers.js.map +1 -0
- package/dist/src/telescope/extension.d.ts +22 -0
- package/dist/src/telescope/extension.d.ts.map +1 -0
- package/dist/src/telescope/extension.js +38 -0
- package/dist/src/telescope/extension.js.map +1 -0
- package/dist/src/telescope/index.d.ts +5 -0
- package/dist/src/telescope/index.d.ts.map +1 -0
- package/dist/src/telescope/index.js +4 -0
- package/dist/src/telescope/index.js.map +1 -0
- package/dist/src/telescope/telescope-sdk.d.ts +123 -0
- package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
- package/dist/src/telescope/telescope-sdk.js +12 -0
- package/dist/src/telescope/telescope-sdk.js.map +1 -0
- package/dist/src/test-helpers.d.ts +11 -0
- package/dist/src/test-helpers.d.ts.map +1 -0
- package/dist/src/test-helpers.js +12 -0
- package/dist/src/test-helpers.js.map +1 -0
- package/dist/src/testing/in-memory-state-store.d.ts +64 -0
- package/dist/src/testing/in-memory-state-store.d.ts.map +1 -0
- package/dist/src/testing/in-memory-state-store.js +259 -0
- package/dist/src/testing/in-memory-state-store.js.map +1 -0
- package/dist/src/testing/in-memory-transport.d.ts +25 -0
- package/dist/src/testing/in-memory-transport.d.ts.map +1 -0
- package/dist/src/testing/in-memory-transport.js +49 -0
- package/dist/src/testing/in-memory-transport.js.map +1 -0
- package/dist/src/testing-kit/admission-backend-conformance.d.ts +18 -0
- package/dist/src/testing-kit/admission-backend-conformance.d.ts.map +1 -0
- package/dist/src/testing-kit/admission-backend-conformance.js +81 -0
- package/dist/src/testing-kit/admission-backend-conformance.js.map +1 -0
- package/dist/src/testing-kit/assertions.d.ts +10 -0
- package/dist/src/testing-kit/assertions.d.ts.map +1 -0
- package/dist/src/testing-kit/assertions.js +41 -0
- package/dist/src/testing-kit/assertions.js.map +1 -0
- package/dist/src/testing-kit/harness.d.ts +28 -0
- package/dist/src/testing-kit/harness.d.ts.map +1 -0
- package/dist/src/testing-kit/harness.js +42 -0
- package/dist/src/testing-kit/harness.js.map +1 -0
- package/dist/src/testing-kit/index.d.ts +8 -0
- package/dist/src/testing-kit/index.d.ts.map +1 -0
- package/dist/src/testing-kit/index.js +8 -0
- package/dist/src/testing-kit/index.js.map +1 -0
- package/dist/src/testing-kit/replay.d.ts +22 -0
- package/dist/src/testing-kit/replay.d.ts.map +1 -0
- package/dist/src/testing-kit/replay.js +38 -0
- package/dist/src/testing-kit/replay.js.map +1 -0
- package/dist/src/testing-kit/state-store-conformance.d.ts +51 -0
- package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -0
- package/dist/src/testing-kit/state-store-conformance.js +430 -0
- package/dist/src/testing-kit/state-store-conformance.js.map +1 -0
- package/dist/src/testing-kit/steps.d.ts +5 -0
- package/dist/src/testing-kit/steps.d.ts.map +1 -0
- package/dist/src/testing-kit/steps.js +15 -0
- package/dist/src/testing-kit/steps.js.map +1 -0
- package/dist/src/testing-kit/transport-conformance.d.ts +16 -0
- package/dist/src/testing-kit/transport-conformance.d.ts.map +1 -0
- package/dist/src/testing-kit/transport-conformance.js +64 -0
- package/dist/src/testing-kit/transport-conformance.js.map +1 -0
- package/dist/src/tokens.d.ts +18 -0
- package/dist/src/tokens.d.ts.map +1 -0
- package/dist/src/tokens.js +18 -0
- package/dist/src/tokens.js.map +1 -0
- package/dist/src/transport-pool.d.ts +30 -0
- package/dist/src/transport-pool.d.ts.map +1 -0
- package/dist/src/transport-pool.js +82 -0
- package/dist/src/transport-pool.js.map +1 -0
- package/dist/src/transports/db-helpers.d.ts +10 -0
- package/dist/src/transports/db-helpers.d.ts.map +1 -0
- package/dist/src/transports/db-helpers.js +33 -0
- package/dist/src/transports/db-helpers.js.map +1 -0
- package/dist/src/transports/db-schema.d.ts +28 -0
- package/dist/src/transports/db-schema.d.ts.map +1 -0
- package/dist/src/transports/db-schema.js +98 -0
- package/dist/src/transports/db-schema.js.map +1 -0
- package/dist/src/transports/db.d.ts +81 -0
- package/dist/src/transports/db.d.ts.map +1 -0
- package/dist/src/transports/db.js +340 -0
- package/dist/src/transports/db.js.map +1 -0
- package/dist/src/transports/factory.d.ts +79 -0
- package/dist/src/transports/factory.d.ts.map +1 -0
- package/dist/src/transports/factory.js +57 -0
- package/dist/src/transports/factory.js.map +1 -0
- package/dist/src/transports/queue-mock-adapter.d.ts +39 -0
- package/dist/src/transports/queue-mock-adapter.d.ts.map +1 -0
- package/dist/src/transports/queue-mock-adapter.js +86 -0
- package/dist/src/transports/queue-mock-adapter.js.map +1 -0
- package/dist/src/transports/queue.d.ts +84 -0
- package/dist/src/transports/queue.d.ts.map +1 -0
- package/dist/src/transports/queue.js +210 -0
- package/dist/src/transports/queue.js.map +1 -0
- package/dist/src/workflow-ctx.d.ts +64 -0
- package/dist/src/workflow-ctx.d.ts.map +1 -0
- package/dist/src/workflow-ctx.js +457 -0
- package/dist/src/workflow-ctx.js.map +1 -0
- package/dist/src/workflow-ref.d.ts +34 -0
- package/dist/src/workflow-ref.d.ts.map +1 -0
- package/dist/src/workflow-ref.js +28 -0
- package/dist/src/workflow-ref.js.map +1 -0
- package/dist/stubs/config/durable.stub +49 -0
- package/dist/stubs/config/durable_dashboard.stub +17 -0
- package/dist/stubs/database/migrations/create_durable_tables.stub +87 -0
- package/dist/stubs/database/migrations/create_durable_transport_tables.stub +75 -0
- package/dist/stubs/main.d.ts +3 -0
- package/dist/stubs/main.d.ts.map +1 -0
- package/dist/stubs/main.js +4 -0
- package/dist/stubs/main.js.map +1 -0
- package/package.json +154 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InMemoryStateStore, InMemoryTransport, type RunResult, type StartOptions, WorkflowEngine, type WorkflowRef } from '../index.js';
|
|
2
|
+
/** A clock you control, for testing durable sleeps without real time. */
|
|
3
|
+
export declare class MutableClock {
|
|
4
|
+
private current;
|
|
5
|
+
constructor(current?: number);
|
|
6
|
+
readonly now: () => number;
|
|
7
|
+
set(ms: number): void;
|
|
8
|
+
advance(ms: number): void;
|
|
9
|
+
}
|
|
10
|
+
export interface TestEngine {
|
|
11
|
+
engine: WorkflowEngine;
|
|
12
|
+
store: InMemoryStateStore;
|
|
13
|
+
transport: InMemoryTransport;
|
|
14
|
+
clock: MutableClock;
|
|
15
|
+
/** Advance the clock by `ms` and resume any durable sleeps now due. */
|
|
16
|
+
tick(ms: number): Promise<RunResult[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Enqueue a run and wait for it to settle (terminal or suspended). `engine.start` only enqueues
|
|
19
|
+
* now (dispatch model), so use this when a test needs the outcome synchronously.
|
|
20
|
+
*/
|
|
21
|
+
run(workflow: WorkflowRef, input: unknown, runId: string, opts?: StartOptions): Promise<RunResult>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A self-contained engine wired to in-memory store + transport and a controllable clock — run a
|
|
25
|
+
* whole workflow in a unit test, with no Postgres, no Redis, and no real time.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createTestEngine(): TestEngine;
|
|
28
|
+
//# sourceMappingURL=harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../../src/testing-kit/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAErB,yEAAyE;AACzE,qBAAa,YAAY;IACX,OAAO,CAAC,OAAO;gBAAP,OAAO,SAAQ;IACnC,QAAQ,CAAC,GAAG,QAAO,MAAM,CAAiB;IAC1C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAGrB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;CAG1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACvC;;;OAGG;IACH,GAAG,CACD,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,YAAY,GAClB,OAAO,CAAC,SAAS,CAAC,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAqB7C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InMemoryStateStore, InMemoryTransport, WorkflowEngine, } from '../index.js';
|
|
2
|
+
/** A clock you control, for testing durable sleeps without real time. */
|
|
3
|
+
export class MutableClock {
|
|
4
|
+
current;
|
|
5
|
+
constructor(current = 1_000) {
|
|
6
|
+
this.current = current;
|
|
7
|
+
}
|
|
8
|
+
now = () => this.current;
|
|
9
|
+
set(ms) {
|
|
10
|
+
this.current = ms;
|
|
11
|
+
}
|
|
12
|
+
advance(ms) {
|
|
13
|
+
this.current += ms;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A self-contained engine wired to in-memory store + transport and a controllable clock — run a
|
|
18
|
+
* whole workflow in a unit test, with no Postgres, no Redis, and no real time.
|
|
19
|
+
*/
|
|
20
|
+
export function createTestEngine() {
|
|
21
|
+
const store = new InMemoryStateStore();
|
|
22
|
+
const transport = new InMemoryTransport();
|
|
23
|
+
const clock = new MutableClock();
|
|
24
|
+
const engine = new WorkflowEngine({ store, transport, clock: clock.now });
|
|
25
|
+
return {
|
|
26
|
+
engine,
|
|
27
|
+
store,
|
|
28
|
+
transport,
|
|
29
|
+
clock,
|
|
30
|
+
async tick(ms) {
|
|
31
|
+
clock.advance(ms);
|
|
32
|
+
return engine.resumeDueTimers(clock.now());
|
|
33
|
+
},
|
|
34
|
+
async run(workflow, input, runId, opts) {
|
|
35
|
+
// `start` is overloaded per ref kind; a `WorkflowRef` union fits neither overload directly, so
|
|
36
|
+
// resolve to the string overload (the engine accepts a class or name at runtime).
|
|
37
|
+
await engine.start(workflow, input, runId, opts);
|
|
38
|
+
return engine.waitForRun(runId);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["../../../src/testing-kit/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAGjB,cAAc,GAEf,MAAM,aAAa,CAAC;AAErB,yEAAyE;AACzE,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,UAAU,KAAK;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAC9B,GAAG,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1C,GAAG,CAAC,EAAU;QACZ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IACD,OAAO,CAAC,EAAU;QAChB,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IACrB,CAAC;CACF;AAqBD;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1E,OAAO;QACL,MAAM;QACN,KAAK;QACL,SAAS;QACT,KAAK;QACL,KAAK,CAAC,IAAI,CAAC,EAAU;YACnB,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI;YACpC,+FAA+F;YAC/F,kFAAkF;YAClF,MAAM,MAAM,CAAC,KAAK,CAAC,QAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3D,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './admission-backend-conformance.js';
|
|
2
|
+
export * from './assertions.js';
|
|
3
|
+
export * from './harness.js';
|
|
4
|
+
export * from './replay.js';
|
|
5
|
+
export * from './state-store-conformance.js';
|
|
6
|
+
export * from './steps.js';
|
|
7
|
+
export * from './transport-conformance.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing-kit/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './admission-backend-conformance.js';
|
|
2
|
+
export * from './assertions.js';
|
|
3
|
+
export * from './harness.js';
|
|
4
|
+
export * from './replay.js';
|
|
5
|
+
export * from './state-store-conformance.js';
|
|
6
|
+
export * from './steps.js';
|
|
7
|
+
export * from './transport-conformance.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing-kit/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StepCheckpoint, WorkflowEngine, type WorkflowRun } from '../index.js';
|
|
2
|
+
export interface RunHistory {
|
|
3
|
+
run: WorkflowRun;
|
|
4
|
+
checkpoints: StepCheckpoint[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Replay a recorded run's history against the CURRENT workflow code and throw if they diverged.
|
|
8
|
+
*
|
|
9
|
+
* Capture a real (ideally in-flight or representative) run from production —
|
|
10
|
+
* `{ run: await store.getRun(id), checkpoints: await store.listCheckpoints(id) }` — commit it as a
|
|
11
|
+
* fixture, and assert here in CI. If a code change renamed/reordered/removed a step at a position the
|
|
12
|
+
* history already recorded, the engine raises a `NonDeterminismError` on replay and this rethrows it,
|
|
13
|
+
* catching the break *before* it reaches an in-flight run on deploy (the moment you'd otherwise
|
|
14
|
+
* silently replay the wrong checkpoint into the wrong step). Register the workflow exactly as the app
|
|
15
|
+
* does:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* await assertReplayable((engine) => engine.register('pipeline', '1', pipeline.run), fixture);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertReplayable(register: (engine: WorkflowEngine) => void, history: RunHistory): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/testing-kit/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,WAAW,CAAC;IACjB,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,EAC1C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InMemoryStateStore, WorkflowEngine, } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Replay a recorded run's history against the CURRENT workflow code and throw if they diverged.
|
|
4
|
+
*
|
|
5
|
+
* Capture a real (ideally in-flight or representative) run from production —
|
|
6
|
+
* `{ run: await store.getRun(id), checkpoints: await store.listCheckpoints(id) }` — commit it as a
|
|
7
|
+
* fixture, and assert here in CI. If a code change renamed/reordered/removed a step at a position the
|
|
8
|
+
* history already recorded, the engine raises a `NonDeterminismError` on replay and this rethrows it,
|
|
9
|
+
* catching the break *before* it reaches an in-flight run on deploy (the moment you'd otherwise
|
|
10
|
+
* silently replay the wrong checkpoint into the wrong step). Register the workflow exactly as the app
|
|
11
|
+
* does:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* await assertReplayable((engine) => engine.register('pipeline', '1', pipeline.run), fixture);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export async function assertReplayable(register, history) {
|
|
18
|
+
const store = new InMemoryStateStore();
|
|
19
|
+
// Seed as a suspended run with no lock so resume() replays the body against the recorded
|
|
20
|
+
// checkpoints — no transport is wired, so nothing new is dispatched.
|
|
21
|
+
await store.createRun({
|
|
22
|
+
...history.run,
|
|
23
|
+
status: 'suspended',
|
|
24
|
+
lockedBy: undefined,
|
|
25
|
+
lockedUntil: undefined,
|
|
26
|
+
});
|
|
27
|
+
for (const cp of history.checkpoints)
|
|
28
|
+
await store.saveCheckpoint(cp);
|
|
29
|
+
const engine = new WorkflowEngine({ store });
|
|
30
|
+
register(engine);
|
|
31
|
+
const result = await engine.resume(history.run.id);
|
|
32
|
+
if (result.status === 'failed' && result.error?.message?.startsWith('non-determinism')) {
|
|
33
|
+
const err = new Error(result.error.message);
|
|
34
|
+
err.name = 'NonDeterminismError';
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/testing-kit/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,cAAc,GAEf,MAAM,aAAa,CAAC;AAOrB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAA0C,EAC1C,OAAmB;IAEnB,MAAM,KAAK,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACvC,yFAAyF;IACzF,qEAAqE;IACrE,MAAM,KAAK,CAAC,SAAS,CAAC;QACpB,GAAG,OAAO,CAAC,GAAG;QACd,MAAM,EAAE,WAAW;QACnB,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,SAAS;KACvB,CAAC,CAAC;IACH,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,WAAW;QAAE,MAAM,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACvF,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5C,GAAG,CAAC,IAAI,GAAG,qBAAqB,CAAC;QACjC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type StateStore } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A freshly provisioned, empty {@link StateStore} plus a `cleanup` to release its resources (close
|
|
4
|
+
* the connection, drop the schema, etc.). The conformance suite asks for one before each test so
|
|
5
|
+
* every case starts from a clean slate — exactly like the per-store specs that build a `:memory:` DB.
|
|
6
|
+
*/
|
|
7
|
+
export interface StateStoreContext {
|
|
8
|
+
store: StateStore;
|
|
9
|
+
cleanup: () => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the store's optional `transaction` can run an ASYNC work callback. Defaults to `true`.
|
|
12
|
+
* Set `false` only for a driver that genuinely can't — e.g. Drizzle on the SYNCHRONOUS
|
|
13
|
+
* `better-sqlite3` driver, whose `transaction()` rejects a promise-returning callback ("Transaction
|
|
14
|
+
* function cannot return a promise"). The same Drizzle adapter on an async driver (libSQL) works,
|
|
15
|
+
* and the contract still asserts `transaction` for every other store, so this never hides drift.
|
|
16
|
+
*/
|
|
17
|
+
supportsAsyncTransaction?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the store can filter `listRuns({ tag })`. Defaults to `true`. Set `false` ONLY for
|
|
20
|
+
* Prisma-on-SQLite: the Prisma adapter filters tags with the `array_contains` JSON predicate, which
|
|
21
|
+
* Prisma supports on its real targets (Postgres + MySQL) but NOT on SQLite. SQLite is only the
|
|
22
|
+
* adapter's local TEST database, so the tag case is skipped there; every other store (and Prisma on
|
|
23
|
+
* a real engine) still asserts it, so this doesn't hide drift in the supported configurations.
|
|
24
|
+
*/
|
|
25
|
+
supportsTagFilter?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Builds a fresh, empty store for one test. Called once per `it` (in `beforeEach`). */
|
|
28
|
+
export type StateStoreFactory = () => Promise<StateStoreContext>;
|
|
29
|
+
/**
|
|
30
|
+
* Thrown by a {@link StateStoreFactory} to SKIP the contract for an unavailable backend instead of
|
|
31
|
+
* failing it — e.g. a testcontainers DB spec when Docker isn't running. Every contract case catches
|
|
32
|
+
* it, logs once, and returns (a no-op pass), so `pnpm test:db` is green-with-skips off a dev box
|
|
33
|
+
* without Docker rather than red.
|
|
34
|
+
*/
|
|
35
|
+
export declare class StateStoreUnavailableError extends Error {
|
|
36
|
+
readonly isStateStoreUnavailable = true;
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The SHARED behavioral contract every `StateStore` must satisfy — in-memory and each ORM adapter
|
|
41
|
+
* alike. Registered as a vitest `describe`; pass a `name` and a {@link StateStoreFactory} that builds
|
|
42
|
+
* a fresh, empty store. The same assertions run against SQLite/in-memory under `pnpm test` and
|
|
43
|
+
* against real Postgres/MySQL (via testcontainers) under `pnpm test:db`, so any drift between an
|
|
44
|
+
* adapter and the canonical (in-memory) semantics — especially the search-attribute side-table
|
|
45
|
+
* pushdown, which is implemented per-store — fails here instead of silently in production.
|
|
46
|
+
*
|
|
47
|
+
* Each adapter's own spec keeps its dialect-specific tests (DDL/longtext/EXISTS-SQL/JSON-tolerance);
|
|
48
|
+
* this suite owns the cross-store behavior so those never drift apart.
|
|
49
|
+
*/
|
|
50
|
+
export declare function runStateStoreContract(name: string, makeStore: StateStoreFactory): void;
|
|
51
|
+
//# sourceMappingURL=state-store-conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-store-conformance.d.ts","sourceRoot":"","sources":["../../../src/testing-kit/state-store-conformance.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EAIhB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,uBAAuB,QAAQ;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAkCD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAoftF"}
|