@kubb/plugin-client 3.18.2 → 3.18.3
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-jd9YVUvl.cjs → Operations-DSUkakET.cjs} +5 -4
- package/dist/{Operations-jd9YVUvl.cjs.map → Operations-DSUkakET.cjs.map} +1 -1
- package/dist/{Operations-Ca8-cnuW.js → Operations-hp89a2hq.js} +5 -4
- package/dist/{Operations-Ca8-cnuW.js.map → Operations-hp89a2hq.js.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CN7wqhQh.js → generators-BlMUAzCj.js} +2 -2
- package/dist/{generators-CN7wqhQh.js.map → generators-BlMUAzCj.js.map} +1 -1
- package/dist/{generators-BCX9TQcn.cjs → generators-Bx8g7HBJ.cjs} +2 -2
- package/dist/{generators-BCX9TQcn.cjs.map → generators-Bx8g7HBJ.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.js +2 -2
- package/package.json +8 -8
- package/src/components/Client.tsx +4 -3
|
@@ -147,7 +147,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
147
147
|
} });
|
|
148
148
|
const formData = isFormData ? `
|
|
149
149
|
const formData = new FormData()
|
|
150
|
-
if(requestData) {
|
|
150
|
+
if (requestData) {
|
|
151
151
|
Object.keys(requestData).forEach((key) => {
|
|
152
152
|
const value = requestData[key as keyof typeof requestData];
|
|
153
153
|
if (typeof value === 'string' || (value as unknown) instanceof Blob) {
|
|
@@ -155,7 +155,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
155
155
|
}
|
|
156
156
|
})
|
|
157
157
|
}
|
|
158
|
-
` :
|
|
158
|
+
` : void 0;
|
|
159
159
|
const childrenElement = children ? children : /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
|
|
160
160
|
dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
|
|
161
161
|
dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
|
|
@@ -174,13 +174,14 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
174
174
|
JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
|
|
175
175
|
returnType,
|
|
176
176
|
children: [
|
|
177
|
-
isConfigurable ? "const { client:request = fetch, ...requestConfig } = config" : "",
|
|
177
|
+
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
178
178
|
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)("br", {}),
|
|
179
179
|
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)("br", {}),
|
|
180
180
|
parser === "zod" && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`,
|
|
181
181
|
parser === "client" && typeSchemas?.request?.name && "const requestData = data",
|
|
182
182
|
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)("br", {}),
|
|
183
183
|
formData,
|
|
184
|
+
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)("br", {}),
|
|
184
185
|
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
185
186
|
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)("br", {}),
|
|
186
187
|
childrenElement
|
|
@@ -232,4 +233,4 @@ Object.defineProperty(exports, 'Url', {
|
|
|
232
233
|
return Url;
|
|
233
234
|
}
|
|
234
235
|
});
|
|
235
|
-
//# sourceMappingURL=Operations-
|
|
236
|
+
//# sourceMappingURL=Operations-DSUkakET.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-jd9YVUvl.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'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAOC,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,8CAAiB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;;AAMxE,QAAOA,4BAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,qDAAwB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;EACvE,qCAAqB,YAAY,YAAY;KAE/C;;AAIR,SAAgB,IAAI,EAAE,MAAM,eAAe,MAAM,cAAc,MAA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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'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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 : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </>\n )\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { 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,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAOC,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,8CAAiB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;;AAMxE,QAAOA,4BAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,qDAAwB,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;EACvE,qCAAqB,YAAY,YAAY;KAE/C;;AAIR,SAAgB,IAAI,EAAE,MAAM,eAAe,MAAM,cAAc,MAAM,aAAa,S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
|
} });
|
|
147
147
|
const formData = isFormData ? `
|
|
148
148
|
const formData = new FormData()
|
|
149
|
-
if(requestData) {
|
|
149
|
+
if (requestData) {
|
|
150
150
|
Object.keys(requestData).forEach((key) => {
|
|
151
151
|
const value = requestData[key as keyof typeof requestData];
|
|
152
152
|
if (typeof value === 'string' || (value as unknown) instanceof Blob) {
|
|
@@ -154,7 +154,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
154
154
|
}
|
|
155
155
|
})
|
|
156
156
|
}
|
|
157
|
-
` :
|
|
157
|
+
` : void 0;
|
|
158
158
|
const childrenElement = children ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
159
159
|
dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
|
|
160
160
|
dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
|
|
@@ -173,13 +173,14 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
173
173
|
JSDoc: { comments: getComments(operation) },
|
|
174
174
|
returnType,
|
|
175
175
|
children: [
|
|
176
|
-
isConfigurable ? "const { client:request = fetch, ...requestConfig } = config" : "",
|
|
176
|
+
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
177
177
|
/* @__PURE__ */ jsx("br", {}),
|
|
178
178
|
/* @__PURE__ */ jsx("br", {}),
|
|
179
179
|
parser === "zod" && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`,
|
|
180
180
|
parser === "client" && typeSchemas?.request?.name && "const requestData = data",
|
|
181
181
|
/* @__PURE__ */ jsx("br", {}),
|
|
182
182
|
formData,
|
|
183
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
183
184
|
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
184
185
|
/* @__PURE__ */ jsx("br", {}),
|
|
185
186
|
childrenElement
|
|
@@ -214,4 +215,4 @@ function Operations({ name, operations }) {
|
|
|
214
215
|
|
|
215
216
|
//#endregion
|
|
216
217
|
export { Client, Operations, Url };
|
|
217
|
-
//# sourceMappingURL=Operations-
|
|
218
|
+
//# sourceMappingURL=Operations-hp89a2hq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-Ca8-cnuW.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'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,GAAG,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;;AAMxE,QAA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AoB;GAC7C,MAAM,IAAI,QAAQ,UAAU,MAAM;GAClC,QAAQ,UAAU;;;AAItB,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW"}
|
|
1
|
+
{"version":3,"file":"Operations-hp89a2hq.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'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\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 : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </>\n )\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { 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,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,GAAG,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;;AAMxE,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OACh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AAU,MAAM;GAClC,QAAQ,UAAU;;;AAItB,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW"}
|
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-hp89a2hq.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-BlMUAzCj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CN7wqhQh.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,aAAa;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,aAErB,kBACE;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,YAAY,SAAS,YAAY;EAEzC,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM;GACjC,MAAM,QAAQ;;EAGhB,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;;GACpE,MAAM,QAAQ;;EAGhB,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC;IAAe,MAAM;;;EAGpE,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC;IAAgB,MAAM;;;AAGrE,SACE,qBAAC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;;GACvD,QAAQ,UAAU;IAAE;IAAK;;;IAEzB,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;;IAC1C,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB;KAAwB,MAAM,QAAQ;KAAY;;IACtF,QAAQ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3,"file":"generators-BlMUAzCj.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,aAAa;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,aAErB,kBACE;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,YAAY,SAAS,YAAY;EAEzC,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM;GACjC,MAAM,QAAQ;;EAGhB,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,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,KAAK;QAE1B,KAAI,KAAK;KAAE;KAAM;KAAM,SAAS,CAAC;;;AAIrC,UAAO;KAET;AAGF,SAAO,YAAY,KAAK,EAAE,MAAM,MAAM,cAAc;AAClD,UACE,qBAAC;IAEC,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,QAAQ,UAAU;KAAE;KAAK,QAAQ,QAAQ;KAAQ,QAAQ,cAAc;;IACvE,QAAQ,UAAU;KAAE;KAAK,QAAQ,QAAQ;;eAExC,QAAQ,KAAK,WACZ,oBAAC,KAAK;KAAyB,MAAM,CAAC,OAAO;KAAO,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,QAG3B,oBAAC,KAAK;KAAa;KAAM;KAAa;eACpC,oBAAC;MAAS;MAAa;gBACpB,YAAY,QAAQ,KAAK,WAAW,OAAO,MAAM,KAAK,MAAM;;;MAb5D,KAAK"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_Operations = require('./Operations-
|
|
2
|
+
const require_Operations = require('./Operations-DSUkakET.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-Bx8g7HBJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-BCX9TQcn.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,aAAa;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,aAErB;EAEF,MAAM;EACN,MAAM,EAAE,YAAY,SAAS;EAE7B,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM;GACjC,MAAM,QAAQ;;EAGhB,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;;GACpE,MAAM,QAAQ;;EAGhB,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA;GACvC,SAAS,W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,KAAK;IACX,MAAM,KAAK;IACX,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;KAAQ,QAAQ,cAAc;;IACvE,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;;eAExC,QAAQ,KAAK,WACZ,kDAACA,kBAAK;KAAyB,MAAM,CAAC,OAAO;KAAO,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,QAG3B,kDAACA,kBAAK;KAAa;KAAM;KAAa;eACpC,kDAACC;MAAS;MAAa;gBACpB,YAAY,QAAQ,KAAK,WAAW,OAAO,MAAM,KAAK,MAAM;;;MAb5D,KAAK"}
|
|
1
|
+
{"version":3,"file":"generators-Bx8g7HBJ.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,aAAa;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,aAErB;EAEF,MAAM;EACN,MAAM,EAAE,YAAY,SAAS;EAE7B,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM;GACjC,MAAM,QAAQ;;EAGhB,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;;GACpE,MAAM,QAAQ;;EAGhB,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA;IAAe,MAAM;;;EAGpE,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACC;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA;IAAgB,MAAM;;;AAGrE,SACE,mDAACC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;;GACvD,+CAAkB;IAAE;IAAK;;;IAEzB,kDAACA,kBAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;;IAC1C,kDAACA,kBAAK;KAAO,MAAM,CAAC,iBAAiB;KAAwB,MAAM,QAAQ;KAAY;;IACtF,QAAQ,WAAW,SAClB,kDAACA,kBAAK;KAAO,MAAM,CAAC,IAAI,QAAQ,SAAS,MAAM,IAAI,QAAQ,SAAS,MAAM,OAAO;KAAU,MAAM,OAAO,KAAK;KAAM,MAAM,IAAI,KAAK;;IAEpI,kDAACA,kBAAK;KACJ,MAAM;MACJ,KAAK,QAAQ,SAAS;MACtB,KAAK,QAAQ,SAAS;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AM,OAAO,OAAO,MAAM,QAAQ,OAAO,OAAO,EAAE,+CAAiB,MAAM,UAAU;AAEnF,QAAI,CAAC,OAAO,OAAO,CAAC,KAClB,QAAO;IAGT,MAAM,OAAO,cAAc,QAAQ;KACjC;KACA,SAAS;KACT;KACA,SAAS,EAAE;;IAGb,MAAM,SAAS;KACb,MAAM,QAAQ,WAAW,EAAE,MAAM;KACjC,MAAM,QAAQ;;IAGhB,MAAM,eAAe,IAAI,MAAM,SAAS,KAAK,KAAK,SAAS,KAAK;AAEhE,QAAI,aACF,cAAa,QAAQ,KAAK;QAE1B,KAAI,KAAK;KAAE;KAAM;KAAM,SAAS,CAAC;;;AAIrC,UAAO;KAET;AAGF,SAAO,YAAY,KAAK,EAAE,MAAM,MAAM,cAAc;AAClD,UACE,mDAACC;IAEC,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;KAAQ,QAAQ,cAAc;;IACvE,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;;eAExC,QAAQ,KAAK,WACZ,kDAACA,kBAAK;KAAyB,MAAM,CAAC,OAAO;KAAO,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,QAG3B,kDAACA,kBAAK;KAAa;KAAM;KAAa;eACpC,kDAACC;MAAS;MAAa;gBACpB,YAAY,QAAQ,KAAK,WAAW,OAAO,MAAM,KAAK,MAAM;;;MAb5D,KAAK"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require('./Operations-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./Operations-DSUkakET.cjs');
|
|
2
|
+
const require_generators = require('./generators-Bx8g7HBJ.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-hp89a2hq.js";
|
|
2
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-BlMUAzCj.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-DSUkakET.cjs');
|
|
3
|
+
const require_generators = require('./generators-Bx8g7HBJ.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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./Operations-
|
|
2
|
-
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-
|
|
1
|
+
import "./Operations-hp89a2hq.js";
|
|
2
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from "./generators-BlMUAzCj.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.3",
|
|
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.18.
|
|
81
|
-
"@kubb/oas": "3.18.
|
|
82
|
-
"@kubb/plugin-oas": "3.18.
|
|
83
|
-
"@kubb/plugin-ts": "3.18.
|
|
84
|
-
"@kubb/plugin-zod": "3.18.
|
|
85
|
-
"@kubb/react": "3.18.
|
|
80
|
+
"@kubb/core": "3.18.3",
|
|
81
|
+
"@kubb/oas": "3.18.3",
|
|
82
|
+
"@kubb/plugin-oas": "3.18.3",
|
|
83
|
+
"@kubb/plugin-ts": "3.18.3",
|
|
84
|
+
"@kubb/plugin-zod": "3.18.3",
|
|
85
|
+
"@kubb/react": "3.18.3"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"axios": "^1.11.0",
|
|
89
89
|
"tsdown": "^0.14.2",
|
|
90
90
|
"typescript": "^5.9.2",
|
|
91
|
-
"@kubb/config-ts": "3.18.
|
|
91
|
+
"@kubb/config-ts": "3.18.3"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@kubb/react": "^3.0.0",
|
|
@@ -189,7 +189,7 @@ export function Client({
|
|
|
189
189
|
const formData = isFormData
|
|
190
190
|
? `
|
|
191
191
|
const formData = new FormData()
|
|
192
|
-
if(requestData) {
|
|
192
|
+
if (requestData) {
|
|
193
193
|
Object.keys(requestData).forEach((key) => {
|
|
194
194
|
const value = requestData[key as keyof typeof requestData];
|
|
195
195
|
if (typeof value === 'string' || (value as unknown) instanceof Blob) {
|
|
@@ -198,7 +198,7 @@ export function Client({
|
|
|
198
198
|
})
|
|
199
199
|
}
|
|
200
200
|
`
|
|
201
|
-
:
|
|
201
|
+
: undefined
|
|
202
202
|
|
|
203
203
|
const childrenElement = children ? (
|
|
204
204
|
children
|
|
@@ -223,13 +223,14 @@ export function Client({
|
|
|
223
223
|
}}
|
|
224
224
|
returnType={returnType}
|
|
225
225
|
>
|
|
226
|
-
{isConfigurable ? 'const { client:request = fetch, ...requestConfig } = config' : ''}
|
|
226
|
+
{isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}
|
|
227
227
|
<br />
|
|
228
228
|
<br />
|
|
229
229
|
{parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}
|
|
230
230
|
{parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}
|
|
231
231
|
<br />
|
|
232
232
|
{formData}
|
|
233
|
+
<br />
|
|
233
234
|
{isConfigurable
|
|
234
235
|
? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`
|
|
235
236
|
: `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}
|