@unlaxer/tramli 1.12.0 → 1.14.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/cjs/flow-engine.d.ts +4 -0
- package/dist/cjs/flow-engine.js +7 -4
- package/dist/cjs/flow-error.d.ts +5 -0
- package/dist/cjs/flow-error.js +7 -0
- package/dist/esm/flow-engine.d.ts +4 -0
- package/dist/esm/flow-engine.js +6 -3
- package/dist/esm/flow-error.d.ts +5 -0
- package/dist/esm/flow-error.js +7 -0
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { FlowDefinition } from './flow-definition.js';
|
|
2
2
|
import { FlowInstance } from './flow-instance.js';
|
|
3
3
|
import type { InMemoryFlowStore } from './in-memory-flow-store.js';
|
|
4
|
+
/** Default max auto-chain depth. Override via constructor options. */
|
|
5
|
+
export declare const DEFAULT_MAX_CHAIN_DEPTH = 10;
|
|
4
6
|
/** Log entry types for tramli's pluggable logger API. */
|
|
5
7
|
export interface TransitionLogEntry {
|
|
6
8
|
flowId: string;
|
|
@@ -24,11 +26,13 @@ export interface ErrorLogEntry {
|
|
|
24
26
|
export declare class FlowEngine {
|
|
25
27
|
private readonly store;
|
|
26
28
|
private readonly strictMode;
|
|
29
|
+
private readonly maxChainDepth;
|
|
27
30
|
private transitionLogger?;
|
|
28
31
|
private stateLogger?;
|
|
29
32
|
private errorLogger?;
|
|
30
33
|
constructor(store: InMemoryFlowStore, options?: {
|
|
31
34
|
strictMode?: boolean;
|
|
35
|
+
maxChainDepth?: number;
|
|
32
36
|
});
|
|
33
37
|
setTransitionLogger(logger: ((entry: TransitionLogEntry) => void) | null): void;
|
|
34
38
|
setStateLogger(logger: ((entry: StateLogEntry) => void) | null): void;
|
package/dist/cjs/flow-engine.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowEngine = void 0;
|
|
3
|
+
exports.FlowEngine = exports.DEFAULT_MAX_CHAIN_DEPTH = void 0;
|
|
4
4
|
const flow_context_js_1 = require("./flow-context");
|
|
5
5
|
const flow_instance_js_1 = require("./flow-instance");
|
|
6
6
|
const flow_error_js_1 = require("./flow-error");
|
|
7
|
-
|
|
7
|
+
/** Default max auto-chain depth. Override via constructor options. */
|
|
8
|
+
exports.DEFAULT_MAX_CHAIN_DEPTH = 10;
|
|
8
9
|
class FlowEngine {
|
|
9
10
|
store;
|
|
10
11
|
strictMode;
|
|
12
|
+
maxChainDepth;
|
|
11
13
|
transitionLogger;
|
|
12
14
|
stateLogger;
|
|
13
15
|
errorLogger;
|
|
14
16
|
constructor(store, options) {
|
|
15
17
|
this.store = store;
|
|
16
18
|
this.strictMode = options?.strictMode ?? false;
|
|
19
|
+
this.maxChainDepth = options?.maxChainDepth ?? exports.DEFAULT_MAX_CHAIN_DEPTH;
|
|
17
20
|
}
|
|
18
21
|
setTransitionLogger(logger) {
|
|
19
22
|
this.transitionLogger = logger ?? undefined;
|
|
@@ -116,7 +119,7 @@ class FlowEngine {
|
|
|
116
119
|
}
|
|
117
120
|
async executeAutoChain(flow) {
|
|
118
121
|
let depth = 0;
|
|
119
|
-
while (depth <
|
|
122
|
+
while (depth < this.maxChainDepth) {
|
|
120
123
|
const current = flow.currentState;
|
|
121
124
|
if (flow.definition.stateConfig[current].terminal) {
|
|
122
125
|
flow.complete(current);
|
|
@@ -168,7 +171,7 @@ class FlowEngine {
|
|
|
168
171
|
}
|
|
169
172
|
depth++;
|
|
170
173
|
}
|
|
171
|
-
if (depth >=
|
|
174
|
+
if (depth >= this.maxChainDepth)
|
|
172
175
|
throw flow_error_js_1.FlowError.maxChainDepth();
|
|
173
176
|
}
|
|
174
177
|
async executeSubFlow(parentFlow, subFlowTransition) {
|
package/dist/cjs/flow-error.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
export type FlowErrorType = 'BUSINESS' | 'SYSTEM' | 'RETRYABLE' | 'FATAL';
|
|
1
2
|
export declare class FlowError extends Error {
|
|
2
3
|
readonly code: string;
|
|
4
|
+
/** Error type classification for retry/recovery strategy. */
|
|
5
|
+
errorType?: FlowErrorType;
|
|
3
6
|
/** Types that were available in context when the error occurred. */
|
|
4
7
|
availableTypes?: Set<string>;
|
|
5
8
|
/** Types that were expected but missing (if applicable). */
|
|
6
9
|
missingTypes?: Set<string>;
|
|
7
10
|
constructor(code: string, message: string);
|
|
11
|
+
/** Attach error type classification. */
|
|
12
|
+
withErrorType(type: FlowErrorType): this;
|
|
8
13
|
/** Attach context snapshot to this error. */
|
|
9
14
|
withContextSnapshot(available: Set<string>, missing: Set<string>): this;
|
|
10
15
|
static invalidTransition(from: string, to: string): FlowError;
|
package/dist/cjs/flow-error.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FlowError = void 0;
|
|
4
4
|
class FlowError extends Error {
|
|
5
5
|
code;
|
|
6
|
+
/** Error type classification for retry/recovery strategy. */
|
|
7
|
+
errorType;
|
|
6
8
|
/** Types that were available in context when the error occurred. */
|
|
7
9
|
availableTypes;
|
|
8
10
|
/** Types that were expected but missing (if applicable). */
|
|
@@ -12,6 +14,11 @@ class FlowError extends Error {
|
|
|
12
14
|
this.code = code;
|
|
13
15
|
this.name = 'FlowError';
|
|
14
16
|
}
|
|
17
|
+
/** Attach error type classification. */
|
|
18
|
+
withErrorType(type) {
|
|
19
|
+
this.errorType = type;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
15
22
|
/** Attach context snapshot to this error. */
|
|
16
23
|
withContextSnapshot(available, missing) {
|
|
17
24
|
this.availableTypes = available;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { FlowDefinition } from './flow-definition.js';
|
|
2
2
|
import { FlowInstance } from './flow-instance.js';
|
|
3
3
|
import type { InMemoryFlowStore } from './in-memory-flow-store.js';
|
|
4
|
+
/** Default max auto-chain depth. Override via constructor options. */
|
|
5
|
+
export declare const DEFAULT_MAX_CHAIN_DEPTH = 10;
|
|
4
6
|
/** Log entry types for tramli's pluggable logger API. */
|
|
5
7
|
export interface TransitionLogEntry {
|
|
6
8
|
flowId: string;
|
|
@@ -24,11 +26,13 @@ export interface ErrorLogEntry {
|
|
|
24
26
|
export declare class FlowEngine {
|
|
25
27
|
private readonly store;
|
|
26
28
|
private readonly strictMode;
|
|
29
|
+
private readonly maxChainDepth;
|
|
27
30
|
private transitionLogger?;
|
|
28
31
|
private stateLogger?;
|
|
29
32
|
private errorLogger?;
|
|
30
33
|
constructor(store: InMemoryFlowStore, options?: {
|
|
31
34
|
strictMode?: boolean;
|
|
35
|
+
maxChainDepth?: number;
|
|
32
36
|
});
|
|
33
37
|
setTransitionLogger(logger: ((entry: TransitionLogEntry) => void) | null): void;
|
|
34
38
|
setStateLogger(logger: ((entry: StateLogEntry) => void) | null): void;
|
package/dist/esm/flow-engine.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { FlowContext } from './flow-context.js';
|
|
2
2
|
import { FlowInstance } from './flow-instance.js';
|
|
3
3
|
import { FlowError } from './flow-error.js';
|
|
4
|
-
|
|
4
|
+
/** Default max auto-chain depth. Override via constructor options. */
|
|
5
|
+
export const DEFAULT_MAX_CHAIN_DEPTH = 10;
|
|
5
6
|
export class FlowEngine {
|
|
6
7
|
store;
|
|
7
8
|
strictMode;
|
|
9
|
+
maxChainDepth;
|
|
8
10
|
transitionLogger;
|
|
9
11
|
stateLogger;
|
|
10
12
|
errorLogger;
|
|
11
13
|
constructor(store, options) {
|
|
12
14
|
this.store = store;
|
|
13
15
|
this.strictMode = options?.strictMode ?? false;
|
|
16
|
+
this.maxChainDepth = options?.maxChainDepth ?? DEFAULT_MAX_CHAIN_DEPTH;
|
|
14
17
|
}
|
|
15
18
|
setTransitionLogger(logger) {
|
|
16
19
|
this.transitionLogger = logger ?? undefined;
|
|
@@ -113,7 +116,7 @@ export class FlowEngine {
|
|
|
113
116
|
}
|
|
114
117
|
async executeAutoChain(flow) {
|
|
115
118
|
let depth = 0;
|
|
116
|
-
while (depth <
|
|
119
|
+
while (depth < this.maxChainDepth) {
|
|
117
120
|
const current = flow.currentState;
|
|
118
121
|
if (flow.definition.stateConfig[current].terminal) {
|
|
119
122
|
flow.complete(current);
|
|
@@ -165,7 +168,7 @@ export class FlowEngine {
|
|
|
165
168
|
}
|
|
166
169
|
depth++;
|
|
167
170
|
}
|
|
168
|
-
if (depth >=
|
|
171
|
+
if (depth >= this.maxChainDepth)
|
|
169
172
|
throw FlowError.maxChainDepth();
|
|
170
173
|
}
|
|
171
174
|
async executeSubFlow(parentFlow, subFlowTransition) {
|
package/dist/esm/flow-error.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
export type FlowErrorType = 'BUSINESS' | 'SYSTEM' | 'RETRYABLE' | 'FATAL';
|
|
1
2
|
export declare class FlowError extends Error {
|
|
2
3
|
readonly code: string;
|
|
4
|
+
/** Error type classification for retry/recovery strategy. */
|
|
5
|
+
errorType?: FlowErrorType;
|
|
3
6
|
/** Types that were available in context when the error occurred. */
|
|
4
7
|
availableTypes?: Set<string>;
|
|
5
8
|
/** Types that were expected but missing (if applicable). */
|
|
6
9
|
missingTypes?: Set<string>;
|
|
7
10
|
constructor(code: string, message: string);
|
|
11
|
+
/** Attach error type classification. */
|
|
12
|
+
withErrorType(type: FlowErrorType): this;
|
|
8
13
|
/** Attach context snapshot to this error. */
|
|
9
14
|
withContextSnapshot(available: Set<string>, missing: Set<string>): this;
|
|
10
15
|
static invalidTransition(from: string, to: string): FlowError;
|
package/dist/esm/flow-error.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export class FlowError extends Error {
|
|
2
2
|
code;
|
|
3
|
+
/** Error type classification for retry/recovery strategy. */
|
|
4
|
+
errorType;
|
|
3
5
|
/** Types that were available in context when the error occurred. */
|
|
4
6
|
availableTypes;
|
|
5
7
|
/** Types that were expected but missing (if applicable). */
|
|
@@ -9,6 +11,11 @@ export class FlowError extends Error {
|
|
|
9
11
|
this.code = code;
|
|
10
12
|
this.name = 'FlowError';
|
|
11
13
|
}
|
|
14
|
+
/** Attach error type classification. */
|
|
15
|
+
withErrorType(type) {
|
|
16
|
+
this.errorType = type;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
12
19
|
/** Attach context snapshot to this error. */
|
|
13
20
|
withContextSnapshot(available, missing) {
|
|
14
21
|
this.availableTypes = available;
|