@kubb/ast 5.0.0-beta.43 → 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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { $ as createText, $t as PrimitiveSchemaType, A as DistributiveOmit, At as ParameterNode, B as createImport, Bt as SourceNode, C as transform, Cn as NodeKind, Ct as OperationNodeBase, D as PrinterPartial, Dn as schemaTypes, Dt as MediaType, E as PrinterFactoryOptions, En as httpMethods, Et as HttpStatusCode, F as createExport, Ft as ParameterGroupNode, G as createParameter, Gt as EnumSchemaNode, H as createJsx, Ht as ComplexSchemaType, I as createFile, It as ParamsTypeNode, J as createProperty, Jt as IntersectionSchemaNode, K as createParameterGroup, Kt as EnumValueNode, L as createFunction, Lt as ExportNode, M as createArrowFunction, Mt as FunctionParamNode, N as createBreak, Nt as FunctionParameterNode, O as createPrinterFactory, Ot as StatusCode, P as createConst, Pt as FunctionParametersNode, Q as createStreamInput, Qt as ObjectSchemaNode, R as createFunctionParameter, Rt as FileNode, S as collect, Sn as BaseNode, St as OperationNode, T as Printer, Tn as VisitorDepth, Tt as ResponseNode, U as createOperation, Ut as DateSchemaNode, V as createInput, Vt as ArraySchemaNode, W as createOutput, Wt as DatetimeSchemaNode, X as createSchema, Xt as Ipv6SchemaNode, Y as createResponse, Yt as Ipv4SchemaNode, Z as createSource, Zt as NumberSchemaNode, _ as ParentOf, _n as JSDocNode, _t as InputStreamNode, a as collectUsedSchemaNames, an as SchemaType, at as DispatchRule, b as VisitorContext, bn as TypeDeclarationNode, bt as HttpMethod, c as createOperationParams, cn as TimeSchemaNode, ct as defineSchemaDialect, d as isStringType, dn as PropertyNode, dt as DedupePlan, en as RefSchemaNode, et as createType, f as objectKey, fn as ArrowFunctionNode, ft as applyDedupe, g as CollectVisitor, gn as FunctionNode, gt as InputNode, h as CollectOptions, hn as ConstNode, ht as InputMeta, i as caseParams, in as SchemaNodeByType, it as ParserOptions, j as UserFileNode, jt as FunctionNodeType, k as definePrinter, kt as ParameterLocation, l as extractStringsFromNodes, ln as UnionSchemaNode, lt as BuildDedupePlanOptions, m as AsyncVisitor, mn as CodeNode, mt as Node, n as buildList, nn as ScalarSchemaType, nt as update, o as containsCircularRef, on as SpecialSchemaType, ot as dispatch, p as syncSchemaRef, pn as BreakNode, pt as buildDedupePlan, q as createParamsType, qt as FormatStringSchemaNode, r as buildObject, rn as SchemaNode, rt as InferSchemaNode, s as createDiscriminantNode, sn as StringSchemaNode, st as SchemaDialect, t as OperationParamsResolver, tn as ScalarSchemaNode, tt as syncOptionality, u as findCircularSchemas, un as UrlSchemaNode, ut as DedupeCanonical, v as TransformOptions, vn as JsxNode, vt as OutputNode, w as walk, wn as ScalarPrimitive, wt as OperationProtocol, x as WalkOptions, xn as TypeNode, xt as HttpOperationNode, y as Visitor, yn as TextNode, yt as GenericOperationNode, z as createFunctionParameters, zt as ImportNode } from "./types-CC46hQUP.js";
2
+ import { $ as update, $t as ScalarSchemaType, A as createBreak, At as FunctionParameterNode, B as createOperation, Bt as DateSchemaNode, C as PrinterFactoryOptions, Cn as httpMethods, Ct as HttpStatusCode, D as DistributiveOmit, Dt as ParameterNode, E as definePrinter, Et as ParameterLocation, F as createFunctionParameter, Ft as FileNode, G as createProperty, Gt as IntersectionSchemaNode, H as createParameter, Ht as EnumSchemaNode, I as createFunctionParameters, It as ImportNode, J as createSource, Jt as NumberSchemaNode, K as createResponse, Kt as Ipv4SchemaNode, L as createImport, Lt as SourceNode, M as createExport, Mt as ParameterGroupNode, N as createFile, Nt as ParamsTypeNode, O as UserFileNode, Ot as FunctionNodeType, P as createFunction, Pt as ExportNode, Q as syncOptionality, Qt as ScalarSchemaNode, R as createInput, Rt as ArraySchemaNode, S as Printer, Sn as VisitorDepth, St as ResponseNode, T as createPrinterFactory, Tt as StatusCode, U as createParameterGroup, Ut as EnumValueNode, V as createOutput, Vt as DatetimeSchemaNode, W as createParamsType, Wt as FormatStringSchemaNode, X as createText, Xt as PrimitiveSchemaType, Y as createStreamInput, Yt as ObjectSchemaNode, Z as createType, Zt as RefSchemaNode, _ as VisitorContext, _n as TypeDeclarationNode, _t as HttpMethod, a as createDiscriminantNode, an as TimeSchemaNode, at as defineSchemaDialect, b as transform, bn as NodeKind, bt as OperationNodeBase, c as findCircularSchemas, cn as PropertyNode, ct as DedupePlan, d as AsyncVisitor, dn as CodeNode, dt as Node, en as SchemaNode, et as InferSchemaNode, f as CollectOptions, fn as ConstNode, ft as InputMeta, g as Visitor, gn as TextNode, gt as GenericOperationNode, h as TransformOptions, hn as JsxNode, ht as OutputNode, i as containsCircularRef, in as StringSchemaNode, it as SchemaDialect, j as createConst, jt as FunctionParametersNode, k as createArrowFunction, kt as FunctionParamNode, l as isStringType, ln as ArrowFunctionNode, lt as applyDedupe, m as ParentOf, mn as JSDocNode, mt as InputStreamNode, n as caseParams, nn as SchemaType, nt as DispatchRule, o as createOperationParams, on as UnionSchemaNode, ot as BuildDedupePlanOptions, p as CollectVisitor, pn as FunctionNode, pt as InputNode, q as createSchema, qt as Ipv6SchemaNode, r as collectUsedSchemaNames, rn as SpecialSchemaType, rt as dispatch, s as extractStringsFromNodes, sn as UrlSchemaNode, st as DedupeCanonical, t as OperationParamsResolver, tn as SchemaNodeByType, tt as ParserOptions, u as syncSchemaRef, un as BreakNode, ut as buildDedupePlan, v as WalkOptions, vn as TypeNode, vt as HttpOperationNode, w as PrinterPartial, wn as schemaTypes, wt as MediaType, x as walk, xn as ScalarPrimitive, xt as OperationProtocol, y as collect, yn as BaseNode, yt as OperationNode, z as createJsx, zt as ComplexSchemaType } from "./types-lc8xMmUs.js";
3
3
 
