axios-annotations 1.3.4 → 2.0.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.
Files changed (98) hide show
  1. package/README.md +257 -105
  2. package/index.d.ts +1 -0
  3. package/index.js +121 -0
  4. package/lib/core/cancel.d.ts +30 -0
  5. package/lib/core/cancel.js +56 -0
  6. package/lib/core/common.d.ts +6 -0
  7. package/lib/core/common.js +166 -1
  8. package/lib/core/config.d.ts +60 -29
  9. package/lib/core/config.js +332 -1
  10. package/lib/core/parser.d.ts +19 -15
  11. package/lib/core/parser.js +79 -1
  12. package/lib/core/provider.d.ts +6 -0
  13. package/lib/core/provider.js +172 -0
  14. package/lib/core/service.d.ts +153 -33
  15. package/lib/core/service.js +562 -1
  16. package/lib/decorator/abort-source.d.ts +3 -9
  17. package/lib/decorator/abort-source.js +25 -1
  18. package/lib/decorator/delete-mapping.d.ts +1 -3
  19. package/lib/decorator/delete-mapping.js +13 -1
  20. package/lib/decorator/get-mapping.d.ts +1 -3
  21. package/lib/decorator/get-mapping.js +13 -1
  22. package/lib/decorator/ignore-residual-params.d.ts +1 -3
  23. package/lib/decorator/ignore-residual-params.js +24 -1
  24. package/lib/decorator/patch-mapping.d.ts +1 -3
  25. package/lib/decorator/patch-mapping.js +13 -1
  26. package/lib/decorator/post-mapping.d.ts +1 -3
  27. package/lib/decorator/post-mapping.js +13 -1
  28. package/lib/decorator/put-mapping.d.ts +1 -3
  29. package/lib/decorator/put-mapping.js +13 -1
  30. package/lib/decorator/request-body.d.ts +1 -3
  31. package/lib/decorator/request-body.js +28 -1
  32. package/lib/decorator/request-config.d.ts +5 -7
  33. package/lib/decorator/request-config.js +23 -1
  34. package/lib/decorator/request-header.d.ts +2 -5
  35. package/lib/decorator/request-header.js +21 -1
  36. package/lib/decorator/request-mapping.d.ts +3 -6
  37. package/lib/decorator/request-mapping.js +58 -1
  38. package/lib/decorator/request-param.d.ts +1 -3
  39. package/lib/decorator/request-param.js +27 -1
  40. package/lib/decorator/request-with.d.ts +1 -3
  41. package/lib/decorator/request-with.js +20 -1
  42. package/lib/index.d.ts +19 -0
  43. package/lib/index.js +139 -0
  44. package/lib/plugins/auth/authorizer.d.ts +23 -49
  45. package/lib/plugins/auth/authorizer.js +271 -1
  46. package/lib/plugins/auth/history.d.ts +14 -15
  47. package/lib/plugins/auth/history.js +96 -1
  48. package/lib/plugins/auth/index.d.ts +9 -4
  49. package/lib/plugins/auth/index.js +368 -1
  50. package/lib/plugins/auth/queue.d.ts +28 -16
  51. package/lib/plugins/auth/queue.js +270 -1
  52. package/lib/plugins/auth/storage.d.ts +6 -7
  53. package/lib/plugins/auth/storage.js +207 -1
  54. package/package.json +16 -16
  55. package/plugins/auth/index.d.ts +4 -4
  56. package/plugins/auth/index.js +26 -1
  57. package/core/config.d.ts +0 -29
  58. package/core/config.js +0 -1
  59. package/core/parser.d.ts +0 -15
  60. package/core/parser.js +0 -1
  61. package/core/service.d.ts +0 -33
  62. package/core/service.js +0 -1
  63. package/decorator/abort-source.d.ts +0 -9
  64. package/decorator/abort-source.js +0 -1
  65. package/decorator/delete-mapping.d.ts +0 -1
  66. package/decorator/delete-mapping.js +0 -1
  67. package/decorator/get-mapping.d.ts +0 -1
  68. package/decorator/get-mapping.js +0 -1
  69. package/decorator/ignore-residual-params.d.ts +0 -1
  70. package/decorator/ignore-residual-params.js +0 -1
  71. package/decorator/patch-mapping.d.ts +0 -1
  72. package/decorator/patch-mapping.js +0 -1
  73. package/decorator/post-mapping.d.ts +0 -1
  74. package/decorator/post-mapping.js +0 -1
  75. package/decorator/put-mapping.d.ts +0 -3
  76. package/decorator/put-mapping.js +0 -1
  77. package/decorator/request-body.d.ts +0 -3
  78. package/decorator/request-body.js +0 -1
  79. package/decorator/request-config.d.ts +0 -29
  80. package/decorator/request-config.js +0 -1
  81. package/decorator/request-header.d.ts +0 -1
  82. package/decorator/request-header.js +0 -1
  83. package/decorator/request-mapping.d.ts +0 -1
  84. package/decorator/request-mapping.js +0 -1
  85. package/decorator/request-param.d.ts +0 -1
  86. package/decorator/request-param.js +0 -1
  87. package/decorator/request-with.d.ts +0 -1
  88. package/decorator/request-with.js +0 -1
  89. package/lib/plugins/cache/index.js +0 -1
  90. package/plugins/auth/authorizer.d.ts +0 -49
  91. package/plugins/auth/authorizer.js +0 -1
  92. package/plugins/auth/history.d.ts +0 -15
  93. package/plugins/auth/history.js +0 -1
  94. package/plugins/auth/queue.d.ts +0 -16
  95. package/plugins/auth/queue.js +0 -1
  96. package/plugins/auth/storage.d.ts +0 -7
  97. package/plugins/auth/storage.js +0 -1
  98. package/plugins/cache/index.js +0 -1
