@principal-ai/principal-view-cli 0.2.3 → 0.2.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+pCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAiI/C"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqrCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAiI/C"}
@@ -225,7 +225,7 @@ const ALLOWED_CANVAS_FIELDS = {
225
225
  'name',
226
226
  'description',
227
227
  'otel',
228
- 'events',
228
+ 'event',
229
229
  'shape',
230
230
  'icon',
231
231
  'fill',
@@ -346,7 +346,7 @@ function findSimilarField(field, allowedFields) {
346
346
  * Check if a canvas has OTEL-related features
347
347
  * Returns true if the canvas contains any of:
348
348
  * 1. Nodes with pv.otel extension (kind, category)
349
- * 2. Event schemas (pv.events with validation)
349
+ * 2. Event schema (pv.event with validation)
350
350
  * 3. Canvas scope/audit config (OTEL log routing)
351
351
  * 4. Resource matching for OTEL logs
352
352
  */
@@ -373,8 +373,8 @@ function hasOtelFeatures(canvas) {
373
373
  if (nodePv.otel !== undefined) {
374
374
  return true;
375
375
  }
376
- // Check for event schemas (pv.events)
377
- if (nodePv.events !== undefined) {
376
+ // Check for event schema (pv.event)
377
+ if (nodePv.event !== undefined) {
378
378
  return true;
379
379
  }
380
380
  // Check for resourceMatch (OTEL log routing)
@@ -634,8 +634,19 @@ function validateCanvas(canvas, filePath, library, repositoryPath) {
634
634
  if (nodePv.otel && typeof nodePv.otel === 'object') {
635
635
  checkUnknownFields(nodePv.otel, ALLOWED_CANVAS_FIELDS.nodePvOtel, `${nodePath}.pv.otel`, issues);
636
636
  }
637
+ // For .otel.canvas files: require event field on nodes with pv extension (except groups)
638
+ if (filePath.endsWith('.otel.canvas') && nodeType !== 'group') {
639
+ if (nodePv.event === undefined) {
640
+ issues.push({
641
+ type: 'error',
642
+ message: `Node "${nodeLabel}" in .otel.canvas file must have "pv.event" field`,
643
+ path: `${nodePath}.pv.event`,
644
+ suggestion: 'Add event name, e.g.: "event": "user.login" or "event": "order.created"',
645
+ });
646
+ }
647
+ }
637
648
  // Validate source file references for OTEL event nodes
638
- const hasOtelFeatures = nodePv.otel !== undefined || nodePv.events !== undefined;
649
+ const hasOtelFeatures = nodePv.otel !== undefined || nodePv.event !== undefined;
639
650
  if (hasOtelFeatures) {
640
651
  // OTEL nodes must have at least one source file reference
641
652
  if (!Array.isArray(nodePv.sources) || nodePv.sources.length === 0) {
@@ -646,6 +657,15 @@ function validateCanvas(canvas, filePath, library, repositoryPath) {
646
657
  suggestion: 'Add at least one source file reference, e.g.: "sources": ["src/services/MyService.ts"]',
647
658
  });
648
659
  }
660
+ // For .otel.canvas files: nodes with event must have pv.otel for UI rendering
661
+ if (filePath.endsWith('.otel.canvas') && nodePv.event !== undefined && nodePv.otel === undefined) {
662
+ issues.push({
663
+ type: 'error',
664
+ message: `Node "${nodeLabel}" in .otel.canvas file has event but is missing "pv.otel" field required for UI badges`,
665
+ path: `${nodePath}.pv.otel`,
666
+ suggestion: 'Add OTEL metadata for UI rendering, e.g.: "otel": { "kind": "event", "category": "lifecycle", "isNew": true }',
667
+ });
668
+ }
649
669
  }
650
670
  // Validate that all source files exist (if repository path is provided)
651
671
  if (Array.isArray(nodePv.sources) && repositoryPath) {
package/dist/index.cjs CHANGED
@@ -228612,7 +228612,7 @@ var ALLOWED_CANVAS_FIELDS = {
228612
228612
  "name",
228613
228613
  "description",
228614
228614
  "otel",
228615
- "events",
228615
+ "event",
228616
228616
  "shape",
228617
228617
  "icon",
228618
228618
  "fill",
@@ -228735,7 +228735,7 @@ function hasOtelFeatures(canvas) {
228735
228735
  if (nodePv.otel !== void 0) {
228736
228736
  return true;
228737
228737
  }
228738
- if (nodePv.events !== void 0) {
228738
+ if (nodePv.event !== void 0) {
228739
228739
  return true;
228740
228740
  }
228741
228741
  if (nodePv.resourceMatch !== void 0) {
@@ -229019,7 +229019,17 @@ function validateCanvas(canvas, filePath, library, repositoryPath) {
229019
229019
  issues
229020
229020
  );
229021
229021
  }
229022
- const hasOtelFeatures2 = nodePv.otel !== void 0 || nodePv.events !== void 0;
229022
+ if (filePath.endsWith(".otel.canvas") && nodeType !== "group") {
229023
+ if (nodePv.event === void 0) {
229024
+ issues.push({
229025
+ type: "error",
229026
+ message: `Node "${nodeLabel}" in .otel.canvas file must have "pv.event" field`,
229027
+ path: `${nodePath2}.pv.event`,
229028
+ suggestion: 'Add event name, e.g.: "event": "user.login" or "event": "order.created"'
229029
+ });
229030
+ }
229031
+ }
229032
+ const hasOtelFeatures2 = nodePv.otel !== void 0 || nodePv.event !== void 0;
229023
229033
  if (hasOtelFeatures2) {
229024
229034
  if (!Array.isArray(nodePv.sources) || nodePv.sources.length === 0) {
229025
229035
  issues.push({
@@ -229029,6 +229039,14 @@ function validateCanvas(canvas, filePath, library, repositoryPath) {
229029
229039
  suggestion: 'Add at least one source file reference, e.g.: "sources": ["src/services/MyService.ts"]'
229030
229040
  });
229031
229041
  }
229042
+ if (filePath.endsWith(".otel.canvas") && nodePv.event !== void 0 && nodePv.otel === void 0) {
229043
+ issues.push({
229044
+ type: "error",
229045
+ message: `Node "${nodeLabel}" in .otel.canvas file has event but is missing "pv.otel" field required for UI badges`,
229046
+ path: `${nodePath2}.pv.otel`,
229047
+ suggestion: 'Add OTEL metadata for UI rendering, e.g.: "otel": { "kind": "event", "category": "lifecycle", "isNew": true }'
229048
+ });
229049
+ }
229032
229050
  }
229033
229051
  if (Array.isArray(nodePv.sources) && repositoryPath) {
229034
229052
  nodePv.sources.forEach((source, sourceIndex) => {