New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/graphql-client

Package Overview
Dependencies
Maintainers
25
Versions
24
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 0.10.1 to 0.10.2

9

dist/graphql-client/constants.js

@@ -13,2 +13,7 @@ 'use strict';

};
const SDK_VARIANT_HEADER = "X-SDK-Variant";
const SDK_VERSION_HEADER = "X-SDK-Version";
const DEFAULT_SDK_VARIANT = "shopify-graphql-client";
// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = "0.10.2";
const RETRY_WAIT_TIME = 1000;

@@ -24,2 +29,4 @@ const RETRIABLE_STATUS_CODES = [429, 503];

exports.CONTENT_TYPES = CONTENT_TYPES;
exports.DEFAULT_CLIENT_VERSION = DEFAULT_CLIENT_VERSION;
exports.DEFAULT_SDK_VARIANT = DEFAULT_SDK_VARIANT;
exports.DEFER_OPERATION_REGEX = DEFER_OPERATION_REGEX;

@@ -34,3 +41,5 @@ exports.GQL_API_ERROR = GQL_API_ERROR;

exports.RETRY_WAIT_TIME = RETRY_WAIT_TIME;
exports.SDK_VARIANT_HEADER = SDK_VARIANT_HEADER;
exports.SDK_VERSION_HEADER = SDK_VERSION_HEADER;
exports.UNEXPECTED_CONTENT_TYPE_ERROR = UNEXPECTED_CONTENT_TYPE_ERROR;
//# sourceMappingURL=constants.js.map

13

dist/graphql-client/graphql-client.js

@@ -69,2 +69,6 @@ 'use strict';

}, {});
if (!flatHeaders[constants.SDK_VARIANT_HEADER] && !flatHeaders[constants.SDK_VERSION_HEADER]) {
flatHeaders[constants.SDK_VARIANT_HEADER] = constants.DEFAULT_SDK_VARIANT;
flatHeaders[constants.SDK_VERSION_HEADER] = constants.DEFAULT_CLIENT_VERSION;
}
const fetchParams = [

@@ -121,11 +125,6 @@ overrideUrl ?? url,

const decoder = new TextDecoder();
// Support node format
// Response body is an async iterator
if (response.body[Symbol.asyncIterator]) {
for await (const chunk of response.body) {
if (Buffer.isBuffer(chunk)) {
yield chunk.toString();
}
else {
yield decoder.decode(chunk);
}
yield decoder.decode(chunk);
}

@@ -132,0 +131,0 @@ }

@@ -11,2 +11,6 @@ export declare const CLIENT = "GraphQL Client";

};
export declare const SDK_VARIANT_HEADER = "X-SDK-Variant";
export declare const SDK_VERSION_HEADER = "X-SDK-Version";
export declare const DEFAULT_SDK_VARIANT = "shopify-graphql-client";
export declare const DEFAULT_CLIENT_VERSION = "ROLLUP_REPLACE_CLIENT_VERSION";
export declare const RETRY_WAIT_TIME = 1000;

@@ -13,0 +17,0 @@ export declare const RETRIABLE_STATUS_CODES: number[];

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

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

@@ -18,2 +18,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

};
const SDK_VARIANT_HEADER = "X-SDK-Variant";
const SDK_VERSION_HEADER = "X-SDK-Version";
const DEFAULT_SDK_VARIANT = "shopify-graphql-client";
// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = "0.10.2";
const RETRY_WAIT_TIME = 1000;

