@duraflows/nestjs 6.1.0 → 7.0.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.
@@ -28,7 +28,8 @@ let WorkflowExceptionFilter = WorkflowExceptionFilter_1 = class WorkflowExceptio
28
28
  });
29
29
  return;
30
30
  }
31
- if (exception instanceof core_1.InvalidEventError) {
31
+ // Both mean the instance's state doesn't fit the governing definition.
32
+ if (exception instanceof core_1.InvalidEventError || exception instanceof core_1.IncompatibleDefinitionError) {
32
33
  response.status(common_1.HttpStatus.CONFLICT).send({
33
34
  statusCode: common_1.HttpStatus.CONFLICT,
34
35
  error: "Conflict",
@@ -12,8 +12,8 @@ export { WorkflowQueryController } from "./controllers/workflow-query.controller
12
12
  export { WorkflowTimeoutController } from "./controllers/workflow-timeout.controller.js";
13
13
  export { WorkflowExceptionFilter } from "./filters/workflow-exception.filter.js";
14
14
  export { TriggerEventDto, TriggerEventParamsDto, HistoryQueryDto, HistoryParamsDto, AvailableEventsParamsDto, TimeoutProcessQueryDto, CreateInstanceDto, } from "./controllers/dto/index.js";
15
- export type { WorkflowDefinition, WorkflowStateDefinition, WorkflowEventDefinition, WorkflowOnEnterDefinition, WorkflowCommandRef, WorkflowTimeoutDefinition, CommandResult, WorkflowExecutionContext, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, ProcessExpiredWorkflowsInput, ProcessExpiredWorkflowsResult, FindParkedTimeoutsInput, WorkflowTimeoutRetry, WorkflowTimeoutRetryOptions, GetAvailableEventsInput, WorkflowInstanceStore, WorkflowHistoryStore, WorkflowHistoryRecord, WorkflowTransactionRunner, WorkflowClock, WorkflowPersistenceProvider, WorkflowDefinitionRegistry, WorkflowCommandRegistry, ValidationResult, ValidationError, CompiledWorkflow, OnEnterChainResult, OnEnterHopResult, WorkflowRuntimeClient, } from "@duraflows/core";
16
- export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
15
+ export type { WorkflowDefinition, WorkflowStateDefinition, WorkflowEventDefinition, WorkflowOnEnterDefinition, WorkflowCommandRef, WorkflowTimeoutDefinition, CommandResult, WorkflowExecutionContext, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, ProcessExpiredWorkflowsInput, ProcessExpiredWorkflowsResult, FindParkedTimeoutsInput, WorkflowTimeoutRetry, WorkflowTimeoutRetryOptions, GetAvailableEventsInput, WorkflowInstanceStore, WorkflowHistoryStore, WorkflowHistoryRecord, DefinitionVersionSummary, WorkflowTransactionRunner, WorkflowClock, WorkflowPersistenceProvider, WorkflowDefinitionRegistry, WorkflowCommandRegistry, ValidationResult, ValidationError, CompiledWorkflow, OnEnterChainResult, OnEnterHopResult, WorkflowRuntimeClient, } from "@duraflows/core";
16
+ export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, IncompatibleDefinitionError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
17
17
  export type { WorkflowObserver, StateEnterEvent, ObserverErrorHandler } from "@duraflows/core";
18
18
  export type { WorkflowGuard, WorkflowGuardRef, WorkflowGuardRegistry } from "@duraflows/core";
19
19
  //# sourceMappingURL=index.d.ts.map
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_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;
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.IncompatibleDefinitionError = 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; } });
@@ -52,6 +52,7 @@ Object.defineProperty(exports, "WorkflowError", { enumerable: true, get: functio
52
52
  Object.defineProperty(exports, "WorkflowDefinitionError", { enumerable: true, get: function () { return core_1.WorkflowDefinitionError; } });
53
53
  Object.defineProperty(exports, "WorkflowInstanceNotFoundError", { enumerable: true, get: function () { return core_1.WorkflowInstanceNotFoundError; } });
54
54
  Object.defineProperty(exports, "InvalidEventError", { enumerable: true, get: function () { return core_1.InvalidEventError; } });
55
+ Object.defineProperty(exports, "IncompatibleDefinitionError", { enumerable: true, get: function () { return core_1.IncompatibleDefinitionError; } });
55
56
  Object.defineProperty(exports, "CommandFailureError", { enumerable: true, get: function () { return core_1.CommandFailureError; } });
56
57
  Object.defineProperty(exports, "OnEnterDepthExceededError", { enumerable: true, get: function () { return core_1.OnEnterDepthExceededError; } });
57
58
  Object.defineProperty(exports, "WorkflowValidator", { enumerable: true, get: function () { return core_1.WorkflowValidator; } });
@@ -1,5 +1,5 @@
1
1
  import { WorkflowHandle } from "@duraflows/core";
2
- import type { WorkflowRuntime, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, GetAvailableEventsInput, WorkflowDefinition, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, WorkflowHistoryRecord } from "@duraflows/core";
2
+ import type { WorkflowRuntime, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, GetAvailableEventsInput, WorkflowDefinition, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, WorkflowHistoryRecord, DefinitionVersionSummary } from "@duraflows/core";
3
3
  export declare class WorkflowService {
4
4
  private readonly runtime;
5
5
  constructor(runtime: WorkflowRuntime);
@@ -32,6 +32,7 @@ export declare class WorkflowService {
32
32
  limit?: number;
33
33
  offset?: number;
34
34
  }): Promise<WorkflowHistoryRecord[]>;
35
+ listDefinitionVersions(workflowName: string): Promise<DefinitionVersionSummary[]>;
35
36
  getHandle(uuid: string): WorkflowHandle;
36
37
  }
37
38
  //# sourceMappingURL=workflow.service.d.ts.map
@@ -71,6 +71,9 @@ let WorkflowService = class WorkflowService {
71
71
  async getHistory(workflowInstanceUuid, options) {
72
72
  return this.runtime.getHistory(workflowInstanceUuid, options);
73
73
  }
74
+ async listDefinitionVersions(workflowName) {
75
+ return this.runtime.listDefinitionVersions(workflowName);
76
+ }
74
77
  getHandle(uuid) {
75
78
  return new core_1.WorkflowHandle(uuid, this);
76
79
  }
@@ -15,6 +15,12 @@ export interface WorkflowModuleOptions {
15
15
  * fails: exponential backoff, then parking. Defaults apply when omitted.
16
16
  */
17
17
  timeoutRetry?: WorkflowTimeoutRetryOptions;
18
+ /**
19
+ * What module init does when a stored definition version that still has
20
+ * active instances references an unregistered command or guard: `"fail"`
21
+ * (default) fails application startup, `"warn"` logs and continues.
22
+ */
23
+ onUnresolvable?: "fail" | "warn";
18
24
  enableControllers?: boolean;
19
25
  }
20
26
  export interface WorkflowModuleFactoryConfig {
@@ -27,6 +33,8 @@ export interface WorkflowModuleFactoryConfig {
27
33
  onObserverError?: ObserverErrorHandler;
28
34
  /** See {@link WorkflowModuleOptions.timeoutRetry}. */
29
35
  timeoutRetry?: WorkflowTimeoutRetryOptions;
36
+ /** See {@link WorkflowModuleOptions.onUnresolvable}. */
37
+ onUnresolvable?: "fail" | "warn";
30
38
  }
31
39
  export interface WorkflowModuleAsyncOptions<TArgs extends unknown[] = unknown[]> {
32
40
  imports?: Type<unknown>[];
@@ -154,6 +154,7 @@ function buildWorkflowProviders(explicitCommands) {
154
154
  observers: config.observers,
155
155
  onObserverError: config.onObserverError,
156
156
  timeoutRetry: config.timeoutRetry,
157
+ onUnresolvable: config.onUnresolvable,
157
158
  }),
158
159
  inject: [
159
160
  injection_tokens_js_1.WORKFLOW_MODULE_OPTIONS,
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  var WorkflowExceptionFilter_1;
8
8
  import { Catch, HttpStatus, Logger } from "@nestjs/common";
9
- import { WorkflowError, WorkflowInstanceNotFoundError, InvalidEventError, InvalidArgumentError } from "@duraflows/core";
9
+ import { WorkflowError, WorkflowInstanceNotFoundError, InvalidEventError, InvalidArgumentError, IncompatibleDefinitionError, } from "@duraflows/core";
10
10
  /**
11
11
  * Maps duraflows domain errors to HTTP statuses for the optional REST
12
12
  * controllers. Without this filter, a missing instance or an event invalid
@@ -25,7 +25,8 @@ let WorkflowExceptionFilter = WorkflowExceptionFilter_1 = class WorkflowExceptio
25
25
  });
26
26
  return;
27
27
  }
28
- if (exception instanceof InvalidEventError) {
28
+ // Both mean the instance's state doesn't fit the governing definition.
29
+ if (exception instanceof InvalidEventError || exception instanceof IncompatibleDefinitionError) {
29
30
  response.status(HttpStatus.CONFLICT).send({
30
31
  statusCode: HttpStatus.CONFLICT,
31
32
  error: "Conflict",
package/dist/index.d.ts CHANGED
@@ -12,8 +12,8 @@ export { WorkflowQueryController } from "./controllers/workflow-query.controller
12
12
  export { WorkflowTimeoutController } from "./controllers/workflow-timeout.controller.js";
13
13
  export { WorkflowExceptionFilter } from "./filters/workflow-exception.filter.js";
14
14
  export { TriggerEventDto, TriggerEventParamsDto, HistoryQueryDto, HistoryParamsDto, AvailableEventsParamsDto, TimeoutProcessQueryDto, CreateInstanceDto, } from "./controllers/dto/index.js";
15
- export type { WorkflowDefinition, WorkflowStateDefinition, WorkflowEventDefinition, WorkflowOnEnterDefinition, WorkflowCommandRef, WorkflowTimeoutDefinition, CommandResult, WorkflowExecutionContext, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, ProcessExpiredWorkflowsInput, ProcessExpiredWorkflowsResult, FindParkedTimeoutsInput, WorkflowTimeoutRetry, WorkflowTimeoutRetryOptions, GetAvailableEventsInput, WorkflowInstanceStore, WorkflowHistoryStore, WorkflowHistoryRecord, WorkflowTransactionRunner, WorkflowClock, WorkflowPersistenceProvider, WorkflowDefinitionRegistry, WorkflowCommandRegistry, ValidationResult, ValidationError, CompiledWorkflow, OnEnterChainResult, OnEnterHopResult, WorkflowRuntimeClient, } from "@duraflows/core";
16
- export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
15
+ export type { WorkflowDefinition, WorkflowStateDefinition, WorkflowEventDefinition, WorkflowOnEnterDefinition, WorkflowCommandRef, WorkflowTimeoutDefinition, CommandResult, WorkflowExecutionContext, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, ProcessExpiredWorkflowsInput, ProcessExpiredWorkflowsResult, FindParkedTimeoutsInput, WorkflowTimeoutRetry, WorkflowTimeoutRetryOptions, GetAvailableEventsInput, WorkflowInstanceStore, WorkflowHistoryStore, WorkflowHistoryRecord, DefinitionVersionSummary, WorkflowTransactionRunner, WorkflowClock, WorkflowPersistenceProvider, WorkflowDefinitionRegistry, WorkflowCommandRegistry, ValidationResult, ValidationError, CompiledWorkflow, OnEnterChainResult, OnEnterHopResult, WorkflowRuntimeClient, } from "@duraflows/core";
16
+ export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, IncompatibleDefinitionError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
17
17
  export type { WorkflowObserver, StateEnterEvent, ObserverErrorHandler } from "@duraflows/core";
18
18
  export type { WorkflowGuard, WorkflowGuardRef, WorkflowGuardRegistry } from "@duraflows/core";
19
19
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -17,5 +17,5 @@ export { WorkflowTimeoutController } from "./controllers/workflow-timeout.contro
17
17
  export { WorkflowExceptionFilter } from "./filters/workflow-exception.filter.js";
18
18
  // DTOs
19
19
  export { TriggerEventDto, TriggerEventParamsDto, HistoryQueryDto, HistoryParamsDto, AvailableEventsParamsDto, TimeoutProcessQueryDto, CreateInstanceDto, } from "./controllers/dto/index.js";
20
- export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
20
+ export { WorkflowError, WorkflowDefinitionError, WorkflowInstanceNotFoundError, InvalidEventError, IncompatibleDefinitionError, CommandFailureError, OnEnterDepthExceededError, WorkflowValidator, WorkflowCompiler, CommandExecutor, EventExecutor, OnEnterExecutor, TimeoutResolver, WorkflowRuntime, WorkflowHandle, InMemoryDefinitionRegistry, InMemoryCommandRegistry, InMemoryGuardRegistry, } from "@duraflows/core";
21
21
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { WorkflowHandle } from "@duraflows/core";
2
- import type { WorkflowRuntime, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, GetAvailableEventsInput, WorkflowDefinition, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, WorkflowHistoryRecord } from "@duraflows/core";
2
+ import type { WorkflowRuntime, CreateWorkflowInstanceInput, TriggerWorkflowEventInput, GetAvailableEventsInput, WorkflowDefinition, WorkflowInstance, WorkflowExecutionResult, AvailableWorkflowEvent, WorkflowHistoryRecord, DefinitionVersionSummary } from "@duraflows/core";
3
3
  export declare class WorkflowService {
4
4
  private readonly runtime;
5
5
  constructor(runtime: WorkflowRuntime);
@@ -32,6 +32,7 @@ export declare class WorkflowService {
32
32
  limit?: number;
33
33
  offset?: number;
34
34
  }): Promise<WorkflowHistoryRecord[]>;
35
+ listDefinitionVersions(workflowName: string): Promise<DefinitionVersionSummary[]>;
35
36
  getHandle(uuid: string): WorkflowHandle;
36
37
  }
37
38
  //# sourceMappingURL=workflow.service.d.ts.map
@@ -68,6 +68,9 @@ let WorkflowService = class WorkflowService {
68
68
  async getHistory(workflowInstanceUuid, options) {
69
69
  return this.runtime.getHistory(workflowInstanceUuid, options);
70
70
  }
71
+ async listDefinitionVersions(workflowName) {
72
+ return this.runtime.listDefinitionVersions(workflowName);
73
+ }
71
74
  getHandle(uuid) {
72
75
  return new WorkflowHandle(uuid, this);
73
76
  }
@@ -15,6 +15,12 @@ export interface WorkflowModuleOptions {
15
15
  * fails: exponential backoff, then parking. Defaults apply when omitted.
16
16
  */
17
17
  timeoutRetry?: WorkflowTimeoutRetryOptions;
18
+ /**
19
+ * What module init does when a stored definition version that still has
20
+ * active instances references an unregistered command or guard: `"fail"`
21
+ * (default) fails application startup, `"warn"` logs and continues.
22
+ */
23
+ onUnresolvable?: "fail" | "warn";
18
24
  enableControllers?: boolean;
19
25
  }
20
26
  export interface WorkflowModuleFactoryConfig {
@@ -27,6 +33,8 @@ export interface WorkflowModuleFactoryConfig {
27
33
  onObserverError?: ObserverErrorHandler;
28
34
  /** See {@link WorkflowModuleOptions.timeoutRetry}. */
29
35
  timeoutRetry?: WorkflowTimeoutRetryOptions;
36
+ /** See {@link WorkflowModuleOptions.onUnresolvable}. */
37
+ onUnresolvable?: "fail" | "warn";
30
38
  }
31
39
  export interface WorkflowModuleAsyncOptions<TArgs extends unknown[] = unknown[]> {
32
40
  imports?: Type<unknown>[];
@@ -151,6 +151,7 @@ function buildWorkflowProviders(explicitCommands) {
151
151
  observers: config.observers,
152
152
  onObserverError: config.onObserverError,
153
153
  timeoutRetry: config.timeoutRetry,
154
+ onUnresolvable: config.onUnresolvable,
154
155
  }),
155
156
  inject: [
156
157
  WORKFLOW_MODULE_OPTIONS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duraflows/nestjs",
3
- "version": "6.1.0",
3
+ "version": "7.0.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,7 +54,7 @@
54
54
  "class-validator": "^0.15.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@duraflows/core": "^6.1.0",
57
+ "@duraflows/core": "^7.0.0",
58
58
  "@nestjs/common": "^11.0.0 || ^12.0.0",
59
59
  "@nestjs/core": "^11.0.0 || ^12.0.0",
60
60
  "reflect-metadata": "^0.2.0"
@@ -65,7 +65,7 @@
65
65
  "@nestjs/platform-express": "^12.1.0",
66
66
  "@nestjs/testing": "^12.1.0",
67
67
  "reflect-metadata": "^0.2.2",
68
- "@duraflows/core": "6.1.0"
68
+ "@duraflows/core": "7.0.0"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "tsc --build"