Socket
Socket
Sign inDemoInstall

@backpackjs/transform-product-feed

Package Overview
Dependencies
Maintainers
27
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backpackjs/transform-product-feed - npm Package Compare versions

Comparing version 4.27.10 to 4.27.11-canary.966.4445563018.0

dist/index.test.d.ts

5

dist/index.d.ts

@@ -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

29

dist/index.js
"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.10",
"version": "4.27.11-canary.966.4445563018.0",
"license": "MIT",

@@ -25,3 +25,3 @@ "author": "BackpackJS <dev@packdigial.com> (http://packdigital.com/)",

},
"gitHead": "63cb7c24ae11d9e19d5a9401ea77809841d7e88e"
"gitHead": "6906aaa6c2e419275704299602f2758321e10c19"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc