nestjs-serverless-workflow 0.1.0 → 0.1.3
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/README.md +43 -5
- package/dist/adapter/base-workflow.adapter.d.ts +38 -0
- package/dist/adapter/base-workflow.adapter.d.ts.map +1 -0
- package/dist/adapter/base-workflow.adapter.js +42 -0
- package/dist/adapter/base-workflow.adapter.js.map +1 -0
- package/dist/adapter/durable-lambda.adapter.d.ts +1 -5
- package/dist/adapter/durable-lambda.adapter.d.ts.map +1 -1
- package/dist/adapter/durable-lambda.adapter.js +81 -77
- package/dist/adapter/durable-lambda.adapter.js.map +1 -1
- package/dist/adapter/index.d.ts +1 -0
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +1 -0
- package/dist/adapter/index.js.map +1 -1
- package/dist/core/decorators/default.decorator.d.ts +17 -0
- package/dist/core/decorators/default.decorator.d.ts.map +1 -1
- package/dist/core/decorators/default.decorator.js +17 -0
- package/dist/core/decorators/default.decorator.js.map +1 -1
- package/dist/core/decorators/event.decorator.d.ts +18 -0
- package/dist/core/decorators/event.decorator.d.ts.map +1 -1
- package/dist/core/decorators/event.decorator.js +18 -0
- package/dist/core/decorators/event.decorator.js.map +1 -1
- package/dist/core/decorators/params.decorator.d.ts +27 -0
- package/dist/core/decorators/params.decorator.d.ts.map +1 -1
- package/dist/core/decorators/params.decorator.js +27 -0
- package/dist/core/decorators/params.decorator.js.map +1 -1
- package/dist/core/decorators/with-retry.decorator.d.ts +27 -0
- package/dist/core/decorators/with-retry.decorator.d.ts.map +1 -1
- package/dist/core/decorators/with-retry.decorator.js +28 -0
- package/dist/core/decorators/with-retry.decorator.js.map +1 -1
- package/dist/core/decorators/workflow.decorator.d.ts +29 -0
- package/dist/core/decorators/workflow.decorator.d.ts.map +1 -1
- package/dist/core/decorators/workflow.decorator.js +29 -0
- package/dist/core/decorators/workflow.decorator.js.map +1 -1
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/providers/orchestrator.service.d.ts +23 -0
- package/dist/core/providers/orchestrator.service.d.ts.map +1 -1
- package/dist/core/providers/orchestrator.service.js +23 -0
- package/dist/core/providers/orchestrator.service.js.map +1 -1
- package/dist/core/providers/router.factory.d.ts +8 -0
- package/dist/core/providers/router.factory.d.ts.map +1 -1
- package/dist/core/providers/router.factory.js +8 -0
- package/dist/core/providers/router.factory.js.map +1 -1
- package/dist/core/providers/router.service.d.ts +28 -0
- package/dist/core/providers/router.service.d.ts.map +1 -1
- package/dist/core/providers/router.service.js +28 -0
- package/dist/core/providers/router.service.js.map +1 -1
- package/dist/core/types/entity.interface.d.ts +22 -0
- package/dist/core/types/entity.interface.d.ts.map +1 -1
- package/dist/core/types/retry.interface.d.ts +32 -2
- package/dist/core/types/retry.interface.d.ts.map +1 -1
- package/dist/core/types/retry.interface.js +5 -1
- package/dist/core/types/retry.interface.js.map +1 -1
- package/dist/core/types/shared.type.d.ts +15 -1
- package/dist/core/types/shared.type.d.ts.map +1 -1
- package/dist/core/types/transit-result.type.d.ts +15 -0
- package/dist/core/types/transit-result.type.d.ts.map +1 -1
- package/dist/core/types/workflow-definition.interface.d.ts +51 -2
- package/dist/core/types/workflow-definition.interface.d.ts.map +1 -1
- package/dist/core/types/workflow-event.interface.d.ts +20 -0
- package/dist/core/types/workflow-event.interface.d.ts.map +1 -1
- package/dist/core/workflow.module.d.ts +28 -0
- package/dist/core/workflow.module.d.ts.map +1 -1
- package/dist/core/workflow.module.js +28 -0
- package/dist/core/workflow.module.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper that maps all keys unique to `T` (not in `U`) to `never`.
|
|
3
|
+
* Used internally by {@link TEither} to enforce mutually exclusive unions.
|
|
4
|
+
*/
|
|
1
5
|
export type TWithout<T, U> = {
|
|
2
6
|
[P in Exclude<keyof T, keyof U>]?: never;
|
|
3
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* A true mutually exclusive union of two object types.
|
|
10
|
+
*
|
|
11
|
+
* Unlike `T | U`, this prevents accidentally mixing properties from both
|
|
12
|
+
* types in a single value — only one side is allowed at a time.
|
|
13
|
+
*/
|
|
4
14
|
export type TEither<T, U> = T extends object ? (U extends object ? (TWithout<T, U> & U) | (TWithout<U, T> & T) : U) : T;
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
16
|
+
* A human-readable duration used for timeout configuration throughout the
|
|
17
|
+
* library (callback waits, idle state timeouts, retry delays, etc.).
|
|
18
|
+
*
|
|
19
|
+
* At least one field should be set. Fields are additive when the consuming
|
|
20
|
+
* code converts them — e.g. `{ minutes: 1, seconds: 30 }` = 90 seconds.
|
|
7
21
|
*/
|
|
8
22
|
export interface Duration {
|
|
9
23
|
hours?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.type.d.ts","sourceRoot":"","sources":["../../../packages/core/types/shared.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.type.d.ts","sourceRoot":"","sources":["../../../packages/core/types/shared.type.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAE,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAExH;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { Duration } from './shared.type.js';
|
|
2
2
|
import type { IWorkflowEvent } from './workflow-event.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Discriminated union returned by {@link OrchestratorService.transit}.
|
|
5
|
+
*
|
|
6
|
+
* Each variant tells the caller what happened and what to do next:
|
|
7
|
+
*
|
|
8
|
+
* | Status | Meaning |
|
|
9
|
+
* |-----------------|----------------------------------------------------|
|
|
10
|
+
* | `final` | Entity reached a terminal state — workflow done. |
|
|
11
|
+
* | `idle` | Entity is idle, waiting for an external callback. |
|
|
12
|
+
* | `continued` | Auto-transition found — feed `nextEvent` back in. |
|
|
13
|
+
* | `no_transition` | No unambiguous next step — wait for explicit event.|
|
|
14
|
+
*
|
|
15
|
+
* Adapters consume this via `BaseWorkflowAdapter` handler methods or a
|
|
16
|
+
* manual `switch` on `result.status`.
|
|
17
|
+
*/
|
|
3
18
|
export type TransitResult = {
|
|
4
19
|
status: 'final';
|
|
5
20
|
state: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transit-result.type.d.ts","sourceRoot":"","sources":["../../../packages/core/types/transit-result.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC3C;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAClD;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"transit-result.type.d.ts","sourceRoot":"","sources":["../../../packages/core/types/transit-result.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC3C;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAClD;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC"}
|
|
@@ -10,17 +10,46 @@ import type { Duration, IBackoffRetryConfig, ITransitionEvent, IWorkflowEntity }
|
|
|
10
10
|
* - `Entity`: An optional entity service or configuration for loading/updating entities.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* An idle state entry — either a bare state value or a state with per-state
|
|
13
|
+
* An idle state entry — either a bare state value or a state with a per-state
|
|
14
|
+
* callback timeout that overrides {@link IWorkflowDefinition.defaultCallbackTimeout}.
|
|
14
15
|
*/
|
|
15
16
|
export type IdleStateEntry<State> = State | {
|
|
16
17
|
state: State;
|
|
17
18
|
timeout?: Duration;
|
|
18
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Complete definition of a workflow, passed to the {@link Workflow} class decorator.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - Entity type (e.g. `Order`)
|
|
24
|
+
* @typeParam Event - Union of event names (e.g. `OrderEvent`)
|
|
25
|
+
* @typeParam State - Union of state values (e.g. `OrderStatus`)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* @Workflow<Order, OrderEvent, OrderStatus>({
|
|
30
|
+
* name: 'OrderWorkflow',
|
|
31
|
+
* states: {
|
|
32
|
+
* finals: [OrderStatus.Completed, OrderStatus.Cancelled],
|
|
33
|
+
* idles: [OrderStatus.Pending],
|
|
34
|
+
* failed: OrderStatus.Failed,
|
|
35
|
+
* },
|
|
36
|
+
* transitions: [
|
|
37
|
+
* { from: [OrderStatus.Pending], to: OrderStatus.Processing, event: OrderEvent.Submit },
|
|
38
|
+
* ],
|
|
39
|
+
* entityService: 'entity.order',
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
19
43
|
export interface IWorkflowDefinition<T, Event, State> {
|
|
44
|
+
/** Human-readable workflow name (used in logs). */
|
|
20
45
|
name: string;
|
|
46
|
+
/** Categorised states that drive the orchestrator's routing behaviour. */
|
|
21
47
|
states: {
|
|
48
|
+
/** Terminal states — reaching one ends the workflow. */
|
|
22
49
|
finals: State[];
|
|
50
|
+
/** Idle states — the workflow pauses and waits for an external callback. */
|
|
23
51
|
idles: IdleStateEntry<State>[];
|
|
52
|
+
/** The state to transition to when a handler throws an error. */
|
|
24
53
|
failed: State;
|
|
25
54
|
};
|
|
26
55
|
/**
|
|
@@ -28,13 +57,21 @@ export interface IWorkflowDefinition<T, Event, State> {
|
|
|
28
57
|
* Per-state timeouts in `idles` take precedence over this value.
|
|
29
58
|
*/
|
|
30
59
|
defaultCallbackTimeout?: Duration;
|
|
60
|
+
/** Allowed transitions between states, guarded by optional conditions. */
|
|
31
61
|
transitions: ITransitionEvent<T, Event, State, any>[];
|
|
62
|
+
/** Global conditions evaluated on every transition in this workflow. */
|
|
32
63
|
conditions?: (<P>(entity: T, payload?: P | T | object | string) => boolean)[];
|
|
33
64
|
/**
|
|
34
|
-
*
|
|
65
|
+
* NestJS injection token for the {@link IWorkflowEntity} service that
|
|
66
|
+
* handles persistence for this workflow's entities.
|
|
35
67
|
*/
|
|
36
68
|
entityService: string;
|
|
37
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Internal route entry built by {@link OrchestratorService} during module
|
|
72
|
+
* initialisation. Maps an event name to everything needed to execute a transition.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
38
75
|
export interface IWorkflowDefaultRoute {
|
|
39
76
|
instance: any;
|
|
40
77
|
definition: IWorkflowDefinition<any, string, string>;
|
|
@@ -44,10 +81,22 @@ export interface IWorkflowDefaultRoute {
|
|
|
44
81
|
entityService: IWorkflowEntity;
|
|
45
82
|
retryConfig?: IBackoffRetryConfig;
|
|
46
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Metadata entry created by the {@link OnEvent} decorator.
|
|
86
|
+
* Stored on the workflow class via `Reflect.defineMetadata`.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
47
89
|
export interface IWorkflowHandler {
|
|
90
|
+
/** The event name this handler responds to. */
|
|
48
91
|
event: string;
|
|
92
|
+
/** The method name on the workflow class. */
|
|
49
93
|
name: string;
|
|
94
|
+
/** Reference to the method itself. */
|
|
50
95
|
handler: (...payload: any[]) => Promise<any>;
|
|
51
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Signature for the fallback handler registered with {@link OnDefault}.
|
|
99
|
+
* Invoked when no transition matches the incoming event.
|
|
100
|
+
*/
|
|
52
101
|
export type TDefaultHandler<T, Event = string> = <P>(entity: T, event: Event, payload?: P | T | object | string) => Promise<T>;
|
|
53
102
|
//# sourceMappingURL=workflow-definition.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-definition.interface.d.ts","sourceRoot":"","sources":["../../../packages/core/types/workflow-definition.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE/F;;;;;;;;;GASG;AACH
|
|
1
|
+
{"version":3,"file":"workflow-definition.interface.d.ts","sourceRoot":"","sources":["../../../packages/core/types/workflow-definition.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE/F;;;;;;;;;GASG;AACH;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,KAAK,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK;IAClD,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,MAAM,EAAE;QACN,0DAAwD;QACxD,MAAM,EAAE,KAAK,EAAE,CAAC;QAChB,8EAA4E;QAC5E,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,iEAAiE;QACjE,MAAM,EAAE,KAAK,CAAC;KACf,CAAC;IACF;;;OAGG;IACH,sBAAsB,CAAC,EAAE,QAAQ,CAAC;IAClC,0EAA0E;IAC1E,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IACtD,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,EAAE,CAAC;IAC9E;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,aAAa,EAAE,eAAe,CAAC;IAC/B,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,IAAI,CAAC,CAAC,EACjD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,MAAM,KAC9B,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The event object passed into {@link OrchestratorService.transit} to trigger
|
|
3
|
+
* a state transition.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - Type of the optional payload data.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const event: IWorkflowEvent = {
|
|
10
|
+
* event: 'order.submit',
|
|
11
|
+
* urn: 'order-123',
|
|
12
|
+
* payload: { items: [{ sku: 'ABC', qty: 2 }] },
|
|
13
|
+
* attempt: 0,
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export interface IWorkflowEvent<T = any> {
|
|
18
|
+
/** Event name that matches a transition's `event` field. */
|
|
2
19
|
event: string;
|
|
20
|
+
/** Unique resource name identifying the entity instance. */
|
|
3
21
|
urn: string | number;
|
|
22
|
+
/** Optional data forwarded to the handler and transition conditions. */
|
|
4
23
|
payload?: T | object | string;
|
|
24
|
+
/** Zero-based retry attempt counter, managed by the adapter. */
|
|
5
25
|
attempt: number;
|
|
6
26
|
}
|
|
7
27
|
//# sourceMappingURL=workflow-event.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-event.interface.d.ts","sourceRoot":"","sources":["../../../packages/core/types/workflow-event.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
1
|
+
{"version":3,"file":"workflow-event.interface.d.ts","sourceRoot":"","sources":["../../../packages/core/types/workflow-event.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { type DynamicModule, type Provider } from '@nestjs/common';
|
|
2
2
|
import type { IWorkflowEntity } from './types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Dynamic NestJS module that bootstraps the workflow engine.
|
|
5
|
+
*
|
|
6
|
+
* Call {@link WorkflowModule.register} to supply entity services, workflow
|
|
7
|
+
* classes, and any extra providers. The module sets up {@link OrchestratorService}
|
|
8
|
+
* and the {@link StateRouterHelperFactory} automatically.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @Module({
|
|
13
|
+
* imports: [
|
|
14
|
+
* WorkflowModule.register({
|
|
15
|
+
* entities: [{ provide: 'entity.order', useClass: OrderEntityService }],
|
|
16
|
+
* workflows: [OrderWorkflow],
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* })
|
|
20
|
+
* export class AppModule {}
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
3
23
|
export declare class WorkflowModule {
|
|
24
|
+
/**
|
|
25
|
+
* Register workflows with the module.
|
|
26
|
+
*
|
|
27
|
+
* @param options.imports - Additional NestJS modules to import
|
|
28
|
+
* @param options.entities - Providers for {@link IWorkflowEntity} implementations (keyed by injection token)
|
|
29
|
+
* @param options.workflows - Workflow classes decorated with {@link Workflow}
|
|
30
|
+
* @param options.providers - Extra providers to include in the module
|
|
31
|
+
*/
|
|
4
32
|
static register(options: {
|
|
5
33
|
imports?: any[];
|
|
6
34
|
entities: Provider<IWorkflowEntity>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.module.d.ts","sourceRoot":"","sources":["../../packages/core/workflow.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,qBACa,cAAc;IACzB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;QACvB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACtC,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;KACxB,GAAG,aAAa,CAiBhB;CACF"}
|
|
1
|
+
{"version":3,"file":"workflow.module.d.ts","sourceRoot":"","sources":["../../packages/core/workflow.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,cAAc;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;QACvB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACtC,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;KACxB,GAAG,aAAa,CAiBhB;CACF"}
|
|
@@ -7,7 +7,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Module } from '@nestjs/common';
|
|
8
8
|
import { DiscoveryModule } from '@nestjs/core';
|
|
9
9
|
import { OrchestratorService, StateRouterHelperFactory } from '../core/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Dynamic NestJS module that bootstraps the workflow engine.
|
|
12
|
+
*
|
|
13
|
+
* Call {@link WorkflowModule.register} to supply entity services, workflow
|
|
14
|
+
* classes, and any extra providers. The module sets up {@link OrchestratorService}
|
|
15
|
+
* and the {@link StateRouterHelperFactory} automatically.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @Module({
|
|
20
|
+
* imports: [
|
|
21
|
+
* WorkflowModule.register({
|
|
22
|
+
* entities: [{ provide: 'entity.order', useClass: OrderEntityService }],
|
|
23
|
+
* workflows: [OrderWorkflow],
|
|
24
|
+
* }),
|
|
25
|
+
* ],
|
|
26
|
+
* })
|
|
27
|
+
* export class AppModule {}
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
10
30
|
let WorkflowModule = class WorkflowModule {
|
|
31
|
+
/**
|
|
32
|
+
* Register workflows with the module.
|
|
33
|
+
*
|
|
34
|
+
* @param options.imports - Additional NestJS modules to import
|
|
35
|
+
* @param options.entities - Providers for {@link IWorkflowEntity} implementations (keyed by injection token)
|
|
36
|
+
* @param options.workflows - Workflow classes decorated with {@link Workflow}
|
|
37
|
+
* @param options.providers - Extra providers to include in the module
|
|
38
|
+
*/
|
|
11
39
|
static register(options) {
|
|
12
40
|
const { imports, entities, workflows, providers: extraProviders } = options;
|
|
13
41
|
const providers = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.module.js","sourceRoot":"","sources":["../../packages/core/workflow.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow.module.js","sourceRoot":"","sources":["../../packages/core/workflow.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAIvE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,IAAa,cAAc,GAA3B,MAAa,cAAc;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,OAKf,EAAiB;QAChB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QAE5E,MAAM,SAAS,GAAG;YAChB,GAAG,QAAQ;YACX,GAAG,SAAS;YACZ,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;YACzB,wBAAwB;YACxB,mBAAmB;SACpB,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,CAAC,eAAe,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YAC9C,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,SAAS;SACnB,CAAC;IAAA,CACH;CACF,CAAA;AAhCY,cAAc;IAD1B,MAAM,CAAC,EAAE,CAAC;GACE,cAAc,CAgC1B"}
|