axios-annotations 1.3.3 → 2.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 +248 -105
- package/index.d.ts +1 -0
- package/index.js +121 -0
- package/lib/core/cancel.d.ts +30 -0
- package/lib/core/cancel.js +56 -0
- package/lib/core/common.d.ts +6 -0
- package/lib/core/common.js +166 -1
- package/lib/core/config.d.ts +60 -29
- package/lib/core/config.js +332 -1
- package/lib/core/parser.d.ts +19 -15
- package/lib/core/parser.js +79 -1
- package/lib/core/provider.d.ts +6 -0
- package/lib/core/provider.js +172 -0
- package/lib/core/service.d.ts +153 -33
- package/lib/core/service.js +562 -1
- package/lib/decorator/abort-source.d.ts +3 -9
- package/lib/decorator/abort-source.js +25 -1
- package/lib/decorator/delete-mapping.d.ts +1 -3
- package/lib/decorator/delete-mapping.js +13 -1
- package/lib/decorator/get-mapping.d.ts +1 -3
- package/lib/decorator/get-mapping.js +13 -1
- package/lib/decorator/ignore-residual-params.d.ts +1 -3
- package/lib/decorator/ignore-residual-params.js +24 -1
- package/lib/decorator/patch-mapping.d.ts +1 -3
- package/lib/decorator/patch-mapping.js +13 -1
- package/lib/decorator/post-mapping.d.ts +1 -3
- package/lib/decorator/post-mapping.js +13 -1
- package/lib/decorator/put-mapping.d.ts +1 -3
- package/lib/decorator/put-mapping.js +13 -1
- package/lib/decorator/request-body.d.ts +1 -3
- package/lib/decorator/request-body.js +28 -1
- package/lib/decorator/request-config.d.ts +5 -7
- package/lib/decorator/request-config.js +23 -1
- package/lib/decorator/request-header.d.ts +2 -5
- package/lib/decorator/request-header.js +21 -1
- package/lib/decorator/request-mapping.d.ts +3 -6
- package/lib/decorator/request-mapping.js +58 -1
- package/lib/decorator/request-param.d.ts +1 -3
- package/lib/decorator/request-param.js +27 -1
- package/lib/decorator/request-with.d.ts +1 -3
- package/lib/decorator/request-with.js +20 -1
- package/lib/index.d.ts +19 -0
- package/lib/index.js +139 -0
- package/lib/plugins/auth/authorizer.d.ts +23 -49
- package/lib/plugins/auth/authorizer.js +271 -1
- package/lib/plugins/auth/history.d.ts +14 -15
- package/lib/plugins/auth/history.js +96 -1
- package/lib/plugins/auth/index.d.ts +9 -4
- package/lib/plugins/auth/index.js +368 -1
- package/lib/plugins/auth/queue.d.ts +28 -16
- package/lib/plugins/auth/queue.js +270 -1
- package/lib/plugins/auth/storage.d.ts +6 -7
- package/lib/plugins/auth/storage.js +207 -1
- package/package.json +16 -16
- package/plugins/auth/index.d.ts +4 -4
- package/plugins/auth/index.js +26 -1
- package/core/config.d.ts +0 -29
- package/core/config.js +0 -1
- package/core/parser.d.ts +0 -15
- package/core/parser.js +0 -1
- package/core/service.d.ts +0 -33
- package/core/service.js +0 -1
- package/decorator/abort-source.d.ts +0 -9
- package/decorator/abort-source.js +0 -1
- package/decorator/delete-mapping.d.ts +0 -1
- package/decorator/delete-mapping.js +0 -1
- package/decorator/get-mapping.d.ts +0 -1
- package/decorator/get-mapping.js +0 -1
- package/decorator/ignore-residual-params.d.ts +0 -1
- package/decorator/ignore-residual-params.js +0 -1
- package/decorator/patch-mapping.d.ts +0 -1
- package/decorator/patch-mapping.js +0 -1
- package/decorator/post-mapping.d.ts +0 -1
- package/decorator/post-mapping.js +0 -1
- package/decorator/put-mapping.d.ts +0 -3
- package/decorator/put-mapping.js +0 -1
- package/decorator/request-body.d.ts +0 -3
- package/decorator/request-body.js +0 -1
- package/decorator/request-config.d.ts +0 -29
- package/decorator/request-config.js +0 -1
- package/decorator/request-header.d.ts +0 -1
- package/decorator/request-header.js +0 -1
- package/decorator/request-mapping.d.ts +0 -1
- package/decorator/request-mapping.js +0 -1
- package/decorator/request-param.d.ts +0 -1
- package/decorator/request-param.js +0 -1
- package/decorator/request-with.d.ts +0 -1
- package/decorator/request-with.js +0 -1
- package/lib/plugins/cache/index.js +0 -1
- package/plugins/auth/authorizer.d.ts +0 -49
- package/plugins/auth/authorizer.js +0 -1
- package/plugins/auth/history.d.ts +0 -15
- package/plugins/auth/history.js +0 -1
- package/plugins/auth/queue.d.ts +0 -16
- package/plugins/auth/queue.js +0 -1
- package/plugins/auth/storage.d.ts +0 -7
- package/plugins/auth/storage.js +0 -1
- package/plugins/cache/index.js +0 -1
package/lib/core/service.d.ts
CHANGED
|
@@ -1,33 +1,153 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
body
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import type { AxiosRequestConfig, AxiosResponse, CancelTokenSource } from "axios";
|
|
2
|
+
import AbortControllerAdapter from "./cancel";
|
|
3
|
+
import Config from "./config";
|
|
4
|
+
export type HeaderMappingValueType = string | ((...args: any[]) => string);
|
|
5
|
+
export type AxiosConfigOptionMappingType = keyof AxiosRequestConfig | ((...args: any[]) => (keyof AxiosRequestConfig));
|
|
6
|
+
export type AbortControllerGenerator = ((...args: any[]) => (AbortController | AbortControllerAdapter));
|
|
7
|
+
export type QueryStringEncodeFeatures = {
|
|
8
|
+
ignoreResidualParams?: boolean;
|
|
9
|
+
abortController?: (AbortController | AbortControllerAdapter) | AbortControllerGenerator;
|
|
10
|
+
};
|
|
11
|
+
export type RequestParamEncodeRule = {
|
|
12
|
+
body?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type NextAbortVersionAxiosRequestConfig = AxiosRequestConfig & {
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export declare const ConfigMapping: {
|
|
19
|
+
requestHeaders(rules: Record<string, HeaderMappingValueType>, args?: any[]): Record<string, string>;
|
|
20
|
+
axiosConfig<D = any>(options: AxiosConfigOptionMappingType[], args: any[]): AxiosRequestConfig<D>;
|
|
21
|
+
querystring(features: QueryStringEncodeFeatures | null, rules: Record<string, RequestParamEncodeRule>, data: Record<string, any>): string;
|
|
22
|
+
/**
|
|
23
|
+
* 从参数对象中提取 body 所属字段
|
|
24
|
+
* @param rules
|
|
25
|
+
* @param data
|
|
26
|
+
*/
|
|
27
|
+
body(rules: Record<string, RequestParamEncodeRule>, data: Record<string, any>): any;
|
|
28
|
+
};
|
|
29
|
+
export default class Service {
|
|
30
|
+
_path: string;
|
|
31
|
+
_config: Config;
|
|
32
|
+
_headers: Record<string, Record<string, HeaderMappingValueType>>;
|
|
33
|
+
_params: Record<string, Record<string, RequestParamEncodeRule>>;
|
|
34
|
+
_configs: Record<string, AxiosConfigOptionMappingType[]>;
|
|
35
|
+
_for: Record<string, string>;
|
|
36
|
+
_features: Record<string, QueryStringEncodeFeatures>;
|
|
37
|
+
constructor(path?: any);
|
|
38
|
+
get config(): Config;
|
|
39
|
+
set config(value: Config);
|
|
40
|
+
get path(): string;
|
|
41
|
+
set path(value: string);
|
|
42
|
+
params(id: string, name: string, config?: RequestParamEncodeRule): void;
|
|
43
|
+
headers(id: string, header: string, value: HeaderMappingValueType): void;
|
|
44
|
+
for(id: string, registrationName?: string): string;
|
|
45
|
+
abort(id: string, abortController: (AbortController | AbortControllerAdapter | AbortControllerGenerator)): void;
|
|
46
|
+
features(id: string, options?: QueryStringEncodeFeatures): QueryStringEncodeFeatures;
|
|
47
|
+
configs(id: string, options: AxiosConfigOptionMappingType): void;
|
|
48
|
+
/**
|
|
49
|
+
* 填充路径占位符 <br/>
|
|
50
|
+
* override this method to custom placeholder replacement <br>
|
|
51
|
+
* default implement: data = { id: 111 }; <br/>
|
|
52
|
+
* "/path/{id}" -> return "/path/111"
|
|
53
|
+
* @param path
|
|
54
|
+
* @param data
|
|
55
|
+
*/
|
|
56
|
+
pathVariable(path: string, data: Record<string, any>): string;
|
|
57
|
+
createRequestConfig(id: string, path: string, data: Record<string, any>, headerArgs?: any[], configArgs?: AxiosConfigOptionMappingType[]): {
|
|
58
|
+
path: string;
|
|
59
|
+
body: any;
|
|
60
|
+
config: AxiosRequestConfig<any>;
|
|
61
|
+
query: string;
|
|
62
|
+
};
|
|
63
|
+
request<T = any, R = AxiosResponse<T>, D = any>(method: string, path: string, data?: Record<string, any>, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
64
|
+
requestWith<T = any, R = AxiosResponse<T>, D = any>(method: string, path?: string): {
|
|
65
|
+
with(registration: string): {
|
|
66
|
+
with(registration: string): any;
|
|
67
|
+
param: (key: string, required?: boolean) => any;
|
|
68
|
+
abort(abortController: ((AbortController & {
|
|
69
|
+
source: CancelTokenSource;
|
|
70
|
+
}) | AbortControllerGenerator)): any;
|
|
71
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
72
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
73
|
+
body: (key: string) => any;
|
|
74
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
75
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
76
|
+
};
|
|
77
|
+
param: (key: string, required?: boolean) => {
|
|
78
|
+
with(registration: string): any;
|
|
79
|
+
param: (key: string, required?: boolean) => any;
|
|
80
|
+
abort(abortController: ((AbortController & {
|
|
81
|
+
source: CancelTokenSource;
|
|
82
|
+
}) | AbortControllerGenerator)): any;
|
|
83
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
84
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
85
|
+
body: (key: string) => any;
|
|
86
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
87
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
88
|
+
};
|
|
89
|
+
abort(abortController: ((AbortController & {
|
|
90
|
+
source: CancelTokenSource;
|
|
91
|
+
}) | AbortControllerGenerator)): {
|
|
92
|
+
with(registration: string): any;
|
|
93
|
+
param: (key: string, required?: boolean) => any;
|
|
94
|
+
abort(abortController: ((AbortController & {
|
|
95
|
+
source: CancelTokenSource;
|
|
96
|
+
}) | AbortControllerGenerator)): any;
|
|
97
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
98
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
99
|
+
body: (key: string) => any;
|
|
100
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
101
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
102
|
+
};
|
|
103
|
+
ignoreResidualParams(ignore?: boolean): {
|
|
104
|
+
with(registration: string): any;
|
|
105
|
+
param: (key: string, required?: boolean) => any;
|
|
106
|
+
abort(abortController: ((AbortController & {
|
|
107
|
+
source: CancelTokenSource;
|
|
108
|
+
}) | AbortControllerGenerator)): any;
|
|
109
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
110
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
111
|
+
body: (key: string) => any;
|
|
112
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
113
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
114
|
+
};
|
|
115
|
+
header: (header: string, value: HeaderMappingValueType) => {
|
|
116
|
+
with(registration: string): any;
|
|
117
|
+
param: (key: string, required?: boolean) => any;
|
|
118
|
+
abort(abortController: ((AbortController & {
|
|
119
|
+
source: CancelTokenSource;
|
|
120
|
+
}) | AbortControllerGenerator)): any;
|
|
121
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
122
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
123
|
+
body: (key: string) => any;
|
|
124
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
125
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
126
|
+
};
|
|
127
|
+
body: (key: string) => {
|
|
128
|
+
with(registration: string): any;
|
|
129
|
+
param: (key: string, required?: boolean) => any;
|
|
130
|
+
abort(abortController: ((AbortController & {
|
|
131
|
+
source: CancelTokenSource;
|
|
132
|
+
}) | AbortControllerGenerator)): any;
|
|
133
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
134
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
135
|
+
body: (key: string) => any;
|
|
136
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
137
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
138
|
+
};
|
|
139
|
+
config: (cfg: AxiosConfigOptionMappingType) => {
|
|
140
|
+
with(registration: string): any;
|
|
141
|
+
param: (key: string, required?: boolean) => any;
|
|
142
|
+
abort(abortController: ((AbortController & {
|
|
143
|
+
source: CancelTokenSource;
|
|
144
|
+
}) | AbortControllerGenerator)): any;
|
|
145
|
+
ignoreResidualParams(ignore?: boolean): any;
|
|
146
|
+
header: (header: string, value: HeaderMappingValueType) => any;
|
|
147
|
+
body: (key: string) => any;
|
|
148
|
+
config: (cfg: AxiosConfigOptionMappingType) => any;
|
|
149
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
150
|
+
};
|
|
151
|
+
send: (data?: Record<string, any>) => (Promise<R>);
|
|
152
|
+
};
|
|
153
|
+
}
|