@neat.is/types 0.6.4 → 0.7.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/index.cjs +83 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +916 -267
- package/dist/index.d.ts +916 -267
- package/dist/index.js +78 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22,7 +22,16 @@ var EdgeType = {
|
|
|
22
22
|
// Static module dependency between two FileNodes within a service (ADR-092,
|
|
23
23
|
// file-awareness.md §10). Compile-time, not runtime — represents one file
|
|
24
24
|
// importing another. Distinct from CALLS which records runtime invocations.
|
|
25
|
-
IMPORTS: "IMPORTS"
|
|
25
|
+
IMPORTS: "IMPORTS",
|
|
26
|
+
// Static heritage between two SymbolNodes (ADR-158 §3). `INHERITS` records a
|
|
27
|
+
// class's `extends` clause (`class ──INHERITS──▶ superclass`); `IMPLEMENTS`
|
|
28
|
+
// records an `implements` clause (`class ──IMPLEMENTS──▶ implemented`). Both
|
|
29
|
+
// are symbol→symbol, EXTRACTED, minted only when the parent name resolves to
|
|
30
|
+
// exactly one known SymbolNode — same-file or through the import graph — never
|
|
31
|
+
// fuzzy-matched. A parent that resolves to nothing (external package,
|
|
32
|
+
// re-export chain, an interface, which is not a SymbolNode) emits no edge.
|
|
33
|
+
INHERITS: "INHERITS",
|
|
34
|
+
IMPLEMENTS: "IMPLEMENTS"
|
|
26
35
|
};
|
|
27
36
|
var NodeType = {
|
|
28
37
|
ServiceNode: "ServiceNode",
|
|
@@ -72,7 +81,18 @@ var NodeType = {
|
|
|
72
81
|
// edge that carries `lastObserved` and decays OBSERVED → STALE on CONNECTS_TO's
|
|
73
82
|
// own staleness threshold when the channel goes quiet. See
|
|
74
83
|
// docs/contracts/otel-ingest.md.
|
|
75
|
-
WebSocketChannelNode: "WebSocketChannelNode"
|
|
84
|
+
WebSocketChannelNode: "WebSocketChannelNode",
|
|
85
|
+
// A symbol under a file — a function, method, constructor, or class
|
|
86
|
+
// definition — at definition-span granularity (ADR-158). Static-first: the
|
|
87
|
+
// extractor mints one per definition and the file owns it through a
|
|
88
|
+
// `file ──CONTAINS──▶ symbol` edge, one containment level below
|
|
89
|
+
// `service ──CONTAINS──▶ file`. It carries its `{ startLine, endLine }`
|
|
90
|
+
// definition span, which is the fusion key ingest joins a span's `code.line`
|
|
91
|
+
// against to land an OBSERVED edge on the calling symbol rather than only its
|
|
92
|
+
// file (observed-first edges, one grain finer than §4 file grain). The node is
|
|
93
|
+
// language-neutral; the per-language tree-sitter extractor is the adapter. See
|
|
94
|
+
// docs/contracts/static-extraction.md and docs/contracts/file-awareness.md §1.
|
|
95
|
+
SymbolNode: "SymbolNode"
|
|
76
96
|
};
|
|
77
97
|
var NodeTypeSchema = z.enum([
|
|
78
98
|
NodeType.ServiceNode,
|
|
@@ -84,7 +104,8 @@ var NodeTypeSchema = z.enum([
|
|
|
84
104
|
NodeType.RouteNode,
|
|
85
105
|
NodeType.GraphQLOperationNode,
|
|
86
106
|
NodeType.GrpcMethodNode,
|
|
87
|
-
NodeType.WebSocketChannelNode
|
|
107
|
+
NodeType.WebSocketChannelNode,
|
|
108
|
+
NodeType.SymbolNode
|
|
88
109
|
]);
|
|
89
110
|
|
|
90
111
|
// src/nodes.ts
|
|
@@ -275,6 +296,21 @@ var WebSocketChannelNodeSchema = z2.object({
|
|
|
275
296
|
line: z2.number().int().nonnegative().optional(),
|
|
276
297
|
discoveredVia: DiscoveredViaSchema.optional()
|
|
277
298
|
});
|
|
299
|
+
var SymbolKindSchema = z2.enum(["function", "method", "constructor", "class"]);
|
|
300
|
+
var SymbolSpanSchema = z2.object({
|
|
301
|
+
startLine: z2.number().int().nonnegative(),
|
|
302
|
+
endLine: z2.number().int().nonnegative()
|
|
303
|
+
});
|
|
304
|
+
var SymbolNodeSchema = z2.object({
|
|
305
|
+
id: z2.string(),
|
|
306
|
+
type: z2.literal(NodeType.SymbolNode),
|
|
307
|
+
kind: SymbolKindSchema,
|
|
308
|
+
qualname: z2.string(),
|
|
309
|
+
span: SymbolSpanSchema,
|
|
310
|
+
service: z2.string(),
|
|
311
|
+
relPath: z2.string(),
|
|
312
|
+
discoveredVia: DiscoveredViaSchema.optional()
|
|
313
|
+
});
|
|
278
314
|
var GraphNodeSchema = z2.discriminatedUnion("type", [
|
|
279
315
|
ServiceNodeSchema,
|
|
280
316
|
DatabaseNodeSchema,
|
|
@@ -285,7 +321,8 @@ var GraphNodeSchema = z2.discriminatedUnion("type", [
|
|
|
285
321
|
RouteNodeSchema,
|
|
286
322
|
GraphQLOperationNodeSchema,
|
|
287
323
|
GrpcMethodNodeSchema,
|
|
288
|
-
WebSocketChannelNodeSchema
|
|
324
|
+
WebSocketChannelNodeSchema,
|
|
325
|
+
SymbolNodeSchema
|
|
289
326
|
]);
|
|
290
327
|
|
|
291
328
|
// src/edges.ts
|
|
@@ -305,7 +342,9 @@ var EdgeTypeSchema = z3.enum([
|
|
|
305
342
|
EdgeType.CONSUMES_FROM,
|
|
306
343
|
EdgeType.RUNS_ON,
|
|
307
344
|
EdgeType.CONTAINS,
|
|
308
|
-
EdgeType.IMPORTS
|
|
345
|
+
EdgeType.IMPORTS,
|
|
346
|
+
EdgeType.INHERITS,
|
|
347
|
+
EdgeType.IMPLEMENTS
|
|
309
348
|
]);
|
|
310
349
|
var EdgeEvidenceSchema = z3.object({
|
|
311
350
|
file: z3.string(),
|
|
@@ -493,6 +532,7 @@ var ROUTE_PREFIX = "route:";
|
|
|
493
532
|
var GRAPHQL_OP_PREFIX = "graphql:";
|
|
494
533
|
var GRPC_METHOD_PREFIX = "grpc:";
|
|
495
534
|
var WEBSOCKET_CHANNEL_PREFIX = "ws:";
|
|
535
|
+
var SYMBOL_PREFIX = "symbol:";
|
|
496
536
|
var ENV_UNKNOWN = "unknown";
|
|
497
537
|
function serviceId(name, env) {
|
|
498
538
|
if (env === void 0 || env === ENV_UNKNOWN) return `${SERVICE_PREFIX}${name}`;
|
|
@@ -612,6 +652,34 @@ function parseWebsocketChannelId(id) {
|
|
|
612
652
|
if (service.length === 0 || channel.length === 0) return null;
|
|
613
653
|
return { service, channel };
|
|
614
654
|
}
|
|
655
|
+
function symbolId(service, relPath, qualname, disambiguator) {
|
|
656
|
+
const base = `${SYMBOL_PREFIX}${service}:${relPath}#${qualname}`;
|
|
657
|
+
return disambiguator === void 0 ? base : `${base}~${disambiguator}`;
|
|
658
|
+
}
|
|
659
|
+
function parseSymbolId(id) {
|
|
660
|
+
if (!id.startsWith(SYMBOL_PREFIX)) return null;
|
|
661
|
+
const rest = id.slice(SYMBOL_PREFIX.length);
|
|
662
|
+
const colon = rest.indexOf(":");
|
|
663
|
+
if (colon === -1) return null;
|
|
664
|
+
const service = rest.slice(0, colon);
|
|
665
|
+
const tail = rest.slice(colon + 1);
|
|
666
|
+
const hash = tail.lastIndexOf("#");
|
|
667
|
+
if (hash === -1) return null;
|
|
668
|
+
const relPath = tail.slice(0, hash);
|
|
669
|
+
let qualname = tail.slice(hash + 1);
|
|
670
|
+
if (service.length === 0 || relPath.length === 0 || qualname.length === 0) return null;
|
|
671
|
+
let disambiguator;
|
|
672
|
+
const tilde = qualname.lastIndexOf("~");
|
|
673
|
+
if (tilde !== -1) {
|
|
674
|
+
const suffix = qualname.slice(tilde + 1);
|
|
675
|
+
if (suffix.length > 0 && /^\d+$/.test(suffix)) {
|
|
676
|
+
disambiguator = Number(suffix);
|
|
677
|
+
qualname = qualname.slice(0, tilde);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (qualname.length === 0) return null;
|
|
681
|
+
return { service, relPath, qualname, ...disambiguator !== void 0 ? { disambiguator } : {} };
|
|
682
|
+
}
|
|
615
683
|
var EDGE_ARROW = "->";
|
|
616
684
|
function extractedEdgeId(source, target, type) {
|
|
617
685
|
return `${type}:${source}${EDGE_ARROW}${target}`;
|
|
@@ -1174,6 +1242,9 @@ export {
|
|
|
1174
1242
|
StaleEventSchema,
|
|
1175
1243
|
StaleEventsResponseSchema,
|
|
1176
1244
|
StructuralRuleSchema,
|
|
1245
|
+
SymbolKindSchema,
|
|
1246
|
+
SymbolNodeSchema,
|
|
1247
|
+
SymbolSpanSchema,
|
|
1177
1248
|
TransitiveDependenciesResultSchema,
|
|
1178
1249
|
TransitiveDependencySchema,
|
|
1179
1250
|
VersionMismatchDivergenceSchema,
|
|
@@ -1202,10 +1273,12 @@ export {
|
|
|
1202
1273
|
parseInfraId,
|
|
1203
1274
|
parseRouteId,
|
|
1204
1275
|
parseServiceId,
|
|
1276
|
+
parseSymbolId,
|
|
1205
1277
|
parseWebsocketChannelId,
|
|
1206
1278
|
passesExtractedFloor,
|
|
1207
1279
|
routeId,
|
|
1208
1280
|
serviceId,
|
|
1281
|
+
symbolId,
|
|
1209
1282
|
websocketChannelId
|
|
1210
1283
|
};
|
|
1211
1284
|
//# sourceMappingURL=index.js.map
|