@kubb/ast 5.0.0-beta.7 → 5.0.0-beta.71

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 (65) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +53 -27
  3. package/dist/defineMacro-5Dvct8k_.cjs +114 -0
  4. package/dist/defineMacro-5Dvct8k_.cjs.map +1 -0
  5. package/dist/defineMacro-BXpTwp0y.d.ts +466 -0
  6. package/dist/defineMacro-VfsvblGi.js +98 -0
  7. package/dist/defineMacro-VfsvblGi.js.map +1 -0
  8. package/dist/index-DJEyS5y6.d.ts +2428 -0
  9. package/dist/index.cjs +198 -2239
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +98 -3400
  12. package/dist/index.js +149 -2160
  13. package/dist/index.js.map +1 -1
  14. package/dist/macros.cjs +130 -0
  15. package/dist/macros.cjs.map +1 -0
  16. package/dist/macros.d.ts +61 -0
  17. package/dist/macros.js +128 -0
  18. package/dist/macros.js.map +1 -0
  19. package/dist/operationParams-BaY12i2I.d.ts +148 -0
  20. package/dist/refs-D18OeCgb.js +117 -0
  21. package/dist/refs-D18OeCgb.js.map +1 -0
  22. package/dist/refs-DuP3_Leg.cjs +157 -0
  23. package/dist/refs-DuP3_Leg.cjs.map +1 -0
  24. package/dist/rolldown-runtime-CNktS9qV.js +17 -0
  25. package/dist/types-BsP1SK9j.d.ts +244 -0
  26. package/dist/types.cjs +0 -0
  27. package/dist/types.d.ts +5 -0
  28. package/dist/types.js +1 -0
  29. package/dist/utils.cjs +803 -0
  30. package/dist/utils.cjs.map +1 -0
  31. package/dist/utils.d.ts +354 -0
  32. package/dist/utils.js +777 -0
  33. package/dist/utils.js.map +1 -0
  34. package/dist/visitor-CQdSiClY.cjs +1749 -0
  35. package/dist/visitor-CQdSiClY.cjs.map +1 -0
  36. package/dist/visitor-dcVC5TOW.js +1313 -0
  37. package/dist/visitor-dcVC5TOW.js.map +1 -0
  38. package/package.json +17 -5
  39. package/dist/chunk--u3MIqq1.js +0 -8
  40. package/src/constants.ts +0 -228
  41. package/src/factory.ts +0 -742
  42. package/src/guards.ts +0 -110
  43. package/src/index.ts +0 -46
  44. package/src/infer.ts +0 -130
  45. package/src/mocks.ts +0 -176
  46. package/src/nodes/base.ts +0 -56
  47. package/src/nodes/code.ts +0 -304
  48. package/src/nodes/file.ts +0 -230
  49. package/src/nodes/function.ts +0 -223
  50. package/src/nodes/http.ts +0 -119
  51. package/src/nodes/index.ts +0 -86
  52. package/src/nodes/operation.ts +0 -111
  53. package/src/nodes/output.ts +0 -26
  54. package/src/nodes/parameter.ts +0 -41
  55. package/src/nodes/property.ts +0 -34
  56. package/src/nodes/response.ts +0 -43
  57. package/src/nodes/root.ts +0 -64
  58. package/src/nodes/schema.ts +0 -656
  59. package/src/printer.ts +0 -250
  60. package/src/refs.ts +0 -67
  61. package/src/resolvers.ts +0 -45
  62. package/src/transformers.ts +0 -159
  63. package/src/types.ts +0 -70
  64. package/src/utils.ts +0 -915
  65. package/src/visitor.ts +0 -592
