@suss/ir-core 0.5.8 → 0.5.10

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.cjs CHANGED
@@ -42,7 +42,9 @@ __export(index_exports, {
42
42
  bodyShapesMatch: () => bodyShapesMatch,
43
43
  boundaryKey: () => boundaryKey,
44
44
  boundaryLabel: () => boundaryLabel,
45
+ busIdentityKey: () => busIdentityKey,
45
46
  busesAgree: () => busesAgree,
47
+ canPair: () => canPair,
46
48
  channelsPair: () => channelsPair,
47
49
  codeScopePath: () => codeScopePath,
48
50
  countsForThreshold: () => countsForThreshold,
@@ -51,10 +53,13 @@ __export(index_exports, {
51
53
  ecsContainerInstanceName: () => ecsContainerInstanceName,
52
54
  exchangesHttpResponses: () => exchangesHttpResponses,
53
55
  fileInCodeScope: () => fileInCodeScope,
56
+ fnIdentityKey: () => fnIdentityKey,
54
57
  formatChannel: () => formatChannel,
55
58
  functionCallBinding: () => functionCallBinding,
59
+ gqlIdentityKey: () => gqlIdentityKey,
56
60
  graphqlOperationBinding: () => graphqlOperationBinding,
57
61
  graphqlResolverBinding: () => graphqlResolverBinding,
62
+ isGraphqlOperationBinding: () => isGraphqlOperationBinding,
58
63
  messageBusBinding: () => messageBusBinding,
59
64
  methodsAgree: () => methodsAgree,
60
65
  normalizePath: () => normalizePath,
@@ -76,13 +81,7 @@ __export(index_exports, {
76
81
  });
77
82
  module.exports = __toCommonJS(index_exports);
78
83
 
79
- // src/schemas.ts
80
- var import_zod10 = require("zod");
81
-
82
- // src/semantics/registry.ts
83
- var import_zod9 = require("zod");
84
-
85
- // src/semantics/functionCall.ts
84
+ // src/semantics/graphqlOperation.ts
86
85
  var import_zod = require("zod");
87
86
 
88
87
  // src/semantics/definition.ts
@@ -90,18 +89,63 @@ function defineBoundarySemantics(definition) {
90
89
  return definition;
91
90
  }
92
91
 
92
+ // src/semantics/graphqlOperation.ts
93
+ var GraphqlOperationSemanticsSchema = import_zod.z.object({
94
+ name: import_zod.z.literal("graphql-operation"),
95
+ /** Optional operation name. An anonymous query or mutation leaves it unset. */
96
+ operationName: import_zod.z.string().optional(),
97
+ operationType: import_zod.z.enum(["query", "mutation", "subscription"])
98
+ });
99
+ var graphqlOperationSemantics = defineBoundarySemantics({
100
+ name: "graphql-operation",
101
+ schema: GraphqlOperationSemanticsSchema,
102
+ behavior: {
103
+ /**
104
+ * An operation gets a data-and-errors document back, which the
105
+ * GraphQL contract checker reads. Status codes say nothing here.
106
+ */
107
+ exchangesHttpResponses: false,
108
+ reportsUnpairedItself: false,
109
+ identityKey: () => null,
110
+ /** Keyless by design; the dedicated pass pairs it by its document. */
111
+ canPair: () => true,
112
+ /** "query GetUser". The contract checker pairs it, the key does not. */
113
+ displayLabel(semantics) {
114
+ return `${semantics.operationType} ${semantics.operationName ?? "<anonymous>"}`;
115
+ }
116
+ }
117
+ });
118
+
119
+ // src/identityKeys.ts
120
+ function gqlIdentityKey(typeName, fieldName) {
121
+ return `gql:${typeName}.${fieldName}`;
122
+ }
123
+ function fnIdentityKey(packageName, exportPath) {
124
+ return `fn:${packageName}::${exportPath.join(".")}`;
125
+ }
126
+ function busIdentityKey(messageBus, subject) {
127
+ return `bus:${messageBus} ${subject}`;
128
+ }
129
+
130
+ // src/schemas.ts
131
+ var import_zod10 = require("zod");
132
+
133
+ // src/semantics/registry.ts
134
+ var import_zod9 = require("zod");
135
+
93
136
  // src/semantics/functionCall.ts
94
- var FunctionCallSemanticsSchema = import_zod.z.object({
95
- name: import_zod.z.literal("function-call"),
137
+ var import_zod2 = require("zod");
138
+ var FunctionCallSemanticsSchema = import_zod2.z.object({
139
+ name: import_zod2.z.literal("function-call"),
96
140
  /**
97
141
  * Optional module identifier for cross-unit references
98
142
  * (e.g. `"./components/Button"` for a React component, or the TS
99
143
  * module path for a bare function export). Packs that don't do
100
144
  * cross-module pairing can leave it unset.
101
145
  */
102
- module: import_zod.z.string().optional(),
146
+ module: import_zod2.z.string().optional(),
103
147
  /** Named export within the module, when applicable. */
104
- exportName: import_zod.z.string().optional(),
148
+ exportName: import_zod2.z.string().optional(),
105
149
  /**
106
150
  * Package name, as written in `package.json`, when this identity
107
151
  * refers to a public package export, for example
@@ -110,7 +154,7 @@ var FunctionCallSemanticsSchema = import_zod.z.object({
110
154
  * `exportPath`. It is different from `module`, which is a
111
155
  * repo-relative module path used for pairing inside one repo.
112
156
  */
113
- package: import_zod.z.string().optional(),
157
+ package: import_zod2.z.string().optional(),
114
158
  /**
115
159
  * Path to the exported binding within the package, starting with the
116
160
  * sub-path key when one is used. Examples:
@@ -120,7 +164,7 @@ var FunctionCallSemanticsSchema = import_zod.z.object({
120
164
  * The first segment is the sub-path without the leading `./`, and
121
165
  * `"."` is left out. The last segment is the exported name.
122
166
  */
123
- exportPath: import_zod.z.array(import_zod.z.string()).optional()
167
+ exportPath: import_zod2.z.array(import_zod2.z.string()).optional()
124
168
  });
125
169
  var functionCallSemantics = defineBoundarySemantics({
126
170
  name: "function-call",
@@ -129,6 +173,12 @@ var functionCallSemantics = defineBoundarySemantics({
129
173
  /** A call returns a value, which is not a status and a body. */
130
174
  exchangesHttpResponses: false,
131
175
  reportsUnpairedItself: false,
176
+ /**
177
+ * In-repo units (components, bare handlers) are keyless by design
178
+ * and pair through call edges rather than the keyed pass, so a
179
+ * missing key is not a boundary nothing can reach.
180
+ */
181
+ canPair: () => true,
132
182
  /**
133
183
  * `"fn:<package>::<exportPath>"` when both are set. Other in-process
134
184
  * function-call units, such as components and bare handlers inside
@@ -136,39 +186,13 @@ var functionCallSemantics = defineBoundarySemantics({
136
186
  */
137
187
  identityKey(semantics) {
138
188
  if (semantics.package !== void 0 && semantics.exportPath !== void 0 && semantics.exportPath.length > 0) {
139
- return `fn:${semantics.package}::${semantics.exportPath.join(".")}`;
189
+ return fnIdentityKey(semantics.package, semantics.exportPath);
140
190
  }
141
191
  return null;
142
192
  }
143
193
  }
144
194
  });
145
195
 
146
- // src/semantics/graphqlOperation.ts
147
- var import_zod2 = require("zod");
148
- var GraphqlOperationSemanticsSchema = import_zod2.z.object({
149
- name: import_zod2.z.literal("graphql-operation"),
150
- /** Optional operation name. An anonymous query or mutation leaves it unset. */
151
- operationName: import_zod2.z.string().optional(),
152
- operationType: import_zod2.z.enum(["query", "mutation", "subscription"])
153
- });
154
- var graphqlOperationSemantics = defineBoundarySemantics({
155
- name: "graphql-operation",
156
- schema: GraphqlOperationSemanticsSchema,
157
- behavior: {
158
- /**
159
- * An operation gets a data-and-errors document back, which the
160
- * GraphQL contract checker reads. Status codes say nothing here.
161
- */
162
- exchangesHttpResponses: false,
163
- reportsUnpairedItself: false,
164
- identityKey: () => null,
165
- /** "query GetUser". The contract checker pairs it, the key does not. */
166
- displayLabel(semantics) {
167
- return `${semantics.operationType} ${semantics.operationName ?? "<anonymous>"}`;
168
- }
169
- }
170
- });
171
-
172
196
  // src/semantics/graphqlResolver.ts
173
197
  var import_zod3 = require("zod");
174
198
  var GraphqlResolverSemanticsSchema = import_zod3.z.object({
@@ -198,7 +222,7 @@ var graphqlResolverSemantics = defineBoundarySemantics({
198
222
  if (semantics.typeName === null || semantics.fieldName === "") {
199
223
  return null;
200
224
  }
201
- return `gql:${semantics.typeName}.${semantics.fieldName}`;
225
+ return gqlIdentityKey(semantics.typeName, semantics.fieldName);
202
226
  }
203
227
  }
204
228
  });
@@ -260,6 +284,12 @@ var messageBusSemantics = defineBoundarySemantics({
260
284
  * ones, so the generic unmatched lists leave them alone.
261
285
  */
262
286
  reportsUnpairedItself: true,
287
+ /**
288
+ * A channel unnamed here can still pair: the dedicated pass
289
+ * collapses env chains before comparing, so a consumer whose
290
+ * channel arrives at runtime meets the template that declares it.
291
+ */
292
+ canPair: () => true,
263
293
  /**
264
294
  * `"bus:<messageBus> <subject>"`, or null when the channel is null
265
295
  * or its subject is empty.
@@ -282,7 +312,7 @@ var messageBusSemantics = defineBoundarySemantics({
282
312
  if (subject === "") {
283
313
  return null;
284
314
  }
285
- return `bus:${semantics.messageBus} ${subject}`;
315
+ return busIdentityKey(semantics.messageBus, subject);
286
316
  },
287
317
  sidesAgree(a, b) {
288
318
  if (a.channel === null || b.channel === null) {
@@ -477,8 +507,13 @@ var StorageRelationalSemanticsSchema = import_zod8.z.object({
477
507
  * and a monorepo with several schemas gives each one its own value.
478
508
  */
479
509
  scope: import_zod8.z.string(),
480
- /** The table or model name, as declared in the schema. */
481
- table: import_zod8.z.string()
510
+ /**
511
+ * The table or model name as the schema declares it, or null when
512
+ * the source states one this reader could not settle. A null table
513
+ * pairs with nothing, rather than with whatever its source text
514
+ * happens to spell.
515
+ */
516
+ table: import_zod8.z.string().nullable()
482
517
  });
483
518
  var storageRelationalSemantics = defineBoundarySemantics({
484
519
  name: "storage-relational",
@@ -677,6 +712,13 @@ function normalizeRuleBoundary(raw) {
677
712
  function exchangesHttpResponses(binding) {
678
713
  return behaviorOf(binding.semantics).exchangesHttpResponses;
679
714
  }
715
+ function canPair(binding) {
716
+ const behavior = behaviorOf(binding.semantics);
717
+ if (behavior.canPair !== void 0) {
718
+ return behavior.canPair(binding.semantics);
719
+ }
720
+ return pairingKey(binding) !== null;
721
+ }
680
722
  function reportsUnpairedItself(binding) {
681
723
  return behaviorOf(binding.semantics).reportsUnpairedItself;
682
724
  }
@@ -1033,6 +1075,9 @@ function graphqlOperationBinding(opts) {
1033
1075
  recognition: opts.recognition
1034
1076
  };
1035
1077
  }
1078
+ function isGraphqlOperationBinding(binding) {
1079
+ return binding != null && GraphqlOperationSemanticsSchema.safeParse(binding.semantics).success;
1080
+ }
1036
1081
  function runtimeConfigBinding(opts) {
1037
1082
  return {
1038
1083
  transport: "os",
@@ -1051,7 +1096,7 @@ function storageRelationalBinding(opts) {
1051
1096
  name: "storage-relational",
1052
1097
  storageSystem: opts.storageSystem,
1053
1098
  scope: opts.scope,
1054
- table: opts.table
1099
+ table: namedOrNull(opts.table, "storage table")
1055
1100
  },
1056
1101
  recognition: opts.recognition
1057
1102
  };
@@ -1091,7 +1136,9 @@ function messageBusBinding(opts) {
1091
1136
  bodyShapesMatch,
1092
1137
  boundaryKey,
1093
1138
  boundaryLabel,
1139
+ busIdentityKey,
1094
1140
  busesAgree,
1141
+ canPair,
1095
1142
  channelsPair,
1096
1143
  codeScopePath,
1097
1144
  countsForThreshold,
@@ -1100,10 +1147,13 @@ function messageBusBinding(opts) {
1100
1147
  ecsContainerInstanceName,
1101
1148
  exchangesHttpResponses,
1102
1149
  fileInCodeScope,
1150
+ fnIdentityKey,
1103
1151
  formatChannel,
1104
1152
  functionCallBinding,
1153
+ gqlIdentityKey,
1105
1154
  graphqlOperationBinding,
1106
1155
  graphqlResolverBinding,
1156
+ isGraphqlOperationBinding,
1107
1157
  messageBusBinding,
1108
1158
  methodsAgree,
1109
1159
  normalizePath,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { T as TypeShape, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, M as MessageBusTechnology } from './schemas-BWvfkxSH.cjs';
3
- export { D as DeployableUnit, e as DeployableUnitSchema, F as FunctionCallSemantics, f as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, g as GraphqlOperationSemanticsSchema, h as GraphqlResolverSemantics, i as GraphqlResolverSemanticsSchema, j as MessageBusSemantics, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageRelationalSemantics, q as StorageRelationalSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-BWvfkxSH.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 } from './schemas-N9GyG0Sn.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 StorageRelationalSemantics, q as StorageRelationalSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-N9GyG0Sn.cjs';
4
4
 
5
5
  /**
6
6
  * Comparing two TypeShapes structurally.
@@ -104,6 +104,13 @@ interface BoundaryBehavior<S extends {
104
104
  * paired with nothing, so the generic unmatched list can leave it out.
105
105
  */
106
106
  reportsUnpairedItself: boolean;
107
+ /**
108
+ * Whether a boundary with these semantics can pair with anything.
109
+ * Defaults to a non-null pairing key. A protocol whose dedicated
110
+ * pass pairs keyless boundaries overrides it, the way GraphQL
111
+ * operations pair by document rather than by key.
112
+ */
113
+ canPair?(semantics: S): boolean;
107
114
  }
108
115
  /**
109
116
  * One protocol in full: the schema for its identity fields, and the
@@ -118,6 +125,23 @@ interface BoundarySemanticsDefinition<Z extends z.ZodType<{
118
125
  behavior: BoundaryBehavior<z.infer<Z>>;
119
126
  }
120
127
 
128
+ declare const IdentityKeyBrand: unique symbol;
129
+ /** `gql:Type.field`, the boundary key both GraphQL sides pair on. */
130
+ type GqlIdentityKey = `gql:${string}.${string}` & {
131
+ readonly [IdentityKeyBrand]: "gql";
132
+ };
133
+ declare function gqlIdentityKey(typeName: string, fieldName: string): GqlIdentityKey;
134
+ /** `fn:package::export.path`, the key a package-export boundary pairs on. */
135
+ type FnIdentityKey = `fn:${string}::${string}` & {
136
+ readonly [IdentityKeyBrand]: "fn";
137
+ };
138
+ declare function fnIdentityKey(packageName: string, exportPath: readonly string[]): FnIdentityKey;
139
+ /** `bus:technology subject`, with the technology closed off the schema. */
140
+ type BusIdentityKey = `bus:${MessageBusSemantics["messageBus"]} ${string}` & {
141
+ readonly [IdentityKeyBrand]: "bus";
142
+ };
143
+ declare function busIdentityKey(messageBus: MessageBusSemantics["messageBus"], subject: string): BusIdentityKey;
144
+
121
145
  /**
122
146
  * Keys for a boundary binding, and whether two of them agree. Every
123
147
  * function here asks the binding's protocol and returns whatever it
@@ -143,6 +167,11 @@ declare function displayLabel(binding: BoundaryBinding): string;
143
167
  */
144
168
  declare function normalizeRuleBoundary(raw: string): string;
145
169
  declare function exchangesHttpResponses(binding: BoundaryBinding): boolean;
170
+ /**
171
+ * Whether anything can pair with this binding: it has a pairing key,
172
+ * or its protocol pairs keyless boundaries in a dedicated pass.
173
+ */
174
+ declare function canPair(binding: BoundaryBinding): boolean;
146
175
  declare function reportsUnpairedItself(binding: BoundaryBinding): boolean;
147
176
  /**
148
177
  * Null means the protocol does not address its boundaries by method and
@@ -171,7 +200,17 @@ interface ParsedChannel {
171
200
  subject: string;
172
201
  }
173
202
  declare function parseChannel(channel: string): ParsedChannel;
174
- declare function formatChannel(bus: string | null, subject: string): string;
203
+ declare const ChannelBrand: unique symbol;
204
+ /**
205
+ * `bus#subject`, or the bare subject when no source said the bus. The
206
+ * unqualified form is legal, so fields keep the type string and the
207
+ * mint is the whole win: a channel assembled by hand cannot claim the
208
+ * brand, and the format has one spelling (#167).
209
+ */
210
+ type Channel = string & {
211
+ readonly [ChannelBrand]: "channel";
212
+ };
213
+ declare function formatChannel(bus: string | null, subject: string): Channel;
175
214
  declare function busesAgree(a: string | null, b: string | null): boolean;
176
215
  declare function channelsPair(a: string, b: string): boolean;
177
216
 
@@ -418,6 +457,12 @@ declare function graphqlOperationBinding(opts: {
418
457
  operationType: "query" | "mutation" | "subscription";
419
458
  operationName?: string;
420
459
  }): BoundaryBinding;
460
+ /**
461
+ * Whether a binding is the consumer side of a GraphQL boundary,
462
+ * settled by the protocol's own schema so callers do not compare the
463
+ * semantics tag themselves.
464
+ */
465
+ declare function isGraphqlOperationBinding(binding: BoundaryBinding | null | undefined): boolean;
421
466
  /**
422
467
  * Build a runtime-config binding, the provider side of a runtime
423
468
  * configuration channel (env vars on a Lambda, ECS task, container, or
@@ -439,7 +484,8 @@ declare function storageRelationalBinding(opts: {
439
484
  recognition: string;
440
485
  storageSystem: "postgres" | "mysql" | "sqlite";
441
486
  scope: string;
442
- table: string;
487
+ /** Null when the source names a table this reader could not settle. */
488
+ table: string | null;
443
489
  }): BoundaryBinding;
444
490
  /**
445
491
  * Build a message-bus binding, the boundary between a producer that
@@ -452,4 +498,4 @@ declare function messageBusBinding(opts: {
452
498
  channel: string | null;
453
499
  }): BoundaryBinding;
454
500
 
455
- export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DispatchTable, type FindingSuppression, type MatchResult, MessageBusTechnology, type ParsedChannel, Semantics, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busesAgree, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, formatChannel, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageRelationalBinding, validateRule };
501
+ 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, isGraphqlOperationBinding, messageBusBinding, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageRelationalBinding, validateRule };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { T as TypeShape, S as Semantics, B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, d as SourceLocationSchema, M as MessageBusTechnology } from './schemas-BWvfkxSH.js';
3
- export { D as DeployableUnit, e as DeployableUnitSchema, F as FunctionCallSemantics, f as FunctionCallSemanticsSchema, G as GraphqlOperationSemantics, g as GraphqlOperationSemanticsSchema, h as GraphqlResolverSemantics, i as GraphqlResolverSemanticsSchema, j as MessageBusSemantics, k as MessageBusSemanticsSchema, R as RestSemantics, l as RestSemanticsSchema, m as RuntimeConfigSemantics, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, p as StorageRelationalSemantics, q as StorageRelationalSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-BWvfkxSH.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 } from './schemas-N9GyG0Sn.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 StorageRelationalSemantics, q as StorageRelationalSemanticsSchema, r as TypeShapeSchema, s as ecsContainerInstanceName, t as methodsAgree, u as normalizePath, v as routePathAdmits, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-N9GyG0Sn.js';
4
4
 
5
5
  /**
6
6
  * Comparing two TypeShapes structurally.
@@ -104,6 +104,13 @@ interface BoundaryBehavior<S extends {
104
104
  * paired with nothing, so the generic unmatched list can leave it out.
105
105
  */
106
106
  reportsUnpairedItself: boolean;
107
+ /**
108
+ * Whether a boundary with these semantics can pair with anything.
109
+ * Defaults to a non-null pairing key. A protocol whose dedicated
110
+ * pass pairs keyless boundaries overrides it, the way GraphQL
111
+ * operations pair by document rather than by key.
112
+ */
113
+ canPair?(semantics: S): boolean;
107
114
  }
108
115
  /**
109
116
  * One protocol in full: the schema for its identity fields, and the
@@ -118,6 +125,23 @@ interface BoundarySemanticsDefinition<Z extends z.ZodType<{
118
125
  behavior: BoundaryBehavior<z.infer<Z>>;
119
126
  }
120
127
 
128
+ declare const IdentityKeyBrand: unique symbol;
129
+ /** `gql:Type.field`, the boundary key both GraphQL sides pair on. */
130
+ type GqlIdentityKey = `gql:${string}.${string}` & {
131
+ readonly [IdentityKeyBrand]: "gql";
132
+ };
133
+ declare function gqlIdentityKey(typeName: string, fieldName: string): GqlIdentityKey;
134
+ /** `fn:package::export.path`, the key a package-export boundary pairs on. */
135
+ type FnIdentityKey = `fn:${string}::${string}` & {
136
+ readonly [IdentityKeyBrand]: "fn";
137
+ };
138
+ declare function fnIdentityKey(packageName: string, exportPath: readonly string[]): FnIdentityKey;
139
+ /** `bus:technology subject`, with the technology closed off the schema. */
140
+ type BusIdentityKey = `bus:${MessageBusSemantics["messageBus"]} ${string}` & {
141
+ readonly [IdentityKeyBrand]: "bus";
142
+ };
143
+ declare function busIdentityKey(messageBus: MessageBusSemantics["messageBus"], subject: string): BusIdentityKey;
144
+
121
145
  /**
122
146
  * Keys for a boundary binding, and whether two of them agree. Every
123
147
  * function here asks the binding's protocol and returns whatever it
@@ -143,6 +167,11 @@ declare function displayLabel(binding: BoundaryBinding): string;
143
167
  */
144
168
  declare function normalizeRuleBoundary(raw: string): string;
145
169
  declare function exchangesHttpResponses(binding: BoundaryBinding): boolean;
170
+ /**
171
+ * Whether anything can pair with this binding: it has a pairing key,
172
+ * or its protocol pairs keyless boundaries in a dedicated pass.
173
+ */
174
+ declare function canPair(binding: BoundaryBinding): boolean;
146
175
  declare function reportsUnpairedItself(binding: BoundaryBinding): boolean;
147
176
  /**
148
177
  * Null means the protocol does not address its boundaries by method and
@@ -171,7 +200,17 @@ interface ParsedChannel {
171
200
  subject: string;
172
201
  }
173
202
  declare function parseChannel(channel: string): ParsedChannel;
174
- declare function formatChannel(bus: string | null, subject: string): string;
203
+ declare const ChannelBrand: unique symbol;
204
+ /**
205
+ * `bus#subject`, or the bare subject when no source said the bus. The
206
+ * unqualified form is legal, so fields keep the type string and the
207
+ * mint is the whole win: a channel assembled by hand cannot claim the
208
+ * brand, and the format has one spelling (#167).
209
+ */
210
+ type Channel = string & {
211
+ readonly [ChannelBrand]: "channel";
212
+ };
213
+ declare function formatChannel(bus: string | null, subject: string): Channel;
175
214
  declare function busesAgree(a: string | null, b: string | null): boolean;
176
215
  declare function channelsPair(a: string, b: string): boolean;
177
216
 
@@ -418,6 +457,12 @@ declare function graphqlOperationBinding(opts: {
418
457
  operationType: "query" | "mutation" | "subscription";
419
458
  operationName?: string;
420
459
  }): BoundaryBinding;
460
+ /**
461
+ * Whether a binding is the consumer side of a GraphQL boundary,
462
+ * settled by the protocol's own schema so callers do not compare the
463
+ * semantics tag themselves.
464
+ */
465
+ declare function isGraphqlOperationBinding(binding: BoundaryBinding | null | undefined): boolean;
421
466
  /**
422
467
  * Build a runtime-config binding, the provider side of a runtime
423
468
  * configuration channel (env vars on a Lambda, ECS task, container, or
@@ -439,7 +484,8 @@ declare function storageRelationalBinding(opts: {
439
484
  recognition: string;
440
485
  storageSystem: "postgres" | "mysql" | "sqlite";
441
486
  scope: string;
442
- table: string;
487
+ /** Null when the source names a table this reader could not settle. */
488
+ table: string | null;
443
489
  }): BoundaryBinding;
444
490
  /**
445
491
  * Build a message-bus binding, the boundary between a producer that
@@ -452,4 +498,4 @@ declare function messageBusBinding(opts: {
452
498
  channel: string | null;
453
499
  }): BoundaryBinding;
454
500
 
455
- export { type BoundaryBehavior, type BoundaryBinding, BoundaryBindingSchema, type BoundarySemanticsDefinition, type ConfidenceInfo, ConfidenceInfoSchema, type ConfidenceLevel, ConfidenceLevelSchema, type ConfidenceSource, ConfidenceSourceSchema, type Corroboration, CorroborationSchema, type DispatchTable, type FindingSuppression, type MatchResult, MessageBusTechnology, type ParsedChannel, Semantics, type SourceLocation, SourceLocationSchema, type SuppressableSeverity, type SuppressibleFinding, type SuppressionFile, SuppressionFileSchema, type SuppressionRule, SuppressionRuleSchema, TypeShape, applySuppressionsToFindings, bodyShapesMatch, boundaryKey, boundaryLabel, busesAgree, channelsPair, codeScopePath, countsForThreshold, dispatchByType, displayLabel, exchangesHttpResponses, fileInCodeScope, formatChannel, functionCallBinding, graphqlOperationBinding, graphqlResolverBinding, messageBusBinding, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageRelationalBinding, validateRule };
501
+ 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, isGraphqlOperationBinding, messageBusBinding, normalizeRuleBoundary, packageExportBinding, pairingKey, parseChannel, reportsUnpairedItself, restBinding, ruleBoundaryMatchesKey, runtimeConfigBinding, semanticsAgree, servesRequest, storageRelationalBinding, validateRule };
package/dist/index.js CHANGED
@@ -17,17 +17,20 @@ import {
17
17
  TypeShapeSchema,
18
18
  allBehaviors,
19
19
  behaviorOf,
20
+ busIdentityKey,
20
21
  busesAgree,
21
22
  channelsPair,
22
23
  ecsContainerInstanceName,
24
+ fnIdentityKey,
23
25
  formatChannel,
26
+ gqlIdentityKey,
24
27
  methodsAgree,
25
28
  normalizePath,
26
29
  parseChannel,
27
30
  routePathAdmits,
28
31
  typeDefinitionKey,
29
32
  withDefinitionsInlined
30
- } from "./chunk-5KE7OWN3.js";
33
+ } from "./chunk-WKR5SU4N.js";
31
34
 
32
35
  // src/boundaryKey.ts
33
36
  function boundaryKey(binding) {
@@ -63,6 +66,13 @@ function normalizeRuleBoundary(raw) {
63
66
  function exchangesHttpResponses(binding) {
64
67
  return behaviorOf(binding.semantics).exchangesHttpResponses;
65
68
  }
69
+ function canPair(binding) {
70
+ const behavior = behaviorOf(binding.semantics);
71
+ if (behavior.canPair !== void 0) {
72
+ return behavior.canPair(binding.semantics);
73
+ }
74
+ return pairingKey(binding) !== null;
75
+ }
66
76
  function reportsUnpairedItself(binding) {
67
77
  return behaviorOf(binding.semantics).reportsUnpairedItself;
68
78
  }
@@ -419,6 +429,9 @@ function graphqlOperationBinding(opts) {
419
429
  recognition: opts.recognition
420
430
  };
421
431
  }
432
+ function isGraphqlOperationBinding(binding) {
433
+ return binding != null && GraphqlOperationSemanticsSchema.safeParse(binding.semantics).success;
434
+ }
422
435
  function runtimeConfigBinding(opts) {
423
436
  return {
424
437
  transport: "os",
@@ -437,7 +450,7 @@ function storageRelationalBinding(opts) {
437
450
  name: "storage-relational",
438
451
  storageSystem: opts.storageSystem,
439
452
  scope: opts.scope,
440
- table: opts.table
453
+ table: namedOrNull(opts.table, "storage table")
441
454
  },
442
455
  recognition: opts.recognition
443
456
  };
@@ -476,7 +489,9 @@ export {
476
489
  bodyShapesMatch,
477
490
  boundaryKey,
478
491
  boundaryLabel,
492
+ busIdentityKey,
479
493
  busesAgree,
494
+ canPair,
480
495
  channelsPair,
481
496
  codeScopePath,
482
497
  countsForThreshold,
@@ -485,10 +500,13 @@ export {
485
500
  ecsContainerInstanceName,
486
501
  exchangesHttpResponses,
487
502
  fileInCodeScope,
503
+ fnIdentityKey,
488
504
  formatChannel,
489
505
  functionCallBinding,
506
+ gqlIdentityKey,
490
507
  graphqlOperationBinding,
491
508
  graphqlResolverBinding,
509
+ isGraphqlOperationBinding,
492
510
  messageBusBinding,
493
511
  methodsAgree,
494
512
  normalizePath,
@@ -429,4 +429,4 @@ declare const TypeShapeSchema: z.ZodType<TypeShape>;
429
429
  */
430
430
  declare function withDefinitionsInlined(shape: TypeShape, definitions: Record<string, TypeShape> | undefined, depth?: number, inProgress?: ReadonlySet<string>): TypeShape;
431
431
 
432
- export { BoundaryBindingSchema as B, ConfidenceInfoSchema as C, type DeployableUnit as D, type FunctionCallSemantics as F, type GraphqlOperationSemantics as G, type MessageBusTechnology as M, type RestSemantics as R, type Semantics as S, type TypeShape as T, ConfidenceLevelSchema as a, ConfidenceSourceSchema as b, CorroborationSchema as c, SourceLocationSchema as d, DeployableUnitSchema as e, FunctionCallSemanticsSchema as f, GraphqlOperationSemanticsSchema as g, type GraphqlResolverSemantics as h, GraphqlResolverSemanticsSchema as i, type MessageBusSemantics as j, MessageBusSemanticsSchema as k, RestSemanticsSchema as l, type RuntimeConfigSemantics as m, RuntimeConfigSemanticsSchema as n, SemanticsSchema as o, type StorageRelationalSemantics as p, StorageRelationalSemanticsSchema as q, TypeShapeSchema as r, ecsContainerInstanceName as s, methodsAgree as t, normalizePath as u, routePathAdmits as v, typeDefinitionKey as w, withDefinitionsInlined as x };
432
+ export { BoundaryBindingSchema as B, ConfidenceInfoSchema as C, type DeployableUnit as D, type FunctionCallSemantics as F, type GraphqlOperationSemantics as G, type MessageBusSemantics as M, type RestSemantics as R, type Semantics as S, type TypeShape as T, ConfidenceLevelSchema as a, ConfidenceSourceSchema as b, CorroborationSchema as c, SourceLocationSchema as d, type MessageBusTechnology as e, DeployableUnitSchema as f, FunctionCallSemanticsSchema as g, GraphqlOperationSemanticsSchema as h, type GraphqlResolverSemantics as i, GraphqlResolverSemanticsSchema as j, MessageBusSemanticsSchema as k, RestSemanticsSchema as l, type RuntimeConfigSemantics as m, RuntimeConfigSemanticsSchema as n, SemanticsSchema as o, type StorageRelationalSemantics as p, StorageRelationalSemanticsSchema as q, TypeShapeSchema as r, ecsContainerInstanceName as s, methodsAgree as t, normalizePath as u, routePathAdmits as v, typeDefinitionKey as w, withDefinitionsInlined as x };
@@ -429,4 +429,4 @@ declare const TypeShapeSchema: z.ZodType<TypeShape>;
429
429
  */
430
430
  declare function withDefinitionsInlined(shape: TypeShape, definitions: Record<string, TypeShape> | undefined, depth?: number, inProgress?: ReadonlySet<string>): TypeShape;
431
431
 
432
- export { BoundaryBindingSchema as B, ConfidenceInfoSchema as C, type DeployableUnit as D, type FunctionCallSemantics as F, type GraphqlOperationSemantics as G, type MessageBusTechnology as M, type RestSemantics as R, type Semantics as S, type TypeShape as T, ConfidenceLevelSchema as a, ConfidenceSourceSchema as b, CorroborationSchema as c, SourceLocationSchema as d, DeployableUnitSchema as e, FunctionCallSemanticsSchema as f, GraphqlOperationSemanticsSchema as g, type GraphqlResolverSemantics as h, GraphqlResolverSemanticsSchema as i, type MessageBusSemantics as j, MessageBusSemanticsSchema as k, RestSemanticsSchema as l, type RuntimeConfigSemantics as m, RuntimeConfigSemanticsSchema as n, SemanticsSchema as o, type StorageRelationalSemantics as p, StorageRelationalSemanticsSchema as q, TypeShapeSchema as r, ecsContainerInstanceName as s, methodsAgree as t, normalizePath as u, routePathAdmits as v, typeDefinitionKey as w, withDefinitionsInlined as x };
432
+ export { BoundaryBindingSchema as B, ConfidenceInfoSchema as C, type DeployableUnit as D, type FunctionCallSemantics as F, type GraphqlOperationSemantics as G, type MessageBusSemantics as M, type RestSemantics as R, type Semantics as S, type TypeShape as T, ConfidenceLevelSchema as a, ConfidenceSourceSchema as b, CorroborationSchema as c, SourceLocationSchema as d, type MessageBusTechnology as e, DeployableUnitSchema as f, FunctionCallSemanticsSchema as g, GraphqlOperationSemanticsSchema as h, type GraphqlResolverSemantics as i, GraphqlResolverSemanticsSchema as j, MessageBusSemanticsSchema as k, RestSemanticsSchema as l, type RuntimeConfigSemantics as m, RuntimeConfigSemanticsSchema as n, SemanticsSchema as o, type StorageRelationalSemantics as p, StorageRelationalSemanticsSchema as q, TypeShapeSchema as r, ecsContainerInstanceName as s, methodsAgree as t, normalizePath as u, routePathAdmits as v, typeDefinitionKey as w, withDefinitionsInlined as x };