🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@kubb/ast

Package Overview
Dependencies
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubb/ast - npm Package Compare versions

Comparing version
5.0.0-beta.99
to
5.0.0-beta.100
dist/types-DK2c0yY4.d.ts

Sorry, the diff of this file is too big to display

+13
-339

@@ -366,29 +366,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });

//#endregion
//#region ../../internals/utils/src/casing.ts
/**
* Shared implementation for camelCase and PascalCase conversion.
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
* and capitalizes each word according to `pascal`.
*
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
*/
function toCamelOrPascal(text, pascal) {
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) => {
if (word.length > 1 && word === word.toUpperCase()) return word;
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
}).join("").replace(/[^a-zA-Z0-9]/g, "");
}
/**
* Converts `text` to PascalCase.
*
* @example Word boundaries
* `pascalCase('hello-world') // 'HelloWorld'`
*
* @example With a suffix
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
*/
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
}
//#endregion
//#region ../../internals/utils/src/fs.ts

@@ -1101,5 +1074,5 @@ /**

*
* Shared by `transform` and `collectLazy` so node-kind dispatch lives in one place.
* Shared by `transform` and `collect` so node-kind dispatch lives in one place.
* `TResult` is the caller's expected return: the same node type for `transform`,
* the collected value type for `collectLazy`.
* the collected value type for `collect`.
*/

