@kubb/ast 5.0.0-beta.60 → 5.0.0-beta.62
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 +2 -1
- package/dist/defineMacro-BryDiuQl.cjs +115 -0
- package/dist/defineMacro-BryDiuQl.cjs.map +1 -0
- package/dist/defineMacro-CNkUpxia.js +99 -0
- package/dist/defineMacro-CNkUpxia.js.map +1 -0
- package/dist/defineMacro-Vw-xQvq7.d.ts +467 -0
- package/dist/factory.cjs +64 -4
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.ts +2 -37
- package/dist/factory.js +58 -3
- package/dist/factory.js.map +1 -0
- package/dist/{index-BzjwdK2M.d.ts → index-CTaN_ee_.d.ts} +235 -198
- package/dist/index.cjs +33 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +36 -36
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +130 -0
- package/dist/macros.cjs.map +1 -0
- package/dist/macros.d.ts +61 -0
- package/dist/macros.js +128 -0
- package/dist/macros.js.map +1 -0
- package/dist/{operationParams-BZ07xDm0.d.ts → operationParams-B44p6EQy.d.ts} +2 -2
- package/dist/{response-DS5S3IG4.cjs → response-BeG6hq2D.cjs} +389 -173
- package/dist/response-BeG6hq2D.cjs.map +1 -0
- package/dist/{response-DKxTr522.js → response-Rd1uisM1.js} +377 -162
- package/dist/response-Rd1uisM1.js.map +1 -0
- package/dist/types-DQTgVSwE.d.ts +314 -0
- package/dist/types.d.ts +5 -5
- package/dist/{utils-D83JA6Xx.cjs → utils-BDI3kXlb.cjs} +20 -753
- package/dist/utils-BDI3kXlb.cjs.map +1 -0
- package/dist/{utils-Dj_KoXMv.js → utils-DW9rnfsD.js} +11 -630
- package/dist/utils-DW9rnfsD.js.map +1 -0
- package/dist/utils.cjs +11 -9
- package/dist/utils.d.ts +38 -4
- package/dist/utils.js +4 -3
- package/dist/visitor-B7Zlnp4c.cjs +604 -0
- package/dist/visitor-B7Zlnp4c.cjs.map +1 -0
- package/dist/visitor-DepQEKyp.js +510 -0
- package/dist/visitor-DepQEKyp.js.map +1 -0
- package/package.json +5 -1
- package/src/constants.ts +0 -30
- package/src/dedupe.ts +1 -9
- package/src/defineMacro.ts +139 -0
- package/src/{node.ts → defineNode.ts} +19 -42
- package/src/dialect.ts +42 -19
- package/src/factory.ts +3 -90
- package/src/index.ts +9 -15
- package/src/macros/index.ts +3 -0
- package/src/macros/macroDiscriminatorEnum.ts +50 -0
- package/src/macros/macroEnumName.ts +33 -0
- package/src/macros/macroSimplifyUnion.ts +60 -0
- package/src/nodes/code.ts +32 -75
- package/src/nodes/content.ts +2 -7
- package/src/nodes/file.ts +102 -14
- package/src/nodes/function.ts +46 -46
- package/src/nodes/index.ts +2 -3
- package/src/nodes/input.ts +13 -9
- package/src/nodes/operation.ts +5 -5
- package/src/nodes/output.ts +1 -1
- package/src/nodes/parameter.ts +6 -6
- package/src/nodes/property.ts +6 -6
- package/src/nodes/requestBody.ts +6 -13
- package/src/nodes/response.ts +93 -8
- package/src/nodes/schema.ts +1 -1
- package/src/registry.ts +1 -1
- package/src/types.ts +4 -4
- package/src/utils/extractStringsFromNodes.ts +1 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/operationParams.ts +1 -1
- package/src/utils/refs.ts +27 -1
- package/src/utils/schemaMerge.ts +34 -0
- package/src/visitor.ts +2 -13
- package/dist/extractStringsFromNodes-WMYJ8nQL.d.ts +0 -82
- package/dist/factory-Cl8Z7mcc.cjs +0 -299
- package/dist/factory-Cl8Z7mcc.cjs.map +0 -1
- package/dist/factory-Du7nEP4B.js +0 -282
- package/dist/factory-Du7nEP4B.js.map +0 -1
- package/dist/response-DKxTr522.js.map +0 -1
- package/dist/response-DS5S3IG4.cjs.map +0 -1
- package/dist/types-olVl9v5p.d.ts +0 -764
- package/dist/utils-D83JA6Xx.cjs.map +0 -1
- package/dist/utils-Dj_KoXMv.js.map +0 -1
- package/src/mocks.ts +0 -56
- package/src/nodes/http.ts +0 -85
- package/src/transformers.ts +0 -191
- /package/src/{printer.ts → definePrinter.ts} +0 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { n as __name } from "./chunk-CNktS9qV.js";
|
|
2
|
+
import { C as ParameterNode, Et as PropertyNode, _t as SchemaNode, f as OperationNode, h as ResponseNode, n as OutputNode, o as InputNode, rt as ContentNode, t as Node, y as RequestBodyNode } from "./index-CTaN_ee_.js";
|
|
3
|
+
|
|
4
|
+
//#region src/constants.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Traversal depth for AST visitor utilities.
|
|
7
|
+
*
|
|
8
|
+
* - `'shallow'` visits only the immediate node, skipping children.
|
|
9
|
+
* - `'deep'` recursively visits all descendant nodes.
|
|
10
|
+
*/
|
|
11
|
+
type VisitorDepth = 'shallow' | 'deep';
|
|
12
|
+
/**
|
|
13
|
+
* Schema type discriminators used by all AST schema nodes.
|
|
14
|
+
*
|
|
15
|
+
* Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).
|
|
16
|
+
* Call `isScalarPrimitive()` to check for the scalar types.
|
|
17
|
+
*/
|
|
18
|
+
declare const schemaTypes: {
|
|
19
|
+
/**
|
|
20
|
+
* Text value.
|
|
21
|
+
*/
|
|
22
|
+
readonly string: "string";
|
|
23
|
+
/**
|
|
24
|
+
* Floating-point number (`float`, `double`).
|
|
25
|
+
*/
|
|
26
|
+
readonly number: "number";
|
|
27
|
+
/**
|
|
28
|
+
* Whole number (`int32`). Use `bigint` for `int64`.
|
|
29
|
+
*/
|
|
30
|
+
readonly integer: "integer";
|
|
31
|
+
/**
|
|
32
|
+
* 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
|
|
33
|
+
*/
|
|
34
|
+
readonly bigint: "bigint";
|
|
35
|
+
/**
|
|
36
|
+
* Boolean value.
|
|
37
|
+
*/
|
|
38
|
+
readonly boolean: "boolean";
|
|
39
|
+
/**
|
|
40
|
+
* Explicit null value.
|
|
41
|
+
*/
|
|
42
|
+
readonly null: "null";
|
|
43
|
+
/**
|
|
44
|
+
* Any value (no type restriction).
|
|
45
|
+
*/
|
|
46
|
+
readonly any: "any";
|
|
47
|
+
/**
|
|
48
|
+
* Unknown value (must be narrowed before usage).
|
|
49
|
+
*/
|
|
50
|
+
readonly unknown: "unknown";
|
|
51
|
+
/**
|
|
52
|
+
* No return value (`void`).
|
|
53
|
+
*/
|
|
54
|
+
readonly void: "void";
|
|
55
|
+
/**
|
|
56
|
+
* Object with named properties.
|
|
57
|
+
*/
|
|
58
|
+
readonly object: "object";
|
|
59
|
+
/**
|
|
60
|
+
* Sequential list of items.
|
|
61
|
+
*/
|
|
62
|
+
readonly array: "array";
|
|
63
|
+
/**
|
|
64
|
+
* Fixed-length list with position-specific items.
|
|
65
|
+
*/
|
|
66
|
+
readonly tuple: "tuple";
|
|
67
|
+
/**
|
|
68
|
+
* "One of" multiple schema members.
|
|
69
|
+
*/
|
|
70
|
+
readonly union: "union";
|
|
71
|
+
/**
|
|
72
|
+
* "All of" multiple schema members.
|
|
73
|
+
*/
|
|
74
|
+
readonly intersection: "intersection";
|
|
75
|
+
/**
|
|
76
|
+
* Enum schema.
|
|
77
|
+
*/
|
|
78
|
+
readonly enum: "enum";
|
|
79
|
+
/**
|
|
80
|
+
* Reference to another schema.
|
|
81
|
+
*/
|
|
82
|
+
readonly ref: "ref";
|
|
83
|
+
/**
|
|
84
|
+
* Calendar date (for example `2026-03-24`).
|
|
85
|
+
*/
|
|
86
|
+
readonly date: "date";
|
|
87
|
+
/**
|
|
88
|
+
* Date-time value (for example `2026-03-24T09:00:00Z`).
|
|
89
|
+
*/
|
|
90
|
+
readonly datetime: "datetime";
|
|
91
|
+
/**
|
|
92
|
+
* Time-only value (for example `09:00:00`).
|
|
93
|
+
*/
|
|
94
|
+
readonly time: "time";
|
|
95
|
+
/**
|
|
96
|
+
* UUID value.
|
|
97
|
+
*/
|
|
98
|
+
readonly uuid: "uuid";
|
|
99
|
+
/**
|
|
100
|
+
* Email address value.
|
|
101
|
+
*/
|
|
102
|
+
readonly email: "email";
|
|
103
|
+
/**
|
|
104
|
+
* URL value.
|
|
105
|
+
*/
|
|
106
|
+
readonly url: "url";
|
|
107
|
+
/**
|
|
108
|
+
* IPv4 address value.
|
|
109
|
+
*/
|
|
110
|
+
readonly ipv4: "ipv4";
|
|
111
|
+
/**
|
|
112
|
+
* IPv6 address value.
|
|
113
|
+
*/
|
|
114
|
+
readonly ipv6: "ipv6";
|
|
115
|
+
/**
|
|
116
|
+
* Binary/blob value.
|
|
117
|
+
*/
|
|
118
|
+
readonly blob: "blob";
|
|
119
|
+
/**
|
|
120
|
+
* Impossible value (`never`).
|
|
121
|
+
*/
|
|
122
|
+
readonly never: "never";
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/visitor.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Ordered mapping of `[NodeType, ParentType]` pairs.
|
|
128
|
+
*
|
|
129
|
+
* `ParentOf` uses this map to find parent types.
|
|
130
|
+
*/
|
|
131
|
+
type ParentNodeMap = [[InputNode, undefined], [OutputNode, undefined], [OperationNode, InputNode], [RequestBodyNode, OperationNode], [ContentNode, RequestBodyNode | ResponseNode], [SchemaNode, InputNode | ContentNode | SchemaNode | PropertyNode | ParameterNode], [PropertyNode, SchemaNode], [ParameterNode, OperationNode], [ResponseNode, OperationNode]];
|
|
132
|
+
/**
|
|
133
|
+
* Resolves the parent node type for a given AST node type.
|
|
134
|
+
*
|
|
135
|
+
* Visitor context relies on this so `ctx.parent` is typed for each callback.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* type InputParent = ParentOf<InputNode>
|
|
140
|
+
* // undefined
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* type PropertyParent = ParentOf<PropertyNode>
|
|
146
|
+
* // SchemaNode
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* type SchemaParent = ParentOf<SchemaNode>
|
|
152
|
+
* // InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
type ParentOf<T extends Node, TEntries extends ReadonlyArray<[Node, unknown]> = ParentNodeMap> = TEntries extends [infer TEntry extends [Node, unknown], ...infer TRest extends ReadonlyArray<[Node, unknown]>] ? T extends TEntry[0] ? TEntry[1] : ParentOf<T, TRest> : Node;
|
|
156
|
+
/**
|
|
157
|
+
* Traversal context passed as the second argument to every visitor callback.
|
|
158
|
+
* `parent` is typed from the current node type.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const visitor: Visitor = {
|
|
163
|
+
* schema(node, { parent }) {
|
|
164
|
+
* // parent type is narrowed by node kind
|
|
165
|
+
* },
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
type VisitorContext<T extends Node = Node> = {
|
|
170
|
+
/**
|
|
171
|
+
* Parent node of the currently visited node.
|
|
172
|
+
* For `InputNode`, this is `undefined`.
|
|
173
|
+
*/
|
|
174
|
+
parent?: ParentOf<T>;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Synchronous visitor consumed by `transform`. Each optional callback runs
|
|
178
|
+
* for the matching node type. Return a new node to replace it, or `undefined`
|
|
179
|
+
* to leave it untouched.
|
|
180
|
+
*
|
|
181
|
+
* Plugins typically expose `transformer` so users can supply a `Visitor` that
|
|
182
|
+
* rewrites the AST before printing.
|
|
183
|
+
*
|
|
184
|
+
* @example Prefix every operationId
|
|
185
|
+
* ```ts
|
|
186
|
+
* const visitor: Visitor = {
|
|
187
|
+
* operation(node) {
|
|
188
|
+
* return { ...node, operationId: `api_${node.operationId}` }
|
|
189
|
+
* },
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example Strip schema descriptions
|
|
194
|
+
* ```ts
|
|
195
|
+
* const visitor: Visitor = {
|
|
196
|
+
* schema(node) {
|
|
197
|
+
* return { ...node, description: undefined }
|
|
198
|
+
* },
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
type Visitor = {
|
|
203
|
+
input?(node: InputNode, context: VisitorContext<InputNode>): undefined | null | InputNode;
|
|
204
|
+
output?(node: OutputNode, context: VisitorContext<OutputNode>): undefined | null | OutputNode;
|
|
205
|
+
operation?(node: OperationNode, context: VisitorContext<OperationNode>): undefined | null | OperationNode;
|
|
206
|
+
schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): undefined | null | SchemaNode;
|
|
207
|
+
property?(node: PropertyNode, context: VisitorContext<PropertyNode>): undefined | null | PropertyNode;
|
|
208
|
+
parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): undefined | null | ParameterNode;
|
|
209
|
+
response?(node: ResponseNode, context: VisitorContext<ResponseNode>): undefined | null | ResponseNode;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* A visitor callback result that may be sync or async.
|
|
213
|
+
*/
|
|
214
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
215
|
+
/**
|
|
216
|
+
* Async visitor for `walk`. Synchronous `Visitor` objects are compatible.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const visitor: AsyncVisitor = {
|
|
221
|
+
* async operation(node) {
|
|
222
|
+
* await Promise.resolve(node.operationId)
|
|
223
|
+
* },
|
|
224
|
+
* }
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
type AsyncVisitor = {
|
|
228
|
+
input?(node: InputNode, context: VisitorContext<InputNode>): MaybePromise<undefined | null | InputNode>;
|
|
229
|
+
output?(node: OutputNode, context: VisitorContext<OutputNode>): MaybePromise<undefined | null | OutputNode>;
|
|
230
|
+
operation?(node: OperationNode, context: VisitorContext<OperationNode>): MaybePromise<undefined | null | OperationNode>;
|
|
231
|
+
schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): MaybePromise<undefined | null | SchemaNode>;
|
|
232
|
+
property?(node: PropertyNode, context: VisitorContext<PropertyNode>): MaybePromise<undefined | null | PropertyNode>;
|
|
233
|
+
parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): MaybePromise<undefined | null | ParameterNode>;
|
|
234
|
+
response?(node: ResponseNode, context: VisitorContext<ResponseNode>): MaybePromise<undefined | null | ResponseNode>;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Visitor used by `collect`.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const visitor: CollectVisitor<string> = {
|
|
242
|
+
* operation(node) {
|
|
243
|
+
* return node.operationId
|
|
244
|
+
* },
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
type CollectVisitor<T> = {
|
|
249
|
+
input?(node: InputNode, context: VisitorContext<InputNode>): T | null | undefined;
|
|
250
|
+
output?(node: OutputNode, context: VisitorContext<OutputNode>): T | null | undefined;
|
|
251
|
+
operation?(node: OperationNode, context: VisitorContext<OperationNode>): T | null | undefined;
|
|
252
|
+
schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): T | null | undefined;
|
|
253
|
+
property?(node: PropertyNode, context: VisitorContext<PropertyNode>): T | null | undefined;
|
|
254
|
+
parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): T | null | undefined;
|
|
255
|
+
response?(node: ResponseNode, context: VisitorContext<ResponseNode>): T | null | undefined;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Options for `transform`.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const options: TransformOptions = { depth: 'deep', schema: (node) => node }
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* // Only transform the current node, not nested children
|
|
268
|
+
* const options: TransformOptions = { depth: 'shallow', schema: (node) => node }
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
type TransformOptions = Visitor & {
|
|
272
|
+
/**
|
|
273
|
+
* Traversal depth.
|
|
274
|
+
* @default 'deep'
|
|
275
|
+
*/
|
|
276
|
+
depth?: VisitorDepth;
|
|
277
|
+
/**
|
|
278
|
+
* Internal parent override used during recursion.
|
|
279
|
+
*/
|
|
280
|
+
parent?: Node;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Options for `walk`.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* const options: WalkOptions = { depth: 'deep', concurrency: 10, root: () => {} }
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
type WalkOptions = AsyncVisitor & {
|
|
291
|
+
/**
|
|
292
|
+
* Traversal depth.
|
|
293
|
+
* @default 'deep'
|
|
294
|
+
*/
|
|
295
|
+
depth?: VisitorDepth;
|
|
296
|
+
/**
|
|
297
|
+
* Maximum number of sibling nodes visited concurrently.
|
|
298
|
+
* @default 30
|
|
299
|
+
*/
|
|
300
|
+
concurrency?: number;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Options for `collect`.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* const options: CollectOptions<string> = { depth: 'shallow', schema: () => undefined }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
type CollectOptions<T> = CollectVisitor<T> & {
|
|
311
|
+
/**
|
|
312
|
+
* Traversal depth.
|
|
313
|
+
* @default 'deep'
|
|
314
|
+
*/
|
|
315
|
+
depth?: VisitorDepth;
|
|
316
|
+
/**
|
|
317
|
+
* Internal parent override used during recursion.
|
|
318
|
+
*/
|
|
319
|
+
parent?: Node;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Async depth-first traversal for side effects. Visitor return values are
|
|
323
|
+
* ignored. Use `transform` when you want to rewrite nodes.
|
|
324
|
+
*
|
|
325
|
+
* Sibling nodes at each depth run concurrently up to `options.concurrency`
|
|
326
|
+
* (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
|
|
327
|
+
* work. Lower values reduce memory pressure.
|
|
328
|
+
*
|
|
329
|
+
* @example Log every operation
|
|
330
|
+
* ```ts
|
|
331
|
+
* await walk(root, {
|
|
332
|
+
* operation(node) {
|
|
333
|
+
* console.log(node.operationId)
|
|
334
|
+
* },
|
|
335
|
+
* })
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @example Only visit the root node
|
|
339
|
+
* ```ts
|
|
340
|
+
* await walk(root, { depth: 'shallow', input: () => {} })
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function walk(node: Node, options: WalkOptions): Promise<void>;
|
|
344
|
+
/**
|
|
345
|
+
* Synchronous depth-first transform. Each visitor callback can return a
|
|
346
|
+
* replacement node. Returning `undefined` keeps the original.
|
|
347
|
+
*
|
|
348
|
+
* The original tree is never mutated, a new tree is returned. Pass
|
|
349
|
+
* `depth: 'shallow'` to skip recursion into children.
|
|
350
|
+
*
|
|
351
|
+
* @example Prefix every operationId
|
|
352
|
+
* ```ts
|
|
353
|
+
* const next = transform(root, {
|
|
354
|
+
* operation(node) {
|
|
355
|
+
* return { ...node, operationId: `prefixed_${node.operationId}` }
|
|
356
|
+
* },
|
|
357
|
+
* })
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @example Replace only the root node
|
|
361
|
+
* ```ts
|
|
362
|
+
* const next = transform(root, {
|
|
363
|
+
* depth: 'shallow',
|
|
364
|
+
* input: (node) => ({ ...node, meta: { ...node.meta, title: 'Rewritten' } }),
|
|
365
|
+
* })
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
declare function transform(node: InputNode, options: TransformOptions): InputNode;
|
|
369
|
+
declare function transform(node: OutputNode, options: TransformOptions): OutputNode;
|
|
370
|
+
declare function transform(node: OperationNode, options: TransformOptions): OperationNode;
|
|
371
|
+
declare function transform(node: SchemaNode, options: TransformOptions): SchemaNode;
|
|
372
|
+
declare function transform(node: PropertyNode, options: TransformOptions): PropertyNode;
|
|
373
|
+
declare function transform(node: ParameterNode, options: TransformOptions): ParameterNode;
|
|
374
|
+
declare function transform(node: ResponseNode, options: TransformOptions): ResponseNode;
|
|
375
|
+
declare function transform(node: Node, options: TransformOptions): Node;
|
|
376
|
+
/**
|
|
377
|
+
* Eager depth-first collection pass. Gathers every non-null value the visitor
|
|
378
|
+
* callbacks return into an array.
|
|
379
|
+
*
|
|
380
|
+
* @example Collect every operationId
|
|
381
|
+
* ```ts
|
|
382
|
+
* const ids = collect<string>(root, {
|
|
383
|
+
* operation(node) {
|
|
384
|
+
* return node.operationId
|
|
385
|
+
* },
|
|
386
|
+
* })
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
declare function collect<T>(node: Node, options: CollectOptions<T>): Array<T>;
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/defineMacro.d.ts
|
|
392
|
+
/**
|
|
393
|
+
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
394
|
+
* and `undefined` keeps declaration order.
|
|
395
|
+
*/
|
|
396
|
+
type Enforce = 'pre' | 'post';
|
|
397
|
+
/**
|
|
398
|
+
* A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
|
|
399
|
+
* {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
|
|
400
|
+
* optional `when` gate. Macros run on the shared AST, so the same macro works across every adapter
|
|
401
|
+
* and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
|
|
402
|
+
*/
|
|
403
|
+
type Macro = Visitor & {
|
|
404
|
+
/**
|
|
405
|
+
* Macro identifier, surfaced in diagnostics. Follows the `macro<Name>` convention.
|
|
406
|
+
*/
|
|
407
|
+
name: string;
|
|
408
|
+
/**
|
|
409
|
+
* Ordering hint. `pre` macros run before unmarked macros, `post` macros run after.
|
|
410
|
+
* Ordering within a bucket follows list order.
|
|
411
|
+
*/
|
|
412
|
+
enforce?: Enforce;
|
|
413
|
+
/**
|
|
414
|
+
* Gate checked against the current node before any callback runs. When it returns `false`
|
|
415
|
+
* the macro is skipped for that node.
|
|
416
|
+
*/
|
|
417
|
+
when?: (node: Node) => boolean;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Types a macro for inference and a single construction site, mirroring `definePlugin`.
|
|
421
|
+
* Adds no runtime behavior.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* const macroUntagged = defineMacro({
|
|
426
|
+
* name: 'untagged',
|
|
427
|
+
* operation(node) {
|
|
428
|
+
* return node.tags?.length ? undefined : { ...node, tags: ['untagged'] }
|
|
429
|
+
* },
|
|
430
|
+
* })
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
declare function defineMacro(macro: Macro): Macro;
|
|
434
|
+
/**
|
|
435
|
+
* Folds an ordered list of macros into a single {@link Visitor} that `transform` (and the per-plugin
|
|
436
|
+
* transform layer in `@kubb/core`) can run. Macros are stable-sorted by `enforce`, then applied
|
|
437
|
+
* sequentially per node so later macros see earlier output. This differs from a plain visitor, which
|
|
438
|
+
* has no names, ordering, or composition.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* const visitor = composeMacros([macroSimplifyUnion, macroDiscriminatorEnum])
|
|
443
|
+
* const next = transform(root, visitor)
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
declare function composeMacros(macros: ReadonlyArray<Macro>): Visitor;
|
|
447
|
+
/**
|
|
448
|
+
* Runs a list of macros over a node tree and returns the rewritten tree. Keeps `transform`'s
|
|
449
|
+
* structural sharing, so an empty or no-op macro list returns the same reference. Pass
|
|
450
|
+
* `depth: 'shallow'` to rewrite the root node only.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```ts
|
|
454
|
+
* const next = applyMacros(root, [macroIntegerToString])
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @example Apply to the root node only
|
|
458
|
+
* ```ts
|
|
459
|
+
* const named = applyMacros(node, [macroEnumName({ parentName, propName, enumSuffix })], { depth: 'shallow' })
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
|
|
463
|
+
depth?: VisitorDepth;
|
|
464
|
+
}): TNode;
|
|
465
|
+
//#endregion
|
|
466
|
+
export { defineMacro as a, VisitorContext as c, walk as d, schemaTypes as f, composeMacros as i, collect as l, Macro as n, ParentOf as o, applyMacros as r, Visitor as s, Enforce as t, transform as u };
|
|
467
|
+
//# sourceMappingURL=defineMacro-Vw-xQvq7.d.ts.map
|
package/dist/factory.cjs
CHANGED
|
@@ -1,12 +1,64 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_response = require("./response-
|
|
3
|
-
|
|
2
|
+
const require_response = require("./response-BeG6hq2D.cjs");
|
|
3
|
+
//#region src/factory.ts
|
|
4
|
+
var factory_exports = /* @__PURE__ */ require_response.__exportAll({
|
|
5
|
+
createArrowFunction: () => require_response.createArrowFunction,
|
|
6
|
+
createBreak: () => require_response.createBreak,
|
|
7
|
+
createConst: () => require_response.createConst,
|
|
8
|
+
createContent: () => require_response.createContent,
|
|
9
|
+
createExport: () => require_response.createExport,
|
|
10
|
+
createFile: () => require_response.createFile,
|
|
11
|
+
createFunction: () => require_response.createFunction,
|
|
12
|
+
createFunctionParameter: () => require_response.createFunctionParameter,
|
|
13
|
+
createFunctionParameters: () => require_response.createFunctionParameters,
|
|
14
|
+
createImport: () => require_response.createImport,
|
|
15
|
+
createIndexedAccessType: () => require_response.createIndexedAccessType,
|
|
16
|
+
createInput: () => require_response.createInput,
|
|
17
|
+
createJsx: () => require_response.createJsx,
|
|
18
|
+
createObjectBindingPattern: () => require_response.createObjectBindingPattern,
|
|
19
|
+
createOperation: () => require_response.createOperation,
|
|
20
|
+
createOutput: () => require_response.createOutput,
|
|
21
|
+
createParameter: () => require_response.createParameter,
|
|
22
|
+
createProperty: () => require_response.createProperty,
|
|
23
|
+
createRequestBody: () => require_response.createRequestBody,
|
|
24
|
+
createResponse: () => require_response.createResponse,
|
|
25
|
+
createSchema: () => require_response.createSchema,
|
|
26
|
+
createSource: () => require_response.createSource,
|
|
27
|
+
createText: () => require_response.createText,
|
|
28
|
+
createType: () => require_response.createType,
|
|
29
|
+
createTypeLiteral: () => require_response.createTypeLiteral,
|
|
30
|
+
update: () => update
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Identity-preserving node update: returns `node` unchanged when every field in
|
|
34
|
+
* `changes` already equals (by reference) the current value, otherwise a new node
|
|
35
|
+
* with the changes applied.
|
|
36
|
+
*
|
|
37
|
+
* Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
|
|
38
|
+
* structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
|
|
39
|
+
* downstream passes can detect "nothing changed" by identity. Comparison is
|
|
40
|
+
* shallow: a structurally-equal but newly-allocated array/object counts as a change.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* update(node, { name: node.name }) // -> same `node` reference
|
|
45
|
+
* update(node, { name: 'renamed' }) // -> new node, `name` replaced
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function update(node, changes) {
|
|
49
|
+
for (const key in changes) if (changes[key] !== node[key]) return {
|
|
50
|
+
...node,
|
|
51
|
+
...changes
|
|
52
|
+
};
|
|
53
|
+
return node;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
4
56
|
exports.createArrowFunction = require_response.createArrowFunction;
|
|
5
57
|
exports.createBreak = require_response.createBreak;
|
|
6
58
|
exports.createConst = require_response.createConst;
|
|
7
59
|
exports.createContent = require_response.createContent;
|
|
8
60
|
exports.createExport = require_response.createExport;
|
|
9
|
-
exports.createFile =
|
|
61
|
+
exports.createFile = require_response.createFile;
|
|
10
62
|
exports.createFunction = require_response.createFunction;
|
|
11
63
|
exports.createFunctionParameter = require_response.createFunctionParameter;
|
|
12
64
|
exports.createFunctionParameters = require_response.createFunctionParameters;
|
|
@@ -26,4 +78,12 @@ exports.createSource = require_response.createSource;
|
|
|
26
78
|
exports.createText = require_response.createText;
|
|
27
79
|
exports.createType = require_response.createType;
|
|
28
80
|
exports.createTypeLiteral = require_response.createTypeLiteral;
|
|
29
|
-
exports
|
|
81
|
+
Object.defineProperty(exports, "factory_exports", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return factory_exports;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
exports.update = update;
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=factory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.cjs","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the\n * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is\n * shallow: a structurally-equal but newly-allocated array/object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT"}
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __name, t as __exportAll } from "./chunk-CNktS9qV.js";
|
|
2
|
-
import { F as
|
|
2
|
+
import { F as createFunctionParameters, Gt as createBreak, I as createIndexedAccessType, J as UserFileNode, Jt as createJsx, Kt as createConst, L as createObjectBindingPattern, Ot as createProperty, P as createFunctionParameter, Q as createSource, R as createTypeLiteral, Wt as createArrowFunction, X as createFile, Xt as createType, Y as createExport, Yt as createText, Z as createImport, _ as createResponse, at as createContent, b as createRequestBody, p as createOperation, qt as createFunction, r as createOutput, s as createInput, t as Node, w as createParameter, wt as createSchema } from "./index-CTaN_ee_.js";
|
|
3
3
|
|
|
4
4
|
//#region src/factory.d.ts
|
|
5
5
|
declare namespace factory_d_exports {
|
|
@@ -22,41 +22,6 @@ declare namespace factory_d_exports {
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
declare function update<T extends Node>(node: T, changes: Partial<T>): T;
|
|
25
|
-
/**
|
|
26
|
-
* Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed
|
|
27
|
-
* and `imports`/`exports`/`sources` are deduplicated.
|
|
28
|
-
*/
|
|
29
|
-
type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a fully resolved `FileNode` from a file input descriptor.
|
|
32
|
-
*
|
|
33
|
-
* Computes:
|
|
34
|
-
* - `id` SHA256 hash of the file path
|
|
35
|
-
* - `name` `baseName` without extension
|
|
36
|
-
* - `extname` extension extracted from `baseName`
|
|
37
|
-
*
|
|
38
|
-
* Deduplicates:
|
|
39
|
-
* - `sources` via `combineSources`
|
|
40
|
-
* - `exports` via `combineExports`
|
|
41
|
-
* - `imports` via `combineImports` (also filters unused imports)
|
|
42
|
-
*
|
|
43
|
-
* @throws {Error} when `baseName` has no extension.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* const file = createFile({
|
|
48
|
-
* baseName: 'petStore.ts',
|
|
49
|
-
* path: 'src/models/petStore.ts',
|
|
50
|
-
* sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
|
|
51
|
-
* imports: [createImport({ name: ['z'], path: 'zod' })],
|
|
52
|
-
* exports: [createExport({ name: ['Pet'], path: './petStore' })],
|
|
53
|
-
* })
|
|
54
|
-
* // file.id = SHA256 hash of 'src/models/petStore.ts'
|
|
55
|
-
* // file.name = 'petStore'
|
|
56
|
-
* // file.extname = '.ts'
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
|
|
60
25
|
//#endregion
|
|
61
|
-
export { UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, factory_d_exports as t, update };
|
|
26
|
+
export { type UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, factory_d_exports as t, update };
|
|
62
27
|
//# sourceMappingURL=factory.d.ts.map
|
package/dist/factory.js
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as
|
|
3
|
-
|
|
1
|
+
import { t as __exportAll } from "./chunk-CNktS9qV.js";
|
|
2
|
+
import { B as createConst, D as createImport, E as createFile, H as createJsx, O as createSource, P as createContent, Q as createSchema, R as createArrowFunction, T as createExport, U as createText, V as createFunction, W as createType, _ as createIndexedAccessType, a as createParameter, d as createRequestBody, g as createFunctionParameters, h as createFunctionParameter, l as createOperation, p as createInput, r as createProperty, s as createOutput, t as createResponse, v as createObjectBindingPattern, y as createTypeLiteral, z as createBreak } from "./response-Rd1uisM1.js";
|
|
3
|
+
//#region src/factory.ts
|
|
4
|
+
var factory_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
createArrowFunction: () => createArrowFunction,
|
|
6
|
+
createBreak: () => createBreak,
|
|
7
|
+
createConst: () => createConst,
|
|
8
|
+
createContent: () => createContent,
|
|
9
|
+
createExport: () => createExport,
|
|
10
|
+
createFile: () => createFile,
|
|
11
|
+
createFunction: () => createFunction,
|
|
12
|
+
createFunctionParameter: () => createFunctionParameter,
|
|
13
|
+
createFunctionParameters: () => createFunctionParameters,
|
|
14
|
+
createImport: () => createImport,
|
|
15
|
+
createIndexedAccessType: () => createIndexedAccessType,
|
|
16
|
+
createInput: () => createInput,
|
|
17
|
+
createJsx: () => createJsx,
|
|
18
|
+
createObjectBindingPattern: () => createObjectBindingPattern,
|
|
19
|
+
createOperation: () => createOperation,
|
|
20
|
+
createOutput: () => createOutput,
|
|
21
|
+
createParameter: () => createParameter,
|
|
22
|
+
createProperty: () => createProperty,
|
|
23
|
+
createRequestBody: () => createRequestBody,
|
|
24
|
+
createResponse: () => createResponse,
|
|
25
|
+
createSchema: () => createSchema,
|
|
26
|
+
createSource: () => createSource,
|
|
27
|
+
createText: () => createText,
|
|
28
|
+
createType: () => createType,
|
|
29
|
+
createTypeLiteral: () => createTypeLiteral,
|
|
30
|
+
update: () => update
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Identity-preserving node update: returns `node` unchanged when every field in
|
|
34
|
+
* `changes` already equals (by reference) the current value, otherwise a new node
|
|
35
|
+
* with the changes applied.
|
|
36
|
+
*
|
|
37
|
+
* Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
|
|
38
|
+
* structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
|
|
39
|
+
* downstream passes can detect "nothing changed" by identity. Comparison is
|
|
40
|
+
* shallow: a structurally-equal but newly-allocated array/object counts as a change.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* update(node, { name: node.name }) // -> same `node` reference
|
|
45
|
+
* update(node, { name: 'renamed' }) // -> new node, `name` replaced
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function update(node, changes) {
|
|
49
|
+
for (const key in changes) if (changes[key] !== node[key]) return {
|
|
50
|
+
...node,
|
|
51
|
+
...changes
|
|
52
|
+
};
|
|
53
|
+
return node;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, factory_exports as t, update };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the\n * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is\n * shallow: a structurally-equal but newly-allocated array/object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT"}
|