Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gem-sdk/adapter-shopify

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gem-sdk/adapter-shopify - npm Package Compare versions

Comparing version 1.0.0 to 1.5.27

dist/cjs/graphql/fragments/language.generated.js

21

dist/cjs/api/operations/add-to-cart.js

@@ -7,4 +7,4 @@ 'use strict';

const addToCartOperation = (config) => {
const addToCart = async (input) => {
const addToCartOperation = (config)=>{
const addToCart = async (input)=>{
if (!config.storefrontUrl) {

@@ -15,12 +15,15 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
lines: input.lines.map((v) => ({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes,
})),
lines: input.lines.map((v)=>({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes
}))
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartLinesAdd_generated.CartLinesAddDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cartLinesAdd_generated.CartLinesAddDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesAdd?.userErrors.length || !res.data?.cartLinesAdd?.cart) {

@@ -27,0 +30,0 @@ throw res.data?.cartLinesAdd?.userErrors;

@@ -7,4 +7,4 @@ 'use strict';

const cartDiscountCodesUpdateOperation = (config) => {
const cartNoteUpdate = async (input) => {
const cartDiscountCodesUpdateOperation = (config)=>{
const cartNoteUpdate = async (input)=>{
if (!config.storefrontUrl) {

@@ -15,10 +15,12 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
discountCodes: input.discountCodes,
discountCodes: input.discountCodes
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartDiscountCodesUpdate_generated.CartDiscountCodesUpdateDocument, variables }),
}).then((res) => res.json());
if (res.data?.cartDiscountCodesUpdate?.userErrors.length ||
!res.data?.cartDiscountCodesUpdate?.cart) {
body: JSON.stringify({
query: cartDiscountCodesUpdate_generated.CartDiscountCodesUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartDiscountCodesUpdate?.userErrors.length || !res.data?.cartDiscountCodesUpdate?.cart) {
throw res.data?.cartDiscountCodesUpdate?.userErrors;

@@ -25,0 +27,0 @@ }

@@ -7,4 +7,4 @@ 'use strict';

const cartNoteUpdateOperation = (config) => {
const cartNoteUpdate = async (input) => {
const cartNoteUpdateOperation = (config)=>{
const cartNoteUpdate = async (input)=>{
if (!config.storefrontUrl) {

@@ -15,8 +15,11 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
note: input.note,
note: input.note
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartNoteUpdate_generated.CartNoteUpdateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cartNoteUpdate_generated.CartNoteUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartNoteUpdate?.userErrors.length || !res.data?.cartNoteUpdate?.cart) {

@@ -23,0 +26,0 @@ throw res.data?.cartNoteUpdate?.userErrors;

@@ -7,4 +7,4 @@ 'use strict';

const createCartOperation = (config) => {
const createCart = async (args) => {
const createCartOperation = (config)=>{
const createCart = async (args)=>{
if (!config.storefrontUrl) {

@@ -15,13 +15,16 @@ throw new Error('Shop is not connected');

input: {
lines: args.items.map((v) => ({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes,
})),
},
lines: args.items.map((v)=>({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes
}))
}
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartCreate_generated.CartCreateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cartCreate_generated.CartCreateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartCreate?.userErrors.length || !res.data?.cartCreate?.cart) {

@@ -28,0 +31,0 @@ throw res.data?.cartCreate?.userErrors;

@@ -7,4 +7,4 @@ 'use strict';

const getCartOperation = (config) => {
const getCart = async (input) => {
const getCartOperation = (config)=>{
const getCart = async (input)=>{
if (!config.storefrontUrl) {

@@ -14,8 +14,11 @@ throw new Error('Shop is not connected');

const variables = {
id: input.cartId,
id: input.cartId
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cart_generated.CartDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cart_generated.CartDocument,
variables
})
}).then((res)=>res.json());
if (!res.data?.cart) {

@@ -22,0 +25,0 @@ return undefined;

@@ -7,4 +7,4 @@ 'use strict';

const removeCartItemOperation = (config) => {
const removeCartItem = async (input) => {
const removeCartItemOperation = (config)=>{
const removeCartItem = async (input)=>{
if (!config.storefrontUrl) {

@@ -15,8 +15,13 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
lineIds: [input.lineId],
lineIds: [
input.lineId
]
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartLinesRemove_generated.CartLinesRemoveDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cartLinesRemove_generated.CartLinesRemoveDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesRemove?.userErrors.length || !res.data?.cartLinesRemove?.cart) {

@@ -23,0 +28,0 @@ throw res.data?.cartLinesRemove?.userErrors;

@@ -7,4 +7,4 @@ 'use strict';

const updateCartLineOperation = (config) => {
const updateCartLine = async (input) => {
const updateCartLineOperation = (config)=>{
const updateCartLine = async (input)=>{
if (!config.storefrontUrl) {

@@ -19,10 +19,13 @@ throw new Error('Shop is not connected');

merchandiseId: input.line.variantId,
quantity: input.line.quantity,
},
],
quantity: input.line.quantity
}
]
};
const res = await fetch(config.storefrontUrl, {
...common.composeRequest(config),
body: JSON.stringify({ query: cartLinesUpdate_generated.CartLinesUpdateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: cartLinesUpdate_generated.CartLinesUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesUpdate?.userErrors.length || !res.data?.cartLinesUpdate?.cart) {

@@ -29,0 +32,0 @@ throw res.data?.cartLinesUpdate?.userErrors;

'use strict';
const CartProductVariantSelect = `
/* eslint-disable */ const CartProductVariantSelect = `
fragment CartProductVariantSelect on ProductVariant {

@@ -5,0 +5,0 @@ id

'use strict';
const CartUserErrorSelect = `
/* eslint-disable */ const CartUserErrorSelect = `
fragment CartUserErrorSelect on CartUserError {

@@ -5,0 +5,0 @@ code

'use strict';
const CartSelect = `
/* eslint-disable */ const CartSelect = `
fragment CartSelect on Cart {

@@ -5,0 +5,0 @@ attributes {

'use strict';
const CountrySelect = `
/* eslint-disable */ const CountrySelect = `
fragment CountrySelect on Country {

@@ -5,0 +5,0 @@ isoCode

'use strict';
const CurrencySelect = `
/* eslint-disable */ const CurrencySelect = `
fragment CurrencySelect on Currency {

@@ -5,0 +5,0 @@ isoCode

'use strict';
const ImageSelect = `
/* eslint-disable */ const ImageSelect = `
fragment ImageSelect on Image {

@@ -5,0 +5,0 @@ id

'use strict';
const MoneyV2Select = `
/* eslint-disable */ const MoneyV2Select = `
fragment MoneyV2Select on MoneyV2 {

@@ -5,0 +5,0 @@ amount

'use strict';
const ProductSelect = `
/* eslint-disable */ const ProductSelect = `
fragment ProductSelect on Product {

@@ -5,0 +5,0 @@ availableForSale

@@ -5,2 +5,3 @@ 'use strict';

var currency_generated = require('../fragments/currency.generated.js');
var language_generated = require('../fragments/language.generated.js');

@@ -13,2 +14,5 @@ const ShopMetaDocument = `

}
language {
...LanguageSelect
}
}

@@ -21,4 +25,5 @@ shop {

${country_generated.CountrySelect}
${currency_generated.CurrencySelect}`;
${currency_generated.CurrencySelect}
${language_generated.LanguageSelect}`;
exports.ShopMetaDocument = ShopMetaDocument;
'use strict';
const composeRequest = (config) => {
const composeRequest = (config)=>{
return {

@@ -8,6 +8,6 @@ method: 'POST',

'Content-Type': 'application/json',
...(config.storefrontToken
? { 'X-Shopify-Storefront-Access-Token': config.storefrontToken }
: {}),
},
...config.storefrontToken ? {
'X-Shopify-Storefront-Access-Token': config.storefrontToken
} : {}
}
};

@@ -14,0 +14,0 @@ };

'use strict';
const normalizeCartProductVariant = (variant) => {
const { compareAtPriceV2, priceV2, weight, weightUnit, id, sku, image } = variant;
const normalizeCartProductVariant = (variant)=>{
const { compareAtPriceV2 , priceV2 , weight , weightUnit , id , sku , image } = variant;
return {

@@ -15,9 +15,9 @@ id,

value: weight ?? 0,
unit: weightUnit,
unit: weightUnit
},
image,
image
};
};
const normalizeLineItem = (lineItem) => {
const { quantity, id, merchandise } = lineItem;
const normalizeLineItem = (lineItem)=>{
const { quantity , id , merchandise } = lineItem;
const variant = normalizeCartProductVariant(merchandise);

@@ -34,7 +34,7 @@ return {

path: merchandise.product.handle,
discounts: [],
discounts: []
};
};
const normalizeCart = (cart) => {
const { cost } = cart;
const normalizeCart = (cart)=>{
const { cost } = cart;
return {

@@ -47,3 +47,3 @@ createdAt: cart.createdAt,

currency: {
code: cost.totalAmount.currencyCode,
code: cost.totalAmount.currencyCode
},

@@ -54,6 +54,6 @@ taxesIncluded: true,

note: cart.note,
discounts: cart.discountCodes.map((v) => ({
code: v.code,
applicable: v.applicable,
})),
discounts: cart.discountCodes.map((v)=>({
code: v.code,
applicable: v.applicable
}))
};

@@ -60,0 +60,0 @@ };

@@ -5,4 +5,4 @@ import { CartLinesAddDocument } from '../../graphql/mutations/cart-lines-add.generated.js';

const addToCartOperation = (config) => {
const addToCart = async (input) => {
const addToCartOperation = (config)=>{
const addToCart = async (input)=>{
if (!config.storefrontUrl) {

@@ -13,12 +13,15 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
lines: input.lines.map((v) => ({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes,
})),
lines: input.lines.map((v)=>({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes
}))
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartLinesAddDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartLinesAddDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesAdd?.userErrors.length || !res.data?.cartLinesAdd?.cart) {

@@ -25,0 +28,0 @@ throw res.data?.cartLinesAdd?.userErrors;

@@ -5,4 +5,4 @@ import { CartDiscountCodesUpdateDocument } from '../../graphql/mutations/cart-discount-codes-update.generated.js';

const cartDiscountCodesUpdateOperation = (config) => {
const cartNoteUpdate = async (input) => {
const cartDiscountCodesUpdateOperation = (config)=>{
const cartNoteUpdate = async (input)=>{
if (!config.storefrontUrl) {

@@ -13,10 +13,12 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
discountCodes: input.discountCodes,
discountCodes: input.discountCodes
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartDiscountCodesUpdateDocument, variables }),
}).then((res) => res.json());
if (res.data?.cartDiscountCodesUpdate?.userErrors.length ||
!res.data?.cartDiscountCodesUpdate?.cart) {
body: JSON.stringify({
query: CartDiscountCodesUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartDiscountCodesUpdate?.userErrors.length || !res.data?.cartDiscountCodesUpdate?.cart) {
throw res.data?.cartDiscountCodesUpdate?.userErrors;

@@ -23,0 +25,0 @@ }

@@ -5,4 +5,4 @@ import { CartNoteUpdateDocument } from '../../graphql/mutations/cart-note-update.generated.js';

const cartNoteUpdateOperation = (config) => {
const cartNoteUpdate = async (input) => {
const cartNoteUpdateOperation = (config)=>{
const cartNoteUpdate = async (input)=>{
if (!config.storefrontUrl) {

@@ -13,8 +13,11 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
note: input.note,
note: input.note
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartNoteUpdateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartNoteUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartNoteUpdate?.userErrors.length || !res.data?.cartNoteUpdate?.cart) {

@@ -21,0 +24,0 @@ throw res.data?.cartNoteUpdate?.userErrors;

@@ -5,4 +5,4 @@ import { CartCreateDocument } from '../../graphql/mutations/cart-create.generated.js';

const createCartOperation = (config) => {
const createCart = async (args) => {
const createCartOperation = (config)=>{
const createCart = async (args)=>{
if (!config.storefrontUrl) {

@@ -13,13 +13,16 @@ throw new Error('Shop is not connected');

input: {
lines: args.items.map((v) => ({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes,
})),
},
lines: args.items.map((v)=>({
merchandiseId: v.variantId,
quantity: v.quantity,
attributes: v.attributes
}))
}
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartCreateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartCreateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartCreate?.userErrors.length || !res.data?.cartCreate?.cart) {

@@ -26,0 +29,0 @@ throw res.data?.cartCreate?.userErrors;

@@ -5,4 +5,4 @@ import { CartDocument } from '../../graphql/queries/cart.generated.js';

const getCartOperation = (config) => {
const getCart = async (input) => {
const getCartOperation = (config)=>{
const getCart = async (input)=>{
if (!config.storefrontUrl) {

@@ -12,8 +12,11 @@ throw new Error('Shop is not connected');

const variables = {
id: input.cartId,
id: input.cartId
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartDocument,
variables
})
}).then((res)=>res.json());
if (!res.data?.cart) {

@@ -20,0 +23,0 @@ return undefined;

@@ -5,4 +5,4 @@ import { CartLinesRemoveDocument } from '../../graphql/mutations/cart-lines-remove.generated.js';

const removeCartItemOperation = (config) => {
const removeCartItem = async (input) => {
const removeCartItemOperation = (config)=>{
const removeCartItem = async (input)=>{
if (!config.storefrontUrl) {

@@ -13,8 +13,13 @@ throw new Error('Shop is not connected');

cartId: input.cartId,
lineIds: [input.lineId],
lineIds: [
input.lineId
]
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartLinesRemoveDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartLinesRemoveDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesRemove?.userErrors.length || !res.data?.cartLinesRemove?.cart) {

@@ -21,0 +26,0 @@ throw res.data?.cartLinesRemove?.userErrors;

@@ -5,4 +5,4 @@ import { CartLinesUpdateDocument } from '../../graphql/mutations/cart-lines-update.generated.js';

const updateCartLineOperation = (config) => {
const updateCartLine = async (input) => {
const updateCartLineOperation = (config)=>{
const updateCartLine = async (input)=>{
if (!config.storefrontUrl) {

@@ -17,10 +17,13 @@ throw new Error('Shop is not connected');

merchandiseId: input.line.variantId,
quantity: input.line.quantity,
},
],
quantity: input.line.quantity
}
]
};
const res = await fetch(config.storefrontUrl, {
...composeRequest(config),
body: JSON.stringify({ query: CartLinesUpdateDocument, variables }),
}).then((res) => res.json());
body: JSON.stringify({
query: CartLinesUpdateDocument,
variables
})
}).then((res)=>res.json());
if (res.data?.cartLinesUpdate?.userErrors.length || !res.data?.cartLinesUpdate?.cart) {

@@ -27,0 +30,0 @@ throw res.data?.cartLinesUpdate?.userErrors;

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

const CartProductVariantSelect = `
/* eslint-disable */ const CartProductVariantSelect = `
fragment CartProductVariantSelect on ProductVariant {

@@ -3,0 +3,0 @@ id

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

const CartUserErrorSelect = `
/* eslint-disable */ const CartUserErrorSelect = `
fragment CartUserErrorSelect on CartUserError {

@@ -3,0 +3,0 @@ code

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

const CartSelect = `
/* eslint-disable */ const CartSelect = `
fragment CartSelect on Cart {

@@ -3,0 +3,0 @@ attributes {

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

const CountrySelect = `
/* eslint-disable */ const CountrySelect = `
fragment CountrySelect on Country {

@@ -3,0 +3,0 @@ isoCode

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

const CurrencySelect = `
/* eslint-disable */ const CurrencySelect = `
fragment CurrencySelect on Currency {

@@ -3,0 +3,0 @@ isoCode

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

const ImageSelect = `
/* eslint-disable */ const ImageSelect = `
fragment ImageSelect on Image {

@@ -3,0 +3,0 @@ id

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

const MoneyV2Select = `
/* eslint-disable */ const MoneyV2Select = `
fragment MoneyV2Select on MoneyV2 {

@@ -3,0 +3,0 @@ amount

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

const ProductSelect = `
/* eslint-disable */ const ProductSelect = `
fragment ProductSelect on Product {

@@ -3,0 +3,0 @@ availableForSale

import { CountrySelect } from '../fragments/country.generated.js';
import { CurrencySelect } from '../fragments/currency.generated.js';
import { LanguageSelect } from '../fragments/language.generated.js';

@@ -10,2 +11,5 @@ const ShopMetaDocument = `

}
language {
...LanguageSelect
}
}

@@ -18,4 +22,5 @@ shop {

${CountrySelect}
${CurrencySelect}`;
${CurrencySelect}
${LanguageSelect}`;
export { ShopMetaDocument };

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

const composeRequest = (config) => {
const composeRequest = (config)=>{
return {

@@ -6,6 +6,6 @@ method: 'POST',

'Content-Type': 'application/json',
...(config.storefrontToken
? { 'X-Shopify-Storefront-Access-Token': config.storefrontToken }
: {}),
},
...config.storefrontToken ? {
'X-Shopify-Storefront-Access-Token': config.storefrontToken
} : {}
}
};

@@ -12,0 +12,0 @@ };

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

const normalizeCartProductVariant = (variant) => {
const { compareAtPriceV2, priceV2, weight, weightUnit, id, sku, image } = variant;
const normalizeCartProductVariant = (variant)=>{
const { compareAtPriceV2 , priceV2 , weight , weightUnit , id , sku , image } = variant;
return {

@@ -13,9 +13,9 @@ id,

value: weight ?? 0,
unit: weightUnit,
unit: weightUnit
},
image,
image
};
};
const normalizeLineItem = (lineItem) => {
const { quantity, id, merchandise } = lineItem;
const normalizeLineItem = (lineItem)=>{
const { quantity , id , merchandise } = lineItem;
const variant = normalizeCartProductVariant(merchandise);

@@ -32,7 +32,7 @@ return {

path: merchandise.product.handle,
discounts: [],
discounts: []
};
};
const normalizeCart = (cart) => {
const { cost } = cart;
const normalizeCart = (cart)=>{
const { cost } = cart;
return {

@@ -45,3 +45,3 @@ createdAt: cart.createdAt,

currency: {
code: cost.totalAmount.currencyCode,
code: cost.totalAmount.currencyCode
},

@@ -52,6 +52,6 @@ taxesIncluded: true,

note: cart.note,
discounts: cart.discountCodes.map((v) => ({
code: v.code,
applicable: v.applicable,
})),
discounts: cart.discountCodes.map((v)=>({
code: v.code,
applicable: v.applicable
}))
};

@@ -58,0 +58,0 @@ };

{
"name": "@gem-sdk/adapter-shopify",
"version": "1.0.0",
"version": "1.5.27",
"license": "MIT",

@@ -5,0 +5,0 @@ "sideEffects": false,

Sorry, the diff of this file is too big to display

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