@suss/ir-core 0.7.2 → 0.9.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/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { T as TypeShape, M as MessageBusSemantics, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, e as MessageBusTechnology } from './schemas-D6hKT-zV.cjs';
3
- export { D as DeployableUnit, f as DeployableUnitSchema, F as FunctionCallSemantics, g as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, h as GraphqlOperationSemanticsSchema, i as GraphqlResolverSemantics, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageSemantics, q as StorageSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-D6hKT-zV.cjs';
2
+ import { T as TypeShape, M as MessageBusSemantics, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, e as MessageBusTechnology, D as DeployableUnit } from './schemas-CGR6qjFf.cjs';
3
+ export { f as DeployableUnitSchema, F as FunctionCallSemantics, g as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, h as GraphqlOperationSemanticsSchema, i as GraphqlResolverSemantics, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageSemantics, q as StorageSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-CGR6qjFf.cjs';
4
4
 
5
5
  /**
6
6
  * Comparing two TypeShapes structurally.
@@ -49,8 +49,33 @@ declare function bodyShapesMatch(actual: TypeShape, declared: TypeShape): MatchR
49
49
  * because a published summary has to mean the same thing to a reader
50
50
  * who never installed the pack that wrote it. If a pack needs a
51
51
  * protocol nobody has defined yet, add a module here.
52
+ *
53
+ * A protocol also says which of its words come from OpenTelemetry's
54
+ * semantic conventions, in `semconv`. The README says why that
55
+ * matters and where it stops.
52
56
  */
53
57
 
58
+ /** One identity field written as an OpenTelemetry attribute. */
59
+ interface SemconvAttribute {
60
+ /** The attribute name, as the semantic conventions spell it. */
61
+ name: string;
62
+ /**
63
+ * Values suss writes where the source named none. A span never says
64
+ * them, so the projection leaves the attribute off rather than
65
+ * emitting a string that could only ever mismatch.
66
+ */
67
+ placeholderValues?: readonly string[];
68
+ }
69
+ /**
70
+ * Which identity fields the semantic conventions have an attribute
71
+ * for. A field is absent when they have no attribute for it, or when
72
+ * our value is our own string rather than the one a span gets.
73
+ */
74
+ type SemconvMapping<S extends {
75
+ name: string;
76
+ }> = {
77
+ readonly [K in Exclude<keyof S, "name">]?: SemconvAttribute;
78
+ };
54
79
  /**
55
80
  * How one semantics variant keys its boundaries and pairs them up. Each
56
81
  * variant fills this in inside its own module, and nothing else in the
@@ -123,6 +148,11 @@ interface BoundarySemanticsDefinition<Z extends z.ZodType<{
123
148
  name: z.infer<Z>["name"];
124
149
  schema: Z;
125
150
  behavior: BoundaryBehavior<z.infer<Z>>;
151
+ /**
152
+ * Every protocol declares this, empty included, so that adding one
153
+ * means deciding where its words come from.
154
+ */
155
+ semconv: SemconvMapping<z.infer<Z>>;
126
156
  }
127
157
 
128
158
  declare const IdentityKeyBrand: unique symbol;
@@ -141,6 +171,39 @@ type BusIdentityKey = `bus:${MessageBusSemantics["messageBus"]} ${string}` & {
141
171
  readonly [IdentityKeyBrand]: "bus";
142
172
  };
143
173
  declare function busIdentityKey(messageBus: MessageBusSemantics["messageBus"], subject: string): BusIdentityKey;
174
+ /** `metric:system type`, the key both sides of a metric pair on. */
175
+ type MetricIdentityKey = `metric:${string} ${string}` & {
176
+ readonly [IdentityKeyBrand]: "metric";
177
+ };
178
+ declare function metricIdentityKey(metricSystem: string, metricType: string): MetricIdentityKey;
179
+
180
+ declare const MetricSemanticsSchema: z.ZodObject<{
181
+ name: z.ZodLiteral<"metric">;
182
+ metricSystem: z.ZodString;
183
+ metricType: z.ZodNullable<z.ZodString>;
184
+ }, z.core.$strip>;
185
+ type MetricSemantics = z.infer<typeof MetricSemanticsSchema>;
186
+
187
+ /**
188
+ * A boundary binding read as OpenTelemetry attributes.
189
+ *
190
+ * A summary says what a unit can reach and a span says what it did
191
+ * reach. Joining the two means both sides spelling the boundary the
192
+ * same way, so suss writes the value a span gets wherever the semantic
193
+ * conventions have a word for it, and this projection puts those
194
+ * values under the attributes a trace store already indexes.
195
+ *
196
+ * Which fields those are is each protocol's own declaration, in its
197
+ * module under `semantics/`. Nothing here knows about any protocol.
198
+ */
199
+
200
+ /**
201
+ * The attributes a boundary states, by name. A field the source never
202
+ * gave, a placeholder, and a field the conventions have no attribute
203
+ * for are all left out, so every pair here compares byte for byte
204
+ * against the same attribute on a span.
205
+ */
206
+ declare function semconvAttributes(binding: BoundaryBinding): Record<string, string>;
144
207
 
145
208
  /**
146
209
  * Keys for a boundary binding, and whether two of them agree. Every
@@ -269,12 +332,13 @@ declare function dispatchByType<T extends {
269
332
  * a template writes `!Sub "${StageName}-orders-v1"` and the code writes
270
333
  * `` `${stage}-orders-v1` ``. Neither side states a string, both agree
271
334
  * about the fixed text, and each spells the parameter its own way. So a
272
- * name is written here as fixed text with `{}` holes, the way a REST
273
- * path is written with `{id}`, and two names agree when their fixed
274
- * parts line up.
335
+ * name is written here as fixed text with `{}` holes, and two names
336
+ * agree when their fixed parts line up.
275
337
  *
276
- * A hole covers a whole parameter rather than one path segment,
277
- * because a name has no separator that every project agrees on.
338
+ * A hole covers a whole parameter rather than one piece of a name,
339
+ * because a name has no separator every project agrees on. Two
340
+ * patterns that both cover one name are told apart by how much fixed
341
+ * text each states, rather than by narrowing what a hole can cover.
278
342
  */
279
343
  /**
280
344
  * The name a CloudFormation `Fn::Sub` value states. The array form
@@ -297,6 +361,8 @@ declare function hasNameHole(name: string): boolean;
297
361
  * token, since the two sides pick their own name for the parameter.
298
362
  */
299
363
  declare function namePatternKey(name: string): string;
364
+ /** How much of a name the writer stated rather than left for deploy time. */
365
+ declare function fixedTextLength(name: string): number;
300
366
  /**
301
367
  * Whether two names are the same name. Two patterns agree when their
302
368
  * fixed parts line up, since a hole on one side meets a hole on the
@@ -515,7 +581,7 @@ declare function isGraphqlOperationBinding(binding: BoundaryBinding | null | und
515
581
  */
516
582
  declare function runtimeConfigBinding(opts: {
517
583
  recognition: string;
518
- deploymentTarget: "lambda" | "ecs-task" | "container" | "k8s-deployment";
584
+ deploymentTarget: DeployableUnit["deploymentTarget"];
519
585
  instanceName: string;
520
586
  }): BoundaryBinding;
521
587
  /**
@@ -545,5 +611,15 @@ declare function messageBusBinding(opts: {
545
611
  /** Null when this source does not say which channel. */
546
612
  channel: string | null;
547
613
  }): BoundaryBinding;
