@kubb/plugin-client 3.16.2 → 3.16.4

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 (52) hide show
  1. package/dist/Operations-Cxn7C-GC.cjs +228 -0
  2. package/dist/Operations-Cxn7C-GC.cjs.map +1 -0
  3. package/dist/Operations-tGJwS9Oj.js +210 -0
  4. package/dist/Operations-tGJwS9Oj.js.map +1 -0
  5. package/dist/chunk-CUT6urMc.cjs +30 -0
  6. package/dist/clients/axios.cjs +24 -30
  7. package/dist/clients/axios.cjs.map +1 -1
  8. package/dist/clients/axios.d.cts +23 -21
  9. package/dist/clients/axios.d.ts +23 -21
  10. package/dist/clients/axios.js +23 -23
  11. package/dist/clients/axios.js.map +1 -1
  12. package/dist/clients/fetch.cjs +37 -36
  13. package/dist/clients/fetch.cjs.map +1 -1
  14. package/dist/clients/fetch.d.cts +20 -18
  15. package/dist/clients/fetch.d.ts +20 -18
  16. package/dist/clients/fetch.js +37 -34
  17. package/dist/clients/fetch.js.map +1 -1
  18. package/dist/components.cjs +4 -19
  19. package/dist/components.d.cts +97 -56
  20. package/dist/components.d.ts +97 -56
  21. package/dist/components.js +3 -3
  22. package/dist/generators-BQnLTqYl.js +216 -0
  23. package/dist/generators-BQnLTqYl.js.map +1 -0
  24. package/dist/generators-XXsaqEtA.cjs +234 -0
  25. package/dist/generators-XXsaqEtA.cjs.map +1 -0
  26. package/dist/generators.cjs +5 -20
  27. package/dist/generators.d.cts +12 -11
  28. package/dist/generators.d.ts +12 -11
  29. package/dist/generators.js +4 -4
  30. package/dist/index.cjs +89 -118
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +6 -7
  33. package/dist/index.d.ts +6 -7
  34. package/dist/index.js +88 -112
  35. package/dist/index.js.map +1 -1
  36. package/dist/types-CdM4kNiz.d.ts +1274 -0
  37. package/dist/types-Cpfa5PKO.d.cts +1274 -0
  38. package/package.json +27 -34
  39. package/dist/chunk-H5KNP3DD.cjs +0 -205
  40. package/dist/chunk-H5KNP3DD.cjs.map +0 -1
  41. package/dist/chunk-LNJCFB5O.js +0 -201
  42. package/dist/chunk-LNJCFB5O.js.map +0 -1
  43. package/dist/chunk-QNFXNUH5.js +0 -187
  44. package/dist/chunk-QNFXNUH5.js.map +0 -1
  45. package/dist/chunk-SDEXSATF.cjs +0 -191
  46. package/dist/chunk-SDEXSATF.cjs.map +0 -1
  47. package/dist/components.cjs.map +0 -1
  48. package/dist/components.js.map +0 -1
  49. package/dist/generators.cjs.map +0 -1
  50. package/dist/generators.js.map +0 -1
  51. package/dist/types-DFo3xInC.d.cts +0 -119
  52. package/dist/types-DFo3xInC.d.ts +0 -119
