contentful 9.2.6 → 9.2.8

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.
@@ -2848,7 +2848,7 @@ if ($defineProperty) {
2848
2848
 
2849
2849
  "use strict";
2850
2850
  __webpack_require__.r(__webpack_exports__);
2851
- /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/contentful-resolve-response/node_modules/fast-copy/dist/umd/index.js");
2851
+ /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/fast-copy/dist/fast-copy.js");
2852
2852
  /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fast_copy__WEBPACK_IMPORTED_MODULE_0__);
2853
2853
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2854
2854
 
@@ -3005,1295 +3005,1300 @@ var resolveResponse = function resolveResponse(response, options) {
3005
3005
 
3006
3006
  /***/ }),
3007
3007
 
3008
- /***/ "../node_modules/contentful-resolve-response/node_modules/fast-copy/dist/umd/index.js":
3009
- /*!********************************************************************************************!*\
3010
- !*** ../node_modules/contentful-resolve-response/node_modules/fast-copy/dist/umd/index.js ***!
3011
- \********************************************************************************************/
3012
- /*! no static exports found */
3013
- /***/ (function(module, exports, __webpack_require__) {
3008
+ /***/ "../node_modules/contentful-sdk-core/dist/index.es-modules.js":
3009
+ /*!********************************************************************!*\
3010
+ !*** ../node_modules/contentful-sdk-core/dist/index.es-modules.js ***!
3011
+ \********************************************************************/
3012
+ /*! exports provided: createHttpClient, createRequestConfig, enforceObjPath, errorHandler, freezeSys, getUserAgentHeader, toPlainObject */
3013
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3014
3014
 
3015
- (function (global, factory) {
3016
- true ? factory(exports) :
3017
- undefined;
3018
- })(this, (function (exports) { 'use strict';
3015
+ "use strict";
3016
+ __webpack_require__.r(__webpack_exports__);
3017
+ /* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createHttpClient", function() { return createHttpClient; });
3018
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRequestConfig", function() { return createRequestConfig; });
3019
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enforceObjPath", function() { return enforceObjPath; });
3020
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "errorHandler", function() { return errorHandler; });
3021
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "freezeSys", function() { return freezeSys; });
3022
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUserAgentHeader", function() { return getUserAgentHeader; });
3023
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toPlainObject", function() { return toPlainObject; });
3024
+ /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/contentful-sdk-core/node_modules/fast-copy/dist/umd/index.js");
3025
+ /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fast_copy__WEBPACK_IMPORTED_MODULE_0__);
3026
+ /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! qs */ "../node_modules/qs/lib/index.js");
3027
+ /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_1__);
3028
+ /* harmony import */ var lodash_isstring__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash.isstring */ "../node_modules/lodash.isstring/index.js");
3029
+ /* harmony import */ var lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_isstring__WEBPACK_IMPORTED_MODULE_2__);
3030
+ /* harmony import */ var p_throttle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-throttle */ "../node_modules/p-throttle/index.js");
3031
+ /* harmony import */ var p_throttle__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(p_throttle__WEBPACK_IMPORTED_MODULE_3__);
3032
+ /* harmony import */ var lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash.isplainobject */ "../node_modules/lodash.isplainobject/index.js");
3033
+ /* harmony import */ var lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4__);
3019
3034
 
3020
- var toStringFunction = Function.prototype.toString;
3021
- var create = Object.create;
3022
- var toStringObject = Object.prototype.toString;
3023
- /**
3024
- * @classdesc Fallback cache for when WeakMap is not natively supported
3025
- */
3026
- var LegacyCache = /** @class */ (function () {
3027
- function LegacyCache() {
3028
- this._keys = [];
3029
- this._values = [];
3030
- }
3031
- LegacyCache.prototype.has = function (key) {
3032
- return !!~this._keys.indexOf(key);
3033
- };
3034
- LegacyCache.prototype.get = function (key) {
3035
- return this._values[this._keys.indexOf(key)];
3036
- };
3037
- LegacyCache.prototype.set = function (key, value) {
3038
- this._keys.push(key);
3039
- this._values.push(value);
3040
- };
3041
- return LegacyCache;
3042
- }());
3043
- function createCacheLegacy() {
3044
- return new LegacyCache();
3045
- }
3046
- function createCacheModern() {
3047
- return new WeakMap();
3048
- }
3049
- /**
3050
- * Get a new cache object to prevent circular references.
3051
- */
3052
- var createCache = typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;
3053
- /**
3054
- * Get an empty version of the object with the same prototype it has.
3055
- */
3056
- function getCleanClone(prototype) {
3057
- if (!prototype) {
3058
- return create(null);
3059
- }
3060
- var Constructor = prototype.constructor;
3061
- if (Constructor === Object) {
3062
- return prototype === Object.prototype ? {} : create(prototype);
3063
- }
3064
- if (~toStringFunction.call(Constructor).indexOf('[native code]')) {
3065
- try {
3066
- return new Constructor();
3067
- }
3068
- catch (_a) { }
3069
- }
3070
- return create(prototype);
3071
- }
3072
- function getRegExpFlagsLegacy(regExp) {
3073
- var flags = '';
3074
- if (regExp.global) {
3075
- flags += 'g';
3076
- }
3077
- if (regExp.ignoreCase) {
3078
- flags += 'i';
3079
- }
3080
- if (regExp.multiline) {
3081
- flags += 'm';
3082
- }
3083
- if (regExp.unicode) {
3084
- flags += 'u';
3085
- }
3086
- if (regExp.sticky) {
3087
- flags += 'y';
3088
- }
3089
- return flags;
3090
- }
3091
- function getRegExpFlagsModern(regExp) {
3092
- return regExp.flags;
3093
- }
3094
- /**
3095
- * Get the flags to apply to the copied regexp.
3096
- */
3097
- var getRegExpFlags = /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;
3098
- function getTagLegacy(value) {
3099
- var type = toStringObject.call(value);
3100
- return type.substring(8, type.length - 1);
3035
+
3036
+
3037
+
3038
+
3039
+
3040
+ function ownKeys(object, enumerableOnly) {
3041
+ var keys = Object.keys(object);
3042
+
3043
+ if (Object.getOwnPropertySymbols) {
3044
+ var symbols = Object.getOwnPropertySymbols(object);
3045
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
3046
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3047
+ })), keys.push.apply(keys, symbols);
3048
+ }
3049
+
3050
+ return keys;
3051
+ }
3052
+
3053
+ function _objectSpread2(target) {
3054
+ for (var i = 1; i < arguments.length; i++) {
3055
+ var source = null != arguments[i] ? arguments[i] : {};
3056
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
3057
+ _defineProperty(target, key, source[key]);
3058
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
3059
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3060
+ });
3061
+ }
3062
+
3063
+ return target;
3064
+ }
3065
+
3066
+ function _typeof(obj) {
3067
+ "@babel/helpers - typeof";
3068
+
3069
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
3070
+ return typeof obj;
3071
+ } : function (obj) {
3072
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
3073
+ }, _typeof(obj);
3074
+ }
3075
+
3076
+ function _wrapRegExp() {
3077
+ _wrapRegExp = function (re, groups) {
3078
+ return new BabelRegExp(re, void 0, groups);
3079
+ };
3080
+
3081
+ var _super = RegExp.prototype,
3082
+ _groups = new WeakMap();
3083
+
3084
+ function BabelRegExp(re, flags, groups) {
3085
+ var _this = new RegExp(re, flags);
3086
+
3087
+ return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
3088
+ }
3089
+
3090
+ function buildGroups(result, re) {
3091
+ var g = _groups.get(re);
3092
+
3093
+ return Object.keys(g).reduce(function (groups, name) {
3094
+ var i = g[name];
3095
+ if ("number" == typeof i) groups[name] = result[i];else {
3096
+ for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++;
3097
+
3098
+ groups[name] = result[i[k]];
3099
+ }
3100
+ return groups;
3101
+ }, Object.create(null));
3102
+ }
3103
+
3104
+ return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
3105
+ var result = _super.exec.call(this, str);
3106
+
3107
+ return result && (result.groups = buildGroups(result, this)), result;
3108
+ }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
3109
+ if ("string" == typeof substitution) {
3110
+ var groups = _groups.get(this);
3111
+
3112
+ return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
3113
+ return "$" + groups[name];
3114
+ }));
3101
3115
  }