614
+ /**
615
+ * Build a metric binding, the boundary between whatever declares a
616
+ * named series of measurements and whatever reads it back by that name.
617
+ */
618
+ declare function metricBinding(opts: {
619
+ recognition: string;
620
+ metricSystem: string;
621
+ /** Null when this source states a metric it could not name. */
622
+ metricType: string | null;
623
+ }): BoundaryBinding;
548
624
 
549
- export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type BusIdentityKey, type Channel, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DispatchTable, type FindingSuppression, type FnIdentityKey, type GqlIdentityKey, type MatchResult, MessageBusSemantics, MessageBusTechnology, type ParsedChannel, Semantics, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busIdentityKey, busesAgree, canPair, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, fnIdentityKey, formatChannel, functionCallBinding, gqlIdentityKey, graphqlOperationBinding, graphqlResolverBinding, hasNameHole, isGraphqlOperationBinding, messageBusBinding, namePatternFromSub, namePatternKey, namesAgree, namesNothing, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageBinding, validateRule };
625
+ export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type BusIdentityKey, type Channel, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, DeployableUnit, type DispatchTable, type FindingSuppression, type FnIdentityKey, type GqlIdentityKey, type MatchResult, MessageBusSemantics, MessageBusTechnology, type MetricIdentityKey, type MetricSemantics, MetricSemanticsSchema, type ParsedChannel, Semantics, type SemconvAttribute, type SemconvMapping, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busIdentityKey, busesAgree, canPair, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, fixedTextLength, fnIdentityKey, formatChannel, functionCallBinding, gqlIdentityKey, graphqlOperationBinding, graphqlResolverBinding, hasNameHole, isGraphqlOperationBinding, messageBusBinding, metricBinding, metricIdentityKey, namePatternFromSub, namePatternKey, namesAgree, namesNothing, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, semconvAttributes, servesRequest, storageBinding, validateRule };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { T as TypeShape, M as MessageBusSemantics, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, e as MessageBusTechnology } from './schemas-D6hKT-zV.js';
3
- export { D as DeployableUnit, f as DeployableUnitSchema, F as FunctionCallSemantics, g as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, h as GraphqlOperationSemanticsSchema, i as GraphqlResolverSemantics, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageSemantics, q as StorageSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-D6hKT-zV.js';
2
+ import { T as TypeShape, M as MessageBusSemantics, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, e as MessageBusTechnology, D as DeployableUnit } from './schemas-CGR6qjFf.js';
3
+ export { f as DeployableUnitSchema, F as FunctionCallSemantics, g as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, h as GraphqlOperationSemanticsSchema, i as GraphqlResolverSemantics, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageSemantics, q as StorageSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-CGR6qjFf.js';
4
4
 
5
5
  /**
6
6
  * Comparing two TypeShapes structurally.
@@ -49,8 +49,33 @@ declare function bodyShapesMatch(actual: TypeShape, declared: TypeShape): MatchR
49
49
  * because a published summary has to mean the same thing to a reader
50
50
  * who never installed the pack that wrote it. If a pack needs a
51
51
  * protocol nobody has defined yet, add a module here.
52
+ *
53
+ * A protocol also says which of its words come from OpenTelemetry's
54
+ * semantic conventions, in `semconv`. The README says why that
55
+ * matters and where it stops.
52
56
  */
53
57
 
58
+ /** One identity field written as an OpenTelemetry attribute. */
59
+ interface SemconvAttribute {
60
+ /** The attribute name, as the semantic conventions spell it. */
61
+ name: string;
62
+ /**
63
+ * Values suss writes where the source named none. A span never says
64
+ * them, so the projection leaves the attribute off rather than
65
+ * emitting a string that could only ever mismatch.
66
+ */
67
+ placeholderValues?: readonly string[];
68
+ }
69
+ /**
70
+ * Which identity fields the semantic conventions have an attribute
71
+ * for. A field is absent when they have no attribute for it, or when
72
+ * our value is our own string rather than the one a span gets.
73
+ */
74
+ type SemconvMapping<S extends {
75
+ name: string;
76
+ }> = {
77
+ readonly [K in Exclude<keyof S, "name">]?: SemconvAttribute;
78
+ };
54
79
  /**
55
80
  * How one semantics variant keys its boundaries and pairs them up. Each
56
81
  * variant fills this in inside its own module, and nothing else in the
@@ -123,6 +148,11 @@ interface BoundarySemanticsDefinition<Z extends z.ZodType<{
123
148
  name: z.infer<Z>["name"];
124
149
  schema: Z;
125
150
  behavior: BoundaryBehavior<z.infer<Z>>;
151
+ /**
152
+ * Every protocol declares this, empty included, so that adding one
153
+ * means deciding where its words come from.
154
+ */
155
+ semconv: SemconvMapping<z.infer<Z>>;
126
156
  }
127
157
 
128
158
  declare const IdentityKeyBrand: unique symbol;
@@ -141,6 +171,39 @@ type BusIdentityKey = `bus:${MessageBusSemantics["messageBus"]} ${string}` & {
141
171
  readonly [IdentityKeyBrand]: "bus";
142
172
  };
143
173
  declare function busIdentityKey(messageBus: MessageBusSemantics["messageBus"], subject: string): BusIdentityKey;
174
+ /** `metric:system type`, the key both sides of a metric pair on. */
175
+ type MetricIdentityKey = `metric:${string} ${string}` & {
176
+ readonly [IdentityKeyBrand]: "metric";
177
+ };
178
+ declare function metricIdentityKey(metricSystem: string, metricType: string): MetricIdentityKey;
179
+
180
+ declare const MetricSemanticsSchema: z.ZodObject<{
181
+ name: z.ZodLiteral<"metric">;
182
+ metricSystem: z.ZodString;
183
+ metricType: z.ZodNullable<z.ZodString>;
184
+ }, z.core.$strip>;
185
+ type MetricSemantics = z.infer<typeof MetricSemanticsSchema>;
186
+
187
+ /**
188
+ * A boundary binding read as OpenTelemetry attributes.
189
+ *
190
+ * A summary says what a unit can reach and a span says what it did
191
+ * reach. Joining the two means both sides spelling the boundary the
192
+ * same way, so suss writes the value a span gets wherever the semantic
193
+ * conventions have a word for it, and this projection puts those
194
+ * values under the attributes a trace store already indexes.
195
+ *
196
+ * Which fields those are is each protocol's own declaration, in its
197
+ * module under `semantics/`. Nothing here knows about any protocol.
198
+ */
199
+
200
+ /**
201
+ * The attributes a boundary states, by name. A field the source never
202
+ * gave, a placeholder, and a field the conventions have no attribute
203
+ * for are all left out, so every pair here compares byte for byte
204
+ * against the same attribute on a span.
205
+ */
206
+ declare function semconvAttributes(binding: BoundaryBinding): Record<string, string>;
144
207
 
145
208
  /**
146
209
  * Keys for a boundary binding, and whether two of them agree. Every
@@ -269,12 +332,13 @@ declare function dispatchByType<T extends {
269
332
  * a template writes `!Sub "${StageName}-orders-v1"` and the code writes
270
333
  * `` `${stage}-orders-v1` ``. Neither side states a string, both agree
271
334
  * about the fixed text, and each spells the parameter its own way. So a
272
- * name is written here as fixed text with `{}` holes, the way a REST
273
- * path is written with `{id}`, and two names agree when their fixed
274
- * parts line up.
335
+ * name is written here as fixed text with `{}` holes, and two names
336
+ * agree when their fixed parts line up.
275
337
  *
276
- * A hole covers a whole parameter rather than one path segment,
277
- * because a name has no separator that every project agrees on.
338
+ * A hole covers a whole parameter rather than one piece of a name,
339
+ * because a name has no separator every project agrees on. Two
340
+ * patterns that both cover one name are told apart by how much fixed
341
+ * text each states, rather than by narrowing what a hole can cover.
278
342
  */
279
343
  /**
280
344
  * The name a CloudFormation `Fn::Sub` value states. The array form
@@ -297,6 +361,8 @@ declare function hasNameHole(name: string): boolean;
297
361
  * token, since the two sides pick their own name for the parameter.
298
362
  */
299
363
  declare function namePatternKey(name: string): string;
364
+ /** How much of a name the writer stated rather than left for deploy time. */
365
+ declare function fixedTextLength(name: string): number;
300
366
  /**
301
367
  * Whether two names are the same name. Two patterns agree when their
302
368
  * fixed parts line up, since a hole on one side meets a hole on the
@@ -515,7 +581,7 @@ declare function isGraphqlOperationBinding(binding: BoundaryBinding | null | und
515
581
  */
516
582
  declare function runtimeConfigBinding(opts: {
517
583
  recognition: string;
518
- deploymentTarget: "lambda" | "ecs-task" | "container" | "k8s-deployment";
584
+ deploymentTarget: DeployableUnit["deploymentTarget"];
519
585
  instanceName: string;
520
586
  }): BoundaryBinding;
521
587
  /**
@@ -545,5 +611,15 @@ declare function messageBusBinding(opts: {
545
611
  /** Null when this source does not say which channel. */
546
612
  channel: string | null;
547
613
  }): BoundaryBinding;
