@kubb/ast 5.0.0-beta.91 → 5.0.0-beta.94

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.
@@ -4,8 +4,9 @@ import { n as __name } from "./rolldown-runtime-CNktS9qV.js";
4
4
  /**
5
5
  * Traversal depth for AST visitor utilities.
6
6
  *
7
- * - `'shallow'` visits only the immediate node, skipping children.
8
- * - `'deep'` recursively visits all descendant nodes.
7
+ * - `'shallow'` recurses through every node except nested `Schema` subtrees, which it treats as
8
+ * leaves: a schema node itself is visited, but its children are not.
9
+ * - `'deep'` recursively visits all descendant nodes, including schema subtrees.
9
10
  */
10
11
  type VisitorDepth = 'shallow' | 'deep';
11
12
  /**
@@ -120,68 +121,6 @@ declare const schemaTypes: {
120
121
  readonly never: "never";
121
122
  };
122
123
  //#endregion
123
- //#region src/defineDialect.d.ts
124
- /**
125
- * The spec-specific questions a schema parser answers while turning a source document into Kubb
126
- * AST nodes. The rest of the pipeline is generic, so this is the one seam where source formats
127
- * differ.
128
- */
129
- type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
130
- /**
131
- * Whether the schema is nullable.
132
- */
133
- isNullable(schema?: TSchema): boolean;
134
- /**
135
- * Whether the value is a `$ref` pointer.
136
- */
137
- isReference(value?: unknown): value is TRef;
138
- /**
139
- * Whether the schema carries a discriminator for polymorphism.
140
- */
141
- isDiscriminator(value?: unknown): value is TDiscriminated;
142
- /**
143
- * Whether the schema is binary data, converted to a `blob` node.
144
- */
145
- isBinary(schema: TSchema): boolean;
146
- /**
147
- * Resolves a local `$ref` against the document, or nullish when it cannot.
148
- */
149
- resolveRef<TResolved>(document: TDocument, ref: string): TResolved | null | undefined;
150
- };
151
- /**
152
- * A spec adapter's dialect. `name` identifies it in logs and diagnostics, and `schema` holds the
153
- * spec-specific schema questions the parser answers.
154
- */
155
- type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
156
- /**
157
- * Identifies the dialect in logs and diagnostics.
158
- */
159
- name: string;
160
- /**
161
- * The spec-specific schema behavior. See {@link SchemaDialect}.
162
- */
163
- schema: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>;
164
- };
165
- /**
166
- * Types a {@link Dialect} for an adapter. Adds no runtime behavior and only pins the
167
- * dialect's type for inference.
168
- *
169
- * @example
170
- * ```ts
171
- * export const oasDialect = defineDialect({
172
- * name: 'oas',
173
- * schema: {
174
- * isNullable,
175
- * isReference,
176
- * isDiscriminator,
177
- * isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',
178
- * resolveRef,
179
- * },
180
- * })
181
- * ```
182
- */
183
- declare function defineDialect<TSchema, TRef, TDiscriminated, TDocument>(dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument>): Dialect<TSchema, TRef, TDiscriminated, TDocument>;
184
- //#endregion
185
124
  //#region src/nodes/base.d.ts
186
125
  /**
187
126
  * `kind` values used by AST nodes.
@@ -384,7 +323,7 @@ type TypeNode = BaseNode & {
384
323
  *
385
324
  * @example
386
325
  * ```ts
387
- * createFunctionDeclaration({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
326
+ * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
388
327
  * // export async function getPet(): Promise<Pet> { ... }
389
328
  * ```
390
329
  */