4
4
  //#region src/guards.d.ts
5
5
  /**
@@ -68,23 +68,7 @@ declare function isHttpOperationNode(node: OperationNode): node is HttpOperation
68
68
  */
69
69
  declare const isSchemaNode: (node: unknown) => node is SchemaNode;
70
70
  //#endregion
71
- //#region src/refs.d.ts
72
- /**
73
- * Returns the last path segment of a reference string.
74
- *
75
- * Example: `#/components/schemas/Pet` becomes `Pet`.
76
- *
77
- * @example
78
- * ```ts
79
- * extractRefName('#/components/schemas/Pet') // 'Pet'
80
- * ```
81
- */
82
- declare function extractRefName(ref: string): string;
83
- //#endregion
84
71
  //#region src/resolvers.d.ts
85
- declare function findDiscriminator(mapping: Record<string, string> | undefined, ref: string | undefined): string | null;
86
- declare function childName(parentName: string | null | undefined, propName: string): string | null;
87
- declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
88
72
  /**
89
73
  * Collects import entries for all `ref` schema nodes in `node`.
90
74
  */
@@ -170,5 +154,5 @@ declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Genera
170
154
  declare function simplifyUnion(members: Array<SchemaNode>): Array<SchemaNode>;
171
155
  declare function setEnumName(propNode: SchemaNode, parentName: string | null | undefined, propName: string, enumSuffix: string): SchemaNode;
