contentful 11.7.16 → 11.7.18

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.
@@ -27,20 +27,20 @@ var contentful = (function (exports) {
27
27
  };
28
28
  }
29
29
 
30
- function _arrayWithHoles(r) {
31
- if (Array.isArray(r)) return r;
32
- }
33
-
34
- function _iterableToArray(r) {
35
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
36
- }
37
-
38
30
  function _arrayLikeToArray$4(r, a) {
39
31
  (null == a || a > r.length) && (a = r.length);
40
32
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
41
33
  return n;
42
34
  }
43
35
 
36
+ function _arrayWithoutHoles(r) {
37
+ if (Array.isArray(r)) return _arrayLikeToArray$4(r);
38
+ }
39
+
40
+ function _iterableToArray(r) {
41
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
42
+ }
43
+
44
44
  function _unsupportedIterableToArray$4(r, a) {
45
45
  if (r) {
46
46
  if ("string" == typeof r) return _arrayLikeToArray$4(r, a);
@@ -49,18 +49,6 @@ var contentful = (function (exports) {
49
49
  }
50
50
  }
51
51
 
52
- function _nonIterableRest() {
53
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
- }
55
-
56
- function _toArray(r) {
57
- return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$4(r) || _nonIterableRest();
58
- }
59
-
60
- function _arrayWithoutHoles(r) {
61
- if (Array.isArray(r)) return _arrayLikeToArray$4(r);
62
- }
63
-
64
52
  function _nonIterableSpread() {
65
53
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
66
54
  }
@@ -120,6 +108,10 @@ var contentful = (function (exports) {
120
108
  }), e;
121
109
  }
122
110
 
111
+ function _arrayWithHoles(r) {
112
+ if (Array.isArray(r)) return r;
113
+ }
114
+
123
115
  function _iterableToArrayLimit(r, l) {
124
116
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
125
117
  if (null != t) {
@@ -148,6 +140,10 @@ var contentful = (function (exports) {
148
140
  }
149
141
  }
150
142
 
143
+ function _nonIterableRest() {
144
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
145
+ }
146
+
151
147
  function _slicedToArray$1(r, e) {
152
148
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$4(r, e) || _nonIterableRest();
153
149
  }
@@ -676,7 +672,7 @@ var contentful = (function (exports) {
676
672
  * @returns {boolean} True if value is a Buffer, otherwise false
677
673
  */
678
674
  function isBuffer$1(val) {
679
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
675
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
680
676
  }
681
677
 
682
678
  /**
@@ -720,7 +716,7 @@ var contentful = (function (exports) {
720
716
  * @param {*} val The value to test
721
717
  * @returns {boolean} True if value is a Function, otherwise false
722
718
  */
723
- var isFunction = typeOfTest('function');
719
+ var isFunction$1 = typeOfTest('function');
724
720
 
725
721
  /**
726
722
  * Determine if a value is a Number
@@ -831,7 +827,7 @@ var contentful = (function (exports) {
831
827
  * @returns {boolean} True if value is a Stream, otherwise false
832
828
  */
833
829
  var isStream = function isStream(val) {
834
- return isObject(val) && isFunction(val.pipe);
830
+ return isObject(val) && isFunction$1(val.pipe);
835
831
  };
836
832
 
837
833
  /**
@@ -843,9 +839,9 @@ var contentful = (function (exports) {
843
839
  */
844
840
  var isFormData = function isFormData(thing) {
845
841
  var kind;
846
- return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
842
+ return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
847
843
  // detect form-data instance
848
- kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]'));
844
+ kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
849
845
  };
850
846
 
851
847
  /**
@@ -972,7 +968,8 @@ var contentful = (function (exports) {
972
968
  function merge$1(/* obj1, obj2, obj3, ... */
973
969
  ) {
974
970
  var _ref4 = isContextDefined(this) && this || {},
975
- caseless = _ref4.caseless;
971
+ caseless = _ref4.caseless,
972
+ skipUndefined = _ref4.skipUndefined;
976
973
  var result = {};
977
974
  var assignValue = function assignValue(val, key) {
978
975
  var targetKey = caseless && findKey(result, key) || key;
@@ -982,7 +979,7 @@ var contentful = (function (exports) {
982
979
  result[targetKey] = merge$1({}, val);
983
980
  } else if (isArray$7(val)) {
984
981
  result[targetKey] = val.slice();
985
- } else {
982
+ } else if (!skipUndefined || !isUndefined(val)) {
986
983
  result[targetKey] = val;
987
984
  }
988
985
  };
@@ -1006,7 +1003,7 @@ var contentful = (function (exports) {
1006
1003
  var _ref5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
1007
1004
  allOwnKeys = _ref5.allOwnKeys;
1008
1005
  forEach(b, function (val, key) {
1009
- if (thisArg && isFunction(val)) {
1006
+ if (thisArg && isFunction$1(val)) {
1010
1007
  a[key] = bind$1(val, thisArg);
1011
1008
  } else {
1012
1009
  a[key] = val;
@@ -1214,11 +1211,11 @@ var contentful = (function (exports) {
1214
1211
  var freezeMethods = function freezeMethods(obj) {
1215
1212
  reduceDescriptors(obj, function (descriptor, name) {
1216
1213
  // skip restricted props in strict mode
1217
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1214
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1218
1215
  return false;
1219
1216
  }
1220
1217
  var value = obj[name];
1221
- if (!isFunction(value)) return;
1218
+ if (!isFunction$1(value)) return;
1222
1219
  descriptor.enumerable = false;
1223
1220
  if ('writable' in descriptor) {
1224
1221
  descriptor.writable = false;
@@ -1254,7 +1251,7 @@ var contentful = (function (exports) {
1254
1251
  * @returns {boolean}
1255
1252
  */
1256
1253
  function isSpecCompliantForm(thing) {
1257
- return !!(thing && isFunction(thing.append) && thing[toStringTag$1] === 'FormData' && thing[iterator]);
1254
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag$1] === 'FormData' && thing[iterator]);
1258
1255
  }
1259
1256
  var toJSONObject = function toJSONObject(obj) {
1260
1257
  var stack = new Array(10);
@@ -1285,7 +1282,7 @@ var contentful = (function (exports) {
1285
1282
  };
1286
1283
  var isAsyncFn = kindOfTest('AsyncFunction');
1287
1284
  var isThenable = function isThenable(thing) {
1288
- return thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
1285
+ return thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
1289
1286
  };
1290
1287
 
1291
1288
  // original code
@@ -1310,13 +1307,13 @@ var contentful = (function (exports) {
1310
1307
  }("axios@".concat(Math.random()), []) : function (cb) {
1311
1308
  return setTimeout(cb);
1312
1309
  };
1313
- }(typeof setImmediate === 'function', isFunction(_global.postMessage));
1310
+ }(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
1314
1311
  var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
1315
1312
 
1316
1313
  // *********************
1317
1314
 
1318
1315
  var isIterable = function isIterable(thing) {
1319
- return thing != null && isFunction(thing[iterator]);
1316
+ return thing != null && isFunction$1(thing[iterator]);
1320
1317
  };
1321
1318
  var utils$1$1 = {
1322
1319
  isArray: isArray$7,
@@ -1339,7 +1336,7 @@ var contentful = (function (exports) {
1339
1336
  isFile: isFile,
1340
1337
  isBlob: isBlob,
1341
1338
  isRegExp: isRegExp$2,
1342
- isFunction: isFunction,
1339
+ isFunction: isFunction$1,
1343
1340
  isStream: isStream,
1344
1341
  isURLSearchParams: isURLSearchParams,
1345
1342
  isTypedArray: isTypedArray,
@@ -1450,9 +1447,20 @@ var contentful = (function (exports) {
1450
1447
  }, function (prop) {
1451
1448
  return prop !== 'isAxiosError';
1452
1449
  });
1453
- AxiosError.call(axiosError, error.message, code, config, request, response);
1454
- axiosError.cause = error;
1455
- axiosError.name = error.name;
1450
+ var msg = error && error.message ? error.message : 'Error';
1451
+
1452
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
1453
+ var errCode = code == null && error ? error.code : code;
1454
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
1455
+
1456
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
1457
+ if (error && axiosError.cause == null) {
1458
+ Object.defineProperty(axiosError, 'cause', {
1459
+ value: error,
1460
+ configurable: true
1461
+ });
1462
+ }
1463
+ axiosError.name = error && error.name || 'Error';
1456
1464
  customProps && Object.assign(axiosError, customProps);
1457
1465
  return axiosError;
1458
1466
  };
@@ -1700,7 +1708,7 @@ var contentful = (function (exports) {
1700
1708
  * @returns {string} The encoded value.
1701
1709
  */
1702
1710
  function encode$2(val) {
1703
- return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
1711
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
1704
1712
  }
1705
1713
 
1706
1714
  /**
@@ -2044,7 +2052,7 @@ var contentful = (function (exports) {
2044
2052
  var silentJSONParsing = transitional && transitional.silentJSONParsing;
2045
2053
  var strictJSONParsing = !silentJSONParsing && JSONRequested;
2046
2054
  try {
2047
- return JSON.parse(data);
2055
+ return JSON.parse(data, this.parseReviver);
2048
2056
  } catch (e) {
2049
2057
  if (strictJSONParsing) {
2050
2058
  if (e.name === 'SyntaxError') {
@@ -2810,19 +2818,22 @@ var contentful = (function (exports) {
2810
2818
  if (auth) {
2811
2819
  headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
2812
2820
  }
2813
- var contentType;
2814
2821
  if (utils$1$1.isFormData(data)) {
2815
2822
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2816
- headers.setContentType(undefined); // Let the browser set it
2817
- } else if ((contentType = headers.getContentType()) !== false) {
2818
- // fix semicolon duplication issue for ReactNative FormData implementation
2819
- var _ref11 = contentType ? contentType.split(';').map(function (token) {
2820
- return token.trim();
2821
- }).filter(Boolean) : [],
2822
- _ref12 = _toArray(_ref11),
2823
- type = _ref12[0],
2824
- tokens = _ref12.slice(1);
2825
- headers.setContentType([type || 'multipart/form-data'].concat(_toConsumableArray$1(tokens)).join('; '));
2823
+ headers.setContentType(undefined); // browser handles it
2824
+ } else if (utils$1$1.isFunction(data.getHeaders)) {
2825
+ // Node.js FormData (like form-data package)
2826
+ var formHeaders = data.getHeaders();
2827
+ // Only set safe headers to avoid overwriting security headers
2828
+ var allowedHeaders = ['content-type', 'content-length'];
2829
+ Object.entries(formHeaders).forEach(function (_ref11) {
2830
+ var _ref12 = _slicedToArray$1(_ref11, 2),
2831
+ key = _ref12[0],
2832
+ val = _ref12[1];
2833
+ if (allowedHeaders.includes(key.toLowerCase())) {
2834
+ headers.set(key, val);
2835
+ }
2836
+ });
2826
2837
  }
2827
2838
  }
2828
2839
 
@@ -2927,12 +2938,15 @@ var contentful = (function (exports) {
2927
2938
  };
2928
2939
 
2929
2940
  // Handle low level network errors
2930
- request.onerror = function handleError() {
2931
- // Real errors are hidden from us by the browser
2932
- // onerror should only fire if it's a network error
2933
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2934
-
2935
- // Clean up request
2941
+ request.onerror = function handleError(event) {
2942
+ // Browsers deliver a ProgressEvent in XHR onerror
2943
+ // (message may be empty; when present, surface it)
2944
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2945
+ var msg = event && event.message ? event.message : 'Network Error';
2946
+ var err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
2947
+ // attach the underlying event for consumers who want details
2948
+ err.event = event || null;
2949
+ reject(err);
2936
2950
  request = null;
2937
2951
  };
2938
2952
 
@@ -3258,35 +3272,19 @@ var contentful = (function (exports) {
3258
3272
  highWaterMark: 2
3259
3273
  });
3260
3274
  };
3261
- var isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
3262
- var isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
3263
-
3264
- // used only inside the fetch adapter
3265
- var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
3266
- return function (str) {
3267
- return encoder.encode(str);
3268
- };
3269
- }(new TextEncoder()) : (/*#__PURE__*/function () {
3270
- var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(str) {
3271
- return _regeneratorRuntime.wrap(function _callee4$(_context5) {
3272
- while (1) switch (_context5.prev = _context5.next) {
3273
- case 0:
3274
- _context5.t0 = Uint8Array;
3275
- _context5.next = 3;
3276
- return new Response(str).arrayBuffer();
3277
- case 3:
3278
- _context5.t1 = _context5.sent;
3279
- return _context5.abrupt("return", new _context5.t0(_context5.t1));
3280
- case 5:
3281
- case "end":
3282
- return _context5.stop();
3283
- }
3284
- }, _callee4);
3285
- }));
3286
- return function (_x4) {
3287
- return _ref13.apply(this, arguments);
3275
+ var DEFAULT_CHUNK_SIZE = 64 * 1024;
3276
+ var isFunction = utils$1$1.isFunction;
3277
+ var globalFetchAPI = function (_ref13) {
3278
+ var Request = _ref13.Request,
3279
+ Response = _ref13.Response;
3280
+ return {
3281
+ Request: Request,
3282
+ Response: Response
3288
3283
  };
3289
- }()));
3284
+ }(utils$1$1.global);
3285
+ var _utils$1$global = utils$1$1.global,
3286
+ ReadableStream$1 = _utils$1$global.ReadableStream,
3287
+ TextEncoder = _utils$1$global.TextEncoder;
3290
3288
  var test = function test(fn) {
3291
3289
  try {
3292
3290
  for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key6 = 1; _key6 < _len5; _key6++) {
@@ -3297,231 +3295,299 @@ var contentful = (function (exports) {
3297
3295
  return false;
3298
3296
  }
3299
3297
  };
3300
- var supportsRequestStream = isReadableStreamSupported && test(function () {
3301
- var duplexAccessed = false;
3302
- var hasContentType = new Request(platform.origin, {
3303
- body: new ReadableStream(),
3304
- method: 'POST',
3305
- get duplex() {
3306
- duplexAccessed = true;
3307
- return 'half';
3308
- }
3309
- }).headers.has('Content-Type');
3310
- return duplexAccessed && !hasContentType;
3311
- });
3312
- var DEFAULT_CHUNK_SIZE = 64 * 1024;
3313
- var supportsResponseStream = isReadableStreamSupported && test(function () {
3314
- return utils$1$1.isReadableStream(new Response('').body);
3315
- });
3316
- var resolvers = {
3317
- stream: supportsResponseStream && function (res) {
3318
- return res.body;
3298
+ var factory = function factory(env) {
3299
+ env = utils$1$1.merge.call({
3300
+ skipUndefined: true
3301
+ }, globalFetchAPI, env);
3302
+ var _env = env,
3303
+ envFetch = _env.fetch,
3304
+ Request = _env.Request,
3305
+ Response = _env.Response;
3306
+ var isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3307
+ var isRequestSupported = isFunction(Request);
3308
+ var isResponseSupported = isFunction(Response);
3309
+ if (!isFetchSupported) {
3310
+ return false;
3319
3311
  }
3320
- };
3321
- isFetchSupported && function (res) {
3322
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
3323
- !resolvers[type] && (resolvers[type] = utils$1$1.isFunction(res[type]) ? function (res) {
3324
- return res[type]();
3325
- } : function (_, config) {
3326
- throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
3327
- });
3312
+ var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3313
+ var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
3314
+ return function (str) {
3315
+ return encoder.encode(str);
3316
+ };
3317
+ }(new TextEncoder()) : (/*#__PURE__*/function () {
3318
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(str) {
3319
+ return _regeneratorRuntime.wrap(function _callee4$(_context5) {
3320
+ while (1) switch (_context5.prev = _context5.next) {
3321
+ case 0:
3322
+ _context5.t0 = Uint8Array;
3323
+ _context5.next = 3;
3324
+ return new Request(str).arrayBuffer();
3325
+ case 3:
3326
+ _context5.t1 = _context5.sent;
3327
+ return _context5.abrupt("return", new _context5.t0(_context5.t1));
3328
+ case 5:
3329
+ case "end":
3330
+ return _context5.stop();
3331
+ }
3332
+ }, _callee4);
3333
+ }));
3334
+ return function (_x4) {
3335
+ return _ref14.apply(this, arguments);
3336
+ };
3337
+ }()));
3338
+ var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
3339
+ var duplexAccessed = false;
3340
+ var hasContentType = new Request(platform.origin, {
3341
+ body: new ReadableStream$1(),
3342
+ method: 'POST',
3343
+ get duplex() {
3344
+ duplexAccessed = true;
3345
+ return 'half';
3346
+ }
3347
+ }).headers.has('Content-Type');
3348
+ return duplexAccessed && !hasContentType;
3328
3349
  });
3329
- }(new Response());
3330
- var getBodyLength = /*#__PURE__*/function () {
3331
- var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(body) {
3332
- var _request;
3333
- return _regeneratorRuntime.wrap(function _callee5$(_context6) {
3334
- while (1) switch (_context6.prev = _context6.next) {
3335
- case 0:
3336
- if (!(body == null)) {
3337
- _context6.next = 2;
3338
- break;
3339
- }
3340
- return _context6.abrupt("return", 0);
3341
- case 2:
3342
- if (!utils$1$1.isBlob(body)) {
3343
- _context6.next = 4;
3344
- break;
3345
- }
3346
- return _context6.abrupt("return", body.size);
3347
- case 4:
3348
- if (!utils$1$1.isSpecCompliantForm(body)) {
3349
- _context6.next = 9;
3350
- break;
3351
- }
3352
- _request = new Request(platform.origin, {
3353
- method: 'POST',
3354
- body: body
3355
- });
3356
- _context6.next = 8;
3357
- return _request.arrayBuffer();
3358
- case 8:
3359
- return _context6.abrupt("return", _context6.sent.byteLength);
3360
- case 9:
3361
- if (!(utils$1$1.isArrayBufferView(body) || utils$1$1.isArrayBuffer(body))) {
3362
- _context6.next = 11;
3363
- break;
3364
- }
3365
- return _context6.abrupt("return", body.byteLength);
3366
- case 11:
3367
- if (utils$1$1.isURLSearchParams(body)) {
3368
- body = body + '';
3369
- }
3370
- if (!utils$1$1.isString(body)) {
3371
- _context6.next = 16;
3372
- break;
3373
- }
3374
- _context6.next = 15;
3375
- return encodeText(body);
3376
- case 15:
3377
- return _context6.abrupt("return", _context6.sent.byteLength);
3378
- case 16:
3379
- case "end":
3380
- return _context6.stop();
3381
- }
3382
- }, _callee5);
3383
- }));
3384
- return function getBodyLength(_x5) {
3385
- return _ref14.apply(this, arguments);
3386
- };
3387
- }();
3388
- var resolveBodyLength = /*#__PURE__*/function () {
3389
- var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(headers, body) {
3390
- var length;
3391
- return _regeneratorRuntime.wrap(function _callee6$(_context7) {
3392
- while (1) switch (_context7.prev = _context7.next) {
3393
- case 0:
3394
- length = utils$1$1.toFiniteNumber(headers.getContentLength());
3395
- return _context7.abrupt("return", length == null ? getBodyLength(body) : length);
3396
- case 2:
3397
- case "end":
3398
- return _context7.stop();
3399
- }
3400
- }, _callee6);
3401
- }));
3402
- return function resolveBodyLength(_x6, _x7) {
3403
- return _ref15.apply(this, arguments);
3350
+ var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
3351
+ return utils$1$1.isReadableStream(new Response('').body);
3352
+ });
3353
+ var resolvers = {
3354
+ stream: supportsResponseStream && function (res) {
3355
+ return res.body;
3356
+ }
3404
3357
  };
3405
- }();
3406
- var fetchAdapter = isFetchSupported && (/*#__PURE__*/function () {
3407
- var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(config) {
3408
- var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, response, isStreamResponse, options, responseContentLength, _ref17, _ref18, _onProgress, _flush, responseData;
3409
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
3410
- while (1) switch (_context8.prev = _context8.next) {
3411
- case 0:
3412
- _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
3413
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3414
- composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3415
- unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
3416
- composedSignal.unsubscribe();
3417
- };
3418
- _context8.prev = 4;
3419
- _context8.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3420
- if (!_context8.t0) {
3358
+ isFetchSupported && function () {
3359
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
3360
+ !resolvers[type] && (resolvers[type] = function (res, config) {
3361
+ var method = res && res[type];
3362
+ if (method) {
3363
+ return method.call(res);
3364
+ }
3365
+ throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
3366
+ });
3367
+ });
3368
+ }();
3369
+ var getBodyLength = /*#__PURE__*/function () {
3370
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(body) {
3371
+ var _request;
3372
+ return _regeneratorRuntime.wrap(function _callee5$(_context6) {
3373
+ while (1) switch (_context6.prev = _context6.next) {
3374
+ case 0:
3375
+ if (!(body == null)) {
3376
+ _context6.next = 2;
3377
+ break;
3378
+ }
3379
+ return _context6.abrupt("return", 0);
3380
+ case 2:
3381
+ if (!utils$1$1.isBlob(body)) {
3382
+ _context6.next = 4;
3383
+ break;
3384
+ }
3385
+ return _context6.abrupt("return", body.size);
3386
+ case 4:
3387
+ if (!utils$1$1.isSpecCompliantForm(body)) {
3388
+ _context6.next = 9;
3389
+ break;
3390
+ }
3391
+ _request = new Request(platform.origin, {
3392
+ method: 'POST',
3393
+ body: body
3394
+ });
3395
+ _context6.next = 8;
3396
+ return _request.arrayBuffer();
3397
+ case 8:
3398
+ return _context6.abrupt("return", _context6.sent.byteLength);
3399
+ case 9:
3400
+ if (!(utils$1$1.isArrayBufferView(body) || utils$1$1.isArrayBuffer(body))) {
3401
+ _context6.next = 11;
3402
+ break;
3403
+ }
3404
+ return _context6.abrupt("return", body.byteLength);
3405
+ case 11:
3406
+ if (utils$1$1.isURLSearchParams(body)) {
3407
+ body = body + '';
3408
+ }
3409
+ if (!utils$1$1.isString(body)) {
3410
+ _context6.next = 16;
3411
+ break;
3412
+ }
3413
+ _context6.next = 15;
3414
+ return encodeText(body);
3415
+ case 15:
3416
+ return _context6.abrupt("return", _context6.sent.byteLength);
3417
+ case 16:
3418
+ case "end":
3419
+ return _context6.stop();
3420
+ }
3421
+ }, _callee5);
3422
+ }));
3423
+ return function getBodyLength(_x5) {
3424
+ return _ref15.apply(this, arguments);
3425
+ };
3426
+ }();
3427
+ var resolveBodyLength = /*#__PURE__*/function () {
3428
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(headers, body) {
3429
+ var length;
3430
+ return _regeneratorRuntime.wrap(function _callee6$(_context7) {
3431
+ while (1) switch (_context7.prev = _context7.next) {
3432
+ case 0:
3433
+ length = utils$1$1.toFiniteNumber(headers.getContentLength());
3434
+ return _context7.abrupt("return", length == null ? getBodyLength(body) : length);
3435
+ case 2:
3436
+ case "end":
3437
+ return _context7.stop();
3438
+ }
3439
+ }, _callee6);
3440
+ }));
3441
+ return function resolveBodyLength(_x6, _x7) {
3442
+ return _ref16.apply(this, arguments);
3443
+ };
3444
+ }();
3445
+ return /*#__PURE__*/function () {
3446
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(config) {
3447
+ var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _fetch, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, resolvedOptions, response, isStreamResponse, options, responseContentLength, _ref18, _ref19, _onProgress, _flush, responseData;
3448
+ return _regeneratorRuntime.wrap(function _callee7$(_context8) {
3449
+ while (1) switch (_context8.prev = _context8.next) {
3450
+ case 0:
3451
+ _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
3452
+ _fetch = envFetch || fetch;
3453
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3454
+ composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3455
+ request = null;
3456
+ unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
3457
+ composedSignal.unsubscribe();
3458
+ };
3459
+ _context8.prev = 6;
3460
+ _context8.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3461
+ if (!_context8.t0) {
3462
+ _context8.next = 13;
3463
+ break;
3464
+ }
3421
3465
  _context8.next = 11;
3422
- break;
3423
- }
3424
- _context8.next = 9;
3425
- return resolveBodyLength(headers, data);
3426
- case 9:
3427
- _context8.t1 = requestContentLength = _context8.sent;
3428
- _context8.t0 = _context8.t1 !== 0;
3429
- case 11:
3430
- if (!_context8.t0) {
3431
- _context8.next = 15;
3432
- break;
3433
- }
3434
- _request = new Request(url, {
3435
- method: 'POST',
3436
- body: data,
3437
- duplex: "half"
3438
- });
3439
- if (utils$1$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3440
- headers.setContentType(contentTypeHeader);
3441
- }
3442
- if (_request.body) {
3443
- _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray$1(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
3444
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3445
- }
3446
- case 15:
3447
- if (!utils$1$1.isString(withCredentials)) {
3448
- withCredentials = withCredentials ? 'include' : 'omit';
3449
- }
3466
+ return resolveBodyLength(headers, data);
3467
+ case 11:
3468
+ _context8.t1 = requestContentLength = _context8.sent;
3469
+ _context8.t0 = _context8.t1 !== 0;
3470
+ case 13:
3471
+ if (!_context8.t0) {
3472
+ _context8.next = 17;
3473
+ break;
3474
+ }
3475
+ _request = new Request(url, {
3476
+ method: 'POST',
3477
+ body: data,
3478
+ duplex: "half"
3479
+ });
3480
+ if (utils$1$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3481
+ headers.setContentType(contentTypeHeader);
3482
+ }
3483
+ if (_request.body) {
3484
+ _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray$1(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
3485
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3486
+ }
3487
+ case 17:
3488
+ if (!utils$1$1.isString(withCredentials)) {
3489
+ withCredentials = withCredentials ? 'include' : 'omit';
3490
+ }
3450
3491
 
3451
- // Cloudflare Workers throws when credentials are defined
3452
- // see https://github.com/cloudflare/workerd/issues/902
3453
- isCredentialsSupported = "credentials" in Request.prototype;
3454
- request = new Request(url, _objectSpread$2(_objectSpread$2({}, fetchOptions), {}, {
3455
- signal: composedSignal,
3456
- method: method.toUpperCase(),
3457
- headers: headers.normalize().toJSON(),
3458
- body: data,
3459
- duplex: "half",
3460
- credentials: isCredentialsSupported ? withCredentials : undefined
3461
- }));
3462
- _context8.next = 20;
3463
- return fetch(request, fetchOptions);
3464
- case 20:
3465
- response = _context8.sent;
3466
- isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3467
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3468
- options = {};
3469
- ['status', 'statusText', 'headers'].forEach(function (prop) {
3470
- options[prop] = response[prop];
3492
+ // Cloudflare Workers throws when credentials are defined
3493
+ // see https://github.com/cloudflare/workerd/issues/902
3494
+ isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3495
+ resolvedOptions = _objectSpread$2(_objectSpread$2({}, fetchOptions), {}, {
3496
+ signal: composedSignal,
3497
+ method: method.toUpperCase(),
3498
+ headers: headers.normalize().toJSON(),
3499
+ body: data,
3500
+ duplex: "half",
3501
+ credentials: isCredentialsSupported ? withCredentials : undefined
3471
3502
  });
3472
- responseContentLength = utils$1$1.toFiniteNumber(response.headers.get('content-length'));
3473
- _ref17 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref18 = _slicedToArray$1(_ref17, 2), _onProgress = _ref18[0], _flush = _ref18[1];
3474
- response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
3475
- _flush && _flush();
3476
- unsubscribe && unsubscribe();
3477
- }), options);
3478
- }
3479
- responseType = responseType || 'text';
3480
- _context8.next = 26;
3481
- return resolvers[utils$1$1.findKey(resolvers, responseType) || 'text'](response, config);
3482
- case 26:
3483
- responseData = _context8.sent;
3484
- !isStreamResponse && unsubscribe && unsubscribe();
3485
- _context8.next = 30;
3486
- return new Promise(function (resolve, reject) {
3487
- settle(resolve, reject, {
3488
- data: responseData,
3489
- headers: AxiosHeaders$1.from(response.headers),
3490
- status: response.status,
3491
- statusText: response.statusText,
3492
- config: config,
3493
- request: request
3503
+ request = isRequestSupported && new Request(url, resolvedOptions);
3504
+ _context8.next = 23;
3505
+ return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
3506
+ case 23:
3507
+ response = _context8.sent;
3508
+ isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3509
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3510
+ options = {};
3511
+ ['status', 'statusText', 'headers'].forEach(function (prop) {
3512
+ options[prop] = response[prop];
3513
+ });
3514
+ responseContentLength = utils$1$1.toFiniteNumber(response.headers.get('content-length'));
3515
+ _ref18 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref19 = _slicedToArray$1(_ref18, 2), _onProgress = _ref19[0], _flush = _ref19[1];
3516
+ response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
3517
+ _flush && _flush();
3518
+ unsubscribe && unsubscribe();
3519
+ }), options);
3520
+ }
3521
+ responseType = responseType || 'text';
3522
+ _context8.next = 29;
3523
+ return resolvers[utils$1$1.findKey(resolvers, responseType) || 'text'](response, config);
3524
+ case 29:
3525
+ responseData = _context8.sent;
3526
+ !isStreamResponse && unsubscribe && unsubscribe();
3527
+ _context8.next = 33;
3528
+ return new Promise(function (resolve, reject) {
3529
+ settle(resolve, reject, {
3530
+ data: responseData,
3531
+ headers: AxiosHeaders$1.from(response.headers),
3532
+ status: response.status,
3533
+ statusText: response.statusText,
3534
+ config: config,
3535
+ request: request
3536
+ });
3494
3537
  });
3495
- });
3496
- case 30:
3497
- return _context8.abrupt("return", _context8.sent);
3498
- case 33:
3499
- _context8.prev = 33;
3500
- _context8.t2 = _context8["catch"](4);
3501
- unsubscribe && unsubscribe();
3502
- if (!(_context8.t2 && _context8.t2.name === 'TypeError' && /Load failed|fetch/i.test(_context8.t2.message))) {
3503
- _context8.next = 38;
3504
- break;
3505
- }
3506
- throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
3507
- cause: _context8.t2.cause || _context8.t2
3508
- });
3509
- case 38:
3510
- throw AxiosError.from(_context8.t2, _context8.t2 && _context8.t2.code, config, request);
3511
- case 39:
3512
- case "end":
3513
- return _context8.stop();
3514
- }
3515
- }, _callee7, null, [[4, 33]]);
3516
- }));
3517
- return function (_x8) {
3518
- return _ref16.apply(this, arguments);
3519
- };
3520
- }());
3538
+ case 33:
3539
+ return _context8.abrupt("return", _context8.sent);
3540
+ case 36:
3541
+ _context8.prev = 36;
3542
+ _context8.t2 = _context8["catch"](6);
3543
+ unsubscribe && unsubscribe();
3544
+ if (!(_context8.t2 && _context8.t2.name === 'TypeError' && /Load failed|fetch/i.test(_context8.t2.message))) {
3545
+ _context8.next = 41;
3546
+ break;
3547
+ }
3548
+ throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
3549
+ cause: _context8.t2.cause || _context8.t2
3550
+ });
3551
+ case 41:
3552
+ throw AxiosError.from(_context8.t2, _context8.t2 && _context8.t2.code, config, request);
3553
+ case 42:
3554
+ case "end":
3555
+ return _context8.stop();
3556
+ }
3557
+ }, _callee7, null, [[6, 36]]);
3558
+ }));
3559
+ return function (_x8) {
3560
+ return _ref17.apply(this, arguments);
3561
+ };
3562
+ }();
3563
+ };
3564
+ var seedCache = new Map();
3565
+ var getFetch = function getFetch(config) {
3566
+ var env = config ? config.env : {};
3567
+ var fetch = env.fetch,
3568
+ Request = env.Request,
3569
+ Response = env.Response;
3570
+ var seeds = [Request, Response, fetch];
3571
+ var len = seeds.length,
3572
+ i = len,
3573
+ seed,
3574
+ target,
3575
+ map = seedCache;
3576
+ while (i--) {
3577
+ seed = seeds[i];
3578
+ target = map.get(seed);
3579
+ target === undefined && map.set(seed, target = i ? new Map() : factory(env));
3580
+ map = target;
3581
+ }
3582
+ return target;
3583
+ };
3584
+ getFetch();
3521
3585
  var knownAdapters = {
3522
3586
  http: httpAdapter,
3523
3587
  xhr: xhrAdapter,
3524
- fetch: fetchAdapter
3588
+ fetch: {
3589
+ get: getFetch
3590
+ }
3525
3591
  };
