@kubb/ast 5.0.0-beta.42 → 5.0.0-beta.44

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,794 @@
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
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
197
+ return word.charAt(0).toUpperCase() + word.slice(1);
198
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
199
+ }
200
+ /**
201
+ * Splits `text` on `.` and applies `transformPart` to each segment.
202
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
203
+ * Segments are joined with `/` to form a file path.
204
+ *
205
+ * Only splits on dots followed by a letter so that version numbers
206
+ * embedded in operationIds (e.g. `v2025.0`) are kept intact.
207
+ *
208
+ * Empty segments are filtered before joining. They arise when the text starts with
209
+ * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`
210
+ * and `'..'` transforms to an empty string). Without this filter the join would produce
211
+ * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing
212
+ * generated files to escape the configured output directory.
213
+ */
214
+ function applyToFileParts(text, transformPart) {
215
+ const parts = text.split(/\.(?=[a-zA-Z])/);
216
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).filter(Boolean).join("/");
217
+ }
218
+ /**
219
+ * Converts `text` to camelCase.
220
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
221
+ *
222
+ * @example
223
+ * camelCase('hello-world') // 'helloWorld'
224
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
225
+ */
226
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
227
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
228
+ prefix,
229
+ suffix
230
+ } : {}));
231
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
232
+ }
233
+ /**
234
+ * Converts `text` to PascalCase.
235
+ * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
236
+ *
237
+ * @example
238
+ * pascalCase('hello-world') // 'HelloWorld'
239
+ * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
240
+ */
241
+ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
242
+ if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
243
+ prefix,
244
+ suffix
245
+ }) : camelCase(part));
246
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
247
+ }
248
+ //#endregion
249
+ //#region ../../internals/utils/src/reserved.ts
250
+ /**
251
+ * JavaScript and Java reserved words.
252
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
253
+ */
254
+ const reservedWords = new Set([
255
+ "abstract",
256
+ "arguments",
257
+ "boolean",
258
+ "break",
259
+ "byte",
260
+ "case",
261
+ "catch",
262
+ "char",
263
+ "class",
264
+ "const",
265
+ "continue",
266
+ "debugger",
267
+ "default",
268
+ "delete",
269
+ "do",
270
+ "double",
271
+ "else",
272
+ "enum",
273
+ "eval",
274
+ "export",
275
+ "extends",
276
+ "false",
277
+ "final",
278
+ "finally",
279
+ "float",
280
+ "for",
281
+ "function",
282
+ "goto",
283
+ "if",
284
+ "implements",
285
+ "import",
286
+ "in",
287
+ "instanceof",
288
+ "int",
289
+ "interface",
290
+ "let",
291
+ "long",
292
+ "native",
293
+ "new",
294
+ "null",
295
+ "package",
296
+ "private",
297
+ "protected",
298
+ "public",
299
+ "return",
300
+ "short",
301
+ "static",
302
+ "super",
303
+ "switch",
304
+ "synchronized",
305
+ "this",
306
+ "throw",
307
+ "throws",
308
+ "transient",
309
+ "true",
310
+ "try",
311
+ "typeof",
312
+ "var",
313
+ "void",
314
+ "volatile",
315
+ "while",
316
+ "with",
317
+ "yield",
318
+ "Array",
319
+ "Date",
320
+ "hasOwnProperty",
321
+ "Infinity",
322
+ "isFinite",
323
+ "isNaN",
324
+ "isPrototypeOf",
325
+ "length",
326
+ "Math",
327
+ "name",
328
+ "NaN",
329
+ "Number",
330
+ "Object",
331
+ "prototype",
332
+ "String",
333
+ "toString",
334
+ "undefined",
335
+ "valueOf"
336
+ ]);
337
+ /**
338
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * isValidVarName('status') // true
343
+ * isValidVarName('class') // false (reserved word)
344
+ * isValidVarName('42foo') // false (starts with digit)
345
+ * ```
346
+ */
347
+ function isValidVarName(name) {
348
+ if (!name || reservedWords.has(name)) return false;
349
+ return isIdentifier(name);
350
+ }
351
+ /**
352
+ * Returns `name` when it is already a valid JavaScript variable name, otherwise prefixes it with `_`
353
+ * so the result can be used as an identifier. Useful for sanitizing schema names or operation IDs
354
+ * that start with a digit (`409`, `504AccountCancel`) or collide with a reserved word.
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * ensureValidVarName('409') // '_409'
359
+ * ensureValidVarName('Pet') // 'Pet'
360
+ * ensureValidVarName('class') // '_class'
361
+ * ```
362
+ */
363
+ function ensureValidVarName(name) {
364
+ if (!name || isValidVarName(name)) return name;
365
+ return `_${name}`;
366
+ }
367
+ /**
368
+ * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.
369
+ *
370
+ * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys
371
+ * even though they are not valid variable names, so use this (not {@link isValidVarName}) when
372
+ * deciding whether an object key needs quoting.
373
+ *
374
+ * @example
375
+ * ```ts
376
+ * isIdentifier('name') // true
377
+ * isIdentifier('x-total')// false
378
+ * ```
379
+ */
380
+ function isIdentifier(name) {
381
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
382
+ }
383
+ //#endregion
384
+ //#region ../../internals/utils/src/string.ts
385
+ /**
386
+ * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping
387
+ * any backslash or single quote in the content.
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * singleQuote('foo') // "'foo'"
392
+ * singleQuote("o'clock") // "'o\\'clock'"
393
+ * ```
394
+ */
395
+ function singleQuote(value) {
396
+ if (value === void 0 || value === null) return "''";
397
+ return `'${String(value).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
398
+ }
399
+ /**
400
+ * Strips the file extension from a path or file name.
401
+ * Only removes the last `.ext` segment when the dot is not part of a directory name.
402
+ *
403
+ * @example
404
+ * trimExtName('petStore.ts') // 'petStore'
405
+ * trimExtName('/src/models/pet.ts') // '/src/models/pet'
406
+ * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
407
+ * trimExtName('noExtension') // 'noExtension'
408
+ */
409
+ function trimExtName(text) {
410
+ const dotIndex = text.lastIndexOf(".");
411
+ if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
412
+ return text;
413
+ }
414
+ //#endregion
415
+ //#region src/utils/index.ts
416
+ /**
417
+ * Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
418
+ * Returns the string unchanged when no balanced quote pair is found.
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * trimQuotes('"hello"') // 'hello'
423
+ * trimQuotes('hello') // 'hello'
424
+ * ```
425
+ */
426
+ function trimQuotes(text) {
427
+ if (text.length >= 2) {
428
+ const first = text[0];
429
+ const last = text[text.length - 1];
430
+ if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
431
+ }
432
+ return text;
433
+ }
434
+ /**
435
+ * Serializes a primitive value to a single-quoted string literal, stripping any surrounding quote
436
+ * characters first. Escaping comes from `JSON.stringify`, then the quote style switches to single
437
+ * quotes so generated code matches the repo style without a formatter.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * stringify('hello') // "'hello'"
442
+ * stringify('"hello"') // "'hello'"
443
+ * ```
444
+ */
445
+ function stringify(value) {
446
+ if (value === void 0 || value === null) return "''";
447
+ return `'${JSON.stringify(trimQuotes(value.toString())).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
448
+ }
449
+ /**
450
+ * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,
451
+ * and the Unicode line terminators U+2028 and U+2029.
452
+ *
453
+ * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * jsStringEscape('say "hi"\nbye') // 'say \\"hi\\"\\nbye'
458
+ * ```
459
+ */
460
+ function jsStringEscape(input) {
461
+ return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
462
+ switch (character) {
463
+ case "\"":
464
+ case "'":
465
+ case "\\": return `\\${character}`;
466
+ case "\n": return "\\n";
467
+ case "\r": return "\\r";
468
+ case "\u2028": return "\\u2028";
469
+ case "\u2029": return "\\u2029";
470
+ default: return "";
471
+ }
472
+ });
473
+ }
474
+ /**
475
+ * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.
476
+ * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.
477
+ * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.
478
+ *
479
+ * @example
480
+ * ```ts
481
+ * toRegExpString('^(?im)foo') // 'new RegExp("^foo", "im")'
482
+ * toRegExpString('^(?im)foo', null) // '/^foo/im'
483
+ * ```
484
+ */
485
+ function toRegExpString(text, func = "RegExp") {
486
+ const raw = trimQuotes(text);
487
+ const match = raw.match(/^\^(\(\?([igmsuy]+)\))/i);
488
+ const replacementTarget = match?.[1] ?? "";
489
+ const matchedFlags = match?.[2];
490
+ const cleaned = raw.replace(/^\\?\//, "").replace(/\\?\/$/, "").replace(replacementTarget, "");
491
+ const { source, flags } = new RegExp(cleaned, matchedFlags);
492
+ if (func === null) return `/${source}/${flags}`;
493
+ return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
494
+ }
495
+ /**
496
+ * Renders a plain object as multi-line `key: value` source for embedding in generated code. Nested
497
+ * objects recurse with fixed indentation, so the result drops straight into an object literal
498
+ * without re-parsing.
499
+ *
500
+ * @example
501
+ * ```ts
502
+ * stringifyObject({ foo: 'bar', nested: { a: 1 } })
503
+ * // 'foo: bar,\nnested: {\n a: 1\n }'
504
+ * ```
505
+ */
506
+ function stringifyObject(value) {
507
+ return Object.entries(value).map(([key, val]) => {
508
+ if (val !== null && typeof val === "object") return `${key}: {\n ${stringifyObject(val)}\n }`;
509
+ return `${key}: ${val}`;
510
+ }).filter(Boolean).join(",\n");
511
+ }
512
+ /**
513
+ * Renders a dotted path or string array as an optional-chaining accessor expression rooted at
514
+ * `accessor`. Returns `null` for an empty path.
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * getNestedAccessor('pagination.next.id', 'lastPage')
519
+ * // "lastPage?.['pagination']?.['next']?.['id']"
520
+ * ```
521
+ */
522
+ function getNestedAccessor(param, accessor) {
523
+ const parts = Array.isArray(param) ? param : param.split(".");
524
+ if (parts.length === 0 || parts.length === 1 && parts[0] === "") return null;
525
+ return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
526
+ }
527
+ /**
528
+ * Builds a JSDoc comment block from an array of lines, returning `fallback` when there are no
529
+ * comments so callers always get a usable string.
530
+ *
531
+ * @example
532
+ * ```ts
533
+ * buildJSDoc(['@type string', '@example hello'])
534
+ * // '/**\n * @type string\n * @example hello\n *\/\n '
535
+ * ```
536
+ */
537
+ function buildJSDoc(comments, options = {}) {
538
+ const { indent = " * ", suffix = "\n ", fallback = " " } = options;
539
+ if (comments.length === 0) return fallback;
540
+ return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
541
+ }
542
+ /**
543
+ * Indents every non-empty line of `text` by one indent level, leaving blank lines empty.
544
+ */
545
+ function indentLines(text) {
546
+ if (!text) return "";
547
+ return text.split("\n").map((line) => line.trim() ? `${INDENT}${line}` : "").join("\n");
548
+ }
549
+ /**
550
+ * Renders an object key, quoting it with single quotes only when it is not a valid identifier.
551
+ * Reserved words and globals (`name`, `class`, …) are valid bare keys and stay unquoted.
552
+ *
553
+ * @example
554
+ * ```ts
555
+ * objectKey('name') // 'name'
556
+ * objectKey('x-total') // "'x-total'"
557
+ * ```
558
+ */
559
+ function objectKey(name) {
560
+ return isIdentifier(name) ? name : singleQuote(name);
561
+ }
562
+ /**
563
+ * Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one
564
+ * level and closing the brace at column zero. Nested objects built the same way indent cumulatively,
565
+ * so callers never re-parse the generated code. A trailing comma is added per entry to match the
566
+ * formatter's multi-line style.
567
+ *
568
+ * @example
569
+ * ```ts
570
+ * buildObject(['id: z.number()', 'name: z.string()'])
571
+ * // '{\n id: z.number(),\n name: z.string(),\n}'
572
+ * ```
573
+ */
574
+ function buildObject(entries) {
575
+ if (entries.length === 0) return "{}";
576
+ return `{\n${entries.map((entry) => `${indentLines(entry)},`).join("\n")}\n}`;
577
+ }
578
+ /**
579
+ * Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on
580
+ * one line when no item spans multiple lines, and otherwise puts each item on its own line, indented
581
+ * one level with a trailing comma and the closing bracket at column zero. Use it for `z.union([…])`,
582
+ * `z.array([…])`, and similar member lists so objects inside them nest correctly.
583
+ *
584
+ * @example
585
+ * ```ts
586
+ * buildList(['z.string()', 'z.number()'])
587
+ * // '[z.string(), z.number()]'
588
+ * ```
589
+ */
590
+ function buildList(items, brackets = ["[", "]"]) {
591
+ const [open, close] = brackets;
592
+ if (items.length === 0) return `${open}${close}`;
593
+ if (!items.some((item) => item.includes("\n"))) return `${open}${items.join(", ")}${close}`;
594
+ return `${open}\n${items.map((item) => `${indentLines(item)},`).join("\n")}\n${close}`;
595
+ }
596
+ /**
597
+ * Returns the last path segment of a reference string.
598
+ *
599
+ * @example
600
+ * ```ts
601
+ * extractRefName('#/components/schemas/Pet') // 'Pet'
602
+ * ```
603
+ */
604
+ function extractRefName(ref) {
605
+ return ref.split("/").at(-1) ?? ref;
606
+ }
607
+ /**
608
+ * Builds a PascalCase child schema name by joining a parent name and property name.
609
+ * Returns `null` when there is no parent to nest under.
610
+ *
611
+ * @example
612
+ * ```ts
613
+ * childName('Order', 'shipping_address') // 'OrderShippingAddress'
614
+ * childName(undefined, 'params') // null
615
+ * ```
616
+ */
617
+ function childName(parentName, propName) {
618
+ return parentName ? pascalCase([parentName, propName].join(" ")) : null;
619
+ }
620
+ /**
621
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
622
+ * empty parts.
623
+ *
624
+ * @example
625
+ * ```ts
626
+ * enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'
627
+ * ```
628
+ */
629
+ function enumPropName(parentName, propName, enumSuffix) {
630
+ return pascalCase([
631
+ parentName,
632
+ propName,
633
+ enumSuffix
634
+ ].filter(Boolean).join(" "));
635
+ }
636
+ /**
637
+ * Returns the discriminator key whose mapping value matches `ref`, or `null` when there is no match.
638
+ *
639
+ * @example
640
+ * ```ts
641
+ * findDiscriminator({ dog: '#/components/schemas/Dog' }, '#/components/schemas/Dog') // 'dog'
642
+ * ```
643
+ */
644
+ function findDiscriminator(mapping, ref) {
645
+ if (!mapping || !ref) return null;
646
+ return Object.entries(mapping).find(([, value]) => value === ref)?.[0] ?? null;
647
+ }
648
+ //#endregion
649
+ Object.defineProperty(exports, "__name", {
650
+ enumerable: true,
651
+ get: function() {
652
+ return __name;
653
+ }
654
+ });
655
+ Object.defineProperty(exports, "__toESM", {
656
+ enumerable: true,
657
+ get: function() {
658
+ return __toESM;
659
+ }
660
+ });
661
+ Object.defineProperty(exports, "buildJSDoc", {
662
+ enumerable: true,
663
+ get: function() {
664
+ return buildJSDoc;
665
+ }
666
+ });
667
+ Object.defineProperty(exports, "buildList", {
668
+ enumerable: true,
669
+ get: function() {
670
+ return buildList;
671
+ }
672
+ });
673
+ Object.defineProperty(exports, "buildObject", {
674
+ enumerable: true,
675
+ get: function() {
676
+ return buildObject;
677
+ }
678
+ });
679
+ Object.defineProperty(exports, "camelCase", {
680
+ enumerable: true,
681
+ get: function() {
682
+ return camelCase;
683
+ }
684
+ });
685
+ Object.defineProperty(exports, "childName", {
686
+ enumerable: true,
687
+ get: function() {
688
+ return childName;
689
+ }
690
+ });
691
+ Object.defineProperty(exports, "ensureValidVarName", {
692
+ enumerable: true,
693
+ get: function() {
694
+ return ensureValidVarName;
695
+ }
696
+ });
697
+ Object.defineProperty(exports, "enumPropName", {
698
+ enumerable: true,
699
+ get: function() {
700
+ return enumPropName;
701
+ }
702
+ });
703
+ Object.defineProperty(exports, "extractRefName", {
704
+ enumerable: true,
705
+ get: function() {
706
+ return extractRefName;
707
+ }
708
+ });
709
+ Object.defineProperty(exports, "findDiscriminator", {
710
+ enumerable: true,
711
+ get: function() {
712
+ return findDiscriminator;
713
+ }
714
+ });
715
+ Object.defineProperty(exports, "getNestedAccessor", {
716
+ enumerable: true,
717
+ get: function() {
718
+ return getNestedAccessor;
719
+ }
720
+ });
721
+ Object.defineProperty(exports, "httpMethods", {
722
+ enumerable: true,
723
+ get: function() {
724
+ return httpMethods;
725
+ }
726
+ });
727
+ Object.defineProperty(exports, "isScalarPrimitive", {
728
+ enumerable: true,
729
+ get: function() {
730
+ return isScalarPrimitive;
731
+ }
732
+ });
733
+ Object.defineProperty(exports, "isValidVarName", {
734
+ enumerable: true,
735
+ get: function() {
736
+ return isValidVarName;
737
+ }
738
+ });
739
+ Object.defineProperty(exports, "jsStringEscape", {
740
+ enumerable: true,
741
+ get: function() {
742
+ return jsStringEscape;
743
+ }
744
+ });
745
+ Object.defineProperty(exports, "objectKey", {
746
+ enumerable: true,
747
+ get: function() {
748
+ return objectKey;
749
+ }
750
+ });
751
+ Object.defineProperty(exports, "schemaTypes", {
752
+ enumerable: true,
753
+ get: function() {
754
+ return schemaTypes;
755
+ }
756
+ });
757
+ Object.defineProperty(exports, "stringify", {
758
+ enumerable: true,
759
+ get: function() {
760
+ return stringify;
761
+ }
762
+ });
763
+ Object.defineProperty(exports, "stringifyObject", {
764
+ enumerable: true,
765
+ get: function() {
766
+ return stringifyObject;
767
+ }
768
+ });
769
+ Object.defineProperty(exports, "toRegExpString", {
770
+ enumerable: true,
771
+ get: function() {
772
+ return toRegExpString;
773
+ }
774
+ });
775
+ Object.defineProperty(exports, "trimExtName", {
776
+ enumerable: true,
777
+ get: function() {
778
+ return trimExtName;
779
+ }
780
+ });
781
+ Object.defineProperty(exports, "trimQuotes", {
782
+ enumerable: true,
783
+ get: function() {
784
+ return trimQuotes;
785
+ }
786
+ });
787
+ Object.defineProperty(exports, "visitorDepths", {
788
+ enumerable: true,
789
+ get: function() {
790
+ return visitorDepths;
791
+ }
792
+ });
793
+
794
+ //# sourceMappingURL=utils-CMRZrT-w.cjs.map