@kubb/plugin-client 3.0.0-alpha.9 → 3.0.0-beta.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/README.md +14 -5
- package/client.ts +29 -8
- package/dist/chunk-ILOAIN3U.cjs +231 -0
- package/dist/chunk-ILOAIN3U.cjs.map +1 -0
- package/dist/chunk-PHUXTZZT.js +159 -0
- package/dist/chunk-PHUXTZZT.js.map +1 -0
- package/dist/chunk-UBMTYBLG.cjs +162 -0
- package/dist/chunk-UBMTYBLG.cjs.map +1 -0
- package/dist/chunk-UOML26IJ.js +221 -0
- package/dist/chunk-UOML26IJ.js.map +1 -0
- package/dist/client.cjs +36 -10
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +10 -4
- package/dist/client.d.ts +10 -4
- package/dist/client.js +24 -10
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +11 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +39 -5
- package/dist/components.d.ts +39 -5
- package/dist/components.js +2 -9
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -4
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.d.cts +7 -6
- package/dist/generators.d.ts +7 -6
- package/dist/generators.js +3 -7
- package/dist/generators.js.map +1 -1
- package/dist/index.cjs +11 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +3 -114
- package/dist/index.js.map +1 -1
- package/dist/types-DMMK2qi5.d.cts +88 -0
- package/dist/types-DMMK2qi5.d.ts +88 -0
- package/package.json +14 -17
- package/src/components/Client.tsx +120 -60
- package/src/generators/__snapshots__/deletePet.ts +13 -0
- package/src/generators/__snapshots__/deletePetObject.ts +13 -0
- package/src/generators/__snapshots__/findByTags.ts +13 -0
- package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
- package/src/generators/__snapshots__/findByTagsObject.ts +15 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
- package/src/generators/__snapshots__/importPath.ts +13 -0
- package/src/generators/__snapshots__/operations.ts +82 -0
- package/src/generators/__snapshots__/updatePetById.ts +12 -0
- package/src/generators/clientGenerator.tsx +67 -0
- package/src/generators/groupedClientGenerator.tsx +70 -0
- package/src/generators/index.ts +3 -1
- package/src/generators/operationsGenerator.tsx +26 -0
- package/src/plugin.ts +37 -46
- package/src/types.ts +47 -87
- package/dist/chunk-AZDWYBLW.cjs +0 -1
- package/dist/chunk-AZDWYBLW.cjs.map +0 -1
- package/dist/chunk-GHHJWXKQ.cjs +0 -61
- package/dist/chunk-GHHJWXKQ.cjs.map +0 -1
- package/dist/chunk-OODSLPAP.js +0 -61
- package/dist/chunk-OODSLPAP.js.map +0 -1
- package/dist/chunk-W256NILH.js +0 -128
- package/dist/chunk-W256NILH.js.map +0 -1
- package/dist/chunk-YGRM4AA5.cjs +0 -128
- package/dist/chunk-YGRM4AA5.cjs.map +0 -1
- package/dist/chunk-YJOVLRSC.js +0 -1
- package/dist/chunk-YJOVLRSC.js.map +0 -1
- package/dist/types-DETYKDFZ.d.cts +0 -139
- package/dist/types-DETYKDFZ.d.ts +0 -139
- package/src/components/__snapshots__/Client/showPetById.ts +0 -8
- package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
- package/src/components/__snapshots__/Query/showPetById.ts +0 -15
- package/src/generators/axiosGenerator.tsx +0 -63
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
|
-
import { useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
|
-
import { pluginTsName } from '@kubb/plugin-ts'
|
|
4
|
-
import { File, useApp } from '@kubb/react'
|
|
5
|
-
import { Client } from '../components/Client'
|
|
6
|
-
import { Operations } from '../components/Operations'
|
|
7
|
-
import type { PluginClient } from '../types'
|
|
8
|
-
|
|
9
|
-
export const axiosGenerator = createReactGenerator<PluginClient>({
|
|
10
|
-
name: 'plugin-client',
|
|
11
|
-
Operations({ options, operations }) {
|
|
12
|
-
const { pluginManager } = useApp<PluginClient>()
|
|
13
|
-
|
|
14
|
-
if (!options.templates.operations) {
|
|
15
|
-
return null
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Template = options.templates.operations || Operations
|
|
19
|
-
const name = 'operations'
|
|
20
|
-
const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: ['plugin-client'] })
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<File baseName={file.baseName} path={file.path} meta={file.meta}>
|
|
24
|
-
<Template name={name} operations={operations} />
|
|
25
|
-
</File>
|
|
26
|
-
)
|
|
27
|
-
},
|
|
28
|
-
Operation({ options, operation }) {
|
|
29
|
-
const { getSchemas, getName, getFile } = useOperationManager()
|
|
30
|
-
|
|
31
|
-
const name = getName(operation, { type: 'function' })
|
|
32
|
-
const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })
|
|
33
|
-
const file = getFile(operation)
|
|
34
|
-
const fileType = getFile(operation, { pluginKey: [pluginTsName] })
|
|
35
|
-
|
|
36
|
-
if (!options.templates.client) {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const Template = options.templates.client || Client
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<File baseName={file.baseName} path={file.path} meta={file.meta}>
|
|
44
|
-
<File.Import name={'client'} path={options.client.importPath} />
|
|
45
|
-
<File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />
|
|
46
|
-
<File.Import
|
|
47
|
-
extName={options.extName}
|
|
48
|
-
name={[
|
|
49
|
-
typedSchemas.request?.name,
|
|
50
|
-
typedSchemas.response.name,
|
|
51
|
-
typedSchemas.pathParams?.name,
|
|
52
|
-
typedSchemas.queryParams?.name,
|
|
53
|
-
typedSchemas.headerParams?.name,
|
|
54
|
-
].filter(Boolean)}
|
|
55
|
-
root={file.path}
|
|
56
|
-
path={fileType.path}
|
|
57
|
-
isTypeOnly
|
|
58
|
-
/>
|
|
59
|
-
<Template name={name} options={options} typedSchemas={typedSchemas} operation={operation} />
|
|
60
|
-
</File>
|
|
61
|
-
)
|
|
62
|
-
},
|
|
63
|
-
})
|