(feat): Add TCGTracking pricing integration and ?pricing query param#1428
Open
FalconChipp wants to merge 5 commits into
Open
(feat): Add TCGTracking pricing integration and ?pricing query param#1428FalconChipp wants to merge 5 commits into
?pricing query param#1428FalconChipp wants to merge 5 commits into
Conversation
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.
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.
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.
?pricing query param
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.
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.
Add TCGTracking pricing integration and
?pricingquery parameterIntegrates TCGTracking as a pricing source alongside the existing TCGCSV-backed TCGPlayer data, and exposes a
?pricingpreset 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 byPRICING_SOURCES. Replaces legacy TCGTracking-specific scripts with a unifiedupdatePricing.ts.TCGTracking cache merge — TCGTracking price variants are stored under a
tcgtrackingsub-key in the pricing cache alongside TCGCSV variants, keeping both sources independently addressable.?pricingquery param — all card endpoints (/v2/:lang/cardsand/v2/:lang/cards/:id) now accept apricingpreset:full(default)pricestcgtrackingmetacardtraderId+isSealedonlynonetcgplayerentirelyBug fix — silent failure in
loadPricingCache()caused all TCGPlayer pricing to returnnull; the rejection is now logged and the cache loads correctly.