@@ -445,7 +384,7 @@ type FunctionNode = BaseNode & {
445
384
  *
446
385
  * @example
447
386
  * ```ts
448
- * createArrowFunctionDeclaration({ name: 'getPet', export: true, singleLine: true })
387
+ * createArrowFunction({ name: 'getPet', export: true, singleLine: true })
449
388
  * // export const getPet = () => ...
450
389
  * ```
451
390
  */
@@ -886,7 +825,7 @@ type SchemaType = PrimitiveSchemaType | ComplexSchemaType | SpecialSchemaType;
886
825
  /**
887
826
  * Scalar schema types without extra object/array/ref structure.
888
827
  */
889
- type ScalarSchemaType = Exclude<SchemaType, 'object' | 'array' | 'tuple' | 'union' | 'intersection' | 'enum' | 'ref' | 'datetime' | 'date' | 'time' | 'string' | 'number' | 'integer' | 'bigint' | 'url' | 'uuid' | 'email'>;
828
+ type ScalarSchemaType = Exclude<SchemaType, 'object' | 'array' | 'tuple' | 'union' | 'intersection' | 'enum' | 'ref' | 'datetime' | 'date' | 'time' | 'string' | 'number' | 'integer' | 'bigint' | 'url' | 'uuid' | 'email' | 'ipv4' | 'ipv6'>;
890
829
  /**
891
830
  * Fields shared by all schema nodes.
892
831
  */
@@ -2330,7 +2269,7 @@ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): Ou
2330
2269
  * }
2331
2270
  * ```
2332
2271
  */
2333
- type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode;
2272
+ type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
2334
2273
  //#endregion
2335
2274
  //#region src/visitor.d.ts
2336
2275
  /**
@@ -2616,6 +2555,7 @@ declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyAr
2616
2555
  * const context: PrinterHandlerContext<string, {}> = {
2617
2556
  * options: {},
2618
2557
  * transform: () => 'value',
2558
+ * base: () => 'value',
2619
2559
  * }
2620
2560
  * ```
2621
2561
  */
@@ -2797,5 +2737,5 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
2797
2737
  */
2798
2738
  declare function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
2799
2739
  //#endregion
