@dudousxd/nestjs-durable-testing 0.1.1 → 0.2.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/replay.d.ts +22 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +41 -0
- package/dist/replay.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./assertions"), exports);
|
|
18
18
|
__exportStar(require("./harness"), exports);
|
|
19
|
+
__exportStar(require("./replay"), exports);
|
|
19
20
|
__exportStar(require("./steps"), exports);
|
|
20
21
|
__exportStar(require("./transport-conformance"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,0DAAwC"}
|
package/dist/replay.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StepCheckpoint, WorkflowEngine, type WorkflowRun } from '@dudousxd/nestjs-durable-core';
|
|
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/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AAEvC,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"}
|
package/dist/replay.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertReplayable = assertReplayable;
|
|
4
|
+
const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
|
|
5
|
+
/**
|
|
6
|
+
* Replay a recorded run's history against the CURRENT workflow code and throw if they diverged.
|
|
7
|
+
*
|
|
8
|
+
* Capture a real (ideally in-flight or representative) run from production —
|
|
9
|
+
* `{ run: await store.getRun(id), checkpoints: await store.listCheckpoints(id) }` — commit it as a
|
|
10
|
+
* fixture, and assert here in CI. If a code change renamed/reordered/removed a step at a position the
|
|
11
|
+
* history already recorded, the engine raises a `NonDeterminismError` on replay and this rethrows it,
|
|
12
|
+
* catching the break *before* it reaches an in-flight run on deploy (the moment you'd otherwise
|
|
13
|
+
* silently replay the wrong checkpoint into the wrong step). Register the workflow exactly as the app
|
|
14
|
+
* does:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* await assertReplayable((engine) => engine.register('pipeline', '1', pipeline.run), fixture);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async function assertReplayable(register, history) {
|
|
21
|
+
const store = new nestjs_durable_core_1.InMemoryStateStore();
|
|
22
|
+
// Seed as a suspended run with no lock so resume() replays the body against the recorded
|
|
23
|
+
// checkpoints — no transport is wired, so nothing new is dispatched.
|
|
24
|
+
await store.createRun({
|
|
25
|
+
...history.run,
|
|
26
|
+
status: 'suspended',
|
|
27
|
+
lockedBy: undefined,
|
|
28
|
+
lockedUntil: undefined,
|
|
29
|
+
});
|
|
30
|
+
for (const cp of history.checkpoints)
|
|
31
|
+
await store.saveCheckpoint(cp);
|
|
32
|
+
const engine = new nestjs_durable_core_1.WorkflowEngine({ store });
|
|
33
|
+
register(engine);
|
|
34
|
+
const result = await engine.resume(history.run.id);
|
|
35
|
+
if (result.status === 'failed' && result.error?.message?.startsWith('non-determinism')) {
|
|
36
|
+
const err = new Error(result.error.message);
|
|
37
|
+
err.name = 'NonDeterminismError';
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":";;AA2BA,4CAuBC;AAlDD,uEAKuC;AAOvC;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,gBAAgB,CACpC,QAA0C,EAC1C,OAAmB;IAEnB,MAAM,KAAK,GAAG,IAAI,wCAAkB,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,oCAAc,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-durable-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Testing utilities for nestjs-durable — a test engine harness, crash/flaky-step injection, and replay assertions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"typescript": "5.9.3",
|
|
23
|
-
"@dudousxd/nestjs-durable-core": "^0.
|
|
23
|
+
"@dudousxd/nestjs-durable-core": "^0.4.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc -p tsconfig.json",
|