@kubb/plugin-client 4.3.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Operations-ktPlsW1u.js → Operations-CmHRmAdn.js} +3 -3
- package/dist/Operations-CmHRmAdn.js.map +1 -0
- package/dist/{Operations-CT9m1j9w.cjs → Operations-DXjVfmrY.cjs} +24 -24
- package/dist/Operations-DXjVfmrY.cjs.map +1 -0
- package/dist/chunk-DMmIE7y6.js +28 -0
- package/dist/clients/axios.d.cts +4 -4
- package/dist/clients/axios.d.ts +4 -4
- package/dist/clients/fetch.d.cts +4 -4
- package/dist/clients/fetch.d.ts +4 -4
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +9 -13
- package/dist/components.d.ts +9 -13
- package/dist/components.js +1 -1
- package/dist/{generators-BqXV2IXC.js → generators-0Sc5zPfx.js} +4 -4
- package/dist/generators-0Sc5zPfx.js.map +1 -0
- package/dist/{generators-BSxTToF6.cjs → generators-C_ySk_ES.cjs} +19 -19
- package/dist/generators-C_ySk_ES.cjs.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-BPLzP9R9.d.ts → types-DJmtgGu4.d.ts} +230 -328
- package/dist/{types-rIa1K280.d.cts → types-DuPfvza5.d.cts} +230 -328
- package/package.json +17 -12
- package/src/components/Client.tsx +3 -3
- package/src/components/Operations.tsx +3 -2
- package/src/components/Url.tsx +13 -2
- package/src/generators/clientGenerator.tsx +1 -1
- package/src/generators/groupedClientGenerator.tsx +2 -2
- package/src/generators/operationsGenerator.tsx +1 -1
- package/src/plugin.ts +1 -0
- package/src/types.ts +1 -1
- package/dist/Operations-CT9m1j9w.cjs.map +0 -1
- package/dist/Operations-ktPlsW1u.js.map +0 -1
- package/dist/generators-BSxTToF6.cjs.map +0 -1
- package/dist/generators-BqXV2IXC.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
2
|
-
import { Const, File, Function, FunctionParams } from "@kubb/react";
|
|
2
|
+
import { Const, File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { URLPath } from "@kubb/core/utils";
|
|
4
4
|
import { isOptional } from "@kubb/oas";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Url.tsx
|
|
8
8
|
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
@@ -216,4 +216,4 @@ function Operations({ name, operations }) {
|
|
|
216
216
|
|
|
217
217
|
//#endregion
|
|
218
218
|
export { Client as n, Url as r, Operations as t };
|
|
219
|
-
//# sourceMappingURL=Operations-
|
|
219
|
+
//# sourceMappingURL=Operations-CmHRmAdn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operations-CmHRmAdn.js","names":["getParams","operationsObject: Record<string, { path: string; method: HttpMethod }>"],"sources":["../src/components/Url.tsx","../src/components/Client.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { Const, File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/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 paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n })\n}\n\nexport function Url({\n name,\n isExportable = true,\n isIndexable = true,\n typeSchemas,\n baseURL,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n}: Props): KubbNode {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function name={name} export={isExportable} params={params.toConstructor()}>\n <Const name={'res'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } 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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n urlName?: string\n isExportable?: boolean\n isIndexable?: boolean\n isConfigurable?: boolean\n returnType?: string\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n children?: KubbNode\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n isConfigurable: boolean\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\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 },\n },\n config: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\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: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n returnType,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n urlName,\n children,\n isConfigurable = true,\n}: Props): KubbNode {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' && contentType !== 'multipart/form-data' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\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: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\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' : 'requestData',\n }\n : undefined,\n requestConfig: isConfigurable\n ? {\n mode: 'inlineSpread',\n }\n : undefined,\n headers: headers.length\n ? {\n value: isConfigurable ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : `{ ${headers.join(', ')} }`,\n }\n : undefined,\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if (requestData) {\n Object.keys(requestData).forEach((key) => {\n const value = requestData[key as keyof typeof requestData];\n if (typeof value === 'string' || (value as unknown) instanceof Blob) {\n formData.append(key, value as unknown as string | Blob);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n })\n }\n `\n : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\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 </>\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 returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport { Const, File } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps): KubbNode {\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>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAgCA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,GAAG,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC,EAChF;EACF,EACF,CAAC;AAGJ,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,UAAU,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC;EACtF,UAAU,WAAW,YAAY,YAAY,OAAO;EACrD,GACD,QACL,CAAC;;AAGJ,SAAgB,IAAI,EAClB,MACA,eAAe,MACf,cAAc,MACd,aACA,SACA,YACA,cACA,gBACA,aACkB;CAClB,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ,cAAc,CAAC;CAClE,MAAM,SAASA,YAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;AAEnF,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBA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,cAAc;AAChC,mBAAiB,UAAU,gBAAgB,IAAI;GAC7C,MAAM,IAAI,QAAQ,UAAU,KAAK,CAAC;GAClC,QAAQ,UAAU;GACnB;GACD;AAEF,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAY;GAAM;aAChB,KAAK,UAAU,kBAAkB,QAAW,EAAE;IACzC;GACI"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
3
3
|
__kubb_plugin_oas_utils = require_chunk.__toESM(__kubb_plugin_oas_utils);
|
|
4
|
-
let
|
|
5
|
-
|
|
4
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
5
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
6
6
|
let __kubb_core_utils = require("@kubb/core/utils");
|
|
7
7
|
__kubb_core_utils = require_chunk.__toESM(__kubb_core_utils);
|
|
8
8
|
let __kubb_oas = require("@kubb/oas");
|
|
9
9
|
__kubb_oas = require_chunk.__toESM(__kubb_oas);
|
|
10
|
-
let
|
|
11
|
-
|
|
10
|
+
let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
11
|
+
__kubb_react_fabric_jsx_runtime = require_chunk.__toESM(__kubb_react_fabric_jsx_runtime);
|
|
12
12
|
|
|
13
13
|
//#region src/components/Url.tsx
|
|
14
14
|
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
15
|
-
if (paramsType === "object") return
|
|
15
|
+
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({ data: {
|
|
16
16
|
mode: "object",
|
|
17
17
|
children: { ...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
18
18
|
typed: true,
|
|
19
19
|
casing: paramsCasing
|
|
20
20
|
}) }
|
|
21
21
|
} });
|
|
22
|
-
return
|
|
22
|
+
return __kubb_react_fabric.FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? {
|
|
23
23
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
24
24
|
children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
25
25
|
typed: true,
|
|
@@ -36,20 +36,20 @@ function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseU
|
|
|
36
36
|
pathParamsType,
|
|
37
37
|
typeSchemas
|
|
38
38
|
});
|
|
39
|
-
return /* @__PURE__ */ (0,
|
|
39
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
40
40
|
name,
|
|
41
41
|
isExportable,
|
|
42
42
|
isIndexable,
|
|
43
|
-
children: /* @__PURE__ */ (0,
|
|
43
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.Function, {
|
|
44
44
|
name,
|
|
45
45
|
export: isExportable,
|
|
46
46
|
params: params.toConstructor(),
|
|
47
47
|
children: [
|
|
48
|
-
/* @__PURE__ */ (0,
|
|
48
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Const, {
|
|
49
49
|
name: "res",
|
|
50
50
|
children: `{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`
|
|
51
51
|
}),
|
|
52
|
-
/* @__PURE__ */ (0,
|
|
52
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
53
53
|
"return res"
|
|
54
54
|
]
|
|
55
55
|
})
|
|
@@ -60,7 +60,7 @@ Url.getParams = getParams$1;
|
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region src/components/Client.tsx
|
|
62
62
|
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }) {
|
|
63
|
-
if (paramsType === "object") return
|
|
63
|
+
if (paramsType === "object") return __kubb_react_fabric.FunctionParams.factory({
|
|
64
64
|
data: {
|
|
65
65
|
mode: "object",
|
|
66
66
|
children: {
|
|
@@ -87,7 +87,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isCo
|
|
|
87
87
|
default: "{}"
|
|
88
88
|
} : void 0
|
|
89
89
|
});
|
|
90
|
-
return
|
|
90
|
+
return __kubb_react_fabric.FunctionParams.factory({
|
|
91
91
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
92
92
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
93
93
|
children: (0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
@@ -138,7 +138,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
138
138
|
pathParamsType,
|
|
139
139
|
typeSchemas
|
|
140
140
|
});
|
|
141
|
-
const clientParams =
|
|
141
|
+
const clientParams = __kubb_react_fabric.FunctionParams.factory({ config: {
|
|
142
142
|
mode: "object",
|
|
143
143
|
children: {
|
|
144
144
|
method: { value: JSON.stringify(operation.method.toUpperCase()) },
|
|
@@ -163,17 +163,17 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
163
163
|
})
|
|
164
164
|
}
|
|
165
165
|
` : void 0;
|
|
166
|
-
const childrenElement = children ? children : /* @__PURE__ */ (0,
|
|
166
|
+
const childrenElement = children ? children : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
167
167
|
dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
|
|
168
168
|
dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
|
|
169
169
|
dataReturnType === "full" && parser === "client" && "return res",
|
|
170
170
|
dataReturnType === "data" && parser === "client" && "return res.data"
|
|
171
171
|
] });
|
|
172
|
-
return /* @__PURE__ */ (0,
|
|
172
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
173
173
|
name,
|
|
174
174
|
isExportable,
|
|
175
175
|
isIndexable,
|
|
176
|
-
children: /* @__PURE__ */ (0,
|
|
176
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.Function, {
|
|
177
177
|
name,
|
|
178
178
|
async: true,
|
|
179
179
|
export: isExportable,
|
|
@@ -182,15 +182,15 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
182
182
|
returnType,
|
|
183
183
|
children: [
|
|
184
184
|
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
185
|
-
/* @__PURE__ */ (0,
|
|
186
|
-
/* @__PURE__ */ (0,
|
|
185
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
186
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
187
187
|
parser === "zod" && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`,
|
|
188
188
|
parser === "client" && typeSchemas?.request?.name && "const requestData = data",
|
|
189
|
-
/* @__PURE__ */ (0,
|
|
189
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
190
190
|
formData,
|
|
191
|
-
/* @__PURE__ */ (0,
|
|
191
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
192
192
|
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
193
|
-
/* @__PURE__ */ (0,
|
|
193
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)("br", {}),
|
|
194
194
|
childrenElement
|
|
195
195
|
]
|
|
196
196
|
})
|
|
@@ -208,11 +208,11 @@ function Operations({ name, operations }) {
|
|
|
208
208
|
method: operation.method
|
|
209
209
|
};
|
|
210
210
|
});
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
211
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
212
212
|
name,
|
|
213
213
|
isExportable: true,
|
|
214
214
|
isIndexable: true,
|
|
215
|
-
children: /* @__PURE__ */ (0,
|
|
215
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Const, {
|
|
216
216
|
name,
|
|
217
217
|
export: true,
|
|
218
218
|
children: JSON.stringify(operationsObject, void 0, 2)
|
|
@@ -239,4 +239,4 @@ Object.defineProperty(exports, 'Url', {
|
|
|
239
239
|
return Url;
|
|
240
240
|
}
|
|
241
241
|
});
|
|
242
|
-
//# sourceMappingURL=Operations-
|
|
242
|
+
//# sourceMappingURL=Operations-DXjVfmrY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operations-DXjVfmrY.cjs","names":["getParams","FunctionParams","URLPath","File","Function","Const","FunctionParams","URLPath","File","Function","operationsObject: Record<string, { path: string; method: HttpMethod }>","URLPath","File","Const"],"sources":["../src/components/Url.tsx","../src/components/Client.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { Const, File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/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 paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n })\n}\n\nexport function Url({\n name,\n isExportable = true,\n isIndexable = true,\n typeSchemas,\n baseURL,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n}: Props): KubbNode {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function name={name} export={isExportable} params={params.toConstructor()}>\n <Const name={'res'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } 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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n urlName?: string\n isExportable?: boolean\n isIndexable?: boolean\n isConfigurable?: boolean\n returnType?: string\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n children?: KubbNode\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n isConfigurable: boolean\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\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 },\n },\n config: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\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: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n returnType,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n urlName,\n children,\n isConfigurable = true,\n}: Props): KubbNode {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' && contentType !== 'multipart/form-data' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\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: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\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' : 'requestData',\n }\n : undefined,\n requestConfig: isConfigurable\n ? {\n mode: 'inlineSpread',\n }\n : undefined,\n headers: headers.length\n ? {\n value: isConfigurable ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : `{ ${headers.join(', ')} }`,\n }\n : undefined,\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if (requestData) {\n Object.keys(requestData).forEach((key) => {\n const value = requestData[key as keyof typeof requestData];\n if (typeof value === 'string' || (value as unknown) instanceof Blob) {\n formData.append(key, value as unknown as string | Blob);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n })\n }\n `\n : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\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 </>\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 returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport { Const, File } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps): KubbNode {\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>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAOC,mCAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,8CAAiB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC,EAChF;EACF,EACF,CAAC;AAGJ,QAAOA,mCAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,qDAAwB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC;EACtF,qCAAqB,YAAY,YAAY,OAAO;EACrD,GACD,QACL,CAAC;;AAGJ,SAAgB,IAAI,EAClB,MACA,eAAe,MACf,cAAc,MACd,aACA,SACA,YACA,cACA,gBACA,aACkB;CAClB,MAAM,OAAO,IAAIC,0BAAQ,UAAU,MAAM,EAAE,QAAQ,cAAc,CAAC;CAClE,MAAM,SAASF,YAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;AAEnF,QACE,yDAACG,yBAAK;EAAa;EAAoB;EAA2B;YAChE,0DAACC;GAAe;GAAM,QAAQ;GAAc,QAAQ,OAAO,eAAe;;IACxE,yDAACC;KAAM,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,QAAQ,UAAU;GACnB;GACD;AAEF,QACE,yDAACC,yBAAK;EAAa;EAAM;EAAa;YACpC,yDAACC;GAAY;GAAM;aAChB,KAAK,UAAU,kBAAkB,QAAW,EAAE;IACzC;GACI"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { };
|
package/dist/clients/axios.d.cts
CHANGED
|
@@ -5,12 +5,12 @@ import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
|
5
5
|
/**
|
|
6
6
|
* Subset of AxiosRequestConfig
|
|
7
7
|
*/
|
|
8
|
-
type RequestConfig<TData
|
|
8
|
+
type RequestConfig<TData = unknown> = {
|
|
9
9
|
baseURL?: string;
|
|
10
10
|
url?: string;
|
|
11
11
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
12
12
|
params?: unknown;
|
|
13
|
-
data?: TData
|
|
13
|
+
data?: TData | FormData;
|
|
14
14
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
validateStatus?: (status: number) => boolean;
|
|
@@ -19,8 +19,8 @@ type RequestConfig<TData$1 = unknown> = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Subset of AxiosResponse
|
|
21
21
|
*/
|
|
22
|
-
type ResponseConfig<TData
|
|
23
|
-
data: TData
|
|
22
|
+
type ResponseConfig<TData = unknown> = {
|
|
23
|
+
data: TData;
|
|
24
24
|
status: number;
|
|
25
25
|
statusText: string;
|
|
26
26
|
headers: AxiosResponse['headers'];
|
package/dist/clients/axios.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
|
5
5
|
/**
|
|
6
6
|
* Subset of AxiosRequestConfig
|
|
7
7
|
*/
|
|
8
|
-
type RequestConfig<TData
|
|
8
|
+
type RequestConfig<TData = unknown> = {
|
|
9
9
|
baseURL?: string;
|
|
10
10
|
url?: string;
|
|
11
11
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
12
12
|
params?: unknown;
|
|
13
|
-
data?: TData
|
|
13
|
+
data?: TData | FormData;
|
|
14
14
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
validateStatus?: (status: number) => boolean;
|
|
@@ -19,8 +19,8 @@ type RequestConfig<TData$1 = unknown> = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Subset of AxiosResponse
|
|
21
21
|
*/
|
|
22
|
-
type ResponseConfig<TData
|
|
23
|
-
data: TData
|
|
22
|
+
type ResponseConfig<TData = unknown> = {
|
|
23
|
+
data: TData;
|
|
24
24
|
status: number;
|
|
25
25
|
statusText: string;
|
|
26
26
|
headers: AxiosResponse['headers'];
|
package/dist/clients/fetch.d.cts
CHANGED
|
@@ -6,12 +6,12 @@ type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
|
|
6
6
|
/**
|
|
7
7
|
* Subset of FetchRequestConfig
|
|
8
8
|
*/
|
|
9
|
-
type RequestConfig<TData
|
|
9
|
+
type RequestConfig<TData = unknown> = {
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
url?: string;
|
|
12
12
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
13
13
|
params?: unknown;
|
|
14
|
-
data?: TData
|
|
14
|
+
data?: TData | FormData;
|
|
15
15
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
headers?: [string, string][] | Record<string, string>;
|
|
@@ -20,8 +20,8 @@ type RequestConfig<TData$1 = unknown> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Subset of FetchResponse
|
|
22
22
|
*/
|
|
23
|
-
type ResponseConfig<TData
|
|
24
|
-
data: TData
|
|
23
|
+
type ResponseConfig<TData = unknown> = {
|
|
24
|
+
data: TData;
|
|
25
25
|
status: number;
|
|
26
26
|
statusText: string;
|
|
27
27
|
headers: Headers;
|
package/dist/clients/fetch.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
|
|
6
6
|
/**
|
|
7
7
|
* Subset of FetchRequestConfig
|
|
8
8
|
*/
|
|
9
|
-
type RequestConfig<TData
|
|
9
|
+
type RequestConfig<TData = unknown> = {
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
url?: string;
|
|
12
12
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
13
13
|
params?: unknown;
|
|
14
|
-
data?: TData
|
|
14
|
+
data?: TData | FormData;
|
|
15
15
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
headers?: [string, string][] | Record<string, string>;
|
|
@@ -20,8 +20,8 @@ type RequestConfig<TData$1 = unknown> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Subset of FetchResponse
|
|
22
22
|
*/
|
|
23
|
-
type ResponseConfig<TData
|
|
24
|
-
data: TData
|
|
23
|
+
type ResponseConfig<TData = unknown> = {
|
|
24
|
+
data: TData;
|
|
25
25
|
status: number;
|
|
26
26
|
statusText: string;
|
|
27
27
|
headers: Headers;
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PluginClient, o as Operation, r as OperationSchemas } from "./types-DuPfvza5.cjs";
|
|
2
|
+
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
2
4
|
|
|
3
|
-
//#region ../react/src/index.d.ts
|
|
4
|
-
|
|
5
|
-
import * as import___kubb_react_fabric from "@kubb/react-fabric";
|
|
6
|
-
import * as import___kubb_react_fabric_parsers from "@kubb/react-fabric/parsers";
|
|
7
|
-
import * as import___kubb_react_fabric_plugins from "@kubb/react-fabric/plugins";
|
|
8
|
-
//#endregion
|
|
9
5
|
//#region src/components/Client.d.ts
|
|
10
6
|
type Props$1 = {
|
|
11
7
|
/**
|
|
@@ -26,7 +22,7 @@ type Props$1 = {
|
|
|
26
22
|
typeSchemas: OperationSchemas;
|
|
27
23
|
zodSchemas: OperationSchemas | undefined;
|
|
28
24
|
operation: Operation;
|
|
29
|
-
children?:
|
|
25
|
+
children?: KubbNode;
|
|
30
26
|
};
|
|
31
27
|
type GetParamsProps$1 = {
|
|
32
28
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -52,7 +48,7 @@ declare function Client({
|
|
|
52
48
|
urlName,
|
|
53
49
|
children,
|
|
54
50
|
isConfigurable
|
|
55
|
-
}: Props$1):
|
|
51
|
+
}: Props$1): KubbNode;
|
|
56
52
|
declare namespace Client {
|
|
57
53
|
var getParams: ({
|
|
58
54
|
paramsType,
|
|
@@ -60,7 +56,7 @@ declare namespace Client {
|
|
|
60
56
|
pathParamsType,
|
|
61
57
|
typeSchemas,
|
|
62
58
|
isConfigurable
|
|
63
|
-
}: GetParamsProps$1) =>
|
|
59
|
+
}: GetParamsProps$1) => FunctionParams;
|
|
64
60
|
}
|
|
65
61
|
//#endregion
|
|
66
62
|
//#region src/components/Operations.d.ts
|
|
@@ -71,7 +67,7 @@ type OperationsProps = {
|
|
|
71
67
|
declare function Operations({
|
|
72
68
|
name,
|
|
73
69
|
operations
|
|
74
|
-
}: OperationsProps):
|
|
70
|
+
}: OperationsProps): KubbNode;
|
|
75
71
|
//#endregion
|
|
76
72
|
//#region src/components/Url.d.ts
|
|
77
73
|
type Props = {
|
|
@@ -104,14 +100,14 @@ declare function Url({
|
|
|
104
100
|
paramsCasing,
|
|
105
101
|
pathParamsType,
|
|
106
102
|
operation
|
|
107
|
-
}: Props):
|
|
103
|
+
}: Props): KubbNode;
|
|
108
104
|
declare namespace Url {
|
|
109
105
|
var getParams: ({
|
|
110
106
|
paramsType,
|
|
111
107
|
paramsCasing,
|
|
112
108
|
pathParamsType,
|
|
113
109
|
typeSchemas
|
|
114
|
-
}: GetParamsProps) =>
|
|
110
|
+
}: GetParamsProps) => FunctionParams;
|
|
115
111
|
}
|
|
116
112
|
//#endregion
|
|
117
113
|
export { Client, Operations, Url };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PluginClient, o as Operation, r as OperationSchemas } from "./types-DJmtgGu4.js";
|
|
2
|
+
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
2
4
|
|
|
3
|
-
//#region ../react/src/index.d.ts
|
|
4
|
-
|
|
5
|
-
import * as import___kubb_react_fabric from "@kubb/react-fabric";
|
|
6
|
-
import * as import___kubb_react_fabric_parsers from "@kubb/react-fabric/parsers";
|
|
7
|
-
import * as import___kubb_react_fabric_plugins from "@kubb/react-fabric/plugins";
|
|
8
|
-
//#endregion
|
|
9
5
|
//#region src/components/Client.d.ts
|
|
10
6
|
type Props$1 = {
|
|
11
7
|
/**
|
|
@@ -26,7 +22,7 @@ type Props$1 = {
|
|
|
26
22
|
typeSchemas: OperationSchemas;
|
|
27
23
|
zodSchemas: OperationSchemas | undefined;
|
|
28
24
|
operation: Operation;
|
|
29
|
-
children?:
|
|
25
|
+
children?: KubbNode;
|
|
30
26
|
};
|
|
31
27
|
type GetParamsProps$1 = {
|
|
32
28
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -52,7 +48,7 @@ declare function Client({
|
|
|
52
48
|
urlName,
|
|
53
49
|
children,
|
|
54
50
|
isConfigurable
|
|
55
|
-
}: Props$1):
|
|
51
|
+
}: Props$1): KubbNode;
|
|
56
52
|
declare namespace Client {
|
|
57
53
|
var getParams: ({
|
|
58
54
|
paramsType,
|
|
@@ -60,7 +56,7 @@ declare namespace Client {
|
|
|
60
56
|
pathParamsType,
|
|
61
57
|
typeSchemas,
|
|
62
58
|
isConfigurable
|
|
63
|
-
}: GetParamsProps$1) =>
|
|
59
|
+
}: GetParamsProps$1) => FunctionParams;
|
|
64
60
|
}
|
|
65
61
|
//#endregion
|
|
66
62
|
//#region src/components/Operations.d.ts
|
|
@@ -71,7 +67,7 @@ type OperationsProps = {
|
|
|
71
67
|
declare function Operations({
|
|
72
68
|
name,
|
|
73
69
|
operations
|
|
74
|
-
}: OperationsProps):
|
|
70
|
+
}: OperationsProps): KubbNode;
|
|
75
71
|
//#endregion
|
|
76
72
|
//#region src/components/Url.d.ts
|
|
77
73
|
type Props = {
|
|
@@ -104,14 +100,14 @@ declare function Url({
|
|
|
104
100
|
paramsCasing,
|
|
105
101
|
pathParamsType,
|
|
106
102
|
operation
|
|
107
|
-
}: Props):
|
|
103
|
+
}: Props): KubbNode;
|
|
108
104
|
declare namespace Url {
|
|
109
105
|
var getParams: ({
|
|
110
106
|
paramsType,
|
|
111
107
|
paramsCasing,
|
|
112
108
|
pathParamsType,
|
|
113
109
|
typeSchemas
|
|
114
|
-
}: GetParamsProps) =>
|
|
110
|
+
}: GetParamsProps) => FunctionParams;
|
|
115
111
|
}
|
|
116
112
|
//#endregion
|
|
117
113
|
export { Client, Operations, Url };
|
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Client, r as Url, t as Operations } from "./Operations-
|
|
1
|
+
import { n as Client, r as Url, t as Operations } from "./Operations-CmHRmAdn.js";
|
|
2
2
|
import { camelCase } from "@kubb/core/transformers";
|
|
3
3
|
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
4
4
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
@@ -6,8 +6,8 @@ import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
|
6
6
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
7
7
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
8
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
9
|
-
import { File, Function } from "@kubb/react";
|
|
10
|
-
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
9
|
+
import { File, Function } from "@kubb/react-fabric";
|
|
10
|
+
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/generators/clientGenerator.tsx
|
|
13
13
|
const clientGenerator = createReactGenerator({
|
|
@@ -216,4 +216,4 @@ const groupedClientGenerator = createReactGenerator({
|
|
|
216
216
|
|
|
217
217
|
//#endregion
|
|
218
218
|
export { operationsGenerator as n, clientGenerator as r, groupedClientGenerator as t };
|
|
219
|
-
//# sourceMappingURL=generators-
|
|
219
|
+
//# sourceMappingURL=generators-0Sc5zPfx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-0Sc5zPfx.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { 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 } from '@kubb/react-fabric'\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 pluginManager = usePluginManager()\n const {\n options: { output, urlType },\n } = usePlugin<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 { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\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 key: pluginKey,\n options: { output },\n } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\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 { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 } from '@kubb/react-fabric'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const { options, key: pluginKey } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\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"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB,qBAAmC;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,aAAa;EAChC,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,EACJ,SAAS,EAAE,QAAQ,cACjB,WAAyB;EAC7B,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;IAAO,CAAC;GAC5E,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;GACxD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,cAAc;IAAE,MAAM;IAAY,CAAC;GACjF;AAED,SACE,qBAAC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;;IAElC,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;MAAc;IACxD,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB,sBAAsB;KAAE,MAAM,QAAQ;KAAY;MAAa;IACnG,QAAQ,WAAW,SAClB,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