614
+ /**
615
+ * Build a metric binding, the boundary between whatever declares a
616
+ * named series of measurements and whatever reads it back by that name.
617
+ */
618
+ declare function metricBinding(opts: {
619
+ recognition: string;
620
+ metricSystem: string;
621
+ /** Null when this source states a metric it could not name. */
622
+ metricType: string | null;
623
+ }): BoundaryBinding;
548
624
 
549
- export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type BusIdentityKey, type Channel, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DispatchTable, type FindingSuppression, type FnIdentityKey, type GqlIdentityKey, type MatchResult, MessageBusSemantics, MessageBusTechnology, type ParsedChannel, Semantics, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busIdentityKey, busesAgree, canPair, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, fnIdentityKey, formatChannel, functionCallBinding, gqlIdentityKey, graphqlOperationBinding, graphqlResolverBinding, hasNameHole, isGraphqlOperationBinding, messageBusBinding, namePatternFromSub, namePatternKey, namesAgree, namesNothing, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageBinding, validateRule };
625
+ export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type BusIdentityKey, type Channel, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, DeployableUnit, type DispatchTable, type FindingSuppression, type FnIdentityKey, type GqlIdentityKey, type MatchResult, MessageBusSemantics, MessageBusTechnology, type MetricIdentityKey, type MetricSemantics, MetricSemanticsSchema, type ParsedChannel, Semantics, type SemconvAttribute, type SemconvMapping, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busIdentityKey, busesAgree, canPair, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, fixedTextLength, fnIdentityKey, formatChannel, functionCallBinding, gqlIdentityKey, graphqlOperationBinding, graphqlResolverBinding, hasNameHole, isGraphqlOperationBinding, messageBusBinding, metricBinding, metricIdentityKey, namePatternFromSub, namePatternKey, namesAgree, namesNothing, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, semconvAttributes, servesRequest, storageBinding, validateRule };
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-TEXSN75M.js";
36
+ } from "./chunk-XUXN6DIX.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) {
@@ -129,9 +151,22 @@ function hasNameHole(name) {
129
151
  function namePatternKey(name) {
130
152
  return name.replace(HOLE, "{}");
131
153
  }
154
+ function fixedTextLength(name) {
155
+ return name.replace(HOLE, "").length;
156
+ }
157
+ function isHole(part) {
158
+ return part.startsWith("{") && part.endsWith("}");
159
+ }
160
+ function quote(text) {
161
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
162
+ }
163
+ function holeSource(_following) {
164
+ return ".+";
165
+ }
132
166
  function admits(pattern, name) {
133
- const source = pattern.split(/(\{[^}]*\})/).map(
134
- (part) => part.startsWith("{") && part.endsWith("}") ? ".+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
167
+ const parts = pattern.split(/(\{[^}]*\})/);
168
+ const source = parts.map(
169
+ (part, index) => isHole(part) ? holeSource(parts[index + 1] ?? "") : quote(part)
135
170
  ).join("");
136
171
  return new RegExp(`^${source}$`).test(name);
137
172
  }
