@anker-in/shopify-sdk 1.2.0-beta.4 → 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 +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -1
- 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 +1 -1
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 */
|
|
@@ -1998,6 +2043,36 @@ async function getCollections(client, options) {
|
|
|
1998
2043
|
};
|
|
1999
2044
|
}
|
|
2000
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
|
+
|
|
2001
2076
|
// src/api/blog/normalize.ts
|
|
2002
2077
|
function normalizeBlog(blog) {
|
|
2003
2078
|
return {
|
|
@@ -2298,6 +2373,6 @@ async function getArticlesInBlog(client, options) {
|
|
|
2298
2373
|
return fetchAllPages5(client, options);
|
|
2299
2374
|
}
|
|
2300
2375
|
|
|
2301
|
-
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 };
|
|
2302
2377
|
//# sourceMappingURL=index.mjs.map
|
|
2303
2378
|
//# sourceMappingURL=index.mjs.map
|