@@ -193,2 +198,6 @@ const RETRIABLE_STATUS_CODES = [429, 503];

}, {});
if (!flatHeaders[SDK_VARIANT_HEADER] && !flatHeaders[SDK_VERSION_HEADER]) {
flatHeaders[SDK_VARIANT_HEADER] = DEFAULT_SDK_VARIANT;
flatHeaders[SDK_VERSION_HEADER] = DEFAULT_CLIENT_VERSION;
}
const fetchParams = [

@@ -245,11 +254,6 @@ overrideUrl ?? url,

const decoder = new TextDecoder();
// Support node format
// Response body is an async iterator
if (response.body[Symbol.asyncIterator]) {
for await (const chunk of response.body) {
if (Buffer.isBuffer(chunk)) {
yield chunk.toString();
}
else {
yield decoder.decode(chunk);
}
yield decoder.decode(chunk);
}

@@ -256,0 +260,0 @@ }

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

/*! shopify/graphql-client@0.10.1 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-api-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=0,n=3,s="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",o="Response returned unexpected Content-Type:",a="An unknown error has occurred. The API did not return a data object or any errors in its response.",i={json:"application/json",multipart:"multipart/mixed"},c=1e3,u=[429,503],d=/@(defer)\b/i,l=/boundary="?([^=";]+)"?/i,f="\r\n\r\n";function y(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function h(e){return e instanceof Error?e.message:JSON.stringify(e)}function p(e){return e instanceof Error&&e.cause?e.cause:void 0}function m(e){return e.flatMap((({errors:e})=>e??[]))}function w({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<t||r>n))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than ${t} or greater than ${n}`)}function g(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function b(e,r){if(0===e.length)return r;const t={[e.pop()]:r};return 0===e.length?t:b(e,t)}function x(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=x(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function E([e,...r]){return r.reduce(x,{...e})}function S({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=c,retriableCodes:o=u}){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(y(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${h(t)}`,n))}};return a}async function A(e){const{errors:r,data:t,extensions:n}=await e.json();return{...g("data",t),...g("extensions",n),...r||!t?{errors:{networkStatusCode:e.status,message:y(r?s:a),...g("graphQLErrors",r),response:e}}:{}}}function T(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${h(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...g("errors",o),...g("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?b(r,e):{},...g("errors",t)})));return{data:1===a.length?a[0].data:E([...a.map((({data:e})=>e))]),...g("errors",m(a)),hasNext:n}}))}function $(e,r){if(e.length>0)throw new Error(s,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(a)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:n=x,retries:s=0,logger:a}){w({client:r,retries:s});const u={headers:e,url:t,retries:s},b=function(e){return r=>{e&&e(r)}}(a),x=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:i,headers:c,url:u,retries:d}=a,l=JSON.stringify({query:o,variables:i});w({client:r,retries:d});const f=Object.entries({...n,...c}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});return e([u??t,{method:"POST",headers:f,body:l}],1,d??s)}}(S({customFetchApi:n,clientLogger:b,defaultRetryWaitTime:c}),u),j=function(e){return async(...r)=>{if(d.test(r[0]))throw new Error(y("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:n,statusText:s}=t,a=t.headers.get("content-type")||"";return t.ok?a.includes(i.json)?A(t):{errors:{networkStatusCode:n,message:y(`${o} ${a}`),response:t}}:{errors:{networkStatusCode:n,message:y(s),response:t}}}catch(e){return{errors:{message:h(e)}}}}}(x),k=function(e){return async(...r)=>{if(!d.test(r[0]))throw new Error(y("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:n}=t;if(!t.ok)throw new Error(n,{cause:t});const s=t.headers.get("content-type")||"";switch(!0){case s.includes(i.json):return function(e){return{async*[Symbol.asyncIterator](){const r=await A(e);yield{...r,hasNext:!1}}}}(t);case s.includes(i.multipart):return function(e,r){const t=(r??"").match(l),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)Buffer.isBuffer(t)?yield t.toString():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(f)+f.length).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 - ${h(e)}`)}}}}(s,n)){const t=T(r);o=t.find((e=>e.extensions))?.extensions??o;const n=m(t);a=E([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,$(n,a),yield{...g("data",a),...g("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=p(r);yield{...g("data",a),...g("extensions",o),errors:{message:y(h(r)),networkStatusCode:e.status,...g("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,s);default:throw new Error(`${o} ${s}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=p(e);yield{errors:{message:y(h(e)),...g("networkStatusCode",r?.status),...g("response",r)},hasNext:!1}}}}}}(x);return{config:u,fetch:x,request:j,requestStream:k}}}));
/*! shopify/graphql-client@0.10.2 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-api-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=0,n=3,s="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",o="Response returned unexpected Content-Type:",a="An unknown error has occurred. The API did not return a data object or any errors in its response.",i={json:"application/json",multipart:"multipart/mixed"},c="X-SDK-Variant",u="X-SDK-Version",d="shopify-graphql-client",l="0.10.2",f=1e3,y=[429,503],h=/@(defer)\b/i,p=/boundary="?([^=";]+)"?/i,m="\r\n\r\n";function w(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function g(e){return e instanceof Error?e.message:JSON.stringify(e)}function b(e){return e instanceof Error&&e.cause?e.cause:void 0}function x(e){return e.flatMap((({errors:e})=>e??[]))}function E({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<t||r>n))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than ${t} or greater than ${n}`)}function S(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function A(e,r){if(0===e.length)return r;const t={[e.pop()]:r};return 0===e.length?t:A(e,t)}function T(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=T(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function $([e,...r]){return r.reduce(T,{...e})}function j({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=f,retriableCodes:o=y}){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(w(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${g(t)}`,n))}};return a}async function k(e){const{errors:r,data:t,extensions:n}=await e.json();return{...S("data",t),...S("extensions",n),...r||!t?{errors:{networkStatusCode:e.status,message:w(r?s:a),...S("graphQLErrors",r),response:e}}:{}}}function R(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${g(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...S("errors",o),...S("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?A(r,e):{},...S("errors",t)})));return{data:1===a.length?a[0].data:$([...a.map((({data:e})=>e))]),...S("errors",x(a)),hasNext:n}}))}function I(e,r){if(e.length>0)throw new Error(s,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(a)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:n=T,retries:s=0,logger:a}){E({client:r,retries:s});const y={headers:e,url:t,retries:s},A=function(e){return r=>{e&&e(r)}}(a),T=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:i,headers:f,url:y,retries:h}=a,p=JSON.stringify({query:o,variables:i});E({client:r,retries:h});const m=Object.entries({...n,...f}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});m[c]||m[u]||(m[c]=d,m[u]=l);return e([y??t,{method:"POST",headers:m,body:p}],1,h??s)}}(j({customFetchApi:n,clientLogger:A,defaultRetryWaitTime:f}),y),L=function(e){return async(...r)=>{if(h.test(r[0]))throw new Error(w("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:n,statusText:s}=t,a=t.headers.get("content-type")||"";return t.ok?a.includes(i.json)?k(t):{errors:{networkStatusCode:n,message:w(`${o} ${a}`),response:t}}:{errors:{networkStatusCode:n,message:w(s),response:t}}}catch(e){return{errors:{message:g(e)}}}}}(T),N=function(e){return async(...r)=>{if(!h.test(r[0]))throw new Error(w("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:n}=t;if(!t.ok)throw new Error(n,{cause:t});const s=t.headers.get("content-type")||"";switch(!0){case s.includes(i.json):return function(e){return{async*[Symbol.asyncIterator](){const r=await k(e);yield{...r,hasNext:!1}}}}(t);case s.includes(i.multipart):return function(e,r){const t=(r??"").match(p),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(m)+m.length).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 - ${g(e)}`)}}}}(s,n)){const t=R(r);o=t.find((e=>e.extensions))?.extensions??o;const n=x(t);a=$([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,I(n,a),yield{...S("data",a),...S("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=b(r);yield{...S("data",a),...S("extensions",o),errors:{message:w(g(r)),networkStatusCode:e.status,...S("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,s);default:throw new Error(`${o} ${s}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=b(e);yield{errors:{message:w(g(e)),...S("networkStatusCode",r?.status),...S("response",r)},hasNext:!1}}}}}}(T);return{config:y,fetch:T,request:L,requestStream:N}}}));
//# sourceMappingURL=graphql-client.min.js.map
{
"name": "@shopify/graphql-client",
"version": "0.10.1",
"version": "0.10.2",
"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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc