@kubb/plugin-client 3.0.0-alpha.7 → 3.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.ts +1 -1
- package/dist/chunk-AZDWYBLW.cjs +1 -0
- package/dist/chunk-AZDWYBLW.cjs.map +1 -0
- package/dist/chunk-GHHJWXKQ.cjs +61 -0
- package/dist/chunk-GHHJWXKQ.cjs.map +1 -0
- package/dist/chunk-OODSLPAP.js +61 -0
- package/dist/chunk-OODSLPAP.js.map +1 -0
- package/dist/chunk-W256NILH.js +128 -0
- package/dist/chunk-W256NILH.js.map +1 -0
- package/dist/chunk-YGRM4AA5.cjs +128 -0
- package/dist/chunk-YGRM4AA5.cjs.map +1 -0
- package/dist/chunk-YJOVLRSC.js +1 -0
- package/dist/chunk-YJOVLRSC.js.map +1 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +4 -3
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +1 -3
- package/dist/components.d.ts +1 -3
- package/dist/components.js +2 -1
- package/dist/generators.cjs +8 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +8 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +9 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +8 -28
- package/dist/index.js.map +1 -1
- package/dist/{types-C_-LImV-.d.cts → types-DETYKDFZ.d.cts} +13 -107
- package/dist/{types-C_-LImV-.d.ts → types-DETYKDFZ.d.ts} +13 -107
- package/package.json +20 -12
- package/src/components/Client.tsx +74 -193
- package/src/components/Operations.tsx +6 -72
- package/src/generators/axiosGenerator.tsx +63 -0
- package/src/generators/index.ts +1 -0
- package/src/plugin.ts +4 -4
- package/src/types.ts +2 -2
- package/dist/chunk-BEM4SQUR.cjs +0 -199
- package/dist/chunk-BEM4SQUR.cjs.map +0 -1
- package/dist/chunk-IQZOOJUP.js +0 -199
- package/dist/chunk-IQZOOJUP.js.map +0 -1
- package/src/OperationGenerator.tsx +0 -29
package/client.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const AXIOS_HEADERS: string
|
|
|
11
11
|
export type RequestConfig<TData = unknown> = {
|
|
12
12
|
baseURL?: string
|
|
13
13
|
url?: string
|
|
14
|
-
method: 'get' | 'put' | 'patch' | 'post' | 'delete'
|
|
14
|
+
method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options'
|
|
15
15
|
params?: unknown
|
|
16
16
|
data?: TData
|
|
17
17
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-AZDWYBLW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-AZDWYBLW.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-AZDWYBLW.cjs"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkYGRM4AA5cjs = require('./chunk-YGRM4AA5.cjs');
|
|
5
|
+
|
|
6
|
+
// src/generators/axiosGenerator.tsx
|
|
7
|
+
var _pluginoas = require('@kubb/plugin-oas');
|
|
8
|
+
var _hooks = require('@kubb/plugin-oas/hooks');
|
|
9
|
+
var _plugints = require('@kubb/plugin-ts');
|
|
10
|
+
var _react = require('@kubb/react');
|
|
11
|
+
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
12
|
+
var axiosGenerator = _pluginoas.createReactGenerator.call(void 0, {
|
|
13
|
+
name: "plugin-client",
|
|
14
|
+
Operations({ options, operations }) {
|
|
15
|
+
const { pluginManager } = _react.useApp.call(void 0, );
|
|
16
|
+
if (!options.templates.operations) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const Template = options.templates.operations || _chunkYGRM4AA5cjs.Operations;
|
|
20
|
+
const name = "operations";
|
|
21
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
|
|
22
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template, { name, operations }) });
|
|
23
|
+
},
|
|
24
|
+
Operation({ options, operation }) {
|
|
25
|
+
const { getSchemas, getName, getFile } = _hooks.useOperationManager.call(void 0, );
|
|
26
|
+
const name = getName(operation, { type: "function" });
|
|
27
|
+
const typedSchemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
28
|
+
const file = getFile(operation);
|
|
29
|
+
const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
|
|
30
|
+
if (!options.templates.client) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const Template = options.templates.client || _chunkYGRM4AA5cjs.Client;
|
|
34
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
35
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: options.client.importPath }),
|
|
36
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
37
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
38
|
+
_react.File.Import,
|
|
39
|
+
{
|
|
40
|
+
extName: options.extName,
|
|
41
|
+
name: [
|
|
42
|
+
_optionalChain([typedSchemas, 'access', _ => _.request, 'optionalAccess', _2 => _2.name]),
|
|
43
|
+
typedSchemas.response.name,
|
|
44
|
+
_optionalChain([typedSchemas, 'access', _3 => _3.pathParams, 'optionalAccess', _4 => _4.name]),
|
|
45
|
+
_optionalChain([typedSchemas, 'access', _5 => _5.queryParams, 'optionalAccess', _6 => _6.name]),
|
|
46
|
+
_optionalChain([typedSchemas, 'access', _7 => _7.headerParams, 'optionalAccess', _8 => _8.name])
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
root: file.path,
|
|
49
|
+
path: fileType.path,
|
|
50
|
+
isTypeOnly: true
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template, { name, options, typedSchemas, operation })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
exports.axiosGenerator = axiosGenerator;
|
|
61
|
+
//# sourceMappingURL=chunk-GHHJWXKQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-GHHJWXKQ.cjs","../src/generators/axiosGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,6CAAqC;AACrC,+CAAoC;AACpC,2CAA6B;AAC7B,oCAA6B;AAoBrB,qDAAA;AAfD,IAAM,eAAA,EAAiB,6CAAA;AAAmC,EAC/D,IAAA,EAAM,eAAA;AAAA,EACN,UAAA,CAAW,EAAE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EAA4B,UAAA,CAAsB;AAAA,IAAA,EAAA,CAC5F,CAAA;AAAA,EAEJ;AACF,CAAC,CAAA;ADND;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-GHHJWXKQ.cjs","sourcesContent":[null,"import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const axiosGenerator = createReactGenerator<PluginClient>({\n name: 'plugin-client',\n Operations({ options, operations }) {\n const { pluginManager } = useApp<PluginClient>()\n\n if (!options.templates.operations) {\n return null\n }\n\n const Template = options.templates.operations || Operations\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: ['plugin-client'] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <Template name={name} operations={operations} />\n </File>\n )\n },\n Operation({ options, operation }) {\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n\n if (!options.templates.client) {\n return null\n }\n\n const Template = options.templates.client || Client\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n extName={options.extName}\n name={[\n typedSchemas.request?.name,\n typedSchemas.response.name,\n typedSchemas.pathParams?.name,\n typedSchemas.queryParams?.name,\n typedSchemas.headerParams?.name,\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <Template name={name} options={options} typedSchemas={typedSchemas} operation={operation} />\n </File>\n )\n },\n})\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Client,
|
|
3
|
+
Operations
|
|
4
|
+
} from "./chunk-W256NILH.js";
|
|
5
|
+
|
|
6
|
+
// src/generators/axiosGenerator.tsx
|
|
7
|
+
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
8
|
+
import { useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
9
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
10
|
+
import { File, useApp } from "@kubb/react";
|
|
11
|
+
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
12
|
+
var axiosGenerator = createReactGenerator({
|
|
13
|
+
name: "plugin-client",
|
|
14
|
+
Operations({ options, operations }) {
|
|
15
|
+
const { pluginManager } = useApp();
|
|
16
|
+
if (!options.templates.operations) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const Template = options.templates.operations || Operations;
|
|
20
|
+
const name = "operations";
|
|
21
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
|
|
22
|
+
return /* @__PURE__ */ jsx(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsx(Template, { name, operations }) });
|
|
23
|
+
},
|
|
24
|
+
Operation({ options, operation }) {
|
|
25
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
26
|
+
const name = getName(operation, { type: "function" });
|
|
27
|
+
const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
28
|
+
const file = getFile(operation);
|
|
29
|
+
const fileType = getFile(operation, { pluginKey: [pluginTsName] });
|
|
30
|
+
if (!options.templates.client) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const Template = options.templates.client || Client;
|
|
34
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
35
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
36
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
File.Import,
|
|
39
|
+
{
|
|
40
|
+
extName: options.extName,
|
|
41
|
+
name: [
|
|
42
|
+
typedSchemas.request?.name,
|
|
43
|
+
typedSchemas.response.name,
|
|
44
|
+
typedSchemas.pathParams?.name,
|
|
45
|
+
typedSchemas.queryParams?.name,
|
|
46
|
+
typedSchemas.headerParams?.name
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
root: file.path,
|
|
49
|
+
path: fileType.path,
|
|
50
|
+
isTypeOnly: true
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsx(Template, { name, options, typedSchemas, operation })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
axiosGenerator
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-OODSLPAP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/axiosGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const axiosGenerator = createReactGenerator<PluginClient>({\n name: 'plugin-client',\n Operations({ options, operations }) {\n const { pluginManager } = useApp<PluginClient>()\n\n if (!options.templates.operations) {\n return null\n }\n\n const Template = options.templates.operations || Operations\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: ['plugin-client'] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <Template name={name} operations={operations} />\n </File>\n )\n },\n Operation({ options, operation }) {\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n\n if (!options.templates.client) {\n return null\n }\n\n const Template = options.templates.client || Client\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n extName={options.extName}\n name={[\n typedSchemas.request?.name,\n typedSchemas.response.name,\n typedSchemas.pathParams?.name,\n typedSchemas.queryParams?.name,\n typedSchemas.headerParams?.name,\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <Template name={name} options={options} typedSchemas={typedSchemas} operation={operation} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,MAAM,cAAc;AAoBrB,cAmBF,YAnBE;AAfD,IAAM,iBAAiB,qBAAmC;AAAA,EAC/D,MAAM;AAAA,EACN,WAAW,EAAE,SAAS,WAAW,GAAG;AAClC,UAAM,EAAE,cAAc,IAAI,OAAqB;AAE/C,QAAI,CAAC,QAAQ,UAAU,YAAY;AACjC,aAAO;AAAA,IACT;AAEA,UAAM,WAAW,QAAQ,UAAU,cAAc;AACjD,UAAM,OAAO;AACb,UAAM,OAAO,cAAc,QAAQ,EAAE,MAAM,SAAS,OAAO,WAAW,CAAC,eAAe,EAAE,CAAC;AAEzF,WACE,oBAAC,QAAK,UAAU,KAAK,UAAU,MAAM,KAAK,MAAM,MAAM,KAAK,MACzD,8BAAC,YAAS,MAAY,YAAwB,GAChD;AAAA,EAEJ;AAAA,EACA,UAAU,EAAE,SAAS,UAAU,GAAG;AAChC,UAAM,EAAE,YAAY,SAAS,QAAQ,IAAI,oBAAoB;AAE7D,UAAM,OAAO,QAAQ,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,UAAM,eAAe,WAAW,WAAW,EAAE,WAAW,CAAC,YAAY,GAAG,MAAM,OAAO,CAAC;AACtF,UAAM,OAAO,QAAQ,SAAS;AAC9B,UAAM,WAAW,QAAQ,WAAW,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC;AAEjE,QAAI,CAAC,QAAQ,UAAU,QAAQ;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,WAAW,QAAQ,UAAU,UAAU;AAE7C,WACE,qBAAC,QAAK,UAAU,KAAK,UAAU,MAAM,KAAK,MAAM,MAAM,KAAK,MACzD;AAAA,0BAAC,KAAK,QAAL,EAAY,MAAM,UAAU,MAAM,QAAQ,OAAO,YAAY;AAAA,MAC9D,oBAAC,KAAK,QAAL,EAAY,MAAM,CAAC,gBAAgB,GAAG,MAAM,QAAQ,OAAO,YAAY,YAAU,MAAC;AAAA,MACnF;AAAA,QAAC,KAAK;AAAA,QAAL;AAAA,UACC,SAAS,QAAQ;AAAA,UACjB,MAAM;AAAA,YACJ,aAAa,SAAS;AAAA,YACtB,aAAa,SAAS;AAAA,YACtB,aAAa,YAAY;AAAA,YACzB,aAAa,aAAa;AAAA,YAC1B,aAAa,cAAc;AAAA,UAC7B,EAAE,OAAO,OAAO;AAAA,UAChB,MAAM,KAAK;AAAA,UACX,MAAM,SAAS;AAAA,UACf,YAAU;AAAA;AAAA,MACZ;AAAA,MACA,oBAAC,YAAS,MAAY,SAAkB,cAA4B,WAAsB;AAAA,OAC5F;AAAA,EAEJ;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// src/components/Client.tsx
|
|
2
|
+
import { URLPath } from "@kubb/core/utils";
|
|
3
|
+
import { isOptional } from "@kubb/oas";
|
|
4
|
+
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
5
|
+
import { File, Function, createParams } from "@kubb/react";
|
|
6
|
+
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
7
|
+
function Client({ name, options, typedSchemas, operation }) {
|
|
8
|
+
const contentType = operation.getContentType();
|
|
9
|
+
const baseURL = options.client.importPath === "@kubb/plugin-client/client" ? options.baseURL : void 0;
|
|
10
|
+
const path = new URLPath(operation.path);
|
|
11
|
+
const isFormData = contentType === "multipart/form-data";
|
|
12
|
+
const headers = [
|
|
13
|
+
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
|
|
14
|
+
typedSchemas.headerParams?.name ? "...headers" : void 0
|
|
15
|
+
].filter(Boolean);
|
|
16
|
+
const params = createParams({
|
|
17
|
+
pathParams: {
|
|
18
|
+
mode: options.pathParamsType === "object" ? "object" : "inlineSpread",
|
|
19
|
+
children: getPathParams(typedSchemas.pathParams, { typed: true })
|
|
20
|
+
},
|
|
21
|
+
data: typedSchemas.request?.name ? {
|
|
22
|
+
type: typedSchemas.request?.name,
|
|
23
|
+
optional: isOptional(typedSchemas.request?.schema)
|
|
24
|
+
} : void 0,
|
|
25
|
+
params: typedSchemas.queryParams?.name ? {
|
|
26
|
+
type: typedSchemas.queryParams?.name,
|
|
27
|
+
optional: isOptional(typedSchemas.queryParams?.schema)
|
|
28
|
+
} : void 0,
|
|
29
|
+
headers: typedSchemas.headerParams?.name ? {
|
|
30
|
+
type: typedSchemas.headerParams?.name,
|
|
31
|
+
optional: isOptional(typedSchemas.headerParams?.schema)
|
|
32
|
+
} : void 0,
|
|
33
|
+
options: {
|
|
34
|
+
type: "Partial<Parameters<typeof client>[0]>",
|
|
35
|
+
default: "{}"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const clientParams = createParams({
|
|
39
|
+
data: {
|
|
40
|
+
mode: "object",
|
|
41
|
+
children: {
|
|
42
|
+
method: {
|
|
43
|
+
type: "string",
|
|
44
|
+
value: JSON.stringify(operation.method)
|
|
45
|
+
},
|
|
46
|
+
url: {
|
|
47
|
+
type: "string",
|
|
48
|
+
value: path.template
|
|
49
|
+
},
|
|
50
|
+
baseURL: baseURL ? {
|
|
51
|
+
type: "string",
|
|
52
|
+
value: JSON.stringify(baseURL)
|
|
53
|
+
} : void 0,
|
|
54
|
+
params: typedSchemas.queryParams?.name ? {
|
|
55
|
+
type: "any"
|
|
56
|
+
} : void 0,
|
|
57
|
+
data: typedSchemas.request?.name ? {
|
|
58
|
+
type: "any",
|
|
59
|
+
value: isFormData ? "formData" : void 0
|
|
60
|
+
} : void 0,
|
|
61
|
+
headers: headers.length ? {
|
|
62
|
+
type: "any",
|
|
63
|
+
value: headers.length ? `{ ${headers.join(", ")}, ...options.headers }` : void 0
|
|
64
|
+
} : void 0,
|
|
65
|
+
options: {
|
|
66
|
+
type: "any",
|
|
67
|
+
mode: "inlineSpread"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const formData = isFormData ? `
|
|
73
|
+
const formData = new FormData()
|
|
74
|
+
if(data) {
|
|
75
|
+
Object.keys(data).forEach((key) => {
|
|
76
|
+
const value = data[key];
|
|
77
|
+
if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
|
|
78
|
+
formData.append(key, value);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
` : void 0;
|
|
83
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxs(
|
|
84
|
+
Function,
|
|
85
|
+
{
|
|
86
|
+
name,
|
|
87
|
+
async: true,
|
|
88
|
+
export: true,
|
|
89
|
+
returnType: options.dataReturnType === "data" ? `ResponseConfig<${typedSchemas.response.name}>["data"]` : `ResponseConfig<${typedSchemas.response.name}>`,
|
|
90
|
+
params,
|
|
91
|
+
JSDoc: {
|
|
92
|
+
comments: getComments(operation)
|
|
93
|
+
},
|
|
94
|
+
children: [
|
|
95
|
+
formData || "",
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Function.Call,
|
|
98
|
+
{
|
|
99
|
+
name: "res",
|
|
100
|
+
to: /* @__PURE__ */ jsx(Function, { name: "client", async: true, generics: [typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean), params: clientParams })
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ jsx(Function.Return, { children: options.dataReturnType === "data" ? "res.data" : "res" })
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/components/Operations.tsx
|
|
110
|
+
import { URLPath as URLPath2 } from "@kubb/core/utils";
|
|
111
|
+
import { Const, File as File2 } from "@kubb/react";
|
|
112
|
+
import { jsx as jsx2 } from "@kubb/react/jsx-runtime";
|
|
113
|
+
function Operations({ name, operations }) {
|
|
114
|
+
const operationsObject = {};
|
|
115
|
+
operations.forEach((operation) => {
|
|
116
|
+
operationsObject[operation.getOperationId()] = {
|
|
117
|
+
path: new URLPath2(operation.path).URL,
|
|
118
|
+
method: operation.method
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
return /* @__PURE__ */ jsx2(File2.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx2(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
Client,
|
|
126
|
+
Operations
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-W256NILH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"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, createParams } from '@kubb/react'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n options: PluginClient['resolvedOptions']\n typedSchemas: OperationSchemas\n operation: Operation\n}\n\nexport function Client({ name, options, typedSchemas, operation }: Props): KubbNode {\n const contentType = operation.getContentType()\n const baseURL = options.client.importPath === '@kubb/plugin-client/client' ? options.baseURL : undefined\n const path = new URLPath(operation.path)\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typedSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const params = createParams({\n pathParams: {\n mode: options.pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typedSchemas.pathParams, { typed: true }),\n },\n data: typedSchemas.request?.name\n ? {\n type: typedSchemas.request?.name,\n optional: isOptional(typedSchemas.request?.schema),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: typedSchemas.queryParams?.name,\n optional: isOptional(typedSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typedSchemas.headerParams?.name\n ? {\n type: typedSchemas.headerParams?.name,\n optional: isOptional(typedSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n })\n\n const clientParams = createParams({\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(operation.method),\n },\n url: {\n type: 'string',\n value: path.template,\n },\n baseURL: baseURL\n ? {\n type: 'string',\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: 'any',\n }\n : undefined,\n data: typedSchemas.request?.name\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.join(', ')}, ...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 isIndexable>\n <Function\n name={name}\n async\n export\n returnType={\n options.dataReturnType === 'data' ? `ResponseConfig<${typedSchemas.response.name}>[\"data\"]` : `ResponseConfig<${typedSchemas.response.name}>`\n }\n params={params}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData || ''}\n <Function.Call\n name=\"res\"\n to={<Function name=\"client\" async generics={[typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean)} params={clientParams} />}\n />\n <Function.Return>{options.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,SAAyB,kBAAkB;AAE3C,SAAS,aAAa,qBAAqB;AAC3C,SAAS,MAAM,UAAU,oBAAoB;AAgHvC,SAeQ,KAfR;AAlGC,SAAS,OAAO,EAAE,MAAM,SAAS,cAAc,UAAU,GAAoB;AAClF,QAAM,cAAc,UAAU,eAAe;AAC7C,QAAM,UAAU,QAAQ,OAAO,eAAe,+BAA+B,QAAQ,UAAU;AAC/F,QAAM,OAAO,IAAI,QAAQ,UAAU,IAAI;AACvC,QAAM,aAAa,gBAAgB;AACnC,QAAM,UAAU;AAAA,IACd,gBAAgB,qBAAqB,oBAAoB,WAAW,MAAM;AAAA,IAC1E,aAAa,cAA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,gBAAAE,KAACD,MAAK,QAAL,EAAY,MAAY,cAAY,MAAC,aAAW,MAC/C,0BAAAC,KAAC,SAAM,MAAY,QAAM,MAAC,SAAO,MAC9B,eAAK,UAAU,kBAAkB,QAAW,CAAC,GAChD,GACF;AAEJ;","names":["URLPath","File","jsx"]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }// src/components/Client.tsx
|
|
2
|
+
var _utils = require('@kubb/core/utils');
|
|
3
|
+
var _oas = require('@kubb/oas');
|
|
4
|
+
var _utils3 = require('@kubb/plugin-oas/utils');
|
|
5
|
+
var _react = require('@kubb/react');
|
|
6
|
+
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
7
|
+
function Client({ name, options, typedSchemas, operation }) {
|
|
8
|
+
const contentType = operation.getContentType();
|
|
9
|
+
const baseURL = options.client.importPath === "@kubb/plugin-client/client" ? options.baseURL : void 0;
|
|
10
|
+
const path = new (0, _utils.URLPath)(operation.path);
|
|
11
|
+
const isFormData = contentType === "multipart/form-data";
|
|
12
|
+
const headers = [
|
|
13
|
+
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
|
|
14
|
+
_optionalChain([typedSchemas, 'access', _ => _.headerParams, 'optionalAccess', _2 => _2.name]) ? "...headers" : void 0
|
|
15
|
+
].filter(Boolean);
|
|
16
|
+
const params = _react.createParams.call(void 0, {
|
|
17
|
+
pathParams: {
|
|
18
|
+
mode: options.pathParamsType === "object" ? "object" : "inlineSpread",
|
|
19
|
+
children: _utils3.getPathParams.call(void 0, typedSchemas.pathParams, { typed: true })
|
|
20
|
+
},
|
|
21
|
+
data: _optionalChain([typedSchemas, 'access', _3 => _3.request, 'optionalAccess', _4 => _4.name]) ? {
|
|
22
|
+
type: _optionalChain([typedSchemas, 'access', _5 => _5.request, 'optionalAccess', _6 => _6.name]),
|
|
23
|
+
optional: _oas.isOptional.call(void 0, _optionalChain([typedSchemas, 'access', _7 => _7.request, 'optionalAccess', _8 => _8.schema]))
|
|
24
|
+
} : void 0,
|
|
25
|
+
params: _optionalChain([typedSchemas, 'access', _9 => _9.queryParams, 'optionalAccess', _10 => _10.name]) ? {
|
|
26
|
+
type: _optionalChain([typedSchemas, 'access', _11 => _11.queryParams, 'optionalAccess', _12 => _12.name]),
|
|
27
|
+
optional: _oas.isOptional.call(void 0, _optionalChain([typedSchemas, 'access', _13 => _13.queryParams, 'optionalAccess', _14 => _14.schema]))
|
|
28
|
+
} : void 0,
|
|
29
|
+
headers: _optionalChain([typedSchemas, 'access', _15 => _15.headerParams, 'optionalAccess', _16 => _16.name]) ? {
|
|
30
|
+
type: _optionalChain([typedSchemas, 'access', _17 => _17.headerParams, 'optionalAccess', _18 => _18.name]),
|
|
31
|
+
optional: _oas.isOptional.call(void 0, _optionalChain([typedSchemas, 'access', _19 => _19.headerParams, 'optionalAccess', _20 => _20.schema]))
|
|
32
|
+
} : void 0,
|
|
33
|
+
options: {
|
|
34
|
+
type: "Partial<Parameters<typeof client>[0]>",
|
|
35
|
+
default: "{}"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const clientParams = _react.createParams.call(void 0, {
|
|
39
|
+
data: {
|
|
40
|
+
mode: "object",
|
|
41
|
+
children: {
|
|
42
|
+
method: {
|
|
43
|
+
type: "string",
|
|
44
|
+
value: JSON.stringify(operation.method)
|
|
45
|
+
},
|
|
46
|
+
url: {
|
|
47
|
+
type: "string",
|
|
48
|
+
value: path.template
|
|
49
|
+
},
|
|
50
|
+
baseURL: baseURL ? {
|
|
51
|
+
type: "string",
|
|
52
|
+
value: JSON.stringify(baseURL)
|
|
53
|
+
} : void 0,
|
|
54
|
+
params: _optionalChain([typedSchemas, 'access', _21 => _21.queryParams, 'optionalAccess', _22 => _22.name]) ? {
|
|
55
|
+
type: "any"
|
|
56
|
+
} : void 0,
|
|
57
|
+
data: _optionalChain([typedSchemas, 'access', _23 => _23.request, 'optionalAccess', _24 => _24.name]) ? {
|
|
58
|
+
type: "any",
|
|
59
|
+
value: isFormData ? "formData" : void 0
|
|
60
|
+
} : void 0,
|
|
61
|
+
headers: headers.length ? {
|
|
62
|
+
type: "any",
|
|
63
|
+
value: headers.length ? `{ ${headers.join(", ")}, ...options.headers }` : void 0
|
|
64
|
+
} : void 0,
|
|
65
|
+
options: {
|
|
66
|
+
type: "any",
|
|
67
|
+
mode: "inlineSpread"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const formData = isFormData ? `
|
|
73
|
+
const formData = new FormData()
|
|
74
|
+
if(data) {
|
|
75
|
+
Object.keys(data).forEach((key) => {
|
|
76
|
+
const value = data[key];
|
|
77
|
+
if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
|
|
78
|
+
formData.append(key, value);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
` : void 0;
|
|
83
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
84
|
+
_react.Function,
|
|
85
|
+
{
|
|
86
|
+
name,
|
|
87
|
+
async: true,
|
|
88
|
+
export: true,
|
|
89
|
+
returnType: options.dataReturnType === "data" ? `ResponseConfig<${typedSchemas.response.name}>["data"]` : `ResponseConfig<${typedSchemas.response.name}>`,
|
|
90
|
+
params,
|
|
91
|
+
JSDoc: {
|
|
92
|
+
comments: _utils3.getComments.call(void 0, operation)
|
|
93
|
+
},
|
|
94
|
+
children: [
|
|
95
|
+
formData || "",
|
|
96
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
97
|
+
_react.Function.Call,
|
|
98
|
+
{
|
|
99
|
+
name: "res",
|
|
100
|
+
to: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name: "client", async: true, generics: [typedSchemas.response.name, _optionalChain([typedSchemas, 'access', _25 => _25.request, 'optionalAccess', _26 => _26.name])].filter(Boolean), params: clientParams })
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function.Return, { children: options.dataReturnType === "data" ? "res.data" : "res" })
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/components/Operations.tsx
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
function Operations({ name, operations }) {
|
|
114
|
+
const operationsObject = {};
|
|
115
|
+
operations.forEach((operation) => {
|
|
116
|
+
operationsObject[operation.getOperationId()] = {
|
|
117
|
+
path: new (0, _utils.URLPath)(operation.path).URL,
|
|
118
|
+
method: operation.method
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
exports.Client = Client; exports.Operations = Operations;
|
|
128
|
+
//# sourceMappingURL=chunk-YGRM4AA5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-YGRM4AA5.cjs","../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","jsx","File"],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AA,CAAU,gBAAA,EAAkB,KAAA,CAAA,EAAW,CAAC,EAAA,CAChD,EAAA,CACF,CAAA;AAEJ;AF+FA;AACA;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/chunk-YGRM4AA5.cjs","sourcesContent":[null,"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, createParams } from '@kubb/react'\nimport type { KubbNode, Params } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n options: PluginClient['resolvedOptions']\n typedSchemas: OperationSchemas\n operation: Operation\n}\n\nexport function Client({ name, options, typedSchemas, operation }: Props): KubbNode {\n const contentType = operation.getContentType()\n const baseURL = options.client.importPath === '@kubb/plugin-client/client' ? options.baseURL : undefined\n const path = new URLPath(operation.path)\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typedSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const params = createParams({\n pathParams: {\n mode: options.pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typedSchemas.pathParams, { typed: true }),\n },\n data: typedSchemas.request?.name\n ? {\n type: typedSchemas.request?.name,\n optional: isOptional(typedSchemas.request?.schema),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: typedSchemas.queryParams?.name,\n optional: isOptional(typedSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typedSchemas.headerParams?.name\n ? {\n type: typedSchemas.headerParams?.name,\n optional: isOptional(typedSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Parameters<typeof client>[0]>',\n default: '{}',\n },\n })\n\n const clientParams = createParams({\n data: {\n mode: 'object',\n children: {\n method: {\n type: 'string',\n value: JSON.stringify(operation.method),\n },\n url: {\n type: 'string',\n value: path.template,\n },\n baseURL: baseURL\n ? {\n type: 'string',\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typedSchemas.queryParams?.name\n ? {\n type: 'any',\n }\n : undefined,\n data: typedSchemas.request?.name\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.join(', ')}, ...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 isIndexable>\n <Function\n name={name}\n async\n export\n returnType={\n options.dataReturnType === 'data' ? `ResponseConfig<${typedSchemas.response.name}>[\"data\"]` : `ResponseConfig<${typedSchemas.response.name}>`\n }\n params={params}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData || ''}\n <Function.Call\n name=\"res\"\n to={<Function name=\"client\" async generics={[typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean)} params={clientParams} />}\n />\n <Function.Return>{options.dataReturnType === 'data' ? 'res.data' : 'res'}</Function.Return>\n </Function>\n </File.Source>\n )\n}\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-YJOVLRSC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/client.cjs.map
CHANGED
|
@@ -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":["/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' | 'options'\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"]}
|
package/dist/client.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ 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
12
|
data?: TData;
|
|
13
13
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
package/dist/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ 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
12
|
data?: TData;
|
|
13
13
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
package/dist/client.js.map
CHANGED
|
@@ -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"],"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\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":[]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-AZDWYBLW.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkBEM4SQURcjs = require('./chunk-BEM4SQUR.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkYGRM4AA5cjs = require('./chunk-YGRM4AA5.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
exports.Client = _chunkYGRM4AA5cjs.Client; exports.Operations = _chunkYGRM4AA5cjs.Operations;
|
|
9
10
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.cjs.map
CHANGED
|
@@ -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":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/components.cjs"}
|
package/dist/components.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export { C as Client, a as Operations } from './types-
|
|
1
|
+
export { C as Client, a as Operations } from './types-DETYKDFZ.cjs';
|
|
2
2
|
import '@kubb/core';
|
|
3
3
|
import '@kubb/fs/types';
|
|
4
4
|
import '@kubb/oas';
|
|
5
5
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/core/utils';
|
|
7
6
|
import '@kubb/react/types';
|
|
8
|
-
import 'react';
|
package/dist/components.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export { C as Client, a as Operations } from './types-
|
|
1
|
+
export { C as Client, a as Operations } from './types-DETYKDFZ.js';
|
|
2
2
|
import '@kubb/core';
|
|
3
3
|
import '@kubb/fs/types';
|
|
4
4
|
import '@kubb/oas';
|
|
5
5
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/core/utils';
|
|
7
6
|
import '@kubb/react/types';
|
|
8
|
-
import 'react';
|
package/dist/components.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkGHHJWXKQcjs = require('./chunk-GHHJWXKQ.cjs');
|
|
4
|
+
require('./chunk-YGRM4AA5.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.axiosGenerator = _chunkGHHJWXKQcjs.axiosGenerator;
|
|
8
|
+
//# sourceMappingURL=generators.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-client/dist/generators.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,0DAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-client/dist/generators.cjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginClient } from './types-DETYKDFZ.cjs';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/fs/types';
|
|
5
|
+
import '@kubb/oas';
|
|
6
|
+
import '@kubb/react/types';
|
|
7
|
+
|
|
8
|
+
declare const axiosGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
|
+
|
|
10
|
+
export { axiosGenerator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginClient } from './types-DETYKDFZ.js';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/fs/types';
|
|
5
|
+
import '@kubb/oas';
|
|
6
|
+
import '@kubb/react/types';
|
|
7
|
+
|
|
8
|
+
declare const axiosGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
|
+
|
|
10
|
+
export { axiosGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|