@principal-ai/principal-view-core 0.24.16 → 0.24.17
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/discovery/LibraryDiscovery.d.ts +20 -2
- package/dist/discovery/LibraryDiscovery.d.ts.map +1 -1
- package/dist/discovery/LibraryDiscovery.js +37 -11
- package/dist/discovery/LibraryDiscovery.js.map +1 -1
- package/dist/registry/LocalRegistry.d.ts +10 -8
- package/dist/registry/LocalRegistry.d.ts.map +1 -1
- package/dist/registry/LocalRegistry.js +62 -30
- package/dist/registry/LocalRegistry.js.map +1 -1
- package/dist/types/library.d.ts +19 -1
- package/dist/types/library.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/discovery/LibraryDiscovery.ts +68 -11
- package/src/registry/LocalRegistry.ts +70 -31
- package/src/types/library.ts +20 -1
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { FileTree, FileSystemAdapter } from '@principal-ai/repository-abstraction';
|
|
8
8
|
import type { ComponentLibrary } from '../types/library';
|
|
9
|
+
/**
|
|
10
|
+
* Service with its owned scopes
|
|
11
|
+
*/
|
|
12
|
+
export interface ServiceWithScopes {
|
|
13
|
+
/** Service name (from service.name attribute) */
|
|
14
|
+
serviceName: string;
|
|
15
|
+
/** Instrumentation scopes owned by this service */
|
|
16
|
+
ownedScopes: string[];
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Discovered library with metadata
|
|
11
20
|
*/
|
|
@@ -20,6 +29,8 @@ export interface DiscoveredLibrary {
|
|
|
20
29
|
library: ComponentLibrary;
|
|
21
30
|
/** Service names from this library's resources */
|
|
22
31
|
serviceNames: string[];
|
|
32
|
+
/** Services with their owned scopes */
|
|
33
|
+
servicesWithScopes: ServiceWithScopes[];
|
|
23
34
|
}
|
|
24
35
|
/**
|
|
25
36
|
* Result of library discovery
|
|
@@ -29,6 +40,13 @@ export interface LibraryDiscoveryResult {
|
|
|
29
40
|
libraries: DiscoveredLibrary[];
|
|
30
41
|
/** All service names across all libraries */
|
|
31
42
|
allServiceNames: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Mapping from instrumentation scope name to owning service name
|
|
45
|
+
*
|
|
46
|
+
* Used to route spans from owned scopes to the correct service's storyboards.
|
|
47
|
+
* For example: { "auth-me": "web-ade", "checkout": "web-ade" }
|
|
48
|
+
*/
|
|
49
|
+
scopeToServiceMap: Map<string, string>;
|
|
32
50
|
/** Errors encountered during discovery */
|
|
33
51
|
errors: Array<{
|
|
34
52
|
path: string;
|
|
@@ -70,9 +88,9 @@ export declare class LibraryDiscovery {
|
|
|
70
88
|
*/
|
|
71
89
|
clearCache(): void;
|
|
72
90
|
/**
|
|
73
|
-
* Extract service names from a library's resources
|
|
91
|
+
* Extract service names and owned scopes from a library's resources
|
|
74
92
|
*/
|
|
75
|
-
private
|
|
93
|
+
private extractServicesInfo;
|
|
76
94
|
/**
|
|
77
95
|
* Discover packages with caching by fileTree SHA
|
|
78
96
|
*/
|
|
@@ -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;AAEzD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IAEpB,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,6BAA6B;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAE1B,kDAAkD;IAClD,YAAY,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"LibraryDiscovery.d.ts","sourceRoot":"","sources":["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AM,CAAgB;gBAEV,SAAS,EAAE,iBAAiB;IAKhD;;;;;;;OAOG;IACG,QAAQ,CACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;KAChD,GACA,OAAO,CAAC,sBAAsB,CAAC;IAgHlC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA6B3B;;OAEG;YACW,yBAAyB;CAexC"}
|
|
@@ -54,14 +54,15 @@ class LibraryDiscovery {
|
|
|
54
54
|
// Try to load library from this package
|
|
55
55
|
const loadResult = await this.loader.load(pkg.packageData.path);
|
|
56
56
|
if (loadResult.success && loadResult.library) {
|
|
57
|
-
// Extract service names from resources
|
|
58
|
-
const serviceNames = this.
|
|
57
|
+
// Extract service names and owned scopes from resources
|
|
58
|
+
const { serviceNames, servicesWithScopes } = this.extractServicesInfo(loadResult.library);
|
|
59
59
|
libraries.push({
|
|
60
60
|
path: loadResult.path,
|
|
61
61
|
packageName: pkg.packageData.name,
|
|
62
62
|
packagePath: pkg.packageData.path,
|
|
63
63
|
library: loadResult.library,
|
|
64
64
|
serviceNames,
|
|
65
|
+
servicesWithScopes,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
else if (loadResult.error && !loadResult.error.includes('No library file found')) {
|
|
@@ -86,7 +87,7 @@ class LibraryDiscovery {
|
|
|
86
87
|
if (hasRootLibrary) {
|
|
87
88
|
const loadResult = await this.loader.load(rootPath);
|
|
88
89
|
if (loadResult.success && loadResult.library) {
|
|
89
|
-
const serviceNames = this.
|
|
90
|
+
const { serviceNames, servicesWithScopes } = this.extractServicesInfo(loadResult.library);
|
|
90
91
|
// Check if we already loaded this from a package
|
|
91
92
|
const alreadyLoaded = libraries.some(lib => lib.path === loadResult.path);
|
|
92
93
|
if (!alreadyLoaded) {
|
|
@@ -96,6 +97,7 @@ class LibraryDiscovery {
|
|
|
96
97
|
packagePath: rootPath,
|
|
97
98
|
library: loadResult.library,
|
|
98
99
|
serviceNames,
|
|
100
|
+
servicesWithScopes,
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -112,11 +114,24 @@ class LibraryDiscovery {
|
|
|
112
114
|
}
|
|
113
115
|
// 4. Collect all service names
|
|
114
116
|
const allServiceNames = libraries.flatMap(lib => lib.serviceNames);
|
|
115
|
-
// 5.
|
|
117
|
+
// 5. Build scope to service mapping
|
|
118
|
+
const scopeToServiceMap = new Map();
|
|
119
|
+
for (const lib of libraries) {
|
|
120
|
+
for (const service of lib.servicesWithScopes) {
|
|
121
|
+
// Map the service name to itself (service names are also valid scope names)
|
|
122
|
+
scopeToServiceMap.set(service.serviceName, service.serviceName);
|
|
123
|
+
// Map each owned scope to its owning service
|
|
124
|
+
for (const scope of service.ownedScopes) {
|
|
125
|
+
scopeToServiceMap.set(scope, service.serviceName);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// 6. Sort libraries by package name
|
|
116
130
|
libraries.sort((a, b) => a.packageName.localeCompare(b.packageName));
|
|
117
131
|
return {
|
|
118
132
|
libraries,
|
|
119
133
|
allServiceNames,
|
|
134
|
+
scopeToServiceMap,
|
|
120
135
|
errors,
|
|
121
136
|
};
|
|
122
137
|
}
|
|
@@ -127,16 +142,27 @@ class LibraryDiscovery {
|
|
|
127
142
|
this.packageCache.clear();
|
|
128
143
|
}
|
|
129
144
|
/**
|
|
130
|
-
* Extract service names from a library's resources
|
|
145
|
+
* Extract service names and owned scopes from a library's resources
|
|
131
146
|
*/
|
|
132
|
-
|
|
147
|
+
extractServicesInfo(library) {
|
|
133
148
|
if (!library.resources) {
|
|
134
|
-
return [];
|
|
149
|
+
return { serviceNames: [], servicesWithScopes: [] };
|
|
150
|
+
}
|
|
151
|
+
const serviceNames = [];
|
|
152
|
+
const servicesWithScopes = [];
|
|
153
|
+
for (const attrs of Object.values(library.resources)) {
|
|
154
|
+
const serviceName = attrs['service.name'];
|
|
155
|
+
if (!serviceName)
|
|
156
|
+
continue;
|
|
157
|
+
serviceNames.push(serviceName);
|
|
158
|
+
// Extract owned-scopes (defaults to empty array)
|
|
159
|
+
const ownedScopes = attrs['owned-scopes'] || [];
|
|
160
|
+
servicesWithScopes.push({
|
|
161
|
+
serviceName,
|
|
162
|
+
ownedScopes: Array.isArray(ownedScopes) ? ownedScopes : [],
|
|
163
|
+
});
|
|
135
164
|
}
|
|
136
|
-
|
|
137
|
-
return Object.values(library.resources)
|
|
138
|
-
.map(attrs => attrs['service.name'])
|
|
139
|
-
.filter((name) => !!name);
|
|
165
|
+
return { serviceNames, servicesWithScopes };
|
|
140
166
|
}
|
|
141
167
|
/**
|
|
142
168
|
* Discover packages with caching by fileTree SHA
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibraryDiscovery.js","sourceRoot":"","sources":["../../src/discovery/LibraryDiscovery.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6EAA2F;AAC3F,oDAAiD;
|
|
1
|
+
{"version":3,"file":"LibraryDiscovery.js","sourceRoot":"","sources":["../../src/discovery/LibraryDiscovery.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6EAA2F;AAC3F,oDAAiD;AA2DjD;;;;;;;;;;;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;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ,CACZ,QAAkB,EAClB,OAEC;QAED,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAA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export declare class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
32
32
|
/**
|
|
33
33
|
* Register a local workspace
|
|
34
34
|
*
|
|
35
|
-
* Auto-discovers
|
|
36
|
-
* Each service in resources with a service.name becomes a scope
|
|
35
|
+
* Auto-discovers service names and owned scopes from library.yaml resources section.
|
|
36
|
+
* Each service in resources with a service.name becomes a registered scope.
|
|
37
|
+
* Additionally, owned-scopes from each service are mapped to their owning service.
|
|
37
38
|
*
|
|
38
39
|
* File watching should be handled externally. When .principal-views files change,
|
|
39
40
|
* call invalidateCache(scopeName) to rebuild the snapshot.
|
|
40
41
|
*
|
|
41
42
|
* @param fileTree - FileTree for the workspace
|
|
42
|
-
* @returns Array of
|
|
43
|
+
* @returns Array of all registered scope names (services + owned scopes)
|
|
43
44
|
*/
|
|
44
45
|
registerWorkspace(fileTree: FileTree): Promise<string[]>;
|
|
45
46
|
/**
|
|
@@ -54,15 +55,15 @@ export declare class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
54
55
|
attributes?: Record<string, unknown>;
|
|
55
56
|
}): Promise<VersionSnapshot | null>;
|
|
56
57
|
/**
|
|
57
|
-
* Auto-discover
|
|
58
|
+
* Auto-discover service names and owned scopes from library.yaml files
|
|
58
59
|
*
|
|
59
60
|
* Uses LibraryDiscovery to find all library.yaml files across packages
|
|
60
|
-
* and extract service.name from their resources sections.
|
|
61
|
+
* and extract service.name and owned-scopes from their resources sections.
|
|
61
62
|
*
|
|
62
|
-
* @param fileTree - FileTree to discover
|
|
63
|
-
* @returns
|
|
63
|
+
* @param fileTree - FileTree to discover scopes from
|
|
64
|
+
* @returns Object with serviceNames, ownedScopes, and scopeToServiceMap
|
|
64
65
|
*/
|
|
65
|
-
private
|
|
66
|
+
private discoverScopesInfo;
|
|
66
67
|
/**
|
|
67
68
|
* Build VersionSnapshot from FileTree using CanvasDiscovery
|
|
68
69
|
*/
|
|
@@ -99,6 +100,7 @@ export declare class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
99
100
|
*
|
|
100
101
|
* Unlike getAllSnapshots(), this method ensures all registered scopes
|
|
101
102
|
* have their snapshots built and cached before returning.
|
|
103
|
+
* Note: Returns one snapshot per workspace (not per scope).
|
|
102
104
|
*/
|
|
103
105
|
getAllSnapshotsForRegisteredScopes(): Promise<VersionSnapshot[]>;
|
|
104
106
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/LocalRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIjE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"LocalRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/LocalRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIjE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAY3D;;GAEG;AACH,qBAAa,aAAc,YAAW,2BAA2B;IAQ7D,OAAO,CAAC,UAAU;IAPpB,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,gBAAgB,CAAiC;gBAG/C,UAAU,EAAE,UAAU,EAC9B,SAAS,CAAC,EAAE,iBAAiB;IAQ/B;;;;;;;;;;;;OAYG;IACG,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyC9D;;;OAGG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAuBxC,aAAa,CACjB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EACxC,SAAS,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAClD,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAkClC;;;;;;;;OAQG;YACW,kBAAkB;IA4ChC;;OAEG;YACW,iBAAiB;IA2B/B;;;;;OAKG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKlC,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAiBxE,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,uBAAuB,IAAI,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAiB5E;;;;;;OAMG;IACH,eAAe,IAAI,eAAe,EAAE;IAIpC;;;;;;OAMG;IACG,kCAAkC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAyBtE;;OAEG;IACH,OAAO,IAAI,IAAI;CAQhB"}
|
|
@@ -34,14 +34,15 @@ class LocalRegistry {
|
|
|
34
34
|
/**
|
|
35
35
|
* Register a local workspace
|
|
36
36
|
*
|
|
37
|
-
* Auto-discovers
|
|
38
|
-
* Each service in resources with a service.name becomes a scope
|
|
37
|
+
* Auto-discovers service names and owned scopes from library.yaml resources section.
|
|
38
|
+
* Each service in resources with a service.name becomes a registered scope.
|
|
39
|
+
* Additionally, owned-scopes from each service are mapped to their owning service.
|
|
39
40
|
*
|
|
40
41
|
* File watching should be handled externally. When .principal-views files change,
|
|
41
42
|
* call invalidateCache(scopeName) to rebuild the snapshot.
|
|
42
43
|
*
|
|
43
44
|
* @param fileTree - FileTree for the workspace
|
|
44
|
-
* @returns Array of
|
|
45
|
+
* @returns Array of all registered scope names (services + owned scopes)
|
|
45
46
|
*/
|
|
46
47
|
async registerWorkspace(fileTree) {
|
|
47
48
|
const workspaceId = fileTree.metadata.id;
|
|
@@ -49,30 +50,32 @@ class LocalRegistry {
|
|
|
49
50
|
if (this.workspaces.has(workspaceId)) {
|
|
50
51
|
console.log('[LocalRegistry] Workspace already registered:', workspaceId);
|
|
51
52
|
const existing = this.workspaces.get(workspaceId);
|
|
52
|
-
return existing.
|
|
53
|
+
return [...existing.serviceNames, ...existing.ownedScopes];
|
|
53
54
|
}
|
|
54
|
-
// Auto-discover
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
console.warn('[LocalRegistry] No
|
|
55
|
+
// Auto-discover service names and owned scopes from library.yaml
|
|
56
|
+
const { serviceNames, ownedScopes, scopeToServiceMap } = await this.discoverScopesInfo(fileTree);
|
|
57
|
+
if (serviceNames.length === 0) {
|
|
58
|
+
console.warn('[LocalRegistry] No service names discovered for workspace:', workspaceId);
|
|
58
59
|
console.warn('[LocalRegistry] Make sure library.yaml has a resources section with service.name attributes');
|
|
59
60
|
}
|
|
60
61
|
// Register workspace
|
|
61
62
|
this.workspaces.set(workspaceId, {
|
|
62
63
|
workspaceId,
|
|
63
64
|
fileTree,
|
|
64
|
-
|
|
65
|
+
serviceNames,
|
|
66
|
+
ownedScopes,
|
|
65
67
|
});
|
|
66
|
-
// Map all scope names to this workspace
|
|
67
|
-
for (const scopeName of
|
|
68
|
+
// Map all scope names (services + owned scopes) to this workspace
|
|
69
|
+
for (const [scopeName] of scopeToServiceMap) {
|
|
68
70
|
this.scopeToWorkspaceId.set(scopeName, workspaceId);
|
|
69
71
|
}
|
|
70
72
|
console.log('[LocalRegistry] Registered workspace:', {
|
|
71
73
|
workspaceId,
|
|
72
|
-
|
|
74
|
+
serviceNames,
|
|
75
|
+
ownedScopes,
|
|
73
76
|
fileTreeSha: fileTree.sha,
|
|
74
77
|
});
|
|
75
|
-
return
|
|
78
|
+
return [...serviceNames, ...ownedScopes];
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
81
|
* Unregister a workspace (cleanup)
|
|
@@ -83,8 +86,9 @@ class LocalRegistry {
|
|
|
83
86
|
if (!workspace) {
|
|
84
87
|
return;
|
|
85
88
|
}
|
|
86
|
-
// Clear cache for all scope names
|
|
87
|
-
|
|
89
|
+
// Clear cache for all scope names (services + owned scopes)
|
|
90
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
91
|
+
for (const scopeName of allScopes) {
|
|
88
92
|
this.cache.delete(scopeName);
|
|
89
93
|
this.scopeToWorkspaceId.delete(scopeName);
|
|
90
94
|
}
|
|
@@ -92,7 +96,8 @@ class LocalRegistry {
|
|
|
92
96
|
this.workspaces.delete(workspaceId);
|
|
93
97
|
console.log('[LocalRegistry] Unregistered workspace:', {
|
|
94
98
|
workspaceId,
|
|
95
|
-
|
|
99
|
+
serviceNames: workspace.serviceNames,
|
|
100
|
+
ownedScopes: workspace.ownedScopes,
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
async lookupByScope(scope, _resource) {
|
|
@@ -124,18 +129,18 @@ class LocalRegistry {
|
|
|
124
129
|
return snapshot;
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
|
-
* Auto-discover
|
|
132
|
+
* Auto-discover service names and owned scopes from library.yaml files
|
|
128
133
|
*
|
|
129
134
|
* Uses LibraryDiscovery to find all library.yaml files across packages
|
|
130
|
-
* and extract service.name from their resources sections.
|
|
135
|
+
* and extract service.name and owned-scopes from their resources sections.
|
|
131
136
|
*
|
|
132
|
-
* @param fileTree - FileTree to discover
|
|
133
|
-
* @returns
|
|
137
|
+
* @param fileTree - FileTree to discover scopes from
|
|
138
|
+
* @returns Object with serviceNames, ownedScopes, and scopeToServiceMap
|
|
134
139
|
*/
|
|
135
|
-
async
|
|
140
|
+
async discoverScopesInfo(fileTree) {
|
|
136
141
|
if (!this.libraryDiscovery) {
|
|
137
142
|
console.warn('[LocalRegistry] No LibraryDiscovery available - provide FileSystemAdapter to constructor');
|
|
138
|
-
return [];
|
|
143
|
+
return { serviceNames: [], ownedScopes: [], scopeToServiceMap: new Map() };
|
|
139
144
|
}
|
|
140
145
|
try {
|
|
141
146
|
const result = await this.libraryDiscovery.discover(fileTree, {
|
|
@@ -144,12 +149,27 @@ class LocalRegistry {
|
|
|
144
149
|
if (result.errors.length > 0) {
|
|
145
150
|
console.warn('[LocalRegistry] Errors during library discovery:', result.errors);
|
|
146
151
|
}
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
// Collect all owned scopes across all services
|
|
153
|
+
const ownedScopes = [];
|
|
154
|
+
for (const lib of result.libraries) {
|
|
155
|
+
for (const service of lib.servicesWithScopes) {
|
|
156
|
+
ownedScopes.push(...service.ownedScopes);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
console.log('[LocalRegistry] Discovered services and scopes:', {
|
|
160
|
+
serviceNames: result.allServiceNames,
|
|
161
|
+
ownedScopes,
|
|
162
|
+
scopeToServiceMapSize: result.scopeToServiceMap.size,
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
serviceNames: result.allServiceNames,
|
|
166
|
+
ownedScopes,
|
|
167
|
+
scopeToServiceMap: result.scopeToServiceMap,
|
|
168
|
+
};
|
|
149
169
|
}
|
|
150
170
|
catch (error) {
|
|
151
|
-
console.error('[LocalRegistry] Failed to discover
|
|
152
|
-
return [];
|
|
171
|
+
console.error('[LocalRegistry] Failed to discover scopes:', error);
|
|
172
|
+
return { serviceNames: [], ownedScopes: [], scopeToServiceMap: new Map() };
|
|
153
173
|
}
|
|
154
174
|
}
|
|
155
175
|
/**
|
|
@@ -191,7 +211,9 @@ class LocalRegistry {
|
|
|
191
211
|
async listScopes() {
|
|
192
212
|
const scopes = [];
|
|
193
213
|
for (const workspace of this.workspaces.values()) {
|
|
194
|
-
|
|
214
|
+
// Include service names and owned scopes
|
|
215
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
216
|
+
for (const scopeName of allScopes) {
|
|
195
217
|
scopes.push({
|
|
196
218
|
name: scopeName,
|
|
197
219
|
versions: ['dev'], // Local workspaces always use 'dev' version
|
|
@@ -209,7 +231,9 @@ class LocalRegistry {
|
|
|
209
231
|
getRegisteredWorkspaces() {
|
|
210
232
|
const workspaces = [];
|
|
211
233
|
for (const workspace of this.workspaces.values()) {
|
|
212
|
-
|
|
234
|
+
// Include service names and owned scopes
|
|
235
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
236
|
+
for (const scopeName of allScopes) {
|
|
213
237
|
workspaces.push({
|
|
214
238
|
scopeName,
|
|
215
239
|
fileTreeSha: workspace.fileTree.sha || 'unknown',
|
|
@@ -233,12 +257,20 @@ class LocalRegistry {
|
|
|
233
257
|
*
|
|
234
258
|
* Unlike getAllSnapshots(), this method ensures all registered scopes
|
|
235
259
|
* have their snapshots built and cached before returning.
|
|
260
|
+
* Note: Returns one snapshot per workspace (not per scope).
|
|
236
261
|
*/
|
|
237
262
|
async getAllSnapshotsForRegisteredScopes() {
|
|
238
263
|
const snapshots = [];
|
|
264
|
+
const seenWorkspaceIds = new Set();
|
|
239
265
|
for (const workspace of this.workspaces.values()) {
|
|
240
|
-
|
|
241
|
-
|
|
266
|
+
// Only build one snapshot per workspace
|
|
267
|
+
if (seenWorkspaceIds.has(workspace.workspaceId))
|
|
268
|
+
continue;
|
|
269
|
+
seenWorkspaceIds.add(workspace.workspaceId);
|
|
270
|
+
// Use first service name to trigger snapshot build
|
|
271
|
+
const firstServiceName = workspace.serviceNames[0];
|
|
272
|
+
if (firstServiceName) {
|
|
273
|
+
const snapshot = await this.lookupByScope({ name: firstServiceName, version: 'dev' }, {});
|
|
242
274
|
if (snapshot) {
|
|
243
275
|
snapshots.push(snapshot);
|
|
244
276
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalRegistry.js","sourceRoot":"","sources":["../../src/registry/LocalRegistry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAKH,kEAA+D;AAC/D,oEAAiE;
|
|
1
|
+
{"version":3,"file":"LocalRegistry.js","sourceRoot":"","sources":["../../src/registry/LocalRegistry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAKH,kEAA+D;AAC/D,oEAAiE;AAiBjE;;GAEG;AACH,MAAa,aAAa;IAOxB,YACU,UAAsB,EAC9B,SAA6B;QADrB,eAAU,GAAV,UAAU,CAAY;QAPxB,UAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC3C,eAAU,GAAG,IAAI,GAAG,EAAiC,CAAC,CAAC,6BAA6B;QACpF,uBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,0BAA0B;QAE1E,qBAAgB,GAA4B,IAAI,CAAC;QAMvD,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAe,EAAE,CAAC;QACvC,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAgB,CAAC,SAAS,CAAC,CAAC;SACzD;IACH,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAkB;QACxC,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAEzC,8BAA8B;QAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACpC,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,WAAW,CA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AAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE3C,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;YAChD,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC;gBAAE,SAAS;YAC1D,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAE5C,mDAAmD;YACnD,MAAM,gBAAgB,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACnD,IAAI,gBAAgB,EAAE;gBACpB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CACvC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,EAC1C,EAAE,CACH,CAAC;gBACF,IAAI,QAAQ,EAAE;oBACZ,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC1B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAEhE,cAAc;QACd,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACF;AApUD,sCAoUC"}
|
package/dist/types/library.d.ts
CHANGED
|
@@ -57,8 +57,26 @@ export interface ResourceAttributes {
|
|
|
57
57
|
'messaging.system'?: string;
|
|
58
58
|
/** Messaging destination name */
|
|
59
59
|
'messaging.destination.name'?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Instrumentation scopes owned by this service
|
|
62
|
+
*
|
|
63
|
+
* Lists the tracer/instrumentation scope names that belong to this service.
|
|
64
|
+
* Spans from these scopes will be matched against this service's storyboards
|
|
65
|
+
* rather than looking up external registries.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```yaml
|
|
69
|
+
* resources:
|
|
70
|
+
* web-ade:
|
|
71
|
+
* service.name: "web-ade"
|
|
72
|
+
* owned-scopes:
|
|
73
|
+
* - "auth-me"
|
|
74
|
+
* - "checkout"
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
'owned-scopes'?: string[];
|
|
60
78
|
/** Allow arbitrary OTEL resource attributes */
|
|
61
|
-
[key: string]: string | undefined;
|
|
79
|
+
[key: string]: string | string[] | undefined;
|
|
62
80
|
}
|
|
63
81
|
/**
|
|
64
82
|
* A reusable node component definition in the library.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/types/library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,eAAe,EAEf,WAAW,EACX,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IAEvB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,mCAAmC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,qCAAqC;IACrC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2CAA2C;IAC3C,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,2BAA2B;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,iCAAiC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,gCAAgC;IAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,2BAA2B;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,sBAAsB;IACtB,WAAW,CAAC,EAAE,MAAM,CA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|
10
10
|
import { LibraryLoader } from '../LibraryLoader';
|
|
11
11
|
import type { ComponentLibrary } from '../types/library';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Service with its owned scopes
|
|
15
|
+
*/
|
|
16
|
+
export interface ServiceWithScopes {
|
|
17
|
+
/** Service name (from service.name attribute) */
|
|
18
|
+
serviceName: string;
|
|
19
|
+
|
|
20
|
+
/** Instrumentation scopes owned by this service */
|
|
21
|
+
ownedScopes: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
/**
|
|
14
25
|
* Discovered library with metadata
|
|
15
26
|
*/
|
|
@@ -28,6 +39,9 @@ export interface DiscoveredLibrary {
|
|
|
28
39
|
|
|
29
40
|
/** Service names from this library's resources */
|
|
30
41
|
serviceNames: string[];
|
|
42
|
+
|
|
43
|
+
/** Services with their owned scopes */
|
|
44
|
+
servicesWithScopes: ServiceWithScopes[];
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
/**
|
|
@@ -40,6 +54,14 @@ export interface LibraryDiscoveryResult {
|
|
|
40
54
|
/** All service names across all libraries */
|
|
41
55
|
allServiceNames: string[];
|
|
42
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Mapping from instrumentation scope name to owning service name
|
|
59
|
+
*
|
|
60
|
+
* Used to route spans from owned scopes to the correct service's storyboards.
|
|
61
|
+
* For example: { "auth-me": "web-ade", "checkout": "web-ade" }
|
|
62
|
+
*/
|
|
63
|
+
scopeToServiceMap: Map<string, string>;
|
|
64
|
+
|
|
43
65
|
/** Errors encountered during discovery */
|
|
44
66
|
errors: Array<{ path: string; error: string }>;
|
|
45
67
|
}
|
|
@@ -104,8 +126,8 @@ export class LibraryDiscovery {
|
|
|
104
126
|
const loadResult = await this.loader.load(pkg.packageData.path);
|
|
105
127
|
|
|
106
128
|
if (loadResult.success && loadResult.library) {
|
|
107
|
-
// Extract service names from resources
|
|
108
|
-
const serviceNames = this.
|
|
129
|
+
// Extract service names and owned scopes from resources
|
|
130
|
+
const { serviceNames, servicesWithScopes } = this.extractServicesInfo(loadResult.library);
|
|
109
131
|
|
|
110
132
|
libraries.push({
|
|
111
133
|
path: loadResult.path,
|
|
@@ -113,6 +135,7 @@ export class LibraryDiscovery {
|
|
|
113
135
|
packagePath: pkg.packageData.path,
|
|
114
136
|
library: loadResult.library,
|
|
115
137
|
serviceNames,
|
|
138
|
+
servicesWithScopes,
|
|
116
139
|
});
|
|
117
140
|
} else if (loadResult.error && !loadResult.error.includes('No library file found')) {
|
|
118
141
|
// Only report errors that aren't "file not found" (which is normal)
|
|
@@ -138,7 +161,7 @@ export class LibraryDiscovery {
|
|
|
138
161
|
const loadResult = await this.loader.load(rootPath);
|
|
139
162
|
|
|
140
163
|
if (loadResult.success && loadResult.library) {
|
|
141
|
-
const serviceNames = this.
|
|
164
|
+
const { serviceNames, servicesWithScopes } = this.extractServicesInfo(loadResult.library);
|
|
142
165
|
|
|
143
166
|
// Check if we already loaded this from a package
|
|
144
167
|
const alreadyLoaded = libraries.some(lib => lib.path === loadResult.path);
|
|
@@ -150,6 +173,7 @@ export class LibraryDiscovery {
|
|
|
150
173
|
packagePath: rootPath,
|
|
151
174
|
library: loadResult.library,
|
|
152
175
|
serviceNames,
|
|
176
|
+
servicesWithScopes,
|
|
153
177
|
});
|
|
154
178
|
}
|
|
155
179
|
} else if (loadResult.error) {
|
|
@@ -166,12 +190,27 @@ export class LibraryDiscovery {
|
|
|
166
190
|
// 4. Collect all service names
|
|
167
191
|
const allServiceNames = libraries.flatMap(lib => lib.serviceNames);
|
|
168
192
|
|
|
169
|
-
// 5.
|
|
193
|
+
// 5. Build scope to service mapping
|
|
194
|
+
const scopeToServiceMap = new Map<string, string>();
|
|
195
|
+
for (const lib of libraries) {
|
|
196
|
+
for (const service of lib.servicesWithScopes) {
|
|
197
|
+
// Map the service name to itself (service names are also valid scope names)
|
|
198
|
+
scopeToServiceMap.set(service.serviceName, service.serviceName);
|
|
199
|
+
|
|
200
|
+
// Map each owned scope to its owning service
|
|
201
|
+
for (const scope of service.ownedScopes) {
|
|
202
|
+
scopeToServiceMap.set(scope, service.serviceName);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 6. Sort libraries by package name
|
|
170
208
|
libraries.sort((a, b) => a.packageName.localeCompare(b.packageName));
|
|
171
209
|
|
|
172
210
|
return {
|
|
173
211
|
libraries,
|
|
174
212
|
allServiceNames,
|
|
213
|
+
scopeToServiceMap,
|
|
175
214
|
errors,
|
|
176
215
|
};
|
|
177
216
|
}
|
|
@@ -184,17 +223,35 @@ export class LibraryDiscovery {
|
|
|
184
223
|
}
|
|
185
224
|
|
|
186
225
|
/**
|
|
187
|
-
* Extract service names from a library's resources
|
|
226
|
+
* Extract service names and owned scopes from a library's resources
|
|
188
227
|
*/
|
|
189
|
-
private
|
|
228
|
+
private extractServicesInfo(library: ComponentLibrary): {
|
|
229
|
+
serviceNames: string[];
|
|
230
|
+
servicesWithScopes: ServiceWithScopes[];
|
|
231
|
+
} {
|
|
190
232
|
if (!library.resources) {
|
|
191
|
-
return [];
|
|
233
|
+
return { serviceNames: [], servicesWithScopes: [] };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const serviceNames: string[] = [];
|
|
237
|
+
const servicesWithScopes: ServiceWithScopes[] = [];
|
|
238
|
+
|
|
239
|
+
for (const attrs of Object.values(library.resources)) {
|
|
240
|
+
const serviceName = attrs['service.name'];
|
|
241
|
+
if (!serviceName) continue;
|
|
242
|
+
|
|
243
|
+
serviceNames.push(serviceName);
|
|
244
|
+
|
|
245
|
+
// Extract owned-scopes (defaults to empty array)
|
|
246
|
+
const ownedScopes = attrs['owned-scopes'] || [];
|
|
247
|
+
|
|
248
|
+
servicesWithScopes.push({
|
|
249
|
+
serviceName,
|
|
250
|
+
ownedScopes: Array.isArray(ownedScopes) ? ownedScopes : [],
|
|
251
|
+
});
|
|
192
252
|
}
|
|
193
253
|
|
|
194
|
-
|
|
195
|
-
return Object.values(library.resources)
|
|
196
|
-
.map(attrs => attrs['service.name'])
|
|
197
|
-
.filter((name): name is string => !!name);
|
|
254
|
+
return { serviceNames, servicesWithScopes };
|
|
198
255
|
}
|
|
199
256
|
|
|
200
257
|
/**
|
|
@@ -29,7 +29,8 @@ export type FileReader = (path: string) => Promise<string>;
|
|
|
29
29
|
interface WorkspaceRegistration {
|
|
30
30
|
workspaceId: string;
|
|
31
31
|
fileTree: FileTree;
|
|
32
|
-
|
|
32
|
+
serviceNames: string[]; // Service names (from service.name attribute)
|
|
33
|
+
ownedScopes: string[]; // All owned instrumentation scopes
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -55,14 +56,15 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
55
56
|
/**
|
|
56
57
|
* Register a local workspace
|
|
57
58
|
*
|
|
58
|
-
* Auto-discovers
|
|
59
|
-
* Each service in resources with a service.name becomes a scope
|
|
59
|
+
* Auto-discovers service names and owned scopes from library.yaml resources section.
|
|
60
|
+
* Each service in resources with a service.name becomes a registered scope.
|
|
61
|
+
* Additionally, owned-scopes from each service are mapped to their owning service.
|
|
60
62
|
*
|
|
61
63
|
* File watching should be handled externally. When .principal-views files change,
|
|
62
64
|
* call invalidateCache(scopeName) to rebuild the snapshot.
|
|
63
65
|
*
|
|
64
66
|
* @param fileTree - FileTree for the workspace
|
|
65
|
-
* @returns Array of
|
|
67
|
+
* @returns Array of all registered scope names (services + owned scopes)
|
|
66
68
|
*/
|
|
67
69
|
async registerWorkspace(fileTree: FileTree): Promise<string[]> {
|
|
68
70
|
const workspaceId = fileTree.metadata.id;
|
|
@@ -71,14 +73,14 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
71
73
|
if (this.workspaces.has(workspaceId)) {
|
|
72
74
|
console.log('[LocalRegistry] Workspace already registered:', workspaceId);
|
|
73
75
|
const existing = this.workspaces.get(workspaceId)!;
|
|
74
|
-
return existing.
|
|
76
|
+
return [...existing.serviceNames, ...existing.ownedScopes];
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
// Auto-discover
|
|
78
|
-
const
|
|
79
|
+
// Auto-discover service names and owned scopes from library.yaml
|
|
80
|
+
const { serviceNames, ownedScopes, scopeToServiceMap } = await this.discoverScopesInfo(fileTree);
|
|
79
81
|
|
|
80
|
-
if (
|
|
81
|
-
console.warn('[LocalRegistry] No
|
|
82
|
+
if (serviceNames.length === 0) {
|
|
83
|
+
console.warn('[LocalRegistry] No service names discovered for workspace:', workspaceId);
|
|
82
84
|
console.warn('[LocalRegistry] Make sure library.yaml has a resources section with service.name attributes');
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -86,21 +88,23 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
86
88
|
this.workspaces.set(workspaceId, {
|
|
87
89
|
workspaceId,
|
|
88
90
|
fileTree,
|
|
89
|
-
|
|
91
|
+
serviceNames,
|
|
92
|
+
ownedScopes,
|
|
90
93
|
});
|
|
91
94
|
|
|
92
|
-
// Map all scope names to this workspace
|
|
93
|
-
for (const scopeName of
|
|
95
|
+
// Map all scope names (services + owned scopes) to this workspace
|
|
96
|
+
for (const [scopeName] of scopeToServiceMap) {
|
|
94
97
|
this.scopeToWorkspaceId.set(scopeName, workspaceId);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
console.log('[LocalRegistry] Registered workspace:', {
|
|
98
101
|
workspaceId,
|
|
99
|
-
|
|
102
|
+
serviceNames,
|
|
103
|
+
ownedScopes,
|
|
100
104
|
fileTreeSha: fileTree.sha,
|
|
101
105
|
});
|
|
102
106
|
|
|
103
|
-
return
|
|
107
|
+
return [...serviceNames, ...ownedScopes];
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
/**
|
|
@@ -113,8 +117,9 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
// Clear cache for all scope names
|
|
117
|
-
|
|
120
|
+
// Clear cache for all scope names (services + owned scopes)
|
|
121
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
122
|
+
for (const scopeName of allScopes) {
|
|
118
123
|
this.cache.delete(scopeName);
|
|
119
124
|
this.scopeToWorkspaceId.delete(scopeName);
|
|
120
125
|
}
|
|
@@ -124,7 +129,8 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
124
129
|
|
|
125
130
|
console.log('[LocalRegistry] Unregistered workspace:', {
|
|
126
131
|
workspaceId,
|
|
127
|
-
|
|
132
|
+
serviceNames: workspace.serviceNames,
|
|
133
|
+
ownedScopes: workspace.ownedScopes,
|
|
128
134
|
});
|
|
129
135
|
}
|
|
130
136
|
|
|
@@ -166,18 +172,22 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
166
172
|
}
|
|
167
173
|
|
|
168
174
|
/**
|
|
169
|
-
* Auto-discover
|
|
175
|
+
* Auto-discover service names and owned scopes from library.yaml files
|
|
170
176
|
*
|
|
171
177
|
* Uses LibraryDiscovery to find all library.yaml files across packages
|
|
172
|
-
* and extract service.name from their resources sections.
|
|
178
|
+
* and extract service.name and owned-scopes from their resources sections.
|
|
173
179
|
*
|
|
174
|
-
* @param fileTree - FileTree to discover
|
|
175
|
-
* @returns
|
|
180
|
+
* @param fileTree - FileTree to discover scopes from
|
|
181
|
+
* @returns Object with serviceNames, ownedScopes, and scopeToServiceMap
|
|
176
182
|
*/
|
|
177
|
-
private async
|
|
183
|
+
private async discoverScopesInfo(fileTree: FileTree): Promise<{
|
|
184
|
+
serviceNames: string[];
|
|
185
|
+
ownedScopes: string[];
|
|
186
|
+
scopeToServiceMap: Map<string, string>;
|
|
187
|
+
}> {
|
|
178
188
|
if (!this.libraryDiscovery) {
|
|
179
189
|
console.warn('[LocalRegistry] No LibraryDiscovery available - provide FileSystemAdapter to constructor');
|
|
180
|
-
return [];
|
|
190
|
+
return { serviceNames: [], ownedScopes: [], scopeToServiceMap: new Map() };
|
|
181
191
|
}
|
|
182
192
|
|
|
183
193
|
try {
|
|
@@ -189,11 +199,28 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
189
199
|
console.warn('[LocalRegistry] Errors during library discovery:', result.errors);
|
|
190
200
|
}
|
|
191
201
|
|
|
192
|
-
|
|
193
|
-
|
|
202
|
+
// Collect all owned scopes across all services
|
|
203
|
+
const ownedScopes: string[] = [];
|
|
204
|
+
for (const lib of result.libraries) {
|
|
205
|
+
for (const service of lib.servicesWithScopes) {
|
|
206
|
+
ownedScopes.push(...service.ownedScopes);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
console.log('[LocalRegistry] Discovered services and scopes:', {
|
|
211
|
+
serviceNames: result.allServiceNames,
|
|
212
|
+
ownedScopes,
|
|
213
|
+
scopeToServiceMapSize: result.scopeToServiceMap.size,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
serviceNames: result.allServiceNames,
|
|
218
|
+
ownedScopes,
|
|
219
|
+
scopeToServiceMap: result.scopeToServiceMap,
|
|
220
|
+
};
|
|
194
221
|
} catch (error) {
|
|
195
|
-
console.error('[LocalRegistry] Failed to discover
|
|
196
|
-
return [];
|
|
222
|
+
console.error('[LocalRegistry] Failed to discover scopes:', error);
|
|
223
|
+
return { serviceNames: [], ownedScopes: [], scopeToServiceMap: new Map() };
|
|
197
224
|
}
|
|
198
225
|
}
|
|
199
226
|
|
|
@@ -242,7 +269,9 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
242
269
|
const scopes: Array<{ name: string; versions: string[] }> = [];
|
|
243
270
|
|
|
244
271
|
for (const workspace of this.workspaces.values()) {
|
|
245
|
-
|
|
272
|
+
// Include service names and owned scopes
|
|
273
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
274
|
+
for (const scopeName of allScopes) {
|
|
246
275
|
scopes.push({
|
|
247
276
|
name: scopeName,
|
|
248
277
|
versions: ['dev'], // Local workspaces always use 'dev' version
|
|
@@ -264,7 +293,9 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
264
293
|
const workspaces: Array<{ scopeName: string; fileTreeSha: string }> = [];
|
|
265
294
|
|
|
266
295
|
for (const workspace of this.workspaces.values()) {
|
|
267
|
-
|
|
296
|
+
// Include service names and owned scopes
|
|
297
|
+
const allScopes = [...workspace.serviceNames, ...workspace.ownedScopes];
|
|
298
|
+
for (const scopeName of allScopes) {
|
|
268
299
|
workspaces.push({
|
|
269
300
|
scopeName,
|
|
270
301
|
fileTreeSha: workspace.fileTree.sha || 'unknown',
|
|
@@ -291,14 +322,22 @@ export class LocalRegistry implements StoryboardRegistryInterface {
|
|
|
291
322
|
*
|
|
292
323
|
* Unlike getAllSnapshots(), this method ensures all registered scopes
|
|
293
324
|
* have their snapshots built and cached before returning.
|
|
325
|
+
* Note: Returns one snapshot per workspace (not per scope).
|
|
294
326
|
*/
|
|
295
327
|
async getAllSnapshotsForRegisteredScopes(): Promise<VersionSnapshot[]> {
|
|
296
328
|
const snapshots: VersionSnapshot[] = [];
|
|
329
|
+
const seenWorkspaceIds = new Set<string>();
|
|
297
330
|
|
|
298
331
|
for (const workspace of this.workspaces.values()) {
|
|
299
|
-
|
|
332
|
+
// Only build one snapshot per workspace
|
|
333
|
+
if (seenWorkspaceIds.has(workspace.workspaceId)) continue;
|
|
334
|
+
seenWorkspaceIds.add(workspace.workspaceId);
|
|
335
|
+
|
|
336
|
+
// Use first service name to trigger snapshot build
|
|
337
|
+
const firstServiceName = workspace.serviceNames[0];
|
|
338
|
+
if (firstServiceName) {
|
|
300
339
|
const snapshot = await this.lookupByScope(
|
|
301
|
-
{ name:
|
|
340
|
+
{ name: firstServiceName, version: 'dev' },
|
|
302
341
|
{}
|
|
303
342
|
);
|
|
304
343
|
if (snapshot) {
|
package/src/types/library.ts
CHANGED
|
@@ -88,8 +88,27 @@ export interface ResourceAttributes {
|
|
|
88
88
|
/** Messaging destination name */
|
|
89
89
|
'messaging.destination.name'?: string;
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Instrumentation scopes owned by this service
|
|
93
|
+
*
|
|
94
|
+
* Lists the tracer/instrumentation scope names that belong to this service.
|
|
95
|
+
* Spans from these scopes will be matched against this service's storyboards
|
|
96
|
+
* rather than looking up external registries.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```yaml
|
|
100
|
+
* resources:
|
|
101
|
+
* web-ade:
|
|
102
|
+
* service.name: "web-ade"
|
|
103
|
+
* owned-scopes:
|
|
104
|
+
* - "auth-me"
|
|
105
|
+
* - "checkout"
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
'owned-scopes'?: string[];
|
|
109
|
+
|
|
91
110
|
/** Allow arbitrary OTEL resource attributes */
|
|
92
|
-
[key: string]: string | undefined;
|
|
111
|
+
[key: string]: string | string[] | undefined;
|
|
93
112
|
}
|
|
94
113
|
|
|
95
114
|
// ============================================================================
|