@seayoo-web/request 4.0.4 → 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/dist/index.js +143 -166
- package/dist/node.js +61 -81
- package/dist/request.fetch-CY3SKtx7.js +48 -0
- package/dist/retry-x0AqZ13h.js +635 -0
- package/dist/uni.js +61 -0
- package/dist/wx.js +62 -68
- package/package.json +30 -25
- package/types/inc/main.d.ts +1 -0
- package/types/inc/request.uni.d.ts +5 -0
- package/types/index.d.ts +28 -28
- package/types/node.d.ts +24 -24
- package/types/uni.d.ts +60 -0
- package/types/wx.d.ts +20 -20
- package/dist/request.fetch-zzHMZXfR.js +0 -54
- package/dist/retry-LYfsjIVg.js +0 -655
package/dist/wx.js
CHANGED
|
@@ -1,70 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
import { a as e, d as t, g as n, i as r, l as i, n as a, r as o, s, t as c, u as l } from "./retry-x0AqZ13h.js";
|
|
2
|
+
//#region src/inc/request.wx.ts
|
|
3
|
+
var u = async function(e, t, n) {
|
|
4
|
+
return o(await c(d, e, t, n), e, t, n);
|
|
5
|
+
}, d = async function(r, o, c) {
|
|
6
|
+
let l = await e(r, o, c), u = l.method;
|
|
7
|
+
return !n() || u === "PATCH" ? {
|
|
8
|
+
url: l.url,
|
|
9
|
+
method: u,
|
|
10
|
+
status: -1,
|
|
11
|
+
error: t.NotSupport,
|
|
12
|
+
statusText: t.NotSupport,
|
|
13
|
+
body: ""
|
|
14
|
+
} : new Promise((e) => {
|
|
15
|
+
let n = wx.request({
|
|
16
|
+
url: l.url,
|
|
17
|
+
data: l.body,
|
|
18
|
+
header: l.headers,
|
|
19
|
+
method: u,
|
|
20
|
+
dataType: "raw",
|
|
21
|
+
timeout: l.timeout,
|
|
22
|
+
responseType: l.asBuffer ? "arraybuffer" : "text",
|
|
23
|
+
fail({ errMsg: n, errno: r, exception: i }) {
|
|
24
|
+
e({
|
|
25
|
+
url: l.url,
|
|
26
|
+
method: u,
|
|
27
|
+
status: -1,
|
|
28
|
+
error: t.Unknown,
|
|
29
|
+
statusText: n,
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
errMsg: n,
|
|
32
|
+
errno: r,
|
|
33
|
+
exception: i
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async success(t) {
|
|
38
|
+
e(await a({
|
|
39
|
+
url: l.url,
|
|
40
|
+
method: u,
|
|
41
|
+
status: t.statusCode,
|
|
42
|
+
statusText: `WxRequest${t.statusCode}`,
|
|
43
|
+
headers: { ...t.header },
|
|
44
|
+
body: null
|
|
45
|
+
}, {
|
|
46
|
+
asBuffer: l.asBuffer,
|
|
47
|
+
text: () => i(t.data),
|
|
48
|
+
buffer: async () => t.data instanceof ArrayBuffer ? t.data : await s(i(t.data))
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
l.abort?.addEventListener("abort", () => {
|
|
53
|
+
n.abort();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
54
56
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/wx.ts
|
|
59
|
+
function f(e) {
|
|
60
|
+
return new l(u, e);
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
u as RequestInternalError,
|
|
63
|
-
S as del,
|
|
64
|
-
B as get,
|
|
65
|
-
O as getResponseRulesDescription,
|
|
66
|
-
N as head,
|
|
67
|
-
C as post,
|
|
68
|
-
A as put,
|
|
69
|
-
T as setGlobalConfig
|
|
70
|
-
};
|
|
62
|
+
var p = f(), m = p.setConfig, h = p.head, g = p.get, _ = p.post, v = p.del, y = p.put;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { f as NetRequest, t as RequestInternalError, v as del, g as get, r as getResponseRulesDescription, h as head, _ as post, y as put, m as setGlobalConfig };
|
package/package.json
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/request",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "request tools for seayoo web",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fetch",
|
|
7
|
+
"request",
|
|
8
|
+
"upload"
|
|
9
|
+
],
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"author": "web@seayoo.com",
|
|
6
12
|
"source": "./src/index.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"types",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
7
20
|
"main": "./dist/index.js",
|
|
8
21
|
"module": "./dist/index.js",
|
|
9
22
|
"types": "./types/index.d.ts",
|
|
10
|
-
"sideEffects": false,
|
|
11
23
|
"exports": {
|
|
12
24
|
".": {
|
|
13
25
|
"types": "./types/index.d.ts",
|
|
@@ -18,52 +30,45 @@
|
|
|
18
30
|
"browser": null,
|
|
19
31
|
"types": "./types/node.d.ts",
|
|
20
32
|
"import": "./dist/node.js",
|
|
21
|
-
"default": "./dist/node.
|
|
33
|
+
"default": "./dist/node.js"
|
|
22
34
|
},
|
|
23
35
|
"./dist/node": {
|
|
24
36
|
"browser": null,
|
|
25
37
|
"types": "./types/node.d.ts",
|
|
26
38
|
"import": "./dist/node.js",
|
|
27
|
-
"default": "./dist/node.
|
|
39
|
+
"default": "./dist/node.js"
|
|
28
40
|
},
|
|
29
41
|
"./wx": {
|
|
30
42
|
"types": "./types/wx.d.ts",
|
|
31
43
|
"import": "./dist/wx.js",
|
|
32
44
|
"default": "./dist/wx.js"
|
|
45
|
+
},
|
|
46
|
+
"./uni": {
|
|
47
|
+
"types": "./types/uni.d.ts",
|
|
48
|
+
"import": "./dist/uni.js",
|
|
49
|
+
"default": "./dist/uni.js"
|
|
33
50
|
}
|
|
34
51
|
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist",
|
|
37
|
-
"types",
|
|
38
|
-
"README.md"
|
|
39
|
-
],
|
|
40
52
|
"publishConfig": {
|
|
41
53
|
"access": "public"
|
|
42
54
|
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=22"
|
|
45
|
-
},
|
|
46
|
-
"keywords": [
|
|
47
|
-
"request",
|
|
48
|
-
"fetch",
|
|
49
|
-
"upload"
|
|
50
|
-
],
|
|
51
|
-
"author": "web@seayoo.com",
|
|
52
|
-
"license": "ISC",
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"@vitest/browser": "^
|
|
55
|
-
"@vitest/coverage-istanbul": "^
|
|
56
|
+
"@vitest/browser": "^4.1.0",
|
|
57
|
+
"@vitest/coverage-istanbul": "^4.1.0",
|
|
56
58
|
"happy-dom": "^12.10.3",
|
|
57
59
|
"msw": "^2.10.5",
|
|
58
|
-
"vitest": "^
|
|
60
|
+
"vitest": "^4.1.0",
|
|
59
61
|
"@seayoo-web/utils": "^4.4.1"
|
|
60
62
|
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=22"
|
|
65
|
+
},
|
|
61
66
|
"scripts": {
|
|
62
67
|
"prebuild": "pnpm --F utils build",
|
|
63
68
|
"build": "vite build && tsc --emitDeclarationOnly",
|
|
64
69
|
"type-check": "tsc --noEmit",
|
|
65
|
-
"lint": "
|
|
66
|
-
"lint:fix": "
|
|
70
|
+
"lint": "oxlint -c ../../oxlint.config.mjs",
|
|
71
|
+
"lint:fix": "oxlint -c ../../oxlint.config.mjs --fix",
|
|
67
72
|
"prepublish": "pnpm lint:fix && pnpm build",
|
|
68
73
|
"test": "vitest --typecheck --dom",
|
|
69
74
|
"coverage": "vitest run --coverage"
|
package/types/inc/main.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type URLPlus = string | {
|
|
|
7
7
|
export type BufferRequestOptions = RequestOptions & {
|
|
8
8
|
asBuffer: true;
|
|
9
9
|
};
|
|
10
|
+
export type INetRequestHandler = Pick<NetRequestHandler, keyof NetRequestHandler>;
|
|
10
11
|
/** 工具函数主类 */
|
|
11
12
|
export declare class NetRequestHandler {
|
|
12
13
|
private agent;
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INetRequestHandler } from "./inc/main";
|
|
2
2
|
import { xhrUpload } from "./inc/request.xhr";
|
|
3
3
|
import type { RequestGlobalConfig } from "./inc/type";
|
|
4
4
|
export { jsonp, jsonx } from "./inc/jsonp";
|
|
5
5
|
export { getResponseRulesDescription } from "./inc/rule";
|
|
6
6
|
export { RequestInternalError } from "./inc/type";
|
|
7
|
-
export type { NetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
7
|
+
export type { NetRequestHandler, INetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
8
8
|
export type { RequestOptions, RequestGlobalConfig, ResponseRule, ResponseResult, RequestLog, RequestMethod, RequestQueryParams, } from "./inc/type";
|
|
9
9
|
/**
|
|
10
10
|
* 基于 xhr 模块的上传工具,支持上传进度
|
|
@@ -15,7 +15,7 @@ export type NetRequestFactory = typeof NetRequest;
|
|
|
15
15
|
/**
|
|
16
16
|
* 创建新的实例空间,配置和缓存跟全局默认实例是隔离的,仅支持在浏览器环境使用
|
|
17
17
|
*/
|
|
18
|
-
export declare function NetRequest(config?: RequestGlobalConfig):
|
|
18
|
+
export declare function NetRequest(config?: RequestGlobalConfig): INetRequestHandler;
|
|
19
19
|
/**
|
|
20
20
|
* 设置全局默认的 Request Config
|
|
21
21
|
*/
|
|
@@ -26,60 +26,60 @@ export declare const setGlobalConfig: (config: RequestGlobalConfig) => void;
|
|
|
26
26
|
export declare const request: {
|
|
27
27
|
(op: {
|
|
28
28
|
url: string;
|
|
29
|
-
options?: import("
|
|
30
|
-
}): Promise<import("
|
|
29
|
+
options?: import(".").RequestOptions;
|
|
30
|
+
}): Promise<import(".").ResponseResult<unknown>>;
|
|
31
31
|
<T>(op: {
|
|
32
32
|
url: string;
|
|
33
|
-
options?: import("
|
|
33
|
+
options?: import(".").RequestOptions;
|
|
34
34
|
guard: import("./inc/type").DataGuard<T>;
|
|
35
|
-
}): Promise<import("
|
|
35
|
+
}): Promise<import(".").ResponseResult<T>>;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* 发送一个 HEAD 请求
|
|
39
39
|
*/
|
|
40
|
-
export declare const head: (url: string, params?: import("
|
|
40
|
+
export declare const head: (url: string, params?: import(".").RequestQueryParams | null, options?: Omit<import(".").RequestOptions, "asBuffer">) => import("./inc/type").ResponseWithoutType;
|
|
41
41
|
/**
|
|
42
42
|
* 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
|
|
43
43
|
*/
|
|
44
44
|
export declare const get: {
|
|
45
|
-
(url: string, params?: import("
|
|
46
|
-
(url: string, params: import("
|
|
47
|
-
(url: string, params: import("
|
|
48
|
-
<T>(url: string, params: import("
|
|
45
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
46
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
47
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
48
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
51
|
* 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
|
|
52
52
|
*/
|
|
53
53
|
export declare const post: {
|
|
54
|
-
(url: import("
|
|
55
|
-
(url: import("
|
|
56
|
-
(url: import("
|
|
57
|
-
<T>(url: import("
|
|
54
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
55
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
56
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
57
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
|
|
61
61
|
*/
|
|
62
62
|
export declare const del: {
|
|
63
|
-
(url: string, params?: import("
|
|
64
|
-
(url: string, params: import("
|
|
65
|
-
(url: string, params: import("
|
|
66
|
-
<T>(url: string, params: import("
|
|
63
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
64
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
65
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
66
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
|
|
70
70
|
*/
|
|
71
71
|
export declare const put: {
|
|
72
|
-
(url: import("
|
|
73
|
-
(url: import("
|
|
74
|
-
(url: import("
|
|
75
|
-
<T>(url: import("
|
|
72
|
+
(url: import(".").URLPlus, body?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
73
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
74
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
75
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
78
|
* 发送一个 PATCH 请求,可选 typeGuard 用于检查数据类型
|
|
79
79
|
*/
|
|
80
80
|
export declare const patch: {
|
|
81
|
-
(url: import("
|
|
82
|
-
(url: import("
|
|
83
|
-
(url: import("
|
|
84
|
-
<T>(url: import("
|
|
81
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
82
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
83
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
84
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
85
85
|
};
|
package/types/node.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INetRequestHandler } from "./inc/main";
|
|
2
2
|
import type { RequestGlobalConfig } from "./inc/type";
|
|
3
3
|
export { getResponseRulesDescription } from "./inc/rule";
|
|
4
4
|
export { RequestInternalError } from "./inc/type";
|
|
5
|
-
export type { NetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
5
|
+
export type { NetRequestHandler, INetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
6
6
|
export type { RequestOptions, RequestGlobalConfig, ResponseRule, ResponseResult, RequestLog, RequestMethod, RequestQueryParams, } from "./inc/type";
|
|
7
7
|
/**
|
|
8
8
|
* 创建新的实例空间,配置和缓存跟全局默认实例是隔离的
|
|
9
9
|
*/
|
|
10
|
-
export declare function NetRequest(config?: RequestGlobalConfig):
|
|
10
|
+
export declare function NetRequest(config?: RequestGlobalConfig): INetRequestHandler;
|
|
11
11
|
/**
|
|
12
12
|
* 设置全局默认的 Request Config
|
|
13
13
|
*/
|
|
@@ -15,49 +15,49 @@ export declare const setGlobalConfig: (config: RequestGlobalConfig) => void;
|
|
|
15
15
|
/**
|
|
16
16
|
* 发送一个 HEAD 请求
|
|
17
17
|
*/
|
|
18
|
-
export declare const head: (url: string, params?: import("
|
|
18
|
+
export declare const head: (url: string, params?: import(".").RequestQueryParams | null, options?: Omit<import(".").RequestOptions, "asBuffer">) => import("./inc/type").ResponseWithoutType;
|
|
19
19
|
/**
|
|
20
20
|
* 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
|
|
21
21
|
*/
|
|
22
22
|
export declare const get: {
|
|
23
|
-
(url: string, params?: import("
|
|
24
|
-
(url: string, params: import("
|
|
25
|
-
(url: string, params: import("
|
|
26
|
-
<T>(url: string, params: import("
|
|
23
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
24
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
25
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
26
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
|
|
30
30
|
*/
|
|
31
31
|
export declare const post: {
|
|
32
|
-
(url: import("
|
|
33
|
-
(url: import("
|
|
34
|
-
(url: import("
|
|
35
|
-
<T>(url: import("
|
|
32
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
33
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
34
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
35
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
|
|
39
39
|
*/
|
|
40
40
|
export declare const del: {
|
|
41
|
-
(url: string, params?: import("
|
|
42
|
-
(url: string, params: import("
|
|
43
|
-
(url: string, params: import("
|
|
44
|
-
<T>(url: string, params: import("
|
|
41
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
42
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
43
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
44
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
|
|
48
48
|
*/
|
|
49
49
|
export declare const put: {
|
|
50
|
-
(url: import("
|
|
51
|
-
(url: import("
|
|
52
|
-
(url: import("
|
|
53
|
-
<T>(url: import("
|
|
50
|
+
(url: import(".").URLPlus, body?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
51
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
52
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
53
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
56
|
* 发送一个 PATCH 请求,可选 typeGuard 用于检查数据类型
|
|
57
57
|
*/
|
|
58
58
|
export declare const patch: {
|
|
59
|
-
(url: import("
|
|
60
|
-
(url: import("
|
|
61
|
-
(url: import("
|
|
62
|
-
<T>(url: import("
|
|
59
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
60
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
61
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
62
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
63
63
|
};
|
package/types/uni.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { INetRequestHandler } from "./inc/main";
|
|
2
|
+
import type { RequestGlobalConfig } from "./inc/type";
|
|
3
|
+
export { getResponseRulesDescription } from "./inc/rule";
|
|
4
|
+
export { RequestInternalError } from "./inc/type";
|
|
5
|
+
export type { NetRequestHandler, INetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
6
|
+
export type { RequestOptions, RequestGlobalConfig, ResponseRule, ResponseResult, RequestLog, RequestMethod, RequestQueryParams, } from "./inc/type";
|
|
7
|
+
/**
|
|
8
|
+
* 创建新的实例空间,配置和缓存跟全局默认实例是隔离的
|
|
9
|
+
*/
|
|
10
|
+
export declare function NetRequest(config?: RequestGlobalConfig): INetRequestHandler;
|
|
11
|
+
/**
|
|
12
|
+
* 设置全局默认的 Request Config
|
|
13
|
+
*/
|
|
14
|
+
export declare const setGlobalConfig: (config: RequestGlobalConfig) => void;
|
|
15
|
+
/**
|
|
16
|
+
* 发送一个 HEAD 请求
|
|
17
|
+
*
|
|
18
|
+
* 支持环境:微信小程序、百度小程序
|
|
19
|
+
*/
|
|
20
|
+
export declare const head: (url: string, params?: import(".").RequestQueryParams | null, options?: Omit<import(".").RequestOptions, "asBuffer">) => import("./inc/type").ResponseWithoutType;
|
|
21
|
+
/**
|
|
22
|
+
* 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
|
|
23
|
+
*/
|
|
24
|
+
export declare const get: {
|
|
25
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
26
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
27
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
28
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
|
|
32
|
+
*/
|
|
33
|
+
export declare const post: {
|
|
34
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
35
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
36
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
37
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
|
|
41
|
+
*
|
|
42
|
+
* 支持环境:微信小程序、百度小程序
|
|
43
|
+
*/
|
|
44
|
+
export declare const del: {
|
|
45
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
46
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
47
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
48
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
|
|
52
|
+
*
|
|
53
|
+
* 支持环境:微信小程序、百度小程序、抖音小程序、飞书小程序
|
|
54
|
+
*/
|
|
55
|
+
export declare const put: {
|
|
56
|
+
(url: import(".").URLPlus, body?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
57
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
58
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
59
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
60
|
+
};
|
package/types/wx.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INetRequestHandler } from "./inc/main";
|
|
2
2
|
import type { RequestGlobalConfig } from "./inc/type";
|
|
3
3
|
export { getResponseRulesDescription } from "./inc/rule";
|
|
4
4
|
export { RequestInternalError } from "./inc/type";
|
|
5
|
-
export type { NetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
5
|
+
export type { NetRequestHandler, INetRequestHandler, URLPlus, BufferRequestOptions } from "./inc/main";
|
|
6
6
|
export type { RequestOptions, RequestGlobalConfig, ResponseRule, ResponseResult, RequestLog, RequestMethod, RequestQueryParams, } from "./inc/type";
|
|
7
7
|
/**
|
|
8
8
|
* 创建新的实例空间,配置和缓存跟全局默认实例是隔离的
|
|
9
9
|
*/
|
|
10
|
-
export declare function NetRequest(config?: RequestGlobalConfig):
|
|
10
|
+
export declare function NetRequest(config?: RequestGlobalConfig): INetRequestHandler;
|
|
11
11
|
/**
|
|
12
12
|
* 设置全局默认的 Request Config
|
|
13
13
|
*/
|
|
@@ -15,40 +15,40 @@ export declare const setGlobalConfig: (config: RequestGlobalConfig) => void;
|
|
|
15
15
|
/**
|
|
16
16
|
* 发送一个 HEAD 请求
|
|
17
17
|
*/
|
|
18
|
-
export declare const head: (url: string, params?: import("
|
|
18
|
+
export declare const head: (url: string, params?: import(".").RequestQueryParams | null, options?: Omit<import(".").RequestOptions, "asBuffer">) => import("./inc/type").ResponseWithoutType;
|
|
19
19
|
/**
|
|
20
20
|
* 发送一个 GET 请求,请求自带 500ms 缓冲控制以应对并发场景,可选 typeGuard 用于检查数据类型
|
|
21
21
|
*/
|
|
22
22
|
export declare const get: {
|
|
23
|
-
(url: string, params?: import("
|
|
24
|
-
(url: string, params: import("
|
|
25
|
-
(url: string, params: import("
|
|
26
|
-
<T>(url: string, params: import("
|
|
23
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
24
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
25
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
26
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
|
|
30
30
|
*/
|
|
31
31
|
export declare const post: {
|
|
32
|
-
(url: import("
|
|
33
|
-
(url: import("
|
|
34
|
-
(url: import("
|
|
35
|
-
<T>(url: import("
|
|
32
|
+
(url: import(".").URLPlus, data?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
33
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
34
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
35
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
|
|
39
39
|
*/
|
|
40
40
|
export declare const del: {
|
|
41
|
-
(url: string, params?: import("
|
|
42
|
-
(url: string, params: import("
|
|
43
|
-
(url: string, params: import("
|
|
44
|
-
<T>(url: string, params: import("
|
|
41
|
+
(url: string, params?: import(".").RequestQueryParams): import("./inc/type").ResponseWithoutType;
|
|
42
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
43
|
+
(url: string, params: import(".").RequestQueryParams | null, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
44
|
+
<T>(url: string, params: import(".").RequestQueryParams | null, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
|
|
48
48
|
*/
|
|
49
49
|
export declare const put: {
|
|
50
|
-
(url: import("
|
|
51
|
-
(url: import("
|
|
52
|
-
(url: import("
|
|
53
|
-
<T>(url: import("
|
|
50
|
+
(url: import(".").URLPlus, body?: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
51
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options: import(".").BufferRequestOptions): import("./inc/type").ResponseWithType<ArrayBuffer>;
|
|
52
|
+
(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: null, options?: import(".").RequestOptions): import("./inc/type").ResponseWithoutType;
|
|
53
|
+
<T>(url: import(".").URLPlus, body: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, guard: import("./inc/type").DataGuard<T>, options?: import(".").RequestOptions): import("./inc/type").ResponseWithType<T>;
|
|
54
54
|
};
|