@kubb/ast 5.0.0-beta.32 → 5.0.0-beta.34
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 +17 -8
- package/dist/index.cjs +3 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -3705
- package/dist/index.js +4 -63
- package/dist/index.js.map +1 -1
- package/dist/types-CE8VJ5_y.d.ts +3605 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +5 -1
- package/src/constants.ts +0 -50
- package/src/index.ts +4 -8
- package/src/infer.ts +0 -9
- package/src/refs.ts +0 -7
- package/src/types.ts +1 -2
- package/src/visitor.ts +8 -4
package/dist/types.cjs
ADDED
|
File without changes
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $t as ScalarSchemaType, At as FunctionParameterNode, Bt as DateSchemaNode, C as PrinterFactoryOptions, Ct as HttpStatusCode, D as DistributiveOmit, Dt as ParameterNode, Et as ParameterLocation, Ft as FileNode, Gt as IntersectionSchemaNode, Ht as EnumSchemaNode, It as ImportNode, Jt as NumberSchemaNode, Kt as Ipv4SchemaNode, Lt as SourceNode, Mt as ParameterGroupNode, Nt as ParamsTypeNode, O as UserFileNode, Ot as FunctionNodeType, Pt as ExportNode, Qt as ScalarSchemaNode, Rt as ArraySchemaNode, S as Printer, Sn as VisitorDepth, St as ResponseNode, Tt as StatusCode, Ut as EnumValueNode, Vt as DatetimeSchemaNode, Wt as FormatStringSchemaNode, Xt as PrimitiveSchemaType, Yt as ObjectSchemaNode, Zt as RefSchemaNode, _ as VisitorContext, _n as TypeDeclarationNode, _t as HttpMethod, an as TimeSchemaNode, bn as NodeKind, bt as OperationNodeBase, cn as PropertyNode, ct as DedupePlan, d as AsyncVisitor, dn as CodeNode, dt as Node, en as SchemaNode, et as InferSchemaNode, f as CollectOptions, fn as ConstNode, ft as InputMeta, g as Visitor, gn as TextNode, gt as GenericOperationNode, h as TransformOptions, hn as JsxNode, ht as OutputNode, in as StringSchemaNode, it as SchemaDialect, jt as FunctionParametersNode, kt as FunctionParamNode, ln as ArrowFunctionNode, m as ParentOf, mn as JSDocNode, mt as InputStreamNode, nn as SchemaType, nt as DispatchRule, on as UnionSchemaNode, ot as BuildDedupePlanOptions, p as CollectVisitor, pn as FunctionNode, pt as InputNode, qt as Ipv6SchemaNode, rn as SpecialSchemaType, sn as UrlSchemaNode, st as DedupeCanonical, t as OperationParamsResolver, tn as SchemaNodeByType, tt as ParserOptions, un as BreakNode, v as WalkOptions, vn as TypeNode, vt as HttpOperationNode, w as PrinterPartial, wt as MediaType, xn as ScalarPrimitive, xt as OperationProtocol, yn as BaseNode, yt as OperationNode, zt as ComplexSchemaType } from "./types-CE8VJ5_y.js";
|
|
2
|
+
export type { ArraySchemaNode, ArrowFunctionNode, AsyncVisitor, BaseNode, BreakNode, BuildDedupePlanOptions, CodeNode, CollectOptions, CollectVisitor, ComplexSchemaType, ConstNode, DateSchemaNode, DatetimeSchemaNode, DedupeCanonical, DedupePlan, DispatchRule, DistributiveOmit, EnumSchemaNode, EnumValueNode, ExportNode, FileNode, FormatStringSchemaNode, FunctionNode, FunctionNodeType, FunctionParamNode, FunctionParameterNode, FunctionParametersNode, GenericOperationNode, HttpMethod, HttpOperationNode, HttpStatusCode, ImportNode, InferSchemaNode, InputMeta, InputNode, InputStreamNode, IntersectionSchemaNode, Ipv4SchemaNode, Ipv6SchemaNode, JSDocNode, JsxNode, MediaType, Node, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, OperationNodeBase, OperationParamsResolver, OperationProtocol, OutputNode, ParameterGroupNode, ParameterLocation, ParameterNode, ParamsTypeNode, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, ResponseNode, ScalarPrimitive, ScalarSchemaNode, ScalarSchemaType, SchemaDialect, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, SpecialSchemaType, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TransformOptions, TypeDeclarationNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, VisitorDepth, WalkOptions };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/ast",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.34",
|
|
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",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"import": "./dist/index.js",
|
|
33
33
|
"require": "./dist/index.cjs"
|
|
34
34
|
},
|
|
35
|
+
"./types": {
|
|
36
|
+
"import": "./dist/types.js",
|
|
37
|
+
"require": "./dist/types.cjs"
|
|
38
|
+
},
|
|
35
39
|
"./package.json": "./package.json"
|
|
36
40
|
},
|
|
37
41
|
"publishConfig": {
|
package/src/constants.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { NodeKind } from './nodes/base.ts'
|
|
2
|
-
import type { MediaType } from './nodes/http.ts'
|
|
3
1
|
import type { HttpMethod } from './nodes/operation.ts'
|
|
4
2
|
import type { SchemaType } from './nodes/schema.ts'
|
|
5
3
|
|
|
@@ -16,26 +14,6 @@ export const visitorDepths = {
|
|
|
16
14
|
deep: 'deep',
|
|
17
15
|
} as const satisfies Record<VisitorDepth, VisitorDepth>
|
|
18
16
|
|
|
19
|
-
export const nodeKinds = {
|
|
20
|
-
input: 'Input',
|
|
21
|
-
output: 'Output',
|
|
22
|
-
operation: 'Operation',
|
|
23
|
-
schema: 'Schema',
|
|
24
|
-
property: 'Property',
|
|
25
|
-
parameter: 'Parameter',
|
|
26
|
-
response: 'Response',
|
|
27
|
-
functionParameter: 'FunctionParameter',
|
|
28
|
-
parameterGroup: 'ParameterGroup',
|
|
29
|
-
functionParameters: 'FunctionParameters',
|
|
30
|
-
type: 'Type',
|
|
31
|
-
file: 'File',
|
|
32
|
-
import: 'Import',
|
|
33
|
-
export: 'Export',
|
|
34
|
-
source: 'Source',
|
|
35
|
-
text: 'Text',
|
|
36
|
-
break: 'Break',
|
|
37
|
-
} as const satisfies Record<string, NodeKind>
|
|
38
|
-
|
|
39
17
|
/**
|
|
40
18
|
* Schema type discriminators used by all AST schema nodes.
|
|
41
19
|
*
|
|
@@ -198,31 +176,3 @@ export const httpMethods = {
|
|
|
198
176
|
* ```
|
|
199
177
|
*/
|
|
200
178
|
export const WALK_CONCURRENCY = 30
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Common MIME types used in request/response content negotiation.
|
|
204
|
-
*
|
|
205
|
-
* Covers JSON, XML, form data, PDFs, images, audio, and video formats.
|
|
206
|
-
* Use these as keys when serializing request/response bodies.
|
|
207
|
-
*/
|
|
208
|
-
export const mediaTypes = {
|
|
209
|
-
applicationJson: 'application/json',
|
|
210
|
-
applicationXml: 'application/xml',
|
|
211
|
-
applicationFormUrlEncoded: 'application/x-www-form-urlencoded',
|
|
212
|
-
applicationOctetStream: 'application/octet-stream',
|
|
213
|
-
applicationPdf: 'application/pdf',
|
|
214
|
-
applicationZip: 'application/zip',
|
|
215
|
-
applicationGraphql: 'application/graphql',
|
|
216
|
-
multipartFormData: 'multipart/form-data',
|
|
217
|
-
textPlain: 'text/plain',
|
|
218
|
-
textHtml: 'text/html',
|
|
219
|
-
textCsv: 'text/csv',
|
|
220
|
-
textXml: 'text/xml',
|
|
221
|
-
imagePng: 'image/png',
|
|
222
|
-
imageJpeg: 'image/jpeg',
|
|
223
|
-
imageGif: 'image/gif',
|
|
224
|
-
imageWebp: 'image/webp',
|
|
225
|
-
imageSvgXml: 'image/svg+xml',
|
|
226
|
-
audioMpeg: 'audio/mpeg',
|
|
227
|
-
videoMp4: 'video/mp4',
|
|
228
|
-
} as const satisfies Record<string, MediaType>
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { httpMethods,
|
|
1
|
+
export { httpMethods, schemaTypes } from './constants.ts'
|
|
2
2
|
export { applyDedupe, buildDedupePlan } from './dedupe.ts'
|
|
3
3
|
export { defineSchemaDialect } from './dialect.ts'
|
|
4
4
|
export { dispatch } from './dispatch.ts'
|
|
@@ -6,7 +6,6 @@ export {
|
|
|
6
6
|
createArrowFunction,
|
|
7
7
|
createBreak,
|
|
8
8
|
createConst,
|
|
9
|
-
createContent,
|
|
10
9
|
createExport,
|
|
11
10
|
createFile,
|
|
12
11
|
createFunction,
|
|
@@ -22,7 +21,6 @@ export {
|
|
|
22
21
|
createParameterGroup,
|
|
23
22
|
createParamsType,
|
|
24
23
|
createProperty,
|
|
25
|
-
createRequestBody,
|
|
26
24
|
createResponse,
|
|
27
25
|
createSchema,
|
|
28
26
|
createSource,
|
|
@@ -35,12 +33,11 @@ export { isHttpOperationNode, isInputNode, isOperationNode, isOutputNode, isSche
|
|
|
35
33
|
export { createPrinterFactory, definePrinter } from './printer.ts'
|
|
36
34
|
export { extractRefName } from './refs.ts'
|
|
37
35
|
export { childName, collectImports, enumPropName, findDiscriminator } from './resolvers.ts'
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
36
|
+
export { schemaSignature } from './signature.ts'
|
|
37
|
+
export { mergeAdjacentObjectsLazy, setDiscriminatorEnum, setEnumName, simplifyUnion } from './transformers.ts'
|
|
40
38
|
export type * from './types.ts'
|
|
41
39
|
export {
|
|
42
40
|
caseParams,
|
|
43
|
-
collectReferencedSchemaNames,
|
|
44
41
|
collectUsedSchemaNames,
|
|
45
42
|
containsCircularRef,
|
|
46
43
|
createDiscriminantNode,
|
|
@@ -48,7 +45,6 @@ export {
|
|
|
48
45
|
extractStringsFromNodes,
|
|
49
46
|
findCircularSchemas,
|
|
50
47
|
isStringType,
|
|
51
|
-
resolveRefName,
|
|
52
48
|
syncSchemaRef,
|
|
53
49
|
} from './utils.ts'
|
|
54
|
-
export { collect,
|
|
50
|
+
export { collect, transform, walk } from './visitor.ts'
|
package/src/infer.ts
CHANGED
|
@@ -130,12 +130,3 @@ export type InferSchemaNode<
|
|
|
130
130
|
? TEntry[1]
|
|
131
131
|
: InferSchemaNode<TSchema, TDateType, TRest>
|
|
132
132
|
: SchemaNode
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Backward-compatible alias for `InferSchemaNode`.
|
|
136
|
-
*/
|
|
137
|
-
export type InferSchema<
|
|
138
|
-
TSchema extends object,
|
|
139
|
-
TDateType extends ParserOptions['dateType'] = 'string',
|
|
140
|
-
TEntries extends ReadonlyArray<[object, SchemaNode]> = SchemaNodeMap<TDateType>,
|
|
141
|
-
> = InferSchemaNode<TSchema, TDateType, TEntries>
|
package/src/refs.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { BuildDedupePlanOptions, DedupeCanonical, DedupePlan } from './dedu
|
|
|
3
3
|
export type { SchemaDialect } from './dialect.ts'
|
|
4
4
|
export type { DispatchRule } from './dispatch.ts'
|
|
5
5
|
export type { DistributiveOmit } from './factory.ts'
|
|
6
|
-
export type {
|
|
6
|
+
export type { InferSchemaNode, ParserOptions } from './infer.ts'
|
|
7
7
|
export type {
|
|
8
8
|
ArraySchemaNode,
|
|
9
9
|
ArrowFunctionNode,
|
|
@@ -70,7 +70,6 @@ export type {
|
|
|
70
70
|
UnionSchemaNode,
|
|
71
71
|
UrlSchemaNode,
|
|
72
72
|
} from './nodes/index.ts'
|
|
73
|
-
export type { RefMap } from './refs.ts'
|
|
74
73
|
export type { AsyncVisitor, CollectOptions, CollectVisitor, ParentOf, TransformOptions, Visitor, VisitorContext, WalkOptions } from './visitor.ts'
|
|
75
74
|
export type { Printer, PrinterFactoryOptions, PrinterPartial } from './printer.ts'
|
|
76
75
|
export type { ScalarPrimitive } from './constants.ts'
|
package/src/visitor.ts
CHANGED
|
@@ -401,10 +401,14 @@ export async function walk(node: Node, options: WalkOptions): Promise<void> {
|
|
|
401
401
|
async function _walk(node: Node, visitor: AsyncVisitor, recurse: boolean, limit: LimitFn, parent: Node | undefined): Promise<void> {
|
|
402
402
|
await limit(() => applyVisitor(node, visitor, parent))
|
|
403
403
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
// Visit siblings concurrently and let the shared `limit` cap how many callbacks
|
|
405
|
+
// run at once. Awaiting each child sequentially here would serialize the whole
|
|
406
|
+
// traversal and make `concurrency` inert — every visitor callback would run one
|
|
407
|
+
// at a time regardless of the limit.
|
|
408
|
+
const children = Array.from(getChildren(node, recurse))
|
|
409
|
+
if (children.length === 0) return
|
|
410
|
+
|
|
411
|
+
await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit, node)))
|
|
408
412
|
}
|
|
409
413
|
|
|
410
414
|
/**
|