crmbonus-component-wake 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/crmbonus-component-wake/app-modal.entry.js +1 -1
- package/dist/crmbonus-component-wake/crm-bonus-form.entry.js +2 -2
- package/dist/crmbonus-component-wake/crm-bonus.entry.js +2 -2
- package/dist/crmbonus-component-wake/{crmbonus.service-5e579e1c.js → crmbonus.service-04472105.js} +2 -2
- package/dist/crmbonus-component-wake/{crmbonus.service-5e579e1c.js.map → crmbonus.service-04472105.js.map} +1 -1
- package/dist/crmbonus-component-wake/giftback-finish.entry.js +1 -1
- package/dist/crmbonus-component-wake/giftback-pin.entry.js +1 -1
- package/dist/crmbonus-component-wake/giftback-progress.entry.js +1 -1
- package/dist/crmbonus-component-wake/loading-spinner.entry.js +1 -1
- package/dist/crmbonus-component-wake/pedido-finalizado.entry.js +2 -2
- package/dist/crmbonus-component-wake/phone-input-mask.entry.js +1 -1
- package/dist/crmbonus-component-wake/phone-input.entry.js +1 -1
- package/package.json +1 -1
- package/dist/crmbonus-component-wake/crmbonus.service-72c64bc3.js +0 -3868
- package/dist/crmbonus-component-wake/crmbonus.service-72c64bc3.js.map +0 -1
- package/dist/crmbonus-component-wake/crmbonus.service-a0dea046.js +0 -3868
- package/dist/crmbonus-component-wake/crmbonus.service-a0dea046.js.map +0 -1
- package/dist/crmbonus-component-wake/crmbonus.service-ce105f62.js +0 -3868
- package/dist/crmbonus-component-wake/crmbonus.service-ce105f62.js.map +0 -1
@@ -1,3868 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
function bind(fn, thisArg) {
|
4
|
-
return function wrap() {
|
5
|
-
return fn.apply(thisArg, arguments);
|
6
|
-
};
|
7
|
-
}
|
8
|
-
|
9
|
-
'use strict';
|
10
|
-
|
11
|
-
// utils is a library of generic helper functions non-specific to axios
|
12
|
-
|
13
|
-
const {toString} = Object.prototype;
|
14
|
-
const {getPrototypeOf} = Object;
|
15
|
-
|
16
|
-
const kindOf = (cache => thing => {
|
17
|
-
const str = toString.call(thing);
|
18
|
-
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
19
|
-
})(Object.create(null));
|
20
|
-
|
21
|
-
const kindOfTest = (type) => {
|
22
|
-
type = type.toLowerCase();
|
23
|
-
return (thing) => kindOf(thing) === type
|
24
|
-
};
|
25
|
-
|
26
|
-
const typeOfTest = type => thing => typeof thing === type;
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Determine if a value is an Array
|
30
|
-
*
|
31
|
-
* @param {Object} val The value to test
|
32
|
-
*
|
33
|
-
* @returns {boolean} True if value is an Array, otherwise false
|
34
|
-
*/
|
35
|
-
const {isArray} = Array;
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Determine if a value is undefined
|
39
|
-
*
|
40
|
-
* @param {*} val The value to test
|
41
|
-
*
|
42
|
-
* @returns {boolean} True if the value is undefined, otherwise false
|
43
|
-
*/
|
44
|
-
const isUndefined = typeOfTest('undefined');
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Determine if a value is a Buffer
|
48
|
-
*
|
49
|
-
* @param {*} val The value to test
|
50
|
-
*
|
51
|
-
* @returns {boolean} True if value is a Buffer, otherwise false
|
52
|
-
*/
|
53
|
-
function isBuffer(val) {
|
54
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
55
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Determine if a value is an ArrayBuffer
|
60
|
-
*
|
61
|
-
* @param {*} val The value to test
|
62
|
-
*
|
63
|
-
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
64
|
-
*/
|
65
|
-
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
66
|
-
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Determine if a value is a view on an ArrayBuffer
|
70
|
-
*
|
71
|
-
* @param {*} val The value to test
|
72
|
-
*
|
73
|
-
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
74
|
-
*/
|
75
|
-
function isArrayBufferView(val) {
|
76
|
-
let result;
|
77
|
-
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
78
|
-
result = ArrayBuffer.isView(val);
|
79
|
-
} else {
|
80
|
-
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
81
|
-
}
|
82
|
-
return result;
|
83
|
-
}
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Determine if a value is a String
|
87
|
-
*
|
88
|
-
* @param {*} val The value to test
|
89
|
-
*
|
90
|
-
* @returns {boolean} True if value is a String, otherwise false
|
91
|
-
*/
|
92
|
-
const isString = typeOfTest('string');
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Determine if a value is a Function
|
96
|
-
*
|
97
|
-
* @param {*} val The value to test
|
98
|
-
* @returns {boolean} True if value is a Function, otherwise false
|
99
|
-
*/
|
100
|
-
const isFunction = typeOfTest('function');
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Determine if a value is a Number
|
104
|
-
*
|
105
|
-
* @param {*} val The value to test
|
106
|
-
*
|
107
|
-
* @returns {boolean} True if value is a Number, otherwise false
|
108
|
-
*/
|
109
|
-
const isNumber = typeOfTest('number');
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Determine if a value is an Object
|
113
|
-
*
|
114
|
-
* @param {*} thing The value to test
|
115
|
-
*
|
116
|
-
* @returns {boolean} True if value is an Object, otherwise false
|
117
|
-
*/
|
118
|
-
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Determine if a value is a Boolean
|
122
|
-
*
|
123
|
-
* @param {*} thing The value to test
|
124
|
-
* @returns {boolean} True if value is a Boolean, otherwise false
|
125
|
-
*/
|
126
|
-
const isBoolean = thing => thing === true || thing === false;
|
127
|
-
|
128
|
-
/**
|
129
|
-
* Determine if a value is a plain Object
|
130
|
-
*
|
131
|
-
* @param {*} val The value to test
|
132
|
-
*
|
133
|
-
* @returns {boolean} True if value is a plain Object, otherwise false
|
134
|
-
*/
|
135
|
-
const isPlainObject = (val) => {
|
136
|
-
if (kindOf(val) !== 'object') {
|
137
|
-
return false;
|
138
|
-
}
|
139
|
-
|
140
|
-
const prototype = getPrototypeOf(val);
|
141
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
142
|
-
};
|
143
|
-
|
144
|
-
/**
|
145
|
-
* Determine if a value is a Date
|
146
|
-
*
|
147
|
-
* @param {*} val The value to test
|
148
|
-
*
|
149
|
-
* @returns {boolean} True if value is a Date, otherwise false
|
150
|
-
*/
|
151
|
-
const isDate = kindOfTest('Date');
|
152
|
-
|
153
|
-
/**
|
154
|
-
* Determine if a value is a File
|
155
|
-
*
|
156
|
-
* @param {*} val The value to test
|
157
|
-
*
|
158
|
-
* @returns {boolean} True if value is a File, otherwise false
|
159
|
-
*/
|
160
|
-
const isFile = kindOfTest('File');
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Determine if a value is a Blob
|
164
|
-
*
|
165
|
-
* @param {*} val The value to test
|
166
|
-
*
|
167
|
-
* @returns {boolean} True if value is a Blob, otherwise false
|
168
|
-
*/
|
169
|
-
const isBlob = kindOfTest('Blob');
|
170
|
-
|
171
|
-
/**
|
172
|
-
* Determine if a value is a FileList
|
173
|
-
*
|
174
|
-
* @param {*} val The value to test
|
175
|
-
*
|
176
|
-
* @returns {boolean} True if value is a File, otherwise false
|
177
|
-
*/
|
178
|
-
const isFileList = kindOfTest('FileList');
|
179
|
-
|
180
|
-
/**
|
181
|
-
* Determine if a value is a Stream
|
182
|
-
*
|
183
|
-
* @param {*} val The value to test
|
184
|
-
*
|
185
|
-
* @returns {boolean} True if value is a Stream, otherwise false
|
186
|
-
*/
|
187
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
188
|
-
|
189
|
-
/**
|
190
|
-
* Determine if a value is a FormData
|
191
|
-
*
|
192
|
-
* @param {*} thing The value to test
|
193
|
-
*
|
194
|
-
* @returns {boolean} True if value is an FormData, otherwise false
|
195
|
-
*/
|
196
|
-
const isFormData = (thing) => {
|
197
|
-
let kind;
|
198
|
-
return thing && (
|
199
|
-
(typeof FormData === 'function' && thing instanceof FormData) || (
|
200
|
-
isFunction(thing.append) && (
|
201
|
-
(kind = kindOf(thing)) === 'formdata' ||
|
202
|
-
// detect form-data instance
|
203
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
204
|
-
)
|
205
|
-
)
|
206
|
-
)
|
207
|
-
};
|
208
|
-
|
209
|
-
/**
|
210
|
-
* Determine if a value is a URLSearchParams object
|
211
|
-
*
|
212
|
-
* @param {*} val The value to test
|
213
|
-
*
|
214
|
-
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
215
|
-
*/
|
216
|
-
const isURLSearchParams = kindOfTest('URLSearchParams');
|
217
|
-
|
218
|
-
const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
|
219
|
-
|
220
|
-
/**
|
221
|
-
* Trim excess whitespace off the beginning and end of a string
|
222
|
-
*
|
223
|
-
* @param {String} str The String to trim
|
224
|
-
*
|
225
|
-
* @returns {String} The String freed of excess whitespace
|
226
|
-
*/
|
227
|
-
const trim = (str) => str.trim ?
|
228
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
229
|
-
|
230
|
-
/**
|
231
|
-
* Iterate over an Array or an Object invoking a function for each item.
|
232
|
-
*
|
233
|
-
* If `obj` is an Array callback will be called passing
|
234
|
-
* the value, index, and complete array for each item.
|
235
|
-
*
|
236
|
-
* If 'obj' is an Object callback will be called passing
|
237
|
-
* the value, key, and complete object for each property.
|
238
|
-
*
|
239
|
-
* @param {Object|Array} obj The object to iterate
|
240
|
-
* @param {Function} fn The callback to invoke for each item
|
241
|
-
*
|
242
|
-
* @param {Boolean} [allOwnKeys = false]
|
243
|
-
* @returns {any}
|
244
|
-
*/
|
245
|
-
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
246
|
-
// Don't bother if no value provided
|
247
|
-
if (obj === null || typeof obj === 'undefined') {
|
248
|
-
return;
|
249
|
-
}
|
250
|
-
|
251
|
-
let i;
|
252
|
-
let l;
|
253
|
-
|
254
|
-
// Force an array if not already something iterable
|
255
|
-
if (typeof obj !== 'object') {
|
256
|
-
/*eslint no-param-reassign:0*/
|
257
|
-
obj = [obj];
|
258
|
-
}
|
259
|
-
|
260
|
-
if (isArray(obj)) {
|
261
|
-
// Iterate over array values
|
262
|
-
for (i = 0, l = obj.length; i < l; i++) {
|
263
|
-
fn.call(null, obj[i], i, obj);
|
264
|
-
}
|
265
|
-
} else {
|
266
|
-
// Iterate over object keys
|
267
|
-
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
268
|
-
const len = keys.length;
|
269
|
-
let key;
|
270
|
-
|
271
|
-
for (i = 0; i < len; i++) {
|
272
|
-
key = keys[i];
|
273
|
-
fn.call(null, obj[key], key, obj);
|
274
|
-
}
|
275
|
-
}
|
276
|
-
}
|
277
|
-
|
278
|
-
function findKey(obj, key) {
|
279
|
-
key = key.toLowerCase();
|
280
|
-
const keys = Object.keys(obj);
|
281
|
-
let i = keys.length;
|
282
|
-
let _key;
|
283
|
-
while (i-- > 0) {
|
284
|
-
_key = keys[i];
|
285
|
-
if (key === _key.toLowerCase()) {
|
286
|
-
return _key;
|
287
|
-
}
|
288
|
-
}
|
289
|
-
return null;
|
290
|
-
}
|
291
|
-
|
292
|
-
const _global = (() => {
|
293
|
-
/*eslint no-undef:0*/
|
294
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
295
|
-
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
296
|
-
})();
|
297
|
-
|
298
|
-
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
299
|
-
|
300
|
-
/**
|
301
|
-
* Accepts varargs expecting each argument to be an object, then
|
302
|
-
* immutably merges the properties of each object and returns result.
|
303
|
-
*
|
304
|
-
* When multiple objects contain the same key the later object in
|
305
|
-
* the arguments list will take precedence.
|
306
|
-
*
|
307
|
-
* Example:
|
308
|
-
*
|
309
|
-
* ```js
|
310
|
-
* var result = merge({foo: 123}, {foo: 456});
|
311
|
-
* console.log(result.foo); // outputs 456
|
312
|
-
* ```
|
313
|
-
*
|
314
|
-
* @param {Object} obj1 Object to merge
|
315
|
-
*
|
316
|
-
* @returns {Object} Result of all merge properties
|
317
|
-
*/
|
318
|
-
function merge(/* obj1, obj2, obj3, ... */) {
|
319
|
-
const {caseless} = isContextDefined(this) && this || {};
|
320
|
-
const result = {};
|
321
|
-
const assignValue = (val, key) => {
|
322
|
-
const targetKey = caseless && findKey(result, key) || key;
|
323
|
-
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
324
|
-
result[targetKey] = merge(result[targetKey], val);
|
325
|
-
} else if (isPlainObject(val)) {
|
326
|
-
result[targetKey] = merge({}, val);
|
327
|
-
} else if (isArray(val)) {
|
328
|
-
result[targetKey] = val.slice();
|
329
|
-
} else {
|
330
|
-
result[targetKey] = val;
|
331
|
-
}
|
332
|
-
};
|
333
|
-
|
334
|
-
for (let i = 0, l = arguments.length; i < l; i++) {
|
335
|
-
arguments[i] && forEach(arguments[i], assignValue);
|
336
|
-
}
|
337
|
-
return result;
|
338
|
-
}
|
339
|
-
|
340
|
-
/**
|
341
|
-
* Extends object a by mutably adding to it the properties of object b.
|
342
|
-
*
|
343
|
-
* @param {Object} a The object to be extended
|
344
|
-
* @param {Object} b The object to copy properties from
|
345
|
-
* @param {Object} thisArg The object to bind function to
|
346
|
-
*
|
347
|
-
* @param {Boolean} [allOwnKeys]
|
348
|
-
* @returns {Object} The resulting value of object a
|
349
|
-
*/
|
350
|
-
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
351
|
-
forEach(b, (val, key) => {
|
352
|
-
if (thisArg && isFunction(val)) {
|
353
|
-
a[key] = bind(val, thisArg);
|
354
|
-
} else {
|
355
|
-
a[key] = val;
|
356
|
-
}
|
357
|
-
}, {allOwnKeys});
|
358
|
-
return a;
|
359
|
-
};
|
360
|
-
|
361
|
-
/**
|
362
|
-
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
363
|
-
*
|
364
|
-
* @param {string} content with BOM
|
365
|
-
*
|
366
|
-
* @returns {string} content value without BOM
|
367
|
-
*/
|
368
|
-
const stripBOM = (content) => {
|
369
|
-
if (content.charCodeAt(0) === 0xFEFF) {
|
370
|
-
content = content.slice(1);
|
371
|
-
}
|
372
|
-
return content;
|
373
|
-
};
|
374
|
-
|
375
|
-
/**
|
376
|
-
* Inherit the prototype methods from one constructor into another
|
377
|
-
* @param {function} constructor
|
378
|
-
* @param {function} superConstructor
|
379
|
-
* @param {object} [props]
|
380
|
-
* @param {object} [descriptors]
|
381
|
-
*
|
382
|
-
* @returns {void}
|
383
|
-
*/
|
384
|
-
const inherits = (constructor, superConstructor, props, descriptors) => {
|
385
|
-
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
386
|
-
constructor.prototype.constructor = constructor;
|
387
|
-
Object.defineProperty(constructor, 'super', {
|
388
|
-
value: superConstructor.prototype
|
389
|
-
});
|
390
|
-
props && Object.assign(constructor.prototype, props);
|
391
|
-
};
|
392
|
-
|
393
|
-
/**
|
394
|
-
* Resolve object with deep prototype chain to a flat object
|
395
|
-
* @param {Object} sourceObj source object
|
396
|
-
* @param {Object} [destObj]
|
397
|
-
* @param {Function|Boolean} [filter]
|
398
|
-
* @param {Function} [propFilter]
|
399
|
-
*
|
400
|
-
* @returns {Object}
|
401
|
-
*/
|
402
|
-
const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
403
|
-
let props;
|
404
|
-
let i;
|
405
|
-
let prop;
|
406
|
-
const merged = {};
|
407
|
-
|
408
|
-
destObj = destObj || {};
|
409
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
410
|
-
if (sourceObj == null) return destObj;
|
411
|
-
|
412
|
-
do {
|
413
|
-
props = Object.getOwnPropertyNames(sourceObj);
|
414
|
-
i = props.length;
|
415
|
-
while (i-- > 0) {
|
416
|
-
prop = props[i];
|
417
|
-
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
418
|
-
destObj[prop] = sourceObj[prop];
|
419
|
-
merged[prop] = true;
|
420
|
-
}
|
421
|
-
}
|
422
|
-
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
423
|
-
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
424
|
-
|
425
|
-
return destObj;
|
426
|
-
};
|
427
|
-
|
428
|
-
/**
|
429
|
-
* Determines whether a string ends with the characters of a specified string
|
430
|
-
*
|
431
|
-
* @param {String} str
|
432
|
-
* @param {String} searchString
|
433
|
-
* @param {Number} [position= 0]
|
434
|
-
*
|
435
|
-
* @returns {boolean}
|
436
|
-
*/
|
437
|
-
const endsWith = (str, searchString, position) => {
|
438
|
-
str = String(str);
|
439
|
-
if (position === undefined || position > str.length) {
|
440
|
-
position = str.length;
|
441
|
-
}
|
442
|
-
position -= searchString.length;
|
443
|
-
const lastIndex = str.indexOf(searchString, position);
|
444
|
-
return lastIndex !== -1 && lastIndex === position;
|
445
|
-
};
|
446
|
-
|
447
|
-
|
448
|
-
/**
|
449
|
-
* Returns new array from array like object or null if failed
|
450
|
-
*
|
451
|
-
* @param {*} [thing]
|
452
|
-
*
|
453
|
-
* @returns {?Array}
|
454
|
-
*/
|
455
|
-
const toArray = (thing) => {
|
456
|
-
if (!thing) return null;
|
457
|
-
if (isArray(thing)) return thing;
|
458
|
-
let i = thing.length;
|
459
|
-
if (!isNumber(i)) return null;
|
460
|
-
const arr = new Array(i);
|
461
|
-
while (i-- > 0) {
|
462
|
-
arr[i] = thing[i];
|
463
|
-
}
|
464
|
-
return arr;
|
465
|
-
};
|
466
|
-
|
467
|
-
/**
|
468
|
-
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
469
|
-
* thing passed in is an instance of Uint8Array
|
470
|
-
*
|
471
|
-
* @param {TypedArray}
|
472
|
-
*
|
473
|
-
* @returns {Array}
|
474
|
-
*/
|
475
|
-
// eslint-disable-next-line func-names
|
476
|
-
const isTypedArray = (TypedArray => {
|
477
|
-
// eslint-disable-next-line func-names
|
478
|
-
return thing => {
|
479
|
-
return TypedArray && thing instanceof TypedArray;
|
480
|
-
};
|
481
|
-
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
482
|
-
|
483
|
-
/**
|
484
|
-
* For each entry in the object, call the function with the key and value.
|
485
|
-
*
|
486
|
-
* @param {Object<any, any>} obj - The object to iterate over.
|
487
|
-
* @param {Function} fn - The function to call for each entry.
|
488
|
-
*
|
489
|
-
* @returns {void}
|
490
|
-
*/
|
491
|
-
const forEachEntry = (obj, fn) => {
|
492
|
-
const generator = obj && obj[Symbol.iterator];
|
493
|
-
|
494
|
-
const iterator = generator.call(obj);
|
495
|
-
|
496
|
-
let result;
|
497
|
-
|
498
|
-
while ((result = iterator.next()) && !result.done) {
|
499
|
-
const pair = result.value;
|
500
|
-
fn.call(obj, pair[0], pair[1]);
|
501
|
-
}
|
502
|
-
};
|
503
|
-
|
504
|
-
/**
|
505
|
-
* It takes a regular expression and a string, and returns an array of all the matches
|
506
|
-
*
|
507
|
-
* @param {string} regExp - The regular expression to match against.
|
508
|
-
* @param {string} str - The string to search.
|
509
|
-
*
|
510
|
-
* @returns {Array<boolean>}
|
511
|
-
*/
|
512
|
-
const matchAll = (regExp, str) => {
|
513
|
-
let matches;
|
514
|
-
const arr = [];
|
515
|
-
|
516
|
-
while ((matches = regExp.exec(str)) !== null) {
|
517
|
-
arr.push(matches);
|
518
|
-
}
|
519
|
-
|
520
|
-
return arr;
|
521
|
-
};
|
522
|
-
|
523
|
-
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
524
|
-
const isHTMLForm = kindOfTest('HTMLFormElement');
|
525
|
-
|
526
|
-
const toCamelCase = str => {
|
527
|
-
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
528
|
-
function replacer(m, p1, p2) {
|
529
|
-
return p1.toUpperCase() + p2;
|
530
|
-
}
|
531
|
-
);
|
532
|
-
};
|
533
|
-
|
534
|
-
/* Creating a function that will check if an object has a property. */
|
535
|
-
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
536
|
-
|
537
|
-
/**
|
538
|
-
* Determine if a value is a RegExp object
|
539
|
-
*
|
540
|
-
* @param {*} val The value to test
|
541
|
-
*
|
542
|
-
* @returns {boolean} True if value is a RegExp object, otherwise false
|
543
|
-
*/
|
544
|
-
const isRegExp = kindOfTest('RegExp');
|
545
|
-
|
546
|
-
const reduceDescriptors = (obj, reducer) => {
|
547
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
548
|
-
const reducedDescriptors = {};
|
549
|
-
|
550
|
-
forEach(descriptors, (descriptor, name) => {
|
551
|
-
let ret;
|
552
|
-
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
553
|
-
reducedDescriptors[name] = ret || descriptor;
|
554
|
-
}
|
555
|
-
});
|
556
|
-
|
557
|
-
Object.defineProperties(obj, reducedDescriptors);
|
558
|
-
};
|
559
|
-
|
560
|
-
/**
|
561
|
-
* Makes all methods read-only
|
562
|
-
* @param {Object} obj
|
563
|
-
*/
|
564
|
-
|
565
|
-
const freezeMethods = (obj) => {
|
566
|
-
reduceDescriptors(obj, (descriptor, name) => {
|
567
|
-
// skip restricted props in strict mode
|
568
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
569
|
-
return false;
|
570
|
-
}
|
571
|
-
|
572
|
-
const value = obj[name];
|
573
|
-
|
574
|
-
if (!isFunction(value)) return;
|
575
|
-
|
576
|
-
descriptor.enumerable = false;
|
577
|
-
|
578
|
-
if ('writable' in descriptor) {
|
579
|
-
descriptor.writable = false;
|
580
|
-
return;
|
581
|
-
}
|
582
|
-
|
583
|
-
if (!descriptor.set) {
|
584
|
-
descriptor.set = () => {
|
585
|
-
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
586
|
-
};
|
587
|
-
}
|
588
|
-
});
|
589
|
-
};
|
590
|
-
|
591
|
-
const toObjectSet = (arrayOrString, delimiter) => {
|
592
|
-
const obj = {};
|
593
|
-
|
594
|
-
const define = (arr) => {
|
595
|
-
arr.forEach(value => {
|
596
|
-
obj[value] = true;
|
597
|
-
});
|
598
|
-
};
|
599
|
-
|
600
|
-
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
601
|
-
|
602
|
-
return obj;
|
603
|
-
};
|
604
|
-
|
605
|
-
const noop = () => {};
|
606
|
-
|
607
|
-
const toFiniteNumber = (value, defaultValue) => {
|
608
|
-
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
609
|
-
};
|
610
|
-
|
611
|
-
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
612
|
-
|
613
|
-
const DIGIT = '0123456789';
|
614
|
-
|
615
|
-
const ALPHABET = {
|
616
|
-
DIGIT,
|
617
|
-
ALPHA,
|
618
|
-
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
619
|
-
};
|
620
|
-
|
621
|
-
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
622
|
-
let str = '';
|
623
|
-
const {length} = alphabet;
|
624
|
-
while (size--) {
|
625
|
-
str += alphabet[Math.random() * length|0];
|
626
|
-
}
|
627
|
-
|
628
|
-
return str;
|
629
|
-
};
|
630
|
-
|
631
|
-
/**
|
632
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
633
|
-
*
|
634
|
-
* @param {unknown} thing - The thing to check.
|
635
|
-
*
|
636
|
-
* @returns {boolean}
|
637
|
-
*/
|
638
|
-
function isSpecCompliantForm(thing) {
|
639
|
-
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
640
|
-
}
|
641
|
-
|
642
|
-
const toJSONObject = (obj) => {
|
643
|
-
const stack = new Array(10);
|
644
|
-
|
645
|
-
const visit = (source, i) => {
|
646
|
-
|
647
|
-
if (isObject(source)) {
|
648
|
-
if (stack.indexOf(source) >= 0) {
|
649
|
-
return;
|
650
|
-
}
|
651
|
-
|
652
|
-
if(!('toJSON' in source)) {
|
653
|
-
stack[i] = source;
|
654
|
-
const target = isArray(source) ? [] : {};
|
655
|
-
|
656
|
-
forEach(source, (value, key) => {
|
657
|
-
const reducedValue = visit(value, i + 1);
|
658
|
-
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
659
|
-
});
|
660
|
-
|
661
|
-
stack[i] = undefined;
|
662
|
-
|
663
|
-
return target;
|
664
|
-
}
|
665
|
-
}
|
666
|
-
|
667
|
-
return source;
|
668
|
-
};
|
669
|
-
|
670
|
-
return visit(obj, 0);
|
671
|
-
};
|
672
|
-
|
673
|
-
const isAsyncFn = kindOfTest('AsyncFunction');
|
674
|
-
|
675
|
-
const isThenable = (thing) =>
|
676
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
677
|
-
|
678
|
-
// original code
|
679
|
-
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
680
|
-
|
681
|
-
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
682
|
-
if (setImmediateSupported) {
|
683
|
-
return setImmediate;
|
684
|
-
}
|
685
|
-
|
686
|
-
return postMessageSupported ? ((token, callbacks) => {
|
687
|
-
_global.addEventListener("message", ({source, data}) => {
|
688
|
-
if (source === _global && data === token) {
|
689
|
-
callbacks.length && callbacks.shift()();
|
690
|
-
}
|
691
|
-
}, false);
|
692
|
-
|
693
|
-
return (cb) => {
|
694
|
-
callbacks.push(cb);
|
695
|
-
_global.postMessage(token, "*");
|
696
|
-
}
|
697
|
-
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
698
|
-
})(
|
699
|
-
typeof setImmediate === 'function',
|
700
|
-
isFunction(_global.postMessage)
|
701
|
-
);
|
702
|
-
|
703
|
-
const asap = typeof queueMicrotask !== 'undefined' ?
|
704
|
-
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
705
|
-
|
706
|
-
// *********************
|
707
|
-
|
708
|
-
const utils$1 = {
|
709
|
-
isArray,
|
710
|
-
isArrayBuffer,
|
711
|
-
isBuffer,
|
712
|
-
isFormData,
|
713
|
-
isArrayBufferView,
|
714
|
-
isString,
|
715
|
-
isNumber,
|
716
|
-
isBoolean,
|
717
|
-
isObject,
|
718
|
-
isPlainObject,
|
719
|
-
isReadableStream,
|
720
|
-
isRequest,
|
721
|
-
isResponse,
|
722
|
-
isHeaders,
|
723
|
-
isUndefined,
|
724
|
-
isDate,
|
725
|
-
isFile,
|
726
|
-
isBlob,
|
727
|
-
isRegExp,
|
728
|
-
isFunction,
|
729
|
-
isStream,
|
730
|
-
isURLSearchParams,
|
731
|
-
isTypedArray,
|
732
|
-
isFileList,
|
733
|
-
forEach,
|
734
|
-
merge,
|
735
|
-
extend,
|
736
|
-
trim,
|
737
|
-
stripBOM,
|
738
|
-
inherits,
|
739
|
-
toFlatObject,
|
740
|
-
kindOf,
|
741
|
-
kindOfTest,
|
742
|
-
endsWith,
|
743
|
-
toArray,
|
744
|
-
forEachEntry,
|
745
|
-
matchAll,
|
746
|
-
isHTMLForm,
|
747
|
-
hasOwnProperty,
|
748
|
-
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
749
|
-
reduceDescriptors,
|
750
|
-
freezeMethods,
|
751
|
-
toObjectSet,
|
752
|
-
toCamelCase,
|
753
|
-
noop,
|
754
|
-
toFiniteNumber,
|
755
|
-
findKey,
|
756
|
-
global: _global,
|
757
|
-
isContextDefined,
|
758
|
-
ALPHABET,
|
759
|
-
generateString,
|
760
|
-
isSpecCompliantForm,
|
761
|
-
toJSONObject,
|
762
|
-
isAsyncFn,
|
763
|
-
isThenable,
|
764
|
-
setImmediate: _setImmediate,
|
765
|
-
asap
|
766
|
-
};
|
767
|
-
|
768
|
-
'use strict';
|
769
|
-
|
770
|
-
/**
|
771
|
-
* Create an Error with the specified message, config, error code, request and response.
|
772
|
-
*
|
773
|
-
* @param {string} message The error message.
|
774
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
775
|
-
* @param {Object} [config] The config.
|
776
|
-
* @param {Object} [request] The request.
|
777
|
-
* @param {Object} [response] The response.
|
778
|
-
*
|
779
|
-
* @returns {Error} The created error.
|
780
|
-
*/
|
781
|
-
function AxiosError$1(message, code, config, request, response) {
|
782
|
-
Error.call(this);
|
783
|
-
|
784
|
-
if (Error.captureStackTrace) {
|
785
|
-
Error.captureStackTrace(this, this.constructor);
|
786
|
-
} else {
|
787
|
-
this.stack = (new Error()).stack;
|
788
|
-
}
|
789
|
-
|
790
|
-
this.message = message;
|
791
|
-
this.name = 'AxiosError';
|
792
|
-
code && (this.code = code);
|
793
|
-
config && (this.config = config);
|
794
|
-
request && (this.request = request);
|
795
|
-
if (response) {
|
796
|
-
this.response = response;
|
797
|
-
this.status = response.status ? response.status : null;
|
798
|
-
}
|
799
|
-
}
|
800
|
-
|
801
|
-
utils$1.inherits(AxiosError$1, Error, {
|
802
|
-
toJSON: function toJSON() {
|
803
|
-
return {
|
804
|
-
// Standard
|
805
|
-
message: this.message,
|
806
|
-
name: this.name,
|
807
|
-
// Microsoft
|
808
|
-
description: this.description,
|
809
|
-
number: this.number,
|
810
|
-
// Mozilla
|
811
|
-
fileName: this.fileName,
|
812
|
-
lineNumber: this.lineNumber,
|
813
|
-
columnNumber: this.columnNumber,
|
814
|
-
stack: this.stack,
|
815
|
-
// Axios
|
816
|
-
config: utils$1.toJSONObject(this.config),
|
817
|
-
code: this.code,
|
818
|
-
status: this.status
|
819
|
-
};
|
820
|
-
}
|
821
|
-
});
|
822
|
-
|
823
|
-
const prototype$1 = AxiosError$1.prototype;
|
824
|
-
const descriptors = {};
|
825
|
-
|
826
|
-
[
|
827
|
-
'ERR_BAD_OPTION_VALUE',
|
828
|
-
'ERR_BAD_OPTION',
|
829
|
-
'ECONNABORTED',
|
830
|
-
'ETIMEDOUT',
|
831
|
-
'ERR_NETWORK',
|
832
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
833
|
-
'ERR_DEPRECATED',
|
834
|
-
'ERR_BAD_RESPONSE',
|
835
|
-
'ERR_BAD_REQUEST',
|
836
|
-
'ERR_CANCELED',
|
837
|
-
'ERR_NOT_SUPPORT',
|
838
|
-
'ERR_INVALID_URL'
|
839
|
-
// eslint-disable-next-line func-names
|
840
|
-
].forEach(code => {
|
841
|
-
descriptors[code] = {value: code};
|
842
|
-
});
|
843
|
-
|
844
|
-
Object.defineProperties(AxiosError$1, descriptors);
|
845
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
846
|
-
|
847
|
-
// eslint-disable-next-line func-names
|
848
|
-
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
849
|
-
const axiosError = Object.create(prototype$1);
|
850
|
-
|
851
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
852
|
-
return obj !== Error.prototype;
|
853
|
-
}, prop => {
|
854
|
-
return prop !== 'isAxiosError';
|
855
|
-
});
|
856
|
-
|
857
|
-
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
858
|
-
|
859
|
-
axiosError.cause = error;
|
860
|
-
|
861
|
-
axiosError.name = error.name;
|
862
|
-
|
863
|
-
customProps && Object.assign(axiosError, customProps);
|
864
|
-
|
865
|
-
return axiosError;
|
866
|
-
};
|
867
|
-
|
868
|
-
// eslint-disable-next-line strict
|
869
|
-
const httpAdapter = null;
|
870
|
-
|
871
|
-
'use strict';
|
872
|
-
|
873
|
-
/**
|
874
|
-
* Determines if the given thing is a array or js object.
|
875
|
-
*
|
876
|
-
* @param {string} thing - The object or array to be visited.
|
877
|
-
*
|
878
|
-
* @returns {boolean}
|
879
|
-
*/
|
880
|
-
function isVisitable(thing) {
|
881
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
882
|
-
}
|
883
|
-
|
884
|
-
/**
|
885
|
-
* It removes the brackets from the end of a string
|
886
|
-
*
|
887
|
-
* @param {string} key - The key of the parameter.
|
888
|
-
*
|
889
|
-
* @returns {string} the key without the brackets.
|
890
|
-
*/
|
891
|
-
function removeBrackets(key) {
|
892
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
893
|
-
}
|
894
|
-
|
895
|
-
/**
|
896
|
-
* It takes a path, a key, and a boolean, and returns a string
|
897
|
-
*
|
898
|
-
* @param {string} path - The path to the current key.
|
899
|
-
* @param {string} key - The key of the current object being iterated over.
|
900
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
901
|
-
*
|
902
|
-
* @returns {string} The path to the current key.
|
903
|
-
*/
|
904
|
-
function renderKey(path, key, dots) {
|
905
|
-
if (!path) return key;
|
906
|
-
return path.concat(key).map(function each(token, i) {
|
907
|
-
// eslint-disable-next-line no-param-reassign
|
908
|
-
token = removeBrackets(token);
|
909
|
-
return !dots && i ? '[' + token + ']' : token;
|
910
|
-
}).join(dots ? '.' : '');
|
911
|
-
}
|
912
|
-
|
913
|
-
/**
|
914
|
-
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
915
|
-
*
|
916
|
-
* @param {Array<any>} arr - The array to check
|
917
|
-
*
|
918
|
-
* @returns {boolean}
|
919
|
-
*/
|
920
|
-
function isFlatArray(arr) {
|
921
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
922
|
-
}
|
923
|
-
|
924
|
-
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
925
|
-
return /^is[A-Z]/.test(prop);
|
926
|
-
});
|
927
|
-
|
928
|
-
/**
|
929
|
-
* Convert a data object to FormData
|
930
|
-
*
|
931
|
-
* @param {Object} obj
|
932
|
-
* @param {?Object} [formData]
|
933
|
-
* @param {?Object} [options]
|
934
|
-
* @param {Function} [options.visitor]
|
935
|
-
* @param {Boolean} [options.metaTokens = true]
|
936
|
-
* @param {Boolean} [options.dots = false]
|
937
|
-
* @param {?Boolean} [options.indexes = false]
|
938
|
-
*
|
939
|
-
* @returns {Object}
|
940
|
-
**/
|
941
|
-
|
942
|
-
/**
|
943
|
-
* It converts an object into a FormData object
|
944
|
-
*
|
945
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
946
|
-
* @param {string} formData - The FormData object to append to.
|
947
|
-
* @param {Object<string, any>} options
|
948
|
-
*
|
949
|
-
* @returns
|
950
|
-
*/
|
951
|
-
function toFormData$1(obj, formData, options) {
|
952
|
-
if (!utils$1.isObject(obj)) {
|
953
|
-
throw new TypeError('target must be an object');
|
954
|
-
}
|
955
|
-
|
956
|
-
// eslint-disable-next-line no-param-reassign
|
957
|
-
formData = formData || new (httpAdapter || FormData)();
|
958
|
-
|
959
|
-
// eslint-disable-next-line no-param-reassign
|
960
|
-
options = utils$1.toFlatObject(options, {
|
961
|
-
metaTokens: true,
|
962
|
-
dots: false,
|
963
|
-
indexes: false
|
964
|
-
}, false, function defined(option, source) {
|
965
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
966
|
-
return !utils$1.isUndefined(source[option]);
|
967
|
-
});
|
968
|
-
|
969
|
-
const metaTokens = options.metaTokens;
|
970
|
-
// eslint-disable-next-line no-use-before-define
|
971
|
-
const visitor = options.visitor || defaultVisitor;
|
972
|
-
const dots = options.dots;
|
973
|
-
const indexes = options.indexes;
|
974
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
975
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
976
|
-
|
977
|
-
if (!utils$1.isFunction(visitor)) {
|
978
|
-
throw new TypeError('visitor must be a function');
|
979
|
-
}
|
980
|
-
|
981
|
-
function convertValue(value) {
|
982
|
-
if (value === null) return '';
|
983
|
-
|
984
|
-
if (utils$1.isDate(value)) {
|
985
|
-
return value.toISOString();
|
986
|
-
}
|
987
|
-
|
988
|
-
if (!useBlob && utils$1.isBlob(value)) {
|
989
|
-
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
990
|
-
}
|
991
|
-
|
992
|
-
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
993
|
-
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
994
|
-
}
|
995
|
-
|
996
|
-
return value;
|
997
|
-
}
|
998
|
-
|
999
|
-
/**
|
1000
|
-
* Default visitor.
|
1001
|
-
*
|
1002
|
-
* @param {*} value
|
1003
|
-
* @param {String|Number} key
|
1004
|
-
* @param {Array<String|Number>} path
|
1005
|
-
* @this {FormData}
|
1006
|
-
*
|
1007
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
1008
|
-
*/
|
1009
|
-
function defaultVisitor(value, key, path) {
|
1010
|
-
let arr = value;
|
1011
|
-
|
1012
|
-
if (value && !path && typeof value === 'object') {
|
1013
|
-
if (utils$1.endsWith(key, '{}')) {
|
1014
|
-
// eslint-disable-next-line no-param-reassign
|
1015
|
-
key = metaTokens ? key : key.slice(0, -2);
|
1016
|
-
// eslint-disable-next-line no-param-reassign
|
1017
|
-
value = JSON.stringify(value);
|
1018
|
-
} else if (
|
1019
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
1020
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
1021
|
-
)) {
|
1022
|
-
// eslint-disable-next-line no-param-reassign
|
1023
|
-
key = removeBrackets(key);
|
1024
|
-
|
1025
|
-
arr.forEach(function each(el, index) {
|
1026
|
-
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
1027
|
-
// eslint-disable-next-line no-nested-ternary
|
1028
|
-
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
1029
|
-
convertValue(el)
|
1030
|
-
);
|
1031
|
-
});
|
1032
|
-
return false;
|
1033
|
-
}
|
1034
|
-
}
|
1035
|
-
|
1036
|
-
if (isVisitable(value)) {
|
1037
|
-
return true;
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
formData.append(renderKey(path, key, dots), convertValue(value));
|
1041
|
-
|
1042
|
-
return false;
|
1043
|
-
}
|
1044
|
-
|
1045
|
-
const stack = [];
|
1046
|
-
|
1047
|
-
const exposedHelpers = Object.assign(predicates, {
|
1048
|
-
defaultVisitor,
|
1049
|
-
convertValue,
|
1050
|
-
isVisitable
|
1051
|
-
});
|
1052
|
-
|
1053
|
-
function build(value, path) {
|
1054
|
-
if (utils$1.isUndefined(value)) return;
|
1055
|
-
|
1056
|
-
if (stack.indexOf(value) !== -1) {
|
1057
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
1058
|
-
}
|
1059
|
-
|
1060
|
-
stack.push(value);
|
1061
|
-
|
1062
|
-
utils$1.forEach(value, function each(el, key) {
|
1063
|
-
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
1064
|
-
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
1065
|
-
);
|
1066
|
-
|
1067
|
-
if (result === true) {
|
1068
|
-
build(el, path ? path.concat(key) : [key]);
|
1069
|
-
}
|
1070
|
-
});
|
1071
|
-
|
1072
|
-
stack.pop();
|
1073
|
-
}
|
1074
|
-
|
1075
|
-
if (!utils$1.isObject(obj)) {
|
1076
|
-
throw new TypeError('data must be an object');
|
1077
|
-
}
|
1078
|
-
|
1079
|
-
build(obj);
|
1080
|
-
|
1081
|
-
return formData;
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
'use strict';
|
1085
|
-
|
1086
|
-
/**
|
1087
|
-
* It encodes a string by replacing all characters that are not in the unreserved set with
|
1088
|
-
* their percent-encoded equivalents
|
1089
|
-
*
|
1090
|
-
* @param {string} str - The string to encode.
|
1091
|
-
*
|
1092
|
-
* @returns {string} The encoded string.
|
1093
|
-
*/
|
1094
|
-
function encode$1(str) {
|
1095
|
-
const charMap = {
|
1096
|
-
'!': '%21',
|
1097
|
-
"'": '%27',
|
1098
|
-
'(': '%28',
|
1099
|
-
')': '%29',
|
1100
|
-
'~': '%7E',
|
1101
|
-
'%20': '+',
|
1102
|
-
'%00': '\x00'
|
1103
|
-
};
|
1104
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
1105
|
-
return charMap[match];
|
1106
|
-
});
|
1107
|
-
}
|
1108
|
-
|
1109
|
-
/**
|
1110
|
-
* It takes a params object and converts it to a FormData object
|
1111
|
-
*
|
1112
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
1113
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
1114
|
-
*
|
1115
|
-
* @returns {void}
|
1116
|
-
*/
|
1117
|
-
function AxiosURLSearchParams(params, options) {
|
1118
|
-
this._pairs = [];
|
1119
|
-
|
1120
|
-
params && toFormData$1(params, this, options);
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
const prototype = AxiosURLSearchParams.prototype;
|
1124
|
-
|
1125
|
-
prototype.append = function append(name, value) {
|
1126
|
-
this._pairs.push([name, value]);
|
1127
|
-
};
|
1128
|
-
|
1129
|
-
prototype.toString = function toString(encoder) {
|
1130
|
-
const _encode = encoder ? function(value) {
|
1131
|
-
return encoder.call(this, value, encode$1);
|
1132
|
-
} : encode$1;
|
1133
|
-
|
1134
|
-
return this._pairs.map(function each(pair) {
|
1135
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
1136
|
-
}, '').join('&');
|
1137
|
-
};
|
1138
|
-
|
1139
|
-
'use strict';
|
1140
|
-
|
1141
|
-
/**
|
1142
|
-
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
1143
|
-
* URI encoded counterparts
|
1144
|
-
*
|
1145
|
-
* @param {string} val The value to be encoded.
|
1146
|
-
*
|
1147
|
-
* @returns {string} The encoded value.
|
1148
|
-
*/
|
1149
|
-
function encode(val) {
|
1150
|
-
return encodeURIComponent(val).
|
1151
|
-
replace(/%3A/gi, ':').
|
1152
|
-
replace(/%24/g, '$').
|
1153
|
-
replace(/%2C/gi, ',').
|
1154
|
-
replace(/%20/g, '+').
|
1155
|
-
replace(/%5B/gi, '[').
|
1156
|
-
replace(/%5D/gi, ']');
|
1157
|
-
}
|
1158
|
-
|
1159
|
-
/**
|
1160
|
-
* Build a URL by appending params to the end
|
1161
|
-
*
|
1162
|
-
* @param {string} url The base of the url (e.g., http://www.google.com)
|
1163
|
-
* @param {object} [params] The params to be appended
|
1164
|
-
* @param {?object} options
|
1165
|
-
*
|
1166
|
-
* @returns {string} The formatted url
|
1167
|
-
*/
|
1168
|
-
function buildURL(url, params, options) {
|
1169
|
-
/*eslint no-param-reassign:0*/
|
1170
|
-
if (!params) {
|
1171
|
-
return url;
|
1172
|
-
}
|
1173
|
-
|
1174
|
-
const _encode = options && options.encode || encode;
|
1175
|
-
|
1176
|
-
const serializeFn = options && options.serialize;
|
1177
|
-
|
1178
|
-
let serializedParams;
|
1179
|
-
|
1180
|
-
if (serializeFn) {
|
1181
|
-
serializedParams = serializeFn(params, options);
|
1182
|
-
} else {
|
1183
|
-
serializedParams = utils$1.isURLSearchParams(params) ?
|
1184
|
-
params.toString() :
|
1185
|
-
new AxiosURLSearchParams(params, options).toString(_encode);
|
1186
|
-
}
|
1187
|
-
|
1188
|
-
if (serializedParams) {
|
1189
|
-
const hashmarkIndex = url.indexOf("#");
|
1190
|
-
|
1191
|
-
if (hashmarkIndex !== -1) {
|
1192
|
-
url = url.slice(0, hashmarkIndex);
|
1193
|
-
}
|
1194
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
1195
|
-
}
|
1196
|
-
|
1197
|
-
return url;
|
1198
|
-
}
|
1199
|
-
|
1200
|
-
'use strict';
|
1201
|
-
|
1202
|
-
class InterceptorManager {
|
1203
|
-
constructor() {
|
1204
|
-
this.handlers = [];
|
1205
|
-
}
|
1206
|
-
|
1207
|
-
/**
|
1208
|
-
* Add a new interceptor to the stack
|
1209
|
-
*
|
1210
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
1211
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
1212
|
-
*
|
1213
|
-
* @return {Number} An ID used to remove interceptor later
|
1214
|
-
*/
|
1215
|
-
use(fulfilled, rejected, options) {
|
1216
|
-
this.handlers.push({
|
1217
|
-
fulfilled,
|
1218
|
-
rejected,
|
1219
|
-
synchronous: options ? options.synchronous : false,
|
1220
|
-
runWhen: options ? options.runWhen : null
|
1221
|
-
});
|
1222
|
-
return this.handlers.length - 1;
|
1223
|
-
}
|
1224
|
-
|
1225
|
-
/**
|
1226
|
-
* Remove an interceptor from the stack
|
1227
|
-
*
|
1228
|
-
* @param {Number} id The ID that was returned by `use`
|
1229
|
-
*
|
1230
|
-
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
1231
|
-
*/
|
1232
|
-
eject(id) {
|
1233
|
-
if (this.handlers[id]) {
|
1234
|
-
this.handlers[id] = null;
|
1235
|
-
}
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
/**
|
1239
|
-
* Clear all interceptors from the stack
|
1240
|
-
*
|
1241
|
-
* @returns {void}
|
1242
|
-
*/
|
1243
|
-
clear() {
|
1244
|
-
if (this.handlers) {
|
1245
|
-
this.handlers = [];
|
1246
|
-
}
|
1247
|
-
}
|
1248
|
-
|
1249
|
-
/**
|
1250
|
-
* Iterate over all the registered interceptors
|
1251
|
-
*
|
1252
|
-
* This method is particularly useful for skipping over any
|
1253
|
-
* interceptors that may have become `null` calling `eject`.
|
1254
|
-
*
|
1255
|
-
* @param {Function} fn The function to call for each interceptor
|
1256
|
-
*
|
1257
|
-
* @returns {void}
|
1258
|
-
*/
|
1259
|
-
forEach(fn) {
|
1260
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
1261
|
-
if (h !== null) {
|
1262
|
-
fn(h);
|
1263
|
-
}
|
1264
|
-
});
|
1265
|
-
}
|
1266
|
-
}
|
1267
|
-
|
1268
|
-
'use strict';
|
1269
|
-
|
1270
|
-
const transitionalDefaults = {
|
1271
|
-
silentJSONParsing: true,
|
1272
|
-
forcedJSONParsing: true,
|
1273
|
-
clarifyTimeoutError: false
|
1274
|
-
};
|
1275
|
-
|
1276
|
-
'use strict';
|
1277
|
-
const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
1278
|
-
|
1279
|
-
'use strict';
|
1280
|
-
|
1281
|
-
const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
1282
|
-
|
1283
|
-
'use strict';
|
1284
|
-
|
1285
|
-
const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
1286
|
-
|
1287
|
-
const platform$1 = {
|
1288
|
-
isBrowser: true,
|
1289
|
-
classes: {
|
1290
|
-
URLSearchParams: URLSearchParams$1,
|
1291
|
-
FormData: FormData$1,
|
1292
|
-
Blob: Blob$1
|
1293
|
-
},
|
1294
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
1295
|
-
};
|
1296
|
-
|
1297
|
-
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
1298
|
-
|
1299
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
1300
|
-
|
1301
|
-
/**
|
1302
|
-
* Determine if we're running in a standard browser environment
|
1303
|
-
*
|
1304
|
-
* This allows axios to run in a web worker, and react-native.
|
1305
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
1306
|
-
*
|
1307
|
-
* web workers:
|
1308
|
-
* typeof window -> undefined
|
1309
|
-
* typeof document -> undefined
|
1310
|
-
*
|
1311
|
-
* react-native:
|
1312
|
-
* navigator.product -> 'ReactNative'
|
1313
|
-
* nativescript
|
1314
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
1315
|
-
*
|
1316
|
-
* @returns {boolean}
|
1317
|
-
*/
|
1318
|
-
const hasStandardBrowserEnv = hasBrowserEnv &&
|
1319
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
1320
|
-
|
1321
|
-
/**
|
1322
|
-
* Determine if we're running in a standard browser webWorker environment
|
1323
|
-
*
|
1324
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
1325
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
1326
|
-
* filtered out due to its judgment standard
|
1327
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1328
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
1329
|
-
*/
|
1330
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
1331
|
-
return (
|
1332
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
1333
|
-
// eslint-disable-next-line no-undef
|
1334
|
-
self instanceof WorkerGlobalScope &&
|
1335
|
-
typeof self.importScripts === 'function'
|
1336
|
-
);
|
1337
|
-
})();
|
1338
|
-
|
1339
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
1340
|
-
|
1341
|
-
const utils = /*#__PURE__*/Object.freeze({
|
1342
|
-
__proto__: null,
|
1343
|
-
hasBrowserEnv: hasBrowserEnv,
|
1344
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
1345
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
1346
|
-
navigator: _navigator,
|
1347
|
-
origin: origin
|
1348
|
-
});
|
1349
|
-
|
1350
|
-
const platform = {
|
1351
|
-
...utils,
|
1352
|
-
...platform$1
|
1353
|
-
};
|
1354
|
-
|
1355
|
-
'use strict';
|
1356
|
-
|
1357
|
-
function toURLEncodedForm(data, options) {
|
1358
|
-
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
1359
|
-
visitor: function(value, key, path, helpers) {
|
1360
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
1361
|
-
this.append(key, value.toString('base64'));
|
1362
|
-
return false;
|
1363
|
-
}
|
1364
|
-
|
1365
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
1366
|
-
}
|
1367
|
-
}, options));
|
1368
|
-
}
|
1369
|
-
|
1370
|
-
'use strict';
|
1371
|
-
|
1372
|
-
/**
|
1373
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
1374
|
-
*
|
1375
|
-
* @param {string} name - The name of the property to get.
|
1376
|
-
*
|
1377
|
-
* @returns An array of strings.
|
1378
|
-
*/
|
1379
|
-
function parsePropPath(name) {
|
1380
|
-
// foo[x][y][z]
|
1381
|
-
// foo.x.y.z
|
1382
|
-
// foo-x-y-z
|
1383
|
-
// foo x y z
|
1384
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
1385
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
1386
|
-
});
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
/**
|
1390
|
-
* Convert an array to an object.
|
1391
|
-
*
|
1392
|
-
* @param {Array<any>} arr - The array to convert to an object.
|
1393
|
-
*
|
1394
|
-
* @returns An object with the same keys and values as the array.
|
1395
|
-
*/
|
1396
|
-
function arrayToObject(arr) {
|
1397
|
-
const obj = {};
|
1398
|
-
const keys = Object.keys(arr);
|
1399
|
-
let i;
|
1400
|
-
const len = keys.length;
|
1401
|
-
let key;
|
1402
|
-
for (i = 0; i < len; i++) {
|
1403
|
-
key = keys[i];
|
1404
|
-
obj[key] = arr[key];
|
1405
|
-
}
|
1406
|
-
return obj;
|
1407
|
-
}
|
1408
|
-
|
1409
|
-
/**
|
1410
|
-
* It takes a FormData object and returns a JavaScript object
|
1411
|
-
*
|
1412
|
-
* @param {string} formData The FormData object to convert to JSON.
|
1413
|
-
*
|
1414
|
-
* @returns {Object<string, any> | null} The converted object.
|
1415
|
-
*/
|
1416
|
-
function formDataToJSON(formData) {
|
1417
|
-
function buildPath(path, value, target, index) {
|
1418
|
-
let name = path[index++];
|
1419
|
-
|
1420
|
-
if (name === '__proto__') return true;
|
1421
|
-
|
1422
|
-
const isNumericKey = Number.isFinite(+name);
|
1423
|
-
const isLast = index >= path.length;
|
1424
|
-
name = !name && utils$1.isArray(target) ? target.length : name;
|
1425
|
-
|
1426
|
-
if (isLast) {
|
1427
|
-
if (utils$1.hasOwnProp(target, name)) {
|
1428
|
-
target[name] = [target[name], value];
|
1429
|
-
} else {
|
1430
|
-
target[name] = value;
|
1431
|
-
}
|
1432
|
-
|
1433
|
-
return !isNumericKey;
|
1434
|
-
}
|
1435
|
-
|
1436
|
-
if (!target[name] || !utils$1.isObject(target[name])) {
|
1437
|
-
target[name] = [];
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
const result = buildPath(path, value, target[name], index);
|
1441
|
-
|
1442
|
-
if (result && utils$1.isArray(target[name])) {
|
1443
|
-
target[name] = arrayToObject(target[name]);
|
1444
|
-
}
|
1445
|
-
|
1446
|
-
return !isNumericKey;
|
1447
|
-
}
|
1448
|
-
|
1449
|
-
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
1450
|
-
const obj = {};
|
1451
|
-
|
1452
|
-
utils$1.forEachEntry(formData, (name, value) => {
|
1453
|
-
buildPath(parsePropPath(name), value, obj, 0);
|
1454
|
-
});
|
1455
|
-
|
1456
|
-
return obj;
|
1457
|
-
}
|
1458
|
-
|
1459
|
-
return null;
|
1460
|
-
}
|
1461
|
-
|
1462
|
-
'use strict';
|
1463
|
-
|
1464
|
-
/**
|
1465
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1466
|
-
* of the input
|
1467
|
-
*
|
1468
|
-
* @param {any} rawValue - The value to be stringified.
|
1469
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1470
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
1471
|
-
*
|
1472
|
-
* @returns {string} A stringified version of the rawValue.
|
1473
|
-
*/
|
1474
|
-
function stringifySafely(rawValue, parser, encoder) {
|
1475
|
-
if (utils$1.isString(rawValue)) {
|
1476
|
-
try {
|
1477
|
-
(parser || JSON.parse)(rawValue);
|
1478
|
-
return utils$1.trim(rawValue);
|
1479
|
-
} catch (e) {
|
1480
|
-
if (e.name !== 'SyntaxError') {
|
1481
|
-
throw e;
|
1482
|
-
}
|
1483
|
-
}
|
1484
|
-
}
|
1485
|
-
|
1486
|
-
return (encoder || JSON.stringify)(rawValue);
|
1487
|
-
}
|
1488
|
-
|
1489
|
-
const defaults = {
|
1490
|
-
|
1491
|
-
transitional: transitionalDefaults,
|
1492
|
-
|
1493
|
-
adapter: ['xhr', 'http', 'fetch'],
|
1494
|
-
|
1495
|
-
transformRequest: [function transformRequest(data, headers) {
|
1496
|
-
const contentType = headers.getContentType() || '';
|
1497
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1498
|
-
const isObjectPayload = utils$1.isObject(data);
|
1499
|
-
|
1500
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
1501
|
-
data = new FormData(data);
|
1502
|
-
}
|
1503
|
-
|
1504
|
-
const isFormData = utils$1.isFormData(data);
|
1505
|
-
|
1506
|
-
if (isFormData) {
|
1507
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1508
|
-
}
|
1509
|
-
|
1510
|
-
if (utils$1.isArrayBuffer(data) ||
|
1511
|
-
utils$1.isBuffer(data) ||
|
1512
|
-
utils$1.isStream(data) ||
|
1513
|
-
utils$1.isFile(data) ||
|
1514
|
-
utils$1.isBlob(data) ||
|
1515
|
-
utils$1.isReadableStream(data)
|
1516
|
-
) {
|
1517
|
-
return data;
|
1518
|
-
}
|
1519
|
-
if (utils$1.isArrayBufferView(data)) {
|
1520
|
-
return data.buffer;
|
1521
|
-
}
|
1522
|
-
if (utils$1.isURLSearchParams(data)) {
|
1523
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1524
|
-
return data.toString();
|
1525
|
-
}
|
1526
|
-
|
1527
|
-
let isFileList;
|
1528
|
-
|
1529
|
-
if (isObjectPayload) {
|
1530
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1531
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
1532
|
-
}
|
1533
|
-
|
1534
|
-
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1535
|
-
const _FormData = this.env && this.env.FormData;
|
1536
|
-
|
1537
|
-
return toFormData$1(
|
1538
|
-
isFileList ? {'files[]': data} : data,
|
1539
|
-
_FormData && new _FormData(),
|
1540
|
-
this.formSerializer
|
1541
|
-
);
|
1542
|
-
}
|
1543
|
-
}
|
1544
|
-
|
1545
|
-
if (isObjectPayload || hasJSONContentType ) {
|
1546
|
-
headers.setContentType('application/json', false);
|
1547
|
-
return stringifySafely(data);
|
1548
|
-
}
|
1549
|
-
|
1550
|
-
return data;
|
1551
|
-
}],
|
1552
|
-
|
1553
|
-
transformResponse: [function transformResponse(data) {
|
1554
|
-
const transitional = this.transitional || defaults.transitional;
|
1555
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1556
|
-
const JSONRequested = this.responseType === 'json';
|
1557
|
-
|
1558
|
-
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
1559
|
-
return data;
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1563
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1564
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1565
|
-
|
1566
|
-
try {
|
1567
|
-
return JSON.parse(data);
|
1568
|
-
} catch (e) {
|
1569
|
-
if (strictJSONParsing) {
|
1570
|
-
if (e.name === 'SyntaxError') {
|
1571
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
1572
|
-
}
|
1573
|
-
throw e;
|
1574
|
-
}
|
1575
|
-
}
|
1576
|
-
}
|
1577
|
-
|
1578
|
-
return data;
|
1579
|
-
}],
|
1580
|
-
|
1581
|
-
/**
|
1582
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1583
|
-
* timeout is not created.
|
1584
|
-
*/
|
1585
|
-
timeout: 0,
|
1586
|
-
|
1587
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
1588
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1589
|
-
|
1590
|
-
maxContentLength: -1,
|
1591
|
-
maxBodyLength: -1,
|
1592
|
-
|
1593
|
-
env: {
|
1594
|
-
FormData: platform.classes.FormData,
|
1595
|
-
Blob: platform.classes.Blob
|
1596
|
-
},
|
1597
|
-
|
1598
|
-
validateStatus: function validateStatus(status) {
|
1599
|
-
return status >= 200 && status < 300;
|
1600
|
-
},
|
1601
|
-
|
1602
|
-
headers: {
|
1603
|
-
common: {
|
1604
|
-
'Accept': 'application/json, text/plain, */*',
|
1605
|
-
'Content-Type': undefined
|
1606
|
-
}
|
1607
|
-
}
|
1608
|
-
};
|
1609
|
-
|
1610
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
1611
|
-
defaults.headers[method] = {};
|
1612
|
-
});
|
1613
|
-
|
1614
|
-
'use strict';
|
1615
|
-
|
1616
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
1617
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1618
|
-
const ignoreDuplicateOf = utils$1.toObjectSet([
|
1619
|
-
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
1620
|
-
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
1621
|
-
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
1622
|
-
'referer', 'retry-after', 'user-agent'
|
1623
|
-
]);
|
1624
|
-
|
1625
|
-
/**
|
1626
|
-
* Parse headers into an object
|
1627
|
-
*
|
1628
|
-
* ```
|
1629
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
1630
|
-
* Content-Type: application/json
|
1631
|
-
* Connection: keep-alive
|
1632
|
-
* Transfer-Encoding: chunked
|
1633
|
-
* ```
|
1634
|
-
*
|
1635
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
1636
|
-
*
|
1637
|
-
* @returns {Object} Headers parsed into an object
|
1638
|
-
*/
|
1639
|
-
const parseHeaders = rawHeaders => {
|
1640
|
-
const parsed = {};
|
1641
|
-
let key;
|
1642
|
-
let val;
|
1643
|
-
let i;
|
1644
|
-
|
1645
|
-
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
1646
|
-
i = line.indexOf(':');
|
1647
|
-
key = line.substring(0, i).trim().toLowerCase();
|
1648
|
-
val = line.substring(i + 1).trim();
|
1649
|
-
|
1650
|
-
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
1651
|
-
return;
|
1652
|
-
}
|
1653
|
-
|
1654
|
-
if (key === 'set-cookie') {
|
1655
|
-
if (parsed[key]) {
|
1656
|
-
parsed[key].push(val);
|
1657
|
-
} else {
|
1658
|
-
parsed[key] = [val];
|
1659
|
-
}
|
1660
|
-
} else {
|
1661
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
1662
|
-
}
|
1663
|
-
});
|
1664
|
-
|
1665
|
-
return parsed;
|
1666
|
-
};
|
1667
|
-
|
1668
|
-
'use strict';
|
1669
|
-
|
1670
|
-
const $internals = Symbol('internals');
|
1671
|
-
|
1672
|
-
function normalizeHeader(header) {
|
1673
|
-
return header && String(header).trim().toLowerCase();
|
1674
|
-
}
|
1675
|
-
|
1676
|
-
function normalizeValue(value) {
|
1677
|
-
if (value === false || value == null) {
|
1678
|
-
return value;
|
1679
|
-
}
|
1680
|
-
|
1681
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
1682
|
-
}
|
1683
|
-
|
1684
|
-
function parseTokens(str) {
|
1685
|
-
const tokens = Object.create(null);
|
1686
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
1687
|
-
let match;
|
1688
|
-
|
1689
|
-
while ((match = tokensRE.exec(str))) {
|
1690
|
-
tokens[match[1]] = match[2];
|
1691
|
-
}
|
1692
|
-
|
1693
|
-
return tokens;
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
1697
|
-
|
1698
|
-
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1699
|
-
if (utils$1.isFunction(filter)) {
|
1700
|
-
return filter.call(this, value, header);
|
1701
|
-
}
|
1702
|
-
|
1703
|
-
if (isHeaderNameFilter) {
|
1704
|
-
value = header;
|
1705
|
-
}
|
1706
|
-
|
1707
|
-
if (!utils$1.isString(value)) return;
|
1708
|
-
|
1709
|
-
if (utils$1.isString(filter)) {
|
1710
|
-
return value.indexOf(filter) !== -1;
|
1711
|
-
}
|
1712
|
-
|
1713
|
-
if (utils$1.isRegExp(filter)) {
|
1714
|
-
return filter.test(value);
|
1715
|
-
}
|
1716
|
-
}
|
1717
|
-
|
1718
|
-
function formatHeader(header) {
|
1719
|
-
return header.trim()
|
1720
|
-
.toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
1721
|
-
return char.toUpperCase() + str;
|
1722
|
-
});
|
1723
|
-
}
|
1724
|
-
|
1725
|
-
function buildAccessors(obj, header) {
|
1726
|
-
const accessorName = utils$1.toCamelCase(' ' + header);
|
1727
|
-
|
1728
|
-
['get', 'set', 'has'].forEach(methodName => {
|
1729
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
1730
|
-
value: function(arg1, arg2, arg3) {
|
1731
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
1732
|
-
},
|
1733
|
-
configurable: true
|
1734
|
-
});
|
1735
|
-
});
|
1736
|
-
}
|
1737
|
-
|
1738
|
-
class AxiosHeaders$1 {
|
1739
|
-
constructor(headers) {
|
1740
|
-
headers && this.set(headers);
|
1741
|
-
}
|
1742
|
-
|
1743
|
-
set(header, valueOrRewrite, rewrite) {
|
1744
|
-
const self = this;
|
1745
|
-
|
1746
|
-
function setHeader(_value, _header, _rewrite) {
|
1747
|
-
const lHeader = normalizeHeader(_header);
|
1748
|
-
|
1749
|
-
if (!lHeader) {
|
1750
|
-
throw new Error('header name must be a non-empty string');
|
1751
|
-
}
|
1752
|
-
|
1753
|
-
const key = utils$1.findKey(self, lHeader);
|
1754
|
-
|
1755
|
-
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
1756
|
-
self[key || _header] = normalizeValue(_value);
|
1757
|
-
}
|
1758
|
-
}
|
1759
|
-
|
1760
|
-
const setHeaders = (headers, _rewrite) =>
|
1761
|
-
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1762
|
-
|
1763
|
-
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
1764
|
-
setHeaders(header, valueOrRewrite);
|
1765
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1766
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
1767
|
-
} else if (utils$1.isHeaders(header)) {
|
1768
|
-
for (const [key, value] of header.entries()) {
|
1769
|
-
setHeader(value, key, rewrite);
|
1770
|
-
}
|
1771
|
-
} else {
|
1772
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1773
|
-
}
|
1774
|
-
|
1775
|
-
return this;
|
1776
|
-
}
|
1777
|
-
|
1778
|
-
get(header, parser) {
|
1779
|
-
header = normalizeHeader(header);
|
1780
|
-
|
1781
|
-
if (header) {
|
1782
|
-
const key = utils$1.findKey(this, header);
|
1783
|
-
|
1784
|
-
if (key) {
|
1785
|
-
const value = this[key];
|
1786
|
-
|
1787
|
-
if (!parser) {
|
1788
|
-
return value;
|
1789
|
-
}
|
1790
|
-
|
1791
|
-
if (parser === true) {
|
1792
|
-
return parseTokens(value);
|
1793
|
-
}
|
1794
|
-
|
1795
|
-
if (utils$1.isFunction(parser)) {
|
1796
|
-
return parser.call(this, value, key);
|
1797
|
-
}
|
1798
|
-
|
1799
|
-
if (utils$1.isRegExp(parser)) {
|
1800
|
-
return parser.exec(value);
|
1801
|
-
}
|
1802
|
-
|
1803
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
1804
|
-
}
|
1805
|
-
}
|
1806
|
-
}
|
1807
|
-
|
1808
|
-
has(header, matcher) {
|
1809
|
-
header = normalizeHeader(header);
|
1810
|
-
|
1811
|
-
if (header) {
|
1812
|
-
const key = utils$1.findKey(this, header);
|
1813
|
-
|
1814
|
-
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1815
|
-
}
|
1816
|
-
|
1817
|
-
return false;
|
1818
|
-
}
|
1819
|
-
|
1820
|
-
delete(header, matcher) {
|
1821
|
-
const self = this;
|
1822
|
-
let deleted = false;
|
1823
|
-
|
1824
|
-
function deleteHeader(_header) {
|
1825
|
-
_header = normalizeHeader(_header);
|
1826
|
-
|
1827
|
-
if (_header) {
|
1828
|
-
const key = utils$1.findKey(self, _header);
|
1829
|
-
|
1830
|
-
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1831
|
-
delete self[key];
|
1832
|
-
|
1833
|
-
deleted = true;
|
1834
|
-
}
|
1835
|
-
}
|
1836
|
-
}
|
1837
|
-
|
1838
|
-
if (utils$1.isArray(header)) {
|
1839
|
-
header.forEach(deleteHeader);
|
1840
|
-
} else {
|
1841
|
-
deleteHeader(header);
|
1842
|
-
}
|
1843
|
-
|
1844
|
-
return deleted;
|
1845
|
-
}
|
1846
|
-
|
1847
|
-
clear(matcher) {
|
1848
|
-
const keys = Object.keys(this);
|
1849
|
-
let i = keys.length;
|
1850
|
-
let deleted = false;
|
1851
|
-
|
1852
|
-
while (i--) {
|
1853
|
-
const key = keys[i];
|
1854
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
1855
|
-
delete this[key];
|
1856
|
-
deleted = true;
|
1857
|
-
}
|
1858
|
-
}
|
1859
|
-
|
1860
|
-
return deleted;
|
1861
|
-
}
|
1862
|
-
|
1863
|
-
normalize(format) {
|
1864
|
-
const self = this;
|
1865
|
-
const headers = {};
|
1866
|
-
|
1867
|
-
utils$1.forEach(this, (value, header) => {
|
1868
|
-
const key = utils$1.findKey(headers, header);
|
1869
|
-
|
1870
|
-
if (key) {
|
1871
|
-
self[key] = normalizeValue(value);
|
1872
|
-
delete self[header];
|
1873
|
-
return;
|
1874
|
-
}
|
1875
|
-
|
1876
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
1877
|
-
|
1878
|
-
if (normalized !== header) {
|
1879
|
-
delete self[header];
|
1880
|
-
}
|
1881
|
-
|
1882
|
-
self[normalized] = normalizeValue(value);
|
1883
|
-
|
1884
|
-
headers[normalized] = true;
|
1885
|
-
});
|
1886
|
-
|
1887
|
-
return this;
|
1888
|
-
}
|
1889
|
-
|
1890
|
-
concat(...targets) {
|
1891
|
-
return this.constructor.concat(this, ...targets);
|
1892
|
-
}
|
1893
|
-
|
1894
|
-
toJSON(asStrings) {
|
1895
|
-
const obj = Object.create(null);
|
1896
|
-
|
1897
|
-
utils$1.forEach(this, (value, header) => {
|
1898
|
-
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
1899
|
-
});
|
1900
|
-
|
1901
|
-
return obj;
|
1902
|
-
}
|
1903
|
-
|
1904
|
-
[Symbol.iterator]() {
|
1905
|
-
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1906
|
-
}
|
1907
|
-
|
1908
|
-
toString() {
|
1909
|
-
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
1910
|
-
}
|
1911
|
-
|
1912
|
-
get [Symbol.toStringTag]() {
|
1913
|
-
return 'AxiosHeaders';
|
1914
|
-
}
|
1915
|
-
|
1916
|
-
static from(thing) {
|
1917
|
-
return thing instanceof this ? thing : new this(thing);
|
1918
|
-
}
|
1919
|
-
|
1920
|
-
static concat(first, ...targets) {
|
1921
|
-
const computed = new this(first);
|
1922
|
-
|
1923
|
-
targets.forEach((target) => computed.set(target));
|
1924
|
-
|
1925
|
-
return computed;
|
1926
|
-
}
|
1927
|
-
|
1928
|
-
static accessor(header) {
|
1929
|
-
const internals = this[$internals] = (this[$internals] = {
|
1930
|
-
accessors: {}
|
1931
|
-
});
|
1932
|
-
|
1933
|
-
const accessors = internals.accessors;
|
1934
|
-
const prototype = this.prototype;
|
1935
|
-
|
1936
|
-
function defineAccessor(_header) {
|
1937
|
-
const lHeader = normalizeHeader(_header);
|
1938
|
-
|
1939
|
-
if (!accessors[lHeader]) {
|
1940
|
-
buildAccessors(prototype, _header);
|
1941
|
-
accessors[lHeader] = true;
|
1942
|
-
}
|
1943
|
-
}
|
1944
|
-
|
1945
|
-
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1946
|
-
|
1947
|
-
return this;
|
1948
|
-
}
|
1949
|
-
}
|
1950
|
-
|
1951
|
-
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1952
|
-
|
1953
|
-
// reserved names hotfix
|
1954
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
1955
|
-
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
1956
|
-
return {
|
1957
|
-
get: () => value,
|
1958
|
-
set(headerValue) {
|
1959
|
-
this[mapped] = headerValue;
|
1960
|
-
}
|
1961
|
-
}
|
1962
|
-
});
|
1963
|
-
|
1964
|
-
utils$1.freezeMethods(AxiosHeaders$1);
|
1965
|
-
|
1966
|
-
'use strict';
|
1967
|
-
|
1968
|
-
/**
|
1969
|
-
* Transform the data for a request or a response
|
1970
|
-
*
|
1971
|
-
* @param {Array|Function} fns A single function or Array of functions
|
1972
|
-
* @param {?Object} response The response object
|
1973
|
-
*
|
1974
|
-
* @returns {*} The resulting transformed data
|
1975
|
-
*/
|
1976
|
-
function transformData(fns, response) {
|
1977
|
-
const config = this || defaults;
|
1978
|
-
const context = response || config;
|
1979
|
-
const headers = AxiosHeaders$1.from(context.headers);
|
1980
|
-
let data = context.data;
|
1981
|
-
|
1982
|
-
utils$1.forEach(fns, function transform(fn) {
|
1983
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1984
|
-
});
|
1985
|
-
|
1986
|
-
headers.normalize();
|
1987
|
-
|
1988
|
-
return data;
|
1989
|
-
}
|
1990
|
-
|
1991
|
-
'use strict';
|
1992
|
-
|
1993
|
-
function isCancel$1(value) {
|
1994
|
-
return !!(value && value.__CANCEL__);
|
1995
|
-
}
|
1996
|
-
|
1997
|
-
'use strict';
|
1998
|
-
|
1999
|
-
/**
|
2000
|
-
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
2001
|
-
*
|
2002
|
-
* @param {string=} message The message.
|
2003
|
-
* @param {Object=} config The config.
|
2004
|
-
* @param {Object=} request The request.
|
2005
|
-
*
|
2006
|
-
* @returns {CanceledError} The created error.
|
2007
|
-
*/
|
2008
|
-
function CanceledError$1(message, config, request) {
|
2009
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
2010
|
-
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
2011
|
-
this.name = 'CanceledError';
|
2012
|
-
}
|
2013
|
-
|
2014
|
-
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
2015
|
-
__CANCEL__: true
|
2016
|
-
});
|
2017
|
-
|
2018
|
-
'use strict';
|
2019
|
-
|
2020
|
-
/**
|
2021
|
-
* Resolve or reject a Promise based on response status.
|
2022
|
-
*
|
2023
|
-
* @param {Function} resolve A function that resolves the promise.
|
2024
|
-
* @param {Function} reject A function that rejects the promise.
|
2025
|
-
* @param {object} response The response.
|
2026
|
-
*
|
2027
|
-
* @returns {object} The response.
|
2028
|
-
*/
|
2029
|
-
function settle(resolve, reject, response) {
|
2030
|
-
const validateStatus = response.config.validateStatus;
|
2031
|
-
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
2032
|
-
resolve(response);
|
2033
|
-
} else {
|
2034
|
-
reject(new AxiosError$1(
|
2035
|
-
'Request failed with status code ' + response.status,
|
2036
|
-
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
2037
|
-
response.config,
|
2038
|
-
response.request,
|
2039
|
-
response
|
2040
|
-
));
|
2041
|
-
}
|
2042
|
-
}
|
2043
|
-
|
2044
|
-
'use strict';
|
2045
|
-
|
2046
|
-
function parseProtocol(url) {
|
2047
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
2048
|
-
return match && match[1] || '';
|
2049
|
-
}
|
2050
|
-
|
2051
|
-
'use strict';
|
2052
|
-
|
2053
|
-
/**
|
2054
|
-
* Calculate data maxRate
|
2055
|
-
* @param {Number} [samplesCount= 10]
|
2056
|
-
* @param {Number} [min= 1000]
|
2057
|
-
* @returns {Function}
|
2058
|
-
*/
|
2059
|
-
function speedometer(samplesCount, min) {
|
2060
|
-
samplesCount = samplesCount || 10;
|
2061
|
-
const bytes = new Array(samplesCount);
|
2062
|
-
const timestamps = new Array(samplesCount);
|
2063
|
-
let head = 0;
|
2064
|
-
let tail = 0;
|
2065
|
-
let firstSampleTS;
|
2066
|
-
|
2067
|
-
min = min !== undefined ? min : 1000;
|
2068
|
-
|
2069
|
-
return function push(chunkLength) {
|
2070
|
-
const now = Date.now();
|
2071
|
-
|
2072
|
-
const startedAt = timestamps[tail];
|
2073
|
-
|
2074
|
-
if (!firstSampleTS) {
|
2075
|
-
firstSampleTS = now;
|
2076
|
-
}
|
2077
|
-
|
2078
|
-
bytes[head] = chunkLength;
|
2079
|
-
timestamps[head] = now;
|
2080
|
-
|
2081
|
-
let i = tail;
|
2082
|
-
let bytesCount = 0;
|
2083
|
-
|
2084
|
-
while (i !== head) {
|
2085
|
-
bytesCount += bytes[i++];
|
2086
|
-
i = i % samplesCount;
|
2087
|
-
}
|
2088
|
-
|
2089
|
-
head = (head + 1) % samplesCount;
|
2090
|
-
|
2091
|
-
if (head === tail) {
|
2092
|
-
tail = (tail + 1) % samplesCount;
|
2093
|
-
}
|
2094
|
-
|
2095
|
-
if (now - firstSampleTS < min) {
|
2096
|
-
return;
|
2097
|
-
}
|
2098
|
-
|
2099
|
-
const passed = startedAt && now - startedAt;
|
2100
|
-
|
2101
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
2102
|
-
};
|
2103
|
-
}
|
2104
|
-
|
2105
|
-
/**
|
2106
|
-
* Throttle decorator
|
2107
|
-
* @param {Function} fn
|
2108
|
-
* @param {Number} freq
|
2109
|
-
* @return {Function}
|
2110
|
-
*/
|
2111
|
-
function throttle(fn, freq) {
|
2112
|
-
let timestamp = 0;
|
2113
|
-
let threshold = 1000 / freq;
|
2114
|
-
let lastArgs;
|
2115
|
-
let timer;
|
2116
|
-
|
2117
|
-
const invoke = (args, now = Date.now()) => {
|
2118
|
-
timestamp = now;
|
2119
|
-
lastArgs = null;
|
2120
|
-
if (timer) {
|
2121
|
-
clearTimeout(timer);
|
2122
|
-
timer = null;
|
2123
|
-
}
|
2124
|
-
fn.apply(null, args);
|
2125
|
-
};
|
2126
|
-
|
2127
|
-
const throttled = (...args) => {
|
2128
|
-
const now = Date.now();
|
2129
|
-
const passed = now - timestamp;
|
2130
|
-
if ( passed >= threshold) {
|
2131
|
-
invoke(args, now);
|
2132
|
-
} else {
|
2133
|
-
lastArgs = args;
|
2134
|
-
if (!timer) {
|
2135
|
-
timer = setTimeout(() => {
|
2136
|
-
timer = null;
|
2137
|
-
invoke(lastArgs);
|
2138
|
-
}, threshold - passed);
|
2139
|
-
}
|
2140
|
-
}
|
2141
|
-
};
|
2142
|
-
|
2143
|
-
const flush = () => lastArgs && invoke(lastArgs);
|
2144
|
-
|
2145
|
-
return [throttled, flush];
|
2146
|
-
}
|
2147
|
-
|
2148
|
-
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
2149
|
-
let bytesNotified = 0;
|
2150
|
-
const _speedometer = speedometer(50, 250);
|
2151
|
-
|
2152
|
-
return throttle(e => {
|
2153
|
-
const loaded = e.loaded;
|
2154
|
-
const total = e.lengthComputable ? e.total : undefined;
|
2155
|
-
const progressBytes = loaded - bytesNotified;
|
2156
|
-
const rate = _speedometer(progressBytes);
|
2157
|
-
const inRange = loaded <= total;
|
2158
|
-
|
2159
|
-
bytesNotified = loaded;
|
2160
|
-
|
2161
|
-
const data = {
|
2162
|
-
loaded,
|
2163
|
-
total,
|
2164
|
-
progress: total ? (loaded / total) : undefined,
|
2165
|
-
bytes: progressBytes,
|
2166
|
-
rate: rate ? rate : undefined,
|
2167
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
2168
|
-
event: e,
|
2169
|
-
lengthComputable: total != null,
|
2170
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
2171
|
-
};
|
2172
|
-
|
2173
|
-
listener(data);
|
2174
|
-
}, freq);
|
2175
|
-
};
|
2176
|
-
|
2177
|
-
const progressEventDecorator = (total, throttled) => {
|
2178
|
-
const lengthComputable = total != null;
|
2179
|
-
|
2180
|
-
return [(loaded) => throttled[0]({
|
2181
|
-
lengthComputable,
|
2182
|
-
total,
|
2183
|
-
loaded
|
2184
|
-
}), throttled[1]];
|
2185
|
-
};
|
2186
|
-
|
2187
|
-
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
2188
|
-
|
2189
|
-
'use strict';
|
2190
|
-
|
2191
|
-
const isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
2192
|
-
|
2193
|
-
// Standard browser envs have full support of the APIs needed to test
|
2194
|
-
// whether the request URL is of the same origin as current location.
|
2195
|
-
(function standardBrowserEnv() {
|
2196
|
-
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
2197
|
-
const urlParsingNode = document.createElement('a');
|
2198
|
-
let originURL;
|
2199
|
-
|
2200
|
-
/**
|
2201
|
-
* Parse a URL to discover its components
|
2202
|
-
*
|
2203
|
-
* @param {String} url The URL to be parsed
|
2204
|
-
* @returns {Object}
|
2205
|
-
*/
|
2206
|
-
function resolveURL(url) {
|
2207
|
-
let href = url;
|
2208
|
-
|
2209
|
-
if (msie) {
|
2210
|
-
// IE needs attribute set twice to normalize properties
|
2211
|
-
urlParsingNode.setAttribute('href', href);
|
2212
|
-
href = urlParsingNode.href;
|
2213
|
-
}
|
2214
|
-
|
2215
|
-
urlParsingNode.setAttribute('href', href);
|
2216
|
-
|
2217
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
2218
|
-
return {
|
2219
|
-
href: urlParsingNode.href,
|
2220
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
2221
|
-
host: urlParsingNode.host,
|
2222
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
2223
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
2224
|
-
hostname: urlParsingNode.hostname,
|
2225
|
-
port: urlParsingNode.port,
|
2226
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
2227
|
-
urlParsingNode.pathname :
|
2228
|
-
'/' + urlParsingNode.pathname
|
2229
|
-
};
|
2230
|
-
}
|
2231
|
-
|
2232
|
-
originURL = resolveURL(window.location.href);
|
2233
|
-
|
2234
|
-
/**
|
2235
|
-
* Determine if a URL shares the same origin as the current location
|
2236
|
-
*
|
2237
|
-
* @param {String} requestURL The URL to test
|
2238
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
2239
|
-
*/
|
2240
|
-
return function isURLSameOrigin(requestURL) {
|
2241
|
-
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
2242
|
-
return (parsed.protocol === originURL.protocol &&
|
2243
|
-
parsed.host === originURL.host);
|
2244
|
-
};
|
2245
|
-
})() :
|
2246
|
-
|
2247
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
2248
|
-
(function nonStandardBrowserEnv() {
|
2249
|
-
return function isURLSameOrigin() {
|
2250
|
-
return true;
|
2251
|
-
};
|
2252
|
-
})();
|
2253
|
-
|
2254
|
-
const cookies = platform.hasStandardBrowserEnv ?
|
2255
|
-
|
2256
|
-
// Standard browser envs support document.cookie
|
2257
|
-
{
|
2258
|
-
write(name, value, expires, path, domain, secure) {
|
2259
|
-
const cookie = [name + '=' + encodeURIComponent(value)];
|
2260
|
-
|
2261
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
2262
|
-
|
2263
|
-
utils$1.isString(path) && cookie.push('path=' + path);
|
2264
|
-
|
2265
|
-
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
2266
|
-
|
2267
|
-
secure === true && cookie.push('secure');
|
2268
|
-
|
2269
|
-
document.cookie = cookie.join('; ');
|
2270
|
-
},
|
2271
|
-
|
2272
|
-
read(name) {
|
2273
|
-
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
2274
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
2275
|
-
},
|
2276
|
-
|
2277
|
-
remove(name) {
|
2278
|
-
this.write(name, '', Date.now() - 86400000);
|
2279
|
-
}
|
2280
|
-
}
|
2281
|
-
|
2282
|
-
:
|
2283
|
-
|
2284
|
-
// Non-standard browser env (web workers, react-native) lack needed support.
|
2285
|
-
{
|
2286
|
-
write() {},
|
2287
|
-
read() {
|
2288
|
-
return null;
|
2289
|
-
},
|
2290
|
-
remove() {}
|
2291
|
-
};
|
2292
|
-
|
2293
|
-
'use strict';
|
2294
|
-
|
2295
|
-
/**
|
2296
|
-
* Determines whether the specified URL is absolute
|
2297
|
-
*
|
2298
|
-
* @param {string} url The URL to test
|
2299
|
-
*
|
2300
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
2301
|
-
*/
|
2302
|
-
function isAbsoluteURL(url) {
|
2303
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
2304
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
2305
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
2306
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
2307
|
-
}
|
2308
|
-
|
2309
|
-
'use strict';
|
2310
|
-
|
2311
|
-
/**
|
2312
|
-
* Creates a new URL by combining the specified URLs
|
2313
|
-
*
|
2314
|
-
* @param {string} baseURL The base URL
|
2315
|
-
* @param {string} relativeURL The relative URL
|
2316
|
-
*
|
2317
|
-
* @returns {string} The combined URL
|
2318
|
-
*/
|
2319
|
-
function combineURLs(baseURL, relativeURL) {
|
2320
|
-
return relativeURL
|
2321
|
-
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
2322
|
-
: baseURL;
|
2323
|
-
}
|
2324
|
-
|
2325
|
-
'use strict';
|
2326
|
-
|
2327
|
-
/**
|
2328
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
2329
|
-
* only when the requestedURL is not already an absolute URL.
|
2330
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
2331
|
-
*
|
2332
|
-
* @param {string} baseURL The base URL
|
2333
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
2334
|
-
*
|
2335
|
-
* @returns {string} The combined full path
|
2336
|
-
*/
|
2337
|
-
function buildFullPath(baseURL, requestedURL) {
|
2338
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
2339
|
-
return combineURLs(baseURL, requestedURL);
|
2340
|
-
}
|
2341
|
-
return requestedURL;
|
2342
|
-
}
|
2343
|
-
|
2344
|
-
'use strict';
|
2345
|
-
|
2346
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
2347
|
-
|
2348
|
-
/**
|
2349
|
-
* Config-specific merge-function which creates a new config-object
|
2350
|
-
* by merging two configuration objects together.
|
2351
|
-
*
|
2352
|
-
* @param {Object} config1
|
2353
|
-
* @param {Object} config2
|
2354
|
-
*
|
2355
|
-
* @returns {Object} New object resulting from merging config2 to config1
|
2356
|
-
*/
|
2357
|
-
function mergeConfig$1(config1, config2) {
|
2358
|
-
// eslint-disable-next-line no-param-reassign
|
2359
|
-
config2 = config2 || {};
|
2360
|
-
const config = {};
|
2361
|
-
|
2362
|
-
function getMergedValue(target, source, caseless) {
|
2363
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
2364
|
-
return utils$1.merge.call({caseless}, target, source);
|
2365
|
-
} else if (utils$1.isPlainObject(source)) {
|
2366
|
-
return utils$1.merge({}, source);
|
2367
|
-
} else if (utils$1.isArray(source)) {
|
2368
|
-
return source.slice();
|
2369
|
-
}
|
2370
|
-
return source;
|
2371
|
-
}
|
2372
|
-
|
2373
|
-
// eslint-disable-next-line consistent-return
|
2374
|
-
function mergeDeepProperties(a, b, caseless) {
|
2375
|
-
if (!utils$1.isUndefined(b)) {
|
2376
|
-
return getMergedValue(a, b, caseless);
|
2377
|
-
} else if (!utils$1.isUndefined(a)) {
|
2378
|
-
return getMergedValue(undefined, a, caseless);
|
2379
|
-
}
|
2380
|
-
}
|
2381
|
-
|
2382
|
-
// eslint-disable-next-line consistent-return
|
2383
|
-
function valueFromConfig2(a, b) {
|
2384
|
-
if (!utils$1.isUndefined(b)) {
|
2385
|
-
return getMergedValue(undefined, b);
|
2386
|
-
}
|
2387
|
-
}
|
2388
|
-
|
2389
|
-
// eslint-disable-next-line consistent-return
|
2390
|
-
function defaultToConfig2(a, b) {
|
2391
|
-
if (!utils$1.isUndefined(b)) {
|
2392
|
-
return getMergedValue(undefined, b);
|
2393
|
-
} else if (!utils$1.isUndefined(a)) {
|
2394
|
-
return getMergedValue(undefined, a);
|
2395
|
-
}
|
2396
|
-
}
|
2397
|
-
|
2398
|
-
// eslint-disable-next-line consistent-return
|
2399
|
-
function mergeDirectKeys(a, b, prop) {
|
2400
|
-
if (prop in config2) {
|
2401
|
-
return getMergedValue(a, b);
|
2402
|
-
} else if (prop in config1) {
|
2403
|
-
return getMergedValue(undefined, a);
|
2404
|
-
}
|
2405
|
-
}
|
2406
|
-
|
2407
|
-
const mergeMap = {
|
2408
|
-
url: valueFromConfig2,
|
2409
|
-
method: valueFromConfig2,
|
2410
|
-
data: valueFromConfig2,
|
2411
|
-
baseURL: defaultToConfig2,
|
2412
|
-
transformRequest: defaultToConfig2,
|
2413
|
-
transformResponse: defaultToConfig2,
|
2414
|
-
paramsSerializer: defaultToConfig2,
|
2415
|
-
timeout: defaultToConfig2,
|
2416
|
-
timeoutMessage: defaultToConfig2,
|
2417
|
-
withCredentials: defaultToConfig2,
|
2418
|
-
withXSRFToken: defaultToConfig2,
|
2419
|
-
adapter: defaultToConfig2,
|
2420
|
-
responseType: defaultToConfig2,
|
2421
|
-
xsrfCookieName: defaultToConfig2,
|
2422
|
-
xsrfHeaderName: defaultToConfig2,
|
2423
|
-
onUploadProgress: defaultToConfig2,
|
2424
|
-
onDownloadProgress: defaultToConfig2,
|
2425
|
-
decompress: defaultToConfig2,
|
2426
|
-
maxContentLength: defaultToConfig2,
|
2427
|
-
maxBodyLength: defaultToConfig2,
|
2428
|
-
beforeRedirect: defaultToConfig2,
|
2429
|
-
transport: defaultToConfig2,
|
2430
|
-
httpAgent: defaultToConfig2,
|
2431
|
-
httpsAgent: defaultToConfig2,
|
2432
|
-
cancelToken: defaultToConfig2,
|
2433
|
-
socketPath: defaultToConfig2,
|
2434
|
-
responseEncoding: defaultToConfig2,
|
2435
|
-
validateStatus: mergeDirectKeys,
|
2436
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
2437
|
-
};
|
2438
|
-
|
2439
|
-
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
2440
|
-
const merge = mergeMap[prop] || mergeDeepProperties;
|
2441
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
2442
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
2443
|
-
});
|
2444
|
-
|
2445
|
-
return config;
|
2446
|
-
}
|
2447
|
-
|
2448
|
-
const resolveConfig = (config) => {
|
2449
|
-
const newConfig = mergeConfig$1({}, config);
|
2450
|
-
|
2451
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
2452
|
-
|
2453
|
-
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
2454
|
-
|
2455
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
2456
|
-
|
2457
|
-
// HTTP basic authentication
|
2458
|
-
if (auth) {
|
2459
|
-
headers.set('Authorization', 'Basic ' +
|
2460
|
-
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
2461
|
-
);
|
2462
|
-
}
|
2463
|
-
|
2464
|
-
let contentType;
|
2465
|
-
|
2466
|
-
if (utils$1.isFormData(data)) {
|
2467
|
-
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
2468
|
-
headers.setContentType(undefined); // Let the browser set it
|
2469
|
-
} else if ((contentType = headers.getContentType()) !== false) {
|
2470
|
-
// fix semicolon duplication issue for ReactNative FormData implementation
|
2471
|
-
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
2472
|
-
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
2473
|
-
}
|
2474
|
-
}
|
2475
|
-
|
2476
|
-
// Add xsrf header
|
2477
|
-
// This is only done if running in a standard browser environment.
|
2478
|
-
// Specifically not if we're in a web worker, or react-native.
|
2479
|
-
|
2480
|
-
if (platform.hasStandardBrowserEnv) {
|
2481
|
-
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
2482
|
-
|
2483
|
-
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
2484
|
-
// Add xsrf header
|
2485
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
2486
|
-
|
2487
|
-
if (xsrfValue) {
|
2488
|
-
headers.set(xsrfHeaderName, xsrfValue);
|
2489
|
-
}
|
2490
|
-
}
|
2491
|
-
}
|
2492
|
-
|
2493
|
-
return newConfig;
|
2494
|
-
};
|
2495
|
-
|
2496
|
-
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2497
|
-
|
2498
|
-
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
2499
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
2500
|
-
const _config = resolveConfig(config);
|
2501
|
-
let requestData = _config.data;
|
2502
|
-
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
2503
|
-
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
2504
|
-
let onCanceled;
|
2505
|
-
let uploadThrottled, downloadThrottled;
|
2506
|
-
let flushUpload, flushDownload;
|
2507
|
-
|
2508
|
-
function done() {
|
2509
|
-
flushUpload && flushUpload(); // flush events
|
2510
|
-
flushDownload && flushDownload(); // flush events
|
2511
|
-
|
2512
|
-
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
2513
|
-
|
2514
|
-
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
2515
|
-
}
|
2516
|
-
|
2517
|
-
let request = new XMLHttpRequest();
|
2518
|
-
|
2519
|
-
request.open(_config.method.toUpperCase(), _config.url, true);
|
2520
|
-
|
2521
|
-
// Set the request timeout in MS
|
2522
|
-
request.timeout = _config.timeout;
|
2523
|
-
|
2524
|
-
function onloadend() {
|
2525
|
-
if (!request) {
|
2526
|
-
return;
|
2527
|
-
}
|
2528
|
-
// Prepare the response
|
2529
|
-
const responseHeaders = AxiosHeaders$1.from(
|
2530
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
2531
|
-
);
|
2532
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
2533
|
-
request.responseText : request.response;
|
2534
|
-
const response = {
|
2535
|
-
data: responseData,
|
2536
|
-
status: request.status,
|
2537
|
-
statusText: request.statusText,
|
2538
|
-
headers: responseHeaders,
|
2539
|
-
config,
|
2540
|
-
request
|
2541
|
-
};
|
2542
|
-
|
2543
|
-
settle(function _resolve(value) {
|
2544
|
-
resolve(value);
|
2545
|
-
done();
|
2546
|
-
}, function _reject(err) {
|
2547
|
-
reject(err);
|
2548
|
-
done();
|
2549
|
-
}, response);
|
2550
|
-
|
2551
|
-
// Clean up request
|
2552
|
-
request = null;
|
2553
|
-
}
|
2554
|
-
|
2555
|
-
if ('onloadend' in request) {
|
2556
|
-
// Use onloadend if available
|
2557
|
-
request.onloadend = onloadend;
|
2558
|
-
} else {
|
2559
|
-
// Listen for ready state to emulate onloadend
|
2560
|
-
request.onreadystatechange = function handleLoad() {
|
2561
|
-
if (!request || request.readyState !== 4) {
|
2562
|
-
return;
|
2563
|
-
}
|
2564
|
-
|
2565
|
-
// The request errored out and we didn't get a response, this will be
|
2566
|
-
// handled by onerror instead
|
2567
|
-
// With one exception: request that using file: protocol, most browsers
|
2568
|
-
// will return status as 0 even though it's a successful request
|
2569
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
2570
|
-
return;
|
2571
|
-
}
|
2572
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
2573
|
-
// so we should call onloadend on the next 'tick'
|
2574
|
-
setTimeout(onloadend);
|
2575
|
-
};
|
2576
|
-
}
|
2577
|
-
|
2578
|
-
// Handle browser request cancellation (as opposed to a manual cancellation)
|
2579
|
-
request.onabort = function handleAbort() {
|
2580
|
-
if (!request) {
|
2581
|
-
return;
|
2582
|
-
}
|
2583
|
-
|
2584
|
-
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
2585
|
-
|
2586
|
-
// Clean up request
|
2587
|
-
request = null;
|
2588
|
-
};
|
2589
|
-
|
2590
|
-
// Handle low level network errors
|
2591
|
-
request.onerror = function handleError() {
|
2592
|
-
// Real errors are hidden from us by the browser
|
2593
|
-
// onerror should only fire if it's a network error
|
2594
|
-
reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
2595
|
-
|
2596
|
-
// Clean up request
|
2597
|
-
request = null;
|
2598
|
-
};
|
2599
|
-
|
2600
|
-
// Handle timeout
|
2601
|
-
request.ontimeout = function handleTimeout() {
|
2602
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
2603
|
-
const transitional = _config.transitional || transitionalDefaults;
|
2604
|
-
if (_config.timeoutErrorMessage) {
|
2605
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
2606
|
-
}
|
2607
|
-
reject(new AxiosError$1(
|
2608
|
-
timeoutErrorMessage,
|
2609
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
2610
|
-
config,
|
2611
|
-
request));
|
2612
|
-
|
2613
|
-
// Clean up request
|
2614
|
-
request = null;
|
2615
|
-
};
|
2616
|
-
|
2617
|
-
// Remove Content-Type if data is undefined
|
2618
|
-
requestData === undefined && requestHeaders.setContentType(null);
|
2619
|
-
|
2620
|
-
// Add headers to the request
|
2621
|
-
if ('setRequestHeader' in request) {
|
2622
|
-
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
2623
|
-
request.setRequestHeader(key, val);
|
2624
|
-
});
|
2625
|
-
}
|
2626
|
-
|
2627
|
-
// Add withCredentials to request if needed
|
2628
|
-
if (!utils$1.isUndefined(_config.withCredentials)) {
|
2629
|
-
request.withCredentials = !!_config.withCredentials;
|
2630
|
-
}
|
2631
|
-
|
2632
|
-
// Add responseType to request if needed
|
2633
|
-
if (responseType && responseType !== 'json') {
|
2634
|
-
request.responseType = _config.responseType;
|
2635
|
-
}
|
2636
|
-
|
2637
|
-
// Handle progress if needed
|
2638
|
-
if (onDownloadProgress) {
|
2639
|
-
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
2640
|
-
request.addEventListener('progress', downloadThrottled);
|
2641
|
-
}
|
2642
|
-
|
2643
|
-
// Not all browsers support upload events
|
2644
|
-
if (onUploadProgress && request.upload) {
|
2645
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
2646
|
-
|
2647
|
-
request.upload.addEventListener('progress', uploadThrottled);
|
2648
|
-
|
2649
|
-
request.upload.addEventListener('loadend', flushUpload);
|
2650
|
-
}
|
2651
|
-
|
2652
|
-
if (_config.cancelToken || _config.signal) {
|
2653
|
-
// Handle cancellation
|
2654
|
-
// eslint-disable-next-line func-names
|
2655
|
-
onCanceled = cancel => {
|
2656
|
-
if (!request) {
|
2657
|
-
return;
|
2658
|
-
}
|
2659
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
2660
|
-
request.abort();
|
2661
|
-
request = null;
|
2662
|
-
};
|
2663
|
-
|
2664
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
2665
|
-
if (_config.signal) {
|
2666
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
2667
|
-
}
|
2668
|
-
}
|
2669
|
-
|
2670
|
-
const protocol = parseProtocol(_config.url);
|
2671
|
-
|
2672
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
2673
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
2674
|
-
return;
|
2675
|
-
}
|
2676
|
-
|
2677
|
-
|
2678
|
-
// Send the request
|
2679
|
-
request.send(requestData || null);
|
2680
|
-
});
|
2681
|
-
};
|
2682
|
-
|
2683
|
-
const composeSignals = (signals, timeout) => {
|
2684
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
2685
|
-
|
2686
|
-
if (timeout || length) {
|
2687
|
-
let controller = new AbortController();
|
2688
|
-
|
2689
|
-
let aborted;
|
2690
|
-
|
2691
|
-
const onabort = function (reason) {
|
2692
|
-
if (!aborted) {
|
2693
|
-
aborted = true;
|
2694
|
-
unsubscribe();
|
2695
|
-
const err = reason instanceof Error ? reason : this.reason;
|
2696
|
-
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
2697
|
-
}
|
2698
|
-
};
|
2699
|
-
|
2700
|
-
let timer = timeout && setTimeout(() => {
|
2701
|
-
timer = null;
|
2702
|
-
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
2703
|
-
}, timeout);
|
2704
|
-
|
2705
|
-
const unsubscribe = () => {
|
2706
|
-
if (signals) {
|
2707
|
-
timer && clearTimeout(timer);
|
2708
|
-
timer = null;
|
2709
|
-
signals.forEach(signal => {
|
2710
|
-
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
2711
|
-
});
|
2712
|
-
signals = null;
|
2713
|
-
}
|
2714
|
-
};
|
2715
|
-
|
2716
|
-
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
2717
|
-
|
2718
|
-
const {signal} = controller;
|
2719
|
-
|
2720
|
-
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
2721
|
-
|
2722
|
-
return signal;
|
2723
|
-
}
|
2724
|
-
};
|
2725
|
-
|
2726
|
-
const streamChunk = function* (chunk, chunkSize) {
|
2727
|
-
let len = chunk.byteLength;
|
2728
|
-
|
2729
|
-
if (!chunkSize || len < chunkSize) {
|
2730
|
-
yield chunk;
|
2731
|
-
return;
|
2732
|
-
}
|
2733
|
-
|
2734
|
-
let pos = 0;
|
2735
|
-
let end;
|
2736
|
-
|
2737
|
-
while (pos < len) {
|
2738
|
-
end = pos + chunkSize;
|
2739
|
-
yield chunk.slice(pos, end);
|
2740
|
-
pos = end;
|
2741
|
-
}
|
2742
|
-
};
|
2743
|
-
|
2744
|
-
const readBytes = async function* (iterable, chunkSize) {
|
2745
|
-
for await (const chunk of readStream(iterable)) {
|
2746
|
-
yield* streamChunk(chunk, chunkSize);
|
2747
|
-
}
|
2748
|
-
};
|
2749
|
-
|
2750
|
-
const readStream = async function* (stream) {
|
2751
|
-
if (stream[Symbol.asyncIterator]) {
|
2752
|
-
yield* stream;
|
2753
|
-
return;
|
2754
|
-
}
|
2755
|
-
|
2756
|
-
const reader = stream.getReader();
|
2757
|
-
try {
|
2758
|
-
for (;;) {
|
2759
|
-
const {done, value} = await reader.read();
|
2760
|
-
if (done) {
|
2761
|
-
break;
|
2762
|
-
}
|
2763
|
-
yield value;
|
2764
|
-
}
|
2765
|
-
} finally {
|
2766
|
-
await reader.cancel();
|
2767
|
-
}
|
2768
|
-
};
|
2769
|
-
|
2770
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
2771
|
-
const iterator = readBytes(stream, chunkSize);
|
2772
|
-
|
2773
|
-
let bytes = 0;
|
2774
|
-
let done;
|
2775
|
-
let _onFinish = (e) => {
|
2776
|
-
if (!done) {
|
2777
|
-
done = true;
|
2778
|
-
onFinish && onFinish(e);
|
2779
|
-
}
|
2780
|
-
};
|
2781
|
-
|
2782
|
-
return new ReadableStream({
|
2783
|
-
async pull(controller) {
|
2784
|
-
try {
|
2785
|
-
const {done, value} = await iterator.next();
|
2786
|
-
|
2787
|
-
if (done) {
|
2788
|
-
_onFinish();
|
2789
|
-
controller.close();
|
2790
|
-
return;
|
2791
|
-
}
|
2792
|
-
|
2793
|
-
let len = value.byteLength;
|
2794
|
-
if (onProgress) {
|
2795
|
-
let loadedBytes = bytes += len;
|
2796
|
-
onProgress(loadedBytes);
|
2797
|
-
}
|
2798
|
-
controller.enqueue(new Uint8Array(value));
|
2799
|
-
} catch (err) {
|
2800
|
-
_onFinish(err);
|
2801
|
-
throw err;
|
2802
|
-
}
|
2803
|
-
},
|
2804
|
-
cancel(reason) {
|
2805
|
-
_onFinish(reason);
|
2806
|
-
return iterator.return();
|
2807
|
-
}
|
2808
|
-
}, {
|
2809
|
-
highWaterMark: 2
|
2810
|
-
})
|
2811
|
-
};
|
2812
|
-
|
2813
|
-
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
2814
|
-
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
2815
|
-
|
2816
|
-
// used only inside the fetch adapter
|
2817
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
2818
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
2819
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
2820
|
-
);
|
2821
|
-
|
2822
|
-
const test = (fn, ...args) => {
|
2823
|
-
try {
|
2824
|
-
return !!fn(...args);
|
2825
|
-
} catch (e) {
|
2826
|
-
return false
|
2827
|
-
}
|
2828
|
-
};
|
2829
|
-
|
2830
|
-
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
2831
|
-
let duplexAccessed = false;
|
2832
|
-
|
2833
|
-
const hasContentType = new Request(platform.origin, {
|
2834
|
-
body: new ReadableStream(),
|
2835
|
-
method: 'POST',
|
2836
|
-
get duplex() {
|
2837
|
-
duplexAccessed = true;
|
2838
|
-
return 'half';
|
2839
|
-
},
|
2840
|
-
}).headers.has('Content-Type');
|
2841
|
-
|
2842
|
-
return duplexAccessed && !hasContentType;
|
2843
|
-
});
|
2844
|
-
|
2845
|
-
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
2846
|
-
|
2847
|
-
const supportsResponseStream = isReadableStreamSupported &&
|
2848
|
-
test(() => utils$1.isReadableStream(new Response('').body));
|
2849
|
-
|
2850
|
-
|
2851
|
-
const resolvers = {
|
2852
|
-
stream: supportsResponseStream && ((res) => res.body)
|
2853
|
-
};
|
2854
|
-
|
2855
|
-
isFetchSupported && (((res) => {
|
2856
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
2857
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
2858
|
-
(_, config) => {
|
2859
|
-
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
2860
|
-
});
|
2861
|
-
});
|
2862
|
-
})(new Response));
|
2863
|
-
|
2864
|
-
const getBodyLength = async (body) => {
|
2865
|
-
if (body == null) {
|
2866
|
-
return 0;
|
2867
|
-
}
|
2868
|
-
|
2869
|
-
if(utils$1.isBlob(body)) {
|
2870
|
-
return body.size;
|
2871
|
-
}
|
2872
|
-
|
2873
|
-
if(utils$1.isSpecCompliantForm(body)) {
|
2874
|
-
const _request = new Request(platform.origin, {
|
2875
|
-
method: 'POST',
|
2876
|
-
body,
|
2877
|
-
});
|
2878
|
-
return (await _request.arrayBuffer()).byteLength;
|
2879
|
-
}
|
2880
|
-
|
2881
|
-
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
2882
|
-
return body.byteLength;
|
2883
|
-
}
|
2884
|
-
|
2885
|
-
if(utils$1.isURLSearchParams(body)) {
|
2886
|
-
body = body + '';
|
2887
|
-
}
|
2888
|
-
|
2889
|
-
if(utils$1.isString(body)) {
|
2890
|
-
return (await encodeText(body)).byteLength;
|
2891
|
-
}
|
2892
|
-
};
|
2893
|
-
|
2894
|
-
const resolveBodyLength = async (headers, body) => {
|
2895
|
-
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
2896
|
-
|
2897
|
-
return length == null ? getBodyLength(body) : length;
|
2898
|
-
};
|
2899
|
-
|
2900
|
-
const fetchAdapter = isFetchSupported && (async (config) => {
|
2901
|
-
let {
|
2902
|
-
url,
|
2903
|
-
method,
|
2904
|
-
data,
|
2905
|
-
signal,
|
2906
|
-
cancelToken,
|
2907
|
-
timeout,
|
2908
|
-
onDownloadProgress,
|
2909
|
-
onUploadProgress,
|
2910
|
-
responseType,
|
2911
|
-
headers,
|
2912
|
-
withCredentials = 'same-origin',
|
2913
|
-
fetchOptions
|
2914
|
-
} = resolveConfig(config);
|
2915
|
-
|
2916
|
-
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
2917
|
-
|
2918
|
-
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
2919
|
-
|
2920
|
-
let request;
|
2921
|
-
|
2922
|
-
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
2923
|
-
composedSignal.unsubscribe();
|
2924
|
-
});
|
2925
|
-
|
2926
|
-
let requestContentLength;
|
2927
|
-
|
2928
|
-
try {
|
2929
|
-
if (
|
2930
|
-
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
2931
|
-
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
2932
|
-
) {
|
2933
|
-
let _request = new Request(url, {
|
2934
|
-
method: 'POST',
|
2935
|
-
body: data,
|
2936
|
-
duplex: "half"
|
2937
|
-
});
|
2938
|
-
|
2939
|
-
let contentTypeHeader;
|
2940
|
-
|
2941
|
-
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
2942
|
-
headers.setContentType(contentTypeHeader);
|
2943
|
-
}
|
2944
|
-
|
2945
|
-
if (_request.body) {
|
2946
|
-
const [onProgress, flush] = progressEventDecorator(
|
2947
|
-
requestContentLength,
|
2948
|
-
progressEventReducer(asyncDecorator(onUploadProgress))
|
2949
|
-
);
|
2950
|
-
|
2951
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
2952
|
-
}
|
2953
|
-
}
|
2954
|
-
|
2955
|
-
if (!utils$1.isString(withCredentials)) {
|
2956
|
-
withCredentials = withCredentials ? 'include' : 'omit';
|
2957
|
-
}
|
2958
|
-
|
2959
|
-
// Cloudflare Workers throws when credentials are defined
|
2960
|
-
// see https://github.com/cloudflare/workerd/issues/902
|
2961
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
2962
|
-
request = new Request(url, {
|
2963
|
-
...fetchOptions,
|
2964
|
-
signal: composedSignal,
|
2965
|
-
method: method.toUpperCase(),
|
2966
|
-
headers: headers.normalize().toJSON(),
|
2967
|
-
body: data,
|
2968
|
-
duplex: "half",
|
2969
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
2970
|
-
});
|
2971
|
-
|
2972
|
-
let response = await fetch(request);
|
2973
|
-
|
2974
|
-
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
2975
|
-
|
2976
|
-
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
2977
|
-
const options = {};
|
2978
|
-
|
2979
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
2980
|
-
options[prop] = response[prop];
|
2981
|
-
});
|
2982
|
-
|
2983
|
-
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
2984
|
-
|
2985
|
-
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
2986
|
-
responseContentLength,
|
2987
|
-
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
2988
|
-
) || [];
|
2989
|
-
|
2990
|
-
response = new Response(
|
2991
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
2992
|
-
flush && flush();
|
2993
|
-
unsubscribe && unsubscribe();
|
2994
|
-
}),
|
2995
|
-
options
|
2996
|
-
);
|
2997
|
-
}
|
2998
|
-
|
2999
|
-
responseType = responseType || 'text';
|
3000
|
-
|
3001
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
3002
|
-
|
3003
|
-
!isStreamResponse && unsubscribe && unsubscribe();
|
3004
|
-
|
3005
|
-
return await new Promise((resolve, reject) => {
|
3006
|
-
settle(resolve, reject, {
|
3007
|
-
data: responseData,
|
3008
|
-
headers: AxiosHeaders$1.from(response.headers),
|
3009
|
-
status: response.status,
|
3010
|
-
statusText: response.statusText,
|
3011
|
-
config,
|
3012
|
-
request
|
3013
|
-
});
|
3014
|
-
})
|
3015
|
-
} catch (err) {
|
3016
|
-
unsubscribe && unsubscribe();
|
3017
|
-
|
3018
|
-
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
3019
|
-
throw Object.assign(
|
3020
|
-
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
3021
|
-
{
|
3022
|
-
cause: err.cause || err
|
3023
|
-
}
|
3024
|
-
)
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
throw AxiosError$1.from(err, err && err.code, config, request);
|
3028
|
-
}
|
3029
|
-
});
|
3030
|
-
|
3031
|
-
const knownAdapters = {
|
3032
|
-
http: httpAdapter,
|
3033
|
-
xhr: xhrAdapter,
|
3034
|
-
fetch: fetchAdapter
|
3035
|
-
};
|
3036
|
-
|
3037
|
-
utils$1.forEach(knownAdapters, (fn, value) => {
|
3038
|
-
if (fn) {
|
3039
|
-
try {
|
3040
|
-
Object.defineProperty(fn, 'name', {value});
|
3041
|
-
} catch (e) {
|
3042
|
-
// eslint-disable-next-line no-empty
|
3043
|
-
}
|
3044
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
3045
|
-
}
|
3046
|
-
});
|
3047
|
-
|
3048
|
-
const renderReason = (reason) => `- ${reason}`;
|
3049
|
-
|
3050
|
-
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
3051
|
-
|
3052
|
-
const adapters = {
|
3053
|
-
getAdapter: (adapters) => {
|
3054
|
-
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
3055
|
-
|
3056
|
-
const {length} = adapters;
|
3057
|
-
let nameOrAdapter;
|
3058
|
-
let adapter;
|
3059
|
-
|
3060
|
-
const rejectedReasons = {};
|
3061
|
-
|
3062
|
-
for (let i = 0; i < length; i++) {
|
3063
|
-
nameOrAdapter = adapters[i];
|
3064
|
-
let id;
|
3065
|
-
|
3066
|
-
adapter = nameOrAdapter;
|
3067
|
-
|
3068
|
-
if (!isResolvedHandle(nameOrAdapter)) {
|
3069
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
3070
|
-
|
3071
|
-
if (adapter === undefined) {
|
3072
|
-
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
3073
|
-
}
|
3074
|
-
}
|
3075
|
-
|
3076
|
-
if (adapter) {
|
3077
|
-
break;
|
3078
|
-
}
|
3079
|
-
|
3080
|
-
rejectedReasons[id || '#' + i] = adapter;
|
3081
|
-
}
|
3082
|
-
|
3083
|
-
if (!adapter) {
|
3084
|
-
|
3085
|
-
const reasons = Object.entries(rejectedReasons)
|
3086
|
-
.map(([id, state]) => `adapter ${id} ` +
|
3087
|
-
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
3088
|
-
);
|
3089
|
-
|
3090
|
-
let s = length ?
|
3091
|
-
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
3092
|
-
'as no adapter specified';
|
3093
|
-
|
3094
|
-
throw new AxiosError$1(
|
3095
|
-
`There is no suitable adapter to dispatch the request ` + s,
|
3096
|
-
'ERR_NOT_SUPPORT'
|
3097
|
-
);
|
3098
|
-
}
|
3099
|
-
|
3100
|
-
return adapter;
|
3101
|
-
},
|
3102
|
-
adapters: knownAdapters
|
3103
|
-
};
|
3104
|
-
|
3105
|
-
'use strict';
|
3106
|
-
|
3107
|
-
/**
|
3108
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
3109
|
-
*
|
3110
|
-
* @param {Object} config The config that is to be used for the request
|
3111
|
-
*
|
3112
|
-
* @returns {void}
|
3113
|
-
*/
|
3114
|
-
function throwIfCancellationRequested(config) {
|
3115
|
-
if (config.cancelToken) {
|
3116
|
-
config.cancelToken.throwIfRequested();
|
3117
|
-
}
|
3118
|
-
|
3119
|
-
if (config.signal && config.signal.aborted) {
|
3120
|
-
throw new CanceledError$1(null, config);
|
3121
|
-
}
|
3122
|
-
}
|
3123
|
-
|
3124
|
-
/**
|
3125
|
-
* Dispatch a request to the server using the configured adapter.
|
3126
|
-
*
|
3127
|
-
* @param {object} config The config that is to be used for the request
|
3128
|
-
*
|
3129
|
-
* @returns {Promise} The Promise to be fulfilled
|
3130
|
-
*/
|
3131
|
-
function dispatchRequest(config) {
|
3132
|
-
throwIfCancellationRequested(config);
|
3133
|
-
|
3134
|
-
config.headers = AxiosHeaders$1.from(config.headers);
|
3135
|
-
|
3136
|
-
// Transform request data
|
3137
|
-
config.data = transformData.call(
|
3138
|
-
config,
|
3139
|
-
config.transformRequest
|
3140
|
-
);
|
3141
|
-
|
3142
|
-
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
3143
|
-
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
3144
|
-
}
|
3145
|
-
|
3146
|
-
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
3147
|
-
|
3148
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
3149
|
-
throwIfCancellationRequested(config);
|
3150
|
-
|
3151
|
-
// Transform response data
|
3152
|
-
response.data = transformData.call(
|
3153
|
-
config,
|
3154
|
-
config.transformResponse,
|
3155
|
-
response
|
3156
|
-
);
|
3157
|
-
|
3158
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
3159
|
-
|
3160
|
-
return response;
|
3161
|
-
}, function onAdapterRejection(reason) {
|
3162
|
-
if (!isCancel$1(reason)) {
|
3163
|
-
throwIfCancellationRequested(config);
|
3164
|
-
|
3165
|
-
// Transform response data
|
3166
|
-
if (reason && reason.response) {
|
3167
|
-
reason.response.data = transformData.call(
|
3168
|
-
config,
|
3169
|
-
config.transformResponse,
|
3170
|
-
reason.response
|
3171
|
-
);
|
3172
|
-
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
3173
|
-
}
|
3174
|
-
}
|
3175
|
-
|
3176
|
-
return Promise.reject(reason);
|
3177
|
-
});
|
3178
|
-
}
|
3179
|
-
|
3180
|
-
const VERSION$1 = "1.7.7";
|
3181
|
-
|
3182
|
-
'use strict';
|
3183
|
-
|
3184
|
-
const validators$1 = {};
|
3185
|
-
|
3186
|
-
// eslint-disable-next-line func-names
|
3187
|
-
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
|
3188
|
-
validators$1[type] = function validator(thing) {
|
3189
|
-
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
3190
|
-
};
|
3191
|
-
});
|
3192
|
-
|
3193
|
-
const deprecatedWarnings = {};
|
3194
|
-
|
3195
|
-
/**
|
3196
|
-
* Transitional option validator
|
3197
|
-
*
|
3198
|
-
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
3199
|
-
* @param {string?} version - deprecated version / removed since version
|
3200
|
-
* @param {string?} message - some message with additional info
|
3201
|
-
*
|
3202
|
-
* @returns {function}
|
3203
|
-
*/
|
3204
|
-
validators$1.transitional = function transitional(validator, version, message) {
|
3205
|
-
function formatMessage(opt, desc) {
|
3206
|
-
return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
3207
|
-
}
|
3208
|
-
|
3209
|
-
// eslint-disable-next-line func-names
|
3210
|
-
return (value, opt, opts) => {
|
3211
|
-
if (validator === false) {
|
3212
|
-
throw new AxiosError$1(
|
3213
|
-
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
3214
|
-
AxiosError$1.ERR_DEPRECATED
|
3215
|
-
);
|
3216
|
-
}
|
3217
|
-
|
3218
|
-
if (version && !deprecatedWarnings[opt]) {
|
3219
|
-
deprecatedWarnings[opt] = true;
|
3220
|
-
// eslint-disable-next-line no-console
|
3221
|
-
console.warn(
|
3222
|
-
formatMessage(
|
3223
|
-
opt,
|
3224
|
-
' has been deprecated since v' + version + ' and will be removed in the near future'
|
3225
|
-
)
|
3226
|
-
);
|
3227
|
-
}
|
3228
|
-
|
3229
|
-
return validator ? validator(value, opt, opts) : true;
|
3230
|
-
};
|
3231
|
-
};
|
3232
|
-
|
3233
|
-
/**
|
3234
|
-
* Assert object's properties type
|
3235
|
-
*
|
3236
|
-
* @param {object} options
|
3237
|
-
* @param {object} schema
|
3238
|
-
* @param {boolean?} allowUnknown
|
3239
|
-
*
|
3240
|
-
* @returns {object}
|
3241
|
-
*/
|
3242
|
-
|
3243
|
-
function assertOptions(options, schema, allowUnknown) {
|
3244
|
-
if (typeof options !== 'object') {
|
3245
|
-
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
3246
|
-
}
|
3247
|
-
const keys = Object.keys(options);
|
3248
|
-
let i = keys.length;
|
3249
|
-
while (i-- > 0) {
|
3250
|
-
const opt = keys[i];
|
3251
|
-
const validator = schema[opt];
|
3252
|
-
if (validator) {
|
3253
|
-
const value = options[opt];
|
3254
|
-
const result = value === undefined || validator(value, opt, options);
|
3255
|
-
if (result !== true) {
|
3256
|
-
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
3257
|
-
}
|
3258
|
-
continue;
|
3259
|
-
}
|
3260
|
-
if (allowUnknown !== true) {
|
3261
|
-
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
3262
|
-
}
|
3263
|
-
}
|
3264
|
-
}
|
3265
|
-
|
3266
|
-
const validator = {
|
3267
|
-
assertOptions,
|
3268
|
-
validators: validators$1
|
3269
|
-
};
|
3270
|
-
|
3271
|
-
'use strict';
|
3272
|
-
|
3273
|
-
const validators = validator.validators;
|
3274
|
-
|
3275
|
-
/**
|
3276
|
-
* Create a new instance of Axios
|
3277
|
-
*
|
3278
|
-
* @param {Object} instanceConfig The default config for the instance
|
3279
|
-
*
|
3280
|
-
* @return {Axios} A new instance of Axios
|
3281
|
-
*/
|
3282
|
-
class Axios$1 {
|
3283
|
-
constructor(instanceConfig) {
|
3284
|
-
this.defaults = instanceConfig;
|
3285
|
-
this.interceptors = {
|
3286
|
-
request: new InterceptorManager(),
|
3287
|
-
response: new InterceptorManager()
|
3288
|
-
};
|
3289
|
-
}
|
3290
|
-
|
3291
|
-
/**
|
3292
|
-
* Dispatch a request
|
3293
|
-
*
|
3294
|
-
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
3295
|
-
* @param {?Object} config
|
3296
|
-
*
|
3297
|
-
* @returns {Promise} The Promise to be fulfilled
|
3298
|
-
*/
|
3299
|
-
async request(configOrUrl, config) {
|
3300
|
-
try {
|
3301
|
-
return await this._request(configOrUrl, config);
|
3302
|
-
} catch (err) {
|
3303
|
-
if (err instanceof Error) {
|
3304
|
-
let dummy;
|
3305
|
-
|
3306
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
|
3307
|
-
|
3308
|
-
// slice off the Error: ... line
|
3309
|
-
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
3310
|
-
try {
|
3311
|
-
if (!err.stack) {
|
3312
|
-
err.stack = stack;
|
3313
|
-
// match without the 2 top stack lines
|
3314
|
-
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
3315
|
-
err.stack += '\n' + stack;
|
3316
|
-
}
|
3317
|
-
} catch (e) {
|
3318
|
-
// ignore the case where "stack" is an un-writable property
|
3319
|
-
}
|
3320
|
-
}
|
3321
|
-
|
3322
|
-
throw err;
|
3323
|
-
}
|
3324
|
-
}
|
3325
|
-
|
3326
|
-
_request(configOrUrl, config) {
|
3327
|
-
/*eslint no-param-reassign:0*/
|
3328
|
-
// Allow for axios('example/url'[, config]) a la fetch API
|
3329
|
-
if (typeof configOrUrl === 'string') {
|
3330
|
-
config = config || {};
|
3331
|
-
config.url = configOrUrl;
|
3332
|
-
} else {
|
3333
|
-
config = configOrUrl || {};
|
3334
|
-
}
|
3335
|
-
|
3336
|
-
config = mergeConfig$1(this.defaults, config);
|
3337
|
-
|
3338
|
-
const {transitional, paramsSerializer, headers} = config;
|
3339
|
-
|
3340
|
-
if (transitional !== undefined) {
|
3341
|
-
validator.assertOptions(transitional, {
|
3342
|
-
silentJSONParsing: validators.transitional(validators.boolean),
|
3343
|
-
forcedJSONParsing: validators.transitional(validators.boolean),
|
3344
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
3345
|
-
}, false);
|
3346
|
-
}
|
3347
|
-
|
3348
|
-
if (paramsSerializer != null) {
|
3349
|
-
if (utils$1.isFunction(paramsSerializer)) {
|
3350
|
-
config.paramsSerializer = {
|
3351
|
-
serialize: paramsSerializer
|
3352
|
-
};
|
3353
|
-
} else {
|
3354
|
-
validator.assertOptions(paramsSerializer, {
|
3355
|
-
encode: validators.function,
|
3356
|
-
serialize: validators.function
|
3357
|
-
}, true);
|
3358
|
-
}
|
3359
|
-
}
|
3360
|
-
|
3361
|
-
// Set config.method
|
3362
|
-
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
3363
|
-
|
3364
|
-
// Flatten headers
|
3365
|
-
let contextHeaders = headers && utils$1.merge(
|
3366
|
-
headers.common,
|
3367
|
-
headers[config.method]
|
3368
|
-
);
|
3369
|
-
|
3370
|
-
headers && utils$1.forEach(
|
3371
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
3372
|
-
(method) => {
|
3373
|
-
delete headers[method];
|
3374
|
-
}
|
3375
|
-
);
|
3376
|
-
|
3377
|
-
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
3378
|
-
|
3379
|
-
// filter out skipped interceptors
|
3380
|
-
const requestInterceptorChain = [];
|
3381
|
-
let synchronousRequestInterceptors = true;
|
3382
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
3383
|
-
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
3384
|
-
return;
|
3385
|
-
}
|
3386
|
-
|
3387
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
3388
|
-
|
3389
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
3390
|
-
});
|
3391
|
-
|
3392
|
-
const responseInterceptorChain = [];
|
3393
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
3394
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
3395
|
-
});
|
3396
|
-
|
3397
|
-
let promise;
|
3398
|
-
let i = 0;
|
3399
|
-
let len;
|
3400
|
-
|
3401
|
-
if (!synchronousRequestInterceptors) {
|
3402
|
-
const chain = [dispatchRequest.bind(this), undefined];
|
3403
|
-
chain.unshift.apply(chain, requestInterceptorChain);
|
3404
|
-
chain.push.apply(chain, responseInterceptorChain);
|
3405
|
-
len = chain.length;
|
3406
|
-
|
3407
|
-
promise = Promise.resolve(config);
|
3408
|
-
|
3409
|
-
while (i < len) {
|
3410
|
-
promise = promise.then(chain[i++], chain[i++]);
|
3411
|
-
}
|
3412
|
-
|
3413
|
-
return promise;
|
3414
|
-
}
|
3415
|
-
|
3416
|
-
len = requestInterceptorChain.length;
|
3417
|
-
|
3418
|
-
let newConfig = config;
|
3419
|
-
|
3420
|
-
i = 0;
|
3421
|
-
|
3422
|
-
while (i < len) {
|
3423
|
-
const onFulfilled = requestInterceptorChain[i++];
|
3424
|
-
const onRejected = requestInterceptorChain[i++];
|
3425
|
-
try {
|
3426
|
-
newConfig = onFulfilled(newConfig);
|
3427
|
-
} catch (error) {
|
3428
|
-
onRejected.call(this, error);
|
3429
|
-
break;
|
3430
|
-
}
|
3431
|
-
}
|
3432
|
-
|
3433
|
-
try {
|
3434
|
-
promise = dispatchRequest.call(this, newConfig);
|
3435
|
-
} catch (error) {
|
3436
|
-
return Promise.reject(error);
|
3437
|
-
}
|
3438
|
-
|
3439
|
-
i = 0;
|
3440
|
-
len = responseInterceptorChain.length;
|
3441
|
-
|
3442
|
-
while (i < len) {
|
3443
|
-
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
3444
|
-
}
|
3445
|
-
|
3446
|
-
return promise;
|
3447
|
-
}
|
3448
|
-
|
3449
|
-
getUri(config) {
|
3450
|
-
config = mergeConfig$1(this.defaults, config);
|
3451
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
3452
|
-
return buildURL(fullPath, config.params, config.paramsSerializer);
|
3453
|
-
}
|
3454
|
-
}
|
3455
|
-
|
3456
|
-
// Provide aliases for supported request methods
|
3457
|
-
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
3458
|
-
/*eslint func-names:0*/
|
3459
|
-
Axios$1.prototype[method] = function(url, config) {
|
3460
|
-
return this.request(mergeConfig$1(config || {}, {
|
3461
|
-
method,
|
3462
|
-
url,
|
3463
|
-
data: (config || {}).data
|
3464
|
-
}));
|
3465
|
-
};
|
3466
|
-
});
|
3467
|
-
|
3468
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
3469
|
-
/*eslint func-names:0*/
|
3470
|
-
|
3471
|
-
function generateHTTPMethod(isForm) {
|
3472
|
-
return function httpMethod(url, data, config) {
|
3473
|
-
return this.request(mergeConfig$1(config || {}, {
|
3474
|
-
method,
|
3475
|
-
headers: isForm ? {
|
3476
|
-
'Content-Type': 'multipart/form-data'
|
3477
|
-
} : {},
|
3478
|
-
url,
|
3479
|
-
data
|
3480
|
-
}));
|
3481
|
-
};
|
3482
|
-
}
|
3483
|
-
|
3484
|
-
Axios$1.prototype[method] = generateHTTPMethod();
|
3485
|
-
|
3486
|
-
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
3487
|
-
});
|
3488
|
-
|
3489
|
-
'use strict';
|
3490
|
-
|
3491
|
-
/**
|
3492
|
-
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
3493
|
-
*
|
3494
|
-
* @param {Function} executor The executor function.
|
3495
|
-
*
|
3496
|
-
* @returns {CancelToken}
|
3497
|
-
*/
|
3498
|
-
class CancelToken$1 {
|
3499
|
-
constructor(executor) {
|
3500
|
-
if (typeof executor !== 'function') {
|
3501
|
-
throw new TypeError('executor must be a function.');
|
3502
|
-
}
|
3503
|
-
|
3504
|
-
let resolvePromise;
|
3505
|
-
|
3506
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
3507
|
-
resolvePromise = resolve;
|
3508
|
-
});
|
3509
|
-
|
3510
|
-
const token = this;
|
3511
|
-
|
3512
|
-
// eslint-disable-next-line func-names
|
3513
|
-
this.promise.then(cancel => {
|
3514
|
-
if (!token._listeners) return;
|
3515
|
-
|
3516
|
-
let i = token._listeners.length;
|
3517
|
-
|
3518
|
-
while (i-- > 0) {
|
3519
|
-
token._listeners[i](cancel);
|
3520
|
-
}
|
3521
|
-
token._listeners = null;
|
3522
|
-
});
|
3523
|
-
|
3524
|
-
// eslint-disable-next-line func-names
|
3525
|
-
this.promise.then = onfulfilled => {
|
3526
|
-
let _resolve;
|
3527
|
-
// eslint-disable-next-line func-names
|
3528
|
-
const promise = new Promise(resolve => {
|
3529
|
-
token.subscribe(resolve);
|
3530
|
-
_resolve = resolve;
|
3531
|
-
}).then(onfulfilled);
|
3532
|
-
|
3533
|
-
promise.cancel = function reject() {
|
3534
|
-
token.unsubscribe(_resolve);
|
3535
|
-
};
|
3536
|
-
|
3537
|
-
return promise;
|
3538
|
-
};
|
3539
|
-
|
3540
|
-
executor(function cancel(message, config, request) {
|
3541
|
-
if (token.reason) {
|
3542
|
-
// Cancellation has already been requested
|
3543
|
-
return;
|
3544
|
-
}
|
3545
|
-
|
3546
|
-
token.reason = new CanceledError$1(message, config, request);
|
3547
|
-
resolvePromise(token.reason);
|
3548
|
-
});
|
3549
|
-
}
|
3550
|
-
|
3551
|
-
/**
|
3552
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
3553
|
-
*/
|
3554
|
-
throwIfRequested() {
|
3555
|
-
if (this.reason) {
|
3556
|
-
throw this.reason;
|
3557
|
-
}
|
3558
|
-
}
|
3559
|
-
|
3560
|
-
/**
|
3561
|
-
* Subscribe to the cancel signal
|
3562
|
-
*/
|
3563
|
-
|
3564
|
-
subscribe(listener) {
|
3565
|
-
if (this.reason) {
|
3566
|
-
listener(this.reason);
|
3567
|
-
return;
|
3568
|
-
}
|
3569
|
-
|
3570
|
-
if (this._listeners) {
|
3571
|
-
this._listeners.push(listener);
|
3572
|
-
} else {
|
3573
|
-
this._listeners = [listener];
|
3574
|
-
}
|
3575
|
-
}
|
3576
|
-
|
3577
|
-
/**
|
3578
|
-
* Unsubscribe from the cancel signal
|
3579
|
-
*/
|
3580
|
-
|
3581
|
-
unsubscribe(listener) {
|
3582
|
-
if (!this._listeners) {
|
3583
|
-
return;
|
3584
|
-
}
|
3585
|
-
const index = this._listeners.indexOf(listener);
|
3586
|
-
if (index !== -1) {
|
3587
|
-
this._listeners.splice(index, 1);
|
3588
|
-
}
|
3589
|
-
}
|
3590
|
-
|
3591
|
-
toAbortSignal() {
|
3592
|
-
const controller = new AbortController();
|
3593
|
-
|
3594
|
-
const abort = (err) => {
|
3595
|
-
controller.abort(err);
|
3596
|
-
};
|
3597
|
-
|
3598
|
-
this.subscribe(abort);
|
3599
|
-
|
3600
|
-
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
3601
|
-
|
3602
|
-
return controller.signal;
|
3603
|
-
}
|
3604
|
-
|
3605
|
-
/**
|
3606
|
-
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
3607
|
-
* cancels the `CancelToken`.
|
3608
|
-
*/
|
3609
|
-
static source() {
|
3610
|
-
let cancel;
|
3611
|
-
const token = new CancelToken$1(function executor(c) {
|
3612
|
-
cancel = c;
|
3613
|
-
});
|
3614
|
-
return {
|
3615
|
-
token,
|
3616
|
-
cancel
|
3617
|
-
};
|
3618
|
-
}
|
3619
|
-
}
|
3620
|
-
|
3621
|
-
'use strict';
|
3622
|
-
|
3623
|
-
/**
|
3624
|
-
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
3625
|
-
*
|
3626
|
-
* Common use case would be to use `Function.prototype.apply`.
|
3627
|
-
*
|
3628
|
-
* ```js
|
3629
|
-
* function f(x, y, z) {}
|
3630
|
-
* var args = [1, 2, 3];
|
3631
|
-
* f.apply(null, args);
|
3632
|
-
* ```
|
3633
|
-
*
|
3634
|
-
* With `spread` this example can be re-written.
|
3635
|
-
*
|
3636
|
-
* ```js
|
3637
|
-
* spread(function(x, y, z) {})([1, 2, 3]);
|
3638
|
-
* ```
|
3639
|
-
*
|
3640
|
-
* @param {Function} callback
|
3641
|
-
*
|
3642
|
-
* @returns {Function}
|
3643
|
-
*/
|
3644
|
-
function spread$1(callback) {
|
3645
|
-
return function wrap(arr) {
|
3646
|
-
return callback.apply(null, arr);
|
3647
|
-
};
|
3648
|
-
}
|
3649
|
-
|
3650
|
-
'use strict';
|
3651
|
-
|
3652
|
-
/**
|
3653
|
-
* Determines whether the payload is an error thrown by Axios
|
3654
|
-
*
|
3655
|
-
* @param {*} payload The value to test
|
3656
|
-
*
|
3657
|
-
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
3658
|
-
*/
|
3659
|
-
function isAxiosError$1(payload) {
|
3660
|
-
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
3661
|
-
}
|
3662
|
-
|
3663
|
-
const HttpStatusCode$1 = {
|
3664
|
-
Continue: 100,
|
3665
|
-
SwitchingProtocols: 101,
|
3666
|
-
Processing: 102,
|
3667
|
-
EarlyHints: 103,
|
3668
|
-
Ok: 200,
|
3669
|
-
Created: 201,
|
3670
|
-
Accepted: 202,
|
3671
|
-
NonAuthoritativeInformation: 203,
|
3672
|
-
NoContent: 204,
|
3673
|
-
ResetContent: 205,
|
3674
|
-
PartialContent: 206,
|
3675
|
-
MultiStatus: 207,
|
3676
|
-
AlreadyReported: 208,
|
3677
|
-
ImUsed: 226,
|
3678
|
-
MultipleChoices: 300,
|
3679
|
-
MovedPermanently: 301,
|
3680
|
-
Found: 302,
|
3681
|
-
SeeOther: 303,
|
3682
|
-
NotModified: 304,
|
3683
|
-
UseProxy: 305,
|
3684
|
-
Unused: 306,
|
3685
|
-
TemporaryRedirect: 307,
|
3686
|
-
PermanentRedirect: 308,
|
3687
|
-
BadRequest: 400,
|
3688
|
-
Unauthorized: 401,
|
3689
|
-
PaymentRequired: 402,
|
3690
|
-
Forbidden: 403,
|
3691
|
-
NotFound: 404,
|
3692
|
-
MethodNotAllowed: 405,
|
3693
|
-
NotAcceptable: 406,
|
3694
|
-
ProxyAuthenticationRequired: 407,
|
3695
|
-
RequestTimeout: 408,
|
3696
|
-
Conflict: 409,
|
3697
|
-
Gone: 410,
|
3698
|
-
LengthRequired: 411,
|
3699
|
-
PreconditionFailed: 412,
|
3700
|
-
PayloadTooLarge: 413,
|
3701
|
-
UriTooLong: 414,
|
3702
|
-
UnsupportedMediaType: 415,
|
3703
|
-
RangeNotSatisfiable: 416,
|
3704
|
-
ExpectationFailed: 417,
|
3705
|
-
ImATeapot: 418,
|
3706
|
-
MisdirectedRequest: 421,
|
3707
|
-
UnprocessableEntity: 422,
|
3708
|
-
Locked: 423,
|
3709
|
-
FailedDependency: 424,
|
3710
|
-
TooEarly: 425,
|
3711
|
-
UpgradeRequired: 426,
|
3712
|
-
PreconditionRequired: 428,
|
3713
|
-
TooManyRequests: 429,
|
3714
|
-
RequestHeaderFieldsTooLarge: 431,
|
3715
|
-
UnavailableForLegalReasons: 451,
|
3716
|
-
InternalServerError: 500,
|
3717
|
-
NotImplemented: 501,
|
3718
|
-
BadGateway: 502,
|
3719
|
-
ServiceUnavailable: 503,
|
3720
|
-
GatewayTimeout: 504,
|
3721
|
-
HttpVersionNotSupported: 505,
|
3722
|
-
VariantAlsoNegotiates: 506,
|
3723
|
-
InsufficientStorage: 507,
|
3724
|
-
LoopDetected: 508,
|
3725
|
-
NotExtended: 510,
|
3726
|
-
NetworkAuthenticationRequired: 511,
|
3727
|
-
};
|
3728
|
-
|
3729
|
-
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
3730
|
-
HttpStatusCode$1[value] = key;
|
3731
|
-
});
|
3732
|
-
|
3733
|
-
'use strict';
|
3734
|
-
|
3735
|
-
/**
|
3736
|
-
* Create an instance of Axios
|
3737
|
-
*
|
3738
|
-
* @param {Object} defaultConfig The default config for the instance
|
3739
|
-
*
|
3740
|
-
* @returns {Axios} A new instance of Axios
|
3741
|
-
*/
|
3742
|
-
function createInstance(defaultConfig) {
|
3743
|
-
const context = new Axios$1(defaultConfig);
|
3744
|
-
const instance = bind(Axios$1.prototype.request, context);
|
3745
|
-
|
3746
|
-
// Copy axios.prototype to instance
|
3747
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
3748
|
-
|
3749
|
-
// Copy context to instance
|
3750
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
3751
|
-
|
3752
|
-
// Factory for creating new instances
|
3753
|
-
instance.create = function create(instanceConfig) {
|
3754
|
-
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
3755
|
-
};
|
3756
|
-
|
3757
|
-
return instance;
|
3758
|
-
}
|
3759
|
-
|
3760
|
-
// Create the default instance to be exported
|
3761
|
-
const axios = createInstance(defaults);
|
3762
|
-
|
3763
|
-
// Expose Axios class to allow class inheritance
|
3764
|
-
axios.Axios = Axios$1;
|
3765
|
-
|
3766
|
-
// Expose Cancel & CancelToken
|
3767
|
-
axios.CanceledError = CanceledError$1;
|
3768
|
-
axios.CancelToken = CancelToken$1;
|
3769
|
-
axios.isCancel = isCancel$1;
|
3770
|
-
axios.VERSION = VERSION$1;
|
3771
|
-
axios.toFormData = toFormData$1;
|
3772
|
-
|
3773
|
-
// Expose AxiosError class
|
3774
|
-
axios.AxiosError = AxiosError$1;
|
3775
|
-
|
3776
|
-
// alias for CanceledError for backward compatibility
|
3777
|
-
axios.Cancel = axios.CanceledError;
|
3778
|
-
|
3779
|
-
// Expose all/spread
|
3780
|
-
axios.all = function all(promises) {
|
3781
|
-
return Promise.all(promises);
|
3782
|
-
};
|
3783
|
-
|
3784
|
-
axios.spread = spread$1;
|
3785
|
-
|
3786
|
-
// Expose isAxiosError
|
3787
|
-
axios.isAxiosError = isAxiosError$1;
|
3788
|
-
|
3789
|
-
// Expose mergeConfig
|
3790
|
-
axios.mergeConfig = mergeConfig$1;
|
3791
|
-
|
3792
|
-
axios.AxiosHeaders = AxiosHeaders$1;
|
3793
|
-
|
3794
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3795
|
-
|
3796
|
-
axios.getAdapter = adapters.getAdapter;
|
3797
|
-
|
3798
|
-
axios.HttpStatusCode = HttpStatusCode$1;
|
3799
|
-
|
3800
|
-
axios.default = axios;
|
3801
|
-
|
3802
|
-
// This module is intended to unwrap Axios default export as named.
|
3803
|
-
// Keep top-level export same with static properties
|
3804
|
-
// so that it can keep same with es module or cjs
|
3805
|
-
const {
|
3806
|
-
Axios,
|
3807
|
-
AxiosError,
|
3808
|
-
CanceledError,
|
3809
|
-
isCancel,
|
3810
|
-
CancelToken,
|
3811
|
-
VERSION,
|
3812
|
-
all,
|
3813
|
-
Cancel,
|
3814
|
-
isAxiosError,
|
3815
|
-
spread,
|
3816
|
-
toFormData,
|
3817
|
-
AxiosHeaders,
|
3818
|
-
HttpStatusCode,
|
3819
|
-
formToJSON,
|
3820
|
-
getAdapter,
|
3821
|
-
mergeConfig
|
3822
|
-
} = axios;
|
3823
|
-
|
3824
|
-
const CRM_BONUS_API_URL = "https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
|
3825
|
-
const CRM_BONUS_ID_LOJA = "undefined";
|
3826
|
-
const CRM_BONUS_CODEMPRESA = "undefined";
|
3827
|
-
const CRM_BONUS_AUTHORIZATION = "undefined";
|
3828
|
-
|
3829
|
-
class CrmBonusService {
|
3830
|
-
constructor() {
|
3831
|
-
this.axiosInstance = axios.create({
|
3832
|
-
baseURL: CRM_BONUS_API_URL,
|
3833
|
-
headers: {
|
3834
|
-
'Content-Type': 'application/json',
|
3835
|
-
'accept': 'application/json',
|
3836
|
-
},
|
3837
|
-
});
|
3838
|
-
}
|
3839
|
-
async getCustomer(userId, store) {
|
3840
|
-
const response = await this.axiosInstance.put(`/api/wake/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } });
|
3841
|
-
console.log('response.data', response.data);
|
3842
|
-
return response.data;
|
3843
|
-
}
|
3844
|
-
async updateOrder(cartId, orderId) {
|
3845
|
-
const response = await this.axiosInstance.post(`/api/update_cart/${cartId}`, { orderId }, { headers: { 'Content-Type': 'application/json' } });
|
3846
|
-
console.log('response', response.data);
|
3847
|
-
}
|
3848
|
-
async sendPin(phone, store) {
|
3849
|
-
const response = await this.axiosInstance.post("/api/crm-bonus/send-pin", { celular: phone, nome: "giftback" }, { headers: { store } });
|
3850
|
-
return {
|
3851
|
-
storeId: response.data.store_id,
|
3852
|
-
userId: response.data.user_id
|
3853
|
-
};
|
3854
|
-
}
|
3855
|
-
async validatePinBonus(payload, store) {
|
3856
|
-
console.log('[validatePinBonus]', payload);
|
3857
|
-
const response = await this.axiosInstance.post("/api/crm-bonus/process-pin-bonus", payload, { headers: { store } });
|
3858
|
-
return response.data;
|
3859
|
-
}
|
3860
|
-
async reserve(payload, store) {
|
3861
|
-
const response = await this.axiosInstance.post("/api/crm-bonus/redeem-bonus", payload, { headers: { store } });
|
3862
|
-
return response.data;
|
3863
|
-
}
|
3864
|
-
}
|
3865
|
-
|
3866
|
-
export { CrmBonusService as C };
|
3867
|
-
|
3868
|
-
//# sourceMappingURL=crmbonus.service-a0dea046.js.map
|