@kubb/plugin-client 3.0.0-alpha.3 → 3.0.0-alpha.30

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 (63) hide show
  1. package/README.md +13 -4
  2. package/client.ts +2 -2
  3. package/dist/chunk-ELPE4OER.cjs +183 -0
  4. package/dist/chunk-ELPE4OER.cjs.map +1 -0
  5. package/dist/chunk-RQSMSP6A.js +174 -0
  6. package/dist/chunk-RQSMSP6A.js.map +1 -0
  7. package/dist/chunk-X73EA6RA.cjs +133 -0
  8. package/dist/chunk-X73EA6RA.cjs.map +1 -0
  9. package/dist/chunk-YYBNZBCI.js +130 -0
  10. package/dist/chunk-YYBNZBCI.js.map +1 -0
  11. package/dist/client.cjs +16 -7
  12. package/dist/client.cjs.map +1 -1
  13. package/dist/client.d.cts +2 -2
  14. package/dist/client.d.ts +2 -2
  15. package/dist/client.js +5 -6
  16. package/dist/client.js.map +1 -1
  17. package/dist/components.cjs +11 -4
  18. package/dist/components.cjs.map +1 -1
  19. package/dist/components.d.cts +37 -7
  20. package/dist/components.d.ts +37 -7
  21. package/dist/components.js +2 -8
  22. package/dist/components.js.map +1 -1
  23. package/dist/generators.cjs +17 -0
  24. package/dist/generators.cjs.map +1 -0
  25. package/dist/generators.d.cts +9 -0
  26. package/dist/generators.d.ts +9 -0
  27. package/dist/generators.js +4 -0
  28. package/dist/generators.js.map +1 -0
  29. package/dist/index.cjs +10 -137
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -6
  32. package/dist/index.d.ts +1 -6
  33. package/dist/index.js +3 -143
  34. package/dist/index.js.map +1 -1
  35. package/dist/types-Bc-y9yTU.d.cts +100 -0
  36. package/dist/types-Bc-y9yTU.d.ts +100 -0
  37. package/package.json +22 -17
  38. package/src/components/Client.tsx +111 -212
  39. package/src/components/Operations.tsx +9 -75
  40. package/src/generators/__snapshots__/deletePet.ts +13 -0
  41. package/src/generators/__snapshots__/deletePetObject.ts +15 -0
  42. package/src/generators/__snapshots__/findByTags.ts +13 -0
  43. package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
  44. package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
  45. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
  46. package/src/generators/__snapshots__/importPath.ts +13 -0
  47. package/src/generators/__snapshots__/operations.ts +82 -0
  48. package/src/generators/__snapshots__/updatePetById.ts +12 -0
  49. package/src/generators/clientGenerator.tsx +66 -0
  50. package/src/generators/index.ts +2 -0
  51. package/src/generators/operationsGenerator.tsx +26 -0
  52. package/src/plugin.ts +23 -42
  53. package/src/types.ts +27 -55
  54. package/dist/chunk-W57BRY5O.js +0 -201
  55. package/dist/chunk-W57BRY5O.js.map +0 -1
  56. package/dist/chunk-W7F5CMU6.cjs +0 -201
  57. package/dist/chunk-W7F5CMU6.cjs.map +0 -1
  58. package/dist/types-C14AAtNX.d.cts +0 -233
  59. package/dist/types-C14AAtNX.d.ts +0 -233
  60. package/src/OperationGenerator.tsx +0 -29
  61. package/src/components/__snapshots__/Client/showPetById.ts +0 -11
  62. package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
  63. package/src/components/__snapshots__/Query/showPetById.ts +0 -15
