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

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 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-CEIHPTfs.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";
3
3
 
4
4
  //#region src/guards.d.ts
5
5
  /**
@@ -170,5 +170,5 @@ declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Genera
170
170
  declare function simplifyUnion(members: Array<SchemaNode>): Array<SchemaNode>;
171
171
  declare function setEnumName(propNode: SchemaNode, parentName: string | null | undefined, propName: string, enumSuffix: string): SchemaNode;
172
172
  //#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, 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, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
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 };
174
174
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -154,6 +154,10 @@ const httpMethods = {
154
154
  options: "OPTIONS",
155
155
  trace: "TRACE"
156
156
  };
157
+ /**
158
+ * One indentation level, derived from {@link INDENT_SIZE}.
159
+ */
160
+ const INDENT = Array.from({ length: 2 }, () => " ").join("");
157
161
  //#endregion
158
162
  //#region ../../internals/utils/src/casing.ts
159
163
  /**
@@ -1180,6 +1184,59 @@ function extractStringsFromNodes(nodes) {
1180
1184
  }).filter(Boolean).join("\n");
1181
1185
  }
1182
1186
  /**
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
+ /**
1183
1240
  * Resolves the schema name of a ref node, falling back through `ref` → `name` → nested `schema.name`.
1184
1241
  *
1185
1242
  * Returns `null` for non-ref nodes or when no name can be resolved. Use this to get a schema's
@@ -2666,6 +2723,6 @@ function setEnumName(propNode, parentName, propName, enumSuffix) {
2666
2723
  return propNode;
2667
2724
  }
2668
2725
  //#endregion
2669
- export { applyDedupe, buildDedupePlan, 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, schemaSignature, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, update, walk };
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 };
2670
2727
 
2671
2728
  //# sourceMappingURL=index.js.map