@kubb/ast 5.0.0-beta.7 → 5.0.0-beta.70
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/LICENSE +17 -10
- package/README.md +53 -27
- package/dist/defineMacro-Bh5E_Il6.cjs +114 -0
- package/dist/defineMacro-Bh5E_Il6.cjs.map +1 -0
- package/dist/defineMacro-CVrU3ajV.js +98 -0
- package/dist/defineMacro-CVrU3ajV.js.map +1 -0
- package/dist/defineMacro-D9ekmTW5.d.ts +466 -0
- package/dist/index-q_ldM1YP.d.ts +2422 -0
- package/dist/index.cjs +198 -2239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +97 -3399
- package/dist/index.js +149 -2160
- 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-Dme8H-sR.d.ts +211 -0
- package/dist/refs-8IwpesXW.cjs +157 -0
- package/dist/refs-8IwpesXW.cjs.map +1 -0
- package/dist/refs-D2qwT5ck.js +117 -0
- package/dist/refs-D2qwT5ck.js.map +1 -0
- package/dist/rolldown-runtime-CNktS9qV.js +17 -0
- package/dist/types-Df1jVmRy.d.ts +244 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +1 -0
- package/dist/utils.cjs +808 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +381 -0
- package/dist/utils.js +777 -0
- package/dist/utils.js.map +1 -0
- package/dist/visitor-CLLDwBvv.cjs +1743 -0
- package/dist/visitor-CLLDwBvv.cjs.map +1 -0
- package/dist/visitor-DG5ROqRx.js +1307 -0
- package/dist/visitor-DG5ROqRx.js.map +1 -0
- package/package.json +17 -5
- package/dist/chunk--u3MIqq1.js +0 -8
- package/src/constants.ts +0 -228
- package/src/factory.ts +0 -742
- package/src/guards.ts +0 -110
- package/src/index.ts +0 -46
- package/src/infer.ts +0 -130
- package/src/mocks.ts +0 -176
- package/src/nodes/base.ts +0 -56
- package/src/nodes/code.ts +0 -304
- package/src/nodes/file.ts +0 -230
- package/src/nodes/function.ts +0 -223
- package/src/nodes/http.ts +0 -119
- package/src/nodes/index.ts +0 -86
- package/src/nodes/operation.ts +0 -111
- package/src/nodes/output.ts +0 -26
- package/src/nodes/parameter.ts +0 -41
- package/src/nodes/property.ts +0 -34
- package/src/nodes/response.ts +0 -43
- package/src/nodes/root.ts +0 -64
- package/src/nodes/schema.ts +0 -656
- package/src/printer.ts +0 -250
- package/src/refs.ts +0 -67
- package/src/resolvers.ts +0 -45
- package/src/transformers.ts +0 -159
- package/src/types.ts +0 -70
- package/src/utils.ts +0 -915
- package/src/visitor.ts +0 -592
package/src/nodes/root.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { BaseNode } from './base.ts'
|
|
2
|
-
import type { OperationNode } from './operation.ts'
|
|
3
|
-
import type { SchemaNode } from './schema.ts'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Basic metadata for an API document.
|
|
7
|
-
* Adapters fill fields that exist in their source format.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* const meta: InputMeta = { title: 'Pet API', version: '1.0.0' }
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export type InputMeta = {
|
|
15
|
-
/**
|
|
16
|
-
* API title (from `info.title` in OAS/AsyncAPI).
|
|
17
|
-
*/
|
|
18
|
-
title?: string
|
|
19
|
-
/**
|
|
20
|
-
* API description (from `info.description` in OAS/AsyncAPI).
|
|
21
|
-
*/
|
|
22
|
-
description?: string
|
|
23
|
-
/**
|
|
24
|
-
* API version string (from `info.version` in OAS/AsyncAPI).
|
|
25
|
-
*/
|
|
26
|
-
version?: string
|
|
27
|
-
/**
|
|
28
|
-
* Resolved API base URL.
|
|
29
|
-
* For OpenAPI and AsyncAPI, this comes from the selected server URL.
|
|
30
|
-
*/
|
|
31
|
-
baseURL?: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Input AST node that contains all schemas and operations for one API document.
|
|
36
|
-
* Produced by the adapter and consumed by all Kubb plugins.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* const input: InputNode = {
|
|
41
|
-
* kind: 'Input',
|
|
42
|
-
* schemas: [],
|
|
43
|
-
* operations: [],
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export type InputNode = BaseNode & {
|
|
48
|
-
/**
|
|
49
|
-
* Node kind.
|
|
50
|
-
*/
|
|
51
|
-
kind: 'Input'
|
|
52
|
-
/**
|
|
53
|
-
* All schema nodes in the document.
|
|
54
|
-
*/
|
|
55
|
-
schemas: Array<SchemaNode>
|
|
56
|
-
/**
|
|
57
|
-
* All operation nodes in the document.
|
|
58
|
-
*/
|
|
59
|
-
operations: Array<OperationNode>
|
|
60
|
-
/**
|
|
61
|
-
* Optional document metadata populated by the adapter.
|
|
62
|
-
*/
|
|
63
|
-
meta?: InputMeta
|
|
64
|
-
}
|
package/src/nodes/schema.ts
DELETED
|
@@ -1,656 +0,0 @@
|
|
|
1
|
-
import type { BaseNode } from './base.ts'
|
|
2
|
-
import type { PropertyNode } from './property.ts'
|
|
3
|
-
|
|
4
|
-
export type PrimitiveSchemaType =
|
|
5
|
-
/**
|
|
6
|
-
* Text value.
|
|
7
|
-
*/
|
|
8
|
-
| 'string'
|
|
9
|
-
/**
|
|
10
|
-
* Floating-point number.
|
|
11
|
-
*/
|
|
12
|
-
| 'number'
|
|
13
|
-
/**
|
|
14
|
-
* Integer number.
|
|
15
|
-
*/
|
|
16
|
-
| 'integer'
|
|
17
|
-
/**
|
|
18
|
-
* Big integer number.
|
|
19
|
-
*/
|
|
20
|
-
| 'bigint'
|
|
21
|
-
/**
|
|
22
|
-
* Boolean value.
|
|
23
|
-
*/
|
|
24
|
-
| 'boolean'
|
|
25
|
-
/**
|
|
26
|
-
* Null value.
|
|
27
|
-
*/
|
|
28
|
-
| 'null'
|
|
29
|
-
/**
|
|
30
|
-
* Any value.
|
|
31
|
-
*/
|
|
32
|
-
| 'any'
|
|
33
|
-
/**
|
|
34
|
-
* Unknown value.
|
|
35
|
-
*/
|
|
36
|
-
| 'unknown'
|
|
37
|
-
/**
|
|
38
|
-
* No value (`void`).
|
|
39
|
-
*/
|
|
40
|
-
| 'void'
|
|
41
|
-
/**
|
|
42
|
-
* Never value.
|
|
43
|
-
*/
|
|
44
|
-
| 'never'
|
|
45
|
-
/**
|
|
46
|
-
* Object value.
|
|
47
|
-
*/
|
|
48
|
-
| 'object'
|
|
49
|
-
/**
|
|
50
|
-
* Array value.
|
|
51
|
-
*/
|
|
52
|
-
| 'array'
|
|
53
|
-
/**
|
|
54
|
-
* Date value.
|
|
55
|
-
*/
|
|
56
|
-
| 'date'
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Composite schema types.
|
|
60
|
-
*/
|
|
61
|
-
export type ComplexSchemaType = 'tuple' | 'union' | 'intersection' | 'enum'
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Schema types that need special handling in generators.
|
|
65
|
-
*/
|
|
66
|
-
export type SpecialSchemaType = 'ref' | 'datetime' | 'time' | 'uuid' | 'email' | 'url' | 'ipv4' | 'ipv6' | 'blob'
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* All schema type strings.
|
|
70
|
-
*/
|
|
71
|
-
export type SchemaType = PrimitiveSchemaType | ComplexSchemaType | SpecialSchemaType
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Scalar schema types without extra object/array/ref structure.
|
|
75
|
-
*/
|
|
76
|
-
export type ScalarSchemaType = Exclude<
|
|
77
|
-
SchemaType,
|
|
78
|
-
| 'object'
|
|
79
|
-
| 'array'
|
|
80
|
-
| 'tuple'
|
|
81
|
-
| 'union'
|
|
82
|
-
| 'intersection'
|
|
83
|
-
| 'enum'
|
|
84
|
-
| 'ref'
|
|
85
|
-
| 'datetime'
|
|
86
|
-
| 'date'
|
|
87
|
-
| 'time'
|
|
88
|
-
| 'string'
|
|
89
|
-
| 'number'
|
|
90
|
-
| 'integer'
|
|
91
|
-
| 'bigint'
|
|
92
|
-
| 'url'
|
|
93
|
-
| 'uuid'
|
|
94
|
-
| 'email'
|
|
95
|
-
>
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Fields shared by all schema nodes.
|
|
99
|
-
*/
|
|
100
|
-
type SchemaNodeBase = BaseNode & {
|
|
101
|
-
/**
|
|
102
|
-
* Node kind.
|
|
103
|
-
*/
|
|
104
|
-
kind: 'Schema'
|
|
105
|
-
/**
|
|
106
|
-
* Schema name for named definitions (for example, `"Pet"`).
|
|
107
|
-
* Inline schemas omit this field.
|
|
108
|
-
* `null` means kubb has processed this and determined there is no applicable name.
|
|
109
|
-
* `undefined` means the name has not been set yet.
|
|
110
|
-
*/
|
|
111
|
-
name?: string | null
|
|
112
|
-
/**
|
|
113
|
-
* Short schema title.
|
|
114
|
-
*/
|
|
115
|
-
title?: string
|
|
116
|
-
/**
|
|
117
|
-
* Schema description text.
|
|
118
|
-
*/
|
|
119
|
-
description?: string
|
|
120
|
-
/**
|
|
121
|
-
* Whether `null` is allowed.
|
|
122
|
-
*/
|
|
123
|
-
nullable?: boolean
|
|
124
|
-
/**
|
|
125
|
-
* Whether the field is optional.
|
|
126
|
-
*/
|
|
127
|
-
optional?: boolean
|
|
128
|
-
/**
|
|
129
|
-
* Both optional and nullable (`optional` + `nullable`).
|
|
130
|
-
*/
|
|
131
|
-
nullish?: boolean
|
|
132
|
-
/**
|
|
133
|
-
* Whether the schema is deprecated.
|
|
134
|
-
*/
|
|
135
|
-
deprecated?: boolean
|
|
136
|
-
/**
|
|
137
|
-
* Whether the schema is read-only.
|
|
138
|
-
*/
|
|
139
|
-
readOnly?: boolean
|
|
140
|
-
/**
|
|
141
|
-
* Whether the schema is write-only.
|
|
142
|
-
*/
|
|
143
|
-
writeOnly?: boolean
|
|
144
|
-
/**
|
|
145
|
-
* Default value.
|
|
146
|
-
*/
|
|
147
|
-
default?: unknown
|
|
148
|
-
/**
|
|
149
|
-
* Example value.
|
|
150
|
-
*/
|
|
151
|
-
example?: unknown
|
|
152
|
-
/**
|
|
153
|
-
* Base primitive type.
|
|
154
|
-
* For example, this is `'string'` for a `uuid` schema.
|
|
155
|
-
*/
|
|
156
|
-
primitive?: PrimitiveSchemaType
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Object schema with ordered properties.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```ts
|
|
164
|
-
* const objectSchema: ObjectSchemaNode = {
|
|
165
|
-
* kind: 'Schema',
|
|
166
|
-
* type: 'object',
|
|
167
|
-
* properties: [],
|
|
168
|
-
* }
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
export type ObjectSchemaNode = SchemaNodeBase & {
|
|
172
|
-
/**
|
|
173
|
-
* Schema type discriminator.
|
|
174
|
-
*/
|
|
175
|
-
type: 'object'
|
|
176
|
-
/**
|
|
177
|
-
* Primitive type — always `'object'` for object schemas.
|
|
178
|
-
*/
|
|
179
|
-
primitive: 'object'
|
|
180
|
-
/**
|
|
181
|
-
* Ordered object properties.
|
|
182
|
-
*/
|
|
183
|
-
properties: Array<PropertyNode>
|
|
184
|
-
/**
|
|
185
|
-
* Additional object properties behavior:
|
|
186
|
-
* - `true`: allow any value
|
|
187
|
-
* - `false`: reject unknown properties (maps to `.strict()` in Zod)
|
|
188
|
-
* - `SchemaNode`: allow values that match that schema
|
|
189
|
-
* - `undefined`: no additional properties constraint (open object)
|
|
190
|
-
*/
|
|
191
|
-
additionalProperties?: SchemaNode | boolean
|
|
192
|
-
/**
|
|
193
|
-
* Pattern-based property schemas.
|
|
194
|
-
*/
|
|
195
|
-
patternProperties?: Record<string, SchemaNode>
|
|
196
|
-
/**
|
|
197
|
-
* Minimum number of properties allowed.
|
|
198
|
-
*/
|
|
199
|
-
minProperties?: number
|
|
200
|
-
/**
|
|
201
|
-
* Maximum number of properties allowed.
|
|
202
|
-
*/
|
|
203
|
-
maxProperties?: number
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Array-like schema (`array` or `tuple`).
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* const arraySchema: ArraySchemaNode = {
|
|
212
|
-
* kind: 'Schema',
|
|
213
|
-
* type: 'array',
|
|
214
|
-
* items: [],
|
|
215
|
-
* }
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
export type ArraySchemaNode = SchemaNodeBase & {
|
|
219
|
-
/**
|
|
220
|
-
* Schema type discriminator (`array` or `tuple`).
|
|
221
|
-
*/
|
|
222
|
-
type: 'array' | 'tuple'
|
|
223
|
-
/**
|
|
224
|
-
* Item schemas.
|
|
225
|
-
*/
|
|
226
|
-
items?: Array<SchemaNode>
|
|
227
|
-
/**
|
|
228
|
-
* Tuple rest-item schema for elements beyond positional `items`.
|
|
229
|
-
*/
|
|
230
|
-
rest?: SchemaNode
|
|
231
|
-
/**
|
|
232
|
-
* Minimum item count (or tuple length).
|
|
233
|
-
*/
|
|
234
|
-
min?: number
|
|
235
|
-
/**
|
|
236
|
-
* Maximum item count (or tuple length).
|
|
237
|
-
*/
|
|
238
|
-
max?: number
|
|
239
|
-
/**
|
|
240
|
-
* Whether all items must be unique.
|
|
241
|
-
*/
|
|
242
|
-
unique?: boolean
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Shared shape for union and intersection schemas.
|
|
247
|
-
*/
|
|
248
|
-
type CompositeSchemaNodeBase = SchemaNodeBase & {
|
|
249
|
-
/**
|
|
250
|
-
* Member schemas.
|
|
251
|
-
*/
|
|
252
|
-
members?: Array<SchemaNode>
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Union schema, often from `oneOf` or `anyOf`.
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* const unionSchema: UnionSchemaNode = {
|
|
261
|
-
* kind: 'Schema',
|
|
262
|
-
* type: 'union',
|
|
263
|
-
* members: [],
|
|
264
|
-
* }
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
export type UnionSchemaNode = CompositeSchemaNodeBase & {
|
|
268
|
-
/**
|
|
269
|
-
* Schema type discriminator.
|
|
270
|
-
*/
|
|
271
|
-
type: 'union'
|
|
272
|
-
/**
|
|
273
|
-
* Discriminator property name from OpenAPI `discriminator.propertyName`.
|
|
274
|
-
*/
|
|
275
|
-
discriminatorPropertyName?: string
|
|
276
|
-
/**
|
|
277
|
-
* Logical strategy applied to union members: 'one' means exactly one member must be valid (from `oneOf`),
|
|
278
|
-
* 'any' means any number of members can be valid (from `anyOf`).
|
|
279
|
-
*/
|
|
280
|
-
strategy?: 'one' | 'any'
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Intersection schema, often from `allOf`.
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```ts
|
|
288
|
-
* const intersectionSchema: IntersectionSchemaNode = {
|
|
289
|
-
* kind: 'Schema',
|
|
290
|
-
* type: 'intersection',
|
|
291
|
-
* members: [],
|
|
292
|
-
* }
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
export type IntersectionSchemaNode = CompositeSchemaNodeBase & {
|
|
296
|
-
/**
|
|
297
|
-
* Schema type discriminator.
|
|
298
|
-
*/
|
|
299
|
-
type: 'intersection'
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* One named enum item.
|
|
304
|
-
*/
|
|
305
|
-
export type EnumValueNode = {
|
|
306
|
-
/**
|
|
307
|
-
* Enum item name.
|
|
308
|
-
*/
|
|
309
|
-
name: string
|
|
310
|
-
/**
|
|
311
|
-
* Enum item value.
|
|
312
|
-
*/
|
|
313
|
-
value: string | number | boolean
|
|
314
|
-
/**
|
|
315
|
-
* Primitive type of the enum value.
|
|
316
|
-
*/
|
|
317
|
-
primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Enum schema node.
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
* ```ts
|
|
325
|
-
* const enumSchema: EnumSchemaNode = {
|
|
326
|
-
* kind: 'Schema',
|
|
327
|
-
* type: 'enum',
|
|
328
|
-
* enumValues: ['a', 'b'],
|
|
329
|
-
* }
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
export type EnumSchemaNode = SchemaNodeBase & {
|
|
333
|
-
/**
|
|
334
|
-
* Schema type discriminator.
|
|
335
|
-
*/
|
|
336
|
-
type: 'enum'
|
|
337
|
-
/**
|
|
338
|
-
* Enum values in simple form.
|
|
339
|
-
*/
|
|
340
|
-
enumValues?: Array<string | number | boolean | null>
|
|
341
|
-
/**
|
|
342
|
-
* Enum values in named form.
|
|
343
|
-
* If present, this is used instead of `enumValues`.
|
|
344
|
-
*/
|
|
345
|
-
namedEnumValues?: Array<EnumValueNode>
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Reference schema that points to another schema definition.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* const refSchema: RefSchemaNode = {
|
|
354
|
-
* kind: 'Schema',
|
|
355
|
-
* type: 'ref',
|
|
356
|
-
* ref: '#/components/schemas/Pet',
|
|
357
|
-
* }
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
export type RefSchemaNode = SchemaNodeBase & {
|
|
361
|
-
/**
|
|
362
|
-
* Schema type discriminator.
|
|
363
|
-
*/
|
|
364
|
-
type: 'ref'
|
|
365
|
-
/**
|
|
366
|
-
* Referenced schema name.
|
|
367
|
-
*/
|
|
368
|
-
name?: string
|
|
369
|
-
/**
|
|
370
|
-
* Original `$ref` path, for example, `#/components/schemas/Order`.
|
|
371
|
-
* Used to resolve names later.
|
|
372
|
-
*/
|
|
373
|
-
ref?: string
|
|
374
|
-
/**
|
|
375
|
-
* Pattern copied from a sibling `pattern` field.
|
|
376
|
-
*/
|
|
377
|
-
pattern?: string
|
|
378
|
-
/**
|
|
379
|
-
* The fully-parsed schema that this ref resolves to.
|
|
380
|
-
* Populated during OAS parsing when the referenced definition can be resolved.
|
|
381
|
-
* `undefined` when the ref cannot be resolved or is part of a circular chain.
|
|
382
|
-
*
|
|
383
|
-
* Useful for inspecting the referenced schema's structure (e.g. `primitive`, `properties`)
|
|
384
|
-
* without following the reference manually.
|
|
385
|
-
*/
|
|
386
|
-
schema?: SchemaNode
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Datetime schema.
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* ```ts
|
|
394
|
-
* const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }
|
|
395
|
-
* ```
|
|
396
|
-
*/
|
|
397
|
-
export type DatetimeSchemaNode = SchemaNodeBase & {
|
|
398
|
-
/**
|
|
399
|
-
* Schema type discriminator.
|
|
400
|
-
*/
|
|
401
|
-
type: 'datetime'
|
|
402
|
-
/**
|
|
403
|
-
* Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).
|
|
404
|
-
*/
|
|
405
|
-
offset?: boolean
|
|
406
|
-
/**
|
|
407
|
-
* Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).
|
|
408
|
-
*/
|
|
409
|
-
local?: boolean
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Shared base for `date` and `time` schemas.
|
|
414
|
-
*/
|
|
415
|
-
type TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {
|
|
416
|
-
/**
|
|
417
|
-
* Schema type discriminator.
|
|
418
|
-
*/
|
|
419
|
-
type: T
|
|
420
|
-
/**
|
|
421
|
-
* Output representation in generated code.
|
|
422
|
-
*/
|
|
423
|
-
representation: 'date' | 'string'
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Date schema node.
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
export type DateSchemaNode = TemporalSchemaNodeBase<'date'>
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Time schema node.
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```ts
|
|
441
|
-
* const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }
|
|
442
|
-
* ```
|
|
443
|
-
*/
|
|
444
|
-
export type TimeSchemaNode = TemporalSchemaNodeBase<'time'>
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* String schema node.
|
|
448
|
-
*
|
|
449
|
-
* @example
|
|
450
|
-
* ```ts
|
|
451
|
-
* const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }
|
|
452
|
-
* ```
|
|
453
|
-
*/
|
|
454
|
-
export type StringSchemaNode = SchemaNodeBase & {
|
|
455
|
-
/**
|
|
456
|
-
* Schema type discriminator.
|
|
457
|
-
*/
|
|
458
|
-
type: 'string'
|
|
459
|
-
/**
|
|
460
|
-
* Minimum string length.
|
|
461
|
-
*/
|
|
462
|
-
min?: number
|
|
463
|
-
/**
|
|
464
|
-
* Maximum string length.
|
|
465
|
-
*/
|
|
466
|
-
max?: number
|
|
467
|
-
/**
|
|
468
|
-
* Regex pattern.
|
|
469
|
-
*/
|
|
470
|
-
pattern?: string
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Numeric schema (`number`, `integer`, or `bigint`).
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* ```ts
|
|
478
|
-
* const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }
|
|
479
|
-
* ```
|
|
480
|
-
*/
|
|
481
|
-
export type NumberSchemaNode = SchemaNodeBase & {
|
|
482
|
-
/**
|
|
483
|
-
* Schema type discriminator.
|
|
484
|
-
*/
|
|
485
|
-
type: 'number' | 'integer' | 'bigint'
|
|
486
|
-
/**
|
|
487
|
-
* Minimum value.
|
|
488
|
-
*/
|
|
489
|
-
min?: number
|
|
490
|
-
/**
|
|
491
|
-
* Maximum value.
|
|
492
|
-
*/
|
|
493
|
-
max?: number
|
|
494
|
-
/**
|
|
495
|
-
* Exclusive minimum value.
|
|
496
|
-
*/
|
|
497
|
-
exclusiveMinimum?: number
|
|
498
|
-
/**
|
|
499
|
-
* Exclusive maximum value.
|
|
500
|
-
*/
|
|
501
|
-
exclusiveMaximum?: number
|
|
502
|
-
/**
|
|
503
|
-
* The value must be a multiple of this number.
|
|
504
|
-
*/
|
|
505
|
-
multipleOf?: number
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Scalar schema with no extra constraints.
|
|
510
|
-
*
|
|
511
|
-
* @example
|
|
512
|
-
* ```ts
|
|
513
|
-
* const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }
|
|
514
|
-
* ```
|
|
515
|
-
*/
|
|
516
|
-
export type ScalarSchemaNode = SchemaNodeBase & {
|
|
517
|
-
/**
|
|
518
|
-
* Schema type discriminator.
|
|
519
|
-
*/
|
|
520
|
-
type: ScalarSchemaType
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* URL schema node.
|
|
525
|
-
* Can include an OpenAPI-style path template for template literal types.
|
|
526
|
-
*
|
|
527
|
-
* @example
|
|
528
|
-
* ```ts
|
|
529
|
-
* const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }
|
|
530
|
-
* ```
|
|
531
|
-
*/
|
|
532
|
-
export type UrlSchemaNode = SchemaNodeBase & {
|
|
533
|
-
/**
|
|
534
|
-
* Schema type discriminator.
|
|
535
|
-
*/
|
|
536
|
-
type: 'url'
|
|
537
|
-
/**
|
|
538
|
-
* OpenAPI-style path template, for example, `'/pets/{petId}'`.
|
|
539
|
-
*/
|
|
540
|
-
path?: string
|
|
541
|
-
/**
|
|
542
|
-
* Minimum string length.
|
|
543
|
-
*/
|
|
544
|
-
min?: number
|
|
545
|
-
/**
|
|
546
|
-
* Maximum string length.
|
|
547
|
-
*/
|
|
548
|
-
max?: number
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Format-string schema for string-based formats that support length constraints.
|
|
553
|
-
*
|
|
554
|
-
* @example
|
|
555
|
-
* ```ts
|
|
556
|
-
* const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
export type FormatStringSchemaNode = SchemaNodeBase & {
|
|
560
|
-
/**
|
|
561
|
-
* Schema type discriminator.
|
|
562
|
-
*/
|
|
563
|
-
type: 'uuid' | 'email'
|
|
564
|
-
/**
|
|
565
|
-
* Minimum string length.
|
|
566
|
-
*/
|
|
567
|
-
min?: number
|
|
568
|
-
/**
|
|
569
|
-
* Maximum string length.
|
|
570
|
-
*/
|
|
571
|
-
max?: number
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* IPv4 address schema node.
|
|
576
|
-
*
|
|
577
|
-
* @example
|
|
578
|
-
* ```ts
|
|
579
|
-
* const ipv4Schema: Ipv4SchemaNode = { kind: 'Schema', type: 'ipv4' }
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
export type Ipv4SchemaNode = SchemaNodeBase & {
|
|
583
|
-
/**
|
|
584
|
-
* Schema type discriminator.
|
|
585
|
-
*/
|
|
586
|
-
type: 'ipv4'
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* IPv6 address schema node.
|
|
591
|
-
*
|
|
592
|
-
* @example
|
|
593
|
-
* ```ts
|
|
594
|
-
* const ipv6Schema: Ipv6SchemaNode = { kind: 'Schema', type: 'ipv6' }
|
|
595
|
-
* ```
|
|
596
|
-
*/
|
|
597
|
-
export type Ipv6SchemaNode = SchemaNodeBase & {
|
|
598
|
-
/**
|
|
599
|
-
* Schema type discriminator.
|
|
600
|
-
*/
|
|
601
|
-
type: 'ipv6'
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Mapping from schema type literals to concrete schema node types.
|
|
606
|
-
* Used by `narrowSchema`.
|
|
607
|
-
*/
|
|
608
|
-
export type SchemaNodeByType = {
|
|
609
|
-
object: ObjectSchemaNode
|
|
610
|
-
array: ArraySchemaNode
|
|
611
|
-
tuple: ArraySchemaNode
|
|
612
|
-
union: UnionSchemaNode
|
|
613
|
-
intersection: IntersectionSchemaNode
|
|
614
|
-
enum: EnumSchemaNode
|
|
615
|
-
ref: RefSchemaNode
|
|
616
|
-
datetime: DatetimeSchemaNode
|
|
617
|
-
date: DateSchemaNode
|
|
618
|
-
time: TimeSchemaNode
|
|
619
|
-
string: StringSchemaNode
|
|
620
|
-
number: NumberSchemaNode
|
|
621
|
-
integer: NumberSchemaNode
|
|
622
|
-
bigint: NumberSchemaNode
|
|
623
|
-
boolean: ScalarSchemaNode
|
|
624
|
-
null: ScalarSchemaNode
|
|
625
|
-
any: ScalarSchemaNode
|
|
626
|
-
unknown: ScalarSchemaNode
|
|
627
|
-
void: ScalarSchemaNode
|
|
628
|
-
never: ScalarSchemaNode
|
|
629
|
-
uuid: FormatStringSchemaNode
|
|
630
|
-
email: FormatStringSchemaNode
|
|
631
|
-
url: UrlSchemaNode
|
|
632
|
-
ipv4: Ipv4SchemaNode
|
|
633
|
-
ipv6: Ipv6SchemaNode
|
|
634
|
-
blob: ScalarSchemaNode
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Union of all schema node types.
|
|
639
|
-
*/
|
|
640
|
-
export type SchemaNode =
|
|
641
|
-
| ObjectSchemaNode
|
|
642
|
-
| ArraySchemaNode
|
|
643
|
-
| UnionSchemaNode
|
|
644
|
-
| IntersectionSchemaNode
|
|
645
|
-
| EnumSchemaNode
|
|
646
|
-
| RefSchemaNode
|
|
647
|
-
| DatetimeSchemaNode
|
|
648
|
-
| DateSchemaNode
|
|
649
|
-
| TimeSchemaNode
|
|
650
|
-
| StringSchemaNode
|
|
651
|
-
| NumberSchemaNode
|
|
652
|
-
| UrlSchemaNode
|
|
653
|
-
| FormatStringSchemaNode
|
|
654
|
-
| Ipv4SchemaNode
|
|
655
|
-
| Ipv6SchemaNode
|
|
656
|
-
| ScalarSchemaNode
|