@kubb/ast 5.0.0-beta.99 → 5.0.0
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/README.md +5 -14
- package/dist/index.cjs +88 -354
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +33 -155
- package/dist/index.js +85 -340
- package/dist/index.js.map +1 -1
- package/dist/{types-CqXMgUzC.d.ts → types-BPqinVNh.d.ts} +26 -9
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -2460,20 +2460,37 @@ declare function transform(node: PropertyNode, options: TransformOptions): Prope
|
|
|
2460
2460
|
declare function transform(node: ParameterNode, options: TransformOptions): ParameterNode;
|
|
2461
2461
|
declare function transform(node: ResponseNode, options: TransformOptions): ResponseNode;
|
|
2462
2462
|
declare function transform(node: Node, options: TransformOptions): Node;
|
|
2463
|
+
/**
|
|
2464
|
+
* Lazy depth-first collection pass. Yields every non-null value returned by
|
|
2465
|
+
* the visitor callbacks. Use `collectSync` for the eager array form.
|
|
2466
|
+
*
|
|
2467
|
+
* @example Collect every operationId
|
|
2468
|
+
* ```ts
|
|
2469
|
+
* const ids: string[] = []
|
|
2470
|
+
* for (const id of collect<string>(root, {
|
|
2471
|
+
* operation(node) {
|
|
2472
|
+
* return node.operationId
|
|
2473
|
+
* },
|
|
2474
|
+
* })) {
|
|
2475
|
+
* ids.push(id)
|
|
2476
|
+
* }
|
|
2477
|
+
* ```
|
|
2478
|
+
*/
|
|
2479
|
+
declare function collect<T>(node: Node, options: CollectOptions<T>): Generator<T, void, undefined>;
|
|
2463
2480
|
/**
|
|
2464
2481
|
* Eager depth-first collection pass. Gathers every non-null value the visitor
|
|
2465
2482
|
* callbacks return into an array.
|
|
2466
2483
|
*
|
|
2467
2484
|
* @example Collect every operationId
|
|
2468
2485
|
* ```ts
|
|
2469
|
-
* const ids =
|
|
2486
|
+
* const ids = collectSync<string>(root, {
|
|
2470
2487
|
* operation(node) {
|
|
2471
2488
|
* return node.operationId
|
|
2472
2489
|
* },
|
|
2473
2490
|
* })
|
|
2474
2491
|
* ```
|
|
2475
2492
|
*/
|
|
2476
|
-
declare function
|
|
2493
|
+
declare function collectSync<T>(node: Node, options: CollectOptions<T>): Array<T>;
|
|
2477
2494
|
//#endregion
|
|
2478
2495
|
//#region src/defineMacro.d.ts
|
|
2479
2496
|
/**
|
|
@@ -2484,8 +2501,8 @@ type Enforce = 'pre' | 'post';
|
|
|
2484
2501
|
/**
|
|
2485
2502
|
* A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
|
|
2486
2503
|
* {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
|
|
2487
|
-
* optional `
|
|
2488
|
-
* and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
|
|
2504
|
+
* optional `match` predicate. Macros run on the shared AST, so the same macro works across every
|
|
2505
|
+
* adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
|
|
2489
2506
|
*/
|
|
2490
2507
|
type Macro = Visitor & {
|
|
2491
2508
|
/**
|
|
@@ -2498,10 +2515,10 @@ type Macro = Visitor & {
|
|
|
2498
2515
|
*/
|
|
2499
2516
|
enforce?: Enforce;
|
|
2500
2517
|
/**
|
|
2501
|
-
*
|
|
2502
|
-
* the macro
|
|
2518
|
+
* Predicate checked against the current node before any callback runs. Returning `false`
|
|
2519
|
+
* skips the macro for that node.
|
|
2503
2520
|
*/
|
|
2504
|
-
|
|
2521
|
+
match?: (node: Node) => boolean;
|
|
2505
2522
|
};
|
|
2506
2523
|
/**
|
|
2507
2524
|
* Types a macro for inference and a single construction site, mirroring `definePlugin`.
|
|
@@ -2743,5 +2760,5 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
|
|
|
2743
2760
|
*/
|
|
2744
2761
|
declare function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
|
|
2745
2762
|
//#endregion
|
|
2746
|
-
export {
|
|
2747
|
-
//# sourceMappingURL=types-
|
|
2763
|
+
export { importDef as $, DistributiveOmit as $t, ResponseNode as A, ArrowFunctionNode as At, createParameter as B, breakDef as Bt, inputDef as C, schemaDef as Ct, OperationNode as D, propertyDef as Dt, HttpOperationNode as E, createProperty as Et, createRequestBody as F, JSDocNode as Ft, SourceNode as G, createFunction as Gt, ExportNode as H, createArrowFunction as Ht, requestBodyDef as I, JsxNode as It, createFile as J, createType as Jt, UserFileNode as K, createJsx as Kt, ParameterLocation as L, TextNode as Lt, createResponse as M, CodeNode as Mt, responseDef as N, ConstNode as Nt, createOperation as O, InferSchemaNode as Ot, RequestBodyNode as P, FunctionNode as Pt, fileDef as Q, typeDef as Qt, ParameterNode as R, TypeNode as Rt, createInput as S, createSchema as St, HttpMethod as T, UserPropertyNode as Tt, FileNode as U, createBreak as Ut, parameterDef as V, constDef as Vt, ImportNode as W, createConst as Wt, createSource as X, jsxDef as Xt, createImport as Y, functionDef as Yt, exportDef as Z, textDef as Zt, OutputNode as _, SchemaType as _t, Enforce as a, DateSchemaNode as at, InputMeta as b, UnionSchemaNode as bt, composeMacros as c, IntersectionSchemaNode as ct, Visitor as d, PrimitiveSchemaType as dt, NodeDef as en, sourceDef as et, VisitorContext as f, RefSchemaNode as ft, Node as g, SchemaNodeByType as gt, transform as h, SchemaNode as ht, createPrinter as i, schemaTypes as in, ArraySchemaNode as it, StatusCode as j, BreakNode as jt, operationDef as k, ParserOptions as kt, defineMacro as l, NumberSchemaNode as lt, collectSync as m, ScalarSchemaType as mt, PrinterFactoryOptions as n, BaseNode as nn, contentDef as nt, Macro as o, DatetimeSchemaNode as ot, collect as p, ScalarSchemaNode as pt, createExport as q, createText as qt, PrinterPartial as r, NodeKind as rn, createContent as rt, applyMacros as s, EnumSchemaNode as st, Printer as t, defineNode as tn, ContentNode as tt, ParentOf as u, ObjectSchemaNode as ut, createOutput as v, StringSchemaNode as vt, GenericOperationNode as w, PropertyNode as wt, InputNode as x, UrlSchemaNode as xt, outputDef as y, TimeSchemaNode as yt, ParameterStyle as z, arrowFunctionDef as zt };
|
|
2764
|
+
//# sourceMappingURL=types-BPqinVNh.d.ts.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
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-BPqinVNh.js";
|
|
2
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
|
|
3
|
+
"version": "5.0.0",
|
|
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",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.20.1",
|
|
46
|
-
"@internals/utils": "0.0.
|
|
46
|
+
"@internals/utils": "0.0.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=22"
|