@skmtc/core 0.53.0 → 0.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,25 +45,12 @@ import { toSerializedError } from '../types/SerializedError.js';
45
45
  import { LogLineIssueArg } from '../types/LogLine.js';
46
46
  import { tryParseAt } from './tryParseAt.js';
47
47
  import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
48
- import { toRawRefTarget, toRefParts, toRefPathBucket, toRefPathSegments, toRefPointer } from '../helpers/refFns.js';
48
+ import { toRawRefTarget, toRefParts, toRefPathBucket, toRefPathSegments } from '../helpers/refFns.js';
49
+ import { Reach } from '../parse/Reach.js';
50
+ import { toRefKey } from '../parse/toRefKey.js';
49
51
  import { toRefTargetV3 } from '../parse/v3-0/ref/toRefTargetV3.js';
50
52
  import { toRefTargetV3 as toRefTargetV31 } from '../parse/v3-1/ref/toRefTargetV3.js';
51
53
  import { toRefTargetV3 as toRefTargetV32 } from '../parse/v3-2/ref/toRefTargetV3.js';
52
- /**
53
- * The key a `$ref`'s consumers and errors are kept under. A component ref
54
- * (`#/components/<bucket>/<name>`) is keyed by the name it resolves,
55
- * unescaped, which is the key `StackTrail.toStackRef()` gives that
56
- * component's own errors: `#/components/schemas/Foo%20Bar` is kept under
57
- * `#/components/schemas/Foo Bar`. Any other ref is keyed by its whole
58
- * pointer in one spelling (`toRefPointer`), which is also the key its
59
- * parsed target is kept under.
60
- */
61
- const toRefKey = ({ refName, refPath }) => {
62
- const bucket = toRefPathBucket(refPath);
63
- return bucket === undefined
64
- ? toRefPointer({ refName, refPath })
65
- : `#/components/${bucket}/${refName}`;
66
- };
67
54
  /** The issue logged when a ref target's parser throws. */
