@kubb/plugin-client 3.0.0-alpha.14 → 3.0.0-alpha.15

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.
Files changed (41) hide show
  1. package/dist/{chunk-YXOI7DUX.js → chunk-BAX6ZFGY.js} +2 -2
  2. package/dist/chunk-BAX6ZFGY.js.map +1 -0
  3. package/dist/chunk-H2OOHGK2.js +147 -0
  4. package/dist/chunk-H2OOHGK2.js.map +1 -0
  5. package/dist/chunk-TNO4CNBR.cjs +156 -0
  6. package/dist/chunk-TNO4CNBR.cjs.map +1 -0
  7. package/dist/{chunk-KGGPZ6QL.cjs → chunk-XDWPA5EL.cjs} +2 -2
  8. package/dist/chunk-XDWPA5EL.cjs.map +1 -0
  9. package/dist/components.cjs +3 -4
  10. package/dist/components.d.cts +10 -2
  11. package/dist/components.d.ts +10 -2
  12. package/dist/components.js +1 -2
  13. package/dist/generators.cjs +8 -4
  14. package/dist/generators.d.cts +5 -3
  15. package/dist/generators.d.ts +5 -3
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +9 -107
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +2 -106
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-DETYKDFZ.d.cts → types-CzL-44IA.d.cts} +18 -34
  24. package/dist/{types-DETYKDFZ.d.ts → types-CzL-44IA.d.ts} +18 -34
  25. package/package.json +12 -12
  26. package/src/components/Client.tsx +1 -1
  27. package/src/generators/{axiosGenerator.tsx → clientGenerator.tsx} +9 -26
  28. package/src/generators/index.ts +2 -1
  29. package/src/generators/operationsGenerator.tsx +21 -0
  30. package/src/plugin.ts +8 -15
  31. package/src/types.ts +17 -28
  32. package/dist/chunk-AZDWYBLW.cjs +0 -4
  33. package/dist/chunk-AZDWYBLW.cjs.map +0 -1
  34. package/dist/chunk-IPKWNP7B.js +0 -56
  35. package/dist/chunk-IPKWNP7B.js.map +0 -1
  36. package/dist/chunk-JKG3C6DG.cjs +0 -58
  37. package/dist/chunk-JKG3C6DG.cjs.map +0 -1
  38. package/dist/chunk-KGGPZ6QL.cjs.map +0 -1
  39. package/dist/chunk-YJOVLRSC.js +0 -3
  40. package/dist/chunk-YJOVLRSC.js.map +0 -1
  41. package/dist/chunk-YXOI7DUX.js.map +0 -1
package/src/plugin.ts CHANGED
@@ -5,11 +5,12 @@ import { camelCase } from '@kubb/core/transformers'
5
5
  import { renderTemplate } from '@kubb/core/utils'
6
6
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
7
7
 
8
- import { Client, Operations } from './components/index.ts'
8
+ import { Client } from './components/index.ts'
9
9
 
10
10
  import type { Plugin } from '@kubb/core'
11
11
  import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
12
- import { axiosGenerator } from './generators/axiosGenerator.tsx'
12
+ import { operationsGenerator } from './generators'
13
+ import { clientGenerator } from './generators/clientGenerator.tsx'
13
14
  import type { PluginClient } from './types.ts'
14
15
 
15
16
  export const pluginClientName = 'plugin-client' satisfies PluginClient['name']
@@ -24,7 +25,8 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
24
25
  transformers = {},
25
26
  dataReturnType = 'data',
26
27
  pathParamsType = 'inline',
27
- templates,
28
+ operations = false,
29
+ importPath = '@kubb/plugin-client/client',
28
30
  } = options
29
31
 
