@kubb/plugin-client 3.0.0-alpha.4 → 3.0.0-alpha.6

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.
@@ -57,18 +57,17 @@ function Template({ name, generics, returnType, params, JSDoc, client }) {
57
57
  })
58
58
  }
59
59
  ` : void 0;
60
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Function, { name, async: true, export: true, generics, returnType, params, JSDoc, children: [
60
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Function, { name, async: true, export: true, generics, returnType, params, JSDoc, children: [
61
61
  formData || "",
62
62
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function.Call, { name: "res", to: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name: "client", async: true, generics: client.generics, params: clientParams }) }),
63
63
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function.Return, { children: client.dataReturnType === "data" ? "res.data" : "res" })
64
- ] });
64
+ ] }) });
65
65
  }
66
66
  function RootTemplate({ children }) {
67
67
  const {
68
68
  plugin: {
69
69
  options: {
70
- client: { importPath },
71
- extName
70
+ client: { importPath }
72
71
  }
73
72
  }
74
73
  } = _react.useApp.call(void 0, );
@@ -77,21 +76,20 @@ function RootTemplate({ children }) {
77
76
  const file = getFile(operation);
78
77
  const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
79
78
  const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
80
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
79
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
81
80
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
82
81
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
83
82
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
84
83
  _react.File.Import,
85
84
  {
86
- extName,
87
85
  name: [_optionalChain([schemas, 'access', _ => _.request, 'optionalAccess', _2 => _2.name]), schemas.response.name, _optionalChain([schemas, 'access', _3 => _3.pathParams, 'optionalAccess', _4 => _4.name]), _optionalChain([schemas, 'access', _5 => _5.queryParams, 'optionalAccess', _6 => _6.name]), _optionalChain([schemas, 'access', _7 => _7.headerParams, 'optionalAccess', _8 => _8.name])].filter(Boolean),
88
86
  root: file.path,
89
87
  path: fileType.path,
90
88
  isTypeOnly: true
91
89
  }
92
90
  ),
93
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children })
94
- ] }) });
91
+ children
92
+ ] });
95
93
  }
96
94
  var defaultTemplates = { default: Template, root: RootTemplate };
97
95
  function Client({ baseURL, Template: Template3 = defaultTemplates.default }) {
@@ -171,7 +169,7 @@ function Template2({ name, operations }) {
171
169
  method: operation.method
172
170
  };
173
171
  });
174
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) });
172
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
175
173
  }
176
174
  function RootTemplate2({ children }) {
177
175
  const {
@@ -179,7 +177,7 @@ function RootTemplate2({ children }) {
179
177
  plugin: { key: pluginKey }
180
178
  } = _react.useApp.call(void 0, );
181
179
  const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
182
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, exportable: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children }) }) });
180
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children });
183
181
  }
184
182
  var defaultTemplates2 = { default: Template2, root: RootTemplate2 };
185
183
  function Operations({ baseURL, Template: Template3 = defaultTemplates2.default }) {
@@ -198,4 +196,4 @@ Operations.templates = defaultTemplates2;
198
196
 
199
197
 
200
198
  exports.Client = Client; exports.Operations = Operations;
201
- //# sourceMappingURL=chunk-W7F5CMU6.cjs.map
199
+ //# sourceMappingURL=chunk-BEM4SQUR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-BEM4SQUR.cjs","../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["Template","RootTemplate","URLPath","jsx","File","useApp","defaultTemplates"],"mappings":"AAAA;ACAA,yCAAwB;AACxB,oCAAuC;AACvC,2CAA6B;AAC7B,+CAAkD;AAClD,gDAA2C;AAE3C,gCAA2B;AA6GrB,qDAAA;AAnEN,SAAS,QAAA,CAAS,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAO,OAAO,CAAA,EAA4B;AAChG,EAAA,MAAM,WAAA,EAAa,MAAA,CAAO,YAAA,IAAgB,qBAAA;AAC1C,EAAA,MAAM,QAAA,EAAU;AAAA,IACd,MAAA,CAAO,YAAA,IAAgB,mBAAA,EAAqB,CAAA,iBAAA,EAAoB,MAAA,CAAO,WAAW,CAAA,CAAA,EAAA,EAAM,KAAA,CAAA;AAAA,IACxF,MAAA,CAAO,YAAA,EAAc,aAAA,EAAe,KAAA;AAAA,EACtC,CAAA,CACG,MAAA,CAAO,OAAO,CAAA,CACd,IAAA,CAAK,I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uBACEE,6BAAAA,aAACF,EAAA,EACC,QAAA,kBAAAE,6BAAAA,UAAC,EAAA,EAAW,OAAA,EAAkB,QAAA,EAAUH,UAAAA,CAAU,EAAA,CACpD,CAAA;AAEJ,CAAA;AAEA,UAAA,CAAW,UAAA,EAAYM,iBAAAA;AFoGvB;AACA;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-BEM4SQUR.cjs","sourcesContent":[null,"import { URLPath } from '@kubb/core/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\n\nimport { isOptional } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: Params\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n baseURL: string | undefined\n generics: string | string[]\n method: HttpMethod\n path: URLPath\n dataReturnType: PluginClient['options']['dataReturnType']\n withQueryParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client }: TemplateProps): KubbNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n const clientParams: Params = {\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(client.method),\n },\n url: {\n type: 'string',\n value: client.path.template,\n },\n baseURL: client.baseURL\n ? {\n type: 'string',\n value: JSON.stringify(client.baseURL),\n }\n : undefined,\n params: client.withQueryParams\n ? {\n type: 'any',\n }\n : undefined,\n data: client.withData\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {formData || ''}\n <Function.Call name=\"res\" to={<Function name=\"client\" async generics={client.generics} params={clientParams} />} />\n <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n plugin: {\n options: {\n client: { importPath },\n },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n {children}\n </File>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype ClientProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Client({ baseURL, Template = defaultTemplates.default }: ClientProps): KubbNode {\n const {\n plugin: {\n options: { client, dataReturnType, pathParamsType },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const contentType = operation.getContentType()\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Template\n name={name}\n params={{\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(schemas.pathParams, { typed: true }),\n },\n data: schemas.request?.name\n ? {\n type: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n type: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n type: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n }}\n returnType={dataReturnType === 'data' ? `ResponseConfig<${schemas.response.name}>[\"data\"]` : `ResponseConfig<${schemas.response.name}>`}\n JSDoc={{\n comments: getComments(operation),\n }}\n client={{\n // only set baseURL from serverIndex(swagger) when no custom client(default) is used\n baseURL: client.importPath === '@kubb/plugin-client/client' ? baseURL : undefined,\n generics: [schemas.response.name, schemas.request?.name].filter(Boolean),\n dataReturnType,\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n contentType,\n }}\n />\n )\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nClient.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Client baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nClient.templates = defaultTemplates\n","import { URLPath } from '@kubb/core/utils'\nimport { useOperations } from '@kubb/plugin-oas/hooks'\nimport { Const, File, useApp } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n operations: Operation[]\n baseURL: string | undefined\n}\n\nfunction Template({ name, operations }: TemplateProps): KubbNode {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n return (\n <File.Source name={name} isExportable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginClient>()\n const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {children}\n </File>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Operations({ baseURL, Template = defaultTemplates.default }: Props): KubbNode {\n const operations = useOperations()\n\n return <Template baseURL={baseURL} name=\"operations\" operations={operations} />\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"]}
@@ -1,6 +1,6 @@
1
1
  // src/components/Client.tsx
