Skip to content

(feat): Add TCGTracking pricing integration and ?pricing query param#1428

Open
FalconChipp wants to merge 5 commits into
masterfrom
TCGTracking-as-a-new-pricing-source
Open

(feat): Add TCGTracking pricing integration and ?pricing query param#1428
FalconChipp wants to merge 5 commits into
masterfrom
TCGTracking-as-a-new-pricing-source

Conversation

@FalconChipp

@FalconChipp FalconChipp commented May 11, 2026

Copy link
Copy Markdown
Member

Add TCGTracking pricing integration and ?pricing query parameter

Integrates TCGTracking as a pricing source alongside the existing TCGCSV-backed TCGPlayer data, and exposes a ?pricing preset parameter on card endpoints.

Changes

New pricing scripts (scripts/pricing/) — modular provider system for fetching and caching set pricing from TCGTracking, with TCGCSV as a fallback. Source order is controlled by PRICING_SOURCES. Replaces legacy TCGTracking-specific scripts with a unified updatePricing.ts.

TCGTracking cache merge — TCGTracking price variants are stored under a tcgtracking sub-key in the pricing cache alongside TCGCSV variants, keeping both sources independently addressable.

?pricing query param — all card endpoints (/v2/:lang/cards and /v2/:lang/cards/:id) now accept a pricing preset:

Value Returns
full (default) TCGCSV prices + TCGTracking prices + metadata
prices TCGCSV price variants only
tcgtracking TCGTracking price variants + metadata
meta cardtraderId + isSealed only
none omits tcgplayer entirely

Bug fix — silent failure in loadPricingCache() caused all TCGPlayer pricing to return null; the rejection is now logged and the cache loads correctly.

Introduce TCGTracking-based pricing pipeline and server support.

- Add new scripts: scripts/preloadTCGTracking.ts (caches TCGTracking set pricing), scripts/updatePricingFromTCGTracking.ts (resolves cached pricing to a resolved-pricing artifact), and scripts/utils-data/tcgtracking.ts (helpers, fetcher, cache path helpers, category mapping, import URL fix).
- Extend scripts/preloadTCGPlayer.ts to also download TCGCSV prices into var/models/tcgplayer/prices as a fallback.
- Add set ID override support, daily cache freshness checks, polite fetch delays, failure reporting (var/reports/tcgtracking-preload-failures.json), and --strict/--apply flags for control.
- New pricing resolver supports three modes via PRICING_SOURCE: tcgtracking (default), tcgcsv (old fallback), tcgtracking-only; updatePricingFromTCGTracking supports dry-run and apply and writes var/models/tcgtracking/resolved-pricing.json when applied.
- Wire the server to use the new provider: add server/src/libs/providers/tcgplayer/tcgtracking.ts and load it by default in server/src/libs/providers/tcgplayer/index.ts unless official credentials or PRICING_SOURCE=tcgcsv are present.

Notes: The scripts do not mutate card source files or create/remap variants; caching filenames use existing TCGPlayer set IDs to remain compatible with existing data.
@FalconChipp FalconChipp marked this pull request as draft May 11, 2026 15:46
Add a unified pricing subsystem and updater: new files under scripts/pricing (cache, sources, tcgplayer, tcgtracking, types) and a top-level scripts/updatePricing.ts that scans card files, resolves prices from configured providers, and writes reports/debug artifacts. Implements a TTLCache, provider factory/ordering (TCGDEX_PRICING_SOURCES), TCGPlayer and TCGTracking providers with caching and inflight deduplication, and set ID overrides for TCGTracking. Remove legacy TCGTracking-specific preload/update scripts (scripts/preloadTCGTracking.ts and scripts/updatePricingFromTCGTracking.ts) and update package.json scripts to use pricing:update / pricing:update:debug.
@FalconChipp FalconChipp marked this pull request as ready for review May 11, 2026 19:44
Integrate TCGTracking product metadata (CardTrader ID and sealed flag) and make pricing more configurable. Key changes:

- Fetch and cache TCGTracking set products and attach cardtraderId/isSealed to product pricing (scripts/utils-data, scripts/pricing).
- Add ProductMeta cache and use it when resolving prices in TCGTrackingProvider.
- Introduce buildTCGTrackingBaseUrl/buildTCGTrackingHeaders to support proxy and API key for TCGTracking requests.
- Add PricingMode type and PRICING_MODES with modes (full, prices, tcgtracking, meta, none) and plumb it through the server APIs and card loading/caching, including separate cache keys per pricing mode.
- Change TCGPlayer provider logic: unify backend selection, run TCGCSV/official proxy and TCGTracking in tandem, merge TCGTracking metadata and price variants into the worker cache, and provide mode-aware getTCGPlayerPrice behavior.
- Expose helpers for TCGTracking cache (getCache/fillCache) and improve update flow to parallelize pricing and metadata fetching.
- Add parsing for ?pricing query param and propagate pricingMode in JSON endpoints.
- Minor cleanup: remove noisy console logs and adjust TTLs/formatting.

These changes allow returning TCGTracking metadata alongside prices, selecting which pricing data to return per-request, and routing TCGTracking requests through a proxy when configured.
@FalconChipp FalconChipp changed the title Add TCGTracking pricing integration and scripts (feat): Add TCGTracking pricing integration and ?pricing query param Jun 10, 2026
Add an explicit cast for the TCGTracking fetch result (returning Promise<TCGTrackingSetProductsResponse>) to ensure correct typing. Also remove the unused PRICING_MODES import from server/src/V2/Components/Card.ts to clean up imports.
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.

2 participants