axios-annotations 2.1.0 → 2.1.1
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 +3 -3
- package/lib/core/config.d.ts +15 -15
- package/lib/core/provider.d.ts +4 -4
- package/lib/core/provider.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,9 +131,9 @@ tsconfig.json / jsconfig.json
|
|
|
131
131
|
```javascript
|
|
132
132
|
import {
|
|
133
133
|
Service,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
RequestConfig,
|
|
135
|
+
RequestParam,
|
|
136
|
+
RequestMapping,
|
|
137
137
|
RequestBody,
|
|
138
138
|
RequestHeader,
|
|
139
139
|
IgnoreResidualParams
|
package/lib/core/config.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import AxiosStaticInstanceProvider from "./provider";
|
|
2
|
-
import type { AxiosInstance } from "axios";
|
|
3
|
-
export type ConfigPlugin = (axios:
|
|
2
|
+
import type { AxiosInstance, AxiosStatic } from "axios";
|
|
3
|
+
export type ConfigPlugin<StaticType = AxiosStatic, InstanceType = AxiosInstance> = (axios: InstanceType, config: Config<StaticType, InstanceType>) => void;
|
|
4
4
|
export type PartialConstructorString = string | null;
|
|
5
5
|
export type PartialConstructorNumber = number | null;
|
|
6
|
-
export type PartialPluginConstructorPlugins = ConfigPlugin[] | null;
|
|
7
|
-
export default class Config {
|
|
6
|
+
export type PartialPluginConstructorPlugins<StaticType = AxiosStatic, InstanceType = AxiosInstance> = ConfigPlugin<StaticType, InstanceType>[] | null;
|
|
7
|
+
export default class Config<StaticType = AxiosStatic, InstanceType = AxiosInstance> {
|
|
8
8
|
private _host;
|
|
9
9
|
private _port;
|
|
10
10
|
private _protocol;
|
|
@@ -17,11 +17,11 @@ export default class Config {
|
|
|
17
17
|
host?: PartialConstructorString;
|
|
18
18
|
port?: PartialConstructorNumber;
|
|
19
19
|
prefix?: PartialConstructorString;
|
|
20
|
-
plugins?: PartialPluginConstructorPlugins
|
|
21
|
-
axiosProvider?: AxiosStaticInstanceProvider
|
|
20
|
+
plugins?: PartialPluginConstructorPlugins<StaticType, InstanceType>;
|
|
21
|
+
axiosProvider?: AxiosStaticInstanceProvider<StaticType>;
|
|
22
22
|
});
|
|
23
23
|
static forName(name: string): Config | null;
|
|
24
|
-
init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins): void;
|
|
24
|
+
init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins<StaticType, InstanceType>): void;
|
|
25
25
|
get host(): string;
|
|
26
26
|
set host(value: string);
|
|
27
27
|
get port(): number;
|
|
@@ -40,21 +40,21 @@ export default class Config {
|
|
|
40
40
|
* return "http://localhost:8080/a"
|
|
41
41
|
*/
|
|
42
42
|
get baseURL(): string;
|
|
43
|
-
get plugins(): PartialPluginConstructorPlugins
|
|
44
|
-
set plugins(value: PartialPluginConstructorPlugins);
|
|
45
|
-
get axiosProvider(): AxiosStaticInstanceProvider
|
|
46
|
-
set axiosProvider(value: AxiosStaticInstanceProvider);
|
|
43
|
+
get plugins(): PartialPluginConstructorPlugins<StaticType, InstanceType>;
|
|
44
|
+
set plugins(value: PartialPluginConstructorPlugins<StaticType, InstanceType>);
|
|
45
|
+
get axiosProvider(): AxiosStaticInstanceProvider<StaticType>;
|
|
46
|
+
set axiosProvider(value: AxiosStaticInstanceProvider<StaticType>);
|
|
47
47
|
/**
|
|
48
48
|
* register config global and return self.
|
|
49
49
|
* @param name
|
|
50
50
|
* @return {Config} config self
|
|
51
51
|
*/
|
|
52
|
-
register(name: string): Config
|
|
52
|
+
register(name: string): Config<StaticType, InstanceType>;
|
|
53
53
|
/**
|
|
54
54
|
* remove self from global config store.
|
|
55
55
|
* @return {Config} - config self
|
|
56
56
|
*/
|
|
57
|
-
unregister(): Config
|
|
58
|
-
requestAxiosInstance(): Promise<
|
|
57
|
+
unregister(): Config<StaticType, InstanceType>;
|
|
58
|
+
requestAxiosInstance(): Promise<InstanceType>;
|
|
59
59
|
}
|
|
60
|
-
export declare const config: Config
|
|
60
|
+
export declare const config: Config<AxiosStatic, AxiosInstance>;
|
package/lib/core/provider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AxiosStatic } from "axios";
|
|
2
|
-
export default class AxiosStaticInstanceProvider {
|
|
3
|
-
__instance:
|
|
4
|
-
provide(): Promise<
|
|
5
|
-
get(): Promise<
|
|
2
|
+
export default class AxiosStaticInstanceProvider<StaticType = AxiosStatic> {
|
|
3
|
+
__instance: StaticType | null;
|
|
4
|
+
provide(): Promise<StaticType>;
|
|
5
|
+
get(): Promise<StaticType>;
|
|
6
6
|
}
|
package/lib/core/provider.js
CHANGED
|
@@ -152,6 +152,12 @@ var AxiosStaticInstanceProvider = /** @class */ function() {
|
|
|
152
152
|
return __generator(this, function(_b) {
|
|
153
153
|
switch(_b.label){
|
|
154
154
|
case 0:
|
|
155
|
+
if (this.__instance) {
|
|
156
|
+
return [
|
|
157
|
+
2 /*return*/ ,
|
|
158
|
+
this.__instance
|
|
159
|
+
];
|
|
160
|
+
}
|
|
155
161
|
_a = this;
|
|
156
162
|
return [
|
|
157
163
|
4 /*yield*/ ,
|