@kubb/ast 5.0.0-beta.57 → 5.0.0-beta.59

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.
Files changed (69) hide show
  1. package/README.md +21 -7
  2. package/dist/casing-BE2R1RXg.cjs +88 -0
  3. package/dist/casing-BE2R1RXg.cjs.map +1 -0
  4. package/dist/chunk-CNktS9qV.js +17 -0
  5. package/dist/extractStringsFromNodes-WMYJ8nQL.d.ts +82 -0
  6. package/dist/factory-BmcGBdeg.cjs +1251 -0
  7. package/dist/factory-BmcGBdeg.cjs.map +1 -0
  8. package/dist/factory-Du7nEP4B.js +282 -0
  9. package/dist/factory-Du7nEP4B.js.map +1 -0
  10. package/dist/factory.cjs +28 -0
  11. package/dist/factory.d.ts +62 -0
  12. package/dist/factory.js +3 -0
  13. package/dist/{types-C5aVnRE1.d.ts → index-BzjwdK2M.d.ts} +94 -1146
  14. package/dist/index.cjs +220 -1481
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +96 -58
  17. package/dist/index.js +182 -1920
  18. package/dist/index.js.map +1 -1
  19. package/dist/operationParams-BZ07xDm0.d.ts +204 -0
  20. package/dist/response-DKxTr522.js +683 -0
  21. package/dist/response-DKxTr522.js.map +1 -0
  22. package/dist/types-olVl9v5p.d.ts +764 -0
  23. package/dist/types.d.ts +5 -2
  24. package/dist/utils-BCtRXfhI.cjs +275 -0
  25. package/dist/utils-BCtRXfhI.cjs.map +1 -0
  26. package/dist/utils-SdZU0F3H.js +1336 -0
  27. package/dist/utils-SdZU0F3H.js.map +1 -0
  28. package/dist/utils.cjs +129 -13
  29. package/dist/utils.d.ts +127 -76
  30. package/dist/utils.js +3 -2
  31. package/package.json +5 -1
  32. package/src/constants.ts +8 -14
  33. package/src/dedupe.ts +8 -0
  34. package/src/factory.ts +18 -1
  35. package/src/guards.ts +1 -1
  36. package/src/index.ts +7 -50
  37. package/src/node.ts +1 -1
  38. package/src/nodes/base.ts +0 -10
  39. package/src/nodes/code.ts +29 -47
  40. package/src/nodes/content.ts +2 -2
  41. package/src/nodes/file.ts +28 -23
  42. package/src/nodes/function.ts +2 -17
  43. package/src/nodes/index.ts +1 -1
  44. package/src/nodes/input.ts +20 -19
  45. package/src/nodes/operation.ts +1 -1
  46. package/src/nodes/parameter.ts +0 -3
  47. package/src/nodes/property.ts +0 -3
  48. package/src/nodes/requestBody.ts +3 -6
  49. package/src/nodes/schema.ts +3 -2
  50. package/src/printer.ts +4 -4
  51. package/src/registry.ts +31 -26
  52. package/src/signature.ts +3 -3
  53. package/src/transformers.ts +28 -1
  54. package/src/types.ts +2 -53
  55. package/src/utils/codegen.ts +104 -0
  56. package/src/utils/extractStringsFromNodes.ts +34 -0
  57. package/src/utils/fileMerge.ts +184 -0
  58. package/src/utils/index.ts +8 -296
  59. package/src/utils/operationParams.ts +353 -0
  60. package/src/utils/refs.ts +112 -0
  61. package/src/utils/schemaGraph.ts +169 -0
  62. package/src/utils/strings.ts +139 -0
  63. package/src/visitor.ts +43 -19
  64. package/dist/chunk-C0LytTxp.js +0 -8
  65. package/dist/utils-0p8ZO287.js +0 -570
  66. package/dist/utils-0p8ZO287.js.map +0 -1
  67. package/dist/utils-cdQ6Pzyi.cjs +0 -726
  68. package/dist/utils-cdQ6Pzyi.cjs.map +0 -1
  69. package/src/utils/ast.ts +0 -879
