@anker-in/shopify-sdk 1.2.0-beta.0 → 1.2.0-beta.10
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/index.d.mts +70 -3
- package/dist/index.d.ts +70 -3
- package/dist/index.js +172 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +171 -48
- package/dist/index.mjs.map +1 -1
- package/dist/queries/index.d.mts +6 -1
- package/dist/queries/index.d.ts +6 -1
- package/dist/queries/index.js +75 -0
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/index.mjs +75 -1
- package/dist/queries/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -927,6 +927,59 @@ var getCartQuery = (
|
|
|
927
927
|
`
|
|
928
928
|
);
|
|
929
929
|
|
|
930
|
+
// src/queries/collection/get-collections-by-handles.ts
|
|
931
|
+
var getCollectionsByHandlesQuery = (handles) => (
|
|
932
|
+
/* GraphQL */
|
|
933
|
+
`
|
|
934
|
+
${collectionFragment}
|
|
935
|
+
${productFragment}
|
|
936
|
+
${variantFragment}
|
|
937
|
+
${metafieldFragment}
|
|
938
|
+
${imageFragment}
|
|
939
|
+
${seoFragment}
|
|
940
|
+
|
|
941
|
+
query GetCollectionsByHandles(
|
|
942
|
+
$collectionMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
943
|
+
$productMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
944
|
+
$variantMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
945
|
+
) {
|
|
946
|
+
${handles.map(
|
|
947
|
+
(handle, index) => (
|
|
948
|
+
/* GraphQL */
|
|
949
|
+
`
|
|
950
|
+
collection_${index}: collection(handle: "${handle}") {
|
|
951
|
+
...collection
|
|
952
|
+
metafields(identifiers: $collectionMetafieldIdentifiers) {
|
|
953
|
+
...metafield
|
|
954
|
+
}
|
|
955
|
+
products(first: 9) {
|
|
956
|
+
edges {
|
|
957
|
+
node {
|
|
958
|
+
...product
|
|
959
|
+
metafields(identifiers: $productMetafieldIdentifiers) {
|
|
960
|
+
...metafield
|
|
961
|
+
}
|
|
962
|
+
variants(first: 10) {
|
|
963
|
+
edges {
|
|
964
|
+
node {
|
|
965
|
+
...variant
|
|
966
|
+
metafields(identifiers: $variantMetafieldIdentifiers) {
|
|
967
|
+
...metafield
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
`
|
|
977
|
+
)
|
|
978
|
+
).join("\n")}
|
|
979
|
+
}
|
|
980
|
+
`
|
|
981
|
+
);
|
|
982
|
+
|
|
930
983
|
// src/mutations/cart/create-cart.ts
|
|
931
984
|
var createCartMutation = (
|
|
932
985
|
/* GraphQL */
|
|
@@ -1249,13 +1302,14 @@ var getProductQuery2 = (
|
|
|
1249
1302
|
`
|
|
1250
1303
|
);
|
|
1251
1304
|
async function getProduct(client, options) {
|
|
1252
|
-
const { handle, metafieldIdentifiers } = options;
|
|
1305
|
+
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
1306
|
+
const query = graphqlQuery || getProductQuery2;
|
|
1253
1307
|
const variables = { handle };
|
|
1254
1308
|
if (metafieldIdentifiers) {
|
|
1255
1309
|
variables.productMetafieldIdentifiers = metafieldIdentifiers;
|
|
1256
1310
|
variables.variantMetafieldIdentifiers = metafieldIdentifiers;
|
|
1257
1311
|
}
|
|
1258
|
-
const data = await client.query(
|
|
1312
|
+
const data = await client.query(query, variables);
|
|
1259
1313
|
if (!data?.product) {
|
|
1260
1314
|
return void 0;
|
|
1261
1315
|
}
|
|
@@ -1310,7 +1364,8 @@ var getAllProductsQuery = (
|
|
|
1310
1364
|
`
|
|
1311
1365
|
);
|
|
1312
1366
|
async function fetchAllPages(client, options, afterCursor) {
|
|
1313
|
-
const { first = 250, query, sortKey, reverse, metafieldIdentifiers } = options;
|
|
1367
|
+
const { first = 250, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
1368
|
+
const queryString = graphqlQuery || getAllProductsQuery;
|
|
1314
1369
|
const variables = {
|
|
1315
1370
|
first,
|
|
1316
1371
|
after: afterCursor,
|
|
@@ -1322,7 +1377,7 @@ async function fetchAllPages(client, options, afterCursor) {
|
|
|
1322
1377
|
variables.productMetafieldIdentifiers = metafieldIdentifiers;
|
|
1323
1378
|
variables.variantMetafieldIdentifiers = metafieldIdentifiers;
|
|
1324
1379
|
}
|
|
1325
|
-
const data = await client.query(
|
|
1380
|
+
const data = await client.query(queryString, variables);
|
|
1326
1381
|
if (!data || !data.products) {
|
|
1327
1382
|
return [];
|
|
1328
1383
|
}
|
|
@@ -1337,7 +1392,8 @@ async function getAllProducts(client, options) {
|
|
|
1337
1392
|
return fetchAllPages(client, options);
|
|
1338
1393
|
}
|
|
1339
1394
|
async function getProducts(client, options) {
|
|
1340
|
-
const { first = 250, after, query, sortKey, reverse, metafieldIdentifiers } = options;
|
|
1395
|
+
const { first = 250, after, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
1396
|
+
const queryString = graphqlQuery || getAllProductsQuery;
|
|
1341
1397
|
const variables = {
|
|
1342
1398
|
first,
|
|
1343
1399
|
after,
|
|
@@ -1349,7 +1405,7 @@ async function getProducts(client, options) {
|
|
|
1349
1405
|
variables.productMetafieldIdentifiers = metafieldIdentifiers;
|
|
1350
1406
|
variables.variantMetafieldIdentifiers = metafieldIdentifiers;
|
|
1351
1407
|
}
|
|
1352
|
-
const data = await client.query(
|
|
1408
|
+
const data = await client.query(queryString, variables);
|
|
1353
1409
|
if (!data || !data.products) {
|
|
1354
1410
|
return {
|
|
1355
1411
|
products: [],
|
|
@@ -1399,11 +1455,11 @@ function buildProductsByHandlesQuery(handles) {
|
|
|
1399
1455
|
);
|
|
1400
1456
|
}
|
|
1401
1457
|
async function getProductsByHandles(client, options) {
|
|
1402
|
-
const { handles, metafieldIdentifiers } = options;
|
|
1458
|
+
const { handles, graphqlQuery, metafieldIdentifiers } = options;
|
|
1403
1459
|
if (!handles || handles.length === 0) {
|
|
1404
1460
|
return [];
|
|
1405
1461
|
}
|
|
1406
|
-
const query = buildProductsByHandlesQuery(handles);
|
|
1462
|
+
const query = graphqlQuery || buildProductsByHandlesQuery(handles);
|
|
1407
1463
|
const data = await client.query(query, {
|
|
1408
1464
|
handles,
|
|
1409
1465
|
// 请勿删除,这个参数虽然没有在 query 中使用,但方便在 chrome dev tools 中查看请求参数
|
|
@@ -1415,7 +1471,12 @@ async function getProductsByHandles(client, options) {
|
|
|
1415
1471
|
if (!data) {
|
|
1416
1472
|
return [];
|
|
1417
1473
|
}
|
|
1418
|
-
return Object.
|
|
1474
|
+
return Object.values(data).map((item) => {
|
|
1475
|
+
if (item) {
|
|
1476
|
+
return normalizeProduct(item);
|
|
1477
|
+
}
|
|
1478
|
+
return void 0;
|
|
1479
|
+
});
|
|
1419
1480
|
}
|
|
1420
1481
|
|
|
1421
1482
|
// src/api/cart/normalize.ts
|
|
@@ -1519,7 +1580,8 @@ function normalizeCart(cart) {
|
|
|
1519
1580
|
|
|
1520
1581
|
// src/api/cart/get-cart.ts
|
|
1521
1582
|
async function getCart(client, options) {
|
|
1522
|
-
const { id, cookieAdapter, metafieldIdentifiers } = options;
|
|
1583
|
+
const { id, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1584
|
+
const query = graphqlQuery || getCartQuery;
|
|
1523
1585
|
const locale = client.getLocale();
|
|
1524
1586
|
const cartId = id || cookieAdapter?.getCartId(locale);
|
|
1525
1587
|
console.log("cartId", cartId);
|
|
@@ -1527,7 +1589,7 @@ async function getCart(client, options) {
|
|
|
1527
1589
|
return void 0;
|
|
1528
1590
|
}
|
|
1529
1591
|
try {
|
|
1530
|
-
const data = await client.query(
|
|
1592
|
+
const data = await client.query(query, {
|
|
1531
1593
|
cartId,
|
|
1532
1594
|
...constructMetafieldIdentifiersQueryParams(
|
|
1533
1595
|
metafieldIdentifiers,
|
|
@@ -1562,12 +1624,14 @@ async function createCart(client, options = {}) {
|
|
|
1562
1624
|
buyerIdentity,
|
|
1563
1625
|
discountCodes,
|
|
1564
1626
|
customAttributes,
|
|
1627
|
+
graphqlQuery,
|
|
1565
1628
|
metafieldIdentifiers,
|
|
1566
1629
|
updateCookie = false
|
|
1567
1630
|
} = options;
|
|
1631
|
+
const query = graphqlQuery || createCartMutation;
|
|
1568
1632
|
const locale = client.getLocale();
|
|
1569
1633
|
try {
|
|
1570
|
-
const data = await client.query(
|
|
1634
|
+
const data = await client.query(query, {
|
|
1571
1635
|
lines,
|
|
1572
1636
|
buyerIdentity,
|
|
1573
1637
|
discountCodes,
|
|
@@ -1597,7 +1661,8 @@ async function createCart(client, options = {}) {
|
|
|
1597
1661
|
|
|
1598
1662
|
// src/api/cart/add-cart-lines.ts
|
|
1599
1663
|
async function addCartLines(client, options) {
|
|
1600
|
-
const { cartId: providedCartId, lines, cookieAdapter, metafieldIdentifiers } = options;
|
|
1664
|
+
const { cartId: providedCartId, lines, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1665
|
+
const query = graphqlQuery || addCartItemsMutation;
|
|
1601
1666
|
const locale = client.getLocale();
|
|
1602
1667
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1603
1668
|
if (!cartId) {
|
|
@@ -1608,7 +1673,7 @@ async function addCartLines(client, options) {
|
|
|
1608
1673
|
client.getConfig().getMetafieldNamespacePrefix()
|
|
1609
1674
|
);
|
|
1610
1675
|
try {
|
|
1611
|
-
const data = await client.query(
|
|
1676
|
+
const data = await client.query(query, {
|
|
1612
1677
|
cartId,
|
|
1613
1678
|
lines,
|
|
1614
1679
|
...normalizedMetafieldIdentifiers
|
|
@@ -1633,7 +1698,8 @@ async function addCartLines(client, options) {
|
|
|
1633
1698
|
|
|
1634
1699
|
// src/api/cart/update-cart-lines.ts
|
|
1635
1700
|
async function updateCartLines(client, options) {
|
|
1636
|
-
const { cartId: providedCartId, lines, cookieAdapter, metafieldIdentifiers } = options;
|
|
1701
|
+
const { cartId: providedCartId, lines, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1702
|
+
const query = graphqlQuery || updateCartItemsMutation;
|
|
1637
1703
|
const locale = client.getLocale();
|
|
1638
1704
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1639
1705
|
if (!cartId) {
|
|
@@ -1646,7 +1712,7 @@ async function updateCartLines(client, options) {
|
|
|
1646
1712
|
console.log("update-cart-lines metafieldIdentifiers:", metafieldIdentifiers);
|
|
1647
1713
|
console.log("update-cart-lines metafieldParams:", metafieldParams);
|
|
1648
1714
|
try {
|
|
1649
|
-
const data = await client.query(
|
|
1715
|
+
const data = await client.query(query, {
|
|
1650
1716
|
cartId,
|
|
1651
1717
|
lines,
|
|
1652
1718
|
...metafieldParams
|
|
@@ -1680,14 +1746,15 @@ async function updateCartLines(client, options) {
|
|
|
1680
1746
|
|
|
1681
1747
|
// src/api/cart/remove-cart-lines.ts
|
|
1682
1748
|
async function removeCartLines(client, options) {
|
|
1683
|
-
const { cartId: providedCartId, lineIds, cookieAdapter, metafieldIdentifiers } = options;
|
|
1749
|
+
const { cartId: providedCartId, lineIds, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1750
|
+
const query = graphqlQuery || removeCartItemsMutation;
|
|
1684
1751
|
const locale = client.getLocale();
|
|
1685
1752
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1686
1753
|
if (!cartId) {
|
|
1687
1754
|
throw new Error("Invalid input used for this operation: Miss cartId");
|
|
1688
1755
|
}
|
|
1689
1756
|
try {
|
|
1690
|
-
const data = await client.query(
|
|
1757
|
+
const data = await client.query(query, {
|
|
1691
1758
|
cartId,
|
|
1692
1759
|
lineIds,
|
|
1693
1760
|
...constructMetafieldIdentifiersQueryParams(
|
|
@@ -1714,14 +1781,15 @@ async function removeCartLines(client, options) {
|
|
|
1714
1781
|
|
|
1715
1782
|
// src/api/cart/update-cart-codes.ts
|
|
1716
1783
|
async function updateCartCodes(client, options) {
|
|
1717
|
-
const { cartId: providedCartId, discountCodes, cookieAdapter, metafieldIdentifiers } = options;
|
|
1784
|
+
const { cartId: providedCartId, discountCodes, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1785
|
+
const query = graphqlQuery || updateCartDiscountCodeMutation;
|
|
1718
1786
|
const locale = client.getLocale();
|
|
1719
1787
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1720
1788
|
if (!cartId) {
|
|
1721
1789
|
throw new Error("Invalid input used for this operation: Miss cartId");
|
|
1722
1790
|
}
|
|
1723
1791
|
try {
|
|
1724
|
-
const data = await client.query(
|
|
1792
|
+
const data = await client.query(query, {
|
|
1725
1793
|
cartId,
|
|
1726
1794
|
discountCodes,
|
|
1727
1795
|
...constructMetafieldIdentifiersQueryParams(
|
|
@@ -1745,14 +1813,15 @@ async function updateCartCodes(client, options) {
|
|
|
1745
1813
|
|
|
1746
1814
|
// src/api/cart/update-cart-attributes.ts
|
|
1747
1815
|
async function updateCartAttributes(client, options) {
|
|
1748
|
-
const { cartId: providedCartId, attributes, cookieAdapter, metafieldIdentifiers } = options;
|
|
1816
|
+
const { cartId: providedCartId, attributes, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1817
|
+
const query = graphqlQuery || updateCartAttributesMutation;
|
|
1749
1818
|
const locale = client.getLocale();
|
|
1750
1819
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1751
1820
|
if (!cartId) {
|
|
1752
1821
|
throw new Error("Invalid input used for this operation: Miss cartId");
|
|
1753
1822
|
}
|
|
1754
1823
|
try {
|
|
1755
|
-
const data = await client.query(
|
|
1824
|
+
const data = await client.query(query, {
|
|
1756
1825
|
cartId,
|
|
1757
1826
|
attributes,
|
|
1758
1827
|
...constructMetafieldIdentifiersQueryParams(
|
|
@@ -1779,14 +1848,15 @@ async function updateCartAttributes(client, options) {
|
|
|
1779
1848
|
|
|
1780
1849
|
// src/api/cart/update-cart-delivery-options.ts
|
|
1781
1850
|
async function updateCartDeliveryOptions(client, options) {
|
|
1782
|
-
const { cartId: providedCartId, selectedDeliveryOptions, cookieAdapter, metafieldIdentifiers } = options;
|
|
1851
|
+
const { cartId: providedCartId, selectedDeliveryOptions, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1852
|
+
const query = graphqlQuery || updateCartDeliveryOptionsMutation;
|
|
1783
1853
|
const locale = client.getLocale();
|
|
1784
1854
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1785
1855
|
if (!cartId) {
|
|
1786
1856
|
throw new Error("Invalid input used for this operation: Miss cartId");
|
|
1787
1857
|
}
|
|
1788
1858
|
try {
|
|
1789
|
-
const data = await client.query(
|
|
1859
|
+
const data = await client.query(query, {
|
|
1790
1860
|
cartId,
|
|
1791
1861
|
selectedDeliveryOptions,
|
|
1792
1862
|
...constructMetafieldIdentifiersQueryParams(
|
|
@@ -1813,14 +1883,15 @@ async function updateCartDeliveryOptions(client, options) {
|
|
|
1813
1883
|
|
|
1814
1884
|
// src/api/cart/update-buyer-identity.ts
|
|
1815
1885
|
async function updateBuyerIdentity(client, options) {
|
|
1816
|
-
const { cartId: providedCartId, buyerIdentity, cookieAdapter, metafieldIdentifiers } = options;
|
|
1886
|
+
const { cartId: providedCartId, buyerIdentity, cookieAdapter, graphqlQuery, metafieldIdentifiers } = options;
|
|
1887
|
+
const query = graphqlQuery || updateBuyerIdentityMutation;
|
|
1817
1888
|
const locale = client.getLocale();
|
|
1818
1889
|
const cartId = providedCartId || cookieAdapter?.getCartId(locale);
|
|
1819
1890
|
if (!cartId) {
|
|
1820
1891
|
throw new Error("Invalid input used for this operation: Miss cartId");
|
|
1821
1892
|
}
|
|
1822
1893
|
try {
|
|
1823
|
-
const data = await client.query(
|
|
1894
|
+
const data = await client.query(query, {
|
|
1824
1895
|
cartId,
|
|
1825
1896
|
buyerIdentity,
|
|
1826
1897
|
...constructMetafieldIdentifiersQueryParams(
|
|
@@ -1891,12 +1962,13 @@ var getCollectionQuery = (
|
|
|
1891
1962
|
`
|
|
1892
1963
|
);
|
|
1893
1964
|
async function getCollection(client, options) {
|
|
1894
|
-
const { handle, metafieldIdentifiers } = options;
|
|
1965
|
+
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
1966
|
+
const query = graphqlQuery || getCollectionQuery;
|
|
1895
1967
|
const variables = { handle };
|
|
1896
1968
|
if (metafieldIdentifiers) {
|
|
1897
1969
|
variables.metafieldIdentifiers = metafieldIdentifiers;
|
|
1898
1970
|
}
|
|
1899
|
-
const data = await client.query(
|
|
1971
|
+
const data = await client.query(query, variables);
|
|
1900
1972
|
if (!data?.collection) {
|
|
1901
1973
|
return void 0;
|
|
1902
1974
|
}
|
|
@@ -1939,7 +2011,8 @@ var getAllCollectionsQuery = (
|
|
|
1939
2011
|
`
|
|
1940
2012
|
);
|
|
1941
2013
|
async function fetchAllPages2(client, options, afterCursor) {
|
|
1942
|
-
const { first = 250, query, sortKey, reverse, metafieldIdentifiers } = options;
|
|
2014
|
+
const { first = 250, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
2015
|
+
const queryString = graphqlQuery || getAllCollectionsQuery;
|
|
1943
2016
|
const variables = {
|
|
1944
2017
|
first,
|
|
1945
2018
|
after: afterCursor,
|
|
@@ -1950,7 +2023,7 @@ async function fetchAllPages2(client, options, afterCursor) {
|
|
|
1950
2023
|
if (metafieldIdentifiers) {
|
|
1951
2024
|
variables.metafieldIdentifiers = metafieldIdentifiers;
|
|
1952
2025
|
}
|
|
1953
|
-
const data = await client.query(
|
|
2026
|
+
const data = await client.query(queryString, variables);
|
|
1954
2027
|
if (!data || !data.collections) {
|
|
1955
2028
|
return [];
|
|
1956
2029
|
}
|
|
@@ -1965,7 +2038,8 @@ async function getAllCollections(client, options) {
|
|
|
1965
2038
|
return fetchAllPages2(client, options);
|
|
1966
2039
|
}
|
|
1967
2040
|
async function getCollections(client, options) {
|
|
1968
|
-
const { first = 250, after, query, sortKey, reverse, metafieldIdentifiers } = options;
|
|
2041
|
+
const { first = 250, after, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
2042
|
+
const queryString = graphqlQuery || getAllCollectionsQuery;
|
|
1969
2043
|
const variables = {
|
|
1970
2044
|
first,
|
|
1971
2045
|
after,
|
|
@@ -1976,7 +2050,7 @@ async function getCollections(client, options) {
|
|
|
1976
2050
|
if (metafieldIdentifiers) {
|
|
1977
2051
|
variables.metafieldIdentifiers = metafieldIdentifiers;
|
|
1978
2052
|
}
|
|
1979
|
-
const data = await client.query(
|
|
2053
|
+
const data = await client.query(queryString, variables);
|
|
1980
2054
|
if (!data || !data.collections) {
|
|
1981
2055
|
return {
|
|
1982
2056
|
collections: [],
|
|
@@ -1993,6 +2067,36 @@ async function getCollections(client, options) {
|
|
|
1993
2067
|
};
|
|
1994
2068
|
}
|
|
1995
2069
|
|
|
2070
|
+
// src/api/collection/get-collections-by-handles.ts
|
|
2071
|
+
var getCollectionsByHandles = async ({
|
|
2072
|
+
client,
|
|
2073
|
+
options
|
|
2074
|
+
}) => {
|
|
2075
|
+
const { handles, graphqlQuery, metafieldIdentifiers } = options;
|
|
2076
|
+
if (handles.length === 0) {
|
|
2077
|
+
return [];
|
|
2078
|
+
}
|
|
2079
|
+
const query = graphqlQuery || getCollectionsByHandlesQuery(handles);
|
|
2080
|
+
const data = await client.query(query, {
|
|
2081
|
+
handles,
|
|
2082
|
+
// 请勿删除,这个参数虽然没有在 query 中使用,但方便在 chrome dev tools 中查看请求参数
|
|
2083
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2084
|
+
metafieldIdentifiers,
|
|
2085
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2086
|
+
)
|
|
2087
|
+
});
|
|
2088
|
+
if (!data) {
|
|
2089
|
+
return [];
|
|
2090
|
+
}
|
|
2091
|
+
const collections = Object.values(data).map((item) => {
|
|
2092
|
+
if (!item) {
|
|
2093
|
+
return void 0;
|
|
2094
|
+
}
|
|
2095
|
+
return normalizeCollection(item);
|
|
2096
|
+
});
|
|
2097
|
+
return collections;
|
|
2098
|
+
};
|
|
2099
|
+
|
|
1996
2100
|
// src/api/blog/normalize.ts
|
|
1997
2101
|
function normalizeBlog(blog) {
|
|
1998
2102
|
return {
|
|
@@ -2037,16 +2141,16 @@ function normalizeMetafields2(metafields) {
|
|
|
2037
2141
|
|
|
2038
2142
|
// src/api/blog/get-blog.ts
|
|
2039
2143
|
async function getBlog(client, options) {
|
|
2040
|
-
const { handle, metafieldIdentifiers } = options;
|
|
2144
|
+
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2041
2145
|
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
2042
2146
|
const fragment = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2043
|
-
const
|
|
2147
|
+
const defaultQuery = (
|
|
2044
2148
|
/* GraphQL */
|
|
2045
2149
|
`
|
|
2046
2150
|
query getBlog(
|
|
2047
2151
|
$handle: String!
|
|
2048
2152
|
${hasMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2049
|
-
)
|
|
2153
|
+
) {
|
|
2050
2154
|
blog(handle: $handle) {
|
|
2051
2155
|
...${hasMetafields ? "blogWithMetafields" : "blog"}
|
|
2052
2156
|
}
|
|
@@ -2054,6 +2158,7 @@ async function getBlog(client, options) {
|
|
|
2054
2158
|
${fragment}
|
|
2055
2159
|
`
|
|
2056
2160
|
);
|
|
2161
|
+
const query = graphqlQuery || defaultQuery;
|
|
2057
2162
|
const variables = { handle };
|
|
2058
2163
|
if (hasMetafields) {
|
|
2059
2164
|
variables.blogMetafieldIdentifiers = metafieldIdentifiers;
|
|
@@ -2067,10 +2172,10 @@ async function getBlog(client, options) {
|
|
|
2067
2172
|
|
|
2068
2173
|
// src/api/blog/get-all-blogs.ts
|
|
2069
2174
|
async function fetchAllPages3(client, options, afterCursor) {
|
|
2070
|
-
const { first = 250, query, metafieldIdentifiers } = options;
|
|
2175
|
+
const { first = 250, query, graphqlQuery, metafieldIdentifiers } = options;
|
|
2071
2176
|
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
2072
2177
|
const fragment = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2073
|
-
const
|
|
2178
|
+
const defaultQueryString = (
|
|
2074
2179
|
/* GraphQL */
|
|
2075
2180
|
`
|
|
2076
2181
|
query getAllBlogs(
|
|
@@ -2078,7 +2183,7 @@ async function fetchAllPages3(client, options, afterCursor) {
|
|
|
2078
2183
|
$after: String
|
|
2079
2184
|
${query ? "$query: String!" : ""}
|
|
2080
2185
|
${hasMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2081
|
-
)
|
|
2186
|
+
) {
|
|
2082
2187
|
blogs(
|
|
2083
2188
|
first: $first
|
|
2084
2189
|
after: $after
|
|
@@ -2098,6 +2203,7 @@ async function fetchAllPages3(client, options, afterCursor) {
|
|
|
2098
2203
|
${pageInfoFragment}
|
|
2099
2204
|
`
|
|
2100
2205
|
);
|
|
2206
|
+
const queryString = graphqlQuery || defaultQueryString;
|
|
2101
2207
|
const variables = { first, after: afterCursor };
|
|
2102
2208
|
if (query) {
|
|
2103
2209
|
variables.query = query;
|
|
@@ -2122,11 +2228,11 @@ async function getAllBlogs(client, options) {
|
|
|
2122
2228
|
|
|
2123
2229
|
// src/api/blog/get-article.ts
|
|
2124
2230
|
async function getArticle(client, options) {
|
|
2125
|
-
const { blogHandle, articleHandle, metafieldIdentifiers } = options;
|
|
2231
|
+
const { blogHandle, articleHandle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2126
2232
|
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
2127
2233
|
const articleFrag = hasMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2128
2234
|
const blogFrag = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2129
|
-
const
|
|
2235
|
+
const defaultQuery = (
|
|
2130
2236
|
/* GraphQL */
|
|
2131
2237
|
`
|
|
2132
2238
|
query getArticle(
|
|
@@ -2134,7 +2240,7 @@ async function getArticle(client, options) {
|
|
|
2134
2240
|
$articleHandle: String!
|
|
2135
2241
|
${hasMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2136
2242
|
${hasMetafields ? "$articleMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2137
|
-
)
|
|
2243
|
+
) {
|
|
2138
2244
|
blog(handle: $blogHandle) {
|
|
2139
2245
|
...${hasMetafields ? "blogWithMetafields" : "blog"}
|
|
2140
2246
|
articleByHandle(handle: $articleHandle) {
|
|
@@ -2149,6 +2255,7 @@ async function getArticle(client, options) {
|
|
|
2149
2255
|
${blogFrag}
|
|
2150
2256
|
`
|
|
2151
2257
|
);
|
|
2258
|
+
const query = graphqlQuery || defaultQuery;
|
|
2152
2259
|
const variables = { blogHandle, articleHandle };
|
|
2153
2260
|
if (hasMetafields) {
|
|
2154
2261
|
variables.blogMetafieldIdentifiers = metafieldIdentifiers;
|
|
@@ -2163,10 +2270,17 @@ async function getArticle(client, options) {
|
|
|
2163
2270
|
|
|
2164
2271
|
// src/api/blog/get-articles.ts
|
|
2165
2272
|
async function fetchAllPages4(client, options, afterCursor) {
|
|
2166
|
-
const {
|
|
2273
|
+
const {
|
|
2274
|
+
first = 250,
|
|
2275
|
+
query,
|
|
2276
|
+
graphqlQuery,
|
|
2277
|
+
sortKey = "PUBLISHED_AT",
|
|
2278
|
+
reverse = false,
|
|
2279
|
+
metafieldIdentifiers
|
|
2280
|
+
} = options;
|
|
2167
2281
|
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
2168
2282
|
const fragment = hasMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2169
|
-
const
|
|
2283
|
+
const defaultQueryString = (
|
|
2170
2284
|
/* GraphQL */
|
|
2171
2285
|
`
|
|
2172
2286
|
query getArticles(
|
|
@@ -2176,7 +2290,7 @@ async function fetchAllPages4(client, options, afterCursor) {
|
|
|
2176
2290
|
$sortKey: ArticleSortKeys!
|
|
2177
2291
|
$reverse: Boolean!
|
|
2178
2292
|
${hasMetafields ? "$articleMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2179
|
-
)
|
|
2293
|
+
) {
|
|
2180
2294
|
articles(
|
|
2181
2295
|
first: $first
|
|
2182
2296
|
after: $after
|
|
@@ -2198,6 +2312,7 @@ async function fetchAllPages4(client, options, afterCursor) {
|
|
|
2198
2312
|
${pageInfoFragment}
|
|
2199
2313
|
`
|
|
2200
2314
|
);
|
|
2315
|
+
const queryString = graphqlQuery || defaultQueryString;
|
|
2201
2316
|
const variables = {
|
|
2202
2317
|
first,
|
|
2203
2318
|
after: afterCursor,
|
|
@@ -2227,11 +2342,18 @@ async function getArticles(client, options) {
|
|
|
2227
2342
|
|
|
2228
2343
|
// src/api/blog/get-articles-in-blog.ts
|
|
2229
2344
|
async function fetchAllPages5(client, options, afterCursor) {
|
|
2230
|
-
const {
|
|
2345
|
+
const {
|
|
2346
|
+
blogHandle,
|
|
2347
|
+
first = 250,
|
|
2348
|
+
graphqlQuery,
|
|
2349
|
+
sortKey = "PUBLISHED_AT",
|
|
2350
|
+
reverse = false,
|
|
2351
|
+
metafieldIdentifiers
|
|
2352
|
+
} = options;
|
|
2231
2353
|
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
2232
2354
|
const articleFrag = hasMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2233
2355
|
const blogFrag = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2234
|
-
const
|
|
2356
|
+
const defaultQuery = (
|
|
2235
2357
|
/* GraphQL */
|
|
2236
2358
|
`
|
|
2237
2359
|
query getArticlesInBlog(
|
|
@@ -2242,7 +2364,7 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2242
2364
|
$reverse: Boolean!
|
|
2243
2365
|
${hasMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2244
2366
|
${hasMetafields ? "$articleMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2245
|
-
)
|
|
2367
|
+
) {
|
|
2246
2368
|
blog(handle: $blogHandle) {
|
|
2247
2369
|
...${hasMetafields ? "blogWithMetafields" : "blog"}
|
|
2248
2370
|
articles(
|
|
@@ -2267,6 +2389,7 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2267
2389
|
${pageInfoFragment}
|
|
2268
2390
|
`
|
|
2269
2391
|
);
|
|
2392
|
+
const query = graphqlQuery || defaultQuery;
|
|
2270
2393
|
const variables = {
|
|
2271
2394
|
blogHandle,
|
|
2272
2395
|
first,
|
|
@@ -2293,6 +2416,6 @@ async function getArticlesInBlog(client, options) {
|
|
|
2293
2416
|
return fetchAllPages5(client, options);
|
|
2294
2417
|
}
|
|
2295
2418
|
|
|
2296
|
-
export { ShopifyClient, addCartItemsMutation, addCartLines, articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, createCart, createCartMutation, createShopifyClient, getAllBlogs, getAllCollections, getAllProducts, getAllProductsPathsQuery, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCartQuery, getCollection, getCollections, getProduct, getProductQuery, getProducts, getProductsByHandles, getProductsByHandlesQuery, getProductsQuery, imageFragment, metafieldFragment, metafieldFragmentStr, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, pageInfoFragment, productFragment, removeCartItemsMutation, removeCartLines, seoFragment, updateBuyerIdentity, updateBuyerIdentityMutation, updateCartAttributes, updateCartAttributesMutation, updateCartCodes, updateCartDeliveryOptions, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation, updateCartLines, variantFragment };
|
|
2419
|
+
export { ShopifyClient, addCartItemsMutation, addCartLines, articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, createCart, createCartMutation, createShopifyClient, getAllBlogs, getAllCollections, getAllProducts, getAllProductsPathsQuery, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCartQuery, getCollection, getCollections, getCollectionsByHandles, getCollectionsByHandlesQuery, getProduct, getProductQuery, getProducts, getProductsByHandles, getProductsByHandlesQuery, getProductsQuery, imageFragment, metafieldFragment, metafieldFragmentStr, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, pageInfoFragment, productFragment, removeCartItemsMutation, removeCartLines, seoFragment, updateBuyerIdentity, updateBuyerIdentityMutation, updateCartAttributes, updateCartAttributesMutation, updateCartCodes, updateCartDeliveryOptions, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation, updateCartLines, variantFragment };
|
|
2297
2420
|
//# sourceMappingURL=index.mjs.map
|
|
2298
2421
|
//# sourceMappingURL=index.mjs.map
|