@dudousxd/nestjs-durable 0.25.0 → 0.26.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.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -9
- package/dist/index.d.ts +14 -9
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -138,7 +138,12 @@ interface DurableStepMeta {
|
|
|
138
138
|
* (e.g. the event-emitter transport) routes dispatched tasks to it. The method's single
|
|
139
139
|
* argument is the step input; its return value is the step output.
|
|
140
140
|
*/
|
|
141
|
-
declare function
|
|
141
|
+
declare function Step(name: string): MethodDecorator;
|
|
142
|
+
/**
|
|
143
|
+
* @deprecated Use `@Step` instead. `@DurableStep` is a back-compat alias of {@link Step} and
|
|
144
|
+
* writes the same `DURABLE_STEP_METADATA`, so discovery/registrars treat them identically.
|
|
145
|
+
*/
|
|
146
|
+
declare const DurableStep: typeof Step;
|
|
142
147
|
declare function getDurableStepMeta(method: Function): DurableStepMeta | undefined;
|
|
143
148
|
declare const DEAD_LETTER_METADATA: unique symbol;
|
|
144
149
|
/**
|
|
@@ -181,7 +186,7 @@ declare function getOnEvents(meta: WorkflowMeta, target: object): string[];
|
|
|
181
186
|
/**
|
|
182
187
|
* Options for a **store-less thin worker** process: where to consume (`connection`/`prefix`) and
|
|
183
188
|
* which worker `groups` this process serves. There is deliberately NO `store`, `transport`, engine,
|
|
184
|
-
* dashboard, recovery, or timer config — a thin worker only registers `@Workflow`/`@
|
|
189
|
+
* dashboard, recovery, or timer config — a thin worker only registers `@Workflow`/`@Step`
|
|
185
190
|
* handlers and runs the BullMQ consumer (see {@link DurableWorkerModule}).
|
|
186
191
|
*/
|
|
187
192
|
interface DurableWorkerModuleOptions {
|
|
@@ -235,7 +240,7 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
|
|
|
235
240
|
onModuleInit(): void;
|
|
236
241
|
}
|
|
237
242
|
/**
|
|
238
|
-
* Discovers every `@
|
|
243
|
+
* Discovers every `@Step` method and registers it as a step handler on the thin
|
|
239
244
|
* {@link DurableWorkerRuntime}. Mirrors the engine-side `DurableStepRegistrar`, but always registers
|
|
240
245
|
* on the runtime (a thin worker IS the consumer — there is no in-process-vs-queue branch).
|
|
241
246
|
*/
|
|
@@ -266,7 +271,7 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
|
|
|
266
271
|
}
|
|
267
272
|
/**
|
|
268
273
|
* A NestJS dynamic module that turns an app into a **PURE durable worker**: it discovers
|
|
269
|
-
* `@Workflow`/`@
|
|
274
|
+
* `@Workflow`/`@Step` providers, registers them on the thin {@link DurableWorkerRuntime}, and
|
|
270
275
|
* runs one BullMQ consumer per group via `runRedisWorker`. It is **control-plane-less** — it binds
|
|
271
276
|
* NO `WorkflowEngine`, NO store/ORM, NO dashboard, NO timer poller, NO recovery, and NO run dispatch.
|
|
272
277
|
* Use it for a worker pod that only executes work an engine elsewhere coordinates.
|
|
@@ -282,7 +287,7 @@ declare class DurableWorkerModule {
|
|
|
282
287
|
|
|
283
288
|
/**
|
|
284
289
|
* Opt-in config for an **in-app worker**: the same NestJS process runs the engine AND serves its own
|
|
285
|
-
* discovered `@Workflow`/`@
|
|
290
|
+
* discovered `@Workflow`/`@Step` on one default `group`. The engine registers each `@Workflow`
|
|
286
291
|
* GROUP-SERVED (its turns are dispatched to `group` over the transport via a {@link RemoteWorkflowExecutor}
|
|
287
292
|
* instead of run inline), and a co-located {@link DurableWorkerRuntime} consumes `group` and replays the
|
|
288
293
|
* very same TS bodies. This is the uniform-dispatch "one app, both roles" shape — every turn pays a
|
|
@@ -330,7 +335,7 @@ interface InAppWorkerBinding {
|
|
|
330
335
|
executor: WorkflowExecutor;
|
|
331
336
|
}
|
|
332
337
|
/**
|
|
333
|
-
* The consumer half of the in-app worker: on init it registers every discovered `@Workflow`/`@
|
|
338
|
+
* The consumer half of the in-app worker: on init it registers every discovered `@Workflow`/`@Step`
|
|
334
339
|
* on a {@link DurableWorkerRuntime} (the SAME bodies the engine registered group-served), and on bootstrap
|
|
335
340
|
* it starts one `runRedisWorker` consumer on the configured group, closing it on shutdown. A no-op when
|
|
336
341
|
* the app didn't opt in. Mirrors the thin {@link import('./durable-worker.module').DurableWorkerModule},
|
|
@@ -440,7 +445,7 @@ interface DurableModuleOptions {
|
|
|
440
445
|
*/
|
|
441
446
|
deadLetterWorkflow?: WorkflowRef;
|
|
442
447
|
/**
|
|
443
|
-
* Whether this instance plays the **worker** role: register `@
|
|
448
|
+
* Whether this instance plays the **worker** role: register `@Step` handlers (consume the
|
|
444
449
|
* transport), recover incomplete runs on boot, and poll due timers. Defaults to `true`. Set
|
|
445
450
|
* `false` for a **dashboard/dispatch-only** instance (e.g. an API pod) that mounts the control
|
|
446
451
|
* plane and reads the store but must not process or recover workflows — leave that to the workers.
|
|
@@ -507,7 +512,7 @@ interface DurableModuleOptions {
|
|
|
507
512
|
compensationRetries?: number;
|
|
508
513
|
/**
|
|
509
514
|
* Opt into an **in-app worker** (uniform dispatch): the same process runs the engine AND serves its
|
|
510
|
-
* own discovered `@Workflow`/`@
|
|
515
|
+
* own discovered `@Workflow`/`@Step` on one default `group`. Each `@Workflow` is registered
|
|
511
516
|
* GROUP-SERVED — its turns are dispatched to `group` over the transport and replayed by a co-located
|
|
512
517
|
* worker consumer — instead of run inline. Requires a workflow-task transport (BullMQ). Omit (the
|
|
513
518
|
* default) to keep every `@Workflow` on the inline fast path with zero dispatch round-trips. See
|
|
@@ -651,4 +656,4 @@ declare class WorkflowService {
|
|
|
651
656
|
}): Promise<number>;
|
|
652
657
|
}
|
|
653
658
|
|
|
654
|
-
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_OPTIONS, DURABLE_WORKER_RUNNERS, DeadLetter, type DurableInAppWorkerOptions, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStep, type DurableStepInterceptor, type DurableStepMeta, DurableWorkerModule, type DurableWorkerModuleAsyncOptions, type DurableWorkerModuleOptions, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_OPTIONS, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, RUN_REDIS_WORKER, type RunRedisWorkerFn, STEP_INTERCEPTOR_METADATA, StepInterceptor, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isStepInterceptor };
|
|
659
|
+
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_OPTIONS, DURABLE_WORKER_RUNNERS, DeadLetter, type DurableInAppWorkerOptions, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStep, type DurableStepInterceptor, type DurableStepMeta, DurableWorkerModule, type DurableWorkerModuleAsyncOptions, type DurableWorkerModuleOptions, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_OPTIONS, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, RUN_REDIS_WORKER, type RunRedisWorkerFn, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isStepInterceptor };
|
package/dist/index.d.ts
CHANGED
|
@@ -138,7 +138,12 @@ interface DurableStepMeta {
|
|
|
138
138
|
* (e.g. the event-emitter transport) routes dispatched tasks to it. The method's single
|
|
139
139
|
* argument is the step input; its return value is the step output.
|
|
140
140
|
*/
|
|
141
|
-
declare function
|
|
141
|
+
declare function Step(name: string): MethodDecorator;
|
|
142
|
+
/**
|
|
143
|
+
* @deprecated Use `@Step` instead. `@DurableStep` is a back-compat alias of {@link Step} and
|
|
144
|
+
* writes the same `DURABLE_STEP_METADATA`, so discovery/registrars treat them identically.
|
|
145
|
+
*/
|
|
146
|
+
declare const DurableStep: typeof Step;
|
|
142
147
|
declare function getDurableStepMeta(method: Function): DurableStepMeta | undefined;
|
|
143
148
|
declare const DEAD_LETTER_METADATA: unique symbol;
|
|
144
149
|
/**
|
|
@@ -181,7 +186,7 @@ declare function getOnEvents(meta: WorkflowMeta, target: object): string[];
|
|
|
181
186
|
/**
|
|
182
187
|
* Options for a **store-less thin worker** process: where to consume (`connection`/`prefix`) and
|
|
183
188
|
* which worker `groups` this process serves. There is deliberately NO `store`, `transport`, engine,
|
|
184
|
-
* dashboard, recovery, or timer config — a thin worker only registers `@Workflow`/`@
|
|
189
|
+
* dashboard, recovery, or timer config — a thin worker only registers `@Workflow`/`@Step`
|
|
185
190
|
* handlers and runs the BullMQ consumer (see {@link DurableWorkerModule}).
|
|
186
191
|
*/
|
|
187
192
|
interface DurableWorkerModuleOptions {
|
|
@@ -235,7 +240,7 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
|
|
|
235
240
|
onModuleInit(): void;
|
|
236
241
|
}
|
|
237
242
|
/**
|
|
238
|
-
* Discovers every `@
|
|
243
|
+
* Discovers every `@Step` method and registers it as a step handler on the thin
|
|
239
244
|
* {@link DurableWorkerRuntime}. Mirrors the engine-side `DurableStepRegistrar`, but always registers
|
|
240
245
|
* on the runtime (a thin worker IS the consumer — there is no in-process-vs-queue branch).
|
|
241
246
|
*/
|
|
@@ -266,7 +271,7 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
|
|
|
266
271
|
}
|
|
267
272
|
/**
|
|
268
273
|
* A NestJS dynamic module that turns an app into a **PURE durable worker**: it discovers
|
|
269
|
-
* `@Workflow`/`@
|
|
274
|
+
* `@Workflow`/`@Step` providers, registers them on the thin {@link DurableWorkerRuntime}, and
|
|
270
275
|
* runs one BullMQ consumer per group via `runRedisWorker`. It is **control-plane-less** — it binds
|
|
271
276
|
* NO `WorkflowEngine`, NO store/ORM, NO dashboard, NO timer poller, NO recovery, and NO run dispatch.
|
|
272
277
|
* Use it for a worker pod that only executes work an engine elsewhere coordinates.
|
|
@@ -282,7 +287,7 @@ declare class DurableWorkerModule {
|
|
|
282
287
|
|
|
283
288
|
/**
|
|
284
289
|
* Opt-in config for an **in-app worker**: the same NestJS process runs the engine AND serves its own
|
|
285
|
-
* discovered `@Workflow`/`@
|
|
290
|
+
* discovered `@Workflow`/`@Step` on one default `group`. The engine registers each `@Workflow`
|
|
286
291
|
* GROUP-SERVED (its turns are dispatched to `group` over the transport via a {@link RemoteWorkflowExecutor}
|
|
287
292
|
* instead of run inline), and a co-located {@link DurableWorkerRuntime} consumes `group` and replays the
|
|
288
293
|
* very same TS bodies. This is the uniform-dispatch "one app, both roles" shape — every turn pays a
|
|
@@ -330,7 +335,7 @@ interface InAppWorkerBinding {
|
|
|
330
335
|
executor: WorkflowExecutor;
|
|
331
336
|
}
|
|
332
337
|
/**
|
|
333
|
-
* The consumer half of the in-app worker: on init it registers every discovered `@Workflow`/`@
|
|
338
|
+
* The consumer half of the in-app worker: on init it registers every discovered `@Workflow`/`@Step`
|
|
334
339
|
* on a {@link DurableWorkerRuntime} (the SAME bodies the engine registered group-served), and on bootstrap
|
|
335
340
|
* it starts one `runRedisWorker` consumer on the configured group, closing it on shutdown. A no-op when
|
|
336
341
|
* the app didn't opt in. Mirrors the thin {@link import('./durable-worker.module').DurableWorkerModule},
|
|
@@ -440,7 +445,7 @@ interface DurableModuleOptions {
|
|
|
440
445
|
*/
|
|
441
446
|
deadLetterWorkflow?: WorkflowRef;
|
|
442
447
|
/**
|
|
443
|
-
* Whether this instance plays the **worker** role: register `@
|
|
448
|
+
* Whether this instance plays the **worker** role: register `@Step` handlers (consume the
|
|
444
449
|
* transport), recover incomplete runs on boot, and poll due timers. Defaults to `true`. Set
|
|
445
450
|
* `false` for a **dashboard/dispatch-only** instance (e.g. an API pod) that mounts the control
|
|
446
451
|
* plane and reads the store but must not process or recover workflows — leave that to the workers.
|
|
@@ -507,7 +512,7 @@ interface DurableModuleOptions {
|
|
|
507
512
|
compensationRetries?: number;
|
|
508
513
|
/**
|
|
509
514
|
* Opt into an **in-app worker** (uniform dispatch): the same process runs the engine AND serves its
|
|
510
|
-
* own discovered `@Workflow`/`@
|
|
515
|
+
* own discovered `@Workflow`/`@Step` on one default `group`. Each `@Workflow` is registered
|
|
511
516
|
* GROUP-SERVED — its turns are dispatched to `group` over the transport and replayed by a co-located
|
|
512
517
|
* worker consumer — instead of run inline. Requires a workflow-task transport (BullMQ). Omit (the
|
|
513
518
|
* default) to keep every `@Workflow` on the inline fast path with zero dispatch round-trips. See
|
|
@@ -651,4 +656,4 @@ declare class WorkflowService {
|
|
|
651
656
|
}): Promise<number>;
|
|
652
657
|
}
|
|
653
658
|
|
|
654
|
-
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_OPTIONS, DURABLE_WORKER_RUNNERS, DeadLetter, type DurableInAppWorkerOptions, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStep, type DurableStepInterceptor, type DurableStepMeta, DurableWorkerModule, type DurableWorkerModuleAsyncOptions, type DurableWorkerModuleOptions, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_OPTIONS, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, RUN_REDIS_WORKER, type RunRedisWorkerFn, STEP_INTERCEPTOR_METADATA, StepInterceptor, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isStepInterceptor };
|
|
659
|
+
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_OPTIONS, DURABLE_WORKER_RUNNERS, DeadLetter, type DurableInAppWorkerOptions, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStep, type DurableStepInterceptor, type DurableStepMeta, DurableWorkerModule, type DurableWorkerModuleAsyncOptions, type DurableWorkerModuleOptions, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_OPTIONS, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, RUN_REDIS_WORKER, type RunRedisWorkerFn, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isStepInterceptor };
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ function getWorkflowMeta(target) {
|
|
|
39
39
|
}
|
|
40
40
|
__name(getWorkflowMeta, "getWorkflowMeta");
|
|
41
41
|
var DURABLE_STEP_METADATA = Symbol("nestjs-durable:step-handler");
|
|
42
|
-
function
|
|
42
|
+
function Step(name) {
|
|
43
43
|
return (_target, _propertyKey, descriptor) => {
|
|
44
44
|
const meta = {
|
|
45
45
|
name
|
|
@@ -48,7 +48,8 @@ function DurableStep(name) {
|
|
|
48
48
|
return descriptor;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
__name(
|
|
51
|
+
__name(Step, "Step");
|
|
52
|
+
var DurableStep = Step;
|
|
52
53
|
function getDurableStepMeta(method) {
|
|
53
54
|
return Reflect.getMetadata(DURABLE_STEP_METADATA, method);
|
|
54
55
|
}
|
|
@@ -1211,6 +1212,7 @@ export {
|
|
|
1211
1212
|
OnEvent,
|
|
1212
1213
|
RUN_REDIS_WORKER,
|
|
1213
1214
|
STEP_INTERCEPTOR_METADATA,
|
|
1215
|
+
Step,
|
|
1214
1216
|
StepInterceptor,
|
|
1215
1217
|
ThinStepRegistrar,
|
|
1216
1218
|
ThinWorkerBootstrap,
|