@principal-ai/principal-view-core 0.24.82 → 0.24.83
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/LibraryLoader.d.ts +2 -0
- package/dist/LibraryLoader.d.ts.map +1 -1
- package/dist/LibraryLoader.js +8 -109
- package/dist/LibraryLoader.js.map +1 -1
- package/dist/discovery/LibraryDiscovery.d.ts +2 -12
- package/dist/discovery/LibraryDiscovery.d.ts.map +1 -1
- package/dist/discovery/LibraryDiscovery.js +5 -5
- package/dist/discovery/LibraryDiscovery.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/validation/index.d.ts +7 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +11 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/libraryValidation.d.ts +53 -0
- package/dist/validation/libraryValidation.d.ts.map +1 -0
- package/dist/validation/libraryValidation.js +160 -0
- package/dist/validation/libraryValidation.js.map +1 -0
- package/package.json +1 -1
- package/src/LibraryLoader.ts +8 -124
- package/src/discovery/LibraryDiscovery.test.ts +5 -5
- package/src/discovery/LibraryDiscovery.ts +8 -21
- package/src/index.ts +8 -2
- package/src/validation/index.ts +12 -0
- package/src/validation/libraryValidation.ts +290 -0
package/dist/LibraryLoader.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export declare class LibraryLoader {
|
|
|
54
54
|
/**
|
|
55
55
|
* Validate the library structure
|
|
56
56
|
*
|
|
57
|
+
* Uses the shared validateLibraryStructure function from validation module.
|
|
58
|
+
*
|
|
57
59
|
* @param library - Parsed library object
|
|
58
60
|
* @param filePath - File path for error messages
|
|
59
61
|
* @returns Error message if invalid, undefined if valid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibraryLoader.d.ts","sourceRoot":"","sources":["../src/LibraryLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"LibraryLoader.d.ts","sourceRoot":"","sources":["../src/LibraryLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAc3E;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,iBAAiB;IAEhD;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+BvD;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiChE;;;;;OAKG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBnD;;;;;;OAMG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,MAAe,GAAG,MAAM;IAKzE;;OAEG;IACH,OAAO,CAAC,SAAS;IAUjB;;OAEG;IACH,OAAO,CAAC,SAAS;IAUjB;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ;CAWjB"}
|
package/dist/LibraryLoader.js
CHANGED
|
@@ -30,6 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.LibraryLoader = void 0;
|
|
33
|
+
const libraryValidation_1 = require("./validation/libraryValidation");
|
|
33
34
|
const yaml = __importStar(require("js-yaml"));
|
|
34
35
|
/**
|
|
35
36
|
* Default library file names to search for (in order of preference)
|
|
@@ -176,120 +177,18 @@ class LibraryLoader {
|
|
|
176
177
|
/**
|
|
177
178
|
* Validate the library structure
|
|
178
179
|
*
|
|
180
|
+
* Uses the shared validateLibraryStructure function from validation module.
|
|
181
|
+
*
|
|
179
182
|
* @param library - Parsed library object
|
|
180
183
|
* @param filePath - File path for error messages
|
|
181
184
|
* @returns Error message if invalid, undefined if valid
|
|
182
185
|
*/
|
|
183
186
|
validate(library, filePath) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
if (!library.nodeComponents || typeof library.nodeComponents !== 'object') {
|
|
191
|
-
return `Missing or invalid 'nodeComponents' in ${filePath}`;
|
|
192
|
-
}
|
|
193
|
-
if (!library.edgeComponents || typeof library.edgeComponents !== 'object') {
|
|
194
|
-
return `Missing or invalid 'edgeComponents' in ${filePath}`;
|
|
195
|
-
}
|
|
196
|
-
// Note: nodeComponents and edgeComponents fields like 'shape' and 'style' are optional.
|
|
197
|
-
// The CLI validator only checks for unknown fields, not required fields.
|
|
198
|
-
// Visual rendering code should handle missing shape/style gracefully with defaults.
|
|
199
|
-
// Validate event schemas if present
|
|
200
|
-
if (library.eventSchemas) {
|
|
201
|
-
if (typeof library.eventSchemas !== 'object') {
|
|
202
|
-
return `Field 'eventSchemas' must be an object in ${filePath}`;
|
|
203
|
-
}
|
|
204
|
-
for (const [eventName, schema] of Object.entries(library.eventSchemas)) {
|
|
205
|
-
if (!schema.description) {
|
|
206
|
-
return `Event schema '${eventName}' is missing required field 'description' in ${filePath}`;
|
|
207
|
-
}
|
|
208
|
-
if (!schema.attributes || typeof schema.attributes !== 'object') {
|
|
209
|
-
return `Event schema '${eventName}' is missing or has invalid 'attributes' field in ${filePath}`;
|
|
210
|
-
}
|
|
211
|
-
// Validate each attribute in the event schema
|
|
212
|
-
for (const [attrName, attrSchema] of Object.entries(schema.attributes)) {
|
|
213
|
-
if (!attrSchema.type) {
|
|
214
|
-
return `Event schema '${eventName}' attribute '${attrName}' is missing required field 'type' in ${filePath}`;
|
|
215
|
-
}
|
|
216
|
-
const validTypes = ['string', 'number', 'boolean', 'object', 'array'];
|
|
217
|
-
if (!validTypes.includes(attrSchema.type)) {
|
|
218
|
-
return `Event schema '${eventName}' attribute '${attrName}' has invalid type '${attrSchema.type}' in ${filePath}. Valid types: ${validTypes.join(', ')}`;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// Validate top-level scopes if present
|
|
224
|
-
if (library.scopes) {
|
|
225
|
-
if (typeof library.scopes !== 'object' || Array.isArray(library.scopes)) {
|
|
226
|
-
return `Field 'scopes' must be an object in ${filePath}`;
|
|
227
|
-
}
|
|
228
|
-
for (const [scopeName, scopeDef] of Object.entries(library.scopes)) {
|
|
229
|
-
if (typeof scopeDef !== 'object' || scopeDef === null) {
|
|
230
|
-
return `Scope '${scopeName}' must be an object in ${filePath}`;
|
|
231
|
-
}
|
|
232
|
-
// External scopes don't require color (defined elsewhere)
|
|
233
|
-
const isExternal = scopeDef.external === true;
|
|
234
|
-
if (!isExternal && typeof scopeDef.color !== 'string') {
|
|
235
|
-
return `Scope '${scopeName}' is missing required 'color' property in ${filePath}. Use 'external: true' for scopes defined in other libraries.`;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
// Validate connection rules if present
|
|
240
|
-
if (library.connectionRules) {
|
|
241
|
-
for (const [index, rule] of library.connectionRules.entries()) {
|
|
242
|
-
if (!rule.from || !rule.to || !rule.via) {
|
|
243
|
-
return `Connection rule at index ${index} is missing required fields (from, to, via) in ${filePath}`;
|
|
244
|
-
}
|
|
245
|
-
// Check that referenced types exist
|
|
246
|
-
if (!library.nodeComponents[rule.from]) {
|
|
247
|
-
return `Connection rule references unknown node type '${rule.from}' in ${filePath}`;
|
|
248
|
-
}
|
|
249
|
-
if (!library.nodeComponents[rule.to]) {
|
|
250
|
-
return `Connection rule references unknown node type '${rule.to}' in ${filePath}`;
|
|
251
|
-
}
|
|
252
|
-
if (!library.edgeComponents[rule.via]) {
|
|
253
|
-
return `Connection rule references unknown edge type '${rule.via}' in ${filePath}`;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
// Validate resources if present
|
|
258
|
-
if (library.resources) {
|
|
259
|
-
if (typeof library.resources !== 'object' || Array.isArray(library.resources)) {
|
|
260
|
-
return `Field 'resources' must be an object in ${filePath}`;
|
|
261
|
-
}
|
|
262
|
-
for (const [serviceId, resourceAttrs] of Object.entries(library.resources)) {
|
|
263
|
-
// Check that each service has a resource attributes object
|
|
264
|
-
if (typeof resourceAttrs !== 'object' || Array.isArray(resourceAttrs) || resourceAttrs === null) {
|
|
265
|
-
return `Resource entry '${serviceId}' must be an object in ${filePath}`;
|
|
266
|
-
}
|
|
267
|
-
// Check that service.name is present (required)
|
|
268
|
-
if (!resourceAttrs['service.name']) {
|
|
269
|
-
return `Resource entry '${serviceId}' is missing required attribute 'service.name' in ${filePath}`;
|
|
270
|
-
}
|
|
271
|
-
// Validate attribute values
|
|
272
|
-
for (const [attrName, attrValue] of Object.entries(resourceAttrs)) {
|
|
273
|
-
// owned-scopes must be an array of strings referencing top-level scopes
|
|
274
|
-
if (attrName === 'owned-scopes') {
|
|
275
|
-
if (!Array.isArray(attrValue)) {
|
|
276
|
-
return `Resource '${serviceId}' attribute 'owned-scopes' must be an array in ${filePath}`;
|
|
277
|
-
}
|
|
278
|
-
for (const scope of attrValue) {
|
|
279
|
-
if (typeof scope !== 'string') {
|
|
280
|
-
return `Resource '${serviceId}' attribute 'owned-scopes' array must contain only strings in ${filePath}`;
|
|
281
|
-
}
|
|
282
|
-
// Validate that scope references exist in top-level scopes (strict)
|
|
283
|
-
if (!library.scopes || !library.scopes[scope]) {
|
|
284
|
-
return `Resource '${serviceId}' references undefined scope '${scope}' in ${filePath}. Define it in the top-level 'scopes' section (use 'external: true' for scopes from other libraries).`;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
else if (typeof attrValue !== 'string') {
|
|
289
|
-
return `Resource '${serviceId}' attribute '${attrName}' must have a string value in ${filePath}`;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
187
|
+
const result = (0, libraryValidation_1.validateLibraryStructure)(library);
|
|
188
|
+
if (!result.valid && result.errors.length > 0) {
|
|
189
|
+
// Return the first error with file path context
|
|
190
|
+
const firstError = result.errors[0];
|
|
191
|
+
return `${firstError.message} in ${filePath}`;
|
|
293
192
|
}
|
|
294
193
|
return undefined;
|
|
295
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibraryLoader.js","sourceRoot":"","sources":["../src/LibraryLoader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,8CAAgC;AAEhC;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC;;GAEG;AACH,MAAa,aAAa;IACxB,YAAoB,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,OAAe;QACxB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE5D,6CAA6C;QAC7C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAElF,IAAI,CAAC,YAAY,IAAI,CAAC,KAAK,EAAE;YAC3B,OAAO;gBACL,OA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AChD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpC,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,QAAQ,EAAE,CAAC;SAC/C;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAxKD,sCAwKC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { FileTree, FileSystemAdapter } from '@principal-ai/repository-abstraction';
|
|
8
8
|
import type { ComponentLibrary } from '../types/library';
|
|
9
|
+
import type { LibraryValidationError, LibraryValidationErrorType } from '../validation';
|
|
9
10
|
/**
|
|
10
11
|
* Service with its owned scopes
|
|
11
12
|
*/
|
|
@@ -32,18 +33,7 @@ export interface DiscoveredLibrary {
|
|
|
32
33
|
/** Services with their owned scopes */
|
|
33
34
|
servicesWithScopes: ServiceWithScopes[];
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
* Types of validation errors
|
|
37
|
-
*/
|
|
38
|
-
export type LibraryValidationErrorType = 'parse-error' | 'validation-error' | 'scopes-canvas-required';
|
|
39
|
-
/**
|
|
40
|
-
* Library validation error with type information
|
|
41
|
-
*/
|
|
42
|
-
export interface LibraryValidationError {
|
|
43
|
-
path: string;
|
|
44
|
-
error: string;
|
|
45
|
-
type?: LibraryValidationErrorType;
|
|
46
|
-
}
|
|
36
|
+
export type { LibraryValidationError, LibraryValidationErrorType };
|
|
47
37
|
/**
|
|
48
38
|
* Result of library discovery
|
|
49
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibraryDiscovery.d.ts","sourceRoot":"","sources":["../../src/discovery/LibraryDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAGxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"LibraryDisc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D,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,YAAY,CAA0C;IAC9D,OAAO,CAAC,MAAM,CAAgB;gBAEV,SAAS,EAAE,iBAAiB;IAKhD;;;;;;;;OAQG;IACG,QAAQ,CACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/C,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,GACA,OAAO,CAAC,sBAAsB,CAAC;IA+IlC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA8B3B;;OAEG;YACW,+BAA+B;IAyC7C;;OAEG;YACW,uBAAuB;IAyBrC;;OAEG;YACW,yBAAyB;CAexC"}
|
|
@@ -82,7 +82,7 @@ class LibraryDiscovery {
|
|
|
82
82
|
// Only report errors that aren't "file not found" (which is normal)
|
|
83
83
|
errors.push({
|
|
84
84
|
path: loadResult.path,
|
|
85
|
-
|
|
85
|
+
message: loadResult.error,
|
|
86
86
|
type: 'parse-error',
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -90,7 +90,7 @@ class LibraryDiscovery {
|
|
|
90
90
|
catch (error) {
|
|
91
91
|
errors.push({
|
|
92
92
|
path: pkg.packageData.path,
|
|
93
|
-
|
|
93
|
+
message: error instanceof Error ? error.message : String(error),
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -122,7 +122,7 @@ class LibraryDiscovery {
|
|
|
122
122
|
else if (loadResult.error) {
|
|
123
123
|
errors.push({
|
|
124
124
|
path: loadResult.path,
|
|
125
|
-
|
|
125
|
+
message: loadResult.error,
|
|
126
126
|
type: 'parse-error',
|
|
127
127
|
});
|
|
128
128
|
}
|
|
@@ -202,7 +202,7 @@ class LibraryDiscovery {
|
|
|
202
202
|
if (!pvDirExists) {
|
|
203
203
|
errors.push({
|
|
204
204
|
path: libraryPath,
|
|
205
|
-
|
|
205
|
+
message: `Scopes canvas required: library.yaml defines owned-scopes [${allOwnedScopes.join(', ')}] but no .principal-views/ directory exists. Create a .scopes.canvas file (e.g., architecture.scopes.canvas) documenting scope boundaries.`,
|
|
206
206
|
type: 'scopes-canvas-required',
|
|
207
207
|
});
|
|
208
208
|
return;
|
|
@@ -212,7 +212,7 @@ class LibraryDiscovery {
|
|
|
212
212
|
if (!scopesCanvasExists) {
|
|
213
213
|
errors.push({
|
|
214
214
|
path: libraryPath,
|
|
215
|
-
|
|
215
|
+
message: `Scopes canvas required: library.yaml defines owned-scopes [${allOwnedScopes.join(', ')}] but no .scopes.canvas file found. Create a .scopes.canvas file (e.g., .principal-views/architecture.scopes.canvas) with nodes for each scope (set pv.otel.scope to the scope name).`,
|
|
216
216
|
type: 'scopes-canvas-required',
|
|
217
217
|
});
|
|
218
218
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibraryDiscovery.js","sourceRoot":"","sources":["../../src/discovery/LibraryDiscovery.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6EAA2F;AAC3F,oDAAiD;AAEjD,2CAAgD;
|
|
1
|
+
{"version":3,"file":"LibraryDiscovery.js","sourceRoot":"","sources":["../../src/discovery/LibraryDiscovery.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6EAA2F;AAC3F,oDAAiD;AAEjD,2CAAgD;AA8DhD;;;;;;;;;;;GAWG;AACH,MAAa,gBAAgB;IAO3B,YAAoB,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;QAHxC,iBAAY,GAAgC,IAAI,GAAG,EAAE,CAAC;QAI5D,IAAI,CAAC,aAAa,GAAG,IAAI,yCAAkB,EAAE,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,Q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Q,EAAE,UAAU,CAAC,CAAC;QACjF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAE1C,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA1SuB,2BAAU,GAAG,kBAAkB,AAArB,CAAsB;AAD7C,4CAAgB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -61,8 +61,10 @@ export { LibraryLoader } from './LibraryLoader';
|
|
|
61
61
|
export { LibraryConverter } from './utils/LibraryConverter';
|
|
62
62
|
export type { CreateNodeOptions, CreateEdgeOptions } from './utils/LibraryConverter';
|
|
63
63
|
export type { ResourceAttributes, ScopeDefinition, OwnedScopes } from './types/library';
|
|
64
|
+
export { validateLibraryStructure } from './validation';
|
|
65
|
+
export type { LibraryValidationError, LibraryValidationErrorType, LibraryValidationResult, } from './validation';
|
|
64
66
|
export { LibraryDiscovery } from './discovery/LibraryDiscovery';
|
|
65
|
-
export type { DiscoveredLibrary, LibraryDiscoveryResult,
|
|
67
|
+
export type { DiscoveredLibrary, LibraryDiscoveryResult, } from './discovery/LibraryDiscovery';
|
|
66
68
|
export type { StoryboardReference, WorkflowReference, ScenarioReference, StoryboardContextSliceData, EventNodeMap, BuildStoryboardContextOptions, } from './storyboard/index';
|
|
67
69
|
export { buildStoryboardContext, buildNodeSourcesMap, buildEventNodeMap, getNodeEventName, resolveScenarioNodeIds, resolveWorkflowNodeIds, findNodesMatchingEventPattern, getAllNodeIds, } from './storyboard/index';
|
|
68
70
|
export type { FileSystemAdapter } from '@principal-ai/repository-abstraction';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAGx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;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,2BAA2B,EA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AAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,YAAY,EACZ,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAC7B,aAAa,GACd,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.findScopeByName = exports.getUnmatchedScopes = exports.getPartialMatchedScopes = exports.getMatchedScopes = exports.getAllScopes = exports.getPrimaryScope = exports.getScopeFromUnmatchedSpan = exports.getScopeFromStoryboardMatch = exports.getScopeFromScenarioMatch = exports.groupSpansByTrace = exports.createInMemoryVersionRegistry = exports.InMemoryVersionRegistry = exports.isWarnSeverity = exports.isErrorSeverity = exports.getSpanDuration = exports.parseNanoTime = exports.flattenResourceAttributes = exports.getAttributeValue = exports.findAttribute = exports.getAttributeStringValue = exports.TraceOrchestrator = exports.CompositeRegistry = exports.LocalRegistry = exports.RemoteRegistry = exports.OtlpTraceParser = exports.getWorkflowRootSpan = exports.getEventSpan = exports.getEventTemplateString = exports.isEventTemplate = exports.setNestedValue = exports.getNestedValue = exports.computeAggregates = exports.hasEventMatching = exports.getRequiredEvents = exports.selectScenario = exports.ParsedTemplate = exports.parseTemplate = exports.renderEventTemplate = exports.renderWorkflow = exports.getConfigNameFromFilename = exports.isYamlFile = exports.parseYaml = exports.CanvasConverter = exports.resolveCanvasColor = exports.CANVAS_COLOR_PRESETS = exports.hasPVExtension = exports.isGroupNode = exports.isLinkNode = exports.isFileNode = exports.isTextNode = void 0;
|
|
14
|
-
exports.InMemoryFileSystemAdapter = exports.getAllNodeIds = exports.findNodesMatchingEventPattern = exports.resolveWorkflowNodeIds = exports.resolveScenarioNodeIds = exports.getNodeEventName = exports.buildEventNodeMap = exports.buildNodeSourcesMap = exports.buildStoryboardContext = exports.LibraryDiscovery = exports.LibraryConverter = exports.LibraryLoader = exports.EventRecorderService = exports.SessionManager = exports.PathBasedEventProcessor = exports.analyzeCoverage = exports.createExecutionValidator = exports.ExecutionValidator = exports.resolveEventSpanColor = exports.getSpanColor = exports.matchSpanPattern = exports.buildSpanColorMapFromCanvases = exports.buildSpanColorMap = exports.extractSpanConventions = exports.extractSpanConvention = exports.DEFAULT_SPAN_COLOR = exports.getAllScopeNames = exports.buildScopeColorMap = exports.normalizeScopes = exports.getScopeColor = exports.getScopeDefinition = exports.getScopeNames = exports.DRAFT_NODE_COLOR = exports.DEFAULT_SCOPE_COLOR = exports.ScopesCanvasValidator = exports.CanvasDiscovery = exports.SpanMatcher = exports.getScopeMatchSummary = exports.scopeHasMatches = exports.getScopeWithMostSpans = exports.getSpanCountForScope = void 0;
|
|
14
|
+
exports.InMemoryFileSystemAdapter = exports.getAllNodeIds = exports.findNodesMatchingEventPattern = exports.resolveWorkflowNodeIds = exports.resolveScenarioNodeIds = exports.getNodeEventName = exports.buildEventNodeMap = exports.buildNodeSourcesMap = exports.buildStoryboardContext = exports.LibraryDiscovery = exports.validateLibraryStructure = exports.LibraryConverter = exports.LibraryLoader = exports.EventRecorderService = exports.SessionManager = exports.PathBasedEventProcessor = exports.analyzeCoverage = exports.createExecutionValidator = exports.ExecutionValidator = exports.resolveEventSpanColor = exports.getSpanColor = exports.matchSpanPattern = exports.buildSpanColorMapFromCanvases = exports.buildSpanColorMap = exports.extractSpanConventions = exports.extractSpanConvention = exports.DEFAULT_SPAN_COLOR = exports.getAllScopeNames = exports.buildScopeColorMap = exports.normalizeScopes = exports.getScopeColor = exports.getScopeDefinition = exports.getScopeNames = exports.DRAFT_NODE_COLOR = exports.DEFAULT_SCOPE_COLOR = exports.ScopesCanvasValidator = exports.CanvasDiscovery = exports.SpanMatcher = exports.getScopeMatchSummary = exports.scopeHasMatches = exports.getScopeWithMostSpans = exports.getSpanCountForScope = void 0;
|
|
15
15
|
// Import canvas utility functions to re-export (avoids export-from syntax that breaks with exports field)
|
|
16
16
|
const canvas_1 = require("./types/canvas");
|
|
17
17
|
Object.defineProperty(exports, "isTextNode", { enumerable: true, get: function () { return canvas_1.isTextNode; } });
|
|
@@ -140,6 +140,9 @@ var LibraryLoader_1 = require("./LibraryLoader");
|
|
|
140
140
|
Object.defineProperty(exports, "LibraryLoader", { enumerable: true, get: function () { return LibraryLoader_1.LibraryLoader; } });
|
|
141
141
|
var LibraryConverter_1 = require("./utils/LibraryConverter");
|
|
142
142
|
Object.defineProperty(exports, "LibraryConverter", { enumerable: true, get: function () { return LibraryConverter_1.LibraryConverter; } });
|
|
143
|
+
// Export library validation (browser-safe - standalone validation functions)
|
|
144
|
+
var validation_1 = require("./validation");
|
|
145
|
+
Object.defineProperty(exports, "validateLibraryStructure", { enumerable: true, get: function () { return validation_1.validateLibraryStructure; } });
|
|
143
146
|
// Export library discovery (browser-safe - uses FileSystemAdapter abstraction)
|
|
144
147
|
var LibraryDiscovery_1 = require("./discovery/LibraryDiscovery");
|
|
145
148
|
Object.defineProperty(exports, "LibraryDiscovery", { enumerable: true, get: function () { return LibraryDiscovery_1.LibraryDiscovery; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,0GAA0G;AAC1G,2CAQwB;AAwFtB,2FA/FA,mBAAU,OA+FA;AACV,2FA/FA,mBAAU,OA+FA;AACV,2FA/FA,mBAAU,OA+FA;AACV,4FA/FA,oBAAW,OA+FA;AACX,+FA/FA,uBAAc,OA+FA;AACd,qGA/FA,6BAAoB,OA+FA;AACpB,mGA/FA,2BAAkB,OA+FA;AAGpB,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AAGxB,2CAA2C;AAC3C,iDAAsF;AAA7E,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,uHAAA,yBAAyB,OAAA;AAGzD,iDAAiD;AACjD,mEAAmE;AACnE,kEAAmF;AAA1E,mHAAA,cAAc,OAAA;AAAE,wHAAA,mBAAmB,OAAA;AAC5C,8DAA2E;AAAlE,gHAAA,aAAa,OAAA;AAAE,iHAAA,cAAc,OAAA;AAEtC,gEAOqC;AANnC,kHAAA,cAAc,OAAA;AACd,qHAAA,iBAAiB,OAAA;AACjB,oHAAA,gBAAgB,OAAA;AAChB,qHAAA,iBAAiB,OAAA;AACjB,kHAAA,cAAc,OAAA;AACd,kHAAA,cAAc,OAAA;AAoBhB,0CAK0B;AAJxB,wGAAA,eAAe,OAAA;AACf,+GAAA,sBAAsB,OAAA;AACtB,qGAAA,YAAY,OAAA;AACZ,4GAAA,mBAAmB,OAAA;AAiDrB,2BAA2B;AAC3B,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AAGxB,+BAA+B;AAC/B,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0DAA0E;AAAjE,8GAAA,aAAa,OAAA;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,gBAAgB,OAAA;AAIzB,6EAA6E;AAC7E,2CAAwD;AAA/C,sHAAA,wBAAwB,OAAA;AAOjC,+EAA+E;AAC/E,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AAezB,4CAS4B;AAR1B,+GAAA,sBAAsB,OAAA;AACtB,4GAAA,mBAAmB,OAAA;AACnB,0GAAA,iBAAiB,OAAA;AACjB,yGAAA,gBAAgB,OAAA;AAChB,+GAAA,sBAAsB,OAAA;AACtB,+GAAA,sBAAsB,OAAA;AACtB,sHAAA,6BAA6B,OAAA;AAC7B,sGAAA,aAAa,OAAA;AAKf,+EAAiF;AAAxE,mIAAA,yBAAyB,OAAA;AAElC,4FAA4F;AAC5F,mFAAmF;AACnF,EAAE;AACF,kFAAkF;AAClF,mDAAmD;AACnD,oDAAoD;AACpD,+DAA+D;AAC/D,0FAA0F;AAC1F,uDAAuD;AACvD,8CAA8C;AAC9C,qEAAqE;AACrE,gEAAgE;AAChE,EAAE;AACF,wGAAwG;AACxG,sGAAsG;AACtG,sEAAsE;AACtE,uEAAuE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Module
|
|
3
|
+
*
|
|
4
|
+
* Exports validation functions for various Principal View data structures.
|
|
5
|
+
*/
|
|
6
|
+
export { validateLibraryStructure, type LibraryValidationError, type LibraryValidationErrorType, type LibraryValidationResult, } from './libraryValidation';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validation Module
|
|
4
|
+
*
|
|
5
|
+
* Exports validation functions for various Principal View data structures.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validateLibraryStructure = void 0;
|
|
9
|
+
var libraryValidation_1 = require("./libraryValidation");
|
|
10
|
+
Object.defineProperty(exports, "validateLibraryStructure", { enumerable: true, get: function () { return libraryValidation_1.validateLibraryStructure; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yDAK6B;AAJ3B,6HAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Validation
|
|
3
|
+
*
|
|
4
|
+
* Standalone validation functions for ComponentLibrary schema.
|
|
5
|
+
* Used by both LibraryLoader (core), LibraryDiscovery, and CLI validation.
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentLibrary } from '../types/library';
|
|
8
|
+
/**
|
|
9
|
+
* Types of library validation errors
|
|
10
|
+
*/
|
|
11
|
+
export type LibraryValidationErrorType = 'parse-error' | 'validation-error' | 'schema-error' | 'scopes-canvas-required';
|
|
12
|
+
/**
|
|
13
|
+
* A library validation error
|
|
14
|
+
*
|
|
15
|
+
* Unified type used across LibraryLoader, LibraryDiscovery, and CLI validation.
|
|
16
|
+
*/
|
|
17
|
+
export interface LibraryValidationError {
|
|
18
|
+
/** Error message */
|
|
19
|
+
message: string;
|
|
20
|
+
/** Path to the invalid field or file */
|
|
21
|
+
path: string;
|
|
22
|
+
/** Error category */
|
|
23
|
+
type?: LibraryValidationErrorType;
|
|
24
|
+
/** Optional suggestion for fixing the error */
|
|
25
|
+
suggestion?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Result of library structure validation
|
|
29
|
+
*/
|
|
30
|
+
export interface LibraryValidationResult {
|
|
31
|
+
/** Whether validation passed */
|
|
32
|
+
valid: boolean;
|
|
33
|
+
/** List of validation errors (empty if valid) */
|
|
34
|
+
errors: LibraryValidationError[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate a ComponentLibrary structure
|
|
38
|
+
*
|
|
39
|
+
* This validates the core schema requirements:
|
|
40
|
+
* - Required fields (version, name, nodeComponents, edgeComponents)
|
|
41
|
+
* - Event schemas structure
|
|
42
|
+
* - Top-level scopes (color required unless external)
|
|
43
|
+
* - Resources structure and owned-scopes references
|
|
44
|
+
* - Connection rules references
|
|
45
|
+
*
|
|
46
|
+
* Note: This does NOT validate unknown fields or icon names.
|
|
47
|
+
* The CLI adds those supplementary validations.
|
|
48
|
+
*
|
|
49
|
+
* @param library - The library object to validate
|
|
50
|
+
* @returns Validation result with any errors
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateLibraryStructure(library: ComponentLibrary): LibraryValidationResult;
|
|
53
|
+
//# sourceMappingURL=libraryValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libraryValidation.d.ts","sourceRoot":"","sources":["../../src/validation/libraryValidation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,aAAa,GACb,kBAAkB,GAClB,cAAc,GACd,wBAAwB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,CAAC,EAAE,0BAA0B,CAAC;IAClC,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,MAAM,EAAE,sBAAsB,EAAE,CAAC;CAClC;AAOD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,uBAAuB,CAgO3F"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Library Validation
|
|
4
|
+
*
|
|
5
|
+
* Standalone validation functions for ComponentLibrary schema.
|
|
6
|
+
* Used by both LibraryLoader (core), LibraryDiscovery, and CLI validation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.validateLibraryStructure = void 0;
|
|
10
|
+
/** Helper to create a schema error */
|
|
11
|
+
function schemaError(message, path, suggestion) {
|
|
12
|
+
return { message, path, type: 'schema-error', suggestion };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validate a ComponentLibrary structure
|
|
16
|
+
*
|
|
17
|
+
* This validates the core schema requirements:
|
|
18
|
+
* - Required fields (version, name, nodeComponents, edgeComponents)
|
|
19
|
+
* - Event schemas structure
|
|
20
|
+
* - Top-level scopes (color required unless external)
|
|
21
|
+
* - Resources structure and owned-scopes references
|
|
22
|
+
* - Connection rules references
|
|
23
|
+
*
|
|
24
|
+
* Note: This does NOT validate unknown fields or icon names.
|
|
25
|
+
* The CLI adds those supplementary validations.
|
|
26
|
+
*
|
|
27
|
+
* @param library - The library object to validate
|
|
28
|
+
* @returns Validation result with any errors
|
|
29
|
+
*/
|
|
30
|
+
function validateLibraryStructure(library) {
|
|
31
|
+
const errors = [];
|
|
32
|
+
// Required fields
|
|
33
|
+
if (!library.version) {
|
|
34
|
+
errors.push(schemaError('Missing required field "version"', 'version', 'Add: version: "1.0.0"'));
|
|
35
|
+
}
|
|
36
|
+
if (!library.name) {
|
|
37
|
+
errors.push(schemaError('Missing required field "name"', 'name', 'Add: name: "my-library"'));
|
|
38
|
+
}
|
|
39
|
+
if (!library.nodeComponents || typeof library.nodeComponents !== 'object') {
|
|
40
|
+
errors.push(schemaError('Missing or invalid "nodeComponents" field', 'nodeComponents', 'Add: nodeComponents: {} (can be empty but must be present)'));
|
|
41
|
+
}
|
|
42
|
+
if (!library.edgeComponents || typeof library.edgeComponents !== 'object') {
|
|
43
|
+
errors.push(schemaError('Missing or invalid "edgeComponents" field', 'edgeComponents', 'Add: edgeComponents: {} (can be empty but must be present)'));
|
|
44
|
+
}
|
|
45
|
+
// Validate event schemas if present
|
|
46
|
+
if (library.eventSchemas !== undefined) {
|
|
47
|
+
if (typeof library.eventSchemas !== 'object' || library.eventSchemas === null) {
|
|
48
|
+
errors.push(schemaError('Field "eventSchemas" must be an object', 'eventSchemas', 'Use: eventSchemas: { "my-event": { description: "...", attributes: {} } }'));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
for (const [eventName, schema] of Object.entries(library.eventSchemas)) {
|
|
52
|
+
if (!schema.description) {
|
|
53
|
+
errors.push(schemaError(`Event schema "${eventName}" is missing required field "description"`, `eventSchemas.${eventName}.description`, 'Add a description for this event schema'));
|
|
54
|
+
}
|
|
55
|
+
if (!schema.attributes || typeof schema.attributes !== 'object') {
|
|
56
|
+
errors.push(schemaError(`Event schema "${eventName}" is missing or has invalid "attributes" field`, `eventSchemas.${eventName}.attributes`, 'Add: attributes: {} (can be empty but must be present)'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Validate each attribute
|
|
60
|
+
const validTypes = ['string', 'number', 'boolean', 'object', 'array'];
|
|
61
|
+
for (const [attrName, attrSchema] of Object.entries(schema.attributes)) {
|
|
62
|
+
if (!attrSchema.type) {
|
|
63
|
+
errors.push(schemaError(`Event schema "${eventName}" attribute "${attrName}" is missing required field "type"`, `eventSchemas.${eventName}.attributes.${attrName}.type`, `Add type: one of ${validTypes.join(', ')}`));
|
|
64
|
+
}
|
|
65
|
+
else if (!validTypes.includes(attrSchema.type)) {
|
|
66
|
+
errors.push(schemaError(`Event schema "${eventName}" attribute "${attrName}" has invalid type "${attrSchema.type}"`, `eventSchemas.${eventName}.attributes.${attrName}.type`, `Valid types: ${validTypes.join(', ')}`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Validate top-level scopes if present
|
|
74
|
+
if (library.scopes !== undefined) {
|
|
75
|
+
if (typeof library.scopes !== 'object' || library.scopes === null || Array.isArray(library.scopes)) {
|
|
76
|
+
errors.push(schemaError('Field "scopes" must be an object', 'scopes', 'Define scopes as: scopes: { my-scope: { color: "#DC2626", description: "..." } }'));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
for (const [scopeName, scopeDef] of Object.entries(library.scopes)) {
|
|
80
|
+
if (typeof scopeDef !== 'object' || scopeDef === null) {
|
|
81
|
+
errors.push(schemaError(`Scope "${scopeName}" must be an object`, `scopes.${scopeName}`, 'Use: { color: "#RRGGBB", description: "..." }'));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// External scopes don't require color (defined elsewhere)
|
|
85
|
+
const isExternal = scopeDef.external === true;
|
|
86
|
+
if (!isExternal && typeof scopeDef.color !== 'string') {
|
|
87
|
+
errors.push(schemaError(`Scope "${scopeName}" is missing required "color" property`, `scopes.${scopeName}.color`, 'Add a color: "#RRGGBB" or use external: true for scopes defined in other libraries'));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Validate connection rules if present
|
|
94
|
+
if (library.connectionRules) {
|
|
95
|
+
for (const [index, rule] of library.connectionRules.entries()) {
|
|
96
|
+
if (!rule.from || !rule.to || !rule.via) {
|
|
97
|
+
errors.push(schemaError(`Connection rule at index ${index} is missing required fields`, `connectionRules[${index}]`, 'Connection rules require: from, to, via'));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Check that referenced types exist
|
|
101
|
+
if (library.nodeComponents && !library.nodeComponents[rule.from]) {
|
|
102
|
+
errors.push(schemaError(`Connection rule references unknown node type "${rule.from}"`, `connectionRules[${index}].from`, `Define "${rule.from}" in nodeComponents`));
|
|
103
|
+
}
|
|
104
|
+
if (library.nodeComponents && !library.nodeComponents[rule.to]) {
|
|
105
|
+
errors.push(schemaError(`Connection rule references unknown node type "${rule.to}"`, `connectionRules[${index}].to`, `Define "${rule.to}" in nodeComponents`));
|
|
106
|
+
}
|
|
107
|
+
if (library.edgeComponents && !library.edgeComponents[rule.via]) {
|
|
108
|
+
errors.push(schemaError(`Connection rule references unknown edge type "${rule.via}"`, `connectionRules[${index}].via`, `Define "${rule.via}" in edgeComponents`));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Validate resources if present
|
|
114
|
+
if (library.resources !== undefined) {
|
|
115
|
+
if (typeof library.resources !== 'object' || library.resources === null || Array.isArray(library.resources)) {
|
|
116
|
+
errors.push(schemaError('Field "resources" must be an object', 'resources', 'Use: resources: { my-service: { "service.name": "my-service", ... } }'));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
for (const [serviceId, resourceAttrs] of Object.entries(library.resources)) {
|
|
120
|
+
if (typeof resourceAttrs !== 'object' || Array.isArray(resourceAttrs) || resourceAttrs === null) {
|
|
121
|
+
errors.push(schemaError(`Resource "${serviceId}" must be an object`, `resources.${serviceId}`, 'Use: { "service.name": "...", "owned-scopes": [...] }'));
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
// Check that service.name is present (required)
|
|
125
|
+
if (!resourceAttrs['service.name']) {
|
|
126
|
+
errors.push(schemaError(`Resource "${serviceId}" is missing required attribute "service.name"`, `resources.${serviceId}`, 'Add: "service.name": "my-service-name"'));
|
|
127
|
+
}
|
|
128
|
+
// Validate owned-scopes
|
|
129
|
+
const ownedScopes = resourceAttrs['owned-scopes'];
|
|
130
|
+
if (ownedScopes !== undefined) {
|
|
131
|
+
if (!Array.isArray(ownedScopes)) {
|
|
132
|
+
errors.push(schemaError(`Resource "${serviceId}" owned-scopes must be an array`, `resources.${serviceId}.owned-scopes`, 'Use: owned-scopes: ["scope-name-1", "scope-name-2"]'));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
for (const scope of ownedScopes) {
|
|
136
|
+
if (typeof scope !== 'string') {
|
|
137
|
+
errors.push(schemaError(`Resource "${serviceId}" owned-scopes contains non-string value`, `resources.${serviceId}.owned-scopes`, 'All owned-scopes entries must be strings'));
|
|
138
|
+
}
|
|
139
|
+
else if (!library.scopes || !library.scopes[scope]) {
|
|
140
|
+
errors.push(schemaError(`Resource "${serviceId}" references undefined scope "${scope}"`, `resources.${serviceId}.owned-scopes`, `Define scope "${scope}" in the top-level scopes section:\nscopes:\n ${scope}:\n color: "#RRGGBB"\n description: "Description of this scope"`));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Validate other attributes are strings (except owned-scopes)
|
|
146
|
+
for (const [attrName, attrValue] of Object.entries(resourceAttrs)) {
|
|
147
|
+
if (attrName !== 'owned-scopes' && typeof attrValue !== 'string') {
|
|
148
|
+
errors.push(schemaError(`Resource "${serviceId}" attribute "${attrName}" must have a string value`, `resources.${serviceId}.${attrName}`, 'Resource attributes (except owned-scopes) must be strings'));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
valid: errors.length === 0,
|
|
156
|
+
errors,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
exports.validateLibraryStructure = validateLibraryStructure;
|
|
160
|
+
//# sourceMappingURL=libraryValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libraryValidation.js","sourceRoot":"","sources":["../../src/validation/libraryValidation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAuCH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D,MAAM,CAAC,IAAI,CAAC,WAAW,CACrB,aAAa,SAAS,iCAAiC,KAAK,GAAG,EAC/D,aAAa,SAAS,eAAe,EACrC,iBAAiB,KAAK,kDAAkD,KAAK,uEAAuE,CACrJ,CAAC,CAAC;6BACJ;yBACF;qBACF;iBACF;gBAED,8DAA8D;gBAC9D,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;oBACjE,IAAI,QAAQ,KAAK,cAAc,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;wBAChE,MAAM,CAAC,IAAI,CAAC,WAAW,CACrB,aAAa,SAAS,gBAAgB,QAAQ,4BAA4B,EAC1E,aAAa,SAAS,IAAI,QAAQ,EAAE,EACpC,2DAA2D,CAC5D,CAAC,CAAC;qBACJ;iBACF;aACF;SACF;KACF;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC;AAhOD,4DAgOC"}
|
package/package.json
CHANGED
package/src/LibraryLoader.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { FileSystemAdapter } from '@principal-ai/repository-abstraction';
|
|
9
9
|
import type { ComponentLibrary, LibraryLoadResult } from './types/library';
|
|
10
|
+
import { validateLibraryStructure } from './validation/libraryValidation';
|
|
10
11
|
import * as yaml from 'js-yaml';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -173,136 +174,19 @@ export class LibraryLoader {
|
|
|
173
174
|
/**
|
|
174
175
|
* Validate the library structure
|
|
175
176
|
*
|
|
177
|
+
* Uses the shared validateLibraryStructure function from validation module.
|
|
178
|
+
*
|
|
176
179
|
* @param library - Parsed library object
|
|
177
180
|
* @param filePath - File path for error messages
|
|
178
181
|
* @returns Error message if invalid, undefined if valid
|
|
179
182
|
*/
|
|
180
183
|
private validate(library: ComponentLibrary, filePath: string): string | undefined {
|
|
181
|
-
|
|
182
|
-
return `Missing required field 'version' in ${filePath}`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (!library.name) {
|
|
186
|
-
return `Missing required field 'name' in ${filePath}`;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (!library.nodeComponents || typeof library.nodeComponents !== 'object') {
|
|
190
|
-
return `Missing or invalid 'nodeComponents' in ${filePath}`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (!library.edgeComponents || typeof library.edgeComponents !== 'object') {
|
|
194
|
-
return `Missing or invalid 'edgeComponents' in ${filePath}`;
|
|
195
|
-
}
|
|
184
|
+
const result = validateLibraryStructure(library);
|
|
196
185
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Validate event schemas if present
|
|
202
|
-
if (library.eventSchemas) {
|
|
203
|
-
if (typeof library.eventSchemas !== 'object') {
|
|
204
|
-
return `Field 'eventSchemas' must be an object in ${filePath}`;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
for (const [eventName, schema] of Object.entries(library.eventSchemas)) {
|
|
208
|
-
if (!schema.description) {
|
|
209
|
-
return `Event schema '${eventName}' is missing required field 'description' in ${filePath}`;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (!schema.attributes || typeof schema.attributes !== 'object') {
|
|
213
|
-
return `Event schema '${eventName}' is missing or has invalid 'attributes' field in ${filePath}`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Validate each attribute in the event schema
|
|
217
|
-
for (const [attrName, attrSchema] of Object.entries(schema.attributes)) {
|
|
218
|
-
if (!attrSchema.type) {
|
|
219
|
-
return `Event schema '${eventName}' attribute '${attrName}' is missing required field 'type' in ${filePath}`;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const validTypes = ['string', 'number', 'boolean', 'object', 'array'];
|
|
223
|
-
if (!validTypes.includes(attrSchema.type)) {
|
|
224
|
-
return `Event schema '${eventName}' attribute '${attrName}' has invalid type '${attrSchema.type}' in ${filePath}. Valid types: ${validTypes.join(', ')}`;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Validate top-level scopes if present
|
|
231
|
-
if (library.scopes) {
|
|
232
|
-
if (typeof library.scopes !== 'object' || Array.isArray(library.scopes)) {
|
|
233
|
-
return `Field 'scopes' must be an object in ${filePath}`;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
for (const [scopeName, scopeDef] of Object.entries(library.scopes)) {
|
|
237
|
-
if (typeof scopeDef !== 'object' || scopeDef === null) {
|
|
238
|
-
return `Scope '${scopeName}' must be an object in ${filePath}`;
|
|
239
|
-
}
|
|
240
|
-
// External scopes don't require color (defined elsewhere)
|
|
241
|
-
const isExternal = scopeDef.external === true;
|
|
242
|
-
if (!isExternal && typeof scopeDef.color !== 'string') {
|
|
243
|
-
return `Scope '${scopeName}' is missing required 'color' property in ${filePath}. Use 'external: true' for scopes defined in other libraries.`;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Validate connection rules if present
|
|
249
|
-
if (library.connectionRules) {
|
|
250
|
-
for (const [index, rule] of library.connectionRules.entries()) {
|
|
251
|
-
if (!rule.from || !rule.to || !rule.via) {
|
|
252
|
-
return `Connection rule at index ${index} is missing required fields (from, to, via) in ${filePath}`;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Check that referenced types exist
|
|
256
|
-
if (!library.nodeComponents[rule.from]) {
|
|
257
|
-
return `Connection rule references unknown node type '${rule.from}' in ${filePath}`;
|
|
258
|
-
}
|
|
259
|
-
if (!library.nodeComponents[rule.to]) {
|
|
260
|
-
return `Connection rule references unknown node type '${rule.to}' in ${filePath}`;
|
|
261
|
-
}
|
|
262
|
-
if (!library.edgeComponents[rule.via]) {
|
|
263
|
-
return `Connection rule references unknown edge type '${rule.via}' in ${filePath}`;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Validate resources if present
|
|
269
|
-
if (library.resources) {
|
|
270
|
-
if (typeof library.resources !== 'object' || Array.isArray(library.resources)) {
|
|
271
|
-
return `Field 'resources' must be an object in ${filePath}`;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
for (const [serviceId, resourceAttrs] of Object.entries(library.resources)) {
|
|
275
|
-
// Check that each service has a resource attributes object
|
|
276
|
-
if (typeof resourceAttrs !== 'object' || Array.isArray(resourceAttrs) || resourceAttrs === null) {
|
|
277
|
-
return `Resource entry '${serviceId}' must be an object in ${filePath}`;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Check that service.name is present (required)
|
|
281
|
-
if (!resourceAttrs['service.name']) {
|
|
282
|
-
return `Resource entry '${serviceId}' is missing required attribute 'service.name' in ${filePath}`;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Validate attribute values
|
|
286
|
-
for (const [attrName, attrValue] of Object.entries(resourceAttrs)) {
|
|
287
|
-
// owned-scopes must be an array of strings referencing top-level scopes
|
|
288
|
-
if (attrName === 'owned-scopes') {
|
|
289
|
-
if (!Array.isArray(attrValue)) {
|
|
290
|
-
return `Resource '${serviceId}' attribute 'owned-scopes' must be an array in ${filePath}`;
|
|
291
|
-
}
|
|
292
|
-
for (const scope of attrValue) {
|
|
293
|
-
if (typeof scope !== 'string') {
|
|
294
|
-
return `Resource '${serviceId}' attribute 'owned-scopes' array must contain only strings in ${filePath}`;
|
|
295
|
-
}
|
|
296
|
-
// Validate that scope references exist in top-level scopes (strict)
|
|
297
|
-
if (!library.scopes || !library.scopes[scope]) {
|
|
298
|
-
return `Resource '${serviceId}' references undefined scope '${scope}' in ${filePath}. Define it in the top-level 'scopes' section (use 'external: true' for scopes from other libraries).`;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
} else if (typeof attrValue !== 'string') {
|
|
302
|
-
return `Resource '${serviceId}' attribute '${attrName}' must have a string value in ${filePath}`;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
186
|
+
if (!result.valid && result.errors.length > 0) {
|
|
187
|
+
// Return the first error with file path context
|
|
188
|
+
const firstError = result.errors[0];
|
|
189
|
+
return `${firstError.message} in ${filePath}`;
|
|
306
190
|
}
|
|
307
191
|
|
|
308
192
|
return undefined;
|
|
@@ -46,9 +46,9 @@ resources:
|
|
|
46
46
|
|
|
47
47
|
expect(result.errors).toHaveLength(1);
|
|
48
48
|
expect(result.errors[0].type).toBe('scopes-canvas-required');
|
|
49
|
-
expect(result.errors[0].
|
|
50
|
-
expect(result.errors[0].
|
|
51
|
-
expect(result.errors[0].
|
|
49
|
+
expect(result.errors[0].message).toContain('owned-scopes');
|
|
50
|
+
expect(result.errors[0].message).toContain('scope-a');
|
|
51
|
+
expect(result.errors[0].message).toContain('scope-b');
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
test('no error when library has owned-scopes and .scopes.canvas exists', async () => {
|
|
@@ -149,8 +149,8 @@ resources:
|
|
|
149
149
|
|
|
150
150
|
expect(result.errors).toHaveLength(1);
|
|
151
151
|
expect(result.errors[0].type).toBe('scopes-canvas-required');
|
|
152
|
-
expect(result.errors[0].
|
|
153
|
-
expect(result.errors[0].
|
|
152
|
+
expect(result.errors[0].message).toContain('scope-a');
|
|
153
|
+
expect(result.errors[0].message).toContain('scope-b');
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
test('finds .scopes.canvas in subdirectory', async () => {
|
|
@@ -10,6 +10,7 @@ import { PackageLayerModule, type PackageLayer } from '@principal-ai/codebase-co
|
|
|
10
10
|
import { LibraryLoader } from '../LibraryLoader';
|
|
11
11
|
import type { ComponentLibrary } from '../types/library';
|
|
12
12
|
import { getScopeNames } from '../scopes/utils';
|
|
13
|
+
import type { LibraryValidationError, LibraryValidationErrorType } from '../validation';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Service with its owned scopes
|
|
@@ -45,22 +46,8 @@ export interface DiscoveredLibrary {
|
|
|
45
46
|
servicesWithScopes: ServiceWithScopes[];
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
51
|
-
export type LibraryValidationErrorType =
|
|
52
|
-
| 'parse-error'
|
|
53
|
-
| 'validation-error'
|
|
54
|
-
| 'scopes-canvas-required';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Library validation error with type information
|
|
58
|
-
*/
|
|
59
|
-
export interface LibraryValidationError {
|
|
60
|
-
path: string;
|
|
61
|
-
error: string;
|
|
62
|
-
type?: LibraryValidationErrorType;
|
|
63
|
-
}
|
|
49
|
+
// Re-export validation types from shared module
|
|
50
|
+
export type { LibraryValidationError, LibraryValidationErrorType };
|
|
64
51
|
|
|
65
52
|
/**
|
|
66
53
|
* Result of library discovery
|
|
@@ -180,14 +167,14 @@ export class LibraryDiscovery {
|
|
|
180
167
|
// Only report errors that aren't "file not found" (which is normal)
|
|
181
168
|
errors.push({
|
|
182
169
|
path: loadResult.path,
|
|
183
|
-
|
|
170
|
+
message: loadResult.error,
|
|
184
171
|
type: 'parse-error',
|
|
185
172
|
});
|
|
186
173
|
}
|
|
187
174
|
} catch (error) {
|
|
188
175
|
errors.push({
|
|
189
176
|
path: pkg.packageData.path,
|
|
190
|
-
|
|
177
|
+
message: error instanceof Error ? error.message : String(error),
|
|
191
178
|
});
|
|
192
179
|
}
|
|
193
180
|
}
|
|
@@ -229,7 +216,7 @@ export class LibraryDiscovery {
|
|
|
229
216
|
} else if (loadResult.error) {
|
|
230
217
|
errors.push({
|
|
231
218
|
path: loadResult.path,
|
|
232
|
-
|
|
219
|
+
message: loadResult.error,
|
|
233
220
|
type: 'parse-error',
|
|
234
221
|
});
|
|
235
222
|
}
|
|
@@ -332,7 +319,7 @@ export class LibraryDiscovery {
|
|
|
332
319
|
if (!pvDirExists) {
|
|
333
320
|
errors.push({
|
|
334
321
|
path: libraryPath,
|
|
335
|
-
|
|
322
|
+
message: `Scopes canvas required: library.yaml defines owned-scopes [${allOwnedScopes.join(', ')}] but no .principal-views/ directory exists. Create a .scopes.canvas file (e.g., architecture.scopes.canvas) documenting scope boundaries.`,
|
|
336
323
|
type: 'scopes-canvas-required',
|
|
337
324
|
});
|
|
338
325
|
return;
|
|
@@ -344,7 +331,7 @@ export class LibraryDiscovery {
|
|
|
344
331
|
if (!scopesCanvasExists) {
|
|
345
332
|
errors.push({
|
|
346
333
|
path: libraryPath,
|
|
347
|
-
|
|
334
|
+
message: `Scopes canvas required: library.yaml defines owned-scopes [${allOwnedScopes.join(', ')}] but no .scopes.canvas file found. Create a .scopes.canvas file (e.g., .principal-views/architecture.scopes.canvas) with nodes for each scope (set pv.otel.scope to the scope name).`,
|
|
348
335
|
type: 'scopes-canvas-required',
|
|
349
336
|
});
|
|
350
337
|
}
|
package/src/index.ts
CHANGED
|
@@ -377,13 +377,19 @@ export { LibraryConverter } from './utils/LibraryConverter';
|
|
|
377
377
|
export type { CreateNodeOptions, CreateEdgeOptions } from './utils/LibraryConverter';
|
|
378
378
|
export type { ResourceAttributes, ScopeDefinition, OwnedScopes } from './types/library';
|
|
379
379
|
|
|
380
|
+
// Export library validation (browser-safe - standalone validation functions)
|
|
381
|
+
export { validateLibraryStructure } from './validation';
|
|
382
|
+
export type {
|
|
383
|
+
LibraryValidationError,
|
|
384
|
+
LibraryValidationErrorType,
|
|
385
|
+
LibraryValidationResult,
|
|
386
|
+
} from './validation';
|
|
387
|
+
|
|
380
388
|
// Export library discovery (browser-safe - uses FileSystemAdapter abstraction)
|
|
381
389
|
export { LibraryDiscovery } from './discovery/LibraryDiscovery';
|
|
382
390
|
export type {
|
|
383
391
|
DiscoveredLibrary,
|
|
384
392
|
LibraryDiscoveryResult,
|
|
385
|
-
LibraryValidationError,
|
|
386
|
-
LibraryValidationErrorType,
|
|
387
393
|
} from './discovery/LibraryDiscovery';
|
|
388
394
|
|
|
389
395
|
// Export storyboard context types and builder (browser-safe)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Module
|
|
3
|
+
*
|
|
4
|
+
* Exports validation functions for various Principal View data structures.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
validateLibraryStructure,
|
|
9
|
+
type LibraryValidationError,
|
|
10
|
+
type LibraryValidationErrorType,
|
|
11
|
+
type LibraryValidationResult,
|
|
12
|
+
} from './libraryValidation';
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Validation
|
|
3
|
+
*
|
|
4
|
+
* Standalone validation functions for ComponentLibrary schema.
|
|
5
|
+
* Used by both LibraryLoader (core), LibraryDiscovery, and CLI validation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ComponentLibrary } from '../types/library';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Types of library validation errors
|
|
12
|
+
*/
|
|
13
|
+
export type LibraryValidationErrorType =
|
|
14
|
+
| 'parse-error'
|
|
15
|
+
| 'validation-error'
|
|
16
|
+
| 'schema-error'
|
|
17
|
+
| 'scopes-canvas-required';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A library validation error
|
|
21
|
+
*
|
|
22
|
+
* Unified type used across LibraryLoader, LibraryDiscovery, and CLI validation.
|
|
23
|
+
*/
|
|
24
|
+
export interface LibraryValidationError {
|
|
25
|
+
/** Error message */
|
|
26
|
+
message: string;
|
|
27
|
+
/** Path to the invalid field or file */
|
|
28
|
+
path: string;
|
|
29
|
+
/** Error category */
|
|
30
|
+
type?: LibraryValidationErrorType;
|
|
31
|
+
/** Optional suggestion for fixing the error */
|
|
32
|
+
suggestion?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Result of library structure validation
|
|
37
|
+
*/
|
|
38
|
+
export interface LibraryValidationResult {
|
|
39
|
+
/** Whether validation passed */
|
|
40
|
+
valid: boolean;
|
|
41
|
+
/** List of validation errors (empty if valid) */
|
|
42
|
+
errors: LibraryValidationError[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Helper to create a schema error */
|
|
46
|
+
function schemaError(message: string, path: string, suggestion?: string): LibraryValidationError {
|
|
47
|
+
return { message, path, type: 'schema-error', suggestion };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Validate a ComponentLibrary structure
|
|
52
|
+
*
|
|
53
|
+
* This validates the core schema requirements:
|
|
54
|
+
* - Required fields (version, name, nodeComponents, edgeComponents)
|
|
55
|
+
* - Event schemas structure
|
|
56
|
+
* - Top-level scopes (color required unless external)
|
|
57
|
+
* - Resources structure and owned-scopes references
|
|
58
|
+
* - Connection rules references
|
|
59
|
+
*
|
|
60
|
+
* Note: This does NOT validate unknown fields or icon names.
|
|
61
|
+
* The CLI adds those supplementary validations.
|
|
62
|
+
*
|
|
63
|
+
* @param library - The library object to validate
|
|
64
|
+
* @returns Validation result with any errors
|
|
65
|
+
*/
|
|
66
|
+
export function validateLibraryStructure(library: ComponentLibrary): LibraryValidationResult {
|
|
67
|
+
const errors: LibraryValidationError[] = [];
|
|
68
|
+
|
|
69
|
+
// Required fields
|
|
70
|
+
if (!library.version) {
|
|
71
|
+
errors.push(schemaError(
|
|
72
|
+
'Missing required field "version"',
|
|
73
|
+
'version',
|
|
74
|
+
'Add: version: "1.0.0"'
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!library.name) {
|
|
79
|
+
errors.push(schemaError(
|
|
80
|
+
'Missing required field "name"',
|
|
81
|
+
'name',
|
|
82
|
+
'Add: name: "my-library"'
|
|
83
|
+
));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!library.nodeComponents || typeof library.nodeComponents !== 'object') {
|
|
87
|
+
errors.push(schemaError(
|
|
88
|
+
'Missing or invalid "nodeComponents" field',
|
|
89
|
+
'nodeComponents',
|
|
90
|
+
'Add: nodeComponents: {} (can be empty but must be present)'
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!library.edgeComponents || typeof library.edgeComponents !== 'object') {
|
|
95
|
+
errors.push(schemaError(
|
|
96
|
+
'Missing or invalid "edgeComponents" field',
|
|
97
|
+
'edgeComponents',
|
|
98
|
+
'Add: edgeComponents: {} (can be empty but must be present)'
|
|
99
|
+
));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Validate event schemas if present
|
|
103
|
+
if (library.eventSchemas !== undefined) {
|
|
104
|
+
if (typeof library.eventSchemas !== 'object' || library.eventSchemas === null) {
|
|
105
|
+
errors.push(schemaError(
|
|
106
|
+
'Field "eventSchemas" must be an object',
|
|
107
|
+
'eventSchemas',
|
|
108
|
+
'Use: eventSchemas: { "my-event": { description: "...", attributes: {} } }'
|
|
109
|
+
));
|
|
110
|
+
} else {
|
|
111
|
+
for (const [eventName, schema] of Object.entries(library.eventSchemas)) {
|
|
112
|
+
if (!schema.description) {
|
|
113
|
+
errors.push(schemaError(
|
|
114
|
+
`Event schema "${eventName}" is missing required field "description"`,
|
|
115
|
+
`eventSchemas.${eventName}.description`,
|
|
116
|
+
'Add a description for this event schema'
|
|
117
|
+
));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!schema.attributes || typeof schema.attributes !== 'object') {
|
|
121
|
+
errors.push(schemaError(
|
|
122
|
+
`Event schema "${eventName}" is missing or has invalid "attributes" field`,
|
|
123
|
+
`eventSchemas.${eventName}.attributes`,
|
|
124
|
+
'Add: attributes: {} (can be empty but must be present)'
|
|
125
|
+
));
|
|
126
|
+
} else {
|
|
127
|
+
// Validate each attribute
|
|
128
|
+
const validTypes = ['string', 'number', 'boolean', 'object', 'array'];
|
|
129
|
+
for (const [attrName, attrSchema] of Object.entries(schema.attributes)) {
|
|
130
|
+
if (!attrSchema.type) {
|
|
131
|
+
errors.push(schemaError(
|
|
132
|
+
`Event schema "${eventName}" attribute "${attrName}" is missing required field "type"`,
|
|
133
|
+
`eventSchemas.${eventName}.attributes.${attrName}.type`,
|
|
134
|
+
`Add type: one of ${validTypes.join(', ')}`
|
|
135
|
+
));
|
|
136
|
+
} else if (!validTypes.includes(attrSchema.type)) {
|
|
137
|
+
errors.push(schemaError(
|
|
138
|
+
`Event schema "${eventName}" attribute "${attrName}" has invalid type "${attrSchema.type}"`,
|
|
139
|
+
`eventSchemas.${eventName}.attributes.${attrName}.type`,
|
|
140
|
+
`Valid types: ${validTypes.join(', ')}`
|
|
141
|
+
));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Validate top-level scopes if present
|
|
150
|
+
if (library.scopes !== undefined) {
|
|
151
|
+
if (typeof library.scopes !== 'object' || library.scopes === null || Array.isArray(library.scopes)) {
|
|
152
|
+
errors.push(schemaError(
|
|
153
|
+
'Field "scopes" must be an object',
|
|
154
|
+
'scopes',
|
|
155
|
+
'Define scopes as: scopes: { my-scope: { color: "#DC2626", description: "..." } }'
|
|
156
|
+
));
|
|
157
|
+
} else {
|
|
158
|
+
for (const [scopeName, scopeDef] of Object.entries(library.scopes)) {
|
|
159
|
+
if (typeof scopeDef !== 'object' || scopeDef === null) {
|
|
160
|
+
errors.push(schemaError(
|
|
161
|
+
`Scope "${scopeName}" must be an object`,
|
|
162
|
+
`scopes.${scopeName}`,
|
|
163
|
+
'Use: { color: "#RRGGBB", description: "..." }'
|
|
164
|
+
));
|
|
165
|
+
} else {
|
|
166
|
+
// External scopes don't require color (defined elsewhere)
|
|
167
|
+
const isExternal = scopeDef.external === true;
|
|
168
|
+
if (!isExternal && typeof scopeDef.color !== 'string') {
|
|
169
|
+
errors.push(schemaError(
|
|
170
|
+
`Scope "${scopeName}" is missing required "color" property`,
|
|
171
|
+
`scopes.${scopeName}.color`,
|
|
172
|
+
'Add a color: "#RRGGBB" or use external: true for scopes defined in other libraries'
|
|
173
|
+
));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Validate connection rules if present
|
|
181
|
+
if (library.connectionRules) {
|
|
182
|
+
for (const [index, rule] of library.connectionRules.entries()) {
|
|
183
|
+
if (!rule.from || !rule.to || !rule.via) {
|
|
184
|
+
errors.push(schemaError(
|
|
185
|
+
`Connection rule at index ${index} is missing required fields`,
|
|
186
|
+
`connectionRules[${index}]`,
|
|
187
|
+
'Connection rules require: from, to, via'
|
|
188
|
+
));
|
|
189
|
+
} else {
|
|
190
|
+
// Check that referenced types exist
|
|
191
|
+
if (library.nodeComponents && !library.nodeComponents[rule.from]) {
|
|
192
|
+
errors.push(schemaError(
|
|
193
|
+
`Connection rule references unknown node type "${rule.from}"`,
|
|
194
|
+
`connectionRules[${index}].from`,
|
|
195
|
+
`Define "${rule.from}" in nodeComponents`
|
|
196
|
+
));
|
|
197
|
+
}
|
|
198
|
+
if (library.nodeComponents && !library.nodeComponents[rule.to]) {
|
|
199
|
+
errors.push(schemaError(
|
|
200
|
+
`Connection rule references unknown node type "${rule.to}"`,
|
|
201
|
+
`connectionRules[${index}].to`,
|
|
202
|
+
`Define "${rule.to}" in nodeComponents`
|
|
203
|
+
));
|
|
204
|
+
}
|
|
205
|
+
if (library.edgeComponents && !library.edgeComponents[rule.via]) {
|
|
206
|
+
errors.push(schemaError(
|
|
207
|
+
`Connection rule references unknown edge type "${rule.via}"`,
|
|
208
|
+
`connectionRules[${index}].via`,
|
|
209
|
+
`Define "${rule.via}" in edgeComponents`
|
|
210
|
+
));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Validate resources if present
|
|
217
|
+
if (library.resources !== undefined) {
|
|
218
|
+
if (typeof library.resources !== 'object' || library.resources === null || Array.isArray(library.resources)) {
|
|
219
|
+
errors.push(schemaError(
|
|
220
|
+
'Field "resources" must be an object',
|
|
221
|
+
'resources',
|
|
222
|
+
'Use: resources: { my-service: { "service.name": "my-service", ... } }'
|
|
223
|
+
));
|
|
224
|
+
} else {
|
|
225
|
+
for (const [serviceId, resourceAttrs] of Object.entries(library.resources)) {
|
|
226
|
+
if (typeof resourceAttrs !== 'object' || Array.isArray(resourceAttrs) || resourceAttrs === null) {
|
|
227
|
+
errors.push(schemaError(
|
|
228
|
+
`Resource "${serviceId}" must be an object`,
|
|
229
|
+
`resources.${serviceId}`,
|
|
230
|
+
'Use: { "service.name": "...", "owned-scopes": [...] }'
|
|
231
|
+
));
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Check that service.name is present (required)
|
|
236
|
+
if (!resourceAttrs['service.name']) {
|
|
237
|
+
errors.push(schemaError(
|
|
238
|
+
`Resource "${serviceId}" is missing required attribute "service.name"`,
|
|
239
|
+
`resources.${serviceId}`,
|
|
240
|
+
'Add: "service.name": "my-service-name"'
|
|
241
|
+
));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Validate owned-scopes
|
|
245
|
+
const ownedScopes = resourceAttrs['owned-scopes'];
|
|
246
|
+
if (ownedScopes !== undefined) {
|
|
247
|
+
if (!Array.isArray(ownedScopes)) {
|
|
248
|
+
errors.push(schemaError(
|
|
249
|
+
`Resource "${serviceId}" owned-scopes must be an array`,
|
|
250
|
+
`resources.${serviceId}.owned-scopes`,
|
|
251
|
+
'Use: owned-scopes: ["scope-name-1", "scope-name-2"]'
|
|
252
|
+
));
|
|
253
|
+
} else {
|
|
254
|
+
for (const scope of ownedScopes) {
|
|
255
|
+
if (typeof scope !== 'string') {
|
|
256
|
+
errors.push(schemaError(
|
|
257
|
+
`Resource "${serviceId}" owned-scopes contains non-string value`,
|
|
258
|
+
`resources.${serviceId}.owned-scopes`,
|
|
259
|
+
'All owned-scopes entries must be strings'
|
|
260
|
+
));
|
|
261
|
+
} else if (!library.scopes || !library.scopes[scope]) {
|
|
262
|
+
errors.push(schemaError(
|
|
263
|
+
`Resource "${serviceId}" references undefined scope "${scope}"`,
|
|
264
|
+
`resources.${serviceId}.owned-scopes`,
|
|
265
|
+
`Define scope "${scope}" in the top-level scopes section:\nscopes:\n ${scope}:\n color: "#RRGGBB"\n description: "Description of this scope"`
|
|
266
|
+
));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Validate other attributes are strings (except owned-scopes)
|
|
273
|
+
for (const [attrName, attrValue] of Object.entries(resourceAttrs)) {
|
|
274
|
+
if (attrName !== 'owned-scopes' && typeof attrValue !== 'string') {
|
|
275
|
+
errors.push(schemaError(
|
|
276
|
+
`Resource "${serviceId}" attribute "${attrName}" must have a string value`,
|
|
277
|
+
`resources.${serviceId}.${attrName}`,
|
|
278
|
+
'Resource attributes (except owned-scopes) must be strings'
|
|
279
|
+
));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
valid: errors.length === 0,
|
|
288
|
+
errors,
|
|
289
|
+
};
|
|
290
|
+
}
|