3102
- function getTagModern(value) {
3103
- return value[Symbol.toStringTag] || getTagLegacy(value);
3116
+
3117
+ if ("function" == typeof substitution) {
3118
+ var _this = this;
3119
+
3120
+ return _super[Symbol.replace].call(this, str, function () {
3121
+ var args = arguments;
3122
+ return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
3123
+ });
3104
3124
  }
3105
- /**
3106
- * Get the tag of the value passed, so that the correct copier can be used.
3107
- */
3108
- var getTag = typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;
3109
3125
 
3110
- var defineProperty = Object.defineProperty, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
3111
- var _a = Object.prototype, hasOwnProperty = _a.hasOwnProperty, propertyIsEnumerable = _a.propertyIsEnumerable;
3112
- var SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';
3113
- function getStrictPropertiesModern(object) {
3114
- return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
3126
+ return _super[Symbol.replace].call(this, str, substitution);
3127
+ }, _wrapRegExp.apply(this, arguments);
3128
+ }
3129
+
3130
+ function _defineProperty(obj, key, value) {
3131
+ if (key in obj) {
3132
+ Object.defineProperty(obj, key, {
3133
+ value: value,
3134
+ enumerable: true,
3135
+ configurable: true,
3136
+ writable: true
3137
+ });
3138
+ } else {
3139
+ obj[key] = value;
3140
+ }
3141
+
3142
+ return obj;
3143
+ }
3144
+
3145
+ function _inherits(subClass, superClass) {
3146
+ if (typeof superClass !== "function" && superClass !== null) {
3147
+ throw new TypeError("Super expression must either be null or a function");
3148
+ }
3149
+
3150
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
3151
+ constructor: {
3152
+ value: subClass,
3153
+ writable: true,
3154
+ configurable: true
3115
3155
  }
3116
- /**
3117
- * Get the properites used when copying objects strictly. This includes both keys and symbols.
3118
- */
3119
- var getStrictProperties = SUPPORTS_SYMBOL
3120
- ? getStrictPropertiesModern
3121
- : getOwnPropertyNames;
3122
- /**
3123
- * Striclty copy all properties contained on the object.
3124
- */
3125
- function copyOwnPropertiesStrict(value, clone, state) {
3126
- var properties = getStrictProperties(value);
3127
- for (var index = 0, length_1 = properties.length, property = void 0, descriptor = void 0; index < length_1; ++index) {
3128
- property = properties[index];
3129
- if (property === 'callee' || property === 'caller') {
3130
- continue;
3131
- }
3132
- descriptor = getOwnPropertyDescriptor(value, property);
3133
- if (!descriptor) {
3134
- // In extra edge cases where the property descriptor cannot be retrived, fall back to
3135
- // the loose assignment.
3136
- clone[property] = state.copier(value[property], state);
3137
- continue;
3138
- }
3139
- // Only clone the value if actually a value, not a getter / setter.
3140
- if (!descriptor.get && !descriptor.set) {
3141
- descriptor.value = state.copier(descriptor.value, state);
3142
- }
3143
- try {
3144
- defineProperty(clone, property, descriptor);
3145
- }
3146
- catch (error) {
3147
- // Tee above can fail on node in edge cases, so fall back to the loose assignment.
3148
- clone[property] = descriptor.value;
3149
- }
3150
- }
3151
- return clone;
3152
- }
3153
- /**
3154
- * Deeply copy the indexed values in the array.
3155
- */
3156
- function copyArrayLoose(array, state) {
3157
- var clone = new state.Constructor();
3158
- // set in the cache immediately to be able to reuse the object recursively
3159
- state.cache.set(array, clone);
3160
- for (var index = 0, length_2 = array.length; index < length_2; ++index) {
3161
- clone[index] = state.copier(array[index], state);
3162
- }
3163
- return clone;
3164
- }
3165
- /**
3166
- * Deeply copy the indexed values in the array, as well as any custom properties.
3167
- */
3168
- function copyArrayStrict(array, state) {
3169
- var clone = new state.Constructor();
3170
- // set in the cache immediately to be able to reuse the object recursively
3171
- state.cache.set(array, clone);
3172
- return copyOwnPropertiesStrict(array, clone, state);
3173
- }
3174
- /**
3175
- * Copy the contents of the ArrayBuffer.
3176
- */
3177
- function copyArrayBuffer(arrayBuffer, _state) {
3178
- return arrayBuffer.slice(0);
3179
- }
3180
- /**
3181
- * Create a new Blob with the contents of the original.
3182
- */
3183
- function copyBlob(blob, _state) {
3184
- return blob.slice(0, blob.size, blob.type);
3185
- }
3186
- /**
3187
- * Create a new DataView with the contents of the original.
3188
- */
3189
- function copyDataView(dataView, state) {
3190
- return new state.Constructor(copyArrayBuffer(dataView.buffer));
3156
+ });
3157
+ Object.defineProperty(subClass, "prototype", {
3158
+ writable: false
3159
+ });
3160
+ if (superClass) _setPrototypeOf(subClass, superClass);
3161
+ }
3162
+
3163
+ function _setPrototypeOf(o, p) {
3164
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3165
+ o.__proto__ = p;
3166
+ return o;
3167
+ };
3168
+ return _setPrototypeOf(o, p);
3169
+ }
3170
+
3171
+ function _slicedToArray(arr, i) {
3172
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
3173
+ }
3174
+
3175
+ function _arrayWithHoles(arr) {
3176
+ if (Array.isArray(arr)) return arr;
3177
+ }
3178
+
3179
+ function _iterableToArrayLimit(arr, i) {
3180
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3181
+
3182
+ if (_i == null) return;
3183
+ var _arr = [];
3184
+ var _n = true;
3185
+ var _d = false;
3186
+
3187
+ var _s, _e;
3188
+
3189
+ try {
3190
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
3191
+ _arr.push(_s.value);
3192
+
3193
+ if (i && _arr.length === i) break;
3191
3194
  }
3192
- /**
3193
- * Create a new Date based on the time of the original.
3194
- */
3195
- function copyDate(date, state) {
3196
- return new state.Constructor(date.getTime());
3195
+ } catch (err) {
3196
+ _d = true;
3197
+ _e = err;
3198
+ } finally {
3199
+ try {
3200
+ if (!_n && _i["return"] != null) _i["return"]();
3201
+ } finally {
3202
+ if (_d) throw _e;
3197
3203
  }
3198
- /**
3199
- * Deeply copy the keys and values of the original.
3200
- */
3201
- function copyMapLoose(map, state) {
3202
- var clone = new state.Constructor();
3203
- // set in the cache immediately to be able to reuse the object recursively
3204
- state.cache.set(map, clone);
3205
- map.forEach(function (value, key) {
3206
- clone.set(key, state.copier(value, state));
3207
- });
3208
- return clone;
3204
+ }
3205
+
3206
+ return _arr;
3207
+ }
3208
+
3209
+ function _unsupportedIterableToArray(o, minLen) {
3210
+ if (!o) return;
3211
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
3212
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3213
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3214
+ if (n === "Map" || n === "Set") return Array.from(o);
3215
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
3216
+ }
3217
+
3218
+ function _arrayLikeToArray(arr, len) {
3219
+ if (len == null || len > arr.length) len = arr.length;
3220
+
3221
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3222
+
3223
+ return arr2;
3224
+ }
3225
+
3226
+ function _nonIterableRest() {
3227
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3228
+ }
3229
+
3230
+ function _createForOfIteratorHelper(o, allowArrayLike) {
3231
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
3232
+
3233
+ if (!it) {
3234
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
3235
+ if (it) o = it;
3236
+ var i = 0;
3237
+
3238
+ var F = function () {};
3239
+
3240
+ return {
3241
+ s: F,
3242
+ n: function () {
3243
+ if (i >= o.length) return {
3244
+ done: true
3245
+ };
3246
+ return {
3247
+ done: false,
3248
+ value: o[i++]
3249
+ };
3250
+ },
3251
+ e: function (e) {
3252
+ throw e;
3253
+ },
3254
+ f: F
3255
+ };
3209
3256
  }
3210
- /**
3211
- * Deeply copy the keys and values of the original, as well as any custom properties.
3212
- */
3213
- function copyMapStrict(map, state) {
3214
- return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);
3257
+
3258
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3259
+ }
3260
+
3261
+ var normalCompletion = true,
3262
+ didErr = false,
3263
+ err;
3264
+ return {
3265
+ s: function () {
3266
+ it = it.call(o);
3267
+ },
3268
+ n: function () {
3269
+ var step = it.next();
3270
+ normalCompletion = step.done;
3271
+ return step;
3272
+ },
3273
+ e: function (e) {
3274
+ didErr = true;
3275
+ err = e;
3276
+ },
3277
+ f: function () {
3278
+ try {
3279
+ if (!normalCompletion && it.return != null) it.return();
3280
+ } finally {
3281
+ if (didErr) throw err;
3282
+ }
3215
3283
  }
3216
- function copyObjectLooseLegacy(object, state) {
3217
- var clone = getCleanClone(state.prototype);
3218
- // set in the cache immediately to be able to reuse the object recursively
3219
- state.cache.set(object, clone);
3220
- for (var key in object) {
3221
- if (hasOwnProperty.call(object, key)) {
3222
- clone[key] = state.copier(object[key], state);
3223
- }
3224
- }
3225
- return clone;
3226
- }
3227
- function copyObjectLooseModern(object, state) {
3228
- var clone = getCleanClone(state.prototype);
3229
- // set in the cache immediately to be able to reuse the object recursively
3230
- state.cache.set(object, clone);
3231
- for (var key in object) {
3232
- if (hasOwnProperty.call(object, key)) {
3233
- clone[key] = state.copier(object[key], state);
3234
- }
3235
- }
3236
- var symbols = getOwnPropertySymbols(object);
3237
- for (var index = 0, length_3 = symbols.length, symbol = void 0; index < length_3; ++index) {
3238
- symbol = symbols[index];
3239
- if (propertyIsEnumerable.call(object, symbol)) {
3240
- clone[symbol] = state.copier(object[symbol], state);
3241
- }
3242
- }
3243
- return clone;
3244
- }
3245
- /**
3246
- * Deeply copy the properties (keys and symbols) and values of the original.
3247
- */
3248
- var copyObjectLoose = SUPPORTS_SYMBOL
3249
- ? copyObjectLooseModern
3250
- : copyObjectLooseLegacy;
3251
- /**
3252
- * Deeply copy the properties (keys and symbols) and values of the original, as well
3253
- * as any hidden or non-enumerable properties.
3254
- */
3255
- function copyObjectStrict(object, state) {
3256
- var clone = getCleanClone(state.prototype);
3257
- // set in the cache immediately to be able to reuse the object recursively
3258
- state.cache.set(object, clone);
3259
- return copyOwnPropertiesStrict(object, clone, state);
3260
- }
3261
- /**
3262
- * Create a new primitive wrapper from the value of the original.
3263
- */
3264
- function copyPrimitiveWrapper(primitiveObject, state) {
3265
- return new state.Constructor(primitiveObject.valueOf());
3266
- }
3267
- /**
3268
- * Create a new RegExp based on the value and flags of the original.
3269
- */
3270
- function copyRegExp(regExp, state) {
3271
- var clone = new state.Constructor(regExp.source, getRegExpFlags(regExp));
3272
- clone.lastIndex = regExp.lastIndex;
3273
- return clone;
3274
- }
3275
- /**
3276
- * Return the original value (an identity function).
3277
- *
3278
- * @note
3279
- * THis is used for objects that cannot be copied, such as WeakMap.
3280
- */
3281
- function copySelf(value, _state) {
3282
- return value;
3283
- }
3284
- /**
3285
- * Deeply copy the values of the original.
3286
- */
3287
- function copySetLoose(set, state) {
3288
- var clone = new state.Constructor();
3289
- // set in the cache immediately to be able to reuse the object recursively
3290
- state.cache.set(set, clone);
3291
- set.forEach(function (value) {
3292
- clone.add(state.copier(value, state));
3293
- });
3294
- return clone;
3295
- }
3296
- /**
3297
- * Deeply copy the values of the original, as well as any custom properties.
3298
- */
3299
- function copySetStrict(set, state) {
3300
- return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);
3284
+ };
3285
+ }
3286
+
3287
+ function isNode() {
3288
+ /**
3289
+ * Polyfills of 'process' might set process.browser === true
3290
+ *
3291
+ * See:
3292
+ * https://github.com/webpack/node-libs-browser/blob/master/mock/process.js#L8
3293
+ * https://github.com/defunctzombie/node-process/blob/master/browser.js#L156
3294
+ **/
3295
+ return typeof process !== 'undefined' && !process.browser;
3296
+ }
3297
+ function isReactNative() {
3298
+ return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
3299
+ }
3300
+ function getNodeVersion() {
3301
+ return process.versions && process.versions.node ? "v".concat(process.versions.node) : process.version;
3302
+ }
3303
+ function getWindow() {
3304
+ return window;
3305
+ }
3306
+ function noop() {
3307
+ return undefined;
3308
+ }
3309
+
3310
+ var PERCENTAGE_REGEX = /*#__PURE__*/_wrapRegExp(/(\d+)(%)/, {
3311
+ value: 1
3312
+ });
3313
+
3314
+ function calculateLimit(type) {
3315
+ var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 7;
3316
+ var limit = max;
3317
+
3318
+ if (PERCENTAGE_REGEX.test(type)) {
3319
+ var _type$match;
3320
+
3321
+ var groups = (_type$match = type.match(PERCENTAGE_REGEX)) === null || _type$match === void 0 ? void 0 : _type$match.groups;
3322
+
3323
+ if (groups && groups.value) {
3324
+ var percentage = parseInt(groups.value) / 100;
3325
+ limit = Math.round(max * percentage);
3301
3326
  }
3327
+ }
3302
3328
 
3303
- var isArray = Array.isArray;
3304
- var assign = Object.assign, getPrototypeOf = Object.getPrototypeOf;
3305
- var DEFAULT_LOOSE_OPTIONS = {
3306
- array: copyArrayLoose,
3307
- arrayBuffer: copyArrayBuffer,
3308
- blob: copyBlob,
3309
- dataView: copyDataView,
3310
- date: copyDate,
3311
- error: copySelf,
3312
- map: copyMapLoose,
3313
- object: copyObjectLoose,
3314
- regExp: copyRegExp,
3315
- set: copySetLoose,
3316
- };
3317
- var DEFAULT_STRICT_OPTIONS = assign({}, DEFAULT_LOOSE_OPTIONS, {
3318
- array: copyArrayStrict,
3319
- map: copyMapStrict,
3320
- object: copyObjectStrict,
3321
- set: copySetStrict,
3322
- });
3323
- /**
3324
- * Get the copiers used for each specific object tag.
3325
- */
3326
- function getTagSpecificCopiers(options) {
3327
- return {
3328
- Arguments: options.object,
3329
- Array: options.array,
3330
- ArrayBuffer: options.arrayBuffer,
3331
- Blob: options.blob,
3332
- Boolean: copyPrimitiveWrapper,
3333
- DataView: options.dataView,
3334
- Date: options.date,
3335
- Error: options.error,
3336
- Float32Array: options.arrayBuffer,
3337
- Float64Array: options.arrayBuffer,
3338
- Int8Array: options.arrayBuffer,
3339
- Int16Array: options.arrayBuffer,
3340
- Int32Array: options.arrayBuffer,
3341
- Map: options.map,
3342
- Number: copyPrimitiveWrapper,
3343
- Object: options.object,
3344
- Promise: copySelf,
3345
- RegExp: options.regExp,
3346
- Set: options.set,
3347
- String: copyPrimitiveWrapper,
3348
- WeakMap: copySelf,
3349
- WeakSet: copySelf,
3350
- Uint8Array: options.arrayBuffer,
3351
- Uint8ClampedArray: options.arrayBuffer,
3352
- Uint16Array: options.arrayBuffer,
3353
- Uint32Array: options.arrayBuffer,
3354
- Uint64Array: options.arrayBuffer,
3355
- };
3356
- }
3357
- /**
3358
- * Create a custom copier based on the object-specific copy methods passed.
3359
- */
3360
- function createCopier(options) {
3361
- var normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);
3362
- var tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);
3363
- var array = tagSpecificCopiers.Array, object = tagSpecificCopiers.Object;
3364
- function copier(value, state) {
3365
- state.prototype = state.Constructor = undefined;
3366
- if (!value || typeof value !== 'object') {
3367
- return value;
3368
- }
3369
- if (state.cache.has(value)) {
3370
- return state.cache.get(value);
3371
- }
3372
- state.prototype = value.__proto__ || getPrototypeOf(value);
3373
- state.Constructor = state.prototype && state.prototype.constructor;
3374
- // plain objects
3375
- if (!state.Constructor || state.Constructor === Object) {
3376
- return object(value, state);
3377
- }
3378
- // arrays
3379
- if (isArray(value)) {
3380
- return array(value, state);
3381
- }
3382
- var tagSpecificCopier = tagSpecificCopiers[getTag(value)];
3383
- if (tagSpecificCopier) {
3384
- return tagSpecificCopier(value, state);
3385
- }
3386
- return typeof value.then === 'function' ? value : object(value, state);
3387
- }
3388
- return function copy(value) {
3389
- return copier(value, {
3390
- Constructor: undefined,
3391
- cache: createCache(),
3392
- copier: copier,
3393
- prototype: undefined,
3394
- });
3395
- };
3396
- }
3397
- /**
3398
- * Create a custom copier based on the object-specific copy methods passed, defaulting to the
3399
- * same internals as `copyStrict`.
3400
- */
3401
- function createStrictCopier(options) {
3402
- return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));
3403
- }
3404
- /**
3405
- * Copy an value deeply as much as possible, where strict recreation of object properties
3406
- * are maintained. All properties (including non-enumerable ones) are copied with their
3407
- * original property descriptors on both objects and arrays.
3408
- */
3409
- var copyStrict = createStrictCopier({});
3410
- /**
3411
- * Copy an value deeply as much as possible.
3412
- */
3413
- var index = createCopier({});
3329
+ return Math.min(30, Math.max(1, limit));
3330
+ }
3414
3331
 
