axios-annotations 1.3.4 → 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/config.js
CHANGED
|
@@ -1 +1,332 @@
|
|
|
1
|
-
|
|
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.config = void 0;
|
|
124
|
+
var provider_1 = require("./provider");
|
|
125
|
+
var _global_configs = [];
|
|
126
|
+
var Config = /** @class */ function() {
|
|
127
|
+
function Config(options) {
|
|
128
|
+
this._host = "localhost";
|
|
129
|
+
this._port = 8080;
|
|
130
|
+
this._protocol = "http";
|
|
131
|
+
this._prefix = "";
|
|
132
|
+
this._axiosProvider = new provider_1["default"]();
|
|
133
|
+
this._axios = null;
|
|
134
|
+
this._plugins = null;
|
|
135
|
+
if (options === null || options === void 0 ? void 0 : options.axiosProvider) {
|
|
136
|
+
this._axiosProvider = options === null || options === void 0 ? void 0 : options.axiosProvider;
|
|
137
|
+
}
|
|
138
|
+
this.init((options === null || options === void 0 ? void 0 : options.protocol) || null, (options === null || options === void 0 ? void 0 : options.host) || null, (options === null || options === void 0 ? void 0 : options.port) || null, (options === null || options === void 0 ? void 0 : options.prefix) || null, (options === null || options === void 0 ? void 0 : options.plugins) || null);
|
|
139
|
+
}
|
|
140
|
+
Config.forName = function(name) {
|
|
141
|
+
var c = _global_configs.find(function(i) {
|
|
142
|
+
return i.name === name;
|
|
143
|
+
});
|
|
144
|
+
if (c) {
|
|
145
|
+
return c.config;
|
|
146
|
+
} else {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
Config.prototype.init = function(protocol, host, port, prefix, plugins) {
|
|
151
|
+
if (port) {
|
|
152
|
+
this.port = port;
|
|
153
|
+
}
|
|
154
|
+
if (protocol) {
|
|
155
|
+
this.protocol = protocol;
|
|
156
|
+
}
|
|
157
|
+
if (host) {
|
|
158
|
+
this.host = host;
|
|
159
|
+
}
|
|
160
|
+
if (prefix) {
|
|
161
|
+
this.prefix = prefix;
|
|
162
|
+
}
|
|
163
|
+
if (Array.isArray(plugins)) {
|
|
164
|
+
this._plugins = plugins;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
Object.defineProperty(Config.prototype, "host", {
|
|
168
|
+
get: function get() {
|
|
169
|
+
return this._host;
|
|
170
|
+
},
|
|
171
|
+
set: function set(value) {
|
|
172
|
+
this._host = value;
|
|
173
|
+
},
|
|
174
|
+
enumerable: false,
|
|
175
|
+
configurable: true
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(Config.prototype, "port", {
|
|
178
|
+
get: function get() {
|
|
179
|
+
return this._port;
|
|
180
|
+
},
|
|
181
|
+
set: function set(value) {
|
|
182
|
+
this._port = value;
|
|
183
|
+
},
|
|
184
|
+
enumerable: false,
|
|
185
|
+
configurable: true
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(Config.prototype, "protocol", {
|
|
188
|
+
get: function get() {
|
|
189
|
+
return this._protocol;
|
|
190
|
+
},
|
|
191
|
+
set: function set(value) {
|
|
192
|
+
this._protocol = value;
|
|
193
|
+
},
|
|
194
|
+
enumerable: false,
|
|
195
|
+
configurable: true
|
|
196
|
+
});
|
|
197
|
+
Object.defineProperty(Config.prototype, "prefix", {
|
|
198
|
+
get: function get() {
|
|
199
|
+
return this._prefix;
|
|
200
|
+
},
|
|
201
|
+
set: function set(value) {
|
|
202
|
+
this._prefix = value;
|
|
203
|
+
},
|
|
204
|
+
enumerable: false,
|
|
205
|
+
configurable: true
|
|
206
|
+
});
|
|
207
|
+
Object.defineProperty(Config.prototype, "origin", {
|
|
208
|
+
/**
|
|
209
|
+
* default value: <br/>
|
|
210
|
+
* http://localhost:8080
|
|
211
|
+
*/ get: function get() {
|
|
212
|
+
return "".concat(this.protocol, "://").concat(this.host).concat(this.port ? ":" + this.port : "");
|
|
213
|
+
},
|
|
214
|
+
enumerable: false,
|
|
215
|
+
configurable: true
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(Config.prototype, "baseURL", {
|
|
218
|
+
/**
|
|
219
|
+
* if prefix = "/a" <br/>
|
|
220
|
+
* return "http://localhost:8080/a"
|
|
221
|
+
*/ get: function get() {
|
|
222
|
+
return "".concat(this.origin).concat(this.prefix);
|
|
223
|
+
},
|
|
224
|
+
enumerable: false,
|
|
225
|
+
configurable: true
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(Config.prototype, "plugins", {
|
|
228
|
+
get: function get() {
|
|
229
|
+
return this._plugins;
|
|
230
|
+
},
|
|
231
|
+
set: function set(value) {
|
|
232
|
+
this._plugins = value;
|
|
233
|
+
},
|
|
234
|
+
enumerable: false,
|
|
235
|
+
configurable: true
|
|
236
|
+
});
|
|
237
|
+
Object.defineProperty(Config.prototype, "axiosProvider", {
|
|
238
|
+
get: function get() {
|
|
239
|
+
return this._axiosProvider;
|
|
240
|
+
},
|
|
241
|
+
set: function set(value) {
|
|
242
|
+
this._axiosProvider = value;
|
|
243
|
+
},
|
|
244
|
+
enumerable: false,
|
|
245
|
+
configurable: true
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* register config global and return self.
|
|
249
|
+
* @param name
|
|
250
|
+
* @return {Config} config self
|
|
251
|
+
*/ Config.prototype.register = function(name) {
|
|
252
|
+
var _this = this;
|
|
253
|
+
var c = _global_configs.find(function(i) {
|
|
254
|
+
return i.config === _this;
|
|
255
|
+
});
|
|
256
|
+
if (c) {
|
|
257
|
+
c.name = name;
|
|
258
|
+
} else {
|
|
259
|
+
_global_configs.push({
|
|
260
|
+
name: name,
|
|
261
|
+
config: this
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return this;
|
|
265
|
+
};
|
|
266
|
+
// noinspection JSUnusedGlobalSymbols
|
|
267
|
+
/**
|
|
268
|
+
* remove self from global config store.
|
|
269
|
+
* @return {Config} - config self
|
|
270
|
+
*/ Config.prototype.unregister = function() {
|
|
271
|
+
var _this = this;
|
|
272
|
+
var index = _global_configs.findIndex(function(i) {
|
|
273
|
+
return i.config === _this;
|
|
274
|
+
});
|
|
275
|
+
if (index >= 0) {
|
|
276
|
+
_global_configs.splice(index, 1);
|
|
277
|
+
}
|
|
278
|
+
return this;
|
|
279
|
+
};
|
|
280
|
+
Config.prototype.requestAxiosInstance = function() {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
282
|
+
var _a, e_1;
|
|
283
|
+
var _this = this;
|
|
284
|
+
return __generator(this, function(_b) {
|
|
285
|
+
switch(_b.label){
|
|
286
|
+
case 0:
|
|
287
|
+
if (this._axios) {
|
|
288
|
+
return [
|
|
289
|
+
2 /*return*/ ,
|
|
290
|
+
this._axios
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
_b.label = 1;
|
|
294
|
+
case 1:
|
|
295
|
+
_b.trys.push([
|
|
296
|
+
1,
|
|
297
|
+
3,
|
|
298
|
+
,
|
|
299
|
+
4
|
|
300
|
+
]);
|
|
301
|
+
_a = this;
|
|
302
|
+
return [
|
|
303
|
+
4 /*yield*/ ,
|
|
304
|
+
this._axiosProvider.get()
|
|
305
|
+
];
|
|
306
|
+
case 2:
|
|
307
|
+
_a._axios = _b.sent().create();
|
|
308
|
+
return [
|
|
309
|
+
3 /*break*/ ,
|
|
310
|
+
4
|
|
311
|
+
];
|
|
312
|
+
case 3:
|
|
313
|
+
e_1 = _b.sent();
|
|
314
|
+
throw e_1;
|
|
315
|
+
case 4:
|
|
316
|
+
if (this._plugins && this._plugins.length) {
|
|
317
|
+
this._plugins.forEach(function(plugin) {
|
|
318
|
+
plugin(_this._axios, _this);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return [
|
|
322
|
+
2 /*return*/ ,
|
|
323
|
+
this._axios
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
return Config;
|
|
330
|
+
}();
|
|
331
|
+
exports["default"] = Config;
|
|
332
|
+
exports.config = new Config();
|
package/lib/core/parser.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
declare const URLSearchParamsParser: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
declare const URLSearchParamsParser: {
|
|
2
|
+
/**
|
|
3
|
+
* Converting encoder object to query string. <br/>
|
|
4
|
+
* Refer to the URLSearchParams description for more details <br/>
|
|
5
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
|
|
6
|
+
* @param encoder
|
|
7
|
+
*/
|
|
8
|
+
encode: (encoder: URLSearchParams | Record<string, any>) => string;
|
|
9
|
+
/**
|
|
10
|
+
* returns a new URLSearchParams object
|
|
11
|
+
* @param params
|
|
12
|
+
*/
|
|
13
|
+
decode: (params: string[][] | Record<string, any> | string | URLSearchParams) => URLSearchParams | Record<string, any>;
|
|
14
|
+
has(encoder: URLSearchParams | Record<string, any>, key: string): boolean;
|
|
15
|
+
delete: (encoder: URLSearchParams | Record<string, any>, key: string) => void;
|
|
16
|
+
get: (encoder: URLSearchParams | Record<string, any>, key: string) => any;
|
|
17
|
+
append: (encoder: URLSearchParams | Record<string, any>, key: string, value: any) => void;
|
|
18
|
+
};
|
|
19
|
+
export default URLSearchParamsParser;
|
package/lib/core/parser.js
CHANGED
|
@@ -1 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var common_1 = require("./common");
|
|
6
|
+
var URLSearchParamsParser = {
|
|
7
|
+
/**
|
|
8
|
+
* Converting encoder object to query string. <br/>
|
|
9
|
+
* Refer to the URLSearchParams description for more details <br/>
|
|
10
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
|
|
11
|
+
* @param encoder
|
|
12
|
+
*/ encode: function encode(encoder) {
|
|
13
|
+
if (typeof URLSearchParams === "undefined") {
|
|
14
|
+
// URLSearchParams 将空值 null 转为 "null"
|
|
15
|
+
return Object.entries(encoder).reduce(function(arr, _a) {
|
|
16
|
+
var key = _a[0], _b = _a[1], value = _b === void 0 ? undefined : _b;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
value.forEach(function(i) {
|
|
19
|
+
arr.push("".concat(key, "=").concat(encodeURIComponent(i === null ? "null" : i === undefined ? "" : i)));
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
arr.push("".concat(key, "=").concat(encodeURIComponent(value === null ? "null" : value === undefined ? "" : value)));
|
|
23
|
+
}
|
|
24
|
+
return arr;
|
|
25
|
+
}, []).join("&");
|
|
26
|
+
} else {
|
|
27
|
+
// typeof URLSearchParams
|
|
28
|
+
return encoder.toString();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* returns a new URLSearchParams object
|
|
33
|
+
* @param params
|
|
34
|
+
*/ decode: function decode(params) {
|
|
35
|
+
if (typeof URLSearchParams === "undefined") {
|
|
36
|
+
return Object.assign({}, params);
|
|
37
|
+
} else {
|
|
38
|
+
return new URLSearchParams(params);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
has: function has(encoder, key) {
|
|
42
|
+
if (typeof URLSearchParams === "undefined") {
|
|
43
|
+
return key in encoder;
|
|
44
|
+
} else {
|
|
45
|
+
return encoder.has(key);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"delete": function _delete(encoder, key) {
|
|
49
|
+
if (typeof URLSearchParams === "undefined") {
|
|
50
|
+
if (encoder) {
|
|
51
|
+
delete encoder[key];
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
encoder["delete"](key);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
get: function get(encoder, key) {
|
|
58
|
+
if (typeof URLSearchParams === "undefined") {
|
|
59
|
+
return encoder ? encoder[key] : undefined;
|
|
60
|
+
} else {
|
|
61
|
+
return encoder.get(key);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
append: function append(encoder, key, value) {
|
|
65
|
+
if (typeof URLSearchParams === "undefined") {
|
|
66
|
+
if (encoder) {
|
|
67
|
+
var v = encoder[key];
|
|
68
|
+
if ((0, common_1.isNullOrEmpty)(v)) {
|
|
69
|
+
encoder[key] = value;
|
|
70
|
+
} else {
|
|
71
|
+
encoder[key] = [].concat(v).concat(value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
encoder.append(key, value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports["default"] = URLSearchParamsParser;
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
var AxiosStaticInstanceProvider = /** @class */ function() {
|
|
124
|
+
function AxiosStaticInstanceProvider() {
|
|
125
|
+
this.__instance = null;
|
|
126
|
+
}
|
|
127
|
+
AxiosStaticInstanceProvider.prototype.provide = function() {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
129
|
+
var lib;
|
|
130
|
+
return __generator(this, function(_a) {
|
|
131
|
+
switch(_a.label){
|
|
132
|
+
case 0:
|
|
133
|
+
return [
|
|
134
|
+
4 /*yield*/ ,
|
|
135
|
+
Promise.resolve().then(function() {
|
|
136
|
+
return require("axios");
|
|
137
|
+
})
|
|
138
|
+
];
|
|
139
|
+
case 1:
|
|
140
|
+
lib = _a.sent();
|
|
141
|
+
return [
|
|
142
|
+
2 /*return*/ ,
|
|
143
|
+
lib["default"]
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
AxiosStaticInstanceProvider.prototype.get = function() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
151
|
+
var _a;
|
|
152
|
+
return __generator(this, function(_b) {
|
|
153
|
+
switch(_b.label){
|
|
154
|
+
case 0:
|
|
155
|
+
_a = this;
|
|
156
|
+
return [
|
|
157
|
+
4 /*yield*/ ,
|
|
158
|
+
this.provide()
|
|
159
|
+
];
|
|
160
|
+
case 1:
|
|
161
|
+
_a.__instance = _b.sent();
|
|
162
|
+
return [
|
|
163
|
+
2 /*return*/ ,
|
|
164
|
+
this.__instance
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
return AxiosStaticInstanceProvider;
|
|
171
|
+
}();
|
|
172
|
+
exports["default"] = AxiosStaticInstanceProvider;
|