@principal-ai/principal-view-cli 0.1.22 → 0.1.24
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/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +0 -18
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +1 -3
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +26 -30
- package/dist/index.cjs +46 -38
- package/dist/index.cjs.map +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+GpC,wBAAgB,iBAAiB,IAAI,OAAO,CA6L3C"}
|
package/dist/commands/init.js
CHANGED
|
@@ -6,12 +6,6 @@ import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from 'n
|
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { execSync } from 'node:child_process';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
|
-
const TEMPLATE_LIBRARY = {
|
|
10
|
-
version: '1.0.0',
|
|
11
|
-
name: 'Component Library',
|
|
12
|
-
nodeComponents: {},
|
|
13
|
-
edgeComponents: {},
|
|
14
|
-
};
|
|
15
9
|
const TEMPLATE_CANVAS = {
|
|
16
10
|
nodes: [],
|
|
17
11
|
edges: [],
|
|
@@ -73,18 +67,6 @@ rules:
|
|
|
73
67
|
const HUSKY_PRE_COMMIT = `# Run principal view linting on staged .principal-views files
|
|
74
68
|
npx @principal-ai/principal-view-cli lint --quiet
|
|
75
69
|
`;
|
|
76
|
-
/**
|
|
77
|
-
* Check if a command exists in PATH
|
|
78
|
-
*/
|
|
79
|
-
function commandExists(cmd) {
|
|
80
|
-
try {
|
|
81
|
-
execSync(`which ${cmd}`, { stdio: 'ignore' });
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
70
|
/**
|
|
89
71
|
* Check if we're in a git repository
|
|
90
72
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2PpC,wBAAgB,iBAAiB,IAAI,OAAO,CA2L3C"}
|
package/dist/commands/lint.js
CHANGED
|
@@ -20,6 +20,7 @@ const CONFIG_FILE_NAMES = ['.privurc.yaml', '.privurc.yml', '.privurc.json'];
|
|
|
20
20
|
*/
|
|
21
21
|
function findConfig(startDir) {
|
|
22
22
|
let currentDir = resolve(startDir);
|
|
23
|
+
// eslint-disable-next-line no-constant-condition
|
|
23
24
|
while (true) {
|
|
24
25
|
// Check for config files
|
|
25
26
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
@@ -222,7 +223,6 @@ export function createLintCommand() {
|
|
|
222
223
|
const cwd = process.cwd();
|
|
223
224
|
// Load privurc config
|
|
224
225
|
let privuConfig = getDefaultConfig();
|
|
225
|
-
let configPath;
|
|
226
226
|
if (options.config) {
|
|
227
227
|
// Use specified config file
|
|
228
228
|
const loadedConfig = loadConfigFile(resolve(cwd, options.config));
|
|
@@ -243,7 +243,6 @@ export function createLintCommand() {
|
|
|
243
243
|
process.exit(1);
|
|
244
244
|
}
|
|
245
245
|
privuConfig = mergeConfigs(privuConfig, loadedConfig);
|
|
246
|
-
configPath = resolve(cwd, options.config);
|
|
247
246
|
}
|
|
248
247
|
else {
|
|
249
248
|
// Search for config file
|
|
@@ -261,7 +260,6 @@ export function createLintCommand() {
|
|
|
261
260
|
process.exit(1);
|
|
262
261
|
}
|
|
263
262
|
privuConfig = mergeConfigs(privuConfig, found.config);
|
|
264
|
-
configPath = found.path;
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
265
|
// Determine files to lint
|
|
@@ -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;
|
|
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;AAgjCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAsH/C"}
|
|
@@ -182,7 +182,17 @@ function validateIconName(iconValue, path, issues) {
|
|
|
182
182
|
*/
|
|
183
183
|
const ALLOWED_CANVAS_FIELDS = {
|
|
184
184
|
root: ['nodes', 'edges', 'pv'],
|
|
185
|
-
pv: [
|
|
185
|
+
pv: [
|
|
186
|
+
'version',
|
|
187
|
+
'name',
|
|
188
|
+
'description',
|
|
189
|
+
'nodeTypes',
|
|
190
|
+
'edgeTypes',
|
|
191
|
+
'pathConfig',
|
|
192
|
+
'display',
|
|
193
|
+
'scope',
|
|
194
|
+
'audit',
|
|
195
|
+
],
|
|
186
196
|
pvPathConfig: [
|
|
187
197
|
'projectRoot',
|
|
188
198
|
'captureSource',
|
|
@@ -216,17 +226,21 @@ const ALLOWED_CANVAS_FIELDS = {
|
|
|
216
226
|
// Node pv extension
|
|
217
227
|
nodePv: [
|
|
218
228
|
'nodeType',
|
|
229
|
+
'name',
|
|
219
230
|
'description',
|
|
231
|
+
'otel',
|
|
220
232
|
'shape',
|
|
221
233
|
'icon',
|
|
222
234
|
'fill',
|
|
223
235
|
'stroke',
|
|
224
236
|
'states',
|
|
225
237
|
'sources',
|
|
238
|
+
'resourceMatch',
|
|
226
239
|
'actions',
|
|
227
240
|
'dataSchema',
|
|
228
241
|
'layout',
|
|
229
242
|
],
|
|
243
|
+
nodePvOtel: ['kind', 'category', 'isNew'],
|
|
230
244
|
nodePvState: ['color', 'icon', 'label'],
|
|
231
245
|
nodePvAction: ['pattern', 'event', 'state', 'metadata', 'triggerEdges'],
|
|
232
246
|
nodePvDataSchemaField: ['type', 'required', 'displayInLabel'],
|
|
@@ -263,6 +277,7 @@ const ALLOWED_LIBRARY_FIELDS = {
|
|
|
263
277
|
'size',
|
|
264
278
|
'states',
|
|
265
279
|
'sources',
|
|
280
|
+
'resourceMatch',
|
|
266
281
|
'actions',
|
|
267
282
|
'dataSchema',
|
|
268
283
|
'layout',
|
|
@@ -535,37 +550,15 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
535
550
|
suggestion: 'Add a "url" field with a URL, or change the node type',
|
|
536
551
|
});
|
|
537
552
|
}
|
|
538
|
-
// Validate node type - must be standard
|
|
553
|
+
// Validate node type - must be a standard JSON Canvas type
|
|
539
554
|
const isStandardType = STANDARD_CANVAS_TYPES.includes(nodeType);
|
|
540
555
|
if (!isStandardType) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
suggestion: `Use a standard type (${STANDARD_CANVAS_TYPES.join(', ')}) or add pv.nodeType and pv.shape`,
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
const nodePv = n.pv;
|
|
552
|
-
if (typeof nodePv.nodeType !== 'string' || !nodePv.nodeType) {
|
|
553
|
-
issues.push({
|
|
554
|
-
type: 'error',
|
|
555
|
-
message: `Node "${n.id || index}" with custom type must have "pv.nodeType"`,
|
|
556
|
-
path: `nodes[${index}].pv.nodeType`,
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
if (typeof nodePv.shape !== 'string' ||
|
|
560
|
-
!VALID_NODE_SHAPES.includes(nodePv.shape)) {
|
|
561
|
-
issues.push({
|
|
562
|
-
type: 'error',
|
|
563
|
-
message: `Node "${n.id || index}" must have a valid "pv.shape"`,
|
|
564
|
-
path: `nodes[${index}].pv.shape`,
|
|
565
|
-
suggestion: `Valid shapes: ${VALID_NODE_SHAPES.join(', ')}`,
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
}
|
|
556
|
+
issues.push({
|
|
557
|
+
type: 'error',
|
|
558
|
+
message: `Node "${n.id || index}" uses invalid type "${nodeType}"`,
|
|
559
|
+
path: `nodes[${index}].type`,
|
|
560
|
+
suggestion: `Use a standard JSON Canvas type (${STANDARD_CANVAS_TYPES.join(', ')}). For custom shapes, use type: "text" with pv.shape: "${nodeType}"`,
|
|
561
|
+
});
|
|
569
562
|
}
|
|
570
563
|
// Validate node pv extension fields
|
|
571
564
|
if (n.pv && typeof n.pv === 'object') {
|
|
@@ -595,6 +588,9 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
595
588
|
if (nodePv.layout && typeof nodePv.layout === 'object') {
|
|
596
589
|
checkUnknownFields(nodePv.layout, ALLOWED_CANVAS_FIELDS.nodePvLayout, `${nodePath}.pv.layout`, issues);
|
|
597
590
|
}
|
|
591
|
+
if (nodePv.otel && typeof nodePv.otel === 'object') {
|
|
592
|
+
checkUnknownFields(nodePv.otel, ALLOWED_CANVAS_FIELDS.nodePvOtel, `${nodePath}.pv.otel`, issues);
|
|
593
|
+
}
|
|
598
594
|
if (Array.isArray(nodePv.actions)) {
|
|
599
595
|
nodePv.actions.forEach((action, actionIndex) => {
|
|
600
596
|
if (action && typeof action === 'object') {
|
package/dist/index.cjs
CHANGED
|
@@ -10573,9 +10573,9 @@ var shouldExpandGlobstarDirectory = (pattern) => {
|
|
|
10573
10573
|
if (!match) {
|
|
10574
10574
|
return false;
|
|
10575
10575
|
}
|
|
10576
|
-
const
|
|
10577
|
-
const hasWildcards = /[*?[\]{}]/.test(
|
|
10578
|
-
const hasExtension = import_node_path4.default.extname(
|
|
10576
|
+
const dirname2 = match[1];
|
|
10577
|
+
const hasWildcards = /[*?[\]{}]/.test(dirname2);
|
|
10578
|
+
const hasExtension = import_node_path4.default.extname(dirname2) && !dirname2.startsWith(".");
|
|
10579
10579
|
return !hasWildcards && !hasExtension;
|
|
10580
10580
|
};
|
|
10581
10581
|
var getDirectoryGlob = ({ directoryPath, files, extensions }) => {
|
|
@@ -13511,7 +13511,11 @@ function validateLibrary(library) {
|
|
|
13511
13511
|
issues
|
|
13512
13512
|
);
|
|
13513
13513
|
const state = stateDef;
|
|
13514
|
-
validateIconName(
|
|
13514
|
+
validateIconName(
|
|
13515
|
+
state.icon,
|
|
13516
|
+
`nodeComponents.${compId}.states.${stateId}.icon`,
|
|
13517
|
+
issues
|
|
13518
|
+
);
|
|
13515
13519
|
}
|
|
13516
13520
|
}
|
|
13517
13521
|
}
|
|
@@ -13605,7 +13609,6 @@ function validateLibrary(library) {
|
|
|
13605
13609
|
return issues;
|
|
13606
13610
|
}
|
|
13607
13611
|
var STANDARD_CANVAS_TYPES = ["text", "group", "file", "link"];
|
|
13608
|
-
var VALID_NODE_SHAPES = ["circle", "rectangle", "hexagon", "diamond", "custom"];
|
|
13609
13612
|
function kebabToPascalCase(str2) {
|
|
13610
13613
|
return str2.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join("");
|
|
13611
13614
|
}
|
|
@@ -13638,7 +13641,17 @@ function validateIconName(iconValue, path4, issues) {
|
|
|
13638
13641
|
}
|
|
13639
13642
|
var ALLOWED_CANVAS_FIELDS = {
|
|
13640
13643
|
root: ["nodes", "edges", "pv"],
|
|
13641
|
-
pv: [
|
|
13644
|
+
pv: [
|
|
13645
|
+
"version",
|
|
13646
|
+
"name",
|
|
13647
|
+
"description",
|
|
13648
|
+
"nodeTypes",
|
|
13649
|
+
"edgeTypes",
|
|
13650
|
+
"pathConfig",
|
|
13651
|
+
"display",
|
|
13652
|
+
"scope",
|
|
13653
|
+
"audit"
|
|
13654
|
+
],
|
|
13642
13655
|
pvPathConfig: [
|
|
13643
13656
|
"projectRoot",
|
|
13644
13657
|
"captureSource",
|
|
@@ -13672,17 +13685,21 @@ var ALLOWED_CANVAS_FIELDS = {
|
|
|
13672
13685
|
// Node pv extension
|
|
13673
13686
|
nodePv: [
|
|
13674
13687
|
"nodeType",
|
|
13688
|
+
"name",
|
|
13675
13689
|
"description",
|
|
13690
|
+
"otel",
|
|
13676
13691
|
"shape",
|
|
13677
13692
|
"icon",
|
|
13678
13693
|
"fill",
|
|
13679
13694
|
"stroke",
|
|
13680
13695
|
"states",
|
|
13681
13696
|
"sources",
|
|
13697
|
+
"resourceMatch",
|
|
13682
13698
|
"actions",
|
|
13683
13699
|
"dataSchema",
|
|
13684
13700
|
"layout"
|
|
13685
13701
|
],
|
|
13702
|
+
nodePvOtel: ["kind", "category", "isNew"],
|
|
13686
13703
|
nodePvState: ["color", "icon", "label"],
|
|
13687
13704
|
nodePvAction: ["pattern", "event", "state", "metadata", "triggerEdges"],
|
|
13688
13705
|
nodePvDataSchemaField: ["type", "required", "displayInLabel"],
|
|
@@ -13716,6 +13733,7 @@ var ALLOWED_LIBRARY_FIELDS = {
|
|
|
13716
13733
|
"size",
|
|
13717
13734
|
"states",
|
|
13718
13735
|
"sources",
|
|
13736
|
+
"resourceMatch",
|
|
13719
13737
|
"actions",
|
|
13720
13738
|
"dataSchema",
|
|
13721
13739
|
"layout"
|
|
@@ -13985,33 +14003,14 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
13985
14003
|
nodeType
|
|
13986
14004
|
);
|
|
13987
14005
|
if (!isStandardType) {
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
});
|
|
13997
|
-
} else {
|
|
13998
|
-
const nodePv = n.pv;
|
|
13999
|
-
if (typeof nodePv.nodeType !== "string" || !nodePv.nodeType) {
|
|
14000
|
-
issues.push({
|
|
14001
|
-
type: "error",
|
|
14002
|
-
message: `Node "${n.id || index}" with custom type must have "pv.nodeType"`,
|
|
14003
|
-
path: `nodes[${index}].pv.nodeType`
|
|
14004
|
-
});
|
|
14005
|
-
}
|
|
14006
|
-
if (typeof nodePv.shape !== "string" || !VALID_NODE_SHAPES.includes(nodePv.shape)) {
|
|
14007
|
-
issues.push({
|
|
14008
|
-
type: "error",
|
|
14009
|
-
message: `Node "${n.id || index}" must have a valid "pv.shape"`,
|
|
14010
|
-
path: `nodes[${index}].pv.shape`,
|
|
14011
|
-
suggestion: `Valid shapes: ${VALID_NODE_SHAPES.join(", ")}`
|
|
14012
|
-
});
|
|
14013
|
-
}
|
|
14014
|
-
}
|
|
14006
|
+
issues.push({
|
|
14007
|
+
type: "error",
|
|
14008
|
+
message: `Node "${n.id || index}" uses invalid type "${nodeType}"`,
|
|
14009
|
+
path: `nodes[${index}].type`,
|
|
14010
|
+
suggestion: `Use a standard JSON Canvas type (${STANDARD_CANVAS_TYPES.join(
|
|
14011
|
+
", "
|
|
14012
|
+
)}). For custom shapes, use type: "text" with pv.shape: "${nodeType}"`
|
|
14013
|
+
});
|
|
14015
14014
|
}
|
|
14016
14015
|
if (n.pv && typeof n.pv === "object") {
|
|
14017
14016
|
const nodePv = n.pv;
|
|
@@ -14055,6 +14054,14 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
14055
14054
|
issues
|
|
14056
14055
|
);
|
|
14057
14056
|
}
|
|
14057
|
+
if (nodePv.otel && typeof nodePv.otel === "object") {
|
|
14058
|
+
checkUnknownFields(
|
|
14059
|
+
nodePv.otel,
|
|
14060
|
+
ALLOWED_CANVAS_FIELDS.nodePvOtel,
|
|
14061
|
+
`${nodePath2}.pv.otel`,
|
|
14062
|
+
issues
|
|
14063
|
+
);
|
|
14064
|
+
}
|
|
14058
14065
|
if (Array.isArray(nodePv.actions)) {
|
|
14059
14066
|
nodePv.actions.forEach((action, actionIndex) => {
|
|
14060
14067
|
if (action && typeof action === "object") {
|
|
@@ -14151,7 +14158,9 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
14151
14158
|
type: "error",
|
|
14152
14159
|
message: `Edge "${edgeLabel}" must have a "fromSide" field`,
|
|
14153
14160
|
path: `${edgePath}.fromSide`,
|
|
14154
|
-
suggestion: `Specify which side of the source node the edge starts from: ${VALID_SIDES.join(
|
|
14161
|
+
suggestion: `Specify which side of the source node the edge starts from: ${VALID_SIDES.join(
|
|
14162
|
+
", "
|
|
14163
|
+
)}`
|
|
14155
14164
|
});
|
|
14156
14165
|
} else if (!VALID_SIDES.includes(e.fromSide)) {
|
|
14157
14166
|
issues.push({
|
|
@@ -14166,7 +14175,9 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
14166
14175
|
type: "error",
|
|
14167
14176
|
message: `Edge "${edgeLabel}" must have a "toSide" field`,
|
|
14168
14177
|
path: `${edgePath}.toSide`,
|
|
14169
|
-
suggestion: `Specify which side of the target node the edge connects to: ${VALID_SIDES.join(
|
|
14178
|
+
suggestion: `Specify which side of the target node the edge connects to: ${VALID_SIDES.join(
|
|
14179
|
+
", "
|
|
14180
|
+
)}`
|
|
14170
14181
|
});
|
|
14171
14182
|
} else if (!VALID_SIDES.includes(e.toSide)) {
|
|
14172
14183
|
issues.push({
|
|
@@ -17765,7 +17776,6 @@ function createLintCommand() {
|
|
|
17765
17776
|
try {
|
|
17766
17777
|
const cwd = process.cwd();
|
|
17767
17778
|
let privuConfig = getDefaultConfig();
|
|
17768
|
-
let configPath;
|
|
17769
17779
|
if (options.config) {
|
|
17770
17780
|
const loadedConfig = loadConfigFile((0, import_node_path11.resolve)(cwd, options.config));
|
|
17771
17781
|
if (!loadedConfig) {
|
|
@@ -17784,7 +17794,6 @@ function createLintCommand() {
|
|
|
17784
17794
|
process.exit(1);
|
|
17785
17795
|
}
|
|
17786
17796
|
privuConfig = mergeConfigs(privuConfig, loadedConfig);
|
|
17787
|
-
configPath = (0, import_node_path11.resolve)(cwd, options.config);
|
|
17788
17797
|
} else {
|
|
17789
17798
|
const found = findConfig(cwd);
|
|
17790
17799
|
if (found) {
|
|
@@ -17800,7 +17809,6 @@ function createLintCommand() {
|
|
|
17800
17809
|
process.exit(1);
|
|
17801
17810
|
}
|
|
17802
17811
|
privuConfig = mergeConfigs(privuConfig, found.config);
|
|
17803
|
-
configPath = found.path;
|
|
17804
17812
|
}
|
|
17805
17813
|
}
|
|
17806
17814
|
let patterns;
|