@principal-ai/principal-view-core 0.5.6
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 +126 -0
- package/dist/ConfigurationLoader.d.ts +76 -0
- package/dist/ConfigurationLoader.d.ts.map +1 -0
- package/dist/ConfigurationLoader.js +144 -0
- package/dist/ConfigurationLoader.js.map +1 -0
- package/dist/ConfigurationValidator.d.ts +31 -0
- package/dist/ConfigurationValidator.d.ts.map +1 -0
- package/dist/ConfigurationValidator.js +242 -0
- package/dist/ConfigurationValidator.js.map +1 -0
- package/dist/EventProcessor.d.ts +49 -0
- package/dist/EventProcessor.d.ts.map +1 -0
- package/dist/EventProcessor.js +215 -0
- package/dist/EventProcessor.js.map +1 -0
- package/dist/EventRecorderService.d.ts +305 -0
- package/dist/EventRecorderService.d.ts.map +1 -0
- package/dist/EventRecorderService.js +463 -0
- package/dist/EventRecorderService.js.map +1 -0
- package/dist/LibraryLoader.d.ts +63 -0
- package/dist/LibraryLoader.d.ts.map +1 -0
- package/dist/LibraryLoader.js +188 -0
- package/dist/LibraryLoader.js.map +1 -0
- package/dist/PathBasedEventProcessor.d.ts +90 -0
- package/dist/PathBasedEventProcessor.d.ts.map +1 -0
- package/dist/PathBasedEventProcessor.js +239 -0
- package/dist/PathBasedEventProcessor.js.map +1 -0
- package/dist/SessionManager.d.ts +194 -0
- package/dist/SessionManager.d.ts.map +1 -0
- package/dist/SessionManager.js +299 -0
- package/dist/SessionManager.js.map +1 -0
- package/dist/ValidationEngine.d.ts +31 -0
- package/dist/ValidationEngine.d.ts.map +1 -0
- package/dist/ValidationEngine.js +158 -0
- package/dist/ValidationEngine.js.map +1 -0
- package/dist/helpers/GraphInstrumentationHelper.d.ts +93 -0
- package/dist/helpers/GraphInstrumentationHelper.d.ts.map +1 -0
- package/dist/helpers/GraphInstrumentationHelper.js +248 -0
- package/dist/helpers/GraphInstrumentationHelper.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/config.d.ts +57 -0
- package/dist/rules/config.d.ts.map +1 -0
- package/dist/rules/config.js +382 -0
- package/dist/rules/config.js.map +1 -0
- package/dist/rules/engine.d.ts +70 -0
- package/dist/rules/engine.d.ts.map +1 -0
- package/dist/rules/engine.js +252 -0
- package/dist/rules/engine.js.map +1 -0
- package/dist/rules/implementations/connection-type-references.d.ts +7 -0
- package/dist/rules/implementations/connection-type-references.d.ts.map +1 -0
- package/dist/rules/implementations/connection-type-references.js +104 -0
- package/dist/rules/implementations/connection-type-references.js.map +1 -0
- package/dist/rules/implementations/dead-end-states.d.ts +17 -0
- package/dist/rules/implementations/dead-end-states.d.ts.map +1 -0
- package/dist/rules/implementations/dead-end-states.js +72 -0
- package/dist/rules/implementations/dead-end-states.js.map +1 -0
- package/dist/rules/implementations/index.d.ts +24 -0
- package/dist/rules/implementations/index.d.ts.map +1 -0
- package/dist/rules/implementations/index.js +62 -0
- package/dist/rules/implementations/index.js.map +1 -0
- package/dist/rules/implementations/library-node-type-match.d.ts +17 -0
- package/dist/rules/implementations/library-node-type-match.d.ts.map +1 -0
- package/dist/rules/implementations/library-node-type-match.js +123 -0
- package/dist/rules/implementations/library-node-type-match.js.map +1 -0
- package/dist/rules/implementations/minimum-node-sources.d.ts +22 -0
- package/dist/rules/implementations/minimum-node-sources.d.ts.map +1 -0
- package/dist/rules/implementations/minimum-node-sources.js +54 -0
- package/dist/rules/implementations/minimum-node-sources.js.map +1 -0
- package/dist/rules/implementations/no-unknown-fields.d.ts +7 -0
- package/dist/rules/implementations/no-unknown-fields.d.ts.map +1 -0
- package/dist/rules/implementations/no-unknown-fields.js +211 -0
- package/dist/rules/implementations/no-unknown-fields.js.map +1 -0
- package/dist/rules/implementations/orphaned-edge-types.d.ts +7 -0
- package/dist/rules/implementations/orphaned-edge-types.d.ts.map +1 -0
- package/dist/rules/implementations/orphaned-edge-types.js +47 -0
- package/dist/rules/implementations/orphaned-edge-types.js.map +1 -0
- package/dist/rules/implementations/orphaned-node-types.d.ts +7 -0
- package/dist/rules/implementations/orphaned-node-types.d.ts.map +1 -0
- package/dist/rules/implementations/orphaned-node-types.js +50 -0
- package/dist/rules/implementations/orphaned-node-types.js.map +1 -0
- package/dist/rules/implementations/required-metadata.d.ts +7 -0
- package/dist/rules/implementations/required-metadata.d.ts.map +1 -0
- package/dist/rules/implementations/required-metadata.js +57 -0
- package/dist/rules/implementations/required-metadata.js.map +1 -0
- package/dist/rules/implementations/state-transition-references.d.ts +7 -0
- package/dist/rules/implementations/state-transition-references.d.ts.map +1 -0
- package/dist/rules/implementations/state-transition-references.js +135 -0
- package/dist/rules/implementations/state-transition-references.js.map +1 -0
- package/dist/rules/implementations/unreachable-states.d.ts +7 -0
- package/dist/rules/implementations/unreachable-states.d.ts.map +1 -0
- package/dist/rules/implementations/unreachable-states.js +80 -0
- package/dist/rules/implementations/unreachable-states.js.map +1 -0
- package/dist/rules/implementations/valid-action-patterns.d.ts +17 -0
- package/dist/rules/implementations/valid-action-patterns.d.ts.map +1 -0
- package/dist/rules/implementations/valid-action-patterns.js +109 -0
- package/dist/rules/implementations/valid-action-patterns.js.map +1 -0
- package/dist/rules/implementations/valid-color-format.d.ts +7 -0
- package/dist/rules/implementations/valid-color-format.d.ts.map +1 -0
- package/dist/rules/implementations/valid-color-format.js +91 -0
- package/dist/rules/implementations/valid-color-format.js.map +1 -0
- package/dist/rules/implementations/valid-edge-types.d.ts +7 -0
- package/dist/rules/implementations/valid-edge-types.d.ts.map +1 -0
- package/dist/rules/implementations/valid-edge-types.js +244 -0
- package/dist/rules/implementations/valid-edge-types.js.map +1 -0
- package/dist/rules/implementations/valid-node-types.d.ts +7 -0
- package/dist/rules/implementations/valid-node-types.d.ts.map +1 -0
- package/dist/rules/implementations/valid-node-types.js +175 -0
- package/dist/rules/implementations/valid-node-types.js.map +1 -0
- package/dist/rules/index.d.ts +28 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +45 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/types.d.ts +309 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +35 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/types/canvas.d.ts +409 -0
- package/dist/types/canvas.d.ts.map +1 -0
- package/dist/types/canvas.js +70 -0
- package/dist/types/canvas.js.map +1 -0
- package/dist/types/index.d.ts +311 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/library.d.ts +185 -0
- package/dist/types/library.d.ts.map +1 -0
- package/dist/types/library.js +15 -0
- package/dist/types/library.js.map +1 -0
- package/dist/types/path-based-config.d.ts +230 -0
- package/dist/types/path-based-config.d.ts.map +1 -0
- package/dist/types/path-based-config.js +9 -0
- package/dist/types/path-based-config.js.map +1 -0
- package/dist/utils/CanvasConverter.d.ts +118 -0
- package/dist/utils/CanvasConverter.d.ts.map +1 -0
- package/dist/utils/CanvasConverter.js +315 -0
- package/dist/utils/CanvasConverter.js.map +1 -0
- package/dist/utils/GraphConverter.d.ts +18 -0
- package/dist/utils/GraphConverter.d.ts.map +1 -0
- package/dist/utils/GraphConverter.js +61 -0
- package/dist/utils/GraphConverter.js.map +1 -0
- package/dist/utils/LibraryConverter.d.ts +113 -0
- package/dist/utils/LibraryConverter.d.ts.map +1 -0
- package/dist/utils/LibraryConverter.js +166 -0
- package/dist/utils/LibraryConverter.js.map +1 -0
- package/dist/utils/PathMatcher.d.ts +55 -0
- package/dist/utils/PathMatcher.d.ts.map +1 -0
- package/dist/utils/PathMatcher.js +172 -0
- package/dist/utils/PathMatcher.js.map +1 -0
- package/dist/utils/YamlParser.d.ts +36 -0
- package/dist/utils/YamlParser.d.ts.map +1 -0
- package/dist/utils/YamlParser.js +63 -0
- package/dist/utils/YamlParser.js.map +1 -0
- package/package.json +47 -0
- package/src/ConfigurationLoader.test.ts +490 -0
- package/src/ConfigurationLoader.ts +185 -0
- package/src/ConfigurationValidator.test.ts +200 -0
- package/src/ConfigurationValidator.ts +283 -0
- package/src/EventProcessor.test.ts +405 -0
- package/src/EventProcessor.ts +250 -0
- package/src/EventRecorderService.test.ts +541 -0
- package/src/EventRecorderService.ts +744 -0
- package/src/LibraryLoader.ts +215 -0
- package/src/PathBasedEventProcessor.test.ts +567 -0
- package/src/PathBasedEventProcessor.ts +332 -0
- package/src/SessionManager.test.ts +424 -0
- package/src/SessionManager.ts +470 -0
- package/src/ValidationEngine.test.ts +371 -0
- package/src/ValidationEngine.ts +196 -0
- package/src/helpers/GraphInstrumentationHelper.test.ts +340 -0
- package/src/helpers/GraphInstrumentationHelper.ts +326 -0
- package/src/index.ts +85 -0
- package/src/rules/config.test.ts +278 -0
- package/src/rules/config.ts +459 -0
- package/src/rules/engine.test.ts +332 -0
- package/src/rules/engine.ts +318 -0
- package/src/rules/implementations/connection-type-references.ts +117 -0
- package/src/rules/implementations/dead-end-states.ts +101 -0
- package/src/rules/implementations/index.ts +73 -0
- package/src/rules/implementations/library-node-type-match.ts +148 -0
- package/src/rules/implementations/minimum-node-sources.ts +82 -0
- package/src/rules/implementations/no-unknown-fields.ts +342 -0
- package/src/rules/implementations/orphaned-edge-types.ts +55 -0
- package/src/rules/implementations/orphaned-node-types.ts +58 -0
- package/src/rules/implementations/required-metadata.ts +64 -0
- package/src/rules/implementations/state-transition-references.ts +151 -0
- package/src/rules/implementations/unreachable-states.ts +94 -0
- package/src/rules/implementations/valid-action-patterns.ts +136 -0
- package/src/rules/implementations/valid-color-format.ts +140 -0
- package/src/rules/implementations/valid-edge-types.ts +258 -0
- package/src/rules/implementations/valid-node-types.ts +189 -0
- package/src/rules/index.ts +95 -0
- package/src/rules/types.ts +426 -0
- package/src/types/canvas.ts +496 -0
- package/src/types/index.ts +382 -0
- package/src/types/library.ts +233 -0
- package/src/types/path-based-config.ts +281 -0
- package/src/utils/CanvasConverter.ts +431 -0
- package/src/utils/GraphConverter.test.ts +195 -0
- package/src/utils/GraphConverter.ts +71 -0
- package/src/utils/LibraryConverter.ts +245 -0
- package/src/utils/PathMatcher.test.ts +148 -0
- package/src/utils/PathMatcher.ts +183 -0
- package/src/utils/YamlParser.ts +75 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Canvas Extended Types
|
|
3
|
+
*
|
|
4
|
+
* This module defines types that extend the JSON Canvas spec (https://jsoncanvas.org/spec/1.0/)
|
|
5
|
+
* with Principal View Framework extensions.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: All extensions are placed in a `pv` (Principal View) field,
|
|
8
|
+
* which is ignored by standard canvas tools (like Obsidian) but used by our React Flow renderer.
|
|
9
|
+
*
|
|
10
|
+
* This allows:
|
|
11
|
+
* 1. Authoring layouts visually in Obsidian or other canvas tools
|
|
12
|
+
* 2. Rendering with rich animations and states in React Flow
|
|
13
|
+
* 3. Round-trip editing without data loss
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// JSON Canvas Spec Types (1.0)
|
|
18
|
+
// https://jsoncanvas.org/spec/1.0/
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Canvas color - either a hex string or preset number (1-6)
|
|
23
|
+
* Presets: 1=red, 2=orange, 3=yellow, 4=green, 5=cyan, 6=purple
|
|
24
|
+
*/
|
|
25
|
+
export type CanvasColor = string | 1 | 2 | 3 | 4 | 5 | 6;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Side of a node for edge connections
|
|
29
|
+
*/
|
|
30
|
+
export type CanvasSide = 'top' | 'right' | 'bottom' | 'left';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Edge endpoint shape
|
|
34
|
+
*/
|
|
35
|
+
export type CanvasEndpoint = 'none' | 'arrow';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Background style for group nodes
|
|
39
|
+
*/
|
|
40
|
+
export type CanvasBackgroundStyle = 'cover' | 'ratio' | 'repeat';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Base node properties (common to all node types)
|
|
44
|
+
*/
|
|
45
|
+
export interface CanvasNodeBase {
|
|
46
|
+
/** Unique identifier */
|
|
47
|
+
id: string;
|
|
48
|
+
/** X position in pixels */
|
|
49
|
+
x: number;
|
|
50
|
+
/** Y position in pixels */
|
|
51
|
+
y: number;
|
|
52
|
+
/** Width in pixels */
|
|
53
|
+
width: number;
|
|
54
|
+
/** Height in pixels */
|
|
55
|
+
height: number;
|
|
56
|
+
/** Optional color */
|
|
57
|
+
color?: CanvasColor;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Text node - stores plain text or markdown
|
|
62
|
+
*/
|
|
63
|
+
export interface CanvasTextNode extends CanvasNodeBase {
|
|
64
|
+
type: 'text';
|
|
65
|
+
/** Markdown-formatted text content */
|
|
66
|
+
text: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* File node - references an external file
|
|
71
|
+
*/
|
|
72
|
+
export interface CanvasFileNode extends CanvasNodeBase {
|
|
73
|
+
type: 'file';
|
|
74
|
+
/** Path to the file */
|
|
75
|
+
file: string;
|
|
76
|
+
/** Optional subpath (heading or block link) */
|
|
77
|
+
subpath?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Link node - references a URL
|
|
82
|
+
*/
|
|
83
|
+
export interface CanvasLinkNode extends CanvasNodeBase {
|
|
84
|
+
type: 'link';
|
|
85
|
+
/** URL to link to */
|
|
86
|
+
url: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Group node - visual container for other nodes
|
|
91
|
+
*/
|
|
92
|
+
export interface CanvasGroupNode extends CanvasNodeBase {
|
|
93
|
+
type: 'group';
|
|
94
|
+
/** Optional label for the group */
|
|
95
|
+
label?: string;
|
|
96
|
+
/** Optional background image path */
|
|
97
|
+
background?: string;
|
|
98
|
+
/** Background image style */
|
|
99
|
+
backgroundStyle?: CanvasBackgroundStyle;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Union of all standard canvas node types
|
|
104
|
+
*/
|
|
105
|
+
export type CanvasNode = CanvasTextNode | CanvasFileNode | CanvasLinkNode | CanvasGroupNode;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Canvas edge connecting two nodes
|
|
109
|
+
*/
|
|
110
|
+
export interface CanvasEdge {
|
|
111
|
+
/** Unique identifier */
|
|
112
|
+
id: string;
|
|
113
|
+
/** Source node ID */
|
|
114
|
+
fromNode: string;
|
|
115
|
+
/** Target node ID */
|
|
116
|
+
toNode: string;
|
|
117
|
+
/** Side of source node */
|
|
118
|
+
fromSide?: CanvasSide;
|
|
119
|
+
/** Side of target node */
|
|
120
|
+
toSide?: CanvasSide;
|
|
121
|
+
/** Endpoint shape at source (default: 'none') */
|
|
122
|
+
fromEnd?: CanvasEndpoint;
|
|
123
|
+
/** Endpoint shape at target (default: 'arrow') */
|
|
124
|
+
toEnd?: CanvasEndpoint;
|
|
125
|
+
/** Edge color */
|
|
126
|
+
color?: CanvasColor;
|
|
127
|
+
/** Edge label */
|
|
128
|
+
label?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Standard JSON Canvas document
|
|
133
|
+
*/
|
|
134
|
+
export interface Canvas {
|
|
135
|
+
/** Array of nodes (ordered by z-index ascending) */
|
|
136
|
+
nodes?: CanvasNode[];
|
|
137
|
+
/** Array of edges */
|
|
138
|
+
edges?: CanvasEdge[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ============================================================================
|
|
142
|
+
// Principal View Extensions
|
|
143
|
+
// ============================================================================
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Animation types for edges
|
|
147
|
+
*/
|
|
148
|
+
export type PVAnimationType = 'flow' | 'pulse' | 'particle' | 'glow';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Animation direction
|
|
152
|
+
*/
|
|
153
|
+
export type PVAnimationDirection = 'forward' | 'backward' | 'bidirectional';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Node shape for rendering
|
|
157
|
+
*/
|
|
158
|
+
export type PVNodeShape = 'circle' | 'rectangle' | 'hexagon' | 'diamond' | 'custom';
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Edge line style
|
|
162
|
+
*/
|
|
163
|
+
export type PVEdgeStyle = 'solid' | 'dashed' | 'dotted' | 'animated';
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Log level for path-based association
|
|
167
|
+
*/
|
|
168
|
+
export type PVLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Action pattern for extracting events from logs
|
|
172
|
+
*/
|
|
173
|
+
export interface PVActionPattern {
|
|
174
|
+
/** Regex pattern with named capture groups */
|
|
175
|
+
pattern: string;
|
|
176
|
+
/** Event type to emit */
|
|
177
|
+
event: string;
|
|
178
|
+
/** State to transition to */
|
|
179
|
+
state?: string;
|
|
180
|
+
/** Metadata template using $captureGroup syntax */
|
|
181
|
+
metadata?: Record<string, string>;
|
|
182
|
+
/** Edge IDs to trigger animations on */
|
|
183
|
+
triggerEdges?: string[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* State definition for a node
|
|
188
|
+
*/
|
|
189
|
+
export interface PVNodeState {
|
|
190
|
+
/** Color when in this state */
|
|
191
|
+
color?: string;
|
|
192
|
+
/** Icon when in this state */
|
|
193
|
+
icon?: string;
|
|
194
|
+
/** Display label */
|
|
195
|
+
label?: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Edge activation trigger
|
|
200
|
+
*/
|
|
201
|
+
export interface PVEdgeActivation {
|
|
202
|
+
/** Action that triggers this animation */
|
|
203
|
+
action: string;
|
|
204
|
+
/** Animation type */
|
|
205
|
+
animation: PVAnimationType;
|
|
206
|
+
/** Animation direction */
|
|
207
|
+
direction?: PVAnimationDirection;
|
|
208
|
+
/** Duration in milliseconds */
|
|
209
|
+
duration?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Principal View node extensions
|
|
214
|
+
*/
|
|
215
|
+
export interface PVNodeExtension {
|
|
216
|
+
/** Custom node type identifier */
|
|
217
|
+
nodeType: string;
|
|
218
|
+
/** Description of this node */
|
|
219
|
+
description?: string;
|
|
220
|
+
/** Visual shape */
|
|
221
|
+
shape?: PVNodeShape;
|
|
222
|
+
/** Icon identifier (Lucide icons) */
|
|
223
|
+
icon?: string;
|
|
224
|
+
/** Fill color (hex string) - takes priority over node.color */
|
|
225
|
+
fill?: string;
|
|
226
|
+
/** Stroke/border color (hex string) */
|
|
227
|
+
stroke?: string;
|
|
228
|
+
/** State definitions */
|
|
229
|
+
states?: Record<string, PVNodeState>;
|
|
230
|
+
/** Source file patterns for log association */
|
|
231
|
+
sources?: string[];
|
|
232
|
+
/** Action patterns for event extraction */
|
|
233
|
+
actions?: PVActionPattern[];
|
|
234
|
+
/** Data schema for typed fields */
|
|
235
|
+
dataSchema?: Record<
|
|
236
|
+
string,
|
|
237
|
+
{
|
|
238
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
239
|
+
required?: boolean;
|
|
240
|
+
displayInLabel?: boolean;
|
|
241
|
+
}
|
|
242
|
+
>;
|
|
243
|
+
/** Layout hints */
|
|
244
|
+
layout?: {
|
|
245
|
+
layer?: number;
|
|
246
|
+
cluster?: string;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Principal View edge extensions
|
|
252
|
+
*/
|
|
253
|
+
export interface PVEdgeExtension {
|
|
254
|
+
/** Custom edge type identifier */
|
|
255
|
+
edgeType: string;
|
|
256
|
+
/** Line style */
|
|
257
|
+
style?: PVEdgeStyle;
|
|
258
|
+
/** Line width in pixels */
|
|
259
|
+
width?: number;
|
|
260
|
+
/** Default animation */
|
|
261
|
+
animation?: {
|
|
262
|
+
type: PVAnimationType;
|
|
263
|
+
duration?: number;
|
|
264
|
+
color?: string;
|
|
265
|
+
};
|
|
266
|
+
/** Activation triggers */
|
|
267
|
+
activatedBy?: PVEdgeActivation[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Path-based configuration options
|
|
272
|
+
*/
|
|
273
|
+
export interface PVPathConfig {
|
|
274
|
+
/** Project root for path normalization */
|
|
275
|
+
projectRoot?: string;
|
|
276
|
+
/** Enable source capture from stack traces */
|
|
277
|
+
captureSource?: boolean;
|
|
278
|
+
/** Enable action pattern matching */
|
|
279
|
+
enableActionPatterns?: boolean;
|
|
280
|
+
/** Minimum log level to process */
|
|
281
|
+
logLevel?: PVLogLevel;
|
|
282
|
+
/** Ignore logs without source info */
|
|
283
|
+
ignoreUnsourced?: boolean;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Display configuration
|
|
288
|
+
*/
|
|
289
|
+
export interface PVDisplayConfig {
|
|
290
|
+
/** Layout algorithm (manual uses canvas positions) */
|
|
291
|
+
layout?: 'hierarchical' | 'force-directed' | 'circular' | 'manual';
|
|
292
|
+
/** Color theme */
|
|
293
|
+
theme?: {
|
|
294
|
+
primary?: string;
|
|
295
|
+
success?: string;
|
|
296
|
+
warning?: string;
|
|
297
|
+
danger?: string;
|
|
298
|
+
info?: string;
|
|
299
|
+
};
|
|
300
|
+
/** Animation settings */
|
|
301
|
+
animations?: {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
speed?: number;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Node type definition (stored at canvas level in pv.nodeTypes)
|
|
309
|
+
*/
|
|
310
|
+
export interface PVNodeTypeDefinition {
|
|
311
|
+
/** Display label */
|
|
312
|
+
label?: string;
|
|
313
|
+
/** Description of this node type */
|
|
314
|
+
description?: string;
|
|
315
|
+
/** Fill color (hex string) */
|
|
316
|
+
color?: string;
|
|
317
|
+
/** Icon identifier (Lucide icons) */
|
|
318
|
+
icon?: string;
|
|
319
|
+
/** Visual shape */
|
|
320
|
+
shape?: PVNodeShape;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Edge type definition (stored at canvas level)
|
|
325
|
+
*/
|
|
326
|
+
export interface PVEdgeTypeDefinition {
|
|
327
|
+
/** Display label */
|
|
328
|
+
label?: string;
|
|
329
|
+
/** Line style */
|
|
330
|
+
style?: PVEdgeStyle;
|
|
331
|
+
/** Line color */
|
|
332
|
+
color?: string;
|
|
333
|
+
/** Line width */
|
|
334
|
+
width?: number;
|
|
335
|
+
/** Whether edge is directed */
|
|
336
|
+
directed?: boolean;
|
|
337
|
+
/** Default animation */
|
|
338
|
+
animation?: {
|
|
339
|
+
type: PVAnimationType;
|
|
340
|
+
duration?: number;
|
|
341
|
+
color?: string;
|
|
342
|
+
};
|
|
343
|
+
/** Label configuration (for dynamic labels) */
|
|
344
|
+
labelConfig?: {
|
|
345
|
+
field?: string;
|
|
346
|
+
position?: 'start' | 'middle' | 'end';
|
|
347
|
+
};
|
|
348
|
+
/** Activation triggers */
|
|
349
|
+
activatedBy?: PVEdgeActivation[];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Canvas-level Principal View extensions
|
|
354
|
+
*/
|
|
355
|
+
export interface PVCanvasExtension {
|
|
356
|
+
/** Schema version */
|
|
357
|
+
version: string;
|
|
358
|
+
/** Graph name */
|
|
359
|
+
name: string;
|
|
360
|
+
/** Description */
|
|
361
|
+
description?: string;
|
|
362
|
+
/** Node type definitions (shared across nodes) */
|
|
363
|
+
nodeTypes?: Record<string, PVNodeTypeDefinition>;
|
|
364
|
+
/** Edge type definitions (shared across edges) */
|
|
365
|
+
edgeTypes?: Record<string, PVEdgeTypeDefinition>;
|
|
366
|
+
/** Path-based configuration */
|
|
367
|
+
pathConfig?: PVPathConfig;
|
|
368
|
+
/** Display configuration */
|
|
369
|
+
display?: PVDisplayConfig;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ============================================================================
|
|
373
|
+
// Extended Canvas Types (Canvas + PV Extensions)
|
|
374
|
+
// ============================================================================
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Extended text node with PV extensions
|
|
378
|
+
*/
|
|
379
|
+
export interface ExtendedCanvasTextNode extends CanvasTextNode {
|
|
380
|
+
pv?: PVNodeExtension;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Extended file node with PV extensions
|
|
385
|
+
*/
|
|
386
|
+
export interface ExtendedCanvasFileNode extends CanvasFileNode {
|
|
387
|
+
pv?: PVNodeExtension;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Extended link node with PV extensions
|
|
392
|
+
*/
|
|
393
|
+
export interface ExtendedCanvasLinkNode extends CanvasLinkNode {
|
|
394
|
+
pv?: PVNodeExtension;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Extended group node with PV extensions
|
|
399
|
+
*/
|
|
400
|
+
export interface ExtendedCanvasGroupNode extends CanvasGroupNode {
|
|
401
|
+
pv?: PVNodeExtension;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Union of all extended node types
|
|
406
|
+
*/
|
|
407
|
+
export type ExtendedCanvasNode =
|
|
408
|
+
| ExtendedCanvasTextNode
|
|
409
|
+
| ExtendedCanvasFileNode
|
|
410
|
+
| ExtendedCanvasLinkNode
|
|
411
|
+
| ExtendedCanvasGroupNode;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Extended edge with PV extensions
|
|
415
|
+
*/
|
|
416
|
+
export interface ExtendedCanvasEdge extends CanvasEdge {
|
|
417
|
+
pv?: PVEdgeExtension;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Extended Canvas document with Principal View support
|
|
422
|
+
*
|
|
423
|
+
* This is the primary type for .canvas files used with the Principal View Framework.
|
|
424
|
+
* It's fully compatible with standard JSON Canvas tools while supporting rich
|
|
425
|
+
* visualization features when rendered in React Flow.
|
|
426
|
+
*/
|
|
427
|
+
export interface ExtendedCanvas extends Canvas {
|
|
428
|
+
/** Nodes with optional PV extensions */
|
|
429
|
+
nodes?: ExtendedCanvasNode[];
|
|
430
|
+
/** Edges with optional PV extensions */
|
|
431
|
+
edges?: ExtendedCanvasEdge[];
|
|
432
|
+
/** Canvas-level PV configuration */
|
|
433
|
+
pv?: PVCanvasExtension;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ============================================================================
|
|
437
|
+
// Utility Types
|
|
438
|
+
// ============================================================================
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Type guard for text nodes
|
|
442
|
+
*/
|
|
443
|
+
export function isTextNode(node: CanvasNode | ExtendedCanvasNode): node is CanvasTextNode | ExtendedCanvasTextNode {
|
|
444
|
+
return node.type === 'text';
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Type guard for file nodes
|
|
449
|
+
*/
|
|
450
|
+
export function isFileNode(node: CanvasNode | ExtendedCanvasNode): node is CanvasFileNode | ExtendedCanvasFileNode {
|
|
451
|
+
return node.type === 'file';
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Type guard for link nodes
|
|
456
|
+
*/
|
|
457
|
+
export function isLinkNode(node: CanvasNode | ExtendedCanvasNode): node is CanvasLinkNode | ExtendedCanvasLinkNode {
|
|
458
|
+
return node.type === 'link';
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Type guard for group nodes
|
|
463
|
+
*/
|
|
464
|
+
export function isGroupNode(node: CanvasNode | ExtendedCanvasNode): node is CanvasGroupNode | ExtendedCanvasGroupNode {
|
|
465
|
+
return node.type === 'group';
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Type guard for extended nodes (with PV extension)
|
|
470
|
+
*/
|
|
471
|
+
export function hasPVExtension(node: CanvasNode | ExtendedCanvasNode): node is ExtendedCanvasNode {
|
|
472
|
+
return 'pv' in node && node.pv !== undefined;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Color preset mapping
|
|
477
|
+
*/
|
|
478
|
+
export const CANVAS_COLOR_PRESETS: Record<number, string> = {
|
|
479
|
+
1: '#ef4444', // red
|
|
480
|
+
2: '#f97316', // orange
|
|
481
|
+
3: '#eab308', // yellow
|
|
482
|
+
4: '#22c55e', // green
|
|
483
|
+
5: '#06b6d4', // cyan
|
|
484
|
+
6: '#8b5cf6', // purple
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Resolve a canvas color to a hex string
|
|
489
|
+
*/
|
|
490
|
+
export function resolveCanvasColor(color: CanvasColor | undefined): string | undefined {
|
|
491
|
+
if (color === undefined) return undefined;
|
|
492
|
+
if (typeof color === 'number') {
|
|
493
|
+
return CANVAS_COLOR_PRESETS[color];
|
|
494
|
+
}
|
|
495
|
+
return color;
|
|
496
|
+
}
|