3526
3592
  utils$1$1.forEach(knownAdapters, function (fn, value) {
3527
3593
  if (fn) {
@@ -3544,7 +3610,7 @@ var contentful = (function (exports) {
3544
3610
  return utils$1$1.isFunction(adapter) || adapter === null || adapter === false;
3545
3611
  };
3546
3612
  var adapters = {
3547
- getAdapter: function getAdapter(adapters) {
3613
+ getAdapter: function getAdapter(adapters, config) {
3548
3614
  adapters = utils$1$1.isArray(adapters) ? adapters : [adapters];
3549
3615
  var _adapters = adapters,
3550
3616
  length = _adapters.length;
@@ -3561,16 +3627,16 @@ var contentful = (function (exports) {
3561
3627
  throw new AxiosError("Unknown adapter '".concat(id, "'"));
3562
3628
  }
3563
3629
  }
3564
- if (adapter) {
3630
+ if (adapter && (utils$1$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3565
3631
  break;
3566
3632
  }
3567
3633
  rejectedReasons[id || '#' + i] = adapter;
3568
3634
  }
3569
3635
  if (!adapter) {
3570
- var reasons = Object.entries(rejectedReasons).map(function (_ref19) {
3571
- var _ref20 = _slicedToArray$1(_ref19, 2),
3572
- id = _ref20[0],
3573
- state = _ref20[1];
3636
+ var reasons = Object.entries(rejectedReasons).map(function (_ref20) {
3637
+ var _ref21 = _slicedToArray$1(_ref20, 2),
3638
+ id = _ref21[0],
3639
+ state = _ref21[1];
3574
3640
  return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
3575
3641
  });
3576
3642
  var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
@@ -3613,7 +3679,7 @@ var contentful = (function (exports) {
3613
3679
  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3614
3680
  config.headers.setContentType('application/x-www-form-urlencoded', false);
3615
3681
  }
3616
- var adapter = adapters.getAdapter(config.adapter || defaults$1$1.adapter);
3682
+ var adapter = adapters.getAdapter(config.adapter || defaults$1$1.adapter, config);
3617
3683
  return adapter(config).then(function onAdapterResolution(response) {
3618
3684
  throwIfCancellationRequested(config);
3619
3685
 
@@ -3634,7 +3700,7 @@ var contentful = (function (exports) {
3634
3700
  return Promise.reject(reason);
3635
3701
  });
3636
3702
  }
3637
- var VERSION = "1.11.0";
3703
+ var VERSION = "1.12.2";
3638
3704
  var validators$1 = {};
3639
3705
 
3640
3706
  // eslint-disable-next-line func-names
@@ -3875,7 +3941,6 @@ var contentful = (function (exports) {
3875
3941
  }
3876
3942
  len = requestInterceptorChain.length;
3877
3943
  var newConfig = config;
3878
- i = 0;
3879
3944
  while (i < len) {
3880
3945
  var onFulfilled = requestInterceptorChain[i++];
3881
3946
  var onRejected = requestInterceptorChain[i++];
@@ -4168,10 +4233,10 @@ var contentful = (function (exports) {
4168
4233
  NotExtended: 510,
4169
4234
  NetworkAuthenticationRequired: 511
4170
4235
  };
4171
- Object.entries(HttpStatusCode).forEach(function (_ref21) {
4172
- var _ref22 = _slicedToArray$1(_ref21, 2),
4173
- key = _ref22[0],
4174
- value = _ref22[1];
4236
+ Object.entries(HttpStatusCode).forEach(function (_ref22) {
4237
+ var _ref23 = _slicedToArray$1(_ref22, 2),
4238
+ key = _ref23[0],
4239
+ value = _ref23[1];
4175
4240
  HttpStatusCode[value] = key;
4176
4241
  });
4177
4242
  var HttpStatusCode$1 = HttpStatusCode;
@@ -10450,7 +10515,7 @@ var contentful = (function (exports) {
10450
10515
  http.defaults.baseURL = getGlobalOptions().environmentBaseUrl;
10451
10516
  }
10452
10517
  return {
10453
- version: "11.7.16",
10518
+ version: "11.7.18",
10454
10519
  getSpace: getSpace,
10455
10520
  getContentType: getContentType,
10456
10521
  getContentTypes: getContentTypes,
@@ -10577,7 +10642,7 @@ var contentful = (function (exports) {
10577
10642
  environment: 'master'
10578
10643
  };
10579
10644
  var config = Object.assign(Object.assign({}, defaultConfig), params);
10580
- var userAgentHeader = getUserAgentHeader("contentful.js/".concat("11.7.16"), config.application, config.integration);
10645
+ var userAgentHeader = getUserAgentHeader("contentful.js/".concat("11.7.18"), config.application, config.integration);
10581
10646
  config.headers = Object.assign(Object.assign({}, config.headers), {
10582
10647
  'Content-Type': 'application/vnd.contentful.delivery.v1+json',
10583
10648
  'X-Contentful-User-Agent': userAgentHeader