axios-annotations 2.2.0 → 2.3.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 +21 -21
- package/README.md +944 -944
- package/lib/core/expect.d.ts +4 -4
- package/lib/core/expect.js +15 -15
- package/lib/core/service.d.ts +2 -2
- package/lib/plugins/auth/queue.js +21 -13
- package/package.json +16 -16
package/lib/core/expect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {AxiosPromise} from "axios";
|
|
2
|
-
|
|
3
|
-
export default function Expect<T, D = AxiosPromise<T>>(params: any): D;
|
|
4
|
-
export {};
|
|
1
|
+
import type {AxiosPromise} from "axios";
|
|
2
|
+
|
|
3
|
+
export default function Expect<T, D = AxiosPromise<T>>(params: any): D;
|
|
4
|
+
export {};
|
package/lib/core/expect.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports["default"] = Expect;
|
|
6
|
-
/**
|
|
7
|
-
* 警告 Warning: <br/>
|
|
8
|
-
* 仅用于仿冒使用装饰器的方法返回值,绕过IDE/Typescript的类型检查,获得代码提示功能。<br/>
|
|
9
|
-
*
|
|
10
|
-
* Only used to ensure the return value of a method that uses decorators,
|
|
11
|
-
* bypassing IDE/Typescript type checking and obtaining code intelligence.
|
|
12
|
-
*/
|
|
13
|
-
function Expect(params) {
|
|
14
|
-
return params;
|
|
15
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports["default"] = Expect;
|
|
6
|
+
/**
|
|
7
|
+
* 警告 Warning: <br/>
|
|
8
|
+
* 仅用于仿冒使用装饰器的方法返回值,绕过IDE/Typescript的类型检查,获得代码提示功能。<br/>
|
|
9
|
+
*
|
|
10
|
+
* Only used to ensure the return value of a method that uses decorators,
|
|
11
|
+
* bypassing IDE/Typescript type checking and obtaining code intelligence.
|
|
12
|
+
*/
|
|
13
|
+
function Expect(params) {
|
|
14
|
+
return params;
|
|
15
|
+
}
|
package/lib/core/service.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export default class Service {
|
|
|
35
35
|
_for: Record<string, string>;
|
|
36
36
|
_features: Record<string, QueryStringEncodeFeatures>;
|
|
37
37
|
constructor(path?: any);
|
|
38
|
-
get config(): Config
|
|
39
|
-
set config(value: Config
|
|
38
|
+
get config(): Config;
|
|
39
|
+
set config(value: Config);
|
|
40
40
|
get path(): string;
|
|
41
41
|
set path(value: string);
|
|
42
42
|
params(id: string, name: string, config?: RequestParamEncodeRule): void;
|
|
@@ -158,19 +158,21 @@ var PendingQueue = /** @class */ function() {
|
|
|
158
158
|
}
|
|
159
159
|
PendingQueue.prototype.resend = function(error_1) {
|
|
160
160
|
return __awaiter(this, arguments, void 0, function(error, retries) {
|
|
161
|
-
var i, session, axios, e_1;
|
|
161
|
+
var maxTimes, i, session, axios, e_1;
|
|
162
162
|
if (retries === void 0) {
|
|
163
163
|
retries = 3;
|
|
164
164
|
}
|
|
165
165
|
return __generator(this, function(_a) {
|
|
166
166
|
switch(_a.label){
|
|
167
167
|
case 0:
|
|
168
|
+
maxTimes = Math.max(this._retryTimes, retries, 1);
|
|
169
|
+
console.log(maxTimes);
|
|
168
170
|
i = 0;
|
|
169
171
|
_a.label = 1;
|
|
170
172
|
case 1:
|
|
171
|
-
if (!(i <
|
|
173
|
+
if (!(i < maxTimes)) return [
|
|
172
174
|
3 /*break*/ ,
|
|
173
|
-
|
|
175
|
+
10
|
|
174
176
|
];
|
|
175
177
|
if (!(i > 0)) return [
|
|
176
178
|
3 /*break*/ ,
|
|
@@ -198,37 +200,43 @@ var PendingQueue = /** @class */ function() {
|
|
|
198
200
|
case 5:
|
|
199
201
|
_a.trys.push([
|
|
200
202
|
5,
|
|
201
|
-
|
|
203
|
+
8,
|
|
202
204
|
,
|
|
203
|
-
|
|
205
|
+
9
|
|
204
206
|
]);
|
|
205
207
|
return [
|
|
206
208
|
4 /*yield*/ ,
|
|
207
|
-
this._config.
|
|
209
|
+
this._config.axiosProvider.get()
|
|
208
210
|
];
|
|
209
211
|
case 6:
|
|
210
|
-
axios = _a.sent();
|
|
212
|
+
axios = _a.sent().create();
|
|
211
213
|
this._authorizer.withAuthentication(error.config, session);
|
|
212
214
|
return [
|
|
213
|
-
|
|
215
|
+
4 /*yield*/ ,
|
|
214
216
|
axios.request(error.config)
|
|
215
217
|
];
|
|
216
218
|
case 7:
|
|
219
|
+
// fix: 401 循环 忘了加 await
|
|
220
|
+
return [
|
|
221
|
+
2 /*return*/ ,
|
|
222
|
+
_a.sent()
|
|
223
|
+
];
|
|
224
|
+
case 8:
|
|
217
225
|
e_1 = _a.sent();
|
|
218
|
-
if (i >=
|
|
226
|
+
if (i >= maxTimes) {
|
|
219
227
|
throw e_1;
|
|
220
228
|
}
|
|
221
229
|
return [
|
|
222
230
|
3 /*break*/ ,
|
|
223
|
-
|
|
231
|
+
9
|
|
224
232
|
];
|
|
225
|
-
case
|
|
226
|
-
|
|
233
|
+
case 9:
|
|
234
|
+
i++;
|
|
227
235
|
return [
|
|
228
236
|
3 /*break*/ ,
|
|
229
237
|
1
|
|
230
238
|
];
|
|
231
|
-
case
|
|
239
|
+
case 10:
|
|
232
240
|
throw error;
|
|
233
241
|
}
|
|
234
242
|
});
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "axios-annotations",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "HTTP client library uses Axios without Typescript.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"miniprogram": "lib",
|
|
7
|
-
"miniprogramRoot": "lib",
|
|
8
|
-
"keywords": [
|
|
9
|
-
"axios",
|
|
10
|
-
"axios-annotations",
|
|
11
|
-
"axios-decorators"
|
|
12
|
-
],
|
|
13
|
-
"author": "sitorhy",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"homepage": "https://github.com/sitorhy/axios-annotations#readme"
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "axios-annotations",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "HTTP client library uses Axios without Typescript.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"miniprogram": "lib",
|
|
7
|
+
"miniprogramRoot": "lib",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"axios",
|
|
10
|
+
"axios-annotations",
|
|
11
|
+
"axios-decorators"
|
|
12
|
+
],
|
|
13
|
+
"author": "sitorhy",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/sitorhy/axios-annotations#readme"
|
|
16
|
+
}
|