@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
|
@@ -1412,12 +1412,14 @@ export const normalizePages = (edges: PageEdge[], locale?: string): Page[] =>
|
|
|
1412
1412
|
var normalizeCategory = function normalizeCategory(_ref10) {
|
|
1413
1413
|
var name = _ref10.title,
|
|
1414
1414
|
handle = _ref10.handle,
|
|
1415
|
-
id = _ref10.id
|
|
1415
|
+
id = _ref10.id,
|
|
1416
|
+
products = _ref10.products;
|
|
1416
1417
|
return {
|
|
1417
1418
|
id: id,
|
|
1418
1419
|
name: name,
|
|
1419
1420
|
slug: handle,
|
|
1420
|
-
path: "/" + handle
|
|
1421
|
+
path: "/" + handle,
|
|
1422
|
+
isEmpty: products.edges.length === 0
|
|
1421
1423
|
};
|
|
1422
1424
|
};
|
|
1423
1425
|
|
|
@@ -1463,13 +1465,32 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
|
1463
1465
|
return normalizeCart(checkoutPayload == null ? void 0 : checkoutPayload.checkout);
|
|
1464
1466
|
};
|
|
1465
1467
|
|
|
1468
|
+
var simpleProductConnection = "\nfragment simpleProductConnection on ProductConnection {\n edges {\n node {\n id\n }\n }\n}\n";
|
|
1469
|
+
var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle,\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
|
|
1470
|
+
var getCollectionQueryById =
|
|
1471
|
+
/* GraphQL */
|
|
1472
|
+
"\n query getSiteCollection($id: ID!, $first: Int = 1) {\n collection(id: $id) {\n ...collectionFieldsFragment\n }\n }\n " + collectionFieldsFragment + "\n";
|
|
1473
|
+
|
|
1466
1474
|
/*
|
|
1467
1475
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1468
1476
|
Changes: None
|
|
1469
1477
|
*/
|
|
1478
|
+
|
|
1470
1479
|
var getSiteCollectionsQuery =
|
|
1471
1480
|
/* GraphQL */
|
|
1472
|
-
"\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n
|
|
1481
|
+
"\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n ...collectionFieldsFragment\n }\n }\n }\n }\n\n " + collectionFieldsFragment + "\n";
|
|
1482
|
+
|
|
1483
|
+
/*
|
|
1484
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
1485
|
+
Changes: Added query by product id
|
|
1486
|
+
*/
|
|
1487
|
+
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";
|
|
1488
|
+
var getProductQueryBySlug =
|
|
1489
|
+
/* GraphQL */
|
|
1490
|
+
"\n query getProductBySlug($slug: String!) {\n productByHandle(handle: $slug) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1491
|
+
var getProductQueryById =
|
|
1492
|
+
/* GraphQL */
|
|
1493
|
+
"\n query getProductById($id: ID!) {\n product(id: $id) {\n ...productFields\n }\n }\n\n " + productFieldsFragment + "\n";
|
|
1473
1494
|
|
|
1474
1495
|
/*
|
|
1475
1496
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
@@ -1478,7 +1499,7 @@ var getSiteCollectionsQuery =
|
|
|
1478
1499
|
*/
|
|
1479
1500
|
var productConnectionFragment =
|
|
1480
1501
|
/* 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";
|
|
1502
|
+
"\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
1503
|
var getAllProductsQuery =
|
|
1483
1504
|
/* GraphQL */
|
|
1484
1505
|
"\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 +1634,94 @@ var handler = {
|
|
|
1613
1634
|
};
|
|
1614
1635
|
|
|
1615
1636
|
var handler$1 = {
|
|
1637
|
+
fetchOptions: {
|
|
1638
|
+
query: getProductQueryBySlug
|
|
1639
|
+
},
|
|
1640
|
+
fetcher: function fetcher(_ref) {
|
|
1641
|
+
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1642
|
+
var input, options, fetch, id, product, data, _data;
|
|
1643
|
+
|
|
1644
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1645
|
+
while (1) {
|
|
1646
|
+
switch (_context.prev = _context.next) {
|
|
1647
|
+
case 0:
|
|
1648
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
1649
|
+
id = input.id;
|
|
1650
|
+
|
|
1651
|
+
if (id) {
|
|
1652
|
+
_context.next = 4;
|
|
1653
|
+
break;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
return _context.abrupt("return", null);
|
|
1657
|
+
|
|
1658
|
+
case 4:
|
|
1659
|
+
product = null;
|
|
1660
|
+
|
|
1661
|
+
if (!id.startsWith("gid://shopify")) {
|
|
1662
|
+
_context.next = 12;
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
_context.next = 8;
|
|
1667
|
+
return fetch({
|
|
1668
|
+
query: getProductQueryById,
|
|
1669
|
+
variables: {
|
|
1670
|
+
id: id
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
case 8:
|
|
1675
|
+
data = _context.sent;
|
|
1676
|
+
product = data.product;
|
|
1677
|
+
_context.next = 16;
|
|
1678
|
+
break;
|
|
1679
|
+
|
|
1680
|
+
case 12:
|
|
1681
|
+
_context.next = 14;
|
|
1682
|
+
return fetch({
|
|
1683
|
+
query: options.query,
|
|
1684
|
+
variables: {
|
|
1685
|
+
slug: id
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
|
|
1689
|
+
case 14:
|
|
1690
|
+
_data = _context.sent;
|
|
1691
|
+
|
|
1692
|
+
if (_data.productByHandle) {
|
|
1693
|
+
product = _data.productByHandle;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
case 16:
|
|
1697
|
+
return _context.abrupt("return", product ? normalizeProduct(product) : null);
|
|
1698
|
+
|
|
1699
|
+
case 17:
|
|
1700
|
+
case "end":
|
|
1701
|
+
return _context.stop();
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}, _callee);
|
|
1705
|
+
}))();
|
|
1706
|
+
},
|
|
1707
|
+
useHook: function useHook(_ref2) {
|
|
1708
|
+
var useData = _ref2.useData;
|
|
1709
|
+
return function (input) {
|
|
1710
|
+
if (input === void 0) {
|
|
1711
|
+
input = {};
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
return useData({
|
|
1715
|
+
input: [['id', input.id]],
|
|
1716
|
+
swrOptions: _extends({
|
|
1717
|
+
revalidateOnFocus: false
|
|
1718
|
+
}, input.swrOptions)
|
|
1719
|
+
});
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1724
|
+
var handler$2 = {
|
|
1616
1725
|
fetchOptions: {
|
|
1617
1726
|
query: getCheckoutQuery
|
|
1618
1727
|
},
|
|
@@ -1691,7 +1800,7 @@ var handler$1 = {
|
|
|
1691
1800
|
}
|
|
1692
1801
|
};
|
|
1693
1802
|
|
|
1694
|
-
var handler$
|
|
1803
|
+
var handler$3 = {
|
|
1695
1804
|
fetchOptions: {
|
|
1696
1805
|
query: checkoutLineItemAddMutation
|
|
1697
1806
|
},
|
|
@@ -1802,7 +1911,7 @@ var handler$2 = {
|
|
|
1802
1911
|
}
|
|
1803
1912
|
};
|
|
1804
1913
|
|
|
1805
|
-
var handler$
|
|
1914
|
+
var handler$4 = {
|
|
1806
1915
|
fetchOptions: {
|
|
1807
1916
|
query: checkoutLineItemRemoveMutation
|
|
1808
1917
|
},
|
|
@@ -1901,7 +2010,7 @@ var handler$3 = {
|
|
|
1901
2010
|
}
|
|
1902
2011
|
};
|
|
1903
2012
|
|
|
1904
|
-
var handler$
|
|
2013
|
+
var handler$5 = {
|
|
1905
2014
|
fetchOptions: {
|
|
1906
2015
|
query: checkoutLineItemUpdateMutation
|
|
1907
2016
|
},
|
|
@@ -1925,8 +2034,8 @@ var handler$4 = {
|
|
|
1925
2034
|
break;
|
|
1926
2035
|
}
|
|
1927
2036
|
|
|
1928
|
-
return _context.abrupt("return", handler$
|
|
1929
|
-
options: handler$
|
|
2037
|
+
return _context.abrupt("return", handler$4.fetcher({
|
|
2038
|
+
options: handler$4.fetchOptions,
|
|
1930
2039
|
input: {
|
|
1931
2040
|
itemId: itemId
|
|
1932
2041
|
},
|
|
@@ -2046,37 +2155,55 @@ var handler$4 = {
|
|
|
2046
2155
|
}
|
|
2047
2156
|
};
|
|
2048
2157
|
|
|
2049
|
-
var handler$
|
|
2158
|
+
var handler$6 = {
|
|
2050
2159
|
fetchOptions: {
|
|
2051
2160
|
query: getSiteCollectionsQuery
|
|
2052
2161
|
},
|
|
2053
2162
|
fetcher: function fetcher(_ref) {
|
|
2054
2163
|
return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2055
|
-
var _data$collections$edg, _data$collections, _data$collections$edg2;
|
|
2164
|
+
var input, options, fetch, categoryId, _data$collections$edg, _data$collections, _data$collections$edg2, data, _data;
|
|
2056
2165
|
|
|
2057
|
-
var fetch, data;
|
|
2058
2166
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2059
2167
|
while (1) {
|
|
2060
2168
|
switch (_context.prev = _context.next) {
|
|
2061
2169
|
case 0:
|
|
2062
|
-
fetch = _ref.fetch;
|
|
2063
|
-
|
|
2170
|
+
input = _ref.input, options = _ref.options, fetch = _ref.fetch;
|
|
2171
|
+
categoryId = input.categoryId;
|
|
2172
|
+
|
|
2173
|
+
if (categoryId) {
|
|
2174
|
+
_context.next = 9;
|
|
2175
|
+
break;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
_context.next = 5;
|
|
2064
2179
|
return fetch({
|
|
2065
|
-
query:
|
|
2180
|
+
query: options.query,
|
|
2066
2181
|
variables: {
|
|
2067
2182
|
first: 250
|
|
2068
2183
|
}
|
|
2069
2184
|
});
|
|
2070
2185
|
|
|
2071
|
-
case
|
|
2186
|
+
case 5:
|
|
2072
2187
|
data = _context.sent;
|
|
2073
|
-
|
|
2074
|
-
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) {
|
|
2188
|
+
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) {
|
|
2075
2189
|
var node = _ref2.node;
|
|
2076
2190
|
return normalizeCategory(node);
|
|
2077
2191
|
})) != null ? _data$collections$edg : []);
|
|
2078
2192
|
|
|
2079
|
-
case
|
|
2193
|
+
case 9:
|
|
2194
|
+
_context.next = 11;
|
|
2195
|
+
return fetch({
|
|
2196
|
+
query: getCollectionQueryById,
|
|
2197
|
+
variables: {
|
|
2198
|
+
id: categoryId
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
|
|
2202
|
+
case 11:
|
|
2203
|
+
_data = _context.sent;
|
|
2204
|
+
return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
|
|
2205
|
+
|
|
2206
|
+
case 13:
|
|
2080
2207
|
case "end":
|
|
2081
2208
|
return _context.stop();
|
|
2082
2209
|
}
|
|
@@ -2088,6 +2215,7 @@ var handler$5 = {
|
|
|
2088
2215
|
var useData = _ref3.useData;
|
|
2089
2216
|
return function (input) {
|
|
2090
2217
|
var response = useData({
|
|
2218
|
+
input: [['categoryId', input == null ? void 0 : input.categoryId]],
|
|
2091
2219
|
swrOptions: _extends({
|
|
2092
2220
|
revalidateOnFocus: false
|
|
2093
2221
|
}, input == null ? void 0 : input.swrOptions)
|
|
@@ -2108,7 +2236,7 @@ var handler$5 = {
|
|
|
2108
2236
|
}
|
|
2109
2237
|
};
|
|
2110
2238
|
|
|
2111
|
-
var handler$
|
|
2239
|
+
var handler$7 = {
|
|
2112
2240
|
fetchOptions: {
|
|
2113
2241
|
query: getAllProductVendors
|
|
2114
2242
|
},
|
|
@@ -2185,7 +2313,7 @@ var getFetcher = function getFetcher(storeDomain, accessToken) {
|
|
|
2185
2313
|
while (1) {
|
|
2186
2314
|
switch (_context.prev = _context.next) {
|
|
2187
2315
|
case 0:
|
|
2188
|
-
_ref$url = _ref.url, url = _ref$url === void 0 ? "https://" + storeDomain + "/api/
|
|
2316
|
+
_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
2317
|
_ref3 = variables != null ? variables : {}, locale = _ref3.locale, vars = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
2190
2318
|
_context.t0 = handleFetchResponse;
|
|
2191
2319
|
_context.next = 5;
|
|
@@ -2232,18 +2360,19 @@ var getShopifyProvider = function getShopifyProvider(storeDomain, accessToken) {
|
|
|
2232
2360
|
locale: 'en-us',
|
|
2233
2361
|
cartCookie: SHOPIFY_CHECKOUT_ID_COOKIE,
|
|
2234
2362
|
cart: {
|
|
2235
|
-
useCart: handler$
|
|
2236
|
-
useAddItem: handler$
|
|
2237
|
-
useUpdateItem: handler$
|
|
2238
|
-
useRemoveItem: handler$
|
|
2363
|
+
useCart: handler$2,
|
|
2364
|
+
useAddItem: handler$3,
|
|
2365
|
+
useUpdateItem: handler$5,
|
|
2366
|
+
useRemoveItem: handler$4
|
|
2239
2367
|
},
|
|
2240
2368
|
fetcher: getFetcher(storeDomain, accessToken),
|
|
2241
2369
|
products: {
|
|
2242
|
-
useSearch: handler
|
|
2370
|
+
useSearch: handler,
|
|
2371
|
+
useProduct: handler$1
|
|
2243
2372
|
},
|
|
2244
2373
|
site: {
|
|
2245
|
-
useCategories: handler$
|
|
2246
|
-
useBrands: handler$
|
|
2374
|
+
useCategories: handler$6,
|
|
2375
|
+
useBrands: handler$7
|
|
2247
2376
|
}
|
|
2248
2377
|
};
|
|
2249
2378
|
};
|
|
@@ -2267,6 +2396,7 @@ var commerceProviderMeta = {
|
|
|
2267
2396
|
storeDomain: "string",
|
|
2268
2397
|
accessToken: "string"
|
|
2269
2398
|
},
|
|
2399
|
+
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
2400
|
importPath: "commerce-providers/shopify",
|
|
2271
2401
|
importName: "ShopifyProvider"
|
|
2272
2402
|
};
|