2
2
  import { URLPath } from "@kubb/core/utils";
3
- import { Parser, File, Function, useApp } from "@kubb/react";
3
+ import { File, Function, useApp } from "@kubb/react";
4
4
  import { pluginTsName } from "@kubb/plugin-ts";
5
5
  import { useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
6
6
  import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
@@ -57,18 +57,17 @@ function Template({ name, generics, returnType, params, JSDoc, client }) {
57
57
  })
58
58
  }
59
59
  ` : void 0;
60
- return /* @__PURE__ */ jsxs(Function, { name, async: true, export: true, generics, returnType, params, JSDoc, children: [
60
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, children: /* @__PURE__ */ jsxs(Function, { name, async: true, export: true, generics, returnType, params, JSDoc, children: [
61
61
  formData || "",
62
62
  /* @__PURE__ */ jsx(Function.Call, { name: "res", to: /* @__PURE__ */ jsx(Function, { name: "client", async: true, generics: client.generics, params: clientParams }) }),
63
63
  /* @__PURE__ */ jsx(Function.Return, { children: client.dataReturnType === "data" ? "res.data" : "res" })
64
- ] });
64
+ ] }) });
65
65
  }
66
66
  function RootTemplate({ children }) {
67
67
  const {
68
68
  plugin: {
69
69
  options: {
70
- client: { importPath },
71
- extName
70
+ client: { importPath }
72
71
  }
73
72
  }
74
73
  } = useApp();
@@ -77,21 +76,20 @@ function RootTemplate({ children }) {
77
76
  const file = getFile(operation);
78
77
  const fileType = getFile(operation, { pluginKey: [pluginTsName] });
79
78
  const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
80
- return /* @__PURE__ */ jsx(Parser, { language: "typescript", children: /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
79
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
81
80
  /* @__PURE__ */ jsx(File.Import, { name: "client", path: importPath }),
82
81
  /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
83
82
  /* @__PURE__ */ jsx(
84
83
  File.Import,
85
84
  {
86
- extName,
87
85
  name: [schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean),
88
86
  root: file.path,
89
87
  path: fileType.path,
90
88
  isTypeOnly: true
91
89
  }
92
90
  ),
93
- /* @__PURE__ */ jsx(File.Source, { children })
94
- ] }) });
91
+ children
92
+ ] });
95
93
  }
96
94
  var defaultTemplates = { default: Template, root: RootTemplate };
97
95
  function Client({ baseURL, Template: Template3 = defaultTemplates.default }) {
@@ -161,7 +159,7 @@ Client.templates = defaultTemplates;
161
159
  // src/components/Operations.tsx
162
160
  import { URLPath as URLPath2 } from "@kubb/core/utils";
163
161
  import { useOperations } from "@kubb/plugin-oas/hooks";
164
- import { Const, File as File2, Parser as Parser2, useApp as useApp2 } from "@kubb/react";
162
+ import { Const, File as File2, useApp as useApp2 } from "@kubb/react";
165
163
  import { jsx as jsx2 } from "@kubb/react/jsx-runtime";
166
164
  function Template2({ name, operations }) {
167
165
  const operationsObject = {};
@@ -171,7 +169,7 @@ function Template2({ name, operations }) {
171
169
  method: operation.method
172
170
  };
173
171
  });
174
- return /* @__PURE__ */ jsx2(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) });
172
+ return /* @__PURE__ */ jsx2(File2.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx2(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
175
173
  }
176
174
  function RootTemplate2({ children }) {
177
175
  const {
@@ -179,7 +177,7 @@ function RootTemplate2({ children }) {
179
177
  plugin: { key: pluginKey }
180
178
  } = useApp2();
181
179
  const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
182
- return /* @__PURE__ */ jsx2(Parser2, { language: "typescript", children: /* @__PURE__ */ jsx2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, exportable: false, children: /* @__PURE__ */ jsx2(File2.Source, { children }) }) });
180
+ return /* @__PURE__ */ jsx2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children });
183
181
  }
184
182
  var defaultTemplates2 = { default: Template2, root: RootTemplate2 };
185
183
  function Operations({ baseURL, Template: Template3 = defaultTemplates2.default }) {
@@ -198,4 +196,4 @@ export {
198
196
  Client,
199
197
  Operations
200
198
  };
201
- //# sourceMappingURL=chunk-W57BRY5O.js.map
199
+ //# sourceMappingURL=chunk-IQZOOJUP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\n\nimport { isOptional } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: Params\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n baseURL: string | undefined\n generics: string | string[]\n method: HttpMethod\n path: URLPath\n dataReturnType: PluginClient['options']['dataReturnType']\n withQueryParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client }: TemplateProps): KubbNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n const clientParams: Params = {\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(client.method),\n },\n url: {\n type: 'string',\n value: client.path.template,\n },\n baseURL: client.baseURL\n ? {\n type: 'string',\n value: JSON.stringify(client.baseURL),\n }\n : undefined,\n params: client.withQueryParams\n ? {\n type: 'any',\n }\n : undefined,\n data: client.withData\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {formData || ''}\n <Function.Call name=\"res\" to={<Function name=\"client\" async generics={client.generics} params={clientParams} />} />\n <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n plugin: {\n options: {\n client: { importPath },\n },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n {children}\n </File>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype ClientProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Client({ baseURL, Template = defaultTemplates.default }: ClientProps): KubbNode {\n const {\n plugin: {\n options: { client, dataReturnType, pathParamsType },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const contentType = operation.getContentType()\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Template\n name={name}\n params={{\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(schemas.pathParams, { typed: true }),\n },\n data: schemas.request?.name\n ? {\n type: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n type: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n type: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n }}\n returnType={dataReturnType === 'data' ? `ResponseConfig<${schemas.response.name}>[\"data\"]` : `ResponseConfig<${schemas.response.name}>`}\n JSDoc={{\n comments: getComments(operation),\n }}\n client={{\n // only set baseURL from serverIndex(swagger) when no custom client(default) is used\n baseURL: client.importPath === '@kubb/plugin-client/client' ? baseURL : undefined,\n generics: [schemas.response.name, schemas.request?.name].filter(Boolean),\n dataReturnType,\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n contentType,\n }}\n />\n )\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nClient.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Client baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nClient.templates = defaultTemplates\n","import { URLPath } from '@kubb/core/utils'\nimport { useOperations } from '@kubb/plugin-oas/hooks'\nimport { Const, File, useApp } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n operations: Operation[]\n baseURL: string | undefined\n}\n\nfunction Template({ name, operations }: TemplateProps): KubbNode {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n return (\n <File.Source name={name} isExportable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginClient>()\n const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {children}\n </File>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Operations({ baseURL, Template = defaultTemplates.default }: Props): KubbNode {\n const operations = useOperations()\n\n return <Template baseURL={baseURL} name=\"operations\" operations={operations} />\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,MAAM,UAAU,cAAc;AACvC,SAAS,oBAAoB;AAC7B,SAAS,cAAc,2BAA2B;AAClD,SAAS,aAAa,qBAAqB;AAE3C,SAAS,kBAAkB;AA6GrB,SAEgC,KAFhC;AAnEN,SAAS,SAAS,EAAE,MAAM,UAAU,YAAY,QAAQ,OAAO,OAAO,GAA4B;AAChG,QAAM,aAAa,OAAO,gBAAgB;AAC1C,QAAM,UAAU;AAAA,IACd,OAAO,gBAAgB,qBAAqB,oBAAoB,OAAO,WAAW,MAAM;AAAA,IACxF,OAAO,cAAc,eAAe;AAAA,EACtC,EACG,OAAO,OAAO,EACd,KAAK,IAAI;AACZ,QAAM,eAAuB;AAAA,IAC3B,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,QACR,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,OAAO,KAAK,UAAU,OAAO,MAAM;AAAA,QACrC;AAAA,QACA,KAAK;AAAA,UACH,MAAM;AAAA,UACN,OAAO,OAAO,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tE,QAAM,YAAY,EAAE,GAAGE,mBAAkB,GAAG,MAAM,UAAU;AAE5D,QAAMF,YAAW,UAAU;AAC3B,QAAMC,gBAAe,UAAU;AAE/B,SACE,gBAAAF,KAACE,eAAA,EACC,0BAAAF,KAAC,cAAW,SAAkB,UAAUC,WAAU,GACpD;AAEJ;AAEA,WAAW,YAAYE;","names":["Template","RootTemplate","URLPath","File","useApp","jsx","Template","RootTemplate","defaultTemplates"]}
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
4
+ var _chunkBEM4SQURcjs = require('./chunk-BEM4SQUR.cjs');
5
5
 