172
156
  //#endregion
173
- export { type ArraySchemaNode, type ArrowFunctionNode, type AsyncVisitor, type BaseNode, type BreakNode, type BuildDedupePlanOptions, type CodeNode, type CollectOptions, type CollectVisitor, type ComplexSchemaType, type ConstNode, type DateSchemaNode, type DatetimeSchemaNode, type DedupeCanonical, type DedupePlan, type DispatchRule, type DistributiveOmit, type EnumSchemaNode, type EnumValueNode, type ExportNode, type FileNode, type FormatStringSchemaNode, type FunctionNode, type FunctionNodeType, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type HttpStatusCode, type ImportNode, type InferSchemaNode, type InputMeta, type InputNode, type InputStreamNode, type IntersectionSchemaNode, type Ipv4SchemaNode, type Ipv6SchemaNode, type JSDocNode, type JsxNode, type MediaType, type Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OperationNodeBase, type OperationParamsResolver, type OperationProtocol, type OutputNode, type ParameterGroupNode, type ParameterLocation, type ParameterNode, type ParamsTypeNode, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type ResponseNode, type ScalarPrimitive, type ScalarSchemaNode, type ScalarSchemaType, type SchemaDialect, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type SpecialSchemaType, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TransformOptions, type TypeDeclarationNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, type VisitorDepth, type WalkOptions, applyDedupe, buildDedupePlan, buildList, buildObject, caseParams, childName, collect, collectImports, collectUsedSchemaNames, containsCircularRef, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createStreamInput, createText, createType, definePrinter, defineSchemaDialect, dispatch, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, findDiscriminator, httpMethods, isHttpOperationNode, isInputNode, isOperationNode, isOutputNode, isSchemaNode, isStringType, mergeAdjacentObjectsLazy, narrowSchema, objectKey, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
157
+ export { type ArraySchemaNode, type ArrowFunctionNode, type AsyncVisitor, type BaseNode, type BreakNode, type BuildDedupePlanOptions, type CodeNode, type CollectOptions, type CollectVisitor, type ComplexSchemaType, type ConstNode, type DateSchemaNode, type DatetimeSchemaNode, type DedupeCanonical, type DedupePlan, type DispatchRule, type DistributiveOmit, type EnumSchemaNode, type EnumValueNode, type ExportNode, type FileNode, type FormatStringSchemaNode, type FunctionNode, type FunctionNodeType, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type HttpStatusCode, type ImportNode, type InferSchemaNode, type InputMeta, type InputNode, type InputStreamNode, type IntersectionSchemaNode, type Ipv4SchemaNode, type Ipv6SchemaNode, type JSDocNode, type JsxNode, type MediaType, type Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OperationNodeBase, type OperationParamsResolver, type OperationProtocol, type OutputNode, type ParameterGroupNode, type ParameterLocation, type ParameterNode, type ParamsTypeNode, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type ResponseNode, type ScalarPrimitive, type ScalarSchemaNode, type ScalarSchemaType, type SchemaDialect, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type SpecialSchemaType, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TransformOptions, type TypeDeclarationNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, type VisitorDepth, type WalkOptions, applyDedupe, buildDedupePlan, caseParams, collect, collectImports, collectUsedSchemaNames, containsCircularRef, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createStreamInput, createText, createType, definePrinter, defineSchemaDialect, dispatch, extractStringsFromNodes, findCircularSchemas, httpMethods, isHttpOperationNode, isInputNode, isOperationNode, isOutputNode, isSchemaNode, isStringType, mergeAdjacentObjectsLazy, narrowSchema, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
174
158
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,228 +1,7 @@
1
1
  import "./chunk-C0LytTxp.js";
2
+ import { S as visitorDepths, _ as isValidVarName, a as enumPropName, b as isScalarPrimitive, h as trimExtName, o as extractRefName, v as camelCase, x as schemaTypes, y as httpMethods } from "./utils-BIcKgbbc.js";
2
3
  import { hash } from "node:crypto";
3
4
  import path from "node:path";
4
- //#region src/constants.ts
5
- const visitorDepths = {
6
- shallow: "shallow",
7
- deep: "deep"
8
- };
9
- /**
10
- * Schema type discriminators used by all AST schema nodes.
11
- *
12
- * These values serve as stable discriminators across the AST (e.g., `schema.type === schemaTypes.object`).
13
- * Grouped by category: primitives (`string`, `number`, `boolean`), structural types (`object`, `array`, `union`),
14
- * and format-specific types (`date`, `uuid`, `email`). Use `isScalarPrimitive()` to check for scalar types.
15
- */
16
- const schemaTypes = {
17
- /**
18
- * Text value.
19
- */
20
- string: "string",
21
- /**
22
- * Floating-point number (`float`, `double`).
23
- */
24
- number: "number",
25
- /**
26
- * Whole number (`int32`). Use `bigint` for `int64`.
27
- */
28
- integer: "integer",
29
- /**
30
- * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
31
- */
32
- bigint: "bigint",
33
- /**
34
- * Boolean value
35
- */
36
- boolean: "boolean",
37
- /**
38
- * Explicit null value.
39
- */
40
- null: "null",
41
- /**
42
- * Any value (no type restriction).
43
- */
44
- any: "any",
45
- /**
46
- * Unknown value (must be narrowed before usage).
47
- */
48
- unknown: "unknown",
49
- /**
50
- * No return value (`void`).
51
- */
52
- void: "void",
53
- /**
54
- * Object with named properties.
55
- */
56
- object: "object",
57
- /**
58
- * Sequential list of items.
59
- */
60
- array: "array",
61
- /**
62
- * Fixed-length list with position-specific items.
63
- */
64
- tuple: "tuple",
65
- /**
66
- * "One of" multiple schema members.
67
- */
68
- union: "union",
69
- /**
70
- * "All of" multiple schema members.
71
- */
72
- intersection: "intersection",
73
- /**
74
- * Enum schema.
75
- */
76
- enum: "enum",
77
- /**
78
- * Reference to another schema.
79
- */
80
- ref: "ref",
81
- /**
82
- * Calendar date (for example `2026-03-24`).
83
- */
84
- date: "date",
85
- /**
86
- * Date-time value (for example `2026-03-24T09:00:00Z`).
87
- */
88
- datetime: "datetime",
89
- /**
90
- * Time-only value (for example `09:00:00`).
91
- */
92
- time: "time",
93
- /**
94
- * UUID value.
95
- */
96
- uuid: "uuid",
97
- /**
98
- * Email address value.
99
- */
100
- email: "email",
101
- /**
102
- * URL value.
103
- */
104
- url: "url",
105
- /**
106
- * IPv4 address value.
107
- */
108
- ipv4: "ipv4",
109
- /**
110
- * IPv6 address value.
111
- */
112
- ipv6: "ipv6",
113
- /**
114
- * Binary/blob value.
115
- */
116
- blob: "blob",
117
- /**
118
- * Impossible value (`never`).
119
- */
120
- never: "never"
121
- };
122
- /**
123
- * Scalar primitive schema types used for union simplification and type narrowing.
124
- *
125
- * Use `isScalarPrimitive()` to safely check whether a type is a scalar primitive.
126
- */
127
- const SCALAR_PRIMITIVE_TYPES = new Set([
128
- "string",
129
- "number",
130
- "integer",
131
- "bigint",
132
- "boolean"
133
- ]);
134
- /**
135
- * Type guard that returns `true` when `type` is a scalar primitive schema type.
136
- *
137
- * Use this to check if a schema type can be directly assigned without wrapping (e.g., `string | number | boolean`).
138
- */
139
- function isScalarPrimitive(type) {
140
- return SCALAR_PRIMITIVE_TYPES.has(type);
141
- }
142
- /**
143
- * HTTP method identifiers used by operation nodes.
144
- *
145
- * Includes all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE).
146
- */
147
- const httpMethods = {
148
- get: "GET",
149
- post: "POST",
150
- put: "PUT",
151
- patch: "PATCH",
152
- delete: "DELETE",
153
- head: "HEAD",
154
- options: "OPTIONS",
155
- trace: "TRACE"
156
- };
157
- /**
158
- * One indentation level, derived from {@link INDENT_SIZE}.
159
- */
160
- const INDENT = Array.from({ length: 2 }, () => " ").join("");
161
- //#endregion
162
- //#region ../../internals/utils/src/casing.ts
163
- /**
164
- * Shared implementation for camelCase and PascalCase conversion.
165
- * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
166
- * and capitalizes each word according to `pascal`.
167
- *
168
- * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
169
- */
170
- function toCamelOrPascal(text, pascal) {
171
- 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) => {
172
- if (word.length > 1 && word === word.toUpperCase()) return word;
173
- if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
174
- return word.charAt(0).toUpperCase() + word.slice(1);
175
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
176
- }
177
- /**
178
- * Splits `text` on `.` and applies `transformPart` to each segment.
179
- * The last segment receives `isLast = true`, all earlier segments receive `false`.
180
- * Segments are joined with `/` to form a file path.
181
- *
182
- * Only splits on dots followed by a letter so that version numbers
183
- * embedded in operationIds (e.g. `v2025.0`) are kept intact.
184
- *
185
- * Empty segments are filtered before joining. They arise when the text starts with
186
- * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`
187
- * and `'..'` transforms to an empty string). Without this filter the join would produce
188
- * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing
189
- * generated files to escape the configured output directory.
190
- */
191
- function applyToFileParts(text, transformPart) {
192
- const parts = text.split(/\.(?=[a-zA-Z])/);
193
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).filter(Boolean).join("/");
194
- }
195
- /**
196
- * Converts `text` to camelCase.
197
- * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
198
- *
199
- * @example
200
- * camelCase('hello-world') // 'helloWorld'
201
- * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
202
- */
203
- function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
204
- if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
205
- prefix,
206
- suffix
207
- } : {}));
208
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
209
- }
210
- /**
211
- * Converts `text` to PascalCase.
212
- * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
213
- *
214
- * @example
215
- * pascalCase('hello-world') // 'HelloWorld'
216
- * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
217
- */
218
- function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
219
- if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
220
- prefix,
221
- suffix
222
- }) : camelCase(part));
223
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
224
- }
225
- //#endregion
226
5
  //#region ../../internals/utils/src/promise.ts