2800
- export { sourceDef as $, NodeDef as $t, StatusCode as A, BreakNode as At, parameterDef as B, constDef as Bt, GenericOperationNode as C, PropertyNode as Ct, createOperation as D, InferSchemaNode as Dt, OperationNode as E, propertyDef as Et, requestBodyDef as F, JsxNode as Ft, UserFileNode as G, createJsx as Gt, FileNode as H, createBreak as Ht, ParameterLocation as I, TextNode as It, createImport as J, functionDef as Jt, createExport as K, createText as Kt, ParameterNode as L, TypeNode as Lt, responseDef as M, ConstNode as Mt, RequestBodyNode as N, FunctionNode as Nt, operationDef as O, ParserOptions as Ot, createRequestBody as P, JSDocNode as Pt, importDef as Q, DistributiveOmit as Qt, ParameterStyle as R, arrowFunctionDef as Rt, inputDef as S, schemaDef as St, HttpOperationNode as T, createProperty as Tt, ImportNode as U, createConst as Ut, ExportNode as V, createArrowFunction as Vt, SourceNode as W, createFunction as Wt, exportDef as X, textDef as Xt, createSource as Y, jsxDef as Yt, fileDef as Z, typeDef as Zt, createOutput as _, StringSchemaNode as _t, Enforce as a, defineDialect as an, DatetimeSchemaNode as at, InputNode as b, UrlSchemaNode as bt, composeMacros as c, NumberSchemaNode as ct, Visitor as d, RefSchemaNode as dt, defineNode as en, ContentNode as et, VisitorContext as f, ScalarSchemaNode as ft, OutputNode as g, SchemaType as gt, Node as h, SchemaNodeByType as ht, createPrinter as i, SchemaDialect as in, DateSchemaNode as it, createResponse as j, CodeNode as jt, ResponseNode as k, ArrowFunctionNode as kt, defineMacro as l, ObjectSchemaNode as lt, transform as m, SchemaNode as mt, PrinterFactoryOptions as n, NodeKind as nn, createContent as nt, Macro as o, schemaTypes as on, EnumSchemaNode as ot, collect as p, ScalarSchemaType as pt, createFile as q, createType as qt, PrinterPartial as r, Dialect as rn, ArraySchemaNode as rt, applyMacros as s, IntersectionSchemaNode as st, Printer as t, BaseNode as tn, contentDef as tt, ParentOf as u, PrimitiveSchemaType as ut, outputDef as v, TimeSchemaNode as vt, HttpMethod as w, UserPropertyNode as wt, createInput as x, createSchema as xt, InputMeta as y, UnionSchemaNode as yt, createParameter as z, breakDef as zt };
2801
- //# sourceMappingURL=types-D12-e8Av.d.ts.map
2740
+ export { sourceDef as $, NodeDef as $t, StatusCode as A, BreakNode as At, parameterDef as B, constDef as Bt, GenericOperationNode as C, PropertyNode as Ct, createOperation as D, InferSchemaNode as Dt, OperationNode as E, propertyDef as Et, requestBodyDef as F, JsxNode as Ft, UserFileNode as G, createJsx as Gt, FileNode as H, createBreak as Ht, ParameterLocation as I, TextNode as It, createImport as J, functionDef as Jt, createExport as K, createText as Kt, ParameterNode as L, TypeNode as Lt, responseDef as M, ConstNode as Mt, RequestBodyNode as N, FunctionNode as Nt, operationDef as O, ParserOptions as Ot, createRequestBody as P, JSDocNode as Pt, importDef as Q, DistributiveOmit as Qt, ParameterStyle as R, arrowFunctionDef as Rt, inputDef as S, schemaDef as St, HttpOperationNode as T, createProperty as Tt, ImportNode as U, createConst as Ut, ExportNode as V, createArrowFunction as Vt, SourceNode as W, createFunction as Wt, exportDef as X, textDef as Xt, createSource as Y, jsxDef as Yt, fileDef as Z, typeDef as Zt, createOutput as _, StringSchemaNode as _t, Enforce as a, DatetimeSchemaNode as at, InputNode as b, UrlSchemaNode as bt, composeMacros as c, NumberSchemaNode as ct, Visitor as d, RefSchemaNode as dt, defineNode as en, ContentNode as et, VisitorContext as f, ScalarSchemaNode as ft, OutputNode as g, SchemaType as gt, Node as h, SchemaNodeByType as ht, createPrinter as i, DateSchemaNode as it, createResponse as j, CodeNode as jt, ResponseNode as k, ArrowFunctionNode as kt, defineMacro as l, ObjectSchemaNode as lt, transform as m, SchemaNode as mt, PrinterFactoryOptions as n, NodeKind as nn, createContent as nt, Macro as o, EnumSchemaNode as ot, collect as p, ScalarSchemaType as pt, createFile as q, createType as qt, PrinterPartial as r, schemaTypes as rn, ArraySchemaNode as rt, applyMacros as s, IntersectionSchemaNode as st, Printer as t, BaseNode as tn, contentDef as tt, ParentOf as u, PrimitiveSchemaType as ut, outputDef as v, TimeSchemaNode as vt, HttpMethod as w, UserPropertyNode as wt, createInput as x, createSchema as xt, InputMeta as y, UnionSchemaNode as yt, createParameter as z, breakDef as zt };
2741
+ //# sourceMappingURL=types-CsAwiskn.d.ts.map
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- 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, in as SchemaDialect, 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, rn as Dialect, 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-D12-e8Av.js";
2
- export type { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateSchemaNode, DatetimeSchemaNode, Dialect, 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, SchemaDialect, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext };
1
+ 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-CsAwiskn.js";
2
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/ast",
3
- "version": "5.0.0-beta.91",
3
+ "version": "5.0.0-beta.94",
4
4
  "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
5
  "keywords": [
6
6
  "ast",
@@ -42,7 +42,7 @@
42
42
  "registry": "https://registry.npmjs.org/"
43
43
  },
44
44
  "devDependencies": {
45
- "@types/node": "^22.20.1",
45
+ "@types/node": "^22.20.0",
46
46
  "@internals/utils": "0.0.0"
47
47
  },
48
48
  "engines": {