@@ -520,6 +555,17 @@ function messageBusBinding(opts) {
520
555
  recognition: opts.recognition
521
556
  };
522
557
  }
558
+ function metricBinding(opts) {
559
+ return {
560
+ transport: opts.metricSystem,
561
+ semantics: {
562
+ name: "metric",
563
+ metricSystem: opts.metricSystem,
564
+ metricType: namedOrNull(opts.metricType, "metric type")
565
+ },
566
+ recognition: opts.recognition
567
+ };
568
+ }
523
569
  export {
524
570
  BoundaryBindingSchema,
525
571
  ConfidenceInfoSchema,
@@ -531,6 +577,7 @@ export {
531
577
  GraphqlOperationSemanticsSchema,
532
578
  GraphqlResolverSemanticsSchema,
533
579
  MessageBusSemanticsSchema,
580
+ MetricSemanticsSchema,
534
581
  RestSemanticsSchema,
535
582
  RuntimeConfigSemanticsSchema,
536
583
  SemanticsSchema,
@@ -554,6 +601,7 @@ export {
554
601
  ecsContainerInstanceName,
555
602
  exchangesHttpResponses,
556
603
  fileInCodeScope,
604
+ fixedTextLength,
557
605
  fnIdentityKey,
558
606
  formatChannel,
559
607
  functionCallBinding,
@@ -564,6 +612,8 @@ export {
564
612
  isGraphqlOperationBinding,
565
613
  messageBusBinding,
566
614
  methodsAgree,
615
+ metricBinding,
616
+ metricIdentityKey,
567
617
  namePatternFromSub,
568
618
  namePatternKey,
569
619
  namesAgree,
@@ -579,6 +629,7 @@ export {
579
629
  ruleBoundaryMatchesKey,
580
630
  runtimeConfigBinding,
581
631
  semanticsAgree,
632
+ semconvAttributes,
582
633
  servesRequest,
583
634
  storageBinding,
584
635
  typeDefinitionKey,
@@ -2,13 +2,15 @@ import { z } from 'zod';
2
2
 
3
3
  /**
4
4
  * One thing that gets deployed and runs on its own: a Lambda function,
5
- * an ECS task's container, a plain container, or a k8s deployment.
5
+ * an ECS task's container, a plain container, a k8s deployment, or an
6
+ * edge worker.
6
7
  */
7
8
 
8
9
  /**
9
10
  * `instanceName` is the stable identifier the deployment medium uses:
10
11
  * the CFN logical resource id for Lambda and ECS, the deployment name
11
- * for k8s, the container name for a plain container.
12
+ * for k8s, the container name for a plain container, and the script
13
+ * name for an edge worker.
12
14
  */
13
15
  declare const DeployableUnitSchema: z.ZodObject<{
14
16
  deploymentTarget: z.ZodEnum<{
@@ -16,6 +18,7 @@ declare const DeployableUnitSchema: z.ZodObject<{
16
18
  "ecs-task": "ecs-task";
17
19
  container: "container";
18
20
  "k8s-deployment": "k8s-deployment";
21
+ worker: "worker";
19
22
  }>;
20
23
  instanceName: z.ZodString;
21
24
  }, z.core.$strip>;
@@ -59,13 +62,16 @@ type GraphqlResolverSemantics = z.infer<typeof GraphqlResolverSemanticsSchema>;
59
62
  declare const MessageBusSemanticsSchema: z.ZodObject<{
60
63
  name: z.ZodLiteral<"message-bus">;
61
64
  messageBus: z.ZodEnum<{
62
- sqs: "sqs";
63
- sns: "sns";
65
+ aws_sqs: "aws_sqs";
66
+ "aws.sns": "aws.sns";
64
67
  s3: "s3";
65
68
  eventbridge: "eventbridge";
66
69
  bullmq: "bullmq";
67
70
  kafka: "kafka";
68
71
  nats: "nats";
72
+ "cloudflare-queues": "cloudflare-queues";
73
+ "cloudflare-cron": "cloudflare-cron";
74
+ "cloudflare-tail": "cloudflare-tail";
69
75
  }>;
70
76
  channel: z.ZodNullable<z.ZodString>;
71
77
  }, z.core.$strip>;
@@ -120,6 +126,7 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
120
126
  "ecs-task": "ecs-task";
121
127
  container: "container";
122
128
  "k8s-deployment": "k8s-deployment";
129
+ worker: "worker";
123
130
  }>;
124
131
  instanceName: z.ZodString;
125
132
  name: z.ZodLiteral<"runtime-config">;
@@ -132,15 +139,22 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
132
139
  }, z.core.$strip>, z.ZodObject<{
133
140
  name: z.ZodLiteral<"message-bus">;
134
141
  messageBus: z.ZodEnum<{
135
- sqs: "sqs";
136
- sns: "sns";
142
+ aws_sqs: "aws_sqs";
143
+ "aws.sns": "aws.sns";
137
144
  s3: "s3";
138
145
  eventbridge: "eventbridge";
139
146
  bullmq: "bullmq";
140
147
  kafka: "kafka";
141
148
  nats: "nats";
149
+ "cloudflare-queues": "cloudflare-queues";
150
+ "cloudflare-cron": "cloudflare-cron";
151
+ "cloudflare-tail": "cloudflare-tail";
142
152
  }>;
143
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>;
144
158
  }, z.core.$strip>], "name">;
145
159
  type Semantics = z.infer<typeof SemanticsSchema>;
146
160
 
@@ -183,6 +197,7 @@ declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
183
197
  "ecs-task": "ecs-task";
184
198
  container: "container";
185
199
  "k8s-deployment": "k8s-deployment";
200
+ worker: "worker";
186
201
  }>;
187
202
  instanceName: z.ZodString;
188
203
  name: z.ZodLiteral<"runtime-config">;
@@ -310,6 +325,7 @@ declare const BoundaryBindingSchema: z.ZodObject<{
310
325
  "ecs-task": "ecs-task";
311
326
  container: "container";
312
327
  "k8s-deployment": "k8s-deployment";
328
+ worker: "worker";
313
329
  }>;
314
330
  instanceName: z.ZodString;
315
331
  name: z.ZodLiteral<"runtime-config">;
@@ -322,15 +338,22 @@ declare const BoundaryBindingSchema: z.ZodObject<{
322
338
  }, z.core.$strip>, z.ZodObject<{
323
339
  name: z.ZodLiteral<"message-bus">;
324
340
  messageBus: z.ZodEnum<{
325
- sqs: "sqs";
326
- sns: "sns";
341
+ aws_sqs: "aws_sqs";
342
+ "aws.sns": "aws.sns";
327
343
  s3: "s3";
328
344
  eventbridge: "eventbridge";
329
345
  bullmq: "bullmq";
330
346
  kafka: "kafka";
331
347
  nats: "nats";
348
+ "cloudflare-queues": "cloudflare-queues";
349
+ "cloudflare-cron": "cloudflare-cron";
350
+ "cloudflare-tail": "cloudflare-tail";
332
351
  }>;
333
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>;
334
357
  }, z.core.$strip>], "name">;
335
358
  recognition: z.ZodString;
336
359
  }, z.core.$strip>;
