@kubb/plugin-client 3.18.1 → 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/clients/axios.cjs +2 -1
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.js +2 -1
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +2 -1
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.js +2 -1
- package/dist/clients/fetch.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.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- 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,aAA6B,EAAE;AAC5F,KAAI,eAAe,SACjB,QAAOC,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU,EACR,8CAAiB,YAAY,YAAY;GAAE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Aa,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"}
|
|
1
|
+
{"version":3,"file":"Operations-DSUkakET.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 : 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 {JS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6BAA6B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS,KAC3E,2BAA2B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS;IAC7E,kDAAC;IACA;;;;;AAMT,OAAO,YAAY;;;;ACzOnB,SAAgB,WAAW,EAAE,MAAM,cAA+B;CAChE,MAAMC,mBAAyE;AAE/E,YAAW,SAAS,cAAc;AAChC,mBAAiB,UAAU,oBAAoB;GAC7C,MAAM,IAAIC,0BAAQ,UAAU,MAAM;GAClC,QAAQ,UAAU;;;AAItB,QACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GAAY;GAAM;GAAO;aACvB,KAAK,UAAU,kBAAkB,QAAW"}
|
|
@@ -146,7 +146,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
146
146
|
} });
|
|
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,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,OAAO;GAAM,QAAQ;GAAc;EACrF,UAAU,WAAW,YAAY,YAAY;EAC9C,GACD,QACL;AACF;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,cAAc;CACjE,MAAM,SAASA,YAAU;EAAE;EAAY;EAAc;EAAgB;EAAa;AAElF,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBAAC;GAAe;GAAM,QAAQ;GAAc,QAAQ,OAAO;;IACzD,oBAAC;KAAM,MAAM;eAAQ,cAAc,UAAU,OAAO,cAAc,UAAU,KAAK,iBAAiB,EAAE,QAAQ,SAAS,EAAE;;IACvH,oBAAC;IAAK;;;;AAKb;AAED,IAAI,YAAYA;;;;AC5BhB,SAAS,UAAU,EAAE,YAAY,cAAc,gBAA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,WAAW,SAAS,KAAK;EACjH,mBAAmB,UAAU,WAAW,SAAS,cAAc,UAAU,WAAW,SAAS,KAAK;EAClG,mBAAmB,UAAU,WAAW,YAAY;EACpD,mBAAmB,UAAU,WAAW,YAAY;;AAIzD,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBAAC;GACO;GACN;GACA,QAAQ;GACR,QAAQ,OAAO;GACf,OAAO,EACL,UAAU,YAAY,YACvB;GACW;;IAEX,iBAAiB,gEAAgE;IAClF,oBAAC;IACD,oBAAC;IACA,WAAW,SAAS,YAAY,SAAS,QAAQ,uBAAuB,WAAW,QAAQ,KAAK;IAChG,WAAW,YAAY,aAAa,SAAS,QAAQ;IACtD,oBAAC;IACA;IACA,iBACG,6BAA6B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS,KAC3E,2BAA2B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS;IAC7E,oBAAC;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,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"}
|
|
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,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,UAAU,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;;EACvE,UAAU,WAAW,YAAY,YAAY;KAE/C;;AAIR,SAAgB,IAAI,EAAE,MAAM,eAAe,MAAM,cAAc,MAAM,aAAa,SAAS,YAAY,cAAc,gBAAgB,aAAoB;CACvJ,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ;CACnD,MAAM,SAASA,YAAU;EAAE;EAAY;EAAc;EAAgB;;AAErE,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBAAC;GAAe;GAAM,QAAQ;GAAc,QAAQ,OAAO;;IACzD,oBAAC;KAAM,MAAM;eAAQ,cAAc,UAAU,OAAO,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AAS,KAAK;EACjH,mBAAmB,UAAU,WAAW,SAAS,cAAc,UAAU,WAAW,SAAS,KAAK;EAClG,mBAAmB,UAAU,WAAW,YAAY;EACpD,mBAAmB,UAAU,WAAW,YAAY;;AAIzD,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBAAC;GACO;GACN;GACA,QAAQ;GACR,QAAQ,OAAO;GACf,OAAO,EACL,UAAU,YAAY;GAEZ;;IAEX,iBAAiB,iEAAiE;IACnF,oBAAC;IACD,oBAAC;IACA,WAAW,SAAS,YAAY,SAAS,QAAQ,uBAAuB,WAAW,QAAQ,KAAK;IAChG,WAAW,YAAY,aAAa,SAAS,QAAQ;IACtD,oBAAC;IACA;IACD,oBAAC;IACA,iBACG,6BAA6B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS,KAC3E,2BAA2B,SAAS,KAAK,MAAM,IAAI,aAAa,SAAS;IAC7E,oBAAC;IACA;;;;;AAMT,OAAO,YAAY;;;;ACzOnB,SAAgB,WAAW,EAAE,MAAM,cAA+B;CAChE,MAAMC,mBAAyE;AAE/E,YAAW,SAAS,cAAc;AAChC,mBAAiB,UAAU,oBAAoB;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"}
|
package/dist/clients/axios.cjs
CHANGED
|
@@ -28,11 +28,12 @@ const client = async (config) => {
|
|
|
28
28
|
};
|
|
29
29
|
client.getConfig = getConfig;
|
|
30
30
|
client.setConfig = setConfig;
|
|
31
|
+
var axios_default = client;
|
|
31
32
|
|
|
32
33
|
//#endregion
|
|
33
34
|
exports.axiosInstance = axiosInstance;
|
|
34
35
|
exports.client = client;
|
|
35
|
-
exports.default =
|
|
36
|
+
exports.default = axios_default;
|
|
36
37
|
exports.getConfig = getConfig;
|
|
37
38
|
exports.setConfig = setConfig;
|
|
38
39
|
//# sourceMappingURL=axios.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;AAGhG,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO;;AAGT,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;;IAGb,OAAO,MAA0B;AAChC,QAAM;;;AAIZ,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
package/dist/clients/axios.js
CHANGED
|
@@ -26,7 +26,8 @@ const client = async (config) => {
|
|
|
26
26
|
};
|
|
27
27
|
client.getConfig = getConfig;
|
|
28
28
|
client.setConfig = setConfig;
|
|
29
|
+
var axios_default = client;
|
|
29
30
|
|
|
30
31
|
//#endregion
|
|
31
|
-
export { axiosInstance, client,
|
|
32
|
+
export { axiosInstance, client, axios_default as default, getConfig, setConfig };
|
|
32
33
|
//# sourceMappingURL=axios.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;AAGhG,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO;;AAGT,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;;IAGb,OAAO,MAA0B;AAChC,QAAM;;;AAIZ,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
package/dist/clients/fetch.cjs
CHANGED
|
@@ -40,10 +40,11 @@ const client = async (paramsConfig) => {
|
|
|
40
40
|
};
|
|
41
41
|
client.getConfig = getConfig;
|
|
42
42
|
client.setConfig = setConfig;
|
|
43
|
+
var fetch_default = client;
|
|
43
44
|
|
|
44
45
|
//#endregion
|
|
45
46
|
exports.client = client;
|
|
46
|
-
exports.default =
|
|
47
|
+
exports.default = fetch_default;
|
|
47
48
|
exports.getConfig = getConfig;
|
|
48
49
|
exports.setConfig = setConfig;
|
|
49
50
|
//# sourceMappingURL=fetch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;AAEtC,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAAmC;AAC3D,WAAU;AACV,QAAO;;AAKT,MAAa,SAAS,OAAuD,iBAA4E;CACvJ,MAAM,mBAAmB,IAAI;CAE7B,MAAM,eAAe;CACrB,MAAM,SAAS;EAAE,GAAG;EAAc,GAAG;;AAErC,QAAO,QAAQ,OAAO,UAAU,IAAI,SAAS,CAAC,KAAK,WAAW;AAC5D,MAAI,UAAU,OACZ,kBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,MAAM;;CAIjE,IAAI,YAAY,CAAC,OAAO,SAAS,OAAO,KAAK,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;;CAGlB,MAAM,OAAO;EAAC;EAAK;EAAK;GAAK,SAAS,SAAS,WAAW,CAAC,SAAS,OAAO,KAAK,MAAM,SAAS;AAE/F,QAAO;EACC;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,SAAS,SAAS;;;AAItB,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
package/dist/clients/fetch.js
CHANGED
|
@@ -38,7 +38,8 @@ const client = async (paramsConfig) => {
|
|
|
38
38
|
};
|
|
39
39
|
client.getConfig = getConfig;
|
|
40
40
|
client.setConfig = setConfig;
|
|
41
|
+
var fetch_default = client;
|
|
41
42
|
|
|
42
43
|
//#endregion
|
|
43
|
-
export { client,
|
|
44
|
+
export { client, fetch_default as default, getConfig, setConfig };
|
|
44
45
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;AAEtC,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAAmC;AAC3D,WAAU;AACV,QAAO;;AAKT,MAAa,SAAS,OAAuD,iBAA4E;CACvJ,MAAM,mBAAmB,IAAI;CAE7B,MAAM,eAAe;CACrB,MAAM,SAAS;EAAE,GAAG;EAAc,GAAG;;AAErC,QAAO,QAAQ,OAAO,UAAU,IAAI,SAAS,CAAC,KAAK,WAAW;AAC5D,MAAI,UAAU,OACZ,kBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,MAAM;;CAIjE,IAAI,YAAY,CAAC,OAAO,SAAS,OAAO,KAAK,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;;CAGlB,MAAM,OAAO;EAAC;EAAK;EAAK;GAAK,SAAS,SAAS,WAAW,CAAC,SAAS,OAAO,KAAK,MAAM,SAAS;AAE/F,QAAO;EACC;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,SAAS,SAAS;;;AAItB,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
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,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,EAC7B,EACD,eACD,GAAG;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,YAAY,SAAS,SAAS,GAAG;EAEzC,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,CAAC,aAAa,EAAE;GACtD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ;GAC3E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,cAAc;IAAE,MAAM;IAAY;GAChF;AAED,SACE,qBAAC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ;GAC/D,QAAQ,UAAU;IAAE;IAAK;IAAQ;;IAEjC,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ;;IAC1C,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB,s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OAAO,KAAK;KAAE,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;EAkBf;CACF;CACF"}
|
|
1
|
+
{"version":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,EAC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;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,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,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,EAC7B,EACD,eACD;EACD,MAAM;EACN,MAAM,EAAE,YAAY,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AAI;AAEnF,QAAI,CAAC,OAAO,OAAO,CAAC,KAClB,QAAO;IAGT,MAAM,OAAO,cAAc,QAAQ;KACjC;KACA,SAAS;KACT;KACA,SAAS,EAAE,OAAO;KACnB;IAED,MAAM,SAAS;KACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY;KAC7C,MAAM,QAAQ;KACf;IAED,MAAM,eAAe,IAAI,MAAM,SAAS,KAAK,KAAK,SAAS,KAAK;AAEhE,QAAI,aACF,cAAa,QAAQ,KAAK;QAE1B,KAAI,KAAK;KAAE;KAAM;KAAM,SAAS,CAAC,OAAO;KAAE;GAE7C;AAED,UAAO;EACR,GACD,EAAE;AAGJ,SAAO,YAAY,KAAK,EAAE,MAAM,MAAM,SAAS,KAAK;AAClD,UACE,mDAACC;IAEC,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;KAAQ,QAAQ,cAAc;KAAQ;IAC/E,+CAAkB;KAAE;KAAK,QAAQ,QAAQ;KAAQ;eAEhD,QAAQ,KAAK,WACZ,kDAACA,kBAAK;KAAyB,MAAM,CAAC,OAAO,KAAK;KAAE,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;EAkBf;CACF;CACF"}
|
|
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,MAA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A,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.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IACxC,OACA,UAAU,OACV,UAAU,IACV,SACA,WAAW,IACX,eAAe,IACf,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAACA;EAAiB,QAAQC,4CAAyB;EAAW,aAAaC,yCAAsB;GAAW,OAAO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AAQ;GAE5C,MAAM,qBAAqB,IAAIC,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;OAEF,KAAK,OAAO,SAChB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;;GAIJ,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;IAEzB,QAAQ,KAAK;;AAGf,SAAM,KAAK,QAAQ,GAAG"}
|
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/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,cAA4B,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;
|
|
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;IACxC,OACA,UAAU,OACV,UAAU,IACV,SACA,WAAW,IACX,eAAe,IACf,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAAC;EAAiB,QAAQ,yBAAyB;EAAW,aAAa,sBAAsB;GAAW,OAAO,UAChI,SAAS,UACT,SAAS,SACT,aAAa,WAAW,UAAU,sCAAsC,qCACxE,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;;EAEF,KAAK,CAAC,eAAe,WAAW,QAAQ,gBAAgB,QAAW,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,MAAM,QACL,QAAQ;AACP,SAAI,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ator 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
|
-
"tsdown": "^0.14.
|
|
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()})`}
|