@kubb/ast 5.0.0-beta.15 → 5.0.0-beta.16
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 +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factory.ts +14 -0
- package/src/index.ts +1 -0
- package/src/nodes/index.ts +1 -1
- package/src/nodes/root.ts +24 -0
- package/src/types.ts +1 -0
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.16",
|
|
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",
|
package/src/factory.ts
CHANGED
|
@@ -12,7 +12,9 @@ import type {
|
|
|
12
12
|
FunctionParameterNode,
|
|
13
13
|
FunctionParametersNode,
|
|
14
14
|
ImportNode,
|
|
15
|
+
InputMeta,
|
|
15
16
|
InputNode,
|
|
17
|
+
InputStreamNode,
|
|
16
18
|
JsxNode,
|
|
17
19
|
ObjectSchemaNode,
|
|
18
20
|
OperationNode,
|
|
@@ -89,6 +91,18 @@ export function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): I
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Creates an `InputStreamNode` from pre-built `AsyncIterable` sources.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const node = createStreamInput(schemasIterable, operationsIterable, { title: 'My API' })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export function createStreamInput(schemas: AsyncIterable<SchemaNode>, operations: AsyncIterable<OperationNode>, meta?: InputMeta): InputStreamNode {
|
|
103
|
+
return { kind: 'Input', schemas, operations, meta }
|
|
104
|
+
}
|
|
105
|
+
|
|
92
106
|
/**
|
|
93
107
|
* Creates an `OutputNode` with a stable default for `files`.
|
|
94
108
|
*
|
package/src/index.ts
CHANGED
package/src/nodes/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { OutputNode } from './output.ts'
|
|
|
19
19
|
export type { ParameterLocation, ParameterNode } from './parameter.ts'
|
|
20
20
|
export type { PropertyNode } from './property.ts'
|
|
21
21
|
export type { ResponseNode } from './response.ts'
|
|
22
|
-
export type { InputMeta, InputNode } from './root.ts'
|
|
22
|
+
export type { InputMeta, InputNode, InputStreamNode } from './root.ts'
|
|
23
23
|
export type {
|
|
24
24
|
ArraySchemaNode,
|
|
25
25
|
ComplexSchemaType,
|
package/src/nodes/root.ts
CHANGED
|
@@ -62,3 +62,27 @@ export type InputNode = BaseNode & {
|
|
|
62
62
|
*/
|
|
63
63
|
meta?: InputMeta
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Streaming variant of `InputNode` for memory-efficient processing of large API specs.
|
|
68
|
+
*
|
|
69
|
+
* `schemas` and `operations` are `AsyncIterable` rather than arrays — each `for await`
|
|
70
|
+
* loop creates a fresh parse pass from the cached in-memory document, so multiple
|
|
71
|
+
* consumers (plugins) can iterate independently without keeping all nodes in memory.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* for await (const schema of inputStreamNode.schemas) {
|
|
76
|
+
* // only this one SchemaNode is live here; previous ones are GC-eligible
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export type InputStreamNode = {
|
|
81
|
+
kind: 'Input'
|
|
82
|
+
/** Lazily parsed schema nodes. Each `for await` creates a fresh parse pass. */
|
|
83
|
+
schemas: AsyncIterable<SchemaNode>
|
|
84
|
+
/** Lazily parsed operation nodes. Each `for await` creates a fresh parse pass. */
|
|
85
|
+
operations: AsyncIterable<OperationNode>
|
|
86
|
+
/** Document metadata — available immediately, before the first yield. */
|
|
87
|
+
meta?: InputMeta
|
|
88
|
+
}
|