@genapi/presets 4.0.0 → 4.1.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/LICENSE.md +21 -21
- package/README.md +36 -108
- package/dist/_shared/query/config.d.mts +14 -0
- package/dist/_shared/query/config.mjs +58 -0
- package/dist/_shared/query/index.d.mts +3 -0
- package/dist/_shared/query/index.mjs +4 -0
- package/dist/_shared/query/parser.d.mts +7 -0
- package/dist/_shared/query/parser.mjs +75 -0
- package/dist/_shared/schema/compiler.mjs +8 -6
- package/dist/_shared/schema/config.mjs +8 -5
- package/dist/axios/js/config/index.mjs +3 -1
- package/dist/axios/js/parser/index.mjs +3 -3
- package/dist/axios/ts/config/index.mjs +4 -2
- package/dist/axios/ts/parser/index.mjs +3 -3
- package/dist/fetch/js/parser/index.mjs +3 -3
- package/dist/fetch/schema/index.d.mts +1 -0
- package/dist/fetch/schema/parser/index.d.mts +1 -0
- package/dist/fetch/ts/parser/index.mjs +3 -3
- package/dist/got/js/config/index.mjs +3 -1
- package/dist/got/js/parser/index.mjs +3 -3
- package/dist/got/ts/config/index.mjs +4 -2
- package/dist/got/ts/parser/index.mjs +3 -3
- package/dist/index.d.mts +10 -7
- package/dist/index.mjs +11 -8
- package/dist/ky/js/config/index.mjs +3 -1
- package/dist/ky/js/parser/index.mjs +3 -3
- package/dist/ky/ts/config/index.mjs +4 -2
- package/dist/ky/ts/parser/index.mjs +3 -3
- package/dist/ofetch/js/config/index.mjs +3 -1
- package/dist/ofetch/js/parser/index.mjs +3 -3
- package/dist/ofetch/schema/index.d.mts +1 -0
- package/dist/ofetch/schema/parser/index.d.mts +1 -0
- package/dist/ofetch/ts/config/index.mjs +4 -2
- package/dist/ofetch/ts/parser/index.mjs +3 -3
- package/dist/tanstack/colada/config/index.d.mts +2 -2
- package/dist/tanstack/colada/config/index.mjs +2 -11
- package/dist/tanstack/colada/index.d.mts +1 -1
- package/dist/tanstack/colada/parser/index.mjs +2 -66
- package/dist/tanstack/react/config/index.d.mts +2 -2
- package/dist/tanstack/react/config/index.mjs +2 -11
- package/dist/tanstack/react/index.d.mts +1 -1
- package/dist/tanstack/react/parser/index.mjs +2 -70
- package/dist/tanstack/vue/config/index.d.mts +2 -2
- package/dist/tanstack/vue/config/index.mjs +2 -11
- package/dist/tanstack/vue/index.d.mts +1 -1
- package/dist/tanstack/vue/parser/index.mjs +2 -66
- package/dist/uni/js/config/index.mjs +3 -1
- package/dist/uni/js/parser/index.mjs +3 -3
- package/dist/uni/ts/config/index.mjs +4 -2
- package/dist/uni/ts/parser/index.mjs +3 -3
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { config as config$1 } from "@genapi/pipeline";
|
|
2
2
|
import { replaceMainext } from "@genapi/parser";
|
|
3
|
+
import { inject } from "@genapi/shared";
|
|
3
4
|
|
|
4
5
|
//#region src/uni/js/config/index.ts
|
|
5
6
|
function config(userConfig) {
|
|
@@ -9,7 +10,8 @@ function config(userConfig) {
|
|
|
9
10
|
userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
|
|
10
11
|
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
11
12
|
const configRead = config$1(userConfig);
|
|
12
|
-
|
|
13
|
+
const { imports } = inject();
|
|
14
|
+
imports.add("main", {
|
|
13
15
|
name: "http",
|
|
14
16
|
value: userConfig.meta.import.http
|
|
15
17
|
});
|
|
@@ -8,7 +8,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
8
8
|
});
|
|
9
9
|
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
10
10
|
options.push(["...", "config"]);
|
|
11
|
-
interfaces.
|
|
11
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
12
12
|
parameters.push({
|
|
13
13
|
type: "import('@uni-helper/uni-network').UnConfig<never>",
|
|
14
14
|
name: "config",
|
|
@@ -21,12 +21,12 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
21
21
|
syntax: "ecmascript",
|
|
22
22
|
configRead,
|
|
23
23
|
description,
|
|
24
|
-
interfaces,
|
|
24
|
+
interfaces: interfaces.all(),
|
|
25
25
|
responseType,
|
|
26
26
|
generic: "import('@uni-helper/uni-network').UnResponse<{__type__}>"
|
|
27
27
|
});
|
|
28
28
|
url = transformUrlSyntax(url);
|
|
29
|
-
functions.
|
|
29
|
+
functions.add("main", {
|
|
30
30
|
export: true,
|
|
31
31
|
name,
|
|
32
32
|
description,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { config as config$1 } from "@genapi/pipeline";
|
|
2
|
+
import { inject } from "@genapi/shared";
|
|
2
3
|
|
|
3
4
|
//#region src/uni/ts/config/index.ts
|
|
4
5
|
function config(userConfig) {
|
|
@@ -6,12 +7,13 @@ function config(userConfig) {
|
|
|
6
7
|
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
8
|
userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
|
|
8
9
|
const configRead = config$1(userConfig);
|
|
9
|
-
|
|
10
|
+
const { imports } = inject();
|
|
11
|
+
imports.add("main", {
|
|
10
12
|
name: "http",
|
|
11
13
|
names: userConfig.meta.import.http === "@uni-helper/uni-network" ? ["UnConfig"] : void 0,
|
|
12
14
|
value: userConfig.meta.import.http
|
|
13
15
|
});
|
|
14
|
-
if (userConfig.meta.import.http !== "@uni-helper/uni-network")
|
|
16
|
+
if (userConfig.meta.import.http !== "@uni-helper/uni-network") imports.add("main", {
|
|
15
17
|
names: ["UnConfig"],
|
|
16
18
|
value: "@uni-helper/uni-network"
|
|
17
19
|
});
|
|
@@ -8,7 +8,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
8
8
|
});
|
|
9
9
|
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
10
10
|
options.push(["...", "config"]);
|
|
11
|
-
interfaces.
|
|
11
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
12
12
|
parameters.push({
|
|
13
13
|
name: "config",
|
|
14
14
|
type: "UnConfig<never>",
|
|
@@ -18,14 +18,14 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
18
18
|
options.unshift(["method", `"${config.method}"`]);
|
|
19
19
|
if (configRead.config.meta?.baseURL) options.unshift("baseURL");
|
|
20
20
|
const { spaceResponseType } = transformParameters(parameters, {
|
|
21
|
+
interfaces: interfaces.values("type"),
|
|
21
22
|
syntax: "typescript",
|
|
22
23
|
configRead,
|
|
23
24
|
description,
|
|
24
|
-
interfaces,
|
|
25
25
|
responseType
|
|
26
26
|
});
|
|
27
27
|
url = transformUrlSyntax(url);
|
|
28
|
-
functions.
|
|
28
|
+
functions.add("main", {
|
|
29
29
|
export: true,
|
|
30
30
|
name,
|
|
31
31
|
description,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genapi/presets",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"author": "Hairyf <wwu710632@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/hairyf/genapi#readme",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"dist"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"knitwork-x": "^0.
|
|
81
|
+
"knitwork-x": "^0.3.1",
|
|
82
82
|
"openapi-specification-types": "^0.3.0",
|
|
83
|
-
"@genapi/parser": "4.
|
|
84
|
-
"@genapi/pipeline": "4.
|
|
85
|
-
"@genapi/shared": "4.
|
|
83
|
+
"@genapi/parser": "4.1.0",
|
|
84
|
+
"@genapi/pipeline": "4.1.0",
|
|
85
|
+
"@genapi/shared": "4.1.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "tsdown",
|