@unlaxer/tramli 3.5.0 → 3.5.1
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/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { FlowError } from './flow-error.js';
|
|
|
8
8
|
export { InMemoryFlowStore } from './in-memory-flow-store.js';
|
|
9
9
|
export type { TransitionRecord } from './in-memory-flow-store.js';
|
|
10
10
|
export { MermaidGenerator } from './mermaid-generator.js';
|
|
11
|
+
export type { MermaidOptions } from './mermaid-generator.js';
|
|
11
12
|
export { SkeletonGenerator } from './skeleton-generator.js';
|
|
12
13
|
export type { TargetLanguage } from './skeleton-generator.js';
|
|
13
14
|
export { DataFlowGraph } from './data-flow-graph.js';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FlowDefinition } from './flow-definition.js';
|
|
2
|
+
export interface MermaidOptions {
|
|
3
|
+
excludeErrorTransitions?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare class MermaidGenerator {
|
|
3
|
-
static generate<S extends string>(def: FlowDefinition<S
|
|
6
|
+
static generate<S extends string>(def: FlowDefinition<S>, options?: MermaidOptions): string;
|
|
4
7
|
/** Generate Mermaid diagram highlighting external transitions and their data contracts. */
|
|
5
8
|
static generateExternalContract<S extends string>(def: FlowDefinition<S>): string;
|
|
6
9
|
/** Generate Mermaid data-flow diagram from requires/produces declarations. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MermaidGenerator = void 0;
|
|
4
4
|
class MermaidGenerator {
|
|
5
|
-
static generate(def) {
|
|
5
|
+
static generate(def, options) {
|
|
6
6
|
const lines = ['stateDiagram-v2'];
|
|
7
7
|
if (def.initialState)
|
|
8
8
|
lines.push(` [*] --> ${def.initialState}`);
|
|
@@ -34,11 +34,13 @@ class MermaidGenerator {
|
|
|
34
34
|
const label = this.transitionLabel(t);
|
|
35
35
|
lines.push(label ? ` ${t.from} --> ${t.to}: ${label}` : ` ${t.from} --> ${t.to}`);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
seen.
|
|
41
|
-
|
|
37
|
+
if (!options?.excludeErrorTransitions) {
|
|
38
|
+
for (const [from, to] of def.errorTransitions) {
|
|
39
|
+
const key = `${from}->${to}`;
|
|
40
|
+
if (!seen.has(key)) {
|
|
41
|
+
seen.add(key);
|
|
42
|
+
lines.push(` ${from} --> ${to}: error`);
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
for (const s of def.terminalStates) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { FlowError } from './flow-error.js';
|
|
|
8
8
|
export { InMemoryFlowStore } from './in-memory-flow-store.js';
|
|
9
9
|
export type { TransitionRecord } from './in-memory-flow-store.js';
|
|
10
10
|
export { MermaidGenerator } from './mermaid-generator.js';
|
|
11
|
+
export type { MermaidOptions } from './mermaid-generator.js';
|
|
11
12
|
export { SkeletonGenerator } from './skeleton-generator.js';
|
|
12
13
|
export type { TargetLanguage } from './skeleton-generator.js';
|
|
13
14
|
export { DataFlowGraph } from './data-flow-graph.js';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FlowDefinition } from './flow-definition.js';
|
|
2
|
+
export interface MermaidOptions {
|
|
3
|
+
excludeErrorTransitions?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare class MermaidGenerator {
|
|
3
|
-
static generate<S extends string>(def: FlowDefinition<S
|
|
6
|
+
static generate<S extends string>(def: FlowDefinition<S>, options?: MermaidOptions): string;
|
|
4
7
|
/** Generate Mermaid diagram highlighting external transitions and their data contracts. */
|
|
5
8
|
static generateExternalContract<S extends string>(def: FlowDefinition<S>): string;
|
|
6
9
|
/** Generate Mermaid data-flow diagram from requires/produces declarations. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class MermaidGenerator {
|
|
2
|
-
static generate(def) {
|
|
2
|
+
static generate(def, options) {
|
|
3
3
|
const lines = ['stateDiagram-v2'];
|
|
4
4
|
if (def.initialState)
|
|
5
5
|
lines.push(` [*] --> ${def.initialState}`);
|
|
@@ -31,11 +31,13 @@ export class MermaidGenerator {
|
|
|
31
31
|
const label = this.transitionLabel(t);
|
|
32
32
|
lines.push(label ? ` ${t.from} --> ${t.to}: ${label}` : ` ${t.from} --> ${t.to}`);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
seen.
|
|
38
|
-
|
|
34
|
+
if (!options?.excludeErrorTransitions) {
|
|
35
|
+
for (const [from, to] of def.errorTransitions) {
|
|
36
|
+
const key = `${from}->${to}`;
|
|
37
|
+
if (!seen.has(key)) {
|
|
38
|
+
seen.add(key);
|
|
39
|
+
lines.push(` ${from} --> ${to}: error`);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
for (const s of def.terminalStates) {
|