@kubb/adapter-oas 5.18.5 → 5.18.7

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
@@ -1318,5 +1318,4 @@ type Operation = {
1318
1318
  schema: OperationObject$1;
1319
1319
  pathItem: PathItemObject$1;
1320
1320
  };
1321
- export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1322
- //# sourceMappingURL=index.d.cts.map
1321
+ export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
package/dist/index.d.ts CHANGED
@@ -1318,5 +1318,4 @@ type Operation = {
1318
1318
  schema: OperationObject$1;
1319
1319
  pathItem: PathItemObject$1;
1320
1320
  };
1321
- export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1322
- //# sourceMappingURL=index.d.ts.map
1321
+ export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineExtension } from "@kubb/core";
2
- import { Diagnostics, ast, childName, enumPrimitive, enumPropName, extractRefName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
2
+ import { Diagnostics, ast, childName, enumPrimitive, enumPropName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { access, readFile } from "node:fs/promises";
@@ -7,20 +7,14 @@ import { upgrade } from "@scalar/openapi-upgrader";
7
7
  import { bundle } from "api-ref-bundler";
8
8
  import { CORE_SCHEMA, load } from "js-yaml";
9
9
  import * as yaml from "yaml";
10
- import { parse } from "yaml";
11
- // \0rolldown/runtime.js
12
- var __defProp = Object.defineProperty;
13
- var __name = (target, value) => __defProp(target, "name", {
14
- value,
15
- configurable: true
16
- });
10
+ import { parse as parse$1 } from "yaml";
17
11
  // kubb-extension.json
18
12
  var compatibility = {
19
13
  "kubb": ">=5.8.3",
20
14
  "node": ">=22.22"
21
15
  };
22
16
  // package.json
23
- var version = "5.18.5";
17
+ var version = "5.18.7";
24
18
  // src/constants.ts
25
19
  /**
26
20
  * Default parser options applied when no explicit options are provided.
@@ -60,17 +54,6 @@ const SUPPORTED_METHODS = /* @__PURE__ */ new Set([
60
54
  "query"
61
55
  ]);
62
56
  /**
63
- * Media types OpenAPI 3.2 reads as a stream of items (its "sequential media types"), each described by `itemSchema`.
64
- */
65
- const STREAM_MEDIA_TYPES = /* @__PURE__ */ new Set([
66
- "application/jsonl",
67
- "application/x-ndjson",
68
- "application/json-seq",
69
- "application/geo+json-seq",
70
- "text/event-stream",
71
- "multipart/mixed"
72
- ]);
73
- /**
74
57
  * Set of JSON Schema keywords that prevent a schema fragment from being inlined during `allOf` flattening.
75
58
  *
76
59
  * A fragment that contains any of these keys carries structural meaning of its own and must stay as a separate
@@ -167,21 +150,21 @@ const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
167
150
  function buildDiscriminatorChildMap(schemas) {
168
151
  const childMap = /* @__PURE__ */ new Map();
169
152
  for (const schema of schemas) {
170
- const unionNode = ast.narrowSchema(schema, "union") ?? ast.narrowSchema(schema, "intersection")?.members?.map((member) => ast.narrowSchema(member, "union")).find((union) => union);
153
+ const unionNode = ast.schema.narrow(schema, "union") ?? ast.schema.narrow(schema, "intersection")?.members?.map((member) => ast.schema.narrow(member, "union")).find((union) => union);
171
154
  if (!unionNode?.discriminatorPropertyName || !unionNode.members) continue;
172
155
  const { discriminatorPropertyName, members } = unionNode;
173
156
  for (const member of members) {
174
- const intersectionNode = ast.narrowSchema(member, "intersection");
157
+ const intersectionNode = ast.schema.narrow(member, "intersection");
175
158
  if (!intersectionNode?.members) continue;
176
159
  let refNode = null;
177
160
  let objNode = null;
178
161
  for (const m of intersectionNode.members) {
179
- refNode ??= ast.narrowSchema(m, "ref");
180
- objNode ??= ast.narrowSchema(m, "object");
162
+ refNode ??= ast.schema.narrow(m, "ref");
163
+ objNode ??= ast.schema.narrow(m, "object");
181
164
  }
182
165
  if (!refNode?.name || !objNode) continue;
183
166
  const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName);
184
- const enumNode = prop ? ast.narrowSchema(prop.schema, "enum") : null;
167
+ const enumNode = prop ? ast.schema.narrow(prop.schema, "enum") : null;
185
168
  if (!enumNode?.enumValues?.length) continue;
186
169
  const enumValues = enumNode.enumValues.filter((v) => v !== null);
187
170
  if (!enumValues.length) continue;
@@ -216,7 +199,7 @@ function patchDiscriminatorNode(node, entry) {
216
199
  required: true,
217
200
  schema: enumSchema
218
201
  });
219
- const objectNode = ast.narrowSchema(node, "object");
202
+ const objectNode = ast.schema.narrow(node, "object");
220
203
  if (objectNode) {
221
204
  const existingIdx = objectNode.properties.findIndex((p) => p.name === propertyName);
222
205
  const newProperties = existingIdx >= 0 ? objectNode.properties.map((p, i) => i === existingIdx ? newProp : p) : [...objectNode.properties, newProp];
@@ -225,14 +208,14 @@ function patchDiscriminatorNode(node, entry) {
225
208
  properties: newProperties
226
209
  };
227
210
  }
228
- const intersectionNode = ast.narrowSchema(node, "intersection");
211
+ const intersectionNode = ast.schema.narrow(node, "intersection");
229
212
  if (!intersectionNode?.members) return node;
230
213
  const discriminantNode = ast.factory.createSchema({
231
214
  type: "object",
232
215
  primitive: "object",
233
216
  properties: [newProp]
234
217
  });
235
- const patchedIdx = intersectionNode.members.findIndex((member) => ast.narrowSchema(member, "object")?.properties.some((p) => p.name === propertyName));
218
+ const patchedIdx = intersectionNode.members.findIndex((member) => ast.schema.narrow(member, "object")?.properties.some((p) => p.name === propertyName));
236
219
  const newMembers = patchedIdx >= 0 ? intersectionNode.members.map((member, i) => i === patchedIdx ? patchDiscriminatorNode(member, entry) : member) : [...intersectionNode.members, discriminantNode];
237
220
  return {
238
221
  ...intersectionNode,
@@ -754,7 +737,7 @@ function parseYaml(data, { origin, help, json = true }) {
754
737
  if (document !== void 0) return document;
755
738
  } catch {}
756
739
  try {
757
- return parse(data);
740
+ return parse$1(data);
758
741
  } catch (error) {
759
742
  throw new Diagnostics.Error({
760
743
  code: Diagnostics.code.invalidDocument,
@@ -1455,22 +1438,16 @@ function toInputTags(tags) {
1455
1438
  }
1456
1439
  // src/model/mediaType.ts
1457
1440
  /**
1458
- * The media type without its parameters, so `text/event-stream; charset=utf-8` matches the bare name.
1459
- */
1460
- function baseMediaType(contentType) {
1461
- return contentType.split(";")[0].trim().toLowerCase();
1462
- }
1463
- /**
1464
- * Returns `true` for a media type read as a stream of items: one that OpenAPI 3.2 lists, or any that declares `itemSchema`.
1441
+ * Returns `true` for a media type read as a stream of items: one `ast.mediaType.isStream` accepts, or any that declares `itemSchema`.
1465
1442
  */
1466
1443
  function isStream(contentType, mediaType) {
1467
- return STREAM_MEDIA_TYPES.has(baseMediaType(contentType)) || mediaType?.itemSchema !== void 0;
1444
+ return ast.mediaType.isStream(contentType) || mediaType?.itemSchema !== void 0;
1468
1445
  }
1469
1446
  /**
1470
1447
  * Whether the media type is `text/event-stream`, with or without parameters.
1471
1448
  */
1472
1449
  function isEventStream(contentType) {
1473
- return baseMediaType(contentType) === "text/event-stream";
1450
+ return ast.mediaType.getBase(contentType) === "text/event-stream";
1474
1451
  }
1475
1452
  /**
1476
1453
  * Replaces a `data` string that holds JSON with its `contentSchema`, so the event reads as parsed.
@@ -1760,10 +1737,10 @@ function memberValues(node, propertyName, seen = /* @__PURE__ */ new Set()) {
1760
1737
  seen.add(node);
1761
1738
  const target = node.type === "ref" && node.schema ? node.schema : node;
1762
1739
  if (target.type === "union") return [...new Set(target.members?.flatMap((member) => memberValues(member, propertyName, seen)))];
1763
- return intersect(ast.resolveSchemaProperties({
1740
+ return intersect(ast.schema.findProperties({
1764
1741
  node,
1765
1742
  propertyName
1766
- }).map((property) => [...ast.getSchemaLiteralValues(property.schema)]));
1743
+ }).map((property) => [...ast.schema.getLiterals(property.schema)]));
1767
1744
  }
1768
1745
  function intersect(slices) {
1769
1746
  const pinned = slices.filter((values) => values.length > 0);
@@ -2031,6 +2008,25 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
2031
2008
  ...param.allowEmptyValue && { allowEmptyValue: true }
2032
2009
  });
2033
2010
  }
2011
+ function spreadQuerystring(param) {
2012
+ if (param.in !== "querystring") return [param];
2013
+ const schema = ast.ref.getSchema(param.schema);
2014
+ const formEncoded = !param.contentType || ast.mediaType.getBase(param.contentType) === "application/x-www-form-urlencoded";
2015
+ if (schema.type !== "object" || !formEncoded) return [param];
2016
+ return schema.properties.map((property) => {
2017
+ const { style, explode, allowReserved } = param.encoding?.[property.name] ?? {};
2018
+ return ast.factory.createParameter({
2019
+ ...param.pointer ? { pointer: param.pointer } : {},
2020
+ name: property.name,
2021
+ in: "query",
2022
+ schema: property.schema,
2023
+ required: param.required && property.required,
2024
+ ...style !== void 0 && { style },
2025
+ ...explode !== void 0 && { explode },
2026
+ ...allowReserved !== void 0 && { allowReserved }
2027
+ });
2028
+ });
2029
+ }
2034
2030
  /**
2035
2031
  * Converts an OAS `Operation` into an `OperationNode`.
2036
2032
  */
@@ -2048,7 +2044,7 @@ function parseOperation({ operation, ...ctx }) {
2048
2044
  refs,
2049
2045
  ...entry,
2050
2046
  parentName: operationName
2051
- }));
2047
+ })).flatMap(spreadQuerystring);
2052
2048
  const body = getRequestBody({
2053
2049
  operation,
2054
2050
  refs
@@ -2068,7 +2064,7 @@ function parseOperation({ operation, ...ctx }) {
2068
2064
  contentType: ct,
2069
2065
  refs
2070
2066
  });
2071
- const node = ast.optionality(parseSchema({
2067
+ const node = ast.schema.applyOptionality(parseSchema({
2072
2068
  schema,
2073
2069
  name: requestBodyName
2074
2070
  }), bodyRequired);
@@ -2361,7 +2357,7 @@ function isObjectLike(member, refs) {
2361
2357
  */
2362
2358
  function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode, parentType, parse, name, refs }) {
2363
2359
  function pickDiscriminatorPropertyNode(node, propertyName) {
2364
- const discriminatorProperty = ast.narrowSchema(node, "object")?.properties?.find((property) => property.name === propertyName);
2360
+ const discriminatorProperty = ast.schema.narrow(node, "object")?.properties?.find((property) => property.name === propertyName);
2365
2361
  if (!discriminatorProperty) return null;
2366
2362
  return ast.factory.createSchema({
2367
2363
  type: "object",
@@ -2371,7 +2367,7 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
2371
2367
  }
2372
2368
  function implicitDiscriminantValue(member) {
2373
2369
  if (!discriminator || discriminator.mapping || !isReference(member)) return null;
2374
- const value = extractRefName(member.$ref);
2370
+ const value = ast.ref.getName(member.$ref);
2375
2371
  if (!value) return null;
2376
2372
  const variant = refs.resolve(member.$ref, { report: false });
2377
2373
  if (!variant) return null;
@@ -2419,7 +2415,7 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
2419
2415
  name
2420
2416
  });
2421
2417
  if (!discriminatorValues.length || !discriminator || !isObjectLike(s, refs)) return memberNode;
2422
- const narrowedDiscriminatorNode = sharedPropertiesNode ? pickDiscriminatorPropertyNode(ast.applyMacros(sharedPropertiesNode, [macroDiscriminatorEnum({
2418
+ const narrowedDiscriminatorNode = sharedPropertiesNode ? pickDiscriminatorPropertyNode(ast.macro.apply(sharedPropertiesNode, [macroDiscriminatorEnum({
2423
2419
  propertyName: discriminator.propertyName,
2424
2420
  values: discriminatorValues
2425
2421
  })], { depth: "shallow" }), discriminator.propertyName) : void 0;
@@ -2611,7 +2607,7 @@ function resolveUnionSchema(schema, siblingProperties) {
2611
2607
  *
2612
2608
  * The resolved schema is stored in `node.schema`. Usage-site sibling fields
2613
2609
  * (description, readOnly, nullable, etc.) are stored directly on the ref node.
2614
- * Use `syncSchemaRef(node)` in printers to get a merged view of both.
2610
+ * Use `ast.ref.mergeSchema(node)` in printers to get a merged view of both.
2615
2611
  * Circular refs are detected in `refs.resolveNode` and leave `schema` as `null`.
2616
2612
  */
2617
2613
  function convertRef({ schema, name, nullable, defaultValue, document, parse, refs, renames }) {
@@ -2623,7 +2619,7 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
2623
2619
  nullable,
2624
2620
  defaultValue
2625
2621
  };
2626
- if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: ast.schemaTypes.unknown });
2622
+ if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: ast.schema.types.unknown });
2627
2623
  if (refPath && !refPath.startsWith("#/components/schemas/") && resolvedSchema) return ast.factory.createSchema({
2628
2624
  ...resolvedSchema,
2629
2625
  title: schema.title ?? resolvedSchema.title,
@@ -2637,8 +2633,8 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
2637
2633
  });
2638
2634
  const targetName = renames?.get(schema.$ref);
2639
2635
  return createNode(ctx, {
2640
- type: ast.schemaTypes.ref,
2641
- name: extractRefName(schema.$ref),
2636
+ type: ast.schema.types.ref,
2637
+ name: ast.ref.getName(schema.$ref),
2642
2638
  ref: schema.$ref,
2643
2639
  ...targetName ? { targetName } : {},
2644
2640
  schema: resolvedSchema
@@ -2649,7 +2645,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
2649
2645
  const { not, ...rest } = schema;
2650
2646
  const [subschema] = resolveUnionMembers([not], rest.properties ?? {});
2651
2647
  const notNode = ast.factory.createSchema({
2652
- type: ast.schemaTypes.not,
2648
+ type: ast.schema.types.not,
2653
2649
  members: [parse({ schema: subschema })]
2654
2650
  });
2655
2651
  return createNode({
@@ -2658,7 +2654,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
2658
2654
  nullable,
2659
2655
  defaultValue
2660
2656
  }, {
2661
- type: ast.schemaTypes.intersection,
2657
+ type: ast.schema.types.intersection,
2662
2658
  members: [parse({
2663
2659
  schema: rest,
2664
2660
  name
@@ -2786,7 +2782,7 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
2786
2782
  nullable,
2787
2783
  defaultValue
2788
2784
  }, {
2789
- type: ast.schemaTypes.intersection,
2785
+ type: ast.schema.types.intersection,
2790
2786
  members: [...mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ...mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))]
2791
2787
  });
2792
2788
  }
@@ -2830,24 +2826,24 @@ function convertUnion(context) {
2830
2826
  refs
2831
2827
  });
2832
2828
  const unionNode = createNode(ctx, {
2833
- type: ast.schemaTypes.union,
2829
+ type: ast.schema.types.union,
2834
2830
  strategy,
2835
2831
  members,
2836
- discriminatorPropertyName: explicitDiscriminatorPropertyName ?? ast.inferDiscriminatorPropertyName(members)
2832
+ discriminatorPropertyName: explicitDiscriminatorPropertyName ?? ast.schema.inferDiscriminator(members)
2837
2833
  });
2838
2834
  const requiredProperties = missingRequired.map((name) => ast.factory.createProperty({
2839
2835
  name,
2840
2836
  required: true,
2841
- schema: ast.factory.createSchema({ type: ast.schemaTypes.unknown })
2837
+ schema: ast.factory.createSchema({ type: ast.schema.types.unknown })
2842
2838
  }));
2843
2839
  const siblings = sharedPropertiesNode ? [sharedPropertiesNode] : [];
2844
2840
  if (requiredProperties.length) siblings.push(ast.factory.createSchema({
2845
- type: ast.schemaTypes.object,
2841
+ type: ast.schema.types.object,
2846
2842
  properties: requiredProperties
2847
2843
  }));
2848
2844
  if (!siblings.length) return unionNode;
2849
2845
  return createNode(ctx, {
2850
- type: ast.schemaTypes.intersection,
2846
+ type: ast.schema.types.intersection,
2851
2847
  members: [unionNode, ...siblings]
2852
2848
  });
2853
2849
  }
@@ -2856,12 +2852,12 @@ function convertUnion(context) {
2856
2852
  name
2857
2853
  }));
2858
2854
  const unionNode = createNode(ctx, {
2859
- type: ast.schemaTypes.union,
2855
+ type: ast.schema.types.union,
2860
2856
  strategy,
2861
2857
  members,
2862
- discriminatorPropertyName: explicitDiscriminatorPropertyName ?? ast.inferDiscriminatorPropertyName(members)
2858
+ discriminatorPropertyName: explicitDiscriminatorPropertyName ?? ast.schema.inferDiscriminator(members)
2863
2859
  });
2864
- return ast.applyMacros(unionNode, [macroDedupeUnion], { depth: "shallow" });
2860
+ return ast.macro.apply(unionNode, [macroDedupeUnion], { depth: "shallow" });
2865
2861
  }
2866
2862
  /**
2867
2863
  * Converts an OAS 3.1 multi-type array (e.g. `type: ['string', 'number']`) into a `UnionSchemaNode`.
@@ -2878,7 +2874,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
2878
2874
  nullable: types.includes("null") || nullable || void 0,
2879
2875
  defaultValue
2880
2876
  }, {
2881
- type: ast.schemaTypes.union,
2877
+ type: ast.schema.types.union,
2882
2878
  members: nonNullTypes.map((t) => {
2883
2879
  return parse({
2884
2880
  schema: {
@@ -3157,10 +3153,10 @@ function resolveMapSchema(mapSchema, { options, parse }) {
3157
3153
  */
3158
3154
  function nameEnums(node, options) {
3159
3155
  const macro = macroEnumName(options);
3160
- const named = ast.applyMacros(node, [macro], { depth: "shallow" });
3161
- const tupleNode = ast.narrowSchema(named, "tuple");
3156
+ const named = ast.macro.apply(node, [macro], { depth: "shallow" });
3157
+ const tupleNode = ast.schema.narrow(named, "tuple");
3162
3158
  if (tupleNode?.items) {
3163
- const namedItems = tupleNode.items.map((item) => ast.applyMacros(item, [macro], { depth: "shallow" }));
3159
+ const namedItems = tupleNode.items.map((item) => ast.macro.apply(item, [macro], { depth: "shallow" }));
3164
3160
  if (namedItems.some((item, i) => item !== tupleNode.items[i])) return {
3165
3161
  ...tupleNode,
3166
3162
  items: namedItems
@@ -3243,7 +3239,7 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
3243
3239
  })
3244
3240
  });
3245
3241
  const enumName = name ? enumPropName(name, discPropName, options.enumSuffix) : void 0;
3246
- return ast.applyMacros(objectNode, [macroDiscriminatorEnum({
3242
+ return ast.macro.apply(objectNode, [macroDiscriminatorEnum({
3247
3243
  propertyName: discPropName,
3248
3244
  values,
3249
3245
  enumName
@@ -3487,9 +3483,9 @@ function createSchemaParser(ctx) {
3487
3483
  }
3488
3484
  const presenceKeys = /* @__PURE__ */ new WeakMap();
3489
3485
  function requireKeys(keys) {
3490
- const unknown = ast.factory.createSchema({ type: ast.schemaTypes.unknown });
3486
+ const unknown = ast.factory.createSchema({ type: ast.schema.types.unknown });
3491
3487
  const node = ast.factory.createSchema({
3492
- type: ast.schemaTypes.object,
3488
+ type: ast.schema.types.object,
3493
3489
  primitive: "object",
3494
3490
  properties: keys.map((name) => ast.factory.createProperty({
3495
3491
  name,
@@ -3569,8 +3565,8 @@ function createSchemaParser(ctx) {
3569
3565
  function collectInlineEnums(roots, topLevelNames) {
3570
3566
  const promoted = /* @__PURE__ */ new Map();
3571
3567
  for (const root of roots) {
3572
- const isSchemaRoot = root.kind === ast.nodeKinds.schema;
3573
- for (const node of ast.collect(root, { schema: (schemaNode) => schemaNode })) {
3568
+ const isSchemaRoot = root.kind === ast.node.kinds.schema;
3569
+ for (const node of ast.node.collect(root, { schema: (schemaNode) => schemaNode })) {
3574
3570
  if (node.type !== "enum" || !node.name) continue;
3575
3571
  if (isSchemaRoot && node === root) continue;
3576
3572
  if (topLevelNames.has(node.name)) continue;
@@ -3589,7 +3585,7 @@ function collectInlineEnums(roots, topLevelNames) {
3589
3585
  */
3590
3586
  function refPromotedEnums(node, promoted) {
3591
3587
  if (promoted.size === 0) return node;
3592
- return ast.transform(node, { schema(schemaNode) {
3588
+ return ast.node.transform(node, { schema(schemaNode) {
3593
3589
  if (schemaNode.type !== "enum" || !schemaNode.name || !promoted.has(schemaNode.name)) return void 0;
3594
3590
  return ast.factory.createSchema({
3595
3591
  type: "ref",
@@ -3733,7 +3729,7 @@ function indexJson(source) {
3733
3729
  };
3734
3730
  }
3735
3731
  /** Indexes plain JSON text; anything else goes to the YAML parser. */
3736
- function parse$1(source) {
3732
+ function parse(source) {
3737
3733
  if (/^[ \t\n\r]*\{/.test(source)) try {
3738
3734
  return {
3739
3735
  source,
@@ -3745,7 +3741,6 @@ function parse$1(source) {
3745
3741
  document: yaml.parseDocument(source)
3746
3742
  };
3747
3743
  }
3748
- __name(parse$1, "parse");
3749
3744
  /**
3750
3745
  * Maps OpenAPI JSON pointers and unresolved references to ranges in YAML or JSON source.
3751
3746
  */
@@ -3754,7 +3749,7 @@ const locate = (source, location) => {
3754
3749
  cached = cached?.source === source ? {
3755
3750
  ...cached,
3756
3751
  source
3757
- } : parse$1(source);
3752
+ } : parse(source);
3758
3753
  const ref = "ref" in location ? location.ref : void 0;
3759
3754
  if ("json" in cached) {
3760
3755
  const { pointers, refs } = cached.json;
@@ -3852,7 +3847,7 @@ const adapterOas = defineExtension({
3852
3847
  const promotedEnums = enums === "root" ? collectInlineEnums([...parsedByName.values(), ...operationNodes], new Set(Object.keys(schemas))) : null;
3853
3848
  const aliasTargetOf = (name) => {
3854
3849
  const node = refAliasMap.get(name);
3855
- return node?.ref ? ast.refName(node.ref) : node?.name;
3850
+ return node?.ref ? ast.ref.getName(node.ref) : node?.name;
3856
3851
  };
3857
3852
  function isAliasCycle(name) {
3858
3853
  const seen = /* @__PURE__ */ new Set([name]);