@anker-in/shopify-sdk 1.2.0-beta.3 → 1.2.0-beta.5
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 +41 -3
- package/dist/index.d.ts +41 -3
- package/dist/index.js +83 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -2
- 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 +67 -0
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/index.mjs +67 -1
- package/dist/queries/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -927,6 +927,51 @@ 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
|
+
|
|
939
|
+
query GetCollectionsByHandles(
|
|
940
|
+
$collectionMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
941
|
+
$productMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
942
|
+
$variantMetafieldIdentifiers: [HasMetafieldsIdentifier!] = []
|
|
943
|
+
) {
|
|
944
|
+
${handles.map(
|
|
945
|
+
(handle, index) => (
|
|
946
|
+
/* GraphQL */
|
|
947
|
+
`
|
|
948
|
+
collection_${index}: collection(handle: "${handle}") {
|
|
949
|
+
...CollectionFragment
|
|
950
|
+
product(handle: $handle) {
|
|
951
|
+
...product
|
|
952
|
+
metafields(identifiers: $productMetafieldIdentifiers) {
|
|
953
|
+
...metafield
|
|
954
|
+
}
|
|
955
|
+
variants(first: 250) {
|
|
956
|
+
nodes {
|
|
957
|
+
...variant
|
|
958
|
+
metafields(identifiers: $variantMetafieldIdentifiers) {
|
|
959
|
+
...metafield
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
metafields(identifiers: $collectionMetafieldIdentifiers) {
|
|
965
|
+
...metafield
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
`
|
|
969
|
+
)
|
|
970
|
+
).join("\n")}
|
|
971
|
+
}
|
|
972
|
+
`
|
|
973
|
+
);
|
|
974
|
+
|
|
930
975
|
// src/mutations/cart/create-cart.ts
|
|
931
976
|
var createCartMutation = (
|
|
932
977
|
/* GraphQL */
|
|
@@ -1415,7 +1460,12 @@ async function getProductsByHandles(client, options) {
|
|
|
1415
1460
|
if (!data) {
|
|
1416
1461
|
return [];
|
|
1417
1462
|
}
|
|
1418
|
-
return Object.
|
|
1463
|
+
return Object.values(data).map((item) => {
|
|
1464
|
+
if (item) {
|
|
1465
|
+
return normalizeProduct(item);
|
|
1466
|
+
}
|
|
1467
|
+
return void 0;
|
|
1468
|
+
});
|
|
1419
1469
|
}
|
|
1420
1470
|
|
|
1421
1471
|
// src/api/cart/normalize.ts
|
|
@@ -1993,6 +2043,36 @@ async function getCollections(client, options) {
|
|
|
1993
2043
|
};
|
|
1994
2044
|
}
|
|
1995
2045
|
|
|
2046
|
+
// src/api/collection/get-collections-by-handles.ts
|
|
2047
|
+
var getCollectionsByHandles = async ({
|
|
2048
|
+
client,
|
|
2049
|
+
options
|
|
2050
|
+
}) => {
|
|
2051
|
+
const { handles, metafieldIdentifiers } = options;
|
|
2052
|
+
if (handles.length === 0) {
|
|
2053
|
+
return [];
|
|
2054
|
+
}
|
|
2055
|
+
const query = getCollectionsByHandlesQuery(handles);
|
|
2056
|
+
const data = await client.query(query, {
|
|
2057
|
+
handles,
|
|
2058
|
+
// 请勿删除,这个参数虽然没有在 query 中使用,但方便在 chrome dev tools 中查看请求参数
|
|
2059
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2060
|
+
metafieldIdentifiers,
|
|
2061
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2062
|
+
)
|
|
2063
|
+
});
|
|
2064
|
+
if (!data) {
|
|
2065
|
+
return [];
|
|
2066
|
+
}
|
|
2067
|
+
const collections = Object.values(data).map((item) => {
|
|
2068
|
+
if (!item) {
|
|
2069
|
+
return void 0;
|
|
2070
|
+
}
|
|
2071
|
+
return normalizeCollection(item);
|
|
2072
|
+
});
|
|
2073
|
+
return collections;
|
|
2074
|
+
};
|
|
2075
|
+
|
|
1996
2076
|
// src/api/blog/normalize.ts
|
|
1997
2077
|
function normalizeBlog(blog) {
|
|
1998
2078
|
return {
|
|
@@ -2293,6 +2373,6 @@ async function getArticlesInBlog(client, options) {
|
|
|
2293
2373
|
return fetchAllPages5(client, options);
|
|
2294
2374
|
}
|
|
2295
2375
|
|
|
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 };
|
|
2376
|
+
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
2377
|
//# sourceMappingURL=index.mjs.map
|
|
2298
2378
|
//# sourceMappingURL=index.mjs.map
|