30
32
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`
@@ -36,19 +38,10 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
36
38
  ...output,
37
39
  },
38
40
  options: {
39
- extName: output.extName,
40
41
  dataReturnType,
41
- client: {
42
- importPath: '@kubb/plugin-client/client',
43
- methods: ['get', 'post', 'delete', 'put'],
44
- ...options.client,
45
- },
42
+ importPath,
43
+ template: options.template || Client,
46
44
  pathParamsType,
47
- templates: {
48
- operations: Operations,
49
- client: Client,
50
- ...templates,
51
- },
52
45
  baseURL: undefined,
53
46
  },
54
47
  pre: [pluginOasName],
@@ -106,7 +99,7 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
106
99
  },
107
100
  )
108
101
 
109
- const files = await operationGenerator.build(axiosGenerator)
102
+ const files = await operationGenerator.build(...[clientGenerator, operations ? operationsGenerator : undefined].filter(Boolean))
110
103
 
111
104
  await this.addFile(...files)
112
105
 
package/src/types.ts CHANGED
@@ -3,12 +3,7 @@ import type * as KubbFile from '@kubb/fs/types'
3
3
 
4
4
  import type { HttpMethod } from '@kubb/oas'
5
5
  import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
6
- import type { Client, Operations } from './components/index.ts'
7
-
8
- type Templates = {
9
- operations?: typeof Operations | false
10
- client?: typeof Client | false
11
- }
6
+ import type { Client } from './components/index.ts'
12
7
 
13
8
  export type Options = {
14
9
  output?: {
@@ -65,21 +60,20 @@ export type Options = {
65
60
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
66
61
  */
67
62
  override?: Array<Override<ResolvedOptions>>
68
- client?: {
69
- /**
70
- * Path to the client import path that will be used to do the API calls.
71
- * It will be used as `import client from '${client.importPath}'`.
72
- * It allows both relative and absolute path.
73
- * the path will be applied as is, so relative path should be based on the file being generated.
74
- * @default '@kubb/plugin-client/client'
75
- */
76
- importPath?: string
77
- /**
78
- * Define which HttpMethods can be used for queries
79
- * @default ['get', 'post', 'put', 'delete']
80
- */
81
- methods?: Array<HttpMethod>
82
- }
63
+ /**
64
+ * Create `operations.ts` file with all operations grouped by methods.
65
+ * @default `false`
66
+ */
67
+ operations?: boolean
68
+ /**
69
+ * Path to the client import path that will be used to do the API calls.
70
+ * It will be used as `import client from '${client.importPath}'`.
71
+ * It allows both relative and absolute path.
72
+ * the path will be applied as is, so relative path should be based on the file being generated.
73
+ * @default '@kubb/plugin-client/client'
74
+ */
75
+ importPath?: string
76
+ template?: typeof Client
83
77
  /**
84
78
  * ReturnType that needs to be used when calling client().
85
79
  *
@@ -106,19 +100,14 @@ export type Options = {
106
100
  */
107
101
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
108
102
  }
109
- /**
110
- * Make it possible to override one of the templates
111
- */
112
- templates?: Partial<Templates>
113
103
  }
114
104
 
115
105
  type ResolvedOptions = {
116
- extName: KubbFile.Extname | undefined
117
106
  baseURL: string | undefined
118
- client: Required<NonNullable<Options['client']>>
107
+ importPath: NonNullable<Options['importPath']>
108
+ template: NonNullable<Options['template']>
119
109
  dataReturnType: NonNullable<Options['dataReturnType']>
120
110
  pathParamsType: NonNullable<Options['pathParamsType']>
121
- templates: NonNullable<Templates>
122
111
  }
123
112
 
124
113
  export type FileMeta = {
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- //# sourceMappingURL=chunk-AZDWYBLW.cjs.map
4
- //# sourceMappingURL=chunk-AZDWYBLW.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-AZDWYBLW.cjs"}
@@ -1,56 +0,0 @@
1
- import { Operations, Client } from './chunk-YXOI7DUX.js';
2
- import { createReactGenerator } from '@kubb/plugin-oas';
3
- import { useOperationManager } from '@kubb/plugin-oas/hooks';
4
- import { pluginTsName } from '@kubb/plugin-ts';
5
- import { useApp, File } from '@kubb/react';
6
- import { jsx, jsxs } from '@kubb/react/jsx-runtime';
7
-
8
- var axiosGenerator = createReactGenerator({
9
- name: "plugin-client",
10
- Operations({ options, operations }) {
11
- const { pluginManager } = useApp();
12
- if (!options.templates.operations) {
13
- return null;
14
- }
15
- const Template = options.templates.operations || Operations;
16
- const name = "operations";
17
- const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
18
- return /* @__PURE__ */ jsx(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsx(Template, { name, operations }) });
19
- },
20
- Operation({ options, operation }) {
21
- const { getSchemas, getName, getFile } = useOperationManager();
22
- const name = getName(operation, { type: "function" });
23
- const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
24
- const file = getFile(operation);
25
- const fileType = getFile(operation, { pluginKey: [pluginTsName] });
26
- if (!options.templates.client) {
27
- return null;
28
- }
29
- const Template = options.templates.client || Client;
30
- return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
31
- /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
32
- /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
33
- /* @__PURE__ */ jsx(
34
- File.Import,
35
- {
36
- extName: options.extName,
37
- name: [
38
- typedSchemas.request?.name,
39
- typedSchemas.response.name,
40
- typedSchemas.pathParams?.name,
41
- typedSchemas.queryParams?.name,
42
- typedSchemas.headerParams?.name
43
- ].filter(Boolean),
44
- root: file.path,
45
- path: fileType.path,
46
- isTypeOnly: true
47
- }
48
- ),
49
- /* @__PURE__ */ jsx(Template, { name, options, typedSchemas, operation })
50
- ] });
51
- }
52
- });
53
-
54
- export { axiosGenerator };
55
- //# sourceMappingURL=chunk-IPKWNP7B.js.map
56
- //# sourceMappingURL=chunk-IPKWNP7B.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/axiosGenerator.tsx"],"names":[],"mappings":";;;;;;;AAQO,IAAM,iBAAiB,oBAAmC,CAAA;AAAA,EAC/D,IAAM,EAAA,eAAA;AAAA,EACN,UAAW,CAAA,EAAE,OAAS,EAAA,UAAA,EAAc,EAAA;AAClC,IAAM,MAAA,EAAE,aAAc,EAAA,GAAI,MAAqB,EAAA,CAAA;AAE/C,IAAI,IAAA,CAAC,OAAQ,CAAA,SAAA,CAAU,UAAY,EAAA;AACjC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,SAAA,CAAU,UAAc,IAAA,UAAA,CAAA;AACjD,IAAA,MAAM,IAAO,GAAA,YAAA,CAAA;AACb,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,OAAA,C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AK,QAAL,EAAY,IAAA,EAAM,UAAU,IAAM,EAAA,OAAA,CAAQ,OAAO,UAAY,EAAA,CAAA;AAAA,sBAC7D,GAAA,CAAA,IAAA,CAAK,MAAL,EAAA,EAAY,IAAM,EAAA,CAAC,gBAAgB,CAAA,EAAG,IAAM,EAAA,OAAA,CAAQ,MAAO,CAAA,UAAA,EAAY,YAAU,IAAC,EAAA,CAAA;AAAA,sBACnF,GAAA;AAAA,QAAC,IAAK,CAAA,MAAA;AAAA,QAAL;AAAA,UACC,SAAS,OAAQ,CAAA,OAAA;AAAA,UACjB,IAAM,EAAA;AAAA,YACJ,aAAa,OAAS,EAAA,IAAA;AAAA,YACtB,aAAa,QAAS,CAAA,IAAA;AAAA,YACtB,aAAa,UAAY,EAAA,IAAA;AAAA,YACzB,aAAa,WAAa,EAAA,IAAA;AAAA,YAC1B,aAAa,YAAc,EAAA,IAAA;AAAA,WAC7B,CAAE,OAAO,OAAO,CAAA;AAAA,UAChB,MAAM,IAAK,CAAA,IAAA;AAAA,UACX,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,UAAU,EAAA,IAAA;AAAA,SAAA;AAAA,OACZ;AAAA,sBACC,GAAA,CAAA,QAAA,EAAA,EAAS,IAAY,EAAA,OAAA,EAAkB,cAA4B,SAAsB,EAAA,CAAA;AAAA,KAC5F,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-IPKWNP7B.js","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const axiosGenerator = createReactGenerator<PluginClient>({\n name: 'plugin-client',\n Operations({ options, operations }) {\n const { pluginManager } = useApp<PluginClient>()\n\n if (!options.templates.operations) {\n return null\n }\n\n const Template = options.templates.operations || Operations\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: ['plugin-client'] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <Template name={name} operations={operations} />\n </File>\n )\n },\n Operation({ options, operation }) {\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n\n if (!options.templates.client) {\n return null\n }\n\n const Template = options.templates.client || Client\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n extName={options.extName}\n name={[\n typedSchemas.request?.name,\n typedSchemas.response.name,\n typedSchemas.pathParams?.name,\n typedSchemas.queryParams?.name,\n typedSchemas.headerParams?.name,\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <Template name={name} options={options} typedSchemas={typedSchemas} operation={operation} />\n </File>\n )\n },\n})\n"]}
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkKGGPZ6QL_cjs = require('./chunk-KGGPZ6QL.cjs');
4
- var pluginOas = require('@kubb/plugin-oas');
5
- var hooks = require('@kubb/plugin-oas/hooks');
6
- var pluginTs = require('@kubb/plugin-ts');
7
- var react = require('@kubb/react');
8
- var jsxRuntime = require('@kubb/react/jsx-runtime');
9
-
10
- var axiosGenerator = pluginOas.createReactGenerator({
11
- name: "plugin-client",
12
- Operations({ options, operations }) {
13
- const { pluginManager } = react.useApp();
14
- if (!options.templates.operations) {
15
- return null;
16
- }
17
- const Template = options.templates.operations || chunkKGGPZ6QL_cjs.Operations;
18
- const name = "operations";
19
- const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
20
- return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsxRuntime.jsx(Template, { name, operations }) });
21
- },
22
- Operation({ options, operation }) {
23
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
24
- const name = getName(operation, { type: "function" });
25
- const typedSchemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
26
- const file = getFile(operation);
27
- const fileType = getFile(operation, { pluginKey: [pluginTs.pluginTsName] });
28
- if (!options.templates.client) {
29
- return null;
30
- }
31
- const Template = options.templates.client || chunkKGGPZ6QL_cjs.Client;
32
- return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
33
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
34
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
35
- /* @__PURE__ */ jsxRuntime.jsx(
36
- react.File.Import,
37
- {
38
- extName: options.extName,
39
- name: [
40
- typedSchemas.request?.name,
41
- typedSchemas.response.name,
42
- typedSchemas.pathParams?.name,
43
- typedSchemas.queryParams?.name,
44
- typedSchemas.headerParams?.name
45
- ].filter(Boolean),
46
- root: file.path,
47
- path: fileType.path,
48
- isTypeOnly: true
49
- }
50
- ),
51
- /* @__PURE__ */ jsxRuntime.jsx(Template, { name, options, typedSchemas, operation })
52
- ] });
53
- }
54
- });
55
-
56
- exports.axiosGenerator = axiosGenerator;
57
- //# sourceMappingURL=chunk-JKG3C6DG.cjs.map
58
- //# sourceMappingURL=chunk-JKG3C6DG.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/axiosGenerator.tsx"],"names":["createReactGenerator","useApp","Operations","jsx","File","useOperationManager","pluginTsName","Client","jsxs"],"mappings":";;;;;;;;;AAQO,IAAM,iBAAiBA,8BAAmC,CAAA;AAAA,EAC/D,IAAM,EAAA,eAAA;AAAA,EACN,UAAW,CAAA,EAAE,OAAS,EAAA,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,CAAC","file":"chunk-JKG3C6DG.cjs","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const axiosGenerator = createReactGenerator<PluginClient>({\n name: 'plugin-client',\n Operations({ options, operations }) {\n const { pluginManager } = useApp<PluginClient>()\n\n if (!options.templates.operations) {\n return null\n }\n\n const Template = options.templates.operations || Operations\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: ['plugin-client'] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <Template name={name} operations={operations} />\n </File>\n )\n },\n Operation({ options, operation }) {\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n\n if (!options.templates.client) {\n return null\n }\n\n const Template = options.templates.client || Client\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n extName={options.extName}\n name={[\n typedSchemas.request?.name,\n typedSchemas.response.name,\n typedSchemas.pathParams?.name,\n typedSchemas.queryParams?.name,\n typedSchemas.headerParams?.name,\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <Template name={name} options={options} typedSchemas={typedSchemas} operation={operation} />\n </File>\n )\n },\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","createFunctionParams","getPathParams","isOptional","jsx","File","jsxs","Function","getComments","Const"],"mappings":";;;;;;;;;AAmBO,SAAS,O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YAAc,EAAA,CAAA;AAAA,WAAA;AAAA,SAC9I;AAAA,wBACAH,cAAA,CAACG,eAAS,MAAT,EAAA,EAAiB,kBAAQ,cAAmB,KAAA,MAAA,GAAS,aAAa,KAAM,EAAA,CAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GAE7E,EAAA,CAAA,CAAA;AAEJ,CAAA;AChIO,SAAS,UAAW,CAAA,EAAE,IAAM,EAAA,UAAA,EAA+B,EAAA;AAChE,EAAA,MAAM,mBAAyE,EAAC,CAAA;AAEhF,EAAW,UAAA,CAAA,OAAA,CAAQ,CAAC,SAAc,KAAA;AAChC,IAAiB,gBAAA,CAAA,SAAA,CAAU,cAAe,EAAC,CAAI,GAAA;AAAA,MAC7C,IAAM,EAAA,IAAIP,aAAQ,CAAA,SAAA,CAAU,IAAI,CAAE,CAAA,GAAA;AAAA,MAClC,QAAQ,SAAU,CAAA,MAAA;AAAA,KACpB,CAAA;AAAA,GACD,CAAA,CAAA;AAED,EACE,uBAAAI,cAACC,CAAAA,UAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,cAAAA,CAACK,eAAM,IAAY,EAAA,MAAA,EAAM,IAAC,EAAA,OAAA,EAAO,IAC9B,EAAA,QAAA,EAAA,IAAA,CAAK,UAAU,gBAAkB,EAAA,KAAA,CAAA,EAAW,CAAC,CAAA,EAChD,CACF,EAAA,CAAA,CAAA;AAEJ","file":"chunk-KGGPZ6QL.cjs","sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, createFunctionParams } from '@kubb/react'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n options: PluginClient['resolvedOptions']\n typedSchemas: OperationSchemas\n operation: Operation\n}\n\nexport function Client({ name, options, typedSchemas, operation }: Props): KubbNode {\n const contentType = operation.getContentType()\n const baseURL = options.baseURL\n const path = new URLPath(operation.path)\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typedSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const params = createFunctionParams({\n pathParams: {\n mode: options.pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typedSchemas.pathParams, { typed: true }),\n },\n data: typedSchemas.request?.name\n ? {\n type: typedSchemas.request?.name,\n optional: isOptional(typedSchemas.request?.schema),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: typedSchemas.queryParams?.name,\n optional: isOptional(typedSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typedSchemas.headerParams?.name\n ? {\n type: typedSchemas.headerParams?.name,\n optional: isOptional(typedSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n })\n\n const clientParams = createFunctionParams({\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(operation.method),\n },\n url: {\n type: 'string',\n value: path.template,\n },\n baseURL: baseURL\n ? {\n type: 'string',\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: 'any',\n }\n : undefined,\n data: typedSchemas.request?.name\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers.join(', ')}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n async\n export\n returnType={\n options.dataReturnType === 'data' ? `ResponseConfig<${typedSchemas.response.name}>[\"data\"]` : `ResponseConfig<${typedSchemas.response.name}>`\n }\n params={params}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData || ''}\n <Function.Call\n name=\"res\"\n to={<Function name=\"client\" async generics={[typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean)} params={clientParams} />}\n />\n <Function.Return>{options.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-YJOVLRSC.js.map
3
- //# sourceMappingURL=chunk-YJOVLRSC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-YJOVLRSC.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","jsx","File"],"mappings":";;;;;;;AAmBO,SAAS,OAAO,EAAE,IAAA,EAAM,OAAS,EAAA,YAAA,EAAc,WAA8B,EAAA;AAClF,EAAM,MAAA,WAAA,GAAc,UAAU,cAAe,EAAA,CAAA;AAC7C,EAAA,MAAM,UAAU,OAAQ,CA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A,KAAA;AAAA,GAE7E,EAAA,CAAA,CAAA;AAEJ,CAAA;AChIO,SAAS,UAAW,CAAA,EAAE,IAAM,EAAA,UAAA,EAA+B,EAAA;AAChE,EAAA,MAAM,mBAAyE,EAAC,CAAA;AAEhF,EAAW,UAAA,CAAA,OAAA,CAAQ,CAAC,SAAc,KAAA;AAChC,IAAiB,gBAAA,CAAA,SAAA,CAAU,cAAe,EAAC,CAAI,GAAA;AAAA,MAC7C,IAAM,EAAA,IAAIA,OAAQ,CAAA,SAAA,CAAU,IAAI,CAAE,CAAA,GAAA;AAAA,MAClC,QAAQ,SAAU,CAAA,MAAA;AAAA,KACpB,CAAA;AAAA,GACD,CAAA,CAAA;AAED,EACE,uBAAAC,GAACC,CAAAA,IAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,GAAAA,CAAC,SAAM,IAAY,EAAA,MAAA,EAAM,IAAC,EAAA,OAAA,EAAO,IAC9B,EAAA,QAAA,EAAA,IAAA,CAAK,UAAU,gBAAkB,EAAA,KAAA,CAAA,EAAW,CAAC,CAAA,EAChD,CACF,EAAA,CAAA,CAAA;AAEJ","file":"chunk-YXOI7DUX.js","sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, createFunctionParams } from '@kubb/react'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n options: PluginClient['resolvedOptions']\n typedSchemas: OperationSchemas\n operation: Operation\n}\n\nexport function Client({ name, options, typedSchemas, operation }: Props): KubbNode {\n const contentType = operation.getContentType()\n const baseURL = options.baseURL\n const path = new URLPath(operation.path)\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typedSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const params = createFunctionParams({\n pathParams: {\n mode: options.pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typedSchemas.pathParams, { typed: true }),\n },\n data: typedSchemas.request?.name\n ? {\n type: typedSchemas.request?.name,\n optional: isOptional(typedSchemas.request?.schema),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: typedSchemas.queryParams?.name,\n optional: isOptional(typedSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typedSchemas.headerParams?.name\n ? {\n type: typedSchemas.headerParams?.name,\n optional: isOptional(typedSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n })\n\n const clientParams = createFunctionParams({\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(operation.method),\n },\n url: {\n type: 'string',\n value: path.template,\n },\n baseURL: baseURL\n ? {\n type: 'string',\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: 'any',\n }\n : undefined,\n data: typedSchemas.request?.name\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers.join(', ')}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n async\n export\n returnType={\n options.dataReturnType === 'data' ? `ResponseConfig<${typedSchemas.response.name}>[\"data\"]` : `ResponseConfig<${typedSchemas.response.name}>`\n }\n params={params}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData || ''}\n <Function.Call\n name=\"res\"\n to={<Function name=\"client\" async generics={[typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean)} params={clientParams} />}\n />\n <Function.Return>{options.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"]}