Repository navigation
feat(feeds): parse store CSVs, Google product feed XML and Meta catalog CSVs into one item shape (#1264) - #1488
Merged
Merged
Conversation
…og CSVs into one item shape (#1264) A pure library under server/src/lib/feeds: an RFC 4180 reader, RSS 2.0 and Atom Google feeds read one item at a time, and a Meta catalog CSV, each into the catalog's item shape. Products missing a required field or repeating an id are skipped with their row or item number; a file that isn't a feed fails once.
5 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Many brands already keep a product feed for Google or Meta, or can export a CSV. This adds the parsers that read those formats into one item shape, for the feed connector and the CSV import (#1263) and the Merchant Center connector (#1270). It's a pure library under
server/src/lib/feeds/: no network, no database, no new dependency.API (
server/src/lib/feeds/index.js)parseCsvFeed(text, mapping?): a CSV with a header row.id,title,description,link,image_link,price,gtin,brand,availability, …), in any case, with spaces or ag:prefix. A few common names map too (url,image_url,name).mappingnames others:{ id: 'SKU', title: 'Product name' }.parseGoogleFeedXml(text): Google product feed XML, RSS 2.0 with theg:namespace or Atom (<link href>,<summary>).parseFacebookCatalogCsv(text): a Meta catalog CSV. Its columns share Google's names;rich_text_descriptionstands in when there's nodescription.Each returns
{ items, errors }.The item (
item.js, documented asFeedItem):id,itemGroupId,title,description,link,imageLink,additionalImageLinks[],brand,gtin,mpn,priceandsalePrice({ amount, currency }),availability(in_stock,out_of_stock,preorder…),condition,color,size,materialandproductType. #1263's catalog tables should use the same names.g:additional_image_linkelements, or one CSV field with several addresses.Errors
id,title,link,price,availability), or with one that doesn't parse, is skipped. Its error names the row or item and the field, and says what was there:Row 2: price "free" isn't a valid price.idis skipped too, since the catalog keys products by it.FeedFormatError, not one error per row: an empty file, a CSV with noid/link/price/availabilitycolumn, or XML with no<rss>or<feed>.Size
<item>or<entry>at a time, each parsed withcheerioin XML mode (already a dependency). A large feed is never loaded as one document.Related issue
Closes #1264.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/feeds. The fixtures in__fixtures__/cover:item_group_id, three colors), repeated additional images, CDATA and entities;price, which is skipped with its row number;Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm test,npm run lintandnpm run format:checkpass🤖 Generated with Claude Code