@principal-ai/principal-view-core 0.27.2 → 0.28.0
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/events/EventsCanvasValidator.d.ts +13 -0
- package/dist/events/EventsCanvasValidator.d.ts.map +1 -1
- package/dist/events/EventsCanvasValidator.js +70 -0
- package/dist/events/EventsCanvasValidator.js.map +1 -1
- package/dist/events/NamespacePathIndex.d.ts +61 -0
- package/dist/events/NamespacePathIndex.d.ts.map +1 -0
- package/dist/events/NamespacePathIndex.js +74 -0
- package/dist/events/NamespacePathIndex.js.map +1 -0
- package/dist/events/OtelEventPathsValidator.d.ts +75 -0
- package/dist/events/OtelEventPathsValidator.d.ts.map +1 -0
- package/dist/events/OtelEventPathsValidator.js +126 -0
- package/dist/events/OtelEventPathsValidator.js.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +5 -1
- package/dist/events/index.js.map +1 -1
- package/dist/events/path-helpers.d.ts +33 -0
- package/dist/events/path-helpers.d.ts.map +1 -0
- package/dist/events/path-helpers.js +59 -0
- package/dist/events/path-helpers.js.map +1 -0
- package/package.json +1 -1
- package/src/events/EventsCanvasValidator.test.ts +190 -0
- package/src/events/EventsCanvasValidator.ts +86 -0
- package/src/events/NamespacePathIndex.test.ts +97 -0
- package/src/events/NamespacePathIndex.ts +100 -0
- package/src/events/OtelEventPathsValidator.test.ts +243 -0
- package/src/events/OtelEventPathsValidator.ts +191 -0
- package/src/events/index.ts +13 -0
- package/src/events/path-helpers.ts +53 -0
|
@@ -14,6 +14,19 @@ export interface EventNamespaceNode {
|
|
|
14
14
|
namespace: {
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional source paths that define this component's code location.
|
|
19
|
+
* Each entry may be a folder (covers all descendants) or a specific file.
|
|
20
|
+
* When present, events in this namespace may only be emitted from files
|
|
21
|
+
* covered by one of these paths. Namespaces without `paths` remain
|
|
22
|
+
* unenforced — enforcement is opt-in per namespace.
|
|
23
|
+
*
|
|
24
|
+
* Multiple entries are valid for cases like generated code, platform-split
|
|
25
|
+
* implementations, or migration periods. The validator warns when
|
|
26
|
+
* `paths.length > 1` to prompt authors to confirm the multi-location
|
|
27
|
+
* is intentional.
|
|
28
|
+
*/
|
|
29
|
+
paths?: string[];
|
|
17
30
|
events: Array<{
|
|
18
31
|
name: string;
|
|
19
32
|
severity?: 'INFO' | 'WARN' | 'ERROR';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventsCanvasValidator.d.ts","sourceRoot":"","sources":["../../src/events/EventsCanvasValidator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"EventsCanvasValidator.d.ts","sourceRoot":"","sources":["../../src/events/EventsCanvasValidator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAK1E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB;;;;;;;;;;;WAWG;QACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;YACrC,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;gBAC1B,IAAI,EAAE,MAAM,CAAC;gBACb,QAAQ,CAAC,EAAE,OAAO,CAAC;gBACnB,WAAW,CAAC,EAA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AAE,MAAM,EAAE,CAAC;QAC5B,yCAAyC;QACzC,WAAW,EAAE,MAAM,CAAC;QACpB,oDAAoD;QACpD,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,uCAAuC;QACvC,kBAAkB,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAK5B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAsB/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACG,QAAQ,CACZ,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,4BAA4B,CAAC;CAgOzC"}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.EventsCanvasValidator = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const path_helpers_1 = require("./path-helpers");
|
|
10
13
|
/**
|
|
11
14
|
* Validates events canvas files
|
|
12
15
|
*/
|
|
@@ -197,6 +200,73 @@ class EventsCanvasValidator {
|
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
}
|
|
203
|
+
// Validate namespace paths (optional field — enforcement is opt-in per namespace).
|
|
204
|
+
// Collects declared paths across namespaces to check for cross-namespace overlap.
|
|
205
|
+
const declaredPaths = [];
|
|
206
|
+
for (const node of eventsCanvas.nodes || []) {
|
|
207
|
+
if (!this.isEventNamespaceNode(node))
|
|
208
|
+
continue;
|
|
209
|
+
const namespaceNode = node;
|
|
210
|
+
const paths = namespaceNode.namespace.paths;
|
|
211
|
+
if (!paths || paths.length === 0)
|
|
212
|
+
continue;
|
|
213
|
+
// Warn when a namespace declares more than one path — prompt author to
|
|
214
|
+
// confirm the multi-location is intentional (generated code, platform
|
|
215
|
+
// splits, migration) rather than an accidental sprawl.
|
|
216
|
+
if (paths.length > 1) {
|
|
217
|
+
violations.push({
|
|
218
|
+
ruleId: 'events-namespace-multiple-paths',
|
|
219
|
+
severity: 'warn',
|
|
220
|
+
file: eventsCanvasPath || '.principal-views/cli.events.canvas',
|
|
221
|
+
path: `nodes[id="${namespaceNode.id}"].namespace.paths`,
|
|
222
|
+
message: `Namespace "${namespaceNode.namespace.name}" declares ${paths.length} paths`,
|
|
223
|
+
impact: 'Multiple paths can indicate legitimate cases (generated code, platform splits, migration) but often signal that the namespace should be split',
|
|
224
|
+
suggestion: 'Confirm the multi-location is intentional. Otherwise consider splitting the namespace or grouping the code under a single parent folder.',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
for (const p of paths) {
|
|
228
|
+
declaredPaths.push({
|
|
229
|
+
namespace: namespaceNode.namespace.name,
|
|
230
|
+
nodeId: namespaceNode.id,
|
|
231
|
+
path: p,
|
|
232
|
+
});
|
|
233
|
+
// Warn when a declared path does not exist relative to the repo root.
|
|
234
|
+
const resolved = (0, path_1.resolve)(basePath, p);
|
|
235
|
+
if (!(0, fs_1.existsSync)(resolved)) {
|
|
236
|
+
violations.push({
|
|
237
|
+
ruleId: 'events-namespace-paths-missing',
|
|
238
|
+
severity: 'warn',
|
|
239
|
+
file: eventsCanvasPath || '.principal-views/cli.events.canvas',
|
|
240
|
+
path: `nodes[id="${namespaceNode.id}"].namespace.paths`,
|
|
241
|
+
message: `Path "${p}" declared by namespace "${namespaceNode.namespace.name}" does not exist`,
|
|
242
|
+
impact: 'Events emitted under this namespace cannot be validated against a real code location',
|
|
243
|
+
suggestion: 'Verify the path exists relative to the repository root, or remove it from the namespace declaration.',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Cross-namespace overlap check. Parent-child nesting is a valid partition
|
|
249
|
+
// (longest-prefix wins at runtime); any other overlap makes namespace
|
|
250
|
+
// ownership of a file ambiguous.
|
|
251
|
+
for (let i = 0; i < declaredPaths.length; i++) {
|
|
252
|
+
for (let j = i + 1; j < declaredPaths.length; j++) {
|
|
253
|
+
const a = declaredPaths[i];
|
|
254
|
+
const b = declaredPaths[j];
|
|
255
|
+
if (a.namespace === b.namespace)
|
|
256
|
+
continue;
|
|
257
|
+
const relationship = (0, path_helpers_1.pathsOverlap)(a.path, b.path);
|
|
258
|
+
if (relationship === 'conflict') {
|
|
259
|
+
violations.push({
|
|
260
|
+
ruleId: 'events-namespace-paths-overlap',
|
|
261
|
+
severity: 'error',
|
|
262
|
+
file: eventsCanvasPath || '.principal-views/cli.events.canvas',
|
|
263
|
+
message: `Paths overlap between namespaces "${a.namespace}" ("${a.path}") and "${b.namespace}" ("${b.path}")`,
|
|
264
|
+
impact: 'A file covered by two namespaces makes namespace ownership ambiguous',
|
|
265
|
+
suggestion: 'Separate the paths so they are disjoint, or restructure as parent/child namespaces (e.g., "workflow" covering "src/workflow" and "workflow.scenarios" covering "src/workflow/scenarios").',
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
200
270
|
metrics.totalNamespaces = extractedNamespaces.size;
|
|
201
271
|
const errors = violations.filter(v => v.severity === 'error');
|
|
202
272
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventsCanvasValidator.js","sourceRoot":"","sources":["../../src/events/EventsCanvasValidator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"EventsCanvasValidator.js","sourceRoot":"","sources":["../../src/events/EventsCanvasValidator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2BAAgC;AAChC,+BAA+B;AAC/B,iDAA8C;AAoH9C;;GAEG;AACH,MAAa,qBAAqB;IAChC;;;;;;;OAOG;IACK,gBAAgB,CAAC,SAAiB;QACxC,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,Q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AAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACjD,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC3B,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;oBAAE,SAAS;gBAE1C,MAAM,YAAY,GAAG,IAAA,2BAAY,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClD,IAAI,YAAY,KAAK,UAAU,EAAE;oBAC/B,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gCAAgC;wBACxC,QAAQ,EAAE,OAAO;wBACjB,IAAI,EAAE,gBAAgB,IAAI,oCAAoC;wBAC9D,OAAO,EAAE,qCAAqC,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,IAAI,IAAI;wBAC7G,MAAM,EAAE,sEAAsE;wBAC9E,UAAU,EAAE,2LAA2L;qBACxM,CAAC,CAAC;iBACJ;aACF;SACF;QAED,OAAO,CAAC,eAAe,GAAG,mBAAmB,CAAC,IAAI,CAAC;QAEnD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAE9D,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,UAAU;YACV,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAzSD,sDAySC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Namespace Path Index
|
|
3
|
+
*
|
|
4
|
+
* Maps (scope, filepath) to the event-namespace that owns the file, using the
|
|
5
|
+
* `paths` field declared on `event-namespace` nodes.
|
|
6
|
+
*
|
|
7
|
+
* Resolution uses the longest-prefix partitioning rule: when multiple
|
|
8
|
+
* namespaces within a scope have paths that cover the same file, the one
|
|
9
|
+
* whose matched path is the most specific (longest after normalization) wins.
|
|
10
|
+
* This naturally supports nested namespaces such as `workflow` and
|
|
11
|
+
* `workflow.scenarios`, where the child claims its subtree without stealing
|
|
12
|
+
* the parent's.
|
|
13
|
+
*
|
|
14
|
+
* Pure/browser-safe — no filesystem access, just string comparison.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* One declared namespace/paths tuple, tagged with the scope it belongs to.
|
|
18
|
+
* Multiple entries may share the same scope (different namespaces in the
|
|
19
|
+
* same events canvas) or the same namespace across scopes (no cross-scope
|
|
20
|
+
* conflict — resolution is scoped).
|
|
21
|
+
*/
|
|
22
|
+
export interface NamespacePathEntry {
|
|
23
|
+
scope: string;
|
|
24
|
+
namespace: string;
|
|
25
|
+
paths: string[];
|
|
26
|
+
/** Optional — useful for surfacing where a match came from in diagnostics. */
|
|
27
|
+
sourceCanvasPath?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Result of resolving a file against the index.
|
|
31
|
+
*/
|
|
32
|
+
export interface NamespacePathMatch {
|
|
33
|
+
/** The winning entry (by longest-prefix). */
|
|
34
|
+
entry: NamespacePathEntry;
|
|
35
|
+
/** Which of the entry's paths covered the file — the one that won. */
|
|
36
|
+
matchedPath: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class NamespacePathIndex {
|
|
39
|
+
private entries;
|
|
40
|
+
/** Register a single namespace/paths entry. */
|
|
41
|
+
add(entry: NamespacePathEntry): void;
|
|
42
|
+
/** Register many entries at once. */
|
|
43
|
+
addAll(entries: readonly NamespacePathEntry[]): void;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a filepath to its owning namespace within a scope.
|
|
46
|
+
* Returns null if no entry in that scope has a path covering the file.
|
|
47
|
+
*/
|
|
48
|
+
resolve(scope: string, filepath: string): NamespacePathMatch | null;
|
|
49
|
+
/** All entries registered under the given scope (for diagnostics). */
|
|
50
|
+
getScopeEntries(scope: string): readonly NamespacePathEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Look up the entry for a specific (scope, namespace) pair. Returns null
|
|
53
|
+
* when the namespace isn't registered — either because its events-canvas
|
|
54
|
+
* node omits `paths` (opt-out of enforcement) or because no such namespace
|
|
55
|
+
* is declared at all.
|
|
56
|
+
*/
|
|
57
|
+
getEntry(scope: string, namespace: string): NamespacePathEntry | null;
|
|
58
|
+
/** All scopes present in the index. */
|
|
59
|
+
getScopes(): readonly string[];
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=NamespacePathIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamespacePathIndex.d.ts","sourceRoot":"","sources":["../../src/events/NamespacePathIndex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,KAAK,EAAE,kBAAkB,CAAC;IAC1B,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAA4B;IAE3C,+CAA+C;IAC/C,GAAG,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAIpC,qCAAqC;IACrC,MAAM,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI;IAIpD;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IAmBnE,sEAAsE;IACtE,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE;IAI7D;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IAMrE,uCAAuC;IACvC,SAAS,IAAI,SAAS,MAAM,EAAE;CAG/B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Namespace Path Index
|
|
4
|
+
*
|
|
5
|
+
* Maps (scope, filepath) to the event-namespace that owns the file, using the
|
|
6
|
+
* `paths` field declared on `event-namespace` nodes.
|
|
7
|
+
*
|
|
8
|
+
* Resolution uses the longest-prefix partitioning rule: when multiple
|
|
9
|
+
* namespaces within a scope have paths that cover the same file, the one
|
|
10
|
+
* whose matched path is the most specific (longest after normalization) wins.
|
|
11
|
+
* This naturally supports nested namespaces such as `workflow` and
|
|
12
|
+
* `workflow.scenarios`, where the child claims its subtree without stealing
|
|
13
|
+
* the parent's.
|
|
14
|
+
*
|
|
15
|
+
* Pure/browser-safe — no filesystem access, just string comparison.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.NamespacePathIndex = void 0;
|
|
19
|
+
const path_helpers_1 = require("./path-helpers");
|
|
20
|
+
class NamespacePathIndex {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.entries = [];
|
|
23
|
+
}
|
|
24
|
+
/** Register a single namespace/paths entry. */
|
|
25
|
+
add(entry) {
|
|
26
|
+
this.entries.push(entry);
|
|
27
|
+
}
|
|
28
|
+
/** Register many entries at once. */
|
|
29
|
+
addAll(entries) {
|
|
30
|
+
for (const e of entries)
|
|
31
|
+
this.add(e);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a filepath to its owning namespace within a scope.
|
|
35
|
+
* Returns null if no entry in that scope has a path covering the file.
|
|
36
|
+
*/
|
|
37
|
+
resolve(scope, filepath) {
|
|
38
|
+
const normalizedFile = (0, path_helpers_1.normalizePath)(filepath);
|
|
39
|
+
let best = null;
|
|
40
|
+
for (const entry of this.entries) {
|
|
41
|
+
if (entry.scope !== scope)
|
|
42
|
+
continue;
|
|
43
|
+
for (const declared of entry.paths) {
|
|
44
|
+
if (!(0, path_helpers_1.pathCovers)(declared, normalizedFile))
|
|
45
|
+
continue;
|
|
46
|
+
const normalizedDeclared = (0, path_helpers_1.normalizePath)(declared);
|
|
47
|
+
const length = normalizedDeclared.length;
|
|
48
|
+
if (best === null || length > best.length) {
|
|
49
|
+
best = { entry, matchedPath: declared, length };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return best ? { entry: best.entry, matchedPath: best.matchedPath } : null;
|
|
54
|
+
}
|
|
55
|
+
/** All entries registered under the given scope (for diagnostics). */
|
|
56
|
+
getScopeEntries(scope) {
|
|
57
|
+
return this.entries.filter((e) => e.scope === scope);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Look up the entry for a specific (scope, namespace) pair. Returns null
|
|
61
|
+
* when the namespace isn't registered — either because its events-canvas
|
|
62
|
+
* node omits `paths` (opt-out of enforcement) or because no such namespace
|
|
63
|
+
* is declared at all.
|
|
64
|
+
*/
|
|
65
|
+
getEntry(scope, namespace) {
|
|
66
|
+
return this.entries.find((e) => e.scope === scope && e.namespace === namespace) ?? null;
|
|
67
|
+
}
|
|
68
|
+
/** All scopes present in the index. */
|
|
69
|
+
getScopes() {
|
|
70
|
+
return Array.from(new Set(this.entries.map((e) => e.scope)));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.NamespacePathIndex = NamespacePathIndex;
|
|
74
|
+
//# sourceMappingURL=NamespacePathIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamespacePathIndex.js","sourceRoot":"","sources":["../../src/events/NamespacePathIndex.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAA2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AAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,KAAa,EAAE,SAAiB;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,CACtD,IAAI,IAAI,CAAC;IACZ,CAAC;IAED,uCAAuC;IACvC,SAAS;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AAzDD,gDAyDC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTEL Event Paths Validator (Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* Cross-canvas static check. For every `otel-event` node in an OTEL canvas,
|
|
5
|
+
* cross-reference each entry in `otel.files` against the `paths` declared on
|
|
6
|
+
* the event's namespace in the corresponding events canvas.
|
|
7
|
+
*
|
|
8
|
+
* Enforcement is opt-in per namespace: a namespace without `paths` (or a
|
|
9
|
+
* namespace not declared at all) produces no violations for its events.
|
|
10
|
+
*
|
|
11
|
+
* Pure/browser-safe — no filesystem access.
|
|
12
|
+
*/
|
|
13
|
+
import type { ExtendedCanvas } from '../types/canvas';
|
|
14
|
+
/**
|
|
15
|
+
* One events canvas, pre-paired with the scope it owns. Scope pairing is
|
|
16
|
+
* typically derived via the existing scope → filename convention
|
|
17
|
+
* (e.g., scope `principal-view.cli` owns `principal-view-cli.events.canvas`).
|
|
18
|
+
*/
|
|
19
|
+
export interface EventsCanvasInput {
|
|
20
|
+
canvas: ExtendedCanvas;
|
|
21
|
+
canvasPath: string;
|
|
22
|
+
scope: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One OTEL canvas whose `otel-event` nodes we want to cross-check.
|
|
26
|
+
*/
|
|
27
|
+
export interface OtelCanvasInput {
|
|
28
|
+
canvas: ExtendedCanvas;
|
|
29
|
+
canvasPath: string;
|
|
30
|
+
}
|
|
31
|
+
export interface OtelEventPathsValidationContext {
|
|
32
|
+
eventsCanvases: EventsCanvasInput[];
|
|
33
|
+
otelCanvases: OtelCanvasInput[];
|
|
34
|
+
}
|
|
35
|
+
export type OtelEventPathsRuleId = 'events-otel-files-wrong-namespace' | 'events-otel-files-orphan';
|
|
36
|
+
export interface OtelEventPathsViolation {
|
|
37
|
+
ruleId: OtelEventPathsRuleId;
|
|
38
|
+
severity: 'error' | 'warn';
|
|
39
|
+
file: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
message: string;
|
|
42
|
+
impact: string;
|
|
43
|
+
suggestion: string;
|
|
44
|
+
}
|
|
45
|
+
export interface OtelEventPathsValidationResult {
|
|
46
|
+
valid: boolean;
|
|
47
|
+
violations: OtelEventPathsViolation[];
|
|
48
|
+
metrics: {
|
|
49
|
+
/** Events whose files were cross-checked against namespace paths. */
|
|
50
|
+
eventsChecked: number;
|
|
51
|
+
/** Total files examined across all checked events. */
|
|
52
|
+
filesChecked: number;
|
|
53
|
+
/**
|
|
54
|
+
* Events skipped because the event's namespace has no `paths` declared
|
|
55
|
+
* (or is not declared at all) — enforcement is opt-in per namespace.
|
|
56
|
+
*/
|
|
57
|
+
eventsSkippedNoPaths: number;
|
|
58
|
+
/**
|
|
59
|
+
* Events skipped because the `otel-event` node declares no `otel.files`.
|
|
60
|
+
* These events have no claimed implementation location to cross-check.
|
|
61
|
+
*/
|
|
62
|
+
eventsSkippedNoFiles: number;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export declare class OtelEventPathsValidator {
|
|
66
|
+
/**
|
|
67
|
+
* Build a path index from the events canvases, keyed by scope.
|
|
68
|
+
* Only namespaces that declare `paths` contribute entries.
|
|
69
|
+
*/
|
|
70
|
+
private buildIndex;
|
|
71
|
+
/** Extract the namespace from an event name (all segments except the last). */
|
|
72
|
+
private extractNamespace;
|
|
73
|
+
validate(context: OtelEventPathsValidationContext): OtelEventPathsValidationResult;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=OtelEventPathsValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtelEventPathsValidator.d.ts","sourceRoot":"","sources":["../../src/events/OtelEventPathsValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,iBAAiB,CAAC;AAIrE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC;AAED,MAAM,MAAM,oBAAoB,GAC5B,mCAAmC,GACnC,0BAA0B,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,uBAAuB,EAAE,CAAC;IACtC,OAAO,EAAE;QACP,qEAAqE;QACrE,aAAa,EAAE,MAAM,CAAC;QACtB,sDAAsD;QACtD,YAAY,EAAE,MAAM,CAAC;QACrB;;;WAGG;QACH,oBAAoB,EAAE,MAAM,CAAC;QAC7B;;;WAGG;QACH,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED,qBAAa,uBAAuB;IAClC;;;OAGG;IACH,OAAO,CAAC,UAAU;IAqBlB,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;IAMxB,QAAQ,CAAC,OAAO,EAAE,+BAA+B,GAAG,8BAA8B;CAiFnF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OTEL Event Paths Validator (Phase 2)
|
|
4
|
+
*
|
|
5
|
+
* Cross-canvas static check. For every `otel-event` node in an OTEL canvas,
|
|
6
|
+
* cross-reference each entry in `otel.files` against the `paths` declared on
|
|
7
|
+
* the event's namespace in the corresponding events canvas.
|
|
8
|
+
*
|
|
9
|
+
* Enforcement is opt-in per namespace: a namespace without `paths` (or a
|
|
10
|
+
* namespace not declared at all) produces no violations for its events.
|
|
11
|
+
*
|
|
12
|
+
* Pure/browser-safe — no filesystem access.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OtelEventPathsValidator = void 0;
|
|
16
|
+
const canvas_1 = require("../types/canvas");
|
|
17
|
+
const NamespacePathIndex_1 = require("./NamespacePathIndex");
|
|
18
|
+
class OtelEventPathsValidator {
|
|
19
|
+
/**
|
|
20
|
+
* Build a path index from the events canvases, keyed by scope.
|
|
21
|
+
* Only namespaces that declare `paths` contribute entries.
|
|
22
|
+
*/
|
|
23
|
+
buildIndex(eventsCanvases) {
|
|
24
|
+
const index = new NamespacePathIndex_1.NamespacePathIndex();
|
|
25
|
+
for (const ec of eventsCanvases) {
|
|
26
|
+
for (const node of ec.canvas.nodes || []) {
|
|
27
|
+
if (node?.type !== 'event-namespace')
|
|
28
|
+
continue;
|
|
29
|
+
const ns = node.namespace;
|
|
30
|
+
if (!ns || typeof ns.name !== 'string')
|
|
31
|
+
continue;
|
|
32
|
+
if (!Array.isArray(ns.paths) || ns.paths.length === 0)
|
|
33
|
+
continue;
|
|
34
|
+
const entry = {
|
|
35
|
+
scope: ec.scope,
|
|
36
|
+
namespace: ns.name,
|
|
37
|
+
paths: ns.paths,
|
|
38
|
+
sourceCanvasPath: ec.canvasPath,
|
|
39
|
+
};
|
|
40
|
+
index.add(entry);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return index;
|
|
44
|
+
}
|
|
45
|
+
/** Extract the namespace from an event name (all segments except the last). */
|
|
46
|
+
extractNamespace(eventName) {
|
|
47
|
+
const segments = eventName.split('.');
|
|
48
|
+
if (segments.length < 2)
|
|
49
|
+
return null;
|
|
50
|
+
return segments.slice(0, -1).join('.');
|
|
51
|
+
}
|
|
52
|
+
validate(context) {
|
|
53
|
+
const violations = [];
|
|
54
|
+
const metrics = {
|
|
55
|
+
eventsChecked: 0,
|
|
56
|
+
filesChecked: 0,
|
|
57
|
+
eventsSkippedNoPaths: 0,
|
|
58
|
+
eventsSkippedNoFiles: 0,
|
|
59
|
+
};
|
|
60
|
+
const index = this.buildIndex(context.eventsCanvases);
|
|
61
|
+
for (const oc of context.otelCanvases) {
|
|
62
|
+
for (const node of oc.canvas.nodes || []) {
|
|
63
|
+
if (!(0, canvas_1.isOtelEventNode)(node))
|
|
64
|
+
continue;
|
|
65
|
+
const eventNode = node;
|
|
66
|
+
const eventName = eventNode.event?.name;
|
|
67
|
+
const scope = eventNode.otel?.scope;
|
|
68
|
+
const files = eventNode.otel?.files;
|
|
69
|
+
if (!eventName || !scope)
|
|
70
|
+
continue; // malformed — other validators catch this
|
|
71
|
+
const namespace = this.extractNamespace(eventName);
|
|
72
|
+
if (!namespace)
|
|
73
|
+
continue; // invalid event name — caught by other validators
|
|
74
|
+
if (!files || files.length === 0) {
|
|
75
|
+
metrics.eventsSkippedNoFiles++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
// Enforcement is opt-in: if the event's namespace has no declared
|
|
79
|
+
// paths (or isn't declared at all), we don't check its files.
|
|
80
|
+
const eventEntry = index.getEntry(scope, namespace);
|
|
81
|
+
if (!eventEntry) {
|
|
82
|
+
metrics.eventsSkippedNoPaths++;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
metrics.eventsChecked++;
|
|
86
|
+
for (const file of files) {
|
|
87
|
+
metrics.filesChecked++;
|
|
88
|
+
const match = index.resolve(scope, file);
|
|
89
|
+
if (match === null) {
|
|
90
|
+
violations.push({
|
|
91
|
+
ruleId: 'events-otel-files-orphan',
|
|
92
|
+
severity: 'warn',
|
|
93
|
+
file: oc.canvasPath,
|
|
94
|
+
path: `nodes[id="${eventNode.id}"].otel.files["${file}"]`,
|
|
95
|
+
message: `Event "${eventName}" declares file "${file}" which is not covered by any namespace's paths in scope "${scope}"`,
|
|
96
|
+
impact: 'The file emits an event but has no declared component home, so its location cannot be validated against namespace conventions.',
|
|
97
|
+
suggestion: `Either add "${file}" (or an ancestor folder) to the "paths" of the "${namespace}" namespace in the events canvas, or move the implementation into one of the namespace's declared paths: ${eventEntry.paths.map((p) => `"${p}"`).join(', ')}.`,
|
|
98
|
+
});
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (match.entry.namespace === namespace) {
|
|
102
|
+
// File belongs to the event's namespace (longest-prefix match).
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
violations.push({
|
|
106
|
+
ruleId: 'events-otel-files-wrong-namespace',
|
|
107
|
+
severity: 'error',
|
|
108
|
+
file: oc.canvasPath,
|
|
109
|
+
path: `nodes[id="${eventNode.id}"].otel.files["${file}"]`,
|
|
110
|
+
message: `Event "${eventName}" declares file "${file}", but namespace "${match.entry.namespace}" (path "${match.matchedPath}") owns that location — not "${namespace}"`,
|
|
111
|
+
impact: 'Event identity disagrees with code location. Consumers discovering the event by name will land in a folder that belongs to a different namespace.',
|
|
112
|
+
suggestion: `Either rename the event to start with "${match.entry.namespace}." (if the code placement is correct), or move the implementation into one of the "${namespace}" namespace's declared paths (${eventEntry.paths.map((p) => `"${p}"`).join(', ')}).`,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const errors = violations.filter((v) => v.severity === 'error');
|
|
118
|
+
return {
|
|
119
|
+
valid: errors.length === 0,
|
|
120
|
+
violations,
|
|
121
|
+
metrics,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.OtelEventPathsValidator = OtelEventPathsValidator;
|
|
126
|
+
//# sourceMappingURL=OtelEventPathsValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtelEventPathsValidator.js","sourceRoot":"","sources":["../../src/events/OtelEventPathsValidator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAGH,4CAAkD;AAClD,6DAAmF;AA6DnF,MAAa,uBAAuB;IAClC;;;OAGG;IACK,UAAU,CAAC,cAAmC;QACpD,MAAM,KAAK,GAAG,IAAI,uCAAkB,EAAE,CAAC;QACvC,KAAK,MAAM,EAAE,IAAI,cAAc,EAAE;YAC/B,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE;gBACxC,IAAK,IAAY,EAAE,IAAI,KAAK,iBAAiB;oBAAE,SAAS;gBACxD,MAAM,EAAE,GAAI,IAAY,CAAC,SAAS,CAAC;gBACnC,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,CAAC,IAAI,KAAK,QAAQ;oBAAE,SAAS;gBACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;oBAAE,SAAS;gBAEhE,MAAM,KAAK,GAAuB;oB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BAC5P,CAAC,CAAC;wBACH,SAAS;qBACV;oBAED,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE;wBACvC,gEAAgE;wBAChE,SAAS;qBACV;oBAED,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,mCAAmC;wBAC3C,QAAQ,EAAE,OAAO;wBACjB,IAAI,EAAE,EAAE,CAAC,UAAU;wBACnB,IAAI,EAAE,aAAa,SAAS,CAAC,EAAE,kBAAkB,IAAI,IAAI;wBACzD,OAAO,EAAE,UAAU,SAAS,oBAAoB,IAAI,qBAAqB,KAAK,CAAC,KAAK,CAAC,SAAS,YAAY,KAAK,CAAC,WAAW,gCAAgC,SAAS,GAAG;wBACvK,MAAM,EAAE,mJAAmJ;wBAC3J,UAAU,EAAE,0CAA0C,KAAK,CAAC,KAAK,CAAC,SAAS,sFAAsF,SAAS,iCAAiC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;qBAChQ,CAAC,CAAC;iBACJ;aACF;SACF;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAChE,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,UAAU;YACV,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAlHD,0DAkHC"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ export { EventsCanvasValidator } from './EventsCanvasValidator';
|
|
|
2
2
|
export type { EventNamespaceNode, EventsCanvasValidationContext, EventsCanvasViolation, EventsCanvasValidationResult, } from './EventsCanvasValidator';
|
|
3
3
|
export { ScopeEventsValidator } from './ScopeEventsValidator';
|
|
4
4
|
export type { ScopeEventsValidationContext, ScopeEventsViolation, ScopeEventsValidationResult, } from './ScopeEventsValidator';
|
|
5
|
+
export { NamespacePathIndex } from './NamespacePathIndex';
|
|
6
|
+
export type { NamespacePathEntry, NamespacePathMatch } from './NamespacePathIndex';
|
|
7
|
+
export { OtelEventPathsValidator } from './OtelEventPathsValidator';
|
|
8
|
+
export type { OtelEventPathsValidationContext, OtelEventPathsValidationResult, OtelEventPathsViolation, OtelEventPathsRuleId, EventsCanvasInput, OtelCanvasInput, } from './OtelEventPathsValidator';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC"}
|
package/dist/events/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScopeEventsValidator = exports.EventsCanvasValidator = void 0;
|
|
3
|
+
exports.OtelEventPathsValidator = exports.NamespacePathIndex = exports.ScopeEventsValidator = exports.EventsCanvasValidator = void 0;
|
|
4
4
|
var EventsCanvasValidator_1 = require("./EventsCanvasValidator");
|
|
5
5
|
Object.defineProperty(exports, "EventsCanvasValidator", { enumerable: true, get: function () { return EventsCanvasValidator_1.EventsCanvasValidator; } });
|
|
6
6
|
var ScopeEventsValidator_1 = require("./ScopeEventsValidator");
|
|
7
7
|
Object.defineProperty(exports, "ScopeEventsValidator", { enumerable: true, get: function () { return ScopeEventsValidator_1.ScopeEventsValidator; } });
|
|
8
|
+
var NamespacePathIndex_1 = require("./NamespacePathIndex");
|
|
9
|
+
Object.defineProperty(exports, "NamespacePathIndex", { enumerable: true, get: function () { return NamespacePathIndex_1.NamespacePathIndex; } });
|
|
10
|
+
var OtelEventPathsValidator_1 = require("./OtelEventPathsValidator");
|
|
11
|
+
Object.defineProperty(exports, "OtelEventPathsValidator", { enumerable: true, get: function () { return OtelEventPathsValidator_1.OtelEventPathsValidator; } });
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAQ9B,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAQ9B,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAO7B,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAG3B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path helpers shared across events-canvas validators.
|
|
3
|
+
*
|
|
4
|
+
* Paths declared in canvases (namespace `paths`, `otel.files`, etc.) are
|
|
5
|
+
* always repo-relative. These helpers give a consistent notion of
|
|
6
|
+
* canonicalization and prefix-based containment so that separate validators
|
|
7
|
+
* don't drift.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Canonicalize a declared path for comparison.
|
|
11
|
+
* Strips leading `./`, trailing slashes, and collapses duplicate slashes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizePath(p: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* True when `child` is strictly nested under `parent` (not equal).
|
|
16
|
+
* Both inputs should already be normalized.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isPathDescendant(child: string, parent: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* True when `filepath` is covered by `declaredPath` — either equal to it
|
|
21
|
+
* (file match) or nested under it (folder match). Inputs are normalized
|
|
22
|
+
* internally so callers can pass raw canvas values.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pathCovers(declaredPath: string, filepath: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Classify the relationship between two declared paths.
|
|
27
|
+
* - 'none': disjoint — no overlap
|
|
28
|
+
* - 'partition': one is strictly a parent of the other — valid nested-namespace case
|
|
29
|
+
* (longest-prefix wins at runtime, parent/child partition the tree)
|
|
30
|
+
* - 'conflict': identical, or overlap that isn't a clean parent-child partition
|
|
31
|
+
*/
|
|
32
|
+
export declare function pathsOverlap(a: string, b: string): 'none' | 'partition' | 'conflict';
|
|
33
|
+
//# sourceMappingURL=path-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-helpers.d.ts","sourceRoot":"","sources":["../../src/events/path-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI1E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAMpF"}
|