@kubb/plugin-zod 3.0.0-alpha.6 → 3.0.0-alpha.8
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-PMYJN6KG.js → chunk-CD3EZWBX.js} +162 -146
- package/dist/chunk-CD3EZWBX.js.map +1 -0
- package/dist/{chunk-INEB36EJ.cjs → chunk-TSJ74266.cjs} +121 -105
- package/dist/chunk-TSJ74266.cjs.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/package.json +12 -12
- package/src/components/OperationSchema.tsx +1 -1
- package/src/components/Operations.tsx +2 -2
- package/src/components/Schema.tsx +3 -3
- package/src/components/__snapshots__/operations.ts +8 -8
- package/src/plugin.ts +12 -6
- package/dist/chunk-INEB36EJ.cjs.map +0 -1
- package/dist/chunk-PMYJN6KG.js.map +0 -1
package/dist/components.cjs
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkTSJ74266cjs = require('./chunk-TSJ74266.cjs');
|
|
7
7
|
|
|
8
8
|
// src/components/index.ts
|
|
9
|
-
|
|
9
|
+
_chunkTSJ74266cjs.init_cjs_shims.call(void 0, );
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.OperationSchema =
|
|
14
|
+
exports.OperationSchema = _chunkTSJ74266cjs.OperationSchema; exports.Operations = _chunkTSJ74266cjs.Operations; exports.Schema = _chunkTSJ74266cjs.Schema;
|
|
15
15
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkTSJ74266cjs = require('./chunk-TSJ74266.cjs');
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
-
|
|
8
|
+
_chunkTSJ74266cjs.init_cjs_shims.call(void 0, );
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.pluginZod =
|
|
12
|
+
exports.pluginZod = _chunkTSJ74266cjs.pluginZod; exports.pluginZodName = _chunkTSJ74266cjs.pluginZodName;
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"description": "Generator plugin-zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -56,25 +56,25 @@
|
|
|
56
56
|
"!/**/__tests__/**"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@kubb/core": "3.0.0-alpha.
|
|
60
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
61
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
62
|
-
"@kubb/parser-ts": "3.0.0-alpha.
|
|
63
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
64
|
-
"@kubb/react": "3.0.0-alpha.
|
|
65
|
-
"@kubb/types": "3.0.0-alpha.
|
|
59
|
+
"@kubb/core": "3.0.0-alpha.8",
|
|
60
|
+
"@kubb/fs": "3.0.0-alpha.8",
|
|
61
|
+
"@kubb/oas": "3.0.0-alpha.8",
|
|
62
|
+
"@kubb/parser-ts": "3.0.0-alpha.8",
|
|
63
|
+
"@kubb/plugin-oas": "3.0.0-alpha.8",
|
|
64
|
+
"@kubb/react": "3.0.0-alpha.8",
|
|
65
|
+
"@kubb/types": "3.0.0-alpha.8"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/react": "^18.3.4",
|
|
69
69
|
"prettier": "^3.3.3",
|
|
70
70
|
"react": "^18.3.1",
|
|
71
71
|
"tsup": "^8.2.4",
|
|
72
|
-
"@kubb/config-
|
|
73
|
-
"@kubb/config-
|
|
74
|
-
"@kubb/config-
|
|
72
|
+
"@kubb/config-biome": "3.0.0-alpha.8",
|
|
73
|
+
"@kubb/config-ts": "3.0.0-alpha.8",
|
|
74
|
+
"@kubb/config-tsup": "3.0.0-alpha.8"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@kubb/react": "3.0.0-alpha.
|
|
77
|
+
"@kubb/react": "3.0.0-alpha.8"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20"
|
|
@@ -45,7 +45,7 @@ OperationSchema.File = function ({}: FileProps): ReactNode {
|
|
|
45
45
|
|
|
46
46
|
return (
|
|
47
47
|
<Oas.Schema key={i} name={name} value={schema} tree={[...tree, optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)}>
|
|
48
|
-
{mode === 'split' && <Oas.Schema.Imports />}
|
|
48
|
+
{mode === 'split' && <Oas.Schema.Imports isTypeOnly={false} />}
|
|
49
49
|
<OperationSchema description={description} keysToOmit={keysToOmit} />
|
|
50
50
|
</Oas.Schema>
|
|
51
51
|
)
|
|
@@ -46,12 +46,12 @@ function Template({ operationsName, pathsName, operations }: TemplateProps): Kub
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<>
|
|
49
|
-
<File.Source name={operationsName} isExportable>
|
|
49
|
+
<File.Source name={operationsName} isExportable isIndexable>
|
|
50
50
|
<Const export name={operationsName} asConst>
|
|
51
51
|
{`{${transformers.stringifyObject(operationsJSON)}}`}
|
|
52
52
|
</Const>
|
|
53
53
|
</File.Source>
|
|
54
|
-
<File.Source name={pathsName} isExportable>
|
|
54
|
+
<File.Source name={pathsName} isExportable isIndexable>
|
|
55
55
|
<Const export name={pathsName} asConst>
|
|
56
56
|
{`{${transformers.stringifyObject(pathsJSON)}}`}
|
|
57
57
|
</Const>
|
|
@@ -46,7 +46,7 @@ export function Schema(props: Props): ReactNode {
|
|
|
46
46
|
|
|
47
47
|
if (!tree.length) {
|
|
48
48
|
return (
|
|
49
|
-
<File.Source name={resolvedName} isExportable>
|
|
49
|
+
<File.Source name={resolvedName} isExportable isIndexable>
|
|
50
50
|
<Const
|
|
51
51
|
name={resolvedName}
|
|
52
52
|
export
|
|
@@ -79,7 +79,7 @@ export function Schema(props: Props): ReactNode {
|
|
|
79
79
|
|
|
80
80
|
return (
|
|
81
81
|
<>
|
|
82
|
-
<File.Source name={resolvedName} isExportable>
|
|
82
|
+
<File.Source name={resolvedName} isExportable isIndexable>
|
|
83
83
|
<Const
|
|
84
84
|
export
|
|
85
85
|
name={resolvedName}
|
|
@@ -97,7 +97,7 @@ export function Schema(props: Props): ReactNode {
|
|
|
97
97
|
</Const>
|
|
98
98
|
</File.Source>
|
|
99
99
|
{typedSchema && (
|
|
100
|
-
<File.Source name={resolvedTypeName} isExportable isTypeOnly>
|
|
100
|
+
<File.Source name={resolvedTypeName} isExportable isIndexable isTypeOnly>
|
|
101
101
|
<Type export name={resolvedTypeName}>
|
|
102
102
|
{`z.infer<typeof ${resolvedName}>`}
|
|
103
103
|
</Type>
|
|
@@ -6,8 +6,8 @@ export const operations = {"get_pets-pet-id": {
|
|
|
6
6
|
header: undefined
|
|
7
7
|
},
|
|
8
8
|
responses: {
|
|
9
|
-
200:
|
|
10
|
-
default:
|
|
9
|
+
200: getPetsPetIdQueryResponse,
|
|
10
|
+
default: getPetsPetIdQueryResponse
|
|
11
11
|
},
|
|
12
12
|
errors: {
|
|
13
13
|
|
|
@@ -17,27 +17,27 @@ export const operations = {"get_pets-pet-id": {
|
|
|
17
17
|
request: undefined,
|
|
18
18
|
parameters: {
|
|
19
19
|
path: undefined,
|
|
20
|
-
query:
|
|
20
|
+
query: listPetsQueryParams,
|
|
21
21
|
header: undefined
|
|
22
22
|
},
|
|
23
23
|
responses: {
|
|
24
|
-
200:
|
|
25
|
-
default:
|
|
24
|
+
200: listPetsQueryResponse,
|
|
25
|
+
default: listPetsQueryResponse
|
|
26
26
|
},
|
|
27
27
|
errors: {
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"createPets": {
|
|
32
|
-
request:
|
|
32
|
+
request: createPetsMutationRequest,
|
|
33
33
|
parameters: {
|
|
34
34
|
path: undefined,
|
|
35
35
|
query: undefined,
|
|
36
36
|
header: undefined
|
|
37
37
|
},
|
|
38
38
|
responses: {
|
|
39
|
-
201:
|
|
40
|
-
default:
|
|
39
|
+
201: createPetsMutationResponse,
|
|
40
|
+
default: createPetsMutationResponse
|
|
41
41
|
},
|
|
42
42
|
errors: {
|
|
43
43
|
|
package/src/plugin.ts
CHANGED
|
@@ -3,15 +3,15 @@ import path from 'node:path'
|
|
|
3
3
|
import { FileManager, PluginManager, createPlugin } from '@kubb/core'
|
|
4
4
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
5
5
|
import { renderTemplate } from '@kubb/core/utils'
|
|
6
|
-
import { OperationGenerator,
|
|
6
|
+
import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
7
7
|
|
|
8
8
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
9
9
|
|
|
10
10
|
import type { Plugin } from '@kubb/core'
|
|
11
11
|
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
12
|
+
import { zodParser } from './SchemaGenerator.tsx'
|
|
12
13
|
import { Operations } from './components/Operations.tsx'
|
|
13
14
|
import type { PluginZod } from './types.ts'
|
|
14
|
-
import { zodParser } from './SchemaGenerator.tsx'
|
|
15
15
|
|
|
16
16
|
export const pluginZodName = 'plugin-zod' satisfies PluginZod['name']
|
|
17
17
|
|
|
@@ -36,6 +36,10 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
38
|
name: pluginZodName,
|
|
39
|
+
output: {
|
|
40
|
+
exportType: 'barrelNamed',
|
|
41
|
+
...output,
|
|
42
|
+
},
|
|
39
43
|
options: {
|
|
40
44
|
extName: output.extName,
|
|
41
45
|
transformers,
|
|
@@ -126,16 +130,18 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
126
130
|
const operationFiles = await operationGenerator.build(zodParser)
|
|
127
131
|
await this.addFile(...operationFiles)
|
|
128
132
|
|
|
129
|
-
if (this.config.output.
|
|
130
|
-
const
|
|
133
|
+
if (this.config.output.exportType) {
|
|
134
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
131
135
|
root,
|
|
132
136
|
output,
|
|
133
137
|
files: this.fileManager.files,
|
|
134
|
-
|
|
138
|
+
meta: {
|
|
139
|
+
pluginKey: this.plugin.key,
|
|
140
|
+
},
|
|
135
141
|
logger: this.logger,
|
|
136
142
|
})
|
|
137
143
|
|
|
138
|
-
await this.addFile(...
|
|
144
|
+
await this.addFile(...barrelFiles)
|
|
139
145
|
}
|
|
140
146
|
},
|
|
141
147
|
}
|