Skip to content

feat(feeds): parse store CSVs, Google product feed XML and Meta catalog CSVs into one item shape (#1264) - #1488

Merged
gkhngyk merged 1 commit into
mainfrom
feature/product-feed-parsers
Oct 25, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/product-feed-parsers

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

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.
    • Columns named after Google's attributes map by themselves (id, title, description, link, image_link, price, gtin, brand, availability, …), in any case, with spaces or a g: prefix. A few common names map too (url, image_url, name).
    • mapping names others: { id: 'SKU', title: 'Product name' }.
    • Tab-separated text (Google's text feeds) is read the same way.
  • parseGoogleFeedXml(text): Google product feed XML, RSS 2.0 with the g: namespace or Atom (<link href>, <summary>).
  • parseFacebookCatalogCsv(text): a Meta catalog CSV. Its columns share Google's names; rich_text_description stands in when there's no description.

Each returns { items, errors }.

The item (item.js, documented as FeedItem): id, itemGroupId, title, description, link, imageLink, additionalImageLinks[], brand, gtin, mpn, price and salePrice ({ amount, currency }), availability (in_stock, out_of_stock, preorder…), condition, color, size, material and productType. #1263's catalog tables should use the same names.

  • Prices: "15.00 USD", "USD 15.00", "15.00" with no currency, "1,249.90 TRY", "1.249,90 EUR", "€39".
  • Several images: repeated g:additional_image_link elements, or one CSV field with several addresses.

Errors

  • A product missing a required field (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 3: price is missing."
    • Row 2: price "free" isn't a valid price.
  • CSV rows are numbered as a spreadsheet numbers them: the header is row 1, and a quoted line break doesn't start a row.
  • A repeated id is skipped too, since the catalog keys products by it.
  • A file that isn't the expected format throws one FeedFormatError, not one error per row: an empty file, a CSV with no id / link / price / availability column, or XML with no <rss> or <feed>.

Size

  • CSV: a small RFC 4180 reader (quoted fields, doubled quotes, commas and line breaks inside quotes, CRLF, a byte-order mark). It yields one row at a time.
  • XML: read one <item> or <entry> at a time, each parsed with cheerio in XML mode (already a dependency). A large feed is never loaded as one document.

Related issue

Closes #1264.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

cd server && npx vitest run src/lib/feeds. The fixtures in __fixtures__/ cover:

  • an RSS feed with a variant group (one item_group_id, three colors), repeated additional images, CDATA and entities;
  • the same products as an Atom feed and as a Meta CSV, which parse into the same items;
  • prices with and without a currency;
  • a store export with a byte-order mark, a quoted field holding a comma, quotes and a line break, and a row missing price, which is skipped with its row number;
  • a 10,000-row CSV.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • Server npm test, npm run lint and npm run format:check pass
  • Changes are focused — one concern per PR

🤖 Generated with Claude Code

…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.
@gkhngyk
gkhngyk merged commit 8496228 into main Oct 25, 2026
6 checks passed
@gkhngyk
gkhngyk deleted the feature/product-feed-parsers branch October 25, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(e-commerce): parse CSV, Google product feed XML and Facebook catalog CSV into the catalog model

1 participant