@@ -1,187 +0,0 @@
1
- import { Url, Client, Operations } from './chunk-LNJCFB5O.js';
2
- import { createReactGenerator } from '@kubb/plugin-oas';
3
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
4
- import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
5
- import { pluginTsName } from '@kubb/plugin-ts';
6
- import { pluginZodName } from '@kubb/plugin-zod';
7
- import { useApp, File, Function } from '@kubb/react';
8
- import { jsxs, jsx } from '@kubb/react/jsx-runtime';
9
- import { camelCase } from '@kubb/core/transformers';
10
-
11
- var clientGenerator = createReactGenerator({
12
- name: "client",
13
- Operation({ options, operation }) {
14
- const {
15
- plugin: {
16
- options: { output, urlType }
17
- },
18
- pluginManager
19
- } = useApp();
20
- const oas = useOas();
21
- const { getSchemas, getName, getFile } = useOperationManager();
22
- const client = {
23
- name: getName(operation, { type: "function" }),
24
- file: getFile(operation)
25
- };
26
- const url = {
27
- name: getName(operation, { type: "function", suffix: "url", prefix: "get" }),
28
- file: getFile(operation)
29
- };
30
- const type = {
31
- file: getFile(operation, { pluginKey: [pluginTsName] }),
32
- schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
33
- };
34
- const zod = {
35
- file: getFile(operation, { pluginKey: [pluginZodName] }),
36
- schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
37
- };
38
- return /* @__PURE__ */ jsxs(
39
- File,
40
- {
41
- baseName: client.file.baseName,
42
- path: client.file.path,
43
- meta: client.file.meta,
44
- banner: getBanner({ oas, output, config: pluginManager.config }),
45
- footer: getFooter({ oas, output }),
46
- children: [
47
- /* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.importPath }),
48
- /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.importPath, isTypeOnly: true }),
49
- options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: client.file.path, path: zod.file.path }),
50
- /* @__PURE__ */ jsx(
51
- File.Import,
52
- {
53
- name: [
54
- type.schemas.request?.name,
55
- type.schemas.response.name,
56
- type.schemas.pathParams?.name,
57
- type.schemas.queryParams?.name,
58
- type.schemas.headerParams?.name,
59
- ...type.schemas.statusCodes?.map((item) => item.name) || []
60
- ].filter(Boolean),
61
- root: client.file.path,
62
- path: type.file.path,
63
- isTypeOnly: true
64
- }
65
- ),
66
- /* @__PURE__ */ jsx(
67
- Url,
68
- {
69
- name: url.name,
70
- baseURL: options.baseURL,
71
- pathParamsType: options.pathParamsType,
72
- paramsCasing: options.paramsCasing,
73
- paramsType: options.paramsType,
74
- typeSchemas: type.schemas,
75
- operation,
76
- isIndexable: urlType === "export",
77
- isExportable: urlType === "export"
78
- }
79
- ),
80
- /* @__PURE__ */ jsx(
81
- Client,
82
- {
83
- name: client.name,
84
- urlName: url.name,
85
- baseURL: options.baseURL,
86
- dataReturnType: options.dataReturnType,
87
- pathParamsType: options.pathParamsType,
88
- paramsCasing: options.paramsCasing,
89
- paramsType: options.paramsType,
90
- typeSchemas: type.schemas,
91
- operation,
92
- parser: options.parser,
93
- zodSchemas: zod.schemas
94
- }
95
- )
96
- ]
97
- }
98
- );
99
- }
100
- });
101
- var operationsGenerator = createReactGenerator({
102
- name: "client",
103
- Operations({ operations }) {
104
- const {
105
- pluginManager,
106
- plugin: {
107
- key: pluginKey,
108
- options: { output }
109
- }
110
- } = useApp();
111
- const oas = useOas();
112
- const name = "operations";
113
- const file = pluginManager.getFile({ name, extname: ".ts", pluginKey });
114
- return /* @__PURE__ */ jsx(
115
- File,
116
- {
117
- baseName: file.baseName,
118
- path: file.path,
119
- meta: file.meta,
120
- banner: getBanner({ oas, output, config: pluginManager.config }),
121
- footer: getFooter({ oas, output }),
122
- children: /* @__PURE__ */ jsx(Operations, { name, operations })
123
- }
124
- );
125
- }
126
- });
127
- var groupedClientGenerator = createReactGenerator({
128
- name: "groupedClient",
129
- Operations({ operations }) {
130
- const {
131
- pluginManager,
132
- plugin: { options, key: pluginKey }
133
- } = useApp();
134
- const oas = useOas();
135
- const { getName, getFile, getGroup } = useOperationManager();
136
- const controllers = operations.reduce(
137
- (acc, operation) => {
138
- if (options.group?.type === "tag") {
139
- const group = getGroup(operation);
140
- const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : void 0;
141
- if (!group?.tag || !name) {
142
- return acc;
143
- }
144
- const file = pluginManager.getFile({
145
- name,
146
- extname: ".ts",
147
- pluginKey,
148
- options: { group }
149
- });
150
- const client = {
151
- name: getName(operation, { type: "function" }),
152
- file: getFile(operation)
153
- };
154
- const previousFile = acc.find((item) => item.file.path === file.path);
155
- if (previousFile) {
156
- previousFile.clients.push(client);
157
- } else {
158
- acc.push({ name, file, clients: [client] });
159
- }
160
- }
161
- return acc;
162
- },
163
- []
164
- );
165
- return controllers.map(({ name, file, clients }) => {
166
- return /* @__PURE__ */ jsxs(
167
- File,
168
- {
169
- baseName: file.baseName,
170
- path: file.path,
171
- meta: file.meta,
172
- banner: getBanner({ oas, output: options.output, config: pluginManager.config }),
173
- footer: getFooter({ oas, output: options.output }),
174
- children: [
175
- clients.map((client) => /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: file.path, path: client.file.path }, client.name)),
176
- /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { export: true, name, children: `return { ${clients.map((client) => client.name).join(", ")} }` }) })
177
- ]
178
- },
179
- file.path
180
- );
181
- });
182
- }
183
- });
184
-
185
- export { clientGenerator, groupedClientGenerator, operationsGenerator };
186
- //# sourceMappingURL=chunk-QNFXNUH5.js.map
187
- //# sourceMappingURL=chunk-QNFXNUH5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","jsx","File","getBanner","getFooter","useOperationManager","jsxs"],"mappings":";;;;;;;;;;AAUO,IAAM,kBAAkB,oBAAmC,CAAA;AAAA,EAChE,IAAM,EAAA,QAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAA,EAAQ,OAAQ;AAAA,OAC7B;AAAA,MACA;AAAA,QACE,MAAqB,EAAA;AACzB,IAAA,MAAM,MAAM,MAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAY,mBAAoB,EAAA;AAE7D,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,MAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA;AAAA,MAC7C,IAAA,EAAM,QAAQ,SAAS;AAAA,KACzB;AAEA,IAAA,MAAM,GAAM,GAAA;AAAA,MACV,IAAA,EAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,MAAQ,EAAA,KAAA,EAAO,MAAQ,EAAA,KAAA,EAAO,CAAA;AAAA,MAC3E,IAAA,EAAM,QAAQ,SAAS;AAAA,KACzB;AAEA,IAAA,MAAM,IAAO,GAAA;AAAA,MACX,IAAA,EAAM,QAAQ,SAAW,EAAA,EAAE,W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,EAC/C,QAAAD,kBAAAA,GAAAA,CAAC,QAAS,EAAA,EAAA,MAAA,EAAM,IAAC,EAAA,IAAA,EACd,QAAY,EAAA,CAAA,SAAA,EAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,MAAW,KAAA,MAAA,CAAO,IAAI,CAAA,CAAE,IAAK,CAAA,IAAI,CAAC,CAAA,EAAA,CAAA,EAC9D,CACF,EAAA;AAAA;AAAA,SAAA;AAAA,QAfK,IAAK,CAAA;AAAA,OAgBZ;AAAA,KAEH,CAAA;AAAA;AAEL,CAAC","file":"chunk-QNFXNUH5.js","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"]}
@@ -1,191 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkH5KNP3DD_cjs = require('./chunk-H5KNP3DD.cjs');
4
- var pluginOas = require('@kubb/plugin-oas');
5
- var hooks = require('@kubb/plugin-oas/hooks');
6
- var utils = require('@kubb/plugin-oas/utils');
7
- var pluginTs = require('@kubb/plugin-ts');
8
- var pluginZod = require('@kubb/plugin-zod');
9
- var react = require('@kubb/react');
10
- var jsxRuntime = require('@kubb/react/jsx-runtime');
11
- var transformers = require('@kubb/core/transformers');
12
-
13
- var clientGenerator = pluginOas.createReactGenerator({
14
- name: "client",
15
- Operation({ options, operation }) {
16
- const {
17
- plugin: {
18
- options: { output, urlType }
19
- },
20
- pluginManager
21
- } = react.useApp();
22
- const oas = hooks.useOas();
23
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
24
- const client = {
25
- name: getName(operation, { type: "function" }),
26
- file: getFile(operation)
27
- };
28
- const url = {
29
- name: getName(operation, { type: "function", suffix: "url", prefix: "get" }),
30
- file: getFile(operation)
31
- };
32
- const type = {
33
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
34
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
35
- };
36
- const zod = {
37
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
38
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
39
- };
40
- return /* @__PURE__ */ jsxRuntime.jsxs(
41
- react.File,
42
- {
43
- baseName: client.file.baseName,
44
- path: client.file.path,
45
- meta: client.file.meta,
46
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
47
- footer: utils.getFooter({ oas, output }),
48
- children: [
49
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.importPath }),
50
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.importPath, isTypeOnly: true }),
51
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: client.file.path, path: zod.file.path }),
52
- /* @__PURE__ */ jsxRuntime.jsx(
53
- react.File.Import,
54
- {
55
- name: [
56
- type.schemas.request?.name,
57
- type.schemas.response.name,
58
- type.schemas.pathParams?.name,
59
- type.schemas.queryParams?.name,
60
- type.schemas.headerParams?.name,
61
- ...type.schemas.statusCodes?.map((item) => item.name) || []
62
- ].filter(Boolean),
63
- root: client.file.path,
64
- path: type.file.path,
65
- isTypeOnly: true
66
- }
67
- ),
68
- /* @__PURE__ */ jsxRuntime.jsx(
69
- chunkH5KNP3DD_cjs.Url,
70
- {
71
- name: url.name,
72
- baseURL: options.baseURL,
73
- pathParamsType: options.pathParamsType,
74
- paramsCasing: options.paramsCasing,
75
- paramsType: options.paramsType,
76
- typeSchemas: type.schemas,
77
- operation,
78
- isIndexable: urlType === "export",
79
- isExportable: urlType === "export"
80
- }
81
- ),
82
- /* @__PURE__ */ jsxRuntime.jsx(
83
- chunkH5KNP3DD_cjs.Client,
84
- {
85
- name: client.name,
86
- urlName: url.name,
87
- baseURL: options.baseURL,
88
- dataReturnType: options.dataReturnType,
89
- pathParamsType: options.pathParamsType,
90
- paramsCasing: options.paramsCasing,
91
- paramsType: options.paramsType,
92
- typeSchemas: type.schemas,
93
- operation,
94
- parser: options.parser,
95
- zodSchemas: zod.schemas
96
- }
97
- )
98
- ]
99
- }
100
- );
101
- }
102
- });
103
- var operationsGenerator = pluginOas.createReactGenerator({
104
- name: "client",
105
- Operations({ operations }) {
106
- const {
107
- pluginManager,
108
- plugin: {
109
- key: pluginKey,
110
- options: { output }
111
- }
112
- } = react.useApp();
113
- const oas = hooks.useOas();
114
- const name = "operations";
115
- const file = pluginManager.getFile({ name, extname: ".ts", pluginKey });
116
- return /* @__PURE__ */ jsxRuntime.jsx(
117
- react.File,
118
- {
119
- baseName: file.baseName,
120
- path: file.path,
121
- meta: file.meta,
122
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
123
- footer: utils.getFooter({ oas, output }),
124
- children: /* @__PURE__ */ jsxRuntime.jsx(chunkH5KNP3DD_cjs.Operations, { name, operations })
125
- }
126
- );
127
- }
128
- });
129
- var groupedClientGenerator = pluginOas.createReactGenerator({
130
- name: "groupedClient",
131
- Operations({ operations }) {
132
- const {
133
- pluginManager,
134
- plugin: { options, key: pluginKey }
135
- } = react.useApp();
136
- const oas = hooks.useOas();
137
- const { getName, getFile, getGroup } = hooks.useOperationManager();
138
- const controllers = operations.reduce(
139
- (acc, operation) => {
140
- if (options.group?.type === "tag") {
141
- const group = getGroup(operation);
142
- const name = group?.tag ? options.group?.name?.({ group: transformers.camelCase(group.tag) }) : void 0;
143
- if (!group?.tag || !name) {
144
- return acc;
145
- }
146
- const file = pluginManager.getFile({
147
- name,
148
- extname: ".ts",
149
- pluginKey,
150
- options: { group }
151
- });
152
- const client = {
153
- name: getName(operation, { type: "function" }),
154
- file: getFile(operation)
155
- };
156
- const previousFile = acc.find((item) => item.file.path === file.path);
157
- if (previousFile) {
158
- previousFile.clients.push(client);
159
- } else {
160
- acc.push({ name, file, clients: [client] });
161
- }
162
- }
163
- return acc;
164
- },
165
- []
166
- );
167
- return controllers.map(({ name, file, clients }) => {
168
- return /* @__PURE__ */ jsxRuntime.jsxs(
169
- react.File,
170
- {
171
- baseName: file.baseName,
172
- path: file.path,
173
- meta: file.meta,
174
- banner: utils.getBanner({ oas, output: options.output, config: pluginManager.config }),
175
- footer: utils.getFooter({ oas, output: options.output }),
176
- children: [
177
- clients.map((client) => /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: file.path, path: client.file.path }, client.name)),
178
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { export: true, name, children: `return { ${clients.map((client) => client.name).join(", ")} }` }) })
179
- ]
180
- },
181
- file.path
182
- );
183
- });
184
- }
185
- });
186
-
187
- exports.clientGenerator = clientGenerator;
188
- exports.groupedClientGenerator = groupedClientGenerator;
189
- exports.operationsGenerator = operationsGenerator;
190
- //# sourceMappingURL=chunk-SDEXSATF.cjs.map
191
- //# sourceMappingURL=chunk-SDEXSATF.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","pluginTsName","pluginZodName","jsxs","File","getBanner","getFooter","jsx","Url","Client","Operations","camelCase","Function"],"mappings":";;;;;;;;;;;;AAUO,IAAM,kBAAkBA,8BAAmC,CAAA;AAAA,EAChE,IAAM,EAAA,QAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAA,EAAQ,OAAQ;AAAA,OAC7B;AAAA,MACA;AAAA,QACEC,YAAqB,EAAA;AACzB,IAAA,MAAM,MAAMC,YAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA;AAE7D,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,MAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA;AAAA,MAC7C,IAAA,EAAM,QAAQ,SAAS;AAAA,KACzB;AAEA,IAAA,MAAM,GAAM,GAAA;AAAA,MACV,IAAA,EAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,MAAQ,EAAA,KAAA,EAAO,MAAQ,EAAA,KAAA,EAAO,CAAA;AAAA,MAC3E,IAAA,EAAM,QAAQ,SAAS;AAAA,KACzB;AAEA,IAAA,MAAM,IAAO,GAAA;AAAA,MACX,IAAA,EAAM,QAAQ,SAAW,EAAA,EAAE,WAAW,CAACC,qBAAY,GAAG,CAAA;AAAA,MACtD,OAAA,EAAS,UAAW,CAAA,SAAA,EAAW,EAAE,SAAA,EAAW,CAACA,qBAAY,CAAA,EAAG,IA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A,CAAA,SAAA,EAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,MAAW,KAAA,MAAA,CAAO,IAAI,CAAA,CAAE,IAAK,CAAA,IAAI,CAAC,CAAA,EAAA,CAAA,EAC9D,CACF,EAAA;AAAA;AAAA,SAAA;AAAA,QAfK,IAAK,CAAA;AAAA,OAgBZ;AAAA,KAEH,CAAA;AAAA;AAEL,CAAC","file":"chunk-SDEXSATF.cjs","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
@@ -1,119 +0,0 @@
1
- import { Output, Group, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import { Oas, contentType } from '@kubb/oas';
3
- import { Exclude, Include, Override, Generator, ResolvePathOptions } from '@kubb/plugin-oas';
4
-
5
- type Options = {
6
- /**
7
- * Specify the export location for the files and define the behavior of the output
8
- * @default { path: 'clients', barrelType: 'named' }
9
- */
10
- output?: Output<Oas>;
11
- /**
12
- * Define which contentType should be used.
13
- * By default, the first JSON valid mediaType will be used
14
- */
15
- contentType?: contentType;
16
- /**
17
- * Group the clients based on the provided name.
18
- */
19
- group?: Group;
20
- /**
21
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
22
- */
23
- exclude?: Array<Exclude>;
24
- /**
25
- * Array containing include parameters to include tags/operations/methods/paths.
26
- */
27
- include?: Array<Include>;
28
- /**
29
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
30
- */
31
- override?: Array<Override<ResolvedOptions>>;
32
- /**
33
- * Create `operations.ts` file with all operations grouped by methods.
34
- * @default false
35
- */
36
- operations?: boolean;
37
- /**
38
- * Export urls that are used by operation x
39
- * `export` will make them part of your barrel file
40
- * false will not make them exportable
41
- * @example getGetPetByIdUrl
42
- */
43
- urlType?: 'export' | false;
44
- /**
45
- * Path to the client import path that will be used to do the API calls.
46
- * It will be used as `import client from '${client.importPath}'`.
47
- * It allows both relative and absolute path but be aware that we will not change the path.
48
- * @default '@kubb/plugin-client/clients/axios'
49
- */
50
- importPath?: string;
51
- /**
52
- * Allows you to set a custom base url for all generated calls.
53
- */
54
- baseURL?: string;
55
- /**
56
- * ReturnType that will be used when calling the client.
57
- * - 'data' will return ResponseConfig[data].
58
- * - 'full' will return ResponseConfig.
59
- * @default 'data'
60
- */
61
- dataReturnType?: 'data' | 'full';
62
- /**
63
- * How to style your params, by default no casing is applied
64
- * - 'camelcase' will use camelcase for the params names
65
- */
66
- paramsCasing?: 'camelcase';
67
- /**
68
- * How to pass your params
69
- * - 'object' will return the params and pathParams as an object.
70
- * - 'inline' will return the params as comma separated params.
71
- * @default 'inline'
72
- */
73
- paramsType?: 'object' | 'inline';
74
- /**
75
- * How to pass your pathParams.
76
- * - 'object' will return the pathParams as an object.
77
- * - 'inline' will return the pathParams as comma separated params.
78
- * @default 'inline'
79
- */
80
- pathParamsType?: 'object' | 'inline';
81
- /**
82
- * Which parser can be used before returning the data
83
- * - 'zod' will use `@kubb/plugin-zod` to parse the data.
84
- * @default 'client'
85
- */
86
- parser?: 'client' | 'zod';
87
- /**
88
- * Which client should be used to do the HTTP calls
89
- * - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
90
- * - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
91
- * @default 'axios'
92
- */
93
- client?: 'axios' | 'fetch';
94
- transformers?: {
95
- /**
96
- * Customize the names based on the type that is provided by the plugin.
97
- */
98
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
99
- };
100
- /**
101
- * Define some generators next to the client generators
102
- */
103
- generators?: Array<Generator<PluginClient>>;
104
- };
105
- type ResolvedOptions = {
106
- output: Output<Oas>;
107
- group?: Options['group'];
108
- baseURL: string | undefined;
109
- parser: NonNullable<Options['parser']>;
110
- urlType: NonNullable<Options['urlType']>;
111
- importPath: NonNullable<Options['importPath']>;
112
- dataReturnType: NonNullable<Options['dataReturnType']>;
113
- pathParamsType: NonNullable<Options['pathParamsType']>;
114
- paramsType: NonNullable<Options['paramsType']>;
115
- paramsCasing: Options['paramsCasing'];
116
- };
117
- type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
118
-
119
- export type { Options as O, PluginClient as P };