Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio), valuation and sort-by-price, card detail pricing UI, and nearby store discovery via home zip and OSM geo clients. Co-authored-by: Cursor <cursoragent@cursor.com>
2.8 KiB
2.8 KiB
| convoy | brief_number | depends_on | recommended_model | model_tier | files | cross_brief_commitments | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pricing-online-local | 2 |
|
composer-2.5 | standard |
|
|
Brief 2: Pricing foundation lib
Goal (1 sentence)
Create shared pricing helpers for foil-aware unit prices, daily history snapshots, collection valuation SQL, and outbound buy links.
Files in scope (do not edit anything else)
lib/pricing/card-price.jslib/pricing/price-history.jslib/pricing/collection-valuation.jslib/pricing/outbound-links.jstest/lib/pricing/card-price.test.jstest/lib/pricing/price-history.test.jstest/lib/pricing/collection-valuation.test.js
Conventions to follow
- ESM (
import/export); DB viaimport { sql } from '../sql.js'(relative fromlib/pricing/). card-price.js: exportresolveUnitPrice({ currentPrice, marketPrice, isFoil })— nonfoil preferscurrent_price, foil prefersmarket_price; exportPRICE_STALE_HOURS = 24.collection-valuation.js: exporteffectiveUnitPriceExpr({ cardAlias = 'c', userCardAlias = 'uc' })returning SQLCASE WHEN uc.is_foil THEN c.market_price ELSE COALESCE(c.current_price, c.market_price) END; exportlistUnitPriceExpr({ cardAlias = 'c' })→COALESCE(c.current_price, c.market_price).price-history.js: exportrecordPriceSnapshots(rows)where each row is{ cardId, source, priceType, currency, amount }; upsert on daily UNIQUE key.outbound-links.js: extract TCGPlayer + eBay URL logic currently inline inCardDetailView.js(game-aware).- Mirror test style from
test/lib/collection-vocabulary.test.js.
Acceptance criteria
resolveUnitPricereturns foil vs nonfoil correctly for MTG-shaped datarecordPriceSnapshotsis idempotent for same card/day/source/typeeffectiveUnitPriceExprproduces valid SQL fragment (unit-tested via known inputs or integration mock)buildTcgplayerUrl(card)andbuildEbayUrl(card)exported- All three test files pass (
npm run test:run) - No scope expansion
Rationale (≤3 sentences)
Centralizes pricing semantics so bulk sync, valuation fix, and APIs cannot drift. The foil bug (market_price = Scryfall usd_foil) is fixed once at the helper layer. Snapshot writer gives Briefs 3–5 a single hook.