@suss/ir-core 0.1.0 → 0.2.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/{chunk-BQEWYFCF.js → chunk-JIFTLUZX.js} +60 -9
- package/dist/index.cjs +96 -13
- package/dist/index.d.cts +35 -4
- package/dist/index.d.ts +35 -4
- package/dist/index.js +38 -6
- package/dist/schemas.cjs +64 -10
- package/dist/schemas.d.cts +74 -6
- package/dist/schemas.d.ts +74 -6
- package/dist/schemas.js +9 -3
- package/package.json +1 -1
|
@@ -84,19 +84,19 @@ var GraphqlOperationSemanticsSchema = z.object({
|
|
|
84
84
|
operationName: z.string().optional(),
|
|
85
85
|
operationType: z.enum(["query", "mutation", "subscription"])
|
|
86
86
|
});
|
|
87
|
-
var
|
|
88
|
-
name: z.literal("runtime-config"),
|
|
87
|
+
var DeployableUnitSchema = z.object({
|
|
89
88
|
deploymentTarget: z.enum([
|
|
90
89
|
"lambda",
|
|
91
90
|
"ecs-task",
|
|
92
91
|
"container",
|
|
93
92
|
"k8s-deployment"
|
|
94
93
|
]),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
// An empty name would agree with every other empty name, so a unit
|
|
95
|
+
// that names nothing has to leave the field off instead.
|
|
96
|
+
instanceName: z.string().min(1)
|
|
97
|
+
});
|
|
98
|
+
var RuntimeConfigSemanticsSchema = DeployableUnitSchema.extend({
|
|
99
|
+
name: z.literal("runtime-config")
|
|
100
100
|
});
|
|
101
101
|
var StorageRelationalSemanticsSchema = z.object({
|
|
102
102
|
name: z.literal("storage-relational"),
|
|
@@ -129,6 +129,9 @@ var BoundaryBindingSchema = z.object({
|
|
|
129
129
|
semantics: SemanticsSchema,
|
|
130
130
|
recognition: z.string()
|
|
131
131
|
});
|
|
132
|
+
function typeDefinitionKey(ref) {
|
|
133
|
+
return ref.def ?? null;
|
|
134
|
+
}
|
|
132
135
|
var TypeShapeSchema = z.lazy(
|
|
133
136
|
() => z.discriminatedUnion("type", [
|
|
134
137
|
z.object({
|
|
@@ -153,10 +156,55 @@ var TypeShapeSchema = z.lazy(
|
|
|
153
156
|
type: z.literal("union"),
|
|
154
157
|
variants: z.array(TypeShapeSchema)
|
|
155
158
|
}),
|
|
156
|
-
z.object({
|
|
159
|
+
z.object({
|
|
160
|
+
type: z.literal("ref"),
|
|
161
|
+
name: z.string(),
|
|
162
|
+
from: z.string().optional(),
|
|
163
|
+
def: z.string().optional()
|
|
164
|
+
}),
|
|
157
165
|
z.object({ type: z.literal("unknown") })
|
|
158
166
|
])
|
|
159
167
|
);
|
|
168
|
+
var MAX_DEFINITION_DEPTH = 6;
|
|
169
|
+
function withDefinitionsInlined(shape, definitions, depth = 0, inProgress = /* @__PURE__ */ new Set()) {
|
|
170
|
+
if (definitions === void 0 || depth >= MAX_DEFINITION_DEPTH) {
|
|
171
|
+
return shape;
|
|
172
|
+
}
|
|
173
|
+
const deeper = (inner) => withDefinitionsInlined(inner, definitions, depth + 1, inProgress);
|
|
174
|
+
if (shape.type === "ref") {
|
|
175
|
+
const key = typeDefinitionKey(shape);
|
|
176
|
+
if (key === null) {
|
|
177
|
+
return shape;
|
|
178
|
+
}
|
|
179
|
+
const defined = definitions[key];
|
|
180
|
+
if (defined === void 0 || inProgress.has(key)) {
|
|
181
|
+
return shape;
|
|
182
|
+
}
|
|
183
|
+
return withDefinitionsInlined(
|
|
184
|
+
defined,
|
|
185
|
+
definitions,
|
|
186
|
+
depth,
|
|
187
|
+
/* @__PURE__ */ new Set([...inProgress, key])
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
if (shape.type === "record") {
|
|
191
|
+
const properties = {};
|
|
192
|
+
for (const [name, value] of Object.entries(shape.properties)) {
|
|
193
|
+
properties[name] = deeper(value);
|
|
194
|
+
}
|
|
195
|
+
return { ...shape, properties };
|
|
196
|
+
}
|
|
197
|
+
if (shape.type === "array") {
|
|
198
|
+
return { ...shape, items: deeper(shape.items) };
|
|
199
|
+
}
|
|
200
|
+
if (shape.type === "dictionary") {
|
|
201
|
+
return { ...shape, values: deeper(shape.values) };
|
|
202
|
+
}
|
|
203
|
+
if (shape.type === "union") {
|
|
204
|
+
return { ...shape, variants: shape.variants.map(deeper) };
|
|
205
|
+
}
|
|
206
|
+
return shape;
|
|
207
|
+
}
|
|
160
208
|
|
|
161
209
|
export {
|
|
162
210
|
ConfidenceSourceSchema,
|
|
@@ -168,10 +216,13 @@ export {
|
|
|
168
216
|
FunctionCallSemanticsSchema,
|
|
169
217
|
GraphqlResolverSemanticsSchema,
|
|
170
218
|
GraphqlOperationSemanticsSchema,
|
|
219
|
+
DeployableUnitSchema,
|
|
171
220
|
RuntimeConfigSemanticsSchema,
|
|
172
221
|
StorageRelationalSemanticsSchema,
|
|
173
222
|
MessageBusSemanticsSchema,
|
|
174
223
|
SemanticsSchema,
|
|
175
224
|
BoundaryBindingSchema,
|
|
176
|
-
|
|
225
|
+
typeDefinitionKey,
|
|
226
|
+
TypeShapeSchema,
|
|
227
|
+
withDefinitionsInlined
|
|
177
228
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
ConfidenceLevelSchema: () => ConfidenceLevelSchema,
|
|
26
26
|
ConfidenceSourceSchema: () => ConfidenceSourceSchema,
|
|
27
27
|
CorroborationSchema: () => CorroborationSchema,
|
|
28
|
+
DeployableUnitSchema: () => DeployableUnitSchema,
|
|
28
29
|
FunctionCallSemanticsSchema: () => FunctionCallSemanticsSchema,
|
|
29
30
|
GraphqlOperationSemanticsSchema: () => GraphqlOperationSemanticsSchema,
|
|
30
31
|
GraphqlResolverSemanticsSchema: () => GraphqlResolverSemanticsSchema,
|
|
@@ -42,7 +43,10 @@ __export(index_exports, {
|
|
|
42
43
|
boundaryKey: () => boundaryKey,
|
|
43
44
|
busesAgree: () => busesAgree,
|
|
44
45
|
channelsPair: () => channelsPair,
|
|
46
|
+
codeScopePath: () => codeScopePath,
|
|
45
47
|
countsForThreshold: () => countsForThreshold,
|
|
48
|
+
dispatchByType: () => dispatchByType,
|
|
49
|
+
fileInCodeScope: () => fileInCodeScope,
|
|
46
50
|
functionCallBinding: () => functionCallBinding,
|
|
47
51
|
graphqlOperationBinding: () => graphqlOperationBinding,
|
|
48
52
|
graphqlResolverBinding: () => graphqlResolverBinding,
|
|
@@ -55,7 +59,9 @@ __export(index_exports, {
|
|
|
55
59
|
ruleBoundaryMatchesKey: () => ruleBoundaryMatchesKey,
|
|
56
60
|
runtimeConfigBinding: () => runtimeConfigBinding,
|
|
57
61
|
storageRelationalBinding: () => storageRelationalBinding,
|
|
58
|
-
|
|
62
|
+
typeDefinitionKey: () => typeDefinitionKey,
|
|
63
|
+
validateRule: () => validateRule,
|
|
64
|
+
withDefinitionsInlined: () => withDefinitionsInlined
|
|
59
65
|
});
|
|
60
66
|
module.exports = __toCommonJS(index_exports);
|
|
61
67
|
|
|
@@ -145,19 +151,19 @@ var GraphqlOperationSemanticsSchema = import_zod.z.object({
|
|
|
145
151
|
operationName: import_zod.z.string().optional(),
|
|
146
152
|
operationType: import_zod.z.enum(["query", "mutation", "subscription"])
|
|
147
153
|
});
|
|
148
|
-
var
|
|
149
|
-
name: import_zod.z.literal("runtime-config"),
|
|
154
|
+
var DeployableUnitSchema = import_zod.z.object({
|
|
150
155
|
deploymentTarget: import_zod.z.enum([
|
|
151
156
|
"lambda",
|
|
152
157
|
"ecs-task",
|
|
153
158
|
"container",
|
|
154
159
|
"k8s-deployment"
|
|
155
160
|
]),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
// An empty name would agree with every other empty name, so a unit
|
|
162
|
+
// that names nothing has to leave the field off instead.
|
|
163
|
+
instanceName: import_zod.z.string().min(1)
|
|
164
|
+
});
|
|
165
|
+
var RuntimeConfigSemanticsSchema = DeployableUnitSchema.extend({
|
|
166
|
+
name: import_zod.z.literal("runtime-config")
|
|
161
167
|
});
|
|
162
168
|
var StorageRelationalSemanticsSchema = import_zod.z.object({
|
|
163
169
|
name: import_zod.z.literal("storage-relational"),
|
|
@@ -190,6 +196,9 @@ var BoundaryBindingSchema = import_zod.z.object({
|
|
|
190
196
|
semantics: SemanticsSchema,
|
|
191
197
|
recognition: import_zod.z.string()
|
|
192
198
|
});
|
|
199
|
+
function typeDefinitionKey(ref) {
|
|
200
|
+
return ref.def ?? null;
|
|
201
|
+
}
|
|
193
202
|
var TypeShapeSchema = import_zod.z.lazy(
|
|
194
203
|
() => import_zod.z.discriminatedUnion("type", [
|
|
195
204
|
import_zod.z.object({
|
|
@@ -214,10 +223,55 @@ var TypeShapeSchema = import_zod.z.lazy(
|
|
|
214
223
|
type: import_zod.z.literal("union"),
|
|
215
224
|
variants: import_zod.z.array(TypeShapeSchema)
|
|
216
225
|
}),
|
|
217
|
-
import_zod.z.object({
|
|
226
|
+
import_zod.z.object({
|
|
227
|
+
type: import_zod.z.literal("ref"),
|
|
228
|
+
name: import_zod.z.string(),
|
|
229
|
+
from: import_zod.z.string().optional(),
|
|
230
|
+
def: import_zod.z.string().optional()
|
|
231
|
+
}),
|
|
218
232
|
import_zod.z.object({ type: import_zod.z.literal("unknown") })
|
|
219
233
|
])
|
|
220
234
|
);
|
|
235
|
+
var MAX_DEFINITION_DEPTH = 6;
|
|
236
|
+
function withDefinitionsInlined(shape, definitions, depth = 0, inProgress = /* @__PURE__ */ new Set()) {
|
|
237
|
+
if (definitions === void 0 || depth >= MAX_DEFINITION_DEPTH) {
|
|
238
|
+
return shape;
|
|
239
|
+
}
|
|
240
|
+
const deeper = (inner) => withDefinitionsInlined(inner, definitions, depth + 1, inProgress);
|
|
241
|
+
if (shape.type === "ref") {
|
|
242
|
+
const key = typeDefinitionKey(shape);
|
|
243
|
+
if (key === null) {
|
|
244
|
+
return shape;
|
|
245
|
+
}
|
|
246
|
+
const defined = definitions[key];
|
|
247
|
+
if (defined === void 0 || inProgress.has(key)) {
|
|
248
|
+
return shape;
|
|
249
|
+
}
|
|
250
|
+
return withDefinitionsInlined(
|
|
251
|
+
defined,
|
|
252
|
+
definitions,
|
|
253
|
+
depth,
|
|
254
|
+
/* @__PURE__ */ new Set([...inProgress, key])
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (shape.type === "record") {
|
|
258
|
+
const properties = {};
|
|
259
|
+
for (const [name, value] of Object.entries(shape.properties)) {
|
|
260
|
+
properties[name] = deeper(value);
|
|
261
|
+
}
|
|
262
|
+
return { ...shape, properties };
|
|
263
|
+
}
|
|
264
|
+
if (shape.type === "array") {
|
|
265
|
+
return { ...shape, items: deeper(shape.items) };
|
|
266
|
+
}
|
|
267
|
+
if (shape.type === "dictionary") {
|
|
268
|
+
return { ...shape, values: deeper(shape.values) };
|
|
269
|
+
}
|
|
270
|
+
if (shape.type === "union") {
|
|
271
|
+
return { ...shape, variants: shape.variants.map(deeper) };
|
|
272
|
+
}
|
|
273
|
+
return shape;
|
|
274
|
+
}
|
|
221
275
|
|
|
222
276
|
// src/channel.ts
|
|
223
277
|
function parseChannel(channel) {
|
|
@@ -259,6 +313,9 @@ function boundaryKey(binding) {
|
|
|
259
313
|
return `${method} ${path}`;
|
|
260
314
|
}
|
|
261
315
|
if (semantics.name === "graphql-resolver") {
|
|
316
|
+
if (semantics.typeName === "" || semantics.fieldName === "") {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
262
319
|
return `gql:${semantics.typeName}.${semantics.fieldName}`;
|
|
263
320
|
}
|
|
264
321
|
if (semantics.name === "message-bus") {
|
|
@@ -277,6 +334,25 @@ function boundaryKey(binding) {
|
|
|
277
334
|
return null;
|
|
278
335
|
}
|
|
279
336
|
|
|
337
|
+
// src/codeScope.ts
|
|
338
|
+
function codeScopePath(raw) {
|
|
339
|
+
return raw.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
340
|
+
}
|
|
341
|
+
function fileInCodeScope(file, scope) {
|
|
342
|
+
const prefix = codeScopePath(scope);
|
|
343
|
+
if (prefix === "" || prefix === ".") {
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
const path = codeScopePath(file);
|
|
347
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/dispatch.ts
|
|
351
|
+
function dispatchByType(table, value) {
|
|
352
|
+
const handler = table[value.type];
|
|
353
|
+
return handler(value);
|
|
354
|
+
}
|
|
355
|
+
|
|
280
356
|
// src/suppressions.ts
|
|
281
357
|
var import_zod2 = require("zod");
|
|
282
358
|
var SuppressionSideSchema = import_zod2.z.object({
|
|
@@ -409,10 +485,11 @@ function bodyShapesMatch(actual, declared) {
|
|
|
409
485
|
if (actual.type === "unknown" || declared.type === "unknown") {
|
|
410
486
|
return "unknown";
|
|
411
487
|
}
|
|
488
|
+
if (actual.type === "ref" && declared.type === "ref") {
|
|
489
|
+
const sameDeclaration = actual.from !== void 0 && actual.from === declared.from && actual.name === declared.name;
|
|
490
|
+
return sameDeclaration ? "match" : "unknown";
|
|
491
|
+
}
|
|
412
492
|
if (actual.type === "ref" || declared.type === "ref") {
|
|
413
|
-
if (actual.type === "ref" && declared.type === "ref" && actual.name === declared.name) {
|
|
414
|
-
return "match";
|
|
415
|
-
}
|
|
416
493
|
return "unknown";
|
|
417
494
|
}
|
|
418
495
|
if (actual.type === "union") {
|
|
@@ -644,6 +721,7 @@ function messageBusBinding(opts) {
|
|
|
644
721
|
ConfidenceLevelSchema,
|
|
645
722
|
ConfidenceSourceSchema,
|
|
646
723
|
CorroborationSchema,
|
|
724
|
+
DeployableUnitSchema,
|
|
647
725
|
FunctionCallSemanticsSchema,
|
|
648
726
|
GraphqlOperationSemanticsSchema,
|
|
649
727
|
GraphqlResolverSemanticsSchema,
|
|
@@ -661,7 +739,10 @@ function messageBusBinding(opts) {
|
|
|
661
739
|
boundaryKey,
|
|
662
740
|
busesAgree,
|
|
663
741
|
channelsPair,
|
|
742
|
+
codeScopePath,
|
|
664
743
|
countsForThreshold,
|
|
744
|
+
dispatchByType,
|
|
745
|
+
fileInCodeScope,
|
|
665
746
|
functionCallBinding,
|
|
666
747
|
graphqlOperationBinding,
|
|
667
748
|
graphqlResolverBinding,
|
|
@@ -674,5 +755,7 @@ function messageBusBinding(opts) {
|
|
|
674
755
|
ruleBoundaryMatchesKey,
|
|
675
756
|
runtimeConfigBinding,
|
|
676
757
|
storageRelationalBinding,
|
|
677
|
-
|
|
758
|
+
typeDefinitionKey,
|
|
759
|
+
validateRule,
|
|
760
|
+
withDefinitionsInlined
|
|
678
761
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, SemanticsSchema, SourceLocationSchema } from './schemas.cjs';
|
|
3
|
-
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema } from './schemas.cjs';
|
|
2
|
+
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, DeployableUnitSchema, SemanticsSchema, SourceLocationSchema } from './schemas.cjs';
|
|
3
|
+
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema, typeDefinitionKey, withDefinitionsInlined } from './schemas.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Normalize a route path to a canonical form for matching.
|
|
@@ -14,7 +14,9 @@ declare function normalizePath(path: string): string;
|
|
|
14
14
|
* Compute a stable string key from a boundary binding for grouping.
|
|
15
15
|
* Dispatches on `semantics.name`:
|
|
16
16
|
* - `rest` → `"METHOD /normalized/path"` (null if method or path empty)
|
|
17
|
-
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"`
|
|
17
|
+
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"` (null when
|
|
18
|
+
* either is empty, which is how a resolver says the source never
|
|
19
|
+
* named the field it answers)
|
|
18
20
|
* - `message-bus` → `"bus:<messageBus> <subject>"` (null if the
|
|
19
21
|
* subject is empty)
|
|
20
22
|
* - `function-call` → `"fn:<package>::<exportPath>"` when both
|
|
@@ -45,6 +47,34 @@ declare function busesAgree(a: string | null, b: string | null): boolean;
|
|
|
45
47
|
/** Whether two channels name the same subject on agreeing buses. */
|
|
46
48
|
declare function channelsPair(a: string, b: string): boolean;
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The canonical form of a code-scope directory: no leading `./`, no
|
|
52
|
+
* trailing slash, no surrounding whitespace. An empty result means the
|
|
53
|
+
* scope names the project root.
|
|
54
|
+
*/
|
|
55
|
+
declare function codeScopePath(raw: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a project-relative file sits inside a code scope. Matching
|
|
58
|
+
* stops at a segment boundary, so `src/foo` covers `src/foo/a.ts` and
|
|
59
|
+
* never `src/foobar/a.ts`. A scope naming the project root covers
|
|
60
|
+
* every file.
|
|
61
|
+
*
|
|
62
|
+
* Both arguments pass through `codeScopePath`, so a scope stored under
|
|
63
|
+
* either of the older trailing-slash conventions still reads correctly.
|
|
64
|
+
*/
|
|
65
|
+
declare function fileInCodeScope(file: string, scope: string): boolean;
|
|
66
|
+
|
|
67
|
+
type DispatchTable<T extends {
|
|
68
|
+
type: string;
|
|
69
|
+
}, R> = {
|
|
70
|
+
[K in T["type"]]: (variant: Extract<T, {
|
|
71
|
+
type: K;
|
|
72
|
+
}>) => R;
|
|
73
|
+
};
|
|
74
|
+
declare function dispatchByType<T extends {
|
|
75
|
+
type: string;
|
|
76
|
+
}, R>(table: DispatchTable<T, R>, value: T): R;
|
|
77
|
+
|
|
48
78
|
declare const SuppressionRuleSchema: z.ZodObject<{
|
|
49
79
|
kind: z.ZodOptional<z.ZodString>;
|
|
50
80
|
boundary: z.ZodOptional<z.ZodString>;
|
|
@@ -204,6 +234,7 @@ type StorageRelationalSemantics = Extract<Semantics, {
|
|
|
204
234
|
type MessageBusSemantics = Extract<Semantics, {
|
|
205
235
|
name: "message-bus";
|
|
206
236
|
}>;
|
|
237
|
+
type DeployableUnit = z.infer<typeof DeployableUnitSchema>;
|
|
207
238
|
|
|
208
239
|
/**
|
|
209
240
|
* Build a REST-semantics binding. `method` and `path` can be empty
|
|
@@ -293,4 +324,4 @@ declare function messageBusBinding(opts: {
|
|
|
293
324
|
channel: string;
|
|
294
325
|
}): BoundaryBinding;
|
|
295
326
|
|
|
296
|
-
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, type ParsedChannel, type RestSemantics, type RuntimeConfigSemantics, type Semantics, SemanticsSchema, type SourceLocation, SourceLocationSchema, type StorageRelationalSemantics, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, busesAgree, channelsPair, countsForThreshold, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, parseChannel, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|
|
327
|
+
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DeployableUnit, DeployableUnitSchema, type DispatchTable, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, type ParsedChannel, type RestSemantics, type RuntimeConfigSemantics, type Semantics, SemanticsSchema, type SourceLocation, SourceLocationSchema, type StorageRelationalSemantics, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, busesAgree, channelsPair, codeScopePath, countsForThreshold, dispatchByType, fileInCodeScope, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, parseChannel, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, SemanticsSchema, SourceLocationSchema } from './schemas.js';
|
|
3
|
-
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema } from './schemas.js';
|
|
2
|
+
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, DeployableUnitSchema, SemanticsSchema, SourceLocationSchema } from './schemas.js';
|
|
3
|
+
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema, typeDefinitionKey, withDefinitionsInlined } from './schemas.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Normalize a route path to a canonical form for matching.
|
|
@@ -14,7 +14,9 @@ declare function normalizePath(path: string): string;
|
|
|
14
14
|
* Compute a stable string key from a boundary binding for grouping.
|
|
15
15
|
* Dispatches on `semantics.name`:
|
|
16
16
|
* - `rest` → `"METHOD /normalized/path"` (null if method or path empty)
|
|
17
|
-
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"`
|
|
17
|
+
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"` (null when
|
|
18
|
+
* either is empty, which is how a resolver says the source never
|
|
19
|
+
* named the field it answers)
|
|
18
20
|
* - `message-bus` → `"bus:<messageBus> <subject>"` (null if the
|
|
19
21
|
* subject is empty)
|
|
20
22
|
* - `function-call` → `"fn:<package>::<exportPath>"` when both
|
|
@@ -45,6 +47,34 @@ declare function busesAgree(a: string | null, b: string | null): boolean;
|
|
|
45
47
|
/** Whether two channels name the same subject on agreeing buses. */
|
|
46
48
|
declare function channelsPair(a: string, b: string): boolean;
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The canonical form of a code-scope directory: no leading `./`, no
|
|
52
|
+
* trailing slash, no surrounding whitespace. An empty result means the
|
|
53
|
+
* scope names the project root.
|
|
54
|
+
*/
|
|
55
|
+
declare function codeScopePath(raw: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a project-relative file sits inside a code scope. Matching
|
|
58
|
+
* stops at a segment boundary, so `src/foo` covers `src/foo/a.ts` and
|
|
59
|
+
* never `src/foobar/a.ts`. A scope naming the project root covers
|
|
60
|
+
* every file.
|
|
61
|
+
*
|
|
62
|
+
* Both arguments pass through `codeScopePath`, so a scope stored under
|
|
63
|
+
* either of the older trailing-slash conventions still reads correctly.
|
|
64
|
+
*/
|
|
65
|
+
declare function fileInCodeScope(file: string, scope: string): boolean;
|
|
66
|
+
|
|
67
|
+
type DispatchTable<T extends {
|
|
68
|
+
type: string;
|
|
69
|
+
}, R> = {
|
|
70
|
+
[K in T["type"]]: (variant: Extract<T, {
|
|
71
|
+
type: K;
|
|
72
|
+
}>) => R;
|
|
73
|
+
};
|
|
74
|
+
declare function dispatchByType<T extends {
|
|
75
|
+
type: string;
|
|
76
|
+
}, R>(table: DispatchTable<T, R>, value: T): R;
|
|
77
|
+
|
|
48
78
|
declare const SuppressionRuleSchema: z.ZodObject<{
|
|
49
79
|
kind: z.ZodOptional<z.ZodString>;
|
|
50
80
|
boundary: z.ZodOptional<z.ZodString>;
|
|
@@ -204,6 +234,7 @@ type StorageRelationalSemantics = Extract<Semantics, {
|
|
|
204
234
|
type MessageBusSemantics = Extract<Semantics, {
|
|
205
235
|
name: "message-bus";
|
|
206
236
|
}>;
|
|
237
|
+
type DeployableUnit = z.infer<typeof DeployableUnitSchema>;
|
|
207
238
|
|
|
208
239
|
/**
|
|
209
240
|
* Build a REST-semantics binding. `method` and `path` can be empty
|
|
@@ -293,4 +324,4 @@ declare function messageBusBinding(opts: {
|
|
|
293
324
|
channel: string;
|
|
294
325
|
}): BoundaryBinding;
|
|
295
326
|
|
|
296
|
-
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, type ParsedChannel, type RestSemantics, type RuntimeConfigSemantics, type Semantics, SemanticsSchema, type SourceLocation, SourceLocationSchema, type StorageRelationalSemantics, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, busesAgree, channelsPair, countsForThreshold, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, parseChannel, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|
|
327
|
+
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DeployableUnit, DeployableUnitSchema, type DispatchTable, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, type ParsedChannel, type RestSemantics, type RuntimeConfigSemantics, type Semantics, SemanticsSchema, type SourceLocation, SourceLocationSchema, type StorageRelationalSemantics, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, busesAgree, channelsPair, codeScopePath, countsForThreshold, dispatchByType, fileInCodeScope, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, parseChannel, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ConfidenceLevelSchema,
|
|
5
5
|
ConfidenceSourceSchema,
|
|
6
6
|
CorroborationSchema,
|
|
7
|
+
DeployableUnitSchema,
|
|
7
8
|
FunctionCallSemanticsSchema,
|
|
8
9
|
GraphqlOperationSemanticsSchema,
|
|
9
10
|
GraphqlResolverSemanticsSchema,
|
|
@@ -13,8 +14,10 @@ import {
|
|
|
13
14
|
SemanticsSchema,
|
|
14
15
|
SourceLocationSchema,
|
|
15
16
|
StorageRelationalSemanticsSchema,
|
|
16
|
-
TypeShapeSchema
|
|
17
|
-
|
|
17
|
+
TypeShapeSchema,
|
|
18
|
+
typeDefinitionKey,
|
|
19
|
+
withDefinitionsInlined
|
|
20
|
+
} from "./chunk-JIFTLUZX.js";
|
|
18
21
|
|
|
19
22
|
// src/channel.ts
|
|
20
23
|
function parseChannel(channel) {
|
|
@@ -56,6 +59,9 @@ function boundaryKey(binding) {
|
|
|
56
59
|
return `${method} ${path}`;
|
|
57
60
|
}
|
|
58
61
|
if (semantics.name === "graphql-resolver") {
|
|
62
|
+
if (semantics.typeName === "" || semantics.fieldName === "") {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
59
65
|
return `gql:${semantics.typeName}.${semantics.fieldName}`;
|
|
60
66
|
}
|
|
61
67
|
if (semantics.name === "message-bus") {
|
|
@@ -74,6 +80,25 @@ function boundaryKey(binding) {
|
|
|
74
80
|
return null;
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
// src/codeScope.ts
|
|
84
|
+
function codeScopePath(raw) {
|
|
85
|
+
return raw.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
86
|
+
}
|
|
87
|
+
function fileInCodeScope(file, scope) {
|
|
88
|
+
const prefix = codeScopePath(scope);
|
|
89
|
+
if (prefix === "" || prefix === ".") {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
const path = codeScopePath(file);
|
|
93
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/dispatch.ts
|
|
97
|
+
function dispatchByType(table, value) {
|
|
98
|
+
const handler = table[value.type];
|
|
99
|
+
return handler(value);
|
|
100
|
+
}
|
|
101
|
+
|
|
77
102
|
// src/suppressions.ts
|
|
78
103
|
import { z } from "zod";
|
|
79
104
|
var SuppressionSideSchema = z.object({
|
|
@@ -206,10 +231,11 @@ function bodyShapesMatch(actual, declared) {
|
|
|
206
231
|
if (actual.type === "unknown" || declared.type === "unknown") {
|
|
207
232
|
return "unknown";
|
|
208
233
|
}
|
|
234
|
+
if (actual.type === "ref" && declared.type === "ref") {
|
|
235
|
+
const sameDeclaration = actual.from !== void 0 && actual.from === declared.from && actual.name === declared.name;
|
|
236
|
+
return sameDeclaration ? "match" : "unknown";
|
|
237
|
+
}
|
|
209
238
|
if (actual.type === "ref" || declared.type === "ref") {
|
|
210
|
-
if (actual.type === "ref" && declared.type === "ref" && actual.name === declared.name) {
|
|
211
|
-
return "match";
|
|
212
|
-
}
|
|
213
239
|
return "unknown";
|
|
214
240
|
}
|
|
215
241
|
if (actual.type === "union") {
|
|
@@ -440,6 +466,7 @@ export {
|
|
|
440
466
|
ConfidenceLevelSchema,
|
|
441
467
|
ConfidenceSourceSchema,
|
|
442
468
|
CorroborationSchema,
|
|
469
|
+
DeployableUnitSchema,
|
|
443
470
|
FunctionCallSemanticsSchema,
|
|
444
471
|
GraphqlOperationSemanticsSchema,
|
|
445
472
|
GraphqlResolverSemanticsSchema,
|
|
@@ -457,7 +484,10 @@ export {
|
|
|
457
484
|
boundaryKey,
|
|
458
485
|
busesAgree,
|
|
459
486
|
channelsPair,
|
|
487
|
+
codeScopePath,
|
|
460
488
|
countsForThreshold,
|
|
489
|
+
dispatchByType,
|
|
490
|
+
fileInCodeScope,
|
|
461
491
|
functionCallBinding,
|
|
462
492
|
graphqlOperationBinding,
|
|
463
493
|
graphqlResolverBinding,
|
|
@@ -470,5 +500,7 @@ export {
|
|
|
470
500
|
ruleBoundaryMatchesKey,
|
|
471
501
|
runtimeConfigBinding,
|
|
472
502
|
storageRelationalBinding,
|
|
473
|
-
|
|
503
|
+
typeDefinitionKey,
|
|
504
|
+
validateRule,
|
|
505
|
+
withDefinitionsInlined
|
|
474
506
|
};
|
package/dist/schemas.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(schemas_exports, {
|
|
|
25
25
|
ConfidenceLevelSchema: () => ConfidenceLevelSchema,
|
|
26
26
|
ConfidenceSourceSchema: () => ConfidenceSourceSchema,
|
|
27
27
|
CorroborationSchema: () => CorroborationSchema,
|
|
28
|
+
DeployableUnitSchema: () => DeployableUnitSchema,
|
|
28
29
|
FunctionCallSemanticsSchema: () => FunctionCallSemanticsSchema,
|
|
29
30
|
GraphqlOperationSemanticsSchema: () => GraphqlOperationSemanticsSchema,
|
|
30
31
|
GraphqlResolverSemanticsSchema: () => GraphqlResolverSemanticsSchema,
|
|
@@ -34,7 +35,9 @@ __export(schemas_exports, {
|
|
|
34
35
|
SemanticsSchema: () => SemanticsSchema,
|
|
35
36
|
SourceLocationSchema: () => SourceLocationSchema,
|
|
36
37
|
StorageRelationalSemanticsSchema: () => StorageRelationalSemanticsSchema,
|
|
37
|
-
TypeShapeSchema: () => TypeShapeSchema
|
|
38
|
+
TypeShapeSchema: () => TypeShapeSchema,
|
|
39
|
+
typeDefinitionKey: () => typeDefinitionKey,
|
|
40
|
+
withDefinitionsInlined: () => withDefinitionsInlined
|
|
38
41
|
});
|
|
39
42
|
module.exports = __toCommonJS(schemas_exports);
|
|
40
43
|
var import_zod = require("zod");
|
|
@@ -122,19 +125,19 @@ var GraphqlOperationSemanticsSchema = import_zod.z.object({
|
|
|
122
125
|
operationName: import_zod.z.string().optional(),
|
|
123
126
|
operationType: import_zod.z.enum(["query", "mutation", "subscription"])
|
|
124
127
|
});
|
|
125
|
-
var
|
|
126
|
-
name: import_zod.z.literal("runtime-config"),
|
|
128
|
+
var DeployableUnitSchema = import_zod.z.object({
|
|
127
129
|
deploymentTarget: import_zod.z.enum([
|
|
128
130
|
"lambda",
|
|
129
131
|
"ecs-task",
|
|
130
132
|
"container",
|
|
131
133
|
"k8s-deployment"
|
|
132
134
|
]),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
// An empty name would agree with every other empty name, so a unit
|
|
136
|
+
// that names nothing has to leave the field off instead.
|
|
137
|
+
instanceName: import_zod.z.string().min(1)
|
|
138
|
+
});
|
|
139
|
+
var RuntimeConfigSemanticsSchema = DeployableUnitSchema.extend({
|
|
140
|
+
name: import_zod.z.literal("runtime-config")
|
|
138
141
|
});
|
|
139
142
|
var StorageRelationalSemanticsSchema = import_zod.z.object({
|
|
140
143
|
name: import_zod.z.literal("storage-relational"),
|
|
@@ -167,6 +170,9 @@ var BoundaryBindingSchema = import_zod.z.object({
|
|
|
167
170
|
semantics: SemanticsSchema,
|
|
168
171
|
recognition: import_zod.z.string()
|
|
169
172
|
});
|
|
173
|
+
function typeDefinitionKey(ref) {
|
|
174
|
+
return ref.def ?? null;
|
|
175
|
+
}
|
|
170
176
|
var TypeShapeSchema = import_zod.z.lazy(
|
|
171
177
|
() => import_zod.z.discriminatedUnion("type", [
|
|
172
178
|
import_zod.z.object({
|
|
@@ -191,10 +197,55 @@ var TypeShapeSchema = import_zod.z.lazy(
|
|
|
191
197
|
type: import_zod.z.literal("union"),
|
|
192
198
|
variants: import_zod.z.array(TypeShapeSchema)
|
|
193
199
|
}),
|
|
194
|
-
import_zod.z.object({
|
|
200
|
+
import_zod.z.object({
|
|
201
|
+
type: import_zod.z.literal("ref"),
|
|
202
|
+
name: import_zod.z.string(),
|
|
203
|
+
from: import_zod.z.string().optional(),
|
|
204
|
+
def: import_zod.z.string().optional()
|
|
205
|
+
}),
|
|
195
206
|
import_zod.z.object({ type: import_zod.z.literal("unknown") })
|
|
196
207
|
])
|
|
197
208
|
);
|
|
209
|
+
var MAX_DEFINITION_DEPTH = 6;
|
|
210
|
+
function withDefinitionsInlined(shape, definitions, depth = 0, inProgress = /* @__PURE__ */ new Set()) {
|
|
211
|
+
if (definitions === void 0 || depth >= MAX_DEFINITION_DEPTH) {
|
|
212
|
+
return shape;
|
|
213
|
+
}
|
|
214
|
+
const deeper = (inner) => withDefinitionsInlined(inner, definitions, depth + 1, inProgress);
|
|
215
|
+
if (shape.type === "ref") {
|
|
216
|
+
const key = typeDefinitionKey(shape);
|
|
217
|
+
if (key === null) {
|
|
218
|
+
return shape;
|
|
219
|
+
}
|
|
220
|
+
const defined = definitions[key];
|
|
221
|
+
if (defined === void 0 || inProgress.has(key)) {
|
|
222
|
+
return shape;
|
|
223
|
+
}
|
|
224
|
+
return withDefinitionsInlined(
|
|
225
|
+
defined,
|
|
226
|
+
definitions,
|
|
227
|
+
depth,
|
|
228
|
+
/* @__PURE__ */ new Set([...inProgress, key])
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (shape.type === "record") {
|
|
232
|
+
const properties = {};
|
|
233
|
+
for (const [name, value] of Object.entries(shape.properties)) {
|
|
234
|
+
properties[name] = deeper(value);
|
|
235
|
+
}
|
|
236
|
+
return { ...shape, properties };
|
|
237
|
+
}
|
|
238
|
+
if (shape.type === "array") {
|
|
239
|
+
return { ...shape, items: deeper(shape.items) };
|
|
240
|
+
}
|
|
241
|
+
if (shape.type === "dictionary") {
|
|
242
|
+
return { ...shape, values: deeper(shape.values) };
|
|
243
|
+
}
|
|
244
|
+
if (shape.type === "union") {
|
|
245
|
+
return { ...shape, variants: shape.variants.map(deeper) };
|
|
246
|
+
}
|
|
247
|
+
return shape;
|
|
248
|
+
}
|
|
198
249
|
// Annotate the CommonJS export names for ESM import in node:
|
|
199
250
|
0 && (module.exports = {
|
|
200
251
|
BoundaryBindingSchema,
|
|
@@ -202,6 +253,7 @@ var TypeShapeSchema = import_zod.z.lazy(
|
|
|
202
253
|
ConfidenceLevelSchema,
|
|
203
254
|
ConfidenceSourceSchema,
|
|
204
255
|
CorroborationSchema,
|
|
256
|
+
DeployableUnitSchema,
|
|
205
257
|
FunctionCallSemanticsSchema,
|
|
206
258
|
GraphqlOperationSemanticsSchema,
|
|
207
259
|
GraphqlResolverSemanticsSchema,
|
|
@@ -211,5 +263,7 @@ var TypeShapeSchema = import_zod.z.lazy(
|
|
|
211
263
|
SemanticsSchema,
|
|
212
264
|
SourceLocationSchema,
|
|
213
265
|
StorageRelationalSemanticsSchema,
|
|
214
|
-
TypeShapeSchema
|
|
266
|
+
TypeShapeSchema,
|
|
267
|
+
typeDefinitionKey,
|
|
268
|
+
withDefinitionsInlined
|
|
215
269
|
});
|
package/dist/schemas.d.cts
CHANGED
|
@@ -101,13 +101,32 @@ declare const GraphqlOperationSemanticsSchema: z.ZodObject<{
|
|
|
101
101
|
}>;
|
|
102
102
|
}, z.core.$strip>;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* One thing that gets deployed and runs on its own: a Lambda
|
|
105
|
+
* function, an ECS task's container, a plain container, a k8s
|
|
106
|
+
* deployment.
|
|
107
|
+
*
|
|
108
|
+
* `instanceName` is the stable identifier the deployment medium uses:
|
|
109
|
+
* the CFN logical resource id for Lambda and ECS, the deployment name
|
|
110
|
+
* for k8s, the container name for a plain container.
|
|
111
|
+
*/
|
|
112
|
+
declare const DeployableUnitSchema: z.ZodObject<{
|
|
113
|
+
deploymentTarget: z.ZodEnum<{
|
|
114
|
+
lambda: "lambda";
|
|
115
|
+
"ecs-task": "ecs-task";
|
|
116
|
+
container: "container";
|
|
117
|
+
"k8s-deployment": "k8s-deployment";
|
|
118
|
+
}>;
|
|
119
|
+
instanceName: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
/**
|
|
122
|
+
* Provider-side runtime configuration channel: env vars and their
|
|
105
123
|
* declared values on a deployable unit. The channel is the boundary;
|
|
106
124
|
* env var names are FIELDS on its contract. Pairing key:
|
|
107
|
-
* `(deploymentTarget, instanceName)
|
|
125
|
+
* `(deploymentTarget, instanceName)`, which is exactly a deployable
|
|
126
|
+
* unit, so the two fields come from `DeployableUnitSchema` rather
|
|
127
|
+
* than being spelled a second time.
|
|
108
128
|
*/
|
|
109
129
|
declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
|
|
110
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
111
130
|
deploymentTarget: z.ZodEnum<{
|
|
112
131
|
lambda: "lambda";
|
|
113
132
|
"ecs-task": "ecs-task";
|
|
@@ -115,6 +134,7 @@ declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
|
|
|
115
134
|
"k8s-deployment": "k8s-deployment";
|
|
116
135
|
}>;
|
|
117
136
|
instanceName: z.ZodString;
|
|
137
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
118
138
|
}, z.core.$strip>;
|
|
119
139
|
/**
|
|
120
140
|
* Provider-side relational storage table. Columns are FIELDS on the
|
|
@@ -179,7 +199,6 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
179
199
|
subscription: "subscription";
|
|
180
200
|
}>;
|
|
181
201
|
}, z.core.$strip>, z.ZodObject<{
|
|
182
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
183
202
|
deploymentTarget: z.ZodEnum<{
|
|
184
203
|
lambda: "lambda";
|
|
185
204
|
"ecs-task": "ecs-task";
|
|
@@ -187,6 +206,7 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
187
206
|
"k8s-deployment": "k8s-deployment";
|
|
188
207
|
}>;
|
|
189
208
|
instanceName: z.ZodString;
|
|
209
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
190
210
|
}, z.core.$strip>, z.ZodObject<{
|
|
191
211
|
name: z.ZodLiteral<"storage-relational">;
|
|
192
212
|
storageSystem: z.ZodEnum<{
|
|
@@ -233,7 +253,6 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
233
253
|
subscription: "subscription";
|
|
234
254
|
}>;
|
|
235
255
|
}, z.core.$strip>, z.ZodObject<{
|
|
236
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
237
256
|
deploymentTarget: z.ZodEnum<{
|
|
238
257
|
lambda: "lambda";
|
|
239
258
|
"ecs-task": "ecs-task";
|
|
@@ -241,6 +260,7 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
241
260
|
"k8s-deployment": "k8s-deployment";
|
|
242
261
|
}>;
|
|
243
262
|
instanceName: z.ZodString;
|
|
263
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
244
264
|
}, z.core.$strip>, z.ZodObject<{
|
|
245
265
|
name: z.ZodLiteral<"storage-relational">;
|
|
246
266
|
storageSystem: z.ZodEnum<{
|
|
@@ -297,9 +317,57 @@ type TypeShape = {
|
|
|
297
317
|
} | {
|
|
298
318
|
type: "ref";
|
|
299
319
|
name: string;
|
|
320
|
+
/**
|
|
321
|
+
* Where this type is written down, when it is. The key into the
|
|
322
|
+
* summary's table of definitions.
|
|
323
|
+
*
|
|
324
|
+
* A name does not identify a type. Every instantiation of one
|
|
325
|
+
* generic reports the generic's own name and file, so `Omit<User,
|
|
326
|
+
* "secret">` and `Omit<Order, "total">` are both `Omit`, and a
|
|
327
|
+
* table keyed on that hands the second one the first one's
|
|
328
|
+
* fields. This is built from what the type actually is.
|
|
329
|
+
*/
|
|
330
|
+
def?: string | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* The file that declares this type, when the project declares it.
|
|
333
|
+
* Absent for a name the language or a dependency owns, which means
|
|
334
|
+
* the same thing everywhere.
|
|
335
|
+
*
|
|
336
|
+
* A name on its own does not identify a type. Two modules each
|
|
337
|
+
* declaring a `User` produce the same ref, and a checker comparing
|
|
338
|
+
* them has nothing to go on. This is what tells them apart.
|
|
339
|
+
*/
|
|
340
|
+
from?: string | undefined;
|
|
300
341
|
} | {
|
|
301
342
|
type: "unknown";
|
|
302
343
|
};
|
|
344
|
+
/**
|
|
345
|
+
* How a table of definitions names the type a ref points at.
|
|
346
|
+
*
|
|
347
|
+
* A ref carries the name and the file that declares it, and that pair
|
|
348
|
+
* already identifies the type, so a table keyed on it needs nothing new
|
|
349
|
+
* on the ref. A name the language or a dependency owns has no file and
|
|
350
|
+
* keys on the name alone.
|
|
351
|
+
*/
|
|
352
|
+
declare function typeDefinitionKey(ref: {
|
|
353
|
+
def?: string | undefined;
|
|
354
|
+
}): string | null;
|
|
303
355
|
declare const TypeShapeSchema: z.ZodType<TypeShape>;
|
|
356
|
+
/**
|
|
357
|
+
* A shape with the definitions it names put back into it.
|
|
358
|
+
*
|
|
359
|
+
* Comparing two shapes means comparing their structure, and a ref has
|
|
360
|
+
* none. Rather than teach every comparison to look in a table, the
|
|
361
|
+
* table goes back into the shape once, and everything downstream reads
|
|
362
|
+
* what it always read.
|
|
363
|
+
*
|
|
364
|
+
* Putting a definition back is a substitution rather than a level of
|
|
365
|
+
* nesting, so it does not spend depth. Counting it did: a type six
|
|
366
|
+
* deep came back three deep, and a consumer reading a field past that
|
|
367
|
+
* point was told the provider did not have it. What stops a type that
|
|
368
|
+
* names itself is the set of names already being put back on this
|
|
369
|
+
* path, which is how the shape walk guards its own cycles.
|
|
370
|
+
*/
|
|
371
|
+
declare function withDefinitionsInlined(shape: TypeShape, definitions: Record<string, TypeShape> | undefined, depth?: number, inProgress?: ReadonlySet<string>): TypeShape;
|
|
304
372
|
|
|
305
|
-
export { BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, SemanticsSchema, SourceLocationSchema, StorageRelationalSemanticsSchema, type TypeShape, TypeShapeSchema };
|
|
373
|
+
export { BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, DeployableUnitSchema, FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, SemanticsSchema, SourceLocationSchema, StorageRelationalSemanticsSchema, type TypeShape, TypeShapeSchema, typeDefinitionKey, withDefinitionsInlined };
|
package/dist/schemas.d.ts
CHANGED
|
@@ -101,13 +101,32 @@ declare const GraphqlOperationSemanticsSchema: z.ZodObject<{
|
|
|
101
101
|
}>;
|
|
102
102
|
}, z.core.$strip>;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* One thing that gets deployed and runs on its own: a Lambda
|
|
105
|
+
* function, an ECS task's container, a plain container, a k8s
|
|
106
|
+
* deployment.
|
|
107
|
+
*
|
|
108
|
+
* `instanceName` is the stable identifier the deployment medium uses:
|
|
109
|
+
* the CFN logical resource id for Lambda and ECS, the deployment name
|
|
110
|
+
* for k8s, the container name for a plain container.
|
|
111
|
+
*/
|
|
112
|
+
declare const DeployableUnitSchema: z.ZodObject<{
|
|
113
|
+
deploymentTarget: z.ZodEnum<{
|
|
114
|
+
lambda: "lambda";
|
|
115
|
+
"ecs-task": "ecs-task";
|
|
116
|
+
container: "container";
|
|
117
|
+
"k8s-deployment": "k8s-deployment";
|
|
118
|
+
}>;
|
|
119
|
+
instanceName: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
/**
|
|
122
|
+
* Provider-side runtime configuration channel: env vars and their
|
|
105
123
|
* declared values on a deployable unit. The channel is the boundary;
|
|
106
124
|
* env var names are FIELDS on its contract. Pairing key:
|
|
107
|
-
* `(deploymentTarget, instanceName)
|
|
125
|
+
* `(deploymentTarget, instanceName)`, which is exactly a deployable
|
|
126
|
+
* unit, so the two fields come from `DeployableUnitSchema` rather
|
|
127
|
+
* than being spelled a second time.
|
|
108
128
|
*/
|
|
109
129
|
declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
|
|
110
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
111
130
|
deploymentTarget: z.ZodEnum<{
|
|
112
131
|
lambda: "lambda";
|
|
113
132
|
"ecs-task": "ecs-task";
|
|
@@ -115,6 +134,7 @@ declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
|
|
|
115
134
|
"k8s-deployment": "k8s-deployment";
|
|
116
135
|
}>;
|
|
117
136
|
instanceName: z.ZodString;
|
|
137
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
118
138
|
}, z.core.$strip>;
|
|
119
139
|
/**
|
|
120
140
|
* Provider-side relational storage table. Columns are FIELDS on the
|
|
@@ -179,7 +199,6 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
179
199
|
subscription: "subscription";
|
|
180
200
|
}>;
|
|
181
201
|
}, z.core.$strip>, z.ZodObject<{
|
|
182
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
183
202
|
deploymentTarget: z.ZodEnum<{
|
|
184
203
|
lambda: "lambda";
|
|
185
204
|
"ecs-task": "ecs-task";
|
|
@@ -187,6 +206,7 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
187
206
|
"k8s-deployment": "k8s-deployment";
|
|
188
207
|
}>;
|
|
189
208
|
instanceName: z.ZodString;
|
|
209
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
190
210
|
}, z.core.$strip>, z.ZodObject<{
|
|
191
211
|
name: z.ZodLiteral<"storage-relational">;
|
|
192
212
|
storageSystem: z.ZodEnum<{
|
|
@@ -233,7 +253,6 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
233
253
|
subscription: "subscription";
|
|
234
254
|
}>;
|
|
235
255
|
}, z.core.$strip>, z.ZodObject<{
|
|
236
|
-
name: z.ZodLiteral<"runtime-config">;
|
|
237
256
|
deploymentTarget: z.ZodEnum<{
|
|
238
257
|
lambda: "lambda";
|
|
239
258
|
"ecs-task": "ecs-task";
|
|
@@ -241,6 +260,7 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
241
260
|
"k8s-deployment": "k8s-deployment";
|
|
242
261
|
}>;
|
|
243
262
|
instanceName: z.ZodString;
|
|
263
|
+
name: z.ZodLiteral<"runtime-config">;
|
|
244
264
|
}, z.core.$strip>, z.ZodObject<{
|
|
245
265
|
name: z.ZodLiteral<"storage-relational">;
|
|
246
266
|
storageSystem: z.ZodEnum<{
|
|
@@ -297,9 +317,57 @@ type TypeShape = {
|
|
|
297
317
|
} | {
|
|
298
318
|
type: "ref";
|
|
299
319
|
name: string;
|
|
320
|
+
/**
|
|
321
|
+
* Where this type is written down, when it is. The key into the
|
|
322
|
+
* summary's table of definitions.
|
|
323
|
+
*
|
|
324
|
+
* A name does not identify a type. Every instantiation of one
|
|
325
|
+
* generic reports the generic's own name and file, so `Omit<User,
|
|
326
|
+
* "secret">` and `Omit<Order, "total">` are both `Omit`, and a
|
|
327
|
+
* table keyed on that hands the second one the first one's
|
|
328
|
+
* fields. This is built from what the type actually is.
|
|
329
|
+
*/
|
|
330
|
+
def?: string | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* The file that declares this type, when the project declares it.
|
|
333
|
+
* Absent for a name the language or a dependency owns, which means
|
|
334
|
+
* the same thing everywhere.
|
|
335
|
+
*
|
|
336
|
+
* A name on its own does not identify a type. Two modules each
|
|
337
|
+
* declaring a `User` produce the same ref, and a checker comparing
|
|
338
|
+
* them has nothing to go on. This is what tells them apart.
|
|
339
|
+
*/
|
|
340
|
+
from?: string | undefined;
|
|
300
341
|
} | {
|
|
301
342
|
type: "unknown";
|
|
302
343
|
};
|
|
344
|
+
/**
|
|
345
|
+
* How a table of definitions names the type a ref points at.
|
|
346
|
+
*
|
|
347
|
+
* A ref carries the name and the file that declares it, and that pair
|
|
348
|
+
* already identifies the type, so a table keyed on it needs nothing new
|
|
349
|
+
* on the ref. A name the language or a dependency owns has no file and
|
|
350
|
+
* keys on the name alone.
|
|
351
|
+
*/
|
|
352
|
+
declare function typeDefinitionKey(ref: {
|
|
353
|
+
def?: string | undefined;
|
|
354
|
+
}): string | null;
|
|
303
355
|
declare const TypeShapeSchema: z.ZodType<TypeShape>;
|
|
356
|
+
/**
|
|
357
|
+
* A shape with the definitions it names put back into it.
|
|
358
|
+
*
|
|
359
|
+
* Comparing two shapes means comparing their structure, and a ref has
|
|
360
|
+
* none. Rather than teach every comparison to look in a table, the
|
|
361
|
+
* table goes back into the shape once, and everything downstream reads
|
|
362
|
+
* what it always read.
|
|
363
|
+
*
|
|
364
|
+
* Putting a definition back is a substitution rather than a level of
|
|
365
|
+
* nesting, so it does not spend depth. Counting it did: a type six
|
|
366
|
+
* deep came back three deep, and a consumer reading a field past that
|
|
367
|
+
* point was told the provider did not have it. What stops a type that
|
|
368
|
+
* names itself is the set of names already being put back on this
|
|
369
|
+
* path, which is how the shape walk guards its own cycles.
|
|
370
|
+
*/
|
|
371
|
+
declare function withDefinitionsInlined(shape: TypeShape, definitions: Record<string, TypeShape> | undefined, depth?: number, inProgress?: ReadonlySet<string>): TypeShape;
|
|
304
372
|
|
|
305
|
-
export { BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, SemanticsSchema, SourceLocationSchema, StorageRelationalSemanticsSchema, type TypeShape, TypeShapeSchema };
|
|
373
|
+
export { BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, CorroborationSchema, DeployableUnitSchema, FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, SemanticsSchema, SourceLocationSchema, StorageRelationalSemanticsSchema, type TypeShape, TypeShapeSchema, typeDefinitionKey, withDefinitionsInlined };
|
package/dist/schemas.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ConfidenceLevelSchema,
|
|
5
5
|
ConfidenceSourceSchema,
|
|
6
6
|
CorroborationSchema,
|
|
7
|
+
DeployableUnitSchema,
|
|
7
8
|
FunctionCallSemanticsSchema,
|
|
8
9
|
GraphqlOperationSemanticsSchema,
|
|
9
10
|
GraphqlResolverSemanticsSchema,
|
|
@@ -13,14 +14,17 @@ import {
|
|
|
13
14
|
SemanticsSchema,
|
|
14
15
|
SourceLocationSchema,
|
|
15
16
|
StorageRelationalSemanticsSchema,
|
|
16
|
-
TypeShapeSchema
|
|
17
|
-
|
|
17
|
+
TypeShapeSchema,
|
|
18
|
+
typeDefinitionKey,
|
|
19
|
+
withDefinitionsInlined
|
|
20
|
+
} from "./chunk-JIFTLUZX.js";
|
|
18
21
|
export {
|
|
19
22
|
BoundaryBindingSchema,
|
|
20
23
|
ConfidenceInfoSchema,
|
|
21
24
|
ConfidenceLevelSchema,
|
|
22
25
|
ConfidenceSourceSchema,
|
|
23
26
|
CorroborationSchema,
|
|
27
|
+
DeployableUnitSchema,
|
|
24
28
|
FunctionCallSemanticsSchema,
|
|
25
29
|
GraphqlOperationSemanticsSchema,
|
|
26
30
|
GraphqlResolverSemanticsSchema,
|
|
@@ -30,5 +34,7 @@ export {
|
|
|
30
34
|
SemanticsSchema,
|
|
31
35
|
SourceLocationSchema,
|
|
32
36
|
StorageRelationalSemanticsSchema,
|
|
33
|
-
TypeShapeSchema
|
|
37
|
+
TypeShapeSchema,
|
|
38
|
+
typeDefinitionKey,
|
|
39
|
+
withDefinitionsInlined
|
|
34
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/ir-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared IR primitives for suss — type shapes, boundary bindings, source locations, and confidence. Imported by both @suss/behavioral-ir and @suss/intent-ir so neither depends on the other.",
|
|
6
6
|
"keywords": [
|