@neat.is/types 0.7.0 → 0.7.2

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.js CHANGED
@@ -109,141 +109,211 @@ var NodeTypeSchema = z.enum([
109
109
  ]);
110
110
 
111
111
  // src/nodes.ts
112
+ import { z as z3 } from "zod";
113
+
114
+ // src/edges.ts
112
115
  import { z as z2 } from "zod";
113
- var CompatibleDriverSchema = z2.object({
114
- name: z2.string(),
115
- minVersion: z2.string()
116
+ var ProvenanceSchema = z2.enum([
117
+ Provenance.EXTRACTED,
118
+ Provenance.INFERRED,
119
+ Provenance.OBSERVED,
120
+ Provenance.STALE
121
+ ]);
122
+ var EdgeTypeSchema = z2.enum([
123
+ EdgeType.CALLS,
124
+ EdgeType.DEPENDS_ON,
125
+ EdgeType.CONNECTS_TO,
126
+ EdgeType.CONFIGURED_BY,
127
+ EdgeType.PUBLISHES_TO,
128
+ EdgeType.CONSUMES_FROM,
129
+ EdgeType.RUNS_ON,
130
+ EdgeType.CONTAINS,
131
+ EdgeType.IMPORTS,
132
+ EdgeType.INHERITS,
133
+ EdgeType.IMPLEMENTS
134
+ ]);
135
+ var EdgeEvidenceSchema = z2.object({
136
+ file: z2.string(),
137
+ line: z2.number().int().nonnegative().optional(),
138
+ snippet: z2.string().optional(),
139
+ // HTTP shape of a recognised client call site (ADR-119). Present on a
140
+ // client↔route CALLS edge so the edge records the method + path-template the
141
+ // client named, alongside the file:line it named them at. Absent on every
142
+ // other edge — a config or infra edge has no HTTP method.
143
+ method: z2.string().optional(),
144
+ pathTemplate: z2.string().optional()
145
+ });
146
+ var EdgeSignalSchema = z2.object({
147
+ spanCount: z2.number().int().nonnegative(),
148
+ errorCount: z2.number().int().nonnegative(),
149
+ lastObservedAgeMs: z2.number().nonnegative().optional()
116
150
  });
117
- var DiscoveredViaSchema = z2.enum(["static", "otel", "merged"]);
118
- var ServiceNodeSchema = z2.object({
151
+ var GraphEdgeSchema = z2.object({
119
152
  id: z2.string(),
120
- type: z2.literal(NodeType.ServiceNode),
121
- name: z2.string(),
122
- language: z2.string(),
153
+ source: z2.string(),
154
+ target: z2.string(),
155
+ type: EdgeTypeSchema,
156
+ provenance: ProvenanceSchema,
157
+ confidence: z2.number().min(0).max(1).optional(),
158
+ lastObserved: z2.string().datetime().optional(),
159
+ callCount: z2.number().int().nonnegative().optional(),
160
+ evidence: EdgeEvidenceSchema.optional(),
161
+ signal: EdgeSignalSchema.optional(),
162
+ // OBSERVED grain (ADR-142): `file` when the edge originates from a source
163
+ // file's call site (a `file:` source + `evidence`), `service` for the coarse
164
+ // fallback where no call site was captured. Makes "service-grained only as a
165
+ // labeled fallback" (connector gate #803) a stored, machine-readable fact
166
+ // instead of a re-derivation from the source prefix. `.optional()` — EXTRACTED
167
+ // edges and legacy snapshots carry none; an OBSERVED edge is backfilled on its
168
+ // next observation.
169
+ grain: z2.enum(["file", "service"]).optional()
170
+ });
171
+
172
+ // src/nodes.ts
173
+ var CompatibleDriverSchema = z3.object({
174
+ name: z3.string(),
175
+ minVersion: z3.string()
176
+ });
177
+ var DiscoveredViaSchema = z3.enum(["static", "otel", "merged"]);
178
+ var ServiceNodeSchema = z3.object({
179
+ id: z3.string(),
180
+ type: z3.literal(NodeType.ServiceNode),
181
+ name: z3.string(),
182
+ language: z3.string(),
123
183
  // Deployment environment from the OTel `deployment.environment.name` attr
124
184
  // (with `deployment.environment` and resource-attr fallbacks). The literal
125
185
  // `'unknown'` is the honest sentinel when no env signal is present; static
126
186
  // extraction never sees env at extract time, so its ServiceNodes carry
127
187
  // `undefined` here and the id stays in the env-less wire format
128
188
  // `service:<name>`. See ADR-074 §2 and docs/contracts/env-dimension.md.
129
- env: z2.string().optional(),
189
+ env: z3.string().optional(),
130
190
  // Framework recorded by the static extractor when the install plan
131
191
  // dispatches a framework-specific path (Next.js, Remix, SvelteKit, Nuxt,
132
192
  // Astro). Optional enrichment — `undefined` for lib-only packages and
133
193
  // ambiguous repos. See ADR-074 §3 / docs/contracts/framework-installers.md.
134
- framework: z2.string().optional(),
194
+ framework: z3.string().optional(),
135
195
  // The hosting platform a static extractor recognized this service as
136
196
  // deployed to (`'cloudflare'` today) — a free string, same discipline as
137
197
  // `framework`, so a future platform needs no schema change. This is the
138
198
  // frontend's icon key at the service-rollup level (ADR-133,
139
199
  // docs/contracts/static-extraction.md).
140
- platform: z2.string().optional(),
200
+ platform: z3.string().optional(),
141
201
  discoveredVia: DiscoveredViaSchema.optional(),
142
- version: z2.string().optional(),
143
- dbConnectionTarget: z2.string().optional(),
144
- repoPath: z2.string().optional(),
145
- owner: z2.string().optional(),
146
- dependencies: z2.record(z2.string(), z2.string()).optional(),
202
+ version: z3.string().optional(),
203
+ dbConnectionTarget: z3.string().optional(),
204
+ repoPath: z3.string().optional(),
205
+ owner: z3.string().optional(),
206
+ dependencies: z3.record(z3.string(), z3.string()).optional(),
147
207
  // Hostnames OTel spans might mention for this service: compose service
148
208
  // names, k8s metadata.name (and the cluster-DNS variants), Dockerfile
149
209
  // labels, etc. resolveServiceId in ingest.ts checks these before falling
150
210
  // back to a FRONTIER placeholder.
151
- aliases: z2.array(z2.string()).optional(),
211
+ aliases: z3.array(z3.string()).optional(),
152
212
  // Optional. If set, services declare their `engines.node` here so γ #74's
153
213
  // node-engine compat check has something to test against.
154
- nodeEngine: z2.string().optional(),
155
- incompatibilities: z2.array(
214
+ nodeEngine: z3.string().optional(),
215
+ incompatibilities: z3.array(
156
216
  // Discriminated by `kind`. `driver-engine` is the original shape and
157
217
  // stays default for backward compatibility — older snapshots without a
158
218
  // `kind` field still parse via the union's `.optional()` discriminator
159
219
  // fallback. New kinds came in with γ #74.
160
- z2.union([
161
- z2.object({
162
- kind: z2.literal("driver-engine").optional(),
163
- driver: z2.string(),
164
- driverVersion: z2.string(),
165
- engine: z2.string(),
166
- engineVersion: z2.string(),
167
- reason: z2.string()
220
+ z3.union([
221
+ z3.object({
222
+ kind: z3.literal("driver-engine").optional(),
223
+ driver: z3.string(),
224
+ driverVersion: z3.string(),
225
+ engine: z3.string(),
226
+ engineVersion: z3.string(),
227
+ reason: z3.string()
168
228
  }),
169
- z2.object({
170
- kind: z2.literal("node-engine"),
171
- package: z2.string(),
172
- packageVersion: z2.string().optional(),
173
- requiredNodeVersion: z2.string(),
174
- declaredNodeEngine: z2.string().optional(),
175
- reason: z2.string()
229
+ z3.object({
230
+ kind: z3.literal("node-engine"),
231
+ package: z3.string(),
232
+ packageVersion: z3.string().optional(),
233
+ requiredNodeVersion: z3.string(),
234
+ declaredNodeEngine: z3.string().optional(),
235
+ reason: z3.string()
176
236
  }),
177
- z2.object({
178
- kind: z2.literal("package-conflict"),
179
- package: z2.string(),
180
- packageVersion: z2.string().optional(),
181
- requires: z2.object({
182
- name: z2.string(),
183
- minVersion: z2.string()
237
+ z3.object({
238
+ kind: z3.literal("package-conflict"),
239
+ package: z3.string(),
240
+ packageVersion: z3.string().optional(),
241
+ requires: z3.object({
242
+ name: z3.string(),
243
+ minVersion: z3.string()
184
244
  }),
185
- foundVersion: z2.string().optional(),
186
- reason: z2.string()
245
+ foundVersion: z3.string().optional(),
246
+ reason: z3.string()
187
247
  }),
188
- z2.object({
189
- kind: z2.literal("deprecated-api"),
190
- package: z2.string(),
191
- packageVersion: z2.string().optional(),
192
- reason: z2.string()
248
+ z3.object({
249
+ kind: z3.literal("deprecated-api"),
250
+ package: z3.string(),
251
+ packageVersion: z3.string().optional(),
252
+ reason: z3.string()
193
253
  })
194
254
  ])
195
255
  ).optional()
196
256
  });
197
- var DatabaseNodeSchema = z2.object({
198
- id: z2.string(),
199
- type: z2.literal(NodeType.DatabaseNode),
200
- name: z2.string(),
201
- engine: z2.string(),
202
- engineVersion: z2.string(),
203
- compatibleDrivers: z2.array(CompatibleDriverSchema),
204
- host: z2.string().optional(),
205
- port: z2.number().optional(),
257
+ var DatabaseNodeSchema = z3.object({
258
+ id: z3.string(),
259
+ type: z3.literal(NodeType.DatabaseNode),
260
+ name: z3.string(),
261
+ engine: z3.string(),
262
+ engineVersion: z3.string(),
263
+ compatibleDrivers: z3.array(CompatibleDriverSchema),
264
+ host: z3.string().optional(),
265
+ port: z3.number().optional(),
206
266
  discoveredVia: DiscoveredViaSchema.optional()
207
267
  });
208
- var ConfigNodeSchema = z2.object({
209
- id: z2.string(),
210
- type: z2.literal(NodeType.ConfigNode),
211
- name: z2.string(),
212
- path: z2.string(),
213
- fileType: z2.string()
268
+ var ConfigNodeSchema = z3.object({
269
+ id: z3.string(),
270
+ type: z3.literal(NodeType.ConfigNode),
271
+ name: z3.string(),
272
+ path: z3.string(),
273
+ fileType: z3.string()
214
274
  });
215
- var InfraNodeSchema = z2.object({
216
- id: z2.string(),
217
- type: z2.literal(NodeType.InfraNode),
218
- name: z2.string(),
219
- provider: z2.string(),
220
- region: z2.string().optional(),
221
- kind: z2.string().optional()
275
+ var ColumnAttrSchema = z3.object({
276
+ name: z3.string(),
277
+ provenances: z3.array(ProvenanceSchema),
278
+ confidence: z3.number().min(0).max(1)
222
279
  });
223
- var FrontierNodeSchema = z2.object({
224
- id: z2.string(),
225
- type: z2.literal(NodeType.FrontierNode),
226
- name: z2.string(),
227
- host: z2.string(),
228
- firstObserved: z2.string().datetime().optional(),
229
- lastObserved: z2.string().datetime().optional()
280
+ var InfraNodeSchema = z3.object({
281
+ id: z3.string(),
282
+ type: z3.literal(NodeType.InfraNode),
283
+ name: z3.string(),
284
+ provider: z3.string(),
285
+ region: z3.string().optional(),
286
+ kind: z3.string().optional(),
287
+ // Column-grain attributes on a table InfraNode (`sql-table`, `supabase-table`).
288
+ // Absent on a non-table InfraNode (a project node, a queue, a route). Optional
289
+ // schema growth (ADR-031); ADR-157 stamps the snapshot version because the field
290
+ // records a new grain the graph can now carry. See docs/contracts/schema.md.
291
+ columns: z3.array(ColumnAttrSchema).optional()
230
292
  });
231
- var FileNodeSchema = z2.object({
232
- id: z2.string(),
233
- type: z2.literal(NodeType.FileNode),
234
- service: z2.string(),
235
- path: z2.string(),
236
- language: z2.string().optional(),
293
+ var FrontierNodeSchema = z3.object({
294
+ id: z3.string(),
295
+ type: z3.literal(NodeType.FrontierNode),
296
+ name: z3.string(),
297
+ host: z3.string(),
298
+ firstObserved: z3.string().datetime().optional(),
299
+ lastObserved: z3.string().datetime().optional()
300
+ });
301
+ var FileNodeSchema = z3.object({
302
+ id: z3.string(),
303
+ type: z3.literal(NodeType.FileNode),
304
+ service: z3.string(),
305
+ path: z3.string(),
306
+ language: z3.string().optional(),
237
307
  discoveredVia: DiscoveredViaSchema.optional(),
238
308
  // The raw compiled `dist/...js` frame an OBSERVED call site was captured on,
239
309
  // preserved for diagnostic when ingest resolved it through a source map to
240
310
  // this original `src/...ts` (file-awareness.md §4 / `code.original_filepath`).
241
311
  // Absent when the call site was already source-grained.
242
- originalPath: z2.string().optional(),
312
+ originalPath: z3.string().optional(),
243
313
  // The hosting platform this file is the entry point for (`'cloudflare'`
244
314
  // today) — set on a Worker/Pages-Function's entry file only, mirroring
245
315
  // ServiceNode's own `platform` field. See `platformName` below.
246
- platform: z2.string().optional(),
316
+ platform: z3.string().optional(),
247
317
  // The platform's own name for this file's service, when the platform names
248
318
  // things differently than NEAT's manifest-derived serviceId (a Cloudflare
249
319
  // Worker's wrangler.toml/jsonc `name`, not `package.json#name`). This is the
@@ -251,67 +321,67 @@ var FileNodeSchema = z2.object({
251
321
  // connector's resolveTarget looks up against to fuse an OBSERVED signal onto
252
322
  // this exact FileNode (ADR-133, docs/contracts/static-extraction.md /
253
323
  // docs/contracts/connectors.md).
254
- platformName: z2.string().optional()
324
+ platformName: z3.string().optional()
255
325
  });
256
- var RouteNodeSchema = z2.object({
257
- id: z2.string(),
258
- type: z2.literal(NodeType.RouteNode),
259
- name: z2.string(),
260
- service: z2.string(),
261
- method: z2.string(),
262
- pathTemplate: z2.string(),
263
- path: z2.string(),
264
- line: z2.number().int().nonnegative().optional(),
265
- framework: z2.string().optional(),
326
+ var RouteNodeSchema = z3.object({
327
+ id: z3.string(),
328
+ type: z3.literal(NodeType.RouteNode),
329
+ name: z3.string(),
330
+ service: z3.string(),
331
+ method: z3.string(),
332
+ pathTemplate: z3.string(),
333
+ path: z3.string(),
334
+ line: z3.number().int().nonnegative().optional(),
335
+ framework: z3.string().optional(),
266
336
  discoveredVia: DiscoveredViaSchema.optional()
267
337
  });
268
- var GraphQLOperationNodeSchema = z2.object({
269
- id: z2.string(),
270
- type: z2.literal(NodeType.GraphQLOperationNode),
271
- name: z2.string(),
272
- service: z2.string(),
273
- operationType: z2.string(),
274
- operationName: z2.string(),
275
- path: z2.string().optional(),
276
- line: z2.number().int().nonnegative().optional(),
338
+ var GraphQLOperationNodeSchema = z3.object({
339
+ id: z3.string(),
340
+ type: z3.literal(NodeType.GraphQLOperationNode),
341
+ name: z3.string(),
342
+ service: z3.string(),
343
+ operationType: z3.string(),
344
+ operationName: z3.string(),
345
+ path: z3.string().optional(),
346
+ line: z3.number().int().nonnegative().optional(),
277
347
  discoveredVia: DiscoveredViaSchema.optional()
278
348
  });
279
- var GrpcMethodNodeSchema = z2.object({
280
- id: z2.string(),
281
- type: z2.literal(NodeType.GrpcMethodNode),
282
- name: z2.string(),
283
- rpcService: z2.string(),
284
- rpcMethod: z2.string(),
285
- path: z2.string().optional(),
286
- line: z2.number().int().nonnegative().optional(),
349
+ var GrpcMethodNodeSchema = z3.object({
350
+ id: z3.string(),
351
+ type: z3.literal(NodeType.GrpcMethodNode),
352
+ name: z3.string(),
353
+ rpcService: z3.string(),
354
+ rpcMethod: z3.string(),
355
+ path: z3.string().optional(),
356
+ line: z3.number().int().nonnegative().optional(),
287
357
  discoveredVia: DiscoveredViaSchema.optional()
288
358
  });
289
- var WebSocketChannelNodeSchema = z2.object({
290
- id: z2.string(),
291
- type: z2.literal(NodeType.WebSocketChannelNode),
292
- name: z2.string(),
293
- service: z2.string(),
294
- channel: z2.string(),
295
- path: z2.string().optional(),
296
- line: z2.number().int().nonnegative().optional(),
359
+ var WebSocketChannelNodeSchema = z3.object({
360
+ id: z3.string(),
361
+ type: z3.literal(NodeType.WebSocketChannelNode),
362
+ name: z3.string(),
363
+ service: z3.string(),
364
+ channel: z3.string(),
365
+ path: z3.string().optional(),
366
+ line: z3.number().int().nonnegative().optional(),
297
367
  discoveredVia: DiscoveredViaSchema.optional()
298
368
  });
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()
369
+ var SymbolKindSchema = z3.enum(["function", "method", "constructor", "class"]);
370
+ var SymbolSpanSchema = z3.object({
371
+ startLine: z3.number().int().nonnegative(),
372
+ endLine: z3.number().int().nonnegative()
303
373
  });
304
- var SymbolNodeSchema = z2.object({
305
- id: z2.string(),
306
- type: z2.literal(NodeType.SymbolNode),
374
+ var SymbolNodeSchema = z3.object({
375
+ id: z3.string(),
376
+ type: z3.literal(NodeType.SymbolNode),
307
377
  kind: SymbolKindSchema,
308
- qualname: z2.string(),
378
+ qualname: z3.string(),
309
379
  span: SymbolSpanSchema,
310
- service: z2.string(),
311
- relPath: z2.string(),
380
+ service: z3.string(),
381
+ relPath: z3.string(),
312
382
  discoveredVia: DiscoveredViaSchema.optional()
313
383
  });
314
- var GraphNodeSchema = z2.discriminatedUnion("type", [
384
+ var GraphNodeSchema = z3.discriminatedUnion("type", [
315
385
  ServiceNodeSchema,
316
386
  DatabaseNodeSchema,
317
387
  ConfigNodeSchema,
@@ -325,64 +395,6 @@ var GraphNodeSchema = z2.discriminatedUnion("type", [
325
395
  SymbolNodeSchema
326
396
  ]);
327
397
 
328
- // src/edges.ts
329
- import { z as z3 } from "zod";
330
- var ProvenanceSchema = z3.enum([
331
- Provenance.EXTRACTED,
332
- Provenance.INFERRED,
333
- Provenance.OBSERVED,
334
- Provenance.STALE
335
- ]);
336
- var EdgeTypeSchema = z3.enum([
337
- EdgeType.CALLS,
338
- EdgeType.DEPENDS_ON,
339
- EdgeType.CONNECTS_TO,
340
- EdgeType.CONFIGURED_BY,
341
- EdgeType.PUBLISHES_TO,
342
- EdgeType.CONSUMES_FROM,
343
- EdgeType.RUNS_ON,
344
- EdgeType.CONTAINS,
345
- EdgeType.IMPORTS,
346
- EdgeType.INHERITS,
347
- EdgeType.IMPLEMENTS
348
- ]);
349
- var EdgeEvidenceSchema = z3.object({
350
- file: z3.string(),
351
- line: z3.number().int().nonnegative().optional(),
352
- snippet: z3.string().optional(),
353
- // HTTP shape of a recognised client call site (ADR-119). Present on a
354
- // client↔route CALLS edge so the edge records the method + path-template the
355
- // client named, alongside the file:line it named them at. Absent on every
356
- // other edge — a config or infra edge has no HTTP method.
357
- method: z3.string().optional(),
358
- pathTemplate: z3.string().optional()
359
- });
360
- var EdgeSignalSchema = z3.object({
361
- spanCount: z3.number().int().nonnegative(),
362
- errorCount: z3.number().int().nonnegative(),
363
- lastObservedAgeMs: z3.number().nonnegative().optional()
364
- });
365
- var GraphEdgeSchema = z3.object({
366
- id: z3.string(),
367
- source: z3.string(),
368
- target: z3.string(),
369
- type: EdgeTypeSchema,
370
- provenance: ProvenanceSchema,
371
- confidence: z3.number().min(0).max(1).optional(),
372
- lastObserved: z3.string().datetime().optional(),
373
- callCount: z3.number().int().nonnegative().optional(),
374
- evidence: EdgeEvidenceSchema.optional(),
375
- signal: EdgeSignalSchema.optional(),
376
- // OBSERVED grain (ADR-142): `file` when the edge originates from a source
377
- // file's call site (a `file:` source + `evidence`), `service` for the coarse
378
- // fallback where no call site was captured. Makes "service-grained only as a
379
- // labeled fallback" (connector gate #803) a stored, machine-readable fact
380
- // instead of a re-derivation from the source prefix. `.optional()` — EXTRACTED
381
- // edges and legacy snapshots carry none; an OBSERVED edge is backfilled on its
382
- // next observation.
383
- grain: z3.enum(["file", "service"]).optional()
384
- });
385
-
386
398
  // src/events.ts
387
399
  import { z as z4 } from "zod";
388
400
  var SpanAttributesSchema = z4.record(
@@ -902,14 +914,20 @@ var commonFields = {
902
914
  var MissingObservedDivergenceSchema = z8.object({
903
915
  type: z8.literal("missing-observed"),
904
916
  ...commonFields,
905
- edgeType: EdgeTypeSchema,
906
- extracted: GraphEdgeSchema
917
+ edgeType: EdgeTypeSchema.optional(),
918
+ extracted: GraphEdgeSchema.optional(),
919
+ // Column locus (ADR-157 §4): the `sql-table` node id and the declared-only column.
920
+ table: z8.string().optional(),
921
+ column: z8.string().optional()
907
922
  });
908
923
  var MissingExtractedDivergenceSchema = z8.object({
909
924
  type: z8.literal("missing-extracted"),
910
925
  ...commonFields,
911
- edgeType: EdgeTypeSchema,
912
- observed: GraphEdgeSchema
926
+ edgeType: EdgeTypeSchema.optional(),
927
+ observed: GraphEdgeSchema.optional(),
928
+ // Column locus (ADR-157 §4): the `sql-table` node id and the observed-only column.
929
+ table: z8.string().optional(),
930
+ column: z8.string().optional()
913
931
  });
914
932
  var CompatibilityVerdictSchema = z8.enum(["incompatible", "deprecated", "unknown"]);
915
933
  var VersionMismatchDivergenceSchema = z8.object({
@@ -1162,6 +1180,7 @@ export {
1162
1180
  BlastRadiusResultSchema,
1163
1181
  BlastRadiusRuleSchema,
1164
1182
  CheckPoliciesScopeSchema,
1183
+ ColumnAttrSchema,
1165
1184
  CompatRuleRefSchema,
1166
1185
  CompatViolationDivergenceSchema,
1167
1186
  CompatibilityRuleSchema,