@ancon/wildcat-utils 1.54.0-check-optimizations.5 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/api/generateBackoffWithFullJitter.d.ts +15 -0
  2. package/api/generateBackoffWithFullJitter.js +1 -0
  3. package/api/generateBackoffWithFullJitter.mjs +7 -0
  4. package/api/generateBackoffWithVariableJitter.d.ts +3 -1
  5. package/api/generateBackoffWithVariableJitter.js +1 -1
  6. package/api/generateBackoffWithVariableJitter.mjs +12 -9
  7. package/api/getRateLimitRetryDelay.d.ts +18 -0
  8. package/api/getRateLimitRetryDelay.js +1 -0
  9. package/api/getRateLimitRetryDelay.mjs +14 -0
  10. package/api/index.d.ts +3 -1
  11. package/api/index.js +1 -1
  12. package/api/index.mjs +20 -14
  13. package/check/getOrganizedCheckItemModifications.d.ts +2 -2
  14. package/check/getOrganizedCheckItemModifications.js +1 -1
  15. package/check/getOrganizedCheckItemModifications.mjs +68 -74
  16. package/check/getUniqueCheckItemModificationId.d.ts +2 -2
  17. package/check/getUniqueCheckItemModificationId.js +1 -1
  18. package/check/getUniqueCheckItemModificationId.mjs +5 -5
  19. package/error/getRateLimit.d.ts +31 -0
  20. package/error/getRateLimit.js +1 -0
  21. package/error/getRateLimit.mjs +60 -0
  22. package/error/index.d.ts +4 -2
  23. package/error/index.js +1 -1
  24. package/error/index.mjs +34 -28
  25. package/error/isRateLimitError.d.ts +7 -0
  26. package/error/isRateLimitError.js +1 -0
  27. package/error/isRateLimitError.mjs +8 -0
  28. package/index.js +1 -1
  29. package/index.mjs +375 -362
  30. package/multilingual/createLocalizedCheckDetails.d.ts +2 -2
  31. package/multilingual/createLocalizedCheckDetails.js +1 -1
  32. package/multilingual/createLocalizedCheckDetails.mjs +27 -31
  33. package/package.json +26 -1
  34. package/printing/StarScanConnection.d.ts +64 -0
  35. package/printing/StarScanConnection.js +1 -0
  36. package/printing/StarScanConnection.mjs +93 -0
  37. package/printing/createStarCloudScanHook.d.ts +10 -0
  38. package/printing/createStarCloudScanHook.js +1 -1
  39. package/printing/createStarCloudScanHook.mjs +131 -93
  40. package/printing/index.js +1 -1
  41. package/printing/index.mjs +15 -14
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Delay for one retry attempt with exponential backoff and full jitter:
3
+ * a random value between 0 and `min(maxSleep, baseSleep * 2 ** attempt)`.
4
+ *
5
+ * Full jitter spreads retries from many clients evenly over the window, so
6
+ * devices that failed together do not retry together.
7
+ * https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
8
+ *
9
+ * @param attempt Zero-based retry attempt
10
+ * @param baseSleep Upper bound of the first attempt's window in ms (default 1 s)
11
+ * @param maxSleep Cap on the window in ms (default 30 s)
12
+ * @returns Milliseconds to wait
13
+ */
14
+ declare function generateBackoffWithFullJitter(attempt: number, baseSleep?: number, maxSleep?: number): number;
15
+ export default generateBackoffWithFullJitter;
@@ -0,0 +1 @@
1
+ "use strict";function r(t,n=1e3,e=3e4){const o=Math.max(0,t),a=Math.min(e,n*2**o);return Math.round(Math.random()*a)}module.exports=r;
@@ -0,0 +1,7 @@
1
+ function r(t, n = 1e3, e = 3e4) {
2
+ const a = Math.max(0, t), o = Math.min(e, n * 2 ** a);
3
+ return Math.round(Math.random() * o);
4
+ }
5
+ export {
6
+ r as default
7
+ };
@@ -11,6 +11,8 @@
11
11
  * @param jitterPercentage - Percentage of jitter to apply (0-1), defaults to 0.25 (±25%)
12
12
  * @param attemptJitterMultiplier - Multiplier for attempt-based jitter (ms per attempt), defaults to 100
13
13
  * @param minimumDelayFactor - Factor of baseSleep to use as minimum delay (0-1), defaults to 0.5
14
+ * @param maxSleep - Cap on each delay in milliseconds, defaults to no cap. Pass a cap (e.g. 30000)
15
+ * whenever `numIntervals` is large: without one, 25 intervals from 1 s end at about 194 days.
14
16
  * @returns Array of delay values in milliseconds with applied jitter
15
17
  *
16
18
  * @example
@@ -28,5 +30,5 @@
28
30
  * const delays = generateBackoffWithVariableJitter(3, 100, 0, 0, 0.5)
29
31
  * // [100, 200, 400] (pure exponential without randomization)
30
32
  */
31
- declare function generateBackoffWithVariableJitter(numIntervals?: number, baseSleep?: number, jitterPercentage?: number, attemptJitterMultiplier?: number, minimumDelayFactor?: number): number[];
33
+ declare function generateBackoffWithVariableJitter(numIntervals?: number, baseSleep?: number, jitterPercentage?: number, attemptJitterMultiplier?: number, minimumDelayFactor?: number, maxSleep?: number): number[];
32
34
  export default generateBackoffWithVariableJitter;