@@ -1 +1,332 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.config=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,_toPropertyKey(i.key),i)}}function _createClass(t,e,o){return e&&_defineProperties(t.prototype,e),o&&_defineProperties(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}var _global_configs=[],Config=exports.default=_createClass(function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;_classCallCheck(this,t),_defineProperty(this,"_host","localhost"),_defineProperty(this,"_port",8080),_defineProperty(this,"_protocol","http"),_defineProperty(this,"_prefix",""),_defineProperty(this,"_axios",_axios.default.create()),_defineProperty(this,"_plugins",[]),this.init(e,o,i,n,r)},[{key:"init",value:function(t,e,o,i,n){this.port=o,t&&(this.protocol=t),e&&(this.host=e),i&&(this.prefix=i),Array.isArray(n)&&(this.plugins=n)}},{key:"host",get:function(){return this._host},set:function(t){this._host=t}},{key:"port",get:function(){return this._port},set:function(t){this._port=t}},{key:"protocol",get:function(){return this._protocol},set:function(t){this._protocol=t}},{key:"prefix",get:function(){return this._prefix},set:function(t){this._prefix=t}},{key:"origin",get:function(){return"".concat(this.protocol,"://").concat(this.host).concat(this.port?":"+this.port:"")}},{key:"baseURL",get:function(){return"".concat(this.origin).concat(this.prefix)}},{key:"axios",get:function(){return this._axios},set:function(t){this._axios=t}},{key:"plugins",get:function(){return this._plugins},set:function(t){this._plugins=t}},{key:"register",value:function(t){var e=this,o=_global_configs.find(function(t){return t.config===e});return o?o.name=t:_global_configs.push({name:t,config:this}),this}},{key:"unregister",value:function(){var e=this,t=_global_configs.findIndex(function(t){return t.config===e});return 0<=t&&_global_configs.splice(t,1),this}}],[{key:"forName",value:function(e){var t=_global_configs.find(function(t){return t.name===e});return t?t.config:null}}]),config=exports.config=new Config;
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();
@@ -1,15 +1,19 @@
1
- declare const URLSearchParamsParser: {
2
- encode: (encoder: object) => string;
3
-
4
- decode: (data: object) => object;
5
-
6
- has: (encoder: object, key: string) => boolean;
7
-
8
- delete: (encoder: object, key: string) => void;
9
-
10
- get: (encoder: object, key: string) => any;
11
-
12
- append: (encoder: object, key: string, value: any) => void;
13
- }
14
-
15
- export default URLSearchParamsParser;
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;
@@ -1 +1,79 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _common=require("./common");function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,e){var n;if(r)return"string"==typeof r?_arrayLikeToArray(r,e):"Map"===(n="Object"===(n={}.toString.call(r).slice(8,-1))&&r.constructor?r.constructor.name:n)||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(r,e):void 0}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=Array(e);n<e;n++)t[n]=r[n];return t}function _iterableToArrayLimit(r,e){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var t,a,o,i,u=[],c=!0,l=!1;try{if(o=(n=n.call(r)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(t=o.call(n)).done)&&(u.push(t.value),u.length!==e);c=!0);}catch(r){l=!0,a=r}finally{try{if(!c&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw a}}return u}}function _arrayWithHoles(r){if(Array.isArray(r))return r}var URLSearchParamsParser={encode:function(r){return"undefined"==typeof URLSearchParams?Object.entries(r).reduce(function(e,r){var r=_slicedToArray(r,2),n=r[0],r=r[1],r=void 0===r?void 0:r;return Array.isArray(r)?r.forEach(function(r){e.push("".concat(n,"=").concat(encodeURIComponent(null===r?"null":void 0===r?"":r)))}):e.push("".concat(n,"=").concat(encodeURIComponent(null===r?"null":void 0===r?"":r))),e},[]).join("&"):r.toString()},decode:function(r){return"undefined"==typeof URLSearchParams?Object.assign({},r):new URLSearchParams(r)},has:function(r,e){return"undefined"==typeof URLSearchParams?e in r:r.has(e)},delete:function(r,e){"undefined"==typeof URLSearchParams?r&&delete r[e]:r.delete(e)},get:function(r,e){return"undefined"==typeof URLSearchParams?r?r[e]:void 0:r.get(e)},append:function(r,e,n){var t;"undefined"==typeof URLSearchParams?r&&(t=r[e],(0,_common.isNullOrEmpty)(t)?r[e]=n:r[e]=[].concat(t).concat(n)):r.append(e,n)}},_default=exports.default=URLSearchParamsParser;
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,6 @@
1
+ import type { AxiosStatic } from "axios";
2
+ export default class AxiosStaticInstanceProvider {
3
+ __instance: AxiosStatic | null;
4
+ provide(): Promise<AxiosStatic>;
5
+ get(): Promise<AxiosStatic>;
6
+ }
@@ -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;