3415
- exports.copyStrict = copyStrict;
3416
- exports.createCopier = createCopier;
3417
- exports.createStrictCopier = createStrictCopier;
3418
- exports["default"] = index;
3332
+ function createThrottle(limit, logger) {
3333
+ logger('info', "Throttle request to ".concat(limit, "/s"));
3334
+ return p_throttle__WEBPACK_IMPORTED_MODULE_3___default()({
3335
+ limit: limit,
3336
+ interval: 1000,
3337
+ strict: false
3338
+ });
3339
+ }
3419
3340
 
3420
- Object.defineProperty(exports, '__esModule', { value: true });
3341
+ var rateLimitThrottle = (function (axiosInstance) {
3342
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'auto';
3343
+ var _axiosInstance$defaul = axiosInstance.defaults.logHandler,
3344
+ logHandler = _axiosInstance$defaul === void 0 ? noop : _axiosInstance$defaul;
3345
+ var limit = lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default()(type) ? calculateLimit(type) : calculateLimit('auto', type);
3346
+ var throttle = createThrottle(limit, logHandler);
3347
+ var isCalculated = false;
3348
+ var requestInterceptorId = axiosInstance.interceptors.request.use(function (config) {
3349
+ return throttle(function () {
3350
+ return config;
3351
+ })();
3352
+ }, function (error) {
3353
+ return Promise.reject(error);
3354
+ });
3355
+ var responseInterceptorId = axiosInstance.interceptors.response.use(function (response) {
3356
+ if (!isCalculated && lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default()(type) && (type === 'auto' || PERCENTAGE_REGEX.test(type)) && response.headers && response.headers['x-contentful-ratelimit-second-limit']) {
3357
+ var rawLimit = parseInt(response.headers['x-contentful-ratelimit-second-limit']);
3358
+ var nextLimit = calculateLimit(type, rawLimit);
3421
3359
 
3422
- }));
3423
- //# sourceMappingURL=index.js.map
3360
+ if (nextLimit !== limit) {
3361
+ if (requestInterceptorId) {
3362
+ axiosInstance.interceptors.request.eject(requestInterceptorId);
3363
+ }
3424
3364
 
3365
+ limit = nextLimit;
3366
+ throttle = createThrottle(nextLimit, logHandler);
3367
+ requestInterceptorId = axiosInstance.interceptors.request.use(function (config) {
3368
+ return throttle(function () {
3369
+ return config;
3370
+ })();
3371
+ }, function (error) {
3372
+ return Promise.reject(error);
3373
+ });
3374
+ }
3425
3375
 
3426
- /***/ }),
3376
+ isCalculated = true;
3377
+ }
3427
3378
 
3428
- /***/ "../node_modules/contentful-sdk-core/dist/index.es-modules.js":
3429
- /*!********************************************************************!*\
3430
- !*** ../node_modules/contentful-sdk-core/dist/index.es-modules.js ***!
3431
- \********************************************************************/
3432
- /*! exports provided: createHttpClient, createRequestConfig, enforceObjPath, errorHandler, freezeSys, getUserAgentHeader, toPlainObject */
3433
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
3379
+ return response;
3380
+ }, function (error) {
3381
+ return Promise.reject(error);
3382
+ });
3383
+ return function () {
3384
+ axiosInstance.interceptors.request.eject(requestInterceptorId);
3385
+ axiosInstance.interceptors.response.eject(responseInterceptorId);
3386
+ };
3387
+ });
3434
3388
 
3435
- "use strict";
3436
- __webpack_require__.r(__webpack_exports__);
3437
- /* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createHttpClient", function() { return createHttpClient; });
3438
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRequestConfig", function() { return createRequestConfig; });
3439
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enforceObjPath", function() { return enforceObjPath; });
3440
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "errorHandler", function() { return errorHandler; });
3441
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "freezeSys", function() { return freezeSys; });
3442
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUserAgentHeader", function() { return getUserAgentHeader; });
3443
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toPlainObject", function() { return toPlainObject; });
3444
- /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/fast-copy/dist/fast-copy.js");
3445
- /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fast_copy__WEBPACK_IMPORTED_MODULE_0__);
3446
- /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! qs */ "../node_modules/qs/lib/index.js");
3447
- /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_1__);
3448
- /* harmony import */ var lodash_isstring__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash.isstring */ "../node_modules/lodash.isstring/index.js");
3449
- /* harmony import */ var lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_isstring__WEBPACK_IMPORTED_MODULE_2__);
3450
- /* harmony import */ var p_throttle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! p-throttle */ "../node_modules/p-throttle/index.js");
3451
- /* harmony import */ var p_throttle__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(p_throttle__WEBPACK_IMPORTED_MODULE_3__);
3452
- /* harmony import */ var lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash.isplainobject */ "../node_modules/lodash.isplainobject/index.js");
3453
- /* harmony import */ var lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4__);
3389
+ var delay = function delay(ms) {
3390
+ return new Promise(function (resolve) {
3391
+ setTimeout(resolve, ms);
3392
+ });
3393
+ };
3454
3394
 
3395
+ var defaultWait = function defaultWait(attempts) {
3396
+ return Math.pow(Math.SQRT2, attempts);
3397
+ };
3455
3398
 
3399
+ function rateLimit(instance) {
3400
+ var maxRetry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
3401
+ var _instance$defaults = instance.defaults,
3402
+ _instance$defaults$re = _instance$defaults.responseLogger,
3403
+ responseLogger = _instance$defaults$re === void 0 ? noop : _instance$defaults$re,
3404
+ _instance$defaults$re2 = _instance$defaults.requestLogger,
3405
+ requestLogger = _instance$defaults$re2 === void 0 ? noop : _instance$defaults$re2;
3406
+ instance.interceptors.request.use(function (config) {
3407
+ requestLogger(config);
3408
+ return config;
3409
+ }, function (error) {
3410
+ requestLogger(error);
3411
+ return Promise.reject(error);
3412
+ });
3413
+ instance.interceptors.response.use(function (response) {
3414
+ // we don't need to do anything here
3415
+ responseLogger(response);
3416
+ return response;
3417
+ }, function (error) {
3418
+ var response = error.response;
3419
+ var config = error.config;
3420
+ responseLogger(error); // Do not retry if it is disabled or no request config exists (not an axios error)
3456
3421
 
3422
+ if (!config || !instance.defaults.retryOnError) {
3423
+ return Promise.reject(error);
3424
+ } // Retried already for max attempts
3457
3425
 
3458
3426
 
3427
+ var doneAttempts = config.attempts || 1;
3459
3428
 
3460
- function ownKeys(object, enumerableOnly) {
3461
- var keys = Object.keys(object);
3429
+ if (doneAttempts > maxRetry) {
3430
+ error.attempts = config.attempts;
3431
+ return Promise.reject(error);
3432
+ }
3462
3433
 
3463
- if (Object.getOwnPropertySymbols) {
3464
- var symbols = Object.getOwnPropertySymbols(object);
3465
- enumerableOnly && (symbols = symbols.filter(function (sym) {
3466
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3467
- })), keys.push.apply(keys, symbols);
3468
- }
3434
+ var retryErrorType = null;
3435
+ var wait = defaultWait(doneAttempts); // Errors without response did not receive anything from the server
3469
3436
 
3470
- return keys;
3437
+ if (!response) {
3438
+ retryErrorType = 'Connection';
3439
+ } else if (response.status >= 500 && response.status < 600) {
3440
+ // 5** errors are server related
3441
+ retryErrorType = "Server ".concat(response.status);
3442
+ } else if (response.status === 429) {
3443
+ // 429 errors are exceeded rate limit exceptions
3444
+ retryErrorType = 'Rate limit'; // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
3445
+
3446
+ if (response.headers && error.response.headers['x-contentful-ratelimit-reset']) {
3447
+ wait = response.headers['x-contentful-ratelimit-reset'];
3448
+ }
3449
+ }
3450
+
3451
+ if (retryErrorType) {
3452
+ // convert to ms and add jitter
3453
+ wait = Math.floor(wait * 1000 + Math.random() * 200 + 500);
3454
+ instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying...")); // increase attempts counter
3455
+
3456
+ config.attempts = doneAttempts + 1;
3457
+ /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object
3458
+ to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry
3459
+ requests still use the original http/httpsAgent property */
3460
+
3461
+ delete config.httpAgent;
3462
+ delete config.httpsAgent;
3463
+ return delay(wait).then(function () {
3464
+ return instance(config);
3465
+ });
3466
+ }
3467
+
3468
+ return Promise.reject(error);
3469
+ });
3471
3470
  }
3472
3471
 
3473
- function _objectSpread2(target) {
3474
- for (var i = 1; i < arguments.length; i++) {
3475
- var source = null != arguments[i] ? arguments[i] : {};
3476
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
3477
- _defineProperty(target, key, source[key]);
3478
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
3479
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3472
+ function asyncToken(instance, getToken) {
3473
+ instance.interceptors.request.use(function (config) {
3474
+ return getToken().then(function (accessToken) {
3475
+ config.headers = _objectSpread2(_objectSpread2({}, config.headers), {}, {
3476
+ Authorization: "Bearer ".concat(accessToken)
3477
+ });
3478
+ return config;
3480
3479
  });
3481
- }
3482
-
3483
- return target;
3480
+ });
3484
3481
  }
3485
3482
 
3486
- function _typeof(obj) {
3487
- "@babel/helpers - typeof";
3483
+ // Also enforces toplevel domain specified, no spaces and no protocol
3488
3484
 
3489
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
3490
- return typeof obj;
3491
- } : function (obj) {
3492
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
3493
- }, _typeof(obj);
3494
- }
3485
+ var HOST_REGEX = /^(?!\w+:\/\/)([^\s:]+\.?[^\s:]+)(?::(\d+))?(?!:)$/;
3486
+ /**
3487
+ * Create pre configured axios instance
3488
+ * @private
3489
+ * @param {AxiosStatic} axios - Axios library
3490
+ * @param {CreateHttpClientParams} options - Initialization parameters for the HTTP client
3491
+ * @return {ContentfulAxiosInstance} Initialized axios instance
3492
+ */
3495
3493
 
3496
- function _wrapRegExp() {
3497
- _wrapRegExp = function (re, groups) {
3498
- return new BabelRegExp(re, void 0, groups);
3499
- };
3494
+ function createHttpClient(axios, options) {
3495
+ var defaultConfig = {
3496
+ insecure: false,
3497
+ retryOnError: true,
3498
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3499
+ logHandler: function logHandler(level, data) {
3500
+ if (level === 'error' && data) {
3501
+ var title = [data.name, data.message].filter(function (a) {
3502
+ return a;
3503
+ }).join(' - ');
3504
+ console.error("[error] ".concat(title));
3505
+ console.error(data);
3506
+ return;
3507
+ }
3500
3508
 
3501
- var _super = RegExp.prototype,
3502
- _groups = new WeakMap();
3509
+ console.log("[".concat(level, "] ").concat(data));
3510
+ },
3511
+ // Passed to axios
3512
+ headers: {},
3513
+ httpAgent: false,
3514
+ httpsAgent: false,
3515
+ timeout: 30000,
3516
+ throttle: 0,
3517
+ proxy: false,
3518
+ basePath: '',
3519
+ adapter: undefined,
3520
+ maxContentLength: 1073741824,
3521
+ // 1GB
3522
+ maxBodyLength: 1073741824 // 1GB
3503
3523
 
3504
- function BabelRegExp(re, flags, groups) {
3505
- var _this = new RegExp(re, flags);
3524
+ };
3506
3525
 
3507
- return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
3508
- }
3526
+ var config = _objectSpread2(_objectSpread2({}, defaultConfig), options);
3509
3527
 
3510
- function buildGroups(result, re) {
3511
- var g = _groups.get(re);
3528
+ if (!config.accessToken) {
3529
+ var missingAccessTokenError = new TypeError('Expected parameter accessToken');
3530
+ config.logHandler('error', missingAccessTokenError);
3531
+ throw missingAccessTokenError;
3532
+ } // Construct axios baseURL option
3512
3533
 
3513
- return Object.keys(g).reduce(function (groups, name) {
3514
- return groups[name] = result[g[name]], groups;
3515
- }, Object.create(null));
3516
- }
3517
3534
 
3518
- return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
3519
- var result = _super.exec.call(this, str);
3535
+ var protocol = config.insecure ? 'http' : 'https';
3536
+ var space = config.space ? "".concat(config.space, "/") : '';
3537
+ var hostname = config.defaultHostname;
3538
+ var port = config.insecure ? 80 : 443;
3520
3539
 
3521
- return result && (result.groups = buildGroups(result, this)), result;
3522
- }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
3523
- if ("string" == typeof substitution) {
3524
- var groups = _groups.get(this);
3540
+ if (config.host && HOST_REGEX.test(config.host)) {
3541
+ var parsed = config.host.split(':');
3525
3542
 
3526
- return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
3527
- return "$" + groups[name];
3528
- }));
3529
- }
3543
+ if (parsed.length === 2) {
3530
3544
 
3531
- if ("function" == typeof substitution) {
3532
- var _this = this;
3545
+ var _parsed = _slicedToArray(parsed, 2);
3533
3546
 
3534
- return _super[Symbol.replace].call(this, str, function () {
3535
- var args = arguments;
3536
- return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
3537
- });
3547
+ hostname = _parsed[0];
3548
+ port = _parsed[1];
3549
+ } else {
3550
+ hostname = parsed[0];
3538
3551
  }
3552
+ } // Ensure that basePath does start but not end with a slash
3539
3553
 
