@kubb/ast 5.0.0-beta.97 → 5.0.0-beta.99
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.cjs +0 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -61
- package/dist/index.js +1 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -183,65 +183,6 @@ declare function containsCircularRef(node: SchemaNode | undefined, { circularSch
|
|
|
183
183
|
excludeName?: string;
|
|
184
184
|
}): boolean;
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region src/utils/schemaTraversal.d.ts
|
|
187
|
-
/**
|
|
188
|
-
* Converts a child schema to printer output. Plugins instantiate it with their own output type:
|
|
189
|
-
* `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's
|
|
190
|
-
* `this.transform` fits directly, so its `null` for an empty result carries through to `output`.
|
|
191
|
-
*/
|
|
192
|
-
type SchemaTransform<TOutput> = (schema: SchemaNode) => TOutput;
|
|
193
|
-
/**
|
|
194
|
-
* A union or intersection member, or an array or tuple item, paired with its transformed output.
|
|
195
|
-
*/
|
|
196
|
-
type MappedSchema<TOutput> = {
|
|
197
|
-
/**
|
|
198
|
-
* The original child schema, kept so the printer can read its metadata for leaf formatting.
|
|
199
|
-
*/
|
|
200
|
-
schema: SchemaNode;
|
|
201
|
-
/**
|
|
202
|
-
* The child schema after being run through the transform.
|
|
203
|
-
*/
|
|
204
|
-
output: TOutput;
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* An object property paired with its transformed output.
|
|
208
|
-
*/
|
|
209
|
-
type MappedProperty<TOutput> = {
|
|
210
|
-
/**
|
|
211
|
-
* The property name as written on the schema, before any identifier quoting.
|
|
212
|
-
*/
|
|
213
|
-
name: string;
|
|
214
|
-
/**
|
|
215
|
-
* The original property node, kept so the printer can read `required`, `schema`, and metadata.
|
|
216
|
-
*/
|
|
217
|
-
property: PropertyNode;
|
|
218
|
-
/**
|
|
219
|
-
* The property schema after being run through the transform.
|
|
220
|
-
*/
|
|
221
|
-
output: TOutput;
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Maps each property of an object schema to its transformed output. Pairs every result with the
|
|
225
|
-
* original property so the printer keeps full control over modifiers, getters, and key syntax.
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```ts
|
|
229
|
-
* const entries = mapSchemaProperties(node, (schema) => this.transform(schema))
|
|
230
|
-
* // entries: [{ name: 'id', property, output: 'z.number()' }, ...]
|
|
231
|
-
* ```
|
|
232
|
-
*/
|
|
233
|
-
declare function mapSchemaProperties<TOutput>(node: ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>>;
|
|
234
|
-
/**
|
|
235
|
-
* Maps each member of a union or intersection schema to its transformed output, pairing every
|
|
236
|
-
* result with the original member.
|
|
237
|
-
*/
|
|
238
|
-
declare function mapSchemaMembers<TOutput>(node: UnionSchemaNode | IntersectionSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>>;
|
|
239
|
-
/**
|
|
240
|
-
* Maps each item of an array or tuple schema to its transformed output, pairing every result with
|
|
241
|
-
* the original item.
|
|
242
|
-
*/
|
|
243
|
-
declare function mapSchemaItems<TOutput>(node: ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>>;
|
|
244
|
-
//#endregion
|
|
245
186
|
//#region src/macros/macroDiscriminatorEnum.d.ts
|
|
246
187
|
type Props$2 = {
|
|
247
188
|
propertyName: string;
|
|
@@ -399,8 +340,8 @@ declare const nodeDefs: (NodeDef<InputNode, Partial<Omit<InputNode, "kind">>> |
|
|
|
399
340
|
type: "ipv6";
|
|
400
341
|
}) | ScalarSchemaNode, "kind">> | NodeDef<PropertyNode, UserPropertyNode> | NodeDef<ParameterNode, Pick<ParameterNode, "schema" | "name" | "in"> & Partial<Omit<ParameterNode, "schema" | "kind" | "name" | "in">>> | NodeDef<ConstNode, Omit<ConstNode, "kind">> | NodeDef<TypeNode, Omit<TypeNode, "kind">> | NodeDef<FunctionNode, Omit<FunctionNode, "kind">> | NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNode, "kind">> | NodeDef<TextNode, string> | NodeDef<BreakNode, void> | NodeDef<JsxNode, string> | NodeDef<ImportNode, Omit<ImportNode, "kind">> | NodeDef<ExportNode, Omit<ExportNode, "kind">> | NodeDef<SourceNode, Omit<SourceNode, "kind">> | NodeDef<FileNode<object>, Omit<FileNode<object>, "kind">>)[];
|
|
401
342
|
declare namespace exports_d_exports {
|
|
402
|
-
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateSchemaNode, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InferSchemaNode, InputMeta, InputNode, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeDef, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, OutputNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, arrowFunctionDef, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion,
|
|
343
|
+
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateSchemaNode, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InferSchemaNode, InputMeta, InputNode, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeDef, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, OutputNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, arrowFunctionDef, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, mergeAdjacentObjectsLazy, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, syncSchemaRef, textDef, transform, typeDef };
|
|
403
344
|
}
|
|
404
345
|
//#endregion
|
|
405
|
-
export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateSchemaNode, type DatetimeSchemaNode, type DistributiveOmit, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeDef, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OutputNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, applyMacros, arrowFunctionDef, exports_d_exports as ast, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion,
|
|
346
|
+
export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateSchemaNode, type DatetimeSchemaNode, type DistributiveOmit, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeDef, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OutputNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, applyMacros, arrowFunctionDef, exports_d_exports as ast, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, mergeAdjacentObjectsLazy, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, syncSchemaRef, textDef, transform, typeDef };
|
|
406
347
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1597,45 +1597,6 @@ function containsCircularRef(node, { circularSchemas, excludeName }) {
|
|
|
1597
1597
|
return false;
|
|
1598
1598
|
}
|
|
1599
1599
|
//#endregion
|
|
1600
|
-
//#region src/utils/schemaTraversal.ts
|
|
1601
|
-
/**
|
|
1602
|
-
* Maps each property of an object schema to its transformed output. Pairs every result with the
|
|
1603
|
-
* original property so the printer keeps full control over modifiers, getters, and key syntax.
|
|
1604
|
-
*
|
|
1605
|
-
* @example
|
|
1606
|
-
* ```ts
|
|
1607
|
-
* const entries = mapSchemaProperties(node, (schema) => this.transform(schema))
|
|
1608
|
-
* // entries: [{ name: 'id', property, output: 'z.number()' }, ...]
|
|
1609
|
-
* ```
|
|
1610
|
-
*/
|
|
1611
|
-
function mapSchemaProperties(node, transform) {
|
|
1612
|
-
return node.properties.map((property) => ({
|
|
1613
|
-
name: property.name,
|
|
1614
|
-
property,
|
|
1615
|
-
output: transform(property.schema)
|
|
1616
|
-
}));
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Maps each member of a union or intersection schema to its transformed output, pairing every
|
|
1620
|
-
* result with the original member.
|
|
1621
|
-
*/
|
|
1622
|
-
function mapSchemaMembers(node, transform) {
|
|
1623
|
-
return (node.members ?? []).map((schema) => ({
|
|
1624
|
-
schema,
|
|
1625
|
-
output: transform(schema)
|
|
1626
|
-
}));
|
|
1627
|
-
}
|
|
1628
|
-
/**
|
|
1629
|
-
* Maps each item of an array or tuple schema to its transformed output, pairing every result with
|
|
1630
|
-
* the original item.
|
|
1631
|
-
*/
|
|
1632
|
-
function mapSchemaItems(node, transform) {
|
|
1633
|
-
return (node.items ?? []).map((schema) => ({
|
|
1634
|
-
schema,
|
|
1635
|
-
output: transform(schema)
|
|
1636
|
-
}));
|
|
1637
|
-
}
|
|
1638
|
-
//#endregion
|
|
1639
1600
|
//#region src/macros/macroDiscriminatorEnum.ts
|
|
1640
1601
|
/**
|
|
1641
1602
|
* Builds a macro that replaces a discriminator property's schema with a string enum of the given
|
|
@@ -1870,9 +1831,6 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
1870
1831
|
macroEnumName: () => macroEnumName,
|
|
1871
1832
|
macroRenameSchema: () => macroRenameSchema,
|
|
1872
1833
|
macroSimplifyUnion: () => macroSimplifyUnion,
|
|
1873
|
-
mapSchemaItems: () => mapSchemaItems,
|
|
1874
|
-
mapSchemaMembers: () => mapSchemaMembers,
|
|
1875
|
-
mapSchemaProperties: () => mapSchemaProperties,
|
|
1876
1834
|
mergeAdjacentObjectsLazy: () => mergeAdjacentObjectsLazy,
|
|
1877
1835
|
narrowSchema: () => narrowSchema,
|
|
1878
1836
|
nodeDefs: () => nodeDefs,
|
|
@@ -1893,6 +1851,6 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
1893
1851
|
typeDef: () => typeDef
|
|
1894
1852
|
});
|
|
1895
1853
|
//#endregion
|
|
1896
|
-
export { applyMacros, arrowFunctionDef, exports_exports as ast, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion,
|
|
1854
|
+
export { applyMacros, arrowFunctionDef, exports_exports as ast, breakDef, childName, collect, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, containsCircularRef, contentDef, createPrinter, defineMacro, defineNode, enumPropName, exportDef, extractRefName, extractStringsFromNodes, factory_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, isStringType, jsxDef, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, mergeAdjacentObjectsLazy, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, syncSchemaRef, textDef, transform, typeDef };
|
|
1897
1855
|
|
|
1898
1856
|
//# sourceMappingURL=index.js.map
|