@@ -1 +1 @@
1
- "use strict";const a=require("../number/randomIntFromInterval.js");function m(i=1,e=500,c=.25,s=100,u=.5){const n=[];for(let t=0;t<i;t+=1){const r=e*2**t,o=r*c,f=a(-o,o),h=a(0,t*s),l=Math.max(e*u,r+f+h);n.push(Math.round(l*100)/100)}return n}module.exports=m;
1
+ "use strict";const o=require("../number/randomIntFromInterval.js");function d(a=1,n=500,c=.25,s=100,f=.5,u=1/0){const e=[];for(let t=0;t<a;t+=1){const r=n*2**t,i=r*c,h=o(-i,i),m=o(0,t*s),l=Math.min(u,Math.max(n*f,r+h+m));e.push(Math.round(l*100)/100)}return e}module.exports=d;
@@ -1,15 +1,18 @@
1
- import a from "../number/randomIntFromInterval.mjs";
2
- function d(i = 1, e = 500, c = 0.25, f = 100, s = 0.5) {
3
- const n = [];
1
+ import r from "../number/randomIntFromInterval.mjs";
2
+ function p(i = 1, n = 500, c = 0.25, f = 100, m = 0.5, s = 1 / 0) {
3
+ const a = [];
4
4
  for (let t = 0; t < i; t += 1) {
5
- const o = e * 2 ** t, r = o * c, l = a(-r, r), m = a(0, t * f), h = Math.max(
6
- e * s,
7
- o + l + m
5
+ const e = n * 2 ** t, o = e * c, h = r(-o, o), l = r(0, t * f), u = Math.min(
6
+ s,
7
+ Math.max(
8
+ n * m,
9
+ e + h + l
10
+ )
8
11
  );
9
- n.push(Math.round(h * 100) / 100);
12
+ a.push(Math.round(u * 100) / 100);
10
13
  }
11
- return n;
14
+ return a;
12
15
  }
13
16
  export {
14
- d as default
17
+ p as default
15
18
  };
@@ -0,0 +1,18 @@
1
+ import type { RateLimit } from '../error/getRateLimit';
2
+ /** Give up on a rate-limited request after this many attempts and show the error */
3
+ export declare const RATE_LIMIT_MAX_ATTEMPTS = 5;
4
+ /** Cap on the backoff window for rate-limit retries */
5
+ export declare const RATE_LIMIT_MAX_BACKOFF_MS = 30000;
6
+ /**
7
+ * How long to wait before resending a rate-limited request:
8
+ * `max(retryAfter, random(0, min(30 s, 1 s * 2 ** attempt)))`.
9
+ *
10
+ * Returns `undefined` once `attempt` reaches `maxAttempts`: stop retrying and
11
+ * show the error.
12
+ *
13
+ * @param rateLimit Result of `getRateLimit`
14
+ * @param attempt Zero-based number of retries already made for this request
15
+ * @param maxAttempts Retries allowed in total (default 5)
16
+ */
17
+ declare function getRateLimitRetryDelay(rateLimit: Pick<RateLimit, 'retryAfterMs'>, attempt: number, maxAttempts?: number): number | undefined;
18
+ export default getRateLimitRetryDelay;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("./generateBackoffWithFullJitter.js"),t=5,r=3e4;function i(_,e,M=t){if(!(e>=M))return Math.max(_.retryAfterMs,T(e,1e3,r))}exports.RATE_LIMIT_MAX_ATTEMPTS=t;exports.RATE_LIMIT_MAX_BACKOFF_MS=r;exports.default=i;
@@ -0,0 +1,14 @@
1
+ import i from "./generateBackoffWithFullJitter.mjs";
2
+ const o = 5, M = 3e4;
3
+ function f(e, t, r = o) {
4
+ if (!(t >= r))
5
+ return Math.max(
6
+ e.retryAfterMs,
7
+ i(t, 1e3, M)
8
+ );
9
+ }
10
+ export {
11
+ o as RATE_LIMIT_MAX_ATTEMPTS,
12
+ M as RATE_LIMIT_MAX_BACKOFF_MS,
13
+ f as default
14
+ };
package/api/index.d.ts CHANGED
@@ -2,9 +2,11 @@ import getUrlAndParams from './getUrlAndParams';
2
2
  import getEndpointWithVersion from './getEndpointWithVersion';
3
3
  import generateBackoffWithEqualJitter from './generateBackoffWithEqualJitter';
4
4
  import generateBackoffWithVariableJitter from './generateBackoffWithVariableJitter';
5
+ import generateBackoffWithFullJitter from './generateBackoffWithFullJitter';
6
+ import getRateLimitRetryDelay, { RATE_LIMIT_MAX_ATTEMPTS, RATE_LIMIT_MAX_BACKOFF_MS } from './getRateLimitRetryDelay';
5
7
  import isAcceptedResponse from './isAcceptedResponse';
6
8
  import isNoContentResponse from './isNoContentResponse';
7
9
  import isPartialContentResponse from './isPartialContentResponse';
8
10
  import APIFilterBuilder from './APIFilterBuilder';
9
11
  import getMediaImageClosestSize from './getMediaImageClosestSize';
10
- export { getUrlAndParams, getEndpointWithVersion, generateBackoffWithEqualJitter, generateBackoffWithVariableJitter, isAcceptedResponse, isNoContentResponse, isPartialContentResponse, APIFilterBuilder, getMediaImageClosestSize, };
12
+ export { getUrlAndParams, getEndpointWithVersion, generateBackoffWithEqualJitter, generateBackoffWithVariableJitter, generateBackoffWithFullJitter, getRateLimitRetryDelay, RATE_LIMIT_MAX_ATTEMPTS, RATE_LIMIT_MAX_BACKOFF_MS, isAcceptedResponse, isNoContentResponse, isPartialContentResponse, APIFilterBuilder, getMediaImageClosestSize, };
package/api/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getUrlAndParams.js"),t=require("./getEndpointWithVersion.js"),i=require("./generateBackoffWithEqualJitter.js"),r=require("./generateBackoffWithVariableJitter.js"),a=require("./isAcceptedResponse.js"),n=require("./isNoContentResponse.js"),s=require("./isPartialContentResponse.js"),o=require("./APIFilterBuilder.js"),p=require("./getMediaImageClosestSize.js");require("../number/randomIntFromInterval.js");require("axios");require("./types.js");exports.getUrlAndParams=e;exports.getEndpointWithVersion=t;exports.generateBackoffWithEqualJitter=i;exports.generateBackoffWithVariableJitter=r;exports.isAcceptedResponse=a;exports.isNoContentResponse=n;exports.isPartialContentResponse=s;exports.APIFilterBuilder=o;exports.getMediaImageClosestSize=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./getUrlAndParams.js"),i=require("./getEndpointWithVersion.js"),r=require("./generateBackoffWithEqualJitter.js"),a=require("./generateBackoffWithVariableJitter.js"),n=require("./generateBackoffWithFullJitter.js"),e=require("./getRateLimitRetryDelay.js"),o=require("./isAcceptedResponse.js"),s=require("./isNoContentResponse.js"),_=require("./isPartialContentResponse.js"),l=require("./APIFilterBuilder.js"),u=require("./getMediaImageClosestSize.js");require("../number/randomIntFromInterval.js");require("axios");require("./types.js");exports.getUrlAndParams=t;exports.getEndpointWithVersion=i;exports.generateBackoffWithEqualJitter=r;exports.generateBackoffWithVariableJitter=a;exports.generateBackoffWithFullJitter=n;exports.RATE_LIMIT_MAX_ATTEMPTS=e.RATE_LIMIT_MAX_ATTEMPTS;exports.RATE_LIMIT_MAX_BACKOFF_MS=e.RATE_LIMIT_MAX_BACKOFF_MS;exports.getRateLimitRetryDelay=e.default;exports.isAcceptedResponse=o;exports.isNoContentResponse=s;exports.isPartialContentResponse=_;exports.APIFilterBuilder=l;exports.getMediaImageClosestSize=u;
package/api/index.mjs CHANGED
@@ -1,23 +1,29 @@
1
1
  import { default as f } from "./getUrlAndParams.mjs";
2
2
  import { default as i } from "./getEndpointWithVersion.mjs";
3
- import { default as l } from "./generateBackoffWithEqualJitter.mjs";
4
- import { default as m } from "./generateBackoffWithVariableJitter.mjs";
5
- import { default as u } from "./isAcceptedResponse.mjs";
6
- import { default as g } from "./isNoContentResponse.mjs";
7
- import { default as h } from "./isPartialContentResponse.mjs";
8
- import { default as B } from "./APIFilterBuilder.mjs";
9
- import { default as P } from "./getMediaImageClosestSize.mjs";
3
+ import { default as p } from "./generateBackoffWithEqualJitter.mjs";
4
+ import { default as d } from "./generateBackoffWithVariableJitter.mjs";
5
+ import { default as u } from "./generateBackoffWithFullJitter.mjs";
6
+ import { RATE_LIMIT_MAX_ATTEMPTS as A, RATE_LIMIT_MAX_BACKOFF_MS as g, default as M } from "./getRateLimitRetryDelay.mjs";
7
+ import { default as T } from "./isAcceptedResponse.mjs";
8
+ import { default as I } from "./isNoContentResponse.mjs";
9
+ import { default as B } from "./isPartialContentResponse.mjs";
10
+ import { default as h } from "./APIFilterBuilder.mjs";
11
+ import { default as F } from "./getMediaImageClosestSize.mjs";
10
12
  import "../number/randomIntFromInterval.mjs";
11
13
  import "axios";
12
14
  import "./types.mjs";
13
15
  export {
14
- B as APIFilterBuilder,
15
- l as generateBackoffWithEqualJitter,
16
- m as generateBackoffWithVariableJitter,
16
+ h as APIFilterBuilder,
17
+ A as RATE_LIMIT_MAX_ATTEMPTS,
18
+ g as RATE_LIMIT_MAX_BACKOFF_MS,
19
+ p as generateBackoffWithEqualJitter,
20
+ u as generateBackoffWithFullJitter,
21
+ d as generateBackoffWithVariableJitter,
17
22
  i as getEndpointWithVersion,
18
- P as getMediaImageClosestSize,
23
+ F as getMediaImageClosestSize,
24
+ M as getRateLimitRetryDelay,
19
25
  f as getUrlAndParams,
20
- u as isAcceptedResponse,
21
- g as isNoContentResponse,
22
- h as isPartialContentResponse
26
+ T as isAcceptedResponse,
27
+ I as isNoContentResponse,
28
+ B as isPartialContentResponse
23
29
  };
@@ -1,4 +1,4 @@
1
- import { CheckItemV2 } from '@ancon/wildcat-types';
1
+ import { CheckItem } from '@ancon/wildcat-types';
2
2
  import { OrganizedCheckItemModification } from './types';
3
3
  /**
4
4
  * Organizes all check item modifications including addon products into a array for easier visual representation.
@@ -7,4 +7,4 @@ import { OrganizedCheckItemModification } from './types';
7
7
  * @param addOnProducts - The list of check item add-on products.
8
8
  * @returns An array where the modifications are sorted by their modification kind and positions.
9
9
  */
10
- export default function getOrganizedCheckItemModifications(currency: string, modifications: CheckItemV2['modifications'] | undefined, addOnProducts: CheckItemV2['addOnProducts'] | undefined): OrganizedCheckItemModification[];
10
+ export default function getOrganizedCheckItemModifications(currency: string, modifications: CheckItem['modifications'], addOnProducts: CheckItem['addOnProducts']): OrganizedCheckItemModification[];
@@ -1 +1 @@
1
- "use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=(i??[]).reduce((a,u)=>{const{modification:A,position:s,freeAmount:f,name:y="",quantity:p,cost:g,replacementName:T}=u,m=g===0;if(u.modification===h.ModificationType.Add){(f>0||m)&&a.add.push({id:O(u,"-free"),modificationType:A,name:y,freeAmount:m?p:f,quantity:m?p:f,currency:n,position:s,cost:0});const q=p-f;q>0&&!m&&a.add.push({id:O(u),modificationType:A,name:y,quantity:q,freeAmount:0,currency:n,position:s,cost:g*q})}return u.modification===h.ModificationType.Replace&&a.replace.push({id:O(u),modificationType:A,name:y,replacementName:T,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),u.modification===h.ModificationType.Remove&&a.remove.push({id:O(u),modificationType:A,name:y,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),a},{add:[],replace:[],remove:[]}),o=(r??[]).reduce((a,u)=>{const{product:A,freeAmount:s=0,quantity:f,position:y,addOnGroupId:p,productPriceInclTax:g}=u,{hasVariants:T,variantName:m="",productName:q="",productId:B,variantId:F}=A??{},b=g.unitPrice===0;(s>0||b)&&a.push({id:`${p}-${B}-free`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:b?f:s,quantity:b?f:s,currency:n,position:y,cost:0,variantId:F});const w=f-s;return w>0&&!b&&a.push({id:`${p}-${B}`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:0,quantity:w,currency:n,position:y,cost:g.unitPrice*w,variantId:F}),a},[]);return[...C([...e,...o],["position"],["asc"]),...C(d,["position"],["asc"]),...C(t,["position"],["asc"])]}module.exports=K;
1
+ "use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=i.reduce((a,u)=>{const{modification:A,position:s,freeAmount:f,name:y,quantity:p,cost:g,replacementName:T}=u,m=g===0;if(u.modification===h.ModificationType.Add){(f>0||m)&&a.add.push({id:O(u,"-free"),modificationType:A,name:y,freeAmount:m?p:f,quantity:m?p:f,currency:n,position:s,cost:0});const q=p-f;q>0&&!m&&a.add.push({id:O(u),modificationType:A,name:y,quantity:q,freeAmount:0,currency:n,position:s,cost:g*q})}return u.modification===h.ModificationType.Replace&&a.replace.push({id:O(u),modificationType:A,name:y,replacementName:T,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),u.modification===h.ModificationType.Remove&&a.remove.push({id:O(u),modificationType:A,name:y,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),a},{add:[],replace:[],remove:[]}),o=(r||[]).reduce((a,u)=>{const{product:A,addOnFreeAmount:s,quantity:f,addOnPosition:y,addOnGroupId:p,productPriceInclTax:g}=u,{hasVariants:T,variantName:m,productName:q,productId:B,variantId:F}=A,b=g.unitPrice.amount===0;(s>0||b)&&a.push({id:`${p}-${B}-free`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:b?f:s,quantity:b?f:s,currency:n,position:y,cost:0,variantId:F});const w=f-s;return w>0&&!b&&a.push({id:`${p}-${B}`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:0,quantity:w,currency:n,position:y,cost:g.unitPrice.amount*w,variantId:F}),a},[]);return[...C([...e,...o],["position"],["asc"]),...C(d,["position"],["asc"]),...C(t,["position"],["asc"])]}module.exports=K;
@@ -8,10 +8,10 @@ import T from "./getUniqueCheckItemModificationId.mjs";
8
8
  import "../_baseIsEqual-4ee44a4c.mjs";
9
9
  import "../isObject-b8638513.mjs";
10
10
  function U(n) {
11
- return function(i, t, o) {
12
- for (var d = -1, r = Object(i), u = o(i), f = u.length; f--; ) {
13
- var a = u[n ? f : ++d];
14
- if (t(r[a], a, r) === !1)
11
+ return function(i, t, a) {
12
+ for (var e = -1, r = Object(i), u = a(i), f = u.length; f--; ) {
13
+ var o = u[n ? f : ++e];
14
+ if (t(r[o], o, r) === !1)
15
15
  break;
16
16
  }
17
17
  return i;
@@ -23,12 +23,12 @@ function V(n, i) {
23
23
  return n && z(n, i, L);
24
24
  }
25
25
  function H(n, i) {
26
- return function(t, o) {
26
+ return function(t, a) {
27
27
  if (t == null)
28
28
  return t;
29
29
  if (!P(t))
30
- return n(t, o);
31
- for (var d = t.length, r = i ? d : -1, u = Object(t); (i ? r-- : ++r < d) && o(u[r], r, u) !== !1; )
30
+ return n(t, a);
31
+ for (var e = t.length, r = i ? e : -1, u = Object(t); (i ? r-- : ++r < e) && a(u[r], r, u) !== !1; )
32
32
  ;
33
33
  return t;
34
34
  };
@@ -36,10 +36,10 @@ function H(n, i) {
36
36
  var J = H(V);
37
37
  const K = J;
38
38
  function W(n, i) {
39
- var t = -1, o = P(n) ? Array(n.length) : [];
40
- return K(n, function(d, r, u) {
41
- o[++t] = i(d, r, u);
42
- }), o;
39
+ var t = -1, a = P(n) ? Array(n.length) : [];
40
+ return K(n, function(e, r, u) {
41
+ a[++t] = i(e, r, u);
42
+ }), a;
43
43
  }
44
44
  function X(n, i) {
45
45
  var t = n.length;
@@ -49,22 +49,22 @@ function X(n, i) {
49
49
  }
50
50
  function Y(n, i) {
51
51
  if (n !== i) {
52
- var t = n !== void 0, o = n === null, d = n === n, r = F(n), u = i !== void 0, f = i === null, a = i === i, e = F(i);
53
- if (!f && !e && !r && n > i || r && u && a && !f && !e || o && u && a || !t && a || !d)
52
+ var t = n !== void 0, a = n === null, e = n === n, r = F(n), u = i !== void 0, f = i === null, o = i === i, d = F(i);
53
+ if (!f && !d && !r && n > i || r && u && o && !f && !d || a && u && o || !t && o || !e)
54
54
  return 1;
55
- if (!o && !r && !e && n < i || e && t && d && !o && !r || f && t && d || !u && d || !a)
55
+ if (!a && !r && !d && n < i || d && t && e && !a && !r || f && t && e || !u && e || !o)
56
56
  return -1;
57
57
  }
58
58
  return 0;
59
59
  }
60
60
  function _(n, i, t) {
61
- for (var o = -1, d = n.criteria, r = i.criteria, u = d.length, f = t.length; ++o < u; ) {
62
- var a = Y(d[o], r[o]);
63
- if (a) {
64
- if (o >= f)
65
- return a;
66
- var e = t[o];
67
- return a * (e == "desc" ? -1 : 1);
61
+ for (var a = -1, e = n.criteria, r = i.criteria, u = e.length, f = t.length; ++a < u; ) {
62
+ var o = Y(e[a], r[a]);
63
+ if (o) {
64
+ if (a >= f)
65
+ return o;
66
+ var d = t[a];
67
+ return o * (d == "desc" ? -1 : 1);
68
68
  }
69
69
  }
70
70
  return n.index - i.index;
@@ -75,110 +75,104 @@ function j(n, i, t) {
75
75
  return E(u, r.length === 1 ? r[0] : r);
76
76
  } : r;
77
77
  }) : i = [x];
78
- var o = -1;
78
+ var a = -1;
79
79
  i = q(i, Q(G));
80
- var d = W(n, function(r, u, f) {
81
- var a = q(i, function(e) {
82
- return e(r);
80
+ var e = W(n, function(r, u, f) {
81
+ var o = q(i, function(d) {
82
+ return d(r);
83
83
  });
84
- return { criteria: a, index: ++o, value: r };
84
+ return { criteria: o, index: ++a, value: r };
85
85
  });
86
- return X(d, function(r, u) {
86
+ return X(e, function(r, u) {
87
87
  return _(r, u, t);
88
88
  });
89
89
  }
90
- function C(n, i, t, o) {
91
- return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t = o ? void 0 : t, $(t) || (t = t == null ? [] : [t]), j(n, i, t));
90
+ function C(n, i, t, a) {
91
+ return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t = a ? void 0 : t, $(t) || (t = t == null ? [] : [t]), j(n, i, t));
92
92
  }
93
93
  function rn(n, i, t) {
94
- const { add: o, replace: d, remove: r } = (i ?? []).reduce(
95
- (a, e) => {
94
+ const { add: a, replace: e, remove: r } = i.reduce(
95
+ (o, d) => {
96
96
  const {
97
97
  modification: h,
98
- position: c,
99
- freeAmount: p,
100
- name: m = "",
98
+ position: p,
99
+ freeAmount: c,
100
+ name: m,
101
101
  quantity: s,
102
102
  cost: g,
103
103
  replacementName: O
104
- } = e, A = g === 0;
105
- if (e.modification === y.Add) {
106
- (p > 0 || A) && a.add.push({
107
- id: T(e, "-free"),
104
+ } = d, A = g === 0;
105
+ if (d.modification === y.Add) {
106
+ (c > 0 || A) && o.add.push({
107
+ id: T(d, "-free"),
108
108
  modificationType: h,
109
109
  name: m,
110
- freeAmount: A ? s : p,
111
- quantity: A ? s : p,
110
+ freeAmount: A ? s : c,
111
+ quantity: A ? s : c,
112
112
  currency: n,
113
- position: c,
113
+ position: p,
114
114
  cost: 0
115
115
  });
116
- const b = s - p;
117
- b > 0 && !A && a.add.push({
118
- id: T(e),
116
+ const b = s - c;
117
+ b > 0 && !A && o.add.push({
118
+ id: T(d),
119
119
  modificationType: h,
120
120
  name: m,
121
121
  quantity: b,
122
122
  freeAmount: 0,
123
123
  currency: n,
124
- position: c,
124
+ position: p,
125
125
  cost: g * b
126
126
  });
127
127
  }
128
- return e.modification === y.Replace && a.replace.push({
129
- id: T(e),
128
+ return d.modification === y.Replace && o.replace.push({
129
+ id: T(d),
130
130
  modificationType: h,
131
131
  name: m,
132
132
  replacementName: O,
133
- freeAmount: p,
133
+ freeAmount: c,
134
134
  quantity: s,
135
135
  currency: n,
136
- position: c,
136
+ position: p,
137
137
  cost: g
138
- }), e.modification === y.Remove && a.remove.push({
139
- id: T(e),
138
+ }), d.modification === y.Remove && o.remove.push({
139
+ id: T(d),
140
140
  modificationType: h,
141
141
  name: m,
142
- freeAmount: p,
142
+ freeAmount: c,
143
143
  quantity: s,
144
144
  currency: n,
145
- position: c,
145
+ position: p,
146
146
  cost: g
147
- }), a;
147
+ }), o;
148
148
  },
149
149
  {
150
150
  add: [],
151
151
  replace: [],
152
152
  remove: []
153
153
  }
154
- ), u = (t ?? []).reduce((a, e) => {
154
+ ), u = (t || []).reduce((o, d) => {
155
155
  const {
156
156
  product: h,
157
- freeAmount: c = 0,
158
- quantity: p,
159
- position: m,
157
+ addOnFreeAmount: p,
158
+ quantity: c,
159
+ addOnPosition: m,
160
160
  addOnGroupId: s,
161
161
  productPriceInclTax: g
162
- } = e, {
163
- hasVariants: O,
164
- variantName: A = "",
165
- productName: b = "",
166
- productId: w,
167
- variantId: B
168
- } = h ?? {}, M = g.unitPrice === 0;
169
- (c > 0 || M) && a.push({
162
+ } = d, { hasVariants: O, variantName: A, productName: b, productId: w, variantId: B } = h, M = g.unitPrice.amount === 0;
163
+ (p > 0 || M) && o.push({
170
164
  id: `${s}-${w}-free`,
171
165
  modificationType: y.Add,
172
166
  name: O ? A : b,
173
- freeAmount: M ? p : c,
174
- quantity: M ? p : c,
167
+ freeAmount: M ? c : p,
168
+ quantity: M ? c : p,
175
169
  currency: n,
176
170
  position: m,
177
171
  cost: 0,
178
172
  variantId: B
179
173
  });
180
- const k = p - c;
181
- return k > 0 && !M && a.push({
174
+ const k = c - p;
175
+ return k > 0 && !M && o.push({
182
176
  id: `${s}-${w}`,
183
177
  modificationType: y.Add,
184
178
  name: O ? A : b,
@@ -186,13 +180,13 @@ function rn(n, i, t) {
186
180
  quantity: k,
187
181
  currency: n,
188
182
  position: m,
189
- cost: g.unitPrice * k,
183
+ cost: g.unitPrice.amount * k,
190
184
  variantId: B
191
- }), a;
185
+ }), o;
192
186
  }, []);
193
187
  return [
194
- ...C([...o, ...u], ["position"], ["asc"]),
195
- ...C(d, ["position"], ["asc"]),
188
+ ...C([...a, ...u], ["position"], ["asc"]),
189
+ ...C(e, ["position"], ["asc"]),
196
190
  ...C(r, ["position"], ["asc"])
197
191
  ];
198
192
  }
@@ -1,8 +1,8 @@
1
- import { CheckItemModificationV2 } from '@ancon/wildcat-types';
1
+ import { CheckItemModification } from '@ancon/wildcat-types';
2
2
  /**
3
3
  * Generate a unique ID for a Check Item Modification
4
4
  * @param modification - Check Item Modification
5
5
  * @param suffix - Optional suffix to append to the ID
6
6
  * @returns Unique ID string
7
7
  */
8
- export default function getUniqueCheckItemModificationId(modification: CheckItemModificationV2, suffix?: string): string;
8
+ export default function getUniqueCheckItemModificationId(modification: CheckItemModification, suffix?: string): string;
@@ -1 +1 @@
1
- "use strict";function p(n,e){const{modification:i,ingredientId:o,replaceId:$,addOnGroupId:c,quantity:d,cost:a,freeAmount:r,name:t="",replacementName:m,position:u}=n;return`modification-${i}-${o}-${$??0}-${c??null}-${d}-${a}-${r}-${t}-${m??t}-${u}${e?`-${e}`:""}`}module.exports=p;
1
+ "use strict";function u(i,e){const{modification:n,ingredientId:o,replaceId:$,addOnGroupId:c,quantity:d,cost:a,freeAmount:r,name:t,replacementName:m,position:p}=i;return`modification-${n}-${o}-${$??0}-${c}-${d}-${a}-${r}-${t}-${m??t}-${p}${e?`-${e}`:""}`}module.exports=u;
@@ -1,4 +1,4 @@
1
- function p(n, e) {
1
+ function u(n, e) {
2
2
  const {
3
3
  modification: i,
4
4
  ingredientId: o,
@@ -7,12 +7,12 @@ function p(n, e) {
7
7
  quantity: d,
8
8
  cost: c,
9
9
  freeAmount: r,
10
- name: t = "",
10
+ name: t,
11
11
  replacementName: m,
12
- position: u
12
+ position: p
13
13
  } = n;
14
- return `modification-${i}-${o}-${$ ?? 0}-${a ?? null}-${d}-${c}-${r}-${t}-${m ?? t}-${u}${e ? `-${e}` : ""}`;
14
+ return `modification-${i}-${o}-${$ ?? 0}-${a}-${d}-${c}-${r}-${t}-${m ?? t}-${p}${e ? `-${e}` : ""}`;
15
15
  }
16
16
  export {
17
- p as default
17
+ u as default
18
18
  };
@@ -0,0 +1,31 @@
1
+ /** `code` in the problem+json body of a rate-limited request */
2
+ export declare const RATE_LIMIT_EXCEEDED_CODE = "rate_limit_exceeded";
3
+ /** Wait used when the response says nothing about how long to wait (e.g. the edge's plain-text 429) */
4
+ export declare const DEFAULT_RATE_LIMIT_RETRY_AFTER_MS = 1000;
5
+ export declare type RateLimit = {
6
+ /** HTTP status of the rejection: 429, or 423 for older POS builds */
7
+ status: 429 | 423;
8
+ /** Milliseconds to wait before sending the request again, at least 1 s */
9
+ retryAfterMs: number;
10
+ /** Policy that rejected the request. For logs and support, not for client logic. */
11
+ policy?: string;
12
+ };
13
+ /**
14
+ * Whether an API error is a rate limit, and how long to wait before sending
15
+ * the request again.
16
+ *
17
+ * A rate limit is a 429, or a 423 whose problem+json body has
18
+ * `code: 'rate_limit_exceeded'` (POS builds older than 1.38 get it as 423).
19
+ * Any other 423 keeps its business meaning and returns `undefined`.
20
+ *
21
+ * The wait comes from the `Retry-After` header, else the body's `retryAfter`,
22
+ * else 1 s (the edge answers a plain-text 429 with neither). It is never
23
+ * shorter than 1 s.
24
+ *
25
+ * Nothing ran on the server, so resending after the wait is safe for every
26
+ * method. See the "Client contract" in wildcat.shared `RateLimiting/README.md`.
27
+ *
28
+ * @returns The rate limit, or `undefined` when the error is not a rate limit
29
+ */
30
+ declare function getRateLimit(error: unknown, now?: number): RateLimit | undefined;
31
+ export default getRateLimit;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("axios"),E="rate_limit_exceeded",u=1e3;function y(t,r){if(t==null||typeof t!="object")return;const{get:n}=t;if(typeof n=="function"){const o=n.call(t,r);if(o!=null&&o!==!1)return String(o)}const e=r.toLowerCase(),s=Object.keys(t).find(o=>o.toLowerCase()===e),i=s?t[s]:void 0,c=Array.isArray(i)?i[0]:i;return c!=null?String(c):void 0}function p(t,r){if(t==null||t.trim()==="")return;const n=Number(t);if(Number.isFinite(n))return n*1e3;const e=Date.parse(t);if(!Number.isNaN(e))return e-r}function A(t){if(t!=null&&typeof t=="object")return t;if(typeof t=="string")try{const r=JSON.parse(t);if(r!=null&&typeof r=="object")return r}catch{}}function d(t,r=Date.now()){var f,l,a;if(!_.isAxiosError(t))return;const n=((f=t.response)==null?void 0:f.status)??t.status,e=A((l=t.response)==null?void 0:l.data),s=(e==null?void 0:e.code)===E;if(n!==429&&!(n===423&&s))return;const i=p(y((a=t.response)==null?void 0:a.headers,"Retry-After"),r),c=typeof(e==null?void 0:e.retryAfter)=="number"&&Number.isFinite(e.retryAfter)?e.retryAfter*1e3:void 0,o=Math.max(u,Math.ceil(i??c??u));return{status:n,retryAfterMs:o,policy:typeof(e==null?void 0:e.policy)=="string"?e.policy:void 0}}exports.DEFAULT_RATE_LIMIT_RETRY_AFTER_MS=u;exports.RATE_LIMIT_EXCEEDED_CODE=E;exports.default=d;
@@ -0,0 +1,60 @@
1
+ import { isAxiosError as p } from "axios";
2
+ const y = "rate_limit_exceeded", a = 1e3;
3
+ function m(t, r) {
4
+ if (t == null || typeof t != "object")
5
+ return;
6
+ const { get: n } = t;
7
+ if (typeof n == "function") {
8
+ const o = n.call(t, r);
9
+ if (o != null && o !== !1)
10
+ return String(o);
11
+ }
12
+ const e = r.toLowerCase(), s = Object.keys(t).find((o) => o.toLowerCase() === e), i = s ? t[s] : void 0, c = Array.isArray(i) ? i[0] : i;
13
+ return c != null ? String(c) : void 0;
14
+ }
15
+ function A(t, r) {
16
+ if (t == null || t.trim() === "")
17
+ return;
18
+ const n = Number(t);
19
+ if (Number.isFinite(n))
20
+ return n * 1e3;
21
+ const e = Date.parse(t);
22
+ if (!Number.isNaN(e))
23
+ return e - r;
24
+ }
25
+ function d(t) {
26
+ if (t != null && typeof t == "object")
27
+ return t;
28
+ if (typeof t == "string")
29
+ try {
30
+ const r = JSON.parse(t);
31
+ if (r != null && typeof r == "object")
32
+ return r;
33
+ } catch {
34
+ }
35
+ }
36
+ function _(t, r = Date.now()) {
37
+ var f, u, l;
38
+ if (!p(t))
39
+ return;
40
+ const n = ((f = t.response) == null ? void 0 : f.status) ?? t.status, e = d((u = t.response) == null ? void 0 : u.data), s = (e == null ? void 0 : e.code) === y;
41
+ if (n !== 429 && !(n === 423 && s))
42
+ return;
43
+ const i = A(
44
+ m((l = t.response) == null ? void 0 : l.headers, "Retry-After"),
45
+ r
46
+ ), c = typeof (e == null ? void 0 : e.retryAfter) == "number" && Number.isFinite(e.retryAfter) ? e.retryAfter * 1e3 : void 0, o = Math.max(
47
+ a,
48
+ Math.ceil(i ?? c ?? a)
49
+ );
50
+ return {
51
+ status: n,
52
+ retryAfterMs: o,
53
+ policy: typeof (e == null ? void 0 : e.policy) == "string" ? e.policy : void 0
54
+ };
55
+ }
56
+ export {
57
+ a as DEFAULT_RATE_LIMIT_RETRY_AFTER_MS,
58
+ y as RATE_LIMIT_EXCEEDED_CODE,
59
+ _ as default
60
+ };
package/error/index.d.ts CHANGED
@@ -13,6 +13,8 @@ import isBadGatewayError from './isBadGatewayError';
13
13
  import isServiceUnavailableError from './isServiceUnavailableError';
14
14
  import isTooManyRequestsError from './isTooManyRequestsError';
15
15
  import isUpgradeRequiredError from './isUpgradeRequiredError';
16
+ import getRateLimit, { RateLimit, RATE_LIMIT_EXCEEDED_CODE, DEFAULT_RATE_LIMIT_RETRY_AFTER_MS } from './getRateLimit';
17
+ import isRateLimitError from './isRateLimitError';
16
18
  import { SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError } from './types';
17
- export type { CodedError, SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError, };
18
- export { createCodedError, isCodedError, isNetworkError, isLockedError, isNotFoundError, serializeError, isAPIError, isSerializedAPIError, isSerializedCodedError, isErrorWithStatusCode, isBadGatewayError, isServiceUnavailableError, isTooManyRequestsError, isUpgradeRequiredError, getErrorCode, };
19
+ export type { CodedError, RateLimit, SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError, };
20
+ export { createCodedError, isCodedError, isNetworkError, isLockedError, isNotFoundError, serializeError, isAPIError, isSerializedAPIError, isSerializedCodedError, isErrorWithStatusCode, isBadGatewayError, isServiceUnavailableError, isTooManyRequestsError, isUpgradeRequiredError, getErrorCode, getRateLimit, isRateLimitError, RATE_LIMIT_EXCEEDED_CODE, DEFAULT_RATE_LIMIT_RETRY_AFTER_MS, };
package/error/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./createCodedError.js"),e=require("./isCodedError.js"),o=require("./isNetworkError.js"),i=require("./isLockedError.js"),s=require("./isNotFoundError.js"),t=require("./isAPIError.js"),d=require("./isSerializedAPIError.js"),E=require("./isSerializedCodedError.js"),a=require("./serializeError.js"),u=require("./getErrorCode.js"),c=require("./isErrorWithStatusCode.js"),n=require("./isBadGatewayError.js"),q=require("./isServiceUnavailableError.js"),_=require("./isTooManyRequestsError.js"),l=require("./isUpgradeRequiredError.js");require("axios");require("@ancon/wildcat-types");exports.createCodedError=r;exports.isCodedError=e;exports.isNetworkError=o;exports.isLockedError=i;exports.isNotFoundError=s;exports.isAPIError=t;exports.isSerializedAPIError=d;exports.isSerializedCodedError=E;exports.serializeError=a;exports.getErrorCode=u;exports.isErrorWithStatusCode=c;exports.isBadGatewayError=n;exports.isServiceUnavailableError=q;exports.isTooManyRequestsError=_;exports.isUpgradeRequiredError=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createCodedError.js"),o=require("./isCodedError.js"),i=require("./isNetworkError.js"),s=require("./isLockedError.js"),t=require("./isNotFoundError.js"),E=require("./isAPIError.js"),a=require("./isSerializedAPIError.js"),d=require("./isSerializedCodedError.js"),_=require("./serializeError.js"),u=require("./getErrorCode.js"),c=require("./isErrorWithStatusCode.js"),n=require("./isBadGatewayError.js"),q=require("./isServiceUnavailableError.js"),R=require("./isTooManyRequestsError.js"),T=require("./isUpgradeRequiredError.js"),r=require("./getRateLimit.js"),l=require("./isRateLimitError.js");require("axios");require("@ancon/wildcat-types");exports.createCodedError=e;exports.isCodedError=o;exports.isNetworkError=i;exports.isLockedError=s;exports.isNotFoundError=t;exports.isAPIError=E;exports.isSerializedAPIError=a;exports.isSerializedCodedError=d;exports.serializeError=_;exports.getErrorCode=u;exports.isErrorWithStatusCode=c;exports.isBadGatewayError=n;exports.isServiceUnavailableError=q;exports.isTooManyRequestsError=R;exports.isUpgradeRequiredError=T;exports.DEFAULT_RATE_LIMIT_RETRY_AFTER_MS=r.DEFAULT_RATE_LIMIT_RETRY_AFTER_MS;exports.RATE_LIMIT_EXCEEDED_CODE=r.RATE_LIMIT_EXCEEDED_CODE;exports.getRateLimit=r.default;exports.isRateLimitError=l;