3540
- return _super[Symbol.replace].call(this, str, substitution);
3541
- }, _wrapRegExp.apply(this, arguments);
3542
- }
3543
3554
 
3544
- function _defineProperty(obj, key, value) {
3545
- if (key in obj) {
3546
- Object.defineProperty(obj, key, {
3547
- value: value,
3548
- enumerable: true,
3549
- configurable: true,
3550
- writable: true
3551
- });
3552
- } else {
3553
- obj[key] = value;
3555
+ if (config.basePath) {
3556
+ config.basePath = "/".concat(config.basePath.split('/').filter(Boolean).join('/'));
3554
3557
  }
3555
3558
 
3556
- return obj;
3557
- }
3559
+ var baseURL = options.baseURL || "".concat(protocol, "://").concat(hostname, ":").concat(port).concat(config.basePath, "/spaces/").concat(space);
3558
3560
 
3559
- function _inherits(subClass, superClass) {
3560
- if (typeof superClass !== "function" && superClass !== null) {
3561
- throw new TypeError("Super expression must either be null or a function");
3562
- }
3561
+ if (!config.headers.Authorization && typeof config.accessToken !== 'function') {
3562
+ config.headers.Authorization = 'Bearer ' + config.accessToken;
3563
+ } // Set these headers only for node because browsers don't like it when you
3564
+ // override user-agent or accept-encoding.
3565
+ // The SDKs should set their own X-Contentful-User-Agent.
3563
3566
 
3564
- subClass.prototype = Object.create(superClass && superClass.prototype, {
3565
- constructor: {
3566
- value: subClass,
3567
- writable: true,
3568
- configurable: true
3569
- }
3570
- });
3571
- Object.defineProperty(subClass, "prototype", {
3572
- writable: false
3573
- });
3574
- if (superClass) _setPrototypeOf(subClass, superClass);
3575
- }
3576
3567
 
3577
- function _setPrototypeOf(o, p) {
3578
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
3579
- o.__proto__ = p;
3580
- return o;
3581
- };
3568
+ if (isNode()) {
3569
+ config.headers['user-agent'] = 'node.js/' + getNodeVersion();
3570
+ config.headers['Accept-Encoding'] = 'gzip';
3571
+ }
3582
3572
 
3583
- return _setPrototypeOf(o, p);
3584
- }
3573
+ var axiosOptions = {
3574
+ // Axios
3575
+ baseURL: baseURL,
3576
+ headers: config.headers,
3577
+ httpAgent: config.httpAgent,
3578
+ httpsAgent: config.httpsAgent,
3579
+ paramsSerializer: qs__WEBPACK_IMPORTED_MODULE_1___default.a.stringify,
3580
+ proxy: config.proxy,
3581
+ timeout: config.timeout,
3582
+ adapter: config.adapter,
3583
+ maxContentLength: config.maxContentLength,
3584
+ maxBodyLength: config.maxBodyLength,
3585
+ // Contentful
3586
+ logHandler: config.logHandler,
3587
+ responseLogger: config.responseLogger,
3588
+ requestLogger: config.requestLogger,
3589
+ retryOnError: config.retryOnError
3590
+ };
3591
+ var instance = axios.create(axiosOptions);
3592
+ instance.httpClientParams = options;
3593
+ /**
3594
+ * Creates a new axios instance with the same default base parameters as the
3595
+ * current one, and with any overrides passed to the newParams object
3596
+ * This is useful as the SDKs use dependency injection to get the axios library
3597
+ * and the version of the library comes from different places depending
3598
+ * on whether it's a browser build or a node.js build.
3599
+ * @private
3600
+ * @param {CreateHttpClientParams} httpClientParams - Initialization parameters for the HTTP client
3601
+ * @return {ContentfulAxiosInstance} Initialized axios instance
3602
+ */
3585
3603
 
3586
- function _slicedToArray(arr, i) {
3587
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
3588
- }
3604
+ instance.cloneWithNewParams = function (newParams) {
3605
+ return createHttpClient(axios, _objectSpread2(_objectSpread2({}, fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(options)), newParams));
3606
+ };
3607
+ /**
3608
+ * Apply interceptors.
3609
+ * Please note that the order of interceptors is important
3610
+ */
3589
3611
 
3590
- function _arrayWithHoles(arr) {
3591
- if (Array.isArray(arr)) return arr;
3592
- }
3593
3612
 
3594
- function _iterableToArrayLimit(arr, i) {
3595
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3613
+ if (config.onBeforeRequest) {
3614
+ instance.interceptors.request.use(config.onBeforeRequest);
3615
+ }
3596
3616
 
3597
- if (_i == null) return;
3598
- var _arr = [];
3599
- var _n = true;
3600
- var _d = false;
3617
+ if (typeof config.accessToken === 'function') {
3618
+ asyncToken(instance, config.accessToken);
3619
+ }
3601
3620
 
3602
- var _s, _e;
3621
+ if (config.throttle) {
3622
+ rateLimitThrottle(instance, config.throttle);
3623
+ }
3603
3624
 
3604
- try {
3605
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
3606
- _arr.push(_s.value);
3625
+ rateLimit(instance, config.retryLimit);
3607
3626
 
3608
- if (i && _arr.length === i) break;
3609
- }
3610
- } catch (err) {
3611
- _d = true;
3612
- _e = err;
3613
- } finally {
3614
- try {
3615
- if (!_n && _i["return"] != null) _i["return"]();
3616
- } finally {
3617
- if (_d) throw _e;
3618
- }
3627
+ if (config.onError) {
3628
+ instance.interceptors.response.use(function (response) {
3629
+ return response;
3630
+ }, config.onError);
3619
3631
  }
3620
3632
 
3621
- return _arr;
3622
- }
3623
-
3624
- function _unsupportedIterableToArray(o, minLen) {
3625
- if (!o) return;
3626
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
3627
- var n = Object.prototype.toString.call(o).slice(8, -1);
3628
- if (n === "Object" && o.constructor) n = o.constructor.name;
3629
- if (n === "Map" || n === "Set") return Array.from(o);
3630
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
3633
+ return instance;
3631
3634
  }
3632
3635
 
