@kubb/plugin-zod 3.0.0-alpha.0 → 3.0.0-alpha.10
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/{Operations-BlQtRP31.d.cts → Operations-BG26e_MW.d.cts} +1 -1
- package/dist/{Operations-BlQtRP31.d.ts → Operations-BG26e_MW.d.ts} +1 -1
- package/dist/chunk-57AHBVYK.cjs +3502 -0
- package/dist/chunk-57AHBVYK.cjs.map +1 -0
- package/dist/chunk-CUPQVLRZ.js +3502 -0
- package/dist/chunk-CUPQVLRZ.js.map +1 -0
- package/dist/components.cjs +6 -2
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +6 -2
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +4 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -17
- package/dist/index.d.ts +3 -17
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/SchemaGenerator.tsx +19 -28
- package/src/components/OperationSchema.tsx +8 -14
- package/src/components/Operations.tsx +18 -16
- package/src/components/Schema.tsx +35 -40
- package/src/components/__snapshots__/operations.ts +47 -44
- package/src/index.ts +0 -13
- package/src/parser/index.ts +10 -2
- package/src/plugin.ts +20 -39
- package/src/types.ts +0 -6
- package/dist/chunk-7IAXQL4T.cjs +0 -1291
- package/dist/chunk-7IAXQL4T.cjs.map +0 -1
- package/dist/chunk-OXCOZC6T.js +0 -1291
- package/dist/chunk-OXCOZC6T.js.map +0 -1
- package/src/OperationGenerator.tsx +0 -54
package/src/plugin.ts
CHANGED
|
@@ -3,15 +3,13 @@ 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 { pluginOasName } from '@kubb/plugin-oas'
|
|
7
|
-
import { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'
|
|
8
|
-
import { pluginTsName } from '@kubb/plugin-ts'
|
|
6
|
+
import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
9
7
|
|
|
10
|
-
import {
|
|
11
|
-
import { SchemaGenerator } from './SchemaGenerator.tsx'
|
|
8
|
+
import { pluginTsName } from '@kubb/plugin-ts'
|
|
12
9
|
|
|
13
10
|
import type { Plugin } from '@kubb/core'
|
|
14
11
|
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
12
|
+
import { zodParser } from './SchemaGenerator.tsx'
|
|
15
13
|
import { Operations } from './components/Operations.tsx'
|
|
16
14
|
import type { PluginZod } from './types.ts'
|
|
17
15
|
|
|
@@ -38,6 +36,10 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
38
36
|
|
|
39
37
|
return {
|
|
40
38
|
name: pluginZodName,
|
|
39
|
+
output: {
|
|
40
|
+
exportType: 'barrelNamed',
|
|
41
|
+
...output,
|
|
42
|
+
},
|
|
41
43
|
options: {
|
|
42
44
|
extName: output.extName,
|
|
43
45
|
transformers,
|
|
@@ -93,17 +95,10 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
93
95
|
|
|
94
96
|
return resolvedName
|
|
95
97
|
},
|
|
96
|
-
async writeFile(path, source) {
|
|
97
|
-
if (!path.endsWith('.ts') || !source) {
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return this.fileManager.write(path, source, { sanity: false })
|
|
102
|
-
},
|
|
103
98
|
async buildStart() {
|
|
104
99
|
const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
|
|
105
100
|
|
|
106
|
-
const oas = await swaggerPlugin.
|
|
101
|
+
const oas = await swaggerPlugin.context.getOas()
|
|
107
102
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
108
103
|
const mode = FileManager.getMode(path.resolve(root, output.path))
|
|
109
104
|
|
|
@@ -111,57 +106,43 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
111
106
|
oas,
|
|
112
107
|
pluginManager: this.pluginManager,
|
|
113
108
|
plugin: this.plugin,
|
|
114
|
-
contentType: swaggerPlugin.
|
|
109
|
+
contentType: swaggerPlugin.context.contentType,
|
|
115
110
|
include: undefined,
|
|
116
111
|
override,
|
|
117
112
|
mode,
|
|
118
113
|
output: output.path,
|
|
119
114
|
})
|
|
120
115
|
|
|
121
|
-
const schemaFiles = await schemaGenerator.build()
|
|
116
|
+
const schemaFiles = await schemaGenerator.build(zodParser)
|
|
122
117
|
await this.addFile(...schemaFiles)
|
|
123
118
|
|
|
124
119
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
125
120
|
oas,
|
|
126
121
|
pluginManager: this.pluginManager,
|
|
127
122
|
plugin: this.plugin,
|
|
128
|
-
contentType: swaggerPlugin.
|
|
123
|
+
contentType: swaggerPlugin.context.contentType,
|
|
129
124
|
exclude,
|
|
130
125
|
include,
|
|
131
126
|
override,
|
|
132
127
|
mode,
|
|
133
128
|
})
|
|
134
129
|
|
|
135
|
-
const operationFiles = await operationGenerator.build()
|
|
130
|
+
const operationFiles = await operationGenerator.build(zodParser)
|
|
136
131
|
await this.addFile(...operationFiles)
|
|
137
|
-
},
|
|
138
|
-
async buildEnd() {
|
|
139
|
-
if (this.config.output.write === false) {
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
132
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (group?.type === 'tag') {
|
|
146
|
-
const rootFiles = await getGroupedByTagFiles({
|
|
147
|
-
logger: this.logger,
|
|
148
|
-
files: this.fileManager.files,
|
|
149
|
-
plugin: this.plugin,
|
|
150
|
-
template,
|
|
151
|
-
exportAs: group.exportAs || '{{tag}}Schemas',
|
|
133
|
+
if (this.config.output.exportType) {
|
|
134
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
152
135
|
root,
|
|
153
136
|
output,
|
|
137
|
+
files: this.fileManager.files,
|
|
138
|
+
meta: {
|
|
139
|
+
pluginKey: this.plugin.key,
|
|
140
|
+
},
|
|
141
|
+
logger: this.logger,
|
|
154
142
|
})
|
|
155
143
|
|
|
156
|
-
await this.addFile(...
|
|
144
|
+
await this.addFile(...barrelFiles)
|
|
157
145
|
}
|
|
158
|
-
|
|
159
|
-
await this.fileManager.addIndexes({
|
|
160
|
-
root,
|
|
161
|
-
output,
|
|
162
|
-
meta: { pluginKey: this.plugin.key },
|
|
163
|
-
logger: this.logger,
|
|
164
|
-
})
|
|
165
146
|
},
|
|
166
147
|
}
|
|
167
148
|
})
|
package/src/types.ts
CHANGED
|
@@ -143,9 +143,3 @@ export type FileMeta = {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
146
|
-
|
|
147
|
-
declare module '@kubb/core' {
|
|
148
|
-
export interface _Register {
|
|
149
|
-
['@kubb/plugin-zod']: PluginZod
|
|
150
|
-
}
|
|
151
|
-
}
|