@flatfile/listener 0.3.16 → 0.3.17

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