scryfall-api 4.0.0-beta.0 → 4.0.0-beta.2

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.
@@ -0,0 +1,424 @@
1
+ /**
2
+ * Type definition for Nullable.
3
+ * @type {T | null | undefined} The type can be T, null, or undefined.
4
+ * @template T The type of the value that can be null or undefined.
5
+ */
6
+ type Nullable<T> = T | null | undefined;
7
+
8
+ type QueryValue = boolean | number | string | undefined;
9
+ interface PageQuery {
10
+ [key: string]: QueryValue;
11
+ page: number;
12
+ }
13
+ declare class MagicPageResult<T> {
14
+ #private;
15
+ private readonly apiPath;
16
+ private readonly query;
17
+ constructor(apiPath: string, query: PageQuery);
18
+ get count(): number;
19
+ get hasMore(): boolean;
20
+ all(): Promise<T[]>;
21
+ get(limit: number): Promise<T[]>;
22
+ next(): Promise<T[]>;
23
+ page(page: number): Promise<T[]>;
24
+ private setNextPage;
25
+ }
26
+
27
+ interface CardIdentifierId {
28
+ id: string;
29
+ }
30
+ interface CardIdentifierIllustrationId {
31
+ illustration_id: string;
32
+ }
33
+ interface CardIdentifierMtgGoId {
34
+ mtgo_id: number;
35
+ }
36
+ interface CardIdentifierMultiverseId {
37
+ multiverse_id: number;
38
+ }
39
+ interface CardIdentifierNameSet {
40
+ name: string;
41
+ set?: string;
42
+ }
43
+ interface CardIdentifierOracleId {
44
+ oracle_id: string;
45
+ }
46
+ interface CardIdentifierCollectorSet {
47
+ collector_number: string;
48
+ set: string;
49
+ }
50
+ type CardIdentifier = CardIdentifierId | CardIdentifierIllustrationId | CardIdentifierMtgGoId | CardIdentifierMultiverseId | CardIdentifierNameSet | CardIdentifierOracleId | CardIdentifierCollectorSet;
51
+
52
+ declare class CardIdentifierApi {
53
+ static byId(id: string): CardIdentifier;
54
+ static byIllustrationId(id: string): CardIdentifier;
55
+ static byMtgoId(id: number): CardIdentifier;
56
+ static byMultiverseId(id: number): CardIdentifier;
57
+ static byName(name: string, set?: string): CardIdentifier;
58
+ static byOracleId(id: string): CardIdentifier;
59
+ static bySet(set: string, collectorNumber: number | string): CardIdentifier;
60
+ }
61
+
62
+ type CardLanguage = 'en' | 'es' | 'fr' | 'de' | 'it' | 'pt' | 'ja' | 'ko' | 'ru' | 'zhs' | 'zht' | 'he' | 'la' | 'grc' | 'ar' | 'sa' | 'ph';
63
+ type CardLayout = 'normal' | 'split' | 'flip' | 'transform' | 'modal_dfc' | 'meld' | 'leveler' | 'class' | 'case' | 'saga' | 'adventure' | 'mutate' | 'prototype' | 'battle' | 'planar' | 'scheme' | 'vanguard' | 'token' | 'double_faced_token' | 'emblem' | 'augment' | 'host' | 'art_series' | 'reversible_card';
64
+ interface CardCore {
65
+ arena_id?: Nullable<string>;
66
+ cardmarket_id?: Nullable<number>;
67
+ id: string;
68
+ lang: CardLanguage;
69
+ layout: CardLayout;
70
+ mtgo_foil_id?: Nullable<number>;
71
+ mtgo_id?: Nullable<number>;
72
+ multiverse_ids?: Nullable<number[]>;
73
+ object: 'card';
74
+ oracle_id?: Nullable<string>;
75
+ prints_search_uri: string;
76
+ rulings_uri: string;
77
+ scryfall_uri: string;
78
+ tcgplayer_etched_id?: Nullable<number>;
79
+ tcgplayer_id?: Nullable<number>;
80
+ uri: string;
81
+ }
82
+
83
+ type Color = 'W' | 'B' | 'R' | 'U' | 'G';
84
+ interface ManaCost {
85
+ cmc: number;
86
+ colorless: boolean;
87
+ colors: Color[];
88
+ cost: string;
89
+ monocolored: boolean;
90
+ multicolored: boolean;
91
+ object: 'mana_cost';
92
+ }
93
+ interface Symbology {
94
+ appears_in_mana_costs: boolean;
95
+ colors: Color[];
96
+ english: string;
97
+ funny: boolean;
98
+ gatherer_alternates?: Nullable<string[]>;
99
+ hybrid: boolean;
100
+ loose_variant?: Nullable<string>;
101
+ mana_value?: Nullable<number>;
102
+ object: 'card_symbol';
103
+ phyrexian: boolean;
104
+ represents_mana: boolean;
105
+ svg_uri?: Nullable<string>;
106
+ symbol: string;
107
+ transposable: boolean;
108
+ }
109
+
110
+ declare class SymbologyApi {
111
+ all(): Promise<Symbology[]>;
112
+ parseMana(shorthand: string): Promise<ManaCost>;
113
+ }
114
+ declare const symbology: SymbologyApi;
115
+
116
+ type CardComponent = 'token' | 'meld_part' | 'meld_result' | 'combo_piece';
117
+ type Legality = 'legal' | 'not_legal' | 'restricted' | 'banned';
118
+ interface ImageUris$1 {
119
+ art_crop: string;
120
+ border_crop: string;
121
+ large: string;
122
+ normal: string;
123
+ png: string;
124
+ small: string;
125
+ }
126
+ interface CardFace {
127
+ artist?: Nullable<string>;
128
+ artist_id?: Nullable<string>;
129
+ cmc?: Nullable<number>;
130
+ color_indicator?: Nullable<Color[]>;
131
+ colors?: Nullable<Color[]>;
132
+ defense?: Nullable<string>;
133
+ flavor_text?: Nullable<string>;
134
+ illustration_id?: Nullable<string>;
135
+ image_uris?: Nullable<ImageUris$1>;
136
+ layout?: Nullable<string>;
137
+ loyalty?: Nullable<string>;
138
+ mana_cost: string;
139
+ name: string;
140
+ object: 'card_face';
141
+ oracle_id?: Nullable<string>;
142
+ oracle_text?: Nullable<string>;
143
+ power?: Nullable<string>;
144
+ printed_name?: Nullable<string>;
145
+ printed_text?: Nullable<string>;
146
+ printed_type_line?: Nullable<string>;
147
+ toughness?: Nullable<string>;
148
+ type_line?: Nullable<string>;
149
+ watermark?: Nullable<string>;
150
+ }
151
+ interface RelatedCard {
152
+ component: CardComponent;
153
+ id: string;
154
+ name: string;
155
+ object: 'related_card';
156
+ type_line: string;
157
+ uri: string;
158
+ }
159
+ interface Legalities {
160
+ alchemy: Legality;
161
+ brawl: Legality;
162
+ commander: Legality;
163
+ duel: Legality;
164
+ explorer: Legality;
165
+ future: Legality;
166
+ gladiator: Legality;
167
+ historic: Legality;
168
+ legacy: Legality;
169
+ modern: Legality;
170
+ oathbreaker: Legality;
171
+ oldschool: Legality;
172
+ pauper: Legality;
173
+ paupercommander: Legality;
174
+ penny: Legality;
175
+ pioneer: Legality;
176
+ predh: Legality;
177
+ premodern: Legality;
178
+ standard: Legality;
179
+ standardbrawl: Legality;
180
+ timeless: Legality;
181
+ vintage: Legality;
182
+ }
183
+ interface GameplayCard {
184
+ all_parts?: Nullable<RelatedCard[]>;
185
+ card_faces?: Nullable<CardFace[]>;
186
+ cmc: number;
187
+ color_identity: Color[];
188
+ color_indicator?: Nullable<Color[]>;
189
+ colors?: Nullable<Color[]>;
190
+ defense?: Nullable<string>;
191
+ edhrec_rank?: Nullable<number>;
192
+ hand_modifier?: Nullable<string>;
193
+ keywords: string[];
194
+ legalities: Legalities;
195
+ life_modifier?: Nullable<string>;
196
+ loyalty?: Nullable<string>;
197
+ mana_cost?: Nullable<string>;
198
+ name: string;
199
+ oracle_text?: Nullable<string>;
200
+ penny_rank?: Nullable<number>;
201
+ power?: Nullable<string>;
202
+ produced_mana?: Nullable<Color[]>;
203
+ reserved: boolean;
204
+ toughness?: Nullable<string>;
205
+ type_line: string;
206
+ }
207
+
208
+ type SetType = 'core' | 'expansion' | 'masters' | 'alchemy' | 'masterpiece' | 'arsenal' | 'from_the_vault' | 'spellbook' | 'premium_deck' | 'duel_deck' | 'draft_innovation' | 'treasure_chest' | 'commander' | 'planechase' | 'archenemy' | 'vanguard' | 'funny' | 'starter' | 'box' | 'promo' | 'token' | 'memorabilia' | 'minigame';
209
+ interface Set {
210
+ arena_code?: Nullable<string>;
211
+ block?: Nullable<string>;
212
+ block_code?: Nullable<string>;
213
+ card_count: number;
214
+ code: string;
215
+ digital: boolean;
216
+ foil_only: boolean;
217
+ icon_svg_uri: string;
218
+ id: string;
219
+ mtgo_code?: Nullable<string>;
220
+ name: string;
221
+ nonfoil_only: boolean;
222
+ object: 'set';
223
+ parent_set_code?: Nullable<string>;
224
+ printed_size?: Nullable<number>;
225
+ released_at?: Nullable<Date>;
226
+ scryfall_uri: string;
227
+ search_uri: string;
228
+ set_type: SetType;
229
+ tcgplayer_id?: Nullable<number>;
230
+ uri: string;
231
+ }
232
+
233
+ declare class SetApi {
234
+ all(): Promise<Set[]>;
235
+ byCode(code: string): Promise<Set | undefined>;
236
+ byId(id: string): Promise<Set | undefined>;
237
+ byTcgPlayerId(id: number): Promise<Set | undefined>;
238
+ }
239
+ declare const set: SetApi;
240
+
241
+ type BorderColor = 'black' | 'borderless' | 'gold' | 'silver' | 'white';
242
+ type Finish = 'foil' | 'nonfoil' | 'etched';
243
+ type Frame = '1993' | '1997' | '2003' | '2015' | 'future';
244
+ type FrameEffect = 'legendary' | 'miracle' | 'nyxtouched' | 'draft' | 'devoid' | 'tombstone' | 'colorshifted' | 'inverted' | 'sunmoondfc' | 'compasslanddfc' | 'originpwdfc' | 'mooneldrazidfc' | 'waxingandwaningmoondfc' | 'showcase' | 'extendedart' | 'companion' | 'etched' | 'snow' | 'lesson' | 'shatteredglass' | 'convertdfc' | 'fandfc' | 'upsidedowndfc';
245
+ type Game = 'paper' | 'arena' | 'mtgo';
246
+ type ImageStatus = 'missing' | 'placeholder' | 'lowres' | 'highres_scan';
247
+ interface ImageUris {
248
+ art_crop: string;
249
+ border_crop: string;
250
+ large: string;
251
+ normal: string;
252
+ png: string;
253
+ small: string;
254
+ }
255
+ interface Preview {
256
+ previewed_at: Date;
257
+ source: string;
258
+ source_uri: string;
259
+ }
260
+ interface Prices {
261
+ eur?: Nullable<string>;
262
+ eur_foil?: Nullable<string>;
263
+ tix?: Nullable<string>;
264
+ usd?: Nullable<string>;
265
+ usd_etched?: Nullable<string>;
266
+ usd_foil?: Nullable<string>;
267
+ }
268
+ type PromoType = 'ourney' | 'prerelease' | 'datestamped' | 'planeswalkerdeck' | 'buyabox' | 'judgegift' | 'event' | 'convention' | 'starterdeck' | 'instore' | 'setpromo' | 'fnm' | 'openhouse' | 'league' | 'draftweekend' | 'gameday' | 'release' | 'intropack' | 'giftbox' | 'duels' | 'wizardsplaynetwork' | 'premiereshop' | 'playerrewards' | 'gateway' | 'arenaleague';
269
+ interface PurchaseUris {
270
+ [key: string]: Nullable<string>;
271
+ cardhoarder?: Nullable<string>;
272
+ cardmarket?: Nullable<string>;
273
+ tcgplayer?: Nullable<string>;
274
+ }
275
+ type Rarity = 'common' | 'uncommon' | 'rare' | 'special' | 'mythic' | 'bonus';
276
+ interface RelatedUris {
277
+ [key: string]: Nullable<string>;
278
+ edhrec?: Nullable<string>;
279
+ gatherer?: Nullable<string>;
280
+ mtgtop8?: Nullable<string>;
281
+ tcgplayer_decks?: Nullable<string>;
282
+ tcgplayer_infinite_articles?: Nullable<string>;
283
+ tcgplayer_infinite_decks?: Nullable<string>;
284
+ }
285
+ type SecurityStamp = 'oval' | 'triangle' | 'acorn' | 'circle' | 'arena' | 'heart';
286
+ interface CardPrint {
287
+ artist?: Nullable<string>;
288
+ artist_ids?: Nullable<string[]>;
289
+ attraction_lights?: Nullable<number[]>;
290
+ booster: boolean;
291
+ border_color: BorderColor;
292
+ card_back_id: string;
293
+ collector_number: string;
294
+ content_warning?: Nullable<boolean>;
295
+ digital: boolean;
296
+ finishes: Finish[];
297
+ flavor_name?: Nullable<string>;
298
+ flavor_text?: Nullable<string>;
299
+ frame: Frame;
300
+ frame_effects?: Nullable<FrameEffect[]>;
301
+ full_art: boolean;
302
+ games: Game[];
303
+ highres_image: boolean;
304
+ illustration_id?: Nullable<string>;
305
+ image_status: ImageStatus;
306
+ image_uris?: Nullable<ImageUris>;
307
+ oversized: boolean;
308
+ preview: Preview;
309
+ prices: Prices;
310
+ printed_name?: Nullable<string>;
311
+ printed_text?: Nullable<string>;
312
+ printed_type_line?: Nullable<string>;
313
+ promo: boolean;
314
+ promo_types?: Nullable<PromoType[]>;
315
+ purchase_uris?: Nullable<PurchaseUris>;
316
+ rarity: Rarity;
317
+ related_uris: RelatedUris;
318
+ released_at: Date;
319
+ reprint: boolean;
320
+ scryfall_set_uri: string;
321
+ security_stamp?: Nullable<SecurityStamp>;
322
+ set: string;
323
+ set_id: string;
324
+ set_name: string;
325
+ set_search_uri: string;
326
+ set_type: SetType;
327
+ set_uri: string;
328
+ story_spotlight: boolean;
329
+ textless: boolean;
330
+ variation: boolean;
331
+ variation_of?: Nullable<string>;
332
+ watermark?: Nullable<string>;
333
+ }
334
+
335
+ type Card = CardCore & GameplayCard & CardPrint;
336
+
337
+ type CardSearchUnique = 'cards' | 'art' | 'prints';
338
+ type CardSearchOrder = 'name' | 'set' | 'released' | 'rarity' | 'color' | 'usd' | 'tix' | 'eur' | 'cmc' | 'power' | 'toughness' | 'edhrec' | 'penny' | 'artist' | 'review';
339
+ type CardSearchDir = 'auto' | 'asc' | 'desc';
340
+ type CardSearchFormat = 'json' | 'csv';
341
+ interface CardSearch {
342
+ dir?: CardSearchDir;
343
+ format?: CardSearchFormat;
344
+ include_extras?: boolean;
345
+ include_multilingual?: boolean;
346
+ include_variations?: boolean;
347
+ order?: CardSearchOrder;
348
+ page?: number;
349
+ pretty?: boolean;
350
+ unique?: CardSearchUnique;
351
+ }
352
+
353
+ declare class CardApi {
354
+ autoCompleteName(name: string): Promise<string[]>;
355
+ byArenaId(id: number): Promise<Card | undefined>;
356
+ byId(id: string): Promise<Card | undefined>;
357
+ byMtgoId(id: number): Promise<Card | undefined>;
358
+ byMultiverseId(id: number): Promise<Card | undefined>;
359
+ byName(name: string, fuzzy?: boolean): Promise<Card | undefined>;
360
+ byName(name: string, set?: string, fuzzy?: boolean): Promise<Card | undefined>;
361
+ bySet(setCode: string, collectorNumber: number, lang?: string): Promise<Card | undefined>;
362
+ byTcgPlayerId(id: number): Promise<Card | undefined>;
363
+ collection(...identifiers: CardIdentifier[]): Promise<Card[]>;
364
+ random(): Promise<Card>;
365
+ search(query: string, options?: CardSearch | number): MagicPageResult<Card>;
366
+ }
367
+ declare const cards: CardApi;
368
+
369
+ declare class CatalogApi {
370
+ artifactTypes(): Promise<string[]>;
371
+ artistNames(): Promise<string[]>;
372
+ cardNames(): Promise<string[]>;
373
+ creatureTypes(): Promise<string[]>;
374
+ enchantmentTypes(): Promise<string[]>;
375
+ landTypes(): Promise<string[]>;
376
+ loyalties(): Promise<string[]>;
377
+ planeswalkerTypes(): Promise<string[]>;
378
+ powers(): Promise<string[]>;
379
+ spellTypes(): Promise<string[]>;
380
+ toughnesses(): Promise<string[]>;
381
+ watermarks(): Promise<string[]>;
382
+ wordBank(): Promise<string[]>;
383
+ }
384
+ declare const catalog: CatalogApi;
385
+
386
+ interface Catalog {
387
+ data: string[];
388
+ object: 'catalog';
389
+ total_values: number;
390
+ uri: string;
391
+ }
392
+
393
+ interface Ruling {
394
+ comment: string;
395
+ object: 'ruling';
396
+ oracle_id: string;
397
+ published_at: Date;
398
+ source: string;
399
+ }
400
+
401
+ declare class RulingApi {
402
+ byArenaId(id: number): Promise<Ruling[]>;
403
+ byId(id: string): Promise<Ruling[]>;
404
+ byMtgoId(id: number): Promise<Ruling[]>;
405
+ byMultiverseId(id: number): Promise<Ruling[]>;
406
+ bySet(setCode: string, collectorNumber: number | string): Promise<Ruling[]>;
407
+ }
408
+ declare const rulings: RulingApi;
409
+
410
+ declare class InvalidScryfallArgumentError extends Error {
411
+ }
412
+
413
+ declare class ScryfallError extends Error {
414
+ readonly code: string;
415
+ readonly status: number;
416
+ readonly type?: string | null | undefined;
417
+ readonly warnings?: string[] | null | undefined;
418
+ constructor(code: string, details: string, status: number, type?: string | null | undefined, warnings?: string[] | null | undefined);
419
+ }
420
+
421
+ declare class UnknownScryfallError extends Error {
422
+ }
423
+
424
+ export { type Card, type CardIdentifier, CardIdentifierApi as CardIdentifierBuilder, type CardIdentifierCollectorSet, type CardIdentifierId, type CardIdentifierIllustrationId, type CardIdentifierMtgGoId, type CardIdentifierMultiverseId, type CardIdentifierNameSet, type CardIdentifierOracleId, type CardSearch, type CardSearchDir, type CardSearchFormat, type CardSearchOrder, type CardSearchUnique, cards as Cards, type Catalog, catalog as Catalogs, type Color, InvalidScryfallArgumentError, MagicPageResult, type ManaCost, type Ruling, rulings as Rulings, ScryfallError, type Set, type SetType, set as Sets, type Symbology, symbology as SymbologyApi, UnknownScryfallError };