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/index.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RequestWith = exports.RequestParam = exports.RequestMapping = exports.RequestHeader = exports.RequestConfig = exports.RequestBody = exports.PutMapping = exports.PostMapping = exports.PatchMapping = exports.IgnoreResidualParams = exports.GetMapping = exports.DeleteMapping = exports.AbortSource = exports.Service = exports.AxiosStaticInstanceProvider = exports.AbortControllerAdapter = exports.URLSearchParamsParser = exports.config = exports.Config = void 0;
|
|
7
|
+
var index_1 = require("./lib/index");
|
|
8
|
+
Object.defineProperty(exports, "Config", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return index_1.Config;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "config", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return index_1.config;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "URLSearchParamsParser", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return index_1.URLSearchParamsParser;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "AbortControllerAdapter", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return index_1.AbortControllerAdapter;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "AxiosStaticInstanceProvider", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return index_1.AxiosStaticInstanceProvider;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "Service", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return index_1.Service;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "AbortSource", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return index_1.AbortSource;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "DeleteMapping", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function get() {
|
|
53
|
+
return index_1.DeleteMapping;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "GetMapping", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return index_1.GetMapping;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "IgnoreResidualParams", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function get() {
|
|
65
|
+
return index_1.IgnoreResidualParams;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "PatchMapping", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function get() {
|
|
71
|
+
return index_1.PatchMapping;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "PostMapping", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function get() {
|
|
77
|
+
return index_1.PostMapping;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "PutMapping", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function get() {
|
|
83
|
+
return index_1.PutMapping;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "RequestBody", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function get() {
|
|
89
|
+
return index_1.RequestBody;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "RequestConfig", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function get() {
|
|
95
|
+
return index_1.RequestConfig;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "RequestHeader", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function get() {
|
|
101
|
+
return index_1.RequestHeader;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "RequestMapping", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function get() {
|
|
107
|
+
return index_1.RequestMapping;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, "RequestParam", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function get() {
|
|
113
|
+
return index_1.RequestParam;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "RequestWith", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function get() {
|
|
119
|
+
return index_1.RequestWith;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CancelTokenSource, CancelTokenStatic } from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* 兼容旧版CancelToken,包装成AbortController
|
|
4
|
+
*/
|
|
5
|
+
export default class AbortControllerAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* {
|
|
8
|
+
* cancel: (message, config, request) => void;
|
|
9
|
+
* token: { promise, _listeners, reason: CanceledError }
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
_source: CancelTokenSource;
|
|
13
|
+
_signal: {
|
|
14
|
+
onabort?: (e: Event) => void;
|
|
15
|
+
reason?: string;
|
|
16
|
+
aborted: boolean;
|
|
17
|
+
};
|
|
18
|
+
constructor(CancelToken: CancelTokenStatic);
|
|
19
|
+
/**
|
|
20
|
+
* sham AbortSignal. <br/>
|
|
21
|
+
* signal struct: {aborted: true, reason: string, onabort: null} <br/>
|
|
22
|
+
*/
|
|
23
|
+
get signal(): {
|
|
24
|
+
onabort?: (e: Event) => void;
|
|
25
|
+
reason?: string;
|
|
26
|
+
aborted: boolean;
|
|
27
|
+
};
|
|
28
|
+
get source(): CancelTokenSource;
|
|
29
|
+
abort(message?: string): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
/**
|
|
6
|
+
* 兼容旧版CancelToken,包装成AbortController
|
|
7
|
+
*/ var AbortControllerAdapter = /** @class */ function() {
|
|
8
|
+
function AbortControllerAdapter(CancelToken) {
|
|
9
|
+
var _this = this;
|
|
10
|
+
// sham signal onabort
|
|
11
|
+
this._signal = {
|
|
12
|
+
onabort: undefined,
|
|
13
|
+
reason: "",
|
|
14
|
+
aborted: false
|
|
15
|
+
};
|
|
16
|
+
this._source = CancelToken.source();
|
|
17
|
+
this._source.token.promise.then(function() {
|
|
18
|
+
var _a;
|
|
19
|
+
if (typeof _this._signal.onabort === "function") {
|
|
20
|
+
_this._signal.onabort(new Event("abort"));
|
|
21
|
+
}
|
|
22
|
+
_this._signal.aborted = true;
|
|
23
|
+
_this._signal.reason = (_a = _this._source.token.reason) === null || _a === void 0 ? void 0 : _a.message;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(AbortControllerAdapter.prototype, "signal", {
|
|
27
|
+
/**
|
|
28
|
+
* sham AbortSignal. <br/>
|
|
29
|
+
* signal struct: {aborted: true, reason: string, onabort: null} <br/>
|
|
30
|
+
*/ get: function get() {
|
|
31
|
+
return this._signal;
|
|
32
|
+
},
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(AbortControllerAdapter.prototype, "source", {
|
|
37
|
+
get: function get() {
|
|
38
|
+
return this._source;
|
|
39
|
+
},
|
|
40
|
+
enumerable: false,
|
|
41
|
+
configurable: true
|
|
42
|
+
});
|
|
43
|
+
// sham AbortController.abort(reason)
|
|
44
|
+
AbortControllerAdapter.prototype.abort = function(message) {
|
|
45
|
+
if (message === void 0) {
|
|
46
|
+
message = "";
|
|
47
|
+
}
|
|
48
|
+
if (message) {
|
|
49
|
+
this._source.cancel(message);
|
|
50
|
+
} else {
|
|
51
|
+
this._source.cancel();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return AbortControllerAdapter;
|
|
55
|
+
}();
|
|
56
|
+
exports["default"] = AbortControllerAdapter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
+
export declare function normalizePath(path: string): string;
|
|
3
|
+
export declare function isNullOrEmpty(param: any): boolean;
|
|
4
|
+
export declare function forward<T = any, R = AxiosResponse<T>, D = any>(axios: AxiosInstance, origin: string, prefix1: string, prefix2: string, path: string, method: string, query: string, body: D, config: AxiosRequestConfig<D>): Promise<R>;
|
|
5
|
+
export declare function replaceAllStr(target: string, search: string | RegExp, replacement: string): string;
|
|
6
|
+
export declare function mapToDefaultMethod(method: any, defaultMethod?: string): string;
|
package/lib/core/common.js
CHANGED
|
@@ -1 +1,166 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) {
|
|
4
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
5
|
+
resolve(value);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
9
|
+
function fulfilled(value) {
|
|
10
|
+
try {
|
|
11
|
+
step(generator.next(value));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
reject(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function rejected(value) {
|
|
17
|
+
try {
|
|
18
|
+
step(generator["throw"](value));
|
|
19
|
+
} catch (e) {
|
|
20
|
+
reject(e);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function step(result) {
|
|
24
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
25
|
+
}
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
30
|
+
var _ = {
|
|
31
|
+
label: 0,
|
|
32
|
+
sent: function sent() {
|
|
33
|
+
if (t[0] & 1) throw t[1];
|
|
34
|
+
return t[1];
|
|
35
|
+
},
|
|
36
|
+
trys: [],
|
|
37
|
+
ops: []
|
|
38
|
+
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
39
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
40
|
+
return this;
|
|
41
|
+
}), g;
|
|
42
|
+
function verb(n) {
|
|
43
|
+
return function(v) {
|
|
44
|
+
return step([
|
|
45
|
+
n,
|
|
46
|
+
v
|
|
47
|
+
]);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function step(op) {
|
|
51
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
52
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
53
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
54
|
+
if (y = 0, t) op = [
|
|
55
|
+
op[0] & 2,
|
|
56
|
+
t.value
|
|
57
|
+
];
|
|
58
|
+
switch(op[0]){
|
|
59
|
+
case 0:
|
|
60
|
+
case 1:
|
|
61
|
+
t = op;
|
|
62
|
+
break;
|
|
63
|
+
case 4:
|
|
64
|
+
_.label++;
|
|
65
|
+
return {
|
|
66
|
+
value: op[1],
|
|
67
|
+
done: false
|
|
68
|
+
};
|
|
69
|
+
case 5:
|
|
70
|
+
_.label++;
|
|
71
|
+
y = op[1];
|
|
72
|
+
op = [
|
|
73
|
+
0
|
|
74
|
+
];
|
|
75
|
+
continue;
|
|
76
|
+
case 7:
|
|
77
|
+
op = _.ops.pop();
|
|
78
|
+
_.trys.pop();
|
|
79
|
+
continue;
|
|
80
|
+
default:
|
|
81
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
82
|
+
_ = 0;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
86
|
+
_.label = op[1];
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
90
|
+
_.label = t[1];
|
|
91
|
+
t = op;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (t && _.label < t[2]) {
|
|
95
|
+
_.label = t[2];
|
|
96
|
+
_.ops.push(op);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t[2]) _.ops.pop();
|
|
100
|
+
_.trys.pop();
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
op = body.call(thisArg, _);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
op = [
|
|
106
|
+
6,
|
|
107
|
+
e
|
|
108
|
+
];
|
|
109
|
+
y = 0;
|
|
110
|
+
} finally{
|
|
111
|
+
f = t = 0;
|
|
112
|
+
}
|
|
113
|
+
if (op[0] & 5) throw op[1];
|
|
114
|
+
return {
|
|
115
|
+
value: op[0] ? op[1] : void 0,
|
|
116
|
+
done: true
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
Object.defineProperty(exports, "__esModule", {
|
|
121
|
+
value: true
|
|
122
|
+
});
|
|
123
|
+
exports.normalizePath = normalizePath;
|
|
124
|
+
exports.isNullOrEmpty = isNullOrEmpty;
|
|
125
|
+
exports.forward = forward;
|
|
126
|
+
exports.replaceAllStr = replaceAllStr;
|
|
127
|
+
exports.mapToDefaultMethod = mapToDefaultMethod;
|
|
128
|
+
function normalizePath(path) {
|
|
129
|
+
return path.replace(/\/+/g, "/").replace(/\/$/, "");
|
|
130
|
+
}
|
|
131
|
+
function isNullOrEmpty(param) {
|
|
132
|
+
return param === null || param === undefined || param === "";
|
|
133
|
+
}
|
|
134
|
+
function forward(axios, origin, prefix1, prefix2, path, method, query, body, config) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
136
|
+
var url;
|
|
137
|
+
return __generator(this, function(_a) {
|
|
138
|
+
url = "".concat(origin) + normalizePath("/".concat(prefix1, "/").concat(prefix2, "/").concat(path));
|
|
139
|
+
if (query) {
|
|
140
|
+
if (url.lastIndexOf("?") >= 0) {
|
|
141
|
+
url += "&" + query;
|
|
142
|
+
} else {
|
|
143
|
+
url += "?" + query;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return [
|
|
147
|
+
2 /*return*/ ,
|
|
148
|
+
axios.request(Object.assign({
|
|
149
|
+
method: method,
|
|
150
|
+
url: url,
|
|
151
|
+
data: body
|
|
152
|
+
}, config))
|
|
153
|
+
];
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function replaceAllStr(target, search, replacement) {
|
|
158
|
+
var pattern = typeof search === 'string' ? RegExp(search, 'g') : search;
|
|
159
|
+
return target.replace(pattern, replacement);
|
|
160
|
+
}
|
|
161
|
+
function mapToDefaultMethod(method, defaultMethod) {
|
|
162
|
+
if (defaultMethod === void 0) {
|
|
163
|
+
defaultMethod = "GET";
|
|
164
|
+
}
|
|
165
|
+
return typeof method === "string" ? method : defaultMethod;
|
|
166
|
+
}
|
package/lib/core/config.d.ts
CHANGED
|
@@ -1,29 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
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
|
-
|
|
1
|
+
import AxiosStaticInstanceProvider from "./provider";
|
|
2
|
+
import type { AxiosInstance } from "axios";
|
|
3
|
+
export type ConfigPlugin = (axios: AxiosInstance, config: Config) => void;
|
|
4
|
+
export type PartialConstructorString = string | null;
|
|
5
|
+
export type PartialConstructorNumber = number | null;
|
|
6
|
+
export type PartialPluginConstructorPlugins = ConfigPlugin[] | null;
|
|
7
|
+
export default class Config {
|
|
8
|
+
private _host;
|
|
9
|
+
private _port;
|
|
10
|
+
private _protocol;
|
|
11
|
+
private _prefix;
|
|
12
|
+
private _axiosProvider;
|
|
13
|
+
private _axios;
|
|
14
|
+
private _plugins;
|
|
15
|
+
constructor(options?: {
|
|
16
|
+
protocol?: PartialConstructorString;
|
|
17
|
+
host?: PartialConstructorString;
|
|
18
|
+
port?: PartialConstructorNumber;
|
|
19
|
+
prefix?: PartialConstructorString;
|
|
20
|
+
plugins?: PartialPluginConstructorPlugins;
|
|
21
|
+
axiosProvider?: AxiosStaticInstanceProvider;
|
|
22
|
+
});
|
|
23
|
+
static forName(name: string): Config | null;
|
|
24
|
+
init(protocol: PartialConstructorString, host: PartialConstructorString, port: PartialConstructorNumber, prefix: PartialConstructorString, plugins: PartialPluginConstructorPlugins): void;
|
|
25
|
+
get host(): string;
|
|
26
|
+
set host(value: string);
|
|
27
|
+
get port(): number;
|
|
28
|
+
set port(value: number);
|
|
29
|
+
get protocol(): string;
|
|
30
|
+
set protocol(value: string);
|
|
31
|
+
get prefix(): string;
|
|
32
|
+
set prefix(value: string);
|
|
33
|
+
/**
|
|
34
|
+
* default value: <br/>
|
|
35
|
+
* http://localhost:8080
|
|
36
|
+
*/
|
|
37
|
+
get origin(): string;
|
|
38
|
+
/**
|
|
39
|
+
* if prefix = "/a" <br/>
|
|
40
|
+
* return "http://localhost:8080/a"
|
|
41
|
+
*/
|
|
42
|
+
get baseURL(): string;
|
|
43
|
+
get plugins(): PartialPluginConstructorPlugins;
|
|
44
|
+
set plugins(value: PartialPluginConstructorPlugins);
|
|
45
|
+
get axiosProvider(): AxiosStaticInstanceProvider;
|
|
46
|
+
set axiosProvider(value: AxiosStaticInstanceProvider);
|
|
47
|
+
/**
|
|
48
|
+
* register config global and return self.
|
|
49
|
+
* @param name
|
|
50
|
+
* @return {Config} config self
|
|
51
|
+
*/
|
|
52
|
+
register(name: string): Config;
|
|
53
|
+
/**
|
|
54
|
+
* remove self from global config store.
|
|
55
|
+
* @return {Config} - config self
|
|
56
|
+
*/
|
|
57
|
+
unregister(): Config;
|
|
58
|
+
requestAxiosInstance(): Promise<AxiosInstance>;
|
|
59
|
+
}
|
|
60
|
+
export declare const config: Config;
|