@kontent-ai/core-sdk 10.5.0 → 10.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
899
899
  \***************************************************/
900
900
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
901
901
 
902
- // Axios v1.6.8 Copyright (c) 2024 Matt Zabriskie and contributors
902
+ // Axios v1.7.4 Copyright (c) 2024 Matt Zabriskie and contributors
903
903
 
904
904
 
905
905
  function bind(fn, thisArg) {
@@ -1115,6 +1115,8 @@ const isFormData = (thing) => {
1115
1115
  */
1116
1116
  const isURLSearchParams = kindOfTest('URLSearchParams');
1117
1117
 
1118
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
1119
+
1118
1120
  /**
1119
1121
  * Trim excess whitespace off the beginning and end of a string
1120
1122
  *
@@ -1503,8 +1505,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
1503
1505
  const noop = () => {};
1504
1506
 
1505
1507
  const toFiniteNumber = (value, defaultValue) => {
1506
- value = +value;
1507
- return Number.isFinite(value) ? value : defaultValue;
1508
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
1508
1509
  };
1509
1510
 
1510
1511
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -1574,6 +1575,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
1574
1575
  const isThenable = (thing) =>
1575
1576
  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
1576
1577
 
1578
+ // original code
1579
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
1580
+
1581
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1582
+ if (setImmediateSupported) {
1583
+ return setImmediate;
1584
+ }
1585
+
1586
+ return postMessageSupported ? ((token, callbacks) => {
1587
+ _global.addEventListener("message", ({source, data}) => {
1588
+ if (source === _global && data === token) {
1589
+ callbacks.length && callbacks.shift()();
1590
+ }
1591
+ }, false);
1592
+
1593
+ return (cb) => {
1594
+ callbacks.push(cb);
1595
+ _global.postMessage(token, "*");
1596
+ }
1597
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
1598
+ })(
1599
+ typeof setImmediate === 'function',
1600
+ isFunction(_global.postMessage)
1601
+ );
1602
+
1603
+ const asap = typeof queueMicrotask !== 'undefined' ?
1604
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
1605
+
1606
+ // *********************
1607
+
1577
1608
  var utils$1 = {
1578
1609
  isArray,
1579
1610
  isArrayBuffer,
@@ -1585,6 +1616,10 @@ var utils$1 = {
1585
1616
  isBoolean,
1586
1617
  isObject,
1587
1618
  isPlainObject,
1619
+ isReadableStream,
1620
+ isRequest,
1621
+ isResponse,
1622
+ isHeaders,
1588
1623
  isUndefined,
1589
1624
  isDate,
1590
1625
  isFile,
@@ -1625,7 +1660,9 @@ var utils$1 = {
1625
1660
  isSpecCompliantForm,
1626
1661
  toJSONObject,
1627
1662
  isAsyncFn,
1628
- isThenable
1663
+ isThenable,
1664
+ setImmediate: _setImmediate,
1665
+ asap
1629
1666
  };
1630
1667
 
1631
1668
  /**
@@ -2181,11 +2218,14 @@ const hasStandardBrowserWebWorkerEnv = (() => {
2181
2218
  );
2182
2219
  })();
2183
2220
 
2221
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
2222
+
2184
2223
  var utils = /*#__PURE__*/Object.freeze({
2185
2224
  __proto__: null,
2186
2225
  hasBrowserEnv: hasBrowserEnv,
2187
2226
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2188
- hasStandardBrowserEnv: hasStandardBrowserEnv
2227
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2228
+ origin: origin
2189
2229
  });
2190
2230
 
2191
2231
  var platform = {
@@ -2325,7 +2365,7 @@ const defaults = {
2325
2365
 
2326
2366
  transitional: transitionalDefaults,
2327
2367
 
2328
- adapter: ['xhr', 'http'],
2368
+ adapter: ['xhr', 'http', 'fetch'],
2329
2369
 
2330
2370
  transformRequest: [function transformRequest(data, headers) {
2331
2371
  const contentType = headers.getContentType() || '';
@@ -2346,7 +2386,8 @@ const defaults = {
2346
2386
  utils$1.isBuffer(data) ||
2347
2387
  utils$1.isStream(data) ||
2348
2388
  utils$1.isFile(data) ||
2349
- utils$1.isBlob(data)
2389
+ utils$1.isBlob(data) ||
2390
+ utils$1.isReadableStream(data)
2350
2391
  ) {
2351
2392
  return data;
2352
2393
  }
@@ -2389,6 +2430,10 @@ const defaults = {
2389
2430
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2390
2431
  const JSONRequested = this.responseType === 'json';
2391
2432
 
2433
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2434
+ return data;
2435
+ }
2436
+
2392
2437
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
2393
2438
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
2394
2439
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -2592,6 +2637,10 @@ class AxiosHeaders {
2592
2637
  setHeaders(header, valueOrRewrite);
2593
2638
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2594
2639
  setHeaders(parseHeaders(header), valueOrRewrite);
2640
+ } else if (utils$1.isHeaders(header)) {
2641
+ for (const [key, value] of header.entries()) {
2642
+ setHeader(value, key, rewrite);
2643
+ }
2595
2644
  } else {
2596
2645
  header != null && setHeader(valueOrRewrite, header, rewrite);
2597
2646
  }
@@ -2859,90 +2908,147 @@ function settle(resolve, reject, response) {
2859
2908
  }
2860
2909
  }
2861
2910
 
2862
- var cookies = platform.hasStandardBrowserEnv ?
2911
+ function parseProtocol(url) {
2912
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2913
+ return match && match[1] || '';
2914
+ }
2863
2915
 
2864
- // Standard browser envs support document.cookie
2865
- {
2866
- write(name, value, expires, path, domain, secure) {
2867
- const cookie = [name + '=' + encodeURIComponent(value)];
2916
+ /**
2917
+ * Calculate data maxRate
2918
+ * @param {Number} [samplesCount= 10]
2919
+ * @param {Number} [min= 1000]
2920
+ * @returns {Function}
2921
+ */
2922
+ function speedometer(samplesCount, min) {
2923
+ samplesCount = samplesCount || 10;
2924
+ const bytes = new Array(samplesCount);
2925
+ const timestamps = new Array(samplesCount);
2926
+ let head = 0;
2927
+ let tail = 0;
2928
+ let firstSampleTS;
2868
2929
 
2869
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2930
+ min = min !== undefined ? min : 1000;
2870
2931
 
2871
- utils$1.isString(path) && cookie.push('path=' + path);
2932
+ return function push(chunkLength) {
2933
+ const now = Date.now();
2872
2934
 
2873
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2935
+ const startedAt = timestamps[tail];
2874
2936
 
2875
- secure === true && cookie.push('secure');
2937
+ if (!firstSampleTS) {
2938
+ firstSampleTS = now;
2939
+ }
2876
2940
 
2877
- document.cookie = cookie.join('; ');
2878
- },
2941
+ bytes[head] = chunkLength;
2942
+ timestamps[head] = now;
2879
2943
 
2880
- read(name) {
2881
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2882
- return (match ? decodeURIComponent(match[3]) : null);
2883
- },
2944
+ let i = tail;
2945
+ let bytesCount = 0;
2884
2946
 
2885
- remove(name) {
2886
- this.write(name, '', Date.now() - 86400000);
2947
+ while (i !== head) {
2948
+ bytesCount += bytes[i++];
2949
+ i = i % samplesCount;
2887
2950
  }
2888
- }
2889
2951
 
2890
- :
2952
+ head = (head + 1) % samplesCount;
2891
2953
 
2892
- // Non-standard browser env (web workers, react-native) lack needed support.
2893
- {
2894
- write() {},
2895
- read() {
2896
- return null;
2897
- },
2898
- remove() {}
2899
- };
2954
+ if (head === tail) {
2955
+ tail = (tail + 1) % samplesCount;
2956
+ }
2900
2957
 
2901
- /**
2902
- * Determines whether the specified URL is absolute
2903
- *
2904
- * @param {string} url The URL to test
2905
- *
2906
- * @returns {boolean} True if the specified URL is absolute, otherwise false
2907
- */
2908
- function isAbsoluteURL(url) {
2909
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2910
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2911
- // by any combination of letters, digits, plus, period, or hyphen.
2912
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2913
- }
2958
+ if (now - firstSampleTS < min) {
2959
+ return;
2960
+ }
2914
2961
 
2915
- /**
2916
- * Creates a new URL by combining the specified URLs
2917
- *
2918
- * @param {string} baseURL The base URL
2919
- * @param {string} relativeURL The relative URL
2920
- *
2921
- * @returns {string} The combined URL
2922
- */
2923
- function combineURLs(baseURL, relativeURL) {
2924
- return relativeURL
2925
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2926
- : baseURL;
2962
+ const passed = startedAt && now - startedAt;
2963
+
2964
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2965
+ };
2927
2966
  }
2928
2967
 
2929
2968
  /**
2930
- * Creates a new URL by combining the baseURL with the requestedURL,
2931
- * only when the requestedURL is not already an absolute URL.
2932
- * If the requestURL is absolute, this function returns the requestedURL untouched.
2933
- *
2934
- * @param {string} baseURL The base URL
2935
- * @param {string} requestedURL Absolute or relative URL to combine
2936
- *
2937
- * @returns {string} The combined full path
2969
+ * Throttle decorator
2970
+ * @param {Function} fn
2971
+ * @param {Number} freq
2972
+ * @return {Function}
2938
2973
  */
2939
- function buildFullPath(baseURL, requestedURL) {
2940
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2941
- return combineURLs(baseURL, requestedURL);
2942
- }
2943
- return requestedURL;
2974
+ function throttle(fn, freq) {
2975
+ let timestamp = 0;
2976
+ let threshold = 1000 / freq;
2977
+ let lastArgs;
2978
+ let timer;
2979
+
2980
+ const invoke = (args, now = Date.now()) => {
2981
+ timestamp = now;
2982
+ lastArgs = null;
2983
+ if (timer) {
2984
+ clearTimeout(timer);
2985
+ timer = null;
2986
+ }
2987
+ fn.apply(null, args);
2988
+ };
2989
+
2990
+ const throttled = (...args) => {
2991
+ const now = Date.now();
2992
+ const passed = now - timestamp;
2993
+ if ( passed >= threshold) {
2994
+ invoke(args, now);
2995
+ } else {
2996
+ lastArgs = args;
2997
+ if (!timer) {
2998
+ timer = setTimeout(() => {
2999
+ timer = null;
3000
+ invoke(lastArgs);
3001
+ }, threshold - passed);
3002
+ }
3003
+ }
3004
+ };
3005
+
3006
+ const flush = () => lastArgs && invoke(lastArgs);
3007
+
3008
+ return [throttled, flush];
2944
3009
  }
2945
3010
 
3011
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
3012
+ let bytesNotified = 0;
3013
+ const _speedometer = speedometer(50, 250);
3014
+
3015
+ return throttle(e => {
3016
+ const loaded = e.loaded;
3017
+ const total = e.lengthComputable ? e.total : undefined;
3018
+ const progressBytes = loaded - bytesNotified;
3019
+ const rate = _speedometer(progressBytes);
3020
+ const inRange = loaded <= total;
3021
+
3022
+ bytesNotified = loaded;
3023
+
3024
+ const data = {
3025
+ loaded,
3026
+ total,
3027
+ progress: total ? (loaded / total) : undefined,
3028
+ bytes: progressBytes,
3029
+ rate: rate ? rate : undefined,
3030
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
3031
+ event: e,
3032
+ lengthComputable: total != null,
3033
+ [isDownloadStream ? 'download' : 'upload']: true
3034
+ };
3035
+
3036
+ listener(data);
3037
+ }, freq);
3038
+ };
3039
+
3040
+ const progressEventDecorator = (total, throttled) => {
3041
+ const lengthComputable = total != null;
3042
+
3043
+ return [(loaded) => throttled[0]({
3044
+ lengthComputable,
3045
+ total,
3046
+ loaded
3047
+ }), throttled[1]];
3048
+ };
3049
+
3050
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
3051
+
2946
3052
  var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2947
3053
 
2948
3054
  // Standard browser envs have full support of the APIs needed to test
@@ -3006,137 +3112,267 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
3006
3112
  };
3007
3113
  })();
3008
3114
 
3009
- function parseProtocol(url) {
3010
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
3011
- return match && match[1] || '';
3012
- }
3013
-
3014
- /**
3015
- * Calculate data maxRate
3016
- * @param {Number} [samplesCount= 10]
3017
- * @param {Number} [min= 1000]
3018
- * @returns {Function}
3019
- */
3020
- function speedometer(samplesCount, min) {
3021
- samplesCount = samplesCount || 10;
3022
- const bytes = new Array(samplesCount);
3023
- const timestamps = new Array(samplesCount);
3024
- let head = 0;
3025
- let tail = 0;
3026
- let firstSampleTS;
3027
-
3028
- min = min !== undefined ? min : 1000;
3029
-
3030
- return function push(chunkLength) {
3031
- const now = Date.now();
3115
+ var cookies = platform.hasStandardBrowserEnv ?
3032
3116
 
3033
- const startedAt = timestamps[tail];
3117
+ // Standard browser envs support document.cookie
3118
+ {
3119
+ write(name, value, expires, path, domain, secure) {
3120
+ const cookie = [name + '=' + encodeURIComponent(value)];
3034
3121
 
3035
- if (!firstSampleTS) {
3036
- firstSampleTS = now;
3037
- }
3122
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
3038
3123
 
3039
- bytes[head] = chunkLength;
3040
- timestamps[head] = now;
3124
+ utils$1.isString(path) && cookie.push('path=' + path);
3041
3125
 
3042
- let i = tail;
3043
- let bytesCount = 0;
3126
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
3044
3127
 
3045
- while (i !== head) {
3046
- bytesCount += bytes[i++];
3047
- i = i % samplesCount;
3048
- }
3128
+ secure === true && cookie.push('secure');
3049
3129
 
3050
- head = (head + 1) % samplesCount;
3130
+ document.cookie = cookie.join('; ');
3131
+ },
3051
3132
 
3052
- if (head === tail) {
3053
- tail = (tail + 1) % samplesCount;
3054
- }
3133
+ read(name) {
3134
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
3135
+ return (match ? decodeURIComponent(match[3]) : null);
3136
+ },
3055
3137
 
3056
- if (now - firstSampleTS < min) {
3057
- return;
3138
+ remove(name) {
3139
+ this.write(name, '', Date.now() - 86400000);
3058
3140
  }
3141
+ }
3059
3142
 
3060
- const passed = startedAt && now - startedAt;
3143
+ :
3061
3144
 
3062
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
3145
+ // Non-standard browser env (web workers, react-native) lack needed support.
3146
+ {
3147
+ write() {},
3148
+ read() {
3149
+ return null;
3150
+ },
3151
+ remove() {}
3063
3152
  };
3153
+
3154
+ /**
3155
+ * Determines whether the specified URL is absolute
3156
+ *
3157
+ * @param {string} url The URL to test
3158
+ *
3159
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
3160
+ */
3161
+ function isAbsoluteURL(url) {
3162
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
3163
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
3164
+ // by any combination of letters, digits, plus, period, or hyphen.
3165
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
3064
3166
  }
3065
3167
 
3066
- function progressEventReducer(listener, isDownloadStream) {
3067
- let bytesNotified = 0;
3068
- const _speedometer = speedometer(50, 250);
3168
+ /**
3169
+ * Creates a new URL by combining the specified URLs
3170
+ *
3171
+ * @param {string} baseURL The base URL
3172
+ * @param {string} relativeURL The relative URL
3173
+ *
3174
+ * @returns {string} The combined URL
3175
+ */
3176
+ function combineURLs(baseURL, relativeURL) {
3177
+ return relativeURL
3178
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3179
+ : baseURL;
3180
+ }
3069
3181
 
3070
- return e => {
3071
- const loaded = e.loaded;
3072
- const total = e.lengthComputable ? e.total : undefined;
3073
- const progressBytes = loaded - bytesNotified;
3074
- const rate = _speedometer(progressBytes);
3075
- const inRange = loaded <= total;
3182
+ /**
3183
+ * Creates a new URL by combining the baseURL with the requestedURL,
3184
+ * only when the requestedURL is not already an absolute URL.
3185
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
3186
+ *
3187
+ * @param {string} baseURL The base URL
3188
+ * @param {string} requestedURL Absolute or relative URL to combine
3189
+ *
3190
+ * @returns {string} The combined full path
3191
+ */
3192
+ function buildFullPath(baseURL, requestedURL) {
3193
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
3194
+ return combineURLs(baseURL, requestedURL);
3195
+ }
3196
+ return requestedURL;
3197
+ }
3076
3198
 
3077
- bytesNotified = loaded;
3199
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3078
3200
 
3079
- const data = {
3080
- loaded,
3081
- total,
3082
- progress: total ? (loaded / total) : undefined,
3083
- bytes: progressBytes,
3084
- rate: rate ? rate : undefined,
3085
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
3086
- event: e
3087
- };
3201
+ /**
3202
+ * Config-specific merge-function which creates a new config-object
3203
+ * by merging two configuration objects together.
3204
+ *
3205
+ * @param {Object} config1
3206
+ * @param {Object} config2
3207
+ *
3208
+ * @returns {Object} New object resulting from merging config2 to config1
3209
+ */
3210
+ function mergeConfig(config1, config2) {
3211
+ // eslint-disable-next-line no-param-reassign
3212
+ config2 = config2 || {};
3213
+ const config = {};
3214
+
3215
+ function getMergedValue(target, source, caseless) {
3216
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3217
+ return utils$1.merge.call({caseless}, target, source);
3218
+ } else if (utils$1.isPlainObject(source)) {
3219
+ return utils$1.merge({}, source);
3220
+ } else if (utils$1.isArray(source)) {
3221
+ return source.slice();
3222
+ }
3223
+ return source;
3224
+ }
3088
3225
 
3089
- data[isDownloadStream ? 'download' : 'upload'] = true;
3226
+ // eslint-disable-next-line consistent-return
3227
+ function mergeDeepProperties(a, b, caseless) {
3228
+ if (!utils$1.isUndefined(b)) {
3229
+ return getMergedValue(a, b, caseless);
3230
+ } else if (!utils$1.isUndefined(a)) {
3231
+ return getMergedValue(undefined, a, caseless);
3232
+ }
3233
+ }
3090
3234
 
3091
- listener(data);
3235
+ // eslint-disable-next-line consistent-return
3236
+ function valueFromConfig2(a, b) {
3237
+ if (!utils$1.isUndefined(b)) {
3238
+ return getMergedValue(undefined, b);
3239
+ }
3240
+ }
3241
+
3242
+ // eslint-disable-next-line consistent-return
3243
+ function defaultToConfig2(a, b) {
3244
+ if (!utils$1.isUndefined(b)) {
3245
+ return getMergedValue(undefined, b);
3246
+ } else if (!utils$1.isUndefined(a)) {
3247
+ return getMergedValue(undefined, a);
3248
+ }
3249
+ }
3250
+
3251
+ // eslint-disable-next-line consistent-return
3252
+ function mergeDirectKeys(a, b, prop) {
3253
+ if (prop in config2) {
3254
+ return getMergedValue(a, b);
3255
+ } else if (prop in config1) {
3256
+ return getMergedValue(undefined, a);
3257
+ }
3258
+ }
3259
+
3260
+ const mergeMap = {
3261
+ url: valueFromConfig2,
3262
+ method: valueFromConfig2,
3263
+ data: valueFromConfig2,
3264
+ baseURL: defaultToConfig2,
3265
+ transformRequest: defaultToConfig2,
3266
+ transformResponse: defaultToConfig2,
3267
+ paramsSerializer: defaultToConfig2,
3268
+ timeout: defaultToConfig2,
3269
+ timeoutMessage: defaultToConfig2,
3270
+ withCredentials: defaultToConfig2,
3271
+ withXSRFToken: defaultToConfig2,
3272
+ adapter: defaultToConfig2,
3273
+ responseType: defaultToConfig2,
3274
+ xsrfCookieName: defaultToConfig2,
3275
+ xsrfHeaderName: defaultToConfig2,
3276
+ onUploadProgress: defaultToConfig2,
3277
+ onDownloadProgress: defaultToConfig2,
3278
+ decompress: defaultToConfig2,
3279
+ maxContentLength: defaultToConfig2,
3280
+ maxBodyLength: defaultToConfig2,
3281
+ beforeRedirect: defaultToConfig2,
3282
+ transport: defaultToConfig2,
3283
+ httpAgent: defaultToConfig2,
3284
+ httpsAgent: defaultToConfig2,
3285
+ cancelToken: defaultToConfig2,
3286
+ socketPath: defaultToConfig2,
3287
+ responseEncoding: defaultToConfig2,
3288
+ validateStatus: mergeDirectKeys,
3289
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3092
3290
  };
3291
+
3292
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3293
+ const merge = mergeMap[prop] || mergeDeepProperties;
3294
+ const configValue = merge(config1[prop], config2[prop], prop);
3295
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3296
+ });
3297
+
3298
+ return config;
3093
3299
  }
3094
3300
 
3095
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3301
+ var resolveConfig = (config) => {
3302
+ const newConfig = mergeConfig({}, config);
3096
3303
 
3097
- var xhrAdapter = isXHRAdapterSupported && function (config) {
3098
- return new Promise(function dispatchXhrRequest(resolve, reject) {
3099
- let requestData = config.data;
3100
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
3101
- let {responseType, withXSRFToken} = config;
3102
- let onCanceled;
3103
- function done() {
3104
- if (config.cancelToken) {
3105
- config.cancelToken.unsubscribe(onCanceled);
3106
- }
3304
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
3107
3305
 
3108
- if (config.signal) {
3109
- config.signal.removeEventListener('abort', onCanceled);
3110
- }
3306
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
3307
+
3308
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3309
+
3310
+ // HTTP basic authentication
3311
+ if (auth) {
3312
+ headers.set('Authorization', 'Basic ' +
3313
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
3314
+ );
3315
+ }
3316
+
3317
+ let contentType;
3318
+
3319
+ if (utils$1.isFormData(data)) {
3320
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3321
+ headers.setContentType(undefined); // Let the browser set it
3322
+ } else if ((contentType = headers.getContentType()) !== false) {
3323
+ // fix semicolon duplication issue for ReactNative FormData implementation
3324
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
3325
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
3111
3326
  }
3327
+ }
3328
+
3329
+ // Add xsrf header
3330
+ // This is only done if running in a standard browser environment.
3331
+ // Specifically not if we're in a web worker, or react-native.
3112
3332
 
3113
- let contentType;
3333
+ if (platform.hasStandardBrowserEnv) {
3334
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3114
3335
 
3115
- if (utils$1.isFormData(requestData)) {
3116
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3117
- requestHeaders.setContentType(false); // Let the browser set it
3118
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
3119
- // fix semicolon duplication issue for ReactNative FormData implementation
3120
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
3121
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
3336
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
3337
+ // Add xsrf header
3338
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3339
+
3340
+ if (xsrfValue) {
3341
+ headers.set(xsrfHeaderName, xsrfValue);
3122
3342
  }
3123
3343
  }
3344
+ }
3124
3345
 
3125
- let request = new XMLHttpRequest();
3346
+ return newConfig;
3347
+ };
3348
+
3349
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3126
3350
 
3127
- // HTTP basic authentication
3128
- if (config.auth) {
3129
- const username = config.auth.username || '';
3130
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
3131
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
3351
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
3352
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
3353
+ const _config = resolveConfig(config);
3354
+ let requestData = _config.data;
3355
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3356
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
3357
+ let onCanceled;
3358
+ let uploadThrottled, downloadThrottled;
3359
+ let flushUpload, flushDownload;
3360
+
3361
+ function done() {
3362
+ flushUpload && flushUpload(); // flush events
3363
+ flushDownload && flushDownload(); // flush events
3364
+
3365
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
3366
+
3367
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
3132
3368
  }
3133
3369
 
3134
- const fullPath = buildFullPath(config.baseURL, config.url);
3370
+ let request = new XMLHttpRequest();
3135
3371
 
3136
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
3372
+ request.open(_config.method.toUpperCase(), _config.url, true);
3137
3373
 
3138
3374
  // Set the request timeout in MS
3139
- request.timeout = config.timeout;
3375
+ request.timeout = _config.timeout;
3140
3376
 
3141
3377
  function onloadend() {
3142
3378
  if (!request) {
@@ -3216,10 +3452,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3216
3452
 
3217
3453
  // Handle timeout
3218
3454
  request.ontimeout = function handleTimeout() {
3219
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
3220
- const transitional = config.transitional || transitionalDefaults;
3221
- if (config.timeoutErrorMessage) {
3222
- timeoutErrorMessage = config.timeoutErrorMessage;
3455
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
3456
+ const transitional = _config.transitional || transitionalDefaults;
3457
+ if (_config.timeoutErrorMessage) {
3458
+ timeoutErrorMessage = _config.timeoutErrorMessage;
3223
3459
  }
3224
3460
  reject(new AxiosError(
3225
3461
  timeoutErrorMessage,
@@ -3231,22 +3467,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3231
3467
  request = null;
3232
3468
  };
3233
3469
 
3234
- // Add xsrf header
3235
- // This is only done if running in a standard browser environment.
3236
- // Specifically not if we're in a web worker, or react-native.
3237
- if(platform.hasStandardBrowserEnv) {
3238
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
3239
-
3240
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
3241
- // Add xsrf header
3242
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
3243
-
3244
- if (xsrfValue) {
3245
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
3246
- }
3247
- }
3248
- }
3249
-
3250
3470
  // Remove Content-Type if data is undefined
3251
3471
  requestData === undefined && requestHeaders.setContentType(null);
3252
3472
 
@@ -3258,26 +3478,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3258
3478
  }
3259
3479
 
3260
3480
  // Add withCredentials to request if needed
3261
- if (!utils$1.isUndefined(config.withCredentials)) {
3262
- request.withCredentials = !!config.withCredentials;
3481
+ if (!utils$1.isUndefined(_config.withCredentials)) {
3482
+ request.withCredentials = !!_config.withCredentials;
3263
3483
  }
3264
3484
 
3265
3485
  // Add responseType to request if needed
3266
3486
  if (responseType && responseType !== 'json') {
3267
- request.responseType = config.responseType;
3487
+ request.responseType = _config.responseType;
3268
3488
  }
3269
3489
 
3270
3490
  // Handle progress if needed
3271
- if (typeof config.onDownloadProgress === 'function') {
3272
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
3491
+ if (onDownloadProgress) {
3492
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
3493
+ request.addEventListener('progress', downloadThrottled);
3273
3494
  }
3274
3495
 
3275
3496
  // Not all browsers support upload events
3276
- if (typeof config.onUploadProgress === 'function' && request.upload) {
3277
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
3497
+ if (onUploadProgress && request.upload) {
3498
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
3499
+
3500
+ request.upload.addEventListener('progress', uploadThrottled);
3501
+
3502
+ request.upload.addEventListener('loadend', flushUpload);
3278
3503
  }
3279
3504
 
3280
- if (config.cancelToken || config.signal) {
3505
+ if (_config.cancelToken || _config.signal) {
3281
3506
  // Handle cancellation
3282
3507
  // eslint-disable-next-line func-names
3283
3508
  onCanceled = cancel => {
@@ -3289,13 +3514,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3289
3514
  request = null;
3290
3515
  };
3291
3516
 
3292
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
3293
- if (config.signal) {
3294
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
3517
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3518
+ if (_config.signal) {
3519
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
3295
3520
  }
3296
3521
  }
3297
3522
 
3298
- const protocol = parseProtocol(fullPath);
3523
+ const protocol = parseProtocol(_config.url);
3299
3524
 
3300
3525
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
3301
3526
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
@@ -3308,9 +3533,339 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
3308
3533
  });
3309
3534
  };
3310
3535
 
3536
+ const composeSignals = (signals, timeout) => {
3537
+ let controller = new AbortController();
3538
+
3539
+ let aborted;
3540
+
3541
+ const onabort = function (cancel) {
3542
+ if (!aborted) {
3543
+ aborted = true;
3544
+ unsubscribe();
3545
+ const err = cancel instanceof Error ? cancel : this.reason;
3546
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3547
+ }
3548
+ };
3549
+
3550
+ let timer = timeout && setTimeout(() => {
3551
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3552
+ }, timeout);
3553
+
3554
+ const unsubscribe = () => {
3555
+ if (signals) {
3556
+ timer && clearTimeout(timer);
3557
+ timer = null;
3558
+ signals.forEach(signal => {
3559
+ signal &&
3560
+ (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
3561
+ });
3562
+ signals = null;
3563
+ }
3564
+ };
3565
+
3566
+ signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
3567
+
3568
+ const {signal} = controller;
3569
+
3570
+ signal.unsubscribe = unsubscribe;
3571
+
3572
+ return [signal, () => {
3573
+ timer && clearTimeout(timer);
3574
+ timer = null;
3575
+ }];
3576
+ };
3577
+
3578
+ var composeSignals$1 = composeSignals;
3579
+
3580
+ const streamChunk = function* (chunk, chunkSize) {
3581
+ let len = chunk.byteLength;
3582
+
3583
+ if (!chunkSize || len < chunkSize) {
3584
+ yield chunk;
3585
+ return;
3586
+ }
3587
+
3588
+ let pos = 0;
3589
+ let end;
3590
+
3591
+ while (pos < len) {
3592
+ end = pos + chunkSize;
3593
+ yield chunk.slice(pos, end);
3594
+ pos = end;
3595
+ }
3596
+ };
3597
+
3598
+ const readBytes = async function* (iterable, chunkSize, encode) {
3599
+ for await (const chunk of iterable) {
3600
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
3601
+ }
3602
+ };
3603
+
3604
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
3605
+ const iterator = readBytes(stream, chunkSize, encode);
3606
+
3607
+ let bytes = 0;
3608
+ let done;
3609
+ let _onFinish = (e) => {
3610
+ if (!done) {
3611
+ done = true;
3612
+ onFinish && onFinish(e);
3613
+ }
3614
+ };
3615
+
3616
+ return new ReadableStream({
3617
+ async pull(controller) {
3618
+ try {
3619
+ const {done, value} = await iterator.next();
3620
+
3621
+ if (done) {
3622
+ _onFinish();
3623
+ controller.close();
3624
+ return;
3625
+ }
3626
+
3627
+ let len = value.byteLength;
3628
+ if (onProgress) {
3629
+ let loadedBytes = bytes += len;
3630
+ onProgress(loadedBytes);
3631
+ }
3632
+ controller.enqueue(new Uint8Array(value));
3633
+ } catch (err) {
3634
+ _onFinish(err);
3635
+ throw err;
3636
+ }
3637
+ },
3638
+ cancel(reason) {
3639
+ _onFinish(reason);
3640
+ return iterator.return();
3641
+ }
3642
+ }, {
3643
+ highWaterMark: 2
3644
+ })
3645
+ };
3646
+
3647
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
3648
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
3649
+
3650
+ // used only inside the fetch adapter
3651
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3652
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3653
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
3654
+ );
3655
+
3656
+ const test = (fn, ...args) => {
3657
+ try {
3658
+ return !!fn(...args);
3659
+ } catch (e) {
3660
+ return false
3661
+ }
3662
+ };
3663
+
3664
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
3665
+ let duplexAccessed = false;
3666
+
3667
+ const hasContentType = new Request(platform.origin, {
3668
+ body: new ReadableStream(),
3669
+ method: 'POST',
3670
+ get duplex() {
3671
+ duplexAccessed = true;
3672
+ return 'half';
3673
+ },
3674
+ }).headers.has('Content-Type');
3675
+
3676
+ return duplexAccessed && !hasContentType;
3677
+ });
3678
+
3679
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3680
+
3681
+ const supportsResponseStream = isReadableStreamSupported &&
3682
+ test(() => utils$1.isReadableStream(new Response('').body));
3683
+
3684
+
3685
+ const resolvers = {
3686
+ stream: supportsResponseStream && ((res) => res.body)
3687
+ };
3688
+
3689
+ isFetchSupported && (((res) => {
3690
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3691
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
3692
+ (_, config) => {
3693
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3694
+ });
3695
+ });
3696
+ })(new Response));
3697
+
3698
+ const getBodyLength = async (body) => {
3699
+ if (body == null) {
3700
+ return 0;
3701
+ }
3702
+
3703
+ if(utils$1.isBlob(body)) {
3704
+ return body.size;
3705
+ }
3706
+
3707
+ if(utils$1.isSpecCompliantForm(body)) {
3708
+ return (await new Request(body).arrayBuffer()).byteLength;
3709
+ }
3710
+
3711
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3712
+ return body.byteLength;
3713
+ }
3714
+
3715
+ if(utils$1.isURLSearchParams(body)) {
3716
+ body = body + '';
3717
+ }
3718
+
3719
+ if(utils$1.isString(body)) {
3720
+ return (await encodeText(body)).byteLength;
3721
+ }
3722
+ };
3723
+
3724
+ const resolveBodyLength = async (headers, body) => {
3725
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3726
+
3727
+ return length == null ? getBodyLength(body) : length;
3728
+ };
3729
+
3730
+ var fetchAdapter = isFetchSupported && (async (config) => {
3731
+ let {
3732
+ url,
3733
+ method,
3734
+ data,
3735
+ signal,
3736
+ cancelToken,
3737
+ timeout,
3738
+ onDownloadProgress,
3739
+ onUploadProgress,
3740
+ responseType,
3741
+ headers,
3742
+ withCredentials = 'same-origin',
3743
+ fetchOptions
3744
+ } = resolveConfig(config);
3745
+
3746
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3747
+
3748
+ let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
3749
+ composeSignals$1([signal, cancelToken], timeout) : [];
3750
+
3751
+ let finished, request;
3752
+
3753
+ const onFinish = () => {
3754
+ !finished && setTimeout(() => {
3755
+ composedSignal && composedSignal.unsubscribe();
3756
+ });
3757
+
3758
+ finished = true;
3759
+ };
3760
+
3761
+ let requestContentLength;
3762
+
3763
+ try {
3764
+ if (
3765
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3766
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3767
+ ) {
3768
+ let _request = new Request(url, {
3769
+ method: 'POST',
3770
+ body: data,
3771
+ duplex: "half"
3772
+ });
3773
+
3774
+ let contentTypeHeader;
3775
+
3776
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3777
+ headers.setContentType(contentTypeHeader);
3778
+ }
3779
+
3780
+ if (_request.body) {
3781
+ const [onProgress, flush] = progressEventDecorator(
3782
+ requestContentLength,
3783
+ progressEventReducer(asyncDecorator(onUploadProgress))
3784
+ );
3785
+
3786
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
3787
+ }
3788
+ }
3789
+
3790
+ if (!utils$1.isString(withCredentials)) {
3791
+ withCredentials = withCredentials ? 'include' : 'omit';
3792
+ }
3793
+
3794
+ request = new Request(url, {
3795
+ ...fetchOptions,
3796
+ signal: composedSignal,
3797
+ method: method.toUpperCase(),
3798
+ headers: headers.normalize().toJSON(),
3799
+ body: data,
3800
+ duplex: "half",
3801
+ credentials: withCredentials
3802
+ });
3803
+
3804
+ let response = await fetch(request);
3805
+
3806
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3807
+
3808
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3809
+ const options = {};
3810
+
3811
+ ['status', 'statusText', 'headers'].forEach(prop => {
3812
+ options[prop] = response[prop];
3813
+ });
3814
+
3815
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3816
+
3817
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3818
+ responseContentLength,
3819
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3820
+ ) || [];
3821
+
3822
+ response = new Response(
3823
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3824
+ flush && flush();
3825
+ isStreamResponse && onFinish();
3826
+ }, encodeText),
3827
+ options
3828
+ );
3829
+ }
3830
+
3831
+ responseType = responseType || 'text';
3832
+
3833
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3834
+
3835
+ !isStreamResponse && onFinish();
3836
+
3837
+ stopTimeout && stopTimeout();
3838
+
3839
+ return await new Promise((resolve, reject) => {
3840
+ settle(resolve, reject, {
3841
+ data: responseData,
3842
+ headers: AxiosHeaders$1.from(response.headers),
3843
+ status: response.status,
3844
+ statusText: response.statusText,
3845
+ config,
3846
+ request
3847
+ });
3848
+ })
3849
+ } catch (err) {
3850
+ onFinish();
3851
+
3852
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3853
+ throw Object.assign(
3854
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3855
+ {
3856
+ cause: err.cause || err
3857
+ }
3858
+ )
3859
+ }
3860
+
3861
+ throw AxiosError.from(err, err && err.code, config, request);
3862
+ }
3863
+ });
3864
+
3311
3865
  const knownAdapters = {
3312
3866
  http: httpAdapter,
3313
- xhr: xhrAdapter
3867
+ xhr: xhrAdapter,
3868
+ fetch: fetchAdapter
3314
3869
  };