6
6
 
7
7
 
8
- exports.Client = _chunkW7F5CMU6cjs.Client; exports.Operations = _chunkW7F5CMU6cjs.Operations;
8
+ exports.Client = _chunkBEM4SQURcjs.Client; exports.Operations = _chunkBEM4SQURcjs.Operations;
9
9
  //# sourceMappingURL=components.cjs.map
@@ -1,8 +1,8 @@
1
- export { C as Client, a as Operations } from './types-qg0fig71.cjs';
1
+ export { C as Client, a as Operations } from './types-D0SVMVnj.cjs';
2
2
  import '@kubb/core';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/plugin-oas';
5
5
  import '@kubb/core/utils';
6
6
  import '@kubb/oas';
7
- import '@kubb/react';
7
+ import '@kubb/react/types';
8
8
  import 'react';
@@ -1,8 +1,8 @@
1
- export { C as Client, a as Operations } from './types-qg0fig71.js';
1
+ export { C as Client, a as Operations } from './types-D0SVMVnj.js';
2
2
  import '@kubb/core';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/plugin-oas';
5
5
  import '@kubb/core/utils';
6
6
  import '@kubb/oas';
7
- import '@kubb/react';
7
+ import '@kubb/react/types';
8
8
  import 'react';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Client,
3
3
  Operations
4
- } from "./chunk-W57BRY5O.js";
4
+ } from "./chunk-IQZOOJUP.js";
5
5
  export {
6
6
  Client,
7
7
  Operations
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
4
+ var _chunkBEM4SQURcjs = require('./chunk-BEM4SQUR.cjs');
5
5
 
6
6
  // src/plugin.ts
7
7
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
@@ -9,7 +9,6 @@ var _core = require('@kubb/core');
9
9
  var _transformers = require('@kubb/core/transformers');
10
10
  var _utils = require('@kubb/core/utils');
11
11
  var _pluginoas = require('@kubb/plugin-oas');
12
- var _utils3 = require('@kubb/plugin-oas/utils');
13
12
 
14
13
  // src/OperationGenerator.tsx
15
14
 
@@ -22,14 +21,14 @@ var clientParser = _pluginoas.createReactParser.call(void 0, {
22
21
  if (!options.templates.operations) {
23
22
  return null;
24
23
  }
25
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
24
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkBEM4SQURcjs.Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
26
25
  },
27
26
  Operation({ options, operation }) {
28
27
  const isEnabled = options.client.methods.some((method) => operation.method === method);
29
28
  if (!options.templates.client || !isEnabled) {
30
29
  return null;
31
30
  }
32
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Client.File, { baseURL: options.baseURL, templates: options.templates.client });
31
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkBEM4SQURcjs.Client.File, { baseURL: options.baseURL, templates: options.templates.client });
33
32
  }
34
33
  });
35
34
 
