@dudousxd/nestjs-durable 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.
@@ -0,0 +1,28 @@
1
+ import 'reflect-metadata';
2
+ export declare const WORKFLOW_METADATA: unique symbol;
3
+ export interface WorkflowMeta {
4
+ name: string;
5
+ version: string;
6
+ }
7
+ export interface WorkflowOptions {
8
+ name: string;
9
+ version?: string;
10
+ }
11
+ /**
12
+ * Marks a provider class as a durable workflow. Its `run(ctx, input)` method becomes the
13
+ * workflow function the engine executes and replays.
14
+ */
15
+ export declare function Workflow(options: WorkflowOptions): ClassDecorator;
16
+ export declare function getWorkflowMeta(target: Function): WorkflowMeta | undefined;
17
+ export declare const DURABLE_STEP_METADATA: unique symbol;
18
+ export interface DurableStepMeta {
19
+ name: string;
20
+ }
21
+ /**
22
+ * Marks a provider method as the handler for a remote step `name`. An in-process transport
23
+ * (e.g. the event-emitter transport) routes dispatched tasks to it. The method's single
24
+ * argument is the step input; its return value is the step output.
25
+ */
26
+ export declare function DurableStep(name: string): MethodDecorator;
27
+ export declare function getDurableStepMeta(method: Function): DurableStepMeta | undefined;
28
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +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;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAKjE;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"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DURABLE_STEP_METADATA = exports.WORKFLOW_METADATA = void 0;
4
+ exports.Workflow = Workflow;
5
+ exports.getWorkflowMeta = getWorkflowMeta;
6
+ exports.DurableStep = DurableStep;
7
+ exports.getDurableStepMeta = getDurableStepMeta;
8
+ require("reflect-metadata");
9
+ exports.WORKFLOW_METADATA = Symbol('nestjs-durable:workflow');
10
+ /**
11
+ * Marks a provider class as a durable workflow. Its `run(ctx, input)` method becomes the
12
+ * workflow function the engine executes and replays.
13
+ */
14
+ function Workflow(options) {
15
+ return (target) => {
16
+ const meta = { name: options.name, version: options.version ?? '1' };
17
+ Reflect.defineMetadata(exports.WORKFLOW_METADATA, meta, target);
18
+ };
19
+ }
20
+ // biome-ignore lint/complexity/noBannedTypes: matches reflect-metadata's class target type
21
+ function getWorkflowMeta(target) {
22
+ return Reflect.getMetadata(exports.WORKFLOW_METADATA, target);
23
+ }
24
+ exports.DURABLE_STEP_METADATA = Symbol('nestjs-durable:step-handler');
25
+ /**
26
+ * Marks a provider method as the handler for a remote step `name`. An in-process transport
27
+ * (e.g. the event-emitter transport) routes dispatched tasks to it. The method's single
28
+ * argument is the step input; its return value is the step output.
29
+ */
30
+ function DurableStep(name) {
31
+ return (_target, _propertyKey, descriptor) => {
32
+ const meta = { name };
33
+ Reflect.defineMetadata(exports.DURABLE_STEP_METADATA, meta, descriptor.value);
34
+ return descriptor;
35
+ };
36
+ }
37
+ // biome-ignore lint/complexity/noBannedTypes: reflect-metadata reads from the method function
38
+ function getDurableStepMeta(method) {
39
+ return Reflect.getMetadata(exports.DURABLE_STEP_METADATA, method);
40
+ }
41
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAkBA,4BAKC;AAGD,0CAEC;AAaD,kCAMC;AAGD,gDAEC;AApDD,4BAA0B;AAEb,QAAA,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAYnE;;;GAGG;AACH,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,IAAI,GAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QACnF,OAAO,CAAC,cAAc,CAAC,yBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1D,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"}
@@ -0,0 +1,16 @@
1
+ import { type Transport } from '@dudousxd/nestjs-durable-core';
2
+ import { type OnModuleInit } from '@nestjs/common';
3
+ import { DiscoveryService, MetadataScanner } from '@nestjs/core';
4
+ /**
5
+ * Discovers `@DurableStep` methods and registers them as step handlers on the configured
6
+ * transport, when that transport runs handlers in-process. With a queue/remote transport the
7
+ * handlers live in the worker process instead, so there is nothing to wire here.
8
+ */
9
+ export declare class DurableStepRegistrar implements OnModuleInit {
10
+ private readonly discovery;
11
+ private readonly metadataScanner;
12
+ private readonly transport;
13
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, transport: Transport | null);
14
+ onModuleInit(): void;
15
+ }
16
+ //# sourceMappingURL=durable-step.registrar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-step.registrar.d.ts","sourceRoot":"","sources":["../src/durable-step.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAYjE;;;;GAIG;AACH,qBACa,oBAAqB,YAAW,YAAY;IAErD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAF5B,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EACb,SAAS,EAAE,SAAS,GAAG,IAAI;IAGjE,YAAY,IAAI,IAAI;CAiBrB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DurableStepRegistrar = void 0;
16
+ const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
17
+ const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@nestjs/core");
19
+ const decorators_1 = require("./decorators");
20
+ function supportsHandle(transport) {
21
+ return typeof transport?.handle === 'function';
22
+ }
23
+ /**
24
+ * Discovers `@DurableStep` methods and registers them as step handlers on the configured
25
+ * transport, when that transport runs handlers in-process. With a queue/remote transport the
26
+ * handlers live in the worker process instead, so there is nothing to wire here.
27
+ */
28
+ let DurableStepRegistrar = class DurableStepRegistrar {
29
+ discovery;
30
+ metadataScanner;
31
+ transport;
32
+ constructor(discovery, metadataScanner, transport) {
33
+ this.discovery = discovery;
34
+ this.metadataScanner = metadataScanner;
35
+ this.transport = transport;
36
+ }
37
+ onModuleInit() {
38
+ if (!supportsHandle(this.transport))
39
+ return;
40
+ const transport = this.transport;
41
+ for (const wrapper of this.discovery.getProviders()) {
42
+ const { instance } = wrapper;
43
+ if (!instance || typeof instance !== 'object')
44
+ continue;
45
+ const prototype = Object.getPrototypeOf(instance);
46
+ for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {
47
+ const method = instance[methodName];
48
+ if (typeof method !== 'function')
49
+ continue;
50
+ const meta = (0, decorators_1.getDurableStepMeta)(method);
51
+ if (!meta)
52
+ continue;
53
+ transport.handle(meta.name, (input) => instance[methodName](input));
54
+ }
55
+ }
56
+ }
57
+ };
58
+ exports.DurableStepRegistrar = DurableStepRegistrar;
59
+ exports.DurableStepRegistrar = DurableStepRegistrar = __decorate([
60
+ (0, common_1.Injectable)(),
61
+ __param(2, (0, common_1.Inject)(nestjs_durable_core_1.TRANSPORT)),
62
+ __metadata("design:paramtypes", [core_1.DiscoveryService,
63
+ core_1.MetadataScanner, Object])
64
+ ], DurableStepRegistrar);
65
+ //# sourceMappingURL=durable-step.registrar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-step.registrar.js","sourceRoot":"","sources":["../src/durable-step.registrar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAA0E;AAC1E,2CAAuE;AACvE,uCAAiE;AACjE,6CAAkD;AAOlD,SAAS,cAAc,CAAC,SAAkB;IACxC,OAAO,OAAQ,SAAsC,EAAE,MAAM,KAAK,UAAU,CAAC;AAC/E,CAAC;AAED;;;;GAIG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEZ;IACA;IACmB;IAHtC,YACmB,SAA2B,EAC3B,eAAgC,EACb,SAA2B;QAF9C,cAAS,GAAT,SAAS,CAAkB;QAC3B,oBAAe,GAAf,eAAe,CAAiB;QACb,cAAS,GAAT,SAAS,CAAkB;IAC9D,CAAC;IAEJ,YAAY;QACV,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,OAAO;QAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC;YACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC7B,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;gBAAE,SAAS;YACxD,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YAClD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3E,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACpC,IAAI,OAAO,MAAM,KAAK,UAAU;oBAAE,SAAS;gBAC3C,MAAM,IAAI,GAAG,IAAA,+BAAkB,EAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI;oBAAE,SAAS;gBACpB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAxBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,+BAAS,CAAC,CAAA;qCAFU,uBAAgB;QACV,sBAAe;GAHxC,oBAAoB,CAwBhC"}
@@ -0,0 +1,32 @@
1
+ import { type StateStore, type Transport } from '@dudousxd/nestjs-durable-core';
2
+ import { type DynamicModule, type InjectionToken } from '@nestjs/common';
3
+ export interface DurableModuleOptions {
4
+ store: StateStore;
5
+ transport?: Transport;
6
+ /** Interval (ms) for the durable-timer poller. `0` disables it. Defaults to 1000. */
7
+ timerPollMs?: number;
8
+ /**
9
+ * Auto-create the durable tables on boot via `store.ensureSchema()`. Defaults to true. Turn
10
+ * off in production and call the store adapter's `ensure*DurableSchema()` from a migration.
11
+ */
12
+ autoSchema?: boolean;
13
+ /**
14
+ * Multi-instance recovery lease, in ms — how long an instance owns a run it picked up before
15
+ * another may take over. Defaults to 30000. Set above your longest synchronous run.
16
+ */
17
+ leaseMs?: number;
18
+ /** Unique id for this instance (for leases). Defaults to a random id. */
19
+ instanceId?: string;
20
+ /** Max ms to wait for in-flight runs on shutdown before exiting. Defaults to 10000. */
21
+ shutdownTimeoutMs?: number;
22
+ }
23
+ export interface DurableModuleAsyncOptions {
24
+ useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
25
+ inject?: InjectionToken[];
26
+ }
27
+ export declare class DurableModule {
28
+ static forRoot(options: DurableModuleOptions): DynamicModule;
29
+ static forRootAsync(options: DurableModuleAsyncOptions): DynamicModule;
30
+ private static build;
31
+ }
32
+ //# sourceMappingURL=durable.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable.module.d.ts","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,SAAS,EAEf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAyB,MAAM,gBAAgB,CAAC;AAOhG,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvF,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;CAwCrB"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var DurableModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DurableModule = void 0;
11
+ const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
12
+ const common_1 = require("@nestjs/common");
13
+ const core_1 = require("@nestjs/core");
14
+ const durable_step_registrar_1 = require("./durable-step.registrar");
15
+ const timer_poller_1 = require("./timer-poller");
16
+ const workflow_registrar_1 = require("./workflow.registrar");
17
+ const workflow_service_1 = require("./workflow.service");
18
+ let DurableModule = DurableModule_1 = class DurableModule {
19
+ static forRoot(options) {
20
+ return DurableModule_1.build({ provide: nestjs_durable_core_1.DURABLE_OPTIONS, useValue: options });
21
+ }
22
+ static forRootAsync(options) {
23
+ return DurableModule_1.build({
24
+ provide: nestjs_durable_core_1.DURABLE_OPTIONS,
25
+ useFactory: options.useFactory,
26
+ inject: options.inject ?? [],
27
+ });
28
+ }
29
+ static build(optionsProvider) {
30
+ return {
31
+ module: DurableModule_1,
32
+ global: true,
33
+ imports: [core_1.DiscoveryModule],
34
+ providers: [
35
+ optionsProvider,
36
+ {
37
+ provide: nestjs_durable_core_1.STATE_STORE,
38
+ useFactory: (options) => options.store,
39
+ inject: [nestjs_durable_core_1.DURABLE_OPTIONS],
40
+ },
41
+ {
42
+ provide: nestjs_durable_core_1.TRANSPORT,
43
+ useFactory: (options) => options.transport ?? null,
44
+ inject: [nestjs_durable_core_1.DURABLE_OPTIONS],
45
+ },
46
+ {
47
+ provide: nestjs_durable_core_1.WorkflowEngine,
48
+ useFactory: (store, transport, opts) => new nestjs_durable_core_1.WorkflowEngine({
49
+ store,
50
+ transport: transport ?? undefined,
51
+ leaseMs: opts.leaseMs,
52
+ instanceId: opts.instanceId,
53
+ }),
54
+ inject: [nestjs_durable_core_1.STATE_STORE, nestjs_durable_core_1.TRANSPORT, nestjs_durable_core_1.DURABLE_OPTIONS],
55
+ },
56
+ workflow_service_1.WorkflowService,
57
+ workflow_registrar_1.WorkflowRegistrar,
58
+ durable_step_registrar_1.DurableStepRegistrar,
59
+ timer_poller_1.TimerPoller,
60
+ ],
61
+ exports: [workflow_service_1.WorkflowService, nestjs_durable_core_1.WorkflowEngine, nestjs_durable_core_1.STATE_STORE, nestjs_durable_core_1.TRANSPORT],
62
+ };
63
+ }
64
+ };
65
+ exports.DurableModule = DurableModule;
66
+ exports.DurableModule = DurableModule = DurableModule_1 = __decorate([
67
+ (0, common_1.Module)({})
68
+ ], DurableModule);
69
+ //# sourceMappingURL=durable.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable.module.js","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uEAOuC;AACvC,2CAAgG;AAChG,uCAA+C;AAC/C,qEAAgE;AAChE,iDAA6C;AAC7C,6DAAyD;AACzD,yDAAqD;AA6B9C,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAA6B;QAC1C,OAAO,eAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,qCAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAkC;QACpD,OAAO,eAAa,CAAC,KAAK,CAAC;YACzB,OAAO,EAAE,qCAAe;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,eAAyB;QAC5C,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,CAAC,sBAAe,CAAC;YAC1B,SAAS,EAAE;gBACT,eAAe;gBACf;oBACE,OAAO,EAAE,iCAAW;oBACpB,UAAU,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK;oBAC5D,MAAM,EAAE,CAAC,qCAAe,CAAC;iBAC1B;gBACD;oBACE,OAAO,EAAE,+BAAS;oBAClB,UAAU,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI;oBACxE,MAAM,EAAE,CAAC,qCAAe,CAAC;iBAC1B;gBACD;oBACE,OAAO,EAAE,oCAAc;oBACvB,UAAU,EAAE,CACV,KAAiB,EACjB,SAA2B,EAC3B,IAA0B,EAC1B,EAAE,CACF,IAAI,oCAAc,CAAC;wBACjB,KAAK;wBACL,SAAS,EAAE,SAAS,IAAI,SAAS;wBACjC,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,UAAU,EAAE,IAAI,CAAC,UAAU;qBAC5B,CAAC;oBACJ,MAAM,EAAE,CAAC,iCAAW,EAAE,+BAAS,EAAE,qCAAe,CAAC;iBAClD;gBACD,kCAAe;gBACf,sCAAiB;gBACjB,6CAAoB;gBACpB,0BAAW;aACZ;YACD,OAAO,EAAE,CAAC,kCAAe,EAAE,oCAAc,EAAE,iCAAW,EAAE,+BAAS,CAAC;SACnE,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAqDzB"}
@@ -0,0 +1,4 @@
1
+ export * from './decorators';
2
+ export * from './durable.module';
3
+ export * from './workflow.service';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./decorators"), exports);
18
+ __exportStar(require("./durable.module"), exports);
19
+ __exportStar(require("./workflow.service"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,qDAAmC"}
@@ -0,0 +1,19 @@
1
+ import { WorkflowEngine } from '@dudousxd/nestjs-durable-core';
2
+ import { type OnApplicationBootstrap, type OnModuleDestroy } from '@nestjs/common';
3
+ import type { DurableModuleOptions } from './durable.module';
4
+ /**
5
+ * Resumes suspended runs whose durable timer (`ctx.sleep`) is due — once on boot, then on an
6
+ * interval. Set `timerPollMs` to `0` to disable the interval (e.g. when an external scheduler
7
+ * drives `WorkflowEngine.resumeDueTimers`).
8
+ */
9
+ export declare class TimerPoller implements OnApplicationBootstrap, OnModuleDestroy {
10
+ private readonly engine;
11
+ private readonly options;
12
+ private timer?;
13
+ private polling;
14
+ constructor(engine: WorkflowEngine, options: DurableModuleOptions);
15
+ onApplicationBootstrap(): Promise<void>;
16
+ onModuleDestroy(): void;
17
+ private poll;
18
+ }
19
+ //# sourceMappingURL=timer-poller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-poller.d.ts","sourceRoot":"","sources":["../src/timer-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;GAIG;AACH,qBACa,WAAY,YAAW,sBAAsB,EAAE,eAAe;IAKvE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACE,OAAO,CAAC,QAAQ,CAAC,OAAO;IALnD,OAAO,CAAC,KAAK,CAAC,CAAiC;IAC/C,OAAO,CAAC,OAAO,CAAS;gBAGL,MAAM,EAAE,cAAc,EACG,OAAO,EAAE,oBAAoB;IAGnE,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAS7C,eAAe,IAAI,IAAI;YAIT,IAAI;CASnB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TimerPoller = void 0;
16
+ const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
17
+ const common_1 = require("@nestjs/common");
18
+ /**
19
+ * Resumes suspended runs whose durable timer (`ctx.sleep`) is due — once on boot, then on an
20
+ * interval. Set `timerPollMs` to `0` to disable the interval (e.g. when an external scheduler
21
+ * drives `WorkflowEngine.resumeDueTimers`).
22
+ */
23
+ let TimerPoller = class TimerPoller {
24
+ engine;
25
+ options;
26
+ timer;
27
+ polling = false;
28
+ constructor(engine, options) {
29
+ this.engine = engine;
30
+ this.options = options;
31
+ }
32
+ async onApplicationBootstrap() {
33
+ await this.poll();
34
+ const intervalMs = this.options.timerPollMs ?? 1_000;
35
+ if (intervalMs > 0) {
36
+ this.timer = setInterval(() => void this.poll(), intervalMs);
37
+ this.timer.unref?.();
38
+ }
39
+ }
40
+ onModuleDestroy() {
41
+ if (this.timer)
42
+ clearInterval(this.timer);
43
+ }
44
+ async poll() {
45
+ if (this.polling)
46
+ return; // never overlap two sweeps
47
+ this.polling = true;
48
+ try {
49
+ await this.engine.resumeDueTimers();
50
+ }
51
+ finally {
52
+ this.polling = false;
53
+ }
54
+ }
55
+ };
56
+ exports.TimerPoller = TimerPoller;
57
+ exports.TimerPoller = TimerPoller = __decorate([
58
+ (0, common_1.Injectable)(),
59
+ __param(1, (0, common_1.Inject)(nestjs_durable_core_1.DURABLE_OPTIONS)),
60
+ __metadata("design:paramtypes", [nestjs_durable_core_1.WorkflowEngine, Object])
61
+ ], TimerPoller);
62
+ //# sourceMappingURL=timer-poller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-poller.js","sourceRoot":"","sources":["../src/timer-poller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAAgF;AAChF,2CAKwB;AAGxB;;;;GAIG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAKH;IACyB;IALpC,KAAK,CAAkC;IACvC,OAAO,GAAG,KAAK,CAAC;IAExB,YACmB,MAAsB,EACG,OAA6B;QADtD,WAAM,GAAN,MAAM,CAAgB;QACG,YAAO,GAAP,OAAO,CAAsB;IACtE,CAAC;IAEJ,KAAK,CAAC,sBAAsB;QAC1B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC;QACrD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;YAC7D,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,KAAK;YAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,CAAC,2BAA2B;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACtC,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;CACF,CAAA;AA/BY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,qCAAe,CAAC,CAAA;qCADC,oCAAc;GAL9B,WAAW,CA+BvB"}
@@ -0,0 +1,22 @@
1
+ import { type StateStore, WorkflowEngine } from '@dudousxd/nestjs-durable-core';
2
+ import { type OnApplicationBootstrap, type OnApplicationShutdown, type OnModuleInit } from '@nestjs/common';
3
+ import { DiscoveryService } from '@nestjs/core';
4
+ import type { DurableModuleOptions } from './durable.module';
5
+ /**
6
+ * Ensures the schema (auto-schema) and registers `@Workflow` providers on init, resumes runs left
7
+ * incomplete by a previous process once booted, and drains in-flight runs on shutdown.
8
+ *
9
+ * For the shutdown drain to fire, enable Nest's shutdown hooks: `app.enableShutdownHooks()`.
10
+ */
11
+ export declare class WorkflowRegistrar implements OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown {
12
+ private readonly discovery;
13
+ private readonly engine;
14
+ private readonly store;
15
+ private readonly options;
16
+ constructor(discovery: DiscoveryService, engine: WorkflowEngine, store: StateStore, options: DurableModuleOptions);
17
+ onApplicationBootstrap(): Promise<void>;
18
+ /** On deploy/shutdown: stop picking up new runs and wait for in-flight ones to settle. */
19
+ onApplicationShutdown(): Promise<void>;
20
+ onModuleInit(): Promise<void>;
21
+ }
22
+ //# sourceMappingURL=workflow.registrar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.registrar.d.ts","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,cAAc,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAM7D;;;;;GAKG;AACH,qBACa,iBACX,YAAW,YAAY,EAAE,sBAAsB,EAAE,qBAAqB;IAGpE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACF,OAAO,CAAC,QAAQ,CAAC,KAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHhC,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,cAAc,EACD,KAAK,EAAE,UAAU,EACb,OAAO,EAAE,oBAAoB;IAGnE,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7C,0FAA0F;IACpF,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBpC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WorkflowRegistrar = void 0;
16
+ const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
17
+ const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@nestjs/core");
19
+ const decorators_1 = require("./decorators");
20
+ /**
21
+ * Ensures the schema (auto-schema) and registers `@Workflow` providers on init, resumes runs left
22
+ * incomplete by a previous process once booted, and drains in-flight runs on shutdown.
23
+ *
24
+ * For the shutdown drain to fire, enable Nest's shutdown hooks: `app.enableShutdownHooks()`.
25
+ */
26
+ let WorkflowRegistrar = class WorkflowRegistrar {
27
+ discovery;
28
+ engine;
29
+ store;
30
+ options;
31
+ constructor(discovery, engine, store, options) {
32
+ this.discovery = discovery;
33
+ this.engine = engine;
34
+ this.store = store;
35
+ this.options = options;
36
+ }
37
+ async onApplicationBootstrap() {
38
+ await this.engine.recoverIncomplete();
39
+ }
40
+ /** On deploy/shutdown: stop picking up new runs and wait for in-flight ones to settle. */
41
+ async onApplicationShutdown() {
42
+ await this.engine.drain(this.options.shutdownTimeoutMs);
43
+ }
44
+ async onModuleInit() {
45
+ if (this.options.autoSchema !== false) {
46
+ await this.store.ensureSchema?.();
47
+ }
48
+ for (const wrapper of this.discovery.getProviders()) {
49
+ const { instance } = wrapper;
50
+ if (!instance || typeof instance !== 'object')
51
+ continue;
52
+ const meta = (0, decorators_1.getWorkflowMeta)(instance.constructor);
53
+ if (!meta)
54
+ continue;
55
+ const workflow = instance;
56
+ if (typeof workflow.run !== 'function') {
57
+ throw new Error(`@Workflow ${meta.name} must define a run(ctx, input) method`);
58
+ }
59
+ this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input));
60
+ }
61
+ }
62
+ };
63
+ exports.WorkflowRegistrar = WorkflowRegistrar;
64
+ exports.WorkflowRegistrar = WorkflowRegistrar = __decorate([
65
+ (0, common_1.Injectable)(),
66
+ __param(2, (0, common_1.Inject)(nestjs_durable_core_1.STATE_STORE)),
67
+ __param(3, (0, common_1.Inject)(nestjs_durable_core_1.DURABLE_OPTIONS)),
68
+ __metadata("design:paramtypes", [core_1.DiscoveryService,
69
+ nestjs_durable_core_1.WorkflowEngine, Object, Object])
70
+ ], WorkflowRegistrar);
71
+ //# sourceMappingURL=workflow.registrar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.registrar.js","sourceRoot":"","sources":["../src/workflow.registrar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAMuC;AACvC,2CAMwB;AACxB,uCAAgD;AAChD,6CAA+C;AAO/C;;;;;GAKG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAIT;IACA;IACqB;IACI;IAJ5C,YACmB,SAA2B,EAC3B,MAAsB,EACD,KAAiB,EACb,OAA6B;QAHtD,cAAS,GAAT,SAAS,CAAkB;QAC3B,WAAM,GAAN,MAAM,CAAgB;QACD,UAAK,GAAL,KAAK,CAAY;QACb,YAAO,GAAP,OAAO,CAAsB;IACtE,CAAC;IAEJ,KAAK,CAAC,sBAAsB;QAC1B,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACxC,CAAC;IAED,0FAA0F;IAC1F,KAAK,CAAC,qBAAqB;QACzB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC;YACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC7B,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;gBAAE,SAAS;YACxD,MAAM,IAAI,GAAG,IAAA,4BAAe,EAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACnD,IAAI,CAAC,IAAI;gBAAE,SAAS;YACpB,MAAM,QAAQ,GAAG,QAA4B,CAAC;YAC9C,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,IAAI,uCAAuC,CAAC,CAAC;YACjF,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;CACF,CAAA;AAnCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,iCAAW,CAAC,CAAA;IACnB,WAAA,IAAA,eAAM,EAAC,qCAAe,CAAC,CAAA;qCAHI,uBAAgB;QACnB,oCAAc;GAL9B,iBAAiB,CAmC7B"}
@@ -0,0 +1,11 @@
1
+ import { type RunResult, WorkflowEngine } from '@dudousxd/nestjs-durable-core';
2
+ /** Public entry point for starting and resuming workflow runs. */
3
+ export declare class WorkflowService {
4
+ private readonly engine;
5
+ constructor(engine: WorkflowEngine);
6
+ start(workflow: string, input: unknown, runId?: string): Promise<RunResult>;
7
+ resume(runId: string): Promise<RunResult>;
8
+ /** Deliver an external signal (e.g. from a webhook) to the run waiting on `token`. */
9
+ signal(token: string, payload: unknown): Promise<RunResult | null>;
10
+ }
11
+ //# sourceMappingURL=workflow.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.service.d.ts","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/E,kEAAkE;AAClE,qBACa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,cAAc;IAEnD,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,GAAE,MAAqB,GAAG,OAAO,CAAC,SAAS,CAAC;IAIzF,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"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WorkflowService = void 0;
13
+ const node_crypto_1 = require("node:crypto");
14
+ const nestjs_durable_core_1 = require("@dudousxd/nestjs-durable-core");
15
+ const common_1 = require("@nestjs/common");
16
+ /** Public entry point for starting and resuming workflow runs. */
17
+ let WorkflowService = class WorkflowService {
18
+ engine;
19
+ constructor(engine) {
20
+ this.engine = engine;
21
+ }
22
+ start(workflow, input, runId = (0, node_crypto_1.randomUUID)()) {
23
+ return this.engine.start(workflow, input, runId);
24
+ }
25
+ resume(runId) {
26
+ return this.engine.resume(runId);
27
+ }
28
+ /** Deliver an external signal (e.g. from a webhook) to the run waiting on `token`. */
29
+ signal(token, payload) {
30
+ return this.engine.signal(token, payload);
31
+ }
32
+ };
33
+ exports.WorkflowService = WorkflowService;
34
+ exports.WorkflowService = WorkflowService = __decorate([
35
+ (0, common_1.Injectable)(),
36
+ __metadata("design:paramtypes", [nestjs_durable_core_1.WorkflowEngine])
37
+ ], WorkflowService);
38
+ //# sourceMappingURL=workflow.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.service.js","sourceRoot":"","sources":["../src/workflow.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AACzC,uEAA+E;AAC/E,2CAA4C;AAE5C,kEAAkE;AAE3D,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAEvD,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;AAfY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAE0B,oCAAc;GADxC,eAAe,CAe3B"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@dudousxd/nestjs-durable",
3
+ "version": "0.1.0",
4
+ "description": "Durable workflows for NestJS — module, decorators, discovery and boot recovery",
5
+ "license": "MIT",
6
+ "author": "Davide Carvalho",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/DavideCarvalho/nestjs-durable.git",
10
+ "directory": "packages/nestjs"
11
+ },
12
+ "type": "commonjs",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "@dudousxd/nestjs-durable-core": ">=0.1.0 <1.0.0",
20
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
21
+ "@nestjs/core": "^10.0.0 || ^11.0.0",
22
+ "reflect-metadata": "^0.2.0"
23
+ },
24
+ "devDependencies": {
25
+ "@nestjs/common": "11.1.26",
26
+ "@nestjs/core": "11.1.26",
27
+ "@nestjs/event-emitter": "3.1.0",
28
+ "@nestjs/testing": "11.1.26",
29
+ "eventemitter2": "6.4.9",
30
+ "reflect-metadata": "0.2.2",
31
+ "rxjs": "7.8.2",
32
+ "typescript": "5.9.3",
33
+ "zod": "3.25.76",
34
+ "@dudousxd/nestjs-durable-core": "^0.1.0",
35
+ "@dudousxd/nestjs-durable-transport-event-emitter": "^0.1.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.json",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit"
40
+ }
41
+ }