@plasmicpkgs/commerce-shopify 0.0.8 → 0.0.9
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/commerce-shopify.cjs.development.js +118 -16
- package/dist/commerce-shopify.cjs.development.js.map +1 -1
- package/dist/commerce-shopify.cjs.production.min.js +1 -1
- package/dist/commerce-shopify.cjs.production.min.js.map +1 -1
- package/dist/commerce-shopify.esm.js +118 -16
- package/dist/commerce-shopify.esm.js.map +1 -1
- package/dist/product/use-product.d.ts +8 -0
- package/dist/provider.d.ts +3 -0
- package/dist/utils/queries/get-all-products-query.d.ts +1 -1
- package/dist/utils/queries/get-product-query.d.ts +3 -2
- package/package.json +4 -4
|
@@ -1471,6 +1471,18 @@ var getSiteCollectionsQuery =
|
|
|
1471
1471
|
/* GraphQL */
|
|
1472
1472
|
"\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n id\n title\n handle\n }\n }\n }\n }\n";
|
|
1473
1473
|
|
|
1474
|
+
/*
|
|
1475
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1476
|
+
Changes: Added query by product id
|
|
1477
|
+
*/
|
|
1478
|
+
var productFieldsFragment = "\n fragment productFields on Product {\n id\n handle\n availableForSale\n title\n productType\n vendor\n description\n descriptionHtml\n options {\n id\n name\n values\n }\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n sku\n availableForSale\n requiresShipping\n selectedOptions {\n name\n value\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n }\n }\n }\n images(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n originalSrc\n altText\n width\n height\n }\n }\n }\n }\n";
|
|
1479
|
+
var getProductQueryBySlug =
|
|
1480
|
+
/* GraphQL */
|
|
1481
|
+
"\n query getProductBySlug($slug: String!) {\n productByHandle(handle: $slug) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1482
|
+
var getProductQueryById =
|
|
1483
|
+
/* GraphQL */
|
|
1484
|
+
"\n query getProductById($id: ID!) {\n product(id: $id) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1485
|
+
|
|
1474
1486
|
/*
|
|
1475
1487
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1476
1488
|
Changes:
|
|
@@ -1478,7 +1490,7 @@ var getSiteCollectionsQuery =
|
|
|
1478
1490
|
*/
|
|
1479
1491
|
var productConnectionFragment =
|
|
1480
1492
|
/* GraphQL */
|
|
1481
|
-
"\n fragment productConnection on ProductConnection {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n vendor\n handle\n description\n descriptionHtml\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n options {\n id\n name\n values\n }\n variants(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n sku\n availableForSale\n requiresShipping\n selectedOptions {\n name\n value\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n }\n }\n }\n images(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n originalSrc\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n";
|
|
1493
|
+
"\n fragment productConnection on ProductConnection {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n handle\n title\n vendor\n handle\n description\n descriptionHtml\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n options {\n id\n name\n values\n }\n variants(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n sku\n availableForSale\n requiresShipping\n selectedOptions {\n name\n value\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n }\n }\n }\n images(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n originalSrc\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n";
|
|
1482
1494
|
var getAllProductsQuery =
|
|
1483
1495
|
/* GraphQL */
|
|
1484
1496
|
"\n query getAllProducts(\n $first: Int = 250\n $query: String = \"\"\n $sortKey: ProductSortKeys = RELEVANCE\n $reverse: Boolean = false\n ) {\n products(\n first: $first\n sortKey: $sortKey\n reverse: $reverse\n query: $query\n ) {\n ...productConnection\n }\n }\n\n " + productConnectionFragment + "\n";
|
|
@@ -1613,6 +1625,94 @@ var handler = {
|
|
|
1613
1625
|
};
|
|
1614
1626
|
|
|
1615
1627
|
var handler$1 = {
|
|
1628
|
+
fetchOptions: {
|
|
1629
|
+
query: getProductQueryBySlug
|
|
1630
|
+
},
|
|
1631
|
+
fetcher: function fetcher(_ref) {
|
|
1632
|
+
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1633
|
+
var input, options, fetch, id, product, data, _data;
|
|
1634
|
+
|
|
1635
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1636
|
+
while (1) {
|
|
1637
|
+
switch (_context.prev = _context.next) {
|
|
1638
|
+
case 0:
|
|
1639
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1640
|
+
id = input.id;
|
|
1641
|
+
|
|
1642
|
+
if (id) {
|
|
1643
|
+
_context.next = 4;
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
return _context.abrupt("return", null);
|
|
1648
|
+
|
|
1649
|
+
case 4:
|
|
1650
|
+
product = null;
|
|
1651
|
+
|
|
1652
|
+
if (!id.startsWith("gid://shopify")) {
|
|
1653
|
+
_context.next = 12;
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
_context.next = 8;
|
|
1658
|
+
return fetch({
|
|
1659
|
+
query: getProductQueryById,
|
|
1660
|
+
variables: {
|
|
1661
|
+
id: id
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
|
|
1665
|
+
case 8:
|
|
1666
|
+
data = _context.sent;
|
|
1667
|
+
product = data.product;
|
|
1668
|
+
_context.next = 16;
|
|
1669
|
+
break;
|
|
1670
|
+
|
|
1671
|
+
case 12:
|
|
1672
|
+
_context.next = 14;
|
|
1673
|
+
return fetch({
|
|
1674
|
+
query: options.query,
|
|
1675
|
+
variables: {
|
|
1676
|
+
slug: id
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
|
|
1680
|
+
case 14:
|
|
1681
|
+
_data = _context.sent;
|
|
1682
|
+
|
|
1683
|
+
if (_data.productByHandle) {
|
|
1684
|
+
product = _data.productByHandle;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
case 16:
|
|
1688
|
+
return _context.abrupt("return", product ? normalizeProduct(product) : null);
|
|
1689
|
+
|
|
1690
|
+
case 17:
|
|
1691
|
+
case "end":
|
|
1692
|
+
return _context.stop();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}, _callee);
|
|
1696
|
+
}))();
|
|
1697
|
+
},
|
|
1698
|
+
useHook: function useHook(_ref2) {
|
|
1699
|
+
var useData = _ref2.useData;
|
|
1700
|
+
return function (input) {
|
|
1701
|
+
if (input === void 0) {
|
|
1702
|
+
input = {};
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return useData({
|
|
1706
|
+
input: [['id', input.id]],
|
|
1707
|
+
swrOptions: _extends({
|
|
1708
|
+
revalidateOnFocus: false
|
|
1709
|
+
}, input.swrOptions)
|
|
1710
|
+
});
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
var handler$2 = {
|
|
1616
1716
|
fetchOptions: {
|
|
1617
1717
|
query: getCheckoutQuery
|
|
1618
1718
|
},
|
|
@@ -1691,7 +1791,7 @@ var handler$1 = {
|
|
|
1691
1791
|
}
|
|
1692
1792
|
};
|
|
1693
1793
|
|
|
1694
|
-
var handler$
|
|
1794
|
+
var handler$3 = {
|
|
1695
1795
|
fetchOptions: {
|
|
1696
1796
|
query: checkoutLineItemAddMutation
|
|
1697
1797
|
},
|
|
@@ -1802,7 +1902,7 @@ var handler$2 = {
|
|
|
1802
1902
|
}
|
|
1803
1903
|
};
|
|
1804
1904
|
|
|
1805
|
-
var handler$
|
|
1905
|
+
var handler$4 = {
|
|
1806
1906
|
fetchOptions: {
|
|
1807
1907
|
query: checkoutLineItemRemoveMutation
|
|
1808
1908
|
},
|
|
@@ -1901,7 +2001,7 @@ var handler$3 = {
|
|
|
1901
2001
|
}
|
|
1902
2002
|
};
|
|
1903
2003
|
|
|
1904
|
-
var handler$
|
|
2004
|
+
var handler$5 = {
|
|
1905
2005
|
fetchOptions: {
|
|
1906
2006
|
query: checkoutLineItemUpdateMutation
|
|
1907
2007
|
},
|
|
@@ -1925,8 +2025,8 @@ var handler$4 = {
|
|
|
1925
2025
|
break;
|
|
1926
2026
|
}
|
|
1927
2027
|
|
|
1928
|
-
return _context.abrupt("return", handler$
|
|
1929
|
-
options: handler$
|
|
2028
|
+
return _context.abrupt("return", handler$4.fetcher({
|
|
2029
|
+
options: handler$4.fetchOptions,
|
|
1930
2030
|
input: {
|
|
1931
2031
|
itemId: itemId
|
|
1932
2032
|
},
|
|
@@ -2046,7 +2146,7 @@ var handler$4 = {
|
|
|
2046
2146
|
}
|
|
2047
2147
|
};
|
|
2048
2148
|
|
|
2049
|
-
var handler$
|
|
2149
|
+
var handler$6 = {
|
|
2050
2150
|
fetchOptions: {
|
|
2051
2151
|
query: getSiteCollectionsQuery
|
|
2052
2152
|
},
|
|
@@ -2108,7 +2208,7 @@ var handler$5 = {
|
|
|
2108
2208
|
}
|
|
2109
2209
|
};
|
|
2110
2210
|
|
|
2111
|
-
var handler$
|
|
2211
|
+
var handler$7 = {
|
|
2112
2212
|
fetchOptions: {
|
|
2113
2213
|
query: getAllProductVendors
|
|
2114
2214
|
},
|
|
@@ -2185,7 +2285,7 @@ var getFetcher = function getFetcher(storeDomain, accessToken) {
|
|
|
2185
2285
|
while (1) {
|
|
2186
2286
|
switch (_context.prev = _context.next) {
|
|
2187
2287
|
case 0:
|
|
2188
|
-
_ref$url = _ref.url, url = _ref$url === void 0 ? "https://" + storeDomain + "/api/
|
|
2288
|
+
_ref$url = _ref.url, url = _ref$url === void 0 ? "https://" + storeDomain + "/api/2022-04/graphql.json" : _ref$url, _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, variables = _ref.variables, query = _ref.query;
|
|
2189
2289
|
_ref3 = variables != null ? variables : {}, locale = _ref3.locale, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
2190
2290
|
_context.t0 = handleFetchResponse;
|
|
2191
2291
|
_context.next = 5;
|
|
@@ -2232,18 +2332,19 @@ var getShopifyProvider = function getShopifyProvider(storeDomain, accessToken) {
|
|
|
2232
2332
|
locale: 'en-us',
|
|
2233
2333
|
cartCookie: SHOPIFY_CHECKOUT_ID_COOKIE,
|
|
2234
2334
|
cart: {
|
|
2235
|
-
useCart: handler$
|
|
2236
|
-
useAddItem: handler$
|
|
2237
|
-
useUpdateItem: handler$
|
|
2238
|
-
useRemoveItem: handler$
|
|
2335
|
+
useCart: handler$2,
|
|
2336
|
+
useAddItem: handler$3,
|
|
2337
|
+
useUpdateItem: handler$5,
|
|
2338
|
+
useRemoveItem: handler$4
|
|
2239
2339
|
},
|
|
2240
2340
|
fetcher: getFetcher(storeDomain, accessToken),
|
|
2241
2341
|
products: {
|
|
2242
|
-
useSearch: handler
|
|
2342
|
+
useSearch: handler,
|
|
2343
|
+
useProduct: handler$1
|
|
2243
2344
|
},
|
|
2244
2345
|
site: {
|
|
2245
|
-
useCategories: handler$
|
|
2246
|
-
useBrands: handler$
|
|
2346
|
+
useCategories: handler$6,
|
|
2347
|
+
useBrands: handler$7
|
|
2247
2348
|
}
|
|
2248
2349
|
};
|
|
2249
2350
|
};
|
|
@@ -2267,6 +2368,7 @@ var commerceProviderMeta = {
|
|
|
2267
2368
|
storeDomain: "string",
|
|
2268
2369
|
accessToken: "string"
|
|
2269
2370
|
},
|
|
2371
|
+
description: "Your store domain should look like **storename.myshopify.com**.\n For your access token, get it by following [this video](https://www.youtube.com/watch?v=wB_6cM7tdv4).",
|
|
2270
2372
|
importPath: "commerce-providers/shopify",
|
|
2271
2373
|
importName: "ShopifyProvider"
|
|
2272
2374
|
};
|