@suss/ir-core 0.0.1
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/LICENSE +205 -0
- package/README.md +40 -0
- package/dist/chunk-BWK3IPL7.js +166 -0
- package/dist/index.cjs +626 -0
- package/dist/index.d.cts +264 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +435 -0
- package/dist/schemas.cjs +203 -0
- package/dist/schemas.d.cts +272 -0
- package/dist/schemas.d.ts +272 -0
- package/dist/schemas.js +32 -0
- package/package.json +63 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, SemanticsSchema, SourceLocationSchema } from './schemas.cjs';
|
|
3
|
+
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema } from './schemas.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Normalize a route path to a canonical form for matching.
|
|
7
|
+
*
|
|
8
|
+
* - Converts Express-style params (`:id`) to brace-style (`{id}`)
|
|
9
|
+
* - Strips trailing slashes (except bare `/`)
|
|
10
|
+
* - Lowercases the static segments (params stay case-sensitive)
|
|
11
|
+
*/
|
|
12
|
+
declare function normalizePath(path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compute a stable string key from a boundary binding for grouping.
|
|
15
|
+
* Dispatches on `semantics.name`:
|
|
16
|
+
* - `rest` → `"METHOD /normalized/path"` (null if method or path empty)
|
|
17
|
+
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"`
|
|
18
|
+
* - `function-call` → `"fn:<package>::<exportPath>"` when both
|
|
19
|
+
* `package` and `exportPath` are set; other in-process function-call
|
|
20
|
+
* units (intra-repo components, bare handlers) return null.
|
|
21
|
+
* - everything else → null
|
|
22
|
+
*/
|
|
23
|
+
declare function boundaryKey(binding: BoundaryBinding): string | null;
|
|
24
|
+
|
|
25
|
+
declare const SuppressionRuleSchema: z.ZodObject<{
|
|
26
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
27
|
+
boundary: z.ZodOptional<z.ZodString>;
|
|
28
|
+
consumer: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
30
|
+
transitionId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
33
|
+
narrow: "narrow";
|
|
34
|
+
broad: "broad";
|
|
35
|
+
}>>;
|
|
36
|
+
reason: z.ZodString;
|
|
37
|
+
effect: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
mark: "mark";
|
|
39
|
+
downgrade: "downgrade";
|
|
40
|
+
hide: "hide";
|
|
41
|
+
}>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
type SuppressionRule = z.infer<typeof SuppressionRuleSchema>;
|
|
44
|
+
declare const SuppressionFileSchema: z.ZodObject<{
|
|
45
|
+
version: z.ZodLiteral<1>;
|
|
46
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
47
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
48
|
+
boundary: z.ZodOptional<z.ZodString>;
|
|
49
|
+
consumer: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
51
|
+
transitionId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
narrow: "narrow";
|
|
55
|
+
broad: "broad";
|
|
56
|
+
}>>;
|
|
57
|
+
reason: z.ZodString;
|
|
58
|
+
effect: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
mark: "mark";
|
|
60
|
+
downgrade: "downgrade";
|
|
61
|
+
hide: "hide";
|
|
62
|
+
}>>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
type SuppressionFile = z.infer<typeof SuppressionFileSchema>;
|
|
66
|
+
type SuppressableSeverity = "error" | "warning" | "info";
|
|
67
|
+
/** The `suppressed` annotation stamped onto a matched finding. */
|
|
68
|
+
interface FindingSuppression {
|
|
69
|
+
reason: string;
|
|
70
|
+
effect: "mark" | "downgrade" | "hide";
|
|
71
|
+
/** Original severity, present only when effect is "downgrade". */
|
|
72
|
+
originalSeverity?: SuppressableSeverity | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The structural base both finding shapes satisfy. Behavioural
|
|
76
|
+
* `Finding` and intent `IntentFinding` each declare these fields in
|
|
77
|
+
* their own schemas (kept structurally identical); the pipeline needs
|
|
78
|
+
* nothing more. The `| undefined` unions match what zod infers for
|
|
79
|
+
* `.optional()` fields under exactOptionalPropertyTypes.
|
|
80
|
+
*/
|
|
81
|
+
interface SuppressibleFinding {
|
|
82
|
+
kind: string;
|
|
83
|
+
severity: SuppressableSeverity;
|
|
84
|
+
suppressed?: FindingSuppression | undefined;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate that a narrow rule actually constrains *something* — a bare
|
|
88
|
+
* rule with only `reason` would suppress every finding in the codebase,
|
|
89
|
+
* which is almost always a mistake. Broad-scope rules deliberately
|
|
90
|
+
* allow less-specific matching.
|
|
91
|
+
*/
|
|
92
|
+
declare function validateRule(rule: SuppressionRule): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Normalize a rule's boundary string to match `boundaryKey`'s output
|
|
95
|
+
* format. Authors may write "GET /pet/:id" or "GET /pet/{id}"; we
|
|
96
|
+
* accept either. Method is uppercased; the path goes through
|
|
97
|
+
* `normalizePath` (colon-to-brace, trailing-slash stripping, lowercase
|
|
98
|
+
* static segments). Non-REST keys ("fn:...", "gql:...") don't have the
|
|
99
|
+
* METHOD-space-path shape and are compared verbatim by callers.
|
|
100
|
+
*/
|
|
101
|
+
declare function normalizeRuleBoundary(raw: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Does a rule's `boundary` discriminator match a finding's boundary
|
|
104
|
+
* key? Exact match first (covers "fn:...", "gql:..."), then the
|
|
105
|
+
* REST-normalized form.
|
|
106
|
+
*/
|
|
107
|
+
declare function ruleBoundaryMatchesKey(ruleBoundary: string, key: string | null): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Apply suppression rules to a list of findings. Generic over the
|
|
110
|
+
* finding shape: `matches` decides whether a rule's discriminators
|
|
111
|
+
* beyond `kind` (boundary, consumer, ...) match a finding — the kind
|
|
112
|
+
* check itself is universal and handled here.
|
|
113
|
+
*
|
|
114
|
+
* Returns a new array. Findings with `effect: "hide"` are omitted from
|
|
115
|
+
* the output entirely unless `keepHidden` is set. Findings with
|
|
116
|
+
* `effect: "mark"` or `"downgrade"` are included with an added
|
|
117
|
+
* `suppressed` field. First matching rule wins.
|
|
118
|
+
*/
|
|
119
|
+
declare function applySuppressionsToFindings<T extends SuppressibleFinding>(findings: T[], rules: SuppressionRule[], matches: (rule: SuppressionRule, finding: T) => boolean, opts?: {
|
|
120
|
+
keepHidden?: boolean;
|
|
121
|
+
}): T[];
|
|
122
|
+
/**
|
|
123
|
+
* `hide` and `mark` findings are excluded from exit-code threshold
|
|
124
|
+
* calculations; `downgrade` findings count at their post-downgrade
|
|
125
|
+
* severity. Callers use this to decide whether a finding contributes
|
|
126
|
+
* to `hasErrors`-style gating.
|
|
127
|
+
*/
|
|
128
|
+
declare function countsForThreshold(finding: SuppressibleFinding): boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Three-valued comparison result:
|
|
132
|
+
* - "match" — `actual` satisfies `declared`
|
|
133
|
+
* - "nomatch" — a concrete, verifiable incompatibility exists
|
|
134
|
+
* - "unknown" — uncertainty that would mask a real mismatch (spreads,
|
|
135
|
+
* refs, unknown shapes)
|
|
136
|
+
*/
|
|
137
|
+
type MatchResult = "match" | "nomatch" | "unknown";
|
|
138
|
+
/**
|
|
139
|
+
* Compare an actual body shape against a declared body shape and report
|
|
140
|
+
* whether the actual satisfies the declared.
|
|
141
|
+
*
|
|
142
|
+
* Semantics are asymmetric: `actual` is the produced value (a response
|
|
143
|
+
* body, a return value) and `declared` is the contract it must conform
|
|
144
|
+
* to. `unknown` is a soft signal; callers decide whether to surface it.
|
|
145
|
+
*/
|
|
146
|
+
declare function bodyShapesMatch(actual: TypeShape, declared: TypeShape): MatchResult;
|
|
147
|
+
|
|
148
|
+
type ConfidenceSource = z.infer<typeof ConfidenceSourceSchema>;
|
|
149
|
+
type ConfidenceLevel = z.infer<typeof ConfidenceLevelSchema>;
|
|
150
|
+
type ConfidenceInfo = z.infer<typeof ConfidenceInfoSchema>;
|
|
151
|
+
type SourceLocation = z.infer<typeof SourceLocationSchema>;
|
|
152
|
+
type BoundaryBinding = z.infer<typeof BoundaryBindingSchema>;
|
|
153
|
+
type Semantics = z.infer<typeof SemanticsSchema>;
|
|
154
|
+
type RestSemantics = Extract<Semantics, {
|
|
155
|
+
name: "rest";
|
|
156
|
+
}>;
|
|
157
|
+
type FunctionCallSemantics = Extract<Semantics, {
|
|
158
|
+
name: "function-call";
|
|
159
|
+
}>;
|
|
160
|
+
type GraphqlResolverSemantics = Extract<Semantics, {
|
|
161
|
+
name: "graphql-resolver";
|
|
162
|
+
}>;
|
|
163
|
+
type GraphqlOperationSemantics = Extract<Semantics, {
|
|
164
|
+
name: "graphql-operation";
|
|
165
|
+
}>;
|
|
166
|
+
type RuntimeConfigSemantics = Extract<Semantics, {
|
|
167
|
+
name: "runtime-config";
|
|
168
|
+
}>;
|
|
169
|
+
type StorageRelationalSemantics = Extract<Semantics, {
|
|
170
|
+
name: "storage-relational";
|
|
171
|
+
}>;
|
|
172
|
+
type MessageBusSemantics = Extract<Semantics, {
|
|
173
|
+
name: "message-bus";
|
|
174
|
+
}>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Build a REST-semantics binding. `method` and `path` can be empty
|
|
178
|
+
* strings to signal "not yet resolved" (the adapter's wrapper-expansion
|
|
179
|
+
* pass uses this); pairing treats empty method/path as unplaced.
|
|
180
|
+
*/
|
|
181
|
+
declare function restBinding(opts: {
|
|
182
|
+
transport: string;
|
|
183
|
+
method: string;
|
|
184
|
+
path: string;
|
|
185
|
+
recognition: string;
|
|
186
|
+
declaredResponses?: number[];
|
|
187
|
+
}): BoundaryBinding;
|
|
188
|
+
/**
|
|
189
|
+
* Build a function-call-semantics binding. Used by in-process packs
|
|
190
|
+
* (React components, custom-hook boundaries, bare TS function exports).
|
|
191
|
+
*/
|
|
192
|
+
declare function functionCallBinding(opts: {
|
|
193
|
+
transport: string;
|
|
194
|
+
recognition: string;
|
|
195
|
+
module?: string;
|
|
196
|
+
exportName?: string;
|
|
197
|
+
package?: string;
|
|
198
|
+
exportPath?: string[];
|
|
199
|
+
}): BoundaryBinding;
|
|
200
|
+
/**
|
|
201
|
+
* Build a function-call binding that identifies a public package export
|
|
202
|
+
* — the provider side of a library boundary. Transport defaults to
|
|
203
|
+
* `"in-process"` for typical TypeScript library consumption.
|
|
204
|
+
*/
|
|
205
|
+
declare function packageExportBinding(opts: {
|
|
206
|
+
transport?: string;
|
|
207
|
+
recognition: string;
|
|
208
|
+
packageName: string;
|
|
209
|
+
exportPath: string[];
|
|
210
|
+
}): BoundaryBinding;
|
|
211
|
+
/**
|
|
212
|
+
* Build a graphql-resolver-semantics binding. Transport varies by
|
|
213
|
+
* deployment: `"http"` for Apollo Server, `"aws-https"` for AppSync.
|
|
214
|
+
*/
|
|
215
|
+
declare function graphqlResolverBinding(opts: {
|
|
216
|
+
transport: string;
|
|
217
|
+
recognition: string;
|
|
218
|
+
typeName: string;
|
|
219
|
+
fieldName: string;
|
|
220
|
+
}): BoundaryBinding;
|
|
221
|
+
/**
|
|
222
|
+
* Build a graphql-operation-semantics binding — the consumer side of a
|
|
223
|
+
* GraphQL boundary. Anonymous operations leave `operationName` unset.
|
|
224
|
+
*/
|
|
225
|
+
declare function graphqlOperationBinding(opts: {
|
|
226
|
+
transport: string;
|
|
227
|
+
recognition: string;
|
|
228
|
+
operationType: "query" | "mutation" | "subscription";
|
|
229
|
+
operationName?: string;
|
|
230
|
+
}): BoundaryBinding;
|
|
231
|
+
/**
|
|
232
|
+
* Build a runtime-config binding — the provider side of a runtime
|
|
233
|
+
* configuration channel (env vars on a Lambda / ECS task / container /
|
|
234
|
+
* k8s pod). Transport is `"os"`: env vars are handed to the process by
|
|
235
|
+
* the OS at startup regardless of the deployment medium.
|
|
236
|
+
*/
|
|
237
|
+
declare function runtimeConfigBinding(opts: {
|
|
238
|
+
recognition: string;
|
|
239
|
+
deploymentTarget: "lambda" | "ecs-task" | "container" | "k8s-deployment";
|
|
240
|
+
instanceName: string;
|
|
241
|
+
}): BoundaryBinding;
|
|
242
|
+
/**
|
|
243
|
+
* Build a storage-relational binding — the provider side of a
|
|
244
|
+
* relational storage table. Transport carries the `storageSystem`
|
|
245
|
+
* value so the layering stays informative without a separate
|
|
246
|
+
* wire-protocol taxonomy.
|
|
247
|
+
*/
|
|
248
|
+
declare function storageRelationalBinding(opts: {
|
|
249
|
+
recognition: string;
|
|
250
|
+
storageSystem: "postgres" | "mysql" | "sqlite";
|
|
251
|
+
scope: string;
|
|
252
|
+
table: string;
|
|
253
|
+
}): BoundaryBinding;
|
|
254
|
+
/**
|
|
255
|
+
* Build a message-bus binding — the boundary between a producer that
|
|
256
|
+
* sends discrete messages and the consumer(s) that receive them.
|
|
257
|
+
*/
|
|
258
|
+
declare function messageBusBinding(opts: {
|
|
259
|
+
recognition: string;
|
|
260
|
+
messageBus: "sqs" | "eventbridge" | "bullmq" | "kafka" | "nats";
|
|
261
|
+
channel: string;
|
|
262
|
+
}): BoundaryBinding;
|
|
263
|
+
|
|
264
|
+
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, 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, countsForThreshold, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TypeShape, BoundaryBindingSchema, ConfidenceInfoSchema, ConfidenceLevelSchema, ConfidenceSourceSchema, SemanticsSchema, SourceLocationSchema } from './schemas.js';
|
|
3
|
+
export { FunctionCallSemanticsSchema, GraphqlOperationSemanticsSchema, GraphqlResolverSemanticsSchema, MessageBusSemanticsSchema, RestSemanticsSchema, RuntimeConfigSemanticsSchema, StorageRelationalSemanticsSchema, TypeShapeSchema } from './schemas.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Normalize a route path to a canonical form for matching.
|
|
7
|
+
*
|
|
8
|
+
* - Converts Express-style params (`:id`) to brace-style (`{id}`)
|
|
9
|
+
* - Strips trailing slashes (except bare `/`)
|
|
10
|
+
* - Lowercases the static segments (params stay case-sensitive)
|
|
11
|
+
*/
|
|
12
|
+
declare function normalizePath(path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compute a stable string key from a boundary binding for grouping.
|
|
15
|
+
* Dispatches on `semantics.name`:
|
|
16
|
+
* - `rest` → `"METHOD /normalized/path"` (null if method or path empty)
|
|
17
|
+
* - `graphql-resolver` → `"gql:<TypeName>.<fieldName>"`
|
|
18
|
+
* - `function-call` → `"fn:<package>::<exportPath>"` when both
|
|
19
|
+
* `package` and `exportPath` are set; other in-process function-call
|
|
20
|
+
* units (intra-repo components, bare handlers) return null.
|
|
21
|
+
* - everything else → null
|
|
22
|
+
*/
|
|
23
|
+
declare function boundaryKey(binding: BoundaryBinding): string | null;
|
|
24
|
+
|
|
25
|
+
declare const SuppressionRuleSchema: z.ZodObject<{
|
|
26
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
27
|
+
boundary: z.ZodOptional<z.ZodString>;
|
|
28
|
+
consumer: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
30
|
+
transitionId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
33
|
+
narrow: "narrow";
|
|
34
|
+
broad: "broad";
|
|
35
|
+
}>>;
|
|
36
|
+
reason: z.ZodString;
|
|
37
|
+
effect: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
mark: "mark";
|
|
39
|
+
downgrade: "downgrade";
|
|
40
|
+
hide: "hide";
|
|
41
|
+
}>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
type SuppressionRule = z.infer<typeof SuppressionRuleSchema>;
|
|
44
|
+
declare const SuppressionFileSchema: z.ZodObject<{
|
|
45
|
+
version: z.ZodLiteral<1>;
|
|
46
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
47
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
48
|
+
boundary: z.ZodOptional<z.ZodString>;
|
|
49
|
+
consumer: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
51
|
+
transitionId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
narrow: "narrow";
|
|
55
|
+
broad: "broad";
|
|
56
|
+
}>>;
|
|
57
|
+
reason: z.ZodString;
|
|
58
|
+
effect: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
mark: "mark";
|
|
60
|
+
downgrade: "downgrade";
|
|
61
|
+
hide: "hide";
|
|
62
|
+
}>>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
type SuppressionFile = z.infer<typeof SuppressionFileSchema>;
|
|
66
|
+
type SuppressableSeverity = "error" | "warning" | "info";
|
|
67
|
+
/** The `suppressed` annotation stamped onto a matched finding. */
|
|
68
|
+
interface FindingSuppression {
|
|
69
|
+
reason: string;
|
|
70
|
+
effect: "mark" | "downgrade" | "hide";
|
|
71
|
+
/** Original severity, present only when effect is "downgrade". */
|
|
72
|
+
originalSeverity?: SuppressableSeverity | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The structural base both finding shapes satisfy. Behavioural
|
|
76
|
+
* `Finding` and intent `IntentFinding` each declare these fields in
|
|
77
|
+
* their own schemas (kept structurally identical); the pipeline needs
|
|
78
|
+
* nothing more. The `| undefined` unions match what zod infers for
|
|
79
|
+
* `.optional()` fields under exactOptionalPropertyTypes.
|
|
80
|
+
*/
|
|
81
|
+
interface SuppressibleFinding {
|
|
82
|
+
kind: string;
|
|
83
|
+
severity: SuppressableSeverity;
|
|
84
|
+
suppressed?: FindingSuppression | undefined;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate that a narrow rule actually constrains *something* — a bare
|
|
88
|
+
* rule with only `reason` would suppress every finding in the codebase,
|
|
89
|
+
* which is almost always a mistake. Broad-scope rules deliberately
|
|
90
|
+
* allow less-specific matching.
|
|
91
|
+
*/
|
|
92
|
+
declare function validateRule(rule: SuppressionRule): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Normalize a rule's boundary string to match `boundaryKey`'s output
|
|
95
|
+
* format. Authors may write "GET /pet/:id" or "GET /pet/{id}"; we
|
|
96
|
+
* accept either. Method is uppercased; the path goes through
|
|
97
|
+
* `normalizePath` (colon-to-brace, trailing-slash stripping, lowercase
|
|
98
|
+
* static segments). Non-REST keys ("fn:...", "gql:...") don't have the
|
|
99
|
+
* METHOD-space-path shape and are compared verbatim by callers.
|
|
100
|
+
*/
|
|
101
|
+
declare function normalizeRuleBoundary(raw: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Does a rule's `boundary` discriminator match a finding's boundary
|
|
104
|
+
* key? Exact match first (covers "fn:...", "gql:..."), then the
|
|
105
|
+
* REST-normalized form.
|
|
106
|
+
*/
|
|
107
|
+
declare function ruleBoundaryMatchesKey(ruleBoundary: string, key: string | null): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Apply suppression rules to a list of findings. Generic over the
|
|
110
|
+
* finding shape: `matches` decides whether a rule's discriminators
|
|
111
|
+
* beyond `kind` (boundary, consumer, ...) match a finding — the kind
|
|
112
|
+
* check itself is universal and handled here.
|
|
113
|
+
*
|
|
114
|
+
* Returns a new array. Findings with `effect: "hide"` are omitted from
|
|
115
|
+
* the output entirely unless `keepHidden` is set. Findings with
|
|
116
|
+
* `effect: "mark"` or `"downgrade"` are included with an added
|
|
117
|
+
* `suppressed` field. First matching rule wins.
|
|
118
|
+
*/
|
|
119
|
+
declare function applySuppressionsToFindings<T extends SuppressibleFinding>(findings: T[], rules: SuppressionRule[], matches: (rule: SuppressionRule, finding: T) => boolean, opts?: {
|
|
120
|
+
keepHidden?: boolean;
|
|
121
|
+
}): T[];
|
|
122
|
+
/**
|
|
123
|
+
* `hide` and `mark` findings are excluded from exit-code threshold
|
|
124
|
+
* calculations; `downgrade` findings count at their post-downgrade
|
|
125
|
+
* severity. Callers use this to decide whether a finding contributes
|
|
126
|
+
* to `hasErrors`-style gating.
|
|
127
|
+
*/
|
|
128
|
+
declare function countsForThreshold(finding: SuppressibleFinding): boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Three-valued comparison result:
|
|
132
|
+
* - "match" — `actual` satisfies `declared`
|
|
133
|
+
* - "nomatch" — a concrete, verifiable incompatibility exists
|
|
134
|
+
* - "unknown" — uncertainty that would mask a real mismatch (spreads,
|
|
135
|
+
* refs, unknown shapes)
|
|
136
|
+
*/
|
|
137
|
+
type MatchResult = "match" | "nomatch" | "unknown";
|
|
138
|
+
/**
|
|
139
|
+
* Compare an actual body shape against a declared body shape and report
|
|
140
|
+
* whether the actual satisfies the declared.
|
|
141
|
+
*
|
|
142
|
+
* Semantics are asymmetric: `actual` is the produced value (a response
|
|
143
|
+
* body, a return value) and `declared` is the contract it must conform
|
|
144
|
+
* to. `unknown` is a soft signal; callers decide whether to surface it.
|
|
145
|
+
*/
|
|
146
|
+
declare function bodyShapesMatch(actual: TypeShape, declared: TypeShape): MatchResult;
|
|
147
|
+
|
|
148
|
+
type ConfidenceSource = z.infer<typeof ConfidenceSourceSchema>;
|
|
149
|
+
type ConfidenceLevel = z.infer<typeof ConfidenceLevelSchema>;
|
|
150
|
+
type ConfidenceInfo = z.infer<typeof ConfidenceInfoSchema>;
|
|
151
|
+
type SourceLocation = z.infer<typeof SourceLocationSchema>;
|
|
152
|
+
type BoundaryBinding = z.infer<typeof BoundaryBindingSchema>;
|
|
153
|
+
type Semantics = z.infer<typeof SemanticsSchema>;
|
|
154
|
+
type RestSemantics = Extract<Semantics, {
|
|
155
|
+
name: "rest";
|
|
156
|
+
}>;
|
|
157
|
+
type FunctionCallSemantics = Extract<Semantics, {
|
|
158
|
+
name: "function-call";
|
|
159
|
+
}>;
|
|
160
|
+
type GraphqlResolverSemantics = Extract<Semantics, {
|
|
161
|
+
name: "graphql-resolver";
|
|
162
|
+
}>;
|
|
163
|
+
type GraphqlOperationSemantics = Extract<Semantics, {
|
|
164
|
+
name: "graphql-operation";
|
|
165
|
+
}>;
|
|
166
|
+
type RuntimeConfigSemantics = Extract<Semantics, {
|
|
167
|
+
name: "runtime-config";
|
|
168
|
+
}>;
|
|
169
|
+
type StorageRelationalSemantics = Extract<Semantics, {
|
|
170
|
+
name: "storage-relational";
|
|
171
|
+
}>;
|
|
172
|
+
type MessageBusSemantics = Extract<Semantics, {
|
|
173
|
+
name: "message-bus";
|
|
174
|
+
}>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Build a REST-semantics binding. `method` and `path` can be empty
|
|
178
|
+
* strings to signal "not yet resolved" (the adapter's wrapper-expansion
|
|
179
|
+
* pass uses this); pairing treats empty method/path as unplaced.
|
|
180
|
+
*/
|
|
181
|
+
declare function restBinding(opts: {
|
|
182
|
+
transport: string;
|
|
183
|
+
method: string;
|
|
184
|
+
path: string;
|
|
185
|
+
recognition: string;
|
|
186
|
+
declaredResponses?: number[];
|
|
187
|
+
}): BoundaryBinding;
|
|
188
|
+
/**
|
|
189
|
+
* Build a function-call-semantics binding. Used by in-process packs
|
|
190
|
+
* (React components, custom-hook boundaries, bare TS function exports).
|
|
191
|
+
*/
|
|
192
|
+
declare function functionCallBinding(opts: {
|
|
193
|
+
transport: string;
|
|
194
|
+
recognition: string;
|
|
195
|
+
module?: string;
|
|
196
|
+
exportName?: string;
|
|
197
|
+
package?: string;
|
|
198
|
+
exportPath?: string[];
|
|
199
|
+
}): BoundaryBinding;
|
|
200
|
+
/**
|
|
201
|
+
* Build a function-call binding that identifies a public package export
|
|
202
|
+
* — the provider side of a library boundary. Transport defaults to
|
|
203
|
+
* `"in-process"` for typical TypeScript library consumption.
|
|
204
|
+
*/
|
|
205
|
+
declare function packageExportBinding(opts: {
|
|
206
|
+
transport?: string;
|
|
207
|
+
recognition: string;
|
|
208
|
+
packageName: string;
|
|
209
|
+
exportPath: string[];
|
|
210
|
+
}): BoundaryBinding;
|
|
211
|
+
/**
|
|
212
|
+
* Build a graphql-resolver-semantics binding. Transport varies by
|
|
213
|
+
* deployment: `"http"` for Apollo Server, `"aws-https"` for AppSync.
|
|
214
|
+
*/
|
|
215
|
+
declare function graphqlResolverBinding(opts: {
|
|
216
|
+
transport: string;
|
|
217
|
+
recognition: string;
|
|
218
|
+
typeName: string;
|
|
219
|
+
fieldName: string;
|
|
220
|
+
}): BoundaryBinding;
|
|
221
|
+
/**
|
|
222
|
+
* Build a graphql-operation-semantics binding — the consumer side of a
|
|
223
|
+
* GraphQL boundary. Anonymous operations leave `operationName` unset.
|
|
224
|
+
*/
|
|
225
|
+
declare function graphqlOperationBinding(opts: {
|
|
226
|
+
transport: string;
|
|
227
|
+
recognition: string;
|
|
228
|
+
operationType: "query" | "mutation" | "subscription";
|
|
229
|
+
operationName?: string;
|
|
230
|
+
}): BoundaryBinding;
|
|
231
|
+
/**
|
|
232
|
+
* Build a runtime-config binding — the provider side of a runtime
|
|
233
|
+
* configuration channel (env vars on a Lambda / ECS task / container /
|
|
234
|
+
* k8s pod). Transport is `"os"`: env vars are handed to the process by
|
|
235
|
+
* the OS at startup regardless of the deployment medium.
|
|
236
|
+
*/
|
|
237
|
+
declare function runtimeConfigBinding(opts: {
|
|
238
|
+
recognition: string;
|
|
239
|
+
deploymentTarget: "lambda" | "ecs-task" | "container" | "k8s-deployment";
|
|
240
|
+
instanceName: string;
|
|
241
|
+
}): BoundaryBinding;
|
|
242
|
+
/**
|
|
243
|
+
* Build a storage-relational binding — the provider side of a
|
|
244
|
+
* relational storage table. Transport carries the `storageSystem`
|
|
245
|
+
* value so the layering stays informative without a separate
|
|
246
|
+
* wire-protocol taxonomy.
|
|
247
|
+
*/
|
|
248
|
+
declare function storageRelationalBinding(opts: {
|
|
249
|
+
recognition: string;
|
|
250
|
+
storageSystem: "postgres" | "mysql" | "sqlite";
|
|
251
|
+
scope: string;
|
|
252
|
+
table: string;
|
|
253
|
+
}): BoundaryBinding;
|
|
254
|
+
/**
|
|
255
|
+
* Build a message-bus binding — the boundary between a producer that
|
|
256
|
+
* sends discrete messages and the consumer(s) that receive them.
|
|
257
|
+
*/
|
|
258
|
+
declare function messageBusBinding(opts: {
|
|
259
|
+
recognition: string;
|
|
260
|
+
messageBus: "sqs" | "eventbridge" | "bullmq" | "kafka" | "nats";
|
|
261
|
+
channel: string;
|
|
262
|
+
}): BoundaryBinding;
|
|
263
|
+
|
|
264
|
+
export { type BoundaryBinding, BoundaryBindingSchema, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type FindingSuppression, type FunctionCallSemantics, type GraphqlOperationSemantics, type GraphqlResolverSemantics, type MatchResult, type MessageBusSemantics, 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, countsForThreshold, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizePath, normalizeRuleBoundary, packageExportBinding, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, storageRelationalBinding, validateRule };
|