@kubb/plugin-zod 5.0.0-alpha.8 → 5.0.0-beta.3
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 +1 -3
- package/dist/index.cjs +1061 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +369 -4
- package/dist/index.js +1053 -104
- package/dist/index.js.map +1 -1
- package/package.json +44 -70
- package/src/components/Operations.tsx +25 -18
- package/src/components/Zod.tsx +21 -121
- package/src/constants.ts +5 -0
- package/src/generators/zodGenerator.tsx +174 -160
- package/src/index.ts +11 -2
- package/src/plugin.ts +67 -156
- package/src/printers/printerZod.ts +339 -0
- package/src/printers/printerZodMini.ts +295 -0
- package/src/resolvers/resolverZod.ts +57 -0
- package/src/types.ts +130 -115
- package/src/utils.ts +222 -0
- package/dist/components-B7zUFnAm.cjs +0 -890
- package/dist/components-B7zUFnAm.cjs.map +0 -1
- package/dist/components-eECfXVou.js +0 -842
- package/dist/components-eECfXVou.js.map +0 -1
- package/dist/components.cjs +0 -4
- package/dist/components.d.ts +0 -56
- package/dist/components.js +0 -2
- package/dist/generators-BjPDdJUz.cjs +0 -301
- package/dist/generators-BjPDdJUz.cjs.map +0 -1
- package/dist/generators-lTWPS6oN.js +0 -290
- package/dist/generators-lTWPS6oN.js.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -479
- package/dist/generators.js +0 -2
- package/dist/templates/ToZod.source.cjs +0 -7
- package/dist/templates/ToZod.source.cjs.map +0 -1
- package/dist/templates/ToZod.source.d.ts +0 -7
- package/dist/templates/ToZod.source.js +0 -6
- package/dist/templates/ToZod.source.js.map +0 -1
- package/dist/types-CoCoOc2u.d.ts +0 -172
- package/src/components/index.ts +0 -2
- package/src/generators/index.ts +0 -2
- package/src/generators/operationsGenerator.tsx +0 -50
- package/src/parser.ts +0 -909
- package/src/templates/ToZod.source.ts +0 -4
- package/templates/ToZod.ts +0 -61
package/src/generators/index.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { usePluginDriver } from '@kubb/core/hooks'
|
|
2
|
-
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
3
|
-
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
|
-
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
5
|
-
import { File } from '@kubb/react-fabric'
|
|
6
|
-
import { Operations } from '../components/Operations.tsx'
|
|
7
|
-
import type { PluginZod } from '../types'
|
|
8
|
-
|
|
9
|
-
export const operationsGenerator = createReactGenerator<PluginZod>({
|
|
10
|
-
name: 'operations',
|
|
11
|
-
Operations({ operations, generator, plugin }) {
|
|
12
|
-
const {
|
|
13
|
-
name: pluginName,
|
|
14
|
-
options: { output, importPath },
|
|
15
|
-
} = plugin
|
|
16
|
-
const driver = usePluginDriver()
|
|
17
|
-
|
|
18
|
-
const oas = useOas()
|
|
19
|
-
const { getFile, groupSchemasByName } = useOperationManager(generator)
|
|
20
|
-
|
|
21
|
-
const name = 'operations'
|
|
22
|
-
const file = driver.getFile({ name, extname: '.ts', pluginName })
|
|
23
|
-
|
|
24
|
-
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))
|
|
25
|
-
|
|
26
|
-
const imports = Object.entries(transformedOperations)
|
|
27
|
-
.map(([key, { data, operation }]) => {
|
|
28
|
-
const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)
|
|
29
|
-
|
|
30
|
-
return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />
|
|
31
|
-
})
|
|
32
|
-
.filter(Boolean)
|
|
33
|
-
|
|
34
|
-
const isZodImport = importPath === 'zod' || importPath === 'zod/mini'
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<File
|
|
38
|
-
baseName={file.baseName}
|
|
39
|
-
path={file.path}
|
|
40
|
-
meta={file.meta}
|
|
41
|
-
banner={getBanner({ oas, output, config: driver.config })}
|
|
42
|
-
footer={getFooter({ oas, output })}
|
|
43
|
-
>
|
|
44
|
-
<File.Import isTypeOnly name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />
|
|
45
|
-
{imports}
|
|
46
|
-
<Operations name={name} operations={transformedOperations} />
|
|
47
|
-
</File>
|
|
48
|
-
)
|
|
49
|
-
},
|
|
50
|
-
})
|