@pokemontcgapi/sdk 0.1.3 → 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/README.md CHANGED
@@ -6,8 +6,10 @@ international, Japanese and Simplified Chinese, with card names in eight locales
6
6
  that state their source, basis, grade and sample size. The current counts are live at
7
7
  [/v1/status](https://api.pokemontcgapi.com/v1/status).
8
8
 
9
- **Sealed products and the `/v1/changes` feed have no client here yet.** The API serves both; this
10
- package does not wrap them, so reach them over plain REST until it does.
9
+ **Every data route has a method**: cards, sets, series, artists, sealed products, the dedicated
10
+ price routes (current, batch, history, stats, movers, sources), the `/v1/changes` feed, the reference
11
+ vocabularies and photo recognition. Account and billing routes (`/v1/me`, keys, checkout) are not
12
+ wrapped: they belong to the dashboard.
11
13
 
12
14
  **Zero runtime dependencies.** Uses the global `fetch`, so it runs unchanged on Node ≥ 20, Bun, Deno,
13
15
  Cloudflare Workers and in the browser.
@@ -18,16 +20,26 @@ their respective owners.
18
20
 
19
21
  ## Get a key
20
22
 
21
- One call, no dashboard and no card:
23
+ Generate the Idempotency-Key once per signup and keep it with the request body:
24
+
25
+ ```bash
26
+ IDEM=$(uuidgen)
27
+ ```
22
28
 
23
29
  ```bash
24
30
  curl -s -X POST "https://api.pokemontcgapi.com/v1/accounts/free" \
25
31
  -H "Content-Type: application/json" \
26
- -H "Idempotency-Key: $(uuidgen)" \
32
+ -H "Idempotency-Key: $IDEM" \
27
33
  -d '{"email":"you@example.com"}'
28
34
  ```
29
35
 
30
- The key comes back once, in `data.key.secret`. Confirming the address we email raises the trial from
36
+ Lost the response? Repeat the exact same request (same Idempotency-Key, same body byte for byte, same network: same public IPv4 or the same IPv6 /64) within 24 hours and the response comes back, if stored, secret included; it is the original response, so a key rotated or revoked since then is not revived. A new Idempotency-Key for the same email returns 409 ACCOUNT_EXISTS; the same key with a different body returns 409 IDEMPOTENCY_CONFLICT.
37
+
38
+ We store only a hash of the key; the signup response is kept for 24 hours so the same request can be replayed. Save `data.key.secret` now.
39
+
40
+ If replay is unavailable, [sign in](https://pokemontcgapi.com/account) and rotate the key, or use /v1/accounts/recover with an already verified email to get a new secret.
41
+
42
+ The key comes back in `data.key.secret`. Confirming the address we email raises the trial from
31
43
  80 to 800 credits, and the trial ends 30 days after signup. Paid plans start at 29 EUR a month:
32
44
  [pricing](https://pokemontcgapi.com/pricing).
33
45
 
@@ -56,14 +68,27 @@ not start with a matching problem.
56
68
  ### Pagination that you never have to think about
57
69
 
58
70
  Every list method returns a `Page`, which is also an `AsyncIterable`. Iterating it follows
59
- `links.next` for you:
71
+ `links.next` for you. For an initial import of all cards, use the flat card list so pages fill
72
+ across set boundaries:
60
73
 
61
74
  ```ts
62
- for await (const set of await client.sets.list({ region: 'JP' })) {
63
- console.log(set.code, set.name, set.release_date);
75
+ for await (const card of await client.cards.search({ limit: 250, orderBy: 'id' })) {
76
+ console.log(card.id, card.name, card.set_code);
64
77
  }
65
78
  ```
66
79
 
80
+ For Japanese cards, add `q: 'set.region:JP'`; for Simplified Chinese cards, use
81
+ `q: 'set.region:CN'`. Add `include: ['translations']` when you need localized names;
82
+ this keeps the plain catalogue cost. `include: ['index']` and `include: ['prices']`
83
+ have different credit costs. `lang` selects a name translation, not a print region.
84
+
85
+ Use `client.sets.list({ region: 'JP', limit: 250 })` to browse set metadata and
86
+ `client.sets.cards('obf', { limit: 250 })` when you need one particular set. For all cards,
87
+ the flat list uses fewer requests than a card loop for every set. The
88
+ [quickstart](https://pokemontcgapi.com/docs/quickstart#page-the-whole-catalogue) includes dated
89
+ measurements, and the [migration guide](https://pokemontcgapi.com/docs/migrate-from-pokemontcg-io)
90
+ explains capturing the change feed watermark before an import and keeping the replica current.
91
+
67
92
  The cursor carries a signature of the sort order, so it must never be reconstructed by hand — the SDK
68
93
  follows the URL the API returned, which is the failure mode this avoids. `.toArray({ max })` requires
69
94
  an explicit ceiling, because the catalogue is large enough that an unbounded materialisation is a
@@ -72,15 +97,24 @@ mistake rather than a choice.
72
97
  ### One call for a hundred cards
73
98
 
74
99
  ```ts
75
- const { data, requested, found } = await client.cards.batch(['bs-4', 'sv3-001'], {
100
+ const { data, requested, found, missing } = await client.cards.batch(['sv8-116', 'sv8-100', 'inventato-xyz'], {
76
101
  include: ['index'], // index_eur on list and batch rows is opt-in: 1 credit per 50 cards
77
102
  select: ['id', 'name', 'index_eur'],
78
103
  });
79
104
  ```
80
105
 
81
- Ids that do not exist are omitted rather than reported one by one compare `requested` with `found`.
106
+ `missing` is optional: it is absent when every id resolves. Otherwise each unresolved id appears once
107
+ as `{ id, suggested_id? }`. A suggestion is included only for an existing historical candidate in a
108
+ different canonical set. In this example only `sv8-100` is returned; `sv8-116` suggests `ssp-116`,
109
+ and `inventato-xyz` has no suggestion. A canonical set prefix binds the lookup to that set;
110
+ `base1-4` still resolves to `bs-4` because `base1` is only a historical alias.
82
111
 
83
- ### Japanese, and the other five locales
112
+ `data` contains distinct cards. Repeated ids count towards `requested` and credits, but do not
113
+ repeat rows in `data` or `missing`. Two valid aliases for one card can make `found` smaller than
114
+ `requested` with no missing ids. Missing entries ignore case and retain the first spelling and
115
+ request order after whitespace trimming. `withheld` remains an optional top-level field.
116
+
117
+ ### Japanese, and the other seven locales
84
118
 
85
119
  ```ts
86
120
  const page = await client.sets.cards('sv8', { lang: 'ja', limit: 1 });
@@ -152,6 +186,14 @@ Every error carries `code`, `status`, `details` and `requestId` — quote the re
152
186
  message, it is the only thing that can be looked up. Retries use exponential backoff with full
153
187
  jitter on 429, 5xx and network failures, honour `Retry-After`, and never retry a quota exhaustion.
154
188
 
189
+ Commercial refusals include `details.next_step`, exposed as the typed `err.nextStep`. If `err.nextStep` exists, show `err.nextStep.handoff` and its URL to the account owner verbatim and do not retry. `err.actionUrl` returns the URL for any action: `checkout_url` for subscribe, `manage_url` for upgrade, `verify_url` for email verification, or `contact_url` for sales and support. Show it alongside `err.handoff`. Upgrades point to the account page, where the owner opens the billing portal to change plan. `err.checkoutUrl` remains a shortcut for subscribe only.
190
+
191
+ ```ts
192
+ if (err instanceof PokemonTcgApiError && err.nextStep) {
193
+ showToUser(err.nextStep.handoff);
194
+ }
195
+ ```
196
+
155
197
  ## What this API does not have
156
198
 
157
199
  Stated up front so you find out here rather than three days into an integration:
@@ -162,13 +204,13 @@ Stated up front so you find out here rather than three days into an integration:
162
204
  `subtypes`, `retreat_cost`, `rules` and `flavor_text` carry rows since 3 September 2026, on the
163
205
  20,725 Western printings. Measured on 16 September 2026 against 57,450 cards: `attacks` on 29.9% of
164
206
  the whole catalogue and 82.9% of the Western part, `subtypes` 35.0%, `abilities` 7.0%.
165
- Japanese and Chinese printings carry none. The types in this package keep them nullable and say
166
- the measured rate on each field, so the compiler makes you handle the half that is absent.
167
- - **No format legalities.** `legalities` is empty for every card. If you are building a deck
168
- checker, this is still not the data source you need.
207
+ Japanese and Chinese printings carry none. The types in this package keep them nullable, so the
208
+ compiler makes you handle the part that is absent.
209
+ - **No format legalities.** The card object has no `legalities` field and `include` rejects the
210
+ value with a 400. If you are building a deck checker, this is not the data source you need.
169
211
 
170
212
  What it does have: the printing itself — set, number, rarity, region, release date, illustrator,
171
- image, marketplace ids, six-language names — and prices.
213
+ image, marketplace ids, names in eight locales — and prices.
172
214
 
173
215
  ## Prices
174
216
 
@@ -179,7 +221,24 @@ for (const price of card.prices ?? []) {
179
221
  }
180
222
  ```
181
223
 
182
- There is no printing filter: first edition, holofoil and graded rows come back together, so read
224
+ The dedicated price routes have their own methods, and they are the ones to use when prices are the
225
+ point of the call:
226
+
227
+ ```ts
228
+ const { data, meta } = await client.prices.card('base1-4'); // index + quotes, 2 credits
229
+ const many = await client.prices.current(['base1-4', 'sv3-125']); // up to 50 ids, 4 credits per 25
230
+ const history = await client.prices.history('base1-4', { bucket: 'week' }); // 5 credits
231
+ const stats = await client.prices.stats('base1-4', { window: '30d' }); // 2 credits
232
+ const movers = await client.prices.movers({ window: '7d', direction: 'gainers' }); // Growth and up
233
+ const box = await client.sealed.prices('evolving-skies-booster-box');
234
+ ```
235
+
236
+ `history` is bounded by your plan (7 days on the trial, 30 on Developer, everything from Growth): a
237
+ wider window throws `UpgradeRequiredError`, whose `permittedWindow` says what you may ask for.
238
+ `movers` below Growth throws `PlanRequiredError`, and a trial past its 30 days throws
239
+ `TrialExpiredError` on every route that costs credits. Both extend `PermissionDeniedError`.
240
+
241
+ There is no printing filter on `include: ['prices']`: first edition, holofoil and graded rows come back together, so read
183
242
  `printing`, `condition` and `grading` per row. `basis` separates `GUIDE` (published upstream) from
184
243
  `DERIVED` (computed by us). `PTCG_INDEX` is a composite index in EUR carrying `sample_n`, and the same
185
244
  number sits on the card row as `index_eur` wherever we have enough observations to compute one: 51,636
@@ -191,9 +250,9 @@ read the one that matches the call you made:
191
250
 
192
251
  | call | where the exclusions are |
193
252
  |---|---|
194
- | `GET /v1/cards/{id}/prices` | `meta.withheld` |
195
- | `GET /v1/cards/{id}?include=prices` | the `X-Plan-Withheld` response header |
196
- | `GET /v1/cards/batch` | a top-level `withheld` field |
253
+ | `client.prices.card(id)` | `meta.withheld` |
254
+ | `client.cards.get(id, { include: ['prices'] })` | the `X-Plan-Withheld` header: `client.lastResponse?.planWithheld` |
255
+ | `client.cards.batch(ids, …)` | a top-level `withheld` field |
197
256
 
198
257
  The values are `graded` and `non_english_locales`: a trial key gets both, Developer keeps `graded`,
199
258
  and from Growth up nothing is withheld, in which case the field is absent rather than an empty array.
@@ -201,6 +260,35 @@ Read it before concluding that a card has no graded observations: it may be your
201
260
  catalogue. Prices also carry their own `locale`, and a card read with `include: ['prices']` returns
202
261
  every locale your plan allows, so the currency does not tell you the language.
203
262
 
263
+ ## Credits and quota
264
+
265
+ Every response says what it cost. The SDK keeps the headers of the last one, and hands each one to
266
+ `onResponse` if you want a running total:
267
+
268
+ ```ts
269
+ let spent = 0;
270
+ const client = new PokemonTcgApi({ onResponse: (r) => { spent += r.creditsCost ?? 0; } });
271
+
272
+ await client.cards.search({ q: 'name:charizard', include: ['index'] });
273
+ console.log(client.lastResponse?.creditsCost, client.lastResponse?.quotaRemaining);
274
+ ```
275
+
276
+ The trial is 800 credits, once, for 30 days, with at most 400 spent in a day; `trialExpiresAt` on
277
+ the same object says when it ends.
278
+
279
+ ## The change feed
280
+
281
+ ```ts
282
+ let since = Number(await store.get('ptcg_since') ?? 0);
283
+ for (;;) {
284
+ const page = await client.changes({ since, limit: 500 });
285
+ for (const change of page.data) await apply(change); // kind, entity_id, op, version
286
+ since = page.meta.next_since;
287
+ await store.set('ptcg_since', since);
288
+ if (!page.meta.has_more) break;
289
+ }
290
+ ```
291
+
204
292
  ## Also available
205
293
 
206
294
  - **MCP server** for agents: [`@pokemontcgapi/mcp`](https://www.npmjs.com/package/@pokemontcgapi/mcp) — [source](https://github.com/pokemontcgapi/mcp-server)
@@ -215,8 +303,8 @@ npm run typecheck
215
303
  npm run build
216
304
  ```
217
305
 
218
- Node >= 20. No test suite lives here yet: what CI enforces is that the package
219
- typechecks and builds on both Node 20 and Node 22, and that `npm pack` produces
306
+ Node >= 20. `npm test` runs the type-level and unit tests in `tests/`. CI enforces that the
307
+ package typechecks and builds on both Node 20 and Node 22, and that `npm pack` produces
220
308
  the file list the registry is meant to receive.
221
309
 
222
310
  This package is developed inside the private monorepo that runs
package/dist/client.d.ts CHANGED
@@ -28,6 +28,29 @@ export interface ClientOptions {
28
28
  */
29
29
  readonly cache?: 'none' | 'etag';
30
30
  readonly userAgent?: string;
31
+ /** Chiamata a ogni risposta ricevuta, errori compresi: il posto per un contatore di crediti. */
32
+ readonly onResponse?: (info: ResponseInfo) => void;
33
+ }
34
+ /**
35
+ * Cio' che la risposta dice negli header e che il corpo non porta.
36
+ *
37
+ * `planWithheld` e' il motivo per cui esiste: su `cards.get(id, { include:
38
+ * ['prices'] })` le righe che il piano non copre (le quotazioni gradate sotto
39
+ * Growth) mancano in silenzio dal corpo, e solo `X-Plan-Withheld` lo dice.
40
+ */
41
+ export interface ResponseInfo {
42
+ readonly url: string;
43
+ readonly status: number;
44
+ readonly requestId: string | null;
45
+ /** Crediti scalati da questa chiamata. 0 su rotte gratuite, 304 ed errori del client. */
46
+ readonly creditsCost: number | null;
47
+ readonly quotaLimit: number | null;
48
+ readonly quotaRemaining: number | null;
49
+ readonly quotaReset: string | null;
50
+ readonly rateLimitRemaining: number | null;
51
+ readonly planWithheld: readonly string[];
52
+ /** Solo sulla prova: quando scade. */
53
+ readonly trialExpiresAt: string | null;
31
54
  }
32
55
  export declare function serializeParams(params: Record<string, unknown> | undefined): URLSearchParams;
33
56
  export declare class HttpClient {
@@ -38,6 +61,9 @@ export declare class HttpClient {
38
61
  private readonly doFetch;
39
62
  private readonly userAgent;
40
63
  private readonly etags;
64
+ private readonly onResponse;
65
+ /** Gli header dell'ultima risposta ricevuta da questa istanza. */
66
+ lastResponse: ResponseInfo | null;
41
67
  constructor(options?: ClientOptions);
42
68
  /** URL assoluto da un path applicativo piu' i parametri. */
43
69
  url(path: string, params?: Record<string, unknown>): string;
@@ -88,8 +114,8 @@ export declare class Page<T> implements AsyncIterable<T> {
88
114
  nextPage(): Promise<Page<T> | null>;
89
115
  [Symbol.asyncIterator](): AsyncIterator<T>;
90
116
  /**
91
- * Materializza in un array. `max` e' OBBLIGATORIO: il catalogo ha oltre
92
- * 52.000 carte, e un `.toArray()` senza tetto e' il modo piu' rapido di
117
+ * Materializza in un array. `max` e' OBBLIGATORIO: il catalogo ha decine di
118
+ * migliaia di carte, e un `.toArray()` senza tetto e' il modo piu' rapido di
93
119
  * riempire la memoria di un processo per sbaglio.
94
120
  */
95
121
  toArray({ max }: {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,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IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAOjD,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAMlC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;IAQjD;;;;OAIG;IACG,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAQtD"}
package/dist/client.js CHANGED
@@ -1,4 +1,27 @@
1
1
  import { ApiConnectionError, ApiTimeoutError, PokemonTcgApiError, QuotaExceededError, RateLimitedError, ServerError, toApiError, } from './errors.js';
2
+ function headerNumber(headers, name) {
3
+ const raw = headers.get(name);
4
+ if (raw === null)
5
+ return null;
6
+ const n = Number(raw);
7
+ return Number.isFinite(n) ? n : null;
8
+ }
9
+ function toResponseInfo(url, response) {
10
+ const h = response.headers;
11
+ const withheld = h.get('x-plan-withheld');
12
+ return {
13
+ url,
14
+ status: response.status,
15
+ requestId: h.get('x-request-id'),
16
+ creditsCost: headerNumber(h, 'x-credits-cost'),
17
+ quotaLimit: headerNumber(h, 'x-quota-limit'),
18
+ quotaRemaining: headerNumber(h, 'x-quota-remaining'),
19
+ quotaReset: h.get('x-quota-reset'),
20
+ rateLimitRemaining: headerNumber(h, 'ratelimit-remaining'),
21
+ planWithheld: withheld === null || withheld === '' ? [] : withheld.split(',').map((v) => v.trim()),
22
+ trialExpiresAt: h.get('x-trial-expires-at'),
23
+ };
24
+ }
2
25
  const DEFAULT_BASE_URL = 'https://api.pokemontcgapi.com';
3
26
  const DEFAULT_TIMEOUT = 30_000;
4
27
  const DEFAULT_MAX_RETRIES = 2;
@@ -64,6 +87,9 @@ export class HttpClient {
64
87
  doFetch;
65
88
  userAgent;
66
89
  etags;
90
+ onResponse;
91
+ /** Gli header dell'ultima risposta ricevuta da questa istanza. */
92
+ lastResponse = null;
67
93
  constructor(options = {}) {
68
94
  this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
69
95
  this.apiKey = options.apiKey ?? readEnv('PTCG_API_KEY');
@@ -72,6 +98,7 @@ export class HttpClient {
72
98
  this.doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
73
99
  this.userAgent = options.userAgent ?? '@pokemontcgapi/sdk';
74
100
  this.etags = options.cache === 'etag' ? new Map() : null;
101
+ this.onResponse = options.onResponse;
75
102
  }
76
103
  /** URL assoluto da un path applicativo piu' i parametri. */
77
104
  url(path, params) {
@@ -157,6 +184,8 @@ export class HttpClient {
157
184
  finally {
158
185
  clearTimeout(timer);
159
186
  }
187
+ this.lastResponse = toResponseInfo(url, response);
188
+ this.onResponse?.(this.lastResponse);
160
189
  // 304: il corpo e' vuoto per definizione, la risposta e' quella in cache.
161
190
  if (response.status === 304 && cached !== undefined)
162
191
  return cached.body;
@@ -230,8 +259,8 @@ export class Page {
230
259
  }
231
260
  }
232
261
  /**
233
- * Materializza in un array. `max` e' OBBLIGATORIO: il catalogo ha oltre
234
- * 52.000 carte, e un `.toArray()` senza tetto e' il modo piu' rapido di
262
+ * Materializza in un array. `max` e' OBBLIGATORIO: il catalogo ha decine di
263
+ * migliaia di carte, e un `.toArray()` senza tetto e' il modo piu' rapido di
235
264
  * riempire la memoria di un processo per sbaglio.
236
265
  */
237
266
  async toArray({ max }) {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,UAAU,GAEX,MAAM,aAAa,CAAC;AAmCrB,MAA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B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAmB;QACpC,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG;gBAAE,MAAM;QAC/B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
package/dist/errors.d.ts CHANGED
@@ -12,6 +12,24 @@
12
12
  * modo di consumare tempo. Il retry automatico di questo client riprova il
13
13
  * primo e non riprova mai il secondo.
14
14
  */
15
+ export interface NextStep {
16
+ readonly action: 'subscribe' | 'upgrade' | 'contact_sales' | 'contact_support' | 'verify_email';
17
+ readonly actor: 'account_owner';
18
+ readonly plan?: {
19
+ readonly code: string;
20
+ readonly name: string;
21
+ readonly monthly_eur?: string;
22
+ readonly yearly_eur?: string;
23
+ readonly credits_per_month?: number;
24
+ };
25
+ readonly checkout_url?: string;
26
+ readonly checkout_url_yearly?: string;
27
+ readonly manage_url?: string;
28
+ readonly contact_url?: string;
29
+ readonly verify_url?: string;
30
+ readonly plans_url: string;
31
+ readonly handoff: string;
32
+ }
15
33
  export interface ApiErrorBody {
16
34
  readonly code: string;
17
35
  readonly message: string;
@@ -28,6 +46,10 @@ export declare class PokemonTcgApiError extends Error {
28
46
  */
29
47
  readonly requestId: string | undefined;
30
48
  readonly details: Record<string, unknown> | undefined;
49
+ get nextStep(): NextStep | undefined;
50
+ get checkoutUrl(): string | undefined;
51
+ get actionUrl(): string | undefined;
52
+ get handoff(): string | undefined;
31
53
  constructor(status: number, body: ApiErrorBody);
32
54
  }
33
55
  /** 401 — chiave assente, malformata o revocata. */
@@ -36,7 +58,20 @@ export declare class AuthenticationError extends PokemonTcgApiError {
36
58
  /** 403 — la chiave e' valida ma non puo' fare questa cosa. */
37
59
  export declare class PermissionDeniedError extends PokemonTcgApiError {
38
60
  }
39
- /** 402 / UPGRADE_REQUIRED — serve un piano superiore. */
61
+ /**
62
+ * 403 PLAN_REQUIRED — la rotta non e' nel piano (movers e foto partono da
63
+ * Growth). Estende `PermissionDeniedError`: chi gia' la catturava continua a
64
+ * farlo, chi vuole distinguere "compra" da "scope sbagliato" ora puo'.
65
+ */
66
+ export declare class PlanRequiredError extends PermissionDeniedError {
67
+ }
68
+ /**
69
+ * 403 TRIAL_EXPIRED — la prova e' finita (30 giorni) e la rotta costa crediti.
70
+ * Non passa aspettando ne' riprovando: serve un piano.
71
+ */
72
+ export declare class TrialExpiredError extends PermissionDeniedError {
73
+ }
74
+ /** 403 UPGRADE_REQUIRED — la finestra chiesta e' piu' larga di quella del piano. */
40
75
  export declare class UpgradeRequiredError extends PokemonTcgApiError {
41
76
  /** Finestra concessa dal piano corrente, quando l'API la dichiara. */
42
77
  get permittedWindow(): unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAA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AA0D;AAC1D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,gEAAgE;IAChE,SAAkB,KAAK,EAAE,OAAO,CAAC;gBACrB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK5C;AAED,+DAA+D;AAC/D,qBAAa,eAAgB,SAAQ,kBAAkB;gBACzC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAI9C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAetG"}
package/dist/errors.js CHANGED
@@ -22,6 +22,35 @@ export class PokemonTcgApiError extends Error {
22
22
  */
23
23
  requestId;
24
24
  details;
25
+ get nextStep() {
26
+ const value = this.details?.['next_step'];
27
+ if (typeof value !== 'object' || value === null)
28
+ return undefined;
29
+ const step = value;
30
+ if (step['actor'] !== 'account_owner' || typeof step['handoff'] !== 'string' ||
31
+ typeof step['plans_url'] !== 'string' ||
32
+ !['subscribe', 'upgrade', 'contact_sales', 'contact_support', 'verify_email'].includes(String(step['action']))) {
33
+ return undefined;
34
+ }
35
+ return value;
36
+ }
37
+ get checkoutUrl() {
38
+ const value = this.nextStep?.checkout_url;
39
+ return typeof value === 'string' ? value : undefined;
40
+ }
41
+ get actionUrl() {
42
+ const step = this.nextStep;
43
+ if (!step)
44
+ return undefined;
45
+ const value = step.action === 'subscribe' ? step.checkout_url
46
+ : step.action === 'upgrade' ? step.manage_url
47
+ : step.action === 'verify_email' ? step.verify_url
48
+ : step.contact_url;
49
+ return typeof value === 'string' ? value : undefined;
50
+ }
51
+ get handoff() {
52
+ return this.nextStep?.handoff;
53
+ }
25
54
  constructor(status, body) {
26
55
  super(`${body.code}: ${body.message}`);
27
56
  this.name = new.target.name;
@@ -37,7 +66,20 @@ export class AuthenticationError extends PokemonTcgApiError {
37
66
  /** 403 — la chiave e' valida ma non puo' fare questa cosa. */
38
67
  export class PermissionDeniedError extends PokemonTcgApiError {
39
68
  }
40
- /** 402 / UPGRADE_REQUIRED — serve un piano superiore. */
69
+ /**
70
+ * 403 PLAN_REQUIRED — la rotta non e' nel piano (movers e foto partono da
71
+ * Growth). Estende `PermissionDeniedError`: chi gia' la catturava continua a
72
+ * farlo, chi vuole distinguere "compra" da "scope sbagliato" ora puo'.
73
+ */
74
+ export class PlanRequiredError extends PermissionDeniedError {
75
+ }
76
+ /**
77
+ * 403 TRIAL_EXPIRED — la prova e' finita (30 giorni) e la rotta costa crediti.
78
+ * Non passa aspettando ne' riprovando: serve un piano.
79
+ */
80
+ export class TrialExpiredError extends PermissionDeniedError {
81
+ }
82
+ /** 403 UPGRADE_REQUIRED — la finestra chiesta e' piu' larga di quella del piano. */
41
83
  export class UpgradeRequiredError extends PokemonTcgApiError {
42
84
  /** Finestra concessa dal piano corrente, quando l'API la dichiara. */
43
85
  get permittedWindow() {
@@ -95,10 +137,14 @@ export class ApiTimeoutError extends ApiConnectionError {
95
137
  */
96
138
  export function toApiError(status, body, retryAfter) {
97
139
  const code = body.code;
98
- if (code === 'QUOTA_EXCEEDED' || code === 'MONTHLY_QUOTA_EXCEEDED')
140
+ if (code === 'QUOTA_EXCEEDED')
99
141
  return new QuotaExceededError(status, body);
100
- if (code === 'UPGRADE_REQUIRED' || status === 402)
142
+ if (code === 'UPGRADE_REQUIRED')
101
143
  return new UpgradeRequiredError(status, body);
144
+ if (code === 'PLAN_REQUIRED')
145
+ return new PlanRequiredError(status, body);
146
+ if (code === 'TRIAL_EXPIRED')
147
+ return new TrialExpiredError(status, body);
102
148
  if (status === 429)
103
149
  return new RateLimitedError(status, body, retryAfter);
104
150
  if (status === 401)
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,6DAA6D;IACpD,IAAI,CAAS;I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