@principal-ai/principal-view-cli 0.1.21 → 0.1.23
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 +31 -1
- package/dist/index.cjs +35 -7
- 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;AA0jCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAsH/C"}
|
|
@@ -182,7 +182,7 @@ function validateIconName(iconValue, path, issues) {
|
|
|
182
182
|
*/
|
|
183
183
|
const ALLOWED_CANVAS_FIELDS = {
|
|
184
184
|
root: ['nodes', 'edges', 'pv'],
|
|
185
|
-
pv: ['version', 'name', 'description', 'nodeTypes', 'edgeTypes', 'pathConfig', 'display'],
|
|
185
|
+
pv: ['version', 'name', 'description', 'nodeTypes', 'edgeTypes', 'pathConfig', 'display', 'scope', 'audit'],
|
|
186
186
|
pvPathConfig: [
|
|
187
187
|
'projectRoot',
|
|
188
188
|
'captureSource',
|
|
@@ -216,17 +216,21 @@ const ALLOWED_CANVAS_FIELDS = {
|
|
|
216
216
|
// Node pv extension
|
|
217
217
|
nodePv: [
|
|
218
218
|
'nodeType',
|
|
219
|
+
'name',
|
|
219
220
|
'description',
|
|
221
|
+
'otel',
|
|
220
222
|
'shape',
|
|
221
223
|
'icon',
|
|
222
224
|
'fill',
|
|
223
225
|
'stroke',
|
|
224
226
|
'states',
|
|
225
227
|
'sources',
|
|
228
|
+
'resourceMatch',
|
|
226
229
|
'actions',
|
|
227
230
|
'dataSchema',
|
|
228
231
|
'layout',
|
|
229
232
|
],
|
|
233
|
+
nodePvOtel: ['kind', 'category', 'isNew'],
|
|
230
234
|
nodePvState: ['color', 'icon', 'label'],
|
|
231
235
|
nodePvAction: ['pattern', 'event', 'state', 'metadata', 'triggerEdges'],
|
|
232
236
|
nodePvDataSchemaField: ['type', 'required', 'displayInLabel'],
|
|
@@ -263,6 +267,7 @@ const ALLOWED_LIBRARY_FIELDS = {
|
|
|
263
267
|
'size',
|
|
264
268
|
'states',
|
|
265
269
|
'sources',
|
|
270
|
+
'resourceMatch',
|
|
266
271
|
'actions',
|
|
267
272
|
'dataSchema',
|
|
268
273
|
'layout',
|
|
@@ -595,6 +600,9 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
595
600
|
if (nodePv.layout && typeof nodePv.layout === 'object') {
|
|
596
601
|
checkUnknownFields(nodePv.layout, ALLOWED_CANVAS_FIELDS.nodePvLayout, `${nodePath}.pv.layout`, issues);
|
|
597
602
|
}
|
|
603
|
+
if (nodePv.otel && typeof nodePv.otel === 'object') {
|
|
604
|
+
checkUnknownFields(nodePv.otel, ALLOWED_CANVAS_FIELDS.nodePvOtel, `${nodePath}.pv.otel`, issues);
|
|
605
|
+
}
|
|
598
606
|
if (Array.isArray(nodePv.actions)) {
|
|
599
607
|
nodePv.actions.forEach((action, actionIndex) => {
|
|
600
608
|
if (action && typeof action === 'object') {
|
|
@@ -724,6 +732,28 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
724
732
|
suggestion: `Valid values: ${VALID_SIDES.join(', ')}`,
|
|
725
733
|
});
|
|
726
734
|
}
|
|
735
|
+
// Validate pv extension is present with edgeType
|
|
736
|
+
if (!e.pv || typeof e.pv !== 'object') {
|
|
737
|
+
issues.push({
|
|
738
|
+
type: 'error',
|
|
739
|
+
message: `Edge "${edgeLabel}" must have a "pv" extension with edgeType`,
|
|
740
|
+
path: `${edgePath}.pv`,
|
|
741
|
+
suggestion: 'Add: "pv": { "edgeType": "your-edge-type" }',
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
const edgePv = e.pv;
|
|
746
|
+
if (typeof edgePv.edgeType !== 'string' || !edgePv.edgeType) {
|
|
747
|
+
issues.push({
|
|
748
|
+
type: 'error',
|
|
749
|
+
message: `Edge "${edgeLabel}" must have a "pv.edgeType" field`,
|
|
750
|
+
path: `${edgePath}.pv.edgeType`,
|
|
751
|
+
suggestion: allDefinedEdgeTypes.length > 0
|
|
752
|
+
? `Available types: ${allDefinedEdgeTypes.join(', ')}`
|
|
753
|
+
: 'Define edge types in canvas pv.edgeTypes or library.yaml edgeComponents',
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
}
|
|
727
757
|
// Validate edge pv extension fields
|
|
728
758
|
if (e.pv && typeof e.pv === 'object') {
|
|
729
759
|
const edgePv = e.pv;
|
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 }) => {
|
|
@@ -13638,7 +13638,7 @@ function validateIconName(iconValue, path4, issues) {
|
|
|
13638
13638
|
}
|
|
13639
13639
|
var ALLOWED_CANVAS_FIELDS = {
|
|
13640
13640
|
root: ["nodes", "edges", "pv"],
|
|
13641
|
-
pv: ["version", "name", "description", "nodeTypes", "edgeTypes", "pathConfig", "display"],
|
|
13641
|
+
pv: ["version", "name", "description", "nodeTypes", "edgeTypes", "pathConfig", "display", "scope", "audit"],
|
|
13642
13642
|
pvPathConfig: [
|
|
13643
13643
|
"projectRoot",
|
|
13644
13644
|
"captureSource",
|
|
@@ -13672,17 +13672,21 @@ var ALLOWED_CANVAS_FIELDS = {
|
|
|
13672
13672
|
// Node pv extension
|
|
13673
13673
|
nodePv: [
|
|
13674
13674
|
"nodeType",
|
|
13675
|
+
"name",
|
|
13675
13676
|
"description",
|
|
13677
|
+
"otel",
|
|
13676
13678
|
"shape",
|
|
13677
13679
|
"icon",
|
|
13678
13680
|
"fill",
|
|
13679
13681
|
"stroke",
|
|
13680
13682
|
"states",
|
|
13681
13683
|
"sources",
|
|
13684
|
+
"resourceMatch",
|
|
13682
13685
|
"actions",
|
|
13683
13686
|
"dataSchema",
|
|
13684
13687
|
"layout"
|
|
13685
13688
|
],
|
|
13689
|
+
nodePvOtel: ["kind", "category", "isNew"],
|
|
13686
13690
|
nodePvState: ["color", "icon", "label"],
|
|
13687
13691
|
nodePvAction: ["pattern", "event", "state", "metadata", "triggerEdges"],
|
|
13688
13692
|
nodePvDataSchemaField: ["type", "required", "displayInLabel"],
|
|
@@ -13716,6 +13720,7 @@ var ALLOWED_LIBRARY_FIELDS = {
|
|
|
13716
13720
|
"size",
|
|
13717
13721
|
"states",
|
|
13718
13722
|
"sources",
|
|
13723
|
+
"resourceMatch",
|
|
13719
13724
|
"actions",
|
|
13720
13725
|
"dataSchema",
|
|
13721
13726
|
"layout"
|
|
@@ -14055,6 +14060,14 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
14055
14060
|
issues
|
|
14056
14061
|
);
|
|
14057
14062
|
}
|
|
14063
|
+
if (nodePv.otel && typeof nodePv.otel === "object") {
|
|
14064
|
+
checkUnknownFields(
|
|
14065
|
+
nodePv.otel,
|
|
14066
|
+
ALLOWED_CANVAS_FIELDS.nodePvOtel,
|
|
14067
|
+
`${nodePath2}.pv.otel`,
|
|
14068
|
+
issues
|
|
14069
|
+
);
|
|
14070
|
+
}
|
|
14058
14071
|
if (Array.isArray(nodePv.actions)) {
|
|
14059
14072
|
nodePv.actions.forEach((action, actionIndex) => {
|
|
14060
14073
|
if (action && typeof action === "object") {
|
|
@@ -14176,6 +14189,24 @@ function validateCanvas(canvas, filePath, library) {
|
|
|
14176
14189
|
suggestion: `Valid values: ${VALID_SIDES.join(", ")}`
|
|
14177
14190
|
});
|
|
14178
14191
|
}
|
|
14192
|
+
if (!e.pv || typeof e.pv !== "object") {
|
|
14193
|
+
issues.push({
|
|
14194
|
+
type: "error",
|
|
14195
|
+
message: `Edge "${edgeLabel}" must have a "pv" extension with edgeType`,
|
|
14196
|
+
path: `${edgePath}.pv`,
|
|
14197
|
+
suggestion: 'Add: "pv": { "edgeType": "your-edge-type" }'
|
|
14198
|
+
});
|
|
14199
|
+
} else {
|
|
14200
|
+
const edgePv = e.pv;
|
|
14201
|
+
if (typeof edgePv.edgeType !== "string" || !edgePv.edgeType) {
|
|
14202
|
+
issues.push({
|
|
14203
|
+
type: "error",
|
|
14204
|
+
message: `Edge "${edgeLabel}" must have a "pv.edgeType" field`,
|
|
14205
|
+
path: `${edgePath}.pv.edgeType`,
|
|
14206
|
+
suggestion: allDefinedEdgeTypes.length > 0 ? `Available types: ${allDefinedEdgeTypes.join(", ")}` : "Define edge types in canvas pv.edgeTypes or library.yaml edgeComponents"
|
|
14207
|
+
});
|
|
14208
|
+
}
|
|
14209
|
+
}
|
|
14179
14210
|
if (e.pv && typeof e.pv === "object") {
|
|
14180
14211
|
const edgePv = e.pv;
|
|
14181
14212
|
checkUnknownFields(edgePv, ALLOWED_CANVAS_FIELDS.edgePv, `${edgePath}.pv`, issues);
|
|
@@ -17747,7 +17778,6 @@ function createLintCommand() {
|
|
|
17747
17778
|
try {
|
|
17748
17779
|
const cwd = process.cwd();
|
|
17749
17780
|
let privuConfig = getDefaultConfig();
|
|
17750
|
-
let configPath;
|
|
17751
17781
|
if (options.config) {
|
|
17752
17782
|
const loadedConfig = loadConfigFile((0, import_node_path11.resolve)(cwd, options.config));
|
|
17753
17783
|
if (!loadedConfig) {
|
|
@@ -17766,7 +17796,6 @@ function createLintCommand() {
|
|
|
17766
17796
|
process.exit(1);
|
|
17767
17797
|
}
|
|
17768
17798
|
privuConfig = mergeConfigs(privuConfig, loadedConfig);
|
|
17769
|
-
configPath = (0, import_node_path11.resolve)(cwd, options.config);
|
|
17770
17799
|
} else {
|
|
17771
17800
|
const found = findConfig(cwd);
|
|
17772
17801
|
if (found) {
|
|
@@ -17782,7 +17811,6 @@ function createLintCommand() {
|
|
|
17782
17811
|
process.exit(1);
|
|
17783
17812
|
}
|
|
17784
17813
|
privuConfig = mergeConfigs(privuConfig, found.config);
|
|
17785
|
-
configPath = found.path;
|
|
17786
17814
|
}
|
|
17787
17815
|
}
|
|
17788
17816
|
let patterns;
|