@genapi/presets 3.7.0 → 4.0.0
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/README.md +108 -0
- package/dist/_shared/schema/compiler.d.mts +10 -0
- package/dist/_shared/schema/compiler.mjs +68 -0
- package/dist/_shared/schema/config.d.mts +12 -0
- package/dist/_shared/schema/config.mjs +45 -0
- package/dist/_shared/schema/index.d.mts +4 -0
- package/dist/_shared/schema/index.mjs +5 -0
- package/dist/_shared/schema/parser.d.mts +14 -0
- package/dist/_shared/schema/parser.mjs +49 -0
- package/dist/axios/index.d.mts +8 -8
- package/dist/axios/index.mjs +11 -8
- package/dist/axios/js/config/index.d.mts +4 -1
- package/dist/axios/js/config/index.mjs +18 -1
- package/dist/axios/js/index.d.mts +16 -3
- package/dist/axios/js/index.mjs +16 -4
- package/dist/axios/js/parser/index.d.mts +5 -2
- package/dist/axios/js/parser/index.mjs +38 -2
- package/dist/axios/ts/config/index.d.mts +4 -1
- package/dist/axios/ts/config/index.mjs +20 -1
- package/dist/axios/ts/index.d.mts +16 -3
- package/dist/axios/ts/index.mjs +16 -4
- package/dist/axios/ts/parser/index.d.mts +5 -2
- package/dist/axios/ts/parser/index.mjs +37 -2
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/fetch/index.d.mts +9 -8
- package/dist/fetch/index.mjs +13 -8
- package/dist/fetch/js/config/index.d.mts +4 -1
- package/dist/fetch/js/config/index.mjs +12 -1
- package/dist/fetch/js/index.d.mts +16 -3
- package/dist/fetch/js/index.mjs +16 -4
- package/dist/fetch/js/parser/index.d.mts +5 -2
- package/dist/fetch/js/parser/index.mjs +52 -2
- package/dist/fetch/schema/compiler/index.d.mts +6 -0
- package/dist/fetch/schema/compiler/index.mjs +7 -0
- package/dist/fetch/schema/config/index.d.mts +6 -0
- package/dist/fetch/schema/config/index.mjs +7 -0
- package/dist/fetch/schema/index.d.mts +19 -0
- package/dist/fetch/schema/index.mjs +18 -0
- package/dist/fetch/schema/parser/index.d.mts +2 -0
- package/dist/fetch/schema/parser/index.mjs +3 -0
- package/dist/fetch/ts/config/index.d.mts +4 -1
- package/dist/fetch/ts/config/index.mjs +10 -1
- package/dist/fetch/ts/index.d.mts +16 -3
- package/dist/fetch/ts/index.mjs +16 -4
- package/dist/fetch/ts/parser/index.d.mts +5 -2
- package/dist/fetch/ts/parser/index.mjs +47 -2
- package/dist/got/index.d.mts +8 -8
- package/dist/got/index.mjs +11 -8
- package/dist/got/js/config/index.d.mts +4 -1
- package/dist/got/js/config/index.mjs +18 -1
- package/dist/got/js/index.d.mts +16 -3
- package/dist/got/js/index.mjs +16 -4
- package/dist/got/js/parser/index.d.mts +5 -2
- package/dist/got/js/parser/index.mjs +44 -2
- package/dist/got/ts/config/index.d.mts +4 -1
- package/dist/got/ts/config/index.mjs +20 -1
- package/dist/got/ts/index.d.mts +16 -3
- package/dist/got/ts/index.mjs +16 -4
- package/dist/got/ts/parser/index.d.mts +5 -2
- package/dist/got/ts/parser/index.mjs +44 -2
- package/dist/index.d.mts +21 -50
- package/dist/index.mjs +15 -43
- package/dist/ky/index.d.mts +8 -8
- package/dist/ky/index.mjs +11 -8
- package/dist/ky/js/config/index.d.mts +4 -1
- package/dist/ky/js/config/index.mjs +18 -1
- package/dist/ky/js/index.d.mts +16 -3
- package/dist/ky/js/index.mjs +16 -4
- package/dist/ky/js/parser/index.d.mts +5 -2
- package/dist/ky/js/parser/index.mjs +44 -2
- package/dist/ky/ts/config/index.d.mts +4 -1
- package/dist/ky/ts/config/index.mjs +20 -1
- package/dist/ky/ts/index.d.mts +16 -3
- package/dist/ky/ts/index.mjs +16 -4
- package/dist/ky/ts/parser/index.d.mts +5 -2
- package/dist/ky/ts/parser/index.mjs +43 -2
- package/dist/ofetch/index.d.mts +9 -8
- package/dist/ofetch/index.mjs +13 -8
- package/dist/ofetch/js/config/index.d.mts +4 -1
- package/dist/ofetch/js/config/index.mjs +18 -1
- package/dist/ofetch/js/index.d.mts +16 -3
- package/dist/ofetch/js/index.mjs +16 -4
- package/dist/ofetch/js/parser/index.d.mts +5 -2
- package/dist/ofetch/js/parser/index.mjs +42 -2
- package/dist/ofetch/schema/compiler/index.d.mts +6 -0
- package/dist/ofetch/schema/compiler/index.mjs +7 -0
- package/dist/ofetch/schema/config/index.d.mts +6 -0
- package/dist/ofetch/schema/config/index.mjs +10 -0
- package/dist/ofetch/schema/index.d.mts +19 -0
- package/dist/ofetch/schema/index.mjs +18 -0
- package/dist/ofetch/schema/parser/index.d.mts +2 -0
- package/dist/ofetch/schema/parser/index.mjs +3 -0
- package/dist/ofetch/ts/config/index.d.mts +4 -1
- package/dist/ofetch/ts/config/index.mjs +19 -1
- package/dist/ofetch/ts/index.d.mts +16 -3
- package/dist/ofetch/ts/index.mjs +16 -4
- package/dist/ofetch/ts/parser/index.d.mts +5 -2
- package/dist/ofetch/ts/parser/index.mjs +41 -2
- package/dist/{index.d-Ceqrd7FN.d.mts → tanstack/colada/config/index.d.mts} +2 -3
- package/dist/tanstack/colada/config/index.mjs +16 -0
- package/dist/tanstack/colada/index.d.mts +18 -0
- package/dist/tanstack/colada/index.mjs +17 -0
- package/dist/tanstack/colada/parser/index.d.mts +6 -0
- package/dist/tanstack/colada/parser/index.mjs +71 -0
- package/dist/tanstack/index.d.mts +10 -0
- package/dist/tanstack/index.mjs +14 -0
- package/dist/{index.d-7vIBcqWp.d.mts → tanstack/react/config/index.d.mts} +2 -3
- package/dist/tanstack/react/config/index.mjs +16 -0
- package/dist/tanstack/react/index.d.mts +18 -0
- package/dist/tanstack/react/index.mjs +17 -0
- package/dist/tanstack/react/parser/index.d.mts +6 -0
- package/dist/tanstack/react/parser/index.mjs +75 -0
- package/dist/{index.d-C5ya5SE3.d.mts → tanstack/vue/config/index.d.mts} +2 -3
- package/dist/tanstack/vue/config/index.mjs +16 -0
- package/dist/tanstack/vue/index.d.mts +18 -0
- package/dist/tanstack/vue/index.mjs +17 -0
- package/dist/tanstack/vue/parser/index.d.mts +6 -0
- package/dist/tanstack/vue/parser/index.mjs +71 -0
- package/dist/uni/index.d.mts +8 -8
- package/dist/uni/index.mjs +11 -8
- package/dist/uni/js/config/index.d.mts +4 -1
- package/dist/uni/js/config/index.mjs +18 -1
- package/dist/uni/js/index.d.mts +16 -3
- package/dist/uni/js/index.mjs +16 -4
- package/dist/uni/js/parser/index.d.mts +5 -2
- package/dist/uni/js/parser/index.mjs +38 -2
- package/dist/uni/ts/config/index.d.mts +4 -1
- package/dist/uni/ts/config/index.mjs +20 -1
- package/dist/uni/ts/index.d.mts +16 -3
- package/dist/uni/ts/index.mjs +16 -4
- package/dist/uni/ts/parser/index.d.mts +5 -2
- package/dist/uni/ts/parser/index.mjs +37 -2
- package/package.json +26 -6
- package/dist/axios-C--VNFKW.mjs +0 -13
- package/dist/chunk-BL35Yyzp.mjs +0 -12
- package/dist/config-B89EoGE7.mjs +0 -21
- package/dist/config-BGwXcXx1.mjs +0 -21
- package/dist/config-BHBub1xl.mjs +0 -12
- package/dist/config-BJZnXcL3.mjs +0 -14
- package/dist/config-C94x0Nge.mjs +0 -21
- package/dist/config-CEngTpXa.mjs +0 -21
- package/dist/config-CwmGeydd.mjs +0 -19
- package/dist/config-DdUVYIe0.mjs +0 -19
- package/dist/config-DgC2f2AO.mjs +0 -19
- package/dist/config-Dm0OCPw8.mjs +0 -19
- package/dist/config-Dn-mxTew.mjs +0 -19
- package/dist/config-aVU8JEKy.mjs +0 -21
- package/dist/fetch-TYDXDaTS.mjs +0 -13
- package/dist/got-D5A7dJdZ.mjs +0 -13
- package/dist/index.d-1kS19nJx.d.mts +0 -18
- package/dist/index.d-1qaowKKm.d.mts +0 -18
- package/dist/index.d-42t92mX0.d.mts +0 -7
- package/dist/index.d-B0xaEiBX.d.mts +0 -18
- package/dist/index.d-B1m7PaBv.d.mts +0 -14
- package/dist/index.d-B6j2V4Az.d.mts +0 -18
- package/dist/index.d-BCWDJjEV.d.mts +0 -7
- package/dist/index.d-BN2_wiGD.d.mts +0 -18
- package/dist/index.d-BNkgVflG.d.mts +0 -14
- package/dist/index.d-BY4lF6QY.d.mts +0 -7
- package/dist/index.d-BxDzXRov.d.mts +0 -12
- package/dist/index.d-BxQraJfG.d.mts +0 -18
- package/dist/index.d-Bxgqqjp3.d.mts +0 -7
- package/dist/index.d-C0EKSJ26.d.mts +0 -7
- package/dist/index.d-C6gpVbqC.d.mts +0 -12
- package/dist/index.d-CFvCqVRj.d.mts +0 -7
- package/dist/index.d-CJ27pjS6.d.mts +0 -7
- package/dist/index.d-CM3KHaZM.d.mts +0 -12
- package/dist/index.d-CTkBXgsL.d.mts +0 -7
- package/dist/index.d-CXNw0ZkA.d.mts +0 -14
- package/dist/index.d-C_cfONoz.d.mts +0 -14
- package/dist/index.d-Cgflcv1m.d.mts +0 -18
- package/dist/index.d-CmW7DwIV.d.mts +0 -18
- package/dist/index.d-DDTGaUmA.d.mts +0 -14
- package/dist/index.d-DHMHzs8Q.d.mts +0 -14
- package/dist/index.d-DJv4EMYu.d.mts +0 -7
- package/dist/index.d-DOPIfZ0r.d.mts +0 -12
- package/dist/index.d-Dd6ZDpp9.d.mts +0 -12
- package/dist/index.d-DgbGF4C3.d.mts +0 -12
- package/dist/index.d-DmOkv7N9.d.mts +0 -18
- package/dist/index.d-DpQbWiOh.d.mts +0 -14
- package/dist/index.d-Dvtsr9g-.d.mts +0 -14
- package/dist/index.d-LlaJb0pD.d.mts +0 -18
- package/dist/index.d-RZUAACu-.d.mts +0 -14
- package/dist/index.d-SxIr6Uhl.d.mts +0 -18
- package/dist/index.d-TD1X3MeU.d.mts +0 -14
- package/dist/index.d-mJ3Pcxey.d.mts +0 -14
- package/dist/index.d-mXlHJ3vm.d.mts +0 -18
- package/dist/index.d-xPgxVw9l.d.mts +0 -14
- package/dist/js-BHy43BOA.mjs +0 -19
- package/dist/js-CsFu-S2j.mjs +0 -19
- package/dist/js-SMul0x9Q.mjs +0 -19
- package/dist/js-Swp-o6ZG.mjs +0 -19
- package/dist/js-jTe7QP2M.mjs +0 -19
- package/dist/js-rCsJDgHU.mjs +0 -19
- package/dist/ky--lXnn0gU.mjs +0 -13
- package/dist/ofetch-qhtvI1gy.mjs +0 -13
- package/dist/parser-820U-7tY.mjs +0 -79
- package/dist/parser-BEbsKXRG.mjs +0 -74
- package/dist/parser-BMWMb1tW.mjs +0 -65
- package/dist/parser-BMaYANAS.mjs +0 -70
- package/dist/parser-BOXlubkg.mjs +0 -64
- package/dist/parser-B_pvME5o.mjs +0 -71
- package/dist/parser-By1vGa1J.mjs +0 -65
- package/dist/parser-C267rNUI.mjs +0 -71
- package/dist/parser-CFUtEOtZ.mjs +0 -69
- package/dist/parser-CedZCyxl.mjs +0 -68
- package/dist/parser-OUoEsF2d.mjs +0 -64
- package/dist/parser-kk99DwsW.mjs +0 -71
- package/dist/ts-B-VDMOmJ.mjs +0 -19
- package/dist/ts-CBFVpM-p.mjs +0 -19
- package/dist/ts-CBWxAza5.mjs +0 -19
- package/dist/ts-CKsdt6vA.mjs +0 -19
- package/dist/ts-Cnuezdyy.mjs +0 -19
- package/dist/ts-ILF3D-J-.mjs +0 -19
- package/dist/uni-CQMaFViG.mjs +0 -13
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import * as _genapi_pipeline0 from "@genapi/pipeline";
|
|
4
|
+
import { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
5
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
6
|
+
|
|
7
|
+
//#region src/tanstack/vue/index.d.ts
|
|
8
|
+
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
|
+
declare namespace openapiPipeline {
|
|
10
|
+
var config: typeof config;
|
|
11
|
+
var original: typeof _genapi_pipeline0.original;
|
|
12
|
+
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
|
+
var compiler: typeof _genapi_pipeline0.compiler;
|
|
14
|
+
var generate: typeof _genapi_pipeline0.generate;
|
|
15
|
+
var dest: typeof _genapi_pipeline0.dest;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import pipeline, { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
4
|
+
|
|
5
|
+
//#region src/tanstack/vue/index.ts
|
|
6
|
+
function openapiPipeline(userConfig) {
|
|
7
|
+
return pipeline((userConfig) => config(userConfig), (configRead) => original(configRead), (configRead) => parser(configRead), (configRead) => compiler(configRead), (configRead) => generate(configRead), (configRead) => dest(configRead))(userConfig);
|
|
8
|
+
}
|
|
9
|
+
openapiPipeline.config = config;
|
|
10
|
+
openapiPipeline.original = original;
|
|
11
|
+
openapiPipeline.parser = parser;
|
|
12
|
+
openapiPipeline.compiler = compiler;
|
|
13
|
+
openapiPipeline.generate = generate;
|
|
14
|
+
openapiPipeline.dest = dest;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createParser, parseMethodMetadata, parseMethodParameters, transformBodyStringify, transformFetchBody, transformHeaderOptions, transformParameters, transformQueryParams, transformUrlSyntax } from "@genapi/parser";
|
|
2
|
+
|
|
3
|
+
//#region src/tanstack/vue/parser/index.ts
|
|
4
|
+
function hookName(fetcherName) {
|
|
5
|
+
return `use${fetcherName.charAt(0).toUpperCase()}${fetcherName.slice(1)}`;
|
|
6
|
+
}
|
|
7
|
+
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
8
|
+
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
9
|
+
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
+
interfaces.push(...attachInters);
|
|
11
|
+
const fetcherParams = [...parameters];
|
|
12
|
+
fetcherParams.push({
|
|
13
|
+
name: "config",
|
|
14
|
+
type: "RequestInit",
|
|
15
|
+
required: false
|
|
16
|
+
});
|
|
17
|
+
if (config.method.toLowerCase() !== "get") options.unshift(["method", `"${config.method}"`]);
|
|
18
|
+
transformHeaderOptions("body", {
|
|
19
|
+
options,
|
|
20
|
+
parameters
|
|
21
|
+
});
|
|
22
|
+
options.push(["...", "config"]);
|
|
23
|
+
const { spaceResponseType } = transformParameters(parameters, {
|
|
24
|
+
syntax: "typescript",
|
|
25
|
+
configRead,
|
|
26
|
+
description,
|
|
27
|
+
interfaces,
|
|
28
|
+
responseType
|
|
29
|
+
});
|
|
30
|
+
transformBodyStringify("body", {
|
|
31
|
+
options,
|
|
32
|
+
parameters
|
|
33
|
+
});
|
|
34
|
+
url = transformQueryParams("query", {
|
|
35
|
+
body,
|
|
36
|
+
options,
|
|
37
|
+
url
|
|
38
|
+
});
|
|
39
|
+
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
40
|
+
const fetchBody = transformFetchBody(url, options, spaceResponseType);
|
|
41
|
+
functions.push({
|
|
42
|
+
export: true,
|
|
43
|
+
async: true,
|
|
44
|
+
name,
|
|
45
|
+
description,
|
|
46
|
+
parameters: fetcherParams,
|
|
47
|
+
body: [...body, ...fetchBody]
|
|
48
|
+
});
|
|
49
|
+
const isRead = ["get", "head"].includes(config.method.toLowerCase());
|
|
50
|
+
const hook = hookName(name);
|
|
51
|
+
const paramNames = fetcherParams.map((p) => p.name).join(", ");
|
|
52
|
+
if (isRead) {
|
|
53
|
+
const queryKeyItems = `'${name}', ${paramNames}`;
|
|
54
|
+
functions.push({
|
|
55
|
+
export: true,
|
|
56
|
+
name: hook,
|
|
57
|
+
description: [`@wraps ${name}`],
|
|
58
|
+
parameters: fetcherParams,
|
|
59
|
+
body: [`return useQuery({ queryKey: [${queryKeyItems}], queryFn: () => ${name}(${paramNames}) })`]
|
|
60
|
+
});
|
|
61
|
+
} else functions.push({
|
|
62
|
+
export: true,
|
|
63
|
+
name: hook,
|
|
64
|
+
description: description ? [...Array.isArray(description) ? description : [description], `@wraps ${name}`] : [`@wraps ${name}`],
|
|
65
|
+
parameters: [],
|
|
66
|
+
body: [`return useMutation({ mutationFn: ${name} })`]
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { parser };
|
package/dist/uni/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
import { openapiPipeline$6 as openapiPipeline } from "../index.d-mXlHJ3vm.mjs";
|
|
4
|
-
import "../index.d-DHMHzs8Q.mjs";
|
|
5
|
-
import "../index.d-CFvCqVRj.mjs";
|
|
6
|
-
import { openapiPipeline$4 as openapiPipeline$1 } from "../index.d-1kS19nJx.mjs";
|
|
7
|
-
import "../index.d-C6gpVbqC.mjs";
|
|
1
|
+
import openapiPipeline from "./js/index.mjs";
|
|
2
|
+
import openapiPipeline$1 from "./ts/index.mjs";
|
|
8
3
|
|
|
9
|
-
|
|
4
|
+
//#region src/uni/index.d.ts
|
|
5
|
+
declare namespace index_d_exports {
|
|
6
|
+
export { openapiPipeline as js, openapiPipeline$1 as ts };
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { openapiPipeline as js, index_d_exports as t, openapiPipeline$1 as ts };
|
package/dist/uni/index.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import "../config-CEngTpXa.mjs";
|
|
5
|
-
import "../parser-BOXlubkg.mjs";
|
|
6
|
-
import { ts_default$5 as ts_default } from "../ts-B-VDMOmJ.mjs";
|
|
7
|
-
import "../uni-CQMaFViG.mjs";
|
|
1
|
+
import { t as __exportAll } from "../chunk-DQk6qfdC.mjs";
|
|
2
|
+
import openapiPipeline from "./js/index.mjs";
|
|
3
|
+
import openapiPipeline$1 from "./ts/index.mjs";
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
//#region src/uni/index.ts
|
|
6
|
+
var uni_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
js: () => openapiPipeline,
|
|
8
|
+
ts: () => openapiPipeline$1
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { openapiPipeline as js, uni_exports as t, openapiPipeline$1 as ts };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
+
//#region src/uni/js/config/index.d.ts
|
|
4
|
+
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
+
//#endregion
|
|
3
6
|
export { config };
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
import { config
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
|
+
import { replaceMainext } from "@genapi/parser";
|
|
2
3
|
|
|
4
|
+
//#region src/uni/js/config/index.ts
|
|
5
|
+
function config(userConfig) {
|
|
6
|
+
userConfig.meta = userConfig.meta || {};
|
|
7
|
+
userConfig.meta.import = userConfig.meta.import || {};
|
|
8
|
+
userConfig.output = userConfig.output || {};
|
|
9
|
+
userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
|
|
10
|
+
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
11
|
+
const configRead = config$1(userConfig);
|
|
12
|
+
configRead.graphs.imports.push({
|
|
13
|
+
name: "http",
|
|
14
|
+
value: userConfig.meta.import.http
|
|
15
|
+
});
|
|
16
|
+
return configRead;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
3
20
|
export { config };
|
package/dist/uni/js/index.d.mts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import * as _genapi_pipeline0 from "@genapi/pipeline";
|
|
4
|
+
import { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
5
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
4
6
|
|
|
7
|
+
//#region src/uni/js/index.d.ts
|
|
8
|
+
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
|
+
declare namespace openapiPipeline {
|
|
10
|
+
var config: typeof config;
|
|
11
|
+
var original: typeof _genapi_pipeline0.original;
|
|
12
|
+
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
|
+
var compiler: typeof _genapi_pipeline0.compiler;
|
|
14
|
+
var generate: typeof _genapi_pipeline0.generate;
|
|
15
|
+
var dest: typeof _genapi_pipeline0.dest;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
5
18
|
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
package/dist/uni/js/index.mjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { config
|
|
2
|
-
import { parser
|
|
3
|
-
import { compiler
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import pipeline, { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
//#region src/uni/js/index.ts
|
|
6
|
+
function openapiPipeline(userConfig) {
|
|
7
|
+
return pipeline((userConfig) => config(userConfig), (configRead) => original(configRead), (configRead) => parser(configRead), (configRead) => compiler(configRead), (configRead) => generate(configRead), (configRead) => dest(configRead))(userConfig);
|
|
8
|
+
}
|
|
9
|
+
openapiPipeline.config = config;
|
|
10
|
+
openapiPipeline.original = original;
|
|
11
|
+
openapiPipeline.parser = parser;
|
|
12
|
+
openapiPipeline.compiler = compiler;
|
|
13
|
+
openapiPipeline.generate = generate;
|
|
14
|
+
openapiPipeline.dest = dest;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/uni/js/parser/index.d.ts
|
|
4
|
+
declare const parser: (configRead: _genapi_shared0.ApiPipeline.ConfigRead) => _genapi_shared0.ApiPipeline.ConfigRead;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parser };
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodParameters, transformParameters, transformUrlSyntax } from "@genapi/parser";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/uni/js/parser/index.ts
|
|
4
|
+
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
|
+
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
|
|
6
|
+
body: "data",
|
|
7
|
+
query: "params"
|
|
8
|
+
});
|
|
9
|
+
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
10
|
+
options.push(["...", "config"]);
|
|
11
|
+
interfaces.push(...attachInters);
|
|
12
|
+
parameters.push({
|
|
13
|
+
type: "import('@uni-helper/uni-network').UnConfig<never>",
|
|
14
|
+
name: "config",
|
|
15
|
+
required: false
|
|
16
|
+
});
|
|
17
|
+
options.unshift("url");
|
|
18
|
+
options.unshift(["method", `"${config.method}"`]);
|
|
19
|
+
if (configRead.config.meta?.baseURL) options.unshift("baseURL");
|
|
20
|
+
transformParameters(parameters, {
|
|
21
|
+
syntax: "ecmascript",
|
|
22
|
+
configRead,
|
|
23
|
+
description,
|
|
24
|
+
interfaces,
|
|
25
|
+
responseType,
|
|
26
|
+
generic: "import('@uni-helper/uni-network').UnResponse<{__type__}>"
|
|
27
|
+
});
|
|
28
|
+
url = transformUrlSyntax(url);
|
|
29
|
+
functions.push({
|
|
30
|
+
export: true,
|
|
31
|
+
name,
|
|
32
|
+
description,
|
|
33
|
+
parameters,
|
|
34
|
+
body: [`const url = ${url}`, `return http.request({ ${literalFieldsToString(options)} })`]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { parser };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
+
//#region src/uni/ts/config/index.d.ts
|
|
4
|
+
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
+
//#endregion
|
|
3
6
|
export { config };
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import { config
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
2
|
|
|
3
|
+
//#region src/uni/ts/config/index.ts
|
|
4
|
+
function config(userConfig) {
|
|
5
|
+
userConfig.meta = userConfig.meta || {};
|
|
6
|
+
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
+
userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
|
|
8
|
+
const configRead = config$1(userConfig);
|
|
9
|
+
configRead.graphs.imports.push({
|
|
10
|
+
name: "http",
|
|
11
|
+
names: userConfig.meta.import.http === "@uni-helper/uni-network" ? ["UnConfig"] : void 0,
|
|
12
|
+
value: userConfig.meta.import.http
|
|
13
|
+
});
|
|
14
|
+
if (userConfig.meta.import.http !== "@uni-helper/uni-network") configRead.graphs.imports.push({
|
|
15
|
+
names: ["UnConfig"],
|
|
16
|
+
value: "@uni-helper/uni-network"
|
|
17
|
+
});
|
|
18
|
+
return configRead;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
3
22
|
export { config };
|
package/dist/uni/ts/index.d.mts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import * as _genapi_pipeline0 from "@genapi/pipeline";
|
|
4
|
+
import { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
5
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
4
6
|
|
|
7
|
+
//#region src/uni/ts/index.d.ts
|
|
8
|
+
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
|
+
declare namespace openapiPipeline {
|
|
10
|
+
var config: typeof config;
|
|
11
|
+
var original: typeof _genapi_pipeline0.original;
|
|
12
|
+
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
|
+
var compiler: typeof _genapi_pipeline0.compiler;
|
|
14
|
+
var generate: typeof _genapi_pipeline0.generate;
|
|
15
|
+
var dest: typeof _genapi_pipeline0.dest;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
5
18
|
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
package/dist/uni/ts/index.mjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { config
|
|
2
|
-
import { parser
|
|
3
|
-
import { compiler
|
|
1
|
+
import { config } from "./config/index.mjs";
|
|
2
|
+
import { parser } from "./parser/index.mjs";
|
|
3
|
+
import pipeline, { compiler, dest, generate, original } from "@genapi/pipeline";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
//#region src/uni/ts/index.ts
|
|
6
|
+
function openapiPipeline(userConfig) {
|
|
7
|
+
return pipeline((userConfig) => config(userConfig), (configRead) => original(configRead), (configRead) => parser(configRead), (configRead) => compiler(configRead), (configRead) => generate(configRead), (configRead) => dest(configRead))(userConfig);
|
|
8
|
+
}
|
|
9
|
+
openapiPipeline.config = config;
|
|
10
|
+
openapiPipeline.original = original;
|
|
11
|
+
openapiPipeline.parser = parser;
|
|
12
|
+
openapiPipeline.compiler = compiler;
|
|
13
|
+
openapiPipeline.generate = generate;
|
|
14
|
+
openapiPipeline.dest = dest;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/uni/ts/parser/index.d.ts
|
|
4
|
+
declare const parser: (configRead: _genapi_shared0.ApiPipeline.ConfigRead) => _genapi_shared0.ApiPipeline.ConfigRead;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { parser };
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodParameters, transformParameters, transformUrlSyntax } from "@genapi/parser";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/uni/ts/parser/index.ts
|
|
4
|
+
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
|
+
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
|
|
6
|
+
body: "data",
|
|
7
|
+
query: "params"
|
|
8
|
+
});
|
|
9
|
+
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
10
|
+
options.push(["...", "config"]);
|
|
11
|
+
interfaces.push(...attachInters);
|
|
12
|
+
parameters.push({
|
|
13
|
+
name: "config",
|
|
14
|
+
type: "UnConfig<never>",
|
|
15
|
+
required: false
|
|
16
|
+
});
|
|
17
|
+
options.unshift("url");
|
|
18
|
+
options.unshift(["method", `"${config.method}"`]);
|
|
19
|
+
if (configRead.config.meta?.baseURL) options.unshift("baseURL");
|
|
20
|
+
const { spaceResponseType } = transformParameters(parameters, {
|
|
21
|
+
syntax: "typescript",
|
|
22
|
+
configRead,
|
|
23
|
+
description,
|
|
24
|
+
interfaces,
|
|
25
|
+
responseType
|
|
26
|
+
});
|
|
27
|
+
url = transformUrlSyntax(url);
|
|
28
|
+
functions.push({
|
|
29
|
+
export: true,
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
parameters,
|
|
33
|
+
body: [`const url = ${url}`, `return http.request<${spaceResponseType}>({ ${literalFieldsToString(options)} })`]
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { parser };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genapi/presets",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"author": "Hairyf <wwu710632@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/hairyf/genapi#readme",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./dist/index.mjs",
|
|
20
|
+
"./package.json": "./package.json",
|
|
20
21
|
"./swag-axios-js": {
|
|
21
22
|
"types": "./dist/axios/js/index.d.mts",
|
|
22
23
|
"default": "./dist/axios/js/index.mjs"
|
|
@@ -56,19 +57,38 @@
|
|
|
56
57
|
"./swag-ofetch-ts": {
|
|
57
58
|
"types": "./dist/ofetch/ts/index.d.mts",
|
|
58
59
|
"default": "./dist/ofetch/ts/index.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./tanstack-react": {
|
|
62
|
+
"types": "./dist/tanstack/react/index.d.mts",
|
|
63
|
+
"default": "./dist/tanstack/react/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./tanstack-vue": {
|
|
66
|
+
"types": "./dist/tanstack/vue/index.d.mts",
|
|
67
|
+
"default": "./dist/tanstack/vue/index.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./colada": {
|
|
70
|
+
"types": "./dist/tanstack/colada/index.d.mts",
|
|
71
|
+
"default": "./dist/tanstack/colada/index.mjs"
|
|
59
72
|
}
|
|
60
73
|
},
|
|
74
|
+
"main": "./dist/index.mjs",
|
|
75
|
+
"module": "./dist/index.mjs",
|
|
76
|
+
"types": "./dist/index.d.mts",
|
|
61
77
|
"files": [
|
|
62
78
|
"dist"
|
|
63
79
|
],
|
|
64
80
|
"dependencies": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"@genapi/
|
|
68
|
-
"@genapi/
|
|
81
|
+
"knitwork-x": "^0.2.0",
|
|
82
|
+
"openapi-specification-types": "^0.3.0",
|
|
83
|
+
"@genapi/parser": "4.0.0",
|
|
84
|
+
"@genapi/pipeline": "4.0.0",
|
|
85
|
+
"@genapi/shared": "4.0.0"
|
|
69
86
|
},
|
|
70
87
|
"scripts": {
|
|
71
88
|
"build": "tsdown",
|
|
72
|
-
"
|
|
89
|
+
"dev": "tsdown --watch",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"typecheck": "tsc --noEmit",
|
|
92
|
+
"automd": "automd"
|
|
73
93
|
}
|
|
74
94
|
}
|
package/dist/axios-C--VNFKW.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { __export } from "./chunk-BL35Yyzp.mjs";
|
|
2
|
-
import { js_default } from "./js-SMul0x9Q.mjs";
|
|
3
|
-
import { ts_default } from "./ts-CBFVpM-p.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/axios/index.ts
|
|
6
|
-
var axios_exports = {};
|
|
7
|
-
__export(axios_exports, {
|
|
8
|
-
js: () => js_default,
|
|
9
|
-
ts: () => ts_default
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { axios_exports };
|
package/dist/chunk-BL35Yyzp.mjs
DELETED
package/dist/config-B89EoGE7.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
|
|
3
|
-
//#region src/axios/ts/config/index.ts
|
|
4
|
-
function config$1(userConfig) {
|
|
5
|
-
userConfig.import = userConfig.import || {};
|
|
6
|
-
userConfig.import.http = userConfig.import.http || "axios";
|
|
7
|
-
const configRead = config(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
name: "http",
|
|
10
|
-
names: userConfig.import.http === "axios" ? ["AxiosRequestConfig"] : void 0,
|
|
11
|
-
value: userConfig.import.http
|
|
12
|
-
});
|
|
13
|
-
if (userConfig.import.http !== "axios") configRead.graphs.imports.push({
|
|
14
|
-
names: ["AxiosRequestConfig"],
|
|
15
|
-
value: "axios"
|
|
16
|
-
});
|
|
17
|
-
return configRead;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { config$1 };
|
package/dist/config-BGwXcXx1.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
|
|
3
|
-
//#region src/ky/ts/config/index.ts
|
|
4
|
-
function config$1(userConfig) {
|
|
5
|
-
userConfig.import = userConfig.import || {};
|
|
6
|
-
userConfig.import.http = userConfig.import.http || "ky";
|
|
7
|
-
const configRead = config(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
name: "http",
|
|
10
|
-
names: userConfig.import.http === "ky" ? ["Options"] : void 0,
|
|
11
|
-
value: userConfig.import.http
|
|
12
|
-
});
|
|
13
|
-
if (userConfig.import.http !== "ky") configRead.graphs.imports.push({
|
|
14
|
-
names: ["Options"],
|
|
15
|
-
value: "ky"
|
|
16
|
-
});
|
|
17
|
-
return configRead;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { config$1 as config$7 };
|
package/dist/config-BHBub1xl.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
|
|
3
|
-
//#region src/fetch/ts/config/index.ts
|
|
4
|
-
function config$1(userConfig) {
|
|
5
|
-
userConfig.import = userConfig.import || {};
|
|
6
|
-
userConfig.import.http = userConfig.import.http || "axios";
|
|
7
|
-
const configRead = config(userConfig);
|
|
8
|
-
return configRead;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { config$1 as config$3 };
|
package/dist/config-BJZnXcL3.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
import { replaceMainext } from "@genapi/parser";
|
|
3
|
-
|
|
4
|
-
//#region src/fetch/js/config/index.ts
|
|
5
|
-
function config$1(userConfig) {
|
|
6
|
-
userConfig.import = userConfig.import || {};
|
|
7
|
-
userConfig.output = userConfig.output || {};
|
|
8
|
-
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
9
|
-
const configRead = config(userConfig);
|
|
10
|
-
return configRead;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { config$1 as config$2 };
|
package/dist/config-C94x0Nge.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
|
|
3
|
-
//#region src/ofetch/ts/config/index.ts
|
|
4
|
-
function config$1(userConfig) {
|
|
5
|
-
userConfig.import = userConfig.import || {};
|
|
6
|
-
userConfig.import.http = userConfig.import.http || "ofetch";
|
|
7
|
-
const configRead = config(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
name: "ofetch",
|
|
10
|
-
names: userConfig.import.http === "ofetch" ? ["FetchOptions"] : void 0,
|
|
11
|
-
value: userConfig.import.http
|
|
12
|
-
});
|
|
13
|
-
if (userConfig.import.http !== "ofetch") configRead.graphs.imports.push({
|
|
14
|
-
names: ["FetchOptions"],
|
|
15
|
-
value: "ofetch"
|
|
16
|
-
});
|
|
17
|
-
return configRead;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { config$1 as config$9 };
|
package/dist/config-CEngTpXa.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
|
|
3
|
-
//#region src/uni/ts/config/index.ts
|
|
4
|
-
function config$1(userConfig) {
|
|
5
|
-
userConfig.import = userConfig.import || {};
|
|
6
|
-
userConfig.import.http = userConfig.import.http || "@uni-helper/uni-network";
|
|
7
|
-
const configRead = config(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
name: "http",
|
|
10
|
-
names: userConfig.import.http === "@uni-helper/uni-network" ? ["UnConfig"] : void 0,
|
|
11
|
-
value: userConfig.import.http
|
|
12
|
-
});
|
|
13
|
-
if (userConfig.import.http !== "@uni-helper/uni-network") configRead.graphs.imports.push({
|
|
14
|
-
names: ["UnConfig"],
|
|
15
|
-
value: "@uni-helper/uni-network"
|
|
16
|
-
});
|
|
17
|
-
return configRead;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { config$1 as config$11 };
|
package/dist/config-CwmGeydd.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { config } from "@genapi/pipeline";
|
|
2
|
-
import { replaceMainext } from "@genapi/parser";
|
|
3
|
-
|
|
4
|
-
//#region src/axios/js/config/index.ts
|
|
5
|
-
function config$1(userConfig) {
|
|
6
|
-
userConfig.import = userConfig.import || {};
|
|
7
|
-
userConfig.output = userConfig.output || {};
|
|
8
|
-
userConfig.import.http = userConfig.import.http || "axios";
|
|
9
|
-
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
10
|
-
const configRead = config(userConfig);
|
|
11
|
-
configRead.graphs.imports.push({
|
|
12
|
-
name: "http",
|
|
13
|
-
value: userConfig.import.http
|
|
14
|
-
});
|
|
15
|
-
return configRead;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { config$1 as config };
|