@@ -0,0 +1,130 @@
1
+ import { URLPath } from '@kubb/core/utils';
2
+ import { isOptional } from '@kubb/oas';
3
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
4
+ import { FunctionParams, File, Function, Const } from '@kubb/react';
5
+ import { jsx, jsxs } from '@kubb/react/jsx-runtime';
6
+
7
+ // src/components/Client.tsx
8
+ function getParams({ pathParamsType, typeSchemas }) {
9
+ return FunctionParams.factory({
10
+ pathParams: {
11
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
12
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
13
+ },
14
+ data: typeSchemas.request?.name ? {
15
+ type: typeSchemas.request?.name,
16
+ optional: isOptional(typeSchemas.request?.schema)
17
+ } : void 0,
18
+ params: typeSchemas.queryParams?.name ? {
19
+ type: typeSchemas.queryParams?.name,
20
+ optional: isOptional(typeSchemas.queryParams?.schema)
21
+ } : void 0,
22
+ headers: typeSchemas.headerParams?.name ? {
23
+ type: typeSchemas.headerParams?.name,
24
+ optional: isOptional(typeSchemas.headerParams?.schema)
25
+ } : void 0,
26
+ config: {
27
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
28
+ default: "{}"
29
+ }
30
+ });
31
+ }
32
+ function Client({
33
+ name,
34
+ isExportable = true,
35
+ isIndexable = true,
36
+ typeSchemas,
37
+ baseURL,
38
+ dataReturnType,
39
+ parser,
40
+ zodSchemas,
41
+ pathParamsType,
42
+ operation
43
+ }) {
44
+ const path = new URLPath(operation.path);
45
+ const contentType = operation.getContentType();
46
+ const isFormData = contentType === "multipart/form-data";
47
+ const headers = [
48
+ contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
49
+ typeSchemas.headerParams?.name ? "...headers" : void 0
50
+ ].filter(Boolean);
51
+ const generics = [
52
+ typeSchemas.response.name,
53
+ typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error",
54
+ typeSchemas.request?.name || "unknown"
55
+ ].filter(Boolean);
56
+ const params = getParams({ pathParamsType, typeSchemas });
57
+ const clientParams = FunctionParams.factory({
58
+ config: {
59
+ mode: "object",
60
+ children: {
61
+ method: {
62
+ value: JSON.stringify(operation.method.toUpperCase())
63
+ },
64
+ url: {
65
+ value: path.template
66
+ },
67
+ baseURL: baseURL ? {
68
+ value: JSON.stringify(baseURL)
69
+ } : void 0,
70
+ params: typeSchemas.queryParams?.name ? {} : void 0,
71
+ data: typeSchemas.request?.name ? {
72
+ value: isFormData ? "formData" : void 0
73
+ } : void 0,
74
+ headers: headers.length ? {
75
+ value: headers.length ? `{ ${headers.join(", ")}, ...config.headers }` : void 0
76
+ } : void 0,
77
+ config: {
78
+ mode: "inlineSpread"
79
+ }
80
+ }
81
+ }
82
+ });
83
+ const formData = isFormData ? `
84
+ const formData = new FormData()
85
+ if(data) {
86
+ Object.keys(data).forEach((key) => {
87
+ const value = data[key as keyof typeof data];
88
+ if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
89
+ formData.append(key, value);
90
+ }
91
+ })
92
+ }
93
+ ` : "";
94
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsxs(
95
+ Function,
96
+ {
97
+ name,
98
+ async: true,
99
+ export: isExportable,
100
+ params: params.toConstructor(),
101
+ JSDoc: {
102
+ comments: getComments(operation)
103
+ },
104
+ children: [
105
+ formData,
106
+ `const res = await client<${generics.join(", ")}>(${clientParams.toCall()})`,
107
+ /* @__PURE__ */ jsx("br", {}),
108
+ dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
109
+ dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
110
+ dataReturnType === "full" && parser === "client" && "return res",
111
+ dataReturnType === "data" && parser === "client" && "return res.data"
112
+ ]
113
+ }
114
+ ) });
115
+ }
116
+ Client.getParams = getParams;
117
+ function Operations({ name, operations }) {
118
+ const operationsObject = {};
119
+ operations.forEach((operation) => {
120
+ operationsObject[operation.getOperationId()] = {
121
+ path: new URLPath(operation.path).URL,
122
+ method: operation.method
123
+ };
124
+ });
125
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
126
+ }
127
+
128
+ export { Client, Operations };
129
+ //# sourceMappingURL=chunk-YYBNZBCI.js.map
130
+ //# sourceMappingURL=chunk-YYBNZBCI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","jsx","File"],"mappings":";;;;;;;AA+BA,SAAS,SAAU,CAAA,EAAE,cAAgB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AChD,CACF,EAAA,CAAA,CAAA;AAEJ","file":"chunk-YYBNZBCI.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, FunctionParams } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n isExportable?: boolean\n isIndexable?: boolean\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n pathParamsType,\n operation,\n}: Props): KubbNode {\n const path = new URLPath(operation.path)\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const generics = [\n typeSchemas.response.name,\n typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error',\n typeSchemas.request?.name || 'unknown',\n ].filter(Boolean)\n const params = getParams({ pathParamsType, typeSchemas })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method.toUpperCase()),\n },\n url: {\n value: path.template,\n },\n baseURL: baseURL\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n value: headers.length ? `{ ${headers.join(', ')}, ...config.headers }` : undefined,\n }\n : undefined,\n config: {\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 as keyof typeof data];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : ''\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData}\n {`const res = await client<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\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"]}
package/dist/client.cjs CHANGED
@@ -1,6 +1,15 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// client.ts
2
- var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
3
- var axiosInstance = _axios2.default.create({
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
10
+
11
+ // client.ts
12
+ var axiosInstance = axios__default.default.create({
4
13
  baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0,
5
14
  headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0
6
15
  });
@@ -12,8 +21,8 @@ var axiosClient = async (config) => {
12
21
  };
13
22
  var client_default = axiosClient;
14
23
 
15
-
16
-
17
-
18
- exports.axiosClient = axiosClient; exports.axiosInstance = axiosInstance; exports.default = client_default;
24
+ exports.axiosClient = axiosClient;
25
+ exports.axiosInstance = axiosInstance;
26
+ exports.default = client_default;
27
+ //# sourceMappingURL=client.cjs.map
19
28
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/client.cjs","../client.ts"],"names":[],"mappings":"AAAA;ACAA,4EAAkB;AA8BX,IAAM,cAAA,EAAgB,eAAA,CAAM,MAAA,CAAO;AAAA,EACxC,OAAA,EAAS,OAAO,WAAA,IAAe,YAAA,EAAc,WAAA,EAAa,KAAA,CAAA;AAAA,EAC1D,OAAA,EAAS,OAAO,cAAA,IAAkB,YAAA,EAAe,IAAA,CAAK,KAAA,CAAM,aAAa,EAAA,EAAqB,KAAA;AAChG,CAAC,CAAA;AAEM,IAAM,YAAA,EAAc,MAAA,CAAsD,MAAA,EAAA,GAAsE;AACrJ,EAAA,MAAM,QAAA,EAAU,aAAA,CAAc,OAAA,CAAsC,MAAM,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,EAAA,GAA0B;AAC3G,IAAA,MAAM,CAAA;AAAA,EACR,CAAC,CAAA;AAED,EAAA,OAAO,OAAA;AACT,CAAA;AAEA,IAAO,eAAA,EAAQ,WAAA;AD9Bf;AACE;AACA;AACA;AACF,2GAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/client.cjs","sourcesContent":[null,"import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete'\n params?: unknown\n data?: TData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
1
+ {"version":3,"sources":["../client.ts"],"names":["axios"],"mappings":";;;;;;;;;;;AA8Ba,IAAA,aAAA,GAAgBA,uBAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.cjs","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
package/dist/client.d.cts CHANGED
@@ -7,9 +7,9 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';
7
7
  type RequestConfig<TData = unknown> = {
8
8
  baseURL?: string;
9
9
  url?: string;
10
- method: 'get' | 'put' | 'patch' | 'post' | 'delete';
10
+ method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS';
11
11
  params?: unknown;
12
- data?: TData;
12
+ data?: TData | FormData;
13
13
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
14
14
  signal?: AbortSignal;
15
15
  headers?: AxiosRequestConfig['headers'];
package/dist/client.d.ts CHANGED
@@ -7,9 +7,9 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';
7
7
  type RequestConfig<TData = unknown> = {
8
8
  baseURL?: string;
9
9
  url?: string;
10
- method: 'get' | 'put' | 'patch' | 'post' | 'delete';
10
+ method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS';
11
11
  params?: unknown;
12
- data?: TData;
12
+ data?: TData | FormData;
13
13
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
14
14
  signal?: AbortSignal;
15
15
  headers?: AxiosRequestConfig['headers'];
package/dist/client.js CHANGED
@@ -1,5 +1,6 @@
1
+ import axios from 'axios';
2
+
1
3
  // client.ts
2
- import axios from "axios";
3
4
  var axiosInstance = axios.create({
4
5
  baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0,
5
6
  headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0
@@ -11,9 +12,7 @@ var axiosClient = async (config) => {
11
12
  return promise;
12
13
  };
13
14
  var client_default = axiosClient;
14
- export {
15
- axiosClient,
16
- axiosInstance,
17
- client_default as default
18
- };
15
+
16
+ export { axiosClient, axiosInstance, client_default as default };
17
+ //# sourceMappingURL=client.js.map
19
18
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../client.ts"],"sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete'\n params?: unknown\n data?: TData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"],"mappings":";AAAA,OAAO,WAAW;AA8BX,IAAM,gBAAgB,MAAM,OAAO;AAAA,EACxC,SAAS,OAAO,eAAe,cAAc,aAAa;AAAA,EAC1D,SAAS,OAAO,kBAAkB,cAAe,KAAK,MAAM,aAAa,IAAqB;AAChG,CAAC;AAEM,IAAM,cAAc,OAAsD,WAAsE;AACrJ,QAAM,UAAU,cAAc,QAAsC,MAAM,EAAE,MAAM,CAAC,MAA0B;AAC3G,UAAM;AAAA,EACR,CAAC;AAED,SAAO;AACT;AAEA,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../client.ts"],"names":[],"mappings":";;;AA8Ba,IAAA,aAAA,GAAgB,MAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.js","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
@@ -1,9 +1,16 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkX73EA6RA_cjs = require('./chunk-X73EA6RA.cjs');
3
4
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
5
5
 
6
6
 
7
-
8
- exports.Client = _chunkW7F5CMU6cjs.Client; exports.Operations = _chunkW7F5CMU6cjs.Operations;
7
+ Object.defineProperty(exports, "Client", {
8
+ enumerable: true,
9
+ get: function () { return chunkX73EA6RA_cjs.Client; }
10
+ });
11
+ Object.defineProperty(exports, "Operations", {
12
+ enumerable: true,
13
+ get: function () { return chunkX73EA6RA_cjs.Operations; }
14
+ });
15
+ //# sourceMappingURL=components.cjs.map
9
16
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
@@ -1,8 +1,38 @@
1
- export { C as Client, a as Operations } from './types-C14AAtNX.cjs';
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-Bc-y9yTU.cjs';
2
6
  import '@kubb/core';
3
- import '@kubb/fs/types';
4
- import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
+ typeSchemas: OperationSchemas;
20
+ zodSchemas: OperationSchemas | undefined;
21
+ operation: Operation;
22
+ };
23
+ type GetParamsProps = {
24
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
+ typeSchemas: OperationSchemas;
26
+ };
27
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
28
+ declare namespace Client {
29
+ var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
+ }
31
+
32
+ type OperationsProps = {
33
+ name: string;
34
+ operations: Array<Operation>;
35
+ };
36
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
37
+
38
+ export { Client, Operations };
@@ -1,8 +1,38 @@
1
- export { C as Client, a as Operations } from './types-C14AAtNX.js';
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-Bc-y9yTU.js';
2
6
  import '@kubb/core';
3
- import '@kubb/fs/types';
4
- import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
+ typeSchemas: OperationSchemas;
20
+ zodSchemas: OperationSchemas | undefined;
21
+ operation: Operation;
22
+ };
23
+ type GetParamsProps = {
24
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
+ typeSchemas: OperationSchemas;
26
+ };
27
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
28
+ declare namespace Client {
29
+ var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
+ }
31
+
32
+ type OperationsProps = {
33
+ name: string;
34
+ operations: Array<Operation>;
35
+ };
36
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
37
+
38
+ export { Client, Operations };
@@ -1,9 +1,3 @@
1
- import {
2
- Client,
3
- Operations
4
- } from "./chunk-W57BRY5O.js";
5
- export {
6
- Client,
7
- Operations
8
- };
1
+ export { Client, Operations } from './chunk-YYBNZBCI.js';
2
+ //# sourceMappingURL=components.js.map
9
3
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunkELPE4OER_cjs = require('./chunk-ELPE4OER.cjs');
4
+ require('./chunk-X73EA6RA.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "clientGenerator", {
9
+ enumerable: true,
10
+ get: function () { return chunkELPE4OER_cjs.clientGenerator; }
11
+ });
12
+ Object.defineProperty(exports, "operationsGenerator", {
13
+ enumerable: true,
14
+ get: function () { return chunkELPE4OER_cjs.operationsGenerator; }
15
+ });
16
+ //# sourceMappingURL=generators.cjs.map
17
+ //# sourceMappingURL=generators.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-Bc-y9yTU.cjs';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ export { clientGenerator, operationsGenerator };
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-Bc-y9yTU.js';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ export { clientGenerator, operationsGenerator };
@@ -0,0 +1,4 @@
1
+ export { clientGenerator, operationsGenerator } from './chunk-RQSMSP6A.js';
2
+ import './chunk-YYBNZBCI.js';
3
+ //# sourceMappingURL=generators.js.map
4
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/index.cjs CHANGED
@@ -1,144 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ 'use strict';
2
2
 
3
+ var chunkELPE4OER_cjs = require('./chunk-ELPE4OER.cjs');
4
+ require('./chunk-X73EA6RA.cjs');
3
5
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
5
6
 
6
- // src/plugin.ts
7
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
- var _core = require('@kubb/core');
9
- var _transformers = require('@kubb/core/transformers');
10
- var _utils = require('@kubb/core/utils');
11
- var _pluginoas = require('@kubb/plugin-oas');
12
- var _utils3 = require('@kubb/plugin-oas/utils');
13
7
 
14
- // src/OperationGenerator.tsx
15
-
16
- require('@kubb/plugin-oas/components');
17
- require('@kubb/react');
18
- var _jsxruntime = require('@kubb/react/jsx-runtime');
19
- var clientParser = _pluginoas.createReactParser.call(void 0, {
20
- name: "plugin-client",
21
- Operations({ options }) {
22
- if (!options.templates.operations) {
23
- return null;
24
- }
25
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
26
- },
27
- Operation({ options, operation }) {
28
- const isEnabled = options.client.methods.some((method) => operation.method === method);
29
- if (!options.templates.client || !isEnabled) {
30
- return null;
31
- }
32
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Client.File, { baseURL: options.baseURL, templates: options.templates.client });
33
- }
8
+ Object.defineProperty(exports, "pluginClient", {
9
+ enumerable: true,
10
+ get: function () { return chunkELPE4OER_cjs.pluginClient; }
34
11
  });
35
-
36
- // src/plugin.ts
37
- var pluginClientName = "plugin-client";
38
- var pluginClient = _core.createPlugin.call(void 0, (options) => {
39
- const {
40
- output = { path: "clients" },
41
- group,
42
- exclude = [],
43
- include,
44
- override = [],
45
- transformers = {},
46
- dataReturnType = "data",
47
- pathParamsType = "inline",
48
- templates
49
- } = options;
50
- const template = _optionalChain([group, 'optionalAccess', _ => _.output]) ? group.output : `${output.path}/{{tag}}Controller`;
51
- return {
52
- name: pluginClientName,
53
- options: {
54
- extName: output.extName,
55
- dataReturnType,
56
- client: {
57
- importPath: "@kubb/plugin-client/client",
58
- methods: ["get", "post", "delete", "put"],
59
- ...options.client
60
- },
61
- pathParamsType,
62
- templates: {
63
- operations: _chunkW7F5CMU6cjs.Operations.templates,
64
- client: _chunkW7F5CMU6cjs.Client.templates,
65
- ...templates
66
- },
67
- baseURL: void 0
68
- },
69
- pre: [_pluginoas.pluginOasName],
70
- resolvePath(baseName, pathMode, options2) {
71
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
72
- const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
73
- if (mode === "single") {
74
- return _path2.default.resolve(root, output.path);
75
- }
76
- if (_optionalChain([options2, 'optionalAccess', _2 => _2.tag]) && _optionalChain([group, 'optionalAccess', _3 => _3.type]) === "tag") {
77
- const tag = _transformers.camelCase.call(void 0, options2.tag);
78
- return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
79
- }
80
- return _path2.default.resolve(root, output.path, baseName);
81
- },
82
- resolveName(name, type) {
83
- const resolvedName = _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
84
- if (type) {
85
- return _optionalChain([transformers, 'optionalAccess', _4 => _4.name, 'optionalCall', _5 => _5(resolvedName, type)]) || resolvedName;
86
- }
87
- return resolvedName;
88
- },
89
- async buildStart() {
90
- const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
91
- const oas = await swaggerPlugin.context.getOas();
92
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
93
- const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
94
- const baseURL = await swaggerPlugin.context.getBaseURL();
95
- const operationGenerator = new (0, _pluginoas.OperationGenerator)(
96
- {
97
- ...this.plugin.options,
98
- baseURL
99
- },
100
- {
101
- oas,
102
- pluginManager: this.pluginManager,
103
- plugin: this.plugin,
104
- contentType: swaggerPlugin.context.contentType,
105
- exclude,
106
- include,
107
- override,
108
- mode
109
- }
110
- );
111
- const files = await operationGenerator.build(clientParser);
112
- await this.addFile(...files);
113
- },
114
- async buildEnd() {
115
- if (this.config.output.write === false) {
116
- return;
117
- }
118
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
119
- if (_optionalChain([group, 'optionalAccess', _6 => _6.type]) === "tag") {
120
- const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
121
- logger: this.logger,
122
- files: this.fileManager.files,
123
- plugin: this.plugin,
124
- template,
125
- exportAs: group.exportAs || "{{tag}}Service",
126
- root,
127
- output
128
- });
129
- await this.addFile(...rootFiles);
130
- }
131
- await this.fileManager.addIndexes({
132
- root,
133
- output,
134
- meta: { pluginKey: this.plugin.key },
135
- logger: this.logger
136
- });
137
- }
138
- };
12
+ Object.defineProperty(exports, "pluginClientName", {
13
+ enumerable: true,
14
+ get: function () { return chunkELPE4OER_cjs.pluginClientName; }
139
15
  });
140
-
141
-
142
-
143
- exports.pluginClient = pluginClient; exports.pluginClientName = pluginClientName;
16
+ //# sourceMappingURL=index.cjs.map
144
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAA0B;AAC1B,yCAA+B;AAC/B,6CAAkD;AAClD,gDAAqC;ADMrC;AACA;AEbA;AACA,uCAAoB;AACpB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ADCkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Service',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,11 +1,6 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-C14AAtNX.cjs';
3
- import '@kubb/fs/types';
2
+ import { O as Options, P as PluginClient } from './types-Bc-y9yTU.cjs';
4
3
  import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
9
4
 
10
5
  declare const pluginClientName = "plugin-client";
11
6
  declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;