@@ -1162,3 +1135,3 @@ function applyVisitor(node, visitor, parent) {

* Lazy depth-first collection pass. Yields every non-null value returned by
* the visitor callbacks. Use `collect` for the eager array form.
* the visitor callbacks. Use `collectSync` for the eager array form.
*

@@ -1168,3 +1141,3 @@ * @example Collect every operationId

* const ids: string[] = []
* for (const id of collectLazy<string>(root, {
* for (const id of collect<string>(root, {
* operation(node) {

@@ -1178,3 +1151,3 @@ * return node.operationId

*/
function* collectLazy(node, options) {
function* collect(node, options) {
const { depth, parent, ...visitor } = options;

@@ -1194,3 +1167,3 @@ yield* collectNode(node, visitor, (depth ?? visitorDepths.deep) === visitorDepths.deep, parent);

* ```ts
* const ids = collect<string>(root, {
* const ids = collectSync<string>(root, {
* operation(node) {

@@ -1202,4 +1175,4 @@ * return node.operationId

*/
function collect(node, options) {
return Array.from(collectLazy(node, options));
function collectSync(node, options) {
return Array.from(collect(node, options));
}

@@ -1371,51 +1344,4 @@ //#endregion

//#endregion
//#region src/utils/mergeAdjacentSchemas.ts
/**
* Merges a run of adjacent anonymous object members into one. Named or non-object members break the
* run and pass through unchanged. The merge follows member order, so callers control which members
* combine by where they place them in the sequence.
*
* @example
* ```ts
* const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
* ```
*/
function* mergeAdjacentObjectsLazy(members) {
let acc;
for (const member of members) {
const objectMember = narrowSchema(member, "object");
if (objectMember && !objectMember.name && acc !== void 0) {
const accObject = narrowSchema(acc, "object");
if (accObject && !accObject.name) {
acc = createSchema({
...accObject,
properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
});
continue;
}
}
if (acc !== void 0) yield acc;
acc = member;
}
if (acc !== void 0) yield acc;
}
//#endregion
//#region src/utils/refs.ts
const plainStringTypes = /* @__PURE__ */ new Set([
"string",
"uuid",
"email",
"url",
"datetime"
]);
/**
* Returns the last path segment of a reference string.
*
* @example
* `extractRefName('#/components/schemas/Pet') // 'Pet'`
*/
function extractRefName(ref) {
return ref.split("/").at(-1) ?? ref;
}
/**
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when

@@ -1436,69 +1362,5 @@ * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,

if (node.targetName) return node.targetName;
if (node.ref) return extractRefName(node.ref);
if (node.ref) return node.ref.split("/").at(-1) ?? node.ref;
return node.name ?? node.schema?.name ?? null;
}
/**
* Builds a PascalCase child schema name by joining a parent name and property name.
* Returns `null` when there is no parent to nest under.
*
* @example Nested under a parent
* `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
*
* @example No parent
* `childName(undefined, 'params') // null`
*/
function childName(parentName, propName) {
return parentName ? pascalCase([parentName, propName].join(" ")) : null;
}
/**
* Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
* empty parts.
*
* @example
* `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
*/
function enumPropName(parentName, propName, enumSuffix) {
return pascalCase([
parentName,
propName,
enumSuffix
].filter(Boolean).join(" "));
}
/**
* Merges a ref node with its resolved schema, giving usage-site fields precedence.
*
* Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
* same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
* `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
* nodes and refs without a resolved `schema` are returned unchanged.
*
* @example
* ```ts
* const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
* const merged = syncSchemaRef(ref) // merges with resolved Pet schema
* ```
*/
function syncSchemaRef(node) {
const ref = narrowSchema(node, "ref");
if (!ref) return node;
if (!ref.schema) return node;
const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
return createSchema({
...ref.schema,
...definedOverrides
});
}
/**
* Returns `true` when a schema emits as a plain `string` type.
*
* Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
* types, returns `true` only when `representation` is `'string'` rather than `'date'`.
*/
function isStringType(node) {
if (plainStringTypes.has(node.type)) return true;
const temporal = narrowSchema(node, "date") ?? narrowSchema(node, "time");
if (temporal) return temporal.representation !== "date";
return false;
}
//#endregion

@@ -1511,3 +1373,3 @@ //#region src/utils/schemaGraph.ts

const refs = /* @__PURE__ */ new Set();
collect(node, { schema(child) {
collectSync(node, { schema(child) {
if (child.type === "ref") {

@@ -1557,3 +1419,3 @@ const name = resolveRefName(child);

}
for (const op of operations) for (const schema of collectLazy(op, {
for (const op of operations) for (const schema of collect(op, {
depth: "shallow",

@@ -1625,171 +1487,3 @@ schema: (node) => node

}
/**
* Returns `true` when a schema, or anything nested inside it, references a circular schema.
*
* Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
* on their own. Pair it with `findCircularSchemas()` to decide where lazy wrappers go.
*
* @note Stops at the first matching circular ref.
*/
function containsCircularRef(node, { circularSchemas, excludeName }) {
if (!node || circularSchemas.size === 0) return false;
for (const _ of collectLazy(node, { schema(child) {
if (child.type !== "ref") return null;
const name = resolveRefName(child);
return name && name !== excludeName && circularSchemas.has(name) ? true : null;
} })) return true;
return false;
}
//#endregion
//#region src/macros/macroDiscriminatorEnum.ts
/**
* Builds a macro that replaces a discriminator property's schema with a string enum of the given
* values. Object schemas that lack the property are returned unchanged.
*
* @example
* ```ts
* const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
* const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
* ```
*/
function macroDiscriminatorEnum({ propertyName, values, enumName }) {
return defineMacro({
name: "discriminator-enum",
schema(node) {
const objectNode = narrowSchema(node, "object");
if (!objectNode?.properties?.length) return void 0;
if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
return createSchema({
...objectNode,
properties: objectNode.properties.map((prop) => {
if (prop.name !== propertyName) return prop;
return createProperty({
...prop,
schema: createSchema({
type: "enum",
primitive: "string",
enumValues: values,
name: enumName,
readOnly: prop.schema.readOnly,
writeOnly: prop.schema.writeOnly
})
});
})
});
}
});
}
//#endregion
//#region src/macros/macroEnumName.ts
/**
* Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
* are left anonymous. Non-enum nodes are returned unchanged.
*
* @example
* ```ts
* const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
* const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
* ```
*/
function macroEnumName({ parentName, propName, enumSuffix }) {
return defineMacro({
name: "enum-name",
schema(node) {
const enumNode = narrowSchema(node, "enum");
if (enumNode?.primitive === "boolean") return {
...node,
name: null
};
if (enumNode) return {
...node,
name: enumPropName(parentName, propName, enumSuffix)
};
}
});
}
//#endregion
//#region src/macros/macroRenameSchema.ts
/**
* Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
* pointing at it (`targetName`) change together, so imports and printed references stay in
* sync. Renaming only one side by hand produces imports for files that are never generated.
*
* @example
* `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
*/
function macroRenameSchema({ from, to }) {
return defineMacro({
name: "rename-schema",
schema(node) {
const refNode = narrowSchema(node, "ref");
if (!refNode) return node.name === from ? {
...node,
name: to
} : void 0;
const renamesDeclaration = refNode.name === from;
const renamesTarget = resolveRefName(refNode) === from;
if (!renamesDeclaration && !renamesTarget) return void 0;
return {
...refNode,
...renamesDeclaration ? { name: to } : {},
...renamesTarget ? { targetName: to } : {}
};
}
});
}
//#endregion
//#region src/macros/macroSimplifyUnion.ts
/**
* Scalar primitive schema types used for union simplification and type narrowing.
*/
const SCALAR_PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
"string",
"number",
"integer",
"bigint",
"boolean"
]);
function isScalarPrimitive(type) {
return SCALAR_PRIMITIVE_TYPES.has(type);
}
/**
* Filters union members, dropping enum members that a broader scalar primitive already covers.
*/
function simplifyUnionMembers(members) {
const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
if (!scalarPrimitives.size) return members;
return members.filter((member) => {
const enumNode = narrowSchema(member, "enum");
if (!enumNode) return true;
const primitive = enumNode.primitive;
if (!primitive) return true;
if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
if (scalarPrimitives.has(primitive)) return false;
if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
return true;
});
}
/**
* Removes union members a broader scalar primitive already covers, such as a multi-value string enum
* sitting next to a plain `string`. Single-value enums are kept.
*
* @example
* ```ts
* const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
* ```
*/
const macroSimplifyUnion = defineMacro({
name: "simplify-union",
schema(node) {
const unionNode = narrowSchema(node, "union");
if (!unionNode?.members?.length) return void 0;
const simplified = simplifyUnionMembers(unionNode.members);
if (simplified.length === unionNode.members.length) return void 0;
return {
...unionNode,
members: simplified
};
}
});
//#endregion
//#region src/factory.ts

@@ -1848,4 +1542,4 @@ var factory_exports = /* @__PURE__ */ __exportAll({

breakDef: () => breakDef,
childName: () => childName,
collect: () => collect,
collectSync: () => collectSync,
collectUsedSchemaNames: () => collectUsedSchemaNames,

@@ -1857,3 +1551,2 @@ combineExports: () => combineExports,

constDef: () => constDef,
containsCircularRef: () => containsCircularRef,
contentDef: () => contentDef,

@@ -1863,5 +1556,3 @@ createPrinter: () => createPrinter,

defineNode: () => defineNode,
enumPropName: () => enumPropName,
exportDef: () => exportDef,
extractRefName: () => extractRefName,
extractStringsFromNodes: () => extractStringsFromNodes,

@@ -1875,9 +1566,3 @@ factory: () => factory_exports,

isHttpOperationNode: () => isHttpOperationNode,
isStringType: () => isStringType,
jsxDef: () => jsxDef,
macroDiscriminatorEnum: () => macroDiscriminatorEnum,
macroEnumName: () => macroEnumName,
macroRenameSchema: () => macroRenameSchema,
macroSimplifyUnion: () => macroSimplifyUnion,
mergeAdjacentObjectsLazy: () => mergeAdjacentObjectsLazy,
narrowSchema: () => narrowSchema,

@@ -1896,3 +1581,2 @@ nodeDefs: () => nodeDefs,

sourceDef: () => sourceDef,
syncSchemaRef: () => syncSchemaRef,
textDef: () => textDef,

@@ -1912,4 +1596,4 @@ transform: () => transform,

exports.breakDef = breakDef;
exports.childName = childName;
exports.collect = collect;
exports.collectSync = collectSync;
exports.collectUsedSchemaNames = collectUsedSchemaNames;

@@ -1921,3 +1605,2 @@ exports.combineExports = combineExports;

exports.constDef = constDef;
exports.containsCircularRef = containsCircularRef;
exports.contentDef = contentDef;

@@ -1927,5 +1610,3 @@ exports.createPrinter = createPrinter;

exports.defineNode = defineNode;
exports.enumPropName = enumPropName;
exports.exportDef = exportDef;
exports.extractRefName = extractRefName;
exports.extractStringsFromNodes = extractStringsFromNodes;

@@ -1944,9 +1625,3 @@ Object.defineProperty(exports, "factory", {

exports.isHttpOperationNode = isHttpOperationNode;
exports.isStringType = isStringType;
exports.jsxDef = jsxDef;
exports.macroDiscriminatorEnum = macroDiscriminatorEnum;
exports.macroEnumName = macroEnumName;
exports.macroRenameSchema = macroRenameSchema;
exports.macroSimplifyUnion = macroSimplifyUnion;
exports.mergeAdjacentObjectsLazy = mergeAdjacentObjectsLazy;
exports.narrowSchema = narrowSchema;

@@ -1965,3 +1640,2 @@ exports.nodeDefs = nodeDefs;

exports.sourceDef = sourceDef;
exports.syncSchemaRef = syncSchemaRef;
exports.textDef = textDef;

@@ -1968,0 +1642,0 @@ exports.transform = transform;

import { n as __name, t as __exportAll } from "./rolldown-runtime-CNktS9qV.js";
import { $ as sourceDef, $t as NodeDef, A as StatusCode, At as BreakNode, B as parameterDef, Bt as constDef, C as GenericOperationNode, Ct as PropertyNode, D as createOperation, Dt as InferSchemaNode, E as OperationNode, Et as propertyDef, F as requestBodyDef, Ft as JsxNode, G as UserFileNode, Gt as createJsx, H as FileNode, Ht as createBreak, I as ParameterLocation, It as TextNode, J as createImport, Jt as functionDef, K as createExport, Kt as createText, L as ParameterNode, Lt as TypeNode, M as responseDef, Mt as ConstNode, N as RequestBodyNode, Nt as FunctionNode, O as operationDef, Ot as ParserOptions, P as createRequestBody, Pt as JSDocNode, Q as importDef, Qt as DistributiveOmit, R as ParameterStyle, Rt as arrowFunctionDef, S as inputDef, St as schemaDef, T as HttpOperationNode, Tt as createProperty, U as ImportNode, Ut as createConst, V as ExportNode, Vt as createArrowFunction, W as SourceNode, Wt as createFunction, X as exportDef, Xt as textDef, Y as createSource, Yt as jsxDef, Z as fileDef, Zt as typeDef, _ as createOutput, _t as StringSchemaNode, a as Enforce, at as DatetimeSchemaNode, b as InputNode, bt as UrlSchemaNode, c as composeMacros, ct as NumberSchemaNode, d as Visitor, dt as RefSchemaNode, en as defineNode, et as ContentNode, f as VisitorContext, ft as ScalarSchemaNode, g as OutputNode, gt as SchemaType, h as Node, ht as SchemaNodeByType, i as createPrinter, it as DateSchemaNode, j as createResponse, jt as CodeNode, k as ResponseNode, kt as ArrowFunctionNode, l as defineMacro, lt as ObjectSchemaNode, m as transform, mt as SchemaNode, n as PrinterFactoryOptions, nn as NodeKind, nt as createContent, o as Macro, ot as EnumSchemaNode, p as collect, pt as ScalarSchemaType, q as createFile, qt as createType, r as PrinterPartial, rn as schemaTypes, rt as ArraySchemaNode, s as applyMacros, st as IntersectionSchemaNode, t as Printer, tn as BaseNode, tt as contentDef, u as ParentOf, ut as PrimitiveSchemaType, v as outputDef, vt as TimeSchemaNode, w as HttpMethod, wt as UserPropertyNode, x as createInput, xt as createSchema, y as InputMeta, yt as UnionSchemaNode, z as createParameter, zt as breakDef } from "./types-CqXMgUzC.js";
import { $ as importDef, $t as DistributiveOmit, A as ResponseNode, At as ArrowFunctionNode, B as createParameter, Bt as breakDef, C as inputDef, Ct as schemaDef, D as OperationNode, Dt as propertyDef, E as HttpOperationNode, Et as createProperty, F as createRequestBody, Ft as JSDocNode, G as SourceNode, Gt as createFunction, H as ExportNode, Ht as createArrowFunction, I as requestBodyDef, It as JsxNode, J as createFile, Jt as createType, K as UserFileNode, Kt as createJsx, L as ParameterLocation, Lt as TextNode, M as createResponse, Mt as CodeNode, N as responseDef, Nt as ConstNode, O as createOperation, Ot as InferSchemaNode, P as RequestBodyNode, Pt as FunctionNode, Q as fileDef, Qt as typeDef, R as ParameterNode, Rt as TypeNode, S as createInput, St as createSchema, T as HttpMethod, Tt as UserPropertyNode, U as FileNode, Ut as createBreak, V as parameterDef, Vt as constDef, W as ImportNode, Wt as createConst, X as createSource, Xt as jsxDef, Y as createImport, Yt as functionDef, Z as exportDef, Zt as textDef, _ as OutputNode, _t as SchemaType, a as Enforce, at as DateSchemaNode, b as InputMeta, bt as UnionSchemaNode, c as composeMacros, ct as IntersectionSchemaNode, d as Visitor, dt as PrimitiveSchemaType, en as NodeDef, et as sourceDef, f as VisitorContext, ft as RefSchemaNode, g as Node, gt as SchemaNodeByType, h as transform, ht as SchemaNode, i as createPrinter, in as schemaTypes, it as ArraySchemaNode, j as StatusCode, jt as BreakNode, k as operationDef, kt as ParserOptions, l as defineMacro, lt as NumberSchemaNode, m as collectSync, mt as ScalarSchemaType, n as PrinterFactoryOptions, nn as BaseNode, nt as contentDef, o as Macro, ot as DatetimeSchemaNode, p as collect, pt as ScalarSchemaNode, q as createExport, qt as createText, r as PrinterPartial, rn as NodeKind, rt as createContent, s as applyMacros, st as EnumSchemaNode, t as Printer, tn as defineNode, tt as ContentNode, u as ParentOf, ut as ObjectSchemaNode, v as createOutput, vt as StringSchemaNode, w as GenericOperationNode, wt as PropertyNode, x as InputNode, xt as UrlSchemaNode, y as outputDef, yt as TimeSchemaNode, z as ParameterStyle, zt as arrowFunctionDef } from "./types-DK2c0yY4.js";
//#region src/guards.d.ts

@@ -64,24 +64,4 @@ /**

//#endregion
//#region src/utils/mergeAdjacentSchemas.d.ts
/**
* Merges a run of adjacent anonymous object members into one. Named or non-object members break the
* run and pass through unchanged. The merge follows member order, so callers control which members
* combine by where they place them in the sequence.
*
* @example
* ```ts
* const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
* ```
*/
declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined>;
//#endregion
//#region src/utils/refs.d.ts
/**
* Returns the last path segment of a reference string.
*
* @example
* `extractRefName('#/components/schemas/Pet') // 'Pet'`
*/
declare function extractRefName(ref: string): string;
/**
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when

@@ -100,43 +80,2 @@ * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,

declare function resolveRefName(node: SchemaNode | null | undefined): string | null;
/**
* Builds a PascalCase child schema name by joining a parent name and property name.
* Returns `null` when there is no parent to nest under.
*
* @example Nested under a parent
* `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
*
* @example No parent
* `childName(undefined, 'params') // null`
*/
declare function childName(parentName: string | null | undefined, propName: string): string | null;
/**
* Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
* empty parts.
*
* @example
* `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
*/
declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
/**
* Merges a ref node with its resolved schema, giving usage-site fields precedence.
*
* Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
* same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
* `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
* nodes and refs without a resolved `schema` are returned unchanged.
*
* @example
* ```ts
* const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
* const merged = syncSchemaRef(ref) // merges with resolved Pet schema
* ```
*/
declare function syncSchemaRef(node: SchemaNode): SchemaNode;
/**
* Returns `true` when a schema emits as a plain `string` type.
*
* Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
* types, returns `true` only when `representation` is `'string'` rather than `'date'`.
*/
declare function isStringType(node: SchemaNode): boolean;
//#endregion

@@ -175,77 +114,2 @@ //#region src/utils/schemaGraph.d.ts

declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
/**
* Returns `true` when a schema, or anything nested inside it, references a circular schema.
*
* Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
* on their own. Pair it with `findCircularSchemas()` to decide where lazy wrappers go.
*
* @note Stops at the first matching circular ref.
*/
declare function containsCircularRef(node: SchemaNode | undefined, { circularSchemas, excludeName }: {
circularSchemas: ReadonlySet<string>;
excludeName?: string;
}): boolean;
//#endregion
//#region src/macros/macroDiscriminatorEnum.d.ts
type Props$2 = {
propertyName: string;
values: Array<string>;
enumName?: string;
};
/**
* Builds a macro that replaces a discriminator property's schema with a string enum of the given
* values. Object schemas that lack the property are returned unchanged.
*
* @example
* ```ts
* const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
* const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
* ```
*/
declare function macroDiscriminatorEnum({ propertyName, values, enumName }: Props$2): Macro;
//#endregion
//#region src/macros/macroEnumName.d.ts
type Props$1 = {
parentName: string | null | undefined;
propName: string;
enumSuffix: string;
};
/**
* Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
* are left anonymous. Non-enum nodes are returned unchanged.
*
* @example
* ```ts
* const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
* const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
* ```
*/
declare function macroEnumName({ parentName, propName, enumSuffix }: Props$1): Macro;
//#endregion
//#region src/macros/macroRenameSchema.d.ts
type Props = {
from: string;
to: string;
};
/**
* Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
* pointing at it (`targetName`) change together, so imports and printed references stay in
* sync. Renaming only one side by hand produces imports for files that are never generated.
*
* @example
* `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
*/
declare function macroRenameSchema({ from, to }: Props): Macro;
//#endregion
//#region src/macros/macroSimplifyUnion.d.ts
/**
* Removes union members a broader scalar primitive already covers, such as a multi-value string enum
* sitting next to a plain `string`. Single-value enums are kept.
*
* @example
* ```ts
* const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
* ```
*/
declare const macroSimplifyUnion: Macro;
declare namespace factory_d_exports {

@@ -346,6 +210,6 @@ export { UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, update };

declare namespace exports_d_exports {
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 };
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, collect, collectSync, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
}
//#endregion
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 };
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, collect, collectSync, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
//# sourceMappingURL=index.d.ts.map

@@ -334,29 +334,2 @@ import { t as __exportAll } from "./rolldown-runtime-CNktS9qV.js";

//#endregion
//#region ../../internals/utils/src/casing.ts
/**
* Shared implementation for camelCase and PascalCase conversion.
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
* and capitalizes each word according to `pascal`.
*
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
*/
function toCamelOrPascal(text, pascal) {
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) => {
if (word.length > 1 && word === word.toUpperCase()) return word;
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
}).join("").replace(/[^a-zA-Z0-9]/g, "");
}
/**
* Converts `text` to PascalCase.
*
* @example Word boundaries
* `pascalCase('hello-world') // 'HelloWorld'`
*
* @example With a suffix
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
*/
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
}
//#endregion
//#region ../../internals/utils/src/fs.ts

@@ -1069,5 +1042,5 @@ /**

*
* Shared by `transform` and `collectLazy` so node-kind dispatch lives in one place.
* Shared by `transform` and `collect` so node-kind dispatch lives in one place.
* `TResult` is the caller's expected return: the same node type for `transform`,
* the collected value type for `collectLazy`.
* the collected value type for `collect`.
*/

@@ -1130,3 +1103,3 @@ function applyVisitor(node, visitor, parent) {

* Lazy depth-first collection pass. Yields every non-null value returned by
* the visitor callbacks. Use `collect` for the eager array form.
* the visitor callbacks. Use `collectSync` for the eager array form.
*

@@ -1136,3 +1109,3 @@ * @example Collect every operationId

* const ids: string[] = []
* for (const id of collectLazy<string>(root, {
* for (const id of collect<string>(root, {
* operation(node) {

@@ -1146,3 +1119,3 @@ * return node.operationId

*/
function* collectLazy(node, options) {
function* collect(node, options) {
const { depth, parent, ...visitor } = options;

@@ -1162,3 +1135,3 @@ yield* collectNode(node, visitor, (depth ?? visitorDepths.deep) === visitorDepths.deep, parent);

* ```ts
* const ids = collect<string>(root, {
* const ids = collectSync<string>(root, {
* operation(node) {

@@ -1170,4 +1143,4 @@ * return node.operationId

*/
function collect(node, options) {
return Array.from(collectLazy(node, options));
function collectSync(node, options) {
return Array.from(collect(node, options));
}

@@ -1339,51 +1312,4 @@ //#endregion

//#endregion
//#region src/utils/mergeAdjacentSchemas.ts
/**
* Merges a run of adjacent anonymous object members into one. Named or non-object members break the
* run and pass through unchanged. The merge follows member order, so callers control which members
* combine by where they place them in the sequence.
*
* @example
* ```ts
* const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
* ```
*/
function* mergeAdjacentObjectsLazy(members) {
let acc;
for (const member of members) {
const objectMember = narrowSchema(member, "object");
if (objectMember && !objectMember.name && acc !== void 0) {
const accObject = narrowSchema(acc, "object");
if (accObject && !accObject.name) {
acc = createSchema({
...accObject,
properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
});
continue;
}
}
if (acc !== void 0) yield acc;
acc = member;
}
if (acc !== void 0) yield acc;
}
//#endregion
//#region src/utils/refs.ts
const plainStringTypes = /* @__PURE__ */ new Set([
"string",
"uuid",
"email",
"url",
"datetime"
]);
/**
* Returns the last path segment of a reference string.
*
* @example
* `extractRefName('#/components/schemas/Pet') // 'Pet'`
*/
function extractRefName(ref) {
return ref.split("/").at(-1) ?? ref;
}
/**
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when

@@ -1404,69 +1330,5 @@ * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,

if (node.targetName) return node.targetName;
if (node.ref) return extractRefName(node.ref);
if (node.ref) return node.ref.split("/").at(-1) ?? node.ref;
return node.name ?? node.schema?.name ?? null;
}
/**
* Builds a PascalCase child schema name by joining a parent name and property name.
* Returns `null` when there is no parent to nest under.
*
* @example Nested under a parent
* `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
*
* @example No parent
* `childName(undefined, 'params') // null`
*/
function childName(parentName, propName) {
return parentName ? pascalCase([parentName, propName].join(" ")) : null;
}
/**
* Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
* empty parts.
*
* @example
* `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
*/
function enumPropName(parentName, propName, enumSuffix) {
return pascalCase([
parentName,
propName,
enumSuffix
].filter(Boolean).join(" "));
}
/**
* Merges a ref node with its resolved schema, giving usage-site fields precedence.
*
* Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
* same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
* `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
* nodes and refs without a resolved `schema` are returned unchanged.
*
* @example
* ```ts
* const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
* const merged = syncSchemaRef(ref) // merges with resolved Pet schema
* ```
*/
function syncSchemaRef(node) {
const ref = narrowSchema(node, "ref");
if (!ref) return node;
if (!ref.schema) return node;
const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
return createSchema({
...ref.schema,
...definedOverrides
});
}
/**
* Returns `true` when a schema emits as a plain `string` type.
*
* Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
* types, returns `true` only when `representation` is `'string'` rather than `'date'`.
*/
function isStringType(node) {
if (plainStringTypes.has(node.type)) return true;
const temporal = narrowSchema(node, "date") ?? narrowSchema(node, "time");
if (temporal) return temporal.representation !== "date";
return false;
}
//#endregion

@@ -1479,3 +1341,3 @@ //#region src/utils/schemaGraph.ts

const refs = /* @__PURE__ */ new Set();
collect(node, { schema(child) {
collectSync(node, { schema(child) {
if (child.type === "ref") {

@@ -1525,3 +1387,3 @@ const name = resolveRefName(child);

}
for (const op of operations) for (const schema of collectLazy(op, {
for (const op of operations) for (const schema of collect(op, {
depth: "shallow",

@@ -1593,171 +1455,3 @@ schema: (node) => node

}
/**
* Returns `true` when a schema, or anything nested inside it, references a circular schema.
*
* Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
* on their own. Pair it with `findCircularSchemas()` to decide where lazy wrappers go.
*
* @note Stops at the first matching circular ref.
*/
function containsCircularRef(node, { circularSchemas, excludeName }) {
if (!node || circularSchemas.size === 0) return false;
for (const _ of collectLazy(node, { schema(child) {
if (child.type !== "ref") return null;
const name = resolveRefName(child);
return name && name !== excludeName && circularSchemas.has(name) ? true : null;
} })) return true;
return false;
}
//#endregion
//#region src/macros/macroDiscriminatorEnum.ts
/**
* Builds a macro that replaces a discriminator property's schema with a string enum of the given
* values. Object schemas that lack the property are returned unchanged.
*
* @example
* ```ts
* const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
* const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
* ```
*/
function macroDiscriminatorEnum({ propertyName, values, enumName }) {
return defineMacro({
name: "discriminator-enum",
schema(node) {
const objectNode = narrowSchema(node, "object");
if (!objectNode?.properties?.length) return void 0;
if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
return createSchema({
...objectNode,
properties: objectNode.properties.map((prop) => {
if (prop.name !== propertyName) return prop;
return createProperty({
...prop,
schema: createSchema({
type: "enum",
primitive: "string",
enumValues: values,
name: enumName,
readOnly: prop.schema.readOnly,
writeOnly: prop.schema.writeOnly
})
});
})
});
}
});
}
//#endregion
//#region src/macros/macroEnumName.ts
/**
* Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
* are left anonymous. Non-enum nodes are returned unchanged.
*
* @example
* ```ts
* const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
* const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
* ```
*/
function macroEnumName({ parentName, propName, enumSuffix }) {
return defineMacro({
name: "enum-name",
schema(node) {
const enumNode = narrowSchema(node, "enum");
if (enumNode?.primitive === "boolean") return {
...node,
name: null
};
if (enumNode) return {
...node,
name: enumPropName(parentName, propName, enumSuffix)
};
}
});
}
//#endregion
//#region src/macros/macroRenameSchema.ts
/**
* Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
* pointing at it (`targetName`) change together, so imports and printed references stay in
* sync. Renaming only one side by hand produces imports for files that are never generated.
*
* @example
* `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
*/
function macroRenameSchema({ from, to }) {
return defineMacro({
name: "rename-schema",
schema(node) {
const refNode = narrowSchema(node, "ref");
if (!refNode) return node.name === from ? {
...node,
name: to
} : void 0;
const renamesDeclaration = refNode.name === from;
const renamesTarget = resolveRefName(refNode) === from;
if (!renamesDeclaration && !renamesTarget) return void 0;
return {
...refNode,
...renamesDeclaration ? { name: to } : {},
...renamesTarget ? { targetName: to } : {}
};
}
});
}
//#endregion
//#region src/macros/macroSimplifyUnion.ts
/**
* Scalar primitive schema types used for union simplification and type narrowing.
*/
const SCALAR_PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
"string",
"number",
"integer",
"bigint",
"boolean"
]);
function isScalarPrimitive(type) {
return SCALAR_PRIMITIVE_TYPES.has(type);
}
/**
* Filters union members, dropping enum members that a broader scalar primitive already covers.
*/
function simplifyUnionMembers(members) {
const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
if (!scalarPrimitives.size) return members;
return members.filter((member) => {
const enumNode = narrowSchema(member, "enum");
if (!enumNode) return true;
const primitive = enumNode.primitive;
if (!primitive) return true;
if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
if (scalarPrimitives.has(primitive)) return false;
if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
return true;
});
}
/**
* Removes union members a broader scalar primitive already covers, such as a multi-value string enum
* sitting next to a plain `string`. Single-value enums are kept.
*
* @example
* ```ts
* const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
* ```
*/
const macroSimplifyUnion = defineMacro({
name: "simplify-union",
schema(node) {
const unionNode = narrowSchema(node, "union");
if (!unionNode?.members?.length) return void 0;
const simplified = simplifyUnionMembers(unionNode.members);
if (simplified.length === unionNode.members.length) return void 0;
return {
...unionNode,
members: simplified
};
}
});
//#endregion
//#region src/factory.ts

@@ -1816,4 +1510,4 @@ var factory_exports = /* @__PURE__ */ __exportAll({

breakDef: () => breakDef,
childName: () => childName,
collect: () => collect,
collectSync: () => collectSync,
collectUsedSchemaNames: () => collectUsedSchemaNames,

@@ -1825,3 +1519,2 @@ combineExports: () => combineExports,

constDef: () => constDef,
containsCircularRef: () => containsCircularRef,
contentDef: () => contentDef,

@@ -1831,5 +1524,3 @@ createPrinter: () => createPrinter,

defineNode: () => defineNode,
enumPropName: () => enumPropName,
exportDef: () => exportDef,
extractRefName: () => extractRefName,
extractStringsFromNodes: () => extractStringsFromNodes,

@@ -1843,9 +1534,3 @@ factory: () => factory_exports,

isHttpOperationNode: () => isHttpOperationNode,
isStringType: () => isStringType,
jsxDef: () => jsxDef,
macroDiscriminatorEnum: () => macroDiscriminatorEnum,
macroEnumName: () => macroEnumName,
macroRenameSchema: () => macroRenameSchema,
macroSimplifyUnion: () => macroSimplifyUnion,
mergeAdjacentObjectsLazy: () => mergeAdjacentObjectsLazy,
narrowSchema: () => narrowSchema,

@@ -1864,3 +1549,2 @@ nodeDefs: () => nodeDefs,

sourceDef: () => sourceDef,
syncSchemaRef: () => syncSchemaRef,
textDef: () => textDef,

@@ -1871,4 +1555,4 @@ transform: () => transform,

//#endregion
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 };
export { applyMacros, arrowFunctionDef, exports_exports as ast, breakDef, collect, collectSync, collectUsedSchemaNames, combineExports, combineImports, combineSources, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_exports as factory, fileDef, findCircularSchemas, functionDef, importDef, inputDef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { $t as NodeDef, A as StatusCode, At as BreakNode, C as GenericOperationNode, Ct as PropertyNode, Dt as InferSchemaNode, E as OperationNode, Ft as JsxNode, G as UserFileNode, H as FileNode, I as ParameterLocation, It as TextNode, L as ParameterNode, Lt as TypeNode, Mt as ConstNode, N as RequestBodyNode, Nt as FunctionNode, Ot as ParserOptions, Pt as JSDocNode, Qt as DistributiveOmit, R as ParameterStyle, T as HttpOperationNode, U as ImportNode, V as ExportNode, W as SourceNode, _t as StringSchemaNode, a as Enforce, at as DatetimeSchemaNode, b as InputNode, bt as UrlSchemaNode, ct as NumberSchemaNode, d as Visitor, dt as RefSchemaNode, et as ContentNode, f as VisitorContext, ft as ScalarSchemaNode, g as OutputNode, gt as SchemaType, h as Node, ht as SchemaNodeByType, it as DateSchemaNode, jt as CodeNode, k as ResponseNode, kt as ArrowFunctionNode, lt as ObjectSchemaNode, mt as SchemaNode, n as PrinterFactoryOptions, nn as NodeKind, o as Macro, ot as EnumSchemaNode, pt as ScalarSchemaType, r as PrinterPartial, rt as ArraySchemaNode, st as IntersectionSchemaNode, t as Printer, u as ParentOf, ut as PrimitiveSchemaType, vt as TimeSchemaNode, w as HttpMethod, y as InputMeta, yt as UnionSchemaNode } from "./types-CqXMgUzC.js";
import { $t as DistributiveOmit, A as ResponseNode, At as ArrowFunctionNode, D as OperationNode, E as HttpOperationNode, Ft as JSDocNode, G as SourceNode, H as ExportNode, It as JsxNode, K as UserFileNode, L as ParameterLocation, Lt as TextNode, Mt as CodeNode, Nt as ConstNode, Ot as InferSchemaNode, P as RequestBodyNode, Pt as FunctionNode, R as ParameterNode, Rt as TypeNode, T as HttpMethod, U as FileNode, W as ImportNode, _ as OutputNode, _t as SchemaType, a as Enforce, at as DateSchemaNode, b as InputMeta, bt as UnionSchemaNode, ct as IntersectionSchemaNode, d as Visitor, dt as PrimitiveSchemaType, en as NodeDef, f as VisitorContext, ft as RefSchemaNode, g as Node, gt as SchemaNodeByType, ht as SchemaNode, it as ArraySchemaNode, j as StatusCode, jt as BreakNode, kt as ParserOptions, lt as NumberSchemaNode, mt as ScalarSchemaType, n as PrinterFactoryOptions, o as Macro, ot as DatetimeSchemaNode, pt as ScalarSchemaNode, r as PrinterPartial, rn as NodeKind, st as EnumSchemaNode, t as Printer, tt as ContentNode, u as ParentOf, ut as ObjectSchemaNode, vt as StringSchemaNode, w as GenericOperationNode, wt as PropertyNode, x as InputNode, xt as UrlSchemaNode, yt as TimeSchemaNode, z as ParameterStyle } from "./types-DK2c0yY4.js";
export type { 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 };
{
"name": "@kubb/ast",
"version": "5.0.0-beta.99",
"version": "5.0.0-beta.100",
"description": "Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -33,3 +33,3 @@ <div align="center">

| ------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `@kubb/ast` | Runtime: node definitions, guards, visitor, macro engine, string and ref helpers, constants |
| `@kubb/ast` | Runtime: node definitions, guards, visitor, macro engine, constants |
| `ast.factory` (via `@kubb/ast`) | Node constructors (`createSchema`, `createFile`, and friends), the `ts.factory` analogue |

@@ -41,4 +41,2 @@ | `@kubb/ast/types` | Types only: all node interfaces, type aliases, visitor types |

The macro presets (`macroDiscriminatorEnum`, `macroSimplifyUnion`, `macroEnumName`) and the string, identifier, and ref helpers live on the root `@kubb/ast` export. They no longer ship as separate `@kubb/ast/macros` and `@kubb/ast/utils` subpaths.
## Node tree

@@ -99,11 +97,4 @@

```ts
import { walk, transform, collect } from '@kubb/ast'
import { collectSync, transform } from '@kubb/ast'
// Side effects
await walk(root, {
schema(node) {
console.log(node.type)
},
})
// Immutable transformation

@@ -117,3 +108,3 @@ const updated = transform(root, {

// Extraction
const types = collect<string>(root, {
const types = collectSync<string>(root, {
schema(node) {

@@ -142,5 +133,5 @@ return node.type

```ts
import { extractRefName } from '@kubb/ast'
import { resolveRefName } from '@kubb/ast'
extractRefName('#/components/schemas/Pet') // 'Pet'
resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'
```

@@ -147,0 +138,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display