@genapi/presets 3.7.1 → 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-Df6nDub9.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-BsBf_9LO.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-BkDRl56J.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-GYxVyS.mjs +0 -13
- package/dist/chunk-BL35Yyzp.mjs +0 -12
- package/dist/config-Bt-OVtrF.mjs +0 -21
- package/dist/config-CCf0xLx5.mjs +0 -12
- package/dist/config-CDvaM7ZL.mjs +0 -19
- package/dist/config-CEngTpXa.mjs +0 -21
- package/dist/config-CRdZhud4.mjs +0 -19
- package/dist/config-CTDgiXdv.mjs +0 -19
- package/dist/config-Dn-mxTew.mjs +0 -19
- package/dist/config-Dp9C4aUE.mjs +0 -21
- package/dist/config-Duv2zgs0.mjs +0 -14
- package/dist/config-IeVj3de_.mjs +0 -21
- package/dist/config-SP_VEcsX.mjs +0 -19
- package/dist/config-aVU8JEKy.mjs +0 -21
- package/dist/fetch-DNLodiAP.mjs +0 -13
- package/dist/got-BIOwnc0x.mjs +0 -13
- package/dist/index.d-99mf5fZX.d.mts +0 -7
- package/dist/index.d-B0Dj119v.d.mts +0 -7
- package/dist/index.d-B1n6Tnt1.d.mts +0 -12
- package/dist/index.d-BAZgb_b9.d.mts +0 -18
- package/dist/index.d-BG_KI3-b.d.mts +0 -7
- package/dist/index.d-BfFQykLh.d.mts +0 -12
- package/dist/index.d-BumPVmi6.d.mts +0 -14
- package/dist/index.d-Bxb1Ew8J.d.mts +0 -14
- package/dist/index.d-BxhX9ZHb.d.mts +0 -14
- package/dist/index.d-C7snKiSp.d.mts +0 -18
- package/dist/index.d-CBozMBWF.d.mts +0 -14
- package/dist/index.d-CDWq1HYV.d.mts +0 -18
- package/dist/index.d-CEAmhQXE.d.mts +0 -14
- package/dist/index.d-CJvL62Un.d.mts +0 -12
- package/dist/index.d-CTkBXgsL.d.mts +0 -7
- package/dist/index.d-CV6YWGPd.d.mts +0 -18
- package/dist/index.d-C_cfONoz.d.mts +0 -14
- package/dist/index.d-CkaW5o1S.d.mts +0 -7
- package/dist/index.d-CoyMx1eg.d.mts +0 -14
- package/dist/index.d-D2DYrmcB.d.mts +0 -14
- package/dist/index.d-D31630wD.d.mts +0 -18
- package/dist/index.d-D4dt4SN4.d.mts +0 -12
- package/dist/index.d-D8QZqVyr.d.mts +0 -18
- package/dist/index.d-DJrTX9xf.d.mts +0 -18
- package/dist/index.d-DMF-u4U9.d.mts +0 -18
- package/dist/index.d-DRC1cM3h.d.mts +0 -18
- package/dist/index.d-DZt4GzNR.d.mts +0 -18
- package/dist/index.d-DbmCOzZ_.d.mts +0 -12
- package/dist/index.d-DhevLWeK.d.mts +0 -18
- package/dist/index.d-Gm6xdqdc.d.mts +0 -14
- package/dist/index.d-KiVamk2z.d.mts +0 -12
- package/dist/index.d-Oclhn_rY.d.mts +0 -7
- package/dist/index.d-SEFhGKxl.d.mts +0 -7
- package/dist/index.d-dxrAw57N.d.mts +0 -7
- package/dist/index.d-fRobkY_s.d.mts +0 -18
- package/dist/index.d-ltrmOwIz.d.mts +0 -14
- package/dist/index.d-lzQFIw8d.d.mts +0 -7
- package/dist/index.d-mJ3Pcxey.d.mts +0 -14
- package/dist/index.d-xPgxVw9l.d.mts +0 -14
- package/dist/js-BIi60-ws.mjs +0 -19
- package/dist/js-CbvjSthC.mjs +0 -19
- package/dist/js-DrRwXaos.mjs +0 -19
- package/dist/js-_HvDqbMK.mjs +0 -19
- package/dist/js-rCsJDgHU.mjs +0 -19
- package/dist/js-tqiiLynG.mjs +0 -19
- package/dist/ky-P-rg3kH4.mjs +0 -13
- package/dist/ofetch-B_VRlsTN.mjs +0 -13
- package/dist/parser-BMWMb1tW.mjs +0 -65
- package/dist/parser-BOXlubkg.mjs +0 -64
- package/dist/parser-BYrX-ru-.mjs +0 -71
- package/dist/parser-BcgivITa.mjs +0 -79
- package/dist/parser-BtnVu9-k.mjs +0 -68
- package/dist/parser-ChqBZo9I.mjs +0 -70
- package/dist/parser-DqCzNFba.mjs +0 -65
- package/dist/parser-ZusEtk4G.mjs +0 -74
- package/dist/parser-ie6DpPJX.mjs +0 -64
- package/dist/parser-kk99DwsW.mjs +0 -71
- package/dist/parser-p29Uia9I.mjs +0 -69
- package/dist/parser-v9oBdoth.mjs +0 -71
- package/dist/ts-B-VDMOmJ.mjs +0 -19
- package/dist/ts-BAOPMwAr.mjs +0 -19
- package/dist/ts-BEo8NDau.mjs +0 -19
- package/dist/ts-C0RacOIG.mjs +0 -19
- package/dist/ts-CBWxAza5.mjs +0 -19
- package/dist/ts-UnhKokN_.mjs +0 -19
- package/dist/uni-CQMaFViG.mjs +0 -13
package/dist/ofetch/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/ofetch/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/ofetch/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,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodParameters, transformParameters, transformQueryParams, transformUrlSyntax } from "@genapi/parser";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/ofetch/js/parser/index.ts
|
|
4
|
+
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
|
+
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
|
|
6
|
+
formData: "body",
|
|
7
|
+
query: "params"
|
|
8
|
+
});
|
|
9
|
+
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
+
interfaces.push(...attachInters);
|
|
11
|
+
parameters.push({
|
|
12
|
+
name: "options",
|
|
13
|
+
type: "import('ofetch').FetchOptions",
|
|
14
|
+
required: false
|
|
15
|
+
});
|
|
16
|
+
options.push(["...", "options"]);
|
|
17
|
+
options.unshift(["method", `"${config.method}"`]);
|
|
18
|
+
if (configRead.config.meta?.baseURL) options.unshift("baseURL");
|
|
19
|
+
transformParameters(parameters, {
|
|
20
|
+
syntax: "ecmascript",
|
|
21
|
+
configRead,
|
|
22
|
+
description,
|
|
23
|
+
interfaces,
|
|
24
|
+
responseType
|
|
25
|
+
});
|
|
26
|
+
url = transformQueryParams("query", {
|
|
27
|
+
body,
|
|
28
|
+
options,
|
|
29
|
+
url
|
|
30
|
+
});
|
|
31
|
+
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
32
|
+
functions.push({
|
|
33
|
+
export: true,
|
|
34
|
+
async: true,
|
|
35
|
+
name,
|
|
36
|
+
description,
|
|
37
|
+
parameters,
|
|
38
|
+
body: [...body, `return ofetch(${url}, {${literalFieldsToString(options)}})`]
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { parser };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/ofetch/schema/compiler/index.d.ts
|
|
4
|
+
declare const compiler: (config: _genapi_shared0.ApiPipeline.ConfigRead) => _genapi_shared0.ApiPipeline.ConfigRead<_genapi_shared0.ApiPipeline.Config>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { compiler };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { schemaParser } from "../../_shared/schema/parser.mjs";
|
|
2
|
+
import { compiler } from "./compiler/index.mjs";
|
|
3
|
+
import { config } from "./config/index.mjs";
|
|
4
|
+
import * as _genapi_pipeline0 from "@genapi/pipeline";
|
|
5
|
+
import { dest, generate, original } from "@genapi/pipeline";
|
|
6
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
7
|
+
|
|
8
|
+
//#region src/ofetch/schema/index.d.ts
|
|
9
|
+
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
10
|
+
declare namespace openapiPipeline {
|
|
11
|
+
var config: (userConfig: ApiPipeline.Config) => ApiPipeline.ConfigRead;
|
|
12
|
+
var original: typeof _genapi_pipeline0.original;
|
|
13
|
+
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
14
|
+
var compiler: (config: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead<ApiPipeline.Config>;
|
|
15
|
+
var generate: typeof _genapi_pipeline0.generate;
|
|
16
|
+
var dest: typeof _genapi_pipeline0.dest;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, schemaParser as parser };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { schemaParser } from "../../_shared/schema/parser.mjs";
|
|
2
|
+
import { compiler } from "./compiler/index.mjs";
|
|
3
|
+
import { config } from "./config/index.mjs";
|
|
4
|
+
import pipeline, { dest, generate, original } from "@genapi/pipeline";
|
|
5
|
+
|
|
6
|
+
//#region src/ofetch/schema/index.ts
|
|
7
|
+
function openapiPipeline(userConfig) {
|
|
8
|
+
return pipeline((userConfig) => config(userConfig), (configRead) => original(configRead), (configRead) => schemaParser(configRead), (configRead) => compiler(configRead), (configRead) => generate(configRead), (configRead) => dest(configRead))(userConfig);
|
|
9
|
+
}
|
|
10
|
+
openapiPipeline.config = config;
|
|
11
|
+
openapiPipeline.original = original;
|
|
12
|
+
openapiPipeline.parser = schemaParser;
|
|
13
|
+
openapiPipeline.compiler = compiler;
|
|
14
|
+
openapiPipeline.generate = generate;
|
|
15
|
+
openapiPipeline.dest = dest;
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { compiler, config, openapiPipeline as default, dest, generate, original, schemaParser as parser };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
+
//#region src/ofetch/ts/config/index.d.ts
|
|
4
|
+
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
+
//#endregion
|
|
3
6
|
export { config };
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import { config
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
2
|
|
|
3
|
+
//#region src/ofetch/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 || "ofetch";
|
|
8
|
+
const configRead = config$1(userConfig);
|
|
9
|
+
configRead.graphs.imports.push({
|
|
10
|
+
names: userConfig.meta.import.http === "ofetch" ? ["FetchOptions", "ofetch"] : ["ofetch"],
|
|
11
|
+
value: userConfig.meta.import.http
|
|
12
|
+
});
|
|
13
|
+
if (userConfig.meta.import.http !== "ofetch") configRead.graphs.imports.push({
|
|
14
|
+
names: ["FetchOptions"],
|
|
15
|
+
value: "ofetch"
|
|
16
|
+
});
|
|
17
|
+
return configRead;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
3
21
|
export { config };
|
|
@@ -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/ofetch/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/ofetch/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/ofetch/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/ofetch/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,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodParameters, transformParameters, transformQueryParams, transformUrlSyntax } from "@genapi/parser";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/ofetch/ts/parser/index.ts
|
|
4
|
+
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
|
+
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
|
|
6
|
+
formData: "body",
|
|
7
|
+
query: "params"
|
|
8
|
+
});
|
|
9
|
+
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
+
interfaces.push(...attachInters);
|
|
11
|
+
parameters.push({
|
|
12
|
+
name: "options",
|
|
13
|
+
type: "FetchOptions",
|
|
14
|
+
required: false
|
|
15
|
+
});
|
|
16
|
+
options.push(["...", "options"]);
|
|
17
|
+
options.unshift(["method", `"${config.method}"`]);
|
|
18
|
+
if (configRead.config.meta?.baseURL) options.unshift("baseURL");
|
|
19
|
+
const { spaceResponseType } = transformParameters(parameters, {
|
|
20
|
+
syntax: "typescript",
|
|
21
|
+
configRead,
|
|
22
|
+
description,
|
|
23
|
+
interfaces,
|
|
24
|
+
responseType
|
|
25
|
+
});
|
|
26
|
+
url = transformQueryParams("query", {
|
|
27
|
+
body,
|
|
28
|
+
options,
|
|
29
|
+
url
|
|
30
|
+
});
|
|
31
|
+
url = transformUrlSyntax(url);
|
|
32
|
+
functions.push({
|
|
33
|
+
export: true,
|
|
34
|
+
name,
|
|
35
|
+
description,
|
|
36
|
+
parameters,
|
|
37
|
+
body: [`return ofetch<${spaceResponseType}>(${url}, {${literalFieldsToString(options)}})`]
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { parser };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/tanstack/colada/config/index.d.ts
|
|
4
4
|
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
-
|
|
6
5
|
//#endregion
|
|
7
|
-
export { config
|
|
6
|
+
export { config };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
|
+
|
|
3
|
+
//#region src/tanstack/colada/config/index.ts
|
|
4
|
+
function config(userConfig) {
|
|
5
|
+
userConfig.meta = userConfig.meta || {};
|
|
6
|
+
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
+
const configRead = config$1(userConfig);
|
|
8
|
+
configRead.graphs.imports.push({
|
|
9
|
+
names: ["useQuery", "useMutation"],
|
|
10
|
+
value: "@pinia/colada"
|
|
11
|
+
});
|
|
12
|
+
return configRead;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { config };
|
|
@@ -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/colada/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/colada/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/colada/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 keyItems = `'${name}', ${paramNames}`;
|
|
54
|
+
functions.push({
|
|
55
|
+
export: true,
|
|
56
|
+
name: hook,
|
|
57
|
+
description: [`@wraps ${name}`],
|
|
58
|
+
parameters: fetcherParams,
|
|
59
|
+
body: [`return useQuery({ key: [${keyItems}], query: () => ${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({ mutation: ${name} })`]
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { parser };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import openapiPipeline from "./colada/index.mjs";
|
|
2
|
+
import openapiPipeline$1 from "./react/index.mjs";
|
|
3
|
+
import openapiPipeline$2 from "./vue/index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/tanstack/index.d.ts
|
|
6
|
+
declare namespace index_d_exports {
|
|
7
|
+
export { openapiPipeline as colada, openapiPipeline$1 as react, openapiPipeline$2 as vue };
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { openapiPipeline as colada, openapiPipeline$1 as react, index_d_exports as t, openapiPipeline$2 as vue };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-DQk6qfdC.mjs";
|
|
2
|
+
import openapiPipeline from "./colada/index.mjs";
|
|
3
|
+
import openapiPipeline$1 from "./react/index.mjs";
|
|
4
|
+
import openapiPipeline$2 from "./vue/index.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/tanstack/index.ts
|
|
7
|
+
var tanstack_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
colada: () => openapiPipeline,
|
|
9
|
+
react: () => openapiPipeline$1,
|
|
10
|
+
vue: () => openapiPipeline$2
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { openapiPipeline as colada, openapiPipeline$1 as react, tanstack_exports as t, openapiPipeline$2 as vue };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/tanstack/react/config/index.d.ts
|
|
4
4
|
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
-
|
|
6
5
|
//#endregion
|
|
7
|
-
export { config
|
|
6
|
+
export { config };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
|
+
|
|
3
|
+
//#region src/tanstack/react/config/index.ts
|
|
4
|
+
function config(userConfig) {
|
|
5
|
+
userConfig.meta = userConfig.meta || {};
|
|
6
|
+
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
+
const configRead = config$1(userConfig);
|
|
8
|
+
configRead.graphs.imports.push({
|
|
9
|
+
names: ["useQuery", "useMutation"],
|
|
10
|
+
value: "@tanstack/react-query"
|
|
11
|
+
});
|
|
12
|
+
return configRead;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { config };
|
|
@@ -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/react/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/react/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,75 @@
|
|
|
1
|
+
import { createParser, parseMethodMetadata, parseMethodParameters, transformBodyStringify, transformFetchBody, transformHeaderOptions, transformParameters, transformQueryParams, transformUrlSyntax } from "@genapi/parser";
|
|
2
|
+
|
|
3
|
+
//#region src/tanstack/react/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({
|
|
60
|
+
queryKey: [${queryKeyItems}],
|
|
61
|
+
queryFn: () => ${name}(${paramNames}),
|
|
62
|
+
...config,
|
|
63
|
+
})`]
|
|
64
|
+
});
|
|
65
|
+
} else functions.push({
|
|
66
|
+
export: true,
|
|
67
|
+
name: hook,
|
|
68
|
+
description: [`@wraps ${name}`],
|
|
69
|
+
parameters: [],
|
|
70
|
+
body: [`return useMutation({ mutationFn: ${name} })`]
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { parser };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ApiPipeline } from "@genapi/shared";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/tanstack/vue/config/index.d.ts
|
|
4
4
|
declare function config(userConfig: ApiPipeline.Config): ApiPipeline.ConfigRead;
|
|
5
|
-
|
|
6
5
|
//#endregion
|
|
7
|
-
export { config
|
|
6
|
+
export { config };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { config as config$1 } from "@genapi/pipeline";
|
|
2
|
+
|
|
3
|
+
//#region src/tanstack/vue/config/index.ts
|
|
4
|
+
function config(userConfig) {
|
|
5
|
+
userConfig.meta = userConfig.meta || {};
|
|
6
|
+
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
+
const configRead = config$1(userConfig);
|
|
8
|
+
configRead.graphs.imports.push({
|
|
9
|
+
names: ["useQuery", "useMutation"],
|
|
10
|
+
value: "@tanstack/vue-query"
|
|
11
|
+
});
|
|
12
|
+
return configRead;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { config };
|