Repository navigation
feat(catalog): add the product catalog and its batch sync (00278, #1263 part 1) - #1489
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.
… part 1) Tables for a brand's products, variants, images and categories, keyed by (brand, source, external id), read by members and written only by the server. syncCatalog writes a source's feed items in place, skips unchanged rows by content hash, and marks a product or variant gone from the source as removed.
8 of 13 tasks
7 of 12 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
#1263, part 1: the catalog model and its batch sync. This gives every catalog source one shape to write into. The connections, credentials, the connector interface, the feed URL connector with its daily sync and CSV upload, and
CONNECTORS.mdfollow in later parts.Stacked on #1488 (the feed parsers, #1264). Its own change is the last commit. Merge #1488 first.
Tables (00278), all a brand's:
catalog_products, keyed by(brand_id, source, external_id): title, description, the product's brand, URL and product type. A feed's item group is one product; an item with no group is its own.catalog_variants, under their product: SKU, GTIN, MPN, a marketplace item id (ASIN), URL, price and sale price with a currency, availability, condition, and the options that make the variant asattributes(color, size, material).catalog_images: a product's or a variant's images, in order.catalog_categories: a flat list per brand, from the product type as written.catalog_product_categoriesholds a product's categories (several).attributesis a small object.authenticatedhas no insert, update or delete, anon has nothing, and only the service role writes.Sync (
server/src/lib/catalog/sync.js):syncCatalog(brandId, source, items)takes the feed parsers' items. Every source will go through it.(brand, source, external id), 500 at a time, and reads page past 1,000 rows.content_hashcovers its content. A row that didn't change isn't written, so syncing the same file again writes nothing.removed_atand is never deleted. One that comes back is live again.Related issue
Part of #1263 (part 1 of several). Builds on #1264 (#1488).
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/catalog. The sync runs against an in-memory stand-in for the tables:Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm test,npm run lintandnpm run format:checkpass;schema.sqlrebuilt🤖 Generated with Claude Code