@kubb/plugin-client 3.0.0-alpha.2 → 3.0.0-alpha.20

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.
Files changed (63) hide show
  1. package/README.md +13 -4
  2. package/client.ts +2 -2
  3. package/dist/chunk-54CFYFPX.js +176 -0
  4. package/dist/chunk-54CFYFPX.js.map +1 -0
  5. package/dist/chunk-HGQQGWKN.js +130 -0
  6. package/dist/chunk-HGQQGWKN.js.map +1 -0
  7. package/dist/chunk-HUIJQCWL.cjs +185 -0
  8. package/dist/chunk-HUIJQCWL.cjs.map +1 -0
  9. package/dist/chunk-NEK3OJBX.cjs +133 -0
  10. package/dist/chunk-NEK3OJBX.cjs.map +1 -0
  11. package/dist/client.cjs +16 -7
  12. package/dist/client.cjs.map +1 -1
  13. package/dist/client.d.cts +2 -2
  14. package/dist/client.d.ts +2 -2
  15. package/dist/client.js +5 -6
  16. package/dist/client.js.map +1 -1
  17. package/dist/components.cjs +11 -4
  18. package/dist/components.cjs.map +1 -1
  19. package/dist/components.d.cts +37 -7
  20. package/dist/components.d.ts +37 -7
  21. package/dist/components.js +2 -8
  22. package/dist/components.js.map +1 -1
  23. package/dist/generators.cjs +17 -0
  24. package/dist/generators.cjs.map +1 -0
  25. package/dist/generators.d.cts +9 -0
  26. package/dist/generators.d.ts +9 -0
  27. package/dist/generators.js +4 -0
  28. package/dist/generators.js.map +1 -0
  29. package/dist/index.cjs +11 -156
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -6
  32. package/dist/index.d.ts +1 -6
  33. package/dist/index.js +3 -161
  34. package/dist/index.js.map +1 -1
  35. package/dist/types-xPfBu1CW.d.cts +96 -0
  36. package/dist/types-xPfBu1CW.d.ts +96 -0
  37. package/package.json +21 -16
  38. package/src/components/Client.tsx +110 -211
  39. package/src/components/Operations.tsx +9 -75
  40. package/src/generators/__snapshots__/deletePet.ts +13 -0
  41. package/src/generators/__snapshots__/deletePetObject.ts +15 -0
  42. package/src/generators/__snapshots__/findByTags.ts +13 -0
  43. package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
  44. package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
  45. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
  46. package/src/generators/__snapshots__/importPath.ts +13 -0
  47. package/src/generators/__snapshots__/operations.ts +82 -0
  48. package/src/generators/__snapshots__/updatePetById.ts +12 -0
  49. package/src/generators/clientGenerator.tsx +67 -0
  50. package/src/generators/index.ts +2 -0
  51. package/src/generators/operationsGenerator.tsx +26 -0
  52. package/src/plugin.ts +23 -40
  53. package/src/types.ts +24 -50
  54. package/dist/chunk-W57BRY5O.js +0 -201
  55. package/dist/chunk-W57BRY5O.js.map +0 -1
  56. package/dist/chunk-W7F5CMU6.cjs +0 -201
  57. package/dist/chunk-W7F5CMU6.cjs.map +0 -1
  58. package/dist/types-xK4X9e5d.d.cts +0 -228
  59. package/dist/types-xK4X9e5d.d.ts +0 -228
  60. package/src/OperationGenerator.tsx +0 -65
  61. package/src/components/__snapshots__/Client/showPetById.ts +0 -11
  62. package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
  63. package/src/components/__snapshots__/Query/showPetById.ts +0 -15
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@kubb/core/utils');
4
+ var oas = require('@kubb/oas');
5
+ var utils$1 = require('@kubb/plugin-oas/utils');
6
+ var react = require('@kubb/react');
7
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
8
+
9
+ // src/components/Client.tsx
10
+ function getParams({ pathParamsType, typeSchemas }) {
11
+ return react.FunctionParams.factory({
12
+ pathParams: {
13
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
14
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
15
+ },
16
+ data: typeSchemas.request?.name ? {
17
+ type: typeSchemas.request?.name,
18
+ optional: oas.isOptional(typeSchemas.request?.schema)
19
+ } : void 0,
20
+ params: typeSchemas.queryParams?.name ? {
21
+ type: typeSchemas.queryParams?.name,
22
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
23
+ } : void 0,
24
+ headers: typeSchemas.headerParams?.name ? {
25
+ type: typeSchemas.headerParams?.name,
26
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
27
+ } : void 0,
28
+ config: {
29
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
30
+ default: "{}"
31
+ }
32
+ });
33
+ }
34
+ function Client({
35
+ name,
36
+ isExportable = true,
37
+ isIndexable = true,
38
+ typeSchemas,
39
+ baseURL,
40
+ dataReturnType,
41
+ parser,
42
+ zodSchemas,
43
+ pathParamsType,
44
+ operation
45
+ }) {
46
+ const path = new utils.URLPath(operation.path);
47
+ const contentType = operation.getContentType();
48
+ const isFormData = contentType === "multipart/form-data";
49
+ const headers = [
50
+ contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
51
+ typeSchemas.headerParams?.name ? "...headers" : void 0
52
+ ].filter(Boolean);
53
+ const generics = [
54
+ typeSchemas.response.name,
55
+ typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown",
56
+ typeSchemas.request?.name || "unknown"
57
+ ].filter(Boolean);
58
+ const params = getParams({ pathParamsType, typeSchemas });
59
+ const clientParams = react.FunctionParams.factory({
60
+ config: {
61
+ mode: "object",
62
+ children: {
63
+ method: {
64
+ value: JSON.stringify(operation.method)
65
+ },
66
+ url: {
67
+ value: path.template
68
+ },
69
+ baseURL: baseURL ? {
70
+ value: JSON.stringify(baseURL)
71
+ } : void 0,
72
+ params: typeSchemas.queryParams?.name ? {} : void 0,
73
+ data: typeSchemas.request?.name ? {
74
+ value: isFormData ? "formData" : void 0
75
+ } : void 0,
76
+ headers: headers.length ? {
77
+ value: headers.length ? `{ ${headers.join(", ")}, ...config.headers }` : void 0
78
+ } : void 0,
79
+ config: {
80
+ mode: "inlineSpread"
81
+ }
82
+ }
83
+ }
84
+ });
85
+ const formData = isFormData ? `
86
+ const formData = new FormData()
87
+ if(data) {
88
+ Object.keys(data).forEach((key) => {
89
+ const value = data[key];
90
+ if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
91
+ formData.append(key, value);
92
+ }
93
+ })
94
+ }
95
+ ` : "";
96
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsxRuntime.jsxs(
97
+ react.Function,
98
+ {
99
+ name,
100
+ async: true,
101
+ export: isExportable,
102
+ params: params.toConstructor(),
103
+ JSDoc: {
104
+ comments: utils$1.getComments(operation)
105
+ },
106
+ children: [
107
+ formData,
108
+ `const res = await client<${generics.join(", ")}>(${clientParams.toCall()})`,
109
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
110
+ dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
111
+ dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
112
+ dataReturnType === "full" && parser === "client" && "return res",
113
+ dataReturnType === "data" && parser === "client" && "return res.data"
114
+ ]
115
+ }
116
+ ) });
117
+ }
118
+ Client.getParams = getParams;
119
+ function Operations({ name, operations }) {
120
+ const operationsObject = {};
121
+ operations.forEach((operation) => {
122
+ operationsObject[operation.getOperationId()] = {
123
+ path: new utils.URLPath(operation.path).URL,
124
+ method: operation.method
125
+ };
126
+ });
127
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
128
+ }
129
+
130
+ exports.Client = Client;
131
+ exports.Operations = Operations;
132
+ //# sourceMappingURL=chunk-NEK3OJBX.cjs.map
133
+ //# sourceMappingURL=chunk-NEK3OJBX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["FunctionParams","getPathParams","isOptional","URLPath","File","jsxs","Function","getComments","jsx","Const"],"mappings":";;;;;;;;;AA+BA,SAAS,SAAU,CAAA,EAAE,cAAgB,EAAA,WAAA,EAA+B,EAAA;AAClE,EAAA,OAAOA,qBAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAAA,EAAM,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,MAC/C,UAAUC,qBAAc,CAAA,WAAA,CAAY,YAAY,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,KACjE;AAAA,IACA,IAAA,EAAM,WAAY,CAAA,OAAA,EAAS,IACvB,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,OAAS,EAAA,IAAA;AAAA,MAC3B,QAAU,EAAAC,cAAA,CAAW,WAAY,CAAA,OAAA,EAAS,MAAM,CAAA;AAAA,KAElD,GAAA,KAAA,CAAA;AAAA,IACJ,MAAA,EAAQ,WAAY,CAAA,WAAA,EAAa,IAC7B,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,WAAa,EAAA,IAAA;AAAA,MAC/B,QAAU,EAAAA,cAAA,CAAW,WAAY,CAAA,WAAA,EAAa,MAAM,CAAA;AAAA,KAEtD,GAAA,KAAA,CAAA;AAAA,IACJ,OAAA,EAAS,WAAY,CAAA,YAAA,EAAc,IAC/B,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,YAAc,EAAA,IAAA;AAAA,MAChC,QAAU,EAAAA,cAAA,CAAW,WAAY,CAAA,YAAA,EAAc,MAAM,CAAA;AAAA,KAEvD,GAAA,KAAA,CAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,YAAY,OAAS,EAAA,IAAA,GAAO,yBAAyB,WAAY,CAAA,OAAA,EAAS,IAAI,CAAO,EAAA,CAAA,GAAA,wBAAA;AAAA,MAC3F,OAAS,EAAA,IAAA;AAAA,KACX;AAAA,GACD,CAAA,CAAA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eAAM,IAAY,EAAA,MAAA,EAAM,IAAC,EAAA,OAAA,EAAO,IAC9B,EAAA,QAAA,EAAA,IAAA,CAAK,UAAU,gBAAkB,EAAA,KAAA,CAAA,EAAW,CAAC,CAAA,EAChD,CACF,EAAA,CAAA,CAAA;AAEJ","file":"chunk-NEK3OJBX.cjs","sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n isExportable?: boolean\n isIndexable?: boolean\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n pathParamsType,\n operation,\n}: Props): KubbNode {\n const path = new URLPath(operation.path)\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const generics = [\n typeSchemas.response.name,\n typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown',\n typeSchemas.request?.name || 'unknown',\n ].filter(Boolean)\n const params = getParams({ pathParamsType, typeSchemas })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method),\n },\n url: {\n value: path.template,\n },\n baseURL: baseURL\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n value: headers.length ? `{ ${headers.join(', ')}, ...config.headers }` : undefined,\n }\n : undefined,\n config: {\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 : ''\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData}\n {`const res = await client<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"]}
package/dist/client.cjs CHANGED
@@ -1,6 +1,15 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// client.ts
2
- var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
3
- var axiosInstance = _axios2.default.create({
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
10
+
11
+ // client.ts
12
+ var axiosInstance = axios__default.default.create({
4
13
  baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0,
5
14
  headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0
6
15
  });
@@ -12,8 +21,8 @@ var axiosClient = async (config) => {
12
21
  };
13
22
  var client_default = axiosClient;
14
23
 
15
-
16
-
17
-
18
- exports.axiosClient = axiosClient; exports.axiosInstance = axiosInstance; exports.default = client_default;
24
+ exports.axiosClient = axiosClient;
25
+ exports.axiosInstance = axiosInstance;
26
+ exports.default = client_default;
27
+ //# sourceMappingURL=client.cjs.map
19
28
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/client.cjs","../client.ts"],"names":[],"mappings":"AAAA;ACAA,4EAAkB;AA8BX,IAAM,cAAA,EAAgB,eAAA,CAAM,MAAA,CAAO;AAAA,EACxC,OAAA,EAAS,OAAO,WAAA,IAAe,YAAA,EAAc,WAAA,EAAa,KAAA,CAAA;AAAA,EAC1D,OAAA,EAAS,OAAO,cAAA,IAAkB,YAAA,EAAe,IAAA,CAAK,KAAA,CAAM,aAAa,EAAA,EAAqB,KAAA;AAChG,CAAC,CAAA;AAEM,IAAM,YAAA,EAAc,MAAA,CAAsD,MAAA,EAAA,GAAsE;AACrJ,EAAA,MAAM,QAAA,EAAU,aAAA,CAAc,OAAA,CAAsC,MAAM,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,EAAA,GAA0B;AAC3G,IAAA,MAAM,CAAA;AAAA,EACR,CAAC,CAAA;AAED,EAAA,OAAO,OAAA;AACT,CAAA;AAEA,IAAO,eAAA,EAAQ,WAAA;AD9Bf;AACE;AACA;AACA;AACF,2GAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/client.cjs","sourcesContent":[null,"import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete'\n params?: unknown\n data?: TData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
1
+ {"version":3,"sources":["../client.ts"],"names":["axios"],"mappings":";;;;;;;;;;;AA8Ba,IAAA,aAAA,GAAgBA,uBAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.cjs","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
package/dist/client.d.cts CHANGED
@@ -7,9 +7,9 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';
7
7
  type RequestConfig<TData = unknown> = {
8
8
  baseURL?: string;
9
9
  url?: string;
10
- method: 'get' | 'put' | 'patch' | 'post' | 'delete';
10
+ method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options';
11
11
  params?: unknown;
12
- data?: TData;
12
+ data?: TData | FormData;
13
13
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
14
14
  signal?: AbortSignal;
15
15
  headers?: AxiosRequestConfig['headers'];
package/dist/client.d.ts CHANGED
@@ -7,9 +7,9 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';
7
7
  type RequestConfig<TData = unknown> = {
8
8
  baseURL?: string;
9
9
  url?: string;
10
- method: 'get' | 'put' | 'patch' | 'post' | 'delete';
10
+ method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options';
11
11
  params?: unknown;
12
- data?: TData;
12
+ data?: TData | FormData;
13
13
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
14
14
  signal?: AbortSignal;
15
15
  headers?: AxiosRequestConfig['headers'];
package/dist/client.js CHANGED
@@ -1,5 +1,6 @@
1
+ import axios from 'axios';
2
+
1
3
  // client.ts
2
- import axios from "axios";
3
4
  var axiosInstance = axios.create({
4
5
  baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0,
5
6
  headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0
@@ -11,9 +12,7 @@ var axiosClient = async (config) => {
11
12
  return promise;
12
13
  };
13
14
  var client_default = axiosClient;
14
- export {
15
- axiosClient,
16
- axiosInstance,
17
- client_default as default
18
- };
15
+
16
+ export { axiosClient, axiosInstance, client_default as default };
17
+ //# sourceMappingURL=client.js.map
19
18
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../client.ts"],"sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete'\n params?: unknown\n data?: TData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"],"mappings":";AAAA,OAAO,WAAW;AA8BX,IAAM,gBAAgB,MAAM,OAAO;AAAA,EACxC,SAAS,OAAO,eAAe,cAAc,aAAa;AAAA,EAC1D,SAAS,OAAO,kBAAkB,cAAe,KAAK,MAAM,aAAa,IAAqB;AAChG,CAAC;AAEM,IAAM,cAAc,OAAsD,WAAsE;AACrJ,QAAM,UAAU,cAAc,QAAsC,MAAM,EAAE,MAAM,CAAC,MAA0B;AAC3G,UAAM;AAAA,EACR,CAAC;AAED,SAAO;AACT;AAEA,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../client.ts"],"names":[],"mappings":";;;AA8Ba,IAAA,aAAA,GAAgB,MAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.js","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
@@ -1,9 +1,16 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkNEK3OJBX_cjs = require('./chunk-NEK3OJBX.cjs');
3
4
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
5
5
 
6
6
 
7
-
8
- exports.Client = _chunkW7F5CMU6cjs.Client; exports.Operations = _chunkW7F5CMU6cjs.Operations;
7
+ Object.defineProperty(exports, "Client", {
8
+ enumerable: true,
9
+ get: function () { return chunkNEK3OJBX_cjs.Client; }
10
+ });
11
+ Object.defineProperty(exports, "Operations", {
12
+ enumerable: true,
13
+ get: function () { return chunkNEK3OJBX_cjs.Operations; }
14
+ });
15
+ //# sourceMappingURL=components.cjs.map
9
16
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
@@ -1,8 +1,38 @@
1
- export { C as Client, a as Operations } from './types-xK4X9e5d.cjs';
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-xPfBu1CW.cjs';
2
6
  import '@kubb/core';
3
- import '@kubb/fs/types';
4
- import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
+ typeSchemas: OperationSchemas;
20
+ zodSchemas: OperationSchemas | undefined;
21
+ operation: Operation;
22
+ };
23
+ type GetParamsProps = {
24
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
+ typeSchemas: OperationSchemas;
26
+ };
27
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
28
+ declare namespace Client {
29
+ var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
+ }
31
+
32
+ type OperationsProps = {
33
+ name: string;
34
+ operations: Array<Operation>;
35
+ };
36
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
37
+
38
+ export { Client, Operations };
@@ -1,8 +1,38 @@
1
- export { C as Client, a as Operations } from './types-xK4X9e5d.js';
1
+ import { Operation } from '@kubb/oas';
2
+ import { OperationSchemas } from '@kubb/plugin-oas';
3
+ import { FunctionParams } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { P as PluginClient } from './types-xPfBu1CW.js';
2
6
  import '@kubb/core';
3
- import '@kubb/fs/types';
4
- import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
7
+
8
+ type Props = {
9
+ /**
10
+ * Name of the function
11
+ */
12
+ name: string;
13
+ isExportable?: boolean;
14
+ isIndexable?: boolean;
15
+ baseURL: string | undefined;
16
+ dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
+ parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
+ typeSchemas: OperationSchemas;
20
+ zodSchemas: OperationSchemas | undefined;
21
+ operation: Operation;
22
+ };
23
+ type GetParamsProps = {
24
+ pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
+ typeSchemas: OperationSchemas;
26
+ };
27
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
28
+ declare namespace Client {
29
+ var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
+ }
31
+
32
+ type OperationsProps = {
33
+ name: string;
34
+ operations: Array<Operation>;
35
+ };
36
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
37
+
38
+ export { Client, Operations };
@@ -1,9 +1,3 @@
1
- import {
2
- Client,
3
- Operations
4
- } from "./chunk-W57BRY5O.js";
5
- export {
6
- Client,
7
- Operations
8
- };
1
+ export { Client, Operations } from './chunk-HGQQGWKN.js';
2
+ //# sourceMappingURL=components.js.map
9
3
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunkHUIJQCWL_cjs = require('./chunk-HUIJQCWL.cjs');
4
+ require('./chunk-NEK3OJBX.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "clientGenerator", {
9
+ enumerable: true,
10
+ get: function () { return chunkHUIJQCWL_cjs.clientGenerator; }
11
+ });
12
+ Object.defineProperty(exports, "operationsGenerator", {
13
+ enumerable: true,
14
+ get: function () { return chunkHUIJQCWL_cjs.operationsGenerator; }
15
+ });
16
+ //# sourceMappingURL=generators.cjs.map
17
+ //# sourceMappingURL=generators.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-xPfBu1CW.cjs';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ export { clientGenerator, operationsGenerator };
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginClient } from './types-xPfBu1CW.js';
3
+ import '@kubb/core';
4
+
5
+ declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
6
+
7
+ declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
8
+
9
+ export { clientGenerator, operationsGenerator };
@@ -0,0 +1,4 @@
1
+ export { clientGenerator, operationsGenerator } from './chunk-54CFYFPX.js';
2
+ import './chunk-HGQQGWKN.js';
3
+ //# sourceMappingURL=generators.js.map
4
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/index.cjs CHANGED
@@ -1,162 +1,17 @@
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; }
1
+ 'use strict';
2
2
 
3
+ var chunkHUIJQCWL_cjs = require('./chunk-HUIJQCWL.cjs');
4
+ require('./chunk-NEK3OJBX.cjs');
3
5
 
4
- var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
5
6
 
6
- // src/plugin.ts
7
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
- var _core = require('@kubb/core');
9
- var _transformers = require('@kubb/core/transformers');
10
- var _utils = require('@kubb/core/utils');
11
- var _pluginoas = require('@kubb/plugin-oas');
12
- var _utils3 = require('@kubb/plugin-oas/utils');
13
7
 
14
- // src/OperationGenerator.tsx
15
-
16
- var _components = require('@kubb/plugin-oas/components');
17
- var _react = require('@kubb/react');
18
- var _jsxruntime = require('@kubb/react/jsx-runtime');
19
- var OperationGenerator = class extends _pluginoas.OperationGenerator {
20
- async all(operations, _operationsByMethod) {
21
- const { pluginManager, oas, plugin, mode } = this.context;
22
- const root = _react.createRoot.call(void 0, {
23
- logger: pluginManager.logger
24
- });
25
- const templates = {
26
- operations: _chunkW7F5CMU6cjs.Operations.templates,
27
- client: _chunkW7F5CMU6cjs.Client.templates,
28
- ...this.options.templates
29
- };
30
- root.render(
31
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations, generator: this, children: templates.operations && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Operations.File, { baseURL: this.options.baseURL, templates: templates.operations }) }) })
32
- );
33
- return root.files;
34
- }
35
- async operation(operation, options) {
36
- const { oas, pluginManager, plugin, mode } = this.context;
37
- const root = _react.createRoot.call(void 0, {
38
- logger: pluginManager.logger
39
- });
40
- const templates = {
41
- operations: _chunkW7F5CMU6cjs.Operations.templates,
42
- client: _chunkW7F5CMU6cjs.Client.templates,
43
- ...options.templates
44
- };
45
- if (!templates.client) {
46
- return [];
47
- }
48
- root.render(
49
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Operation, { operation, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW7F5CMU6cjs.Client.File, { baseURL: this.options.baseURL, templates: templates.client }) }) }) })
50
- );
51
- return root.files;
52
- }
53
- };
54
-
55
- // src/plugin.ts
56
- var pluginClientName = "plugin-client";
57
- var pluginClient = _core.createPlugin.call(void 0, (options) => {
58
- const {
59
- output = { path: "clients" },
60
- group,
61
- exclude = [],
62
- include,
63
- override = [],
64
- transformers = {},
65
- dataReturnType = "data",
66
- pathParamsType = "inline",
67
- templates
68
- } = options;
69
- const template = _optionalChain([group, 'optionalAccess', _ => _.output]) ? group.output : `${output.path}/{{tag}}Controller`;
70
- return {
71
- name: pluginClientName,
72
- options: {
73
- extName: output.extName,
74
- dataReturnType,
75
- client: {
76
- importPath: "@kubb/plugin-client/client",
77
- ...options.client
78
- },
79
- pathParamsType,
80
- templates: {
81
- operations: _chunkW7F5CMU6cjs.Operations.templates,
82
- client: _chunkW7F5CMU6cjs.Client.templates,
83
- ...templates
84
- },
85
- baseURL: void 0
86
- },
87
- pre: [_pluginoas.pluginOasName],
88
- resolvePath(baseName, pathMode, options2) {
89
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
90
- const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
91
- if (mode === "single") {
92
- return _path2.default.resolve(root, output.path);
93
- }
94
- if (_optionalChain([options2, 'optionalAccess', _2 => _2.tag]) && _optionalChain([group, 'optionalAccess', _3 => _3.type]) === "tag") {
95
- const tag = _transformers.camelCase.call(void 0, options2.tag);
96
- return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
97
- }
98
- return _path2.default.resolve(root, output.path, baseName);
99
- },
100
- resolveName(name, type) {
101
- const resolvedName = _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
102
- if (type) {
103
- return _optionalChain([transformers, 'optionalAccess', _4 => _4.name, 'optionalCall', _5 => _5(resolvedName, type)]) || resolvedName;
104
- }
105
- return resolvedName;
106
- },
107
- async buildStart() {
108
- const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
109
- const oas = await swaggerPlugin.context.getOas();
110
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
111
- const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
112
- const baseURL = await swaggerPlugin.context.getBaseURL();
113
- const operationGenerator = new OperationGenerator(
114
- {
115
- ...this.plugin.options,
116
- baseURL
117
- },
118
- {
119
- oas,
120
- pluginManager: this.pluginManager,
121
- plugin: this.plugin,
122
- contentType: swaggerPlugin.context.contentType,
123
- exclude,
124
- include,
125
- override,
126
- mode
127
- }
128
- );
129
- const files = await operationGenerator.build();
130
- await this.addFile(...files);
131
- },
132
- async buildEnd() {
133
- if (this.config.output.write === false) {
134
- return;
135
- }
136
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
137
- if (_optionalChain([group, 'optionalAccess', _6 => _6.type]) === "tag") {
138
- const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
139
- logger: this.logger,
140
- files: this.fileManager.files,
141
- plugin: this.plugin,
142
- template,
143
- exportAs: group.exportAs || "{{tag}}Service",
144
- root,
145
- output
146
- });
147
- await this.addFile(...rootFiles);
148
- }
149
- await this.fileManager.addIndexes({
150
- root,
151
- output,
152
- meta: { pluginKey: this.plugin.key },
153
- logger: this.logger
154
- });
155
- }
156
- };
8
+ Object.defineProperty(exports, "pluginClient", {
9
+ enumerable: true,
10
+ get: function () { return chunkHUIJQCWL_cjs.pluginClient; }
157
11
  });
158
-
159
-
160
-
161
- exports.pluginClient = pluginClient; exports.pluginClientName = pluginClientName;
12
+ Object.defineProperty(exports, "pluginClientName", {
13
+ enumerable: true,
14
+ get: function () { return chunkHUIJQCWL_cjs.pluginClientName; }
15
+ });
16
+ //# sourceMappingURL=index.cjs.map
162
17
  //# sourceMappingURL=index.cjs.map