@kubb/plugin-client 3.0.0-alpha.1 → 3.0.0-alpha.11
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-3NQF7BGA.cjs +58 -0
- package/dist/chunk-3NQF7BGA.cjs.map +1 -0
- package/dist/chunk-AZDWYBLW.cjs +4 -0
- package/dist/chunk-AZDWYBLW.cjs.map +1 -0
- package/dist/chunk-PO22ZUSH.cjs +125 -0
- package/dist/chunk-PO22ZUSH.cjs.map +1 -0
- package/dist/chunk-QBFKND4S.js +122 -0
- package/dist/chunk-QBFKND4S.js.map +1 -0
- package/dist/chunk-QLVGX3VO.js +56 -0
- package/dist/chunk-QLVGX3VO.js.map +1 -0
- package/dist/chunk-YJOVLRSC.js +3 -0
- package/dist/chunk-YJOVLRSC.js.map +1 -0
- package/dist/client.cjs +16 -7
- 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 +5 -6
- package/dist/client.js.map +1 -1
- package/dist/components.cjs +12 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +3 -5
- package/dist/components.d.ts +3 -5
- package/dist/components.js +3 -8
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +13 -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 +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +51 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +31 -91
- package/dist/index.js.map +1 -1
- package/dist/{types-xK4X9e5d.d.cts → types-DETYKDFZ.d.cts} +19 -108
- package/dist/{types-xK4X9e5d.d.ts → types-DETYKDFZ.d.ts} +19 -108
- package/package.json +22 -14
- package/src/components/Client.tsx +77 -198
- package/src/components/Operations.tsx +9 -75
- package/src/components/__snapshots__/Client/showPetById.ts +3 -6
- package/src/components/__snapshots__/Operations/showPetById.ts +5 -5
- package/src/generators/axiosGenerator.tsx +63 -0
- package/src/generators/index.ts +1 -0
- package/src/plugin.ts +21 -38
- package/src/types.ts +9 -3
- package/dist/chunk-W57BRY5O.js +0 -201
- package/dist/chunk-W57BRY5O.js.map +0 -1
- package/dist/chunk-W7F5CMU6.cjs +0 -201
- package/dist/chunk-W7F5CMU6.cjs.map +0 -1
- package/src/OperationGenerator.tsx +0 -65
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,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPO22ZUSH_cjs = require('./chunk-PO22ZUSH.cjs');
|
|
4
|
+
var pluginOas = require('@kubb/plugin-oas');
|
|
5
|
+
var hooks = require('@kubb/plugin-oas/hooks');
|
|
6
|
+
var pluginTs = require('@kubb/plugin-ts');
|
|
7
|
+
var react = require('@kubb/react');
|
|
8
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
var axiosGenerator = pluginOas.createReactGenerator({
|
|
11
|
+
name: "plugin-client",
|
|
12
|
+
Operations({ options, operations }) {
|
|
13
|
+
const { pluginManager } = react.useApp();
|
|
14
|
+
if (!options.templates.operations) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const Template = options.templates.operations || chunkPO22ZUSH_cjs.Operations;
|
|
18
|
+
const name = "operations";
|
|
19
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsxRuntime.jsx(Template, { name, operations }) });
|
|
21
|
+
},
|
|
22
|
+
Operation({ options, operation }) {
|
|
23
|
+
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
24
|
+
const name = getName(operation, { type: "function" });
|
|
25
|
+
const typedSchemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
26
|
+
const file = getFile(operation);
|
|
27
|
+
const fileType = getFile(operation, { pluginKey: [pluginTs.pluginTsName] });
|
|
28
|
+
if (!options.templates.client) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const Template = options.templates.client || chunkPO22ZUSH_cjs.Client;
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
34
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
35
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
react.File.Import,
|
|
37
|
+
{
|
|
38
|
+
extName: options.extName,
|
|
39
|
+
name: [
|
|
40
|
+
typedSchemas.request?.name,
|
|
41
|
+
typedSchemas.response.name,
|
|
42
|
+
typedSchemas.pathParams?.name,
|
|
43
|
+
typedSchemas.queryParams?.name,
|
|
44
|
+
typedSchemas.headerParams?.name
|
|
45
|
+
].filter(Boolean),
|
|
46
|
+
root: file.path,
|
|
47
|
+
path: fileType.path,
|
|
48
|
+
isTypeOnly: true
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx(Template, { name, options, typedSchemas, operation })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
exports.axiosGenerator = axiosGenerator;
|
|
57
|
+
//# sourceMappingURL=chunk-3NQF7BGA.cjs.map
|
|
58
|
+
//# sourceMappingURL=chunk-3NQF7BGA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/axiosGenerator.tsx"],"names":["createReactGenerator","useApp","Operations","jsx","File","useOperationManager","pluginTsName","Client","jsxs"],"mappings":";;;;;;;;;AAQO,IAAM,iBAAiBA,8BAAmC,CAAA;AAAA,EAC/D,IAAM,EAAA,eAAA;AAAA,EACN,UAAW,CAAA,EAAE,OAAS,EAAA,UAAA,EAAc,EAAA;AAClC,IAAM,MAAA,EAAE,aAAc,EAAA,GAAIC,YAAqB,EAAA,CAAA;AAE/C,IAAI,IAAA,CAAC,OAAQ,CAAA,SAAA,CAAU,UAAY,EAAA;AACjC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,SAAA,CAAU,UAAc,IAAAC,4BAAA,CAAA;AACjD,IAAA,MAAM,IAAO,GAAA,YAAA,CAAA;AACb,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,OAAA,CAAQ,EAAE,IAAA,EAAM,OAAS,EAAA,KAAA,EAAO,SAAW,EAAA,CAAC,eAAe,CAAA,EAAG,CAAA,CAAA;AAEzF,IAAA,uBACGC,cAAA,CAAAC,UAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,UAAU,IAAM,EAAA,IAAA,CAAK,IAAM,EAAA,IAAA,EAAM,KAAK,IACzD,EAAA,QAAA,kBAAAD,cAAA,CAAC,QAAS,EAAA,EAAA,IAAA,EAAY,YAAwB,CAChD,EAAA,CAAA,CAAA;AAAA,GAEJ;AAAA,EACA,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAA,MAAM,EAAE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AAA,YACtB,aAAa,QAAS,CAAA,IAAA;AAAA,YACtB,aAAa,UAAY,EAAA,IAAA;AAAA,YACzB,aAAa,WAAa,EAAA,IAAA;AAAA,YAC1B,aAAa,YAAc,EAAA,IAAA;AAAA,WAC7B,CAAE,OAAO,OAAO,CAAA;AAAA,UAChB,MAAM,IAAK,CAAA,IAAA;AAAA,UACX,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,UAAU,EAAA,IAAA;AAAA,SAAA;AAAA,OACZ;AAAA,sBACCD,cAAA,CAAA,QAAA,EAAA,EAAS,IAAY,EAAA,OAAA,EAAkB,cAA4B,SAAsB,EAAA,CAAA;AAAA,KAC5F,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-3NQF7BGA.cjs","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-AZDWYBLW.cjs"}
|
|
@@ -0,0 +1,125 @@
|
|
|
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 Client({ name, options, typedSchemas, operation }) {
|
|
11
|
+
const contentType = operation.getContentType();
|
|
12
|
+
const baseURL = options.client.importPath === "@kubb/plugin-client/client" ? options.baseURL : void 0;
|
|
13
|
+
const path = new utils.URLPath(operation.path);
|
|
14
|
+
const isFormData = contentType === "multipart/form-data";
|
|
15
|
+
const headers = [
|
|
16
|
+
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
|
|
17
|
+
typedSchemas.headerParams?.name ? "...headers" : void 0
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const params = react.createFunctionParams({
|
|
20
|
+
pathParams: {
|
|
21
|
+
mode: options.pathParamsType === "object" ? "object" : "inlineSpread",
|
|
22
|
+
children: utils$1.getPathParams(typedSchemas.pathParams, { typed: true })
|
|
23
|
+
},
|
|
24
|
+
data: typedSchemas.request?.name ? {
|
|
25
|
+
type: typedSchemas.request?.name,
|
|
26
|
+
optional: oas.isOptional(typedSchemas.request?.schema)
|
|
27
|
+
} : void 0,
|
|
28
|
+
params: typedSchemas.queryParams?.name ? {
|
|
29
|
+
type: typedSchemas.queryParams?.name,
|
|
30
|
+
optional: oas.isOptional(typedSchemas.queryParams?.schema)
|
|
31
|
+
} : void 0,
|
|
32
|
+
headers: typedSchemas.headerParams?.name ? {
|
|
33
|
+
type: typedSchemas.headerParams?.name,
|
|
34
|
+
optional: oas.isOptional(typedSchemas.headerParams?.schema)
|
|
35
|
+
} : void 0,
|
|
36
|
+
options: {
|
|
37
|
+
type: "Partial<Parameters<typeof client>[0]>",
|
|
38
|
+
default: "{}"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const clientParams = react.createFunctionParams({
|
|
42
|
+
data: {
|
|
43
|
+
mode: "object",
|
|
44
|
+
children: {
|
|
45
|
+
method: {
|
|
46
|
+
type: "string",
|
|
47
|
+
value: JSON.stringify(operation.method)
|
|
48
|
+
},
|
|
49
|
+
url: {
|
|
50
|
+
type: "string",
|
|
51
|
+
value: path.template
|
|
52
|
+
},
|
|
53
|
+
baseURL: baseURL ? {
|
|
54
|
+
type: "string",
|
|
55
|
+
value: JSON.stringify(baseURL)
|
|
56
|
+
} : void 0,
|
|
57
|
+
params: typedSchemas.queryParams?.name ? {
|
|
58
|
+
type: "any"
|
|
59
|
+
} : void 0,
|
|
60
|
+
data: typedSchemas.request?.name ? {
|
|
61
|
+
type: "any",
|
|
62
|
+
value: isFormData ? "formData" : void 0
|
|
63
|
+
} : void 0,
|
|
64
|
+
headers: headers.length ? {
|
|
65
|
+
type: "any",
|
|
66
|
+
value: headers.length ? `{ ${headers.join(", ")}, ...options.headers }` : void 0
|
|
67
|
+
} : void 0,
|
|
68
|
+
options: {
|
|
69
|
+
type: "any",
|
|
70
|
+
mode: "inlineSpread"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const formData = isFormData ? `
|
|
76
|
+
const formData = new FormData()
|
|
77
|
+
if(data) {
|
|
78
|
+
Object.keys(data).forEach((key) => {
|
|
79
|
+
const value = data[key];
|
|
80
|
+
if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
|
|
81
|
+
formData.append(key, value);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
` : void 0;
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
87
|
+
react.Function,
|
|
88
|
+
{
|
|
89
|
+
name,
|
|
90
|
+
async: true,
|
|
91
|
+
export: true,
|
|
92
|
+
returnType: options.dataReturnType === "data" ? `ResponseConfig<${typedSchemas.response.name}>["data"]` : `ResponseConfig<${typedSchemas.response.name}>`,
|
|
93
|
+
params,
|
|
94
|
+
JSDoc: {
|
|
95
|
+
comments: utils$1.getComments(operation)
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
formData || "",
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
+
react.Function.Call,
|
|
101
|
+
{
|
|
102
|
+
name: "res",
|
|
103
|
+
to: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name: "client", async: true, generics: [typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean), params: clientParams })
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Function.Return, { children: options.dataReturnType === "data" ? "res.data" : "res" })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
) });
|
|
110
|
+
}
|
|
111
|
+
function Operations({ name, operations }) {
|
|
112
|
+
const operationsObject = {};
|
|
113
|
+
operations.forEach((operation) => {
|
|
114
|
+
operationsObject[operation.getOperationId()] = {
|
|
115
|
+
path: new utils.URLPath(operation.path).URL,
|
|
116
|
+
method: operation.method
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
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) }) });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
exports.Client = Client;
|
|
123
|
+
exports.Operations = Operations;
|
|
124
|
+
//# sourceMappingURL=chunk-PO22ZUSH.cjs.map
|
|
125
|
+
//# sourceMappingURL=chunk-PO22ZUSH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","createFunctionParams","getPathParams","isOptional","jsx","File","jsxs","Function","getComments","Const"],"mappings":";;;;;;;;;AAmBO,SAAS,OAAO,EAAE,IAAA,EAAM,OAAS,EAAA,YAAA,EAAc,WAA8B,EAAA;AAClF,EAAM,MAAA,WAAA,GAAc,UAAU,cAAe,EAAA,CAAA;AAC7C,EAAA,MAAM,UAAU,OAAQ,CAAA,MAAA,CAAO,UAAe,KAAA,4BAAA,GAA+B,QAAQ,OAAU,GAAA,KAAA,CAAA,CAAA;AAC/F,EAAA,MAAM,IAAO,GAAA,IAAIA,aAAQ,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AACvC,EAAA,MAAM,aAAa,WAAgB,KAAA,qBAAA,CAAA;AACnC,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,WAAgB,KAAA,kBAAA,GAAqB,CAAoB,iBAAA,EAAA,WAAW,CAAM,CAAA,CAAA,GAAA,KAAA,CAAA;AAAA,IAC1E,YAAA,CAAa,YAAc,EAAA,IAAA,GAAO,YAAe,GAAA,KAAA,CAAA;AAAA,GACnD,CAAE,OAAO,OAAO,CAAA,CAAA;AAEhB,EAAA,MAAM,SAASC,0BAAqB,CAAA;AAAA,IAClC,UAAY,EAAA;AAAA,MACV,IAAM,EAAA,OAAA,CAAQ,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,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WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,cAAAA,CAACK,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-PO22ZUSH.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, createFunctionParams } 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 = createFunctionParams({\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 = createFunctionParams({\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,122 @@
|
|
|
1
|
+
import { URLPath } from '@kubb/core/utils';
|
|
2
|
+
import { isOptional } from '@kubb/oas';
|
|
3
|
+
import { getPathParams, getComments } from '@kubb/plugin-oas/utils';
|
|
4
|
+
import { createFunctionParams, File, Function, Const } from '@kubb/react';
|
|
5
|
+
import { jsx, jsxs } from '@kubb/react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/components/Client.tsx
|
|
8
|
+
function Client({ name, options, typedSchemas, operation }) {
|
|
9
|
+
const contentType = operation.getContentType();
|
|
10
|
+
const baseURL = options.client.importPath === "@kubb/plugin-client/client" ? options.baseURL : void 0;
|
|
11
|
+
const path = new URLPath(operation.path);
|
|
12
|
+
const isFormData = contentType === "multipart/form-data";
|
|
13
|
+
const headers = [
|
|
14
|
+
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
|
|
15
|
+
typedSchemas.headerParams?.name ? "...headers" : void 0
|
|
16
|
+
].filter(Boolean);
|
|
17
|
+
const params = createFunctionParams({
|
|
18
|
+
pathParams: {
|
|
19
|
+
mode: options.pathParamsType === "object" ? "object" : "inlineSpread",
|
|
20
|
+
children: getPathParams(typedSchemas.pathParams, { typed: true })
|
|
21
|
+
},
|
|
22
|
+
data: typedSchemas.request?.name ? {
|
|
23
|
+
type: typedSchemas.request?.name,
|
|
24
|
+
optional: isOptional(typedSchemas.request?.schema)
|
|
25
|
+
} : void 0,
|
|
26
|
+
params: typedSchemas.queryParams?.name ? {
|
|
27
|
+
type: typedSchemas.queryParams?.name,
|
|
28
|
+
optional: isOptional(typedSchemas.queryParams?.schema)
|
|
29
|
+
} : void 0,
|
|
30
|
+
headers: typedSchemas.headerParams?.name ? {
|
|
31
|
+
type: typedSchemas.headerParams?.name,
|
|
32
|
+
optional: isOptional(typedSchemas.headerParams?.schema)
|
|
33
|
+
} : void 0,
|
|
34
|
+
options: {
|
|
35
|
+
type: "Partial<Parameters<typeof client>[0]>",
|
|
36
|
+
default: "{}"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const clientParams = createFunctionParams({
|
|
40
|
+
data: {
|
|
41
|
+
mode: "object",
|
|
42
|
+
children: {
|
|
43
|
+
method: {
|
|
44
|
+
type: "string",
|
|
45
|
+
value: JSON.stringify(operation.method)
|
|
46
|
+
},
|
|
47
|
+
url: {
|
|
48
|
+
type: "string",
|
|
49
|
+
value: path.template
|
|
50
|
+
},
|
|
51
|
+
baseURL: baseURL ? {
|
|
52
|
+
type: "string",
|
|
53
|
+
value: JSON.stringify(baseURL)
|
|
54
|
+
} : void 0,
|
|
55
|
+
params: typedSchemas.queryParams?.name ? {
|
|
56
|
+
type: "any"
|
|
57
|
+
} : void 0,
|
|
58
|
+
data: typedSchemas.request?.name ? {
|
|
59
|
+
type: "any",
|
|
60
|
+
value: isFormData ? "formData" : void 0
|
|
61
|
+
} : void 0,
|
|
62
|
+
headers: headers.length ? {
|
|
63
|
+
type: "any",
|
|
64
|
+
value: headers.length ? `{ ${headers.join(", ")}, ...options.headers }` : void 0
|
|
65
|
+
} : void 0,
|
|
66
|
+
options: {
|
|
67
|
+
type: "any",
|
|
68
|
+
mode: "inlineSpread"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const formData = isFormData ? `
|
|
74
|
+
const formData = new FormData()
|
|
75
|
+
if(data) {
|
|
76
|
+
Object.keys(data).forEach((key) => {
|
|
77
|
+
const value = data[key];
|
|
78
|
+
if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
|
|
79
|
+
formData.append(key, value);
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
` : void 0;
|
|
84
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxs(
|
|
85
|
+
Function,
|
|
86
|
+
{
|
|
87
|
+
name,
|
|
88
|
+
async: true,
|
|
89
|
+
export: true,
|
|
90
|
+
returnType: options.dataReturnType === "data" ? `ResponseConfig<${typedSchemas.response.name}>["data"]` : `ResponseConfig<${typedSchemas.response.name}>`,
|
|
91
|
+
params,
|
|
92
|
+
JSDoc: {
|
|
93
|
+
comments: getComments(operation)
|
|
94
|
+
},
|
|
95
|
+
children: [
|
|
96
|
+
formData || "",
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
Function.Call,
|
|
99
|
+
{
|
|
100
|
+
name: "res",
|
|
101
|
+
to: /* @__PURE__ */ jsx(Function, { name: "client", async: true, generics: [typedSchemas.response.name, typedSchemas.request?.name].filter(Boolean), params: clientParams })
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ jsx(Function.Return, { children: options.dataReturnType === "data" ? "res.data" : "res" })
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
) });
|
|
108
|
+
}
|
|
109
|
+
function Operations({ name, operations }) {
|
|
110
|
+
const operationsObject = {};
|
|
111
|
+
operations.forEach((operation) => {
|
|
112
|
+
operationsObject[operation.getOperationId()] = {
|
|
113
|
+
path: new URLPath(operation.path).URL,
|
|
114
|
+
method: operation.method
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { Client, Operations };
|
|
121
|
+
//# sourceMappingURL=chunk-QBFKND4S.js.map
|
|
122
|
+
//# sourceMappingURL=chunk-QBFKND4S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["URLPath","j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AAS,IAAM,EAAA,YAAA,CAAa,SAAS,IAAI,CAAA,CAAE,OAAO,OAAO,CAAA,EAAG,QAAQ,YAAc,EAAA,CAAA;AAAA,WAAA;AAAA,SAC9I;AAAA,wBACA,GAAA,CAAC,SAAS,MAAT,EAAA,EAAiB,kBAAQ,cAAmB,KAAA,MAAA,GAAS,aAAa,KAAM,EAAA,CAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GAE7E,EAAA,CAAA,CAAA;AAEJ,CAAA;AChIO,SAAS,UAAW,CAAA,EAAE,IAAM,EAAA,UAAA,EAA+B,EAAA;AAChE,EAAA,MAAM,mBAAyE,EAAC,CAAA;AAEhF,EAAW,UAAA,CAAA,OAAA,CAAQ,CAAC,SAAc,KAAA;AAChC,IAAiB,gBAAA,CAAA,SAAA,CAAU,cAAe,EAAC,CAAI,GAAA;AAAA,MAC7C,IAAM,EAAA,IAAIA,OAAQ,CAAA,SAAA,CAAU,IAAI,CAAE,CAAA,GAAA;AAAA,MAClC,QAAQ,SAAU,CAAA,MAAA;AAAA,KACpB,CAAA;AAAA,GACD,CAAA,CAAA;AAED,EACE,uBAAAC,GAACC,CAAAA,IAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,GAAAA,CAAC,SAAM,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-QBFKND4S.js","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, createFunctionParams } 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 = createFunctionParams({\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 = createFunctionParams({\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,56 @@
|
|
|
1
|
+
import { Operations, Client } from './chunk-QBFKND4S.js';
|
|
2
|
+
import { createReactGenerator } from '@kubb/plugin-oas';
|
|
3
|
+
import { useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
4
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
5
|
+
import { useApp, File } from '@kubb/react';
|
|
6
|
+
import { jsx, jsxs } from '@kubb/react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var axiosGenerator = createReactGenerator({
|
|
9
|
+
name: "plugin-client",
|
|
10
|
+
Operations({ options, operations }) {
|
|
11
|
+
const { pluginManager } = useApp();
|
|
12
|
+
if (!options.templates.operations) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const Template = options.templates.operations || Operations;
|
|
16
|
+
const name = "operations";
|
|
17
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: ["plugin-client"] });
|
|
18
|
+
return /* @__PURE__ */ jsx(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsx(Template, { name, operations }) });
|
|
19
|
+
},
|
|
20
|
+
Operation({ options, operation }) {
|
|
21
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
22
|
+
const name = getName(operation, { type: "function" });
|
|
23
|
+
const typedSchemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
24
|
+
const file = getFile(operation);
|
|
25
|
+
const fileType = getFile(operation, { pluginKey: [pluginTsName] });
|
|
26
|
+
if (!options.templates.client) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const Template = options.templates.client || Client;
|
|
30
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
31
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
32
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
File.Import,
|
|
35
|
+
{
|
|
36
|
+
extName: options.extName,
|
|
37
|
+
name: [
|
|
38
|
+
typedSchemas.request?.name,
|
|
39
|
+
typedSchemas.response.name,
|
|
40
|
+
typedSchemas.pathParams?.name,
|
|
41
|
+
typedSchemas.queryParams?.name,
|
|
42
|
+
typedSchemas.headerParams?.name
|
|
43
|
+
].filter(Boolean),
|
|
44
|
+
root: file.path,
|
|
45
|
+
path: fileType.path,
|
|
46
|
+
isTypeOnly: true
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(Template, { name, options, typedSchemas, operation })
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export { axiosGenerator };
|
|
55
|
+
//# sourceMappingURL=chunk-QLVGX3VO.js.map
|
|
56
|
+
//# sourceMappingURL=chunk-QLVGX3VO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/axiosGenerator.tsx"],"names":[],"mappings":";;;;;;;AAQO,IAAM,iBAAiB,oBAAmC,CAAA;AAAA,EAC/D,IAAM,EAAA,eAAA;AAAA,EACN,UAAW,CAAA,EAAE,OAAS,EAAA,UAAA,EAAc,EAAA;AAClC,IAAM,MAAA,EAAE,aAAc,EAAA,GAAI,MAAqB,EAAA,CAAA;AAE/C,IAAI,IAAA,CAAC,OAAQ,CAAA,SAAA,CAAU,UAAY,EAAA;AACjC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,SAAA,CAAU,UAAc,IAAA,UAAA,CAAA;AACjD,IAAA,MAAM,IAAO,GAAA,YAAA,CAAA;AACb,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,OAAA,CAAQ,EAAE,IAAA,EAAM,OAAS,EAAA,KAAA,EAAO,SAAW,EAAA,CAAC,eAAe,CAAA,EAAG,CAAA,CAAA;AAEzF,IAAA,uBACG,GAAA,CAAA,IAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,UAAU,IAAM,EAAA,IAAA,CAAK,IAAM,EAAA,IAAA,EAAM,KAAK,IACzD,EAAA,QAAA,kBAAA,GAAA,CAAC,QAAS,EAAA,EAAA,IAAA,EAAY,YAAwB,CAChD,EAAA,CAAA,CAAA;AAAA,GAEJ;AAAA,EACA,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAA,MAA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ACtB,aAAa,QAAS,CAAA,IAAA;AAAA,YACtB,aAAa,UAAY,EAAA,IAAA;AAAA,YACzB,aAAa,WAAa,EAAA,IAAA;AAAA,YAC1B,aAAa,YAAc,EAAA,IAAA;AAAA,WAC7B,CAAE,OAAO,OAAO,CAAA;AAAA,UAChB,MAAM,IAAK,CAAA,IAAA;AAAA,UACX,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,UAAU,EAAA,IAAA;AAAA,SAAA;AAAA,OACZ;AAAA,sBACC,GAAA,CAAA,QAAA,EAAA,EAAS,IAAY,EAAA,OAAA,EAAkB,cAA4B,SAAsB,EAAA,CAAA;AAAA,KAC5F,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-QLVGX3VO.js","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-YJOVLRSC.js"}
|
package/dist/client.cjs
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
24
|
+
exports.axiosClient = axiosClient;
|
|
25
|
+
exports.axiosInstance = axiosInstance;
|
|
26
|
+
exports.default = client_default;
|
|
27
|
+
//# sourceMappingURL=client.cjs.map
|
|
19
28
|
//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
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\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
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
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"]
|
|
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\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/components.cjs
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
require('./chunk-AZDWYBLW.cjs');
|
|
4
|
+
var chunkPO22ZUSH_cjs = require('./chunk-PO22ZUSH.cjs');
|
|
3
5
|
|
|
4
|
-
var _chunkW7F5CMU6cjs = require('./chunk-W7F5CMU6.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
Object.defineProperty(exports, "Client", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkPO22ZUSH_cjs.Client; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Operations", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkPO22ZUSH_cjs.Operations; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=components.cjs.map
|
|
9
17
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"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
|
-
import '@kubb/plugin-oas';
|
|
5
|
-
import '@kubb/core/utils';
|
|
6
4
|
import '@kubb/oas';
|
|
7
|
-
import '@kubb/
|
|
8
|
-
import 'react';
|
|
5
|
+
import '@kubb/plugin-oas';
|
|
6
|
+
import '@kubb/react/types';
|
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
|
-
import '@kubb/plugin-oas';
|
|
5
|
-
import '@kubb/core/utils';
|
|
6
4
|
import '@kubb/oas';
|
|
7
|
-
import '@kubb/
|
|
8
|
-
import 'react';
|
|
5
|
+
import '@kubb/plugin-oas';
|
|
6
|
+
import '@kubb/react/types';
|
package/dist/components.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-W57BRY5O.js";
|
|
5
|
-
export {
|
|
6
|
-
Client,
|
|
7
|
-
Operations
|
|
8
|
-
};
|
|
1
|
+
import './chunk-YJOVLRSC.js';
|
|
2
|
+
export { Client, Operations } from './chunk-QBFKND4S.js';
|
|
3
|
+
//# sourceMappingURL=components.js.map
|
|
9
4
|
//# sourceMappingURL=components.js.map
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
|