@kubb/plugin-client 4.1.4 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Operations-B5ymSfTm.js → Operations-ktPlsW1u.js} +2 -2
- package/dist/{Operations-B5ymSfTm.js.map → Operations-ktPlsW1u.js.map} +1 -1
- package/dist/clients/axios.d.cts +4 -4
- package/dist/clients/axios.d.ts +4 -4
- package/dist/clients/fetch.d.cts +4 -4
- package/dist/clients/fetch.d.ts +4 -4
- package/dist/components.d.cts +8 -5
- package/dist/components.d.ts +8 -5
- package/dist/components.js +1 -1
- package/dist/{generators-Dlx9ubRQ.cjs → generators-BSxTToF6.cjs} +9 -4
- package/dist/generators-BSxTToF6.cjs.map +1 -0
- package/dist/{generators-CQSnGpkm.js → generators-BqXV2IXC.js} +11 -7
- package/dist/generators-BqXV2IXC.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/{types-Dff_FBev.d.ts → types-BfP2gAzn.d.cts} +85 -174
- package/dist/{types-CX3qvh_y.d.cts → types-DIxcknRD.d.ts} +85 -174
- package/package.json +8 -8
- package/src/generators/clientGenerator.tsx +5 -6
- package/src/generators/groupedClientGenerator.tsx +6 -7
- package/src/generators/operationsGenerator.tsx +7 -7
- package/src/plugin.ts +5 -8
- package/dist/generators-CQSnGpkm.js.map +0 -1
- package/dist/generators-Dlx9ubRQ.cjs.map +0 -1
|
@@ -215,5 +215,5 @@ function Operations({ name, operations }) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
//#endregion
|
|
218
|
-
export { Client
|
|
219
|
-
//# sourceMappingURL=Operations-
|
|
218
|
+
export { Client as n, Url as r, Operations as t };
|
|
219
|
+
//# sourceMappingURL=Operations-ktPlsW1u.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-B5ymSfTm.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' && contentType !== 'multipart/form-data' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method.toUpperCase()),\n },\n url: {\n value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : 'requestData',\n }\n : undefined,\n requestConfig: isConfigurable\n ? {\n mode: 'inlineSpread',\n }\n : undefined,\n headers: headers.length\n ? {\n value: isConfigurable ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : `{ ${headers.join(', ')} }`,\n }\n : undefined,\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if (requestData) {\n Object.keys(requestData).forEach((key) => {\n const value = requestData[key as keyof typeof requestData];\n if (typeof value === 'string' || (value as unknown) instanceof Blob) {\n formData.append(key, value as unknown as string | Blob);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n })\n }\n `\n : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </>\n )\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport { Const, File } from '@kubb/react'\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>\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;GAAc,CAAC,EAChF;EACF,EACF,CAAC;AAGJ,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBA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;IACL,WAAW,SAAS,YAAY,SAAS,QAAQ,uBAAuB,WAAW,QAAQ,KAAK;IAChG,WAAW,YAAY,aAAa,SAAS,QAAQ;IACtD,oBAAC,SAAK;IACL;IACD,oBAAC,SAAK;IACL,iBACG,6BAA6B,SAAS,KAAK,KAAK,CAAC,IAAI,aAAa,QAAQ,CAAC,KAC3E,2BAA2B,SAAS,KAAK,KAAK,CAAC,IAAI,aAAa,QAAQ,CAAC;IAC7E,oBAAC,SAAK;IACL;;IACQ;GACC;;AAIlB,OAAO,YAAY;;;;AC5OnB,SAAgB,WAAW,EAAE,MAAM,cAA+B;CAChE,MAAMC,mBAAyE,EAAE;AAEjF,YAAW,SAAS,cAAc;AAChC,mBAAiB,UAAU,gBAAgB,IAAI;GAC7C,MAAM,IAAI,QAAQ,UAAU,KAAK,CAAC;GAClC,QAAQ,UAAU;GACnB;GACD;AAEF,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAY;GAAM;aAChB,KAAK,UAAU,kBAAkB,QAAW,EAAE;IACzC;GACI"}
|
|
1
|
+
{"version":3,"file":"Operations-ktPlsW1u.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' && contentType !== 'multipart/form-data' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method.toUpperCase()),\n },\n url: {\n value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : 'requestData',\n }\n : undefined,\n requestConfig: isConfigurable\n ? {\n mode: 'inlineSpread',\n }\n : undefined,\n headers: headers.length\n ? {\n value: isConfigurable ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : `{ ${headers.join(', ')} }`,\n }\n : undefined,\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if (requestData) {\n Object.keys(requestData).forEach((key) => {\n const value = requestData[key as keyof typeof requestData];\n if (typeof value === 'string' || (value as unknown) instanceof Blob) {\n formData.append(key, value as unknown as string | Blob);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n })\n }\n `\n : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </>\n )\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport { Const, File } from '@kubb/react'\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>\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;GAAc,CAAC,EAChF;EACF,EACF,CAAC;AAGJ,QAAO,eAAe,QAAQ,EAC5B,YAAY,YAAY,YAAY,OAChC;EACE,MAAM,mBAAmB,WAAW,WAAW;EAC/C,UAAU,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC;EACtF,UAAU,WAAW,YAAY,YAAY,OAAO;EACrD,GACD,QACL,CAAC;;AAGJ,SAAgB,IAAI,EAAE,MAAM,eAAe,MAAM,cAAc,MAAM,aAAa,SAAS,YAAY,cAAc,gBAAgB,aAAoB;CACvJ,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ,cAAc,CAAC;CAClE,MAAM,SAASA,YAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;AAEnF,QACE,oBAAC,KAAK;EAAa;EAAoB;EAA2B;YAChE,qBAAC;GAAe;GAAM,QAAQ;GAAc,QAAQ,OAAO,eAAe;;IACxE,oBAAC;KAAM,MAAM;eAAQ,cAAc,UAAU,OAAO,aAAa,CAAC,UAAU,KAAK,iBAAiB,EAAE,QAAQ,SAAS,CAAC,CAAC;MAAqB;IAC5I,oBAAC,SAAK;;;IAEG;GACC;;AAIlB,IAAI,YAAYA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C;GACI"}
|
package/dist/clients/axios.d.cts
CHANGED
|
@@ -5,12 +5,12 @@ import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
|
5
5
|
/**
|
|
6
6
|
* Subset of AxiosRequestConfig
|
|
7
7
|
*/
|
|
8
|
-
type RequestConfig<TData = unknown> = {
|
|
8
|
+
type RequestConfig<TData$1 = unknown> = {
|
|
9
9
|
baseURL?: string;
|
|
10
10
|
url?: string;
|
|
11
11
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
12
12
|
params?: unknown;
|
|
13
|
-
data?: TData | FormData;
|
|
13
|
+
data?: TData$1 | FormData;
|
|
14
14
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
validateStatus?: (status: number) => boolean;
|
|
@@ -19,8 +19,8 @@ type RequestConfig<TData = unknown> = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Subset of AxiosResponse
|
|
21
21
|
*/
|
|
22
|
-
type ResponseConfig<TData = unknown> = {
|
|
23
|
-
data: TData;
|
|
22
|
+
type ResponseConfig<TData$1 = unknown> = {
|
|
23
|
+
data: TData$1;
|
|
24
24
|
status: number;
|
|
25
25
|
statusText: string;
|
|
26
26
|
headers: AxiosResponse['headers'];
|
package/dist/clients/axios.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
|
5
5
|
/**
|
|
6
6
|
* Subset of AxiosRequestConfig
|
|
7
7
|
*/
|
|
8
|
-
type RequestConfig<TData = unknown> = {
|
|
8
|
+
type RequestConfig<TData$1 = unknown> = {
|
|
9
9
|
baseURL?: string;
|
|
10
10
|
url?: string;
|
|
11
11
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
12
12
|
params?: unknown;
|
|
13
|
-
data?: TData | FormData;
|
|
13
|
+
data?: TData$1 | FormData;
|
|
14
14
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
validateStatus?: (status: number) => boolean;
|
|
@@ -19,8 +19,8 @@ type RequestConfig<TData = unknown> = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Subset of AxiosResponse
|
|
21
21
|
*/
|
|
22
|
-
type ResponseConfig<TData = unknown> = {
|
|
23
|
-
data: TData;
|
|
22
|
+
type ResponseConfig<TData$1 = unknown> = {
|
|
23
|
+
data: TData$1;
|
|
24
24
|
status: number;
|
|
25
25
|
statusText: string;
|
|
26
26
|
headers: AxiosResponse['headers'];
|
package/dist/clients/fetch.d.cts
CHANGED
|
@@ -6,12 +6,12 @@ type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
|
|
6
6
|
/**
|
|
7
7
|
* Subset of FetchRequestConfig
|
|
8
8
|
*/
|
|
9
|
-
type RequestConfig<TData = unknown> = {
|
|
9
|
+
type RequestConfig<TData$1 = unknown> = {
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
url?: string;
|
|
12
12
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
13
13
|
params?: unknown;
|
|
14
|
-
data?: TData | FormData;
|
|
14
|
+
data?: TData$1 | FormData;
|
|
15
15
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
headers?: [string, string][] | Record<string, string>;
|
|
@@ -20,8 +20,8 @@ type RequestConfig<TData = unknown> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Subset of FetchResponse
|
|
22
22
|
*/
|
|
23
|
-
type ResponseConfig<TData = unknown> = {
|
|
24
|
-
data: TData;
|
|
23
|
+
type ResponseConfig<TData$1 = unknown> = {
|
|
24
|
+
data: TData$1;
|
|
25
25
|
status: number;
|
|
26
26
|
statusText: string;
|
|
27
27
|
headers: Headers;
|
package/dist/clients/fetch.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
|
|
6
6
|
/**
|
|
7
7
|
* Subset of FetchRequestConfig
|
|
8
8
|
*/
|
|
9
|
-
type RequestConfig<TData = unknown> = {
|
|
9
|
+
type RequestConfig<TData$1 = unknown> = {
|
|
10
10
|
baseURL?: string;
|
|
11
11
|
url?: string;
|
|
12
12
|
method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
13
13
|
params?: unknown;
|
|
14
|
-
data?: TData | FormData;
|
|
14
|
+
data?: TData$1 | FormData;
|
|
15
15
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
headers?: [string, string][] | Record<string, string>;
|
|
@@ -20,8 +20,8 @@ type RequestConfig<TData = unknown> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Subset of FetchResponse
|
|
22
22
|
*/
|
|
23
|
-
type ResponseConfig<TData = unknown> = {
|
|
24
|
-
data: TData;
|
|
23
|
+
type ResponseConfig<TData$1 = unknown> = {
|
|
24
|
+
data: TData$1;
|
|
25
25
|
status: number;
|
|
26
26
|
statusText: string;
|
|
27
27
|
headers: Headers;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-BfP2gAzn.cjs";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region ../react/src/index.d.ts
|
|
4
4
|
|
|
5
|
+
import * as import___kubb_react_fabric from "@kubb/react-fabric";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/components/Client.d.ts
|
|
5
8
|
type Props$1 = {
|
|
6
9
|
/**
|
|
7
10
|
* Name of the function
|
|
@@ -21,7 +24,7 @@ type Props$1 = {
|
|
|
21
24
|
typeSchemas: OperationSchemas;
|
|
22
25
|
zodSchemas: OperationSchemas | undefined;
|
|
23
26
|
operation: Operation;
|
|
24
|
-
children?: KubbNode;
|
|
27
|
+
children?: types_d_exports.KubbNode;
|
|
25
28
|
};
|
|
26
29
|
type GetParamsProps$1 = {
|
|
27
30
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -55,7 +58,7 @@ declare namespace Client {
|
|
|
55
58
|
pathParamsType,
|
|
56
59
|
typeSchemas,
|
|
57
60
|
isConfigurable
|
|
58
|
-
}: GetParamsProps$1) => FunctionParams;
|
|
61
|
+
}: GetParamsProps$1) => index_d_exports.FunctionParams;
|
|
59
62
|
}
|
|
60
63
|
//#endregion
|
|
61
64
|
//#region src/components/Operations.d.ts
|
|
@@ -106,7 +109,7 @@ declare namespace Url {
|
|
|
106
109
|
paramsCasing,
|
|
107
110
|
pathParamsType,
|
|
108
111
|
typeSchemas
|
|
109
|
-
}: GetParamsProps) => FunctionParams;
|
|
112
|
+
}: GetParamsProps) => index_d_exports.FunctionParams;
|
|
110
113
|
}
|
|
111
114
|
//#endregion
|
|
112
115
|
export { Client, Operations, Url };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-DIxcknRD.js";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region ../react/src/index.d.ts
|
|
4
4
|
|
|
5
|
+
import * as import___kubb_react_fabric from "@kubb/react-fabric";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/components/Client.d.ts
|
|
5
8
|
type Props$1 = {
|
|
6
9
|
/**
|
|
7
10
|
* Name of the function
|
|
@@ -21,7 +24,7 @@ type Props$1 = {
|
|
|
21
24
|
typeSchemas: OperationSchemas;
|
|
22
25
|
zodSchemas: OperationSchemas | undefined;
|
|
23
26
|
operation: Operation;
|
|
24
|
-
children?: KubbNode;
|
|
27
|
+
children?: types_d_exports.KubbNode;
|
|
25
28
|
};
|
|
26
29
|
type GetParamsProps$1 = {
|
|
27
30
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -55,7 +58,7 @@ declare namespace Client {
|
|
|
55
58
|
pathParamsType,
|
|
56
59
|
typeSchemas,
|
|
57
60
|
isConfigurable
|
|
58
|
-
}: GetParamsProps$1) => FunctionParams;
|
|
61
|
+
}: GetParamsProps$1) => index_d_exports.FunctionParams;
|
|
59
62
|
}
|
|
60
63
|
//#endregion
|
|
61
64
|
//#region src/components/Operations.d.ts
|
|
@@ -106,7 +109,7 @@ declare namespace Url {
|
|
|
106
109
|
paramsCasing,
|
|
107
110
|
pathParamsType,
|
|
108
111
|
typeSchemas
|
|
109
|
-
}: GetParamsProps) => FunctionParams;
|
|
112
|
+
}: GetParamsProps) => index_d_exports.FunctionParams;
|
|
110
113
|
}
|
|
111
114
|
//#endregion
|
|
112
115
|
export { Client, Operations, Url };
|
package/dist/components.js
CHANGED
|
@@ -6,6 +6,8 @@ let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
|
6
6
|
__kubb_plugin_oas = require_chunk.__toESM(__kubb_plugin_oas);
|
|
7
7
|
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
8
8
|
__kubb_plugin_zod = require_chunk.__toESM(__kubb_plugin_zod);
|
|
9
|
+
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
10
|
+
__kubb_core_hooks = require_chunk.__toESM(__kubb_core_hooks);
|
|
9
11
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
10
12
|
__kubb_plugin_oas_hooks = require_chunk.__toESM(__kubb_plugin_oas_hooks);
|
|
11
13
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -21,7 +23,8 @@ __kubb_react_jsx_runtime = require_chunk.__toESM(__kubb_react_jsx_runtime);
|
|
|
21
23
|
const clientGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
22
24
|
name: "client",
|
|
23
25
|
Operation({ options, operation }) {
|
|
24
|
-
const
|
|
26
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
27
|
+
const { options: { output, urlType } } = (0, __kubb_core_hooks.usePlugin)();
|
|
25
28
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
26
29
|
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
27
30
|
const client = {
|
|
@@ -125,7 +128,8 @@ const clientGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
125
128
|
const operationsGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
126
129
|
name: "client",
|
|
127
130
|
Operations({ operations }) {
|
|
128
|
-
const {
|
|
131
|
+
const { key: pluginKey, options: { output } } = (0, __kubb_core_hooks.usePlugin)();
|
|
132
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
129
133
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
130
134
|
const name = "operations";
|
|
131
135
|
const file = pluginManager.getFile({
|
|
@@ -159,7 +163,8 @@ const operationsGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
159
163
|
const groupedClientGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
160
164
|
name: "groupedClient",
|
|
161
165
|
Operations({ operations }) {
|
|
162
|
-
const {
|
|
166
|
+
const { options, key: pluginKey } = (0, __kubb_core_hooks.usePlugin)();
|
|
167
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
163
168
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
164
169
|
const { getName, getFile, getGroup } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
165
170
|
return operations.reduce((acc, operation) => {
|
|
@@ -238,4 +243,4 @@ Object.defineProperty(exports, 'operationsGenerator', {
|
|
|
238
243
|
return operationsGenerator;
|
|
239
244
|
}
|
|
240
245
|
});
|
|
241
|
-
//# sourceMappingURL=generators-
|
|
246
|
+
//# sourceMappingURL=generators-BSxTToF6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BSxTToF6.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 { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const pluginManager = usePluginManager()\n const {\n options: { output, urlType },\n } = usePlugin<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n key: pluginKey,\n options: { output },\n } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { camelCase } from '@kubb/core/transformers'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const { options, key: pluginKey } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;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B,YAAY,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,CAAC;OACpD;MACC;MAfT,KAAK,KAgBL;IAET;;CAEL,CAAC"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { n as Client, r as Url, t as Operations } from "./Operations-ktPlsW1u.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";
|
|
5
|
+
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
5
6
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
6
7
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
7
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
8
|
-
import { File, Function
|
|
9
|
+
import { File, Function } from "@kubb/react";
|
|
9
10
|
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
10
11
|
|
|
11
12
|
//#region src/generators/clientGenerator.tsx
|
|
12
13
|
const clientGenerator = createReactGenerator({
|
|
13
14
|
name: "client",
|
|
14
15
|
Operation({ options, operation }) {
|
|
15
|
-
const
|
|
16
|
+
const pluginManager = usePluginManager();
|
|
17
|
+
const { options: { output, urlType } } = usePlugin();
|
|
16
18
|
const oas = useOas();
|
|
17
19
|
const { getSchemas, getName, getFile } = useOperationManager();
|
|
18
20
|
const client = {
|
|
@@ -116,7 +118,8 @@ const clientGenerator = createReactGenerator({
|
|
|
116
118
|
const operationsGenerator = createReactGenerator({
|
|
117
119
|
name: "client",
|
|
118
120
|
Operations({ operations }) {
|
|
119
|
-
const {
|
|
121
|
+
const { key: pluginKey, options: { output } } = usePlugin();
|
|
122
|
+
const pluginManager = usePluginManager();
|
|
120
123
|
const oas = useOas();
|
|
121
124
|
const name = "operations";
|
|
122
125
|
const file = pluginManager.getFile({
|
|
@@ -150,7 +153,8 @@ const operationsGenerator = createReactGenerator({
|
|
|
150
153
|
const groupedClientGenerator = createReactGenerator({
|
|
151
154
|
name: "groupedClient",
|
|
152
155
|
Operations({ operations }) {
|
|
153
|
-
const {
|
|
156
|
+
const { options, key: pluginKey } = usePlugin();
|
|
157
|
+
const pluginManager = usePluginManager();
|
|
154
158
|
const oas = useOas();
|
|
155
159
|
const { getName, getFile, getGroup } = useOperationManager();
|
|
156
160
|
return operations.reduce((acc, operation) => {
|
|
@@ -211,5 +215,5 @@ const groupedClientGenerator = createReactGenerator({
|
|
|
211
215
|
});
|
|
212
216
|
|
|
213
217
|
//#endregion
|
|
214
|
-
export { clientGenerator, groupedClientGenerator
|
|
215
|
-
//# sourceMappingURL=generators-
|
|
218
|
+
export { operationsGenerator as n, clientGenerator as r, groupedClientGenerator as t };
|
|
219
|
+
//# sourceMappingURL=generators-BqXV2IXC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BqXV2IXC.js","names":[],"sources":["../src/generators/clientGenerator.tsx","../src/generators/operationsGenerator.tsx","../src/generators/groupedClientGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Url } from '../components/Url.tsx'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const pluginManager = usePluginManager()\n const {\n options: { output, urlType },\n } = usePlugin<PluginClient>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const url = {\n name: getName(operation, { type: 'function', suffix: 'url', prefix: 'get' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File\n baseName={client.file.baseName}\n path={client.file.path}\n meta={client.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={'fetch'} path={options.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={client.file.path} path={zod.file.path} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Url\n name={url.name}\n baseURL={options.baseURL}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n isIndexable={urlType === 'export'}\n isExportable={urlType === 'export'}\n />\n\n <Client\n name={client.name}\n urlName={url.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n key: pluginKey,\n options: { output },\n } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n","import type { KubbFile } from '@kubb/core/fs'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { camelCase } from '@kubb/core/transformers'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, Function } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const { options, key: pluginKey } = usePlugin<PluginClient>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile, getGroup } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const group = getGroup(operation)\n const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined\n\n if (!group?.tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey,\n options: { group },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File\n key={file.path}\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB,qBAAmC;CAChE,MAAM;CACN,UAAU,EAAE,SAAS,aAAa;EAChC,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,EACJ,SAAS,EAAE,QAAQ,cACjB,WAAyB;EAC7B,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,MAAM,SAAS;GACb,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,QAAQ;IAAO,CAAC;GAC5E,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;EAED,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;GACxD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,cAAc;IAAE,MAAM;IAAY,CAAC;GACjF;AAED,SACE,qBAAC;GACC,UAAU,OAAO,KAAK;GACtB,MAAM,OAAO,KAAK;GAClB,MAAM,OAAO,KAAK;GAClB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,c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AEkB,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;KAAQ,CAAC;IAChF,QAAQ,UAAU;KAAE;KAAK,QAAQ,QAAQ;KAAQ,CAAC;eAEjD,QAAQ,KAAK,WACZ,oBAAC,KAAK;KAAyB,MAAM,CAAC,OAAO,KAAK;KAAE,MAAM,KAAK;KAAM,MAAM,OAAO,KAAK;OAArE,OAAO,KAAsE,CAC/F,EAEF,oBAAC,KAAK;KAAa;KAAM;KAAa;eACpC,oBAAC;MAAS;MAAa;gBACpB,YAAY,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,CAAC;OACpD;MACC;MAfT,KAAK,KAgBL;IAET;;CAEL,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('./Operations-CT9m1j9w.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
2
|
+
const require_generators = require('./generators-BSxTToF6.cjs');
|
|
3
3
|
|
|
4
4
|
exports.clientGenerator = require_generators.clientGenerator;
|
|
5
5
|
exports.groupedClientGenerator = require_generators.groupedClientGenerator;
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./Operations-
|
|
2
|
-
import { clientGenerator, groupedClientGenerator
|
|
1
|
+
import "./Operations-ktPlsW1u.js";
|
|
2
|
+
import { n as operationsGenerator, r as clientGenerator, t as groupedClientGenerator } from "./generators-BqXV2IXC.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
2
|
require('./Operations-CT9m1j9w.cjs');
|
|
3
|
-
const require_generators = require('./generators-
|
|
3
|
+
const require_generators = require('./generators-BSxTToF6.cjs');
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
6
6
|
let __kubb_core = require("@kubb/core");
|
|
@@ -40,7 +40,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
40
40
|
pre: [__kubb_plugin_oas.pluginOasName, parser === "zod" ? __kubb_plugin_zod.pluginZodName : void 0].filter(Boolean),
|
|
41
41
|
resolvePath(baseName, pathMode, options$1) {
|
|
42
42
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
43
|
-
if ((pathMode ?? __kubb_core.
|
|
43
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
44
44
|
/**
|
|
45
45
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
46
46
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -64,7 +64,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
64
64
|
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
65
65
|
const oas = await swaggerPlugin.context.getOas();
|
|
66
66
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
67
|
-
const mode = __kubb_core.
|
|
67
|
+
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
68
68
|
const baseURL$1 = await swaggerPlugin.context.getBaseURL();
|
|
69
69
|
const files = await new __kubb_plugin_oas.OperationGenerator(baseURL$1 ? {
|
|
70
70
|
...this.plugin.options,
|
|
@@ -80,7 +80,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
80
80
|
mode
|
|
81
81
|
}).build(...generators);
|
|
82
82
|
await this.addFile(...files);
|
|
83
|
-
const barrelFiles = await this.fileManager.
|
|
83
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
|
|
84
84
|
type: output.barrelType ?? "named",
|
|
85
85
|
root,
|
|
86
86
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","PluginManager","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } 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 ?? 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 = 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 getBarrelFiles(this.fileManager.files, {\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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,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;AAEjE,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiDG,0BAAc,mBAAyC,KAAK,SAAS,CAACL,gCAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOE,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAMI,YAAU,MAAM,cAAc,QAAQ,YAAY;GAqBxD,MAAM,QAAQ,MAnBa,IAAIC,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PluginClient, o as UserPluginWithLifeCycle, t as Options } from "./types-BfP2gAzn.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./Operations-
|
|
2
|
-
import { clientGenerator, groupedClientGenerator
|
|
1
|
+
import "./Operations-ktPlsW1u.js";
|
|
2
|
+
import { n as operationsGenerator, r as clientGenerator, t as groupedClientGenerator } from "./generators-BqXV2IXC.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
7
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
@@ -34,7 +34,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
34
34
|
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
35
35
|
resolvePath(baseName, pathMode, options$1) {
|
|
36
36
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
37
|
-
if ((pathMode ??
|
|
37
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
38
38
|
/**
|
|
39
39
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
40
40
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -58,7 +58,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
58
58
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
59
59
|
const oas = await swaggerPlugin.context.getOas();
|
|
60
60
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
61
|
-
const mode =
|
|
61
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
62
62
|
const baseURL$1 = await swaggerPlugin.context.getBaseURL();
|
|
63
63
|
const files = await new OperationGenerator(baseURL$1 ? {
|
|
64
64
|
...this.plugin.options,
|
|
@@ -74,7 +74,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
74
74
|
mode
|
|
75
75
|
}).build(...generators);
|
|
76
76
|
await this.addFile(...files);
|
|
77
|
-
const barrelFiles = await this.fileManager.
|
|
77
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
78
78
|
type: output.barrelType ?? "named",
|
|
79
79
|
root,
|
|
80
80
|
output,
|