nestjs-serverless-workflow 0.0.7 → 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/README.md +55 -32
- package/dist/adapter/durable-lambda.adapter.d.ts +55 -0
- package/dist/adapter/durable-lambda.adapter.d.ts.map +1 -0
- package/dist/adapter/durable-lambda.adapter.js +113 -0
- package/dist/adapter/durable-lambda.adapter.js.map +1 -0
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +1 -1
- package/dist/adapter/index.js.map +1 -1
- package/dist/core/decorators/default.decorator.js +1 -1
- package/dist/core/decorators/default.decorator.js.map +1 -1
- package/dist/core/decorators/event.decorator.d.ts +0 -2
- package/dist/core/decorators/event.decorator.d.ts.map +1 -1
- package/dist/core/decorators/event.decorator.js +0 -9
- package/dist/core/decorators/event.decorator.js.map +1 -1
- package/dist/core/decorators/params.decorator.d.ts.map +1 -1
- package/dist/core/decorators/params.decorator.js.map +1 -1
- package/dist/core/decorators/with-retry.decorator.d.ts +1 -1
- package/dist/core/decorators/with-retry.decorator.d.ts.map +1 -1
- package/dist/core/decorators/with-retry.decorator.js +0 -1
- package/dist/core/decorators/with-retry.decorator.js.map +1 -1
- package/dist/core/decorators/workflow.decorator.d.ts +1 -1
- package/dist/core/decorators/workflow.decorator.d.ts.map +1 -1
- package/dist/core/decorators/workflow.decorator.js +1 -2
- package/dist/core/decorators/workflow.decorator.js.map +1 -1
- package/dist/core/providers/index.d.ts +1 -1
- package/dist/core/providers/index.d.ts.map +1 -1
- package/dist/core/providers/index.js +1 -1
- package/dist/core/providers/index.js.map +1 -1
- package/dist/core/providers/orchestrator.service.d.ts +17 -0
- package/dist/core/providers/orchestrator.service.d.ts.map +1 -0
- package/dist/core/providers/orchestrator.service.js +156 -0
- package/dist/core/providers/orchestrator.service.js.map +1 -0
- package/dist/core/providers/router.factory.d.ts +2 -2
- package/dist/core/providers/router.factory.d.ts.map +1 -1
- package/dist/core/providers/router.factory.js +1 -1
- package/dist/core/providers/router.factory.js.map +1 -1
- package/dist/core/providers/router.service.d.ts +9 -3
- package/dist/core/providers/router.service.d.ts.map +1 -1
- package/dist/core/providers/router.service.js +41 -25
- package/dist/core/providers/router.service.js.map +1 -1
- package/dist/core/types/index.d.ts +3 -2
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js +3 -4
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/types/shared.type.d.ts +8 -0
- package/dist/core/types/shared.type.d.ts.map +1 -1
- package/dist/core/types/transit-result.type.d.ts +18 -0
- package/dist/core/types/transit-result.type.d.ts.map +1 -0
- package/dist/core/types/transit-result.type.js +2 -0
- package/dist/core/types/transit-result.type.js.map +1 -0
- package/dist/core/types/workflow-definition.interface.d.ts +14 -21
- package/dist/core/types/workflow-definition.interface.d.ts.map +1 -1
- package/dist/{event-bus → core}/types/workflow-event.interface.d.ts +1 -1
- package/dist/core/types/workflow-event.interface.d.ts.map +1 -0
- package/dist/core/types/workflow-event.interface.js.map +1 -0
- package/dist/core/utils/retry-backoff.d.ts.map +1 -1
- package/dist/core/utils/retry-backoff.js +6 -6
- package/dist/core/utils/retry-backoff.js.map +1 -1
- package/dist/core/workflow.module.d.ts +0 -2
- package/dist/core/workflow.module.d.ts.map +1 -1
- package/dist/core/workflow.module.js +9 -3
- package/dist/core/workflow.module.js.map +1 -1
- package/package.json +18 -5
- package/dist/adapter/lambda.adapater.d.ts +0 -4
- package/dist/adapter/lambda.adapater.d.ts.map +0 -1
- package/dist/adapter/lambda.adapater.js +0 -66
- package/dist/adapter/lambda.adapater.js.map +0 -1
- package/dist/core/providers/ochestrator.service.d.ts +0 -33
- package/dist/core/providers/ochestrator.service.d.ts.map +0 -1
- package/dist/core/providers/ochestrator.service.js +0 -184
- package/dist/core/providers/ochestrator.service.js.map +0 -1
- package/dist/core/providers/saga.service.d.ts +0 -28
- package/dist/core/providers/saga.service.d.ts.map +0 -1
- package/dist/core/providers/saga.service.js +0 -156
- package/dist/core/providers/saga.service.js.map +0 -1
- package/dist/core/types/saga.interface.d.ts +0 -144
- package/dist/core/types/saga.interface.d.ts.map +0 -1
- package/dist/core/types/saga.interface.js +0 -26
- package/dist/core/types/saga.interface.js.map +0 -1
- package/dist/event-bus/index.d.ts +0 -3
- package/dist/event-bus/index.d.ts.map +0 -1
- package/dist/event-bus/index.js +0 -3
- package/dist/event-bus/index.js.map +0 -1
- package/dist/event-bus/sqs/sqs.emitter.d.ts +0 -6
- package/dist/event-bus/sqs/sqs.emitter.d.ts.map +0 -1
- package/dist/event-bus/sqs/sqs.emitter.js +0 -6
- package/dist/event-bus/sqs/sqs.emitter.js.map +0 -1
- package/dist/event-bus/types/broker-publisher.interface.d.ts +0 -5
- package/dist/event-bus/types/broker-publisher.interface.d.ts.map +0 -1
- package/dist/event-bus/types/broker-publisher.interface.js +0 -2
- package/dist/event-bus/types/broker-publisher.interface.js.map +0 -1
- package/dist/event-bus/types/index.d.ts +0 -3
- package/dist/event-bus/types/index.d.ts.map +0 -1
- package/dist/event-bus/types/index.js +0 -3
- package/dist/event-bus/types/index.js.map +0 -1
- package/dist/event-bus/types/workflow-event.interface.d.ts.map +0 -1
- package/dist/event-bus/types/workflow-event.interface.js.map +0 -1
- /package/dist/{event-bus → core}/types/workflow-event.interface.js +0 -0
package/README.md
CHANGED
|
@@ -8,23 +8,22 @@ A powerful, tree-shakable workflow and state machine library for NestJS applicat
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- 🎯 **State Machine Engine**: Define workflows with states, transitions, and events
|
|
11
|
-
-
|
|
12
|
-
-
|
|
11
|
+
- ⚡ **Serverless Optimized**: Built for AWS Lambda with durable execution support
|
|
12
|
+
- 🔄 **Durable Execution**: Checkpoint and replay workflows across Lambda invocations using AWS Durable Functions
|
|
13
13
|
- 📦 **Tree-Shakable**: Subpath exports ensure minimal bundle sizes
|
|
14
14
|
- 🛡️ **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
15
15
|
- 🔁 **Retry Logic**: Built-in retry mechanisms with exponential backoff
|
|
16
16
|
- 🎨 **Decorator-Based API**: Clean, declarative workflow definitions
|
|
17
|
-
- 📊 **Saga Pattern Support**: Distributed transaction managementa (TODO)
|
|
18
17
|
|
|
19
18
|
## Installation
|
|
20
19
|
|
|
21
20
|
```bash
|
|
22
|
-
# Using npm
|
|
23
|
-
npm install nestjs-serverless-workflow @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
24
|
-
|
|
25
21
|
# Using bun
|
|
26
22
|
bun add nestjs-serverless-workflow @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
27
23
|
|
|
24
|
+
# Using npm
|
|
25
|
+
npm install nestjs-serverless-workflow @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
26
|
+
|
|
28
27
|
# Using yarn
|
|
29
28
|
yarn add nestjs-serverless-workflow @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
30
29
|
```
|
|
@@ -73,7 +72,6 @@ import { Workflow, OnEvent, Entity, Payload } from 'nestjs-serverless-workflow/c
|
|
|
73
72
|
},
|
|
74
73
|
],
|
|
75
74
|
entityService: 'entity.order',
|
|
76
|
-
brokerPublisher: 'broker.order',
|
|
77
75
|
})
|
|
78
76
|
export class OrderWorkflow {
|
|
79
77
|
@OnEvent('order.submit')
|
|
@@ -133,7 +131,6 @@ import { OrderEntityService } from './order-entity.service';
|
|
|
133
131
|
WorkflowModule.register({
|
|
134
132
|
entities: [{ provide: 'entity.order', useClass: OrderEntityService }],
|
|
135
133
|
workflows: [OrderWorkflow],
|
|
136
|
-
brokers: [{ provide: 'broker.order', useClass: MySqsEmitter }],
|
|
137
134
|
}),
|
|
138
135
|
],
|
|
139
136
|
})
|
|
@@ -146,7 +143,6 @@ export class OrderModule {}
|
|
|
146
143
|
|
|
147
144
|
- [Getting Started](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/getting-started)
|
|
148
145
|
- [Workflow Module](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/workflow)
|
|
149
|
-
- [Event Bus](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/event-bus)
|
|
150
146
|
- [Lambda Adapter](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/adapters)
|
|
151
147
|
- [API Reference](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/api-reference/workflow-module)
|
|
152
148
|
- [Examples](https://tung-dnt.github.io/nestjs-serverless-workflow/docs/examples/lambda-order-state-machine)
|
|
@@ -157,35 +153,48 @@ The library is organized into tree-shakable subpath exports:
|
|
|
157
153
|
|
|
158
154
|
```
|
|
159
155
|
nestjs-serverless-workflow/
|
|
160
|
-
├── core # Core workflow engine (decorators, services, types)
|
|
161
|
-
├──
|
|
162
|
-
├── adapter # Runtime adapters (Lambda, HTTP)
|
|
156
|
+
├── core # Core workflow engine (decorators, services, types, IWorkflowEvent)
|
|
157
|
+
├── adapter # Durable Lambda adapter for checkpoint/replay execution
|
|
163
158
|
└── exception # Custom exception types
|
|
164
159
|
```
|
|
165
160
|
|
|
166
161
|
### Import Only What You Need
|
|
167
162
|
|
|
168
163
|
```typescript
|
|
169
|
-
//
|
|
170
|
-
import { WorkflowModule } from 'nestjs-serverless-workflow/core';
|
|
171
|
-
|
|
172
|
-
// Only imports event bus
|
|
173
|
-
import { IBrokerPublisher } from 'nestjs-serverless-workflow/event-bus';
|
|
164
|
+
// Core workflow engine
|
|
165
|
+
import { WorkflowModule, IWorkflowEvent } from 'nestjs-serverless-workflow/core';
|
|
174
166
|
|
|
175
|
-
//
|
|
176
|
-
import {
|
|
167
|
+
// Durable Lambda adapter
|
|
168
|
+
import { DurableLambdaEventHandler } from 'nestjs-serverless-workflow/adapter';
|
|
177
169
|
|
|
178
|
-
//
|
|
170
|
+
// Exceptions
|
|
179
171
|
import { UnretriableException } from 'nestjs-serverless-workflow/exception';
|
|
180
172
|
```
|
|
181
173
|
|
|
182
174
|
This ensures minimal bundle sizes and faster cold starts in serverless environments.
|
|
183
175
|
|
|
176
|
+
## Transit Result
|
|
177
|
+
|
|
178
|
+
The `transit()` method on the orchestrator returns a `TransitResult`, which adapters use to decide what to do next:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
type TransitResult =
|
|
182
|
+
| { status: 'final'; state: string | number }
|
|
183
|
+
| { status: 'idle'; state: string | number }
|
|
184
|
+
| { status: 'continued'; nextEvent: IWorkflowEvent }
|
|
185
|
+
| { status: 'no_transition'; state: string | number };
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **`final`** -- the workflow has reached a terminal state.
|
|
189
|
+
- **`idle`** -- the workflow is waiting for an external event.
|
|
190
|
+
- **`continued`** -- the workflow auto-transitioned and provides the next event to process.
|
|
191
|
+
- **`no_transition`** -- no matching transition was found from the current state.
|
|
192
|
+
|
|
184
193
|
## Examples
|
|
185
194
|
|
|
186
195
|
Check out the [examples directory](https://github.com/tung-dnt/nestjs-serverless-workflow/tree/main/examples) for complete working examples:
|
|
187
196
|
|
|
188
|
-
- **[Lambda Order State Machine](https://github.com/tung-dnt/nestjs-serverless-workflow/tree/main/examples/lambda-order-state-machine/)**: Complete AWS Lambda example with
|
|
197
|
+
- **[Lambda Order State Machine](https://github.com/tung-dnt/nestjs-serverless-workflow/tree/main/examples/lambda-order-state-machine/)**: Complete AWS Lambda example with DynamoDB and durable execution
|
|
189
198
|
|
|
190
199
|
## Key Concepts
|
|
191
200
|
|
|
@@ -214,7 +223,18 @@ Transitions define how entities move from one state to another, triggered by eve
|
|
|
214
223
|
|
|
215
224
|
### Events
|
|
216
225
|
|
|
217
|
-
Events trigger state transitions.
|
|
226
|
+
Events trigger state transitions. The `IWorkflowEvent` interface (from `nestjs-serverless-workflow/core`) defines the shape of workflow events:
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
interface IWorkflowEvent<T = any> {
|
|
230
|
+
event: string; // event name that triggers a transition
|
|
231
|
+
urn: string | number; // unique identifier of the entity
|
|
232
|
+
payload?: T; // optional data passed to the handler
|
|
233
|
+
attempt: number; // retry attempt counter
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Define event handlers using the `@OnEvent` decorator:
|
|
218
238
|
|
|
219
239
|
```typescript
|
|
220
240
|
@OnEvent('order.submit')
|
|
@@ -225,19 +245,22 @@ async onSubmit(@Entity() entity: Order, @Payload() data: any) {
|
|
|
225
245
|
|
|
226
246
|
## AWS Lambda Integration
|
|
227
247
|
|
|
228
|
-
The library includes a Lambda adapter that
|
|
248
|
+
The library includes a Durable Lambda adapter (`DurableLambdaEventHandler`) that leverages [AWS Lambda Durable Functions](https://aws.amazon.com/blogs/compute/) for checkpoint and replay. Each workflow instance runs as a single durable execution spanning multiple Lambda invocations:
|
|
229
249
|
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
- SQS event source integration
|
|
250
|
+
- **Checkpointed steps** -- completed transitions are persisted; on replay they return stored results.
|
|
251
|
+
- **Idle state pausing** -- idle states pause via `waitForCallback()` until an external system resumes the workflow.
|
|
252
|
+
- **Final state completion** -- reaching a final state ends the durable execution.
|
|
234
253
|
|
|
235
254
|
```typescript
|
|
236
|
-
import {
|
|
237
|
-
import {
|
|
255
|
+
import { withDurableExecution } from '@aws/durable-execution-sdk-js';
|
|
256
|
+
import { NestFactory } from '@nestjs/core';
|
|
257
|
+
import { DurableLambdaEventHandler } from 'nestjs-serverless-workflow/adapter';
|
|
258
|
+
import { OrderModule } from './order/order.module';
|
|
259
|
+
|
|
260
|
+
const app = await NestFactory.createApplicationContext(OrderModule);
|
|
261
|
+
await app.init();
|
|
238
262
|
|
|
239
|
-
const
|
|
240
|
-
export const handler: SQSHandler = LambdaEventHandler(app);
|
|
263
|
+
export const handler = DurableLambdaEventHandler(app, withDurableExecution);
|
|
241
264
|
```
|
|
242
265
|
|
|
243
266
|
## Requirements
|
|
@@ -276,4 +299,4 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
|
|
|
276
299
|
|
|
277
300
|
- [NestJS](https://nestjs.com/) - A progressive Node.js framework
|
|
278
301
|
- [AWS Lambda](https://aws.amazon.com/lambda/) - Serverless compute service
|
|
279
|
-
- [AWS
|
|
302
|
+
- [AWS Lambda Durable Functions](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html) - Durable execution for Lambda
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { INestApplicationContext } from '@nestjs/common';
|
|
2
|
+
export interface DurableWorkflowEvent {
|
|
3
|
+
urn: string | number;
|
|
4
|
+
initialEvent: string;
|
|
5
|
+
payload?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface DurableWorkflowResult {
|
|
8
|
+
urn: string | number;
|
|
9
|
+
status: string;
|
|
10
|
+
state: string | number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Minimal interface for the AWS Durable Execution SDK's DurableContext.
|
|
14
|
+
* The actual SDK (`@aws/durable-execution-sdk-js`) is a peer dependency — only needed at runtime.
|
|
15
|
+
*/
|
|
16
|
+
export interface IDurableContext {
|
|
17
|
+
step<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
18
|
+
waitForCallback<T>(name: string, onRegister: (callbackId: string) => Promise<void>, options?: {
|
|
19
|
+
timeout?: {
|
|
20
|
+
hours?: number;
|
|
21
|
+
minutes?: number;
|
|
22
|
+
seconds?: number;
|
|
23
|
+
};
|
|
24
|
+
}): Promise<T>;
|
|
25
|
+
wait(duration: {
|
|
26
|
+
seconds?: number;
|
|
27
|
+
minutes?: number;
|
|
28
|
+
hours?: number;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
logger: {
|
|
31
|
+
info(msg: string, data?: any): void;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type for the withDurableExecution wrapper function from the AWS SDK.
|
|
36
|
+
*/
|
|
37
|
+
export type WithDurableExecution = <TEvent, TResult>(handler: (event: TEvent, ctx: IDurableContext) => Promise<TResult>) => (event: TEvent, ctx: any) => Promise<TResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Lambda handler that wraps the workflow orchestrator in a durable execution.
|
|
40
|
+
*
|
|
41
|
+
* Each workflow instance runs as a single durable execution spanning multiple Lambda invocations.
|
|
42
|
+
* Steps are checkpointed at event boundaries — on replay, completed steps return stored results.
|
|
43
|
+
*
|
|
44
|
+
* Idle states pause via `ctx.waitForCallback()` until an external system submits a callback.
|
|
45
|
+
* Final states end the durable execution.
|
|
46
|
+
*
|
|
47
|
+
* @param app - NestJS application context
|
|
48
|
+
* @param withDurableExecution - The `withDurableExecution` function from `@aws/durable-execution-sdk-js`
|
|
49
|
+
*/
|
|
50
|
+
export declare const DurableLambdaEventHandler: (app: INestApplicationContext, withDurableExecution: WithDurableExecution) => (event: DurableWorkflowEvent, ctx: any) => Promise<{
|
|
51
|
+
urn: string | number;
|
|
52
|
+
status: string;
|
|
53
|
+
state: string | number;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=durable-lambda.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-lambda.adapter.d.ts","sourceRoot":"","sources":["../../packages/adapter/durable-lambda.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAI9D,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,eAAe,CAAC,CAAC,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EACjD,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAC7E,OAAO,CAAC,CAAC,CAAC,CAAC;IACd,IAAI,CAAC,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,MAAM,EAAE;QAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,EACjD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,KAC/D,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAmBnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB;;;;EAyErC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { OrchestratorService, RetryBackoff } from '../core/index.js';
|
|
2
|
+
import { UnretriableException } from '../exception/unretriable.exception.js';
|
|
3
|
+
const DEFAULT_CALLBACK_TIMEOUT = { hours: 24 };
|
|
4
|
+
/**
|
|
5
|
+
* Parse a callback result from the SDK.
|
|
6
|
+
* The real SDK delivers callback results as JSON strings via SendDurableExecutionCallbackSuccess.
|
|
7
|
+
*/
|
|
8
|
+
function parseCallbackResult(raw) {
|
|
9
|
+
if (typeof raw === 'string') {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return raw;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return raw;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a Lambda handler that wraps the workflow orchestrator in a durable execution.
|
|
21
|
+
*
|
|
22
|
+
* Each workflow instance runs as a single durable execution spanning multiple Lambda invocations.
|
|
23
|
+
* Steps are checkpointed at event boundaries — on replay, completed steps return stored results.
|
|
24
|
+
*
|
|
25
|
+
* Idle states pause via `ctx.waitForCallback()` until an external system submits a callback.
|
|
26
|
+
* Final states end the durable execution.
|
|
27
|
+
*
|
|
28
|
+
* @param app - NestJS application context
|
|
29
|
+
* @param withDurableExecution - The `withDurableExecution` function from `@aws/durable-execution-sdk-js`
|
|
30
|
+
*/
|
|
31
|
+
export const DurableLambdaEventHandler = (app, withDurableExecution) => {
|
|
32
|
+
const orchestrator = app.get(OrchestratorService);
|
|
33
|
+
return withDurableExecution(async (event, ctx) => {
|
|
34
|
+
let currentEvent = {
|
|
35
|
+
event: event.initialEvent,
|
|
36
|
+
urn: event.urn,
|
|
37
|
+
payload: event.payload,
|
|
38
|
+
attempt: 0,
|
|
39
|
+
};
|
|
40
|
+
let iteration = 0;
|
|
41
|
+
while (true) {
|
|
42
|
+
const result = await transitWithRetry(orchestrator, currentEvent, iteration, ctx);
|
|
43
|
+
switch (result.status) {
|
|
44
|
+
case 'final':
|
|
45
|
+
return { urn: event.urn, status: 'completed', state: result.state };
|
|
46
|
+
case 'idle': {
|
|
47
|
+
const timeout = result.timeout ?? DEFAULT_CALLBACK_TIMEOUT;
|
|
48
|
+
const raw = await ctx.waitForCallback(`idle:${result.state}:${iteration}`, async (callbackId) => {
|
|
49
|
+
// External systems use this callbackId to resume the workflow
|
|
50
|
+
// via SendDurableExecutionCallbackSuccess Lambda API
|
|
51
|
+
ctx.logger.info(`Waiting for callback at idle state ${result.state}`, { callbackId });
|
|
52
|
+
}, { timeout });
|
|
53
|
+
const callbackPayload = parseCallbackResult(raw);
|
|
54
|
+
currentEvent = {
|
|
55
|
+
event: callbackPayload.event,
|
|
56
|
+
urn: event.urn,
|
|
57
|
+
payload: callbackPayload.payload,
|
|
58
|
+
attempt: 0,
|
|
59
|
+
};
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case 'continued': {
|
|
63
|
+
// Checkpoint the progression — on replay, returns stored result
|
|
64
|
+
await ctx.step(`${result.nextEvent.event}:${iteration}`, async () => result.nextEvent);
|
|
65
|
+
currentEvent = result.nextEvent;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case 'no_transition': {
|
|
69
|
+
const timeout = result.timeout ?? DEFAULT_CALLBACK_TIMEOUT;
|
|
70
|
+
// No unambiguous auto-transition — wait for explicit event via callback
|
|
71
|
+
const raw = await ctx.waitForCallback(`awaiting:${result.state}:${iteration}`, async (callbackId) => {
|
|
72
|
+
ctx.logger.info(`No auto-transition from ${result.state}, waiting for explicit event`, { callbackId });
|
|
73
|
+
}, { timeout });
|
|
74
|
+
const noTransitionPayload = parseCallbackResult(raw);
|
|
75
|
+
currentEvent = {
|
|
76
|
+
event: noTransitionPayload.event,
|
|
77
|
+
urn: event.urn,
|
|
78
|
+
payload: noTransitionPayload.payload,
|
|
79
|
+
attempt: 0,
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
iteration++;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Wraps `orchestrator.transit()` with retry logic when the handler has `@WithRetry()` config.
|
|
90
|
+
* Each attempt is checkpointed via `ctx.step()` so replays skip completed attempts.
|
|
91
|
+
*/
|
|
92
|
+
async function transitWithRetry(orchestrator, currentEvent, iteration, ctx) {
|
|
93
|
+
const retryConfig = orchestrator.getRetryConfig(currentEvent.event);
|
|
94
|
+
const maxAttempts = retryConfig?.maxAttempts ?? 1;
|
|
95
|
+
let lastError;
|
|
96
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
97
|
+
try {
|
|
98
|
+
return await ctx.step(`transit:${currentEvent.event}:${iteration}:${attempt}`, () => orchestrator.transit(currentEvent));
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (e instanceof UnretriableException)
|
|
102
|
+
throw e;
|
|
103
|
+
lastError = e;
|
|
104
|
+
if (attempt < maxAttempts - 1) {
|
|
105
|
+
const delay = RetryBackoff.calculateDelay(attempt, retryConfig);
|
|
106
|
+
ctx.logger.info(`Handler ${currentEvent.event} failed (attempt ${attempt + 1}/${maxAttempts}), retrying in ${delay}ms`);
|
|
107
|
+
await ctx.wait({ seconds: Math.ceil(delay / 1000) });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
throw lastError;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=durable-lambda.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-lambda.adapter.js","sourceRoot":"","sources":["../../packages/adapter/durable-lambda.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAA2C,MAAM,QAAQ,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAoCzE,MAAM,wBAAwB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAE/C;;;GAGG;AACH,SAAS,mBAAmB,CAAI,GAAY,EAAK;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,O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/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './lambda.
|
|
1
|
+
export * from './durable-lambda.adapter.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './lambda.
|
|
1
|
+
export * from './durable-lambda.adapter.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../packages/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../packages/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const WORKFLOW_DEFAULT_EVENT = 'workflow.default';
|
|
2
2
|
export const OnDefault = (target, _propertyKey, descriptor) => {
|
|
3
|
-
|
|
3
|
+
const existingFallback = Reflect.getMetadata(WORKFLOW_DEFAULT_EVENT, target.constructor);
|
|
4
4
|
if (!existingFallback) {
|
|
5
5
|
Reflect.defineMetadata(WORKFLOW_DEFAULT_EVENT, descriptor.value, target.constructor);
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/default.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,YAAoB,EAAE,UAA8B,EAAE,EAAE,CAAC;IAC9F,
|
|
1
|
+
{"version":3,"file":"default.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/default.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,YAAoB,EAAE,UAA8B,EAAE,EAAE,CAAC;IAC9F,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAsB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACzF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,UAAU,CAAC;AAAA,CACnB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ISagaConfig } from '../../core/index.js';
|
|
2
1
|
export declare const WORKFLOW_HANDLER_KEY = "workflow:metadata";
|
|
3
2
|
export declare const OnEvent: (event: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
4
|
-
export declare const OnCompensation: (event: string, config: ISagaConfig) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
5
3
|
//# sourceMappingURL=event.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/event.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/event.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD,eAAO,MAAM,OAAO,6GAWnB,CAAC"}
|
|
@@ -8,13 +8,4 @@ export const OnEvent = (event) => (target, propertyKey, descriptor) => {
|
|
|
8
8
|
workflowHandlers.push({ event, handler: descriptor.value, name: propertyKey });
|
|
9
9
|
return descriptor;
|
|
10
10
|
};
|
|
11
|
-
export const OnCompensation = (event, config) => (target, propertyKey, descriptor) => {
|
|
12
|
-
let workflowHandlers = Reflect.getMetadata(WORKFLOW_HANDLER_KEY, target.constructor);
|
|
13
|
-
if (!workflowHandlers) {
|
|
14
|
-
workflowHandlers = [];
|
|
15
|
-
Reflect.defineMetadata(WORKFLOW_HANDLER_KEY, workflowHandlers, target.constructor);
|
|
16
|
-
}
|
|
17
|
-
workflowHandlers.push({ event, handler: descriptor.value, name: propertyKey, sagaConfig: config });
|
|
18
|
-
return descriptor;
|
|
19
|
-
};
|
|
20
11
|
//# sourceMappingURL=event.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/event.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE,CAAC;IAC9G,IAAI,gBAAgB,GAAuB,OAAO,CAAC,WAAW,CAAC,oBAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEzG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,EAAE,CAAC;QACtB,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACrF,CAAC;IAED,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAE/E,OAAO,UAAU,CAAC;AAAA,CACnB,CAAC
|
|
1
|
+
{"version":3,"file":"event.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/event.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE,CAAC;IAC9G,IAAI,gBAAgB,GAAuB,OAAO,CAAC,WAAW,CAAC,oBAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEzG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,EAAE,CAAC;QACtB,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACrF,CAAC;IAED,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAE/E,OAAO,UAAU,CAAC;AAAA,CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/params.decorator.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,IAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"params.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/params.decorator.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,IAAI,kBAAkB,CAQ3C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAQtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/params.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,GAAuB;IAC3C,OAAO,CAAC,MAAc,EAAE,WAA6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AAAA,CACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IBackoffRetryConfig } from '../types/index.js';
|
|
2
2
|
export declare const getRetryKey: (propertyKey: string) => string;
|
|
3
3
|
export declare function WithRetry(config: IBackoffRetryConfig): (_target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
4
4
|
//# sourceMappingURL=with-retry.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-retry.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/with-retry.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"with-retry.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/with-retry.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD,eAAO,MAAM,WAAW,iCAA8D,CAAC;AAEvF,wBAAgB,SAAS,CAAC,MAAM,EAAE,mBAAmB,6FAKpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-retry.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/with-retry.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-retry.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/with-retry.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,GAAG,cAAc,IAAI,WAAW,EAAE,CAAC;AAEvF,MAAM,UAAU,SAAS,CAAC,MAA2B,EAAE;IACrD,OAAO,CAAC,OAAY,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE,CAAC;QAC5E,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO,UAAU,CAAC;IAAA,CACnB,CAAC;AAAA,CACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IWorkflowDefinition } from '../../core/index.js';
|
|
2
2
|
export declare const WORKFLOW_DEFINITION_KEY = "workflow:definition";
|
|
3
3
|
export declare function Workflow<T, Event, State>(definition: IWorkflowDefinition<T, Event, State>): <T extends new (...args: any[]) => {}>(instance: T) => T;
|
|
4
4
|
//# sourceMappingURL=workflow.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/workflow.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"workflow.decorator.d.ts","sourceRoot":"","sources":["../../../packages/core/decorators/workflow.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAElD,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAChF,CAAC,uDAKV"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {} from '../../core/index.js';
|
|
2
1
|
export const WORKFLOW_DEFINITION_KEY = 'workflow:definition';
|
|
3
2
|
export function Workflow(definition) {
|
|
4
|
-
return
|
|
3
|
+
return (instance) => {
|
|
5
4
|
Reflect.defineMetadata(WORKFLOW_DEFINITION_KEY, definition, instance);
|
|
6
5
|
return instance;
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/workflow.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow.decorator.js","sourceRoot":"","sources":["../../../packages/core/decorators/workflow.decorator.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,MAAM,UAAU,QAAQ,CAAkB,UAAgD,EAAE;IAC1F,OAAO,CAAyC,QAAW,EAAE,EAAE,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEtE,OAAO,QAAQ,CAAC;IAAA,CACjB,CAAC;AAAA,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/core/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/core/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type IBackoffRetryConfig, type TransitResult } from '../../core/index.js';
|
|
2
|
+
import { type OnModuleInit } from '@nestjs/common';
|
|
3
|
+
import { DiscoveryService, ModuleRef } from '@nestjs/core';
|
|
4
|
+
import type { IWorkflowEvent } from '../types/workflow-event.interface.js';
|
|
5
|
+
import { StateRouterHelperFactory } from './router.factory.js';
|
|
6
|
+
export declare class OrchestratorService implements OnModuleInit {
|
|
7
|
+
private readonly discoveryService;
|
|
8
|
+
private readonly routerHelperFactory;
|
|
9
|
+
private readonly moduleRef;
|
|
10
|
+
private routes;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(discoveryService: DiscoveryService, routerHelperFactory: StateRouterHelperFactory, moduleRef: ModuleRef);
|
|
13
|
+
onModuleInit(): void;
|
|
14
|
+
getRetryConfig(event: string): IBackoffRetryConfig | undefined;
|
|
15
|
+
transit(params: IWorkflowEvent): Promise<TransitResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=orchestrator.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.service.d.ts","sourceRoot":"","sources":["../../../packages/core/providers/orchestrator.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,mBAAmB,EAMxB,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,qBACa,mBAAoB,YAAW,YAAY;IAKpD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAE/D,YACmB,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,wBAAwB,EAC7C,SAAS,EAAE,SAAS,EACnC;IAEJ,YAAY,SA4CX;IAED,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAE7D;IAEK,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAqG5D;CACF"}
|