@@ -60,8 +59,8 @@ var pluginClient = _core.createPlugin.call(void 0, (options) => {
60
59
  },
61
60
  pathParamsType,
62
61
  templates: {
63
- operations: _chunkW7F5CMU6cjs.Operations.templates,
64
- client: _chunkW7F5CMU6cjs.Client.templates,
62
+ operations: _chunkBEM4SQURcjs.Operations.templates,
63
+ client: _chunkBEM4SQURcjs.Client.templates,
65
64
  ...templates
66
65
  },
67
66
  baseURL: void 0
@@ -110,34 +109,16 @@ var pluginClient = _core.createPlugin.call(void 0, (options) => {
110
109
  );
111
110
  const files = await operationGenerator.build(clientParser);
112
111
  await this.addFile(...files);
113
- if (this.config.output.write && _optionalChain([group, 'optionalAccess', _6 => _6.type]) === "tag") {
114
- const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
115
- logger: this.logger,
112
+ if (this.config.output.write) {
113
+ const indexFiles = await this.fileManager.getIndexFiles({
114
+ root,
115
+ output,
116
116
  files: this.fileManager.files,
117
117
  plugin: this.plugin,
118
- template,
119
- exportAs: group.exportAs || "{{tag}}Service",
120
- root,
121
- output
118
+ logger: this.logger
122
119
  });
123
- await this.addFile(...rootFiles);
120
+ await this.addFile(...indexFiles);
124
121
  }
125
- },
126
- async buildEnd() {
127
- if (this.config.output.write === false) {
128
- return;
129
- }
130
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
131
- const files = await this.fileManager.getIndexFiles({
132
- root,
133
- output,
134
- meta: { pluginKey: this.plugin.key },
135
- logger: this.logger
136
- });
137
- await this.fileManager.processFiles({
138
- logger: this.logger,
139
- files
140
- });
141
122
  }
142
123
  };
143
124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AACT,UAAA;AACW,UAAA;AACX,UAAA;AACb,UAAA;AAC4B,UAAA;AAC5B,UAAA;AACA,UAAA;AACD,QAAA;AAE8B,QAAA;AACjC,MAAA;AACF,IAAA;AACiB,IAAA;AACyB,MAAA;AACtC,QAAA;AACF,MAAA;AAE4C,MAAA;AACP,MAAA;AACnC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AAEmC,MAAA;AACrB,QAAA;AACb,QAAA;AACD,MAAA;AACH,IAAA;AACF,EAAA;AACD;ADCkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n\n if (this.config.output.write && group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Service',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const files = await this.fileManager.getIndexFiles({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n\n await this.fileManager.processFiles({\n logger: this.logger,\n files,\n })\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAA0B;AAC1B,yCAA+B;AAC/B,6CAAkD;ADMlD;AACA;AEZA;AACA,uCAAoB;AACpB,uBAAgC;AAerB,qDAAA;AAPJ,IAAM,aAAA,EAAe,0CAAA;AAAgC,EAC1D,IAAA,EAAM,eAAA;AAAA,EACN,UAAA,CAAW,EAAE,QAAQ,CAAA,EAAG;AACtB,IAAA,GAAA,CAAI,CAAC,OAAA,CAAQ,SAAA,CAAU,UAAA,EAAY;AACjC,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,uBAAO,6BAAA,4BAAC,CAAW,IAAA,EAAX,EAAgB,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,SAAA,EAAW,OAAA,CAAQ,SAAA,CAAU,WAAA,CAAY,CAAA;AAAA,EAC7F,CAAA;AAAA,EACA,SAAA,CAAU,EAAE,OAAA,EAAS,UAAU,CAAA,EAAG;AAChC,IAAA,MAAM,UAAA,EAAY,OAAA,CAAQ,MAAA,CAAO,OA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,MAAA;AAEuC,MAAA;AACzC,IAAA;AACwB,IAAA;AACiB,MAAA;AAE7B,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AACmB,IAAA;AACqD,MAAA;AAE9B,MAAA;AACI,MAAA;AACN,MAAA;AACM,MAAA;AAEb,MAAA;AAC7B,QAAA;AACiB,UAAA;AACf,UAAA;AACF,QAAA;AACA,QAAA;AACE,UAAA;AACoB,UAAA;AACP,UAAA;AACsB,UAAA;AACnC,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACF,QAAA;AACF,MAAA;AAE6C,MAAA;AAElB,MAAA;AAEG,MAAA;AACc,QAAA;AACxC,UAAA;AACA,UAAA;AACwB,UAAA;AACX,UAAA;AACA,UAAA;AACd,QAAA;AAE+B,QAAA;AAClC,MAAA;AACF,IAAA;AACF,EAAA;AACD;ADGkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n\n if (this.config.output.write) {\n const indexFiles = await this.fileManager.getIndexFiles({\n root,\n output,\n files: this.fileManager.files,\n plugin: this.plugin,\n logger: this.logger,\n })\n\n await this.addFile(...indexFiles)\n }\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"]}
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-qg0fig71.cjs';
2
+ import { O as Options, P as PluginClient } from './types-D0SVMVnj.cjs';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/plugin-oas';
5
5
  import '@kubb/core/utils';
6
6
  import '@kubb/oas';
7
- import '@kubb/react';
7
+ import '@kubb/react/types';
8
8
  import 'react';
9
9
 
10
10
  declare const pluginClientName = "plugin-client";
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-qg0fig71.js';
2
+ import { O as Options, P as PluginClient } from './types-D0SVMVnj.js';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/plugin-oas';
5
5
  import '@kubb/core/utils';
6
6
  import '@kubb/oas';
7
- import '@kubb/react';
7
+ import '@kubb/react/types';
8
8
  import 'react';
9
9
 
10
10
  declare const pluginClientName = "plugin-client";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Client,
3
3
  Operations
4
- } from "./chunk-W57BRY5O.js";
4
+ } from "./chunk-IQZOOJUP.js";
5
5
 
6
6
  // src/plugin.ts
7
7
  import path from "path";
@@ -9,7 +9,6 @@ import { FileManager, PluginManager, createPlugin } from "@kubb/core";
9
9
  import { camelCase } from "@kubb/core/transformers";
10
10
  import { renderTemplate } from "@kubb/core/utils";
11
11
  import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
12
- import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
13
12
 
14
13
  // src/OperationGenerator.tsx
15
14
  import { createReactParser } from "@kubb/plugin-oas";
