@ehrenkind/shopify-lib 0.8.1 → 0.8.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.
package/dist/index.cjs CHANGED
@@ -212,13 +212,21 @@ var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
212
212
  "UND_ERR_SOCKET",
213
213
  "UND_ERR_CONNECT_TIMEOUT",
214
214
  "UND_ERR_HEADERS_TIMEOUT",
215
- "UND_ERR_BODY_TIMEOUT"
215
+ "UND_ERR_BODY_TIMEOUT",
216
+ // Shopify GraphQL rate limiting — backoff lets the leaky bucket refill
217
+ "THROTTLED"
216
218
  ]);
217
219
  function hasRetryableCode(value) {
218
220
  if (!value || typeof value !== "object") return false;
219
221
  const code = value.code;
220
222
  return typeof code === "string" && RETRYABLE_ERROR_CODES.has(code);
221
223
  }
224
+ function isThrottledErrors(errors) {
225
+ const list = Array.isArray(errors) ? errors : [errors];
226
+ return list.some(
227
+ (e) => e?.extensions?.code === "THROTTLED"
228
+ );
229
+ }
222
230
  function isRetryableError(error) {
223
231
  if (!(error instanceof Error)) return false;
224
232
  if (hasRetryableCode(error)) return true;
@@ -306,7 +314,12 @@ async function makeRequest(query, variables, retries = 0) {
306
314
  errorMessages = JSON.stringify(errors);
307
315
  }
308
316
  logger.error("GraphQL query failed:", errorMessages);
309
- throw new Error(`GraphQL errors: ${errorMessages}`);
317
+ const graphqlError = new Error(`GraphQL errors: ${errorMessages}`);
318
+ if (isThrottledErrors(errors)) {
319
+ ;
320
+ graphqlError.code = "THROTTLED";
321
+ }
322
+ throw graphqlError;
310
323
  }
311
324
  if (!response.data) {
312
325
  throw new Error("No data in Shopify API response");
@@ -1838,6 +1851,20 @@ var queryOrderByIdFull = gql`#graphql
1838
1851
  amount
1839
1852
  currencyCode
1840
1853
  }
1854
+ presentmentMoney {
1855
+ amount
1856
+ currencyCode
1857
+ }
1858
+ }
1859
+ currentTotalPriceSet {
1860
+ shopMoney {
1861
+ amount
1862
+ currencyCode
1863
+ }
1864
+ presentmentMoney {
1865
+ amount
1866
+ currencyCode
1867
+ }
1841
1868
  }
1842
1869
  customer {
1843
1870
  id
@@ -1892,6 +1919,10 @@ var queryOrderByIdFull = gql`#graphql
1892
1919
  amount
1893
1920
  currencyCode
1894
1921
  }
1922
+ presentmentMoney {
1923
+ amount
1924
+ currencyCode
1925
+ }
1895
1926
  }
1896
1927
  }
1897
1928
  vendor