tcgpriser 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -95,9 +95,19 @@ var HttpClient = class {
95
95
  });
96
96
  if (!res.ok) throw await toApiError(res, url);
97
97
  if (res.status === 204) return void 0;
98
- return await res.json();
98
+ return nullsToUndefined(await res.json());
99
99
  }
100
100
  };
101
+ function nullsToUndefined(value) {
102
+ if (value === null) return void 0;
103
+ if (Array.isArray(value)) return value.map(nullsToUndefined);
104
+ if (typeof value === "object") {
105
+ const result = {};
106
+ for (const [key, v] of Object.entries(value)) result[key] = nullsToUndefined(v);
107
+ return result;
108
+ }
109
+ return value;
110
+ }
101
111
 
102
112
  // src/resources/bargains.ts
103
113
  var BargainsResource = class {
@@ -451,7 +461,11 @@ var TcgPriser = class {
451
461
  }
452
462
  const http = new HttpClient({
453
463
  baseUrl: advanced.baseUrl ?? DEFAULT_BASE_URL,
454
- fetch: advanced.fetch ?? fetch,
464
+ // Bound to globalThis: both browsers and Node's undici implement fetch as a method that
465
+ // checks its receiver, so an unbound reference throws "Illegal invocation" the moment it's
466
+ // called through anything other than `window.fetch(...)`/`globalThis.fetch(...)` — which is
467
+ // exactly what happens once HttpClient stores it and calls `this.fetchImpl(...)`.
468
+ fetch: advanced.fetch ?? fetch.bind(globalThis),
455
469
  headers: advanced.headers,
456
470
  authToken: options.authToken
457
471
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/bargains.ts","../src/resources/cards.ts","../src/resources/expansions.ts","../src/resources/packRates.ts","../src/resources/priceStats.ts","../src/resources/products.ts","../src/resources/shopMatchStats.ts","../src/resources/shopMatches.ts","../src/resources/shopUrls.ts","../src/resources/shops.ts","../src/resources/stats.ts","../src/client.ts"],"names":[],"mappings":";;;AAiBO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EAC/B,UAAA;AAAA,E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AAA,CAAK,WAAA,GAAc,IAAI,mBAAA,CAAoB,IAAI,CAAA;AAC/C,IAAA,IAAA,CAAK,cAAA,GAAiB,IAAI,sBAAA,CAAuB,IAAI,CAAA;AACrD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,kBAAA,CAAmB,IAAI,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAI,CAAA;AAC3C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.cjs","sourcesContent":["/** The stable error codes the API's `error.code` field can hold. */\nexport type TcgPriserErrorCode =\n | 'validationFailed'\n | 'unauthorized'\n | 'forbidden'\n | 'notFound'\n | 'conflict'\n | 'readOnlyField'\n | 'rateLimited'\n | 'premiumRequired'\n | 'internalError'\n /** Response body wasn't the `{ error: { code, message } }` shape. Probably a proxy or gateway\n * error in front of the API. */\n | 'unknown';\n\n/** Thrown for any non-2xx response. Carries the parsed `{ code, message }` when the body matched\n * the API's error envelope, plus the raw status/body regardless so nothing gets lost. */\nexport class TcgPriserError extends Error {\n readonly statusCode: number;\n readonly statusText: string;\n readonly url: string;\n readonly code: TcgPriserErrorCode;\n readonly details: unknown;\n /** The raw response body, for debugging when `code`/`details` don't cover what you need. */\n readonly body: string;\n\n constructor(params: {\n statusCode: number;\n statusText: string;\n url: string;\n code: TcgPriserErrorCode;\n message: string;\n details?: unknown;\n body: string;\n }) {\n super(`tcgpriser: ${params.statusCode} ${params.code} - ${params.message} (${params.url})`);\n this.name = 'TcgPriserError';\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.url = params.url;\n this.code = params.code;\n this.details = params.details;\n this.body = params.body;\n }\n}\n","import { TcgPriserError, type TcgPriserErrorCode } from './errors.js';\n\nexport type QueryValue = string | number | boolean | undefined | null;\n\n/**\n * Builds a query string from a params object, dropping `undefined`/`null` entries so callers can\n * pass params straight through without filtering first.\n *\n * Takes a generic `object` instead of `Record<string, QueryValue>` on purpose. The params\n * interfaces (`ListCardsParams` etc.) intentionally have no index signature, otherwise any string\n * key would type-check.\n */\nexport function toQueryString<T extends object>(params: T): string {\n const search = new URLSearchParams();\n for (const [key, value] of Object.entries(params) as [string, QueryValue][]) {\n if (value === undefined || value === null) continue;\n search.set(key, String(value));\n }\n const query = search.toString();\n return query ? `?${query}` : '';\n}\n\n/** Splits `authToken` off a params object so it goes on the `Authorization` header, not through\n * `toQueryString`. A bearer token has no business in a URL: query strings end up in server logs,\n * browser history, `Referer` headers. */\nexport function splitAuthToken<T extends { authToken?: string }>(\n params: T,\n): [Omit<T, 'authToken'>, string | undefined] {\n const { authToken, ...rest } = params;\n return [rest, authToken];\n}\n\nconst KNOWN_ERROR_CODES: ReadonlySet<string> = new Set([\n 'validationFailed',\n 'unauthorized',\n 'forbidden',\n 'notFound',\n 'conflict',\n 'readOnlyField',\n 'rateLimited',\n 'premiumRequired',\n 'internalError',\n]);\n\nasync function toApiError(res: Response, url: string): Promise<TcgPriserError> {\n const body = await res.text();\n let code: TcgPriserErrorCode = 'unknown';\n let message = res.statusText || 'Request failed';\n let details: unknown;\n\n try {\n const parsed = JSON.parse(body) as { error?: { code?: string; message?: string; details?: unknown } };\n if (parsed.error?.code && KNOWN_ERROR_CODES.has(parsed.error.code)) {\n code = parsed.error.code as TcgPriserErrorCode;\n }\n if (parsed.error?.message) message = parsed.error.message;\n details = parsed.error?.details;\n } catch {\n // Not the standard error envelope, maybe a proxy's HTML error page. Fall back to the status\n // text and leave `body` for anyone who wants to dig in.\n }\n\n return new TcgPriserError({ statusCode: res.status, statusText: res.statusText, url, code, message, details, body });\n}\n\nexport interface HttpClientOptions {\n baseUrl: string;\n fetch: typeof fetch;\n headers?: Record<string, string>;\n /** Default bearer token for premium endpoints, used when a call doesn't pass its own `authToken`. */\n authToken?: string;\n}\n\n/** Per-call auth override for a premium endpoint, on top of the client's default `authToken`.\n * Every premium method takes one of these, either standalone or merged into its params object via\n * `splitAuthToken`. */\nexport interface PremiumOptions {\n /** Overrides the client's default `authToken` for this call. Pass `undefined` explicitly to\n * force an anonymous request even when the client has a default token. */\n authToken?: string;\n}\n\n/** Thin wrapper around `fetch`: joins the base URL, adds default headers, turns non-2xx responses\n * into a `TcgPriserError`. Every resource method goes through this instead of calling `fetch`\n * directly. */\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly defaultHeaders: Record<string, string>;\n private readonly defaultAuthToken: string | undefined;\n\n constructor(options: HttpClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.fetchImpl = options.fetch;\n this.defaultHeaders = options.headers ?? {};\n this.defaultAuthToken = options.authToken;\n }\n\n get<T>(path: string, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('GET', path, undefined, requestOptions);\n }\n\n post<T>(path: string, body: unknown, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('POST', path, body, requestOptions);\n }\n\n patch<T>(path: string, body: unknown, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('PATCH', path, body, requestOptions);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n requestOptions?: PremiumOptions,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const authToken = requestOptions && 'authToken' in requestOptions ? requestOptions.authToken : this.defaultAuthToken;\n\n const headers: Record<string, string> = { Accept: 'application/json', ...this.defaultHeaders };\n if (authToken) headers.Authorization = `Bearer ${authToken}`;\n if (body !== undefined) headers['Content-Type'] = 'application/json';\n\n const res = await this.fetchImpl(url, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n\n if (!res.ok) throw await toApiError(res, url);\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n Bargain,\n BargainReferenceSource,\n CardType,\n GradingCompany,\n ItemCondition,\n ListResponse,\n PaginationParams,\n} from '../types/index.js';\n\nexport interface ListBargainsParams {\n type?: 'sealed' | 'card' | 'all';\n}\n\nexport interface SearchBargainsParams extends PaginationParams {\n authToken?: string;\n type?: 'sealed' | 'card' | 'all';\n /** Filter by shop technicalName. */\n shop?: string;\n /** Filter by which reference price source qualified the bargain. */\n referenceSource?: BargainReferenceSource;\n /** Minimum discount percentage. Default 10. */\n minDiscount?: number;\n /** Default `true`. */\n inStock?: boolean;\n cardType?: CardType;\n itemCondition?: ItemCondition;\n gradingCompany?: GradingCompany;\n grade?: number;\n /** Free-text search on product name / technicalName. */\n search?: string;\n}\n\nexport class BargainsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /bargains`: current shop listings priced notably below their reference price. Result\n * count is fixed by the API (no `limit`/`skip` on the public tier); `pagination.hasMore` tells\n * you if more exist. */\n list(params: ListBargainsParams = {}): Promise<ListResponse<Bargain>> {\n return this.http.get(`/bargains${toQueryString(params)}`);\n }\n\n /** `GET /bargains/search`: like `list()`, but with real pagination and filters (shop, discount\n * threshold, card condition/grade, free-text search). Premium. */\n search(params: SearchBargainsParams = {}): Promise<ListResponse<Bargain>> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/bargains/search${toQueryString(query)}`, { authToken });\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n Card,\n CardType,\n ItemReferencePrices,\n ItemShopMatches,\n ItemSoldPrices,\n ListResponse,\n LivePricingForItem,\n PaginationParams,\n ReferencePriceCardVariant,\n ReferencePriceProvider,\n} from '../types/index.js';\n\nexport interface ListCardsParams extends PaginationParams {\n /** Free-text search over card and set names. */\n search?: string;\n}\n\nexport interface CardMatchesParams extends PaginationParams {\n /** Keep only matches whose shop currently has stock. */\n inStock?: boolean;\n}\n\nexport interface CardReferencePricesParams {\n /** Bearer token for this call. Overrides the client's default `authToken`. */\n authToken?: string;\n /** Rolling window ending today, in days. Ignored when `from`/`to` are supplied. Default 90. */\n days?: number;\n /** `YYYY-MM-DD` */\n from?: string;\n /** `YYYY-MM-DD` */\n to?: string;\n provider?: ReferencePriceProvider;\n cardType?: CardType;\n variant?: ReferencePriceCardVariant;\n}\n\nexport interface CardPricesParams extends PaginationParams {\n authToken?: string;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /cards`: search or list cards. */\n list(params: ListCardsParams = {}): Promise<ListResponse<Card>> {\n return this.http.get(`/cards${toQueryString(params)}`);\n }\n\n /** `GET /cards/{id}`: fetch one card by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<Card> {\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}`);\n }\n\n /** `GET /cards/{id}/matches`: current shop listings matched to this card (latest per shop). */\n matches(idOrTechnicalName: string, params: CardMatchesParams = {}): Promise<ItemShopMatches> {\n return this.http.get(\n `/cards/${encodeURIComponent(idOrTechnicalName)}/matches${toQueryString(params)}`,\n );\n }\n\n /** `GET /cards/{id}/reference-prices`: Cardmarket/TCGplayer/eBay/Tradera price history. Premium. */\n referencePrices(\n idOrTechnicalName: string,\n params: CardReferencePricesParams = {},\n ): Promise<ItemReferencePrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/cards/${encodeURIComponent(idOrTechnicalName)}/reference-prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /cards/{id}/prices`: individual marketplace sale records. Premium. */\n prices(idOrTechnicalName: string, params: CardPricesParams = {}): Promise<ItemSoldPrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}/prices${toQueryString(query)}`, {\n authToken,\n });\n }\n\n /** `GET /cards/{id}/pricing/live`: computed fresh for this request, not read from the last\n * stats job. Premium. */\n livePricing(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<LivePricingForItem> {\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}/pricing/live`, options);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport type { Expansion, ExpansionContents, ExpansionLivePricing } from '../types/index.js';\n\nexport class ExpansionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /expansions`: every expansion. Unwrapped to a plain array, nothing to paginate here. */\n async list(): Promise<Expansion[]> {\n const res = await this.http.get<{ data: Expansion[] }>('/expansions');\n return res.data;\n }\n\n /** `GET /expansions/{technicalName}/products`: every card and sealed product in one\n * expansion, kept as separate `cards`/`sealed` groups. */\n products(technicalName: string): Promise<ExpansionContents> {\n return this.http.get(`/expansions/${encodeURIComponent(technicalName)}/products?grouped=true`);\n }\n\n /** `GET /expansions/{technicalName}/products/live-pricing`: computed fresh for every item in\n * this expansion, not read from the last stats job. Premium. */\n livePricing(technicalName: string, options: PremiumOptions = {}): Promise<ExpansionLivePricing> {\n return this.http.get(\n `/expansions/${encodeURIComponent(technicalName)}/products/live-pricing`,\n options,\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { PackRate } from '../types/index.js';\n\nexport class PackRatesResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /pack-rates`: pull-rate odds for every expansion that has them. Unwrapped to a plain\n * array, nothing to paginate here. */\n async list(): Promise<PackRate[]> {\n const res = await this.http.get<{ data: PackRate[] }>('/pack-rates');\n return res.data;\n }\n\n /** `GET /pack-rates/{expansionId}`: pull-rate odds for one expansion. */\n get(expansionId: string): Promise<PackRate> {\n return this.http.get(`/pack-rates/${encodeURIComponent(expansionId)}`);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n CardType,\n GradingCompany,\n ItemCondition,\n ItemDailyStats,\n ItemEstimatedValue,\n ItemFullStats,\n ItemStats,\n ItemVariantDailyStats,\n ItemVariantStats,\n ListResponse,\n TopItem,\n} from '../types/index.js';\n\n/** Filters shared by `daily()` and `estimatedValues()`: all narrow which product(s) the stats\n * cover; combine as many as you like. */\nexport interface ProductFilterParams {\n productName?: string;\n technicalName?: string;\n priceChartingId?: string;\n modelNumber?: string;\n /** Category technicalName. */\n category?: string;\n /** Expansion technicalName. */\n expansion?: string;\n}\n\nexport interface DailyPriceStatsParams extends ProductFilterParams {\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Expansion id (ObjectId), an alternative to `expansion` (technicalName). */\n expansionId?: string;\n /** Category id (ObjectId), an alternative to `category` (technicalName). */\n categoryId?: string;\n}\n\nexport interface EstimatedValuesParams extends ProductFilterParams {\n page?: number;\n limit?: number;\n}\n\nexport interface TopProductsParams {\n limit?: number;\n}\n\nexport interface ProductDailyStatsParams {\n authToken?: string;\n /** Number of days to retrieve, from today backwards. Default 30. */\n days?: number;\n}\n\nexport interface ProductByVariantParams {\n authToken?: string;\n /** Number of days to include in the average calculation. Default 30. */\n days?: number;\n}\n\nexport interface ProductDailyByVariantParams {\n authToken?: string;\n cardType: CardType;\n /** Required when `cardType` is `'loose'`. */\n condition?: ItemCondition;\n /** Required when `cardType` is `'graded'`. */\n gradingCompany?: GradingCompany;\n /** Required when `cardType` is `'graded'`. */\n grade?: number;\n /** Number of days to retrieve. Default 30. */\n days?: number;\n}\n\nexport class PriceStatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /price-stats/daily`: daily average price history, filtered to matching product(s). */\n daily(params: DailyPriceStatsParams = {}): Promise<ListResponse<ItemDailyStats>> {\n return this.http.get(`/price-stats/daily${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/estimated-values`: current estimated market value, filtered to matching\n * product(s). */\n estimatedValues(params: EstimatedValuesParams = {}): Promise<ListResponse<ItemEstimatedValue>> {\n return this.http.get(`/price-stats/estimated-values${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/top-products`: items ranked by shop availability (how many shops carry\n * them), not by price. */\n topProducts(params: TopProductsParams = {}): Promise<ListResponse<TopItem>> {\n return this.http.get(`/price-stats/top-products${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/product/{id}`: daily price history, current estimate, and a variant-count\n * summary for one product. Premium. */\n product(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemStats> {\n return this.http.get(`/price-stats/product/${encodeURIComponent(idOrTechnicalName)}`, options);\n }\n\n /** `GET /price-stats/product/{id}/full`: everything `product()` has, plus the item's current\n * shop matches. Premium. */\n productFull(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemFullStats> {\n return this.http.get(`/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/full`, options);\n }\n\n /** `GET /price-stats/product/{id}/daily`: daily price history for one product, with a\n * caller-chosen window. Premium. */\n productDaily(\n idOrTechnicalName: string,\n params: ProductDailyStatsParams = {},\n ): Promise<ItemDailyStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /price-stats/product/{id}/daily-last-30`: daily price history for the last 30 days\n * exactly (no window param, for callers that want a stable cache key). Premium. */\n productDailyLast30(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemDailyStats> {\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily-last-30`,\n options,\n );\n }\n\n /** `GET /price-stats/product/{id}/estimated-value`: current estimated value only. Premium. */\n productEstimatedValue(\n idOrTechnicalName: string,\n options: PremiumOptions = {},\n ): Promise<ItemEstimatedValue> {\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/estimated-value`,\n options,\n );\n }\n\n /** `GET /price-stats/product/{id}/by-variant`: price stats broken out per card condition/grade.\n * Premium. */\n productByVariant(\n idOrTechnicalName: string,\n params: ProductByVariantParams = {},\n ): Promise<ItemVariantStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/by-variant${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /price-stats/product/{id}/daily-by-variant`: daily price history for one specific\n * condition/grade. `condition` is required for `cardType: 'loose'`; `gradingCompany` and `grade`\n * are required for `cardType: 'graded'`. Premium. */\n productDailyByVariant(\n idOrTechnicalName: string,\n params: ProductDailyByVariantParams,\n ): Promise<ItemVariantDailyStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily-by-variant${toQueryString(query)}`,\n { authToken },\n );\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n CardType,\n GradingCompany,\n ItemCondition,\n ItemReferencePrices,\n ItemShopMatches,\n ItemSoldPrices,\n ListResponse,\n LivePricingForItem,\n PaginationParams,\n ReferencePriceProvider,\n SealedProduct,\n} from '../types/index.js';\n\nexport interface ListProductsParams extends PaginationParams {\n /** Whitespace-separated tokens, each matched against the start of a word. */\n search?: string;\n}\n\nexport interface ProductMatchesParams extends PaginationParams {\n /** Keep only matches whose shop currently has stock. */\n inStock?: boolean;\n cardType?: CardType;\n condition?: ItemCondition;\n gradingCompany?: GradingCompany;\n grade?: number;\n}\n\nexport interface ProductReferencePricesParams {\n authToken?: string;\n /** Rolling window ending today, in days. Ignored when `from`/`to` are supplied. Default 90. */\n days?: number;\n /** `YYYY-MM-DD` */\n from?: string;\n /** `YYYY-MM-DD` */\n to?: string;\n provider?: ReferencePriceProvider;\n}\n\nexport interface ProductPricesParams extends PaginationParams {\n authToken?: string;\n}\n\n/** Sealed products: booster boxes, ETBs, tins, and the like. Single cards live under\n * `client.cards` instead. */\nexport class ProductsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /product`: search or list sealed products. */\n list(params: ListProductsParams = {}): Promise<ListResponse<SealedProduct>> {\n return this.http.get(`/product${toQueryString(params)}`);\n }\n\n /** `GET /product/{id}`: fetch one sealed product by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<SealedProduct> {\n return this.http.get(`/product/${encodeURIComponent(idOrTechnicalName)}`);\n }\n\n /** `GET /product/{id}/matches`: current shop listings matched to this product (latest per shop). */\n matches(idOrTechnicalName: string, params: ProductMatchesParams = {}): Promise<ItemShopMatches> {\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/matches${toQueryString(params)}`,\n );\n }\n\n /** `GET /product/{id}/reference-prices`: Cardmarket/TCGplayer/Tradera price history. Premium. */\n referencePrices(\n idOrTechnicalName: string,\n params: ProductReferencePricesParams = {},\n ): Promise<ItemReferencePrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/reference-prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /product/{id}/prices`: individual marketplace sale records. Premium. */\n prices(idOrTechnicalName: string, params: ProductPricesParams = {}): Promise<ItemSoldPrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /product/{id}/pricing/live`: computed fresh for this request, not read from the last\n * stats job. Premium. */\n livePricing(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<LivePricingForItem> {\n return this.http.get(`/product/${encodeURIComponent(idOrTechnicalName)}/pricing/live`, options);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type { ItemPriceComparison, ItemShopPriceHistory, ShopPriceHistoryList } from '../types/index.js';\n\nexport interface ShopMatchStatsForProductParams {\n authToken?: string;\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Filter to one shop's technicalName. */\n shop?: string;\n}\n\nexport interface ShopMatchStatsForShopParams {\n authToken?: string;\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Maximum products to return. Default 100. */\n limit?: number;\n}\n\nexport interface CompareShopPricesParams {\n authToken?: string;\n /** Product/card id or technicalName. */\n productId: string;\n /** `YYYY-MM-DD`: defaults to the latest date with data. */\n date?: string;\n}\n\n/** Historical shop-vs-price data, distinct from `client.shopMatches` (which is the current/latest\n * match state). Everything here is premium. */\nexport class ShopMatchStatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shop-match-stats/product/{productId}`: one product's price history, broken out per shop. */\n forProduct(\n productId: string,\n params: ShopMatchStatsForProductParams = {},\n ): Promise<ItemShopPriceHistory> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/shop-match-stats/product/${encodeURIComponent(productId)}${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /shop-match-stats/shop/{shop}`: one shop's price history, broken out per product. */\n forShop(shop: string, params: ShopMatchStatsForShopParams = {}): Promise<ShopPriceHistoryList> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/shop-match-stats/shop/${encodeURIComponent(shop)}${toQueryString(query)}`, {\n authToken,\n });\n }\n\n /** `GET /shop-match-stats/compare`: one product's price at every shop that carries it, as of\n * one date (defaults to the latest). */\n compare(params: CompareShopPricesParams): Promise<ItemPriceComparison> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/shop-match-stats/compare${toQueryString(query)}`, { authToken });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { toQueryString } from '../http.js';\nimport type { ListResponse, PaginationParams, ShopMatch, ShopMatchesForShop, ShopMatchStats } from '../types/index.js';\n\nexport interface ListShopMatchesParams extends PaginationParams {\n /** Filter to one shop's technicalName. */\n shop?: string;\n inStock?: boolean;\n /** Filter by whether the listing has been resolved to a catalog item. */\n linked?: boolean;\n}\n\nexport interface ShopMatchesForShopParams extends PaginationParams {\n inStock?: boolean;\n}\n\n/** Raw shop-to-catalog match data: what's currently listed where, independent of which item or\n * shop you start from. For \"what does this card cost at each shop\" or \"what's in stock at this\n * shop\", prefer `client.cards.matches()` / `client.products.matches()` /\n * `client.shopMatches.forShop()`. */\nexport class ShopMatchesResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shop-matches`: every current match across every shop (latest record per url+shop). */\n list(params: ListShopMatchesParams = {}): Promise<ListResponse<ShopMatch>> {\n return this.http.get(`/shop-matches${toQueryString(params)}`);\n }\n\n /** `GET /shop-matches/{shop}`: every current match at one shop (latest record per url). */\n forShop(technicalName: string, params: ShopMatchesForShopParams = {}): Promise<ShopMatchesForShop> {\n return this.http.get(`/shop-matches/${encodeURIComponent(technicalName)}${toQueryString(params)}`);\n }\n\n /** `GET /shop-matches/shops`: match counts per shop (based on latest records only). */\n shopStats(params: PaginationParams = {}): Promise<ListResponse<ShopMatchStats>> {\n return this.http.get(`/shop-matches/shops${toQueryString(params)}`);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport type { ShopUrlMutationResult } from '../types/index.js';\n\nexport interface SubmitShopUrlParams extends PremiumOptions {\n url: string;\n /** Shop technicalName. Auto-created if it doesn't exist yet. */\n shop: string;\n}\n\nexport interface AssignShopUrlProductParams extends PremiumOptions {\n /** Product/card id to link, or `null` to unlink and let auto-matching resume. */\n productId: string | null;\n}\n\n/** Lets a signed-in subscriber contribute to the catalog: submit a shop URL for scraping, or\n * manually correct which product/card a URL resolves to. Both premium, both mutating. */\nexport class ShopUrlsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `POST /shop-urls/submit`: submit a shop URL for scraping. */\n submit(params: SubmitShopUrlParams): Promise<ShopUrlMutationResult> {\n const { authToken, url, shop } = params;\n return this.http.post('/shop-urls/submit', { url, shop }, { authToken });\n }\n\n /** `PATCH /shop-urls/{id}/product`: manually assign (or clear) the product a shop URL resolves to. */\n assignProduct(\n shopUrlId: string,\n params: AssignShopUrlProductParams,\n ): Promise<ShopUrlMutationResult> {\n const { authToken, productId } = params;\n return this.http.patch(\n `/shop-urls/${encodeURIComponent(shopUrlId)}/product`,\n { productId },\n { authToken },\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { toQueryString } from '../http.js';\nimport type { Shop } from '../types/index.js';\n\nexport interface ListShopsParams {\n active?: boolean;\n}\n\nexport class ShopsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shops`: every tracked shop. Unwrapped to a plain array, nothing to paginate here. */\n async list(params: ListShopsParams = {}): Promise<Shop[]> {\n const res = await this.http.get<{ data: Shop[] }>(`/shops${toQueryString(params)}`);\n return res.data;\n }\n\n /** `GET /shops/{id}`: fetch one shop by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<Shop> {\n return this.http.get(`/shops/${encodeURIComponent(idOrTechnicalName)}`);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { PlatformStats } from '../types/index.js';\n\nexport class StatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /stats`: platform-wide overview counts (shops, expansions, products, prices tracked). */\n platform(): Promise<PlatformStats> {\n return this.http.get('/stats');\n }\n}\n","import { HttpClient } from './http.js';\nimport { BargainsResource } from './resources/bargains.js';\nimport { CardsResource } from './resources/cards.js';\nimport { ExpansionsResource } from './resources/expansions.js';\nimport { PackRatesResource } from './resources/packRates.js';\nimport { PriceStatsResource } from './resources/priceStats.js';\nimport { ProductsResource } from './resources/products.js';\nimport { ShopMatchStatsResource } from './resources/shopMatchStats.js';\nimport { ShopMatchesResource } from './resources/shopMatches.js';\nimport { ShopUrlsResource } from './resources/shopUrls.js';\nimport { ShopsResource } from './resources/shops.js';\nimport { StatsResource } from './resources/stats.js';\n\nexport const DEFAULT_BASE_URL = 'https://api.tcgpriser.se';\n\n/** Local dev, self-hosting and testing overrides. Most integrations never touch these. */\nexport interface TcgPriserAdvancedOptions {\n /** Point at a local dev server or a self-hosted instance. Defaults to production. */\n baseUrl?: string;\n /** Extra headers sent on every request, e.g. a custom `User-Agent`. */\n headers?: Record<string, string>;\n /** Swap in a different `fetch` (older Node, testing, a proxying agent). Defaults to global `fetch`. */\n fetch?: typeof fetch;\n}\n\nexport interface TcgPriserOptions {\n /**\n * A signed-in subscriber's JWT. Only needed for premium methods (`cards.prices()`,\n * `priceStats.product()`, `bargains.search()` etc.); public methods work fine without it.\n * This client has no login flow of its own, so bring your own token.\n *\n * Every premium method also accepts its own `authToken` to override this per call. Useful when\n * one server-side client is shared across requests for several different signed-in users.\n */\n authToken?: string;\n /** Local dev / self-hosting / testing overrides. Leave unset unless you know you need it. */\n advanced?: TcgPriserAdvancedOptions;\n}\n\n/**\n * Client for the tcgpriser.se API: Pokémon TCG price data, catalog, shop matches and bargains for\n * shops tracked in Sweden.\n *\n * ```ts\n * import { TcgPriser } from 'tcgpriser';\n *\n * const tcgpriser = new TcgPriser();\n * const card = await tcgpriser.cards.get('mega-evolution-ascended-heroes-fezandipiti-ex');\n * console.log(card.retailPrice, card.lowestShopOffer?.shop.name);\n * ```\n *\n * That example needs no token. Most of the API is public (https://api.tcgpriser.se/docs). A\n * smaller set of premium methods (live pricing, per-condition history, shop comparison, bargain\n * search, shop-URL submission) need a subscriber's JWT (https://api.tcgpriser.se/premium-docs):\n *\n * ```ts\n * const tcgpriser = new TcgPriser(myJwt); // shorthand for { authToken: myJwt }\n * await tcgpriser.cards.livePricing('fezandipiti-ex');\n * ```\n */\nexport class TcgPriser {\n readonly cards: CardsResource;\n readonly products: ProductsResource;\n readonly expansions: ExpansionsResource;\n readonly shops: ShopsResource;\n readonly shopMatches: ShopMatchesResource;\n readonly shopMatchStats: ShopMatchStatsResource;\n readonly shopUrls: ShopUrlsResource;\n readonly priceStats: PriceStatsResource;\n readonly bargains: BargainsResource;\n readonly packRates: PackRatesResource;\n readonly stats: StatsResource;\n\n /**\n * @param optionsOrAuthToken A subscriber JWT (`new TcgPriser(myJwt)`), a full\n * `TcgPriserOptions` object, or omit it entirely for an anonymous, public-only client.\n */\n constructor(optionsOrAuthToken?: string | TcgPriserOptions) {\n const options: TcgPriserOptions =\n typeof optionsOrAuthToken === 'string' ? { authToken: optionsOrAuthToken } : (optionsOrAuthToken ?? {});\n const advanced = options.advanced ?? {};\n\n if (!advanced.fetch && typeof fetch === 'undefined') {\n throw new Error(\n 'tcgpriser: no global fetch found. Pass { advanced: { fetch } } explicitly on Node < 18, or run on Node 18+.',\n );\n }\n\n const http = new HttpClient({\n baseUrl: advanced.baseUrl ?? DEFAULT_BASE_URL,\n fetch: advanced.fetch ?? fetch,\n headers: advanced.headers,\n authToken: options.authToken,\n });\n\n this.cards = new CardsResource(http);\n this.products = new ProductsResource(http);\n this.expansions = new ExpansionsResource(http);\n this.shops = new ShopsResource(http);\n this.shopMatches = new ShopMatchesResource(http);\n this.shopMatchStats = new ShopMatchStatsResource(http);\n this.shopUrls = new ShopUrlsResource(http);\n this.priceStats = new PriceStatsResource(http);\n this.bargains = new BargainsResource(http);\n this.packRates = new PackRatesResource(http);\n this.stats = new StatsResource(http);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/bargains.ts","../src/resources/cards.ts","../src/resources/expansions.ts","../src/resources/packRates.ts","../src/resources/priceStats.ts","../src/resources/products.ts","../src/resources/shopMatchStats.ts","../src/resources/shopMatches.ts","../src/resources/shopUrls.ts","../src/resources/shops.ts","../src/resources/stats.ts","../src/client.ts"],"names":[],"mappings":";;;AAiBO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EAC/B,UAAA;AAAA,EACA,UAAA;AAAA,EACA,GAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA;AAAA,EAEA,IAAA;AAAA,EAET,YAAY,MAAA,EAQT;AACD,IAAA,KAAA,CAAM,CAAA,WAAA,EAAc,MAAA,CAAO,UAAU,CAAA,CAAA,EAAI,MAAA,CAAO,IAAI,CAAA,GAAA,EAAM,MAAA,CAAO,OAAO,CAAA,EAAA,EAAK,MAAA,CAAO,GAAG,CAAA,CAAA,CAAG,CAAA;AAC1F,IAAA,IAAA,CAAK,IAAA,GAAO,gB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,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,kBAAA,CAAmB,IAAI,CAAA;AAC7C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AACnC,IAAA,IAAA,CAAK,WAAA,GAAc,IAAI,mBAAA,CAAoB,IAAI,CAAA;AAC/C,IAAA,IAAA,CAAK,cAAA,GAAiB,IAAI,sBAAA,CAAuB,IAAI,CAAA;AACrD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,kBAAA,CAAmB,IAAI,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAI,CAAA;AAC3C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.cjs","sourcesContent":["/** The stable error codes the API's `error.code` field can hold. */\nexport type TcgPriserErrorCode =\n | 'validationFailed'\n | 'unauthorized'\n | 'forbidden'\n | 'notFound'\n | 'conflict'\n | 'readOnlyField'\n | 'rateLimited'\n | 'premiumRequired'\n | 'internalError'\n /** Response body wasn't the `{ error: { code, message } }` shape. Probably a proxy or gateway\n * error in front of the API. */\n | 'unknown';\n\n/** Thrown for any non-2xx response. Carries the parsed `{ code, message }` when the body matched\n * the API's error envelope, plus the raw status/body regardless so nothing gets lost. */\nexport class TcgPriserError extends Error {\n readonly statusCode: number;\n readonly statusText: string;\n readonly url: string;\n readonly code: TcgPriserErrorCode;\n readonly details: unknown;\n /** The raw response body, for debugging when `code`/`details` don't cover what you need. */\n readonly body: string;\n\n constructor(params: {\n statusCode: number;\n statusText: string;\n url: string;\n code: TcgPriserErrorCode;\n message: string;\n details?: unknown;\n body: string;\n }) {\n super(`tcgpriser: ${params.statusCode} ${params.code} - ${params.message} (${params.url})`);\n this.name = 'TcgPriserError';\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.url = params.url;\n this.code = params.code;\n this.details = params.details;\n this.body = params.body;\n }\n}\n","import { TcgPriserError, type TcgPriserErrorCode } from './errors.js';\n\nexport type QueryValue = string | number | boolean | undefined | null;\n\n/**\n * Builds a query string from a params object, dropping `undefined`/`null` entries so callers can\n * pass params straight through without filtering first.\n *\n * Takes a generic `object` instead of `Record<string, QueryValue>` on purpose. The params\n * interfaces (`ListCardsParams` etc.) intentionally have no index signature, otherwise any string\n * key would type-check.\n */\nexport function toQueryString<T extends object>(params: T): string {\n const search = new URLSearchParams();\n for (const [key, value] of Object.entries(params) as [string, QueryValue][]) {\n if (value === undefined || value === null) continue;\n search.set(key, String(value));\n }\n const query = search.toString();\n return query ? `?${query}` : '';\n}\n\n/** Splits `authToken` off a params object so it goes on the `Authorization` header, not through\n * `toQueryString`. A bearer token has no business in a URL: query strings end up in server logs,\n * browser history, `Referer` headers. */\nexport function splitAuthToken<T extends { authToken?: string }>(\n params: T,\n): [Omit<T, 'authToken'>, string | undefined] {\n const { authToken, ...rest } = params;\n return [rest, authToken];\n}\n\nconst KNOWN_ERROR_CODES: ReadonlySet<string> = new Set([\n 'validationFailed',\n 'unauthorized',\n 'forbidden',\n 'notFound',\n 'conflict',\n 'readOnlyField',\n 'rateLimited',\n 'premiumRequired',\n 'internalError',\n]);\n\nasync function toApiError(res: Response, url: string): Promise<TcgPriserError> {\n const body = await res.text();\n let code: TcgPriserErrorCode = 'unknown';\n let message = res.statusText || 'Request failed';\n let details: unknown;\n\n try {\n const parsed = JSON.parse(body) as { error?: { code?: string; message?: string; details?: unknown } };\n if (parsed.error?.code && KNOWN_ERROR_CODES.has(parsed.error.code)) {\n code = parsed.error.code as TcgPriserErrorCode;\n }\n if (parsed.error?.message) message = parsed.error.message;\n details = parsed.error?.details;\n } catch {\n // Not the standard error envelope, maybe a proxy's HTML error page. Fall back to the status\n // text and leave `body` for anyone who wants to dig in.\n }\n\n return new TcgPriserError({ statusCode: res.status, statusText: res.statusText, url, code, message, details, body });\n}\n\nexport interface HttpClientOptions {\n baseUrl: string;\n fetch: typeof fetch;\n headers?: Record<string, string>;\n /** Default bearer token for premium endpoints, used when a call doesn't pass its own `authToken`. */\n authToken?: string;\n}\n\n/** Per-call auth override for a premium endpoint, on top of the client's default `authToken`.\n * Every premium method takes one of these, either standalone or merged into its params object via\n * `splitAuthToken`. */\nexport interface PremiumOptions {\n /** Overrides the client's default `authToken` for this call. Pass `undefined` explicitly to\n * force an anonymous request even when the client has a default token. */\n authToken?: string;\n}\n\n/** Thin wrapper around `fetch`: joins the base URL, adds default headers, turns non-2xx responses\n * into a `TcgPriserError`. Every resource method goes through this instead of calling `fetch`\n * directly. */\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly defaultHeaders: Record<string, string>;\n private readonly defaultAuthToken: string | undefined;\n\n constructor(options: HttpClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.fetchImpl = options.fetch;\n this.defaultHeaders = options.headers ?? {};\n this.defaultAuthToken = options.authToken;\n }\n\n get<T>(path: string, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('GET', path, undefined, requestOptions);\n }\n\n post<T>(path: string, body: unknown, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('POST', path, body, requestOptions);\n }\n\n patch<T>(path: string, body: unknown, requestOptions?: PremiumOptions): Promise<T> {\n return this.request<T>('PATCH', path, body, requestOptions);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n requestOptions?: PremiumOptions,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const authToken = requestOptions && 'authToken' in requestOptions ? requestOptions.authToken : this.defaultAuthToken;\n\n const headers: Record<string, string> = { Accept: 'application/json', ...this.defaultHeaders };\n if (authToken) headers.Authorization = `Bearer ${authToken}`;\n if (body !== undefined) headers['Content-Type'] = 'application/json';\n\n const res = await this.fetchImpl(url, {\n method,\n headers,\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n\n if (!res.ok) throw await toApiError(res, url);\n if (res.status === 204) return undefined as T;\n return nullsToUndefined(await res.json()) as T;\n }\n}\n\n/** JSON has no `undefined`, so every optional field the API omits comes back over the wire as\n * `null`. Recurses through the parsed response and turns those into `undefined` so callers work\n * with idiomatic `foo?.bar` / `foo ?? fallback` instead of `foo !== null`, and so responses match\n * the `T | undefined` types in `generated/openapi.d.ts` (see `scripts/generate-types.mjs`). */\nfunction nullsToUndefined<T>(value: T): T {\n if (value === null) return undefined as T;\n if (Array.isArray(value)) return value.map(nullsToUndefined) as T;\n if (typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [key, v] of Object.entries(value)) result[key] = nullsToUndefined(v);\n return result as T;\n }\n return value;\n}\n","import type { HttpClient } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n Bargain,\n BargainReferenceSource,\n CardType,\n GradingCompany,\n ItemCondition,\n ListResponse,\n PaginationParams,\n} from '../types/index.js';\n\nexport interface ListBargainsParams {\n type?: 'sealed' | 'card' | 'all';\n}\n\nexport interface SearchBargainsParams extends PaginationParams {\n authToken?: string;\n type?: 'sealed' | 'card' | 'all';\n /** Filter by shop technicalName. */\n shop?: string;\n /** Filter by which reference price source qualified the bargain. */\n referenceSource?: BargainReferenceSource;\n /** Minimum discount percentage. Default 10. */\n minDiscount?: number;\n /** Default `true`. */\n inStock?: boolean;\n cardType?: CardType;\n itemCondition?: ItemCondition;\n gradingCompany?: GradingCompany;\n grade?: number;\n /** Free-text search on product name / technicalName. */\n search?: string;\n}\n\nexport class BargainsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /bargains`: current shop listings priced notably below their reference price. Result\n * count is fixed by the API (no `limit`/`skip` on the public tier); `pagination.hasMore` tells\n * you if more exist. */\n list(params: ListBargainsParams = {}): Promise<ListResponse<Bargain>> {\n return this.http.get(`/bargains${toQueryString(params)}`);\n }\n\n /** `GET /bargains/search`: like `list()`, but with real pagination and filters (shop, discount\n * threshold, card condition/grade, free-text search). Premium. */\n search(params: SearchBargainsParams = {}): Promise<ListResponse<Bargain>> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/bargains/search${toQueryString(query)}`, { authToken });\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n Card,\n CardType,\n ItemReferencePrices,\n ItemShopMatches,\n ItemSoldPrices,\n ListResponse,\n LivePricingForItem,\n PaginationParams,\n ReferencePriceCardVariant,\n ReferencePriceProvider,\n} from '../types/index.js';\n\nexport interface ListCardsParams extends PaginationParams {\n /** Free-text search over card and set names. */\n search?: string;\n}\n\nexport interface CardMatchesParams extends PaginationParams {\n /** Keep only matches whose shop currently has stock. */\n inStock?: boolean;\n}\n\nexport interface CardReferencePricesParams {\n /** Bearer token for this call. Overrides the client's default `authToken`. */\n authToken?: string;\n /** Rolling window ending today, in days. Ignored when `from`/`to` are supplied. Default 90. */\n days?: number;\n /** `YYYY-MM-DD` */\n from?: string;\n /** `YYYY-MM-DD` */\n to?: string;\n provider?: ReferencePriceProvider;\n cardType?: CardType;\n variant?: ReferencePriceCardVariant;\n}\n\nexport interface CardPricesParams extends PaginationParams {\n authToken?: string;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /cards`: search or list cards. */\n list(params: ListCardsParams = {}): Promise<ListResponse<Card>> {\n return this.http.get(`/cards${toQueryString(params)}`);\n }\n\n /** `GET /cards/{id}`: fetch one card by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<Card> {\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}`);\n }\n\n /** `GET /cards/{id}/matches`: current shop listings matched to this card (latest per shop). */\n matches(idOrTechnicalName: string, params: CardMatchesParams = {}): Promise<ItemShopMatches> {\n return this.http.get(\n `/cards/${encodeURIComponent(idOrTechnicalName)}/matches${toQueryString(params)}`,\n );\n }\n\n /** `GET /cards/{id}/reference-prices`: Cardmarket/TCGplayer/eBay/Tradera price history. Premium. */\n referencePrices(\n idOrTechnicalName: string,\n params: CardReferencePricesParams = {},\n ): Promise<ItemReferencePrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/cards/${encodeURIComponent(idOrTechnicalName)}/reference-prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /cards/{id}/prices`: individual marketplace sale records. Premium. */\n prices(idOrTechnicalName: string, params: CardPricesParams = {}): Promise<ItemSoldPrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}/prices${toQueryString(query)}`, {\n authToken,\n });\n }\n\n /** `GET /cards/{id}/pricing/live`: computed fresh for this request, not read from the last\n * stats job. Premium. */\n livePricing(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<LivePricingForItem> {\n return this.http.get(`/cards/${encodeURIComponent(idOrTechnicalName)}/pricing/live`, options);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport type { Expansion, ExpansionContents, ExpansionLivePricing } from '../types/index.js';\n\nexport class ExpansionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /expansions`: every expansion. Unwrapped to a plain array, nothing to paginate here. */\n async list(): Promise<Expansion[]> {\n const res = await this.http.get<{ data: Expansion[] }>('/expansions');\n return res.data;\n }\n\n /** `GET /expansions/{technicalName}/products`: every card and sealed product in one\n * expansion, kept as separate `cards`/`sealed` groups. */\n products(technicalName: string): Promise<ExpansionContents> {\n return this.http.get(`/expansions/${encodeURIComponent(technicalName)}/products?grouped=true`);\n }\n\n /** `GET /expansions/{technicalName}/products/live-pricing`: computed fresh for every item in\n * this expansion, not read from the last stats job. Premium. */\n livePricing(technicalName: string, options: PremiumOptions = {}): Promise<ExpansionLivePricing> {\n return this.http.get(\n `/expansions/${encodeURIComponent(technicalName)}/products/live-pricing`,\n options,\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { PackRate } from '../types/index.js';\n\nexport class PackRatesResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /pack-rates`: pull-rate odds for every expansion that has them. Unwrapped to a plain\n * array, nothing to paginate here. */\n async list(): Promise<PackRate[]> {\n const res = await this.http.get<{ data: PackRate[] }>('/pack-rates');\n return res.data;\n }\n\n /** `GET /pack-rates/{expansionId}`: pull-rate odds for one expansion. */\n get(expansionId: string): Promise<PackRate> {\n return this.http.get(`/pack-rates/${encodeURIComponent(expansionId)}`);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n CardType,\n GradingCompany,\n ItemCondition,\n ItemDailyStats,\n ItemEstimatedValue,\n ItemFullStats,\n ItemStats,\n ItemVariantDailyStats,\n ItemVariantStats,\n ListResponse,\n TopItem,\n} from '../types/index.js';\n\n/** Filters shared by `daily()` and `estimatedValues()`: all narrow which product(s) the stats\n * cover; combine as many as you like. */\nexport interface ProductFilterParams {\n productName?: string;\n technicalName?: string;\n priceChartingId?: string;\n modelNumber?: string;\n /** Category technicalName. */\n category?: string;\n /** Expansion technicalName. */\n expansion?: string;\n}\n\nexport interface DailyPriceStatsParams extends ProductFilterParams {\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Expansion id (ObjectId), an alternative to `expansion` (technicalName). */\n expansionId?: string;\n /** Category id (ObjectId), an alternative to `category` (technicalName). */\n categoryId?: string;\n}\n\nexport interface EstimatedValuesParams extends ProductFilterParams {\n page?: number;\n limit?: number;\n}\n\nexport interface TopProductsParams {\n limit?: number;\n}\n\nexport interface ProductDailyStatsParams {\n authToken?: string;\n /** Number of days to retrieve, from today backwards. Default 30. */\n days?: number;\n}\n\nexport interface ProductByVariantParams {\n authToken?: string;\n /** Number of days to include in the average calculation. Default 30. */\n days?: number;\n}\n\nexport interface ProductDailyByVariantParams {\n authToken?: string;\n cardType: CardType;\n /** Required when `cardType` is `'loose'`. */\n condition?: ItemCondition;\n /** Required when `cardType` is `'graded'`. */\n gradingCompany?: GradingCompany;\n /** Required when `cardType` is `'graded'`. */\n grade?: number;\n /** Number of days to retrieve. Default 30. */\n days?: number;\n}\n\nexport class PriceStatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /price-stats/daily`: daily average price history, filtered to matching product(s). */\n daily(params: DailyPriceStatsParams = {}): Promise<ListResponse<ItemDailyStats>> {\n return this.http.get(`/price-stats/daily${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/estimated-values`: current estimated market value, filtered to matching\n * product(s). */\n estimatedValues(params: EstimatedValuesParams = {}): Promise<ListResponse<ItemEstimatedValue>> {\n return this.http.get(`/price-stats/estimated-values${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/top-products`: items ranked by shop availability (how many shops carry\n * them), not by price. */\n topProducts(params: TopProductsParams = {}): Promise<ListResponse<TopItem>> {\n return this.http.get(`/price-stats/top-products${toQueryString(params)}`);\n }\n\n /** `GET /price-stats/product/{id}`: daily price history, current estimate, and a variant-count\n * summary for one product. Premium. */\n product(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemStats> {\n return this.http.get(`/price-stats/product/${encodeURIComponent(idOrTechnicalName)}`, options);\n }\n\n /** `GET /price-stats/product/{id}/full`: everything `product()` has, plus the item's current\n * shop matches. Premium. */\n productFull(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemFullStats> {\n return this.http.get(`/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/full`, options);\n }\n\n /** `GET /price-stats/product/{id}/daily`: daily price history for one product, with a\n * caller-chosen window. Premium. */\n productDaily(\n idOrTechnicalName: string,\n params: ProductDailyStatsParams = {},\n ): Promise<ItemDailyStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /price-stats/product/{id}/daily-last-30`: daily price history for the last 30 days\n * exactly (no window param, for callers that want a stable cache key). Premium. */\n productDailyLast30(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<ItemDailyStats> {\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily-last-30`,\n options,\n );\n }\n\n /** `GET /price-stats/product/{id}/estimated-value`: current estimated value only. Premium. */\n productEstimatedValue(\n idOrTechnicalName: string,\n options: PremiumOptions = {},\n ): Promise<ItemEstimatedValue> {\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/estimated-value`,\n options,\n );\n }\n\n /** `GET /price-stats/product/{id}/by-variant`: price stats broken out per card condition/grade.\n * Premium. */\n productByVariant(\n idOrTechnicalName: string,\n params: ProductByVariantParams = {},\n ): Promise<ItemVariantStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/by-variant${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /price-stats/product/{id}/daily-by-variant`: daily price history for one specific\n * condition/grade. `condition` is required for `cardType: 'loose'`; `gradingCompany` and `grade`\n * are required for `cardType: 'graded'`. Premium. */\n productDailyByVariant(\n idOrTechnicalName: string,\n params: ProductDailyByVariantParams,\n ): Promise<ItemVariantDailyStats> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/price-stats/product/${encodeURIComponent(idOrTechnicalName)}/daily-by-variant${toQueryString(query)}`,\n { authToken },\n );\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type {\n CardType,\n GradingCompany,\n ItemCondition,\n ItemReferencePrices,\n ItemShopMatches,\n ItemSoldPrices,\n ListResponse,\n LivePricingForItem,\n PaginationParams,\n ReferencePriceProvider,\n SealedProduct,\n} from '../types/index.js';\n\nexport interface ListProductsParams extends PaginationParams {\n /** Whitespace-separated tokens, each matched against the start of a word. */\n search?: string;\n}\n\nexport interface ProductMatchesParams extends PaginationParams {\n /** Keep only matches whose shop currently has stock. */\n inStock?: boolean;\n cardType?: CardType;\n condition?: ItemCondition;\n gradingCompany?: GradingCompany;\n grade?: number;\n}\n\nexport interface ProductReferencePricesParams {\n authToken?: string;\n /** Rolling window ending today, in days. Ignored when `from`/`to` are supplied. Default 90. */\n days?: number;\n /** `YYYY-MM-DD` */\n from?: string;\n /** `YYYY-MM-DD` */\n to?: string;\n provider?: ReferencePriceProvider;\n}\n\nexport interface ProductPricesParams extends PaginationParams {\n authToken?: string;\n}\n\n/** Sealed products: booster boxes, ETBs, tins, and the like. Single cards live under\n * `client.cards` instead. */\nexport class ProductsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /product`: search or list sealed products. */\n list(params: ListProductsParams = {}): Promise<ListResponse<SealedProduct>> {\n return this.http.get(`/product${toQueryString(params)}`);\n }\n\n /** `GET /product/{id}`: fetch one sealed product by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<SealedProduct> {\n return this.http.get(`/product/${encodeURIComponent(idOrTechnicalName)}`);\n }\n\n /** `GET /product/{id}/matches`: current shop listings matched to this product (latest per shop). */\n matches(idOrTechnicalName: string, params: ProductMatchesParams = {}): Promise<ItemShopMatches> {\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/matches${toQueryString(params)}`,\n );\n }\n\n /** `GET /product/{id}/reference-prices`: Cardmarket/TCGplayer/Tradera price history. Premium. */\n referencePrices(\n idOrTechnicalName: string,\n params: ProductReferencePricesParams = {},\n ): Promise<ItemReferencePrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/reference-prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /product/{id}/prices`: individual marketplace sale records. Premium. */\n prices(idOrTechnicalName: string, params: ProductPricesParams = {}): Promise<ItemSoldPrices> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/product/${encodeURIComponent(idOrTechnicalName)}/prices${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /product/{id}/pricing/live`: computed fresh for this request, not read from the last\n * stats job. Premium. */\n livePricing(idOrTechnicalName: string, options: PremiumOptions = {}): Promise<LivePricingForItem> {\n return this.http.get(`/product/${encodeURIComponent(idOrTechnicalName)}/pricing/live`, options);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { splitAuthToken, toQueryString } from '../http.js';\nimport type { ItemPriceComparison, ItemShopPriceHistory, ShopPriceHistoryList } from '../types/index.js';\n\nexport interface ShopMatchStatsForProductParams {\n authToken?: string;\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Filter to one shop's technicalName. */\n shop?: string;\n}\n\nexport interface ShopMatchStatsForShopParams {\n authToken?: string;\n /** `YYYY-MM-DD` */\n startDate?: string;\n /** `YYYY-MM-DD` */\n endDate?: string;\n /** Maximum products to return. Default 100. */\n limit?: number;\n}\n\nexport interface CompareShopPricesParams {\n authToken?: string;\n /** Product/card id or technicalName. */\n productId: string;\n /** `YYYY-MM-DD`: defaults to the latest date with data. */\n date?: string;\n}\n\n/** Historical shop-vs-price data, distinct from `client.shopMatches` (which is the current/latest\n * match state). Everything here is premium. */\nexport class ShopMatchStatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shop-match-stats/product/{productId}`: one product's price history, broken out per shop. */\n forProduct(\n productId: string,\n params: ShopMatchStatsForProductParams = {},\n ): Promise<ItemShopPriceHistory> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(\n `/shop-match-stats/product/${encodeURIComponent(productId)}${toQueryString(query)}`,\n { authToken },\n );\n }\n\n /** `GET /shop-match-stats/shop/{shop}`: one shop's price history, broken out per product. */\n forShop(shop: string, params: ShopMatchStatsForShopParams = {}): Promise<ShopPriceHistoryList> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/shop-match-stats/shop/${encodeURIComponent(shop)}${toQueryString(query)}`, {\n authToken,\n });\n }\n\n /** `GET /shop-match-stats/compare`: one product's price at every shop that carries it, as of\n * one date (defaults to the latest). */\n compare(params: CompareShopPricesParams): Promise<ItemPriceComparison> {\n const [query, authToken] = splitAuthToken(params);\n return this.http.get(`/shop-match-stats/compare${toQueryString(query)}`, { authToken });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { toQueryString } from '../http.js';\nimport type { ListResponse, PaginationParams, ShopMatch, ShopMatchesForShop, ShopMatchStats } from '../types/index.js';\n\nexport interface ListShopMatchesParams extends PaginationParams {\n /** Filter to one shop's technicalName. */\n shop?: string;\n inStock?: boolean;\n /** Filter by whether the listing has been resolved to a catalog item. */\n linked?: boolean;\n}\n\nexport interface ShopMatchesForShopParams extends PaginationParams {\n inStock?: boolean;\n}\n\n/** Raw shop-to-catalog match data: what's currently listed where, independent of which item or\n * shop you start from. For \"what does this card cost at each shop\" or \"what's in stock at this\n * shop\", prefer `client.cards.matches()` / `client.products.matches()` /\n * `client.shopMatches.forShop()`. */\nexport class ShopMatchesResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shop-matches`: every current match across every shop (latest record per url+shop). */\n list(params: ListShopMatchesParams = {}): Promise<ListResponse<ShopMatch>> {\n return this.http.get(`/shop-matches${toQueryString(params)}`);\n }\n\n /** `GET /shop-matches/{shop}`: every current match at one shop (latest record per url). */\n forShop(technicalName: string, params: ShopMatchesForShopParams = {}): Promise<ShopMatchesForShop> {\n return this.http.get(`/shop-matches/${encodeURIComponent(technicalName)}${toQueryString(params)}`);\n }\n\n /** `GET /shop-matches/shops`: match counts per shop (based on latest records only). */\n shopStats(params: PaginationParams = {}): Promise<ListResponse<ShopMatchStats>> {\n return this.http.get(`/shop-matches/shops${toQueryString(params)}`);\n }\n}\n","import type { HttpClient, PremiumOptions } from '../http.js';\nimport type { ShopUrlMutationResult } from '../types/index.js';\n\nexport interface SubmitShopUrlParams extends PremiumOptions {\n url: string;\n /** Shop technicalName. Auto-created if it doesn't exist yet. */\n shop: string;\n}\n\nexport interface AssignShopUrlProductParams extends PremiumOptions {\n /** Product/card id to link, or `null` to unlink and let auto-matching resume. */\n productId: string | null;\n}\n\n/** Lets a signed-in subscriber contribute to the catalog: submit a shop URL for scraping, or\n * manually correct which product/card a URL resolves to. Both premium, both mutating. */\nexport class ShopUrlsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `POST /shop-urls/submit`: submit a shop URL for scraping. */\n submit(params: SubmitShopUrlParams): Promise<ShopUrlMutationResult> {\n const { authToken, url, shop } = params;\n return this.http.post('/shop-urls/submit', { url, shop }, { authToken });\n }\n\n /** `PATCH /shop-urls/{id}/product`: manually assign (or clear) the product a shop URL resolves to. */\n assignProduct(\n shopUrlId: string,\n params: AssignShopUrlProductParams,\n ): Promise<ShopUrlMutationResult> {\n const { authToken, productId } = params;\n return this.http.patch(\n `/shop-urls/${encodeURIComponent(shopUrlId)}/product`,\n { productId },\n { authToken },\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { toQueryString } from '../http.js';\nimport type { Shop } from '../types/index.js';\n\nexport interface ListShopsParams {\n active?: boolean;\n}\n\nexport class ShopsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /shops`: every tracked shop. Unwrapped to a plain array, nothing to paginate here. */\n async list(params: ListShopsParams = {}): Promise<Shop[]> {\n const res = await this.http.get<{ data: Shop[] }>(`/shops${toQueryString(params)}`);\n return res.data;\n }\n\n /** `GET /shops/{id}`: fetch one shop by its id or technicalName. */\n get(idOrTechnicalName: string): Promise<Shop> {\n return this.http.get(`/shops/${encodeURIComponent(idOrTechnicalName)}`);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { PlatformStats } from '../types/index.js';\n\nexport class StatsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** `GET /stats`: platform-wide overview counts (shops, expansions, products, prices tracked). */\n platform(): Promise<PlatformStats> {\n return this.http.get('/stats');\n }\n}\n","import { HttpClient } from './http.js';\nimport { BargainsResource } from './resources/bargains.js';\nimport { CardsResource } from './resources/cards.js';\nimport { ExpansionsResource } from './resources/expansions.js';\nimport { PackRatesResource } from './resources/packRates.js';\nimport { PriceStatsResource } from './resources/priceStats.js';\nimport { ProductsResource } from './resources/products.js';\nimport { ShopMatchStatsResource } from './resources/shopMatchStats.js';\nimport { ShopMatchesResource } from './resources/shopMatches.js';\nimport { ShopUrlsResource } from './resources/shopUrls.js';\nimport { ShopsResource } from './resources/shops.js';\nimport { StatsResource } from './resources/stats.js';\n\nexport const DEFAULT_BASE_URL = 'https://api.tcgpriser.se';\n\n/** Local dev, self-hosting and testing overrides. Most integrations never touch these. */\nexport interface TcgPriserAdvancedOptions {\n /** Point at a local dev server or a self-hosted instance. Defaults to production. */\n baseUrl?: string;\n /** Extra headers sent on every request, e.g. a custom `User-Agent`. */\n headers?: Record<string, string>;\n /** Swap in a different `fetch` (older Node, testing, a proxying agent). Defaults to global `fetch`. */\n fetch?: typeof fetch;\n}\n\nexport interface TcgPriserOptions {\n /**\n * A signed-in subscriber's JWT. Only needed for premium methods (`cards.prices()`,\n * `priceStats.product()`, `bargains.search()` etc.); public methods work fine without it.\n * This client has no login flow of its own, so bring your own token.\n *\n * Every premium method also accepts its own `authToken` to override this per call. Useful when\n * one server-side client is shared across requests for several different signed-in users.\n */\n authToken?: string;\n /** Local dev / self-hosting / testing overrides. Leave unset unless you know you need it. */\n advanced?: TcgPriserAdvancedOptions;\n}\n\n/**\n * Client for the tcgpriser.se API: Pokémon TCG price data, catalog, shop matches and bargains for\n * shops tracked in Sweden.\n *\n * ```ts\n * import { TcgPriser } from 'tcgpriser';\n *\n * const tcgpriser = new TcgPriser();\n * const card = await tcgpriser.cards.get('mega-evolution-ascended-heroes-fezandipiti-ex');\n * console.log(card.retailPrice, card.lowestShopOffer?.shop.name);\n * ```\n *\n * That example needs no token. Most of the API is public (https://api.tcgpriser.se/docs). A\n * smaller set of premium methods (live pricing, per-condition history, shop comparison, bargain\n * search, shop-URL submission) need a subscriber's JWT (https://api.tcgpriser.se/premium-docs):\n *\n * ```ts\n * const tcgpriser = new TcgPriser(myJwt); // shorthand for { authToken: myJwt }\n * await tcgpriser.cards.livePricing('fezandipiti-ex');\n * ```\n */\nexport class TcgPriser {\n readonly cards: CardsResource;\n readonly products: ProductsResource;\n readonly expansions: ExpansionsResource;\n readonly shops: ShopsResource;\n readonly shopMatches: ShopMatchesResource;\n readonly shopMatchStats: ShopMatchStatsResource;\n readonly shopUrls: ShopUrlsResource;\n readonly priceStats: PriceStatsResource;\n readonly bargains: BargainsResource;\n readonly packRates: PackRatesResource;\n readonly stats: StatsResource;\n\n /**\n * @param optionsOrAuthToken A subscriber JWT (`new TcgPriser(myJwt)`), a full\n * `TcgPriserOptions` object, or omit it entirely for an anonymous, public-only client.\n */\n constructor(optionsOrAuthToken?: string | TcgPriserOptions) {\n const options: TcgPriserOptions =\n typeof optionsOrAuthToken === 'string' ? { authToken: optionsOrAuthToken } : (optionsOrAuthToken ?? {});\n const advanced = options.advanced ?? {};\n\n if (!advanced.fetch && typeof fetch === 'undefined') {\n throw new Error(\n 'tcgpriser: no global fetch found. Pass { advanced: { fetch } } explicitly on Node < 18, or run on Node 18+.',\n );\n }\n\n const http = new HttpClient({\n baseUrl: advanced.baseUrl ?? DEFAULT_BASE_URL,\n // Bound to globalThis: both browsers and Node's undici implement fetch as a method that\n // checks its receiver, so an unbound reference throws \"Illegal invocation\" the moment it's\n // called through anything other than `window.fetch(...)`/`globalThis.fetch(...)` — which is\n // exactly what happens once HttpClient stores it and calls `this.fetchImpl(...)`.\n fetch: advanced.fetch ?? fetch.bind(globalThis),\n headers: advanced.headers,\n authToken: options.authToken,\n });\n\n this.cards = new CardsResource(http);\n this.products = new ProductsResource(http);\n this.expansions = new ExpansionsResource(http);\n this.shops = new ShopsResource(http);\n this.shopMatches = new ShopMatchesResource(http);\n this.shopMatchStats = new ShopMatchStatsResource(http);\n this.shopUrls = new ShopUrlsResource(http);\n this.priceStats = new PriceStatsResource(http);\n this.bargains = new BargainsResource(http);\n this.packRates = new PackRatesResource(http);\n this.stats = new StatsResource(http);\n }\n}\n"]}