@kubb/plugin-client 3.0.0-alpha.14 → 3.0.0-alpha.16
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-44KNIIBT.cjs +178 -0
- package/dist/chunk-44KNIIBT.cjs.map +1 -0
- package/dist/chunk-HGQQGWKN.js +130 -0
- package/dist/chunk-HGQQGWKN.js.map +1 -0
- package/dist/chunk-NEK3OJBX.cjs +133 -0
- package/dist/chunk-NEK3OJBX.cjs.map +1 -0
- package/dist/chunk-XB4BUZDK.js +169 -0
- package/dist/chunk-XB4BUZDK.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 +3 -4
- package/dist/components.d.cts +37 -4
- package/dist/components.d.ts +37 -4
- package/dist/components.js +1 -2
- package/dist/generators.cjs +8 -4
- package/dist/generators.d.cts +5 -5
- package/dist/generators.d.ts +5 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +9 -107
- 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 +2 -106
- package/dist/index.js.map +1 -1
- package/dist/{types-DETYKDFZ.d.cts → types-j-ah_78Y.d.cts} +23 -47
- package/dist/{types-DETYKDFZ.d.ts → types-j-ah_78Y.d.ts} +23 -47
- package/package.json +14 -13
- package/src/components/Client.tsx +76 -56
- package/src/generators/__snapshots__/deletePet.ts +17 -0
- package/src/generators/__snapshots__/deletePetObject.ts +25 -0
- package/src/generators/__snapshots__/findByTags.ts +12 -0
- package/src/generators/__snapshots__/findByTagsFull.ts +12 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +12 -0
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +12 -0
- package/src/generators/__snapshots__/importPath.ts +12 -0
- package/src/generators/__snapshots__/operations.ts +82 -0
- package/src/generators/__snapshots__/updatePetById.ts +15 -0
- package/src/generators/clientGenerator.tsx +65 -0
- package/src/generators/index.ts +2 -1
- package/src/generators/operationsGenerator.tsx +21 -0
- package/src/plugin.ts +10 -17
- package/src/types.ts +21 -29
- package/dist/chunk-AZDWYBLW.cjs +0 -4
- package/dist/chunk-AZDWYBLW.cjs.map +0 -1
- package/dist/chunk-IPKWNP7B.js +0 -56
- package/dist/chunk-IPKWNP7B.js.map +0 -1
- package/dist/chunk-JKG3C6DG.cjs +0 -58
- package/dist/chunk-JKG3C6DG.cjs.map +0 -1
- package/dist/chunk-KGGPZ6QL.cjs +0 -125
- package/dist/chunk-KGGPZ6QL.cjs.map +0 -1
- package/dist/chunk-YJOVLRSC.js +0 -3
- package/dist/chunk-YJOVLRSC.js.map +0 -1
- package/dist/chunk-YXOI7DUX.js +0 -122
- package/dist/chunk-YXOI7DUX.js.map +0 -1
- package/src/components/__snapshots__/Client/showPetById.ts +0 -8
- package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
- package/src/components/__snapshots__/Query/showPetById.ts +0 -15
- package/src/generators/axiosGenerator.tsx +0 -63
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Client, Operations } from './chunk-HGQQGWKN.js';
|
|
2
|
+
import { createReactGenerator, pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
|
|
3
|
+
import { useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
4
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
5
|
+
import { pluginZodName } from '@kubb/plugin-zod';
|
|
6
|
+
import { useApp, File } from '@kubb/react';
|
|
7
|
+
import { jsxs, jsx } from '@kubb/react/jsx-runtime';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
10
|
+
import { camelCase } from '@kubb/core/transformers';
|
|
11
|
+
import { renderTemplate } from '@kubb/core/utils';
|
|
12
|
+
|
|
13
|
+
var clientGenerator = createReactGenerator({
|
|
14
|
+
name: "client",
|
|
15
|
+
Operation({ options, operation }) {
|
|
16
|
+
const {
|
|
17
|
+
plugin: { output }
|
|
18
|
+
} = useApp();
|
|
19
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
20
|
+
const client = {
|
|
21
|
+
name: getName(operation, { type: "function" }),
|
|
22
|
+
file: getFile(operation)
|
|
23
|
+
};
|
|
24
|
+
const type = {
|
|
25
|
+
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
26
|
+
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
27
|
+
};
|
|
28
|
+
const zod = {
|
|
29
|
+
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
30
|
+
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsxs(File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, children: [
|
|
33
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.importPath }),
|
|
34
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.importPath, isTypeOnly: true }),
|
|
35
|
+
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
File.Import,
|
|
38
|
+
{
|
|
39
|
+
extName: output?.extName,
|
|
40
|
+
name: [
|
|
41
|
+
type.schemas.request?.name,
|
|
42
|
+
type.schemas.response.name,
|
|
43
|
+
type.schemas.pathParams?.name,
|
|
44
|
+
type.schemas.queryParams?.name,
|
|
45
|
+
type.schemas.headerParams?.name,
|
|
46
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
root: client.file.path,
|
|
49
|
+
path: type.file.path,
|
|
50
|
+
isTypeOnly: true
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
Client,
|
|
55
|
+
{
|
|
56
|
+
name: client.name,
|
|
57
|
+
baseURL: options.baseURL,
|
|
58
|
+
dataReturnType: options.dataReturnType,
|
|
59
|
+
pathParamsType: options.pathParamsType,
|
|
60
|
+
typeSchemas: type.schemas,
|
|
61
|
+
operation,
|
|
62
|
+
parser: options.parser,
|
|
63
|
+
zodSchemas: zod.schemas
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var pluginClientName = "plugin-client";
|
|
70
|
+
var pluginClient = createPlugin((options) => {
|
|
71
|
+
const {
|
|
72
|
+
output = { path: "clients" },
|
|
73
|
+
group,
|
|
74
|
+
exclude = [],
|
|
75
|
+
include,
|
|
76
|
+
override = [],
|
|
77
|
+
transformers = {},
|
|
78
|
+
dataReturnType = "data",
|
|
79
|
+
pathParamsType = "inline",
|
|
80
|
+
operations = false,
|
|
81
|
+
importPath = "@kubb/plugin-client/client",
|
|
82
|
+
parser = "client"
|
|
83
|
+
} = options;
|
|
84
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
85
|
+
return {
|
|
86
|
+
name: pluginClientName,
|
|
87
|
+
output: {
|
|
88
|
+
exportType: "barrelNamed",
|
|
89
|
+
...output
|
|
90
|
+
},
|
|
91
|
+
options: {
|
|
92
|
+
parser,
|
|
93
|
+
dataReturnType,
|
|
94
|
+
importPath,
|
|
95
|
+
pathParamsType,
|
|
96
|
+
baseURL: void 0
|
|
97
|
+
},
|
|
98
|
+
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
99
|
+
resolvePath(baseName, pathMode, options2) {
|
|
100
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
101
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
102
|
+
if (mode === "single") {
|
|
103
|
+
return path.resolve(root, output.path);
|
|
104
|
+
}
|
|
105
|
+
if (options2?.tag && group?.type === "tag") {
|
|
106
|
+
const tag = camelCase(options2.tag);
|
|
107
|
+
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
108
|
+
}
|
|
109
|
+
return path.resolve(root, output.path, baseName);
|
|
110
|
+
},
|
|
111
|
+
resolveName(name, type) {
|
|
112
|
+
const resolvedName = camelCase(name, { isFile: type === "file" });
|
|
113
|
+
if (type) {
|
|
114
|
+
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
115
|
+
}
|
|
116
|
+
return resolvedName;
|
|
117
|
+
},
|
|
118
|
+
async buildStart() {
|
|
119
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
120
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
121
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
122
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
123
|
+
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
124
|
+
const operationGenerator = new OperationGenerator(
|
|
125
|
+
{
|
|
126
|
+
...this.plugin.options,
|
|
127
|
+
baseURL
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
oas,
|
|
131
|
+
pluginManager: this.pluginManager,
|
|
132
|
+
plugin: this.plugin,
|
|
133
|
+
contentType: swaggerPlugin.context.contentType,
|
|
134
|
+
exclude,
|
|
135
|
+
include,
|
|
136
|
+
override,
|
|
137
|
+
mode
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
const files = await operationGenerator.build(...[clientGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
|
|
141
|
+
await this.addFile(...files);
|
|
142
|
+
if (this.config.output.exportType) {
|
|
143
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
144
|
+
root,
|
|
145
|
+
output,
|
|
146
|
+
files: this.fileManager.files,
|
|
147
|
+
meta: {
|
|
148
|
+
pluginKey: this.plugin.key
|
|
149
|
+
},
|
|
150
|
+
logger: this.logger
|
|
151
|
+
});
|
|
152
|
+
await this.addFile(...barrelFiles);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
var operationsGenerator = createReactGenerator({
|
|
158
|
+
name: "client",
|
|
159
|
+
Operations({ operations }) {
|
|
160
|
+
const { pluginManager } = useApp();
|
|
161
|
+
const name = "operations";
|
|
162
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: [pluginClientName] });
|
|
163
|
+
return /* @__PURE__ */ jsx(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsx(Operations, { name, operations }) });
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export { clientGenerator, operationsGenerator, pluginClient, pluginClientName };
|
|
168
|
+
//# sourceMappingURL=chunk-XB4BUZDK.js.map
|
|
169
|
+
//# sourceMappingURL=chunk-XB4BUZDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/clientGenerator.tsx","../src/plugin.ts","../src/generators/operationsGenerator.tsx"],"names":["pluginZodName","options","createReactGenerator","useApp","jsx","File"],"mappings":";;;;;;;;;;;;AAQO,IAAM,kBAAkB,oBAAmC,CAAA;AAAA,EAChE,IAAM,EAAA,QAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAA,EAAQ,EAAE,MAAO,EAAA;AAAA,QACf,MAAqB,EAAA,CAAA;AACzB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAY,mBAAoB,EAAA,CAAA;AAE7D,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,MAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA;AAAA,MAC7C,IAAA,EAAM,QAAQ,SAAS,CAAA;AAAA,KACzB,CAAA;AAEA,IAAA,MAAM,IAAO,GAAA;AAAA,MACX,IAAA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E,UAAA,EAAc,EAAA;AACzB,IAAM,MAAA,EAAE,aAAc,EAAA,GAAIC,MAAqB,EAAA,CAAA;AAE/C,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,gBAAgB,CAAA,EAAG,CAAA,CAAA;AAE1F,IAAA,uBACEC,GAACC,CAAAA,IAAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,UAAU,IAAM,EAAA,IAAA,CAAK,IAAM,EAAA,IAAA,EAAM,KAAK,IACzD,EAAA,QAAA,kBAAAD,IAAC,UAAW,EAAA,EAAA,IAAA,EAAY,YAAwB,CAClD,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-XB4BUZDK.js","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: { output },\n } = useApp<PluginClient>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File baseName={client.file.baseName} path={client.file.path} meta={client.file.meta}>\n <File.Import name={'client'} path={options.importPath} />\n <File.Import name={['RequestConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && <File.Import extName={output?.extName} name={[zod.schemas.response.name]} root={client.file.path} path={zod.file.path} />}\n <File.Import\n extName={output?.extName}\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={client.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n operations = false,\n importPath = '@kubb/plugin-client/client',\n parser = 'client',\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {\n parser,\n dataReturnType,\n importPath,\n pathParamsType,\n baseURL: undefined,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...[clientGenerator, operations ? operationsGenerator : undefined].filter(Boolean))\n\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const { pluginManager } = useApp<PluginClient>()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: [pluginClientName] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n"]}
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
1
|
+
{"version":3,"sources":["../client.ts"],"names":["axios"],"mappings":";;;;;;;;;;;AA8Ba,IAAA,aAAA,GAAgBA,uBAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.cjs","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
|
package/dist/client.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ type RequestConfig<TData = unknown> = {
|
|
|
9
9
|
url?: string;
|
|
10
10
|
method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options';
|
|
11
11
|
params?: unknown;
|
|
12
|
-
data?: TData;
|
|
12
|
+
data?: TData | FormData;
|
|
13
13
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
14
14
|
signal?: AbortSignal;
|
|
15
15
|
headers?: AxiosRequestConfig['headers'];
|
package/dist/client.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type RequestConfig<TData = unknown> = {
|
|
|
9
9
|
url?: string;
|
|
10
10
|
method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options';
|
|
11
11
|
params?: unknown;
|
|
12
|
-
data?: TData;
|
|
12
|
+
data?: TData | FormData;
|
|
13
13
|
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
14
14
|
signal?: AbortSignal;
|
|
15
15
|
headers?: AxiosRequestConfig['headers'];
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
1
|
+
{"version":3,"sources":["../client.ts"],"names":[],"mappings":";;;AA8Ba,IAAA,aAAA,GAAgB,MAAM,MAAO,CAAA;AAAA,EACxC,OAAS,EAAA,OAAO,UAAe,KAAA,WAAA,GAAc,UAAa,GAAA,KAAA,CAAA;AAAA,EAC1D,SAAS,OAAO,aAAA,KAAkB,cAAe,IAAK,CAAA,KAAA,CAAM,aAAa,CAAqB,GAAA,KAAA,CAAA;AAChG,CAAC,EAAA;AAEY,IAAA,WAAA,GAAc,OAAsD,MAAsE,KAAA;AACrJ,EAAA,MAAM,UAAU,aAAc,CAAA,OAAA,CAAsC,MAAM,CAAE,CAAA,KAAA,CAAM,CAAC,CAA0B,KAAA;AAC3G,IAAM,MAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACT,EAAA;AAEA,IAAO,cAAQ,GAAA","file":"client.js","sourcesContent":["import axios from 'axios'\n\nimport type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'get' | 'put' | 'patch' | 'post' | 'delete' | 'options'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: AxiosRequestConfig['headers']\n}\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers?: AxiosResponse['headers']\n}\n\nexport const axiosInstance = axios.create({\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? (JSON.parse(AXIOS_HEADERS) as AxiosHeaders) : undefined,\n})\n\nexport const axiosClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const promise = axiosInstance.request<TData, ResponseConfig<TData>>(config).catch((e: AxiosError<TError>) => {\n throw e\n })\n\n return promise\n}\n\nexport default axiosClient\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./chunk-
|
|
4
|
-
var chunkKGGPZ6QL_cjs = require('./chunk-KGGPZ6QL.cjs');
|
|
3
|
+
var chunkNEK3OJBX_cjs = require('./chunk-NEK3OJBX.cjs');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
Object.defineProperty(exports, "Client", {
|
|
9
8
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkNEK3OJBX_cjs.Client; }
|
|
11
10
|
});
|
|
12
11
|
Object.defineProperty(exports, "Operations", {
|
|
13
12
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkNEK3OJBX_cjs.Operations; }
|
|
15
14
|
});
|
|
16
15
|
//# sourceMappingURL=components.cjs.map
|
|
17
16
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { FunctionParams } from '@kubb/react';
|
|
4
|
+
import { KubbNode } from '@kubb/react/types';
|
|
5
|
+
import { P as PluginClient } from './types-j-ah_78Y.cjs';
|
|
2
6
|
import '@kubb/core';
|
|
3
7
|
import '@kubb/fs/types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
/**
|
|
11
|
+
* Name of the function
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
isExportable?: boolean;
|
|
15
|
+
isIndexable?: boolean;
|
|
16
|
+
baseURL: string | undefined;
|
|
17
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
18
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
20
|
+
typeSchemas: OperationSchemas;
|
|
21
|
+
zodSchemas: OperationSchemas | undefined;
|
|
22
|
+
operation: Operation;
|
|
23
|
+
};
|
|
24
|
+
type GetParamsProps = {
|
|
25
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
26
|
+
typeSchemas: OperationSchemas;
|
|
27
|
+
};
|
|
28
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
|
|
29
|
+
declare namespace Client {
|
|
30
|
+
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type OperationsProps = {
|
|
34
|
+
name: string;
|
|
35
|
+
operations: Array<Operation>;
|
|
36
|
+
};
|
|
37
|
+
declare function Operations({ name, operations }: OperationsProps): JSX.Element;
|
|
38
|
+
|
|
39
|
+
export { Client, Operations };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { FunctionParams } from '@kubb/react';
|
|
4
|
+
import { KubbNode } from '@kubb/react/types';
|
|
5
|
+
import { P as PluginClient } from './types-j-ah_78Y.js';
|
|
2
6
|
import '@kubb/core';
|
|
3
7
|
import '@kubb/fs/types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
/**
|
|
11
|
+
* Name of the function
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
isExportable?: boolean;
|
|
15
|
+
isIndexable?: boolean;
|
|
16
|
+
baseURL: string | undefined;
|
|
17
|
+
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
18
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
|
+
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
20
|
+
typeSchemas: OperationSchemas;
|
|
21
|
+
zodSchemas: OperationSchemas | undefined;
|
|
22
|
+
operation: Operation;
|
|
23
|
+
};
|
|
24
|
+
type GetParamsProps = {
|
|
25
|
+
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
26
|
+
typeSchemas: OperationSchemas;
|
|
27
|
+
};
|
|
28
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
|
|
29
|
+
declare namespace Client {
|
|
30
|
+
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type OperationsProps = {
|
|
34
|
+
name: string;
|
|
35
|
+
operations: Array<Operation>;
|
|
36
|
+
};
|
|
37
|
+
declare function Operations({ name, operations }: OperationsProps): JSX.Element;
|
|
38
|
+
|
|
39
|
+
export { Client, Operations };
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk44KNIIBT_cjs = require('./chunk-44KNIIBT.cjs');
|
|
4
|
+
require('./chunk-NEK3OJBX.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "clientGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk44KNIIBT_cjs.clientGenerator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "operationsGenerator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunk44KNIIBT_cjs.operationsGenerator; }
|
|
11
15
|
});
|
|
12
16
|
//# sourceMappingURL=generators.cjs.map
|
|
13
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-j-ah_78Y.cjs';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
import '@kubb/fs/types';
|
|
5
|
-
import '@kubb/oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
5
|
|
|
8
|
-
declare const
|
|
6
|
+
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
|
+
|
|
10
|
+
export { clientGenerator, operationsGenerator };
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-j-ah_78Y.js';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
import '@kubb/fs/types';
|
|
5
|
-
import '@kubb/oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
5
|
|
|
8
|
-
declare const
|
|
6
|
+
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
|
9
|
+
|
|
10
|
+
export { clientGenerator, operationsGenerator };
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { clientGenerator, operationsGenerator } from './chunk-XB4BUZDK.js';
|
|
2
|
+
import './chunk-HGQQGWKN.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,115 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./chunk-
|
|
4
|
-
|
|
5
|
-
var chunkKGGPZ6QL_cjs = require('./chunk-KGGPZ6QL.cjs');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var core = require('@kubb/core');
|
|
8
|
-
var transformers = require('@kubb/core/transformers');
|
|
9
|
-
var utils = require('@kubb/core/utils');
|
|
10
|
-
var pluginOas = require('@kubb/plugin-oas');
|
|
3
|
+
var chunk44KNIIBT_cjs = require('./chunk-44KNIIBT.cjs');
|
|
4
|
+
require('./chunk-NEK3OJBX.cjs');
|
|
11
5
|
|
|
12
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
6
|
|
|
14
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
override = [],
|
|
24
|
-
transformers: transformers$1 = {},
|
|
25
|
-
dataReturnType = "data",
|
|
26
|
-
pathParamsType = "inline",
|
|
27
|
-
templates
|
|
28
|
-
} = options;
|
|
29
|
-
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
30
|
-
return {
|
|
31
|
-
name: pluginClientName,
|
|
32
|
-
output: {
|
|
33
|
-
exportType: "barrelNamed",
|
|
34
|
-
...output
|
|
35
|
-
},
|
|
36
|
-
options: {
|
|
37
|
-
extName: output.extName,
|
|
38
|
-
dataReturnType,
|
|
39
|
-
client: {
|
|
40
|
-
importPath: "@kubb/plugin-client/client",
|
|
41
|
-
methods: ["get", "post", "delete", "put"],
|
|
42
|
-
...options.client
|
|
43
|
-
},
|
|
44
|
-
pathParamsType,
|
|
45
|
-
templates: {
|
|
46
|
-
operations: chunkKGGPZ6QL_cjs.Operations,
|
|
47
|
-
client: chunkKGGPZ6QL_cjs.Client,
|
|
48
|
-
...templates
|
|
49
|
-
},
|
|
50
|
-
baseURL: void 0
|
|
51
|
-
},
|
|
52
|
-
pre: [pluginOas.pluginOasName],
|
|
53
|
-
resolvePath(baseName, pathMode, options2) {
|
|
54
|
-
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
55
|
-
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
56
|
-
if (mode === "single") {
|
|
57
|
-
return path__default.default.resolve(root, output.path);
|
|
58
|
-
}
|
|
59
|
-
if (options2?.tag && group?.type === "tag") {
|
|
60
|
-
const tag = transformers.camelCase(options2.tag);
|
|
61
|
-
return path__default.default.resolve(root, utils.renderTemplate(template, { tag }), baseName);
|
|
62
|
-
}
|
|
63
|
-
return path__default.default.resolve(root, output.path, baseName);
|
|
64
|
-
},
|
|
65
|
-
resolveName(name, type) {
|
|
66
|
-
const resolvedName = transformers.camelCase(name, { isFile: type === "file" });
|
|
67
|
-
if (type) {
|
|
68
|
-
return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
69
|
-
}
|
|
70
|
-
return resolvedName;
|
|
71
|
-
},
|
|
72
|
-
async buildStart() {
|
|
73
|
-
const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
|
|
74
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
75
|
-
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
76
|
-
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
77
|
-
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
78
|
-
const operationGenerator = new pluginOas.OperationGenerator(
|
|
79
|
-
{
|
|
80
|
-
...this.plugin.options,
|
|
81
|
-
baseURL
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
oas,
|
|
85
|
-
pluginManager: this.pluginManager,
|
|
86
|
-
plugin: this.plugin,
|
|
87
|
-
contentType: swaggerPlugin.context.contentType,
|
|
88
|
-
exclude,
|
|
89
|
-
include,
|
|
90
|
-
override,
|
|
91
|
-
mode
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
const files = await operationGenerator.build(chunkJKG3C6DG_cjs.axiosGenerator);
|
|
95
|
-
await this.addFile(...files);
|
|
96
|
-
if (this.config.output.exportType) {
|
|
97
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
98
|
-
root,
|
|
99
|
-
output,
|
|
100
|
-
files: this.fileManager.files,
|
|
101
|
-
meta: {
|
|
102
|
-
pluginKey: this.plugin.key
|
|
103
|
-
},
|
|
104
|
-
logger: this.logger
|
|
105
|
-
});
|
|
106
|
-
await this.addFile(...barrelFiles);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
8
|
+
Object.defineProperty(exports, "pluginClient", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk44KNIIBT_cjs.pluginClient; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "pluginClientName", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunk44KNIIBT_cjs.pluginClientName; }
|
|
110
15
|
});
|
|
111
|
-
|
|
112
|
-
exports.pluginClient = pluginClient;
|
|
113
|
-
exports.pluginClientName = pluginClientName;
|
|
114
16
|
//# sourceMappingURL=index.cjs.map
|
|
115
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-j-ah_78Y.cjs';
|
|
3
3
|
import '@kubb/fs/types';
|
|
4
|
-
import '@kubb/oas';
|
|
5
4
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
5
|
|
|
8
6
|
declare const pluginClientName = "plugin-client";
|
|
9
7
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-j-ah_78Y.js';
|
|
3
3
|
import '@kubb/fs/types';
|
|
4
|
-
import '@kubb/oas';
|
|
5
4
|
import '@kubb/plugin-oas';
|
|
6
|
-
import '@kubb/react/types';
|
|
7
5
|
|
|
8
6
|
declare const pluginClientName = "plugin-client";
|
|
9
7
|
declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
|