@kubb/ast 5.0.0-beta.63 → 5.0.0-beta.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{defineMacro-Shz8f6SG.js → defineMacro-B76LsJwO.js} +4 -4
- package/dist/{defineMacro-Shz8f6SG.js.map → defineMacro-B76LsJwO.js.map} +1 -1
- package/dist/{defineMacro-BATi7xoC.d.ts → defineMacro-BQpu6Ags.d.ts} +3 -3
- package/dist/factory-B_qPwA1b.d.ts +27 -0
- package/dist/factory.d.ts +3 -27
- package/dist/factory.js +2 -2
- package/dist/{index-B9cc8MBS.d.ts → index-CeJAFegf.d.ts} +4 -4
- package/dist/index.cjs +55 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -29
- package/dist/index.js +55 -9
- package/dist/index.js.map +1 -1
- package/dist/macros.d.ts +2 -2
- package/dist/macros.js +4 -4
- package/dist/{operationParams-k5CKwSWZ.d.ts → operationParams-DCY3q4C7.d.ts} +3 -3
- package/dist/{refs-BjNDuCBD.js → refs-Dx6U5LoE.js} +3 -3
- package/dist/{refs-BjNDuCBD.js.map → refs-Dx6U5LoE.js.map} +1 -1
- package/dist/schema-BkvrrOAr.cjs.map +1 -1
- package/dist/{schema-Cbnxmz4b.js → schema-YNbOtTCM.js} +2 -2
- package/dist/{schema-Cbnxmz4b.js.map → schema-YNbOtTCM.js.map} +1 -1
- package/dist/{types-BB_xgRJ3.d.ts → types-B6thixAv.d.ts} +8 -8
- package/dist/types.d.ts +5 -5
- package/dist/{utils-DaXkewb1.js → utils-BJi0y-xg.js} +4 -4
- package/dist/utils-BJi0y-xg.js.map +1 -0
- package/dist/utils-CEepwqmb.cjs.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +3 -3
- package/package.json +1 -2
- package/dist/utils-DaXkewb1.js.map +0 -1
- package/src/constants.ts +0 -150
- package/src/defineMacro.ts +0 -139
- package/src/defineNode.ts +0 -102
- package/src/definePrinter.ts +0 -258
- package/src/dialect.ts +0 -86
- package/src/factory.ts +0 -44
- package/src/guards.ts +0 -28
- package/src/index.ts +0 -13
- package/src/infer.ts +0 -132
- package/src/macros/index.ts +0 -3
- package/src/macros/macroDiscriminatorEnum.ts +0 -50
- package/src/macros/macroEnumName.ts +0 -33
- package/src/macros/macroSimplifyUnion.ts +0 -60
- package/src/nodes/base.ts +0 -49
- package/src/nodes/code.ts +0 -355
- package/src/nodes/content.ts +0 -51
- package/src/nodes/file.ts +0 -380
- package/src/nodes/function.ts +0 -283
- package/src/nodes/index.ts +0 -93
- package/src/nodes/input.ts +0 -144
- package/src/nodes/operation.ts +0 -168
- package/src/nodes/output.ts +0 -49
- package/src/nodes/parameter.ts +0 -71
- package/src/nodes/property.ts +0 -67
- package/src/nodes/requestBody.ts +0 -54
- package/src/nodes/response.ts +0 -173
- package/src/nodes/schema.ts +0 -732
- package/src/optionality.ts +0 -15
- package/src/registry.ts +0 -75
- package/src/signature.ts +0 -207
- package/src/types.ts +0 -8
- package/src/utils/codegen.ts +0 -103
- package/src/utils/extractStringsFromNodes.ts +0 -35
- package/src/utils/fileMerge.ts +0 -183
- package/src/utils/index.ts +0 -11
- package/src/utils/operationParams.ts +0 -353
- package/src/utils/refs.ts +0 -134
- package/src/utils/schemaGraph.ts +0 -177
- package/src/utils/schemaMerge.ts +0 -34
- package/src/utils/schemaTraversal.ts +0 -86
- package/src/utils/strings.ts +0 -139
- package/src/visitor.ts +0 -519
- /package/dist/{chunk-CNktS9qV.js → rolldown-runtime-CNktS9qV.js} +0 -0
package/src/nodes/response.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { defineNode } from '../defineNode.ts'
|
|
2
|
-
import type { BaseNode } from './base.ts'
|
|
3
|
-
import { type ContentNode, createContent } from './content.ts'
|
|
4
|
-
import type { SchemaNode } from './schema.ts'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* All supported HTTP status code literals as strings, as used in API specs
|
|
8
|
-
* (for example, `"200"` and `"404"`).
|
|
9
|
-
*/
|
|
10
|
-
type HttpStatusCode =
|
|
11
|
-
// 1xx Informational
|
|
12
|
-
| '100'
|
|
13
|
-
| '101'
|
|
14
|
-
| '102'
|
|
15
|
-
| '103'
|
|
16
|
-
// 2xx Success
|
|
17
|
-
| '200'
|
|
18
|
-
| '201'
|
|
19
|
-
| '202'
|
|
20
|
-
| '203'
|
|
21
|
-
| '204'
|
|
22
|
-
| '205'
|
|
23
|
-
| '206'
|
|
24
|
-
| '207'
|
|
25
|
-
| '208'
|
|
26
|
-
| '226'
|
|
27
|
-
// 3xx Redirection
|
|
28
|
-
| '300'
|
|
29
|
-
| '301'
|
|
30
|
-
| '302'
|
|
31
|
-
| '303'
|
|
32
|
-
| '304'
|
|
33
|
-
| '305'
|
|
34
|
-
| '307'
|
|
35
|
-
| '308'
|
|
36
|
-
// 4xx Client Error
|
|
37
|
-
| '400'
|
|
38
|
-
| '401'
|
|
39
|
-
| '402'
|
|
40
|
-
| '403'
|
|
41
|
-
| '404'
|
|
42
|
-
| '405'
|
|
43
|
-
| '406'
|
|
44
|
-
| '407'
|
|
45
|
-
| '408'
|
|
46
|
-
| '409'
|
|
47
|
-
| '410'
|
|
48
|
-
| '411'
|
|
49
|
-
| '412'
|
|
50
|
-
| '413'
|
|
51
|
-
| '414'
|
|
52
|
-
| '415'
|
|
53
|
-
| '416'
|
|
54
|
-
| '417'
|
|
55
|
-
| '418'
|
|
56
|
-
| '421'
|
|
57
|
-
| '422'
|
|
58
|
-
| '423'
|
|
59
|
-
| '424'
|
|
60
|
-
| '425'
|
|
61
|
-
| '426'
|
|
62
|
-
| '428'
|
|
63
|
-
| '429'
|
|
64
|
-
| '431'
|
|
65
|
-
| '451'
|
|
66
|
-
// 5xx Server Error
|
|
67
|
-
| '500'
|
|
68
|
-
| '501'
|
|
69
|
-
| '502'
|
|
70
|
-
| '503'
|
|
71
|
-
| '504'
|
|
72
|
-
| '505'
|
|
73
|
-
| '506'
|
|
74
|
-
| '507'
|
|
75
|
-
| '508'
|
|
76
|
-
| '510'
|
|
77
|
-
| '511'
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Response status code literal used by operations.
|
|
81
|
-
*
|
|
82
|
-
* Includes specific HTTP status code strings and `"default"` for catch-all responses.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* const status: StatusCode = '200'
|
|
87
|
-
* const fallback: StatusCode = 'default'
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export type StatusCode = HttpStatusCode | 'default'
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* AST node representing one operation response variant.
|
|
94
|
-
*
|
|
95
|
-
* Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside
|
|
96
|
-
* the `content` array (one entry per content type), so the same schema is never duplicated at the
|
|
97
|
-
* node root and inside `content`.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```ts
|
|
101
|
-
* const response: ResponseNode = {
|
|
102
|
-
* kind: 'Response',
|
|
103
|
-
* statusCode: '200',
|
|
104
|
-
* content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export type ResponseNode = BaseNode & {
|
|
109
|
-
/**
|
|
110
|
-
* Node kind.
|
|
111
|
-
*/
|
|
112
|
-
kind: 'Response'
|
|
113
|
-
/**
|
|
114
|
-
* HTTP status code or `'default'` for a fallback response.
|
|
115
|
-
*/
|
|
116
|
-
statusCode: StatusCode
|
|
117
|
-
/**
|
|
118
|
-
* Optional response description.
|
|
119
|
-
*/
|
|
120
|
-
description?: string
|
|
121
|
-
/**
|
|
122
|
-
* All available content type entries for this response.
|
|
123
|
-
*
|
|
124
|
-
* When the adapter `contentType` option is set, this array contains exactly one entry for that
|
|
125
|
-
* content type. Otherwise it contains one entry per content type declared in the spec, so that
|
|
126
|
-
* plugins can generate a union of response types (e.g. `application/json` and `application/xml`).
|
|
127
|
-
* Body-less responses keep a single entry whose `schema` is the empty/`void` placeholder.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* // spec response declares both application/json and application/xml
|
|
132
|
-
* response.content[0].contentType // 'application/json'
|
|
133
|
-
* response.content[1].contentType // 'application/xml'
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
content?: Array<ContentNode>
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type ResponseInput = Pick<ResponseNode, 'statusCode'> &
|
|
140
|
-
Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {
|
|
141
|
-
content?: Array<ContentNode>
|
|
142
|
-
schema?: SchemaNode
|
|
143
|
-
mediaType?: string | null
|
|
144
|
-
keysToOmit?: Array<string> | null
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Definition for the {@link ResponseNode}. A single legacy `schema` (with optional
|
|
149
|
-
* `mediaType`/`keysToOmit`) is normalized into one `content` entry.
|
|
150
|
-
*/
|
|
151
|
-
export const responseDef = defineNode<ResponseNode, ResponseInput>({
|
|
152
|
-
kind: 'Response',
|
|
153
|
-
build: (props) => {
|
|
154
|
-
const { schema, mediaType, keysToOmit, content, ...rest } = props
|
|
155
|
-
const entries = content ?? (schema ? [createContent({ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null })] : undefined)
|
|
156
|
-
return { ...rest, content: entries }
|
|
157
|
-
},
|
|
158
|
-
children: ['content'],
|
|
159
|
-
visitorKey: 'response',
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Creates a `ResponseNode`.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* const response = createResponse({
|
|
168
|
-
* statusCode: '200',
|
|
169
|
-
* content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],
|
|
170
|
-
* })
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
export const createResponse = responseDef.create
|