@@ -110,34 +109,16 @@ var pluginClient = createPlugin((options) => {
110
109
  );
111
110
  const files = await operationGenerator.build(clientParser);
112
111
  await this.addFile(...files);
113
- if (this.config.output.write && group?.type === "tag") {
114
- const rootFiles = await getGroupedByTagFiles({
115
- logger: this.logger,
112
+ if (this.config.output.write) {
113
+ const indexFiles = await this.fileManager.getIndexFiles({
114
+ root,
115
+ output,
116
116
  files: this.fileManager.files,
117
117
  plugin: this.plugin,
118
- template,
119
- exportAs: group.exportAs || "{{tag}}Service",
120
- root,
121
- output
118
+ logger: this.logger
122
119
  });
123
- await this.addFile(...rootFiles);
120
+ await this.addFile(...indexFiles);
124
121
  }
125
- },
126
- async buildEnd() {
127
- if (this.config.output.write === false) {
128
- return;
129
- }
130
- const root = path.resolve(this.config.root, this.config.output.path);
131
- const files = await this.fileManager.getIndexFiles({
132
- root,
133
- output,
134
- meta: { pluginKey: this.plugin.key },
135
- logger: this.logger
136
- });
137
- await this.fileManager.processFiles({
138
- logger: this.logger,
139
- files
140
- });
141
122
  }
142
123
  };
143
124
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n\n if (this.config.output.write && group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Service',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const files = await this.fileManager.getIndexFiles({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n\n await this.fileManager.processFiles({\n logger: this.logger,\n files,\n })\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"],"mappings":";;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,qBAAqB;AAClD,SAAS,4BAA4B;;;ACNrC,SAAS,yBAA0D;AACnE,OAAoB;AACpB,OAAgC;AAerB;AAPJ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AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,YAAM,QAAQ,MAAM,mBAAmB,MAAM,YAAY;AAEzD,YAAM,KAAK,QAAQ,GAAG,KAAK;AAE3B,UAAI,KAAK,OAAO,OAAO,SAAS,OAAO,SAAS,OAAO;AACrD,cAAM,YAAY,MAAM,qBAAqB;AAAA,UAC3C,QAAQ,KAAK;AAAA,UACb,OAAO,KAAK,YAAY;AAAA,UACxB,QAAQ,KAAK;AAAA,UACb;AAAA,UACA,UAAU,MAAM,YAAY;AAAA,UAC5B;AAAA,UACA;AAAA,QACF,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,SAAS;AAAA,MACjC;AAAA,IACF;AAAA,IACA,MAAM,WAAW;AACf,UAAI,KAAK,OAAO,OAAO,UAAU,OAAO;AACtC;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,YAAM,QAAQ,MAAM,KAAK,YAAY,cAAc;AAAA,QACjD;AAAA,QACA;AAAA,QACA,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,QACnC,QAAQ,KAAK;AAAA,MACf,CAAC;AAED,YAAM,KAAK,YAAY,aAAa;AAAA,QAClC,QAAQ,KAAK;AAAA,QACb;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":["options"]}
1
+ {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n\n if (this.config.output.write) {\n const indexFiles = await this.fileManager.getIndexFiles({\n root,\n output,\n files: this.fileManager.files,\n plugin: this.plugin,\n logger: this.logger,\n })\n\n await this.addFile(...indexFiles)\n }\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"],"mappings":";;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,qBAAqB;;;ACLlD,SAAS,yBAA0D;AACnE,OAAoB;AACpB,OAAgC;AAerB;AAPJ,IAAM,eAAe,kBAAgC;AAAA,EAC1D,MAAM;AAAA,EACN,WAAW,EAAE,QAAQ,GAAG;AACtB,QAAI,CAAC,QAAQ,UAAU,YAAY;AACjC,aAAO;AAAA,IACT;AAEA,WAAO,oBAAC,WAAW,MAAX,EAAgB,SAAS,QAAQ,SAAS,WAAW,QAAQ,UAAU,YAAY;AAAA,EAC7F;AAAA,EACA,UAAU,EAAE,SAAS,UAAU,GAAG;AAChC,UAAM,YAAY,QAAQ,OAAO,QAAQ,KAAK,CAAC,WAAW,UAAU,WAAW,MAA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AAU;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["options"]}
@@ -3,7 +3,7 @@ import * as KubbFile from '@kubb/fs/types';
3
3
  import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
4
  import { URLPath } from '@kubb/core/utils';
5
5
  import { HttpMethod, Operation } from '@kubb/oas';
6
- import { KubbNode, Params } from '@kubb/react';
6
+ import { KubbNode, Params } from '@kubb/react/types';
7
7
  import { ComponentType, ComponentProps } from 'react';
8
8
 
9
9
  type TemplateProps$1 = {
@@ -3,7 +3,7 @@ import * as KubbFile from '@kubb/fs/types';
3
3
  import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
4
  import { URLPath } from '@kubb/core/utils';
5
5
  import { HttpMethod, Operation } from '@kubb/oas';
6
- import { KubbNode, Params } from '@kubb/react';
6
+ import { KubbNode, Params } from '@kubb/react/types';
7
7
  import { ComponentType, ComponentProps } from 'react';
8
8
 
9
9
  type TemplateProps$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "Generator plugin-client",
5
5
  "keywords": [
6
6
  "typescript",
@@ -64,13 +64,13 @@
64
64
  "!/**/__tests__/**"
65
65
  ],
66
66
  "dependencies": {
67
- "@kubb/core": "3.0.0-alpha.4",
68
- "@kubb/fs": "3.0.0-alpha.4",
69
- "@kubb/oas": "3.0.0-alpha.4",
70
- "@kubb/parser-ts": "3.0.0-alpha.4",
71
- "@kubb/plugin-oas": "3.0.0-alpha.4",
72
- "@kubb/plugin-ts": "3.0.0-alpha.4",
73
- "@kubb/react": "3.0.0-alpha.4"
67
+ "@kubb/core": "3.0.0-alpha.6",
68
+ "@kubb/fs": "3.0.0-alpha.6",
69
+ "@kubb/oas": "3.0.0-alpha.6",
70
+ "@kubb/parser-ts": "3.0.0-alpha.6",
71
+ "@kubb/plugin-oas": "3.0.0-alpha.6",
72
+ "@kubb/plugin-ts": "3.0.0-alpha.6",
73
+ "@kubb/react": "3.0.0-alpha.6"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/react": "^18.3.4",
@@ -78,13 +78,13 @@
78
78
  "react": "^18.3.1",
79
79
  "tsup": "^8.2.4",
80
80
  "typescript": "^5.5.4",
81
- "@kubb/config-biome": "3.0.0-alpha.4",
82
- "@kubb/config-ts": "3.0.0-alpha.4",
83
- "@kubb/config-tsup": "3.0.0-alpha.4"
81
+ "@kubb/config-biome": "3.0.0-alpha.6",
82
+ "@kubb/config-ts": "3.0.0-alpha.6",
83
+ "@kubb/config-tsup": "3.0.0-alpha.6"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "axios": "^1.7.2",
87
- "@kubb/react": "3.0.0-alpha.4"
87
+ "@kubb/react": "3.0.0-alpha.6"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "axios": {
@@ -1,12 +1,12 @@
1
1
  import { URLPath } from '@kubb/core/utils'
2
- import { Parser, File, Function, useApp } from '@kubb/react'
2
+ import { File, Function, useApp } from '@kubb/react'
3
3
  import { pluginTsName } from '@kubb/plugin-ts'
4
4
  import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
5
5
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
6
6
 
7
7
  import { isOptional } from '@kubb/oas'
8
8
  import type { HttpMethod } from '@kubb/oas'
9
- import type { KubbNode, Params } from '@kubb/react'
9
+ import type { KubbNode, Params } from '@kubb/react/types'
10
10
  import type { ComponentProps, ComponentType } from 'react'
11
11
  import type { FileMeta, PluginClient } from '../types.ts'
12
12
 
@@ -112,11 +112,13 @@ function Template({ name, generics, returnType, params, JSDoc, client }: Templat
112
112
  : undefined
113
113
 
114
114
  return (
115
- <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
116
- {formData || ''}
117
- <Function.Call name="res" to={<Function name="client" async generics={client.generics} params={clientParams} />} />
118
- <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>
119
- </Function>
115
+ <File.Source name={name} isExportable>
116
+ <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
117
+ {formData || ''}
118
+ <Function.Call name="res" to={<Function name="client" async generics={client.generics} params={clientParams} />} />
119
+ <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>
120
+ </Function>
121
+ </File.Source>
120
122
  )
121
123
  }
122
124
 
@@ -129,7 +131,6 @@ function RootTemplate({ children }: RootTemplateProps) {
129
131
  plugin: {
130
132
  options: {
131
133
  client: { importPath },
132
- extName,
133
134
  },
134
135
  },
135
136
  } = useApp<PluginClient>()
@@ -142,20 +143,17 @@ function RootTemplate({ children }: RootTemplateProps) {
142
143
  const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })
143
144
 
144
145
  return (
145
- <Parser language="typescript">
146
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
147
- <File.Import name={'client'} path={importPath} />
148
- <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />
149
- <File.Import
150
- extName={extName}
151
- name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}
152
- root={file.path}
153
- path={fileType.path}
154
- isTypeOnly
155
- />
156
- <File.Source>{children}</File.Source>
157
- </File>
158
- </Parser>
146
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
147
+ <File.Import name={'client'} path={importPath} />
148
+ <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />
149
+ <File.Import
150
+ name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}
151
+ root={file.path}
152
+ path={fileType.path}
153
+ isTypeOnly
154
+ />
155
+ {children}
156
+ </File>
159
157
  )
160
158
  }
161
159
 
@@ -1,9 +1,9 @@
1
1
  import { URLPath } from '@kubb/core/utils'
2
2
  import { useOperations } from '@kubb/plugin-oas/hooks'
3
- import { Const, File, Parser, useApp } from '@kubb/react'
3
+ import { Const, File, useApp } from '@kubb/react'
4
4
 
5
5
  import type { HttpMethod, Operation } from '@kubb/oas'
6
- import type { KubbNode } from '@kubb/react'
6
+ import type { KubbNode } from '@kubb/react/types'
7
7
  import type { ComponentProps, ComponentType } from 'react'
8
8
  import type { FileMeta, PluginClient } from '../types.ts'
9
9
 
@@ -26,9 +26,11 @@ function Template({ name, operations }: TemplateProps): KubbNode {
26
26
  }
27
27
  })
