@dudousxd/nestjs-durable 0.4.0 → 0.5.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/decorators.d.ts +38 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +36 -2
- package/dist/decorators.js.map +1 -1
- package/dist/durable.module.d.ts +9 -6
- package/dist/durable.module.d.ts.map +1 -1
- package/dist/durable.module.js +2 -15
- package/dist/durable.module.js.map +1 -1
- package/dist/workflow.registrar.d.ts +11 -2
- package/dist/workflow.registrar.d.ts.map +1 -1
- package/dist/workflow.registrar.js +58 -3
- package/dist/workflow.registrar.js.map +1 -1
- package/dist/workflow.service.d.ts +7 -1
- package/dist/workflow.service.d.ts.map +1 -1
- package/dist/workflow.service.js.map +1 -1
- package/package.json +2 -2
package/dist/decorators.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
import { type StepError, type WorkflowRef } from '@dudousxd/nestjs-durable-core';
|
|
1
2
|
import 'reflect-metadata';
|
|
2
3
|
export declare const WORKFLOW_METADATA: unique symbol;
|
|
3
4
|
export interface WorkflowMeta {
|
|
4
5
|
name: string;
|
|
5
6
|
version: string;
|
|
7
|
+
/** The workflow this workflow's dead runs route to (a name or a class). See `WorkflowOptions`. */
|
|
8
|
+
deadLetterWorkflow?: WorkflowRef;
|
|
6
9
|
}
|
|
7
10
|
export interface WorkflowOptions {
|
|
8
11
|
name: string;
|
|
9
12
|
version?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Route this workflow's dead-lettered runs to another **registered** workflow — by class
|
|
15
|
+
* (`deadLetterWorkflow: CheckoutDlqWorkflow`, refactor-safe) or by name for a cross-runtime
|
|
16
|
+
* handler. For a handler co-located on the same class, prefer an inline `@DeadLetter()` method
|
|
17
|
+
* instead — it takes precedence, and declaring both is a boot-time error. The handler receives a
|
|
18
|
+
* {@link DeadLetter} payload, idempotent by a `dlq:<runId>` id.
|
|
19
|
+
*/
|
|
20
|
+
deadLetterWorkflow?: WorkflowRef;
|
|
10
21
|
}
|
|
11
22
|
/**
|
|
12
23
|
* Marks a provider class as a durable workflow. Its `run(ctx, input)` method becomes the
|
|
@@ -25,4 +36,31 @@ export interface DurableStepMeta {
|
|
|
25
36
|
*/
|
|
26
37
|
export declare function DurableStep(name: string): MethodDecorator;
|
|
27
38
|
export declare function getDurableStepMeta(method: Function): DurableStepMeta | undefined;
|
|
39
|
+
export declare const DEAD_LETTER_METADATA: unique symbol;
|
|
40
|
+
/**
|
|
41
|
+
* The payload a dead-letter handler receives: the dead run's id, its workflow, the input it was
|
|
42
|
+
* started with (typed via `TInput`), and the failure that killed it.
|
|
43
|
+
*/
|
|
44
|
+
export interface DeadLetter<TInput = unknown> {
|
|
45
|
+
/** Id of the run that was dead-lettered (inspectable + retriable in the dashboard). */
|
|
46
|
+
deadRunId: string;
|
|
47
|
+
/** Name of the workflow whose run died. */
|
|
48
|
+
workflow: string;
|
|
49
|
+
/** The original input the dead run was started with. */
|
|
50
|
+
input: TInput;
|
|
51
|
+
/** The structured error that moved the run to `dead`, when known. */
|
|
52
|
+
error?: StepError;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Marks a method on a `@Workflow` class as that workflow's **inline dead-letter handler**. When a
|
|
56
|
+
* run of the workflow is moved to `dead` (exceeded `maxRecoveryAttempts`), this method runs — as a
|
|
57
|
+
* durable workflow itself, auto-registered as `<workflow>.dlq` with a `dlq:<runId>` id — receiving a
|
|
58
|
+
* {@link DeadLetter} payload. It shares the class's injected dependencies, so the handler lives in
|
|
59
|
+
* the same file as the workflow it protects.
|
|
60
|
+
*
|
|
61
|
+
* Takes precedence over `@Workflow({ deadLetterWorkflow })` and the module-level `deadLetterWorkflow`
|
|
62
|
+
* default. The method signature is `(ctx, dead)` — the same `ctx` a workflow `run` gets.
|
|
63
|
+
*/
|
|
64
|
+
export declare function DeadLetter(): MethodDecorator;
|
|
65
|
+
export declare function isDeadLetterHandler(method: Function): boolean;
|
|
28
66
|
//# sourceMappingURL=decorators.d.ts.map
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB,eAAoC,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB,eAAoC,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,WAAW,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAejE;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAE1E;AAED,eAAO,MAAM,qBAAqB,eAAwC,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAMzD;AAGD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe,GAAG,SAAS,CAEhF;AAED,eAAO,MAAM,oBAAoB,eAAuC,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,GAAG,OAAO;IAC1C,uFAAuF;IACvF,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,IAAI,eAAe,CAK5C;AAGD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAE7D"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DURABLE_STEP_METADATA = exports.WORKFLOW_METADATA = void 0;
|
|
3
|
+
exports.DEAD_LETTER_METADATA = exports.DURABLE_STEP_METADATA = exports.WORKFLOW_METADATA = void 0;
|
|
4
4
|
exports.Workflow = Workflow;
|
|
5
5
|
exports.getWorkflowMeta = getWorkflowMeta;
|
|
6
6
|
exports.DurableStep = DurableStep;
|
|
7
7
|
exports.getDurableStepMeta = getDurableStepMeta;
|
|
8
|
+
exports.DeadLetter = DeadLetter;
|
|
9
|
+
exports.isDeadLetterHandler = isDeadLetterHandler;
|
|
10
|
+
const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
|
|
8
11
|
require("reflect-metadata");
|
|
9
12
|
exports.WORKFLOW_METADATA = Symbol('nestjs-durable:workflow');
|
|
10
13
|
/**
|
|
@@ -13,8 +16,18 @@ exports.WORKFLOW_METADATA = Symbol('nestjs-durable:workflow');
|
|
|
13
16
|
*/
|
|
14
17
|
function Workflow(options) {
|
|
15
18
|
return (target) => {
|
|
16
|
-
const meta = {
|
|
19
|
+
const meta = {
|
|
20
|
+
name: options.name,
|
|
21
|
+
version: options.version ?? '1',
|
|
22
|
+
deadLetterWorkflow: options.deadLetterWorkflow,
|
|
23
|
+
};
|
|
17
24
|
Reflect.defineMetadata(exports.WORKFLOW_METADATA, meta, target);
|
|
25
|
+
// Stamp the registered name so this class can be used as a typed workflow ref (ctx.child,
|
|
26
|
+
// engine.start, deadLetterWorkflow) and resolved back to its name via `workflowName`.
|
|
27
|
+
Object.defineProperty(target, nestjs_durable_core_1.WORKFLOW_NAME_KEY, {
|
|
28
|
+
value: options.name,
|
|
29
|
+
configurable: true,
|
|
30
|
+
});
|
|
18
31
|
};
|
|
19
32
|
}
|
|
20
33
|
// biome-ignore lint/complexity/noBannedTypes: matches reflect-metadata's class target type
|
|
@@ -38,4 +51,25 @@ function DurableStep(name) {
|
|
|
38
51
|
function getDurableStepMeta(method) {
|
|
39
52
|
return Reflect.getMetadata(exports.DURABLE_STEP_METADATA, method);
|
|
40
53
|
}
|
|
54
|
+
exports.DEAD_LETTER_METADATA = Symbol('nestjs-durable:dead-letter');
|
|
55
|
+
/**
|
|
56
|
+
* Marks a method on a `@Workflow` class as that workflow's **inline dead-letter handler**. When a
|
|
57
|
+
* run of the workflow is moved to `dead` (exceeded `maxRecoveryAttempts`), this method runs — as a
|
|
58
|
+
* durable workflow itself, auto-registered as `<workflow>.dlq` with a `dlq:<runId>` id — receiving a
|
|
59
|
+
* {@link DeadLetter} payload. It shares the class's injected dependencies, so the handler lives in
|
|
60
|
+
* the same file as the workflow it protects.
|
|
61
|
+
*
|
|
62
|
+
* Takes precedence over `@Workflow({ deadLetterWorkflow })` and the module-level `deadLetterWorkflow`
|
|
63
|
+
* default. The method signature is `(ctx, dead)` — the same `ctx` a workflow `run` gets.
|
|
64
|
+
*/
|
|
65
|
+
function DeadLetter() {
|
|
66
|
+
return (_target, _propertyKey, descriptor) => {
|
|
67
|
+
Reflect.defineMetadata(exports.DEAD_LETTER_METADATA, true, descriptor.value);
|
|
68
|
+
return descriptor;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// biome-ignore lint/complexity/noBannedTypes: reflect-metadata reads from the method function
|
|
72
|
+
function isDeadLetterHandler(method) {
|
|
73
|
+
return Reflect.getMetadata(exports.DEAD_LETTER_METADATA, method) === true;
|
|
74
|
+
}
|
|
41
75
|
//# sourceMappingURL=decorators.js.map
|
package/dist/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AA6BA,4BAeC;AAGD,0CAEC;AAaD,kCAMC;AAGD,gDAEC;AA6BD,gCAKC;AAGD,kDAEC;AAhHD,uEAAoG;AACpG,4BAA0B;AAEb,QAAA,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAsBnE;;;GAGG;AACH,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,IAAI,GAAiB;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG;YAC/B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;SAC/C,CAAC;QACF,OAAO,CAAC,cAAc,CAAC,yBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACxD,0FAA0F;QAC1F,sFAAsF;QACtF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,uCAAiB,EAAE;YAC/C,KAAK,EAAE,OAAO,CAAC,IAAI;YACnB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,SAAgB,eAAe,CAAC,MAAgB;IAC9C,OAAO,OAAO,CAAC,WAAW,CAAC,yBAAiB,EAAE,MAAM,CAA6B,CAAC;AACpF,CAAC;AAEY,QAAA,qBAAqB,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAM3E;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAA8B,EAAE,EAAE;QAC/D,MAAM,IAAI,GAAoB,EAAE,IAAI,EAAE,CAAC;QACvC,OAAO,CAAC,cAAc,CAAC,6BAAqB,EAAE,IAAI,EAAE,UAAU,CAAC,KAAe,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED,8FAA8F;AAC9F,SAAgB,kBAAkB,CAAC,MAAgB;IACjD,OAAO,OAAO,CAAC,WAAW,CAAC,6BAAqB,EAAE,MAAM,CAAgC,CAAC;AAC3F,CAAC;AAEY,QAAA,oBAAoB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAiBzE;;;;;;;;;GASG;AACH,SAAgB,UAAU;IACxB,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAA8B,EAAE,EAAE;QAC/D,OAAO,CAAC,cAAc,CAAC,4BAAoB,EAAE,IAAI,EAAE,UAAU,CAAC,KAAe,CAAC,CAAC;QAC/E,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED,8FAA8F;AAC9F,SAAgB,mBAAmB,CAAC,MAAgB;IAClD,OAAO,OAAO,CAAC,WAAW,CAAC,4BAAoB,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AACpE,CAAC"}
|
package/dist/durable.module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ControlPlane, type NamedTransport, type QueueConfig, type ScheduledWorkflow, type StateStore, type Transport } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { type ControlPlane, type NamedTransport, type QueueConfig, type ScheduledWorkflow, type StateStore, type Transport, type WorkflowRef } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
import { type DynamicModule, type InjectionToken } from '@nestjs/common';
|
|
3
3
|
export interface DurableModuleOptions {
|
|
4
4
|
store: StateStore;
|
|
@@ -34,12 +34,15 @@ export interface DurableModuleOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
maxRecoveryAttempts?: number;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* (idempotent by a `dlq:<runId>` id) —
|
|
40
|
-
*
|
|
37
|
+
* The **default** workflow to route dead-lettered runs to, for workflows that don't declare their
|
|
38
|
+
* own. When a run is moved to `dead` (exceeded `maxRecoveryAttempts`), the started handler gets a
|
|
39
|
+
* `DeadLetter` payload `{ deadRunId, workflow, input, error }` (idempotent by a `dlq:<runId>` id) —
|
|
40
|
+
* it can alert, compensate, or queue for review. Resolution per dead run: the workflow's inline
|
|
41
|
+
* `@DeadLetter()` method → its `@Workflow({ deadLetterWorkflow })` reference → this default. Omit
|
|
42
|
+
* everything to just leave dead runs parked (inspectable + retriable from the dashboard). Accepts a
|
|
43
|
+
* workflow class (refactor-safe) or a name (cross-runtime).
|
|
41
44
|
*/
|
|
42
|
-
deadLetterWorkflow?:
|
|
45
|
+
deadLetterWorkflow?: WorkflowRef;
|
|
43
46
|
/**
|
|
44
47
|
* Whether this instance plays the **worker** role: register `@DurableStep` handlers (consume the
|
|
45
48
|
* transport), recover incomplete runs on boot, and poll due timers. Defaults to `true`. Set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable.module.d.ts","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"durable.module.d.ts","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,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,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,qBACa,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa;IAI5D,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,yBAAyB,GAAG,aAAa;IAQtE,OAAO,CAAC,MAAM,CAAC,KAAK;CAsDrB"}
|
package/dist/durable.module.js
CHANGED
|
@@ -69,21 +69,8 @@ let DurableModule = DurableModule_1 = class DurableModule {
|
|
|
69
69
|
});
|
|
70
70
|
for (const queue of opts.queues ?? [])
|
|
71
71
|
engine.registerQueue(queue);
|
|
72
|
-
// Dead-letter routing
|
|
73
|
-
//
|
|
74
|
-
const dlq = opts.deadLetterWorkflow;
|
|
75
|
-
if (dlq) {
|
|
76
|
-
engine.onDead((run) => {
|
|
77
|
-
void engine
|
|
78
|
-
.start(dlq, {
|
|
79
|
-
deadRunId: run.id,
|
|
80
|
-
workflow: run.workflow,
|
|
81
|
-
input: run.input,
|
|
82
|
-
error: run.error,
|
|
83
|
-
}, `dlq:${run.id}`)
|
|
84
|
-
.catch(() => undefined);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
72
|
+
// Dead-letter routing (per-workflow `@DeadLetter()` / `deadLetterWorkflow` + this global
|
|
73
|
+
// default) is wired by the WorkflowRegistrar, which owns the `@Workflow` metadata.
|
|
87
74
|
return engine;
|
|
88
75
|
},
|
|
89
76
|
inject: [nestjs_durable_core_1.STATE_STORE, nestjs_durable_core_1.TRANSPORT, nestjs_durable_core_1.DURABLE_OPTIONS],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable.module.js","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"durable.module.js","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uEAYuC;AACvC,2CAAgG;AAChG,uCAA+C;AAC/C,qEAAgE;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|
2
2
|
import { type OnApplicationBootstrap, type OnApplicationShutdown, type OnModuleInit } from '@nestjs/common';
|
|
3
|
-
import { DiscoveryService } from '@nestjs/core';
|
|
3
|
+
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
4
4
|
import type { DurableModuleOptions } from './durable.module';
|
|
5
5
|
/**
|
|
6
6
|
* Ensures the schema (auto-schema) and registers `@Workflow` providers on init, resumes runs left
|
|
@@ -10,13 +10,22 @@ import type { DurableModuleOptions } from './durable.module';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class WorkflowRegistrar implements OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown {
|
|
12
12
|
private readonly discovery;
|
|
13
|
+
private readonly metadataScanner;
|
|
13
14
|
private readonly engine;
|
|
14
15
|
private readonly store;
|
|
15
16
|
private readonly options;
|
|
16
|
-
constructor(discovery: DiscoveryService, engine: WorkflowEngine, store: StateStore, options: DurableModuleOptions);
|
|
17
|
+
constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, engine: WorkflowEngine, store: StateStore, options: DurableModuleOptions);
|
|
17
18
|
onApplicationBootstrap(): Promise<void>;
|
|
18
19
|
/** On deploy/shutdown: stop picking up new runs and wait for in-flight ones to settle. */
|
|
19
20
|
onApplicationShutdown(): Promise<void>;
|
|
20
21
|
onModuleInit(): Promise<void>;
|
|
22
|
+
/** Returns the instance's `@DeadLetter()` method bound to the instance, or undefined if none. */
|
|
23
|
+
private findDeadLetterHandler;
|
|
24
|
+
/**
|
|
25
|
+
* Installs a single onDead listener that routes a dead run to its workflow's handler (from the
|
|
26
|
+
* map) or the module-level `deadLetterWorkflow` default. The handler is started idempotently with
|
|
27
|
+
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
28
|
+
*/
|
|
29
|
+
private installDeadLetterRouting;
|
|
21
30
|
}
|
|
22
31
|
//# sourceMappingURL=workflow.registrar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.registrar.d.ts","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,cAAc,
|
|
1
|
+
{"version":3,"file":"workflow.registrar.d.ts","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,cAAc,EAGf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAQ7D;;;;;GAKG;AACH,qBACa,iBACX,YAAW,YAAY,EAAE,sBAAsB,EAAE,qBAAqB;IAGpE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACF,OAAO,CAAC,QAAQ,CAAC,KAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAJhC,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,cAAc,EACD,KAAK,EAAE,UAAU,EACb,OAAO,EAAE,oBAAoB;IAGnE,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7C,0FAA0F;IACpF,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CnC,iGAAiG;IACjG,OAAO,CAAC,qBAAqB;IAW7B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAiBjC"}
|
|
@@ -25,11 +25,13 @@ const decorators_1 = require("./decorators");
|
|
|
25
25
|
*/
|
|
26
26
|
let WorkflowRegistrar = class WorkflowRegistrar {
|
|
27
27
|
discovery;
|
|
28
|
+
metadataScanner;
|
|
28
29
|
engine;
|
|
29
30
|
store;
|
|
30
31
|
options;
|
|
31
|
-
constructor(discovery, engine, store, options) {
|
|
32
|
+
constructor(discovery, metadataScanner, engine, store, options) {
|
|
32
33
|
this.discovery = discovery;
|
|
34
|
+
this.metadataScanner = metadataScanner;
|
|
33
35
|
this.engine = engine;
|
|
34
36
|
this.store = store;
|
|
35
37
|
this.options = options;
|
|
@@ -49,6 +51,10 @@ let WorkflowRegistrar = class WorkflowRegistrar {
|
|
|
49
51
|
if (this.options.autoSchema !== false) {
|
|
50
52
|
await this.store.ensureSchema?.();
|
|
51
53
|
}
|
|
54
|
+
// Maps a workflow name to the workflow its dead runs route to. Built from each `@Workflow`'s
|
|
55
|
+
// inline `@DeadLetter()` method (preferred) or its `deadLetterWorkflow` reference; the
|
|
56
|
+
// module-level `deadLetterWorkflow` is the fallback applied in the onDead listener below.
|
|
57
|
+
const deadLetterByWorkflow = new Map();
|
|
52
58
|
for (const wrapper of this.discovery.getProviders()) {
|
|
53
59
|
const { instance } = wrapper;
|
|
54
60
|
if (!instance || typeof instance !== 'object')
|
|
@@ -61,15 +67,64 @@ let WorkflowRegistrar = class WorkflowRegistrar {
|
|
|
61
67
|
throw new Error(`@Workflow ${meta.name} must define a run(ctx, input) method`);
|
|
62
68
|
}
|
|
63
69
|
this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input));
|
|
70
|
+
const inline = this.findDeadLetterHandler(instance);
|
|
71
|
+
if (inline && meta.deadLetterWorkflow) {
|
|
72
|
+
// Two dead-letter targets for one workflow is ambiguous config, not a precedence question —
|
|
73
|
+
// fail fast at boot rather than silently picking one.
|
|
74
|
+
throw new Error(`@Workflow ${meta.name} declares both an inline @DeadLetter() method and a deadLetterWorkflow option. Use one: the inline handler, or the reference.`);
|
|
75
|
+
}
|
|
76
|
+
if (inline) {
|
|
77
|
+
// The inline handler is itself a durable workflow, registered as `<name>.dlq`, so it gets
|
|
78
|
+
// checkpointing and a dashboard run linked to the dead run via the `dlq:<runId>` id.
|
|
79
|
+
const dlqName = `${meta.name}.dlq`;
|
|
80
|
+
this.engine.register(dlqName, meta.version, inline);
|
|
81
|
+
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
82
|
+
}
|
|
83
|
+
else if (meta.deadLetterWorkflow) {
|
|
84
|
+
deadLetterByWorkflow.set(meta.name, (0, nestjs_durable_core_1.workflowName)(meta.deadLetterWorkflow));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.installDeadLetterRouting(deadLetterByWorkflow);
|
|
88
|
+
}
|
|
89
|
+
/** Returns the instance's `@DeadLetter()` method bound to the instance, or undefined if none. */
|
|
90
|
+
findDeadLetterHandler(instance) {
|
|
91
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
92
|
+
for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {
|
|
93
|
+
const method = instance[methodName];
|
|
94
|
+
if (typeof method === 'function' && (0, decorators_1.isDeadLetterHandler)(method)) {
|
|
95
|
+
return (ctx, input) => method.call(instance, ctx, input);
|
|
96
|
+
}
|
|
64
97
|
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Installs a single onDead listener that routes a dead run to its workflow's handler (from the
|
|
102
|
+
* map) or the module-level `deadLetterWorkflow` default. The handler is started idempotently with
|
|
103
|
+
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
104
|
+
*/
|
|
105
|
+
installDeadLetterRouting(byWorkflow) {
|
|
106
|
+
const fallback = this.options.deadLetterWorkflow
|
|
107
|
+
? (0, nestjs_durable_core_1.workflowName)(this.options.deadLetterWorkflow)
|
|
108
|
+
: undefined;
|
|
109
|
+
if (byWorkflow.size === 0 && !fallback)
|
|
110
|
+
return;
|
|
111
|
+
this.engine.onDead((run) => {
|
|
112
|
+
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
113
|
+
if (!target)
|
|
114
|
+
return;
|
|
115
|
+
void this.engine
|
|
116
|
+
.start(target, { deadRunId: run.id, workflow: run.workflow, input: run.input, error: run.error }, `dlq:${run.id}`)
|
|
117
|
+
.catch(() => undefined);
|
|
118
|
+
});
|
|
65
119
|
}
|
|
66
120
|
};
|
|
67
121
|
exports.WorkflowRegistrar = WorkflowRegistrar;
|
|
68
122
|
exports.WorkflowRegistrar = WorkflowRegistrar = __decorate([
|
|
69
123
|
(0, common_1.Injectable)(),
|
|
70
|
-
__param(
|
|
71
|
-
__param(
|
|
124
|
+
__param(3, (0, common_1.Inject)(nestjs_durable_core_1.STATE_STORE)),
|
|
125
|
+
__param(4, (0, common_1.Inject)(nestjs_durable_core_1.DURABLE_OPTIONS)),
|
|
72
126
|
__metadata("design:paramtypes", [core_1.DiscoveryService,
|
|
127
|
+
core_1.MetadataScanner,
|
|
73
128
|
nestjs_durable_core_1.WorkflowEngine, Object, Object])
|
|
74
129
|
], WorkflowRegistrar);
|
|
75
130
|
//# sourceMappingURL=workflow.registrar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.registrar.js","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"workflow.registrar.js","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAQuC;AACvC,2CAMwB;AACxB,uCAAiE;AACjE,6CAAoE;AASpE;;;;;GAKG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAIT;IACA;IACA;IACqB;IACI;IAL5C,YACmB,SAA2B,EAC3B,eAAgC,EAChC,MAAsB,EACD,KAAiB,EACb,OAA6B;QAJtD,cAAS,GAAT,SAAS,CAAkB;QAC3B,oBAAe,GAAf,eAAe,CAAiB;QAChC,WAAM,GAAN,MAAM,CAAgB;QACD,UAAK,GAAL,KAAK,CAAY;QACb,YAAO,GAAP,OAAO,CAAsB;IACtE,CAAC;IAEJ,KAAK,CAAC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
1
|
-
import { type RunResult, WorkflowEngine } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { type RunResult, type WorkflowClass, WorkflowEngine, type WorkflowInputOf } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
/** Public entry point for starting and resuming workflow runs. */
|
|
3
3
|
export declare class WorkflowService {
|
|
4
4
|
private readonly engine;
|
|
5
5
|
constructor(engine: WorkflowEngine);
|
|
6
|
+
/**
|
|
7
|
+
* Start a workflow run. Pass the workflow's **class** (`start(CheckoutWorkflow, input)`) for a typed
|
|
8
|
+
* input + refactor-safety, or a **name** string for a cross-runtime workflow. `runId` defaults to a
|
|
9
|
+
* random id; pass your own to make the start idempotent (a redelivery returns the existing run).
|
|
10
|
+
*/
|
|
11
|
+
start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string): Promise<RunResult>;
|
|
6
12
|
start(workflow: string, input: unknown, runId?: string): Promise<RunResult>;
|
|
7
13
|
resume(runId: string): Promise<RunResult>;
|
|
8
14
|
/** Deliver an external signal (e.g. from a webhook) to the run waiting on `token`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.service.d.ts","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"workflow.service.d.ts","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,cAAc,EACd,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAGvC,kEAAkE;AAClE,qBACa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,cAAc;IAEnD;;;;OAIG;IACH,KAAK,CAAC,CAAC,SAAS,aAAa,EAC3B,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,CAAC;IACrB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAK3E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIzC,sFAAsF;IACtF,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;CAGnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.service.js","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"workflow.service.js","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AACzC,uEAKuC;AACvC,2CAA4C;AAE5C,kEAAkE;AAE3D,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAavD,KAAK,CAAC,QAAgB,EAAE,KAAc,EAAE,QAAgB,IAAA,wBAAU,GAAE;QAClE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAa,EAAE,OAAgB;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AA1BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAE0B,oCAAc;GADxC,eAAe,CA0B3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-durable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Durable workflows for NestJS — module, decorators, discovery and boot recovery",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"rxjs": "7.8.2",
|
|
32
32
|
"typescript": "5.9.3",
|
|
33
33
|
"zod": "3.25.76",
|
|
34
|
-
"@dudousxd/nestjs-durable-core": "^0.
|
|
34
|
+
"@dudousxd/nestjs-durable-core": "^0.8.0",
|
|
35
35
|
"@dudousxd/nestjs-durable-transport-event-emitter": "^0.4.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|