@skmtc/core 0.54.0 → 0.55.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.
@@ -0,0 +1,209 @@
1
+ import type { GenerateContextType } from './generateTypes.js';
2
+ import type { OasOperationEntry } from '../dsl/operation/oas/toOasOperationEntry.js';
3
+ import type { WebhookEntry } from '../dsl/webhook/toWebhookEntry.js';
4
+ import type { GqlOperationEntry } from '../dsl/operation/gql/toGqlOperationEntry.js';
5
+ import type { ModelEntry } from '../dsl/model/toModelEntry.js';
6
+ import type { OasOperation } from '../oas/operation/Operation.js';
7
+ import type { OasWebhook } from '../oas/webhook/Webhook.js';
8
+ import type { GqlOperation } from '../gql/operation/GqlOperation.js';
9
+ import type { DeclaredProjection } from '../dsl/DeclaredProjection.js';
10
+ import type { Reach } from '../parse/Reach.js';
11
+ import { type RefParts } from '../helpers/refFns.js';
12
+ import type { RefName } from '../types/RefName.js';
13
+ import type { IncludeModelRefs, IncludePaths, SkipModelRefs, SkipPaths } from '../types/Settings.js';
14
+ import type { GqlOperationSource, ModelSource, OasOperationSource, PreviewModule, WebhookSource } from '../types/Preview.js';
15
+ /** A generator entry, the run's context and one variant: what a subject is asked with. */
16
+ type AskArgs<Entry> = {
17
+ entry: Entry;
18
+ context: GenerateContextType;
19
+ variant: string;
20
+ };
21
+ type ToSourceArgs = {
22
+ generatorId: string;
23
+ variant: string;
24
+ };
25
+ type ToExportPathArgs = {
26
+ projection: DeclaredProjection;
27
+ context: GenerateContextType;
28
+ variant: string;
29
+ };
30
+ /**
31
+ * What the file plan asks of a subject: where its enrichments are, the
32
+ * file a projection gives it, and the models it can get to.
33
+ */
34
+ export type PlannedSubject = {
35
+ /** Its kind, which is the `type` of the entries and the projections that take it. */
36
+ readonly type: DeclaredProjection['type'];
37
+ /** Where its enrichments are below a generator's id. A variant's name follows. */
38
+ readonly enrichmentPath: string[];
39
+ /** What a message calls it. */
40
+ readonly label: string;
41
+ /**
42
+ * The export path a declared projection gives it for one variant, as the
43
+ * projection's statics say it. `undefined` for a projection of another kind.
44
+ */
45
+ toExportPath(args: ToExportPathArgs): string | undefined;
46
+ /**
47
+ * The keys of the models it names: for a model, its own key; for any other
48
+ * subject, the models its `$ref`s give (`Reach.namedByOperation`, `Reach.namedByWebhook`). It can get to
49
+ * each of them, and to what each reaches.
50
+ */
51
+ toNamedModels(reach: Reach): readonly string[];
52
+ };
53
+ /**
54
+ * One subject of a run: an OpenAPI operation, a webhook, a GraphQL operation
55
+ * or a model. For the run, it holds how its kind differs from the others:
56
+ * where its results and its enrichments are, what a message calls it, which
57
+ * filter names it, and how an entry of its kind is called with it. The run
58
+ * asks every kind the same questions, in the same order.
59
+ *
60
+ * @template Entry - The generator entry of the subject's kind
61
+ * @template Filter - One generator's `settings.include` or `settings.skip`
62
+ * filter for the kind; `never` for a kind that has none
63
+ */
64
+ export type Subject<Entry, Filter> = PlannedSubject & {
65
+ /** Its frame or frames below the generator's in a trail, and so its place in `manifest.results`. */
66
+ readonly trail: string | string[];
67
+ isSupported: (args: AskArgs<Entry>) => boolean;
68
+ /** Whether a filter of `settings.include` or `settings.skip` names this variant of it. */
69
+ matches(filter: Filter | undefined, variant: string): boolean;
70
+ transform: (args: AskArgs<Entry>) => void;
71
+ toPreviewModule: (args: AskArgs<Entry>) => PreviewModule | undefined;
72
+ toSource(args: ToSourceArgs): OasOperationSource | WebhookSource | GqlOperationSource | ModelSource;
73
+ };
74
+ /** An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`. */
75
+ export declare class OasOperationSubject implements Subject<OasOperationEntry, IncludePaths | SkipPaths> {
76
+ readonly type = "oasOperation";
77
+ operation: OasOperation;
78
+ trail: string[];
79
+ enrichmentPath: string[];
80
+ label: string;
81
+ constructor(operation: OasOperation);
82
+ isSupported({ entry, context, variant }: AskArgs<OasOperationEntry>): boolean;
83
+ matches(filter: IncludePaths | SkipPaths | undefined, variant: string): boolean;
84
+ transform({ entry, context, variant }: AskArgs<OasOperationEntry>): void;
85
+ toPreviewModule({ entry, context, variant }: AskArgs<OasOperationEntry>): PreviewModule | undefined;
86
+ toExportPath({ projection, context, variant }: ToExportPathArgs): string | undefined;
87
+ toNamedModels(reach: Reach): readonly string[];
88
+ toSource({ generatorId, variant }: ToSourceArgs): OasOperationSource;
89
+ }
90
+ /**
91
+ * A 3.1 webhook as a subject. Its results are at `['webhook'][name][method]`
92
+ * and its enrichments at `[name][method]`. A filter has the shape of an
93
+ * operation's, with the webhook's name in the place of the path.
94
+ */
95
+ export declare class WebhookSubject implements Subject<WebhookEntry, IncludePaths | SkipPaths> {
96
+ readonly type = "webhook";
97
+ webhook: OasWebhook;
98
+ trail: string[];
99
+ enrichmentPath: string[];
100
+ label: string;
101
+ constructor(webhook: OasWebhook);
102
+ isSupported({ entry, context, variant }: AskArgs<WebhookEntry>): boolean;
103
+ matches(filter: IncludePaths | SkipPaths | undefined, variant: string): boolean;
104
+ transform({ entry, context, variant }: AskArgs<WebhookEntry>): void;
105
+ toPreviewModule({ entry, context, variant }: AskArgs<WebhookEntry>): PreviewModule | undefined;
106
+ toExportPath({ projection, context, variant }: ToExportPathArgs): string | undefined;
107
+ toNamedModels(reach: Reach): readonly string[];
108
+ toSource({ generatorId, variant }: ToSourceArgs): WebhookSource;
109
+ }
110
+ /**
111
+ * A GraphQL operation as a subject. Its results and enrichments are at
112
+ * `[rootKind][fieldName]`. `settings.include` and `settings.skip` have no
113
+ * filter for a GraphQL operation, so no filter names it.
114
+ */
115
+ export declare class GqlOperationSubject implements Subject<GqlOperationEntry, never> {
116
+ readonly type = "gqlOperation";
117
+ operation: GqlOperation;
118
+ trail: string[];
119
+ enrichmentPath: string[];
120
+ label: string;
121
+ constructor(operation: GqlOperation);
122
+ isSupported({ entry, context, variant }: AskArgs<GqlOperationEntry>): boolean;
123
+ matches(): boolean;
124
+ transform({ entry, context, variant }: AskArgs<GqlOperationEntry>): void;
125
+ toPreviewModule({ entry, context, variant }: AskArgs<GqlOperationEntry>): PreviewModule | undefined;
126
+ toExportPath(): undefined;
127
+ toNamedModels(): readonly string[];
128
+ toSource({ generatorId, variant }: ToSourceArgs): GqlOperationSource;
129
+ }
130
+ /**
131
+ * A model as a subject. Its results and enrichments are at its model key
132
+ * (`toModelKey`): the `refName` of a component, the whole pointer of any
133
+ * other model. The run makes one for each schema component of either
134
+ * protocol; the file plan also makes one for a model that is no component,
135
+ * which a `$ref` to a place inside a schema gives.
136
+ */
137
+ export declare class ModelSubject implements Subject<ModelEntry, IncludeModelRefs | SkipModelRefs> {
138
+ readonly type = "model";
139
+ refName: RefName;
140
+ ref: RefParts;
141
+ trail: string;
142
+ enrichmentPath: string[];
143
+ label: string;
144
+ constructor(ref: RefParts);
145
+ isSupported({ entry, context, variant }: AskArgs<ModelEntry>): boolean;
146
+ matches(filter: IncludeModelRefs | SkipModelRefs | undefined, variant: string): boolean;
147
+ transform({ entry, context, variant }: AskArgs<ModelEntry>): void;
148
+ toPreviewModule({ entry, context, variant }: AskArgs<ModelEntry>): PreviewModule | undefined;
149
+ toExportPath({ projection, context, variant }: ToExportPathArgs): string | undefined;
150
+ toNamedModels(): readonly string[];
151
+ toSource({ generatorId, variant }: ToSourceArgs): ModelSource;
152
+ }
153
+ type ToOasOperationSourceArgs = {
154
+ operation: OasOperation;
155
+ generatorId: string;
156
+ /** Operation variant the artifact was emitted for (see {@link Variant}) */
157
+ variant: string;
158
+ };
159
+ /**
160
+ * Creates an OasOperationSource from an operation, generator ID, and variant.
161
+ *
162
+ * Transforms operation and generator information into a source descriptor
163
+ * that can be used for tracking operation origins in the generation pipeline.
164
+ *
165
+ * @param args - Arguments containing operation, generator ID, and variant
166
+ * @returns OasOperationSource descriptor for the operation
167
+ */
168
+ export declare const toOasOperationSource: ({ operation, generatorId, variant }: ToOasOperationSourceArgs) => OasOperationSource;
169
+ type ToWebhookSourceArgs = {
170
+ webhook: OasWebhook;
171
+ generatorId: string;
172
+ /** Webhook variant the artifact was emitted for (see {@link Variant}) */
173
+ variant: string;
174
+ };
175
+ /**
176
+ * Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
177
+ * Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
178
+ */
179
+ export declare const toWebhookSource: ({ webhook, generatorId, variant }: ToWebhookSourceArgs) => WebhookSource;
180
+ type ToGqlOperationSourceArgs = {
181
+ operation: GqlOperation;
182
+ generatorId: string;
183
+ /** Operation variant the artifact was emitted for (see {@link Variant}) */
184
+ variant: string;
185
+ };
186
+ /**
187
+ * Creates a GraphQL operation source descriptor.
188
+ *
189
+ * Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
190
+ * `rootKind` and `fieldName` instead of `path` / `method`.
191
+ */
192
+ export declare const toGqlOperationSource: ({ operation, generatorId, variant }: ToGqlOperationSourceArgs) => GqlOperationSource;
193
+ type ToModelSourceArgs = {
194
+ refName: RefName;
195
+ generatorId: string;
196
+ /** Model variant the artifact was emitted for (see {@link Variant}) */
197
+ variant: string;
198
+ };
199
+ /**
200
+ * Creates a ModelSource from a reference name, generator ID, and variant.
201
+ *
202
+ * Transforms model reference and generator information into a source descriptor
203
+ * that can be used for tracking model origins in the generation pipeline.
204
+ *
205
+ * @param args - Arguments containing reference name, generator ID, and variant
206
+ * @returns ModelSource descriptor for the model
207
+ */
208
+ export declare const toModelSource: ({ refName, generatorId, variant }: ToModelSourceArgs) => ModelSource;
209
+ export {};
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toModelSource = exports.toGqlOperationSource = exports.toWebhookSource = exports.toOasOperationSource = exports.ModelSubject = exports.GqlOperationSubject = exports.WebhookSubject = exports.OasOperationSubject = void 0;
4
+ const refFns_js_1 = require("../helpers/refFns.js");
5
+ /** An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`. */
6
+ class OasOperationSubject {
7
+ constructor(operation) {
8
+ Object.defineProperty(this, "type", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: 'oasOperation'
13
+ });
14
+ Object.defineProperty(this, "operation", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "trail", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ Object.defineProperty(this, "enrichmentPath", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ Object.defineProperty(this, "label", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+ this.operation = operation;
39
+ this.trail = [operation.path, operation.method];
40
+ this.enrichmentPath = this.trail;
41
+ this.label = `${operation.method.toUpperCase()} ${operation.path}`;
42
+ }
43
+ isSupported({ entry, context, variant }) {
44
+ return (typeof entry.isSupported !== 'function' ||
45
+ entry.isSupported({ operation: this.operation, context, variant }));
46
+ }
47
+ matches(filter, variant) {
48
+ const { path, method } = this.operation;
49
+ return matchesPathFilter({ paths: filter, path, method, variant });
50
+ }
51
+ transform({ entry, context, variant }) {
52
+ entry.transform({ context, operation: this.operation, variant });
53
+ }
54
+ toPreviewModule({ entry, context, variant }) {
55
+ return entry.toPreviewModule?.({ context, operation: this.operation, variant });
56
+ }
57
+ toExportPath({ projection, context, variant }) {
58
+ if (projection.type !== 'oasOperation') {
59
+ return undefined;
60
+ }
61
+ const enrichments = projection.toEnrichments({ operation: this.operation, context, variant });
62
+ return projection.toExportPath({ operation: this.operation, enrichments, variant });
63
+ }
64
+ toNamedModels(reach) {
65
+ return reach.namedByOperation(this.operation);
66
+ }
67
+ toSource({ generatorId, variant }) {
68
+ return (0, exports.toOasOperationSource)({ operation: this.operation, generatorId, variant });
69
+ }
70
+ }
71
+ exports.OasOperationSubject = OasOperationSubject;
72
+ /**
73
+ * A 3.1 webhook as a subject. Its results are at `['webhook'][name][method]`
74
+ * and its enrichments at `[name][method]`. A filter has the shape of an
75
+ * operation's, with the webhook's name in the place of the path.
76
+ */
77
+ class WebhookSubject {
78
+ constructor(webhook) {
79
+ Object.defineProperty(this, "type", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: 'webhook'
84
+ });
85
+ Object.defineProperty(this, "webhook", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: void 0
90
+ });
91
+ Object.defineProperty(this, "trail", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: void 0
96
+ });
97
+ Object.defineProperty(this, "enrichmentPath", {
98
+ enumerable: true,
99
+ configurable: true,
100
+ writable: true,
101
+ value: void 0
102
+ });
103
+ Object.defineProperty(this, "label", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: void 0
108
+ });
109
+ this.webhook = webhook;
110
+ this.trail = ['webhook', webhook.name, webhook.method];
111
+ this.enrichmentPath = [webhook.name, webhook.method];
112
+ this.label = `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`;
113
+ }
114
+ isSupported({ entry, context, variant }) {
115
+ return (typeof entry.isSupported !== 'function' ||
116
+ entry.isSupported({ webhook: this.webhook, context, variant }));
117
+ }
118
+ matches(filter, variant) {
119
+ const { name, method } = this.webhook;
120
+ return matchesPathFilter({ paths: filter, path: name, method, variant });
121
+ }
122
+ transform({ entry, context, variant }) {
123
+ entry.transform({ context, webhook: this.webhook, variant });
124
+ }
125
+ toPreviewModule({ entry, context, variant }) {
126
+ return entry.toPreviewModule?.({ context, webhook: this.webhook, variant });
127
+ }
128
+ toExportPath({ projection, context, variant }) {
129
+ if (projection.type !== 'webhook') {
130
+ return undefined;
131
+ }
132
+ const enrichments = projection.toEnrichments({ webhook: this.webhook, context, variant });
133
+ return projection.toExportPath({ webhook: this.webhook, enrichments, variant });
134
+ }
135
+ toNamedModels(reach) {
136
+ return reach.namedByWebhook(this.webhook);
137
+ }
138
+ toSource({ generatorId, variant }) {
139
+ return (0, exports.toWebhookSource)({ webhook: this.webhook, generatorId, variant });
140
+ }
141
+ }
142
+ exports.WebhookSubject = WebhookSubject;
143
+ /**
144
+ * A GraphQL operation as a subject. Its results and enrichments are at
145
+ * `[rootKind][fieldName]`. `settings.include` and `settings.skip` have no
146
+ * filter for a GraphQL operation, so no filter names it.
147
+ */
148
+ class GqlOperationSubject {
149
+ constructor(operation) {
150
+ Object.defineProperty(this, "type", {
151
+ enumerable: true,
152
+ configurable: true,
153
+ writable: true,
154
+ value: 'gqlOperation'
155
+ });
156
+ Object.defineProperty(this, "operation", {
157
+ enumerable: true,
158
+ configurable: true,
159
+ writable: true,
160
+ value: void 0
161
+ });
162
+ Object.defineProperty(this, "trail", {
163
+ enumerable: true,
164
+ configurable: true,
165
+ writable: true,
166
+ value: void 0
167
+ });
168
+ Object.defineProperty(this, "enrichmentPath", {
169
+ enumerable: true,
170
+ configurable: true,
171
+ writable: true,
172
+ value: void 0
173
+ });
174
+ Object.defineProperty(this, "label", {
175
+ enumerable: true,
176
+ configurable: true,
177
+ writable: true,
178
+ value: void 0
179
+ });
180
+ this.operation = operation;
181
+ this.trail = [operation.rootKind, operation.fieldName];
182
+ this.enrichmentPath = this.trail;
183
+ this.label = `${operation.rootKind} ${operation.fieldName}`;
184
+ }
185
+ isSupported({ entry, context, variant }) {
186
+ return (typeof entry.isSupported !== 'function' ||
187
+ entry.isSupported({ operation: this.operation, context, variant }));
188
+ }
189
+ matches() {
190
+ return false;
191
+ }
192
+ transform({ entry, context, variant }) {
193
+ entry.transform({ context, operation: this.operation, variant });
194
+ }
195
+ toPreviewModule({ entry, context, variant }) {
196
+ return entry.toPreviewModule?.({ context, operation: this.operation, variant });
197
+ }
198
+ // A GraphQL document has no `$ref`s to read a reach from, so its files are not planned.
199
+ toExportPath() {
200
+ return undefined;
201
+ }
202
+ toNamedModels() {
203
+ return [];
204
+ }
205
+ toSource({ generatorId, variant }) {
206
+ return (0, exports.toGqlOperationSource)({ operation: this.operation, generatorId, variant });
207
+ }
208
+ }
209
+ exports.GqlOperationSubject = GqlOperationSubject;
210
+ /**
211
+ * A model as a subject. Its results and enrichments are at its model key
212
+ * (`toModelKey`): the `refName` of a component, the whole pointer of any
213
+ * other model. The run makes one for each schema component of either
214
+ * protocol; the file plan also makes one for a model that is no component,
215
+ * which a `$ref` to a place inside a schema gives.
216
+ */
217
+ class ModelSubject {
218
+ constructor(ref) {
219
+ Object.defineProperty(this, "type", {
220
+ enumerable: true,
221
+ configurable: true,
222
+ writable: true,
223
+ value: 'model'
224
+ });
225
+ Object.defineProperty(this, "refName", {
226
+ enumerable: true,
227
+ configurable: true,
228
+ writable: true,
229
+ value: void 0
230
+ });
231
+ Object.defineProperty(this, "ref", {
232
+ enumerable: true,
233
+ configurable: true,
234
+ writable: true,
235
+ value: void 0
236
+ });
237
+ Object.defineProperty(this, "trail", {
238
+ enumerable: true,
239
+ configurable: true,
240
+ writable: true,
241
+ value: void 0
242
+ });
243
+ Object.defineProperty(this, "enrichmentPath", {
244
+ enumerable: true,
245
+ configurable: true,
246
+ writable: true,
247
+ value: void 0
248
+ });
249
+ Object.defineProperty(this, "label", {
250
+ enumerable: true,
251
+ configurable: true,
252
+ writable: true,
253
+ value: void 0
254
+ });
255
+ this.refName = ref.refName;
256
+ this.ref = ref;
257
+ const key = (0, refFns_js_1.toModelKey)(ref);
258
+ this.trail = key;
259
+ this.enrichmentPath = [key];
260
+ this.label = key;
261
+ }
262
+ isSupported({ entry, context, variant }) {
263
+ return (typeof entry.isSupported !== 'function' ||
264
+ entry.isSupported({ ref: this.ref, context, variant }));
265
+ }
266
+ matches(filter, variant) {
267
+ return matchesRefFilter({ refs: filter, refName: this.refName, variant });
268
+ }
269
+ transform({ entry, context, variant }) {
270
+ entry.transform({ context, ref: this.ref, variant });
271
+ }
272
+ toPreviewModule({ entry, context, variant }) {
273
+ return entry.toPreviewModule?.({ context, ref: this.ref, variant });
274
+ }
275
+ toExportPath({ projection, context, variant }) {
276
+ if (projection.type !== 'model') {
277
+ return undefined;
278
+ }
279
+ const enrichments = projection.toEnrichments({ ref: this.ref, context, variant });
280
+ return projection.toExportPath({ ref: this.ref, enrichments, variant });
281
+ }
282
+ toNamedModels() {
283
+ return [(0, refFns_js_1.toModelKey)(this.ref)];
284
+ }
285
+ toSource({ generatorId, variant }) {
286
+ return (0, exports.toModelSource)({ refName: this.refName, generatorId, variant });
287
+ }
288
+ }
289
+ exports.ModelSubject = ModelSubject;
290
+ /**
291
+ * Match a `(path, method, variant)` tuple against an operation-shaped
292
+ * skip or include entry. Shared by both arms because skip and include
293
+ * have the same matching rules; only the engine's interpretation of
294
+ * the result differs (skip = deny, include = allow).
295
+ *
296
+ * Returns `false` when:
297
+ * - `paths` is `undefined` (no filter applies)
298
+ * - the `path` isn't keyed in the entry
299
+ * - the `method` isn't present in the inner record
300
+ *
301
+ * Returns `true` when:
302
+ * - the method's variant array is empty (matches every variant)
303
+ * - the method's variant array contains `variant`
304
+ */
305
+ const matchesPathFilter = ({ paths, path, method, variant }) => {
306
+ if (!paths) {
307
+ return false;
308
+ }
309
+ const methodMap = paths[path];
310
+ if (!methodMap) {
311
+ return false;
312
+ }
313
+ const variants = methodMap[method];
314
+ if (variants === undefined) {
315
+ return false;
316
+ }
317
+ if (variants.length === 0) {
318
+ return true;
319
+ }
320
+ return variants.includes(variant);
321
+ };
322
+ /**
323
+ * Match a `(refName, variant)` tuple against a model-shaped skip or
324
+ * include entry. Sibling to {@link matchesPathFilter} — both arms
325
+ * share matching rules; only the engine's interpretation of the
326
+ * result differs (skip = deny, include = allow).
327
+ *
328
+ * Returns `false` when:
329
+ * - `refs` is `undefined` (no filter applies)
330
+ * - the `refName` isn't keyed in the entry
331
+ *
332
+ * Returns `true` when:
333
+ * - the refName's variant array is empty (matches every variant)
334
+ * - the refName's variant array contains `variant`
335
+ */
336
+ const matchesRefFilter = ({ refs, refName, variant }) => {
337
+ if (!refs) {
338
+ return false;
339
+ }
340
+ const variants = refs[refName];
341
+ if (variants === undefined) {
342
+ return false;
343
+ }
344
+ if (variants.length === 0) {
345
+ return true;
346
+ }
347
+ return variants.includes(variant);
348
+ };
349
+ /**
350
+ * Creates an OasOperationSource from an operation, generator ID, and variant.
351
+ *
352
+ * Transforms operation and generator information into a source descriptor
353
+ * that can be used for tracking operation origins in the generation pipeline.
354
+ *
355
+ * @param args - Arguments containing operation, generator ID, and variant
356
+ * @returns OasOperationSource descriptor for the operation
357
+ */
358
+ const toOasOperationSource = ({ operation, generatorId, variant }) => ({
359
+ type: 'oasOperation',
360
+ generatorId,
361
+ operationPath: operation.path,
362
+ operationMethod: operation.method,
363
+ variant
364
+ });
365
+ exports.toOasOperationSource = toOasOperationSource;
366
+ /**
367
+ * Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
368
+ * Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
369
+ */
370
+ const toWebhookSource = ({ webhook, generatorId, variant }) => ({
371
+ type: 'webhook',
372
+ generatorId,
373
+ webhookName: webhook.name,
374
+ webhookMethod: webhook.method,
375
+ variant
376
+ });
377
+ exports.toWebhookSource = toWebhookSource;
378
+ /**
379
+ * Creates a GraphQL operation source descriptor.
380
+ *
381
+ * Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
382
+ * `rootKind` and `fieldName` instead of `path` / `method`.
383
+ */
384
+ const toGqlOperationSource = ({ operation, generatorId, variant }) => ({
385
+ type: 'gqlOperation',
386
+ generatorId,
387
+ rootKind: operation.rootKind,
388
+ fieldName: operation.fieldName,
389
+ variant
390
+ });
391
+ exports.toGqlOperationSource = toGqlOperationSource;
392
+ /**
393
+ * Creates a ModelSource from a reference name, generator ID, and variant.
394
+ *
395
+ * Transforms model reference and generator information into a source descriptor
396
+ * that can be used for tracking model origins in the generation pipeline.
397
+ *
398
+ * @param args - Arguments containing reference name, generator ID, and variant
399
+ * @returns ModelSource descriptor for the model
400
+ */
401
+ const toModelSource = ({ refName, generatorId, variant }) => ({
402
+ type: 'model',
403
+ generatorId,
404
+ refName,
405
+ variant
406
+ });
407
+ exports.toModelSource = toModelSource;
@@ -50,6 +50,13 @@ type FinalizeArgs = {
50
50
  };
51
51
  export declare class EnrichmentAudit {
52
52
  #private;
53
+ /**
54
+ * Runs `fn` with nothing recorded: no lookup counts as a use, and no
55
+ * warning is kept. For a reader that is not the run, such as the file
56
+ * plan: it reads enrichments for projections the run may never insert,
57
+ * and those reads must not make configured paths look used.
58
+ */
59
+ withoutRecording<T>(fn: () => T): T;
53
60
  /**
54
61
  * Record one enrichment lookup. Every prefix of `segments` is marked
55
62
  * consumed, so block-level and leaf-level reads land in one namespace.