🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@shopify/graphql-client

Package Overview
Dependencies
Maintainers
8
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/graphql-client - npm Package Compare versions

Comparing version

to
1.3.1

2

dist/graphql-client/constants.js

@@ -17,3 +17,3 @@ 'use strict';

// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = '1.3.0';
const DEFAULT_CLIENT_VERSION = '1.3.1';
const RETRY_WAIT_TIME = 1000;

@@ -20,0 +20,0 @@ const RETRIABLE_STATUS_CODES = [429, 503];

@@ -1,2 +0,2 @@

/*! shopify/graphql-client@1.3.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
/*! shopify/graphql-client@1.3.1 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
(function (global, factory) {

@@ -22,3 +22,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = '1.3.0';
const DEFAULT_CLIENT_VERSION = '1.3.1';
const RETRY_WAIT_TIME = 1000;

@@ -25,0 +25,0 @@ const RETRIABLE_STATUS_CODES = [429, 503];

@@ -1,3 +0,3 @@

/*! shopify/graphql-client@1.3.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ShopifyGraphQLClient={})}(this,(function(e){"use strict";const r="GraphQL Client",t="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",n="Response returned unexpected Content-Type:",s="An unknown error has occurred. The API did not return a data object or any errors in its response.",o="application/json",a="multipart/mixed",i="X-SDK-Variant",c="X-SDK-Version",u="shopify-graphql-client",d="1.3.0",l=[429,503],f=/@(defer)\b/i,y=/boundary="?([^=";]+)"?/i,h="\r\n\r\n";function p(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function m(e){return e instanceof Error?e.message:JSON.stringify(e)}function w(e){return e instanceof Error&&e.cause?e.cause:void 0}function g(e){return e.flatMap((({errors:e})=>e??[]))}function b({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<0||r>3))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than 0 or greater than 3`)}function x(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function E(e,r){if(0===e.length)return r;const t=e.pop(),n={[t]:r};return 0===e.length?n:E(e,n)}function S(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=S(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function A([e,...r]){return r.reduce(S,{...e})}function T({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=1e3,retriableCodes:o=l}){const a=async(r,i,c)=>{const u=i+1,d=c+1;let l;try{if(l=await t(...r),e({type:"HTTP-Response",content:{requestParams:r,response:l}}),!l.ok&&o.includes(l.status)&&u<=d)throw new Error;return l}catch(t){if(u<=d){const t=l?.headers.get("Retry-After");return await async function(e){return new Promise((r=>setTimeout(r,e)))}(t?parseInt(t,10):s),e({type:"HTTP-Retry",content:{requestParams:r,lastResponse:l,retryAttempt:i,maxRetries:c}}),a(r,u,c)}throw new Error(p(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${m(t)}`,n))}};return a}async function k(e){const{errors:r,data:n,extensions:o}=await e.json();return{...x("data",n),...x("extensions",o),headers:e.headers,...r||!n?{errors:{networkStatusCode:e.status,message:p(r?t:s),...x("graphQLErrors",r),response:e}}:{}}}function $(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${m(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...x("errors",o),...x("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?E(r,e):{},...x("errors",t)})));return{data:1===a.length?a[0].data:A([...a.map((({data:e})=>e))]),...x("errors",g(a)),hasNext:n}}))}function j(e,r){if(e.length>0)throw new Error(t,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(s)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:s=fetch,retries:l=0,logger:E}){b({client:r,retries:l});const S={headers:e,url:t,retries:l},R=function(e){return r=>{e&&e(r)}}(E),v=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:l,headers:f,url:y,retries:h,keepalive:p,signal:m}=a,w=JSON.stringify({query:o,variables:l});b({client:r,retries:h});const g=Object.entries({...n,...f}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});g[i]||g[c]||(g[i]=u,g[c]=d);return e([y??t,{method:"POST",headers:g,body:w,signal:m,keepalive:p}],1,h??s)}}(T({customFetchApi:s,clientLogger:R,defaultRetryWaitTime:1e3}),S),I=function(e){return async(...r)=>{if(f.test(r[0]))throw new Error(p("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:s,statusText:a}=t,i=t.headers.get("content-type")||"";return t.ok?i.includes(o)?k(t):{errors:{networkStatusCode:s,message:p(`${n} ${i}`),response:t}}:{errors:{networkStatusCode:s,message:p(a),response:t}}}catch(e){return{errors:{message:m(e)}}}}}(v),L=function(e){return async(...r)=>{if(!f.test(r[0]))throw new Error(p("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:s}=t;if(!t.ok)throw new Error(s,{cause:t});const i=t.headers.get("content-type")||"";switch(!0){case i.includes(o):return function(e){return{async*[Symbol.asyncIterator](){const r=await k(e);yield{...r,hasNext:!1}}}}(t);case i.includes(a):return function(e,r){const t=(r??"").match(y),n=`--${t?t[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});const s=async function*(e){const r=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(const t of e.body)yield r.decode(t);else{const t=e.body.getReader();let n;try{for(;!(n=await t.read()).done;)yield r.decode(n.value)}finally{t.cancel()}}}(e);let o,a={};return{async*[Symbol.asyncIterator](){try{let e=!0;for await(const r of function(e,r){return{async*[Symbol.asyncIterator](){try{let t="";for await(const n of e)if(t+=n,t.indexOf(r)>-1){const e=t.lastIndexOf(r),n=t.slice(0,e).split(r).filter((e=>e.trim().length>0)).map((e=>e.slice(e.indexOf(h)+4).trim()));n.length>0&&(yield n),t=t.slice(e+r.length),"--"===t.trim()&&(t="")}}catch(e){throw new Error(`Error occured while processing stream payload - ${m(e)}`)}}}}(s,n)){const t=$(r);o=t.find((e=>e.extensions))?.extensions??o;const n=g(t);a=A([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,j(n,a),yield{...x("data",a),...x("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=w(r);yield{...x("data",a),...x("extensions",o),errors:{message:p(m(r)),networkStatusCode:e.status,...x("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,i);default:throw new Error(`${n} ${i}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=w(e);yield{errors:{message:p(m(e)),...x("networkStatusCode",r?.status),...x("response",r)},hasNext:!1}}}}}}(v);return{config:S,fetch:v,request:I,requestStream:L}}}));
/*! shopify/graphql-client@1.3.1 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ShopifyGraphQLClient={})}(this,(function(e){"use strict";const r="GraphQL Client",t="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",n="Response returned unexpected Content-Type:",s="An unknown error has occurred. The API did not return a data object or any errors in its response.",o="application/json",a="multipart/mixed",i="X-SDK-Variant",c="X-SDK-Version",u="shopify-graphql-client",d="1.3.1",l=[429,503],f=/@(defer)\b/i,y=/boundary="?([^=";]+)"?/i,h="\r\n\r\n";function p(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function m(e){return e instanceof Error?e.message:JSON.stringify(e)}function w(e){return e instanceof Error&&e.cause?e.cause:void 0}function g(e){return e.flatMap((({errors:e})=>e??[]))}function b({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<0||r>3))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than 0 or greater than 3`)}function x(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function E(e,r){if(0===e.length)return r;const t=e.pop(),n={[t]:r};return 0===e.length?n:E(e,n)}function S(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=S(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function A([e,...r]){return r.reduce(S,{...e})}function T({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=1e3,retriableCodes:o=l}){const a=async(r,i,c)=>{const u=i+1,d=c+1;let l;try{if(l=await t(...r),e({type:"HTTP-Response",content:{requestParams:r,response:l}}),!l.ok&&o.includes(l.status)&&u<=d)throw new Error;return l}catch(t){if(u<=d){const t=l?.headers.get("Retry-After");return await async function(e){return new Promise((r=>setTimeout(r,e)))}(t?parseInt(t,10):s),e({type:"HTTP-Retry",content:{requestParams:r,lastResponse:l,retryAttempt:i,maxRetries:c}}),a(r,u,c)}throw new Error(p(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${m(t)}`,n))}};return a}async function k(e){const{errors:r,data:n,extensions:o}=await e.json();return{...x("data",n),...x("extensions",o),headers:e.headers,...r||!n?{errors:{networkStatusCode:e.status,message:p(r?t:s),...x("graphQLErrors",r),response:e}}:{}}}function $(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${m(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...x("errors",o),...x("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?E(r,e):{},...x("errors",t)})));return{data:1===a.length?a[0].data:A([...a.map((({data:e})=>e))]),...x("errors",g(a)),hasNext:n}}))}function j(e,r){if(e.length>0)throw new Error(t,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(s)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:s=fetch,retries:l=0,logger:E}){b({client:r,retries:l});const S={headers:e,url:t,retries:l},R=function(e){return r=>{e&&e(r)}}(E),v=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:l,headers:f,url:y,retries:h,keepalive:p,signal:m}=a,w=JSON.stringify({query:o,variables:l});b({client:r,retries:h});const g=Object.entries({...n,...f}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});g[i]||g[c]||(g[i]=u,g[c]=d);return e([y??t,{method:"POST",headers:g,body:w,signal:m,keepalive:p}],1,h??s)}}(T({customFetchApi:s,clientLogger:R,defaultRetryWaitTime:1e3}),S),I=function(e){return async(...r)=>{if(f.test(r[0]))throw new Error(p("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:s,statusText:a}=t,i=t.headers.get("content-type")||"";return t.ok?i.includes(o)?k(t):{errors:{networkStatusCode:s,message:p(`${n} ${i}`),response:t}}:{errors:{networkStatusCode:s,message:p(a),response:t}}}catch(e){return{errors:{message:m(e)}}}}}(v),L=function(e){return async(...r)=>{if(!f.test(r[0]))throw new Error(p("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:s}=t;if(!t.ok)throw new Error(s,{cause:t});const i=t.headers.get("content-type")||"";switch(!0){case i.includes(o):return function(e){return{async*[Symbol.asyncIterator](){const r=await k(e);yield{...r,hasNext:!1}}}}(t);case i.includes(a):return function(e,r){const t=(r??"").match(y),n=`--${t?t[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});const s=async function*(e){const r=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(const t of e.body)yield r.decode(t);else{const t=e.body.getReader();let n;try{for(;!(n=await t.read()).done;)yield r.decode(n.value)}finally{t.cancel()}}}(e);let o,a={};return{async*[Symbol.asyncIterator](){try{let e=!0;for await(const r of function(e,r){return{async*[Symbol.asyncIterator](){try{let t="";for await(const n of e)if(t+=n,t.indexOf(r)>-1){const e=t.lastIndexOf(r),n=t.slice(0,e).split(r).filter((e=>e.trim().length>0)).map((e=>e.slice(e.indexOf(h)+4).trim()));n.length>0&&(yield n),t=t.slice(e+r.length),"--"===t.trim()&&(t="")}}catch(e){throw new Error(`Error occured while processing stream payload - ${m(e)}`)}}}}(s,n)){const t=$(r);o=t.find((e=>e.extensions))?.extensions??o;const n=g(t);a=A([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,j(n,a),yield{...x("data",a),...x("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=w(r);yield{...x("data",a),...x("extensions",o),errors:{message:p(m(r)),networkStatusCode:e.status,...x("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,i);default:throw new Error(`${n} ${i}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=w(e);yield{errors:{message:p(m(e)),...x("networkStatusCode",r?.status),...x("response",r)},hasNext:!1}}}}}}(v);return{config:S,fetch:v,request:I,requestStream:L}}}));
//# sourceMappingURL=graphql-client.min.js.map
{
"name": "@shopify/graphql-client",
"version": "1.3.0",
"version": "1.3.1",
"description": "Shopify GraphQL Client - A lightweight generic GraphQL JS client to interact with Shopify GraphQL APIs",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet