@sommpicks/sommpicks-shopify 24.12.11 → 24.12.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopifyUtils.d.ts","sourceRoot":"","sources":["../../shopify/ShopifyUtils.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI7C,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IACxD,YAAY,EAAE,MAAM;QAAE,0BAA0B,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;KAAC,CAAC;CAClJ;AAED,qBAAa,YAAY;IAErB,OAAc,gBAAgB,SAAU,MAAM,SAAS,MAAM,WAAW,MAAM,YAAY,MAAM,WAAW,aAAa,KAAG,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ShopifyUtils.d.ts","sourceRoot":"","sources":["../../shopify/ShopifyUtils.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI7C,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IACxD,YAAY,EAAE,MAAM;QAAE,0BAA0B,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;KAAC,CAAC;CAClJ;AAED,qBAAa,YAAY;IAErB,OAAc,gBAAgB,SAAU,MAAM,SAAS,MAAM,WAAW,MAAM,YAAY,MAAM,WAAW,aAAa,KAAG,qBAAqB,CAqD9I;CACL"}
|
|
@@ -62,7 +62,14 @@ ShopifyUtils.getAxiosInstance = (shop, token, api_key, password, options) => {
|
|
|
62
62
|
},
|
|
63
63
|
shouldResetTimeout: true,
|
|
64
64
|
retryCondition: (error) => {
|
|
65
|
-
|
|
65
|
+
// const status = error?.response?.status;
|
|
66
|
+
// return (axiosRetry as any).isNetworkOrIdempotentRequestError(error)
|
|
67
|
+
// || (typeof status === 'number' && status >= 500 && status <= 599)
|
|
68
|
+
// || status === 429;
|
|
69
|
+
return axios_retry_1.default.isNetworkOrIdempotentRequestError(error) ||
|
|
70
|
+
error.code === 'ECONNABORTED'
|
|
71
|
+
|| (error.response && error.response.status >= 500 && error.response.status <= 599)
|
|
72
|
+
|| (error.response && error.response.status === 429);
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
const axiosRateLimit = new sommpicks_shopify_rate_limit_1.default(client, { maxRequests: options.max_requests_per_sec, timeFrameInMillsForCalls: 1000 }, 50);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopifyUtils.js","sourceRoot":"","sources":["../../shopify/ShopifyUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACrC,0FAAqE;AACrE,iCAA6C;AAC7C,qEAAyE;AACzE,kDAA2C;AAM3C,MAAa,YAAY;;AAAzB,
|
|
1
|
+
{"version":3,"file":"ShopifyUtils.js","sourceRoot":"","sources":["../../shopify/ShopifyUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACrC,0FAAqE;AACrE,iCAA6C;AAC7C,qEAAyE;AACzE,kDAA2C;AAM3C,MAAa,YAAY;;AAAzB,oCAwDC;AAtDiB,6BAAgB,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,OAAe,EAAE,QAAgB,EAAE,OAAsB,EAAyB,EAAE;IAC/I,IAAI,CAAC,OAAO,EAAE;QAAE,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;QAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,oB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import axiosRetry from 'axios-retry';\nimport AxiosRateLimit from '@sommpicks/sommpicks-shopify-rate-limit';\nimport axios, { AxiosInstance } from 'axios';\nimport { setupCache, buildMemoryStorage } from 'axios-cache-interceptor';\nimport APIVersion from './base/APIVersion';\n\nexport interface AxiosInstanceExtended extends AxiosInstance {\n getQueueInfo: () => { request_within_last_second: number; apiQueue: number; graphQueue: number; apiProcessed: number; graphProcessed: number;};\n}\n\nexport class ShopifyUtils {\n\n public static getAxiosInstance = (shop: string, token: string, api_key: string, password: string, options: IRest_Options): AxiosInstanceExtended => {\n if (!options) { options.enableCache = false; options.timeout = 30000; options.retries = 3; options.logger = null; options.max_requests_per_sec = 2; }\n if (!options.timeout) { options.timeout = 30000; }\n if (!options.retries) { options.retries = 5; }\n if (!options.retries) { options.retries = 5; }\n if (!options.enableCache) { options.enableCache = false; }\n if (!options.max_requests_per_sec) { options.max_requests_per_sec = 2; }\n let client;\n if (token) {\n client = axios.create({\n baseURL: `https://${shop}/admin/${APIVersion.API_URL}`,\n timeout: options.timeout,\n headers: {\n 'X-Shopify-Access-Token': token,\n 'Content-Type': 'application/json;charset=UTF-8'\n }\n });\n } else if (api_key && password) {\n client = axios.create({\n baseURL: `https://${api_key}:${password}@${shop}/admin/${APIVersion.API_URL}`,\n timeout: options.timeout,\n headers: { 'Content-Type': 'application/json;charset=UTF-8' }\n });\n } else {\n throw 'No acces token defined AND no private app key and password set so it is not possible to build the admin shop url';\n }\n (axiosRetry as any)(client, {\n retries: options.retries,\n retryDelay: (retryCount: number) => {\n if (options.logger && retryCount === options.retries) options.logger.error(`Retry ${retryCount} ...`);\n return retryCount * (retryCount > 3 ? 2000 : 500);\n },\n shouldResetTimeout: true,\n retryCondition: (error: any) => {\n // const status = error?.response?.status;\n // return (axiosRetry as any).isNetworkOrIdempotentRequestError(error)\n // || (typeof status === 'number' && status >= 500 && status <= 599)\n // || status === 429;\n return (axiosRetry as any).isNetworkOrIdempotentRequestError(error) || \n error.code ==='ECONNABORTED'\n || (error.response && error.response.status >= 500 && error.response.status <= 599) \n || (error.response && error.response.status === 429);\n }\n });\n const axiosRateLimit = new AxiosRateLimit(\n client,\n { maxRequests: options.max_requests_per_sec, timeFrameInMillsForCalls: 1000 },\n 50\n );\n if(options.enableCache) {\n client = setupCache(axiosRateLimit.getInstance(), { methods: ['get'], storage: buildMemoryStorage(true, options.cacheTimeInMiliseconds) });\n }\n return options.enableCache ? client : axiosRateLimit.getInstance();\n };\n}\n"]}
|
package/package.json
CHANGED
package/shopify/ShopifyUtils.ts
CHANGED
|
@@ -44,7 +44,14 @@ export class ShopifyUtils {
|
|
|
44
44
|
},
|
|
45
45
|
shouldResetTimeout: true,
|
|
46
46
|
retryCondition: (error: any) => {
|
|
47
|
-
|
|
47
|
+
// const status = error?.response?.status;
|
|
48
|
+
// return (axiosRetry as any).isNetworkOrIdempotentRequestError(error)
|
|
49
|
+
// || (typeof status === 'number' && status >= 500 && status <= 599)
|
|
50
|
+
// || status === 429;
|
|
51
|
+
return (axiosRetry as any).isNetworkOrIdempotentRequestError(error) ||
|
|
52
|
+
error.code ==='ECONNABORTED'
|
|
53
|
+
|| (error.response && error.response.status >= 500 && error.response.status <= 599)
|
|
54
|
+
|| (error.response && error.response.status === 429);
|
|
48
55
|
}
|
|
49
56
|
});
|
|
50
57
|
const axiosRateLimit = new AxiosRateLimit(
|