contentful-management 7.45.2 → 7.45.3

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.
@@ -2683,15 +2683,16 @@ var rateLimitThrottle = (function (axiosInstance) {
2683
2683
  };
2684
2684
  });
2685
2685
 
2686
- var attempts = {};
2687
- var networkErrorAttempts = 0;
2688
-
2689
2686
  var delay = function delay(ms) {
2690
2687
  return new Promise(function (resolve) {
2691
2688
  setTimeout(resolve, ms);
2692
2689
  });
2693
2690
  };
2694
2691
 
2692
+ var defaultWait = function defaultWait(attempts) {
2693
+ return Math.pow(Math.SQRT2, attempts);
2694
+ };
2695
+
2695
2696
  function rateLimit(instance) {
2696
2697
  var maxRetry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
2697
2698
  var _instance$defaults = instance.defaults,
@@ -2717,40 +2718,24 @@ function rateLimit(instance) {
2717
2718
 
2718
2719
  if (!config || !instance.defaults.retryOnError) {
2719
2720
  return Promise.reject(error);
2721
+ } // Retried already for max attempts
2722
+
2723
+
2724
+ var doneAttempts = config.attempts || 1;
2725
+
2726
+ if (doneAttempts > maxRetry) {
2727
+ error.attempts = config.attempts;
2728
+ return Promise.reject(error);
2720
2729
  }
2721
2730
 
2722
2731
  var retryErrorType = null;
2723
- var wait = 0; // Errors without response did not receive anything from the server
2732
+ var wait = defaultWait(doneAttempts); // Errors without response did not receive anything from the server
2724
2733
 
2725
2734
  if (!response) {
2726
2735
  retryErrorType = 'Connection';
2727
- networkErrorAttempts++;
2728
-
2729
- if (networkErrorAttempts > maxRetry) {
2730
- error.attempts = networkErrorAttempts;
2731
- return Promise.reject(error);
2732
- }
2733
-
2734
- wait = Math.pow(Math.SQRT2, networkErrorAttempts);
2735
- response = {};
2736
- } else {
2737
- networkErrorAttempts = 0;
2738
- }
2739
-
2740
- if (response.status >= 500 && response.status < 600) {
2736
+ } else if (response.status >= 500 && response.status < 600) {
2741
2737
  // 5** errors are server related
2742
2738
  retryErrorType = "Server ".concat(response.status);
2743
- var headers = response.headers || {};
2744
- var requestId = headers['x-contentful-request-id'] || null;
2745
- attempts[requestId] = attempts[requestId] || 0;
2746
- attempts[requestId]++; // we reject if there are too many errors with the same request id or request id is not defined
2747
-
2748
- if (attempts[requestId] > maxRetry || !requestId) {
2749
- error.attempts = attempts[requestId];
2750
- return Promise.reject(error);
2751
- }
2752
-
2753
- wait = Math.pow(Math.SQRT2, attempts[requestId]);
2754
2739
  } else if (response.status === 429) {
2755
2740
  // 429 errors are exceeded rate limit exceptions
2756
2741
  retryErrorType = 'Rate limit'; // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
@@ -2763,7 +2748,9 @@ function rateLimit(instance) {
2763
2748
  if (retryErrorType) {
2764
2749
  // convert to ms and add jitter
2765
2750
  wait = Math.floor(wait * 1000 + Math.random() * 200 + 500);
2766
- instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying..."));
2751
+ instance.defaults.logHandler('warning', "".concat(retryErrorType, " error occurred. Waiting for ").concat(wait, " ms before retrying...")); // increase attempts counter
2752
+
2753
+ config.attempts = doneAttempts + 1;
2767
2754
  /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object
2768
2755
  to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry
2769
2756
  requests still use the original http/httpsAgent property */
@@ -12341,7 +12328,6 @@ var SidebarWidgetTypes = {
12341
12328
  VERSIONS: 'versions-widget',
12342
12329
  INFO_PANEL: 'info-panel',
12343
12330
  JOBS: 'jobs-widget',
12344
- TASKS: 'content-workflows-tasks-widget',
12345
12331
  COMMENTS_PANEL: 'comments-panel'
12346
12332
  };
12347
12333
  var Publication = {
@@ -12356,12 +12342,6 @@ var Releases = {
12356
12342
  name: 'Release',
12357
12343
  description: 'Built-in - View release, add to it, etc.'
12358
12344
  };
12359
- var Tasks = {
12360
- widgetId: SidebarWidgetTypes.TASKS,
12361
- widgetNamespace: _types__WEBPACK_IMPORTED_MODULE_0__["WidgetNamespace"].SIDEBAR_BUILTIN,
12362
- name: 'Tasks',
12363
- description: 'Built-in - Assign tasks to be completed before publishing. Currently only supported for master environment.'
12364
- };
12365
12345
  var ContentPreview = {
12366
12346
  widgetId: SidebarWidgetTypes.CONTENT_PREVIEW,
12367
12347
  widgetNamespace: _types__WEBPACK_IMPORTED_MODULE_0__["WidgetNamespace"].SIDEBAR_BUILTIN,
@@ -12392,7 +12372,7 @@ var Users = {
12392
12372
  name: 'Users',
12393
12373
  description: 'Built-in - Displays users on the same entry.'
12394
12374
  };
12395
- var SidebarEntryConfiguration = [Publication, Releases, Tasks, ContentPreview, Links, Translation, Versions, Users];
12375
+ var SidebarEntryConfiguration = [Publication, Releases, ContentPreview, Links, Translation, Versions, Users];
12396
12376
  var SidebarAssetConfiguration = [Publication, Releases, Links, Translation, Users];
12397
12377
 
12398
12378
  /***/ }),
@@ -12485,7 +12465,7 @@ function createClient(params) {
12485
12465
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12486
12466
  var sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
12487
12467
  var userAgent = Object(contentful_sdk_core__WEBPACK_IMPORTED_MODULE_0__["getUserAgentHeader"])( // @ts-expect-error
12488
- "".concat(sdkMain, "/").concat("7.45.2"), params.application, params.integration, params.feature);
12468
+ "".concat(sdkMain, "/").concat("7.45.3"), params.application, params.integration, params.feature);
12489
12469
  var adapter = Object(_create_adapter__WEBPACK_IMPORTED_MODULE_1__["createAdapter"])(params); // Parameters<?> and ReturnType<?> only return the types of the last overload
12490
12470
  // https://github.com/microsoft/TypeScript/issues/26591
12491
12471
  // @ts-expect-error