contentful 10.12.6 → 10.12.7

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.
@@ -390,6 +390,31 @@ function _arrayLikeToArray(r, a) {
390
390
  function _arrayWithHoles(r) {
391
391
  if (Array.isArray(r)) return r;
392
392
  }
393
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
394
+ try {
395
+ var i = n[a](c),
396
+ u = i.value;
397
+ } catch (n) {
398
+ return void e(n);
399
+ }
400
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
401
+ }
402
+ function _asyncToGenerator(n) {
403
+ return function () {
404
+ var t = this,
405
+ e = arguments;
406
+ return new Promise(function (r, o) {
407
+ var a = n.apply(t, e);
408
+ function _next(n) {
409
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
410
+ }
411
+ function _throw(n) {
412
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
413
+ }
414
+ _next(void 0);
415
+ });
416
+ };
417
+ }
393
418
  function _createForOfIteratorHelper(r, e) {
394
419
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
395
420
  if (!t) {
@@ -509,6 +534,307 @@ function _objectSpread2(e) {
509
534
  }
510
535
  return e;
511
536
  }
537
+ function _regeneratorRuntime() {
538
+ _regeneratorRuntime = function () {
539
+ return e;
540
+ };
541
+ var t,
542
+ e = {},
543
+ r = Object.prototype,
544
+ n = r.hasOwnProperty,
545
+ o = Object.defineProperty || function (t, e, r) {
546
+ t[e] = r.value;
547
+ },
548
+ i = "function" == typeof Symbol ? Symbol : {},
549
+ a = i.iterator || "@@iterator",
550
+ c = i.asyncIterator || "@@asyncIterator",
551
+ u = i.toStringTag || "@@toStringTag";
552
+ function define(t, e, r) {
553
+ return Object.defineProperty(t, e, {
554
+ value: r,
555
+ enumerable: !0,
556
+ configurable: !0,
557
+ writable: !0
558
+ }), t[e];
559
+ }
560
+ try {
561
+ define({}, "");
562
+ } catch (t) {
563
+ define = function (t, e, r) {
564
+ return t[e] = r;
565
+ };
566
+ }
567
+ function wrap(t, e, r, n) {
568
+ var i = e && e.prototype instanceof Generator ? e : Generator,
569
+ a = Object.create(i.prototype),
570
+ c = new Context(n || []);
571
+ return o(a, "_invoke", {
572
+ value: makeInvokeMethod(t, r, c)
573
+ }), a;
574
+ }
575
+ function tryCatch(t, e, r) {
576
+ try {
577
+ return {
578
+ type: "normal",
579
+ arg: t.call(e, r)
580
+ };
581
+ } catch (t) {
582
+ return {
583
+ type: "throw",
584
+ arg: t
585
+ };
586
+ }
587
+ }
588
+ e.wrap = wrap;
589
+ var h = "suspendedStart",
590
+ l = "suspendedYield",
591
+ f = "executing",
592
+ s = "completed",
593
+ y = {};
594
+ function Generator() {}
595
+ function GeneratorFunction() {}
596
+ function GeneratorFunctionPrototype() {}
597
+ var p = {};
598
+ define(p, a, function () {
599
+ return this;
600
+ });
601
+ var d = Object.getPrototypeOf,
602
+ v = d && d(d(values([])));
603
+ v && v !== r && n.call(v, a) && (p = v);
604
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
605
+ function defineIteratorMethods(t) {
606
+ ["next", "throw", "return"].forEach(function (e) {
607
+ define(t, e, function (t) {
608
+ return this._invoke(e, t);
609
+ });
610
+ });
611
+ }
612
+ function AsyncIterator(t, e) {
613
+ function invoke(r, o, i, a) {
614
+ var c = tryCatch(t[r], t, o);
615
+ if ("throw" !== c.type) {
616
+ var u = c.arg,
617
+ h = u.value;
618
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
619
+ invoke("next", t, i, a);
620
+ }, function (t) {
621
+ invoke("throw", t, i, a);
622
+ }) : e.resolve(h).then(function (t) {
623
+ u.value = t, i(u);
624
+ }, function (t) {
625
+ return invoke("throw", t, i, a);
626
+ });
627
+ }
628
+ a(c.arg);
629
+ }
630
+ var r;
631
+ o(this, "_invoke", {
632
+ value: function (t, n) {
633
+ function callInvokeWithMethodAndArg() {
634
+ return new e(function (e, r) {
635
+ invoke(t, n, e, r);
636
+ });
637
+ }
638
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
639
+ }
640
+ });
641
+ }
642
+ function makeInvokeMethod(e, r, n) {
643
+ var o = h;
644
+ return function (i, a) {
645
+ if (o === f) throw Error("Generator is already running");
646
+ if (o === s) {
647
+ if ("throw" === i) throw a;
648
+ return {
649
+ value: t,
650
+ done: !0
651
+ };
652
+ }
653
+ for (n.method = i, n.arg = a;;) {
654
+ var c = n.delegate;
655
+ if (c) {
656
+ var u = maybeInvokeDelegate(c, n);
657
+ if (u) {
658
+ if (u === y) continue;
659
+ return u;
660
+ }
661
+ }
662
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
663
+ if (o === h) throw o = s, n.arg;
664
+ n.dispatchException(n.arg);
665
+ } else "return" === n.method && n.abrupt("return", n.arg);
666
+ o = f;
667
+ var p = tryCatch(e, r, n);
668
+ if ("normal" === p.type) {
669
+ if (o = n.done ? s : l, p.arg === y) continue;
670
+ return {
671
+ value: p.arg,
672
+ done: n.done
673
+ };
674
+ }
675
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
676
+ }
677
+ };
678
+ }
679
+ function maybeInvokeDelegate(e, r) {
680
+ var n = r.method,
681
+ o = e.iterator[n];
682
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
683
+ var i = tryCatch(o, e.iterator, r.arg);
684
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
685
+ var a = i.arg;
686
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
687
+ }
688
+ function pushTryEntry(t) {
689
+ var e = {
690
+ tryLoc: t[0]
691
+ };
692
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
693
+ }
694
+ function resetTryEntry(t) {
695
+ var e = t.completion || {};
696
+ e.type = "normal", delete e.arg, t.completion = e;
697
+ }
698
+ function Context(t) {
699
+ this.tryEntries = [{
700
+ tryLoc: "root"
701
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
702
+ }
703
+ function values(e) {
704
+ if (e || "" === e) {
705
+ var r = e[a];
706
+ if (r) return r.call(e);
707
+ if ("function" == typeof e.next) return e;
708
+ if (!isNaN(e.length)) {
709
+ var o = -1,
710
+ i = function next() {
711
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
712
+ return next.value = t, next.done = !0, next;
713
+ };
714
+ return i.next = i;
715
+ }
716
+ }
717
+ throw new TypeError(typeof e + " is not iterable");
718
+ }
719
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
720
+ value: GeneratorFunctionPrototype,
721
+ configurable: !0
722
+ }), o(GeneratorFunctionPrototype, "constructor", {
723
+ value: GeneratorFunction,
724
+ configurable: !0
725
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
726
+ var e = "function" == typeof t && t.constructor;
727
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
728
+ }, e.mark = function (t) {
729
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
730
+ }, e.awrap = function (t) {
731
+ return {
732
+ __await: t
733
+ };
734
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
735
+ return this;
736
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
737
+ void 0 === i && (i = Promise);
738
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
739
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
740
+ return t.done ? t.value : a.next();
741
+ });
742
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
743
+ return this;
744
+ }), define(g, "toString", function () {
745
+ return "[object Generator]";
746
+ }), e.keys = function (t) {
747
+ var e = Object(t),
748
+ r = [];
749
+ for (var n in e) r.push(n);
750
+ return r.reverse(), function next() {
751
+ for (; r.length;) {
752
+ var t = r.pop();
753
+ if (t in e) return next.value = t, next.done = !1, next;
754
+ }
755
+ return next.done = !0, next;
756
+ };
757
+ }, e.values = values, Context.prototype = {
758
+ constructor: Context,
759
+ reset: function (e) {
760
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
761
+ },
762
+ stop: function () {
763
+ this.done = !0;
764
+ var t = this.tryEntries[0].completion;
765
+ if ("throw" === t.type) throw t.arg;
766
+ return this.rval;
767
+ },
768
+ dispatchException: function (e) {
769
+ if (this.done) throw e;
770
+ var r = this;
771
+ function handle(n, o) {
772
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
773
+ }
774
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
775
+ var i = this.tryEntries[o],
776
+ a = i.completion;
777
+ if ("root" === i.tryLoc) return handle("end");
778
+ if (i.tryLoc <= this.prev) {
779
+ var c = n.call(i, "catchLoc"),
780
+ u = n.call(i, "finallyLoc");
781
+ if (c && u) {
782
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
783
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
784
+ } else if (c) {
785
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
786
+ } else {
787
+ if (!u) throw Error("try statement without catch or finally");
788
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
789
+ }
790
+ }
791
+ }
792
+ },
793
+ abrupt: function (t, e) {
794
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
795
+ var o = this.tryEntries[r];
796
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
797
+ var i = o;
798
+ break;
799
+ }
800
+ }
801
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
802
+ var a = i ? i.completion : {};
803
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
804
+ },
805
+ complete: function (t, e) {
806
+ if ("throw" === t.type) throw t.arg;
807
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
808
+ },
809
+ finish: function (t) {
810
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
811
+ var r = this.tryEntries[e];
812
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
813
+ }
814
+ },
815
+ catch: function (t) {
816
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
817
+ var r = this.tryEntries[e];
818
+ if (r.tryLoc === t) {
819
+ var n = r.completion;
820
+ if ("throw" === n.type) {
821
+ var o = n.arg;
822
+ resetTryEntry(r);
823
+ }
824
+ return o;
825
+ }
826
+ }
827
+ throw Error("illegal catch attempt");
828
+ },
829
+ delegateYield: function (e, r, n) {
830
+ return this.delegate = {
831
+ iterator: values(e),
832
+ resultName: r,
833
+ nextLoc: n
834
+ }, "next" === this.method && (this.arg = t), y;
835
+ }
836
+ }, e;
837
+ }
512
838
  function _setPrototypeOf(t, e) {
513
839
  return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
514
840
  return t.__proto__ = e, t;
@@ -653,57 +979,85 @@ function rateLimit(instance) {
653
979
  // we don't need to do anything here
654
980
  responseLogger(response);
655
981
  return response;
656
- }, function (error) {
657
- var response = error.response;
658
- var config = error.config;
659
- responseLogger(error);
660
- // Do not retry if it is disabled or no request config exists (not an axios error)
661
- if (!config || !instance.defaults.retryOnError) {
662
- return Promise.reject(error);
663
- }
664
-
665
- // Retried already for max attempts
666
- var doneAttempts = config.attempts || 1;
667
- if (doneAttempts > maxRetry) {
668
- error.attempts = config.attempts;
669
- return Promise.reject(error);
670
- }
671
- var retryErrorType = null;
672
- var wait = defaultWait(doneAttempts);
673
-
674
- // Errors without response did not receive anything from the server
675
- if (!response) {
676
- retryErrorType = 'Connection';
677
- } else if (response.status >= 500 && response.status < 600) {
678
- // 5** errors are server related
679
- retryErrorType = "Server ".concat(response.status);
680
- } else if (response.status === 429) {
681
- // 429 errors are exceeded rate limit exceptions
682
- retryErrorType = 'Rate limit';
683
- // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
684
- if (response.headers && error.response.headers['x-contentful-ratelimit-reset']) {
685
- wait = response.headers['x-contentful-ratelimit-reset'];
686
- }
687
- }
688
- if (retryErrorType) {
689
- // convert to ms and add jitter
690
- wait = Math.floor(wait * 1000 + Math.random() * 200 + 500);
691
- instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying..."));
692
-
693
- // increase attempts counter
694
- config.attempts = doneAttempts + 1;
695
-
696
- /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object
697
- to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry
698
- requests still use the original http/httpsAgent property */
699
- delete config.httpAgent;
700
- delete config.httpsAgent;
701
- return delay(wait).then(function () {
702
- return instance(config);
703
- });
704
- }
705
- return Promise.reject(error);
706
- });
982
+ }, /*#__PURE__*/function () {
983
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(error) {
984
+ var response, config, doneAttempts, retryErrorType, wait;
985
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
986
+ while (1) switch (_context.prev = _context.next) {
987
+ case 0:
988
+ response = error.response;
989
+ config = error.config;
990
+ responseLogger(error);
991
+ // Do not retry if it is disabled or no request config exists (not an axios error)
992
+ if (!(!config || !instance.defaults.retryOnError)) {
993
+ _context.next = 5;
994
+ break;
995
+ }
996
+ return _context.abrupt("return", Promise.reject(error));
997
+ case 5:
998
+ // Retried already for max attempts
999
+ doneAttempts = config.attempts || 1;
1000
+ if (!(doneAttempts > maxRetry)) {
1001
+ _context.next = 9;
1002
+ break;
1003
+ }
1004
+ error.attempts = config.attempts;
1005
+ return _context.abrupt("return", Promise.reject(error));
1006
+ case 9:
1007
+ retryErrorType = null;
1008
+ wait = defaultWait(doneAttempts); // Errors without response did not receive anything from the server
1009
+ if (!response) {
1010
+ retryErrorType = 'Connection';
1011
+ } else if (response.status >= 500 && response.status < 600) {
1012
+ // 5** errors are server related
1013
+ retryErrorType = "Server ".concat(response.status);
1014
+ } else if (response.status === 429) {
1015
+ // 429 errors are exceeded rate limit exceptions
1016
+ retryErrorType = 'Rate limit';
1017
+ // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
1018
+ if (response.headers && error.response.headers['x-contentful-ratelimit-reset']) {
1019
+ wait = response.headers['x-contentful-ratelimit-reset'];
1020
+ }
1021
+ }
1022
+ if (!retryErrorType) {
1023
+ _context.next = 20;
1024
+ break;
1025
+ }
1026
+ // convert to ms and add jitter
1027
+ wait = Math.floor(wait * 1000 + Math.random() * 200 + 500);
1028
+ instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying..."));
1029
+
1030
+ // increase attempts counter
1031
+ config.attempts = doneAttempts + 1;
1032
+
1033
+ /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object
1034
+ to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry
1035
+ requests still use the original http/httpsAgent property */
1036
+ delete config.httpAgent;
1037
+ delete config.httpsAgent;
1038
+
1039
+ /**
1040
+ * Hack to mitigate (likely) bug introduced in axios v1.7.0 where `url`,
1041
+ * when using the default `xhr` adapter, is a fully qualified URL (instead of a path),
1042
+ * which somehow causes the request params to be repeatedly appended
1043
+ * to the final request URL upon each retry.
1044
+ */
1045
+ config.url = config.url.split('?')[0];
1046
+ return _context.abrupt("return", delay(wait).then(function () {
1047
+ return instance(config);
1048
+ }));
1049
+ case 20:
1050
+ return _context.abrupt("return", Promise.reject(error));
1051
+ case 21:
1052
+ case "end":
1053
+ return _context.stop();
1054
+ }
1055
+ }, _callee);
1056
+ }));
1057
+ return function (_x) {
1058
+ return _ref.apply(this, arguments);
1059
+ };
1060
+ }());
707
1061
  }
