@plasmicpkgs/commerce-shopify 0.0.8 → 0.0.11
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 +158 -28
- 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 +158 -28
- 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/normalize.d.ts +1 -1
- package/dist/utils/queries/get-all-collections-query.d.ts +1 -1
- package/dist/utils/queries/get-all-products-query.d.ts +1 -1
- package/dist/utils/queries/get-collection-query.d.ts +3 -0
- package/dist/utils/queries/get-product-query.d.ts +3 -2
- package/package.json +4 -4
|
@@ -1405,12 +1405,14 @@ export const normalizePages = (edges: PageEdge[], locale?: string): Page[] =>
|
|
|
1405
1405
|
var normalizeCategory = function normalizeCategory(_ref10) {
|
|
1406
1406
|
var name = _ref10.title,
|
|
1407
1407
|
handle = _ref10.handle,
|
|
1408
|
-
id = _ref10.id
|
|
1408
|
+
id = _ref10.id,
|
|
1409
|
+
products = _ref10.products;
|
|
1409
1410
|
return {
|
|
1410
1411
|
id: id,
|
|
1411
1412
|
name: name,
|
|
1412
1413
|
slug: handle,
|
|
1413
|
-
path: "/" + handle
|
|
1414
|
+
path: "/" + handle,
|
|
1415
|
+
isEmpty: products.edges.length === 0
|
|
1414
1416
|
};
|
|
1415
1417
|
};
|
|
1416
1418
|
|
|
@@ -1456,13 +1458,32 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
|
1456
1458
|
return normalizeCart(checkoutPayload == null ? void 0 : checkoutPayload.checkout);
|
|
1457
1459
|
};
|
|
1458
1460
|
|
|
1461
|
+
var simpleProductConnection = "\nfragment simpleProductConnection on ProductConnection {\n edges {\n node {\n id\n }\n }\n}\n";
|
|
1462
|
+
var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle,\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
|
|
1463
|
+
var getCollectionQueryById =
|
|
1464
|
+
/* GraphQL */
|
|
1465
|
+
"\n query getSiteCollection($id: ID!, $first: Int = 1) {\n collection(id: $id) {\n ...collectionFieldsFragment\n }\n }\n " + collectionFieldsFragment + "\n";
|
|
1466
|
+
|
|
1459
1467
|
/*
|
|
1460
1468
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1461
1469
|
Changes: None
|
|
1462
1470
|
*/
|
|
1471
|
+
|
|
1463
1472
|
var getSiteCollectionsQuery =
|
|
1464
1473
|
/* GraphQL */
|
|
1465
|
-
"\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n
|
|
1474
|
+
"\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n ...collectionFieldsFragment\n }\n }\n }\n }\n\n " + collectionFieldsFragment + "\n";
|
|
1475
|
+
|
|
1476
|
+
/*
|
|
1477
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1478
|
+
Changes: Added query by product id
|
|
1479
|
+
*/
|
|
1480
|
+
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";
|
|
1481
|
+
var getProductQueryBySlug =
|
|
1482
|
+
/* GraphQL */
|
|
1483
|
+
"\n query getProductBySlug($slug: String!) {\n productByHandle(handle: $slug) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1484
|
+
var getProductQueryById =
|
|
1485
|
+
/* GraphQL */
|
|
1486
|
+
"\n query getProductById($id: ID!) {\n product(id: $id) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1466
1487
|
|
|
1467
1488
|
/*
|
|
1468
1489
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
@@ -1471,7 +1492,7 @@ var getSiteCollectionsQuery =
|
|
|
1471
1492
|
*/
|
|
1472
1493
|
var productConnectionFragment =
|
|
1473
1494
|
/* GraphQL */
|
|
1474
|
-
"\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";
|
|
1495
|
+
"\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";
|
|
1475
1496
|
var getAllProductsQuery =
|
|
1476
1497
|
/* GraphQL */
|
|
1477
1498
|
"\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";
|
|
@@ -1606,6 +1627,94 @@ var handler = {
|
|
|
1606
1627
|
};
|
|
1607
1628
|
|
|
1608
1629
|
var handler$1 = {
|
|
1630
|
+
fetchOptions: {
|
|
1631
|
+
query: getProductQueryBySlug
|
|
1632
|
+
},
|
|
1633
|
+
fetcher: function fetcher(_ref) {
|
|
1634
|
+
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1635
|
+
var input, options, fetch, id, product, data, _data;
|
|
1636
|
+
|
|
1637
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1638
|
+
while (1) {
|
|
1639
|
+
switch (_context.prev = _context.next) {
|
|
1640
|
+
case 0:
|
|
1641
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1642
|
+
id = input.id;
|
|
1643
|
+
|
|
1644
|
+
if (id) {
|
|
1645
|
+
_context.next = 4;
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
return _context.abrupt("return", null);
|
|
1650
|
+
|
|
1651
|
+
case 4:
|
|
1652
|
+
product = null;
|
|
1653
|
+
|
|
1654
|
+
if (!id.startsWith("gid://shopify")) {
|
|
1655
|
+
_context.next = 12;
|
|
1656
|
+
break;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
_context.next = 8;
|
|
1660
|
+
return fetch({
|
|
1661
|
+
query: getProductQueryById,
|
|
1662
|
+
variables: {
|
|
1663
|
+
id: id
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
|
|
1667
|
+
case 8:
|
|
1668
|
+
data = _context.sent;
|
|
1669
|
+
product = data.product;
|
|
1670
|
+
_context.next = 16;
|
|
1671
|
+
break;
|
|
1672
|
+
|
|
1673
|
+
case 12:
|
|
1674
|
+
_context.next = 14;
|
|
1675
|
+
return fetch({
|
|
1676
|
+
query: options.query,
|
|
1677
|
+
variables: {
|
|
1678
|
+
slug: id
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
|
|
1682
|
+
case 14:
|
|
1683
|
+
_data = _context.sent;
|
|
1684
|
+
|
|
1685
|
+
if (_data.productByHandle) {
|
|
1686
|
+
product = _data.productByHandle;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
case 16:
|
|
1690
|
+
return _context.abrupt("return", product ? normalizeProduct(product) : null);
|
|
1691
|
+
|
|
1692
|
+
case 17:
|
|
1693
|
+
case "end":
|
|
1694
|
+
return _context.stop();
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}, _callee);
|
|
1698
|
+
}))();
|
|
1699
|
+
},
|
|
1700
|
+
useHook: function useHook(_ref2) {
|
|
1701
|
+
var useData = _ref2.useData;
|
|
1702
|
+
return function (input) {
|
|
1703
|
+
if (input === void 0) {
|
|
1704
|
+
input = {};
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
return useData({
|
|
1708
|
+
input: [['id', input.id]],
|
|
1709
|
+
swrOptions: _extends({
|
|
1710
|
+
revalidateOnFocus: false
|
|
1711
|
+
}, input.swrOptions)
|
|
1712
|
+
});
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
|
|
1717
|
+
var handler$2 = {
|
|
1609
1718
|
fetchOptions: {
|
|
1610
1719
|
query: getCheckoutQuery
|
|
1611
1720
|
},
|
|
@@ -1684,7 +1793,7 @@ var handler$1 = {
|
|
|
1684
1793
|
}
|
|
1685
1794
|
};
|
|
1686
1795
|
|
|
1687
|
-
var handler$
|
|
1796
|
+
var handler$3 = {
|
|
1688
1797
|
fetchOptions: {
|
|
1689
1798
|
query: checkoutLineItemAddMutation
|
|
1690
1799
|
},
|
|
@@ -1795,7 +1904,7 @@ var handler$2 = {
|
|
|
1795
1904
|
}
|
|
1796
1905
|
};
|
|
1797
1906
|
|
|
1798
|
-
var handler$
|
|
1907
|
+
var handler$4 = {
|
|
1799
1908
|
fetchOptions: {
|
|
1800
1909
|
query: checkoutLineItemRemoveMutation
|
|
1801
1910
|
},
|
|
@@ -1894,7 +2003,7 @@ var handler$3 = {
|
|
|
1894
2003
|
}
|
|
1895
2004
|
};
|
|
1896
2005
|
|
|
1897
|
-
var handler$
|
|
2006
|
+
var handler$5 = {
|
|
1898
2007
|
fetchOptions: {
|
|
1899
2008
|
query: checkoutLineItemUpdateMutation
|
|
1900
2009
|
},
|
|
@@ -1918,8 +2027,8 @@ var handler$4 = {
|
|
|
1918
2027
|
break;
|
|
1919
2028
|
}
|
|
1920
2029
|
|
|
1921
|
-
return _context.abrupt("return", handler$
|
|
1922
|
-
options: handler$
|
|
2030
|
+
return _context.abrupt("return", handler$4.fetcher({
|
|
2031
|
+
options: handler$4.fetchOptions,
|
|
1923
2032
|
input: {
|
|
1924
2033
|
itemId: itemId
|
|
1925
2034
|
},
|
|
@@ -2039,37 +2148,55 @@ var handler$4 = {
|
|
|
2039
2148
|
}
|
|
2040
2149
|
};
|
|
2041
2150
|
|
|
2042
|
-
var handler$
|
|
2151
|
+
var handler$6 = {
|
|
2043
2152
|
fetchOptions: {
|
|
2044
2153
|
query: getSiteCollectionsQuery
|
|
2045
2154
|
},
|
|
2046
2155
|
fetcher: function fetcher(_ref) {
|
|
2047
2156
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2048
|
-
var _data$collections$edg, _data$collections, _data$collections$edg2;
|
|
2157
|
+
var input, options, fetch, categoryId, _data$collections$edg, _data$collections, _data$collections$edg2, data, _data;
|
|
2049
2158
|
|
|
2050
|
-
var fetch, data;
|
|
2051
2159
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2052
2160
|
while (1) {
|
|
2053
2161
|
switch (_context.prev = _context.next) {
|
|
2054
2162
|
case 0:
|
|
2055
|
-
fetch = _ref.fetch;
|
|
2056
|
-
|
|
2163
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
2164
|
+
categoryId = input.categoryId;
|
|
2165
|
+
|
|
2166
|
+
if (categoryId) {
|
|
2167
|
+
_context.next = 9;
|
|
2168
|
+
break;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
_context.next = 5;
|
|
2057
2172
|
return fetch({
|
|
2058
|
-
query:
|
|
2173
|
+
query: options.query,
|
|
2059
2174
|
variables: {
|
|
2060
2175
|
first: 250
|
|
2061
2176
|
}
|
|
2062
2177
|
});
|
|
2063
2178
|
|
|
2064
|
-
case
|
|
2179
|
+
case 5:
|
|
2065
2180
|
data = _context.sent;
|
|
2066
|
-
|
|
2067
|
-
return _context.abrupt("return", (_data$collections$edg = (_data$collections = data.collections) == null ? void 0 : (_data$collections$edg2 = _data$collections.edges) == null ? void 0 : _data$collections$edg2.map(function (_ref2) {
|
|
2181
|
+
return _context.abrupt("return", (_data$collections$edg = data == null ? void 0 : (_data$collections = data.collections) == null ? void 0 : (_data$collections$edg2 = _data$collections.edges) == null ? void 0 : _data$collections$edg2.map(function (_ref2) {
|
|
2068
2182
|
var node = _ref2.node;
|
|
2069
2183
|
return normalizeCategory(node);
|
|
2070
2184
|
})) != null ? _data$collections$edg : []);
|
|
2071
2185
|
|
|
2072
|
-
case
|
|
2186
|
+
case 9:
|
|
2187
|
+
_context.next = 11;
|
|
2188
|
+
return fetch({
|
|
2189
|
+
query: getCollectionQueryById,
|
|
2190
|
+
variables: {
|
|
2191
|
+
id: categoryId
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2195
|
+
case 11:
|
|
2196
|
+
_data = _context.sent;
|
|
2197
|
+
return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
|
|
2198
|
+
|
|
2199
|
+
case 13:
|
|
2073
2200
|
case "end":
|
|
2074
2201
|
return _context.stop();
|
|
2075
2202
|
}
|
|
@@ -2081,6 +2208,7 @@ var handler$5 = {
|
|
|
2081
2208
|
var useData = _ref3.useData;
|
|
2082
2209
|
return function (input) {
|
|
2083
2210
|
var response = useData({
|
|
2211
|
+
input: [['categoryId', input == null ? void 0 : input.categoryId]],
|
|
2084
2212
|
swrOptions: _extends({
|
|
2085
2213
|
revalidateOnFocus: false
|
|
2086
2214
|
}, input == null ? void 0 : input.swrOptions)
|
|
@@ -2101,7 +2229,7 @@ var handler$5 = {
|
|
|
2101
2229
|
}
|
|
2102
2230
|
};
|
|
2103
2231
|
|
|
2104
|
-
var handler$
|
|
2232
|
+
var handler$7 = {
|
|
2105
2233
|
fetchOptions: {
|
|
2106
2234
|
query: getAllProductVendors
|
|
2107
2235
|
},
|
|
@@ -2178,7 +2306,7 @@ var getFetcher = function getFetcher(storeDomain, accessToken) {
|
|
|
2178
2306
|
while (1) {
|
|
2179
2307
|
switch (_context.prev = _context.next) {
|
|
2180
2308
|
case 0:
|
|
2181
|
-
_ref$url = _ref.url, url = _ref$url === void 0 ? "https://" + storeDomain + "/api/
|
|
2309
|
+
_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;
|
|
2182
2310
|
_ref3 = variables != null ? variables : {}, locale = _ref3.locale, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
2183
2311
|
_context.t0 = handleFetchResponse;
|
|
2184
2312
|
_context.next = 5;
|
|
@@ -2225,18 +2353,19 @@ var getShopifyProvider = function getShopifyProvider(storeDomain, accessToken) {
|
|
|
2225
2353
|
locale: 'en-us',
|
|
2226
2354
|
cartCookie: SHOPIFY_CHECKOUT_ID_COOKIE,
|
|
2227
2355
|
cart: {
|
|
2228
|
-
useCart: handler$
|
|
2229
|
-
useAddItem: handler$
|
|
2230
|
-
useUpdateItem: handler$
|
|
2231
|
-
useRemoveItem: handler$
|
|
2356
|
+
useCart: handler$2,
|
|
2357
|
+
useAddItem: handler$3,
|
|
2358
|
+
useUpdateItem: handler$5,
|
|
2359
|
+
useRemoveItem: handler$4
|
|
2232
2360
|
},
|
|
2233
2361
|
fetcher: getFetcher(storeDomain, accessToken),
|
|
2234
2362
|
products: {
|
|
2235
|
-
useSearch: handler
|
|
2363
|
+
useSearch: handler,
|
|
2364
|
+
useProduct: handler$1
|
|
2236
2365
|
},
|
|
2237
2366
|
site: {
|
|
2238
|
-
useCategories: handler$
|
|
2239
|
-
useBrands: handler$
|
|
2367
|
+
useCategories: handler$6,
|
|
2368
|
+
useBrands: handler$7
|
|
2240
2369
|
}
|
|
2241
2370
|
};
|
|
2242
2371
|
};
|
|
@@ -2260,6 +2389,7 @@ var commerceProviderMeta = {
|
|
|
2260
2389
|
storeDomain: "string",
|
|
2261
2390
|
accessToken: "string"
|
|
2262
2391
|
},
|
|
2392
|
+
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).",
|
|
2263
2393
|
importPath: "commerce-providers/shopify",
|
|
2264
2394
|
importName: "ShopifyProvider"
|
|
2265
2395
|
};
|