@kubb/ast 5.0.0-beta.6 → 5.0.0-beta.61

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.
Files changed (102) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +51 -27
  3. package/dist/chunk-CNktS9qV.js +17 -0
  4. package/dist/defineMacro-BLIR6k-j.d.ts +475 -0
  5. package/dist/defineMacro-BTXvS8nI.js +106 -0
  6. package/dist/defineMacro-BTXvS8nI.js.map +1 -0
  7. package/dist/defineMacro-Bv9R_9a2.cjs +123 -0
  8. package/dist/defineMacro-Bv9R_9a2.cjs.map +1 -0
  9. package/dist/extractStringsFromNodes-Cja-xxx5.js +29 -0
  10. package/dist/extractStringsFromNodes-Cja-xxx5.js.map +1 -0
  11. package/dist/extractStringsFromNodes-DKgDjFO0.cjs +34 -0
  12. package/dist/extractStringsFromNodes-DKgDjFO0.cjs.map +1 -0
  13. package/dist/extractStringsFromNodes-p4mX1TQD.d.ts +14 -0
  14. package/dist/factory-CZNOGI-N.js +283 -0
  15. package/dist/factory-CZNOGI-N.js.map +1 -0
  16. package/dist/factory-DG1CVkEb.cjs +300 -0
  17. package/dist/factory-DG1CVkEb.cjs.map +1 -0
  18. package/dist/factory.cjs +29 -0
  19. package/dist/factory.d.ts +62 -0
  20. package/dist/factory.js +3 -0
  21. package/dist/index-BzjwdK2M.d.ts +2433 -0
  22. package/dist/index.cjs +444 -2180
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +94 -3408
  25. package/dist/index.js +395 -2101
  26. package/dist/index.js.map +1 -1
  27. package/dist/macros.cjs +117 -0
  28. package/dist/macros.cjs.map +1 -0
  29. package/dist/macros.d.ts +59 -0
  30. package/dist/macros.js +115 -0
  31. package/dist/macros.js.map +1 -0
  32. package/dist/operationParams-BZ07xDm0.d.ts +204 -0
  33. package/dist/response-KUdWiDWw.js +658 -0
  34. package/dist/response-KUdWiDWw.js.map +1 -0
  35. package/dist/response-hnSw2NKE.cjs +1027 -0
  36. package/dist/response-hnSw2NKE.cjs.map +1 -0
  37. package/dist/types-DyDzizSf.d.ts +364 -0
  38. package/dist/types.cjs +0 -0
  39. package/dist/types.d.ts +6 -0
  40. package/dist/types.js +1 -0
  41. package/dist/utils-BLJwyza-.cjs +912 -0
  42. package/dist/utils-BLJwyza-.cjs.map +1 -0
  43. package/dist/utils-CF_-Pn_c.js +770 -0
  44. package/dist/utils-CF_-Pn_c.js.map +1 -0
  45. package/dist/utils.cjs +36 -0
  46. package/dist/utils.d.ts +358 -0
  47. package/dist/utils.js +4 -0
  48. package/dist/visitor-DJ6ZEJvq.js +548 -0
  49. package/dist/visitor-DJ6ZEJvq.js.map +1 -0
  50. package/dist/visitor-DpKZ9Tk0.cjs +654 -0
  51. package/dist/visitor-DpKZ9Tk0.cjs.map +1 -0
  52. package/package.json +21 -6
  53. package/src/constants.ts +19 -64
  54. package/src/dedupe.ts +239 -0
  55. package/src/defineMacro.ts +132 -0
  56. package/src/dialect.ts +53 -0
  57. package/src/factory.ts +67 -678
  58. package/src/guards.ts +10 -92
  59. package/src/index.ts +13 -44
  60. package/src/infer.ts +16 -14
  61. package/src/macros/index.ts +3 -0
  62. package/src/macros/macroDiscriminatorEnum.ts +44 -0
  63. package/src/macros/macroEnumName.ts +25 -0
  64. package/src/macros/macroSimplifyUnion.ts +50 -0
  65. package/src/mocks.ts +7 -127
  66. package/src/node.ts +128 -0
  67. package/src/nodes/base.ts +5 -12
  68. package/src/nodes/code.ts +165 -74
  69. package/src/nodes/content.ts +56 -0
  70. package/src/nodes/file.ts +97 -36
  71. package/src/nodes/function.ts +216 -156
  72. package/src/nodes/http.ts +1 -35
  73. package/src/nodes/index.ts +23 -15
  74. package/src/nodes/input.ts +140 -0
  75. package/src/nodes/operation.ts +122 -68
  76. package/src/nodes/output.ts +23 -0
  77. package/src/nodes/parameter.ts +33 -3
  78. package/src/nodes/property.ts +36 -3
  79. package/src/nodes/requestBody.ts +61 -0
  80. package/src/nodes/response.ts +58 -13
  81. package/src/nodes/schema.ts +93 -17
  82. package/src/printer.ts +48 -42
  83. package/src/registry.ts +75 -0
  84. package/src/signature.ts +207 -0
  85. package/src/types.ts +8 -68
  86. package/src/utils/codegen.ts +104 -0
  87. package/src/utils/extractStringsFromNodes.ts +34 -0
  88. package/src/utils/fileMerge.ts +184 -0
  89. package/src/utils/index.ts +11 -0
  90. package/src/utils/operationParams.ts +353 -0
  91. package/src/utils/refs.ts +138 -0
  92. package/src/utils/schemaGraph.ts +169 -0
  93. package/src/utils/schemaMerge.ts +34 -0
  94. package/src/utils/schemaTraversal.ts +86 -0
  95. package/src/utils/strings.ts +139 -0
  96. package/src/visitor.ts +227 -289
  97. package/dist/chunk--u3MIqq1.js +0 -8
  98. package/src/nodes/root.ts +0 -64
  99. package/src/refs.ts +0 -67
  100. package/src/resolvers.ts +0 -45
  101. package/src/transformers.ts +0 -159
  102. package/src/utils.ts +0 -915
