awaitly-visualizer 1.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.
- package/dist/index.browser.cjs +1677 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +166 -0
- package/dist/index.browser.d.ts +166 -0
- package/dist/index.browser.js +1677 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +1680 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +242 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.js +1680 -0
- package/dist/index.js.map +1 -0
- package/dist/kroki/fetch.cjs +3 -0
- package/dist/kroki/fetch.cjs.map +1 -0
- package/dist/kroki/fetch.d.cts +86 -0
- package/dist/kroki/fetch.d.ts +86 -0
- package/dist/kroki/fetch.js +3 -0
- package/dist/kroki/fetch.js.map +1 -0
- package/dist/notifiers/discord.cjs +3 -0
- package/dist/notifiers/discord.cjs.map +1 -0
- package/dist/notifiers/discord.d.cts +70 -0
- package/dist/notifiers/discord.d.ts +70 -0
- package/dist/notifiers/discord.js +3 -0
- package/dist/notifiers/discord.js.map +1 -0
- package/dist/notifiers/slack.cjs +38 -0
- package/dist/notifiers/slack.cjs.map +1 -0
- package/dist/notifiers/slack.d.cts +95 -0
- package/dist/notifiers/slack.d.ts +95 -0
- package/dist/notifiers/slack.js +38 -0
- package/dist/notifiers/slack.js.map +1 -0
- package/dist/notifiers/webhook.cjs +3 -0
- package/dist/notifiers/webhook.cjs.map +1 -0
- package/dist/notifiers/webhook.d.cts +115 -0
- package/dist/notifiers/webhook.d.ts +115 -0
- package/dist/notifiers/webhook.js +3 -0
- package/dist/notifiers/webhook.js.map +1 -0
- package/dist/performance-analyzer-B5VF5b1F.d.ts +663 -0
- package/dist/performance-analyzer-BNwE4AiO.d.cts +663 -0
- package/dist/types-BIZSmXif.d.ts +350 -0
- package/dist/types-BnWc9Wlr.d.cts +350 -0
- package/dist/url-PkfQz4V5.d.cts +750 -0
- package/dist/url-PkfQz4V5.d.ts +750 -0
- package/package.json +105 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { WorkflowEvent } from 'awaitly/workflow';
|
|
2
|
+
export { ScopeType } from 'awaitly/workflow';
|
|
3
|
+
import { D as DiagramSource, E as ExportFormat, a as ExportOptions, b as DecisionStartEvent, c as DecisionBranchEvent, d as DecisionEndEvent, S as ScopeStartEvent, e as ScopeEndEvent, W as WorkflowIR, O as OutputFormat, V as VisualizerOptions } from './url-PkfQz4V5.cjs';
|
|
4
|
+
export { A as ActiveStepSnapshot, B as BaseNode, C as ColorScheme, f as DecisionBranch, g as DecisionEvent, h as DecisionNode, i as EnhancedRenderOptions, F as FlowNode, j as FlowchartRenderOptions, H as HTMLRenderOptions, k as HTMLTheme, l as HeatLevel, m as HeatmapData, n as HookExecution, o as HookState, I as IRSnapshot, K as KrokiExportOptions, p as KrokiFormat, L as LayoutDirection, q as LiveVisualizerOptions, M as MermaidInkExportOptions, r as MermaidRenderOptions, N as NodePerformance, P as ParallelNode, R as RaceNode, s as RenderOptions, t as Renderer, u as ScopeEvent, v as SequenceNode, w as ServerMessage, x as StepNode, y as StepSkippedEvent, z as StepState, G as StreamNode, T as TimeTravelState, U as UrlGeneratorOptions, J as VisualizingWorkflowOptions, Q as WebVisualizerMessage, X as WorkflowHooks, Y as WorkflowNode, Z as createUrlGenerator, _ as hasChildren, $ as isDecisionNode, a0 as isParallelNode, a1 as isRaceNode, a2 as isSequenceNode, a3 as isStepNode, a4 as isStreamNode, a5 as toKrokiPngUrl, a6 as toKrokiSvgUrl, a7 as toKrokiUrl } from './url-PkfQz4V5.cjs';
|
|
5
|
+
export { D as DecisionTracker, H as HookLog, I as IRBuilderOptions, a as IfTracker, L as LiveVisualizer, b as LoggerOutput, c as LoggerRenderOptions, P as ParallelDetectorOptions, d as PerformanceAnalyzer, S as StepLog, e as SwitchTracker, T as TimeTravelController, f as TimeTravelOptions, W as WorkflowRun, g as WorkflowSummary, h as asciiRenderer, i as createIRBuilder, j as createLiveVisualizer, k as createParallelDetector, l as createPerformanceAnalyzer, m as createTimeTravelController, n as defaultColorScheme, o as detectParallelGroups, p as flowchartRenderer, q as getHeatLevel, r as htmlRenderer, s as loggerRenderer, t as mermaidRenderer, u as renderToHTML, v as trackDecision, w as trackIf, x as trackSwitch } from './performance-analyzer-BNwE4AiO.cjs';
|
|
6
|
+
export { D as DiagramProvider, K as KrokiProviderOptions, M as MermaidInkFormat, a as MermaidInkGenerator, b as MermaidInkImageType, c as MermaidInkOptions, d as MermaidInkPaperSize, e as MermaidInkProviderOptions, f as MermaidInkTheme, P as ProviderOptions, g as buildMermaidInkUrl, h as createMermaidInkGenerator, i as encodeForMermaidInk, t as toMermaidInkJpegUrl, j as toMermaidInkPdfUrl, k as toMermaidInkPngUrl, l as toMermaidInkSvgUrl, m as toMermaidInkUrl, n as toMermaidInkWebpUrl } from './types-BnWc9Wlr.cjs';
|
|
7
|
+
import { Result } from 'awaitly';
|
|
8
|
+
import 'awaitly/core';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Unified Export URL Generation
|
|
12
|
+
*
|
|
13
|
+
* Generates export URLs from diagram sources using configured providers.
|
|
14
|
+
* Decoupled from IR - takes already-rendered diagram text.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Error types for export URL generation.
|
|
19
|
+
*/
|
|
20
|
+
type ExportUrlError = "UNSUPPORTED_DIAGRAM_KIND" | "UNSUPPORTED_FORMAT" | "UNKNOWN_PROVIDER";
|
|
21
|
+
/**
|
|
22
|
+
* Internal context for export operations.
|
|
23
|
+
* Used to provide caller context in error messages.
|
|
24
|
+
*/
|
|
25
|
+
interface ExportContext {
|
|
26
|
+
/** The calling method name (e.g., "toSvgUrl") */
|
|
27
|
+
caller?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate export URL from diagram source.
|
|
31
|
+
* Decoupled from IR - takes already-rendered diagram text.
|
|
32
|
+
*
|
|
33
|
+
* @param diagram - The diagram source (kind + text)
|
|
34
|
+
* @param format - Export format (svg, png, pdf)
|
|
35
|
+
* @param options - Provider-specific options
|
|
36
|
+
* @param ctx - Optional context for error messages
|
|
37
|
+
* @returns Result with export URL or ExportUrlError
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const result = toExportUrl(
|
|
42
|
+
* { kind: "mermaid", source: "flowchart TD\n A-->B" },
|
|
43
|
+
* "svg",
|
|
44
|
+
* { provider: "kroki" }
|
|
45
|
+
* );
|
|
46
|
+
* if (result.ok) {
|
|
47
|
+
* console.log(result.value);
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function toExportUrl(diagram: DiagramSource, format: ExportFormat, options: ExportOptions, ctx?: ExportContext): Result<string, ExportUrlError>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Workflow Visualization Module
|
|
55
|
+
*
|
|
56
|
+
* Provides tools for visualizing workflow execution with color-coded
|
|
57
|
+
* step states and support for parallel/race operations.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { createVisualizer } from 'awaitly-visualizer';
|
|
62
|
+
*
|
|
63
|
+
* const viz = createVisualizer({ workflowName: 'checkout' });
|
|
64
|
+
* const workflow = createWorkflow(deps, { onEvent: viz.handleEvent });
|
|
65
|
+
*
|
|
66
|
+
* await workflow(async (step) => {
|
|
67
|
+
* await step(() => validateCart(cart), 'Validate cart');
|
|
68
|
+
* await step(() => processPayment(payment), 'Process payment');
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* console.log(viz.render());
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Workflow visualizer that processes events and renders output.
|
|
77
|
+
*/
|
|
78
|
+
interface WorkflowVisualizer {
|
|
79
|
+
/** Process a workflow event */
|
|
80
|
+
handleEvent: (event: WorkflowEvent<unknown>) => void;
|
|
81
|
+
/** Process a scope event (parallel/race) */
|
|
82
|
+
handleScopeEvent: (event: ScopeStartEvent | ScopeEndEvent) => void;
|
|
83
|
+
/** Process a decision event (conditional branches) */
|
|
84
|
+
handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
|
|
85
|
+
/** Get current IR state */
|
|
86
|
+
getIR: () => WorkflowIR;
|
|
87
|
+
/** Render current state using the default renderer */
|
|
88
|
+
render: () => string;
|
|
89
|
+
/** Render to a specific format */
|
|
90
|
+
renderAs: (format: OutputFormat) => string;
|
|
91
|
+
/** Reset state for a new workflow */
|
|
92
|
+
reset: () => void;
|
|
93
|
+
/** Subscribe to IR updates (for live visualization) */
|
|
94
|
+
onUpdate: (callback: (ir: WorkflowIR) => void) => () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Generate export URL for the current workflow diagram.
|
|
97
|
+
* Requires explicit provider unless export.default is configured.
|
|
98
|
+
*
|
|
99
|
+
* @param format - Export format (svg, png, pdf)
|
|
100
|
+
* @param options - Provider options (required unless default configured)
|
|
101
|
+
* @returns The export URL
|
|
102
|
+
* @throws If no provider configured and none passed
|
|
103
|
+
* @throws If format not supported by provider
|
|
104
|
+
*/
|
|
105
|
+
toUrl: (format: ExportFormat, options?: ExportOptions) => string;
|
|
106
|
+
/**
|
|
107
|
+
* Generate SVG export URL for the current workflow diagram.
|
|
108
|
+
* Requires explicit provider unless export.default is configured.
|
|
109
|
+
*
|
|
110
|
+
* @param options - Provider options (required unless default configured)
|
|
111
|
+
* @returns The SVG export URL
|
|
112
|
+
* @throws If no provider configured and none passed
|
|
113
|
+
*/
|
|
114
|
+
toSvgUrl: (options?: ExportOptions) => string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate PNG export URL for the current workflow diagram.
|
|
117
|
+
* Requires explicit provider unless export.default is configured.
|
|
118
|
+
*
|
|
119
|
+
* @param options - Provider options (required unless default configured)
|
|
120
|
+
* @returns The PNG export URL
|
|
121
|
+
* @throws If no provider configured and none passed
|
|
122
|
+
*/
|
|
123
|
+
toPngUrl: (options?: ExportOptions) => string;
|
|
124
|
+
/**
|
|
125
|
+
* Generate PDF export URL for the current workflow diagram.
|
|
126
|
+
* Requires explicit provider unless export.default is configured.
|
|
127
|
+
* Note: Kroki does not support PDF for mermaid diagrams.
|
|
128
|
+
*
|
|
129
|
+
* @param options - Provider options (required unless default configured)
|
|
130
|
+
* @returns The PDF export URL
|
|
131
|
+
* @throws If no provider configured and none passed
|
|
132
|
+
* @throws If provider doesn't support PDF (e.g., Kroki for mermaid)
|
|
133
|
+
*/
|
|
134
|
+
toPdfUrl: (options?: ExportOptions) => string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a workflow visualizer.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const viz = createVisualizer({ workflowName: 'my-workflow' });
|
|
142
|
+
*
|
|
143
|
+
* const workflow = createWorkflow(deps, {
|
|
144
|
+
* onEvent: viz.handleEvent,
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* await workflow(async (step) => { ... });
|
|
148
|
+
*
|
|
149
|
+
* console.log(viz.render());
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function createVisualizer(options?: VisualizerOptions): WorkflowVisualizer;
|
|
153
|
+
/**
|
|
154
|
+
* Combine multiple event handlers into one.
|
|
155
|
+
* Use when you need visualization + logging + custom handlers.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const viz = createVisualizer({ workflowName: 'checkout' });
|
|
160
|
+
* const workflow = createWorkflow(deps, {
|
|
161
|
+
* onEvent: combineEventHandlers(
|
|
162
|
+
* viz.handleEvent,
|
|
163
|
+
* (e) => console.log(e.type),
|
|
164
|
+
* (e) => metrics.track(e),
|
|
165
|
+
* ),
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare function combineEventHandlers<E = unknown, C = void>(...handlers: Array<(event: WorkflowEvent<E, C>, ctx?: C) => void>): (event: WorkflowEvent<E, C>, ctx: C) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Union type for all collectable/visualizable events (workflow + decision).
|
|
172
|
+
*/
|
|
173
|
+
type CollectableEvent = WorkflowEvent<unknown> | DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent;
|
|
174
|
+
/**
|
|
175
|
+
* Visualize collected events (post-execution).
|
|
176
|
+
*
|
|
177
|
+
* Supports both workflow events (from onEvent) and decision events
|
|
178
|
+
* (from trackDecision/trackIf/trackSwitch).
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const events: CollectableEvent[] = [];
|
|
183
|
+
* const workflow = createWorkflow(deps, {
|
|
184
|
+
* onEvent: (e) => events.push(e),
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* await workflow(async (step) => {
|
|
188
|
+
* const decision = trackIf('check', condition, {
|
|
189
|
+
* emit: (e) => events.push(e),
|
|
190
|
+
* });
|
|
191
|
+
* // ...
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* console.log(visualizeEvents(events));
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
declare function visualizeEvents(events: CollectableEvent[], options?: VisualizerOptions): string;
|
|
198
|
+
/**
|
|
199
|
+
* Create an event collector for later visualization.
|
|
200
|
+
*
|
|
201
|
+
* Supports both workflow events (from onEvent) and decision events
|
|
202
|
+
* (from trackDecision/trackIf/trackSwitch).
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const collector = createEventCollector();
|
|
207
|
+
*
|
|
208
|
+
* const workflow = createWorkflow(deps, {
|
|
209
|
+
* onEvent: collector.handleEvent,
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* await workflow(async (step) => {
|
|
213
|
+
* // Decision events can also be collected
|
|
214
|
+
* const decision = trackIf('check', condition, {
|
|
215
|
+
* emit: collector.handleDecisionEvent,
|
|
216
|
+
* });
|
|
217
|
+
* // ...
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* console.log(collector.visualize());
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
declare function createEventCollector(options?: VisualizerOptions): {
|
|
224
|
+
/** Handle a workflow event */
|
|
225
|
+
handleEvent: (event: WorkflowEvent<unknown>) => void;
|
|
226
|
+
/** Handle a decision event */
|
|
227
|
+
handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
|
|
228
|
+
/** Get all collected events */
|
|
229
|
+
getEvents: () => CollectableEvent[];
|
|
230
|
+
/** Get workflow events only */
|
|
231
|
+
getWorkflowEvents: () => WorkflowEvent<unknown>[];
|
|
232
|
+
/** Get decision events only */
|
|
233
|
+
getDecisionEvents: () => (DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent)[];
|
|
234
|
+
/** Clear collected events */
|
|
235
|
+
clear: () => void;
|
|
236
|
+
/** Visualize collected events */
|
|
237
|
+
visualize: () => string;
|
|
238
|
+
/** Visualize in a specific format */
|
|
239
|
+
visualizeAs: (format: OutputFormat) => string;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export { type CollectableEvent, DecisionBranchEvent, DecisionEndEvent, DecisionStartEvent, DiagramSource, ExportFormat, ExportOptions, OutputFormat, ScopeEndEvent, ScopeStartEvent, VisualizerOptions, WorkflowIR, type WorkflowVisualizer, combineEventHandlers, createEventCollector, createVisualizer, toExportUrl, visualizeEvents };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { WorkflowEvent } from 'awaitly/workflow';
|
|
2
|
+
export { ScopeType } from 'awaitly/workflow';
|
|
3
|
+
import { D as DiagramSource, E as ExportFormat, a as ExportOptions, b as DecisionStartEvent, c as DecisionBranchEvent, d as DecisionEndEvent, S as ScopeStartEvent, e as ScopeEndEvent, W as WorkflowIR, O as OutputFormat, V as VisualizerOptions } from './url-PkfQz4V5.js';
|
|
4
|
+
export { A as ActiveStepSnapshot, B as BaseNode, C as ColorScheme, f as DecisionBranch, g as DecisionEvent, h as DecisionNode, i as EnhancedRenderOptions, F as FlowNode, j as FlowchartRenderOptions, H as HTMLRenderOptions, k as HTMLTheme, l as HeatLevel, m as HeatmapData, n as HookExecution, o as HookState, I as IRSnapshot, K as KrokiExportOptions, p as KrokiFormat, L as LayoutDirection, q as LiveVisualizerOptions, M as MermaidInkExportOptions, r as MermaidRenderOptions, N as NodePerformance, P as ParallelNode, R as RaceNode, s as RenderOptions, t as Renderer, u as ScopeEvent, v as SequenceNode, w as ServerMessage, x as StepNode, y as StepSkippedEvent, z as StepState, G as StreamNode, T as TimeTravelState, U as UrlGeneratorOptions, J as VisualizingWorkflowOptions, Q as WebVisualizerMessage, X as WorkflowHooks, Y as WorkflowNode, Z as createUrlGenerator, _ as hasChildren, $ as isDecisionNode, a0 as isParallelNode, a1 as isRaceNode, a2 as isSequenceNode, a3 as isStepNode, a4 as isStreamNode, a5 as toKrokiPngUrl, a6 as toKrokiSvgUrl, a7 as toKrokiUrl } from './url-PkfQz4V5.js';
|
|
5
|
+
export { D as DecisionTracker, H as HookLog, I as IRBuilderOptions, a as IfTracker, L as LiveVisualizer, b as LoggerOutput, c as LoggerRenderOptions, P as ParallelDetectorOptions, d as PerformanceAnalyzer, S as StepLog, e as SwitchTracker, T as TimeTravelController, f as TimeTravelOptions, W as WorkflowRun, g as WorkflowSummary, h as asciiRenderer, i as createIRBuilder, j as createLiveVisualizer, k as createParallelDetector, l as createPerformanceAnalyzer, m as createTimeTravelController, n as defaultColorScheme, o as detectParallelGroups, p as flowchartRenderer, q as getHeatLevel, r as htmlRenderer, s as loggerRenderer, t as mermaidRenderer, u as renderToHTML, v as trackDecision, w as trackIf, x as trackSwitch } from './performance-analyzer-B5VF5b1F.js';
|
|
6
|
+
export { D as DiagramProvider, K as KrokiProviderOptions, M as MermaidInkFormat, a as MermaidInkGenerator, b as MermaidInkImageType, c as MermaidInkOptions, d as MermaidInkPaperSize, e as MermaidInkProviderOptions, f as MermaidInkTheme, P as ProviderOptions, g as buildMermaidInkUrl, h as createMermaidInkGenerator, i as encodeForMermaidInk, t as toMermaidInkJpegUrl, j as toMermaidInkPdfUrl, k as toMermaidInkPngUrl, l as toMermaidInkSvgUrl, m as toMermaidInkUrl, n as toMermaidInkWebpUrl } from './types-BIZSmXif.js';
|
|
7
|
+
import { Result } from 'awaitly';
|
|
8
|
+
import 'awaitly/core';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Unified Export URL Generation
|
|
12
|
+
*
|
|
13
|
+
* Generates export URLs from diagram sources using configured providers.
|
|
14
|
+
* Decoupled from IR - takes already-rendered diagram text.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Error types for export URL generation.
|
|
19
|
+
*/
|
|
20
|
+
type ExportUrlError = "UNSUPPORTED_DIAGRAM_KIND" | "UNSUPPORTED_FORMAT" | "UNKNOWN_PROVIDER";
|
|
21
|
+
/**
|
|
22
|
+
* Internal context for export operations.
|
|
23
|
+
* Used to provide caller context in error messages.
|
|
24
|
+
*/
|
|
25
|
+
interface ExportContext {
|
|
26
|
+
/** The calling method name (e.g., "toSvgUrl") */
|
|
27
|
+
caller?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate export URL from diagram source.
|
|
31
|
+
* Decoupled from IR - takes already-rendered diagram text.
|
|
32
|
+
*
|
|
33
|
+
* @param diagram - The diagram source (kind + text)
|
|
34
|
+
* @param format - Export format (svg, png, pdf)
|
|
35
|
+
* @param options - Provider-specific options
|
|
36
|
+
* @param ctx - Optional context for error messages
|
|
37
|
+
* @returns Result with export URL or ExportUrlError
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const result = toExportUrl(
|
|
42
|
+
* { kind: "mermaid", source: "flowchart TD\n A-->B" },
|
|
43
|
+
* "svg",
|
|
44
|
+
* { provider: "kroki" }
|
|
45
|
+
* );
|
|
46
|
+
* if (result.ok) {
|
|
47
|
+
* console.log(result.value);
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function toExportUrl(diagram: DiagramSource, format: ExportFormat, options: ExportOptions, ctx?: ExportContext): Result<string, ExportUrlError>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Workflow Visualization Module
|
|
55
|
+
*
|
|
56
|
+
* Provides tools for visualizing workflow execution with color-coded
|
|
57
|
+
* step states and support for parallel/race operations.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { createVisualizer } from 'awaitly-visualizer';
|
|
62
|
+
*
|
|
63
|
+
* const viz = createVisualizer({ workflowName: 'checkout' });
|
|
64
|
+
* const workflow = createWorkflow(deps, { onEvent: viz.handleEvent });
|
|
65
|
+
*
|
|
66
|
+
* await workflow(async (step) => {
|
|
67
|
+
* await step(() => validateCart(cart), 'Validate cart');
|
|
68
|
+
* await step(() => processPayment(payment), 'Process payment');
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* console.log(viz.render());
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Workflow visualizer that processes events and renders output.
|
|
77
|
+
*/
|
|
78
|
+
interface WorkflowVisualizer {
|
|
79
|
+
/** Process a workflow event */
|
|
80
|
+
handleEvent: (event: WorkflowEvent<unknown>) => void;
|
|
81
|
+
/** Process a scope event (parallel/race) */
|
|
82
|
+
handleScopeEvent: (event: ScopeStartEvent | ScopeEndEvent) => void;
|
|
83
|
+
/** Process a decision event (conditional branches) */
|
|
84
|
+
handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
|
|
85
|
+
/** Get current IR state */
|
|
86
|
+
getIR: () => WorkflowIR;
|
|
87
|
+
/** Render current state using the default renderer */
|
|
88
|
+
render: () => string;
|
|
89
|
+
/** Render to a specific format */
|
|
90
|
+
renderAs: (format: OutputFormat) => string;
|
|
91
|
+
/** Reset state for a new workflow */
|
|
92
|
+
reset: () => void;
|
|
93
|
+
/** Subscribe to IR updates (for live visualization) */
|
|
94
|
+
onUpdate: (callback: (ir: WorkflowIR) => void) => () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Generate export URL for the current workflow diagram.
|
|
97
|
+
* Requires explicit provider unless export.default is configured.
|
|
98
|
+
*
|
|
99
|
+
* @param format - Export format (svg, png, pdf)
|
|
100
|
+
* @param options - Provider options (required unless default configured)
|
|
101
|
+
* @returns The export URL
|
|
102
|
+
* @throws If no provider configured and none passed
|
|
103
|
+
* @throws If format not supported by provider
|
|
104
|
+
*/
|
|
105
|
+
toUrl: (format: ExportFormat, options?: ExportOptions) => string;
|
|
106
|
+
/**
|
|
107
|
+
* Generate SVG export URL for the current workflow diagram.
|
|
108
|
+
* Requires explicit provider unless export.default is configured.
|
|
109
|
+
*
|
|
110
|
+
* @param options - Provider options (required unless default configured)
|
|
111
|
+
* @returns The SVG export URL
|
|
112
|
+
* @throws If no provider configured and none passed
|
|
113
|
+
*/
|
|
114
|
+
toSvgUrl: (options?: ExportOptions) => string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate PNG export URL for the current workflow diagram.
|
|
117
|
+
* Requires explicit provider unless export.default is configured.
|
|
118
|
+
*
|
|
119
|
+
* @param options - Provider options (required unless default configured)
|
|
120
|
+
* @returns The PNG export URL
|
|
121
|
+
* @throws If no provider configured and none passed
|
|
122
|
+
*/
|
|
123
|
+
toPngUrl: (options?: ExportOptions) => string;
|
|
124
|
+
/**
|
|
125
|
+
* Generate PDF export URL for the current workflow diagram.
|
|
126
|
+
* Requires explicit provider unless export.default is configured.
|
|
127
|
+
* Note: Kroki does not support PDF for mermaid diagrams.
|
|
128
|
+
*
|
|
129
|
+
* @param options - Provider options (required unless default configured)
|
|
130
|
+
* @returns The PDF export URL
|
|
131
|
+
* @throws If no provider configured and none passed
|
|
132
|
+
* @throws If provider doesn't support PDF (e.g., Kroki for mermaid)
|
|
133
|
+
*/
|
|
134
|
+
toPdfUrl: (options?: ExportOptions) => string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a workflow visualizer.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const viz = createVisualizer({ workflowName: 'my-workflow' });
|
|
142
|
+
*
|
|
143
|
+
* const workflow = createWorkflow(deps, {
|
|
144
|
+
* onEvent: viz.handleEvent,
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* await workflow(async (step) => { ... });
|
|
148
|
+
*
|
|
149
|
+
* console.log(viz.render());
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function createVisualizer(options?: VisualizerOptions): WorkflowVisualizer;
|
|
153
|
+
/**
|
|
154
|
+
* Combine multiple event handlers into one.
|
|
155
|
+
* Use when you need visualization + logging + custom handlers.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const viz = createVisualizer({ workflowName: 'checkout' });
|
|
160
|
+
* const workflow = createWorkflow(deps, {
|
|
161
|
+
* onEvent: combineEventHandlers(
|
|
162
|
+
* viz.handleEvent,
|
|
163
|
+
* (e) => console.log(e.type),
|
|
164
|
+
* (e) => metrics.track(e),
|
|
165
|
+
* ),
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare function combineEventHandlers<E = unknown, C = void>(...handlers: Array<(event: WorkflowEvent<E, C>, ctx?: C) => void>): (event: WorkflowEvent<E, C>, ctx: C) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Union type for all collectable/visualizable events (workflow + decision).
|
|
172
|
+
*/
|
|
173
|
+
type CollectableEvent = WorkflowEvent<unknown> | DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent;
|
|
174
|
+
/**
|
|
175
|
+
* Visualize collected events (post-execution).
|
|
176
|
+
*
|
|
177
|
+
* Supports both workflow events (from onEvent) and decision events
|
|
178
|
+
* (from trackDecision/trackIf/trackSwitch).
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const events: CollectableEvent[] = [];
|
|
183
|
+
* const workflow = createWorkflow(deps, {
|
|
184
|
+
* onEvent: (e) => events.push(e),
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* await workflow(async (step) => {
|
|
188
|
+
* const decision = trackIf('check', condition, {
|
|
189
|
+
* emit: (e) => events.push(e),
|
|
190
|
+
* });
|
|
191
|
+
* // ...
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* console.log(visualizeEvents(events));
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
declare function visualizeEvents(events: CollectableEvent[], options?: VisualizerOptions): string;
|
|
198
|
+
/**
|
|
199
|
+
* Create an event collector for later visualization.
|
|
200
|
+
*
|
|
201
|
+
* Supports both workflow events (from onEvent) and decision events
|
|
202
|
+
* (from trackDecision/trackIf/trackSwitch).
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const collector = createEventCollector();
|
|
207
|
+
*
|
|
208
|
+
* const workflow = createWorkflow(deps, {
|
|
209
|
+
* onEvent: collector.handleEvent,
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* await workflow(async (step) => {
|
|
213
|
+
* // Decision events can also be collected
|
|
214
|
+
* const decision = trackIf('check', condition, {
|
|
215
|
+
* emit: collector.handleDecisionEvent,
|
|
216
|
+
* });
|
|
217
|
+
* // ...
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* console.log(collector.visualize());
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
declare function createEventCollector(options?: VisualizerOptions): {
|
|
224
|
+
/** Handle a workflow event */
|
|
225
|
+
handleEvent: (event: WorkflowEvent<unknown>) => void;
|
|
226
|
+
/** Handle a decision event */
|
|
227
|
+
handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
|
|
228
|
+
/** Get all collected events */
|
|
229
|
+
getEvents: () => CollectableEvent[];
|
|
230
|
+
/** Get workflow events only */
|
|
231
|
+
getWorkflowEvents: () => WorkflowEvent<unknown>[];
|
|
232
|
+
/** Get decision events only */
|
|
233
|
+
getDecisionEvents: () => (DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent)[];
|
|
234
|
+
/** Clear collected events */
|
|
235
|
+
clear: () => void;
|
|
236
|
+
/** Visualize collected events */
|
|
237
|
+
visualize: () => string;
|
|
238
|
+
/** Visualize in a specific format */
|
|
239
|
+
visualizeAs: (format: OutputFormat) => string;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export { type CollectableEvent, DecisionBranchEvent, DecisionEndEvent, DecisionStartEvent, DiagramSource, ExportFormat, ExportOptions, OutputFormat, ScopeEndEvent, ScopeStartEvent, VisualizerOptions, WorkflowIR, type WorkflowVisualizer, combineEventHandlers, createEventCollector, createVisualizer, toExportUrl, visualizeEvents };
|