28
28
  return (
29
- <Const name={name} export asConst>
30
- {JSON.stringify(operationsObject, undefined, 2)}
31
- </Const>
29
+ <File.Source name={name} isExportable>
30
+ <Const name={name} export asConst>
31
+ {JSON.stringify(operationsObject, undefined, 2)}
32
+ </Const>
33
+ </File.Source>
32
34
  )
33
35
  }
34
36
 
@@ -44,11 +46,9 @@ function RootTemplate({ children }: RootTemplateProps) {
44
46
  const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })
45
47
 
46
48
  return (
47
- <Parser language="typescript">
48
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta} exportable={false}>
49
- <File.Source>{children}</File.Source>
50
- </File>
51
- </Parser>
49
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
50
+ {children}
51
+ </File>
52
52
  )
53
53
  }
54
54
 
@@ -2,10 +2,7 @@
2
2
  * @summary Info for a specific pet
3
3
  * @link /pets/:pet_id
4
4
  */
5
- export async function showPetById(
6
- { petId, testId }: { petId: ShowPetByIdPathParams['pet_id']; testId: ShowPetByIdPathParams['testId'] },
7
- options: Partial<Parameters<typeof client>[0]> = {},
8
- ): Promise<ResponseConfig<ShowPetByIdQueryResponse>['data']> {
9
- const res = await client<ShowPetByIdQueryResponse>({ method: 'get', url: `/pets/${petId}`, ...options })
5
+ export async function showPetById({ petId, testId }: { petId: ShowPetByIdPathParams["pet_id"]; testId: ShowPetByIdPathParams["testId"] }, options: Partial<Parameters<typeof client>[0]> = {}): Promise<ResponseConfig<ShowPetByIdQueryResponse>["data"]> {
6
+ const res = await client<ShowPetByIdQueryResponse>({ method : "get", url : `/pets/${petId}`, ... options })
10
7
  return res.data
11
- }
8
+ }
@@ -1,6 +1,6 @@
1
1
  export const operations = {
2
- showPetById: {
3
- path: '/pets/:pet_id',
4
- method: 'get',
5
- },
6
- } as const
2
+ "showPetById": {
3
+ "path": "/pets/:pet_id",
4
+ "method": "get"
5
+ }
6
+ } as const
package/src/plugin.ts CHANGED
@@ -4,7 +4,6 @@ import { FileManager, PluginManager, createPlugin } from '@kubb/core'
4
4
  import { camelCase } from '@kubb/core/transformers'
5
5
  import { renderTemplate } from '@kubb/core/utils'
