Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backpackjs/transform-product-feed

Package Overview
Dependencies
Maintainers
7
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.4.0 to 4.5.0

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [4.5.0](https://github.com/backpackjs/backpackjs-monorepo/compare/@backpackjs/transform-product-feed@4.4.0...@backpackjs/transform-product-feed@4.5.0) (2022-06-30)
**Note:** Version bump only for package @backpackjs/transform-product-feed
# 4.4.0 (2022-06-28)

@@ -8,0 +16,0 @@

45

dist/index.js

@@ -8,2 +8,4 @@ "use strict";

const fbcatalog_1 = (0, tslib_1.__importDefault)(require("fbcatalog"));
const errors = [];
const messages = [];
const buildXML = (feedItems) => {

@@ -13,8 +15,8 @@ const feed = fbcatalog_1.default.feed();

return feed.toRSS({
title: "",
description: "",
title: '',
description: '',
link: process.env.SITE_URL,
}, { pretty: false });
};
const filterDraft = (product) => product.status.toLowerCase() !== "draft";
const filterDraft = (product) => product.status.toLowerCase() !== 'draft';
const getProduct = (products) => (handle) => {

@@ -37,7 +39,7 @@ return products.find((product) => product.handle === handle);

product_type: product.productType,
gtin: variant.sku || variant.legacyResourceId,
gtin: variant.sku,
link: `${process.env.SITE_URL}/products/${product.handle}?variant=${variant.legacyResourceId}`,
brand: product.vendor,
condition: "new",
availability: variant.availableForSale ? "in stock" : "out of stock",
condition: 'new',
availability: variant.availableForSale ? 'in stock' : 'out of stock',
inventory: String(variant.inventoryQuantity),

@@ -54,11 +56,36 @@ shipping_weight: `${variant.weight} ${variant.weightUnit}`,

};
const testForValidity = (valid) => (item) => {
const isNull = Object.values(item).includes(null);
const isUndefined = Object.values(item).includes(undefined);
if (valid) {
return !isNull && !isUndefined;
}
return isNull || isUndefined;
};
const logInvalidItems = (feedItems, task) => {
const invalidItems = feedItems.filter(testForValidity(false));
const remainingItemsCount = invalidItems.length - 5;
const invalidItemsList = invalidItems.slice(0, 5).map((item) => item.id);
if (remainingItemsCount > 0) {
invalidItemsList.push(`... ${remainingItemsCount} more items`);
}
if (invalidItems.length > 0) {
const message = `🚨 The following ids are invalid and will be removed from the feed:`;
const items = `• [ ${invalidItemsList.join(', ')} ]`;
errors.push(`${message}\n${items}`);
}
// task.output = ;
};
exports.default = async (input) => {
try {
if (!input.collections.length || !input.products.length) {
if (!input.products.length)
return input;
}
const feedItems = getProducts(input)
.filter(filterDraft)
.flatMap(getFeedItems);
await fs_extra_1.default.outputFile(path_1.default.resolve(input.context.target, "public/product-feed.xml"), buildXML(feedItems));
logInvalidItems(feedItems, input.task);
const validItems = feedItems.filter(testForValidity(true));
await fs_extra_1.default.outputFile(path_1.default.resolve(input.context.target, 'public/product-feed.xml'), buildXML(validItems));
console.log(Object.keys(input.task));
// if (errors.length) {}
return input;

@@ -65,0 +92,0 @@ }

4

package.json
{
"name": "@backpackjs/transform-product-feed",
"version": "4.4.0",
"version": "4.5.0",
"license": "MIT",

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

},
"gitHead": "51b3679cfced77999d2511f91f4673073a2ff2dd"
"gitHead": "5c5b08c812b8038c7c906a91b1135a0eaad0c77c"
}

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