@@ -2,13 +2,15 @@ import { z } from 'zod';
2
2
 
3
3
  /**
4
4
  * One thing that gets deployed and runs on its own: a Lambda function,
5
- * an ECS task's container, a plain container, or a k8s deployment.
5
+ * an ECS task's container, a plain container, a k8s deployment, or an
6
+ * edge worker.
6
7
  */
7
8
 
8
9
  /**
9
10
  * `instanceName` is the stable identifier the deployment medium uses:
10
11
  * the CFN logical resource id for Lambda and ECS, the deployment name
11
- * for k8s, the container name for a plain container.
12
+ * for k8s, the container name for a plain container, and the script
13
+ * name for an edge worker.
12
14
  */
13
15
  declare const DeployableUnitSchema: z.ZodObject<{
14
16
  deploymentTarget: z.ZodEnum<{
@@ -16,6 +18,7 @@ declare const DeployableUnitSchema: z.ZodObject<{
16
18
  "ecs-task": "ecs-task";
17
19
  container: "container";
18
20
  "k8s-deployment": "k8s-deployment";
21
+ worker: "worker";
19
22
  }>;
20
23
  instanceName: z.ZodString;
21
24
  }, z.core.$strip>;
@@ -59,13 +62,16 @@ type GraphqlResolverSemantics = z.infer<typeof GraphqlResolverSemanticsSchema>;
59
62
  declare const MessageBusSemanticsSchema: z.ZodObject<{
60
63
  name: z.ZodLiteral<"message-bus">;
61
64
  messageBus: z.ZodEnum<{
62
- sqs: "sqs";
63
- sns: "sns";
65
+ aws_sqs: "aws_sqs";
66
+ "aws.sns": "aws.sns";
64
67
  s3: "s3";
65
68
  eventbridge: "eventbridge";
66
69
  bullmq: "bullmq";
67
70
  kafka: "kafka";
68
71
  nats: "nats";
72
+ "cloudflare-queues": "cloudflare-queues";
73
+ "cloudflare-cron": "cloudflare-cron";
74
+ "cloudflare-tail": "cloudflare-tail";
69
75
  }>;
70
76
  channel: z.ZodNullable<z.ZodString>;
71
77
  }, z.core.$strip>;
@@ -120,6 +126,7 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
120
126
  "ecs-task": "ecs-task";
121
127
  container: "container";
122
128
  "k8s-deployment": "k8s-deployment";
129
+ worker: "worker";
123
130
  }>;
