@backpackjs/transform-product-feed
Advanced tools
Comparing version 4.27.11-next.42 to 4.27.11
@@ -0,3 +1,8 @@ | ||
export function getProducts({ products, collections, options }: { | ||
products: any; | ||
collections: any; | ||
options: any; | ||
}): any; | ||
declare function _default(input: any): Promise<any>; | ||
export default _default; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getProducts = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -18,18 +19,20 @@ /* eslint-disable camelcase */ | ||
const filterDraft = (product) => product.status.toLowerCase() !== 'draft'; | ||
const getProduct = (products) => (handle) => { | ||
return products.find((product) => product.handle === handle); | ||
}; | ||
const getProducts = ({ products, collections, options }) => { | ||
const optionCollection = options.collectionHandle; | ||
const productByHandle = getProduct(products); | ||
const byOptionsCollection = ({ handle }) => handle === optionCollection; | ||
const collection = collections.find(byOptionsCollection); | ||
const feedCollectionProducts = collection?.products | ||
.map((product) => product.handle) | ||
.map(productByHandle); | ||
if (!feedCollectionProducts) { | ||
const collection = collections.find((c) => options.collectionHandle === c.handle); | ||
if (!collection || collection.products.length < 1) { | ||
return products; | ||
} | ||
return feedCollectionProducts; | ||
const productMapByHandle = new Map(); | ||
products.forEach((product) => { | ||
productMapByHandle.set(product.handle, product); | ||
}); | ||
const collectionProducts = []; | ||
collection.products.forEach((product) => { | ||
if (productMapByHandle.has(product.handle)) { | ||
collectionProducts.push(productMapByHandle.get(product.handle)); | ||
} | ||
}); | ||
return collectionProducts; | ||
}; | ||
exports.getProducts = getProducts; | ||
const getFeedItems = (product) => { | ||
@@ -84,3 +87,3 @@ return product.variants.map((variant) => { | ||
const { products, collections, context, options, log } = input; | ||
const feedItems = getProducts({ products, collections, options }) | ||
const feedItems = (0, exports.getProducts)({ products, collections, options }) | ||
.filter(filterDraft) | ||
@@ -87,0 +90,0 @@ .flatMap(getFeedItems); |
{ | ||
"name": "@backpackjs/transform-product-feed", | ||
"version": "4.27.11-next.42+4b2dc28e", | ||
"version": "4.27.11", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "author": "BackpackJS <dev@packdigial.com> (http://packdigital.com/)", | ||
}, | ||
"gitHead": "4b2dc28ea9649ea00f0e795d3e0ac425200cd9dc" | ||
"gitHead": "e062af030c5596da0686ca519c04baacb78529aa" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
14082
10
143
1
0