@principal-ai/principal-view-core 0.26.11 → 0.26.13
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/dashboard/DashboardValidator.d.ts +85 -0
- package/dist/dashboard/DashboardValidator.d.ts.map +1 -0
- package/dist/dashboard/DashboardValidator.js +772 -0
- package/dist/dashboard/DashboardValidator.js.map +1 -0
- package/dist/dashboard/index.d.ts +6 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +10 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/discovery/CanvasDiscovery.d.ts +7 -0
- package/dist/discovery/CanvasDiscovery.d.ts.map +1 -1
- package/dist/discovery/CanvasDiscovery.js +49 -5
- package/dist/discovery/CanvasDiscovery.js.map +1 -1
- package/dist/discovery/types.d.ts +15 -0
- package/dist/discovery/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +6 -2
- package/dist/node.js.map +1 -1
- package/package.json +1 -1
- package/src/dashboard/DashboardValidator.ts +901 -0
- package/src/dashboard/index.ts +14 -0
- package/src/discovery/CanvasDiscovery.ts +66 -3
- package/src/discovery/types.ts +16 -0
- package/src/index.ts +8 -0
- package/src/node.ts +8 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard module exports
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
DashboardValidator,
|
|
7
|
+
createDashboardValidator,
|
|
8
|
+
} from './DashboardValidator';
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
DashboardValidationError,
|
|
12
|
+
DashboardValidationResult,
|
|
13
|
+
DashboardValidationContext,
|
|
14
|
+
} from './DashboardValidator';
|
|
@@ -16,7 +16,14 @@ import type {
|
|
|
16
16
|
CanvasDiscoveryResult,
|
|
17
17
|
DiscoveryOptions,
|
|
18
18
|
CanvasType,
|
|
19
|
+
ReferencedSpan,
|
|
19
20
|
} from './types';
|
|
21
|
+
import { deriveWorkflowEdges } from '../workflow/edge-derivation';
|
|
22
|
+
import type { ExtendedCanvas } from '../types/canvas';
|
|
23
|
+
import { isOtelSpanConventionNode } from '../types/canvas';
|
|
24
|
+
|
|
25
|
+
/** Lookup map from span pattern to display label */
|
|
26
|
+
type SpanLabelLookup = Map<string, string>;
|
|
20
27
|
|
|
21
28
|
/**
|
|
22
29
|
* Unified discovery system for canvas and execution files in a package-aware way
|
|
@@ -52,6 +59,40 @@ export class CanvasDiscovery {
|
|
|
52
59
|
this.packageModule = new PackageLayerModule();
|
|
53
60
|
}
|
|
54
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Build a lookup map from span pattern to display label from spans.canvas files
|
|
64
|
+
*
|
|
65
|
+
* @param canvases - Discovered canvases (must include content for spans.canvas)
|
|
66
|
+
* @returns Map of spanPattern → label
|
|
67
|
+
*/
|
|
68
|
+
private buildSpanLabelLookup(
|
|
69
|
+
canvases: (DiscoveredCanvas | DiscoveredCanvasWithContent)[]
|
|
70
|
+
): SpanLabelLookup {
|
|
71
|
+
const lookup: SpanLabelLookup = new Map();
|
|
72
|
+
|
|
73
|
+
for (const canvas of canvases) {
|
|
74
|
+
// Only process spans.canvas files with content
|
|
75
|
+
if (canvas.type !== 'spans') continue;
|
|
76
|
+
|
|
77
|
+
const canvasWithContent = canvas as DiscoveredCanvasWithContent;
|
|
78
|
+
const content = canvasWithContent.content as ExtendedCanvas | undefined;
|
|
79
|
+
if (!content?.nodes) continue;
|
|
80
|
+
|
|
81
|
+
// Extract span patterns and labels from otel-span-convention nodes
|
|
82
|
+
for (const node of content.nodes) {
|
|
83
|
+
if (isOtelSpanConventionNode(node)) {
|
|
84
|
+
const spanPattern = node.otel.spanPattern;
|
|
85
|
+
const label = node.label;
|
|
86
|
+
if (spanPattern && label) {
|
|
87
|
+
lookup.set(spanPattern, label);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return lookup;
|
|
94
|
+
}
|
|
95
|
+
|
|
55
96
|
/**
|
|
56
97
|
* Discover all canvas, workflow, and test trace files in the file tree
|
|
57
98
|
*
|
|
@@ -75,9 +116,12 @@ export class CanvasDiscovery {
|
|
|
75
116
|
// 3. Discover canvas files
|
|
76
117
|
const canvases = await this.discoverCanvasFiles(fileTree, packageMap, options, errors);
|
|
77
118
|
|
|
119
|
+
// 3.5. Build span label lookup from spans.canvas files (for enriching workflow referencedSpans)
|
|
120
|
+
const spanLabelLookup = this.buildSpanLabelLookup(canvases);
|
|
121
|
+
|
|
78
122
|
// 4. Discover storyboards (hierarchical organization)
|
|
79
123
|
// Note: Test traces are discovered as part of workflows, not separately
|
|
80
|
-
const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, options, errors);
|
|
124
|
+
const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, options, errors, spanLabelLookup);
|
|
81
125
|
|
|
82
126
|
// 5. Collect all test traces from workflows for backward compatibility
|
|
83
127
|
const testTraces: (DiscoveredTestTrace | DiscoveredTestTraceWithContent)[] = [];
|
|
@@ -204,7 +248,8 @@ export class CanvasDiscovery {
|
|
|
204
248
|
packageMap: Map<string, PackageLayer>,
|
|
205
249
|
canvases: DiscoveredCanvas[],
|
|
206
250
|
options: DiscoveryOptions,
|
|
207
|
-
errors: Array<{ path: string; error: string }
|
|
251
|
+
errors: Array<{ path: string; error: string }>,
|
|
252
|
+
spanLabelLookup: SpanLabelLookup
|
|
208
253
|
): Promise<(DiscoveredStoryboard | DiscoveredStoryboardWithContent)[]> {
|
|
209
254
|
const storyboards: (DiscoveredStoryboard | DiscoveredStoryboardWithContent)[] = [];
|
|
210
255
|
|
|
@@ -251,6 +296,7 @@ export class CanvasDiscovery {
|
|
|
251
296
|
storyboardName,
|
|
252
297
|
packageMap,
|
|
253
298
|
options,
|
|
299
|
+
spanLabelLookup,
|
|
254
300
|
errors
|
|
255
301
|
);
|
|
256
302
|
|
|
@@ -326,6 +372,7 @@ export class CanvasDiscovery {
|
|
|
326
372
|
storyboardName: string,
|
|
327
373
|
packageMap: Map<string, PackageLayer>,
|
|
328
374
|
options: DiscoveryOptions,
|
|
375
|
+
spanLabelLookup: SpanLabelLookup,
|
|
329
376
|
errors: Array<{ path: string; error: string }>
|
|
330
377
|
): Promise<(DiscoveredWorkflow | DiscoveredWorkflowWithContent)[]> {
|
|
331
378
|
const workflows: (DiscoveredWorkflow | DiscoveredWorkflowWithContent)[] = [];
|
|
@@ -384,7 +431,23 @@ export class CanvasDiscovery {
|
|
|
384
431
|
try {
|
|
385
432
|
const content = await options.fileReader(path);
|
|
386
433
|
const parsedContent = JSON.parse(content);
|
|
387
|
-
|
|
434
|
+
|
|
435
|
+
// Extract referenced spans from workflow content
|
|
436
|
+
const edgeResult = deriveWorkflowEdges(parsedContent, path);
|
|
437
|
+
|
|
438
|
+
// Convert span patterns to ReferencedSpan objects with labels
|
|
439
|
+
const referencedSpans: ReferencedSpan[] = edgeResult.referencedSpans.map(
|
|
440
|
+
(pattern) => ({
|
|
441
|
+
pattern,
|
|
442
|
+
label: spanLabelLookup.get(pattern),
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
workflow = {
|
|
447
|
+
...workflow,
|
|
448
|
+
content: parsedContent,
|
|
449
|
+
referencedSpans,
|
|
450
|
+
} as DiscoveredWorkflowWithContent;
|
|
388
451
|
} catch (error) {
|
|
389
452
|
errors.push({
|
|
390
453
|
path,
|
package/src/discovery/types.ts
CHANGED
|
@@ -74,6 +74,16 @@ export interface DiscoveredTestTrace {
|
|
|
74
74
|
scope: 'root' | 'package';
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* A span convention (surface) referenced by a workflow
|
|
79
|
+
*/
|
|
80
|
+
export interface ReferencedSpan {
|
|
81
|
+
/** The span pattern (e.g., "canvas.load", "multi-canvas-panel.render") */
|
|
82
|
+
pattern: string;
|
|
83
|
+
/** Display label from the spans.canvas node, if found */
|
|
84
|
+
label?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
/**
|
|
78
88
|
* Discovered workflow file within a storyboard
|
|
79
89
|
*/
|
|
@@ -96,6 +106,12 @@ export interface DiscoveredWorkflow {
|
|
|
96
106
|
scope: 'root' | 'package';
|
|
97
107
|
/** Associated test trace files for this workflow */
|
|
98
108
|
testTraces: DiscoveredTestTrace[];
|
|
109
|
+
/**
|
|
110
|
+
* All span conventions (surfaces) referenced by this workflow.
|
|
111
|
+
* Includes rootSpan and any explicit span fields in event templates.
|
|
112
|
+
* Only populated when includeContent: true during discovery.
|
|
113
|
+
*/
|
|
114
|
+
referencedSpans?: ReferencedSpan[];
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
/**
|
package/src/index.ts
CHANGED
|
@@ -350,6 +350,14 @@ export type {
|
|
|
350
350
|
ExecutionValidationResult,
|
|
351
351
|
} from './execution/ExecutionValidator';
|
|
352
352
|
|
|
353
|
+
// Export dashboard validation (browser-safe - no Node.js dependencies)
|
|
354
|
+
export { DashboardValidator, createDashboardValidator } from './dashboard';
|
|
355
|
+
export type {
|
|
356
|
+
DashboardValidationError,
|
|
357
|
+
DashboardValidationResult,
|
|
358
|
+
DashboardValidationContext,
|
|
359
|
+
} from './dashboard';
|
|
360
|
+
|
|
353
361
|
// Export telemetry coverage analysis (browser-safe - uses FileTree abstraction)
|
|
354
362
|
export { analyzeCoverage } from './telemetry/coverage';
|
|
355
363
|
export type {
|
package/src/node.ts
CHANGED
|
@@ -186,6 +186,14 @@ export type {
|
|
|
186
186
|
ExecutionValidationResult,
|
|
187
187
|
} from './execution/ExecutionValidator';
|
|
188
188
|
|
|
189
|
+
// Export dashboard validation
|
|
190
|
+
export { DashboardValidator, createDashboardValidator } from './dashboard';
|
|
191
|
+
export type {
|
|
192
|
+
DashboardValidationError,
|
|
193
|
+
DashboardValidationResult,
|
|
194
|
+
DashboardValidationContext,
|
|
195
|
+
} from './dashboard';
|
|
196
|
+
|
|
189
197
|
// Export execution loading (Node.js only - file system)
|
|
190
198
|
export { ExecutionLoader, createExecutionLoader } from './execution/ExecutionLoader';
|
|
191
199
|
export type {
|