3315
3870
 
3316
3871
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -3454,109 +4009,7 @@ function dispatchRequest(config) {
3454
4009
  });
3455
4010
  }
3456
4011
 
3457
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3458
-
3459
- /**
3460
- * Config-specific merge-function which creates a new config-object
3461
- * by merging two configuration objects together.
3462
- *
3463
- * @param {Object} config1
3464
- * @param {Object} config2
3465
- *
3466
- * @returns {Object} New object resulting from merging config2 to config1
3467
- */
3468
- function mergeConfig(config1, config2) {
3469
- // eslint-disable-next-line no-param-reassign
3470
- config2 = config2 || {};
3471
- const config = {};
3472
-
3473
- function getMergedValue(target, source, caseless) {
3474
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3475
- return utils$1.merge.call({caseless}, target, source);
3476
- } else if (utils$1.isPlainObject(source)) {
3477
- return utils$1.merge({}, source);
3478
- } else if (utils$1.isArray(source)) {
3479
- return source.slice();
3480
- }
3481
- return source;
3482
- }
3483
-
3484
- // eslint-disable-next-line consistent-return
3485
- function mergeDeepProperties(a, b, caseless) {
3486
- if (!utils$1.isUndefined(b)) {
3487
- return getMergedValue(a, b, caseless);
3488
- } else if (!utils$1.isUndefined(a)) {
3489
- return getMergedValue(undefined, a, caseless);
3490
- }
3491
- }
3492
-
3493
- // eslint-disable-next-line consistent-return
3494
- function valueFromConfig2(a, b) {
3495
- if (!utils$1.isUndefined(b)) {
3496
- return getMergedValue(undefined, b);
3497
- }
3498
- }
3499
-
3500
- // eslint-disable-next-line consistent-return
3501
- function defaultToConfig2(a, b) {
3502
- if (!utils$1.isUndefined(b)) {
3503
- return getMergedValue(undefined, b);
3504
- } else if (!utils$1.isUndefined(a)) {
3505
- return getMergedValue(undefined, a);
3506
- }
3507
- }
3508
-
3509
- // eslint-disable-next-line consistent-return
3510
- function mergeDirectKeys(a, b, prop) {
3511
- if (prop in config2) {
3512
- return getMergedValue(a, b);
3513
- } else if (prop in config1) {
3514
- return getMergedValue(undefined, a);
3515
- }
3516
- }
3517
-
3518
- const mergeMap = {
3519
- url: valueFromConfig2,
3520
- method: valueFromConfig2,
3521
- data: valueFromConfig2,
3522
- baseURL: defaultToConfig2,
3523
- transformRequest: defaultToConfig2,
3524
- transformResponse: defaultToConfig2,
3525
- paramsSerializer: defaultToConfig2,
3526
- timeout: defaultToConfig2,
3527
- timeoutMessage: defaultToConfig2,
3528
- withCredentials: defaultToConfig2,
3529
- withXSRFToken: defaultToConfig2,
3530
- adapter: defaultToConfig2,
3531
- responseType: defaultToConfig2,
3532
- xsrfCookieName: defaultToConfig2,
3533
- xsrfHeaderName: defaultToConfig2,
3534
- onUploadProgress: defaultToConfig2,
3535
- onDownloadProgress: defaultToConfig2,
3536
- decompress: defaultToConfig2,
3537
- maxContentLength: defaultToConfig2,
3538
- maxBodyLength: defaultToConfig2,
3539
- beforeRedirect: defaultToConfig2,
3540
- transport: defaultToConfig2,
3541
- httpAgent: defaultToConfig2,
3542
- httpsAgent: defaultToConfig2,
3543
- cancelToken: defaultToConfig2,
3544
- socketPath: defaultToConfig2,
3545
- responseEncoding: defaultToConfig2,
3546
- validateStatus: mergeDirectKeys,
3547
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3548
- };
3549
-
3550
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3551
- const merge = mergeMap[prop] || mergeDeepProperties;
3552
- const configValue = merge(config1[prop], config2[prop], prop);
3553
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3554
- });
3555
-
3556
- return config;
3557
- }
3558
-
3559
- const VERSION = "1.6.8";
4012
+ const VERSION = "1.7.4";
3560
4013
 
3561
4014
  const validators$1 = {};
3562
4015
 
@@ -3682,12 +4135,15 @@ class Axios {
3682
4135
 
3683
4136
  // slice off the Error: ... line
3684
4137
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3685
-
3686
- if (!err.stack) {
3687
- err.stack = stack;
3688
- // match without the 2 top stack lines
3689
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3690
- err.stack += '\n' + stack;
4138
+ try {
4139
+ if (!err.stack) {
4140
+ err.stack = stack;
4141
+ // match without the 2 top stack lines
4142
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
4143
+ err.stack += '\n' + stack;
4144
+ }
4145
+ } catch (e) {
4146
+ // ignore the case where "stack" is an un-writable property
3691
4147
  }
3692
4148
  }
3693
4149