@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.
- package/README.md +13 -4
- package/client.ts +2 -2
- package/dist/chunk-ELPE4OER.cjs +183 -0
- package/dist/chunk-ELPE4OER.cjs.map +1 -0
- package/dist/chunk-RQSMSP6A.js +174 -0
- package/dist/chunk-RQSMSP6A.js.map +1 -0
- package/dist/chunk-X73EA6RA.cjs +133 -0
- package/dist/chunk-X73EA6RA.cjs.map +1 -0
- package/dist/chunk-YYBNZBCI.js +130 -0
- package/dist/chunk-YYBNZBCI.js.map +1 -0
- package/dist/client.cjs +16 -7
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -6
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +11 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +37 -7
- package/dist/components.d.ts +37 -7
- package/dist/components.js +2 -8
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +9 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +10 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +3 -143
- package/dist/index.js.map +1 -1
- package/dist/types-Bc-y9yTU.d.cts +100 -0
- package/dist/types-Bc-y9yTU.d.ts +100 -0
- package/package.json +22 -17
- package/src/components/Client.tsx +111 -212
- package/src/components/Operations.tsx +9 -75
- package/src/generators/__snapshots__/deletePet.ts +13 -0
- package/src/generators/__snapshots__/deletePetObject.ts +15 -0
- package/src/generators/__snapshots__/findByTags.ts +13 -0
- package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
- package/src/generators/__snapshots__/importPath.ts +13 -0
- package/src/generators/__snapshots__/operations.ts +82 -0
- package/src/generators/__snapshots__/updatePetById.ts +12 -0
- package/src/generators/clientGenerator.tsx +66 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/operationsGenerator.tsx +26 -0
- package/src/plugin.ts +23 -42
- package/src/types.ts +27 -55
- package/dist/chunk-W57BRY5O.js +0 -201
- package/dist/chunk-W57BRY5O.js.map +0 -1
- package/dist/chunk-W7F5CMU6.cjs +0 -201
- package/dist/chunk-W7F5CMU6.cjs.map +0 -1
- package/dist/types-C14AAtNX.d.cts +0 -233
- package/dist/types-C14AAtNX.d.ts +0 -233
- package/src/OperationGenerator.tsx +0 -29
- package/src/components/__snapshots__/Client/showPetById.ts +0 -11
- package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
- 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,EAAA,WAAA,EAA+B,EAAA;AAClE,EAAA,OAAO,eAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAAA,EAAM,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,MAC/C,UAAU,aAAc,CAAA,WAAA,CAAY,YAAY,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,KACjE;AAAA,IACA,IAAA,EAAM,WAAY,CAAA,OAAA,EAAS,IACvB,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,OAAS,EAAA,IAAA;AAAA,MAC3B,QAAU,EAAA,UAAA,CAAW,WAAY,CAAA,OAAA,EAAS,MAAM,CAAA;AAAA,KAElD,GAAA,K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AAA;AAAA,OAAA;AAAA,KAAA;AAAA,GAEzD,EAAA,CAAA,CAAA;AAEJ,CAAA;AAEA,MAAA,CAAO,SAAY,GAAA,SAAA,CAAA;ACpJZ,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-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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
24
|
+
exports.axiosClient = axiosClient;
|
|
25
|
+
exports.axiosInstance = axiosInstance;
|
|
26
|
+
exports.default = client_default;
|
|
27
|
+
//# sourceMappingURL=client.cjs.map
|
|
19
28
|
//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
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: '
|
|
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: '
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
package/dist/client.js.map
CHANGED
|
@@ -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: '
|
|
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"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
|
package/dist/components.d.cts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|
package/dist/components.js
CHANGED
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,144 +1,17 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
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-
|
|
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>;
|