@kubb/plugin-client 5.0.0-beta.42 → 5.0.0-beta.56
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/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.js.map +1 -1
- package/dist/index.cjs +393 -342
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +57 -22
- package/dist/index.js +389 -342
- package/dist/index.js.map +1 -1
- package/dist/templates/clients/axios.source.cjs.map +1 -1
- package/dist/templates/clients/axios.source.js.map +1 -1
- package/dist/templates/clients/fetch.source.cjs.map +1 -1
- package/dist/templates/clients/fetch.source.js.map +1 -1
- package/dist/templates/config.source.cjs.map +1 -1
- package/dist/templates/config.source.js.map +1 -1
- package/package.json +10 -17
- package/src/components/ClassClient.tsx +31 -7
- package/src/components/Client.tsx +33 -25
- package/src/components/StaticClassClient.tsx +31 -7
- package/src/components/Url.tsx +2 -3
- package/src/generators/classClientGenerator.tsx +20 -12
- package/src/generators/clientGenerator.tsx +18 -10
- package/src/generators/groupedClientGenerator.tsx +2 -2
- package/src/generators/operationsGenerator.ts +47 -0
- package/src/generators/staticClassClientGenerator.tsx +20 -12
- package/src/index.ts +2 -1
- package/src/plugin.ts +5 -4
- package/src/resolvers/resolverClient.ts +5 -4
- package/src/types.ts +29 -21
- package/src/utils.ts +122 -22
- package/extension.yaml +0 -1267
- package/src/components/Operations.tsx +0 -29
- package/src/generators/operationsGenerator.tsx +0 -34
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { URLPath } from '@internals/utils'
|
|
2
|
-
import { ast } from '@kubb/core'
|
|
3
|
-
import { Const, File } from '@kubb/renderer-jsx'
|
|
4
|
-
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
5
|
-
|
|
6
|
-
type OperationsProps = {
|
|
7
|
-
name: string
|
|
8
|
-
nodes: Array<ast.OperationNode>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function Operations({ name, nodes }: OperationsProps): KubbReactNode {
|
|
12
|
-
const operationsObject: Record<string, { path: string; method: string }> = {}
|
|
13
|
-
|
|
14
|
-
nodes.forEach((node) => {
|
|
15
|
-
if (!ast.isHttpOperationNode(node)) return
|
|
16
|
-
operationsObject[node.operationId] = {
|
|
17
|
-
path: new URLPath(node.path).URL,
|
|
18
|
-
method: node.method.toLowerCase(),
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<File.Source name={name} isExportable isIndexable>
|
|
24
|
-
<Const name={name} export>
|
|
25
|
-
{JSON.stringify(operationsObject, undefined, 2)}
|
|
26
|
-
</Const>
|
|
27
|
-
</File.Source>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ast, defineGenerator } from '@kubb/core'
|
|
2
|
-
import { File, jsxRendererSync } from '@kubb/renderer-jsx'
|
|
3
|
-
import { Operations } from '../components/Operations'
|
|
4
|
-
import type { PluginClient } from '../types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Generates an `operations.ts` file that re-exports every operation grouped
|
|
8
|
-
* by HTTP method. Enabled when `pluginClient({ operations: true })`. Useful
|
|
9
|
-
* for building meta-tooling on top of the generated client (route
|
|
10
|
-
* registries, API explorers).
|
|
11
|
-
*/
|
|
12
|
-
export const operationsGenerator = defineGenerator<PluginClient>({
|
|
13
|
-
name: 'client',
|
|
14
|
-
renderer: jsxRendererSync,
|
|
15
|
-
operations(nodes, ctx) {
|
|
16
|
-
const { config, resolver, root } = ctx
|
|
17
|
-
const { output, group } = ctx.options
|
|
18
|
-
|
|
19
|
-
const name = 'operations'
|
|
20
|
-
const file = resolver.resolveFile({ name, extname: '.ts' }, { root, output, group: group ?? undefined })
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<File
|
|
24
|
-
baseName={file.baseName}
|
|
25
|
-
path={file.path}
|
|
26
|
-
meta={file.meta}
|
|
27
|
-
banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: file.path, baseName: file.baseName } })}
|
|
28
|
-
footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: file.path, baseName: file.baseName } })}
|
|
29
|
-
>
|
|
30
|
-
<Operations name={name} nodes={nodes.filter(ast.isHttpOperationNode)} />
|
|
31
|
-
</File>
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
})
|