@principal-ai/principal-view-core 0.26.12 → 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.
@@ -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,8 +16,14 @@ import type {
16
16
  CanvasDiscoveryResult,
17
17
  DiscoveryOptions,
18
18
  CanvasType,
19
+ ReferencedSpan,
19
20
  } from './types';
20
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>;
21
27
 
22
28
  /**
23
29
  * Unified discovery system for canvas and execution files in a package-aware way
@@ -53,6 +59,40 @@ export class CanvasDiscovery {
53
59
  this.packageModule = new PackageLayerModule();
54
60
  }
55
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
+
56
96
  /**
57
97
  * Discover all canvas, workflow, and test trace files in the file tree
58
98
  *
@@ -76,9 +116,12 @@ export class CanvasDiscovery {
76
116
  // 3. Discover canvas files
77
117
  const canvases = await this.discoverCanvasFiles(fileTree, packageMap, options, errors);
78
118
 
119
+ // 3.5. Build span label lookup from spans.canvas files (for enriching workflow referencedSpans)
120
+ const spanLabelLookup = this.buildSpanLabelLookup(canvases);
121
+
79
122
  // 4. Discover storyboards (hierarchical organization)
80
123
  // Note: Test traces are discovered as part of workflows, not separately
81
- const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, options, errors);
124
+ const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, options, errors, spanLabelLookup);
82
125
 
83
126
  // 5. Collect all test traces from workflows for backward compatibility
84
127
  const testTraces: (DiscoveredTestTrace | DiscoveredTestTraceWithContent)[] = [];
@@ -205,7 +248,8 @@ export class CanvasDiscovery {
205
248
  packageMap: Map<string, PackageLayer>,
206
249
  canvases: DiscoveredCanvas[],
207
250
  options: DiscoveryOptions,
208
- errors: Array<{ path: string; error: string }>
251
+ errors: Array<{ path: string; error: string }>,
252
+ spanLabelLookup: SpanLabelLookup
209
253
  ): Promise<(DiscoveredStoryboard | DiscoveredStoryboardWithContent)[]> {
210
254
  const storyboards: (DiscoveredStoryboard | DiscoveredStoryboardWithContent)[] = [];
211
255
 
@@ -252,6 +296,7 @@ export class CanvasDiscovery {
252
296
  storyboardName,
253
297
  packageMap,
254
298
  options,
299
+ spanLabelLookup,
255
300
  errors
256
301
  );
257
302
 
@@ -327,6 +372,7 @@ export class CanvasDiscovery {
327
372
  storyboardName: string,
328
373
  packageMap: Map<string, PackageLayer>,
329
374
  options: DiscoveryOptions,
375
+ spanLabelLookup: SpanLabelLookup,
330
376
  errors: Array<{ path: string; error: string }>
331
377
  ): Promise<(DiscoveredWorkflow | DiscoveredWorkflowWithContent)[]> {
332
378
  const workflows: (DiscoveredWorkflow | DiscoveredWorkflowWithContent)[] = [];
@@ -388,7 +434,14 @@ export class CanvasDiscovery {
388
434
 
389
435
  // Extract referenced spans from workflow content
390
436
  const edgeResult = deriveWorkflowEdges(parsedContent, path);
391
- const referencedSpans = edgeResult.referencedSpans;
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
+ );
392
445
 
393
446
  workflow = {
394
447
  ...workflow,
@@ -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
  */
@@ -97,11 +107,11 @@ export interface DiscoveredWorkflow {
97
107
  /** Associated test trace files for this workflow */
98
108
  testTraces: DiscoveredTestTrace[];
99
109
  /**
100
- * All span conventions referenced by this workflow.
110
+ * All span conventions (surfaces) referenced by this workflow.
101
111
  * Includes rootSpan and any explicit span fields in event templates.
102
112
  * Only populated when includeContent: true during discovery.
103
113
  */
104
- referencedSpans?: string[];
114
+ referencedSpans?: ReferencedSpan[];
105
115
  }
106
116
 
107
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 {