124
131
  instanceName: z.ZodString;
125
132
  name: z.ZodLiteral<"runtime-config">;
@@ -132,15 +139,22 @@ declare const SemanticsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
132
139
  }, z.core.$strip>, z.ZodObject<{
133
140
  name: z.ZodLiteral<"message-bus">;
134
141
  messageBus: z.ZodEnum<{
135
- sqs: "sqs";
136
- sns: "sns";
142
+ aws_sqs: "aws_sqs";
143
+ "aws.sns": "aws.sns";
137
144
  s3: "s3";
138
145
  eventbridge: "eventbridge";
139
146
  bullmq: "bullmq";
140
147
  kafka: "kafka";
141
148
  nats: "nats";
149
+ "cloudflare-queues": "cloudflare-queues";
150
+ "cloudflare-cron": "cloudflare-cron";
151
+ "cloudflare-tail": "cloudflare-tail";
142
152
  }>;
143
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>;
144
158
  }, z.core.$strip>], "name">;
145
159
  type Semantics = z.infer<typeof SemanticsSchema>;
146
160
 
@@ -183,6 +197,7 @@ declare const RuntimeConfigSemanticsSchema: z.ZodObject<{
183
197
  "ecs-task": "ecs-task";
184
198
  container: "container";
185
199
  "k8s-deployment": "k8s-deployment";
200
+ worker: "worker";
186
201
  }>;