227
6
  /**
228
7
  * Wraps `factory` with a keyed cache backed by the provided store.
@@ -263,126 +42,6 @@ function memoize(store, factory) {
263
42
  };
264
43
  }
265
44
  //#endregion
266
- //#region ../../internals/utils/src/reserved.ts
267
- /**
268
- * JavaScript and Java reserved words.
269
- * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
270
- */
271
- const reservedWords = new Set([
272
- "abstract",
273
- "arguments",
274
- "boolean",
275
- "break",
276
- "byte",
277
- "case",
278
- "catch",
279
- "char",
280
- "class",
281
- "const",
282
- "continue",
283
- "debugger",
284
- "default",
285
- "delete",
286
- "do",
287
- "double",
288
- "else",
289
- "enum",
290
- "eval",
291
- "export",
292
- "extends",
293
- "false",
294
- "final",
295
- "finally",
296
- "float",
297
- "for",
298
- "function",
299
- "goto",
300
- "if",
301
- "implements",
302
- "import",
303
- "in",
304
- "instanceof",
305
- "int",
306
- "interface",
307
- "let",
308
- "long",
309
- "native",
310
- "new",
311
- "null",
312
- "package",
313
- "private",
314
- "protected",
315
- "public",
316
- "return",
317
- "short",
318
- "static",
319
- "super",
320
- "switch",
321
- "synchronized",
322
- "this",
323
- "throw",
324
- "throws",
325
- "transient",
326
- "true",
327
- "try",
328
- "typeof",
329
- "var",
330
- "void",
331
- "volatile",
332
- "while",
333
- "with",
334
- "yield",
335
- "Array",
336
- "Date",
337
- "hasOwnProperty",
338
- "Infinity",
339
- "isFinite",
340
- "isNaN",
341
- "isPrototypeOf",
342
- "length",
343
- "Math",
344
- "name",
345
- "NaN",
346
- "Number",
347
- "Object",
348
- "prototype",
349
- "String",
350
- "toString",
351
- "undefined",
352
- "valueOf"
353
- ]);
354
- /**
355
- * Returns `true` when `name` is a syntactically valid JavaScript variable name.
356
- *
357
- * @example
358
- * ```ts
359
- * isValidVarName('status') // true
360
- * isValidVarName('class') // false (reserved word)
361
- * isValidVarName('42foo') // false (starts with digit)
362
- * ```
363
- */
364
- function isValidVarName(name) {
365
- if (!name || reservedWords.has(name)) return false;
366
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
367
- }
368
- //#endregion
369
- //#region ../../internals/utils/src/string.ts
370
- /**
371
- * Strips the file extension from a path or file name.
372
- * Only removes the last `.ext` segment when the dot is not part of a directory name.
373
- *
374
- * @example
375
- * trimExtName('petStore.ts') // 'petStore'
376
- * trimExtName('/src/models/pet.ts') // '/src/models/pet'
377
- * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
378
- * trimExtName('noExtension') // 'noExtension'
379
- */
380
- function trimExtName(text) {
381
- const dotIndex = text.lastIndexOf(".");
382
- if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
383
- return text;
384
- }
385
- //#endregion
386
45
  //#region src/guards.ts