708
1062
 
709
1063
  var PERCENTAGE_REGEX = /*#__PURE__*/_wrapRegExp(/(\d+)(%)/, {
@@ -5065,7 +5419,7 @@ function createClient(params) {
5065
5419
  environment: 'master',
5066
5420
  };
5067
5421
  const config = Object.assign(Object.assign({}, defaultConfig), params);
5068
- const userAgentHeader = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.getUserAgentHeader)(`contentful.js/${"10.12.6"}`, config.application, config.integration);
5422
+ const userAgentHeader = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.getUserAgentHeader)(`contentful.js/${"10.12.7"}`, config.application, config.integration);
5069
5423
  config.headers = Object.assign(Object.assign({}, config.headers), { 'Content-Type': 'application/vnd.contentful.delivery.v1+json', 'X-Contentful-User-Agent': userAgentHeader });
5070
5424
  const http = (0,contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__.createHttpClient)(axios__WEBPACK_IMPORTED_MODULE_4__["default"], config);
5071
5425
  if (!http.defaults.baseURL) {
@@ -5411,7 +5765,7 @@ function createContentfulApi({ http, getGlobalOptions }, options) {
5411
5765
  http.defaults.baseURL = getGlobalOptions().environmentBaseUrl;
5412
5766
  }
5413
5767
  return {
5414
- version: "10.12.6",
5768
+ version: "10.12.7",
5415
5769
  getSpace,
5416
5770
  getContentType,
5417
5771
  getContentTypes,