3633
- function _arrayLikeToArray(arr, len) {
3634
- if (len == null || len > arr.length) len = arr.length;
3635
-
3636
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3636
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3637
3637
 
3638
- return arr2;
3638
+ /**
3639
+ * Creates request parameters configuration by parsing an existing query object
3640
+ * @private
3641
+ * @param {Object} query
3642
+ * @return {Object} Config object with `params` property, ready to be used in axios
3643
+ */
3644
+ function createRequestConfig(_ref) {
3645
+ var query = _ref.query;
3646
+ var config = {};
3647
+ delete query.resolveLinks;
3648
+ config.params = fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(query);
3649
+ return config;
3639
3650
  }
3640
3651
 
3641
- function _nonIterableRest() {
3642
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3652
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3653
+ function enforceObjPath(obj, path) {
3654
+ if (!(path in obj)) {
3655
+ var err = new Error();
3656
+ err.name = 'PropertyMissing';
3657
+ err.message = "Required property ".concat(path, " missing from:\n\n").concat(JSON.stringify(obj), "\n\n");
3658
+ throw err;
3659
+ }
3660
+
3661
+ return true;
3643
3662
  }
3644
3663
 
3645
- function _createForOfIteratorHelper(o, allowArrayLike) {
3646
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
3664
+ // copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
3665
+ function deepFreeze(object) {
3666
+ var propNames = Object.getOwnPropertyNames(object);
3647
3667
 
3648
- if (!it) {
3649
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
3650
- if (it) o = it;
3651
- var i = 0;
3668
+ var _iterator = _createForOfIteratorHelper(propNames),
3669
+ _step;
3652
3670
 
3653
- var F = function () {};
3671
+ try {
3672
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3673
+ var name = _step.value;
3674
+ var value = object[name];
3654
3675
 
3655
- return {
3656
- s: F,
3657
- n: function () {
3658
- if (i >= o.length) return {
3659
- done: true
3660
- };
3661
- return {
3662
- done: false,
3663
- value: o[i++]
3664
- };
3665
- },
3666
- e: function (e) {
3667
- throw e;
3668
- },
3669
- f: F
3670
- };
3676
+ if (value && _typeof(value) === 'object') {
3677
+ deepFreeze(value);
3678
+ }
3671
3679
  }
3672
-
3673
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3680
+ } catch (err) {
3681
+ _iterator.e(err);
3682
+ } finally {
3683
+ _iterator.f();
3674
3684
  }
3675
3685
 
3676
- var normalCompletion = true,
3677
- didErr = false,
3678
- err;
3679
- return {
3680
- s: function () {
3681
- it = it.call(o);
3682
- },
3683
- n: function () {
3684
- var step = it.next();
3685
- normalCompletion = step.done;
3686
- return step;
3687
- },
3688
- e: function (e) {
3689
- didErr = true;
3690
- err = e;
3691
- },
3692
- f: function () {
3693
- try {
3694
- if (!normalCompletion && it.return != null) it.return();
3695
- } finally {
3696
- if (didErr) throw err;
3697
- }
3698
- }
3699
- };
3686
+ return Object.freeze(object);
3700
3687
  }
3701
3688
 
3702
- function isNode() {
3703
- /**
3704
- * Polyfills of 'process' might set process.browser === true
3705
- *
3706
- * See:
3707
- * https://github.com/webpack/node-libs-browser/blob/master/mock/process.js#L8
3708
- * https://github.com/defunctzombie/node-process/blob/master/browser.js#L156
3709
- **/
3710
- return typeof process !== 'undefined' && !process.browser;
3711
- }
3712
- function isReactNative() {
3713
- return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
3714
- }
3715
- function getNodeVersion() {
3716
- return process.versions && process.versions.node ? "v".concat(process.versions.node) : process.version;
3717
- }
3718
- function getWindow() {
3719
- return window;
3720
- }
3721
- function noop() {
3722
- return undefined;
3689
+ function freezeSys(obj) {
3690
+ deepFreeze(obj.sys || {});
3691
+ return obj;
3723
3692
  }
3724
3693
 
3725
- var PERCENTAGE_REGEX = /*#__PURE__*/_wrapRegExp(/(\d+)(%)/, {
3726
- value: 1
3727
- });
3694
+ function getBrowserOS() {
3695
+ var win = getWindow();
3728
3696
 
3729
- function calculateLimit(type) {
3730
- var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 7;
3731
- var limit = max;
3697
+ if (!win) {
3698
+ return null;
3699
+ }
3732
3700
 
3733
- if (PERCENTAGE_REGEX.test(type)) {
3734
- var _type$match;
3701
+ var userAgent = win.navigator.userAgent; // TODO: platform is deprecated.
3735
3702
 
3736
- var groups = (_type$match = type.match(PERCENTAGE_REGEX)) === null || _type$match === void 0 ? void 0 : _type$match.groups;
3703
+ var platform = win.navigator.platform;
3704
+ var macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
3705
+ var windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
3706
+ var iosPlatforms = ['iPhone', 'iPad', 'iPod'];
3737
3707
 
3738
- if (groups && groups.value) {
3739
- var percentage = parseInt(groups.value) / 100;
3740
- limit = Math.round(max * percentage);
3741
- }
3708
+ if (macosPlatforms.indexOf(platform) !== -1) {
3709
+ return 'macOS';
3710
+ } else if (iosPlatforms.indexOf(platform) !== -1) {
3711
+ return 'iOS';
3712
+ } else if (windowsPlatforms.indexOf(platform) !== -1) {
3713
+ return 'Windows';
3714
+ } else if (/Android/.test(userAgent)) {
3715
+ return 'Android';
3716
+ } else if (/Linux/.test(platform)) {
3717
+ return 'Linux';
3742
3718
  }
3743
3719
 
3744
- return Math.min(30, Math.max(1, limit));
3745
- }
3746
-
3747
- function createThrottle(limit, logger) {
3748
- logger('info', "Throttle request to ".concat(limit, "/s"));
3749
- return p_throttle__WEBPACK_IMPORTED_MODULE_3___default()({
3750
- limit: limit,
3751
- interval: 1000,
3752
- strict: false
3753
- });
3720
+ return null;
3754
3721
  }
3755
3722
 
3756
- var rateLimitThrottle = (function (axiosInstance) {
3757
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'auto';
3758
- var _axiosInstance$defaul = axiosInstance.defaults.logHandler,
3759
- logHandler = _axiosInstance$defaul === void 0 ? noop : _axiosInstance$defaul;
3760
- var limit = lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default()(type) ? calculateLimit(type) : calculateLimit('auto', type);
3761
- var throttle = createThrottle(limit, logHandler);
3762
- var isCalculated = false;
3763
- var requestInterceptorId = axiosInstance.interceptors.request.use(function (config) {
3764
- return throttle(function () {
3765
- return config;
3766
- })();
3767
- }, function (error) {
3768
- return Promise.reject(error);
3769
- });
3770
- var responseInterceptorId = axiosInstance.interceptors.response.use(function (response) {
3771
- if (!isCalculated && lodash_isstring__WEBPACK_IMPORTED_MODULE_2___default()(type) && (type === 'auto' || PERCENTAGE_REGEX.test(type)) && response.headers && response.headers['x-contentful-ratelimit-second-limit']) {
3772
- var rawLimit = parseInt(response.headers['x-contentful-ratelimit-second-limit']);
3773
- var nextLimit = calculateLimit(type, rawLimit);
3723
+ function getNodeOS() {
3724
+ var platform = process.platform || 'linux';
3725
+ var version = process.version || '0.0.0';
3726
+ var platformMap = {
3727
+ android: 'Android',
3728
+ aix: 'Linux',
3729
+ darwin: 'macOS',
3730
+ freebsd: 'Linux',
3731
+ linux: 'Linux',
3732
+ openbsd: 'Linux',
3733
+ sunos: 'Linux',
3734
+ win32: 'Windows'
3735
+ };
3774
3736
 
3775
- if (nextLimit !== limit) {
3776
- if (requestInterceptorId) {
3777
- axiosInstance.interceptors.request.eject(requestInterceptorId);
3778
- }
3737
+ if (platform in platformMap) {
3738
+ return "".concat(platformMap[platform] || 'Linux', "/").concat(version);
3739
+ }
3779
3740
 
3780
- limit = nextLimit;
3781
- throttle = createThrottle(nextLimit, logHandler);
3782
- requestInterceptorId = axiosInstance.interceptors.request.use(function (config) {
3783
- return throttle(function () {
3784
- return config;
3785
- })();
3786
- }, function (error) {
3787
- return Promise.reject(error);
3788
- });
3789
- }
3741
+ return null;
3742
+ }
3790
3743
 
3791
- isCalculated = true;
3744
+ function getUserAgentHeader(sdk, application, integration, feature) {
3745
+ var headerParts = [];
3746
+
3747
+ if (application) {
3748
+ headerParts.push("app ".concat(application));
3749
+ }
3750
+
3751
+ if (integration) {
3752
+ headerParts.push("integration ".concat(integration));
3753
+ }
3754
+
3755
+ if (feature) {
3756
+ headerParts.push('feature ' + feature);
3757
+ }
3758
+
3759
+ headerParts.push("sdk ".concat(sdk));
3760
+ var platform = null;
3761
+
3762
+ try {
3763
+ if (isReactNative()) {
3764
+ platform = getBrowserOS();
3765
+ headerParts.push('platform ReactNative');
3766
+ } else if (isNode()) {
3767
+ platform = getNodeOS();
3768
+ headerParts.push("platform node.js/".concat(getNodeVersion()));
3769
+ } else {
3770
+ platform = getBrowserOS();
3771
+ headerParts.push('platform browser');
3792
3772
  }
3773
+ } catch (e) {
3774
+ platform = null;
3775
+ }
3793
3776
 
3794
- return response;
3795
- }, function (error) {
3796
- return Promise.reject(error);
3797
- });
3798
- return function () {
3799
- axiosInstance.interceptors.request.eject(requestInterceptorId);
3800
- axiosInstance.interceptors.response.eject(responseInterceptorId);
3801
- };
3802
- });
3777
+ if (platform) {
3778
+ headerParts.push("os ".concat(platform));
3779
+ }
3803
3780
 
3804
- var delay = function delay(ms) {
3805
- return new Promise(function (resolve) {
3806
- setTimeout(resolve, ms);
3807
- });
3808
- };
3781
+ return "".concat(headerParts.filter(function (item) {
3782
+ return item !== '';
3783
+ }).join('; '), ";");
3784
+ }
3809
3785
 
3810
- var defaultWait = function defaultWait(attempts) {
3811
- return Math.pow(Math.SQRT2, attempts);
3812
- };
3786
+ /**
3787
+ * Mixes in a method to return just a plain object with no additional methods
3788
+ * @private
3789
+ * @param data - Any plain JSON response returned from the API
3790
+ * @return Enhanced object with toPlainObject method
3791
+ */
3813
3792
 
3814
- function rateLimit(instance) {
3815
- var maxRetry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
3816
- var _instance$defaults = instance.defaults,
3817
- _instance$defaults$re = _instance$defaults.responseLogger,
3818
- responseLogger = _instance$defaults$re === void 0 ? noop : _instance$defaults$re,
3819
- _instance$defaults$re2 = _instance$defaults.requestLogger,
3820
- requestLogger = _instance$defaults$re2 === void 0 ? noop : _instance$defaults$re2;
3821
- instance.interceptors.request.use(function (config) {
3822
- requestLogger(config);
3823
- return config;
3824
- }, function (error) {
3825
- requestLogger(error);
3826
- return Promise.reject(error);
3793
+ function toPlainObject(data) {
3794
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3795
+ // @ts-expect-error
3796
+ return Object.defineProperty(data, 'toPlainObject', {
3797
+ enumerable: false,
3798
+ configurable: false,
3799
+ writable: false,
3800
+ value: function value() {
3801
+ return fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(this);
3802
+ }
3827
3803
  });
3828
- instance.interceptors.response.use(function (response) {
3829
- // we don't need to do anything here
3830
- responseLogger(response);
3831
- return response;
3832
- }, function (error) {
3833
- var response = error.response;
3834
- var config = error.config;
3835
- responseLogger(error); // Do not retry if it is disabled or no request config exists (not an axios error)
3804
+ }
3836
3805
 
3837
- if (!config || !instance.defaults.retryOnError) {
3838
- return Promise.reject(error);
3839
- } // Retried already for max attempts
3806
+ /**
3807
+ * Handles errors received from the server. Parses the error into a more useful
3808
+ * format, places it in an exception and throws it.
3809
+ * See https://www.contentful.com/developers/docs/references/errors/
3810
+ * for more details on the data received on the errorResponse.data property
3811
+ * and the expected error codes.
3812
+ * @private
3813
+ */
3814
+ function errorHandler(errorResponse) {
3815
+ var config = errorResponse.config,
3816
+ response = errorResponse.response;
3817
+ var errorName; // Obscure the Management token
3818
+
3819
+ if (config && config.headers && config.headers['Authorization']) {
3820
+ var token = "...".concat(config.headers['Authorization'].toString().substr(-5));
3821
+ config.headers['Authorization'] = "Bearer ".concat(token);
3822
+ }
3840
3823
 
3824
+ if (!lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(response) || !lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(config)) {
3825
+ throw errorResponse;
3826
+ }
3841
3827
 
3842
- var doneAttempts = config.attempts || 1;
3828
+ var data = response === null || response === void 0 ? void 0 : response.data;
3829
+ var errorData = {
3830
+ status: response === null || response === void 0 ? void 0 : response.status,
3831
+ statusText: response === null || response === void 0 ? void 0 : response.statusText,
3832
+ message: '',
3833
+ details: {}
3834
+ };
3843
3835
 
3844
- if (doneAttempts > maxRetry) {
3845
- error.attempts = config.attempts;
3846
- return Promise.reject(error);
3836
+ if (lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(config)) {
3837
+ errorData.request = {
3838
+ url: config.url,
3839
+ headers: config.headers,
3840
+ method: config.method,
3841
+ payloadData: config.data
3842
+ };
3843
+ }
3844
+
3845
+ if (data && lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(data)) {
3846
+ if ('requestId' in data) {
3847
+ errorData.requestId = data.requestId || 'UNKNOWN';
3847
3848
  }
3848
3849
 
3849
- var retryErrorType = null;
3850
- var wait = defaultWait(doneAttempts); // Errors without response did not receive anything from the server
3850
+ if ('message' in data) {
3851
+ errorData.message = data.message || '';
3852
+ }
3851
3853
 
3852
- if (!response) {
3853
- retryErrorType = 'Connection';
3854
- } else if (response.status >= 500 && response.status < 600) {
3855
- // 5** errors are server related
3856
- retryErrorType = "Server ".concat(response.status);
3857
- } else if (response.status === 429) {
3858
- // 429 errors are exceeded rate limit exceptions
3859
- retryErrorType = 'Rate limit'; // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
3854
+ if ('details' in data) {
3855
+ errorData.details = data.details || {};
3856
+ }
3860
3857
 
3861
- if (response.headers && error.response.headers['x-contentful-ratelimit-reset']) {
3862
- wait = response.headers['x-contentful-ratelimit-reset'];
3858
+ if ('sys' in data) {
3859
+ if ('id' in data.sys) {
3860
+ errorName = data.sys.id;
3863
3861
  }
3864
3862
  }
3863
+ }
3865
3864
 
3866
- if (retryErrorType) {
3867
- // convert to ms and add jitter
3868
- wait = Math.floor(wait * 1000 + Math.random() * 200 + 500);
3869
- instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying...")); // increase attempts counter
3865
+ var error = new Error();
3866
+ error.name = errorName && errorName !== 'Unknown' ? errorName : "".concat(response === null || response === void 0 ? void 0 : response.status, " ").concat(response === null || response === void 0 ? void 0 : response.statusText);
3870
3867
 
3871
- config.attempts = doneAttempts + 1;
3872
- /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object
3873
- to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry
3874
- requests still use the original http/httpsAgent property */
3868
+ try {
3869
+ error.message = JSON.stringify(errorData, null, ' ');
3870
+ } catch (_unused) {
3871
+ var _errorData$message;
3875
3872
 
3876
- delete config.httpAgent;
3877
- delete config.httpsAgent;
3878
- return delay(wait).then(function () {
3879
- return instance(config);
3880
- });
3881
- }
3873
+ error.message = (_errorData$message = errorData === null || errorData === void 0 ? void 0 : errorData.message) !== null && _errorData$message !== void 0 ? _errorData$message : '';
3874
+ }
3882
3875
 
3883
- return Promise.reject(error);
3884
- });
3876
+ throw error;
3885
3877
  }
3886
3878
 
3887
- function asyncToken(instance, getToken) {
3888
- instance.interceptors.request.use(function (config) {
3889
- return getToken().then(function (accessToken) {
3890
- config.headers = _objectSpread2(_objectSpread2({}, config.headers), {}, {
3891
- Authorization: "Bearer ".concat(accessToken)
3892
- });
3893
- return config;
3894
- });
3895
- });
3896
- }
3897
3879
 
3898
- // Also enforces toplevel domain specified, no spaces and no protocol
3899
3880
 
3900
- var HOST_REGEX = /^(?!\w+:\/\/)([^\s:]+\.?[^\s:]+)(?::(\d+))?(?!:)$/;
3901
- /**
3902
- * Create pre configured axios instance
3903
- * @private
3904
- * @param {AxiosStatic} axios - Axios library
3905
- * @param {CreateHttpClientParams} options - Initialization parameters for the HTTP client
3906
- * @return {ContentfulAxiosInstance} Initialized axios instance
3907
- */
3881
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "../node_modules/process/browser.js")))
3908
3882
 
3909
- function createHttpClient(axios, options) {
3910
- var defaultConfig = {
3911
- insecure: false,
3912
- retryOnError: true,
3913
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3914
- logHandler: function logHandler(level, data) {
3915
- if (level === 'error' && data) {
3916
- var title = [data.name, data.message].filter(function (a) {
3917
- return a;
3918
- }).join(' - ');
3919
- console.error("[error] ".concat(title));
3920
- console.error(data);
3921
- return;
3922
- }
3923
-
3924
- console.log("[".concat(level, "] ").concat(data));
3925
- },
3926
- // Passed to axios
3927
- headers: {},
3928
- httpAgent: false,
3929
- httpsAgent: false,
3930
- timeout: 30000,
3931
- throttle: 0,
3932
- proxy: false,
3933
- basePath: '',
3934
- adapter: undefined,
3935
- maxContentLength: 1073741824,
3936
- // 1GB
3937
- maxBodyLength: 1073741824 // 1GB
3938
-
3939
- };
3940
-
3941
- var config = _objectSpread2(_objectSpread2({}, defaultConfig), options);
3942
-
3943
- if (!config.accessToken) {
3944
- var missingAccessTokenError = new TypeError('Expected parameter accessToken');
3945
- config.logHandler('error', missingAccessTokenError);
3946
- throw missingAccessTokenError;
3947
- } // Construct axios baseURL option
3948
-
3949
-
3950
- var protocol = config.insecure ? 'http' : 'https';
3951
- var space = config.space ? "".concat(config.space, "/") : '';
3952
- var hostname = config.defaultHostname;
3953
- var port = config.insecure ? 80 : 443;
3954
-
3955
- if (config.host && HOST_REGEX.test(config.host)) {
3956
- var parsed = config.host.split(':');
3883
+ /***/ }),
3957
3884
 
3958
- if (parsed.length === 2) {
3885
+ /***/ "../node_modules/contentful-sdk-core/node_modules/fast-copy/dist/umd/index.js":
3886
+ /*!************************************************************************************!*\
3887
+ !*** ../node_modules/contentful-sdk-core/node_modules/fast-copy/dist/umd/index.js ***!
3888
+ \************************************************************************************/
3889
+ /*! no static exports found */
3890
+ /***/ (function(module, exports, __webpack_require__) {
3959
3891
 
3960
- var _parsed = _slicedToArray(parsed, 2);
3892
+ (function (global, factory) {
3893
+ true ? factory(exports) :
3894
+ undefined;
3895
+ })(this, (function (exports) { 'use strict';
3961
3896
 
3962
- hostname = _parsed[0];
3963
- port = _parsed[1];
3964
- } else {
3965
- hostname = parsed[0];
3897
+ var toStringFunction = Function.prototype.toString;
3898
+ var create = Object.create;
3899
+ var toStringObject = Object.prototype.toString;
3900
+ /**
3901
+ * @classdesc Fallback cache for when WeakMap is not natively supported
3902
+ */
3903
+ var LegacyCache = /** @class */ (function () {
3904
+ function LegacyCache() {
3905
+ this._keys = [];
3906
+ this._values = [];
3907
+ }
3908
+ LegacyCache.prototype.has = function (key) {
3909
+ return !!~this._keys.indexOf(key);
3910
+ };
3911
+ LegacyCache.prototype.get = function (key) {
3912
+ return this._values[this._keys.indexOf(key)];
3913
+ };
3914
+ LegacyCache.prototype.set = function (key, value) {
3915
+ this._keys.push(key);
3916
+ this._values.push(value);
3917
+ };
3918
+ return LegacyCache;
3919
+ }());
3920
+ function createCacheLegacy() {
3921
+ return new LegacyCache();
3966
3922
  }
3967
- } // Ensure that basePath does start but not end with a slash
3968
-
3969
-
3970
- if (config.basePath) {
3971
- config.basePath = "/".concat(config.basePath.split('/').filter(Boolean).join('/'));
3972
- }
3973
-
3974
- var baseURL = options.baseURL || "".concat(protocol, "://").concat(hostname, ":").concat(port).concat(config.basePath, "/spaces/").concat(space);
3975
-
3976
- if (!config.headers.Authorization && typeof config.accessToken !== 'function') {
3977
- config.headers.Authorization = 'Bearer ' + config.accessToken;
3978
- } // Set these headers only for node because browsers don't like it when you
3979
- // override user-agent or accept-encoding.
3980
- // The SDKs should set their own X-Contentful-User-Agent.
3981
-
3982
-
3983
- if (isNode()) {
3984
- config.headers['user-agent'] = 'node.js/' + getNodeVersion();
3985
- config.headers['Accept-Encoding'] = 'gzip';
3986
- }
3987
-
3988
- var axiosOptions = {
3989
- // Axios
3990
- baseURL: baseURL,
3991
- headers: config.headers,
3992
- httpAgent: config.httpAgent,
3993
- httpsAgent: config.httpsAgent,
3994
- paramsSerializer: qs__WEBPACK_IMPORTED_MODULE_1___default.a.stringify,
3995
- proxy: config.proxy,
3996
- timeout: config.timeout,
3997
- adapter: config.adapter,
3998
- maxContentLength: config.maxContentLength,
3999
- maxBodyLength: config.maxBodyLength,
4000
- // Contentful
4001
- logHandler: config.logHandler,
4002
- responseLogger: config.responseLogger,
4003
- requestLogger: config.requestLogger,
4004
- retryOnError: config.retryOnError
4005
- };
4006
- var instance = axios.create(axiosOptions);
4007
- instance.httpClientParams = options;
4008
- /**
4009
- * Creates a new axios instance with the same default base parameters as the
4010
- * current one, and with any overrides passed to the newParams object
4011
- * This is useful as the SDKs use dependency injection to get the axios library
4012
- * and the version of the library comes from different places depending
4013
- * on whether it's a browser build or a node.js build.
4014
- * @private
4015
- * @param {CreateHttpClientParams} httpClientParams - Initialization parameters for the HTTP client
4016
- * @return {ContentfulAxiosInstance} Initialized axios instance
4017
- */
4018
-
4019
- instance.cloneWithNewParams = function (newParams) {
4020
- return createHttpClient(axios, _objectSpread2(_objectSpread2({}, fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(options)), newParams));
4021
- };
4022
- /**
4023
- * Apply interceptors.
4024
- * Please note that the order of interceptors is important
4025
- */
4026
-
4027
-
4028
- if (config.onBeforeRequest) {
4029
- instance.interceptors.request.use(config.onBeforeRequest);
4030
- }
4031
-
4032
- if (typeof config.accessToken === 'function') {
4033
- asyncToken(instance, config.accessToken);
4034
- }
4035
-
4036
- if (config.throttle) {
4037
- rateLimitThrottle(instance, config.throttle);
4038
- }
4039
-
4040
- rateLimit(instance, config.retryLimit);
4041
-
4042
- if (config.onError) {
4043
- instance.interceptors.response.use(function (response) {
4044
- return response;
4045
- }, config.onError);
4046
- }
4047
-
4048
- return instance;
4049
- }
4050
-
4051
- /* eslint-disable @typescript-eslint/no-explicit-any */
4052
-
4053
- /**
4054
- * Creates request parameters configuration by parsing an existing query object
4055
- * @private
4056
- * @param {Object} query
4057
- * @return {Object} Config object with `params` property, ready to be used in axios
4058
- */
4059
- function createRequestConfig(_ref) {
4060
- var query = _ref.query;
4061
- var config = {};
4062
- delete query.resolveLinks;
4063
- config.params = fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(query);
4064
- return config;
4065
- }
4066
-
4067
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4068
- function enforceObjPath(obj, path) {
4069
- if (!(path in obj)) {
4070
- var err = new Error();
4071
- err.name = 'PropertyMissing';
4072
- err.message = "Required property ".concat(path, " missing from:\n\n").concat(JSON.stringify(obj), "\n\n");
4073
- throw err;
4074
- }
4075
-
4076
- return true;
4077
- }
4078
-
4079
- // copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
4080
- function deepFreeze(object) {
4081
- var propNames = Object.getOwnPropertyNames(object);
4082
-
4083
- var _iterator = _createForOfIteratorHelper(propNames),
4084
- _step;
4085
-
4086
- try {
4087
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
4088
- var name = _step.value;
4089
- var value = object[name];
4090
-
4091
- if (value && _typeof(value) === 'object') {
4092
- deepFreeze(value);
4093
- }
3923
+ function createCacheModern() {
3924
+ return new WeakMap();
4094
3925
  }
4095
- } catch (err) {
4096
- _iterator.e(err);
4097
- } finally {
4098
- _iterator.f();
4099
- }
4100
-
4101
- return Object.freeze(object);
4102
- }
4103
-
4104
- function freezeSys(obj) {
4105
- deepFreeze(obj.sys || {});
4106
- return obj;
4107
- }
4108
-
4109
- function getBrowserOS() {
4110
- var win = getWindow();
4111
-
4112
- if (!win) {
4113
- return null;
4114
- }
4115
-
4116
- var userAgent = win.navigator.userAgent; // TODO: platform is deprecated.
4117
-
4118
- var platform = win.navigator.platform;
4119
- var macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
4120
- var windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
4121
- var iosPlatforms = ['iPhone', 'iPad', 'iPod'];
4122
-
4123
- if (macosPlatforms.indexOf(platform) !== -1) {
4124
- return 'macOS';
4125
- } else if (iosPlatforms.indexOf(platform) !== -1) {
4126
- return 'iOS';
4127
- } else if (windowsPlatforms.indexOf(platform) !== -1) {
4128
- return 'Windows';
4129
- } else if (/Android/.test(userAgent)) {
4130
- return 'Android';
4131
- } else if (/Linux/.test(platform)) {
4132
- return 'Linux';
4133
- }
4134
-
4135
- return null;
4136
- }
4137
-
4138
- function getNodeOS() {
4139
- var platform = process.platform || 'linux';
4140
- var version = process.version || '0.0.0';
4141
- var platformMap = {
4142
- android: 'Android',
4143
- aix: 'Linux',
4144
- darwin: 'macOS',
4145
- freebsd: 'Linux',
4146
- linux: 'Linux',
4147
- openbsd: 'Linux',
4148
- sunos: 'Linux',
4149
- win32: 'Windows'
4150
- };
4151
-
4152
- if (platform in platformMap) {
4153
- return "".concat(platformMap[platform] || 'Linux', "/").concat(version);
4154
- }
4155
-
4156
- return null;
4157
- }
4158
-
4159
- function getUserAgentHeader(sdk, application, integration, feature) {
4160
- var headerParts = [];
4161
-
4162
- if (application) {
4163
- headerParts.push("app ".concat(application));
4164
- }
4165
-
4166
- if (integration) {
4167
- headerParts.push("integration ".concat(integration));
4168
- }
4169
-
4170
- if (feature) {
4171
- headerParts.push('feature ' + feature);
4172
- }
4173
-
4174
- headerParts.push("sdk ".concat(sdk));
4175
- var platform = null;
3926
+ /**
3927
+ * Get a new cache object to prevent circular references.
3928
+ */
3929
+ var createCache = typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;
3930
+ /**
3931
+ * Get an empty version of the object with the same prototype it has.
3932
+ */
3933
+ function getCleanClone(prototype) {
3934
+ if (!prototype) {
3935
+ return create(null);
3936
+ }
3937
+ var Constructor = prototype.constructor;
3938
+ if (Constructor === Object) {
3939
+ return prototype === Object.prototype ? {} : create(prototype);
3940
+ }
3941
+ if (~toStringFunction.call(Constructor).indexOf('[native code]')) {
3942
+ try {
3943
+ return new Constructor();
3944
+ }
3945
+ catch (_a) { }
3946
+ }
3947
+ return create(prototype);
3948
+ }
3949
+ function getRegExpFlagsLegacy(regExp) {
3950
+ var flags = '';
3951
+ if (regExp.global) {
3952
+ flags += 'g';
3953
+ }
3954
+ if (regExp.ignoreCase) {
3955
+ flags += 'i';
3956
+ }
3957
+ if (regExp.multiline) {
3958
+ flags += 'm';
3959
+ }
3960
+ if (regExp.unicode) {
3961
+ flags += 'u';
3962
+ }
3963
+ if (regExp.sticky) {
3964
+ flags += 'y';
3965
+ }
3966
+ return flags;
3967
+ }
3968
+ function getRegExpFlagsModern(regExp) {
3969
+ return regExp.flags;
3970
+ }
3971
+ /**
3972
+ * Get the flags to apply to the copied regexp.
3973
+ */
3974
+ var getRegExpFlags = /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;
3975
+ function getTagLegacy(value) {
3976
+ var type = toStringObject.call(value);
3977
+ return type.substring(8, type.length - 1);
3978
+ }
3979
+ function getTagModern(value) {
3980
+ return value[Symbol.toStringTag] || getTagLegacy(value);
3981
+ }
3982
+ /**
3983
+ * Get the tag of the value passed, so that the correct copier can be used.
3984
+ */
3985
+ var getTag = typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;
4176
3986
 
4177
- try {
4178
- if (isReactNative()) {
4179
- platform = getBrowserOS();
4180
- headerParts.push('platform ReactNative');
4181
- } else if (isNode()) {
4182
- platform = getNodeOS();
4183
- headerParts.push("platform node.js/".concat(getNodeVersion()));
4184
- } else {
4185
- platform = getBrowserOS();
4186
- headerParts.push('platform browser');
3987
+ var defineProperty = Object.defineProperty, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
3988
+ var _a = Object.prototype, hasOwnProperty = _a.hasOwnProperty, propertyIsEnumerable = _a.propertyIsEnumerable;
3989
+ var SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';
3990
+ function getStrictPropertiesModern(object) {
3991
+ return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
3992
+ }
3993
+ /**
3994
+ * Get the properites used when copying objects strictly. This includes both keys and symbols.
3995
+ */
3996
+ var getStrictProperties = SUPPORTS_SYMBOL
3997
+ ? getStrictPropertiesModern
3998
+ : getOwnPropertyNames;
3999
+ /**
4000
+ * Striclty copy all properties contained on the object.
4001
+ */
4002
+ function copyOwnPropertiesStrict(value, clone, state) {
4003
+ var properties = getStrictProperties(value);
4004
+ for (var index = 0, length_1 = properties.length, property = void 0, descriptor = void 0; index < length_1; ++index) {
4005
+ property = properties[index];
4006
+ if (property === 'callee' || property === 'caller') {
4007
+ continue;
4008
+ }
4009
+ descriptor = getOwnPropertyDescriptor(value, property);
4010
+ if (!descriptor) {
4011
+ // In extra edge cases where the property descriptor cannot be retrived, fall back to
4012
+ // the loose assignment.
4013
+ clone[property] = state.copier(value[property], state);
4014
+ continue;
4015
+ }
4016
+ // Only clone the value if actually a value, not a getter / setter.
4017
+ if (!descriptor.get && !descriptor.set) {
4018
+ descriptor.value = state.copier(descriptor.value, state);
4019
+ }
4020
+ try {
4021
+ defineProperty(clone, property, descriptor);
4022
+ }
4023
+ catch (error) {
4024
+ // Tee above can fail on node in edge cases, so fall back to the loose assignment.
4025
+ clone[property] = descriptor.value;
4026
+ }
4027
+ }
4028
+ return clone;
4029
+ }
4030
+ /**
4031
+ * Deeply copy the indexed values in the array.
4032
+ */
4033
+ function copyArrayLoose(array, state) {
4034
+ var clone = new state.Constructor();
4035
+ // set in the cache immediately to be able to reuse the object recursively
4036
+ state.cache.set(array, clone);
4037
+ for (var index = 0, length_2 = array.length; index < length_2; ++index) {
4038
+ clone[index] = state.copier(array[index], state);
4039
+ }
4040
+ return clone;
4041
+ }
4042
+ /**
4043
+ * Deeply copy the indexed values in the array, as well as any custom properties.
4044
+ */
4045
+ function copyArrayStrict(array, state) {
4046
+ var clone = new state.Constructor();
4047
+ // set in the cache immediately to be able to reuse the object recursively
4048
+ state.cache.set(array, clone);
4049
+ return copyOwnPropertiesStrict(array, clone, state);
4050
+ }
4051
+ /**
4052
+ * Copy the contents of the ArrayBuffer.
4053
+ */
4054
+ function copyArrayBuffer(arrayBuffer, _state) {
4055
+ return arrayBuffer.slice(0);
4056
+ }
4057
+ /**
4058
+ * Create a new Blob with the contents of the original.
4059
+ */
4060
+ function copyBlob(blob, _state) {
4061
+ return blob.slice(0, blob.size, blob.type);
4062
+ }
4063
+ /**
4064
+ * Create a new DataView with the contents of the original.
4065
+ */
4066
+ function copyDataView(dataView, state) {
4067
+ return new state.Constructor(copyArrayBuffer(dataView.buffer));
4068
+ }
4069
+ /**
4070
+ * Create a new Date based on the time of the original.
4071
+ */
4072
+ function copyDate(date, state) {
4073
+ return new state.Constructor(date.getTime());
4074
+ }
4075
+ /**
4076
+ * Deeply copy the keys and values of the original.
4077
+ */
4078
+ function copyMapLoose(map, state) {
4079
+ var clone = new state.Constructor();
4080
+ // set in the cache immediately to be able to reuse the object recursively
4081
+ state.cache.set(map, clone);
4082
+ map.forEach(function (value, key) {
4083
+ clone.set(key, state.copier(value, state));
4084
+ });
4085
+ return clone;
4086
+ }
4087
+ /**
4088
+ * Deeply copy the keys and values of the original, as well as any custom properties.
4089
+ */
4090
+ function copyMapStrict(map, state) {
4091
+ return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);
4092
+ }
4093
+ function copyObjectLooseLegacy(object, state) {
4094
+ var clone = getCleanClone(state.prototype);
4095
+ // set in the cache immediately to be able to reuse the object recursively
4096
+ state.cache.set(object, clone);
4097
+ for (var key in object) {
4098
+ if (hasOwnProperty.call(object, key)) {
4099
+ clone[key] = state.copier(object[key], state);
4100
+ }
4101
+ }
4102
+ return clone;
4103
+ }
4104
+ function copyObjectLooseModern(object, state) {
4105
+ var clone = getCleanClone(state.prototype);
4106
+ // set in the cache immediately to be able to reuse the object recursively
4107
+ state.cache.set(object, clone);
4108
+ for (var key in object) {
4109
+ if (hasOwnProperty.call(object, key)) {
4110
+ clone[key] = state.copier(object[key], state);
4111
+ }
4112
+ }
4113
+ var symbols = getOwnPropertySymbols(object);
4114
+ for (var index = 0, length_3 = symbols.length, symbol = void 0; index < length_3; ++index) {
4115
+ symbol = symbols[index];
4116
+ if (propertyIsEnumerable.call(object, symbol)) {
4117
+ clone[symbol] = state.copier(object[symbol], state);
4118
+ }
4119
+ }
4120
+ return clone;
4121
+ }
4122
+ /**
4123
+ * Deeply copy the properties (keys and symbols) and values of the original.
4124
+ */
4125
+ var copyObjectLoose = SUPPORTS_SYMBOL
4126
+ ? copyObjectLooseModern
4127
+ : copyObjectLooseLegacy;
4128
+ /**
4129
+ * Deeply copy the properties (keys and symbols) and values of the original, as well
4130
+ * as any hidden or non-enumerable properties.
4131
+ */
4132
+ function copyObjectStrict(object, state) {
4133
+ var clone = getCleanClone(state.prototype);
4134
+ // set in the cache immediately to be able to reuse the object recursively
4135
+ state.cache.set(object, clone);
4136
+ return copyOwnPropertiesStrict(object, clone, state);
4187
4137
  }
4188
- } catch (e) {
4189
- platform = null;
4190
- }
4191
-
4192
- if (platform) {
4193
- headerParts.push("os ".concat(platform));
4194
- }
4195
-
4196
- return "".concat(headerParts.filter(function (item) {
4197
- return item !== '';
4198
- }).join('; '), ";");
4199
- }
4200
-
4201
- /**
4202
- * Mixes in a method to return just a plain object with no additional methods
4203
- * @private
4204
- * @param data - Any plain JSON response returned from the API
4205
- * @return Enhanced object with toPlainObject method
4206
- */
4207
-
4208
- function toPlainObject(data) {
4209
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4210
- // @ts-expect-error
4211
- return Object.defineProperty(data, 'toPlainObject', {
4212
- enumerable: false,
4213
- configurable: false,
4214
- writable: false,
4215
- value: function value() {
4216
- return fast_copy__WEBPACK_IMPORTED_MODULE_0___default()(this);
4138
+ /**
4139
+ * Create a new primitive wrapper from the value of the original.
4140
+ */
4141
+ function copyPrimitiveWrapper(primitiveObject, state) {
4142
+ return new state.Constructor(primitiveObject.valueOf());
4217
4143
  }
4218
- });
4219
- }
4220
-
4221
- /**
4222
- * Handles errors received from the server. Parses the error into a more useful
4223
- * format, places it in an exception and throws it.
4224
- * See https://www.contentful.com/developers/docs/references/errors/
4225
- * for more details on the data received on the errorResponse.data property
4226
- * and the expected error codes.
4227
- * @private
4228
- */
4229
- function errorHandler(errorResponse) {
4230
- var config = errorResponse.config,
4231
- response = errorResponse.response;
4232
- var errorName; // Obscure the Management token
4233
-
4234
- if (config && config.headers && config.headers['Authorization']) {
4235
- var token = "...".concat(config.headers['Authorization'].toString().substr(-5));
4236
- config.headers['Authorization'] = "Bearer ".concat(token);
4237
- }
4238
-
4239
- if (!lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(response) || !lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(config)) {
4240
- throw errorResponse;
4241
- }
4242
-
4243
- var data = response === null || response === void 0 ? void 0 : response.data;
4244
- var errorData = {
4245
- status: response === null || response === void 0 ? void 0 : response.status,
4246
- statusText: response === null || response === void 0 ? void 0 : response.statusText,
4247
- message: '',
4248
- details: {}
4249
- };
4250
-
4251
- if (lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(config)) {
4252
- errorData.request = {
4253
- url: config.url,
4254
- headers: config.headers,
4255
- method: config.method,
4256
- payloadData: config.data
4257
- };
4258
- }
4259
-
4260
- if (data && lodash_isplainobject__WEBPACK_IMPORTED_MODULE_4___default()(data)) {
4261
- if ('requestId' in data) {
4262
- errorData.requestId = data.requestId || 'UNKNOWN';
4144
+ /**
4145
+ * Create a new RegExp based on the value and flags of the original.
4146
+ */
4147
+ function copyRegExp(regExp, state) {
4148
+ var clone = new state.Constructor(regExp.source, getRegExpFlags(regExp));
4149
+ clone.lastIndex = regExp.lastIndex;
4150
+ return clone;
4263
4151
  }
4264
-
4265
- if ('message' in data) {
4266
- errorData.message = data.message || '';
4152
+ /**
4153
+ * Return the original value (an identity function).
4154
+ *
4155
+ * @note
4156
+ * THis is used for objects that cannot be copied, such as WeakMap.
4157
+ */
4158
+ function copySelf(value, _state) {
4159
+ return value;
4267
4160
  }
4268
-
4269
- if ('details' in data) {
4270
- errorData.details = data.details || {};
4161
+ /**
4162
+ * Deeply copy the values of the original.
4163
+ */
4164
+ function copySetLoose(set, state) {
4165
+ var clone = new state.Constructor();
4166
+ // set in the cache immediately to be able to reuse the object recursively
4167
+ state.cache.set(set, clone);
4168
+ set.forEach(function (value) {
4169
+ clone.add(state.copier(value, state));
4170
+ });
4171
+ return clone;
4271
4172
  }
4272
-
4273
- if ('sys' in data) {
4274
- if ('id' in data.sys) {
4275
- errorName = data.sys.id;
4276
- }
4173
+ /**
4174
+ * Deeply copy the values of the original, as well as any custom properties.
4175
+ */
4176
+ function copySetStrict(set, state) {
4177
+ return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);
4277
4178
  }
4278
- }
4279
-
4280
- var error = new Error();
4281
- error.name = errorName && errorName !== 'Unknown' ? errorName : "".concat(response === null || response === void 0 ? void 0 : response.status, " ").concat(response === null || response === void 0 ? void 0 : response.statusText);
4282
-
4283
- try {
4284
- error.message = JSON.stringify(errorData, null, ' ');
4285
- } catch (_unused) {
4286
- var _errorData$message;
4287
4179
 
4288
- error.message = (_errorData$message = errorData === null || errorData === void 0 ? void 0 : errorData.message) !== null && _errorData$message !== void 0 ? _errorData$message : '';
4289
- }
4180
+ var isArray = Array.isArray;
4181
+ var assign = Object.assign, getPrototypeOf = Object.getPrototypeOf;
4182
+ var DEFAULT_LOOSE_OPTIONS = {
4183
+ array: copyArrayLoose,
4184
+ arrayBuffer: copyArrayBuffer,
4185
+ blob: copyBlob,
4186
+ dataView: copyDataView,
4187
+ date: copyDate,
4188
+ error: copySelf,
4189
+ map: copyMapLoose,
4190
+ object: copyObjectLoose,
4191
+ regExp: copyRegExp,
4192
+ set: copySetLoose,
4193
+ };
4194
+ var DEFAULT_STRICT_OPTIONS = assign({}, DEFAULT_LOOSE_OPTIONS, {
4195
+ array: copyArrayStrict,
4196
+ map: copyMapStrict,
4197
+ object: copyObjectStrict,
4198
+ set: copySetStrict,
4199
+ });
4200
+ /**
4201
+ * Get the copiers used for each specific object tag.
4202
+ */
4203
+ function getTagSpecificCopiers(options) {
4204
+ return {
4205
+ Arguments: options.object,
4206
+ Array: options.array,
4207
+ ArrayBuffer: options.arrayBuffer,
4208
+ Blob: options.blob,
4209
+ Boolean: copyPrimitiveWrapper,
4210
+ DataView: options.dataView,
4211
+ Date: options.date,
4212
+ Error: options.error,
4213
+ Float32Array: options.arrayBuffer,
4214
+ Float64Array: options.arrayBuffer,
4215
+ Int8Array: options.arrayBuffer,
4216
+ Int16Array: options.arrayBuffer,
4217
+ Int32Array: options.arrayBuffer,
4218
+ Map: options.map,
4219
+ Number: copyPrimitiveWrapper,
4220
+ Object: options.object,
4221
+ Promise: copySelf,
4222
+ RegExp: options.regExp,
4223
+ Set: options.set,
4224
+ String: copyPrimitiveWrapper,
4225
+ WeakMap: copySelf,
4226
+ WeakSet: copySelf,
4227
+ Uint8Array: options.arrayBuffer,
4228
+ Uint8ClampedArray: options.arrayBuffer,
4229
+ Uint16Array: options.arrayBuffer,
4230
+ Uint32Array: options.arrayBuffer,
4231
+ Uint64Array: options.arrayBuffer,
4232
+ };
4233
+ }
4234
+ /**
4235
+ * Create a custom copier based on the object-specific copy methods passed.
4236
+ */
4237
+ function createCopier(options) {
4238
+ var normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);
4239
+ var tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);
4240
+ var array = tagSpecificCopiers.Array, object = tagSpecificCopiers.Object;
4241
+ function copier(value, state) {
4242
+ state.prototype = state.Constructor = undefined;
4243
+ if (!value || typeof value !== 'object') {
4244
+ return value;
4245
+ }
4246
+ if (state.cache.has(value)) {
4247
+ return state.cache.get(value);
4248
+ }
4249
+ state.prototype = value.__proto__ || getPrototypeOf(value);
4250
+ state.Constructor = state.prototype && state.prototype.constructor;
4251
+ // plain objects
4252
+ if (!state.Constructor || state.Constructor === Object) {
4253
+ return object(value, state);
4254
+ }
4255
+ // arrays
4256
+ if (isArray(value)) {
4257
+ return array(value, state);
4258
+ }
4259
+ var tagSpecificCopier = tagSpecificCopiers[getTag(value)];
4260
+ if (tagSpecificCopier) {
4261
+ return tagSpecificCopier(value, state);
4262
+ }
4263
+ return typeof value.then === 'function' ? value : object(value, state);
4264
+ }
4265
+ return function copy(value) {
4266
+ return copier(value, {
4267
+ Constructor: undefined,
4268
+ cache: createCache(),
4269
+ copier: copier,
4270
+ prototype: undefined,
4271
+ });
4272
+ };
4273
+ }
4274
+ /**
4275
+ * Create a custom copier based on the object-specific copy methods passed, defaulting to the
4276
+ * same internals as `copyStrict`.
4277
+ */
4278
+ function createStrictCopier(options) {
4279
+ return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));
4280
+ }
4281
+ /**
4282
+ * Copy an value deeply as much as possible, where strict recreation of object properties
4283
+ * are maintained. All properties (including non-enumerable ones) are copied with their
4284
+ * original property descriptors on both objects and arrays.
4285
+ */
4286
+ var copyStrict = createStrictCopier({});
4287
+ /**
4288
+ * Copy an value deeply as much as possible.
4289
+ */
4290
+ var index = createCopier({});
4290
4291
 
4291
- throw error;
4292
- }
4292
+ exports.copyStrict = copyStrict;
4293
+ exports.createCopier = createCopier;
4294
+ exports.createStrictCopier = createStrictCopier;
4295
+ exports["default"] = index;
4293
4296
 
4297
+ Object.defineProperty(exports, '__esModule', { value: true });
4294
4298
 
4299
+ }));
4300
+ //# sourceMappingURL=index.js.map
4295
4301
 
4296
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "../node_modules/process/browser.js")))
4297
4302
 
4298
4303
  /***/ }),
4299
4304
 
@@ -8583,6 +8588,7 @@ var stringify = function stringify(
8583
8588
  object,
8584
8589
  prefix,
8585
8590
  generateArrayPrefix,
8591
+ commaRoundTrip,
8586
8592
  strictNullHandling,
8587
8593
  skipNulls,
8588
8594
  encoder,
@@ -8647,7 +8653,7 @@ var stringify = function stringify(
8647
8653
  for (var i = 0; i < valuesArray.length; ++i) {
8648
8654
  valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
8649
8655
  }
8650
- return [formatter(keyValue) + '=' + valuesJoined];
8656
+ return [formatter(keyValue) + (commaRoundTrip && isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
8651
8657
  }
8652
8658
  return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
8653
8659
  }
@@ -8671,6 +8677,8 @@ var stringify = function stringify(
8671
8677
  objKeys = sort ? keys.sort(sort) : keys;
8672
8678
  }
8673
8679
 
8680
+ var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
8681
+
8674
8682
  for (var j = 0; j < objKeys.length; ++j) {
8675
8683
  var key = objKeys[j];
8676
8684
  var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
@@ -8680,8 +8688,8 @@ var stringify = function stringify(
8680
8688
  }
8681
8689
 
8682
8690
  var keyPrefix = isArray(obj)
8683
- ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix
8684
- : prefix + (allowDots ? '.' + key : '[' + key + ']');
8691
+ ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
8692
+ : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
8685
8693
 
8686
8694
  sideChannel.set(object, step);
8687
8695
  var valueSideChannel = getSideChannel();
@@ -8690,6 +8698,7 @@ var stringify = function stringify(
8690
8698
  value,
8691
8699
  keyPrefix,
8692
8700
  generateArrayPrefix,
8701
+ commaRoundTrip,
8693
8702
  strictNullHandling,
8694
8703
  skipNulls,
8695
8704
  encoder,
@@ -8786,6 +8795,10 @@ module.exports = function (object, opts) {
8786
8795
  }
8787
8796
 
8788
8797
  var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
8798
+ if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
8799
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
8800
+ }
8801
+ var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
8789
8802
 
8790
8803
  if (!objKeys) {
8791
8804
  objKeys = Object.keys(obj);
@@ -8806,6 +8819,7 @@ module.exports = function (object, opts) {
8806
8819
  obj[key],
8807
8820
  key,
8808
8821
  generateArrayPrefix,
8822
+ commaRoundTrip,
8809
8823
  options.strictNullHandling,
8810
8824
  options.skipNulls,
8811
8825
  options.encode ? options.encoder : null,
@@ -9349,7 +9363,7 @@ function createClient(params) {
9349
9363
  environment: 'master'
9350
9364
  };
9351
9365
  const config = _objectSpread(_objectSpread({}, defaultConfig), params);
9352
- const userAgentHeader = Object(contentful_sdk_core__WEBPACK_IMPORTED_MODULE_1__["getUserAgentHeader"])(`contentful.js/${"9.2.6"}`, config.application, config.integration);
9366
+ const userAgentHeader = Object(contentful_sdk_core__WEBPACK_IMPORTED_MODULE_1__["getUserAgentHeader"])(`contentful.js/${"9.2.8"}`, config.application, config.integration);
9353
9367
  config.headers = _objectSpread(_objectSpread({}, config.headers), {}, {
9354
9368
  'Content-Type': 'application/vnd.contentful.delivery.v1+json',
9355
9369
  'X-Contentful-User-Agent': userAgentHeader