@kubb/plugin-zod 3.0.0-alpha.8 → 3.0.0-alpha.9
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-TSJ74266.cjs → chunk-57AHBVYK.cjs} +54 -47
- package/dist/chunk-57AHBVYK.cjs.map +1 -0
- package/dist/{chunk-CD3EZWBX.js → chunk-CUPQVLRZ.js} +68 -61
- package/dist/{chunk-CD3EZWBX.js.map → chunk-CUPQVLRZ.js.map} +1 -1
- 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/SchemaGenerator.tsx +4 -4
- package/src/components/Operations.tsx +2 -2
- package/src/parser/index.ts +10 -2
- package/dist/chunk-TSJ74266.cjs.map +0 -1
package/dist/components.cjs
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk57AHBVYKcjs = require('./chunk-57AHBVYK.cjs');
|
|
7
7
|
|
|
8
8
|
// src/components/index.ts
|
|
9
|
-
|
|
9
|
+
_chunk57AHBVYKcjs.init_cjs_shims.call(void 0, );
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.OperationSchema =
|
|
14
|
+
exports.OperationSchema = _chunk57AHBVYKcjs.OperationSchema; exports.Operations = _chunk57AHBVYKcjs.Operations; exports.Schema = _chunk57AHBVYKcjs.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 _chunk57AHBVYKcjs = require('./chunk-57AHBVYK.cjs');
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
-
|
|
8
|
+
_chunk57AHBVYKcjs.init_cjs_shims.call(void 0, );
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.pluginZod =
|
|
12
|
+
exports.pluginZod = _chunk57AHBVYKcjs.pluginZod; exports.pluginZodName = _chunk57AHBVYKcjs.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.9",
|
|
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.9",
|
|
60
|
+
"@kubb/fs": "3.0.0-alpha.9",
|
|
61
|
+
"@kubb/oas": "3.0.0-alpha.9",
|
|
62
|
+
"@kubb/parser-ts": "3.0.0-alpha.9",
|
|
63
|
+
"@kubb/plugin-oas": "3.0.0-alpha.9",
|
|
64
|
+
"@kubb/react": "3.0.0-alpha.9",
|
|
65
|
+
"@kubb/types": "3.0.0-alpha.9"
|
|
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-biome": "3.0.0-alpha.
|
|
73
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
74
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
72
|
+
"@kubb/config-biome": "3.0.0-alpha.9",
|
|
73
|
+
"@kubb/config-ts": "3.0.0-alpha.9",
|
|
74
|
+
"@kubb/config-tsup": "3.0.0-alpha.9"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@kubb/react": "3.0.0-alpha.
|
|
77
|
+
"@kubb/react": "3.0.0-alpha.9"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20"
|
package/src/SchemaGenerator.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
|
+
import { OperationSchema } from './components/OperationSchema.tsx'
|
|
3
|
+
import { Operations } from './components/Operations.tsx'
|
|
2
4
|
import { Schema } from './components/Schema.tsx'
|
|
3
5
|
import type { PluginZod } from './types.ts'
|
|
4
|
-
import { Operations } from './components/Operations.tsx'
|
|
5
|
-
import { OperationSchema } from './components/OperationSchema.tsx'
|
|
6
6
|
|
|
7
|
-
export const zodParser =
|
|
7
|
+
export const zodParser = createReactGenerator<PluginZod>({
|
|
8
8
|
name: 'plugin-zod',
|
|
9
9
|
Operations({ options }) {
|
|
10
10
|
if (!options.templates.operations) {
|
|
@@ -80,10 +80,10 @@ function RootTemplate({ children }: RootTemplateProps) {
|
|
|
80
80
|
|
|
81
81
|
const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })
|
|
82
82
|
const imports = Object.entries(transformedOperations)
|
|
83
|
-
.map(([
|
|
83
|
+
.map(([key, { data, operation }]) => {
|
|
84
84
|
const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)
|
|
85
85
|
|
|
86
|
-
return <File.Import key={
|
|
86
|
+
return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />
|
|
87
87
|
})
|
|
88
88
|
.filter(Boolean)
|
|
89
89
|
|
package/src/parser/index.ts
CHANGED
|
@@ -12,7 +12,11 @@ export const zodKeywordMapper = {
|
|
|
12
12
|
.join('')
|
|
13
13
|
},
|
|
14
14
|
integer: (coercion?: boolean, min?: number, max?: number) => {
|
|
15
|
-
return [
|
|
15
|
+
return [
|
|
16
|
+
coercion ? 'z.coerce.number().int()' : 'z.number().int()',
|
|
17
|
+
min !== undefined ? `.min(${min})` : undefined,
|
|
18
|
+
max !== undefined ? `.max(${max})` : undefined,
|
|
19
|
+
]
|
|
16
20
|
.filter(Boolean)
|
|
17
21
|
.join('')
|
|
18
22
|
},
|
|
@@ -308,10 +312,14 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
|
|
|
308
312
|
return zodKeywordMapper.string(options.coercion)
|
|
309
313
|
}
|
|
310
314
|
|
|
311
|
-
if (isKeyword(current, schemaKeywords.number)
|
|
315
|
+
if (isKeyword(current, schemaKeywords.number)) {
|
|
312
316
|
return zodKeywordMapper.number(options.coercion)
|
|
313
317
|
}
|
|
314
318
|
|
|
319
|
+
if (isKeyword(current, schemaKeywords.integer)) {
|
|
320
|
+
return zodKeywordMapper.integer(options.coercion)
|
|
321
|
+
}
|
|
322
|
+
|
|
315
323
|
if (isKeyword(current, schemaKeywords.min)) {
|
|
316
324
|
return zodKeywordMapper.min(current.args)
|
|
317
325
|
}
|