@gem-sdk/adapter-bigcommerce 1.0.0
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/README.md +1 -0
- package/dist/cjs/api/operations/add-to-cart.js +32 -0
- package/dist/cjs/api/operations/create-cart.js +32 -0
- package/dist/cjs/api/operations/get-cart.js +27 -0
- package/dist/cjs/api/operations/remove-cart-item.js +29 -0
- package/dist/cjs/api/operations/update-cart-line.js +35 -0
- package/dist/cjs/graphql/fragments/cart-line.generated.js +44 -0
- package/dist/cjs/graphql/fragments/cart.generated.js +51 -0
- package/dist/cjs/graphql/fragments/media.generated.js +14 -0
- package/dist/cjs/graphql/mutations/cart-create.generated.js +25 -0
- package/dist/cjs/graphql/mutations/cart-lines-add.generated.js +25 -0
- package/dist/cjs/graphql/mutations/cart-lines-remove.generated.js +25 -0
- package/dist/cjs/graphql/mutations/cart-lines-update.generated.js +25 -0
- package/dist/cjs/graphql/queries/cart.generated.js +18 -0
- package/dist/cjs/helpers/common.js +15 -0
- package/dist/cjs/helpers/normalize.js +48 -0
- package/dist/cjs/index.js +15 -0
- package/dist/esm/api/operations/add-to-cart.js +30 -0
- package/dist/esm/api/operations/create-cart.js +30 -0
- package/dist/esm/api/operations/get-cart.js +25 -0
- package/dist/esm/api/operations/remove-cart-item.js +27 -0
- package/dist/esm/api/operations/update-cart-line.js +33 -0
- package/dist/esm/graphql/fragments/cart-line.generated.js +41 -0
- package/dist/esm/graphql/fragments/cart.generated.js +49 -0
- package/dist/esm/graphql/fragments/media.generated.js +12 -0
- package/dist/esm/graphql/mutations/cart-create.generated.js +23 -0
- package/dist/esm/graphql/mutations/cart-lines-add.generated.js +23 -0
- package/dist/esm/graphql/mutations/cart-lines-remove.generated.js +23 -0
- package/dist/esm/graphql/mutations/cart-lines-update.generated.js +23 -0
- package/dist/esm/graphql/queries/cart.generated.js +16 -0
- package/dist/esm/helpers/common.js +13 -0
- package/dist/esm/helpers/normalize.js +46 -0
- package/dist/esm/index.js +5 -0
- package/dist/types/index.d.ts +13 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# GemX Adapter
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cartLinesAdd_generated = require('../../graphql/mutations/cart-lines-add.generated.js');
|
|
4
|
+
var common = require('../../helpers/common.js');
|
|
5
|
+
var normalize = require('../../helpers/normalize.js');
|
|
6
|
+
|
|
7
|
+
const addToCartOperation = (config) => {
|
|
8
|
+
const addToCart = async (args) => {
|
|
9
|
+
if (!config.storefrontUrl) {
|
|
10
|
+
throw new Error('Shop is not connected');
|
|
11
|
+
}
|
|
12
|
+
const variables = {
|
|
13
|
+
cartId: args.cartId,
|
|
14
|
+
platform: 3,
|
|
15
|
+
lines: args.lines.map((v) => ({
|
|
16
|
+
quantity: v.quantity,
|
|
17
|
+
merchandiseId: v.variantId,
|
|
18
|
+
})),
|
|
19
|
+
};
|
|
20
|
+
const res = await fetch(config.storefrontUrl, {
|
|
21
|
+
...common.composeRequest(config),
|
|
22
|
+
body: JSON.stringify({ query: cartLinesAdd_generated.CartLinesAddDocument, variables }),
|
|
23
|
+
}).then((res) => res.json());
|
|
24
|
+
if (!res.data?.cartLinesAdd?.cart) {
|
|
25
|
+
return Promise.reject("Can't add to cart");
|
|
26
|
+
}
|
|
27
|
+
return normalize.normalizeCart(res.data.cartLinesAdd.cart);
|
|
28
|
+
};
|
|
29
|
+
return addToCart;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.addToCartOperation = addToCartOperation;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cartCreate_generated = require('../../graphql/mutations/cart-create.generated.js');
|
|
4
|
+
var common = require('../../helpers/common.js');
|
|
5
|
+
var normalize = require('../../helpers/normalize.js');
|
|
6
|
+
|
|
7
|
+
const createCartOperation = (config) => {
|
|
8
|
+
const createCart = async (args) => {
|
|
9
|
+
if (!config.storefrontUrl) {
|
|
10
|
+
throw new Error('Shop is not connected');
|
|
11
|
+
}
|
|
12
|
+
const variables = {
|
|
13
|
+
input: {
|
|
14
|
+
lines: args.items.map((v) => ({
|
|
15
|
+
quantity: v.quantity ?? 1,
|
|
16
|
+
merchandiseId: v.variantId,
|
|
17
|
+
})),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const res = await fetch(config.storefrontUrl, {
|
|
21
|
+
...common.composeRequest(config),
|
|
22
|
+
body: JSON.stringify({ query: cartCreate_generated.CartCreateDocument, variables }),
|
|
23
|
+
}).then((res) => res.json());
|
|
24
|
+
if (!res.data?.cartCreate?.cart) {
|
|
25
|
+
return Promise.reject("Can't create cart");
|
|
26
|
+
}
|
|
27
|
+
return normalize.normalizeCart(res.data.cartCreate.cart);
|
|
28
|
+
};
|
|
29
|
+
return createCart;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.createCartOperation = createCartOperation;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../../graphql/queries/cart.generated.js');
|
|
4
|
+
var common = require('../../helpers/common.js');
|
|
5
|
+
var normalize = require('../../helpers/normalize.js');
|
|
6
|
+
|
|
7
|
+
const getCartOperation = (config) => {
|
|
8
|
+
const getCart = async (args) => {
|
|
9
|
+
if (!config.storefrontUrl) {
|
|
10
|
+
throw new Error('Shop is not connected');
|
|
11
|
+
}
|
|
12
|
+
const variables = {
|
|
13
|
+
id: args.cartId,
|
|
14
|
+
};
|
|
15
|
+
const res = await fetch(config.storefrontUrl, {
|
|
16
|
+
...common.composeRequest(config),
|
|
17
|
+
body: JSON.stringify({ query: cart_generated.CartDocument, variables }),
|
|
18
|
+
}).then((res) => res.json());
|
|
19
|
+
if (!res.data?.cart) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return normalize.normalizeCart(res.data.cart);
|
|
23
|
+
};
|
|
24
|
+
return getCart;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.getCartOperation = getCartOperation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cartLinesRemove_generated = require('../../graphql/mutations/cart-lines-remove.generated.js');
|
|
4
|
+
var common = require('../../helpers/common.js');
|
|
5
|
+
var normalize = require('../../helpers/normalize.js');
|
|
6
|
+
|
|
7
|
+
const removeCartItemOperation = (config) => {
|
|
8
|
+
const removeCartItem = async (args) => {
|
|
9
|
+
if (!config.storefrontUrl) {
|
|
10
|
+
throw new Error('Shop is not connected');
|
|
11
|
+
}
|
|
12
|
+
const variables = {
|
|
13
|
+
cartId: args.cartId,
|
|
14
|
+
lineIds: [args.lineId],
|
|
15
|
+
platform: 3,
|
|
16
|
+
};
|
|
17
|
+
const res = await fetch(config.storefrontUrl, {
|
|
18
|
+
...common.composeRequest(config),
|
|
19
|
+
body: JSON.stringify({ query: cartLinesRemove_generated.CartLinesRemoveDocument, variables }),
|
|
20
|
+
}).then((res) => res.json());
|
|
21
|
+
if (!res.data?.cartLinesRemove?.cart) {
|
|
22
|
+
return Promise.reject("Can't remove cart");
|
|
23
|
+
}
|
|
24
|
+
return normalize.normalizeCart(res.data.cartLinesRemove.cart);
|
|
25
|
+
};
|
|
26
|
+
return removeCartItem;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.removeCartItemOperation = removeCartItemOperation;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cartLinesUpdate_generated = require('../../graphql/mutations/cart-lines-update.generated.js');
|
|
4
|
+
var common = require('../../helpers/common.js');
|
|
5
|
+
var normalize = require('../../helpers/normalize.js');
|
|
6
|
+
|
|
7
|
+
const updateCartLineOperation = (config) => {
|
|
8
|
+
const updateCartLine = async (args) => {
|
|
9
|
+
if (!config.storefrontUrl) {
|
|
10
|
+
throw new Error('Shop is not connected');
|
|
11
|
+
}
|
|
12
|
+
const variables = {
|
|
13
|
+
cartId: args.cartId,
|
|
14
|
+
platform: 3,
|
|
15
|
+
lines: [
|
|
16
|
+
{
|
|
17
|
+
id: args.line.id,
|
|
18
|
+
quantity: args.line.quantity,
|
|
19
|
+
merchandiseId: args.line.variantId,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
const res = await fetch(config.storefrontUrl, {
|
|
24
|
+
...common.composeRequest(config),
|
|
25
|
+
body: JSON.stringify({ query: cartLinesUpdate_generated.CartLinesUpdateDocument, variables }),
|
|
26
|
+
}).then((res) => res.json());
|
|
27
|
+
if (!res.data?.cartLinesUpdate?.cart) {
|
|
28
|
+
return Promise.reject("Can't update cart");
|
|
29
|
+
}
|
|
30
|
+
return normalize.normalizeCart(res.data.cartLinesUpdate.cart);
|
|
31
|
+
};
|
|
32
|
+
return updateCartLine;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.updateCartLineOperation = updateCartLineOperation;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CartProductVariantSelect = `
|
|
4
|
+
fragment CartProductVariantSelect on ProductVariant {
|
|
5
|
+
id
|
|
6
|
+
title
|
|
7
|
+
sku
|
|
8
|
+
price
|
|
9
|
+
salePrice
|
|
10
|
+
costPrice
|
|
11
|
+
selectedOptions {
|
|
12
|
+
name
|
|
13
|
+
value
|
|
14
|
+
}
|
|
15
|
+
media {
|
|
16
|
+
...MediaSelect
|
|
17
|
+
}
|
|
18
|
+
baseID
|
|
19
|
+
product {
|
|
20
|
+
id
|
|
21
|
+
handle
|
|
22
|
+
title
|
|
23
|
+
}
|
|
24
|
+
weight
|
|
25
|
+
width
|
|
26
|
+
height
|
|
27
|
+
length
|
|
28
|
+
isDigital
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const CartLineSelect = `
|
|
32
|
+
fragment CartLineSelect on CartLine {
|
|
33
|
+
id
|
|
34
|
+
quantity
|
|
35
|
+
variant {
|
|
36
|
+
... on ProductVariant {
|
|
37
|
+
...CartProductVariantSelect
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports.CartLineSelect = CartLineSelect;
|
|
44
|
+
exports.CartProductVariantSelect = CartProductVariantSelect;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CartSelect = `
|
|
4
|
+
fragment CartSelect on Cart {
|
|
5
|
+
id
|
|
6
|
+
attribute {
|
|
7
|
+
id
|
|
8
|
+
key
|
|
9
|
+
value
|
|
10
|
+
}
|
|
11
|
+
customer {
|
|
12
|
+
id
|
|
13
|
+
email
|
|
14
|
+
firstName
|
|
15
|
+
lastName
|
|
16
|
+
}
|
|
17
|
+
baseId
|
|
18
|
+
checkoutUrl
|
|
19
|
+
createdAt
|
|
20
|
+
deletedAt
|
|
21
|
+
discountCodes {
|
|
22
|
+
applicable
|
|
23
|
+
code
|
|
24
|
+
id
|
|
25
|
+
}
|
|
26
|
+
lines(after: $after, before: $before, first: $first, last: $last, query: $query) {
|
|
27
|
+
totalCount
|
|
28
|
+
edges {
|
|
29
|
+
cursor
|
|
30
|
+
node {
|
|
31
|
+
...CartLineSelect
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
note
|
|
36
|
+
platform
|
|
37
|
+
subtotalAmount
|
|
38
|
+
subtotalAmountCurrencyCode
|
|
39
|
+
totalAmount
|
|
40
|
+
totalAmountCurrencyCode
|
|
41
|
+
totalDiscountedAmount
|
|
42
|
+
totalDutyAmount
|
|
43
|
+
totalDutyAmountCurrencyCode
|
|
44
|
+
totalQuantity
|
|
45
|
+
totalTaxAmount
|
|
46
|
+
totalTaxAmountCurrencyCode
|
|
47
|
+
updatedAt
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports.CartSelect = CartSelect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../fragments/cart.generated.js');
|
|
4
|
+
var cartLine_generated = require('../fragments/cart-line.generated.js');
|
|
5
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
6
|
+
|
|
7
|
+
const CartCreateDocument = `
|
|
8
|
+
mutation cartCreate($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $input: CartInput!) {
|
|
9
|
+
cartCreate(input: $input) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
code
|
|
15
|
+
field
|
|
16
|
+
message
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
${cart_generated.CartSelect}
|
|
21
|
+
${cartLine_generated.CartLineSelect}
|
|
22
|
+
${cartLine_generated.CartProductVariantSelect}
|
|
23
|
+
${media_generated.MediaSelect}`;
|
|
24
|
+
|
|
25
|
+
exports.CartCreateDocument = CartCreateDocument;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../fragments/cart.generated.js');
|
|
4
|
+
var cartLine_generated = require('../fragments/cart-line.generated.js');
|
|
5
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
6
|
+
|
|
7
|
+
const CartLinesAddDocument = `
|
|
8
|
+
mutation cartLinesAdd($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lines: [CartLineInput!]!, $platform: Int!) {
|
|
9
|
+
cartLinesAdd(cartId: $cartId, lines: $lines, platform: $platform) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
code
|
|
15
|
+
field
|
|
16
|
+
message
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
${cart_generated.CartSelect}
|
|
21
|
+
${cartLine_generated.CartLineSelect}
|
|
22
|
+
${cartLine_generated.CartProductVariantSelect}
|
|
23
|
+
${media_generated.MediaSelect}`;
|
|
24
|
+
|
|
25
|
+
exports.CartLinesAddDocument = CartLinesAddDocument;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../fragments/cart.generated.js');
|
|
4
|
+
var cartLine_generated = require('../fragments/cart-line.generated.js');
|
|
5
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
6
|
+
|
|
7
|
+
const CartLinesRemoveDocument = `
|
|
8
|
+
mutation cartLinesRemove($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lineIds: [ID!]!, $platform: Int!) {
|
|
9
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lineIds, platform: $platform) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
code
|
|
15
|
+
field
|
|
16
|
+
message
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
${cart_generated.CartSelect}
|
|
21
|
+
${cartLine_generated.CartLineSelect}
|
|
22
|
+
${cartLine_generated.CartProductVariantSelect}
|
|
23
|
+
${media_generated.MediaSelect}`;
|
|
24
|
+
|
|
25
|
+
exports.CartLinesRemoveDocument = CartLinesRemoveDocument;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../fragments/cart.generated.js');
|
|
4
|
+
var cartLine_generated = require('../fragments/cart-line.generated.js');
|
|
5
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
6
|
+
|
|
7
|
+
const CartLinesUpdateDocument = `
|
|
8
|
+
mutation cartLinesUpdate($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lines: [CartLineUpdateInput!]!, $platform: Int!) {
|
|
9
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines, platform: $platform) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
code
|
|
15
|
+
field
|
|
16
|
+
message
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
${cart_generated.CartSelect}
|
|
21
|
+
${cartLine_generated.CartLineSelect}
|
|
22
|
+
${cartLine_generated.CartProductVariantSelect}
|
|
23
|
+
${media_generated.MediaSelect}`;
|
|
24
|
+
|
|
25
|
+
exports.CartLinesUpdateDocument = CartLinesUpdateDocument;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cart_generated = require('../fragments/cart.generated.js');
|
|
4
|
+
var cartLine_generated = require('../fragments/cart-line.generated.js');
|
|
5
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
6
|
+
|
|
7
|
+
const CartDocument = `
|
|
8
|
+
query cart($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $id: ID!) {
|
|
9
|
+
cart(id: $id) {
|
|
10
|
+
...CartSelect
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
${cart_generated.CartSelect}
|
|
14
|
+
${cartLine_generated.CartLineSelect}
|
|
15
|
+
${cartLine_generated.CartProductVariantSelect}
|
|
16
|
+
${media_generated.MediaSelect}`;
|
|
17
|
+
|
|
18
|
+
exports.CartDocument = CartDocument;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const composeRequest = (config) => {
|
|
4
|
+
return {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
...(config.storefrontToken
|
|
9
|
+
? { 'X-Bigcommerce-Storefront-Access-Token': config.storefrontToken }
|
|
10
|
+
: {}),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.composeRequest = composeRequest;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const normalizeLineItem = (item) => {
|
|
4
|
+
const { quantity, id, variant } = item;
|
|
5
|
+
return {
|
|
6
|
+
id: id ?? '',
|
|
7
|
+
quantity,
|
|
8
|
+
name: variant?.title ?? '',
|
|
9
|
+
productTitle: variant?.product?.title ?? '',
|
|
10
|
+
variant: {
|
|
11
|
+
id: variant?.id ?? '',
|
|
12
|
+
sku: variant?.sku ?? '',
|
|
13
|
+
name: variant?.title ?? '',
|
|
14
|
+
image: variant?.media?.src
|
|
15
|
+
? {
|
|
16
|
+
url: variant.media.src,
|
|
17
|
+
}
|
|
18
|
+
: undefined,
|
|
19
|
+
requiresShipping: false,
|
|
20
|
+
price: variant?.price ?? 0,
|
|
21
|
+
listPrice: 0,
|
|
22
|
+
},
|
|
23
|
+
variantId: variant?.id ?? '',
|
|
24
|
+
productId: variant?.product?.id ?? '',
|
|
25
|
+
path: variant?.product?.handle,
|
|
26
|
+
discounts: [],
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const normalizeCart = (cart) => {
|
|
30
|
+
return {
|
|
31
|
+
createdAt: cart.createdAt,
|
|
32
|
+
id: cart.id,
|
|
33
|
+
customerId: cart.customer?.id,
|
|
34
|
+
email: cart.customer?.email,
|
|
35
|
+
lineItems: cart.lines?.edges?.map((node) => normalizeLineItem(node.node)) ?? [],
|
|
36
|
+
subtotalPrice: cart.subtotalAmount ? +cart.subtotalAmount : 0,
|
|
37
|
+
totalPrice: cart.totalAmount ? +cart.totalAmount : 0,
|
|
38
|
+
currency: {
|
|
39
|
+
code: cart.totalAmountCurrencyCode,
|
|
40
|
+
},
|
|
41
|
+
taxesIncluded: true,
|
|
42
|
+
discounts: [],
|
|
43
|
+
lineItemsSubtotalPrice: cart.subtotalAmount ? +cart.subtotalAmount : 0,
|
|
44
|
+
checkoutUrl: cart.checkoutUrl,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.normalizeCart = normalizeCart;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var addToCart = require('./api/operations/add-to-cart.js');
|
|
4
|
+
var createCart = require('./api/operations/create-cart.js');
|
|
5
|
+
var getCart = require('./api/operations/get-cart.js');
|
|
6
|
+
var removeCartItem = require('./api/operations/remove-cart-item.js');
|
|
7
|
+
var updateCartLine = require('./api/operations/update-cart-line.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.addToCartOperation = addToCart.addToCartOperation;
|
|
12
|
+
exports.createCartOperation = createCart.createCartOperation;
|
|
13
|
+
exports.getCartOperation = getCart.getCartOperation;
|
|
14
|
+
exports.removeCartItemOperation = removeCartItem.removeCartItemOperation;
|
|
15
|
+
exports.updateCartLineOperation = updateCartLine.updateCartLineOperation;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CartLinesAddDocument } from '../../graphql/mutations/cart-lines-add.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const addToCartOperation = (config) => {
|
|
6
|
+
const addToCart = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: args.cartId,
|
|
12
|
+
platform: 3,
|
|
13
|
+
lines: args.lines.map((v) => ({
|
|
14
|
+
quantity: v.quantity,
|
|
15
|
+
merchandiseId: v.variantId,
|
|
16
|
+
})),
|
|
17
|
+
};
|
|
18
|
+
const res = await fetch(config.storefrontUrl, {
|
|
19
|
+
...composeRequest(config),
|
|
20
|
+
body: JSON.stringify({ query: CartLinesAddDocument, variables }),
|
|
21
|
+
}).then((res) => res.json());
|
|
22
|
+
if (!res.data?.cartLinesAdd?.cart) {
|
|
23
|
+
return Promise.reject("Can't add to cart");
|
|
24
|
+
}
|
|
25
|
+
return normalizeCart(res.data.cartLinesAdd.cart);
|
|
26
|
+
};
|
|
27
|
+
return addToCart;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { addToCartOperation };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CartCreateDocument } from '../../graphql/mutations/cart-create.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const createCartOperation = (config) => {
|
|
6
|
+
const createCart = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
input: {
|
|
12
|
+
lines: args.items.map((v) => ({
|
|
13
|
+
quantity: v.quantity ?? 1,
|
|
14
|
+
merchandiseId: v.variantId,
|
|
15
|
+
})),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const res = await fetch(config.storefrontUrl, {
|
|
19
|
+
...composeRequest(config),
|
|
20
|
+
body: JSON.stringify({ query: CartCreateDocument, variables }),
|
|
21
|
+
}).then((res) => res.json());
|
|
22
|
+
if (!res.data?.cartCreate?.cart) {
|
|
23
|
+
return Promise.reject("Can't create cart");
|
|
24
|
+
}
|
|
25
|
+
return normalizeCart(res.data.cartCreate.cart);
|
|
26
|
+
};
|
|
27
|
+
return createCart;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { createCartOperation };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartDocument } from '../../graphql/queries/cart.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const getCartOperation = (config) => {
|
|
6
|
+
const getCart = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
id: args.cartId,
|
|
12
|
+
};
|
|
13
|
+
const res = await fetch(config.storefrontUrl, {
|
|
14
|
+
...composeRequest(config),
|
|
15
|
+
body: JSON.stringify({ query: CartDocument, variables }),
|
|
16
|
+
}).then((res) => res.json());
|
|
17
|
+
if (!res.data?.cart) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return normalizeCart(res.data.cart);
|
|
21
|
+
};
|
|
22
|
+
return getCart;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { getCartOperation };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CartLinesRemoveDocument } from '../../graphql/mutations/cart-lines-remove.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const removeCartItemOperation = (config) => {
|
|
6
|
+
const removeCartItem = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: args.cartId,
|
|
12
|
+
lineIds: [args.lineId],
|
|
13
|
+
platform: 3,
|
|
14
|
+
};
|
|
15
|
+
const res = await fetch(config.storefrontUrl, {
|
|
16
|
+
...composeRequest(config),
|
|
17
|
+
body: JSON.stringify({ query: CartLinesRemoveDocument, variables }),
|
|
18
|
+
}).then((res) => res.json());
|
|
19
|
+
if (!res.data?.cartLinesRemove?.cart) {
|
|
20
|
+
return Promise.reject("Can't remove cart");
|
|
21
|
+
}
|
|
22
|
+
return normalizeCart(res.data.cartLinesRemove.cart);
|
|
23
|
+
};
|
|
24
|
+
return removeCartItem;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { removeCartItemOperation };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CartLinesUpdateDocument } from '../../graphql/mutations/cart-lines-update.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const updateCartLineOperation = (config) => {
|
|
6
|
+
const updateCartLine = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: args.cartId,
|
|
12
|
+
platform: 3,
|
|
13
|
+
lines: [
|
|
14
|
+
{
|
|
15
|
+
id: args.line.id,
|
|
16
|
+
quantity: args.line.quantity,
|
|
17
|
+
merchandiseId: args.line.variantId,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
const res = await fetch(config.storefrontUrl, {
|
|
22
|
+
...composeRequest(config),
|
|
23
|
+
body: JSON.stringify({ query: CartLinesUpdateDocument, variables }),
|
|
24
|
+
}).then((res) => res.json());
|
|
25
|
+
if (!res.data?.cartLinesUpdate?.cart) {
|
|
26
|
+
return Promise.reject("Can't update cart");
|
|
27
|
+
}
|
|
28
|
+
return normalizeCart(res.data.cartLinesUpdate.cart);
|
|
29
|
+
};
|
|
30
|
+
return updateCartLine;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { updateCartLineOperation };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const CartProductVariantSelect = `
|
|
2
|
+
fragment CartProductVariantSelect on ProductVariant {
|
|
3
|
+
id
|
|
4
|
+
title
|
|
5
|
+
sku
|
|
6
|
+
price
|
|
7
|
+
salePrice
|
|
8
|
+
costPrice
|
|
9
|
+
selectedOptions {
|
|
10
|
+
name
|
|
11
|
+
value
|
|
12
|
+
}
|
|
13
|
+
media {
|
|
14
|
+
...MediaSelect
|
|
15
|
+
}
|
|
16
|
+
baseID
|
|
17
|
+
product {
|
|
18
|
+
id
|
|
19
|
+
handle
|
|
20
|
+
title
|
|
21
|
+
}
|
|
22
|
+
weight
|
|
23
|
+
width
|
|
24
|
+
height
|
|
25
|
+
length
|
|
26
|
+
isDigital
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const CartLineSelect = `
|
|
30
|
+
fragment CartLineSelect on CartLine {
|
|
31
|
+
id
|
|
32
|
+
quantity
|
|
33
|
+
variant {
|
|
34
|
+
... on ProductVariant {
|
|
35
|
+
...CartProductVariantSelect
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export { CartLineSelect, CartProductVariantSelect };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const CartSelect = `
|
|
2
|
+
fragment CartSelect on Cart {
|
|
3
|
+
id
|
|
4
|
+
attribute {
|
|
5
|
+
id
|
|
6
|
+
key
|
|
7
|
+
value
|
|
8
|
+
}
|
|
9
|
+
customer {
|
|
10
|
+
id
|
|
11
|
+
email
|
|
12
|
+
firstName
|
|
13
|
+
lastName
|
|
14
|
+
}
|
|
15
|
+
baseId
|
|
16
|
+
checkoutUrl
|
|
17
|
+
createdAt
|
|
18
|
+
deletedAt
|
|
19
|
+
discountCodes {
|
|
20
|
+
applicable
|
|
21
|
+
code
|
|
22
|
+
id
|
|
23
|
+
}
|
|
24
|
+
lines(after: $after, before: $before, first: $first, last: $last, query: $query) {
|
|
25
|
+
totalCount
|
|
26
|
+
edges {
|
|
27
|
+
cursor
|
|
28
|
+
node {
|
|
29
|
+
...CartLineSelect
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
note
|
|
34
|
+
platform
|
|
35
|
+
subtotalAmount
|
|
36
|
+
subtotalAmountCurrencyCode
|
|
37
|
+
totalAmount
|
|
38
|
+
totalAmountCurrencyCode
|
|
39
|
+
totalDiscountedAmount
|
|
40
|
+
totalDutyAmount
|
|
41
|
+
totalDutyAmountCurrencyCode
|
|
42
|
+
totalQuantity
|
|
43
|
+
totalTaxAmount
|
|
44
|
+
totalTaxAmountCurrencyCode
|
|
45
|
+
updatedAt
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export { CartSelect };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
3
|
+
import { MediaSelect } from '../fragments/media.generated.js';
|
|
4
|
+
|
|
5
|
+
const CartCreateDocument = `
|
|
6
|
+
mutation cartCreate($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $input: CartInput!) {
|
|
7
|
+
cartCreate(input: $input) {
|
|
8
|
+
cart {
|
|
9
|
+
...CartSelect
|
|
10
|
+
}
|
|
11
|
+
userErrors {
|
|
12
|
+
code
|
|
13
|
+
field
|
|
14
|
+
message
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${CartLineSelect}
|
|
20
|
+
${CartProductVariantSelect}
|
|
21
|
+
${MediaSelect}`;
|
|
22
|
+
|
|
23
|
+
export { CartCreateDocument };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
3
|
+
import { MediaSelect } from '../fragments/media.generated.js';
|
|
4
|
+
|
|
5
|
+
const CartLinesAddDocument = `
|
|
6
|
+
mutation cartLinesAdd($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lines: [CartLineInput!]!, $platform: Int!) {
|
|
7
|
+
cartLinesAdd(cartId: $cartId, lines: $lines, platform: $platform) {
|
|
8
|
+
cart {
|
|
9
|
+
...CartSelect
|
|
10
|
+
}
|
|
11
|
+
userErrors {
|
|
12
|
+
code
|
|
13
|
+
field
|
|
14
|
+
message
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${CartLineSelect}
|
|
20
|
+
${CartProductVariantSelect}
|
|
21
|
+
${MediaSelect}`;
|
|
22
|
+
|
|
23
|
+
export { CartLinesAddDocument };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
3
|
+
import { MediaSelect } from '../fragments/media.generated.js';
|
|
4
|
+
|
|
5
|
+
const CartLinesRemoveDocument = `
|
|
6
|
+
mutation cartLinesRemove($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lineIds: [ID!]!, $platform: Int!) {
|
|
7
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lineIds, platform: $platform) {
|
|
8
|
+
cart {
|
|
9
|
+
...CartSelect
|
|
10
|
+
}
|
|
11
|
+
userErrors {
|
|
12
|
+
code
|
|
13
|
+
field
|
|
14
|
+
message
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${CartLineSelect}
|
|
20
|
+
${CartProductVariantSelect}
|
|
21
|
+
${MediaSelect}`;
|
|
22
|
+
|
|
23
|
+
export { CartLinesRemoveDocument };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
3
|
+
import { MediaSelect } from '../fragments/media.generated.js';
|
|
4
|
+
|
|
5
|
+
const CartLinesUpdateDocument = `
|
|
6
|
+
mutation cartLinesUpdate($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $cartId: ID!, $lines: [CartLineUpdateInput!]!, $platform: Int!) {
|
|
7
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines, platform: $platform) {
|
|
8
|
+
cart {
|
|
9
|
+
...CartSelect
|
|
10
|
+
}
|
|
11
|
+
userErrors {
|
|
12
|
+
code
|
|
13
|
+
field
|
|
14
|
+
message
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${CartLineSelect}
|
|
20
|
+
${CartProductVariantSelect}
|
|
21
|
+
${MediaSelect}`;
|
|
22
|
+
|
|
23
|
+
export { CartLinesUpdateDocument };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
3
|
+
import { MediaSelect } from '../fragments/media.generated.js';
|
|
4
|
+
|
|
5
|
+
const CartDocument = `
|
|
6
|
+
query cart($after: Cursor, $before: Cursor, $first: Int = 50, $last: Int, $query: CartLineWhereInput, $id: ID!) {
|
|
7
|
+
cart(id: $id) {
|
|
8
|
+
...CartSelect
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
${CartSelect}
|
|
12
|
+
${CartLineSelect}
|
|
13
|
+
${CartProductVariantSelect}
|
|
14
|
+
${MediaSelect}`;
|
|
15
|
+
|
|
16
|
+
export { CartDocument };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const composeRequest = (config) => {
|
|
2
|
+
return {
|
|
3
|
+
method: 'POST',
|
|
4
|
+
headers: {
|
|
5
|
+
'Content-Type': 'application/json',
|
|
6
|
+
...(config.storefrontToken
|
|
7
|
+
? { 'X-Bigcommerce-Storefront-Access-Token': config.storefrontToken }
|
|
8
|
+
: {}),
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { composeRequest };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const normalizeLineItem = (item) => {
|
|
2
|
+
const { quantity, id, variant } = item;
|
|
3
|
+
return {
|
|
4
|
+
id: id ?? '',
|
|
5
|
+
quantity,
|
|
6
|
+
name: variant?.title ?? '',
|
|
7
|
+
productTitle: variant?.product?.title ?? '',
|
|
8
|
+
variant: {
|
|
9
|
+
id: variant?.id ?? '',
|
|
10
|
+
sku: variant?.sku ?? '',
|
|
11
|
+
name: variant?.title ?? '',
|
|
12
|
+
image: variant?.media?.src
|
|
13
|
+
? {
|
|
14
|
+
url: variant.media.src,
|
|
15
|
+
}
|
|
16
|
+
: undefined,
|
|
17
|
+
requiresShipping: false,
|
|
18
|
+
price: variant?.price ?? 0,
|
|
19
|
+
listPrice: 0,
|
|
20
|
+
},
|
|
21
|
+
variantId: variant?.id ?? '',
|
|
22
|
+
productId: variant?.product?.id ?? '',
|
|
23
|
+
path: variant?.product?.handle,
|
|
24
|
+
discounts: [],
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const normalizeCart = (cart) => {
|
|
28
|
+
return {
|
|
29
|
+
createdAt: cart.createdAt,
|
|
30
|
+
id: cart.id,
|
|
31
|
+
customerId: cart.customer?.id,
|
|
32
|
+
email: cart.customer?.email,
|
|
33
|
+
lineItems: cart.lines?.edges?.map((node) => normalizeLineItem(node.node)) ?? [],
|
|
34
|
+
subtotalPrice: cart.subtotalAmount ? +cart.subtotalAmount : 0,
|
|
35
|
+
totalPrice: cart.totalAmount ? +cart.totalAmount : 0,
|
|
36
|
+
currency: {
|
|
37
|
+
code: cart.totalAmountCurrencyCode,
|
|
38
|
+
},
|
|
39
|
+
taxesIncluded: true,
|
|
40
|
+
discounts: [],
|
|
41
|
+
lineItemsSubtotalPrice: cart.subtotalAmount ? +cart.subtotalAmount : 0,
|
|
42
|
+
checkoutUrl: cart.checkoutUrl,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { normalizeCart };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { addToCartOperation } from './api/operations/add-to-cart.js';
|
|
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';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Site, Cart } from '@gem-sdk/adapter-common';
|
|
2
|
+
|
|
3
|
+
declare const addToCartOperation: (config: Site.ProviderConfig) => Cart.AddCartLineFunc;
|
|
4
|
+
|
|
5
|
+
declare const createCartOperation: (config: Site.ProviderConfig) => Cart.CreateCartFunc;
|
|
6
|
+
|
|
7
|
+
declare const getCartOperation: (config: Site.ProviderConfig) => Cart.GetCartFunc;
|
|
8
|
+
|
|
9
|
+
declare const removeCartItemOperation: (config: Site.ProviderConfig) => Cart.RemoveCartLineFunc;
|
|
10
|
+
|
|
11
|
+
declare const updateCartLineOperation: (config: Site.ProviderConfig) => Cart.UpdateCartLineFunc;
|
|
12
|
+
|
|
13
|
+
export { addToCartOperation, createCartOperation, getCartOperation, removeCartItemOperation, updateCartLineOperation };
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gem-sdk/adapter-bigcommerce",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"cleanup": "rimraf es dist lib",
|
|
12
|
+
"prebuild": "yarn cleanup",
|
|
13
|
+
"pre:publish": "node ./../../helpers/convert-publish.js -p",
|
|
14
|
+
"post:publish": "node ./../../helpers/convert-publish.js",
|
|
15
|
+
"watch": "rollup -c ./../../helpers/rollup.config.mjs -w",
|
|
16
|
+
"build": "rollup -c ./../../helpers/rollup.config.mjs --environment NODE_ENV:production",
|
|
17
|
+
"lint": "eslint ./src --ext .tsx,.ts,.gql",
|
|
18
|
+
"type-check": "yarn tsc --noEmit",
|
|
19
|
+
"test": "jest -c ./../../helpers/jest.config.ts",
|
|
20
|
+
"schema:codegen": "gqlg --schemaFilePath ./schema/schema.graphql --rootQuery Query --rootMutation Mutation --destDirPath ./__generated__ --depthLimit 3",
|
|
21
|
+
"schema:download": "graphql-codegen --config codegen/download.yml",
|
|
22
|
+
"codegen": "yarn schema:codegen",
|
|
23
|
+
"typegen": "graphql-codegen --config codegen/codegen.yml"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@gem-sdk/adapter-common": "*"
|
|
27
|
+
},
|
|
28
|
+
"module": "dist/esm/index.js",
|
|
29
|
+
"types": "dist/types/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json",
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/esm/index.js",
|
|
34
|
+
"require": "./dist/cjs/index.js",
|
|
35
|
+
"types": "./dist/types/index.d.ts"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|