6
6
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
7
- import { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'
8
7
 
9
8
  import { clientParser } from './OperationGenerator.tsx'
10
9
  import { Client, Operations } from './components/index.ts'
@@ -107,37 +106,17 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
107
106
 
108
107
  await this.addFile(...files)
109
108
 
110
- if (this.config.output.write && group?.type === 'tag') {
111
- const rootFiles = await getGroupedByTagFiles({
112
- logger: this.logger,
113
- files: this.fileManager.files,
114
- plugin: this.plugin,
115
- template,
116
- exportAs: group.exportAs || '{{tag}}Service',
109
+ if (this.config.output.write) {
110
+ const indexFiles = await this.fileManager.getIndexFiles({
117
111
  root,
118
112
  output,
113
+ files: this.fileManager.files,
114
+ plugin: this.plugin,
115
+ logger: this.logger,
119
116
  })
120
117
 
121
- await this.addFile(...rootFiles)
122
- }
123
- },
124
- async buildEnd() {
125
- if (this.config.output.write === false) {
126
- return
118
+ await this.addFile(...indexFiles)
127
119
  }
128
-
129
- const root = path.resolve(this.config.root, this.config.output.path)
130
- const files = await this.fileManager.getIndexFiles({
131
- root,
132
- output,
133
- meta: { pluginKey: this.plugin.key },
134
- logger: this.logger,
135
- })
136
-
137
- await this.fileManager.processFiles({
138
- logger: this.logger,
139
- files,
140
- })
141
120
  },
142
121
  }
143
122
  })
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { Parser, File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\n\nimport { isOptional } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { KubbNode, Params } from '@kubb/react'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: Params\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n baseURL: string | undefined\n generics: string | string[]\n method: HttpMethod\n path: URLPath\n dataReturnType: PluginClient['options']['dataReturnType']\n withQueryParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client }: TemplateProps): KubbNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n const clientParams: Params = {\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(client.method),\n },\n url: {\n type: 'string',\n value: client.path.template,\n },\n baseURL: client.baseURL\n ? {\n type: 'string',\n value: JSON.stringify(client.baseURL),\n }\n : undefined,\n params: client.withQueryParams\n ? {\n type: 'any',\n }\n : undefined,\n data: client.withData\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {formData || ''}\n <Function.Call name=\"res\" to={<Function name=\"client\" async generics={client.generics} params={clientParams} />} />\n <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n plugin: {\n options: {\n client: { importPath },\n extName,\n },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n extName={extName}\n name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype ClientProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Client({ baseURL, Template = defaultTemplates.default }: ClientProps): KubbNode {\n const {\n plugin: {\n options: { client, dataReturnType, pathParamsType },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const contentType = operation.getContentType()\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Template\n name={name}\n params={{\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(schemas.pathParams, { typed: true }),\n },\n data: schemas.request?.name\n ? {\n type: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n type: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n type: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n }}\n returnType={dataReturnType === 'data' ? `ResponseConfig<${schemas.response.name}>[\"data\"]` : `ResponseConfig<${schemas.response.name}>`}\n JSDoc={{\n comments: getComments(operation),\n }}\n client={{\n // only set baseURL from serverIndex(swagger) when no custom client(default) is used\n baseURL: client.importPath === '@kubb/plugin-client/client' ? baseURL : undefined,\n generics: [schemas.response.name, schemas.request?.name].filter(Boolean),\n dataReturnType,\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n contentType,\n }}\n />\n )\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nClient.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Client baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nClient.templates = defaultTemplates\n","import { URLPath } from '@kubb/core/utils'\nimport { useOperations } from '@kubb/plugin-oas/hooks'\nimport { Const, File, Parser, useApp } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n operations: Operation[]\n baseURL: string | undefined\n}\n\nfunction Template({ name, operations }: TemplateProps): KubbNode {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n return (\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginClient>()\n const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta} exportable={false}>\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Operations({ baseURL, Template = defaultTemplates.default }: Props): KubbNode {\n const operations = useOperations()\n\n return <Template baseURL={baseURL} name=\"operations\" operations={operations} />\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,QAAQ,MAAM,UAAU,cAAc;AAC/C,SAAS,oBAAoB;AAC7B,SAAS,cAAc,2BAA2B;AAClD,SAAS,aAAa,qBAAqB;AAE3C,SAAS,kBAAkB;AA4GvB,SAEgC,KAFhC;AAlEJ,SAAS,SAAS,EAAE,MAAM,UAAU,YAAY,QAAQ,OAAO,OAAO,GAA4B;AAChG,QAAM,aAAa,OAAO,gBAAgB;AAC1C,QAAM,UAAU;AAAA,IACd,OAAO,gBAAgB,qBAAqB,oBAAoB,OAAO,WAAW,MAAM;AAAA,IACxF,OAAO,cAAc,eAAe;AAAA,EACtC,EACG,OAAO,OAAO,EACd,KAAK,IAAI;AACZ,QAAM,eAAuB;AAAA,IAC3B,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,QACR,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,OAAO,KAAK,UAAU,OAAO,MAAM;AAAA,QACrC;AAAA,QACA,KAAK;AAAA,UACH,MAAM;AAAA,UACN,OAAO,OAAO,KAAK;AAAA,QACrB;AAAA,QACA,SAAS,OAAO,UACZ;AAAA,UACE,MAAM;AAAA,UACN,OAAO,KAAK,UAAU,OAAO,OAAO;AAAA,QACtC,IACA;AAAA,QACJ,QAAQ,OAAO,kBACX;AAAA,UACE,MAAM;AAAA,QACR,IACA;AAAA,QACJ,MAAM,OAAO,WACT;AAAA,UACE,MAAM;AAAA,UACN,OAAO,aAAa,aAAa;AAAA,QACnC,IACA;AAAA,QACJ,SAAS,QAAQ,SACb;AAAA,UACE,MAAM;AAAA,UACN,OAAO,QAAQ,SAAS,KAAK,OAAO,2BAA2B;AAAA,QACjE,IACA;AAAA,QACJ,SAAS;AAAA,UACP,MAAM;AAAA,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AAAA,MAC7C,MAAM,IAAIL,SAAQ,UAAU,IAAI,EAAE;AAAA,MAClC,QAAQ,UAAU;AAAA,IACpB;AAAA,EACF,CAAC;AACD,SACE,gBAAAI,KAAC,SAAM,MAAY,QAAM,MAAC,SAAO,MAC9B,eAAK,UAAU,kBAAkB,QAAW,CAAC,GAChD;AAEJ;AAMA,SAASE,cAAa,EAAE,SAAS,GAAsB;AACrD,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ,EAAE,KAAK,UAAU;AAAA,EAC3B,IAAIH,QAAqB;AACzB,QAAM,OAAO,cAAc,QAAQ,EAAE,MAAM,cAAc,SAAS,OAAO,UAAU,CAAC;AAEpF,SACE,gBAAAC,KAACF,SAAA,EAAO,UAAS,cACf,0BAAAE,KAACH,OAAA,EAAe,UAAU,KAAK,UAAU,MAAM,KAAK,MAAM,MAAM,KAAK,MAAM,YAAY,OACrF,0BAAAG,KAACH,MAAK,QAAL,EAAa,UAAS,GACzB,GACF;AAEJ;AAEA,IAAMM,oBAAmB,EAAE,SAASF,WAAU,MAAMC,cAAa;AAY1D,SAAS,WAAW,EAAE,SAAS,UAAAD,YAAWE,kBAAiB,QAAQ,GAAoB;AAC5F,QAAM,aAAa,cAAc;AAEjC,SAAO,gBAAAH,KAACC,WAAA,EAAS,SAAkB,MAAK,cAAa,YAAwB;AAC/E;AAUA,WAAW,OAAO,SAAU,EAAE,SAAS,GAAG,MAAM,GAAwB;AACtE,QAAM,YAAY,EAAE,GAAGE,mBAAkB,GAAG,MAAM,UAAU;AAE5D,QAAMF,YAAW,UAAU;AAC3B,QAAMC,gBAAe,UAAU;AAE/B,SACE,gBAAAF,KAACE,eAAA,EACC,0BAAAF,KAAC,cAAW,SAAkB,UAAUC,WAAU,GACpD;AAEJ;AAEA,WAAW,YAAYE;","names":["Template","RootTemplate","URLPath","File","Parser","useApp","jsx","Template","RootTemplate","defaultTemplates"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-W7F5CMU6.cjs","../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["Template","RootTemplate","URLPath","jsx","useApp","Parser","File","defaultTemplates"],"mappings":"AAAA;ACAA,yCAAwB;AACxB,oCAA+C;AAC/C,2CAA6B;AAC7B,+CAAkD;AAClD,gDAA2C;AAE3C,gCAA2B;AA4GvB,qDAAA;AAlEJ,SAAS,QAAA,CAAS,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAO,OAAO,CAAA,EAA4B;AAChG,EAAA,MAAM,WAAA,EAAa,MAAA,CAAO,YAAA,IAAgB,qBAAA;AAC1C,EAAA,MAAM,QAAA,EAAU;AAAA,IACd,MAAA,CAAO,YAAA,IAAgB,mBAAA,EAAqB,CAAA,iBAAA,EAAoB,MAAA,CAAO,WAAW,CAAA,CAAA,EAAA,EAAM,KAAA,CAAA;AAAA,IACxF,MAAA,CAAO,YAAA,EAAc,aAAA,EAAe,KAAA;AAAA,EACtC,CAAA,CACG,MAAA,CAAO,OAAO,CAAA,CACd,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,aAAA,EAAuB;AAAA,IAC3B,IAAA,EAAM;AAAA,MACJ,IAAA,EAAM,QAAA;AAAA,MACN,QAAA,EAAU;AAAA,QACR,MAAA,EAAQ;AAAA,UACN,IAAA,EAAM,QAAA;AAAA,UACN,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,MAAM;AAAA,QACrC,CAAA;AAAA,QACA,GAAA,EAAK;AAAA,UACH,IAAA,EAAM,QAAA;AAAA,UACN,KAAA,EAAO,MAAA,CAAO,IAAA,CAAK;AAAA,QACrB,CAAA;AAAA,QACA,OAAA,EAAS,MAAA,CAAO,QAAA,EACZ;AAAA,UACE,IAAA,EAAM,QAAA;AAAA,UACN,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,OAAO;AAAA,QACtC,EAAA,EACA,KAAA,CAAA;AA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,EAAM,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,UAAA,EAAY,KAAA,EACrF,QAAA,kBAAAH,6BAAAA,WAACG,CAAK,MAAA,EAAL,EAAa,SAAA,CAAS,EAAA,CACzB,EAAA,CACF,CAAA;AAEJ;AAEA,IAAMC,kBAAAA,EAAmB,EAAE,OAAA,EAASP,SAAAA,EAAU,IAAA,EAAMC,cAAa,CAAA;AAY1D,SAAS,UAAA,CAAW,EAAE,OAAA,EAAS,QAAA,EAAAD,UAAAA,EAAWO,iBAAAA,CAAiB,QAAQ,CAAA,EAAoB;AAC5F,EAAA,MAAM,WAAA,EAAa,kCAAA,CAAc;AAEjC,EAAA,uBAAOJ,6BAAAA,SAACH,EAAA,EAAS,OAAA,EAAkB,IAAA,EAAK,YAAA,EAAa,WAAA,CAAwB,CAAA;AAC/E;AAUA,UAAA,CAAW,KAAA,EAAO,QAAA,CAAU,EAAE,OAAA,EAAS,GAAG,MAAM,CAAA,EAAwB;AACtE,EAAA,MAAM,UAAA,EAAY,EAAE,GAAGO,iBAAAA,EAAkB,GAAG,KAAA,CAAM,UAAU,CAAA;AAE5D,EAAA,MAAMP,UAAAA,EAAW,SAAA,CAAU,OAAA;AAC3B,EAAA,MAAMC,cAAAA,EAAe,SAAA,CAAU,IAAA;AAE/B,EAAA,uBACEE,6BAAAA,aAACF,EAAA,EACC,QAAA,kBAAAE,6BAAAA,UAAC,EAAA,EAAW,OAAA,EAAkB,QAAA,EAAUH,UAAAA,CAAU,EAAA,CACpD,CAAA;AAEJ,CAAA;AAEA,UAAA,CAAW,UAAA,EAAYO,iBAAAA;AFsGvB;AACA;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-W7F5CMU6.cjs","sourcesContent":[null,"import { URLPath } from '@kubb/core/utils'\nimport { Parser, File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\n\nimport { isOptional } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { KubbNode, Params } from '@kubb/react'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: Params\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n baseURL: string | undefined\n generics: string | string[]\n method: HttpMethod\n path: URLPath\n dataReturnType: PluginClient['options']['dataReturnType']\n withQueryParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client }: TemplateProps): KubbNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n const clientParams: Params = {\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(client.method),\n },\n url: {\n type: 'string',\n value: client.path.template,\n },\n baseURL: client.baseURL\n ? {\n type: 'string',\n value: JSON.stringify(client.baseURL),\n }\n : undefined,\n params: client.withQueryParams\n ? {\n type: 'any',\n }\n : undefined,\n data: client.withData\n ? {\n type: 'any',\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n type: 'any',\n value: headers.length ? `{ ${headers}, ...options.headers }` : undefined,\n }\n : undefined,\n options: {\n type: 'any',\n mode: 'inlineSpread',\n },\n },\n },\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {formData || ''}\n <Function.Call name=\"res\" to={<Function name=\"client\" async generics={client.generics} params={clientParams} />} />\n <Function.Return>{client.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n plugin: {\n options: {\n client: { importPath },\n extName,\n },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n extName={extName}\n name={[schemas.request?.name, schemas.response.name, schemas.pathParams?.name, schemas.queryParams?.name, schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype ClientProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Client({ baseURL, Template = defaultTemplates.default }: ClientProps): KubbNode {\n const {\n plugin: {\n options: { client, dataReturnType, pathParamsType },\n },\n } = useApp<PluginClient>()\n\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const contentType = operation.getContentType()\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n return (\n <Template\n name={name}\n params={{\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(schemas.pathParams, { typed: true }),\n },\n data: schemas.request?.name\n ? {\n type: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n type: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n type: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n }}\n returnType={dataReturnType === 'data' ? `ResponseConfig<${schemas.response.name}>[\"data\"]` : `ResponseConfig<${schemas.response.name}>`}\n JSDoc={{\n comments: getComments(operation),\n }}\n client={{\n // only set baseURL from serverIndex(swagger) when no custom client(default) is used\n baseURL: client.importPath === '@kubb/plugin-client/client' ? baseURL : undefined,\n generics: [schemas.response.name, schemas.request?.name].filter(Boolean),\n dataReturnType,\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n contentType,\n }}\n />\n )\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nClient.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Client baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nClient.templates = defaultTemplates\n","import { URLPath } from '@kubb/core/utils'\nimport { useOperations } from '@kubb/plugin-oas/hooks'\nimport { Const, File, Parser, useApp } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react'\nimport type { ComponentProps, ComponentType } from 'react'\nimport type { FileMeta, PluginClient } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n operations: Operation[]\n baseURL: string | undefined\n}\n\nfunction Template({ name, operations }: TemplateProps): KubbNode {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n return (\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginClient>()\n const file = pluginManager.getFile({ name: 'operations', extName: '.ts', pluginKey })\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta} exportable={false}>\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Operations({ baseURL, Template = defaultTemplates.default }: Props): KubbNode {\n const operations = useOperations()\n\n return <Template baseURL={baseURL} name=\"operations\" operations={operations} />\n}\n\ntype FileProps = {\n baseURL: string | undefined\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function ({ baseURL, ...props }: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations baseURL={baseURL} Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"]}