68
55
  const toInvalidType = (refType) => {
69
56
  switch (refType) {
@@ -432,6 +419,19 @@ export class ParseContext {
432
419
  this.currentStackTrail = prev;
433
420
  }
434
421
  }
422
+ /**
423
+ * @internal
424
+ * What each subject of the parsed document can reach through `$ref`s, read
425
+ * from the refs this parse read. Call it when the document is parsed.
426
+ */
427
+ toReach() {
428
+ const rootDepth = __classPrivateFieldGet(this, _ParseContext_rootFrames, "f").length;
429
+ return new Reach(__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").map(({ consumer, ref, refTarget }) => ({
430
+ ref,
431
+ place: consumer.stackTrail.slice(rootDepth),
432
+ refTarget
433
+ })));
434
+ }
435
435
  /**
436
436
  * Register a `$ref`-style consumer site. The key encoding is up to
437
437
  * the caller — OAS uses `#/components/schemas/User` strings, GQL
@@ -0,0 +1,165 @@
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 RefParts } from '../helpers/refFns.js';
10
+ import type { RefName } from '../types/RefName.js';
11
+ import type { IncludeModelRefs, IncludePaths, SkipModelRefs, SkipPaths } from '../types/Settings.js';
12
+ import type { GqlOperationSource, ModelSource, OasOperationSource, PreviewModule, WebhookSource } from '../types/Preview.js';
13
+ /** A generator entry, the run's context and one variant: what a subject is asked with. */
14
+ type AskArgs<Entry> = {
15
+ entry: Entry;
16
+ context: GenerateContextType;
17
+ variant: string;
18
+ };
19
+ type ToSourceArgs = {
20
+ generatorId: string;
21
+ variant: string;
22
+ };
23
+ /**
24
+ * One subject of a run: an OpenAPI operation, a webhook, a GraphQL operation
25
+ * or a model. For the run, it holds how its kind differs from the others:
26
+ * where its results and its enrichments are, what a message calls it, which
27
+ * filter names it, and how an entry of its kind is called with it. The run
28
+ * asks every kind the same questions, in the same order.
29
+ *
30
+ * @template Entry - The generator entry of the subject's kind
31
+ * @template Filter - One generator's `settings.include` or `settings.skip`
32
+ * filter for the kind; `never` for a kind that has none
33
+ */
34
+ export type Subject<Entry, Filter> = {
35
+ /** Its frame or frames below the generator's in a trail, and so its place in `manifest.results`. */
36
+ readonly trail: string | string[];
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
+ isSupported: (args: AskArgs<Entry>) => boolean;
42
+ /** Whether a filter of `settings.include` or `settings.skip` names this variant of it. */
43
+ matches(filter: Filter | undefined, variant: string): boolean;
44
+ transform: (args: AskArgs<Entry>) => void;
45
+ toPreviewModule: (args: AskArgs<Entry>) => PreviewModule | undefined;
46
+ toSource(args: ToSourceArgs): OasOperationSource | WebhookSource | GqlOperationSource | ModelSource;
47
+ };
48
+ /** An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`. */
49
+ export declare class OasOperationSubject implements Subject<OasOperationEntry, IncludePaths | SkipPaths> {
50
+ operation: OasOperation;
51
+ trail: string[];
52
+ enrichmentPath: string[];
53
+ label: string;
54
+ constructor(operation: OasOperation);
55
+ isSupported({ entry, context, variant }: AskArgs<OasOperationEntry>): boolean;
56
+ matches(filter: IncludePaths | SkipPaths | undefined, variant: string): boolean;
57
+ transform({ entry, context, variant }: AskArgs<OasOperationEntry>): void;
58
+ toPreviewModule({ entry, context, variant }: AskArgs<OasOperationEntry>): PreviewModule | undefined;
59
+ toSource({ generatorId, variant }: ToSourceArgs): OasOperationSource;
60
+ }
61
+ /**
62
+ * A 3.1 webhook as a subject. Its results are at `['webhook'][name][method]`
63
+ * and its enrichments at `[name][method]`. A filter has the shape of an
64
+ * operation's, with the webhook's name in the place of the path.
65
+ */
66
+ export declare class WebhookSubject implements Subject<WebhookEntry, IncludePaths | SkipPaths> {
67
+ webhook: OasWebhook;
68
+ trail: string[];
69
+ enrichmentPath: string[];
70
+ label: string;
71
+ constructor(webhook: OasWebhook);
72
+ isSupported({ entry, context, variant }: AskArgs<WebhookEntry>): boolean;
73
+ matches(filter: IncludePaths | SkipPaths | undefined, variant: string): boolean;
74
+ transform({ entry, context, variant }: AskArgs<WebhookEntry>): void;
75
+ toPreviewModule({ entry, context, variant }: AskArgs<WebhookEntry>): PreviewModule | undefined;
76
+ toSource({ generatorId, variant }: ToSourceArgs): WebhookSource;
77
+ }
78
+ /**
79
+ * A GraphQL operation as a subject. Its results and enrichments are at
80
+ * `[rootKind][fieldName]`. `settings.include` and `settings.skip` have no
81
+ * filter for a GraphQL operation, so no filter names it.
82
+ */
83
+ export declare class GqlOperationSubject implements Subject<GqlOperationEntry, never> {
84
+ operation: GqlOperation;
85
+ trail: string[];
86
+ enrichmentPath: string[];
87
+ label: string;
88
+ constructor(operation: GqlOperation);
89
+ isSupported({ entry, context, variant }: AskArgs<GqlOperationEntry>): boolean;
90
+ matches(): boolean;
91
+ transform({ entry, context, variant }: AskArgs<GqlOperationEntry>): void;
92
+ toPreviewModule({ entry, context, variant }: AskArgs<GqlOperationEntry>): PreviewModule | undefined;
93
+ toSource({ generatorId, variant }: ToSourceArgs): GqlOperationSource;
94
+ }
95
+ /** A model as a subject: a schema component of either protocol. Its results and enrichments are at `[refName]`. */
96
+ export declare class ModelSubject implements Subject<ModelEntry, IncludeModelRefs | SkipModelRefs> {
97
+ refName: RefName;
98
+ ref: RefParts;
99
+ trail: string;
100
+ enrichmentPath: string[];
101
+ label: string;
102
+ constructor(refName: RefName);
103
+ isSupported({ entry, context, variant }: AskArgs<ModelEntry>): boolean;
104
+ matches(filter: IncludeModelRefs | SkipModelRefs | undefined, variant: string): boolean;
105
+ transform({ entry, context, variant }: AskArgs<ModelEntry>): void;
106
+ toPreviewModule({ entry, context, variant }: AskArgs<ModelEntry>): PreviewModule | undefined;
107
+ toSource({ generatorId, variant }: ToSourceArgs): ModelSource;
108
+ }
109
+ type ToOasOperationSourceArgs = {
110
+ operation: OasOperation;
111
+ generatorId: string;
112
+ /** Operation variant the artifact was emitted for (see {@link Variant}) */
113
+ variant: string;
114
+ };
115
+ /**
116
+ * Creates an OasOperationSource from an operation, generator ID, and variant.
117
+ *
118
+ * Transforms operation and generator information into a source descriptor
119
+ * that can be used for tracking operation origins in the generation pipeline.
120
+ *
121
+ * @param args - Arguments containing operation, generator ID, and variant
122
+ * @returns OasOperationSource descriptor for the operation
123
+ */
124
+ export declare const toOasOperationSource: ({ operation, generatorId, variant }: ToOasOperationSourceArgs) => OasOperationSource;
125
+ type ToWebhookSourceArgs = {
126
+ webhook: OasWebhook;
127
+ generatorId: string;
128
+ /** Webhook variant the artifact was emitted for (see {@link Variant}) */
129
+ variant: string;
130
+ };
131
+ /**
132
+ * Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
133
+ * Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
134
+ */
135
+ export declare const toWebhookSource: ({ webhook, generatorId, variant }: ToWebhookSourceArgs) => WebhookSource;
136
+ type ToGqlOperationSourceArgs = {
137
+ operation: GqlOperation;
138
+ generatorId: string;
139
+ /** Operation variant the artifact was emitted for (see {@link Variant}) */
140
+ variant: string;
141
+ };
142
+ /**
143
+ * Creates a GraphQL operation source descriptor.
144
+ *
145
+ * Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
146
+ * `rootKind` and `fieldName` instead of `path` / `method`.
147
+ */
148
+ export declare const toGqlOperationSource: ({ operation, generatorId, variant }: ToGqlOperationSourceArgs) => GqlOperationSource;
149
+ type ToModelSourceArgs = {
150
+ refName: RefName;
151
+ generatorId: string;
152
+ /** Model variant the artifact was emitted for (see {@link Variant}) */
153
+ variant: string;
154
+ };
155
+ /**
156
+ * Creates a ModelSource from a reference name, generator ID, and variant.
157
+ *
158
+ * Transforms model reference and generator information into a source descriptor
159
+ * that can be used for tracking model origins in the generation pipeline.
160
+ *
161
+ * @param args - Arguments containing reference name, generator ID, and variant
162
+ * @returns ModelSource descriptor for the model
163
+ */
164
+ export declare const toModelSource: ({ refName, generatorId, variant }: ToModelSourceArgs) => ModelSource;
165
+ export {};
@@ -0,0 +1,328 @@
1
+ import { toSchemaComponentRef } from '../helpers/refFns.js';
2
+ /** An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`. */
3
+ export class OasOperationSubject {
4
+ constructor(operation) {
5
+ Object.defineProperty(this, "operation", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: void 0
10
+ });
11
+ Object.defineProperty(this, "trail", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "enrichmentPath", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "label", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ this.operation = operation;
30
+ this.trail = [operation.path, operation.method];
31
+ this.enrichmentPath = this.trail;
32
+ this.label = `${operation.method.toUpperCase()} ${operation.path}`;
33
+ }
34
+ isSupported({ entry, context, variant }) {
35
+ return (typeof entry.isSupported !== 'function' ||
36
+ entry.isSupported({ operation: this.operation, context, variant }));
37
+ }
38
+ matches(filter, variant) {
39
+ const { path, method } = this.operation;
40
+ return matchesPathFilter({ paths: filter, path, method, variant });
41
+ }
42
+ transform({ entry, context, variant }) {
43
+ entry.transform({ context, operation: this.operation, variant });
44
+ }
45
+ toPreviewModule({ entry, context, variant }) {
46
+ return entry.toPreviewModule?.({ context, operation: this.operation, variant });
47
+ }
48
+ toSource({ generatorId, variant }) {
49
+ return toOasOperationSource({ operation: this.operation, generatorId, variant });
50
+ }
51
+ }
52
+ /**
53
+ * A 3.1 webhook as a subject. Its results are at `['webhook'][name][method]`
54
+ * and its enrichments at `[name][method]`. A filter has the shape of an
55
+ * operation's, with the webhook's name in the place of the path.
56
+ */
57
+ export class WebhookSubject {
58
+ constructor(webhook) {
59
+ Object.defineProperty(this, "webhook", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
65
+ Object.defineProperty(this, "trail", {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: void 0
70
+ });
71
+ Object.defineProperty(this, "enrichmentPath", {
72
+ enumerable: true,
73
+ configurable: true,
74
+ writable: true,
75
+ value: void 0
76
+ });
77
+ Object.defineProperty(this, "label", {
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true,
81
+ value: void 0
82
+ });
83
+ this.webhook = webhook;
84
+ this.trail = ['webhook', webhook.name, webhook.method];
85
+ this.enrichmentPath = [webhook.name, webhook.method];
86
+ this.label = `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`;
87
+ }
88
+ isSupported({ entry, context, variant }) {
89
+ return (typeof entry.isSupported !== 'function' ||
90
+ entry.isSupported({ webhook: this.webhook, context, variant }));
91
+ }
92
+ matches(filter, variant) {
93
+ const { name, method } = this.webhook;
94
+ return matchesPathFilter({ paths: filter, path: name, method, variant });
95
+ }
96
+ transform({ entry, context, variant }) {
97
+ entry.transform({ context, webhook: this.webhook, variant });
98
+ }
99
+ toPreviewModule({ entry, context, variant }) {
100
+ return entry.toPreviewModule?.({ context, webhook: this.webhook, variant });
101
+ }
102
+ toSource({ generatorId, variant }) {
103
+ return toWebhookSource({ webhook: this.webhook, generatorId, variant });
104
+ }
105
+ }
106
+ /**
107
+ * A GraphQL operation as a subject. Its results and enrichments are at
108
+ * `[rootKind][fieldName]`. `settings.include` and `settings.skip` have no
109
+ * filter for a GraphQL operation, so no filter names it.
110
+ */
111
+ export class GqlOperationSubject {
112
+ constructor(operation) {
113
+ Object.defineProperty(this, "operation", {
114
+ enumerable: true,
115
+ configurable: true,
116
+ writable: true,
117
+ value: void 0
118
+ });
119
+ Object.defineProperty(this, "trail", {
120
+ enumerable: true,
121
+ configurable: true,
122
+ writable: true,
123
+ value: void 0
124
+ });
125
+ Object.defineProperty(this, "enrichmentPath", {
126
+ enumerable: true,
127
+ configurable: true,
128
+ writable: true,
129
+ value: void 0
130
+ });
131
+ Object.defineProperty(this, "label", {
132
+ enumerable: true,
133
+ configurable: true,
134
+ writable: true,
135
+ value: void 0
136
+ });
137
+ this.operation = operation;
138
+ this.trail = [operation.rootKind, operation.fieldName];
139
+ this.enrichmentPath = this.trail;
140
+ this.label = `${operation.rootKind} ${operation.fieldName}`;
141
+ }
142
+ isSupported({ entry, context, variant }) {
143
+ return (typeof entry.isSupported !== 'function' ||
144
+ entry.isSupported({ operation: this.operation, context, variant }));
145
+ }
146
+ matches() {
147
+ return false;
148
+ }
149
+ transform({ entry, context, variant }) {
150
+ entry.transform({ context, operation: this.operation, variant });
151
+ }
152
+ toPreviewModule({ entry, context, variant }) {
153
+ return entry.toPreviewModule?.({ context, operation: this.operation, variant });
154
+ }
155
+ toSource({ generatorId, variant }) {
156
+ return toGqlOperationSource({ operation: this.operation, generatorId, variant });
157
+ }
158
+ }
159
+ /** A model as a subject: a schema component of either protocol. Its results and enrichments are at `[refName]`. */
160
+ export class ModelSubject {
161
+ constructor(refName) {
162
+ Object.defineProperty(this, "refName", {
163
+ enumerable: true,
164
+ configurable: true,
165
+ writable: true,
166
+ value: void 0
167
+ });
168
+ Object.defineProperty(this, "ref", {
169
+ enumerable: true,
170
+ configurable: true,
171
+ writable: true,
172
+ value: void 0
173
+ });
174
+ Object.defineProperty(this, "trail", {
175
+ enumerable: true,
176
+ configurable: true,
177
+ writable: true,
178
+ value: void 0
179
+ });
180
+ Object.defineProperty(this, "enrichmentPath", {
181
+ enumerable: true,
182
+ configurable: true,
183
+ writable: true,
184
+ value: void 0
185
+ });
186
+ Object.defineProperty(this, "label", {
187
+ enumerable: true,
188
+ configurable: true,
189
+ writable: true,
190
+ value: void 0
191
+ });
192
+ this.refName = refName;
193
+ this.ref = toSchemaComponentRef(refName);
194
+ this.trail = refName;
195
+ this.enrichmentPath = [refName];
196
+ this.label = refName;
197
+ }
198
+ isSupported({ entry, context, variant }) {
199
+ return (typeof entry.isSupported !== 'function' ||
200
+ entry.isSupported({ ref: this.ref, context, variant }));
201
+ }
202
+ matches(filter, variant) {
203
+ return matchesRefFilter({ refs: filter, refName: this.refName, variant });
204
+ }
205
+ transform({ entry, context, variant }) {
206
+ entry.transform({ context, ref: this.ref, variant });
207
+ }
208
+ toPreviewModule({ entry, context, variant }) {
209
+ return entry.toPreviewModule?.({ context, ref: this.ref, variant });
210
+ }
211
+ toSource({ generatorId, variant }) {
212
+ return toModelSource({ refName: this.refName, generatorId, variant });
213
+ }
214
+ }
215
+ /**
216
+ * Match a `(path, method, variant)` tuple against an operation-shaped
217
+ * skip or include entry. Shared by both arms because skip and include
218
+ * have the same matching rules; only the engine's interpretation of
219
+ * the result differs (skip = deny, include = allow).
220
+ *
221
+ * Returns `false` when:
222
+ * - `paths` is `undefined` (no filter applies)
223
+ * - the `path` isn't keyed in the entry
224
+ * - the `method` isn't present in the inner record
225
+ *
226
+ * Returns `true` when:
227
+ * - the method's variant array is empty (matches every variant)
228
+ * - the method's variant array contains `variant`
229
+ */
230
+ const matchesPathFilter = ({ paths, path, method, variant }) => {
231
+ if (!paths) {
232
+ return false;
233
+ }
234
+ const methodMap = paths[path];
235
+ if (!methodMap) {
236
+ return false;
237
+ }
238
+ const variants = methodMap[method];
239
+ if (variants === undefined) {
240
+ return false;
241
+ }
242
+ if (variants.length === 0) {
243
+ return true;
244
+ }
245
+ return variants.includes(variant);
246
+ };
247
+ /**
248
+ * Match a `(refName, variant)` tuple against a model-shaped skip or
249
+ * include entry. Sibling to {@link matchesPathFilter} — both arms
250
+ * share matching rules; only the engine's interpretation of the
251
+ * result differs (skip = deny, include = allow).
252
+ *
253
+ * Returns `false` when:
254
+ * - `refs` is `undefined` (no filter applies)
255
+ * - the `refName` isn't keyed in the entry
256
+ *
257
+ * Returns `true` when:
258
+ * - the refName's variant array is empty (matches every variant)
259
+ * - the refName's variant array contains `variant`
260
+ */
261
+ const matchesRefFilter = ({ refs, refName, variant }) => {
262
+ if (!refs) {
263
+ return false;
264
+ }
265
+ const variants = refs[refName];
266
+ if (variants === undefined) {
267
+ return false;
268
+ }
269
+ if (variants.length === 0) {
270
+ return true;
271
+ }
272
+ return variants.includes(variant);
273
+ };
274
+ /**
275
+ * Creates an OasOperationSource from an operation, generator ID, and variant.
276
+ *
277
+ * Transforms operation and generator information into a source descriptor
278
+ * that can be used for tracking operation origins in the generation pipeline.
279
+ *
280
+ * @param args - Arguments containing operation, generator ID, and variant
281
+ * @returns OasOperationSource descriptor for the operation
282
+ */
283
+ export const toOasOperationSource = ({ operation, generatorId, variant }) => ({
284
+ type: 'oasOperation',
285
+ generatorId,
286
+ operationPath: operation.path,
287
+ operationMethod: operation.method,
288
+ variant
289
+ });
290
+ /**
291
+ * Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
292
+ * Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
293
+ */
294
+ export const toWebhookSource = ({ webhook, generatorId, variant }) => ({
295
+ type: 'webhook',
296
+ generatorId,
297
+ webhookName: webhook.name,
298
+ webhookMethod: webhook.method,
299
+ variant
300
+ });
301
+ /**
302
+ * Creates a GraphQL operation source descriptor.
303
+ *
304
+ * Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
305
+ * `rootKind` and `fieldName` instead of `path` / `method`.
306
+ */
307
+ export const toGqlOperationSource = ({ operation, generatorId, variant }) => ({
308
+ type: 'gqlOperation',
309
+ generatorId,
310
+ rootKind: operation.rootKind,
311
+ fieldName: operation.fieldName,
312
+ variant
313
+ });
314
+ /**
315
+ * Creates a ModelSource from a reference name, generator ID, and variant.
316
+ *
317
+ * Transforms model reference and generator information into a source descriptor
318
+ * that can be used for tracking model origins in the generation pipeline.
319
+ *
320
+ * @param args - Arguments containing reference name, generator ID, and variant
321
+ * @returns ModelSource descriptor for the model
322
+ */
323
+ export const toModelSource = ({ refName, generatorId, variant }) => ({
324
+ type: 'model',
325
+ generatorId,
326
+ refName,
327
+ variant
328
+ });
@@ -0,0 +1,56 @@
1
+ import { type RefParts } from '../helpers/refFns.js';
2
+ import type { OasRefData } from '../oas/ref/ref-types.js';
3
+ /** A ref the parser read, and where it is. */
4
+ export type ReadRef = {
5
+ /** The ref, with the kind of object the parser read it as: only a `schema` ref can name a model. */
6
+ ref: RefParts & {
7
+ refType: OasRefData['refType'];
8
+ };
9
+ /** The frames of the ref's place in the document: `['paths', '/pets', 'get', …]`. */
10
+ place: readonly string[];
11
+ /** The key of the ref target the parser read it for; `undefined` in the document's own walk. */
12
+ refTarget: string | undefined;
13
+ };
14
+ /** Where an operation is in a document. An `OasOperation` fits it. */
15
+ type OperationPlace = {
16
+ path: string;
17
+ method: string;
18
+ };
19
+ /** Where a webhook is in a document. An `OasWebhook` fits it. */
20
+ type WebhookPlace = {
21
+ name: string;
22
+ method: string;
23
+ };
24
+ /**
25
+ * What a subject of a document can reach through `$ref`s: the models a
26
+ * generator can get to from it, each by its model key (`toModelKey`).
27
+ *
28
+ * It is read from the refs the parser itself read, each with its place
29
+ * (`ParseContext.toReach`). So it has what a generator can follow in the
30
+ * parsed document, and no more: a `$ref` the parser took for data is not in
31
+ * it, and neither is the parent of an `allOf` that the parser merged into
32
+ * its child. It needs no walk of the document of its own.
33
+ *
34
+ * A place is a model, an operation, the parameters of a path item, or a
35
+ * component that is no schema. The models a place names are those its own
36
+ * refs give, and those behind each such component it refers to. A model
37
+ * reaches the models it names, and the models those name.
38
+ */
39
+ export declare class Reach {
40
+ #private;
41
+ constructor(refs: Iterable<ReadRef>);
42
+ /** The keys of the models a model reaches, its own included. */
43
+ ofModel(ref: RefParts): readonly string[];
44
+ /**
45
+ * The keys of the models an operation names: `paths[path][method]`, with
46
+ * what every operation of the path has, which is the path item's
47
+ * `parameters`, and any ref kept at the path item itself. The parser does
48
+ * not read a path item's own `$ref` yet, so that last place is empty. A
49
+ * path item parameter the operation overrides is still named: one model too
50
+ * many is safe for a plan, one too few is not.
51
+ */
52
+ namedByOperation({ path, method }: OperationPlace): readonly string[];
53
+ /** The keys of the models a webhook names: `webhooks[name][method]`, as {@link namedByOperation}. */
54
+ namedByWebhook({ name, method }: WebhookPlace): readonly string[];
55
+ }
56
+ export {};