package/src/constants.ts DELETED
@@ -1,228 +0,0 @@
1
- import type { NodeKind } from './nodes/base.ts'
2
- import type { MediaType } from './nodes/http.ts'
3
- import type { HttpMethod } from './nodes/operation.ts'
4
- import type { SchemaType } from './nodes/schema.ts'
5
-
6
- /**
7
- * Traversal depth for AST visitor utilities.
8
- *
9
- * - `'shallow'` — visits only the immediate node, skipping children.
10
- * - `'deep'` — recursively visits all descendant nodes.
11
- */
12
- export type VisitorDepth = 'shallow' | 'deep'
13
-
14
- export const visitorDepths = {
15
- shallow: 'shallow',
16
- deep: 'deep',
17
- } as const satisfies Record<VisitorDepth, VisitorDepth>
18
-
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
- /**
40
- * Schema type discriminators used by all AST schema nodes.
41
- *
42
- * These values serve as stable discriminators across the AST (e.g., `schema.type === schemaTypes.object`).
43
- * Grouped by category: primitives (`string`, `number`, `boolean`), structural types (`object`, `array`, `union`),
44
- * and format-specific types (`date`, `uuid`, `email`). Use `isScalarPrimitive()` to check for scalar types.
45
- */
46
- export const schemaTypes = {
47
- /**
48
- * Text value.
49
- */
50
- string: 'string',
51
- /**
52
- * Floating-point number (`float`, `double`).
53
- */
54
- number: 'number',
55
- /**
56
- * Whole number (`int32`). Use `bigint` for `int64`.
57
- */
58
- integer: 'integer',
59
- /**
60
- * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
61
- */
62
- bigint: 'bigint',
63
- /**
64
- * Boolean value
65
- */
66
- boolean: 'boolean',
67
- /**
68
- * Explicit null value.
69
- */
70
- null: 'null',
71
- /**
72
- * Any value (no type restriction).
73
- */
74
- any: 'any',
75
- /**
76
- * Unknown value (must be narrowed before usage).
77
- */
78
- unknown: 'unknown',
79
- /**
80
- * No return value (`void`).
81
- */
82
- void: 'void',
83
- /**
84
- * Object with named properties.
85
- */
86
- object: 'object',
87
- /**
88
- * Sequential list of items.
89
- */
90
- array: 'array',
91
- /**
92
- * Fixed-length list with position-specific items.
93
- */
94
- tuple: 'tuple',
95
- /**
96
- * "One of" multiple schema members.
97
- */
98
- union: 'union',
99
- /**
100
- * "All of" multiple schema members.
101
- */
102
- intersection: 'intersection',
103
- /**
104
- * Enum schema.
105
- */
106
- enum: 'enum',
107
- /**
108
- * Reference to another schema.
109
- */
110
- ref: 'ref',
111
- /**
112
- * Calendar date (for example `2026-03-24`).
113
- */
114
- date: 'date',
115
- /**
116
- * Date-time value (for example `2026-03-24T09:00:00Z`).
117
- */
118
- datetime: 'datetime',
119
- /**
120
- * Time-only value (for example `09:00:00`).
121
- */
122
- time: 'time',
123
- /**
124
- * UUID value.
125
- */
126
- uuid: 'uuid',
127
- /**
128
- * Email address value.
129
- */
130
- email: 'email',
131
- /**
132
- * URL value.
133
- */
134
- url: 'url',
135
- /**
136
- * IPv4 address value.
137
- */
138
- ipv4: 'ipv4',
139
- /**
140
- * IPv6 address value.
141
- */
142
- ipv6: 'ipv6',
143
- /**
144
- * Binary/blob value.
145
- */
146
- blob: 'blob',
147
- /**
148
- * Impossible value (`never`).
149
- */
150
- never: 'never',
151
- } as const satisfies Record<SchemaType, SchemaType>
152
-
153
- export type ScalarPrimitive = 'string' | 'number' | 'integer' | 'bigint' | 'boolean'
154
-
155
- /**
156
- * Scalar primitive schema types used for union simplification and type narrowing.
157
- *
158
- * Use `isScalarPrimitive()` to safely check whether a type is a scalar primitive.
159
- */
160
- export const SCALAR_PRIMITIVE_TYPES = new Set<ScalarPrimitive>(['string', 'number', 'integer', 'bigint', 'boolean'])
161
-
162
- /**
163
- * Type guard that returns `true` when `type` is a scalar primitive schema type.
164
- *
165
- * Use this to check if a schema type can be directly assigned without wrapping (e.g., `string | number | boolean`).
166
- */
167
- export function isScalarPrimitive(type: string): type is ScalarPrimitive {
168
- return SCALAR_PRIMITIVE_TYPES.has(type as ScalarPrimitive)
169
- }
170
-
171
- /**
172
- * HTTP method identifiers used by operation nodes.
173
- *
174
- * Includes all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE).
175
- */
176
- export const httpMethods = {
177
- get: 'GET',
178
- post: 'POST',
179
- put: 'PUT',
180
- patch: 'PATCH',
181
- delete: 'DELETE',
182
- head: 'HEAD',
183
- options: 'OPTIONS',
184
- trace: 'TRACE',
185
- } as const satisfies Record<Lowercase<HttpMethod>, HttpMethod>
186
-
187
- /**
188
- * Default concurrency limit for `walk()` traversal utility.
189
- *
190
- * Set to 30 to balance I/O-bound resolver parallelism against event loop pressure and memory usage during large spec traversals.
191
- * Use `WALK_CONCURRENCY` when calling `walk()` or override for different hardware constraints.
192
- *
193
- * @example
194
- * ```ts
195
- * import { walk, WALK_CONCURRENCY } from '@kubb/ast'
196
- *
197
- * walk(root, { concurrency: WALK_CONCURRENCY, root: () => {} })
198
- * ```
199
- */
200
- 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>