@ehrenkind/shopify-lib 0.5.0 → 0.5.1
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.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1873,35 +1873,46 @@ var GetLeanProductVariantsReturn = import_zod7.default.array(
|
|
|
1873
1873
|
productTitle: import_zod7.default.string(),
|
|
1874
1874
|
variantId: import_zod7.default.string(),
|
|
1875
1875
|
variantTitle: import_zod7.default.string(),
|
|
1876
|
-
sku: import_zod7.default.string()
|
|
1876
|
+
sku: import_zod7.default.string(),
|
|
1877
|
+
status: import_zod7.default.enum(["ACTIVE", "ARCHIVED", "DRAFT"])
|
|
1877
1878
|
})
|
|
1878
1879
|
);
|
|
1879
|
-
async function getLeanProductVariants(skus) {
|
|
1880
|
+
async function getLeanProductVariants(skus, options) {
|
|
1880
1881
|
const queryGql = gql`#graphql
|
|
1881
1882
|
query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {
|
|
1882
1883
|
productVariants(first: $first, after: $after, query: $queryFilter) {
|
|
1883
1884
|
edges {
|
|
1884
|
-
node {
|
|
1885
|
+
node {
|
|
1885
1886
|
id
|
|
1886
1887
|
title
|
|
1887
1888
|
sku
|
|
1888
1889
|
product {
|
|
1889
1890
|
id
|
|
1890
1891
|
title
|
|
1892
|
+
status
|
|
1891
1893
|
}
|
|
1892
1894
|
}
|
|
1893
1895
|
}
|
|
1894
|
-
pageInfo {
|
|
1896
|
+
pageInfo {
|
|
1895
1897
|
hasNextPage
|
|
1896
1898
|
endCursor
|
|
1897
1899
|
}
|
|
1898
1900
|
}
|
|
1899
1901
|
}
|
|
1900
1902
|
`;
|
|
1901
|
-
const
|
|
1903
|
+
const queryParts = [];
|
|
1902
1904
|
if (skus && skus.length > 0) {
|
|
1903
|
-
|
|
1905
|
+
queryParts.push(skus.map((sku) => `sku:${sku}`).join(" OR "));
|
|
1906
|
+
}
|
|
1907
|
+
if (options?.activeOnly) {
|
|
1908
|
+
queryParts.push("product_status:active,draft");
|
|
1904
1909
|
}
|
|
1910
|
+
const initialVariables = {
|
|
1911
|
+
first: 250,
|
|
1912
|
+
...queryParts.length > 0 && {
|
|
1913
|
+
queryFilter: queryParts.filter(Boolean).join(" AND ")
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1905
1916
|
const extractedNodes = await fetchShopifyGraphql({
|
|
1906
1917
|
query: queryGql,
|
|
1907
1918
|
variables: initialVariables,
|
|
@@ -1929,7 +1940,8 @@ async function getLeanProductVariants(skus) {
|
|
|
1929
1940
|
productTitle: v.product.title,
|
|
1930
1941
|
variantId: v.id,
|
|
1931
1942
|
variantTitle: v.title,
|
|
1932
|
-
sku: v.sku
|
|
1943
|
+
sku: v.sku,
|
|
1944
|
+
status: v.product.status
|
|
1933
1945
|
}
|
|
1934
1946
|
];
|
|
1935
1947
|
}
|