@suss/ir-core 0.8.0 → 0.10.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/README.md +65 -0
- package/dist/{chunk-WRRENYBR.js → chunk-HBAMPBAO.js} +162 -76
- package/dist/index.cjs +335 -124
- package/dist/index.d.cts +185 -47
- package/dist/index.d.ts +185 -47
- package/dist/index.js +156 -36
- package/dist/{schemas-BLS4PXwc.d.cts → schemas-CGR6qjFf.d.cts} +14 -6
- package/dist/{schemas-BLS4PXwc.d.ts → schemas-CGR6qjFf.d.ts} +14 -6
- package/dist/schemas.cjs +150 -73
- package/dist/schemas.d.cts +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
GraphqlOperationSemanticsSchema,
|
|
10
10
|
GraphqlResolverSemanticsSchema,
|
|
11
11
|
MessageBusSemanticsSchema,
|
|
12
|
+
MetricSemanticsSchema,
|
|
12
13
|
RestSemanticsSchema,
|
|
13
14
|
RuntimeConfigSemanticsSchema,
|
|
14
15
|
SemanticsSchema,
|
|
@@ -25,12 +26,33 @@ import {
|
|
|
25
26
|
formatChannel,
|
|
26
27
|
gqlIdentityKey,
|
|
27
28
|
methodsAgree,
|
|
29
|
+
metricIdentityKey,
|
|
28
30
|
normalizePath,
|
|
29
31
|
parseChannel,
|
|
30
32
|
routePathAdmits,
|
|
33
|
+
semconvMappingOf,
|
|
31
34
|
typeDefinitionKey,
|
|
32
35
|
withDefinitionsInlined
|
|
33
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-HBAMPBAO.js";
|
|
37
|
+
|
|
38
|
+
// src/semconv.ts
|
|
39
|
+
function semconvAttributes(binding) {
|
|
40
|
+
const semantics = binding.semantics;
|
|
41
|
+
const attributes = {};
|
|
42
|
+
for (const [field, attribute] of Object.entries(
|
|
43
|
+
semconvMappingOf(binding.semantics)
|
|
44
|
+
)) {
|
|
45
|
+
const value = semantics[field];
|
|
46
|
+
if (typeof value !== "string") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (attribute.placeholderValues?.includes(value) === true) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
attributes[attribute.name] = value;
|
|
53
|
+
}
|
|
54
|
+
return attributes;
|
|
55
|
+
}
|
|
34
56
|
|
|
35
57
|
// src/boundaryKey.ts
|
|
36
58
|
function boundaryKey(binding) {
|
|
@@ -84,29 +106,47 @@ function servesRequest(binding, method, path) {
|
|
|
84
106
|
return serves(binding.semantics, method, path);
|
|
85
107
|
}
|
|
86
108
|
|
|
87
|
-
// src/codeScope.ts
|
|
88
|
-
function codeScopePath(raw) {
|
|
89
|
-
return raw.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
90
|
-
}
|
|
91
|
-
function fileInCodeScope(file, scope) {
|
|
92
|
-
const prefix = codeScopePath(scope);
|
|
93
|
-
if (prefix === "" || prefix === ".") {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
const path = codeScopePath(file);
|
|
97
|
-
return path === prefix || path.startsWith(`${prefix}/`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
109
|
// src/dispatch.ts
|
|
101
110
|
function dispatchByType(table, value) {
|
|
102
111
|
const handler = table[value.type];
|
|
103
112
|
return handler(value);
|
|
104
113
|
}
|
|
105
114
|
|
|
106
|
-
// src/
|
|
107
|
-
var
|
|
115
|
+
// src/boundaryName.ts
|
|
116
|
+
var HOLE_SPLIT = /(\{[^}]*\})/;
|
|
108
117
|
var SUB_TOKEN = /\$\{([^}]*)\}/g;
|
|
109
118
|
var SUB_ESCAPE = /\$\{!/;
|
|
119
|
+
function isHole(piece) {
|
|
120
|
+
return piece.startsWith("{") && piece.endsWith("}");
|
|
121
|
+
}
|
|
122
|
+
function parseBoundaryName(name) {
|
|
123
|
+
const parts = name.split(HOLE_SPLIT).filter((piece) => piece !== "").map(
|
|
124
|
+
(piece) => isHole(piece) ? { type: "hole", label: piece.slice(1, -1) } : { type: "text", text: piece }
|
|
125
|
+
);
|
|
126
|
+
const only = parts.length === 1 ? parts[0] : void 0;
|
|
127
|
+
if (only !== void 0 && only.type === "hole") {
|
|
128
|
+
return { type: "reference", path: only.label.split(".") };
|
|
129
|
+
}
|
|
130
|
+
if (parts.some((part) => part.type === "hole")) {
|
|
131
|
+
return { type: "pattern", parts };
|
|
132
|
+
}
|
|
133
|
+
return { type: "literal", value: name };
|
|
134
|
+
}
|
|
135
|
+
var partString = {
|
|
136
|
+
text: (part) => part.text,
|
|
137
|
+
hole: (part) => patternHole(part.label)
|
|
138
|
+
};
|
|
139
|
+
var nameString = {
|
|
140
|
+
literal: (name) => name.value,
|
|
141
|
+
pattern: (name) => name.parts.map((part) => dispatchByType(partString, part)).join(""),
|
|
142
|
+
reference: (name) => patternHole(name.path.join("."))
|
|
143
|
+
};
|
|
144
|
+
function boundaryNameString(name) {
|
|
145
|
+
return dispatchByType(nameString, name);
|
|
146
|
+
}
|
|
147
|
+
function patternHole(label) {
|
|
148
|
+
return `{${label}}`;
|
|
149
|
+
}
|
|
110
150
|
function namePatternFromSub(value) {
|
|
111
151
|
if (Array.isArray(value)) {
|
|
112
152
|
return typeof value[0] === "string" ? namePatternFromSub(value[0]) : null;
|
|
@@ -117,43 +157,101 @@ function namePatternFromSub(value) {
|
|
|
117
157
|
if (SUB_ESCAPE.test(value)) {
|
|
118
158
|
return null;
|
|
119
159
|
}
|
|
120
|
-
return value.replace(
|
|
160
|
+
return value.replace(
|
|
161
|
+
SUB_TOKEN,
|
|
162
|
+
(_whole, inner) => patternHole(inner)
|
|
163
|
+
);
|
|
121
164
|
}
|
|
122
165
|
function namesNothing(name) {
|
|
123
|
-
return
|
|
166
|
+
return parseBoundaryName(name).type === "reference";
|
|
124
167
|
}
|
|
125
168
|
function hasNameHole(name) {
|
|
126
|
-
|
|
127
|
-
return HOLE.test(name);
|
|
169
|
+
return parseBoundaryName(name).type !== "literal";
|
|
128
170
|
}
|
|
129
171
|
function namePatternKey(name) {
|
|
130
|
-
return
|
|
172
|
+
return dispatchByType(
|
|
173
|
+
{
|
|
174
|
+
literal: (parsed) => parsed.value,
|
|
175
|
+
pattern: (parsed) => boundaryNameString({
|
|
176
|
+
type: "pattern",
|
|
177
|
+
parts: parsed.parts.map(
|
|
178
|
+
(part) => part.type === "hole" ? { type: "hole", label: "" } : part
|
|
179
|
+
)
|
|
180
|
+
}),
|
|
181
|
+
reference: () => patternHole("")
|
|
182
|
+
},
|
|
183
|
+
parseBoundaryName(name)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function fixedTextLength(name) {
|
|
187
|
+
return dispatchByType(
|
|
188
|
+
{
|
|
189
|
+
literal: (parsed) => parsed.value.length,
|
|
190
|
+
pattern: (parsed) => parsed.parts.reduce(
|
|
191
|
+
(total, part) => total + (part.type === "text" ? part.text.length : 0),
|
|
192
|
+
0
|
|
193
|
+
),
|
|
194
|
+
reference: () => 0
|
|
195
|
+
},
|
|
196
|
+
parseBoundaryName(name)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
function quote(text) {
|
|
200
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
131
201
|
}
|
|
132
202
|
function admits(pattern, name) {
|
|
133
|
-
const source = pattern.
|
|
134
|
-
(part) => part.startsWith("{") && part.endsWith("}") ? ".+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
135
|
-
).join("");
|
|
203
|
+
const source = pattern.parts.map((part) => part.type === "hole" ? ".+" : quote(part.text)).join("");
|
|
136
204
|
return new RegExp(`^${source}$`).test(name);
|
|
137
205
|
}
|
|
138
206
|
function namesAgree(a, b) {
|
|
139
|
-
|
|
207
|
+
const left = parseBoundaryName(a);
|
|
208
|
+
const right = parseBoundaryName(b);
|
|
209
|
+
if (left.type === "reference" || right.type === "reference") {
|
|
140
210
|
return false;
|
|
141
211
|
}
|
|
142
|
-
if (
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
const aHasHole = hasNameHole(a);
|
|
146
|
-
const bHasHole = hasNameHole(b);
|
|
147
|
-
if (aHasHole && bHasHole) {
|
|
212
|
+
if (left.type === "pattern" && right.type === "pattern") {
|
|
148
213
|
return namePatternKey(a) === namePatternKey(b);
|
|
149
214
|
}
|
|
150
|
-
if (
|
|
151
|
-
return admits(
|
|
215
|
+
if (left.type === "pattern") {
|
|
216
|
+
return admits(left, b);
|
|
152
217
|
}
|
|
153
|
-
if (
|
|
154
|
-
return admits(
|
|
218
|
+
if (right.type === "pattern") {
|
|
219
|
+
return admits(right, a);
|
|
155
220
|
}
|
|
156
|
-
return
|
|
221
|
+
return a === b;
|
|
222
|
+
}
|
|
223
|
+
function referenceName(reference) {
|
|
224
|
+
const path = [reference.root, ...reference.fields];
|
|
225
|
+
if (path.some((part) => part === "")) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return boundaryNameString({ type: "reference", path });
|
|
229
|
+
}
|
|
230
|
+
function referenceOf(name) {
|
|
231
|
+
if (name.type !== "reference") {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
const root = name.path[0];
|
|
235
|
+
if (root === void 0 || name.path.some((part) => part === "")) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return { root, fields: name.path.slice(1) };
|
|
239
|
+
}
|
|
240
|
+
function referenceFromName(name) {
|
|
241
|
+
return referenceOf(parseBoundaryName(name));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/codeScope.ts
|
|
245
|
+
function codeScopePath(raw) {
|
|
246
|
+
return raw.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
247
|
+
}
|
|
248
|
+
function fileInCodeScope(file, scope) {
|
|
249
|
+
const prefix = codeScopePath(scope);
|
|
250
|
+
if (prefix === "" || prefix === ".") {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
const path = codeScopePath(file);
|
|
254
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
157
255
|
}
|
|
158
256
|
|
|
159
257
|
// src/suppressions.ts
|
|
@@ -520,6 +618,17 @@ function messageBusBinding(opts) {
|
|
|
520
618
|
recognition: opts.recognition
|
|
521
619
|
};
|
|
522
620
|
}
|
|
621
|
+
function metricBinding(opts) {
|
|
622
|
+
return {
|
|
623
|
+
transport: opts.metricSystem,
|
|
624
|
+
semantics: {
|
|
625
|
+
name: "metric",
|
|
626
|
+
metricSystem: opts.metricSystem,
|
|
627
|
+
metricType: namedOrNull(opts.metricType, "metric type")
|
|
628
|
+
},
|
|
629
|
+
recognition: opts.recognition
|
|
630
|
+
};
|
|
631
|
+
}
|
|
523
632
|
export {
|
|
524
633
|
BoundaryBindingSchema,
|
|
525
634
|
ConfidenceInfoSchema,
|
|
@@ -531,6 +640,7 @@ export {
|
|
|
531
640
|
GraphqlOperationSemanticsSchema,
|
|
532
641
|
GraphqlResolverSemanticsSchema,
|
|
533
642
|
MessageBusSemanticsSchema,
|
|
643
|
+
MetricSemanticsSchema,
|
|
534
644
|
RestSemanticsSchema,
|
|
535
645
|
RuntimeConfigSemanticsSchema,
|
|
536
646
|
SemanticsSchema,
|
|
@@ -543,6 +653,7 @@ export {
|
|
|
543
653
|
bodyShapesMatch,
|
|
544
654
|
boundaryKey,
|
|
545
655
|
boundaryLabel,
|
|
656
|
+
boundaryNameString,
|
|
546
657
|
busIdentityKey,
|
|
547
658
|
busesAgree,
|
|
548
659
|
canPair,
|
|
@@ -554,6 +665,7 @@ export {
|
|
|
554
665
|
ecsContainerInstanceName,
|
|
555
666
|
exchangesHttpResponses,
|
|
556
667
|
fileInCodeScope,
|
|
668
|
+
fixedTextLength,
|
|
557
669
|
fnIdentityKey,
|
|
558
670
|
formatChannel,
|
|
559
671
|
functionCallBinding,
|
|
@@ -564,6 +676,8 @@ export {
|
|
|
564
676
|
isGraphqlOperationBinding,
|
|
565
677
|
messageBusBinding,
|
|
566
678
|
methodsAgree,
|
|
679
|
+
metricBinding,
|
|
680
|
+
metricIdentityKey,
|
|
567
681
|
namePatternFromSub,
|
|
568
682
|
namePatternKey,
|
|
569
683
|
namesAgree,
|
|
@@ -572,13 +686,19 @@ export {
|
|
|
572
686
|
normalizeRuleBoundary,
|
|
573
687
|
packageExportBinding,
|
|
574
688
|
pairingKey,
|
|
689
|
+
parseBoundaryName,
|
|
575
690
|
parseChannel,
|
|
691
|
+
patternHole,
|
|
692
|
+
referenceFromName,
|
|
693
|
+
referenceName,
|
|
694
|
+
referenceOf,
|
|
576
695
|
reportsUnpairedItself,
|
|
577
696
|
restBinding,
|
|
578
697
|
routePathAdmits,
|
|
579
698
|
ruleBoundaryMatchesKey,
|
|
580
699
|
runtimeConfigBinding,
|
|
581
700
|
semanticsAgree,
|
|
701
|
+
semconvAttributes,
|
|
582
702
|
servesRequest,
|
|
583
703
|
storageBinding,
|
|
584
704
|
typeDefinitionKey,
|
|
@@ -62,8 +62,8 @@ type GraphqlResolverSemantics = z.infer<typeof GraphqlResolverSemanticsSchema>;
|
|
|
62
62
|
declare const MessageBusSemanticsSchema: z.ZodObject<{
|
|
63
63
|
name: z.ZodLiteral<"message-bus">;
|
|
64
64
|
messageBus: z.ZodEnum<{
|
|
65
|
-
|
|
66
|
-
sns: "sns";
|
|
65
|
+
aws_sqs: "aws_sqs";
|
|
66
|
+
"aws.sns": "aws.sns";
|
|
67
67
|
s3: "s3";
|
|
68
68
|
eventbridge: "eventbridge";
|
|
69
69
|
bullmq: "bullmq";
|
|
@@ -139,8 +139,8 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
139
139
|
}, z.core.$strip>, z.ZodObject<{
|
|
140
140
|
name: z.ZodLiteral<"message-bus">;
|
|
141
141
|
messageBus: z.ZodEnum<{
|
|
142
|
-
|
|
143
|
-
sns: "sns";
|
|
142
|
+
aws_sqs: "aws_sqs";
|
|
143
|
+
"aws.sns": "aws.sns";
|
|
144
144
|
s3: "s3";
|
|
145
145
|
eventbridge: "eventbridge";
|
|
146
146
|
bullmq: "bullmq";
|
|
@@ -151,6 +151,10 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
151
151
|
"cloudflare-tail": "cloudflare-tail";
|
|
152
152
|
}>;
|
|
153
153
|
channel: z.ZodNullable<z.ZodString>;
|
|
154
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
155
|
+
name: z.ZodLiteral<"metric">;
|
|
156
|
+
metricSystem: z.ZodString;
|
|
157
|
+
metricType: z.ZodNullable<z.ZodString>;
|
|
154
158
|
}, z.core.$strip>], "name">;
|
|
155
159
|
type Semantics = z.infer<typeof SemanticsSchema>;
|
|
156
160
|
|
|
@@ -334,8 +338,8 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
334
338
|
}, z.core.$strip>, z.ZodObject<{
|
|
335
339
|
name: z.ZodLiteral<"message-bus">;
|
|
336
340
|
messageBus: z.ZodEnum<{
|
|
337
|
-
|
|
338
|
-
sns: "sns";
|
|
341
|
+
aws_sqs: "aws_sqs";
|
|
342
|
+
"aws.sns": "aws.sns";
|
|
339
343
|
s3: "s3";
|
|
340
344
|
eventbridge: "eventbridge";
|
|
341
345
|
bullmq: "bullmq";
|
|
@@ -346,6 +350,10 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
346
350
|
"cloudflare-tail": "cloudflare-tail";
|
|
347
351
|
}>;
|
|
348
352
|
channel: z.ZodNullable<z.ZodString>;
|
|
353
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
354
|
+
name: z.ZodLiteral<"metric">;
|
|
355
|
+
metricSystem: z.ZodString;
|
|
356
|
+
metricType: z.ZodNullable<z.ZodString>;
|
|
349
357
|
}, z.core.$strip>], "name">;
|
|
350
358
|
recognition: z.ZodString;
|
|
351
359
|
}, z.core.$strip>;
|
|
@@ -62,8 +62,8 @@ type GraphqlResolverSemantics = z.infer<typeof GraphqlResolverSemanticsSchema>;
|
|
|
62
62
|
declare const MessageBusSemanticsSchema: z.ZodObject<{
|
|
63
63
|
name: z.ZodLiteral<"message-bus">;
|
|
64
64
|
messageBus: z.ZodEnum<{
|
|
65
|
-
|
|
66
|
-
sns: "sns";
|
|
65
|
+
aws_sqs: "aws_sqs";
|
|
66
|
+
"aws.sns": "aws.sns";
|
|
67
67
|
s3: "s3";
|
|
68
68
|
eventbridge: "eventbridge";
|
|
69
69
|
bullmq: "bullmq";
|
|
@@ -139,8 +139,8 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
139
139
|
}, z.core.$strip>, z.ZodObject<{
|
|
140
140
|
name: z.ZodLiteral<"message-bus">;
|
|
141
141
|
messageBus: z.ZodEnum<{
|
|
142
|
-
|
|
143
|
-
sns: "sns";
|
|
142
|
+
aws_sqs: "aws_sqs";
|
|
143
|
+
"aws.sns": "aws.sns";
|
|
144
144
|
s3: "s3";
|
|
145
145
|
eventbridge: "eventbridge";
|
|
146
146
|
bullmq: "bullmq";
|
|
@@ -151,6 +151,10 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
151
151
|
"cloudflare-tail": "cloudflare-tail";
|
|
152
152
|
}>;
|
|
153
153
|
channel: z.ZodNullable<z.ZodString>;
|
|
154
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
155
|
+
name: z.ZodLiteral<"metric">;
|
|
156
|
+
metricSystem: z.ZodString;
|
|
157
|
+
metricType: z.ZodNullable<z.ZodString>;
|
|
154
158
|
}, z.core.$strip>], "name">;
|
|
155
159
|
type Semantics = z.infer<typeof SemanticsSchema>;
|
|
156
160
|
|
|
@@ -334,8 +338,8 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
334
338
|
}, z.core.$strip>, z.ZodObject<{
|
|
335
339
|
name: z.ZodLiteral<"message-bus">;
|
|
336
340
|
messageBus: z.ZodEnum<{
|
|
337
|
-
|
|
338
|
-
sns: "sns";
|
|
341
|
+
aws_sqs: "aws_sqs";
|
|
342
|
+
"aws.sns": "aws.sns";
|
|
339
343
|
s3: "s3";
|
|
340
344
|
eventbridge: "eventbridge";
|
|
341
345
|
bullmq: "bullmq";
|
|
@@ -346,6 +350,10 @@ declare const BoundaryBindingSchema: z.ZodObject<{
|
|
|
346
350
|
"cloudflare-tail": "cloudflare-tail";
|
|
347
351
|
}>;
|
|
348
352
|
channel: z.ZodNullable<z.ZodString>;
|
|
353
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
354
|
+
name: z.ZodLiteral<"metric">;
|
|
355
|
+
metricSystem: z.ZodString;
|
|
356
|
+
metricType: z.ZodNullable<z.ZodString>;
|
|
349
357
|
}, z.core.$strip>], "name">;
|
|
350
358
|
recognition: z.ZodString;
|
|
351
359
|
}, z.core.$strip>;
|