@gem-sdk/adapter-shopify 1.58.0 → 2.0.0-dev.1082
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/cjs/api/operations/add-to-cart.js +1 -35
- package/dist/cjs/api/operations/cart-discount-codes-update.js +1 -31
- package/dist/cjs/api/operations/cart-note-update.js +1 -31
- package/dist/cjs/api/operations/create-cart.js +1 -36
- package/dist/cjs/api/operations/get-cart.js +1 -30
- package/dist/cjs/api/operations/remove-cart-item.js +1 -33
- package/dist/cjs/api/operations/update-cart-line.js +1 -37
- package/dist/cjs/graphql/fragments/cart-line.generated.js +6 -12
- package/dist/cjs/graphql/fragments/cart-user-error.generated.js +2 -6
- package/dist/cjs/graphql/fragments/cart.generated.js +2 -6
- package/dist/cjs/graphql/fragments/country.generated.js +2 -6
- package/dist/cjs/graphql/fragments/currency.generated.js +2 -6
- package/dist/cjs/graphql/fragments/image.generated.js +2 -6
- package/dist/cjs/graphql/fragments/language.generated.js +2 -6
- package/dist/cjs/graphql/fragments/money-v2.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product.generated.js +2 -6
- package/dist/cjs/graphql/mutations/cart-create.generated.js +2 -12
- package/dist/cjs/graphql/mutations/cart-discount-codes-update.generated.js +2 -12
- package/dist/cjs/graphql/mutations/cart-lines-add.generated.js +2 -12
- package/dist/cjs/graphql/mutations/cart-lines-remove.generated.js +2 -12
- package/dist/cjs/graphql/mutations/cart-lines-update.generated.js +2 -12
- package/dist/cjs/graphql/mutations/cart-note-update.generated.js +2 -12
- package/dist/cjs/graphql/queries/cart.generated.js +2 -11
- package/dist/cjs/graphql/queries/product.generated.js +2 -8
- package/dist/cjs/graphql/queries/shop-meta.generated.js +2 -10
- package/dist/cjs/helpers/common.js +1 -15
- package/dist/cjs/helpers/normalize.js +1 -58
- package/dist/cjs/index.js +1 -35
- package/dist/esm/api/operations/add-to-cart.js +1 -33
- package/dist/esm/api/operations/cart-discount-codes-update.js +1 -29
- package/dist/esm/api/operations/cart-note-update.js +1 -29
- package/dist/esm/api/operations/create-cart.js +1 -34
- package/dist/esm/api/operations/get-cart.js +1 -28
- package/dist/esm/api/operations/remove-cart-item.js +1 -31
- package/dist/esm/api/operations/update-cart-line.js +1 -35
- package/dist/esm/graphql/fragments/cart-line.generated.js +6 -9
- package/dist/esm/graphql/fragments/cart-user-error.generated.js +2 -4
- package/dist/esm/graphql/fragments/cart.generated.js +2 -4
- package/dist/esm/graphql/fragments/country.generated.js +2 -4
- package/dist/esm/graphql/fragments/currency.generated.js +2 -4
- package/dist/esm/graphql/fragments/image.generated.js +2 -4
- package/dist/esm/graphql/fragments/language.generated.js +2 -4
- package/dist/esm/graphql/fragments/money-v2.generated.js +2 -4
- package/dist/esm/graphql/fragments/product.generated.js +2 -4
- package/dist/esm/graphql/mutations/cart-create.generated.js +7 -15
- package/dist/esm/graphql/mutations/cart-discount-codes-update.generated.js +7 -15
- package/dist/esm/graphql/mutations/cart-lines-add.generated.js +7 -15
- package/dist/esm/graphql/mutations/cart-lines-remove.generated.js +7 -15
- package/dist/esm/graphql/mutations/cart-lines-update.generated.js +7 -15
- package/dist/esm/graphql/mutations/cart-note-update.generated.js +7 -15
- package/dist/esm/graphql/queries/cart.generated.js +6 -13
- package/dist/esm/graphql/queries/product.generated.js +2 -6
- package/dist/esm/graphql/queries/shop-meta.generated.js +4 -10
- package/dist/esm/helpers/common.js +1 -13
- package/dist/esm/helpers/normalize.js +1 -56
- package/dist/esm/index.js +1 -15
- package/dist/types/index.d.ts +816 -407
- package/package.json +2 -2
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
-
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
-
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
-
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
-
|
|
7
|
-
const CartNoteUpdateDocument = `
|
|
1
|
+
import{CartSelect as t}from"../fragments/cart.generated.js";import{MoneyV2Select as r}from"../fragments/money-v2.generated.js";import{CartLineSelect as e,CartProductVariantSelect as a}from"../fragments/cart-line.generated.js";import{ImageSelect as o}from"../fragments/image.generated.js";import{CartUserErrorSelect as m}from"../fragments/cart-user-error.generated.js";let CartNoteUpdateDocument=`
|
|
8
2
|
mutation cartNoteUpdate($cartId: ID!, $note: String) {
|
|
9
3
|
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
10
4
|
cart {
|
|
@@ -15,11 +9,9 @@ const CartNoteUpdateDocument = `
|
|
|
15
9
|
}
|
|
16
10
|
}
|
|
17
11
|
}
|
|
18
|
-
${
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
24
|
-
|
|
25
|
-
export { CartNoteUpdateDocument };
|
|
12
|
+
${t}
|
|
13
|
+
${r}
|
|
14
|
+
${e}
|
|
15
|
+
${a}
|
|
16
|
+
${o}
|
|
17
|
+
${m}`;export{CartNoteUpdateDocument};
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
-
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
-
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
-
|
|
6
|
-
const CartDocument = `
|
|
1
|
+
import{CartSelect as e}from"../fragments/cart.generated.js";import{MoneyV2Select as r}from"../fragments/money-v2.generated.js";import{CartLineSelect as t,CartProductVariantSelect as a}from"../fragments/cart-line.generated.js";import{ImageSelect as m}from"../fragments/image.generated.js";let CartDocument=`
|
|
7
2
|
query cart($id: ID!) {
|
|
8
3
|
cart(id: $id) {
|
|
9
4
|
...CartSelect
|
|
10
5
|
}
|
|
11
6
|
}
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
|
|
18
|
-
export { CartDocument };
|
|
7
|
+
${e}
|
|
8
|
+
${r}
|
|
9
|
+
${t}
|
|
10
|
+
${a}
|
|
11
|
+
${m}`;export{CartDocument};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const ProductDocument = `
|
|
1
|
+
import{ProductSelect as t}from"../fragments/product.generated.js";let ProductDocument=`
|
|
4
2
|
query product($handle: String, $id: ID) {
|
|
5
3
|
product(handle: $handle, id: $id) {
|
|
6
4
|
...ProductSelect
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
|
-
${
|
|
10
|
-
|
|
11
|
-
export { ProductDocument };
|
|
7
|
+
${t}`;export{ProductDocument};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CurrencySelect } from '../fragments/currency.generated.js';
|
|
3
|
-
import { LanguageSelect } from '../fragments/language.generated.js';
|
|
4
|
-
|
|
5
|
-
const ShopMetaDocument = `
|
|
1
|
+
import{CountrySelect as e}from"../fragments/country.generated.js";import{CurrencySelect as t}from"../fragments/currency.generated.js";import{LanguageSelect as o}from"../fragments/language.generated.js";let ShopMetaDocument=`
|
|
6
2
|
query shopMeta {
|
|
7
3
|
localization {
|
|
8
4
|
country {
|
|
@@ -18,8 +14,6 @@ const ShopMetaDocument = `
|
|
|
18
14
|
moneyFormat
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
24
|
-
|
|
25
|
-
export { ShopMetaDocument };
|
|
17
|
+
${e}
|
|
18
|
+
${t}
|
|
19
|
+
${o}`;export{ShopMetaDocument};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return {
|
|
3
|
-
method: 'POST',
|
|
4
|
-
headers: {
|
|
5
|
-
'Content-Type': 'application/json',
|
|
6
|
-
...config.storefrontToken ? {
|
|
7
|
-
'X-Shopify-Storefront-Access-Token': config.storefrontToken
|
|
8
|
-
} : {}
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { composeRequest };
|
|
1
|
+
let composeRequest=e=>({method:"POST",headers:{"Content-Type":"application/json",...e.storefrontToken?{"X-Shopify-Storefront-Access-Token":e.storefrontToken}:{}}});export{composeRequest};
|
|
@@ -1,56 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const { compareAtPriceV2, priceV2, weight, weightUnit, id, sku, image } = variant;
|
|
3
|
-
return {
|
|
4
|
-
id,
|
|
5
|
-
requiresShipping: variant.requiresShipping,
|
|
6
|
-
availableForSale: variant.availableForSale,
|
|
7
|
-
sku: sku ?? id,
|
|
8
|
-
name: variant.title,
|
|
9
|
-
listPrice: compareAtPriceV2?.amount ? +compareAtPriceV2?.amount : 0,
|
|
10
|
-
price: +priceV2.amount,
|
|
11
|
-
weight: {
|
|
12
|
-
value: weight ?? 0,
|
|
13
|
-
unit: weightUnit
|
|
14
|
-
},
|
|
15
|
-
image
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const normalizeLineItem = (lineItem)=>{
|
|
19
|
-
const { quantity, id, merchandise } = lineItem;
|
|
20
|
-
const variant = normalizeCartProductVariant(merchandise);
|
|
21
|
-
return {
|
|
22
|
-
id,
|
|
23
|
-
quantity,
|
|
24
|
-
variant,
|
|
25
|
-
attributes: lineItem.attributes,
|
|
26
|
-
variantId: variant.id,
|
|
27
|
-
name: variant.name,
|
|
28
|
-
productTitle: merchandise.product.title,
|
|
29
|
-
productId: variant.id,
|
|
30
|
-
path: merchandise.product.handle,
|
|
31
|
-
discounts: []
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const normalizeCart = (cart)=>{
|
|
35
|
-
const { cost } = cart;
|
|
36
|
-
return {
|
|
37
|
-
createdAt: cart.createdAt,
|
|
38
|
-
id: cart.id,
|
|
39
|
-
lineItems: cart.lines.nodes.map(normalizeLineItem),
|
|
40
|
-
subtotalPrice: +cost.subtotalAmount.amount,
|
|
41
|
-
totalPrice: +cost.totalAmount.amount,
|
|
42
|
-
currency: {
|
|
43
|
-
code: cost.totalAmount.currencyCode
|
|
44
|
-
},
|
|
45
|
-
taxesIncluded: true,
|
|
46
|
-
lineItemsSubtotalPrice: +cost.subtotalAmount.amount,
|
|
47
|
-
checkoutUrl: cart.checkoutUrl,
|
|
48
|
-
note: cart.note,
|
|
49
|
-
discounts: cart.discountCodes.map((v)=>({
|
|
50
|
-
code: v.code,
|
|
51
|
-
applicable: v.applicable
|
|
52
|
-
}))
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { normalizeCart };
|
|
1
|
+
let normalizeCartProductVariant=t=>{let{compareAtPrice:e,price:a,weight:r,weightUnit:o,id:i,sku:n,image:l}=t;return{id:i,requiresShipping:t.requiresShipping,availableForSale:t.availableForSale,sku:n??i,name:t.title,listPrice:e?.amount?+e?.amount:0,price:+a.amount,weight:{value:r??0,unit:o},image:l}},normalizeLineItem=t=>{let{quantity:e,id:a,merchandise:r}=t,o=normalizeCartProductVariant(r);return{id:a,quantity:e,variant:o,attributes:t.attributes,variantId:o.id,name:o.name,productTitle:r.product.title,productId:o.id,path:r.product.handle,discounts:[]}},normalizeCart=t=>{let{cost:e}=t;return{createdAt:t.createdAt,id:t.id,lineItems:t.lines.nodes.map(normalizeLineItem),subtotalPrice:+e.subtotalAmount.amount,totalPrice:+e.totalAmount.amount,currency:{code:e.totalAmount.currencyCode},taxesIncluded:!0,lineItemsSubtotalPrice:+e.subtotalAmount.amount,checkoutUrl:t.checkoutUrl,note:t.note,discounts:t.discountCodes.map(t=>({code:t.code,applicable:t.applicable}))}};export{normalizeCart};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { createCartOperation } from './api/operations/create-cart.js';
|
|
3
|
-
export { getCartOperation } from './api/operations/get-cart.js';
|
|
4
|
-
export { removeCartItemOperation } from './api/operations/remove-cart-item.js';
|
|
5
|
-
export { updateCartLineOperation } from './api/operations/update-cart-line.js';
|
|
6
|
-
export { cartDiscountCodesUpdateOperation } from './api/operations/cart-discount-codes-update.js';
|
|
7
|
-
export { cartNoteUpdateOperation } from './api/operations/cart-note-update.js';
|
|
8
|
-
export { ProductDocument } from './graphql/queries/product.generated.js';
|
|
9
|
-
export { ShopMetaDocument } from './graphql/queries/shop-meta.generated.js';
|
|
10
|
-
export { CartCreateDocument } from './graphql/mutations/cart-create.generated.js';
|
|
11
|
-
export { CartDiscountCodesUpdateDocument } from './graphql/mutations/cart-discount-codes-update.generated.js';
|
|
12
|
-
export { CartLinesAddDocument } from './graphql/mutations/cart-lines-add.generated.js';
|
|
13
|
-
export { CartLinesRemoveDocument } from './graphql/mutations/cart-lines-remove.generated.js';
|
|
14
|
-
export { CartLinesUpdateDocument } from './graphql/mutations/cart-lines-update.generated.js';
|
|
15
|
-
export { CartNoteUpdateDocument } from './graphql/mutations/cart-note-update.generated.js';
|
|
1
|
+
export{addToCartOperation}from"./api/operations/add-to-cart.js";export{createCartOperation}from"./api/operations/create-cart.js";export{getCartOperation}from"./api/operations/get-cart.js";export{removeCartItemOperation}from"./api/operations/remove-cart-item.js";export{updateCartLineOperation}from"./api/operations/update-cart-line.js";export{cartDiscountCodesUpdateOperation}from"./api/operations/cart-discount-codes-update.js";export{cartNoteUpdateOperation}from"./api/operations/cart-note-update.js";export{ProductDocument}from"./graphql/queries/product.generated.js";export{ShopMetaDocument}from"./graphql/queries/shop-meta.generated.js";export{CartCreateDocument}from"./graphql/mutations/cart-create.generated.js";export{CartDiscountCodesUpdateDocument}from"./graphql/mutations/cart-discount-codes-update.generated.js";export{CartLinesAddDocument}from"./graphql/mutations/cart-lines-add.generated.js";export{CartLinesRemoveDocument}from"./graphql/mutations/cart-lines-remove.generated.js";export{CartLinesUpdateDocument}from"./graphql/mutations/cart-lines-update.generated.js";export{CartNoteUpdateDocument}from"./graphql/mutations/cart-note-update.generated.js";
|