@suss/ir-core 0.5.10 → 0.6.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.
@@ -1,432 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * One thing that gets deployed and runs on its own: a Lambda function,
5
- * an ECS task's container, a plain container, or a k8s deployment.
6
- */
7
-
8
- /**
9
- * `instanceName` is the stable identifier the deployment medium uses:
10
- * the CFN logical resource id for Lambda and ECS, the deployment name
11
- * for k8s, the container name for a plain container.
12
- */
13
- declare const DeployableUnitSchema: z.ZodObject<{
14
- deploymentTarget: z.ZodEnum<{
15
- lambda: "lambda";
16
- "ecs-task": "ecs-task";
17
- container: "container";
18
- "k8s-deployment": "k8s-deployment";
19
- }>;
20
- instanceName: z.ZodString;
21
- }, z.core.$strip>;
22
- type DeployableUnit = z.infer<typeof DeployableUnitSchema>;
23
- /**
24
- * The `instanceName` for an ECS task's container: the task definition's
25
- * own logical id, plus the container name from CFN's
26
- * `ContainerDefinitions[*].Name`. Everyone who writes an ECS
27
- * `DeployableUnit`, and everyone who matches a routing edge against
28
- * one, has to put the two together the same way, so they all call this.
29
- */
30
- declare function ecsContainerInstanceName(taskDefinitionLogicalId: string, containerName: string): string;
31
-
32
- declare const FunctionCallSemanticsSchema: z.ZodObject<{
33
- name: z.ZodLiteral<"function-call">;
34
- module: z.ZodOptional<z.ZodString>;
35
- exportName: z.ZodOptional<z.ZodString>;
36
- package: z.ZodOptional<z.ZodString>;
37
- exportPath: z.ZodOptional<z.ZodArray<z.ZodString>>;
38
- }, z.core.$strip>;
39
- type FunctionCallSemantics = z.infer<typeof FunctionCallSemanticsSchema>;
40
-
41
- declare const GraphqlOperationSemanticsSchema: z.ZodObject<{
42
- name: z.ZodLiteral<"graphql-operation">;
43
- operationName: z.ZodOptional<z.ZodString>;
44
- operationType: z.ZodEnum<{
45
- query: "query";
46
- mutation: "mutation";
47
- subscription: "subscription";
48
- }>;
49
- }, z.core.$strip>;
50
- type GraphqlOperationSemantics = z.infer<typeof GraphqlOperationSemanticsSchema>;
51
-
52
- declare const GraphqlResolverSemanticsSchema: z.ZodObject<{
53
- name: z.ZodLiteral<"graphql-resolver">;
54
- typeName: z.ZodNullable<z.ZodString>;
55
- fieldName: z.ZodString;
56
- }, z.core.$strip>;
57
- type GraphqlResolverSemantics = z.infer<typeof GraphqlResolverSemanticsSchema>;
58
-
59
- declare const MessageBusSemanticsSchema: z.ZodObject<{
60
- name: z.ZodLiteral<"message-bus">;
61
- messageBus: z.ZodEnum<{
62
- sqs: "sqs";
63
- sns: "sns";
64
- s3: "s3";
65
- eventbridge: "eventbridge";
66
- bullmq: "bullmq";
67
- kafka: "kafka";
68
- nats: "nats";
69
- }>;
70
- channel: z.ZodNullable<z.ZodString>;
71
- }, z.core.$strip>;
72
- type MessageBusSemantics = z.infer<typeof MessageBusSemanticsSchema>;
73
- /**
74
- * The bus technologies the schema allows. It comes from the enum, so a
75
- * value added there cannot drift from a hand-written copy elsewhere.
76
- */
77
- type MessageBusTechnology = MessageBusSemantics["messageBus"];
78
-
79
- /**
80
- * Where the protocol modules come together.
81
- *
82
- * Each protocol under this directory exports one
83
- * `BoundarySemanticsDefinition`. This file lists them twice, once for
84
- * the schema union and once for the behavior lookup, and the type check
85
- * at the bottom fails compilation if the two lists ever cover different
86
- * sets. Adding a protocol changes this file and no other, by one line in
87
- * each list.
88
- */
89
-
90
- /**
91
- * The discriminated union every boundary binding validates against.
92
- * Built from the protocol modules' own schemas.
93
- */
94
- declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
95
- name: z.ZodLiteral<"rest">;
96
- method: z.ZodNullable<z.ZodString>;
97
- path: z.ZodNullable<z.ZodString>;
98
- declaredResponses: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
99
- }, z.core.$strip>, z.ZodObject<{
100
- name: z.ZodLiteral<"function-call">;
101
- module: z.ZodOptional<z.ZodString>;
102
- exportName: z.ZodOptional<z.ZodString>;
103
- package: z.ZodOptional<z.ZodString>;
104
- exportPath: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
- }, z.core.$strip>, z.ZodObject<{
106
- name: z.ZodLiteral<"graphql-resolver">;
107
- typeName: z.ZodNullable<z.ZodString>;
108
- fieldName: z.ZodString;
109
- }, z.core.$strip>, z.ZodObject<{
110
- name: z.ZodLiteral<"graphql-operation">;
111
- operationName: z.ZodOptional<z.ZodString>;
112
- operationType: z.ZodEnum<{
113
- query: "query";
114
- mutation: "mutation";
115
- subscription: "subscription";
116
- }>;
117
- }, z.core.$strip>, z.ZodObject<{
118
- deploymentTarget: z.ZodEnum<{
119
- lambda: "lambda";
120
- "ecs-task": "ecs-task";
121
- container: "container";
122
- "k8s-deployment": "k8s-deployment";
123
- }>;
124
- instanceName: z.ZodString;
125
- name: z.ZodLiteral<"runtime-config">;
126
- }, z.core.$strip>, z.ZodObject<{
127
- name: z.ZodLiteral<"storage-relational">;
128
- storageSystem: z.ZodEnum<{
129
- postgres: "postgres";
130
- mysql: "mysql";
131
- sqlite: "sqlite";
132
- }>;
133
- scope: z.ZodString;
134
- table: z.ZodNullable<z.ZodString>;
135
- }, z.core.$strip>, z.ZodObject<{
136
- name: z.ZodLiteral<"message-bus">;
137
- messageBus: z.ZodEnum<{
138
- sqs: "sqs";
139
- sns: "sns";
140
- s3: "s3";
141
- eventbridge: "eventbridge";
142
- bullmq: "bullmq";
143
- kafka: "kafka";
144
- nats: "nats";
145
- }>;
146
- channel: z.ZodNullable<z.ZodString>;
147
- }, z.core.$strip>], "name">;
148
- type Semantics = z.infer<typeof SemanticsSchema>;
149
-
150
- declare const RestSemanticsSchema: z.ZodObject<{
151
- name: z.ZodLiteral<"rest">;
152
- method: z.ZodNullable<z.ZodString>;
153
- path: z.ZodNullable<z.ZodString>;
154
- declaredResponses: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
155
- }, z.core.$strip>;
156
- type RestSemantics = z.infer<typeof RestSemanticsSchema>;
157
- /**
158
- * Normalize a route path to a canonical form for matching.
159
- *
160
- * - Converts Express-style params (`:id`) to brace-style (`{id}`)
161
- * - Strips trailing slashes (except bare `/`)
162
- * - Lowercases the static segments (params stay case-sensitive)
163
- */
164
- declare function normalizePath(path: string): string;
165
- /**
166
- * Whether two REST methods mean the same thing. Equal methods agree,
167
- * and `"*"` agrees with any stated method, because a handler that
168
- * responds to every method responds to this one. A null method was never
169
- * stated, so it agrees with nothing: there is no claim to agree with.
170
- *
171
- * This is the counterpart of `busesAgree`. No list of methods appears
172
- * here, so a wildcard pairs with whatever methods consumers write.
173
- */
174
- declare function methodsAgree(a: string | null, b: string | null): boolean;
175
- /** Whether a declared route path admits a concrete request path. */
176
- declare function routePathAdmits(declaredPath: string, requestPath: string): boolean;
177
-
178
- /**
179
- * The pairing key is `(deploymentTarget, instanceName)`, which is
180
- * exactly a deployable unit, so the two fields come from
181
- * `DeployableUnitSchema` instead of being written out a second time.
182
- */
183
- declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
184
- deploymentTarget: z.ZodEnum<{
185
- lambda: "lambda";
186
- "ecs-task": "ecs-task";
187
- container: "container";
188
- "k8s-deployment": "k8s-deployment";
189
- }>;
190
- instanceName: z.ZodString;
191
- name: z.ZodLiteral<"runtime-config">;
192
- }, z.core.$strip>;
193
- type RuntimeConfigSemantics = z.infer<typeof RuntimeConfigSemanticsSchema>;
194
-
195
- declare const StorageRelationalSemanticsSchema: z.ZodObject<{
196
- name: z.ZodLiteral<"storage-relational">;
197
- storageSystem: z.ZodEnum<{
198
- postgres: "postgres";
199
- mysql: "mysql";
200
- sqlite: "sqlite";
201
- }>;
202
- scope: z.ZodString;
203
- table: z.ZodNullable<z.ZodString>;
204
- }, z.core.$strip>;
205
- type StorageRelationalSemantics = z.infer<typeof StorageRelationalSemanticsSchema>;
206
-
207
- /**
208
- * @suss/ir-core schemas: primitives shared by every suss IR.
209
- *
210
- * These are the types that any IR built on suss references: the
211
- * structure of a value (`TypeShape`), the identity of a boundary
212
- * (`BoundaryBinding` and its `Semantics` variants), where something is
213
- * in the source (`SourceLocation`), and how much to trust a claim
214
- * (`Confidence`). Behavioural summaries, intent docs, and later on
215
- * observation records all speak in these terms, so they are defined
216
- * here, in one place none of those IRs needs another IR to reach.
217
- *
218
- * The schemas are the single source of truth, and the package's
219
- * `index.ts` derives the types from them with `z.infer`.
220
- */
221
-
222
- declare const ConfidenceSourceSchema: z.ZodEnum<{
223
- inferred_static: "inferred_static";
224
- inferred_ai: "inferred_ai";
225
- declared: "declared";
226
- derived: "derived";
227
- }>;
228
- declare const ConfidenceLevelSchema: z.ZodEnum<{
229
- high: "high";
230
- medium: "medium";
231
- low: "low";
232
- }>;
233
- /**
234
- * What came of corroborating a claim by running the code
235
- * (`suss corroborate`). Inputs that satisfy the claim's own conditions
236
- * are generated and run through the function, and the observation
237
- * either agreed every time (`observed`), disagreed at least once
238
- * (`refuted`, which is either an extractor bug or a surprise, and the
239
- * counterexample says which input), or never produced a verdict
240
- * (`untested`, meaning no satisfying input was found, or every
241
- * satisfying run hit a dependency the harness cannot supply).
242
- *
243
- * Corroboration adds observations to a derivation. It is extra
244
- * evidence, and it never rewrites the derived claim.
245
- */
246
- declare const CorroborationSchema: z.ZodObject<{
247
- outcome: z.ZodEnum<{
248
- observed: "observed";
249
- refuted: "refuted";
250
- untested: "untested";
251
- }>;
252
- runs: z.ZodNumber;
253
- counterexample: z.ZodOptional<z.ZodUnknown>;
254
- reason: z.ZodOptional<z.ZodString>;
255
- }, z.core.$strip>;
256
- declare const ConfidenceInfoSchema: z.ZodObject<{
257
- source: z.ZodEnum<{
258
- inferred_static: "inferred_static";
259
- inferred_ai: "inferred_ai";
260
- declared: "declared";
261
- derived: "derived";
262
- }>;
263
- level: z.ZodEnum<{
264
- high: "high";
265
- medium: "medium";
266
- low: "low";
267
- }>;
268
- corroboration: z.ZodOptional<z.ZodObject<{
269
- outcome: z.ZodEnum<{
270
- observed: "observed";
271
- refuted: "refuted";
272
- untested: "untested";
273
- }>;
274
- runs: z.ZodNumber;
275
- counterexample: z.ZodOptional<z.ZodUnknown>;
276
- reason: z.ZodOptional<z.ZodString>;
277
- }, z.core.$strip>>;
278
- }, z.core.$strip>;
279
- declare const SourceLocationSchema: z.ZodObject<{
280
- file: z.ZodString;
281
- range: z.ZodObject<{
282
- start: z.ZodNumber;
283
- end: z.ZodNumber;
284
- }, z.core.$strip>;
285
- exportName: z.ZodNullable<z.ZodString>;
286
- workspace: z.ZodOptional<z.ZodString>;
287
- }, z.core.$strip>;
288
- declare const BoundaryBindingSchema: z.ZodObject<{
289
- transport: z.ZodString;
290
- semantics: z.ZodDiscriminatedUnion<[z.ZodObject<{
291
- name: z.ZodLiteral<"rest">;
292
- method: z.ZodNullable<z.ZodString>;
293
- path: z.ZodNullable<z.ZodString>;
294
- declaredResponses: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
295
- }, z.core.$strip>, z.ZodObject<{
296
- name: z.ZodLiteral<"function-call">;
297
- module: z.ZodOptional<z.ZodString>;
298
- exportName: z.ZodOptional<z.ZodString>;
299
- package: z.ZodOptional<z.ZodString>;
300
- exportPath: z.ZodOptional<z.ZodArray<z.ZodString>>;
301
- }, z.core.$strip>, z.ZodObject<{
302
- name: z.ZodLiteral<"graphql-resolver">;
303
- typeName: z.ZodNullable<z.ZodString>;
304
- fieldName: z.ZodString;
305
- }, z.core.$strip>, z.ZodObject<{
306
- name: z.ZodLiteral<"graphql-operation">;
307
- operationName: z.ZodOptional<z.ZodString>;
308
- operationType: z.ZodEnum<{
309
- query: "query";
310
- mutation: "mutation";
311
- subscription: "subscription";
312
- }>;
313
- }, z.core.$strip>, z.ZodObject<{
314
- deploymentTarget: z.ZodEnum<{
315
- lambda: "lambda";
316
- "ecs-task": "ecs-task";
317
- container: "container";
318
- "k8s-deployment": "k8s-deployment";
319
- }>;
320
- instanceName: z.ZodString;
321
- name: z.ZodLiteral<"runtime-config">;
322
- }, z.core.$strip>, z.ZodObject<{
323
- name: z.ZodLiteral<"storage-relational">;
324
- storageSystem: z.ZodEnum<{
325
- postgres: "postgres";
326
- mysql: "mysql";
327
- sqlite: "sqlite";
328
- }>;
329
- scope: z.ZodString;
330
- table: z.ZodNullable<z.ZodString>;
331
- }, z.core.$strip>, z.ZodObject<{
332
- name: z.ZodLiteral<"message-bus">;
333
- messageBus: z.ZodEnum<{
334
- sqs: "sqs";
335
- sns: "sns";
336
- s3: "s3";
337
- eventbridge: "eventbridge";
338
- bullmq: "bullmq";
339
- kafka: "kafka";
340
- nats: "nats";
341
- }>;
342
- channel: z.ZodNullable<z.ZodString>;
343
- }, z.core.$strip>], "name">;
344
- recognition: z.ZodString;
345
- }, z.core.$strip>;
346
- type TypeShape = {
347
- type: "record";
348
- properties: Record<string, TypeShape>;
349
- spreads?: Array<{
350
- sourceText: string;
351
- }> | undefined;
352
- } | {
353
- type: "dictionary";
354
- values: TypeShape;
355
- } | {
356
- type: "array";
357
- items: TypeShape;
358
- } | {
359
- type: "literal";
360
- value: string | number | boolean;
361
- raw?: string | undefined;
362
- } | {
363
- type: "text";
364
- } | {
365
- type: "integer";
366
- } | {
367
- type: "number";
368
- } | {
369
- type: "boolean";
370
- } | {
371
- type: "null";
372
- } | {
373
- type: "undefined";
374
- } | {
375
- type: "union";
376
- variants: TypeShape[];
377
- } | {
378
- type: "ref";
379
- name: string;
380
- /**
381
- * Where this type is written down, when it is written down
382
- * anywhere. It is the key into the summary's table of definitions.
383
- *
384
- * A name does not identify a type. Every instantiation of one
385
- * generic reports the generic's own name and file, so `Omit<User,
386
- * "secret">` and `Omit<Order, "total">` are both `Omit`, and a
387
- * table keyed on that gives the second one the first one's fields.
388
- * This key is built from what the type actually is.
389
- */
390
- def?: string | undefined;
391
- /**
392
- * The file that declares this type, when the project declares it.
393
- * Absent for a name the language or a dependency owns, which means
394
- * the same thing everywhere.
395
- *
396
- * A name on its own does not identify a type. Two modules each
397
- * declaring a `User` produce the same ref, and a checker comparing
398
- * them has nothing to go on. This is what tells them apart.
399
- */
400
- from?: string | undefined;
401
- } | {
402
- type: "unknown";
403
- };
404
- /**
405
- * The key a table of definitions uses for the type a ref points at.
406
- *
407
- * A ref has the name and the file that declares it, and that pair
408
- * already identifies the type, so a table keyed on it needs nothing new
409
- * on the ref. A name that the language or a dependency owns has no
410
- * file, and keys on the name alone.
411
- */
412
- declare function typeDefinitionKey(ref: {
413
- def?: string | undefined;
414
- }): string | null;
415
- declare const TypeShapeSchema: z.ZodType<TypeShape>;
416
- /**
417
- * A shape with the definitions it refers to substituted back into it.
418
- *
419
- * Comparing two shapes means comparing their structure, and a ref has
420
- * none. Rather than teach every comparison to look in a table, the
421
- * definitions go back into the shape once and everything downstream
422
- * reads what it always read.
423
- *
424
- * Substituting a definition is not a level of nesting, so it does not
425
- * spend depth. Counting it meant a type six deep came back three deep,
426
- * and a consumer reading a field past that was told the provider did
427
- * not have it. A type that refers to itself is stopped by the names
428
- * already substituted on this path, the shape walk's own cycle guard.
429
- */
430
- declare function withDefinitionsInlined(shape: TypeShape, definitions: Record<string, TypeShape> | undefined, depth?: number, inProgress?: ReadonlySet<string>): TypeShape;
431
-
432
- export { BoundaryBindingSchema as B, ConfidenceInfoSchema as C, type DeployableUnit as D, type FunctionCallSemantics as F, type GraphqlOperationSemantics as G, type MessageBusSemantics as M, type RestSemantics as R, type Semantics as S, type TypeShape as T, ConfidenceLevelSchema as a, ConfidenceSourceSchema as b, CorroborationSchema as c, SourceLocationSchema as d, type MessageBusTechnology as e, DeployableUnitSchema as f, FunctionCallSemanticsSchema as g, GraphqlOperationSemanticsSchema as h, type GraphqlResolverSemantics as i, GraphqlResolverSemanticsSchema as j, MessageBusSemanticsSchema as k, RestSemanticsSchema as l, type RuntimeConfigSemantics as m, RuntimeConfigSemanticsSchema as n, SemanticsSchema as o, type StorageRelationalSemantics as p, StorageRelationalSemanticsSchema as q, TypeShapeSchema as r, ecsContainerInstanceName as s, methodsAgree as t, normalizePath as u, routePathAdmits as v, typeDefinitionKey as w, withDefinitionsInlined as x };