@kubb/plugin-client 3.16.3 → 3.17.0
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-tGJwS9Oj.js → Operations-C07cjD4Z.js} +12 -4
- package/dist/Operations-C07cjD4Z.js.map +1 -0
- package/dist/{Operations-Cxn7C-GC.cjs → Operations-CAVXlump.cjs} +12 -4
- package/dist/Operations-CAVXlump.cjs.map +1 -0
- package/dist/clients/axios.cjs +1 -2
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.js +1 -2
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +1 -2
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.js +1 -2
- package/dist/clients/fetch.js.map +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-BQnLTqYl.js → generators-BbQ8PU0C.js} +2 -2
- package/dist/{generators-BQnLTqYl.js.map → generators-BbQ8PU0C.js.map} +1 -1
- package/dist/{generators-XXsaqEtA.cjs → generators-F4RvOVY5.cjs} +2 -2
- package/dist/{generators-XXsaqEtA.cjs.map → generators-F4RvOVY5.cjs.map} +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/components/Client.tsx +3 -3
- package/src/components/Url.tsx +11 -3
- package/src/generators/__snapshots__/deletePet.ts +6 -2
- package/src/generators/__snapshots__/deletePetObject.ts +6 -2
- package/src/generators/__snapshots__/findByTags.ts +6 -2
- package/src/generators/__snapshots__/findByTagsFull.ts +6 -2
- package/src/generators/__snapshots__/findByTagsObject.ts +6 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +6 -2
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +6 -2
- package/src/generators/__snapshots__/importPath.ts +6 -2
- package/src/generators/__snapshots__/updatePetById.ts +6 -2
- package/src/generators/__snapshots__/updatePetByIdClean.ts +6 -2
- package/dist/Operations-Cxn7C-GC.cjs.map +0 -1
- package/dist/Operations-tGJwS9Oj.js.map +0 -1
|
@@ -34,11 +34,19 @@ function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseU
|
|
|
34
34
|
name,
|
|
35
35
|
isExportable,
|
|
36
36
|
isIndexable,
|
|
37
|
-
children: /* @__PURE__ */
|
|
37
|
+
children: /* @__PURE__ */ jsxs(Function, {
|
|
38
38
|
name,
|
|
39
39
|
export: isExportable,
|
|
40
40
|
params: params.toConstructor(),
|
|
41
|
-
children:
|
|
41
|
+
children: [/* @__PURE__ */ jsx(Const, {
|
|
42
|
+
name: "res",
|
|
43
|
+
children: `
|
|
44
|
+
{
|
|
45
|
+
method: '${operation.method.toUpperCase()}',
|
|
46
|
+
url: ${path.toTemplateString({ prefix: baseURL })} as const
|
|
47
|
+
}
|
|
48
|
+
`
|
|
49
|
+
}), "return res"]
|
|
42
50
|
})
|
|
43
51
|
});
|
|
44
52
|
}
|
|
@@ -129,7 +137,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
129
137
|
mode: "object",
|
|
130
138
|
children: {
|
|
131
139
|
method: { value: JSON.stringify(operation.method.toUpperCase()) },
|
|
132
|
-
url: { value: urlName ? `${urlName}(${urlParams.toCall()}).toString()` : path.template },
|
|
140
|
+
url: { value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template },
|
|
133
141
|
baseURL: baseURL && !urlName ? { value: JSON.stringify(baseURL) } : void 0,
|
|
134
142
|
params: typeSchemas.queryParams?.name ? {} : void 0,
|
|
135
143
|
data: typeSchemas.request?.name ? { value: isFormData ? "formData" : "requestData" } : void 0,
|
|
@@ -207,4 +215,4 @@ function Operations({ name, operations }) {
|
|
|
207
215
|
|
|
208
216
|
//#endregion
|
|
209
217
|
export { Client, Operations, Url };
|
|
210
|
-
//# sourceMappingURL=Operations-
|
|
218
|
+
//# sourceMappingURL=Operations-C07cjD4Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operations-C07cjD4Z.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'\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({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\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'}>\n {`\n {\n method: '${operation.method.toUpperCase()}',\n url: ${path.toTemplateString({ prefix: baseURL })} as const\n }\n `}\n </Const>\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'\nimport type { KubbNode } from '@kubb/react/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) {\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' ? `'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 }\n })\n }\n `\n : ''\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 {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 { 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"],"mappings":";;;;;;;AA+BA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,aAA6B,EAAE;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,GAAG,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,GAC/E;EACF,EACF;AAGH,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,UAAU,cAAc,YAAY,YAAY;GAAE,O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CAChE,MAAMC,mBAAyE,EAAE;AAEjF,YAAW,SAAS,cAAc;AAChC,mBAAiB,UAAU,oBAAoB;GAC7C,MAAM,IAAI,QAAQ,UAAU,MAAM;GAClC,QAAQ,UAAU;GACnB;CACF;AAED,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW;;;AAIpD"}
|
|
@@ -35,11 +35,19 @@ function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseU
|
|
|
35
35
|
name,
|
|
36
36
|
isExportable,
|
|
37
37
|
isIndexable,
|
|
38
|
-
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.
|
|
38
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.Function, {
|
|
39
39
|
name,
|
|
40
40
|
export: isExportable,
|
|
41
41
|
params: params.toConstructor(),
|
|
42
|
-
children:
|
|
42
|
+
children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Const, {
|
|
43
|
+
name: "res",
|
|
44
|
+
children: `
|
|
45
|
+
{
|
|
46
|
+
method: '${operation.method.toUpperCase()}',
|
|
47
|
+
url: ${path.toTemplateString({ prefix: baseURL })} as const
|
|
48
|
+
}
|
|
49
|
+
`
|
|
50
|
+
}), "return res"]
|
|
43
51
|
})
|
|
44
52
|
});
|
|
45
53
|
}
|
|
@@ -130,7 +138,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
130
138
|
mode: "object",
|
|
131
139
|
children: {
|
|
132
140
|
method: { value: JSON.stringify(operation.method.toUpperCase()) },
|
|
133
|
-
url: { value: urlName ? `${urlName}(${urlParams.toCall()}).toString()` : path.template },
|
|
141
|
+
url: { value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template },
|
|
134
142
|
baseURL: baseURL && !urlName ? { value: JSON.stringify(baseURL) } : void 0,
|
|
135
143
|
params: typeSchemas.queryParams?.name ? {} : void 0,
|
|
136
144
|
data: typeSchemas.request?.name ? { value: isFormData ? "formData" : "requestData" } : void 0,
|
|
@@ -225,4 +233,4 @@ Object.defineProperty(exports, 'Url', {
|
|
|
225
233
|
return Url;
|
|
226
234
|
}
|
|
227
235
|
});
|
|
228
|
-
//# sourceMappingURL=Operations-
|
|
236
|
+
//# sourceMappingURL=Operations-CAVXlump.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operations-CAVXlump.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'\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({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\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'}>\n {`\n {\n method: '${operation.method.toUpperCase()}',\n url: ${path.toTemplateString({ prefix: baseURL })} as const\n }\n `}\n </Const>\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'\nimport type { KubbNode } from '@kubb/react/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) {\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' ? `'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 }\n })\n }\n `\n : ''\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 {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 { 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"],"mappings":";;;;;;;;AA+BA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,aAA6B,EAAE;AAC5F,KAAI,eAAe,S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,SAAS,QAAQ;IACtD,kDAAC;IACA;IACA,iBACG,6BAA6B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS,KAC3E,2BAA2B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS;IAC7E,kDAAC;IACA;;;;AAIR;AAED,OAAO,YAAY;;;;ACxOnB,SAAgB,WAAW,EAAE,MAAM,YAA6B,EAAE;CAChE,MAAMC,mBAAyE,EAAE;AAEjF,YAAW,SAAS,cAAc;AAChC,mBAAiB,UAAU,oBAAoB;GAC7C,MAAM,IAAIC,0BAAQ,UAAU,MAAM;GAClC,QAAQ,UAAU;GACnB;CACF;AAED,QACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW;;;AAIpD"}
|
package/dist/clients/axios.cjs
CHANGED
|
@@ -28,12 +28,11 @@ const client = async (config) => {
|
|
|
28
28
|
};
|
|
29
29
|
client.getConfig = getConfig;
|
|
30
30
|
client.setConfig = setConfig;
|
|
31
|
-
var axios_default = client;
|
|
32
31
|
|
|
33
32
|
//#endregion
|
|
34
33
|
exports.axiosInstance = axiosInstance;
|
|
35
34
|
exports.client = client;
|
|
36
|
-
exports.default =
|
|
35
|
+
exports.default = client;
|
|
37
36
|
exports.getConfig = getConfig;
|
|
38
37
|
exports.setConfig = setConfig;
|
|
39
38
|
//# sourceMappingURL=axios.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.cjs","names":["_config: Partial<RequestConfig>"
|
|
1
|
+
{"version":3,"file":"axios.cjs","names":["_config: Partial<RequestConfig>"],"sources":["../../src/clients/axios.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' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n validateStatus?: (status: number) => boolean\n headers?: AxiosRequestConfig['headers']\n}\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 type ResponseErrorConfig<TError = unknown> = AxiosError<TError>\n\nlet _config: Partial<RequestConfig> = {\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 getConfig = () => _config\n\nexport const setConfig = (config: RequestConfig) => {\n _config = config\n return getConfig()\n}\n\nexport const axiosInstance = axios.create(getConfig())\n\nexport const client = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const globalConfig = getConfig()\n\n return axiosInstance\n .request<TData, ResponseConfig<TData>>({\n ...globalConfig,\n ...config,\n headers: {\n ...globalConfig.headers,\n ...config.headers,\n },\n })\n .catch((e: AxiosError<TError>) => {\n throw e\n })\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";;;;;AAkCA,IAAIA,UAAkC;CACpC,SAAS,OAAO,eAAe,cAAc,aAAa;CAC1D,SAAS,OAAO,kBAAkB,cAAe,KAAK,MAAM,iBAAkC;CAC/F;AAED,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO;AACR;AAED,MAAa,gBAAgB,cAAM,OAAO;AAE1C,MAAa,SAAS,OAAsD,WAAsE;CAChJ,MAAM,eAAe;AAErB,QAAO,cACJ,QAAsC;EACrC,GAAG;EACH,GAAG;EACH,SAAS;GACP,GAAG,aAAa;GAChB,GAAG,OAAO;GACX;EACF,EACA,OAAO,MAA0B;AAChC,QAAM;CACP;AACJ;AAED,OAAO,YAAY;AACnB,OAAO,YAAY"}
|
package/dist/clients/axios.js
CHANGED
|
@@ -26,8 +26,7 @@ const client = async (config) => {
|
|
|
26
26
|
};
|
|
27
27
|
client.getConfig = getConfig;
|
|
28
28
|
client.setConfig = setConfig;
|
|
29
|
-
var axios_default = client;
|
|
30
29
|
|
|
31
30
|
//#endregion
|
|
32
|
-
export { axiosInstance, client,
|
|
31
|
+
export { axiosInstance, client, client as default, getConfig, setConfig };
|
|
33
32
|
//# sourceMappingURL=axios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","names":["_config: Partial<RequestConfig>"
|
|
1
|
+
{"version":3,"file":"axios.js","names":["_config: Partial<RequestConfig>"],"sources":["../../src/clients/axios.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' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n validateStatus?: (status: number) => boolean\n headers?: AxiosRequestConfig['headers']\n}\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 type ResponseErrorConfig<TError = unknown> = AxiosError<TError>\n\nlet _config: Partial<RequestConfig> = {\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 getConfig = () => _config\n\nexport const setConfig = (config: RequestConfig) => {\n _config = config\n return getConfig()\n}\n\nexport const axiosInstance = axios.create(getConfig())\n\nexport const client = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const globalConfig = getConfig()\n\n return axiosInstance\n .request<TData, ResponseConfig<TData>>({\n ...globalConfig,\n ...config,\n headers: {\n ...globalConfig.headers,\n ...config.headers,\n },\n })\n .catch((e: AxiosError<TError>) => {\n throw e\n })\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";;;AAkCA,IAAIA,UAAkC;CACpC,SAAS,OAAO,eAAe,cAAc,aAAa;CAC1D,SAAS,OAAO,kBAAkB,cAAe,KAAK,MAAM,iBAAkC;CAC/F;AAED,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO;AACR;AAED,MAAa,gBAAgB,MAAM,OAAO;AAE1C,MAAa,SAAS,OAAsD,WAAsE;CAChJ,MAAM,eAAe;AAErB,QAAO,cACJ,QAAsC;EACrC,GAAG;EACH,GAAG;EACH,SAAS;GACP,GAAG,aAAa;GAChB,GAAG,OAAO;GACX;EACF,EACA,OAAO,MAA0B;AAChC,QAAM;CACP;AACJ;AAED,OAAO,YAAY;AACnB,OAAO,YAAY"}
|
package/dist/clients/fetch.cjs
CHANGED
|
@@ -40,11 +40,10 @@ const client = async (paramsConfig) => {
|
|
|
40
40
|
};
|
|
41
41
|
client.getConfig = getConfig;
|
|
42
42
|
client.setConfig = setConfig;
|
|
43
|
-
var fetch_default = client;
|
|
44
43
|
|
|
45
44
|
//#endregion
|
|
46
45
|
exports.client = client;
|
|
47
|
-
exports.default =
|
|
46
|
+
exports.default = client;
|
|
48
47
|
exports.getConfig = getConfig;
|
|
49
48
|
exports.setConfig = setConfig;
|
|
50
49
|
//# sourceMappingURL=fetch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.cjs","names":["_config: Partial<RequestConfig>"
|
|
1
|
+
{"version":3,"file":"fetch.cjs","names":["_config: Partial<RequestConfig>"],"sources":["../../src/clients/fetch.ts"],"sourcesContent":["/**\n * RequestCredentials\n */\nexport type RequestCredentials = 'omit' | 'same-origin' | 'include'\n\n/**\n * Subset of FetchRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: [string, string][] | Record<string, string>\n credentials?: RequestCredentials\n}\n\n/**\n * Subset of FetchResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: Headers\n}\n\nlet _config: Partial<RequestConfig> = {}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: Partial<RequestConfig>) => {\n _config = config\n return getConfig()\n}\n\nexport type ResponseErrorConfig<TError = unknown> = TError\n\nexport const client = async <TData, _TError = unknown, TVariables = unknown>(paramsConfig: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const normalizedParams = new URLSearchParams()\n\n const globalConfig = getConfig()\n const config = { ...globalConfig, ...paramsConfig }\n\n Object.entries(config.params || {}).forEach(([key, value]) => {\n if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : value.toString())\n }\n })\n\n let targetUrl = [config.baseURL, config.url].filter(Boolean).join('')\n\n if (config.params) {\n targetUrl += `?${normalizedParams}`\n }\n\n const response = await fetch(targetUrl, {\n credentials: config.credentials || 'same-origin',\n method: config.method?.toUpperCase(),\n body: JSON.stringify(config.data),\n signal: config.signal,\n headers: config.headers,\n })\n\n const data = [204, 205, 304].includes(response.status) || !response.body ? {} : await response.json()\n\n return {\n data: data as TData,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Headers,\n }\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";;;AA8BA,IAAIA,UAAkC,EAAE;AAExC,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAAmC;AAC3D,WAAU;AACV,QAAO;AACR;AAID,MAAa,SAAS,OAAuD,iBAA4E;CACvJ,MAAM,mBAAmB,IAAI;CAE7B,MAAM,eAAe;CACrB,MAAM,SAAS;EAAE,GAAG;EAAc,GAAG;EAAc;AAEnD,QAAO,QAAQ,OAAO,UAAU,EAAE,EAAE,SAAS,CAAC,KAAK,MAAM,KAAK;AAC5D,MAAI,UAAU,OACZ,kBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,MAAM;CAEhE;CAED,IAAI,YAAY,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAAO,SAAS,KAAK;AAElE,KAAI,OAAO,OACT,cAAa,IAAI;CAGnB,MAAM,WAAW,MAAM,MAAM,WAAW;EACtC,aAAa,OAAO,eAAe;EACnC,QAAQ,OAAO,QAAQ;EACvB,MAAM,KAAK,UAAU,OAAO;EAC5B,QAAQ,OAAO;EACf,SAAS,OAAO;EACjB;CAED,MAAM,OAAO;EAAC;EAAK;EAAK;EAAI,CAAC,SAAS,SAAS,WAAW,CAAC,SAAS,OAAO,EAAE,GAAG,MAAM,SAAS;AAE/F,QAAO;EACC;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,SAAS,SAAS;EACnB;AACF;AAED,OAAO,YAAY;AACnB,OAAO,YAAY"}
|
package/dist/clients/fetch.js
CHANGED
|
@@ -38,8 +38,7 @@ const client = async (paramsConfig) => {
|
|
|
38
38
|
};
|
|
39
39
|
client.getConfig = getConfig;
|
|
40
40
|
client.setConfig = setConfig;
|
|
41
|
-
var fetch_default = client;
|
|
42
41
|
|
|
43
42
|
//#endregion
|
|
44
|
-
export { client,
|
|
43
|
+
export { client, client as default, getConfig, setConfig };
|
|
45
44
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","names":["_config: Partial<RequestConfig>"
|
|
1
|
+
{"version":3,"file":"fetch.js","names":["_config: Partial<RequestConfig>"],"sources":["../../src/clients/fetch.ts"],"sourcesContent":["/**\n * RequestCredentials\n */\nexport type RequestCredentials = 'omit' | 'same-origin' | 'include'\n\n/**\n * Subset of FetchRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: [string, string][] | Record<string, string>\n credentials?: RequestCredentials\n}\n\n/**\n * Subset of FetchResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: Headers\n}\n\nlet _config: Partial<RequestConfig> = {}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: Partial<RequestConfig>) => {\n _config = config\n return getConfig()\n}\n\nexport type ResponseErrorConfig<TError = unknown> = TError\n\nexport const client = async <TData, _TError = unknown, TVariables = unknown>(paramsConfig: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const normalizedParams = new URLSearchParams()\n\n const globalConfig = getConfig()\n const config = { ...globalConfig, ...paramsConfig }\n\n Object.entries(config.params || {}).forEach(([key, value]) => {\n if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : value.toString())\n }\n })\n\n let targetUrl = [config.baseURL, config.url].filter(Boolean).join('')\n\n if (config.params) {\n targetUrl += `?${normalizedParams}`\n }\n\n const response = await fetch(targetUrl, {\n credentials: config.credentials || 'same-origin',\n method: config.method?.toUpperCase(),\n body: JSON.stringify(config.data),\n signal: config.signal,\n headers: config.headers,\n })\n\n const data = [204, 205, 304].includes(response.status) || !response.body ? {} : await response.json()\n\n return {\n data: data as TData,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Headers,\n }\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";AA8BA,IAAIA,UAAkC,EAAE;AAExC,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAAmC;AAC3D,WAAU;AACV,QAAO;AACR;AAID,MAAa,SAAS,OAAuD,iBAA4E;CACvJ,MAAM,mBAAmB,IAAI;CAE7B,MAAM,eAAe;CACrB,MAAM,SAAS;EAAE,GAAG;EAAc,GAAG;EAAc;AAEnD,QAAO,QAAQ,OAAO,UAAU,EAAE,EAAE,SAAS,CAAC,KAAK,MAAM,KAAK;AAC5D,MAAI,UAAU,OACZ,kBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,MAAM;CAEhE;CAED,IAAI,YAAY,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAAO,SAAS,KAAK;AAElE,KAAI,OAAO,OACT,cAAa,IAAI;CAGnB,MAAM,WAAW,MAAM,MAAM,WAAW;EACtC,aAAa,OAAO,eAAe;EACnC,QAAQ,OAAO,QAAQ;EACvB,MAAM,KAAK,UAAU,OAAO;EAC5B,QAAQ,OAAO;EACf,SAAS,OAAO;EACjB;CAED,MAAM,OAAO;EAAC;EAAK;EAAK;EAAI,CAAC,SAAS,SAAS,WAAW,CAAC,SAAS,OAAO,EAAE,GAAG,MAAM,SAAS;AAE/F,QAAO;EACC;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,SAAS,SAAS;EACnB;AACF;AAED,OAAO,YAAY;AACnB,OAAO,YAAY"}
|
package/dist/components.cjs
CHANGED
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, Operations, Url } from "./Operations-
|
|
1
|
+
import { Client, Operations, Url } from "./Operations-C07cjD4Z.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";
|
|
@@ -213,4 +213,4 @@ const groupedClientGenerator = createReactGenerator({
|
|
|
213
213
|
|
|
214
214
|
//#endregion
|
|
215
215
|
export { clientGenerator, groupedClientGenerator, operationsGenerator };
|
|
216
|
-
//# sourceMappingURL=generators-
|
|
216
|
+
//# sourceMappingURL=generators-BbQ8PU0C.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-BQnLTqYl.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,kBAAkB,qBAAmC;CAChE,MAA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AAM,OAAO,KAAK;OAArE,OAAO,KAAsE,CAC/F,sBAED,KAAK;KAAa;KAAM;KAAa;mCACnC;MAAS;MAAa;gBACpB,CAAC,SAAS,EAAE,QAAQ,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;OACvD;MACC;MAfT,KAAK,KAgBL;EAEV,EAAC;CACH;AACF,EAAC"}
|
|
1
|
+
{"version":3,"file":"generators-BbQ8PU0C.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,kBAAkB,qBAAmC;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,WA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operations = require('./Operations-
|
|
2
|
+
const require_Operations = require('./Operations-CAVXlump.cjs');
|
|
3
3
|
const __kubb_core_transformers = require_chunk.__toESM(require("@kubb/core/transformers"));
|
|
4
4
|
const __kubb_plugin_oas = require_chunk.__toESM(require("@kubb/plugin-oas"));
|
|
5
5
|
const __kubb_plugin_zod = require_chunk.__toESM(require("@kubb/plugin-zod"));
|
|
@@ -231,4 +231,4 @@ Object.defineProperty(exports, 'operationsGenerator', {
|
|
|
231
231
|
return operationsGenerator;
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
|
-
//# sourceMappingURL=generators-
|
|
234
|
+
//# sourceMappingURL=generators-F4RvOVY5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-XXsaqEtA.cjs","names":["pluginTsName","pluginZodName","File","Url","Client","File","Operations","File","Function"],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,8DAAqD;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,EAC7B,EACD,eACD,6BAAyB;EAC1B,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,SAAS,qDAAwB;EAE9D,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,WAAY,EAAC;GAC9C,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;GAAO,EAAC;GAC5E,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,6BAAa,EAAE,EAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,6BAAa;IAAE,MAAM;GAAQ,EAAC;EAC5E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACC,+BAAc,EAAE,EAAC;GACxD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,+BAAc;IAAE,MAAM;GAAY,EAAC;EACjF;AAED,4DACGC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;GAAQ,EAAC;GAChE,+CAAkB;IAAE;IAAK;GAAQ,EAAC;;sDAEjCA,kBAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;MAAc;sDACvDA,kBAAK;KAAO,MAAM,CAAC,iBAAiB,qBAAsB;KAAE,MAAM,QAAQ;KAA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AK,QAAQ,QAAQ;IAAQ,EAAC;eAEjD,QAAQ,IAAI,CAAC,6DACXA,kBAAK;KAAyB,MAAM,CAAC,OAAO,IAAK;KAAE,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,KAAsE,CAC/F,oDAEDA,kBAAK;KAAa;KAAM;KAAa;iEACnCC;MAAS;MAAa;gBACpB,CAAC,SAAS,EAAE,QAAQ,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;OACvD;MACC;MAfT,KAAK,KAgBL;EAEV,EAAC;CACH;AACF,EAAC"}
|
|
1
|
+
{"version":3,"file":"generators-F4RvOVY5.cjs","names":["pluginTsName","pluginZodName","File","Url","Client","File","Operations","File","Function"],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output, urlType },\n },\n pluginManager,\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginClient>()\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/core/fs'\n\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options, key: pluginKey },\n } = useApp<PluginClient>()\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,8DAAqD;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,EAC7B,EACD,eACD;EACD,MAAM;EACN,MAAM,EAAE,YAAY,SAAS,SAAS;EAEtC,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY;GAC7C,MAAM,QAAQ;GACf;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;IAAO;GAC3E,MAAM,QAAQ;GACf;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,8BAAa,EAAE;GACtD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ;GAC3E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACC,gCAAc,EAAE;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,gCAAc;IAAE,MAAM;IAAY;GAChF;AAED,SACE,mDAACC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ;GAC/D,+CAAkB;IAAE;IAAK;IAAQ;;IAEjC,kDAACA,kBAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;;IAC1C,kDAACA,kBAAK;KAAO,MAAM,CAAC,iBAAiB,sBAAsB;KAAE,MAAM,QAAQ;KAAY;;IACtF,QAAQ,WAAW,SAClB,kDAACA,kBAAK;KAAO,MAAM,CAAC,IAAI,QAAQ,SAAS,MAAM,IAAI,QAAQ,SAAS,KAAK,CAAC,OAAO;KAAU,MAAM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js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require('./Operations-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./Operations-CAVXlump.cjs');
|
|
2
|
+
const require_generators = require('./generators-F4RvOVY5.cjs');
|
|
3
3
|
|
|
4
4
|
exports.clientGenerator = require_generators.clientGenerator;
|
|
5
5
|
exports.groupedClientGenerator = require_generators.groupedClientGenerator;
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./Operations-
|
|
2
|
-
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-
|
|
1
|
+
import "./Operations-C07cjD4Z.js";
|
|
2
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-BbQ8PU0C.js";
|
|
3
3
|
|
|
4
4
|
export { clientGenerator, groupedClientGenerator, operationsGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
require('./Operations-
|
|
3
|
-
const require_generators = require('./generators-
|
|
2
|
+
require('./Operations-CAVXlump.cjs');
|
|
3
|
+
const require_generators = require('./generators-F4RvOVY5.cjs');
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const __kubb_core = require_chunk.__toESM(require("@kubb/core"));
|
|
6
6
|
const __kubb_core_transformers = require_chunk.__toESM(require("@kubb/core/transformers"));
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\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', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAcA,MAAa,mBAAmB;AAEhC,MAAa,8CAA2C,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAACA;EAAiB,QAAQC,4CAAyB;EAAW,aAAaC,yCAAsB;EAAU,CAAC,OAAO,UAChI,SAAS,UACT,SAAS,SACT,aAAa,WA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MAAM,cAAc,QAAQ;GAE5C,MAAM,qBAAqB,IAAIC,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD;GAGH,MAAM,QAAQ,MAAM,mBAAmB,MAAM,GAAG;AAEhD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd;AAED,SAAM,KAAK,QAAQ,GAAG;EACvB;EACF;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./Operations-
|
|
2
|
-
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-
|
|
1
|
+
import "./Operations-C07cjD4Z.js";
|
|
2
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-BbQ8PU0C.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\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', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAcA,MAAa,mBAAmB;AAEhC,MAAa,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\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', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAcA,MAAa,mBAAmB;AAEhC,MAAa,eAAe,cAA4B,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAAC;EAAiB,QAAQ,yBAAyB;EAAW,aAAa,sBAAsB;EAAU,CAAC,OAAO,UAChI,SAAS,UACT,SAAS,SACT,aAAa,WAAW,UAAU,sCAAsC,qCACxE,aACD,GAAG;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,WAAW,QAAQ,gBAAgB,OAAU,CAAC,OAAO;EAC1E,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAO,YAAY,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO;AAEvE,OAAI,SAAS;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO;AAGnC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,M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
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -77,18 +77,18 @@
|
|
|
77
77
|
"!/**/__tests__/**"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@kubb/core": "3.
|
|
81
|
-
"@kubb/oas": "3.
|
|
82
|
-
"@kubb/plugin-oas": "3.
|
|
83
|
-
"@kubb/plugin-ts": "3.
|
|
84
|
-
"@kubb/plugin-zod": "3.
|
|
85
|
-
"@kubb/react": "3.
|
|
80
|
+
"@kubb/core": "3.17.0",
|
|
81
|
+
"@kubb/oas": "3.17.0",
|
|
82
|
+
"@kubb/plugin-oas": "3.17.0",
|
|
83
|
+
"@kubb/plugin-ts": "3.17.0",
|
|
84
|
+
"@kubb/plugin-zod": "3.17.0",
|
|
85
|
+
"@kubb/react": "3.17.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"axios": "^1.11.0",
|
|
89
89
|
"tsdown": "^0.14.1",
|
|
90
90
|
"typescript": "^5.9.2",
|
|
91
|
-
"@kubb/config-ts": "3.
|
|
91
|
+
"@kubb/config-ts": "3.17.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@kubb/react": "^3.0.0",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { URLPath } from '@kubb/core/utils'
|
|
2
2
|
|
|
3
|
-
import { type Operation
|
|
3
|
+
import { isOptional, type Operation } from '@kubb/oas'
|
|
4
4
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
5
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
6
6
|
import { File, Function, FunctionParams } from '@kubb/react'
|
|
7
|
+
import type { KubbNode } from '@kubb/react/types'
|
|
7
8
|
import type { PluginClient } from '../types.ts'
|
|
8
9
|
import { Url } from './Url.tsx'
|
|
9
|
-
import type { KubbNode } from '@kubb/react/types'
|
|
10
10
|
|
|
11
11
|
type Props = {
|
|
12
12
|
/**
|
|
@@ -158,7 +158,7 @@ export function Client({
|
|
|
158
158
|
value: JSON.stringify(operation.method.toUpperCase()),
|
|
159
159
|
},
|
|
160
160
|
url: {
|
|
161
|
-
value: urlName ? `${urlName}(${urlParams.toCall()}).toString()` : path.template,
|
|
161
|
+
value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,
|
|
162
162
|
},
|
|
163
163
|
baseURL:
|
|
164
164
|
baseURL && !urlName
|
package/src/components/Url.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { URLPath } from '@kubb/core/utils'
|
|
2
2
|
|
|
3
|
-
import { type Operation
|
|
3
|
+
import { isOptional, type Operation } from '@kubb/oas'
|
|
4
4
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
5
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
6
|
-
import { File, Function, FunctionParams } from '@kubb/react'
|
|
6
|
+
import { Const, File, Function, FunctionParams } from '@kubb/react'
|
|
7
7
|
import type { PluginClient } from '../types.ts'
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
@@ -59,7 +59,15 @@ export function Url({ name, isExportable = true, isIndexable = true, typeSchemas
|
|
|
59
59
|
return (
|
|
60
60
|
<File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>
|
|
61
61
|
<Function name={name} export={isExportable} params={params.toConstructor()}>
|
|
62
|
-
|
|
62
|
+
<Const name={'res'}>
|
|
63
|
+
{`
|
|
64
|
+
{
|
|
65
|
+
method: '${operation.method.toUpperCase()}',
|
|
66
|
+
url: ${path.toTemplateString({ prefix: baseURL })} as const
|
|
67
|
+
}
|
|
68
|
+
`}
|
|
69
|
+
</Const>
|
|
70
|
+
return res
|
|
63
71
|
</Function>
|
|
64
72
|
</File.Source>
|
|
65
73
|
)
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getDeletePetUrl(petId: DeletePetPathParams['petId']) {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'DELETE',
|
|
12
|
+
url: `/pet/${petId}` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -24,7 +28,7 @@ export async function deletePet(
|
|
|
24
28
|
|
|
25
29
|
const res = await request<DeletePetMutationResponse, ResponseErrorConfig<DeletePet400>, unknown>({
|
|
26
30
|
method: 'DELETE',
|
|
27
|
-
url: getDeletePetUrl(petId).toString(),
|
|
31
|
+
url: getDeletePetUrl(petId).url.toString(),
|
|
28
32
|
...requestConfig,
|
|
29
33
|
headers: { ...headers, ...requestConfig.headers },
|
|
30
34
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getDeletePetUrl({ petId }: { petId: DeletePetPathParams['petId'] }) {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'DELETE',
|
|
12
|
+
url: `/pet/${petId}` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -24,7 +28,7 @@ export async function deletePet(
|
|
|
24
28
|
|
|
25
29
|
const res = await request<DeletePetMutationResponse, ResponseErrorConfig<DeletePet400>, unknown>({
|
|
26
30
|
method: 'DELETE',
|
|
27
|
-
url: getDeletePetUrl({ petId }).toString(),
|
|
31
|
+
url: getDeletePetUrl({ petId }).url.toString(),
|
|
28
32
|
...requestConfig,
|
|
29
33
|
headers: { ...headers, ...requestConfig.headers },
|
|
30
34
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config:
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config:
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryP
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config:
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config:
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from 'axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from 'axios'
|
|
8
8
|
|
|
9
9
|
export function getFindPetsByTagsUrl() {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/pet/findByTags` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,7 +24,7 @@ export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config:
|
|
|
20
24
|
|
|
21
25
|
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
22
26
|
method: 'GET',
|
|
23
|
-
url: getFindPetsByTagsUrl().toString(),
|
|
27
|
+
url: getFindPetsByTagsUrl().url.toString(),
|
|
24
28
|
params,
|
|
25
29
|
...requestConfig,
|
|
26
30
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
export function getUpdatePetWithFormUrl(petId: UpdatePetWithFormPathParams['petId']) {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
url: `/pet/${petId}` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -23,7 +27,7 @@ export async function updatePetWithForm(
|
|
|
23
27
|
|
|
24
28
|
const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
|
|
25
29
|
method: 'POST',
|
|
26
|
-
url: getUpdatePetWithFormUrl(petId).toString(),
|
|
30
|
+
url: getUpdatePetWithFormUrl(petId).url.toString(),
|
|
27
31
|
params,
|
|
28
32
|
...requestConfig,
|
|
29
33
|
})
|
|
@@ -7,7 +7,11 @@ import fetch from '@kubb/plugin-client/clients/axios'
|
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
8
8
|
|
|
9
9
|
function getUpdatePetWithFormUrl(petId: UpdatePetWithFormPathParams['petId']) {
|
|
10
|
-
|
|
10
|
+
const res = {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
url: `/pet/${petId}` as const,
|
|
13
|
+
}
|
|
14
|
+
return res
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -23,7 +27,7 @@ export async function updatePetWithForm(
|
|
|
23
27
|
|
|
24
28
|
const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
|
|
25
29
|
method: 'POST',
|
|
26
|
-
url: getUpdatePetWithFormUrl(petId).toString(),
|
|
30
|
+
url: getUpdatePetWithFormUrl(petId).url.toString(),
|
|
27
31
|
params,
|
|
28
32
|
...requestConfig,
|
|
29
33
|
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-Cxn7C-GC.cjs","names":["getParams","FunctionParams","URLPath","File","Function","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 { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\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 {`return ${path.toTemplateString({ prefix: baseURL })} as const`}\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","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 { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\nimport type { KubbNode } from '@kubb/react/types'\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) {\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' ? `'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()}).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 }\n })\n }\n `\n : ''\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 {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 { 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"],"mappings":";;;;;;;;AA+BA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,aAA6B,EAAE;AAC5F,KAAI,eAAe,SACjB,QAAOC,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,8CAAiB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;EAAc,EAAC,CAChF;CACF,EACF,EAAC;AAGJ,QAAOA,4BAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,qDAAwB,YAAY,YAA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AAU,CACjC;GACW;;IAEX,iBAAiB,gEAAgE;sDACjF,SAAK;sDACL,SAAK;IACL,WAAW,SAAS,YAAY,SAAS,QAAQ,CAAC,oBAAoB,EAAE,WAAW,QAAQ,KAAK,YAAY,CAAC;IAC7G,WAAW,YAAY,aAAa,SAAS,QAAQ;sDACrD,SAAK;IACL;IACA,iBACG,CAAC,0BAA0B,EAAE,SAAS,KAAK,KAAK,CAAC,EAAE,EAAE,aAAa,QAAQ,CAAC,CAAC,CAAC,GAC7E,CAAC,wBAAwB,EAAE,SAAS,KAAK,KAAK,CAAC,EAAE,EAAE,aAAa,QAAQ,CAAC,CAAC,CAAC;sDAC9E,SAAK;IACL;;IACQ;GACC;AAEjB;AAED,OAAO,YAAY;;;;ACxOnB,SAAgB,WAAW,EAAE,MAAM,YAA6B,EAAE;CAChE,MAAMC,mBAAyE,CAAE;CAEjF,WAAW,QAAQ,CAAC,cAAc;EAChC,iBAAiB,UAAU,gBAAgB,IAAI;GAC7C,MAAM,IAAIC,0BAAQ,UAAU,MAAM;GAClC,QAAQ,UAAU;EACnB;CACF,EAAC;AAEF,0DACGC,kBAAK;EAAa;EAAM;EAAa;8DACnCC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW,EAAE;IACzC;GACI;AAEjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-tGJwS9Oj.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 { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\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 {`return ${path.toTemplateString({ prefix: baseURL })} as const`}\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","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 { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\nimport type { KubbNode } from '@kubb/react/types'\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) {\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' ? `'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()}).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 }\n })\n }\n `\n : ''\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 {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 { 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"],"mappings":";;;;;;;AA+BA,SAASA,YAAU,EAAE,YAAY,cAAc,gBAAgB,aAA6B,EAAE;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,GAAG,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;EAAc,EAAC,CAChF;CACF,EACF,EAAC;AAGJ,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,UAAU,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;EAAc,EAAC;EACtF,UAAU,WAAW,YAAY,YAAY,OAAO;CACrD,IACD,OACL,EAAC;AACH;AAED,SAAgB,IAAI,EAAE,MAAM,eAAe,MAAM,cAAc,MAAM,aAAa,SAAS,YAAY,cAAc,gBAAgB,WAAkB,EAAE;CACvJ,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ,aAAc;CACjE,MAAM,SAASA,YAAU;EAAE;EAAY;EAAc;EAAgB;CAAa,EAAC;AAEnF,4BACG,KAAK;EAAa;EAAoB;EAA2B;gCAC/D;GAAe;GAAM,QAAQ;GAAc,QAAQ,OAAO,eAAe;aACvE,CAAC,OAAO,EAAE,KAAK,iBAAiB,EAAE,QAAQ,QAAS,EAAC,CAAC,SAAS,CAAC;IACvD;GACC;AAEjB;AAED,IAAI,YAAYA;;;;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