187
202
  instanceName: z.ZodString;
188
203
  name: z.ZodLiteral<"runtime-config">;
@@ -310,6 +325,7 @@ declare const BoundaryBindingSchema: z.ZodObject<{
310
325
  "ecs-task": "ecs-task";
311
326
  container: "container";
312
327
  "k8s-deployment": "k8s-deployment";
328
+ worker: "worker";
313
329
  }>;
314
330
  instanceName: z.ZodString;
315
331
  name: z.ZodLiteral<"runtime-config">;
@@ -322,15 +338,22 @@ declare const BoundaryBindingSchema: z.ZodObject<{
322
338
  }, z.core.$strip>, z.ZodObject<{
323
339
  name: z.ZodLiteral<"message-bus">;
324
340
  messageBus: z.ZodEnum<{
325
- sqs: "sqs";
326
- sns: "sns";
341
+ aws_sqs: "aws_sqs";
342
+ "aws.sns": "aws.sns";
327
343
  s3: "s3";
328
344
  eventbridge: "eventbridge";
329
345
  bullmq: "bullmq";
330
346
  kafka: "kafka";
331
347
  nats: "nats";
348
+ "cloudflare-queues": "cloudflare-queues";
349
+ "cloudflare-cron": "cloudflare-cron";
350
+ "cloudflare-tail": "cloudflare-tail";
332
351
  }>;
333
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>;
334
357
  }, z.core.$strip>], "name">;
335
358
  recognition: z.ZodString;
336
359
  }, z.core.$strip>;