@@ -1,726 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
- key = keys[i];
15
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: ((k) => from[k]).bind(null, key),
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
- //#endregion
27
- //#region src/constants.ts
28
- const visitorDepths = {
29
- shallow: "shallow",
30
- deep: "deep"
31
- };
32
- /**
33
- * Schema type discriminators used by all AST schema nodes.
34
- *
35
- * These values serve as stable discriminators across the AST (e.g., `schema.type === schemaTypes.object`).
36
- * Grouped by category: primitives (`string`, `number`, `boolean`), structural types (`object`, `array`, `union`),
37
- * and format-specific types (`date`, `uuid`, `email`). Use `isScalarPrimitive()` to check for scalar types.
38
- */
39
- const schemaTypes = {
40
- /**
41
- * Text value.
42
- */
43
- string: "string",
44
- /**
45
- * Floating-point number (`float`, `double`).
46
- */
47
- number: "number",
48
- /**
49
- * Whole number (`int32`). Use `bigint` for `int64`.
50
- */
51
- integer: "integer",
52
- /**
53
- * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
54
- */
55
- bigint: "bigint",
56
- /**
57
- * Boolean value
58
- */
59
- boolean: "boolean",
60
- /**
61
- * Explicit null value.
62
- */
63
- null: "null",
64
- /**
65
- * Any value (no type restriction).
66
- */
67
- any: "any",
68
- /**
69
- * Unknown value (must be narrowed before usage).
70
- */
71
- unknown: "unknown",
72
- /**
73
- * No return value (`void`).
74
- */
75
- void: "void",
76
- /**
77
- * Object with named properties.
78
- */
79
- object: "object",
80
- /**
81
- * Sequential list of items.
82
- */
83
- array: "array",
84
- /**
85
- * Fixed-length list with position-specific items.
86
- */
87
- tuple: "tuple",
88
- /**
89
- * "One of" multiple schema members.
90
- */
91
- union: "union",
92
- /**
93
- * "All of" multiple schema members.
94
- */
95
- intersection: "intersection",
96
- /**
97
- * Enum schema.
98
- */
99
- enum: "enum",
100
- /**
101
- * Reference to another schema.
102
- */
103
- ref: "ref",
104
- /**
105
- * Calendar date (for example `2026-03-24`).
106
- */
107
- date: "date",
108
- /**
109
- * Date-time value (for example `2026-03-24T09:00:00Z`).
110
- */
111
- datetime: "datetime",
112
- /**
113
- * Time-only value (for example `09:00:00`).
114
- */
115
- time: "time",
116
- /**
117
- * UUID value.
118
- */
119
- uuid: "uuid",
120
- /**
121
- * Email address value.
122
- */
123
- email: "email",
124
- /**
125
- * URL value.
126
- */
127
- url: "url",
128
- /**
129
- * IPv4 address value.
130
- */
131
- ipv4: "ipv4",
132
- /**
133
- * IPv6 address value.
134
- */
135
- ipv6: "ipv6",
136
- /**
137
- * Binary/blob value.
138
- */
139
- blob: "blob",
140
- /**
141
- * Impossible value (`never`).
142
- */
143
- never: "never"
144
- };
145
- /**
146
- * Scalar primitive schema types used for union simplification and type narrowing.
147
- *
148
- * Use `isScalarPrimitive()` to safely check whether a type is a scalar primitive.
149
- */
150
- const SCALAR_PRIMITIVE_TYPES = new Set([
151
- "string",
152
- "number",
153
- "integer",
154
- "bigint",
155
- "boolean"
156
- ]);
157
- /**
158
- * Type guard that returns `true` when `type` is a scalar primitive schema type.
159
- *
160
- * Use this to check if a schema type can be directly assigned without wrapping (e.g., `string | number | boolean`).
161
- */
162
- function isScalarPrimitive(type) {
163
- return SCALAR_PRIMITIVE_TYPES.has(type);
164
- }
165
- /**
166
- * HTTP method identifiers used by operation nodes.
167
- *
168
- * Includes all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE).
169
- */
170
- const httpMethods = {
171
- get: "GET",
172
- post: "POST",
173
- put: "PUT",
174
- patch: "PATCH",
175
- delete: "DELETE",
176
- head: "HEAD",
177
- options: "OPTIONS",
178
- trace: "TRACE"
179
- };
180
- /**
181
- * One indentation level, derived from {@link INDENT_SIZE}.
182
- */
183
- const INDENT = Array.from({ length: 2 }, () => " ").join("");
184
- //#endregion
185
- //#region ../../internals/utils/src/casing.ts
186
- /**
187
- * Shared implementation for camelCase and PascalCase conversion.
188
- * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
189
- * and capitalizes each word according to `pascal`.
190
- *
191
- * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
192
- */
193
- function toCamelOrPascal(text, pascal) {
194
- return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
195
- if (word.length > 1 && word === word.toUpperCase()) return word;
196
- return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
197
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
198
- }
199
- /**
200
- * Converts `text` to camelCase.
201
- *
202
- * @example Word boundaries
203
- * `camelCase('hello-world') // 'helloWorld'`
204
- *
205
- * @example With a prefix
206
- * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
207
- */
208
- function camelCase(text, { prefix = "", suffix = "" } = {}) {
209
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
210
- }
211
- /**
212
- * Converts `text` to PascalCase.
213
- *
214
- * @example Word boundaries
215
- * `pascalCase('hello-world') // 'HelloWorld'`
216
- *
217
- * @example With a suffix
218
- * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
219
- */
220
- function pascalCase(text, { prefix = "", suffix = "" } = {}) {
221
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
222
- }
223
- //#endregion
224
- //#region ../../internals/utils/src/reserved.ts
225
- /**
226
- * JavaScript and Java reserved words.
227
- * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
228
- */
229
- const reservedWords = new Set([
230
- "abstract",
231
- "arguments",
232
- "boolean",
233
- "break",
234
- "byte",
235
- "case",
236
- "catch",
237
- "char",
238
- "class",
239
- "const",
240
- "continue",
241
- "debugger",
242
- "default",
243
- "delete",
244
- "do",
245
- "double",
246
- "else",
247
- "enum",
248
- "eval",
249
- "export",
250
- "extends",
251
- "false",
252
- "final",
253
- "finally",
254
- "float",
255
- "for",
256
- "function",
257
- "goto",
258
- "if",
259
- "implements",
260
- "import",
261
- "in",
262
- "instanceof",
263
- "int",
264
- "interface",
265
- "let",
266
- "long",
267
- "native",
268
- "new",
269
- "null",
270
- "package",
271
- "private",
272
- "protected",
273
- "public",
274
- "return",
275
- "short",
276
- "static",
277
- "super",
278
- "switch",
279
- "synchronized",
280
- "this",
281
- "throw",
282
- "throws",
283
- "transient",
284
- "true",
285
- "try",
286
- "typeof",
287
- "var",
288
- "void",
289
- "volatile",
290
- "while",
291
- "with",
292
- "yield",
293
- "Array",
294
- "Date",
295
- "hasOwnProperty",
296
- "Infinity",
297
- "isFinite",
298
- "isNaN",
299
- "isPrototypeOf",
300
- "length",
301
- "Math",
302
- "name",
303
- "NaN",
304
- "Number",
305
- "Object",
306
- "prototype",
307
- "String",
308
- "toString",
309
- "undefined",
310
- "valueOf"
311
- ]);
312
- /**
313
- * Returns `true` when `name` is a syntactically valid JavaScript variable name.
314
- *
315
- * @example
316
- * ```ts
317
- * isValidVarName('status') // true
318
- * isValidVarName('class') // false (reserved word)
319
- * isValidVarName('42foo') // false (starts with digit)
320
- * ```
321
- */
322
- function isValidVarName(name) {
323
- if (!name || reservedWords.has(name)) return false;
324
- return isIdentifier(name);
325
- }
326
- /**
327
- * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.
328
- *
329
- * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys
330
- * even though they are not valid variable names, so use this (not {@link isValidVarName}) when
331
- * deciding whether an object key needs quoting.
332
- *
333
- * @example
334
- * ```ts
335
- * isIdentifier('name') // true
336
- * isIdentifier('x-total')// false
337
- * ```
338
- */
339
- function isIdentifier(name) {
340
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
341
- }
342
- //#endregion
343
- //#region ../../internals/utils/src/string.ts
344
- /**
345
- * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping
346
- * any backslash or single quote in the content.
347
- *
348
- * @example
349
- * ```ts
350
- * singleQuote('foo') // "'foo'"
351
- * singleQuote("o'clock") // "'o\\'clock'"
352
- * ```
353
- */
354
- function singleQuote(value) {
355
- if (value === void 0 || value === null) return "''";
356
- return `'${String(value).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
357
- }
358
- //#endregion
359
- //#region src/utils/index.ts
360
- /**
361
- * Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
362
- * Returns the string unchanged when no balanced quote pair is found.
363
- *
364
- * @example
365
- * ```ts
366
- * trimQuotes('"hello"') // 'hello'
367
- * trimQuotes('hello') // 'hello'
368
- * ```
369
- */
370
- function trimQuotes(text) {
371
- if (text.length >= 2) {
372
- const first = text[0];
373
- const last = text[text.length - 1];
374
- if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
375
- }
376
- return text;
377
- }
378
- /**
379
- * Serializes a primitive value to a single-quoted string literal, stripping any surrounding quote
380
- * characters first. Escaping comes from `JSON.stringify`, then the quote style switches to single
381
- * quotes so generated code matches the repo style without a formatter.
382
- *
383
- * @example
384
- * ```ts
385
- * stringify('hello') // "'hello'"
386
- * stringify('"hello"') // "'hello'"
387
- * ```
388
- */
389
- function stringify(value) {
390
- if (value === void 0 || value === null) return "''";
391
- return `'${JSON.stringify(trimQuotes(value.toString())).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
392
- }
393
- /**
394
- * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,
395
- * and the Unicode line terminators U+2028 and U+2029.
396
- *
397
- * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
398
- *
399
- * @example
400
- * ```ts
401
- * jsStringEscape('say "hi"\nbye') // 'say \\"hi\\"\\nbye'
402
- * ```
403
- */
404
- function jsStringEscape(input) {
405
- return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
406
- switch (character) {
407
- case "\"":
408
- case "'":
409
- case "\\": return `\\${character}`;
410
- case "\n": return "\\n";
411
- case "\r": return "\\r";
412
- case "\u2028": return "\\u2028";
413
- case "\u2029": return "\\u2029";
414
- default: return "";
415
- }
416
- });
417
- }
418
- /**
419
- * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.
420
- * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.
421
- * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.
422
- *
423
- * @example
424
- * ```ts
425
- * toRegExpString('^(?im)foo') // 'new RegExp("^foo", "im")'
426
- * toRegExpString('^(?im)foo', null) // '/^foo/im'
427
- * ```
428
- */
429
- function toRegExpString(text, func = "RegExp") {
430
- const raw = trimQuotes(text);
431
- const match = raw.match(/^\^(\(\?([igmsuy]+)\))/i);
432
- const replacementTarget = match?.[1] ?? "";
433
- const matchedFlags = match?.[2];
434
- const cleaned = raw.replace(/^\\?\//, "").replace(/\\?\/$/, "").replace(replacementTarget, "");
435
- const { source, flags } = new RegExp(cleaned, matchedFlags);
436
- if (func === null) return `/${source}/${flags}`;
437
- return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
438
- }
439
- /**
440
- * Renders a plain object as multi-line `key: value` source for embedding in generated code. Nested
441
- * objects recurse with fixed indentation, so the result drops straight into an object literal
442
- * without re-parsing.
443
- *
444
- * @example
445
- * ```ts
446
- * stringifyObject({ foo: 'bar', nested: { a: 1 } })
447
- * // 'foo: bar,\nnested: {\n a: 1\n }'
448
- * ```
449
- */
450
- function stringifyObject(value) {
451
- return Object.entries(value).map(([key, val]) => {
452
- if (val !== null && typeof val === "object") return `${key}: {\n ${stringifyObject(val)}\n }`;
453
- return `${key}: ${val}`;
454
- }).filter(Boolean).join(",\n");
455
- }
456
- /**
457
- * Renders a dotted path or string array as an optional-chaining accessor expression rooted at
458
- * `accessor`. Returns `null` for an empty path.
459
- *
460
- * @example
461
- * ```ts
462
- * getNestedAccessor('pagination.next.id', 'lastPage')
463
- * // "lastPage?.['pagination']?.['next']?.['id']"
464
- * ```
465
- */
466
- function getNestedAccessor(param, accessor) {
467
- const parts = Array.isArray(param) ? param : param.split(".");
468
- if (parts.length === 0 || parts.length === 1 && parts[0] === "") return null;
469
- return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
470
- }
471
- /**
472
- * Builds a JSDoc comment block from an array of lines, returning `fallback` when there are no
473
- * comments so callers always get a usable string.
474
- *
475
- * @example
476
- * ```ts
477
- * buildJSDoc(['@type string', '@example hello'])
478
- * // '/**\n * @type string\n * @example hello\n *\/\n '
479
- * ```
480
- */
481
- function buildJSDoc(comments, options = {}) {
482
- const { indent = " * ", suffix = "\n ", fallback = " " } = options;
483
- if (comments.length === 0) return fallback;
484
- return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
485
- }
486
- /**
487
- * Indents every non-empty line of `text` by one indent level, leaving blank lines empty.
488
- */
489
- function indentLines(text) {
490
- if (!text) return "";
491
- return text.split("\n").map((line) => line.trim() ? `${INDENT}${line}` : "").join("\n");
492
- }
493
- /**
494
- * Renders an object key, quoting it with single quotes only when it is not a valid identifier.
495
- * Reserved words and globals (`name`, `class`, …) are valid bare keys and stay unquoted.
496
- *
497
- * @example
498
- * ```ts
499
- * objectKey('name') // 'name'
500
- * objectKey('x-total') // "'x-total'"
501
- * ```
502
- */
503
- function objectKey(name) {
504
- return isIdentifier(name) ? name : singleQuote(name);
505
- }
506
- /**
507
- * Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one
508
- * level and closing the brace at column zero. Nested objects built the same way indent cumulatively,
509
- * so callers never re-parse the generated code. A trailing comma is added per entry to match the
510
- * formatter's multi-line style.
511
- *
512
- * @example
513
- * ```ts
514
- * buildObject(['id: z.number()', 'name: z.string()'])
515
- * // '{\n id: z.number(),\n name: z.string(),\n}'
516
- * ```
517
- */
518
- function buildObject(entries) {
519
- if (entries.length === 0) return "{}";
520
- return `{\n${entries.map((entry) => `${indentLines(entry)},`).join("\n")}\n}`;
521
- }
522
- /**
523
- * Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on
524
- * one line when no item spans multiple lines, and otherwise puts each item on its own line, indented
525
- * one level with a trailing comma and the closing bracket at column zero. Use it for `z.union([…])`,
526
- * `z.array([…])`, and similar member lists so objects inside them nest correctly.
527
- *
528
- * @example
529
- * ```ts
530
- * buildList(['z.string()', 'z.number()'])
531
- * // '[z.string(), z.number()]'
532
- * ```
533
- */
534
- function buildList(items, brackets = ["[", "]"]) {
535
- const [open, close] = brackets;
536
- if (items.length === 0) return `${open}${close}`;
537
- if (!items.some((item) => item.includes("\n"))) return `${open}${items.join(", ")}${close}`;
538
- return `${open}\n${items.map((item) => `${indentLines(item)},`).join("\n")}\n${close}`;
539
- }
540
- /**
541
- * Returns the last path segment of a reference string.
542
- *
543
- * @example
544
- * ```ts
545
- * extractRefName('#/components/schemas/Pet') // 'Pet'
546
- * ```
547
- */
548
- function extractRefName(ref) {
549
- return ref.split("/").at(-1) ?? ref;
550
- }
551
- /**
552
- * Builds a PascalCase child schema name by joining a parent name and property name.
553
- * Returns `null` when there is no parent to nest under.
554
- *
555
- * @example
556
- * ```ts
557
- * childName('Order', 'shipping_address') // 'OrderShippingAddress'
558
- * childName(undefined, 'params') // null
559
- * ```
560
- */
561
- function childName(parentName, propName) {
562
- return parentName ? pascalCase([parentName, propName].join(" ")) : null;
563
- }
564
- /**
565
- * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
566
- * empty parts.
567
- *
568
- * @example
569
- * ```ts
570
- * enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'
571
- * ```
572
- */
573
- function enumPropName(parentName, propName, enumSuffix) {
574
- return pascalCase([
575
- parentName,
576
- propName,
577
- enumSuffix
578
- ].filter(Boolean).join(" "));
579
- }
580
- /**
581
- * Returns the discriminator key whose mapping value matches `ref`, or `null` when there is no match.
582
- *
583
- * @example
584
- * ```ts
585
- * findDiscriminator({ dog: '#/components/schemas/Dog' }, '#/components/schemas/Dog') // 'dog'
586
- * ```
587
- */
588
- function findDiscriminator(mapping, ref) {
589
- if (!mapping || !ref) return null;
590
- return Object.entries(mapping).find(([, value]) => value === ref)?.[0] ?? null;
591
- }
592
- //#endregion
593
- Object.defineProperty(exports, "__name", {
594
- enumerable: true,
595
- get: function() {
596
- return __name;
597
- }
598
- });
599
- Object.defineProperty(exports, "__toESM", {
600
- enumerable: true,
601
- get: function() {
602
- return __toESM;
603
- }
604
- });
605
- Object.defineProperty(exports, "buildJSDoc", {
606
- enumerable: true,
607
- get: function() {
608
- return buildJSDoc;
609
- }
610
- });
611
- Object.defineProperty(exports, "buildList", {
612
- enumerable: true,
613
- get: function() {
614
- return buildList;
615
- }
616
- });
617
- Object.defineProperty(exports, "buildObject", {
618
- enumerable: true,
619
- get: function() {
620
- return buildObject;
621
- }
622
- });
623
- Object.defineProperty(exports, "camelCase", {
624
- enumerable: true,
625
- get: function() {
626
- return camelCase;
627
- }
628
- });
629
- Object.defineProperty(exports, "childName", {
630
- enumerable: true,
631
- get: function() {
632
- return childName;
633
- }
634
- });
635
- Object.defineProperty(exports, "enumPropName", {
636
- enumerable: true,
637
- get: function() {
638
- return enumPropName;
639
- }
640
- });
641
- Object.defineProperty(exports, "extractRefName", {
642
- enumerable: true,
643
- get: function() {
644
- return extractRefName;
645
- }
646
- });
647
- Object.defineProperty(exports, "findDiscriminator", {
648
- enumerable: true,
649
- get: function() {
650
- return findDiscriminator;
651
- }
652
- });
653
- Object.defineProperty(exports, "getNestedAccessor", {
654
- enumerable: true,
655
- get: function() {
656
- return getNestedAccessor;
657
- }
658
- });
659
- Object.defineProperty(exports, "httpMethods", {
660
- enumerable: true,
661
- get: function() {
662
- return httpMethods;
663
- }
664
- });
665
- Object.defineProperty(exports, "isScalarPrimitive", {
666
- enumerable: true,
667
- get: function() {
668
- return isScalarPrimitive;
669
- }
670
- });
671
- Object.defineProperty(exports, "isValidVarName", {
672
- enumerable: true,
673
- get: function() {
674
- return isValidVarName;
675
- }
676
- });
677
- Object.defineProperty(exports, "jsStringEscape", {
678
- enumerable: true,
679
- get: function() {
680
- return jsStringEscape;
681
- }
682
- });
683
- Object.defineProperty(exports, "objectKey", {
684
- enumerable: true,
685
- get: function() {
686
- return objectKey;
687
- }
688
- });
689
- Object.defineProperty(exports, "schemaTypes", {
690
- enumerable: true,
691
- get: function() {
692
- return schemaTypes;
693
- }
694
- });
695
- Object.defineProperty(exports, "stringify", {
696
- enumerable: true,
697
- get: function() {
698
- return stringify;
699
- }
700
- });
701
- Object.defineProperty(exports, "stringifyObject", {
702
- enumerable: true,
703
- get: function() {
704
- return stringifyObject;
705
- }
706
- });
707
- Object.defineProperty(exports, "toRegExpString", {
708
- enumerable: true,
709
- get: function() {
710
- return toRegExpString;
711
- }
712
- });
713
- Object.defineProperty(exports, "trimQuotes", {
714
- enumerable: true,
715
- get: function() {
716
- return trimQuotes;
717
- }
718
- });
719
- Object.defineProperty(exports, "visitorDepths", {
720
- enumerable: true,
721
- get: function() {
722
- return visitorDepths;
723
- }
724
- });
725
-
726
- //# sourceMappingURL=utils-cdQ6Pzyi.cjs.map