@pokewallet/sdk 0.1.1 → 0.1.5

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.d.ts CHANGED
@@ -9,6 +9,12 @@ interface ClientOptions {
9
9
  baseUrl?: string;
10
10
  /** Sent on every request. Some network layers reject the default user agents of HTTP libraries. */
11
11
  userAgent?: string;
12
+ /**
13
+ * Sent as `X-PokeWallet-Client`, so the API can tell which integration made a call. Browsers
14
+ * cannot set `User-Agent`, so this is the only identification they can send. Default
15
+ * `pokewallet-sdk-ts/<version>`.
16
+ */
17
+ client?: string;
12
18
  /** Custom `fetch`, mainly for tests. Defaults to the global one. */
13
19
  fetch?: FetchLike;
14
20
  /** Retries after a 429 (with `Retry-After`) or a 503. Default 2. */
@@ -34,6 +40,7 @@ declare class HttpClient {
34
40
  lastRateLimit: RateLimitInfo | null;
35
41
  private readonly baseUrl;
36
42
  private readonly userAgent;
43
+ private readonly client;
37
44
  private readonly fetchImpl;
38
45
  private readonly maxRetries;
39
46
  private readonly capSeconds;
@@ -120,8 +127,8 @@ interface Card {
120
127
  variants: string[];
121
128
  /**
122
129
  * Set identifiers. `setId` is the numeric id (possibly negative); `setCode` the short code.
123
- * Source: `card_info.set_id` / `card_info.set_code`, except for cards listed by a set, where both come
124
- * from the response's `set` object (the Pokémon listing puts the numeric id in `card_info.set_code`).
130
+ * Source: `card_info.set_id` / `card_info.set_code`; for cards listed by a set, both come from the
131
+ * response's `set` object.
125
132
  * One Piece search and detail answers carry neither, so both are null there.
126
133
  */
127
134
  setId: string | null;
@@ -161,7 +168,7 @@ interface Page<T> {
161
168
  totalPages: number;
162
169
  }
163
170
  interface SearchPage extends Page<Card> {
164
- /** Games only: the search stopped at its cap, refine the query instead of paging. */
171
+ /** Pokémon and games: the candidate list was cut at its cap, refine the query instead of paging. Always false for One Piece. */
165
172
  truncated: boolean;
166
173
  }
167
174
  interface SetPage extends Page<Card> {
@@ -255,7 +262,6 @@ interface TopCard {
255
262
  setId: string | null;
256
263
  setCode: string | null;
257
264
  price: number | null;
258
- previousPrice7d: number | null;
259
265
  change7d: string | null;
260
266
  raw: unknown;
261
267
  }
@@ -286,10 +292,10 @@ type PricesOptions = {
286
292
  source?: 'tcg' | 'cm';
287
293
  };
288
294
  type StatisticsOptions = {
289
- variant?: string;
295
+ variant?: 'normal' | 'foil';
290
296
  };
291
297
  type TrendingOptions = {
292
- period?: '7d' | '30d';
298
+ period?: '7d';
293
299
  limit?: number;
294
300
  };
295
301
  type TopCardsOptions = {
@@ -368,8 +374,6 @@ interface World {
368
374
  interface CardWorldConfig {
369
375
  /** Route prefix: `''` for Pokémon, `/mtg` for a game. */
370
376
  prefix: string;
371
- /** Pokémon accepts `period=30d` on trending; the other worlds only `7d`. */
372
- periods: readonly ('7d' | '30d')[];
373
377
  /** Minimum search length: the games reject queries shorter than 2 characters. */
374
378
  minQuery: number;
375
379
  }
@@ -567,7 +571,7 @@ declare class UnavailableError extends PokeWalletError {
567
571
  declare class ServerError extends PokeWalletError {
568
572
  }
569
573
 
570
- declare const VERSION = "0.1.1";
574
+ declare const VERSION = "0.1.5";
571
575
 
572
576
  /**
573
577
  * This file was auto-generated by openapi-typescript.
@@ -623,9 +627,10 @@ interface paths {
623
627
  };
624
628
  /**
625
629
  * Search Pokémon cards by name, number, set or rarity
626
- * @description Note: server-side range checks on `limit` and `page` differ from One Piece and the ten games.
627
- * Send `limit` between 1 and 100 and `page` of at least 1 (the SDKs enforce this before
628
- * sending); `total_pages` can be `null` for out-of-range input.
630
+ * @description `metadata.truncated` is true when the candidates were cut at 500: a more specific query is needed.
631
+ * `page` and `limit`: a missing, non-numeric or lower-than-1 value falls back to the default, and a
632
+ * value above the cap (100 for `limit`) is clamped. The SDKs still check both before sending.
633
+ * A name may contain parentheses, e.g. `Pikachu (Cosmos Holo)`.
629
634
  */
630
635
  get: operations["pokemonSearch"];
631
636
  put?: never;
@@ -660,7 +665,10 @@ interface paths {
660
665
  path?: never;
661
666
  cookie?: never;
662
667
  };
663
- /** Sets with the strongest CardMarket price change (Pro or trial) */
668
+ /**
669
+ * Sets with the strongest CardMarket price change (Pro or trial)
670
+ * @description Same format in every world. Only `period=7d` exists; `30d` answers 400 `Invalid parameter`.
671
+ */
664
672
  get: operations["pokemonTrendingSets"];
665
673
  put?: never;
666
674
  post?: never;
@@ -685,8 +693,9 @@ interface paths {
685
693
  * **200** with `disambiguation: true` and `matches`; on `/prices/{setCode}` it is **300**, on
686
694
  * statistics and completion-value it is **409**. Disambiguate with `?language=` or the numeric `set_id`.
687
695
  *
688
- * Note: in this listing `card_info.set_code` holds the `set_id` ("1382"), while
689
- * `/cards/{id}` and `/search` hold the real code ("PLF"). `prices` is always `[]` here.
696
+ * In this listing `card_info.set_code` and `card_info.set_id` hold the set's real code ("PLF") and
697
+ * numeric id ("1382"), the same as in `/cards/{id}` and `/search`; the `set` object carries `set_id` too.
698
+ * `prices` is always `[]` here.
690
699
  *
691
700
  * Note: send `limit` and `page` within range (see `/search`).
692
701
  */
@@ -708,8 +717,9 @@ interface paths {
708
717
  };
709
718
  /**
710
719
  * Price and rarity statistics of a set (Pro or trial)
711
- * @description Note: `set_info.set_code` is the numeric `set_id` ("1382"); in `completion-value` it is the code ("PLF").
712
- * Ambiguous set: **409**.
720
+ * @description Same format in every world: `set_info` is `{name, set_code, set_id, total_cards}` with the real set code;
721
+ * `total_cards` counts cards (sealed products excluded), not finishes. `trend_direction` compares the
722
+ * 7-day with the 30-day average. Ambiguous set: **409**.
713
723
  */
714
724
  get: operations["pokemonSetStatistics"];
715
725
  put?: never;
@@ -727,7 +737,10 @@ interface paths {
727
737
  path?: never;
728
738
  cookie?: never;
729
739
  };
730
- /** Cost to complete a set (Pro or trial) */
740
+ /**
741
+ * Cost to complete a set (Pro or trial)
742
+ * @description One copy of each card, in its base finish. `set_info` has the same shape as in statistics.
743
+ */
731
744
  get: operations["pokemonSetCompletionValue"];
732
745
  put?: never;
733
746
  post?: never;
@@ -746,7 +759,8 @@ interface paths {
746
759
  };
747
760
  /**
748
761
  * Prices of every card in a set (Pro or trial; hundreds of rows)
749
- * @description Ambiguous set: **300** with the `Disambiguation` body (no `error` field).
762
+ * @description The response carries both `set_id` and `group_id` (the same value).
763
+ * Ambiguous set: **300** with the `Disambiguation` body (no `error` field).
750
764
  */
751
765
  get: operations["pokemonSetPrices"];
752
766
  put?: never;
@@ -767,7 +781,7 @@ interface paths {
767
781
  /**
768
782
  * Pokémon card detail
769
783
  * @description `id` is `pk_<hex>`, a 64-character hex CardMarket `encrypted_id`, or a plain card number
770
- * (`086`, `086/078`) to be combined with `set_code`. An id from another game (`op_`, `mtg_`...)
784
+ * (`086`, `086/078`, `010a/073`) to be combined with `set_code`. An id from another game (`op_`, `mtg_`...)
771
785
  * gives 400 with a hint to the right route.
772
786
  */
773
787
  get: operations["pokemonGetCard"];
@@ -803,7 +817,14 @@ interface paths {
803
817
  path?: never;
804
818
  cookie?: never;
805
819
  };
806
- /** Ranking by price or growth (Pro or trial) */
820
+ /**
821
+ * Ranking by price or growth (Pro or trial)
822
+ * @description Same item format in every world: `{id, card_info, current_price, change_7d?}` (`change_7d` only for growth).
823
+ * `card_info` is the full common card info. Price ranking uses the TCGPlayer market price (`tcg`) or the
824
+ * CardMarket trend price (`cm`). A CardMarket row linked to a TCGPlayer card carries that card's `pk_` id,
825
+ * the others the CardMarket encrypted id; both open with `/cards/{id}`. Growth with `source=tcg` exists
826
+ * for Pokémon only.
827
+ */
807
828
  get: operations["pokemonTopCards"];
808
829
  put?: never;
809
830
  post?: never;
@@ -823,7 +844,8 @@ interface paths {
823
844
  /**
824
845
  * Search One Piece cards
825
846
  * @description Flat pagination `{data,total,page,limit}` (differs from Pokémon, which nests it in `pagination`).
826
- * `page`/`limit` are validated with `Math.max(1, …)`.
847
+ * `page` and `limit`: a missing, non-numeric or lower-than-1 value falls back to the default, and a
848
+ * value above the cap is clamped. A name may contain parentheses, e.g. `Buggy (Reprint)`.
827
849
  */
828
850
  get: operations["opSearch"];
829
851
  put?: never;
@@ -957,6 +979,7 @@ interface paths {
957
979
  * Prices of every card in a set (Pro or trial)
958
980
  * @description The set goes in the query (`set_code` or `group_id`), not in the path as on other routes.
959
981
  * At least one of the two is required, otherwise 400.
982
+ * Like the other worlds, the response has `source`, `set_code`, `set_id` and a `product_type` on every row.
960
983
  */
961
984
  get: operations["opSetPrices"];
962
985
  put?: never;
@@ -1261,8 +1284,8 @@ interface components {
1261
1284
  };
1262
1285
  /**
1263
1286
  * @description Common fields. The ten games add their own fields in snake_case (`mtg`: `p`,`t`,`sub_type`;
1264
- * `ygo`: `attack`,`defense`...). Note: `set_id` is missing in a Pokémon set listing, where
1265
- * `set_code` holds the numeric id; `card_text` and `card_type` are often `null`.
1287
+ * `ygo`: `attack`,`defense`...). `set_code` is the set's real code and `set_id` its numeric id,
1288
+ * also in Pokémon set listings; `card_text` and `card_type` are often `null`.
1266
1289
  */
1267
1290
  CardInfo: {
1268
1291
  name: string;
@@ -1275,6 +1298,7 @@ interface components {
1275
1298
  card_type?: string | null;
1276
1299
  /** @description `card` or sealed product. */
1277
1300
  product_type?: string | null;
1301
+ /** @description Finishes, `Normal` first, then alphabetical. Present in Pokémon search and detail too. */
1278
1302
  variants?: string[];
1279
1303
  card_text?: string | null;
1280
1304
  hp?: string | null;
@@ -1321,7 +1345,7 @@ interface components {
1321
1345
  tcg_only?: number;
1322
1346
  cardmarket_only?: number;
1323
1347
  both_sources?: number;
1324
- /** @description Games only. */
1348
+ /** @description True when the candidate list was cut at its cap (500 for Pokémon): use a more specific query. */
1325
1349
  truncated?: boolean;
1326
1350
  };
1327
1351
  };
@@ -1382,12 +1406,13 @@ interface components {
1382
1406
  tcgplayer?: components["schemas"]["TcgplayerPrice"] | null;
1383
1407
  cardmarket?: components["schemas"]["CardmarketPrice"] | null;
1384
1408
  };
1385
- /** @description The set id is called `group_id` here (`set_id` in the games). */
1409
+ /** @description Carries both `set_id` and `group_id` (the same value). */
1386
1410
  PokemonPricesResponse: {
1387
1411
  success?: boolean;
1388
1412
  /** @enum {string} */
1389
1413
  source?: "both" | "tcg" | "cm";
1390
1414
  set_code?: string | null;
1415
+ set_id?: string;
1391
1416
  group_id?: string;
1392
1417
  data?: components["schemas"]["PriceRow"][];
1393
1418
  total?: number;
@@ -1402,11 +1427,13 @@ interface components {
1402
1427
  total?: number;
1403
1428
  };
1404
1429
  StatisticsResponse: {
1405
- /** @description Pokémon: `set_code` is the numeric `set_id`; `set_id` is missing. */
1430
+ /** @description Same in every world. */
1406
1431
  set_info: {
1407
1432
  name?: string;
1433
+ /** @description The real set code. */
1408
1434
  set_code?: string | null;
1409
1435
  set_id?: string;
1436
+ /** @description Cards, not finishes; sealed products excluded. */
1410
1437
  total_cards?: number;
1411
1438
  };
1412
1439
  price_statistics: {
@@ -1424,7 +1451,6 @@ interface components {
1424
1451
  min_price?: number;
1425
1452
  max_price?: number;
1426
1453
  most_expensive?: {
1427
- /** @description Missing in Pokémon. */
1428
1454
  id?: string;
1429
1455
  name?: string;
1430
1456
  price?: number;
@@ -1436,7 +1462,10 @@ interface components {
1436
1462
  }) | null;
1437
1463
  CompletionValueResponse: {
1438
1464
  set_info: {
1439
- [key: string]: unknown;
1465
+ name?: string;
1466
+ set_code?: string | null;
1467
+ set_id?: string;
1468
+ total_cards?: number;
1440
1469
  };
1441
1470
  completion_cost: {
1442
1471
  tcgplayer?: {
@@ -1465,7 +1494,6 @@ interface components {
1465
1494
  trending_sets: {
1466
1495
  set_name?: string | null;
1467
1496
  set_code?: string | null;
1468
- /** @description Missing in Pokémon. */
1469
1497
  set_id?: string;
1470
1498
  card_count?: number;
1471
1499
  cardmarket?: {
@@ -1478,7 +1506,7 @@ interface components {
1478
1506
  change?: string;
1479
1507
  }[];
1480
1508
  };
1481
- /** @description `{status:'work_in_progress'}` or `null` (CardMarket-only sets). */
1509
+ /** @description `{status, message}` (TCGPlayer history is not available yet) or `null`. */
1482
1510
  tcgplayer?: {
1483
1511
  [key: string]: unknown;
1484
1512
  } | null;
@@ -1493,7 +1521,6 @@ interface components {
1493
1521
  id: string;
1494
1522
  card_info: components["schemas"]["CardInfo"];
1495
1523
  current_price: number;
1496
- previous_price_7d?: number;
1497
1524
  change_7d?: string;
1498
1525
  }[];
1499
1526
  };
@@ -1526,7 +1553,7 @@ interface components {
1526
1553
  };
1527
1554
  };
1528
1555
  } | null;
1529
- /** @description Flat card: no `card_info`, `ext_*` fields; `prices` is a single object (Pokémon: an array per finish). */
1556
+ /** @description Flat card: no `card_info`, `ext_*` fields; `prices` is a single object (Pokémon: an array per finish). CardMarket prices are attached to the cards of the English sets too (OP15, OP14, PRB-02, EB04), so more search and detail answers carry a `cardmarket` block. */
1530
1557
  OpCard: {
1531
1558
  /** @description `op_<hex>` */
1532
1559
  id: string;
@@ -1584,6 +1611,10 @@ interface components {
1584
1611
  };
1585
1612
  OpPricesResponse: {
1586
1613
  success?: boolean;
1614
+ /** @enum {string} */
1615
+ source?: "both" | "tcg" | "cm";
1616
+ set_code?: string | null;
1617
+ set_id?: string;
1587
1618
  group_id?: string | number;
1588
1619
  data?: components["schemas"]["PriceRow"][];
1589
1620
  total?: number;
@@ -1591,8 +1622,8 @@ interface components {
1591
1622
  };
1592
1623
  responses: {
1593
1624
  /**
1594
- * @description Missing or invalid parameter. The body shape differs by family: Pokémon and One Piece send `{error}`,
1595
- * the games send `{error,message,docs}`.
1625
+ * @description Missing or invalid parameter. A bad parameter value answers `{error: 'Invalid parameter', message, docs}`
1626
+ * in every world. Other 400 bodies may carry only `{error}`.
1596
1627
  */
1597
1628
  BadRequest: {
1598
1629
  headers: {
@@ -1685,7 +1716,10 @@ interface components {
1685
1716
  Game: components["schemas"]["GameCode"];
1686
1717
  /** @description `set_code` (`PLF`) or numeric `set_id`, possibly negative. */
1687
1718
  SetCode: string;
1719
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
1688
1720
  Page: number;
1721
+ /** @description `normal` or `foil`; anything else gives 400 `Invalid parameter`. On Pokémon `holo` is still accepted as a legacy alias of `foil`. */
1722
+ Variant: "normal" | "foil";
1689
1723
  /** @description Set language (`eng`, `jap`, `chn`, `en`, `jp`...): the vocabulary is not uniform between Pokémon and One Piece. */
1690
1724
  Language: string;
1691
1725
  Metric: "price" | "growth";
@@ -1760,6 +1794,7 @@ interface operations {
1760
1794
  parameters: {
1761
1795
  query: {
1762
1796
  q: string;
1797
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
1763
1798
  page?: components["parameters"]["Page"];
1764
1799
  limit?: number;
1765
1800
  };
@@ -1831,7 +1866,8 @@ interface operations {
1831
1866
  pokemonTrendingSets: {
1832
1867
  parameters: {
1833
1868
  query?: {
1834
- period?: "7d" | "30d";
1869
+ /** @description Only 7d (30d gives 400). */
1870
+ period?: "7d";
1835
1871
  limit?: number;
1836
1872
  };
1837
1873
  header?: never;
@@ -1867,6 +1903,7 @@ interface operations {
1867
1903
  pokemonGetSet: {
1868
1904
  parameters: {
1869
1905
  query?: {
1906
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
1870
1907
  page?: components["parameters"]["Page"];
1871
1908
  limit?: number;
1872
1909
  /** @description Set language (`eng`, `jap`, `chn`, `en`, `jp`...): the vocabulary is not uniform between Pokémon and One Piece. */
@@ -1908,7 +1945,8 @@ interface operations {
1908
1945
  pokemonSetStatistics: {
1909
1946
  parameters: {
1910
1947
  query?: {
1911
- variant?: "normal" | "holo";
1948
+ /** @description `normal` or `foil`; anything else gives 400 `Invalid parameter`. On Pokémon `holo` is still accepted as a legacy alias of `foil`. */
1949
+ variant?: components["parameters"]["Variant"];
1912
1950
  };
1913
1951
  header?: never;
1914
1952
  path: {
@@ -2144,6 +2182,7 @@ interface operations {
2144
2182
  parameters: {
2145
2183
  query: {
2146
2184
  q: string;
2185
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
2147
2186
  page?: components["parameters"]["Page"];
2148
2187
  limit?: number;
2149
2188
  };
@@ -2252,6 +2291,7 @@ interface operations {
2252
2291
  opGetSet: {
2253
2292
  parameters: {
2254
2293
  query?: {
2294
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
2255
2295
  page?: components["parameters"]["Page"];
2256
2296
  limit?: number;
2257
2297
  };
@@ -2290,7 +2330,8 @@ interface operations {
2290
2330
  opSetStatistics: {
2291
2331
  parameters: {
2292
2332
  query?: {
2293
- variant?: "normal" | "foil";
2333
+ /** @description `normal` or `foil`; anything else gives 400 `Invalid parameter`. On Pokémon `holo` is still accepted as a legacy alias of `foil`. */
2334
+ variant?: components["parameters"]["Variant"];
2294
2335
  };
2295
2336
  header?: never;
2296
2337
  path: {
@@ -2474,6 +2515,7 @@ interface operations {
2474
2515
  parameters: {
2475
2516
  query: {
2476
2517
  q: string;
2518
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
2477
2519
  page?: components["parameters"]["Page"];
2478
2520
  limit?: number;
2479
2521
  };
@@ -2587,6 +2629,7 @@ interface operations {
2587
2629
  gameGetSet: {
2588
2630
  parameters: {
2589
2631
  query?: {
2632
+ /** @description Missing, non-numeric or lower than 1 falls back to 1. */
2590
2633
  page?: components["parameters"]["Page"];
2591
2634
  limit?: number;
2592
2635
  };
@@ -2626,7 +2669,8 @@ interface operations {
2626
2669
  gameSetStatistics: {
2627
2670
  parameters: {
2628
2671
  query?: {
2629
- variant?: "normal" | "foil";
2672
+ /** @description `normal` or `foil`; anything else gives 400 `Invalid parameter`. On Pokémon `holo` is still accepted as a legacy alias of `foil`. */
2673
+ variant?: components["parameters"]["Variant"];
2630
2674
  };
2631
2675
  header?: never;
2632
2676
  path: {
package/dist/index.js CHANGED
@@ -141,7 +141,7 @@ function errorFromResponse(ctx) {
141
141
  }
142
142
 
143
143
  // src/version.ts
144
- var VERSION = "0.1.1";
144
+ var VERSION = "0.1.5";
145
145
  var DEFAULT_BASE_URL = "https://api.pokewallet.io";
146
146
  var DEFAULT_USER_AGENT = `pokewallet-sdk-ts/${VERSION}`;
147
147
 
@@ -177,6 +177,7 @@ var HttpClient = class {
177
177
  #key;
178
178
  baseUrl;
179
179
  userAgent;
180
+ client;
180
181
  fetchImpl;
181
182
  maxRetries;
182
183
  capSeconds;
@@ -186,6 +187,7 @@ var HttpClient = class {
186
187
  this.#key = readKey(options);
187
188
  this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
188
189
  this.userAgent = options.userAgent ?? DEFAULT_USER_AGENT;
190
+ this.client = options.client ?? DEFAULT_USER_AGENT;
189
191
  const g = globalThis;
190
192
  const f = options.fetch ?? (g.fetch ? g.fetch.bind(globalThis) : void 0);
191
193
  if (!f) throw new ValidationError("No fetch available: pass options.fetch (Node 18+ has one built in)");
@@ -238,6 +240,7 @@ var HttpClient = class {
238
240
  headers: {
239
241
  ...this.#key === void 0 ? {} : { "X-API-Key": this.#key },
240
242
  "User-Agent": this.userAgent,
243
+ "X-PokeWallet-Client": this.client,
241
244
  Accept: "application/json"
242
245
  },
243
246
  signal: AbortSignal.timeout(this.timeoutMs)
@@ -566,7 +569,6 @@ function normalizeTopCards(raw) {
566
569
  setId: pair.id,
567
570
  setCode: pair.code,
568
571
  price: num2(c.current_price),
569
- previousPrice7d: num2(c.previous_price_7d),
570
572
  change7d: str2(c.change_7d),
571
573
  raw: item
572
574
  };
@@ -643,6 +645,15 @@ function checkLimit(limit, max) {
643
645
  }
644
646
  return limit;
645
647
  }
648
+ function checkPeriod(period) {
649
+ if (period !== void 0 && period !== "7d") throw new ValidationError(`period ${period} is not available (only 7d)`);
650
+ return "7d";
651
+ }
652
+ function checkVariant(variant) {
653
+ if (variant === void 0) return void 0;
654
+ if (variant !== "normal" && variant !== "foil") throw new ValidationError(`variant must be normal or foil (got ${variant})`);
655
+ return variant;
656
+ }
646
657
  function checkText(name, value, min = 1) {
647
658
  if (typeof value !== "string" || value.trim().length < min) {
648
659
  throw new ValidationError(`${name} must be at least ${min} character${min === 1 ? "" : "s"} long`);
@@ -715,14 +726,13 @@ var CardWorld = class {
715
726
  return normalizeSetPrices(await this.http.get(this.path(`/prices/${seg(code)}`), { source: options.source }));
716
727
  }
717
728
  async statistics(code, options = {}) {
718
- return normalizeStatistics(await this.http.get(this.path(`/sets/${seg(code)}/statistics`), { variant: options.variant }));
729
+ return normalizeStatistics(await this.http.get(this.path(`/sets/${seg(code)}/statistics`), { variant: checkVariant(options.variant) }));
719
730
  }
720
731
  async completionValue(code) {
721
732
  return normalizeCompletionValue(await this.http.get(this.path(`/sets/${seg(code)}/completion-value`)));
722
733
  }
723
734
  async trending(options = {}) {
724
- const period = options.period ?? "7d";
725
- if (!this.config.periods.includes(period)) throw new ValidationError(`period ${period} is not available here (use ${this.config.periods.join(" or ")})`);
735
+ const period = checkPeriod(options.period);
726
736
  return normalizeTrending(await this.http.get(this.path("/sets/trending"), { period, limit: checkLimit(options.limit, LIMITS.trending) }));
727
737
  }
728
738
  async topCards(options = {}) {
@@ -790,14 +800,14 @@ var OnePieceWorld = class {
790
800
  return normalizeSetPrices(await this.http.get("/op/prices", query));
791
801
  }
792
802
  async statistics(code, options = {}) {
793
- return normalizeStatistics(await this.http.get(`/op/sets/${seg(code)}/statistics`, { variant: options.variant }));
803
+ return normalizeStatistics(await this.http.get(`/op/sets/${seg(code)}/statistics`, { variant: checkVariant(options.variant) }));
794
804
  }
795
805
  async completionValue(code) {
796
806
  return normalizeCompletionValue(await this.http.get(`/op/sets/${seg(code)}/completion-value`));
797
807
  }
798
808
  async trending(options = {}) {
799
- if (options.period === "30d") throw new ValidationError("period 30d is not available for One Piece");
800
- return normalizeTrending(await this.http.get("/op/sets/trending", { period: "7d", limit: checkLimit(options.limit, LIMITS.trending) }));
809
+ const period = checkPeriod(options.period);
810
+ return normalizeTrending(await this.http.get("/op/sets/trending", { period, limit: checkLimit(options.limit, LIMITS.trending) }));
801
811
  }
802
812
  async topCards(options = {}) {
803
813
  return normalizeTopCards(
@@ -813,7 +823,7 @@ var OnePieceWorld = class {
813
823
  // src/worlds/pokemon-world.ts
814
824
  var PokemonWorld = class extends CardWorld {
815
825
  constructor(http) {
816
- super(http, { prefix: "", periods: ["7d", "30d"], minQuery: 1 });
826
+ super(http, { prefix: "", minQuery: 1 });
817
827
  }
818
828
  /**
819
829
  * Card by id, or by plain card number together with `setCode` (`card('086/078', { setCode: 'SV8a' })`).
@@ -844,7 +854,7 @@ var PokeWallet = class {
844
854
  this.onepiece = new OnePieceWorld(this.#http);
845
855
  const games = {};
846
856
  for (const code of GAME_CODES) {
847
- games[code] = new CardWorld(this.#http, { prefix: `/${code}`, periods: ["7d"], minQuery: 2 });
857
+ games[code] = new CardWorld(this.#http, { prefix: `/${code}`, minQuery: 2 });
848
858
  }
849
859
  this.games = games;
850
860
  }