@kubb/plugin-ts 3.0.0-beta.9 → 3.0.0
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/{chunk-WIPOSZRK.js → chunk-HJ6SFXKJ.js} +3 -3
- package/dist/chunk-HJ6SFXKJ.js.map +1 -0
- package/dist/{chunk-6MLSMIUW.js → chunk-HZ6BGJL7.js} +39 -21
- package/dist/chunk-HZ6BGJL7.js.map +1 -0
- package/dist/{chunk-7BLSACBB.cjs → chunk-PTC7IOBI.cjs} +11 -11
- package/dist/chunk-PTC7IOBI.cjs.map +1 -0
- package/dist/{chunk-YQQHBU3L.cjs → chunk-RORQTUX5.cjs} +39 -21
- package/dist/chunk-RORQTUX5.cjs.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/package.json +11 -11
- package/src/components/Type.tsx +19 -11
- package/src/parser/index.ts +14 -8
- package/dist/chunk-6MLSMIUW.js.map +0 -1
- package/dist/chunk-7BLSACBB.cjs.map +0 -1
- package/dist/chunk-WIPOSZRK.js.map +0 -1
- package/dist/chunk-YQQHBU3L.cjs.map +0 -1
package/dist/components.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkRORQTUX5_cjs = require('./chunk-RORQTUX5.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "OasType", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkRORQTUX5_cjs.OasType; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "Type", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkRORQTUX5_cjs.Type; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=components.cjs.map
|
|
16
16
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkPTC7IOBI_cjs = require('./chunk-PTC7IOBI.cjs');
|
|
4
|
+
require('./chunk-RORQTUX5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "oasGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkPTC7IOBI_cjs.oasGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "typeGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkPTC7IOBI_cjs.typeGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { oasGenerator, typeGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { oasGenerator, typeGenerator } from './chunk-HJ6SFXKJ.js';
|
|
2
|
+
import './chunk-HZ6BGJL7.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkPTC7IOBI_cjs = require('./chunk-PTC7IOBI.cjs');
|
|
4
|
+
require('./chunk-RORQTUX5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "pluginTs", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkPTC7IOBI_cjs.pluginTs; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "pluginTsName", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkPTC7IOBI_cjs.pluginTsName; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
17
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Generator plugin-ts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -58,23 +58,23 @@
|
|
|
58
58
|
"!/**/__tests__/**"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@kubb/core": "3.0.0
|
|
62
|
-
"@kubb/fs": "3.0.0
|
|
63
|
-
"@kubb/oas": "3.0.0
|
|
64
|
-
"@kubb/
|
|
65
|
-
"@kubb/
|
|
66
|
-
"@kubb/react": "3.0.0
|
|
61
|
+
"@kubb/core": "3.0.0",
|
|
62
|
+
"@kubb/fs": "3.0.0",
|
|
63
|
+
"@kubb/oas": "3.0.0",
|
|
64
|
+
"@kubb/plugin-oas": "3.0.0",
|
|
65
|
+
"@kubb/parser-ts": "3.0.0",
|
|
66
|
+
"@kubb/react": "3.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/react": "^18.3.12",
|
|
70
70
|
"react": "^18.3.1",
|
|
71
|
-
"tsup": "^8.3.
|
|
71
|
+
"tsup": "^8.3.5",
|
|
72
72
|
"typescript": "^5.6.3",
|
|
73
|
-
"@kubb/config-ts": "3.0.0
|
|
74
|
-
"@kubb/config-tsup": "3.0.0
|
|
73
|
+
"@kubb/config-ts": "3.0.0",
|
|
74
|
+
"@kubb/config-tsup": "3.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@kubb/react": "3.0.0
|
|
77
|
+
"@kubb/react": "3.0.0"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20"
|
package/src/components/Type.tsx
CHANGED
|
@@ -33,16 +33,19 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, enumType
|
|
|
33
33
|
|
|
34
34
|
let type =
|
|
35
35
|
(tree
|
|
36
|
-
.map((schema) =>
|
|
37
|
-
parse(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
.map((schema, _index, siblings) =>
|
|
37
|
+
parse(
|
|
38
|
+
{ parent: undefined, current: schema, siblings },
|
|
39
|
+
{
|
|
40
|
+
name,
|
|
41
|
+
typeName: typedName,
|
|
42
|
+
description,
|
|
43
|
+
keysToOmit,
|
|
44
|
+
optionalType,
|
|
45
|
+
enumType,
|
|
46
|
+
mapper,
|
|
47
|
+
},
|
|
48
|
+
),
|
|
46
49
|
)
|
|
47
50
|
.filter(Boolean)
|
|
48
51
|
.at(0) as ts.TypeNode) || typeKeywordMapper.undefined()
|
|
@@ -117,7 +120,12 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, enumType
|
|
|
117
120
|
</File.Source>
|
|
118
121
|
)}
|
|
119
122
|
{
|
|
120
|
-
<File.Source
|
|
123
|
+
<File.Source
|
|
124
|
+
name={typeName}
|
|
125
|
+
isIndexable
|
|
126
|
+
isExportable={['enum', 'asConst', 'constEnum', 'literal', undefined].includes(enumType)}
|
|
127
|
+
isTypeOnly={['asConst', 'constEnum', 'literal', undefined].includes(enumType)}
|
|
128
|
+
>
|
|
121
129
|
{print([typeNode])}
|
|
122
130
|
</File.Source>
|
|
123
131
|
}
|
package/src/parser/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import transformers from '@kubb/core/transformers'
|
|
2
2
|
import * as factory from '@kubb/parser-ts/factory'
|
|
3
|
-
import { isKeyword, schemaKeywords } from '@kubb/plugin-oas'
|
|
3
|
+
import { type SchemaTree, isKeyword, schemaKeywords } from '@kubb/plugin-oas'
|
|
4
4
|
|
|
5
5
|
import type { Schema, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'
|
|
6
6
|
import type ts from 'typescript'
|
|
@@ -136,7 +136,7 @@ type ParserOptions = {
|
|
|
136
136
|
mapper?: Record<string, ts.PropertySignature>
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export function parse(parent
|
|
139
|
+
export function parse({ parent, current, siblings }: SchemaTree, options: ParserOptions): ts.Node | null | undefined {
|
|
140
140
|
const value = typeKeywordMapper[current.keyword as keyof typeof typeKeywordMapper]
|
|
141
141
|
|
|
142
142
|
if (!value) {
|
|
@@ -144,15 +144,19 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
if (isKeyword(current, schemaKeywords.union)) {
|
|
147
|
-
return typeKeywordMapper.union(
|
|
147
|
+
return typeKeywordMapper.union(
|
|
148
|
+
current.args.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
|
|
149
|
+
)
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
if (isKeyword(current, schemaKeywords.and)) {
|
|
151
|
-
return typeKeywordMapper.and(current.args.map((schema) => parse(current, schema, options)).filter(Boolean) as ts.TypeNode[])
|
|
153
|
+
return typeKeywordMapper.and(current.args.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[])
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
if (isKeyword(current, schemaKeywords.array)) {
|
|
155
|
-
return typeKeywordMapper.array(
|
|
157
|
+
return typeKeywordMapper.array(
|
|
158
|
+
current.args.items.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
|
|
159
|
+
)
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
if (isKeyword(current, schemaKeywords.enum)) {
|
|
@@ -168,7 +172,9 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
|
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
if (isKeyword(current, schemaKeywords.tuple)) {
|
|
171
|
-
return typeKeywordMapper.tuple(
|
|
175
|
+
return typeKeywordMapper.tuple(
|
|
176
|
+
current.args.items.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
|
|
177
|
+
)
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
if (isKeyword(current, schemaKeywords.const)) {
|
|
@@ -200,7 +206,7 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
|
|
|
200
206
|
const exampleSchema = schemas.find((schema) => schema.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined
|
|
201
207
|
const schemaSchema = schemas.find((schema) => schema.keyword === schemaKeywords.schema) as SchemaKeywordMapper['schema'] | undefined
|
|
202
208
|
|
|
203
|
-
let type = schemas.map((schema) => parse(current, schema, options)).filter(Boolean)[0] as ts.TypeNode
|
|
209
|
+
let type = schemas.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean)[0] as ts.TypeNode
|
|
204
210
|
|
|
205
211
|
if (isNullable) {
|
|
206
212
|
type = factory.createUnionDeclaration({
|
|
@@ -244,7 +250,7 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
|
|
|
244
250
|
const additionalProperties = current.args?.additionalProperties?.length
|
|
245
251
|
? factory.createIndexSignature(
|
|
246
252
|
current.args.additionalProperties
|
|
247
|
-
.map((schema) => parse(current, schema, options))
|
|
253
|
+
.map((schema) => parse({ parent: current, current: schema, siblings }, options))
|
|
248
254
|
.filter(Boolean)
|
|
249
255
|
.at(0) as ts.TypeNode,
|
|
250
256
|
)
|