@duraflows/nestjs 4.1.0 → 5.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 CHANGED
@@ -33,6 +33,15 @@ You will also need a persistence adapter such as [`@duraflows/pg`](https://www.n
33
33
  pnpm add @duraflows/pg pg
34
34
  ```
35
35
 
36
+ ### Compatibility
37
+
38
+ | NestJS | Supported | Notes |
39
+ | ------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
40
+ | 12.x | ✅ | NestJS 12 ships ESM-only. CommonJS apps load it through `require(esm)`, which needs **Node.js ≥ 20.19 or ≥ 22.12** (a NestJS requirement, not a duraflows one). |
41
+ | 11.x | ✅ | From `11.0.0`. |
42
+
43
+ The same `@duraflows/nestjs` release works on both majors, from both CommonJS and ESM apps. No duraflows changes are needed when you upgrade an app from NestJS 11 to 12.
44
+
36
45
  ## Quick Start
37
46
 
38
47
  ### Module Registration
@@ -2,7 +2,7 @@ export { WorkflowModule } from "./workflow.module.js";
2
2
  export type { WorkflowModuleOptions, WorkflowModuleAsyncOptions, WorkflowModuleFactoryConfig, } from "./workflow.module.js";
3
3
  export { WorkflowService } from "./services/workflow.service.js";
4
4
  export { WorkflowTimeoutService } from "./services/workflow-timeout.service.js";
5
- export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, } from "./providers/injection-tokens.js";
5
+ export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, WORKFLOW_DEFINITION_STORE, } from "./providers/injection-tokens.js";
6
6
  export { NestCommandRegistry } from "./providers/nest-command-registry.js";
7
7
  export type { WorkflowCommandRegistration } from "./providers/nest-command-registry.js";
8
8
  export { WorkflowCommand, WORKFLOW_COMMAND_METADATA_KEY } from "./decorators/workflow-command.decorator.js";
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InMemoryGuardRegistry = exports.InMemoryCommandRegistry = exports.InMemoryDefinitionRegistry = exports.WorkflowHandle = exports.WorkflowRuntime = exports.TimeoutResolver = exports.OnEnterExecutor = exports.EventExecutor = exports.CommandExecutor = exports.WorkflowCompiler = exports.WorkflowValidator = exports.OnEnterDepthExceededError = exports.CommandFailureError = exports.InvalidEventError = exports.WorkflowInstanceNotFoundError = exports.WorkflowDefinitionError = exports.WorkflowError = exports.CreateInstanceDto = exports.TimeoutProcessQueryDto = exports.AvailableEventsParamsDto = exports.HistoryParamsDto = exports.HistoryQueryDto = exports.TriggerEventParamsDto = exports.TriggerEventDto = exports.WorkflowExceptionFilter = exports.WorkflowTimeoutController = exports.WorkflowQueryController = exports.WorkflowEventController = exports.WorkflowInstanceController = exports.WORKFLOW_COMMAND_METADATA_KEY = exports.WorkflowCommand = exports.NestCommandRegistry = exports.WORKFLOW_CLOCK = exports.WORKFLOW_TRANSACTION_RUNNER = exports.WORKFLOW_DEFINITION_REGISTRY = exports.WORKFLOW_GUARD_REGISTRY = exports.WORKFLOW_COMMAND_REGISTRY = exports.WORKFLOW_HISTORY_STORE = exports.WORKFLOW_INSTANCE_STORE = exports.WORKFLOW_RUNTIME = exports.WorkflowTimeoutService = exports.WorkflowService = exports.WorkflowModule = void 0;
3
+ exports.InMemoryGuardRegistry = exports.InMemoryCommandRegistry = exports.InMemoryDefinitionRegistry = exports.WorkflowHandle = exports.WorkflowRuntime = exports.TimeoutResolver = exports.OnEnterExecutor = exports.EventExecutor = exports.CommandExecutor = exports.WorkflowCompiler = exports.WorkflowValidator = exports.OnEnterDepthExceededError = exports.CommandFailureError = exports.InvalidEventError = exports.WorkflowInstanceNotFoundError = exports.WorkflowDefinitionError = exports.WorkflowError = exports.CreateInstanceDto = exports.TimeoutProcessQueryDto = exports.AvailableEventsParamsDto = exports.HistoryParamsDto = exports.HistoryQueryDto = exports.TriggerEventParamsDto = exports.TriggerEventDto = exports.WorkflowExceptionFilter = exports.WorkflowTimeoutController = exports.WorkflowQueryController = exports.WorkflowEventController = exports.WorkflowInstanceController = exports.WORKFLOW_COMMAND_METADATA_KEY = exports.WorkflowCommand = exports.NestCommandRegistry = exports.WORKFLOW_DEFINITION_STORE = exports.WORKFLOW_CLOCK = exports.WORKFLOW_TRANSACTION_RUNNER = exports.WORKFLOW_DEFINITION_REGISTRY = exports.WORKFLOW_GUARD_REGISTRY = exports.WORKFLOW_COMMAND_REGISTRY = exports.WORKFLOW_HISTORY_STORE = exports.WORKFLOW_INSTANCE_STORE = exports.WORKFLOW_RUNTIME = exports.WorkflowTimeoutService = exports.WorkflowService = exports.WorkflowModule = void 0;
4
4
  // Module
5
5
  var workflow_module_js_1 = require("./workflow.module.js");
6
6
  Object.defineProperty(exports, "WorkflowModule", { enumerable: true, get: function () { return workflow_module_js_1.WorkflowModule; } });
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "WORKFLOW_GUARD_REGISTRY", { enumerable: true, ge
19
19
  Object.defineProperty(exports, "WORKFLOW_DEFINITION_REGISTRY", { enumerable: true, get: function () { return injection_tokens_js_1.WORKFLOW_DEFINITION_REGISTRY; } });
20
20
  Object.defineProperty(exports, "WORKFLOW_TRANSACTION_RUNNER", { enumerable: true, get: function () { return injection_tokens_js_1.WORKFLOW_TRANSACTION_RUNNER; } });
21
21
  Object.defineProperty(exports, "WORKFLOW_CLOCK", { enumerable: true, get: function () { return injection_tokens_js_1.WORKFLOW_CLOCK; } });
22
+ Object.defineProperty(exports, "WORKFLOW_DEFINITION_STORE", { enumerable: true, get: function () { return injection_tokens_js_1.WORKFLOW_DEFINITION_STORE; } });
22
23
  var nest_command_registry_js_1 = require("./providers/nest-command-registry.js");
23
24
  Object.defineProperty(exports, "NestCommandRegistry", { enumerable: true, get: function () { return nest_command_registry_js_1.NestCommandRegistry; } });
24
25
  // Decorators
@@ -6,6 +6,7 @@ export declare const WORKFLOW_DEFINITION_REGISTRY: unique symbol;
6
6
  export declare const WORKFLOW_TRANSACTION_RUNNER: unique symbol;
7
7
  export declare const WORKFLOW_CLOCK: unique symbol;
8
8
  export declare const WORKFLOW_GUARD_REGISTRY: unique symbol;
9
+ export declare const WORKFLOW_DEFINITION_STORE: unique symbol;
9
10
  /**
10
11
  * The resolved module configuration. Deliberately not re-exported from the
11
12
  * package barrel: it exists so `forRoot` and `forRootAsync` can publish their
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WORKFLOW_MODULE_OPTIONS = exports.WORKFLOW_GUARD_REGISTRY = exports.WORKFLOW_CLOCK = exports.WORKFLOW_TRANSACTION_RUNNER = exports.WORKFLOW_DEFINITION_REGISTRY = exports.WORKFLOW_COMMAND_REGISTRY = exports.WORKFLOW_HISTORY_STORE = exports.WORKFLOW_INSTANCE_STORE = exports.WORKFLOW_RUNTIME = void 0;
3
+ exports.WORKFLOW_MODULE_OPTIONS = exports.WORKFLOW_DEFINITION_STORE = exports.WORKFLOW_GUARD_REGISTRY = exports.WORKFLOW_CLOCK = exports.WORKFLOW_TRANSACTION_RUNNER = exports.WORKFLOW_DEFINITION_REGISTRY = exports.WORKFLOW_COMMAND_REGISTRY = exports.WORKFLOW_HISTORY_STORE = exports.WORKFLOW_INSTANCE_STORE = exports.WORKFLOW_RUNTIME = void 0;
4
4
  exports.WORKFLOW_RUNTIME = Symbol("WORKFLOW_RUNTIME");
5
5
  exports.WORKFLOW_INSTANCE_STORE = Symbol("WORKFLOW_INSTANCE_STORE");
6
6
  exports.WORKFLOW_HISTORY_STORE = Symbol("WORKFLOW_HISTORY_STORE");
@@ -9,6 +9,7 @@ exports.WORKFLOW_DEFINITION_REGISTRY = Symbol("WORKFLOW_DEFINITION_REGISTRY");
9
9
  exports.WORKFLOW_TRANSACTION_RUNNER = Symbol("WORKFLOW_TRANSACTION_RUNNER");
10
10
  exports.WORKFLOW_CLOCK = Symbol("WORKFLOW_CLOCK");
11
11
  exports.WORKFLOW_GUARD_REGISTRY = Symbol("WORKFLOW_GUARD_REGISTRY");
12
+ exports.WORKFLOW_DEFINITION_STORE = Symbol("WORKFLOW_DEFINITION_STORE");
12
13
  /**
13
14
  * The resolved module configuration. Deliberately not re-exported from the
14
15
  * package barrel: it exists so `forRoot` and `forRootAsync` can publish their
@@ -0,0 +1,13 @@
1
+ import { type OnModuleInit } from "@nestjs/common";
2
+ import type { WorkflowRuntime } from "@duraflows/core";
3
+ /**
4
+ * Runs `WorkflowRuntime.initialize()` during module init so definition
5
+ * snapshots sync (and version-bump violations surface) at application
6
+ * startup rather than on the first workflow operation.
7
+ */
8
+ export declare class WorkflowRuntimeInitializer implements OnModuleInit {
9
+ private readonly runtime;
10
+ constructor(runtime: WorkflowRuntime);
11
+ onModuleInit(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=workflow-runtime-initializer.d.ts.map
@@ -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
+ 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.WorkflowRuntimeInitializer = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const injection_tokens_js_1 = require("./injection-tokens.js");
18
+ /**
19
+ * Runs `WorkflowRuntime.initialize()` during module init so definition
20
+ * snapshots sync (and version-bump violations surface) at application
21
+ * startup rather than on the first workflow operation.
22
+ */
23
+ let WorkflowRuntimeInitializer = class WorkflowRuntimeInitializer {
24
+ runtime;
25
+ constructor(runtime) {
26
+ this.runtime = runtime;
27
+ }
28
+ async onModuleInit() {
29
+ await this.runtime.initialize();
30
+ }
31
+ };
32
+ exports.WorkflowRuntimeInitializer = WorkflowRuntimeInitializer;
33
+ exports.WorkflowRuntimeInitializer = WorkflowRuntimeInitializer = __decorate([
34
+ (0, common_1.Injectable)(),
35
+ __param(0, (0, common_1.Inject)(injection_tokens_js_1.WORKFLOW_RUNTIME)),
36
+ __metadata("design:paramtypes", [Function])
37
+ ], WorkflowRuntimeInitializer);
38
+ //# sourceMappingURL=workflow-runtime-initializer.js.map
@@ -14,6 +14,7 @@ const core_2 = require("@duraflows/core");
14
14
  const nest_command_registry_js_1 = require("./providers/nest-command-registry.js");
15
15
  const command_discovery_js_1 = require("./providers/command-discovery.js");
16
16
  const injection_tokens_js_1 = require("./providers/injection-tokens.js");
17
+ const workflow_runtime_initializer_js_1 = require("./providers/workflow-runtime-initializer.js");
17
18
  const workflow_service_js_1 = require("./services/workflow.service.js");
18
19
  const workflow_timeout_service_js_1 = require("./services/workflow-timeout.service.js");
19
20
  const workflow_event_controller_js_1 = require("./controllers/workflow-event.controller.js");
@@ -129,6 +130,11 @@ function buildWorkflowProviders(explicitCommands) {
129
130
  useFactory: (config) => config.persistence.transactionRunner,
130
131
  inject: [injection_tokens_js_1.WORKFLOW_MODULE_OPTIONS],
131
132
  },
133
+ {
134
+ provide: injection_tokens_js_1.WORKFLOW_DEFINITION_STORE,
135
+ useFactory: (config) => config.persistence.definitionStore ?? null,
136
+ inject: [injection_tokens_js_1.WORKFLOW_MODULE_OPTIONS],
137
+ },
132
138
  {
133
139
  provide: injection_tokens_js_1.WORKFLOW_CLOCK,
134
140
  useFactory: (config) => config.clock ?? { now: () => new Date() },
@@ -136,7 +142,7 @@ function buildWorkflowProviders(explicitCommands) {
136
142
  },
137
143
  {
138
144
  provide: injection_tokens_js_1.WORKFLOW_RUNTIME,
139
- useFactory: (config, definitionRegistry, commandRegistry, guardRegistry, instanceStore, historyStore, transactionRunner, clock) => new core_2.WorkflowRuntime({
145
+ useFactory: (config, definitionRegistry, commandRegistry, guardRegistry, instanceStore, historyStore, transactionRunner, clock, definitionStore) => new core_2.WorkflowRuntime({
140
146
  definitionRegistry,
141
147
  commandRegistry,
142
148
  guardRegistry,
@@ -144,6 +150,7 @@ function buildWorkflowProviders(explicitCommands) {
144
150
  historyStore,
145
151
  transactionRunner,
146
152
  clock,
153
+ definitionStore: definitionStore ?? undefined,
147
154
  observers: config.observers,
148
155
  onObserverError: config.onObserverError,
149
156
  }),
@@ -156,10 +163,12 @@ function buildWorkflowProviders(explicitCommands) {
156
163
  injection_tokens_js_1.WORKFLOW_HISTORY_STORE,
157
164
  injection_tokens_js_1.WORKFLOW_TRANSACTION_RUNNER,
158
165
  injection_tokens_js_1.WORKFLOW_CLOCK,
166
+ injection_tokens_js_1.WORKFLOW_DEFINITION_STORE,
159
167
  ],
160
168
  },
161
169
  workflow_service_js_1.WorkflowService,
162
170
  workflow_timeout_service_js_1.WorkflowTimeoutService,
171
+ workflow_runtime_initializer_js_1.WorkflowRuntimeInitializer,
163
172
  ];
164
173
  }
165
174
  let WorkflowModule = WorkflowModule_1 = class WorkflowModule {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { WorkflowModule } from "./workflow.module.js";
2
2
  export type { WorkflowModuleOptions, WorkflowModuleAsyncOptions, WorkflowModuleFactoryConfig, } from "./workflow.module.js";
3
3
  export { WorkflowService } from "./services/workflow.service.js";
4
4
  export { WorkflowTimeoutService } from "./services/workflow-timeout.service.js";
5
- export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, } from "./providers/injection-tokens.js";
5
+ export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, WORKFLOW_DEFINITION_STORE, } from "./providers/injection-tokens.js";
6
6
  export { NestCommandRegistry } from "./providers/nest-command-registry.js";
7
7
  export type { WorkflowCommandRegistration } from "./providers/nest-command-registry.js";
8
8
  export { WorkflowCommand, WORKFLOW_COMMAND_METADATA_KEY } from "./decorators/workflow-command.decorator.js";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { WorkflowModule } from "./workflow.module.js";
4
4
  export { WorkflowService } from "./services/workflow.service.js";
5
5
  export { WorkflowTimeoutService } from "./services/workflow-timeout.service.js";
6
6
  // Providers
7
- export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, } from "./providers/injection-tokens.js";
7
+ export { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, WORKFLOW_DEFINITION_STORE, } from "./providers/injection-tokens.js";
8
8
  export { NestCommandRegistry } from "./providers/nest-command-registry.js";
9
9
  // Decorators
10
10
  export { WorkflowCommand, WORKFLOW_COMMAND_METADATA_KEY } from "./decorators/workflow-command.decorator.js";
@@ -6,6 +6,7 @@ export declare const WORKFLOW_DEFINITION_REGISTRY: unique symbol;
6
6
  export declare const WORKFLOW_TRANSACTION_RUNNER: unique symbol;
7
7
  export declare const WORKFLOW_CLOCK: unique symbol;
8
8
  export declare const WORKFLOW_GUARD_REGISTRY: unique symbol;
9
+ export declare const WORKFLOW_DEFINITION_STORE: unique symbol;
9
10
  /**
10
11
  * The resolved module configuration. Deliberately not re-exported from the
11
12
  * package barrel: it exists so `forRoot` and `forRootAsync` can publish their
@@ -6,6 +6,7 @@ export const WORKFLOW_DEFINITION_REGISTRY = Symbol("WORKFLOW_DEFINITION_REGISTRY
6
6
  export const WORKFLOW_TRANSACTION_RUNNER = Symbol("WORKFLOW_TRANSACTION_RUNNER");
7
7
  export const WORKFLOW_CLOCK = Symbol("WORKFLOW_CLOCK");
8
8
  export const WORKFLOW_GUARD_REGISTRY = Symbol("WORKFLOW_GUARD_REGISTRY");
9
+ export const WORKFLOW_DEFINITION_STORE = Symbol("WORKFLOW_DEFINITION_STORE");
9
10
  /**
10
11
  * The resolved module configuration. Deliberately not re-exported from the
11
12
  * package barrel: it exists so `forRoot` and `forRootAsync` can publish their
@@ -0,0 +1,13 @@
1
+ import { type OnModuleInit } from "@nestjs/common";
2
+ import type { WorkflowRuntime } from "@duraflows/core";
3
+ /**
4
+ * Runs `WorkflowRuntime.initialize()` during module init so definition
5
+ * snapshots sync (and version-bump violations surface) at application
6
+ * startup rather than on the first workflow operation.
7
+ */
8
+ export declare class WorkflowRuntimeInitializer implements OnModuleInit {
9
+ private readonly runtime;
10
+ constructor(runtime: WorkflowRuntime);
11
+ onModuleInit(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=workflow-runtime-initializer.d.ts.map
@@ -0,0 +1,35 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable } from "@nestjs/common";
14
+ import { WORKFLOW_RUNTIME } from "./injection-tokens.js";
15
+ /**
16
+ * Runs `WorkflowRuntime.initialize()` during module init so definition
17
+ * snapshots sync (and version-bump violations surface) at application
18
+ * startup rather than on the first workflow operation.
19
+ */
20
+ let WorkflowRuntimeInitializer = class WorkflowRuntimeInitializer {
21
+ runtime;
22
+ constructor(runtime) {
23
+ this.runtime = runtime;
24
+ }
25
+ async onModuleInit() {
26
+ await this.runtime.initialize();
27
+ }
28
+ };
29
+ WorkflowRuntimeInitializer = __decorate([
30
+ Injectable(),
31
+ __param(0, Inject(WORKFLOW_RUNTIME)),
32
+ __metadata("design:paramtypes", [Function])
33
+ ], WorkflowRuntimeInitializer);
34
+ export { WorkflowRuntimeInitializer };
35
+ //# sourceMappingURL=workflow-runtime-initializer.js.map
@@ -10,7 +10,8 @@ import { DiscoveryModule, DiscoveryService, ModuleRef } from "@nestjs/core";
10
10
  import { InMemoryDefinitionRegistry, WorkflowRuntime, WorkflowValidator, WorkflowCompiler, InMemoryGuardRegistry, } from "@duraflows/core";
11
11
  import { NestCommandRegistry } from "./providers/nest-command-registry.js";
12
12
  import { discoverDecoratedCommands, mergeCommandRegistrations } from "./providers/command-discovery.js";
13
- import { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, WORKFLOW_GUARD_REGISTRY, WORKFLOW_MODULE_OPTIONS, } from "./providers/injection-tokens.js";
13
+ import { WORKFLOW_RUNTIME, WORKFLOW_INSTANCE_STORE, WORKFLOW_HISTORY_STORE, WORKFLOW_COMMAND_REGISTRY, WORKFLOW_DEFINITION_REGISTRY, WORKFLOW_TRANSACTION_RUNNER, WORKFLOW_CLOCK, WORKFLOW_GUARD_REGISTRY, WORKFLOW_DEFINITION_STORE, WORKFLOW_MODULE_OPTIONS, } from "./providers/injection-tokens.js";
14
+ import { WorkflowRuntimeInitializer } from "./providers/workflow-runtime-initializer.js";
14
15
  import { WorkflowService } from "./services/workflow.service.js";
15
16
  import { WorkflowTimeoutService } from "./services/workflow-timeout.service.js";
16
17
  import { WorkflowEventController } from "./controllers/workflow-event.controller.js";
@@ -126,6 +127,11 @@ function buildWorkflowProviders(explicitCommands) {
126
127
  useFactory: (config) => config.persistence.transactionRunner,
127
128
  inject: [WORKFLOW_MODULE_OPTIONS],
128
129
  },
130
+ {
131
+ provide: WORKFLOW_DEFINITION_STORE,
132
+ useFactory: (config) => config.persistence.definitionStore ?? null,
133
+ inject: [WORKFLOW_MODULE_OPTIONS],
134
+ },
129
135
  {
130
136
  provide: WORKFLOW_CLOCK,
131
137
  useFactory: (config) => config.clock ?? { now: () => new Date() },
@@ -133,7 +139,7 @@ function buildWorkflowProviders(explicitCommands) {
133
139
  },
134
140
  {
135
141
  provide: WORKFLOW_RUNTIME,
136
- useFactory: (config, definitionRegistry, commandRegistry, guardRegistry, instanceStore, historyStore, transactionRunner, clock) => new WorkflowRuntime({
142
+ useFactory: (config, definitionRegistry, commandRegistry, guardRegistry, instanceStore, historyStore, transactionRunner, clock, definitionStore) => new WorkflowRuntime({
137
143
  definitionRegistry,
138
144
  commandRegistry,
139
145
  guardRegistry,
@@ -141,6 +147,7 @@ function buildWorkflowProviders(explicitCommands) {
141
147
  historyStore,
142
148
  transactionRunner,
143
149
  clock,
150
+ definitionStore: definitionStore ?? undefined,
144
151
  observers: config.observers,
145
152
  onObserverError: config.onObserverError,
146
153
  }),
@@ -153,10 +160,12 @@ function buildWorkflowProviders(explicitCommands) {
153
160
  WORKFLOW_HISTORY_STORE,
154
161
  WORKFLOW_TRANSACTION_RUNNER,
155
162
  WORKFLOW_CLOCK,
163
+ WORKFLOW_DEFINITION_STORE,
156
164
  ],
157
165
  },
158
166
  WorkflowService,
159
167
  WorkflowTimeoutService,
168
+ WorkflowRuntimeInitializer,
160
169
  ];
161
170
  }
162
171
  let WorkflowModule = WorkflowModule_1 = class WorkflowModule {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duraflows/nestjs",
3
- "version": "4.1.0",
3
+ "version": "5.1.0",
4
4
  "description": "NestJS integration for duraflows: dependency injection, services, optional REST controllers, and @WorkflowCommand decorator for DI-backed command handlers.",
5
5
  "keywords": [
6
6
  "duraflows",
@@ -54,17 +54,18 @@
54
54
  "class-validator": "^0.15.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@duraflows/core": "^4.1.0",
58
- "@nestjs/common": "^11.0.0",
59
- "@nestjs/core": "^11.0.0",
57
+ "@duraflows/core": "^5.1.0",
58
+ "@nestjs/common": "^11.0.0 || ^12.0.0",
59
+ "@nestjs/core": "^11.0.0 || ^12.0.0",
60
60
  "reflect-metadata": "^0.2.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@nestjs/common": "^11.1.28",
64
- "@nestjs/core": "^11.1.28",
65
- "@nestjs/testing": "^11.1.28",
63
+ "@nestjs/common": "^12.1.0",
64
+ "@nestjs/core": "^12.1.0",
65
+ "@nestjs/platform-express": "^12.1.0",
66
+ "@nestjs/testing": "^12.1.0",
66
67
  "reflect-metadata": "^0.2.2",
67
- "@duraflows/core": "4.1.0"
68
+ "@duraflows/core": "5.1.0"
68
69
  },
69
70
  "scripts": {
70
71
  "build": "tsc --build"