@@ -0,0 +1,1027 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ //#endregion
36
+ //#region src/node.ts
37
+ /**
38
+ * Builds a type guard that matches nodes of the given `kind`.
39
+ */
40
+ function isKind(kind) {
41
+ return (node) => node.kind === kind;
42
+ }
43
+ /**
44
+ * Updates a schema's `optional` and `nullish` flags from a parent's `required`
45
+ * value and the schema's own `nullable`. Mirrors how OpenAPI parameters and
46
+ * object properties combine "required" and "nullable" into a single AST.
47
+ *
48
+ * - Non-required + non-nullable → `optional: true`.
49
+ * - Non-required + nullable → `nullish: true`.
50
+ * - Required → both flags cleared.
51
+ */
52
+ function syncOptionality(schema, required) {
53
+ const nullable = schema.nullable ?? false;
54
+ return {
55
+ ...schema,
56
+ optional: !required && !nullable ? true : void 0,
57
+ nullish: !required && nullable ? true : void 0
58
+ };
59
+ }
60
+ /**
61
+ * Defines a node once and derives its `create` builder, `is` guard, and traversal
62
+ * metadata. `create` merges `defaults`, the `build` hook (or the raw input), and the
63
+ * `kind`, so node construction lives in one place without scattered `as` casts.
64
+ *
65
+ * Set `rebuild: true` when the `build` hook derives fields from children. After a
66
+ * transform rewrites those children, the registry reruns `create` so the derived
67
+ * fields stay correct.
68
+ *
69
+ * @example Simple node
70
+ * ```ts
71
+ * const importDef = defineNode<ImportNode>({ kind: 'Import' })
72
+ * const createImport = importDef.create
73
+ * ```
74
+ *
75
+ * @example Node with a build hook that is rerun on transform
76
+ * ```ts
77
+ * const propertyDef = defineNode<PropertyNode, UserPropertyNode>({
78
+ * kind: 'Property',
79
+ * build: (props) => ({ ...props, required: props.required ?? false }),
80
+ * children: ['schema'],
81
+ * visitorKey: 'property',
82
+ * rebuild: true,
83
+ * })
84
+ * ```
85
+ */
86
+ function defineNode(config) {
87
+ const { kind, defaults, build, children, visitorKey, rebuild } = config;
88
+ function create(input) {
89
+ const base = build ? build(input) : input;
90
+ return {
91
+ ...defaults,
92
+ ...base,
93
+ kind
94
+ };
95
+ }
96
+ return {
97
+ kind,
98
+ create,
99
+ is: isKind(kind),
100
+ children,
101
+ visitorKey,
102
+ rebuild
103
+ };
104
+ }
105
+ //#endregion
106
+ //#region src/nodes/schema.ts
107
+ /**
108
+ * Maps schema `type` to its underlying `primitive`.
109
+ * Primitive types map to themselves. Special string formats map to `'string'`.
110
+ * Complex types (`ref`, `enum`, `union`, `intersection`, `tuple`, `blob`) are left unset.
111
+ */
112
+ const TYPE_TO_PRIMITIVE = {
113
+ string: "string",
114
+ number: "number",
115
+ integer: "integer",
116
+ bigint: "bigint",
117
+ boolean: "boolean",
118
+ null: "null",
119
+ any: "any",
120
+ unknown: "unknown",
121
+ void: "void",
122
+ never: "never",
123
+ object: "object",
124
+ array: "array",
125
+ date: "date",
126
+ uuid: "string",
127
+ email: "string",
128
+ url: "string",
129
+ datetime: "string",
130
+ time: "string"
131
+ };
132
+ /**
133
+ * Definition for the {@link SchemaNode}. Object schemas default `properties` to an
134
+ * empty array, and `primitive` is inferred from `type` when not explicitly provided.
135
+ */
136
+ const schemaDef = defineNode({
137
+ kind: "Schema",
138
+ build: (props) => {
139
+ if (props.type === "object") return {
140
+ properties: [],
141
+ primitive: "object",
142
+ ...props
143
+ };
144
+ return {
145
+ primitive: TYPE_TO_PRIMITIVE[props.type],
146
+ ...props
147
+ };
148
+ },
149
+ children: [
150
+ "properties",
151
+ "items",
152
+ "members",
153
+ "additionalProperties"
154
+ ],
155
+ visitorKey: "schema"
156
+ });
157
+ function createSchema(props) {
158
+ return schemaDef.create(props);
159
+ }
160
+ //#endregion
161
+ //#region ../../internals/utils/src/casing.ts
162
+ /**
163
+ * Shared implementation for camelCase and PascalCase conversion.
164
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
165
+ * and capitalizes each word according to `pascal`.
166
+ *
167
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
168
+ */
169
+ function toCamelOrPascal(text, pascal) {
170
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
171
+ if (word.length > 1 && word === word.toUpperCase()) return word;
172
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
173
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
174
+ }
175
+ /**
176
+ * Converts `text` to camelCase.
177
+ *
178
+ * @example Word boundaries
179
+ * `camelCase('hello-world') // 'helloWorld'`
180
+ *
181
+ * @example With a prefix
182
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
183
+ */
184
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
185
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
186
+ }
187
+ /**
188
+ * Converts `text` to PascalCase.
189
+ *
190
+ * @example Word boundaries
191
+ * `pascalCase('hello-world') // 'HelloWorld'`
192
+ *
193
+ * @example With a suffix
194
+ * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
195
+ */
196
+ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
197
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
198
+ }
199
+ //#endregion
200
+ //#region src/nodes/code.ts
201
+ /**
202
+ * Definition for the {@link ConstNode}.
203
+ */
204
+ const constDef = defineNode({ kind: "Const" });
205
+ /**
206
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
207
+ *
208
+ * @example Exported constant with type and `as const`
209
+ * ```ts
210
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
211
+ * // export const pets: Pet[] = ... as const
212
+ * ```
213
+ */
214
+ const createConst = constDef.create;
215
+ /**
216
+ * Definition for the {@link TypeNode}.
217
+ */
218
+ const typeDef = defineNode({ kind: "Type" });
219
+ /**
220
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * createType({ name: 'Pet', export: true })
225
+ * // export type Pet = ...
226
+ * ```
227
+ */
228
+ const createType = typeDef.create;
229
+ /**
230
+ * Definition for the {@link FunctionNode}.
231
+ */
232
+ const functionDef = defineNode({ kind: "Function" });
233
+ /**
234
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
239
+ * // export async function fetchPet(): Promise<Pet> { ... }
240
+ * ```
241
+ */
242
+ const createFunction = functionDef.create;
243
+ /**
244
+ * Definition for the {@link ArrowFunctionNode}.
245
+ */
246
+ const arrowFunctionDef = defineNode({ kind: "ArrowFunction" });
247
+ /**
248
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
253
+ * // export const double = (n: number) => ...
254
+ * ```
255
+ */
256
+ const createArrowFunction = arrowFunctionDef.create;
257
+ /**
258
+ * Definition for the {@link TextNode}.
259
+ */
260
+ const textDef = defineNode({
261
+ kind: "Text",
262
+ build: (value) => ({ value })
263
+ });
264
+ /**
265
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * createText('return fetch(id)')
270
+ * // { kind: 'Text', value: 'return fetch(id)' }
271
+ * ```
272
+ */
273
+ const createText = textDef.create;
274
+ /**
275
+ * Definition for the {@link BreakNode}.
276
+ */
277
+ const breakDef = defineNode({
278
+ kind: "Break",
279
+ build: () => ({})
280
+ });
281
+ /**
282
+ * Creates a {@link BreakNode} representing a line break in the source output.
283
+ *
284
+ * @example
285
+ * ```ts
286
+ * createBreak()
287
+ * // { kind: 'Break' }
288
+ * ```
289
+ */
290
+ function createBreak() {
291
+ return breakDef.create();
292
+ }
293
+ /**
294
+ * Definition for the {@link JsxNode}.
295
+ */
296
+ const jsxDef = defineNode({
297
+ kind: "Jsx",
298
+ build: (value) => ({ value })
299
+ });
300
+ /**
301
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
306
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
307
+ * ```
308
+ */
309
+ const createJsx = jsxDef.create;
310
+ //#endregion
311
+ //#region src/nodes/content.ts
312
+ /**
313
+ * Definition for the {@link ContentNode}.
314
+ */
315
+ const contentDef = defineNode({
316
+ kind: "Content",
317
+ children: ["schema"]
318
+ });
319
+ /**
320
+ * Creates a `ContentNode` for a single request-body or response content type.
321
+ */
322
+ const createContent = contentDef.create;
323
+ //#endregion
324
+ //#region src/nodes/file.ts
325
+ /**
326
+ * Definition for the {@link ImportNode}.
327
+ */
328
+ const importDef = defineNode({ kind: "Import" });
329
+ /**
330
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
331
+ *
332
+ * @example Named import
333
+ * ```ts
334
+ * createImport({ name: ['useState'], path: 'react' })
335
+ * // import { useState } from 'react'
336
+ * ```
337
+ */
338
+ const createImport = importDef.create;
339
+ /**
340
+ * Definition for the {@link ExportNode}.
341
+ */
342
+ const exportDef = defineNode({ kind: "Export" });
343
+ /**
344
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
345
+ *
346
+ * @example Named export
347
+ * ```ts
348
+ * createExport({ name: ['Pet'], path: './Pet' })
349
+ * // export { Pet } from './Pet'
350
+ * ```
351
+ */
352
+ const createExport = exportDef.create;
353
+ /**
354
+ * Definition for the {@link SourceNode}.
355
+ */
356
+ const sourceDef = defineNode({ kind: "Source" });
357
+ /**
358
+ * Creates a `SourceNode` representing a fragment of source code within a file.
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
363
+ * ```
364
+ */
365
+ const createSource = sourceDef.create;
366
+ /**
367
+ * Definition for the {@link FileNode}. The fully resolved builder lives in
368
+ * `createFile`, so this definition only supplies the guard.
369
+ */
370
+ const fileDef = defineNode({ kind: "File" });
371
+ //#endregion
372
+ //#region src/nodes/function.ts
373
+ /**
374
+ * Definition for the {@link TypeLiteralNode}.
375
+ */
376
+ const typeLiteralDef = defineNode({ kind: "TypeLiteral" });
377
+ /**
378
+ * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
383
+ * // { petId: string }
384
+ * ```
385
+ */
386
+ const createTypeLiteral = typeLiteralDef.create;
387
+ /**
388
+ * Definition for the {@link IndexedAccessTypeNode}.
389
+ */
390
+ const indexedAccessTypeDef = defineNode({ kind: "IndexedAccessType" });
391
+ /**
392
+ * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * createIndexedAccessType({ objectType: 'DeletePetPathParams', indexType: 'petId' })
397
+ * // DeletePetPathParams['petId']
398
+ * ```
399
+ */
400
+ const createIndexedAccessType = indexedAccessTypeDef.create;
401
+ /**
402
+ * Definition for the {@link ObjectBindingPatternNode}.
403
+ */
404
+ const objectBindingPatternDef = defineNode({ kind: "ObjectBindingPattern" });
405
+ /**
406
+ * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
411
+ * // { id, name }
412
+ * ```
413
+ */
414
+ const createObjectBindingPattern = objectBindingPatternDef.create;
415
+ /**
416
+ * Definition for the {@link FunctionParameterNode}. `optional` defaults to `false`.
417
+ * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name
418
+ * paired with a {@link TypeLiteralNode} type.
419
+ */
420
+ const functionParameterDef = defineNode({
421
+ kind: "FunctionParameter",
422
+ build: (input) => {
423
+ if ("properties" in input) return {
424
+ name: createObjectBindingPattern({ elements: input.properties.map((p) => ({ name: p.name })) }),
425
+ type: createTypeLiteral({ members: input.properties.map((p) => ({
426
+ name: p.name,
427
+ type: p.type,
428
+ optional: p.optional ?? false
429
+ })) }),
430
+ optional: input.optional ?? false,
431
+ ...input.default !== void 0 ? { default: input.default } : {}
432
+ };
433
+ return {
434
+ optional: false,
435
+ ...input
436
+ };
437
+ }
438
+ });
439
+ /**
440
+ * Creates a `FunctionParameterNode`. `optional` defaults to `false`.
441
+ *
442
+ * @example Optional param
443
+ * ```ts
444
+ * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })
445
+ * // → params?: QueryParams
446
+ * ```
447
+ *
448
+ * @example Destructured group
449
+ * ```ts
450
+ * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })
451
+ * // → { id, name }: { id: string; name?: string } = {}
452
+ * ```
453
+ */
454
+ const createFunctionParameter = functionParameterDef.create;
455
+ /**
456
+ * Definition for the {@link FunctionParametersNode}.
457
+ */
458
+ const functionParametersDef = defineNode({
459
+ kind: "FunctionParameters",
460
+ defaults: { params: [] }
461
+ });
462
+ /**
463
+ * Creates a `FunctionParametersNode` from an ordered list of parameters.
464
+ *
465
+ * @example
466
+ * ```ts
467
+ * const empty = createFunctionParameters()
468
+ * // { kind: 'FunctionParameters', params: [] }
469
+ * ```
470
+ */
471
+ function createFunctionParameters(props = {}) {
472
+ return functionParametersDef.create(props);
473
+ }
474
+ //#endregion
475
+ //#region src/nodes/input.ts
476
+ /**
477
+ * Definition for the {@link InputNode}.
478
+ */
479
+ const inputDef = defineNode({
480
+ kind: "Input",
481
+ defaults: {
482
+ schemas: [],
483
+ operations: [],
484
+ meta: {
485
+ circularNames: [],
486
+ enumNames: []
487
+ }
488
+ },
489
+ children: ["schemas", "operations"],
490
+ visitorKey: "input"
491
+ });
492
+ /**
493
+ * Creates an `InputNode`. Pass `stream: true` for the streaming variant whose `schemas` and
494
+ * `operations` are `AsyncIterable` sources and whose `meta` is optional. Otherwise it builds the
495
+ * eager variant with array `schemas`/`operations` and the defaulted `meta`.
496
+ *
497
+ * @example Eager
498
+ * ```ts
499
+ * const input = createInput()
500
+ * // { kind: 'Input', schemas: [], operations: [] }
501
+ * ```
502
+ *
503
+ * @example Streaming
504
+ * ```ts
505
+ * const node = createInput({ stream: true, schemas: schemasIterable, operations: operationsIterable, meta: { title: 'My API' } })
506
+ * ```
507
+ */
508
+ function createInput(options = {}) {
509
+ const { stream, ...overrides } = options;
510
+ if (stream) return {
511
+ kind: "Input",
512
+ ...overrides
513
+ };
514
+ return inputDef.create(overrides);
515
+ }
516
+ //#endregion
517
+ //#region src/nodes/requestBody.ts
518
+ /**
519
+ * Definition for the {@link RequestBodyNode}, normalizing each content entry into a `ContentNode`.
520
+ */
521
+ const requestBodyDef = defineNode({
522
+ kind: "RequestBody",
523
+ build: (props) => ({
524
+ ...props,
525
+ content: props.content?.map(createContent)
526
+ }),
527
+ children: ["content"]
528
+ });
529
+ /**
530
+ * Creates a `RequestBodyNode`, normalizing each content entry into a `ContentNode`.
531
+ */
532
+ const createRequestBody = requestBodyDef.create;
533
+ //#endregion
534
+ //#region src/nodes/operation.ts
535
+ /**
536
+ * Definition for the {@link OperationNode}. HTTP operations (those carrying both
537
+ * `method` and `path`) are tagged with `protocol: 'http'`, and the request body is
538
+ * normalized into a `RequestBodyNode`.
539
+ */
540
+ const operationDef = defineNode({
541
+ kind: "Operation",
542
+ build: (props) => {
543
+ const { requestBody, ...rest } = props;
544
+ const isHttp = rest.method !== void 0 && rest.path !== void 0;
545
+ return {
546
+ tags: [],
547
+ parameters: [],
548
+ responses: [],
549
+ ...rest,
550
+ ...isHttp ? { protocol: "http" } : {},
551
+ requestBody: requestBody ? createRequestBody(requestBody) : void 0
552
+ };
553
+ },
554
+ children: [
555
+ "parameters",
556
+ "requestBody",
557
+ "responses"
558
+ ],
559
+ visitorKey: "operation"
560
+ });
561
+ function createOperation(props) {
562
+ return operationDef.create(props);
563
+ }
564
+ //#endregion
565
+ //#region src/nodes/output.ts
566
+ /**
567
+ * Definition for the {@link OutputNode}.
568
+ */
569
+ const outputDef = defineNode({
570
+ kind: "Output",
571
+ defaults: { files: [] },
572
+ visitorKey: "output"
573
+ });
574
+ /**
575
+ * Creates an `OutputNode` with a stable default for `files`.
576
+ *
577
+ * @example
578
+ * ```ts
579
+ * const output = createOutput()
580
+ * // { kind: 'Output', files: [] }
581
+ * ```
582
+ */
583
+ function createOutput(overrides = {}) {
584
+ return outputDef.create(overrides);
585
+ }
586
+ //#endregion
587
+ //#region src/nodes/parameter.ts
588
+ /**
589
+ * Definition for the {@link ParameterNode}. `required` defaults to `false` and the
590
+ * schema's `optional`/`nullish` flags are kept in sync with it.
591
+ */
592
+ const parameterDef = defineNode({
593
+ kind: "Parameter",
594
+ build: (props) => {
595
+ const required = props.required ?? false;
596
+ return {
597
+ ...props,
598
+ required,
599
+ schema: syncOptionality(props.schema, required)
600
+ };
601
+ },
602
+ children: ["schema"],
603
+ visitorKey: "parameter",
604
+ rebuild: true
605
+ });
606
+ /**
607
+ * Creates a `ParameterNode`.
608
+ *
609
+ * @example
610
+ * ```ts
611
+ * const param = createParameter({
612
+ * name: 'petId',
613
+ * in: 'path',
614
+ * required: true,
615
+ * schema: createSchema({ type: 'string' }),
616
+ * })
617
+ * ```
618
+ */
619
+ const createParameter = parameterDef.create;
620
+ //#endregion
621
+ //#region src/nodes/property.ts
622
+ /**
623
+ * Definition for the {@link PropertyNode}. `required` defaults to `false` and the
624
+ * schema's `optional`/`nullish` flags are kept in sync with it.
625
+ */
626
+ const propertyDef = defineNode({
627
+ kind: "Property",
628
+ build: (props) => {
629
+ const required = props.required ?? false;
630
+ return {
631
+ ...props,
632
+ required,
633
+ schema: syncOptionality(props.schema, required)
634
+ };
635
+ },
636
+ children: ["schema"],
637
+ visitorKey: "property",
638
+ rebuild: true
639
+ });
640
+ /**
641
+ * Creates a `PropertyNode`.
642
+ *
643
+ * @example
644
+ * ```ts
645
+ * const property = createProperty({
646
+ * name: 'status',
647
+ * required: true,
648
+ * schema: createSchema({ type: 'string', nullable: true }),
649
+ * })
650
+ * // required=true, no optional/nullish
651
+ * ```
652
+ */
653
+ const createProperty = propertyDef.create;
654
+ //#endregion
655
+ //#region src/nodes/response.ts
656
+ /**
657
+ * Definition for the {@link ResponseNode}. A single legacy `schema` (with optional
658
+ * `mediaType`/`keysToOmit`) is normalized into one `content` entry.
659
+ */
660
+ const responseDef = defineNode({
661
+ kind: "Response",
662
+ build: (props) => {
663
+ const { schema, mediaType, keysToOmit, content, ...rest } = props;
664
+ const entries = content ?? (schema ? [{
665
+ contentType: mediaType ?? "application/json",
666
+ schema,
667
+ keysToOmit: keysToOmit ?? null
668
+ }] : void 0);
669
+ return {
670
+ ...rest,
671
+ content: entries?.map(createContent)
672
+ };
673
+ },
674
+ children: ["content"],
675
+ visitorKey: "response"
676
+ });
677
+ /**
678
+ * Creates a `ResponseNode`.
679
+ *
680
+ * @example
681
+ * ```ts
682
+ * const response = createResponse({
683
+ * statusCode: '200',
684
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],
685
+ * })
686
+ * ```
687
+ */
688
+ const createResponse = responseDef.create;
689
+ //#endregion
690
+ Object.defineProperty(exports, "__exportAll", {
691
+ enumerable: true,
692
+ get: function() {
693
+ return __exportAll;
694
+ }
695
+ });
696
+ Object.defineProperty(exports, "__name", {
697
+ enumerable: true,
698
+ get: function() {
699
+ return __name;
700
+ }
701
+ });
702
+ Object.defineProperty(exports, "__toESM", {
703
+ enumerable: true,
704
+ get: function() {
705
+ return __toESM;
706
+ }
707
+ });
708
+ Object.defineProperty(exports, "arrowFunctionDef", {
709
+ enumerable: true,
710
+ get: function() {
711
+ return arrowFunctionDef;
712
+ }
713
+ });
714
+ Object.defineProperty(exports, "breakDef", {
715
+ enumerable: true,
716
+ get: function() {
717
+ return breakDef;
718
+ }
719
+ });
720
+ Object.defineProperty(exports, "camelCase", {
721
+ enumerable: true,
722
+ get: function() {
723
+ return camelCase;
724
+ }
725
+ });
726
+ Object.defineProperty(exports, "constDef", {
727
+ enumerable: true,
728
+ get: function() {
729
+ return constDef;
730
+ }
731
+ });
732
+ Object.defineProperty(exports, "contentDef", {
733
+ enumerable: true,
734
+ get: function() {
735
+ return contentDef;
736
+ }
737
+ });
738
+ Object.defineProperty(exports, "createArrowFunction", {
739
+ enumerable: true,
740
+ get: function() {
741
+ return createArrowFunction;
742
+ }
743
+ });
744
+ Object.defineProperty(exports, "createBreak", {
745
+ enumerable: true,
746
+ get: function() {
747
+ return createBreak;
748
+ }
749
+ });
750
+ Object.defineProperty(exports, "createConst", {
751
+ enumerable: true,
752
+ get: function() {
753
+ return createConst;
754
+ }
755
+ });
756
+ Object.defineProperty(exports, "createContent", {
757
+ enumerable: true,
758
+ get: function() {
759
+ return createContent;
760
+ }
761
+ });
762
+ Object.defineProperty(exports, "createExport", {
763
+ enumerable: true,
764
+ get: function() {
765
+ return createExport;
766
+ }
767
+ });
768
+ Object.defineProperty(exports, "createFunction", {
769
+ enumerable: true,
770
+ get: function() {
771
+ return createFunction;
772
+ }
773
+ });
774
+ Object.defineProperty(exports, "createFunctionParameter", {
775
+ enumerable: true,
776
+ get: function() {
777
+ return createFunctionParameter;
778
+ }
779
+ });
780
+ Object.defineProperty(exports, "createFunctionParameters", {
781
+ enumerable: true,
782
+ get: function() {
783
+ return createFunctionParameters;
784
+ }
785
+ });
786
+ Object.defineProperty(exports, "createImport", {
787
+ enumerable: true,
788
+ get: function() {
789
+ return createImport;
790
+ }
791
+ });
792
+ Object.defineProperty(exports, "createIndexedAccessType", {
793
+ enumerable: true,
794
+ get: function() {
795
+ return createIndexedAccessType;
796
+ }
797
+ });
798
+ Object.defineProperty(exports, "createInput", {
799
+ enumerable: true,
800
+ get: function() {
801
+ return createInput;
802
+ }
803
+ });
804
+ Object.defineProperty(exports, "createJsx", {
805
+ enumerable: true,
806
+ get: function() {
807
+ return createJsx;
808
+ }
809
+ });
810
+ Object.defineProperty(exports, "createObjectBindingPattern", {
811
+ enumerable: true,
812
+ get: function() {
813
+ return createObjectBindingPattern;
814
+ }
815
+ });
816
+ Object.defineProperty(exports, "createOperation", {
817
+ enumerable: true,
818
+ get: function() {
819
+ return createOperation;
820
+ }
821
+ });
822
+ Object.defineProperty(exports, "createOutput", {
823
+ enumerable: true,
824
+ get: function() {
825
+ return createOutput;
826
+ }
827
+ });
828
+ Object.defineProperty(exports, "createParameter", {
829
+ enumerable: true,
830
+ get: function() {
831
+ return createParameter;
832
+ }
833
+ });
834
+ Object.defineProperty(exports, "createProperty", {
835
+ enumerable: true,
836
+ get: function() {
837
+ return createProperty;
838
+ }
839
+ });
840
+ Object.defineProperty(exports, "createRequestBody", {
841
+ enumerable: true,
842
+ get: function() {
843
+ return createRequestBody;
844
+ }
845
+ });
846
+ Object.defineProperty(exports, "createResponse", {
847
+ enumerable: true,
848
+ get: function() {
849
+ return createResponse;
850
+ }
851
+ });
852
+ Object.defineProperty(exports, "createSchema", {
853
+ enumerable: true,
854
+ get: function() {
855
+ return createSchema;
856
+ }
857
+ });
858
+ Object.defineProperty(exports, "createSource", {
859
+ enumerable: true,
860
+ get: function() {
861
+ return createSource;
862
+ }
863
+ });
864
+ Object.defineProperty(exports, "createText", {
865
+ enumerable: true,
866
+ get: function() {
867
+ return createText;
868
+ }
869
+ });
870
+ Object.defineProperty(exports, "createType", {
871
+ enumerable: true,
872
+ get: function() {
873
+ return createType;
874
+ }
875
+ });
876
+ Object.defineProperty(exports, "createTypeLiteral", {
877
+ enumerable: true,
878
+ get: function() {
879
+ return createTypeLiteral;
880
+ }
881
+ });
882
+ Object.defineProperty(exports, "defineNode", {
883
+ enumerable: true,
884
+ get: function() {
885
+ return defineNode;
886
+ }
887
+ });
888
+ Object.defineProperty(exports, "exportDef", {
889
+ enumerable: true,
890
+ get: function() {
891
+ return exportDef;
892
+ }
893
+ });
894
+ Object.defineProperty(exports, "fileDef", {
895
+ enumerable: true,
896
+ get: function() {
897
+ return fileDef;
898
+ }
899
+ });
900
+ Object.defineProperty(exports, "functionDef", {
901
+ enumerable: true,
902
+ get: function() {
903
+ return functionDef;
904
+ }
905
+ });
906
+ Object.defineProperty(exports, "functionParameterDef", {
907
+ enumerable: true,
908
+ get: function() {
909
+ return functionParameterDef;
910
+ }
911
+ });
912
+ Object.defineProperty(exports, "functionParametersDef", {
913
+ enumerable: true,
914
+ get: function() {
915
+ return functionParametersDef;
916
+ }
917
+ });
918
+ Object.defineProperty(exports, "importDef", {
919
+ enumerable: true,
920
+ get: function() {
921
+ return importDef;
922
+ }
923
+ });
924
+ Object.defineProperty(exports, "indexedAccessTypeDef", {
925
+ enumerable: true,
926
+ get: function() {
927
+ return indexedAccessTypeDef;
928
+ }
929
+ });
930
+ Object.defineProperty(exports, "inputDef", {
931
+ enumerable: true,
932
+ get: function() {
933
+ return inputDef;
934
+ }
935
+ });
936
+ Object.defineProperty(exports, "jsxDef", {
937
+ enumerable: true,
938
+ get: function() {
939
+ return jsxDef;
940
+ }
941
+ });
942
+ Object.defineProperty(exports, "objectBindingPatternDef", {
943
+ enumerable: true,
944
+ get: function() {
945
+ return objectBindingPatternDef;
946
+ }
947
+ });
948
+ Object.defineProperty(exports, "operationDef", {
949
+ enumerable: true,
950
+ get: function() {
951
+ return operationDef;
952
+ }
953
+ });
954
+ Object.defineProperty(exports, "outputDef", {
955
+ enumerable: true,
956
+ get: function() {
957
+ return outputDef;
958
+ }
959
+ });
960
+ Object.defineProperty(exports, "parameterDef", {
961
+ enumerable: true,
962
+ get: function() {
963
+ return parameterDef;
964
+ }
965
+ });
966
+ Object.defineProperty(exports, "pascalCase", {
967
+ enumerable: true,
968
+ get: function() {
969
+ return pascalCase;
970
+ }
971
+ });
972
+ Object.defineProperty(exports, "propertyDef", {
973
+ enumerable: true,
974
+ get: function() {
975
+ return propertyDef;
976
+ }
977
+ });
978
+ Object.defineProperty(exports, "requestBodyDef", {
979
+ enumerable: true,
980
+ get: function() {
981
+ return requestBodyDef;
982
+ }
983
+ });
984
+ Object.defineProperty(exports, "responseDef", {
985
+ enumerable: true,
986
+ get: function() {
987
+ return responseDef;
988
+ }
989
+ });
990
+ Object.defineProperty(exports, "schemaDef", {
991
+ enumerable: true,
992
+ get: function() {
993
+ return schemaDef;
994
+ }
995
+ });
996
+ Object.defineProperty(exports, "sourceDef", {
997
+ enumerable: true,
998
+ get: function() {
999
+ return sourceDef;
1000
+ }
1001
+ });
1002
+ Object.defineProperty(exports, "syncOptionality", {
1003
+ enumerable: true,
1004
+ get: function() {
1005
+ return syncOptionality;
1006
+ }
1007
+ });
1008
+ Object.defineProperty(exports, "textDef", {
1009
+ enumerable: true,
1010
+ get: function() {
1011
+ return textDef;
1012
+ }
1013
+ });
1014
+ Object.defineProperty(exports, "typeDef", {
1015
+ enumerable: true,
1016
+ get: function() {
1017
+ return typeDef;
1018
+ }
1019
+ });
1020
+ Object.defineProperty(exports, "typeLiteralDef", {
1021
+ enumerable: true,
1022
+ get: function() {
1023
+ return typeLiteralDef;
1024
+ }
1025
+ });
1026
+
1027
+ //# sourceMappingURL=response-hnSw2NKE.cjs.map