387
46
  /**
388
47
  * Narrows a `SchemaNode` to the variant that matches `type`.
@@ -457,21 +116,6 @@ function isHttpOperationNode(node) {
457
116
  */
458
117
  const isSchemaNode = isKind("Schema");
459
118
  //#endregion
460
- //#region src/refs.ts
461
- /**
462
- * Returns the last path segment of a reference string.
463
- *
464
- * Example: `#/components/schemas/Pet` becomes `Pet`.
465
- *
466
- * @example
467
- * ```ts
468
- * extractRefName('#/components/schemas/Pet') // 'Pet'
469
- * ```
470
- */
471
- function extractRefName(ref) {
472
- return ref.split("/").at(-1) ?? ref;
473
- }
474
- //#endregion
475
119
  //#region src/visitor.ts
476
120
  /**
477
121
  * Creates a small async concurrency limiter.
@@ -713,7 +357,7 @@ function collect(node, options) {
713
357
  return Array.from(collectLazy(node, options));
714
358
  }
715
359
  //#endregion
716
- //#region src/utils.ts
360
+ //#region src/utils/ast.ts
717
361
  const plainStringTypes = new Set([
718
362
  "string",
719
363
  "uuid",
@@ -1184,59 +828,6 @@ function extractStringsFromNodes(nodes) {
1184
828
  }).filter(Boolean).join("\n");
1185
829
  }
1186
830
  /**
1187
- * Indents every non-empty line of `text` by one indent level, leaving blank lines empty.
1188
- */
1189
- function indentLines(text) {
1190
- if (!text) return "";
1191
- return text.split("\n").map((line) => line.trim() ? `${INDENT}${line}` : "").join("\n");
1192
- }
1193
- /**
1194
- * Renders an object key, quoting it only when it is not a valid variable name.
1195
- *
1196
- * @example
1197
- * ```ts
1198
- * objectKey('id') // 'id'
1199
- * objectKey('x-total') // '"x-total"'
1200
- * ```
1201
- */
1202
- function objectKey(name) {
1203
- return isValidVarName(name) ? name : JSON.stringify(name);
1204
- }
1205
- /**
1206
- * Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one
1207
- * level and closing the brace at column zero. Nested objects built the same way indent cumulatively,
1208
- * so callers never re-parse the generated code. A trailing comma is added per entry to match the
1209
- * formatter's multi-line style.
1210
- *
1211
- * @example
1212
- * ```ts
1213
- * buildObject(['id: z.number()', 'name: z.string()'])
1214
- * // '{\n id: z.number(),\n name: z.string(),\n}'
1215
- * ```
1216
- */
1217
- function buildObject(entries) {
1218
- if (entries.length === 0) return "{}";
1219
- return `{\n${entries.map((entry) => `${indentLines(entry)},`).join("\n")}\n}`;
1220
- }
1221
- /**
1222
- * Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on
1223
- * one line when no item spans multiple lines, and otherwise puts each item on its own line, indented
1224
- * one level with a trailing comma and the closing bracket at column zero. Use it for `z.union([…])`,
1225
- * `z.array([…])`, and similar member lists so objects inside them nest correctly.
1226
- *
1227
- * @example
1228
- * ```ts
1229
- * buildList(['z.string()', 'z.number()'])
1230
- * // '[z.string(), z.number()]'
1231
- * ```
1232
- */
1233
- function buildList(items, brackets = ["[", "]"]) {
1234
- const [open, close] = brackets;
1235
- if (items.length === 0) return `${open}${close}`;
1236
- if (!items.some((item) => item.includes("\n"))) return `${open}${items.join(", ")}${close}`;
1237
- return `${open}\n${items.map((item) => `${indentLines(item)},`).join("\n")}\n${close}`;
1238
- }
1239
- /**
1240
831
  * Resolves the schema name of a ref node, falling back through `ref` → `name` → nested `schema.name`.
1241
832
  *
1242
833
  * Returns `null` for non-ref nodes or when no name can be resolved. Use this to get a schema's
@@ -2588,20 +2179,6 @@ function createPrinterFactory(getKey) {
2588
2179
  }
2589
2180
  //#endregion
2590
2181
  //#region src/resolvers.ts
2591
- function findDiscriminator(mapping, ref) {
2592
- if (!mapping || !ref) return null;
2593
- return Object.entries(mapping).find(([, value]) => value === ref)?.[0] ?? null;
2594
- }
2595
- function childName(parentName, propName) {
2596
- return parentName ? pascalCase([parentName, propName].join(" ")) : null;
2597
- }
2598
- function enumPropName(parentName, propName, enumSuffix) {
2599
- return pascalCase([
2600
- parentName,
2601
- propName,
2602
- enumSuffix
2603
- ].filter(Boolean).join(" "));
2604
- }
2605
2182
  /**
2606
2183
  * Collects import entries for all `ref` schema nodes in `node`.
2607
2184
  */
@@ -2723,6 +2300,6 @@ function setEnumName(propNode, parentName, propName, enumSuffix) {
2723
2300
  return propNode;
2724
2301
  }
2725
2302
  //#endregion
2726
- export { applyDedupe, buildDedupePlan, buildList, buildObject, caseParams, childName, collect, collectImports, collectUsedSchemaNames, containsCircularRef, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createStreamInput, createText, createType, definePrinter, defineSchemaDialect, dispatch, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, findDiscriminator, httpMethods, isHttpOperationNode, isInputNode, isOperationNode, isOutputNode, isSchemaNode, isStringType, mergeAdjacentObjectsLazy, narrowSchema, objectKey, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
2303
+ export { applyDedupe, buildDedupePlan, caseParams, collect, collectImports, collectUsedSchemaNames, containsCircularRef, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createStreamInput, createText, createType, definePrinter, defineSchemaDialect, dispatch, extractStringsFromNodes, findCircularSchemas, httpMethods, isHttpOperationNode, isInputNode, isOperationNode, isOutputNode, isSchemaNode, isStringType, mergeAdjacentObjectsLazy, narrowSchema, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
2727
2304
 
2728
2305
  //# sourceMappingURL=index.js.map