scryfall-api 3.2.3 → 3.2.4

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
@@ -5,7 +5,9 @@
5
5
 
6
6
  A Javascript library for [Scryfall](https://scryfall.com/docs/api) written in Typescript.
7
7
 
8
- As of [August 6th, 2022](./CHANGELOG.md), almost all features described in the [Scryfall documentation](https://scryfall.com/docs/api) are supported. If you see something that isn't supported, make an issue! See [support readme](./SUPPORT.md).
8
+ As of [August 6th, 2022](./CHANGELOG.md), almost all features described in
9
+ the [Scryfall documentation](https://scryfall.com/docs/api) are supported. If you see something that isn't supported,
10
+ make an issue! See [support readme](./SUPPORT.md).
9
11
 
10
12
  ## Installation
11
13
 
package/dist/index.d.ts CHANGED
@@ -33,60 +33,54 @@ export declare enum BulkDataTypes {
33
33
  }
34
34
 
35
35
  export declare interface Card {
36
- object: 'card';
37
- arena_id?: number;
38
- id: string;
39
- lang: string;
40
- mtgo_id?: number;
41
- mtgo_foil_id?: number;
42
- multiverse_ids?: number[];
43
- tcgplayer_id?: number;
44
- oracle_id: string;
45
- prints_search_uri: string;
46
- rulings_uri: string;
47
- scryfall_uri: string;
48
- uri: string;
49
36
  all_parts?: RelatedCard[];
37
+ arena_id?: number;
38
+ artist?: string;
39
+ artist_ids?: string[];
40
+ booster: boolean;
41
+ border_color: keyof typeof Border;
42
+ card_back_id: string;
50
43
  card_faces?: CardFace[];
51
44
  cmc: number;
52
- colors?: Color[];
45
+ collector_number: string;
53
46
  color_identity: Color[];
54
47
  color_indicator?: Color[];
48
+ colors?: Color[];
49
+ digital: boolean;
55
50
  edhrec_rank?: number;
51
+ flavor_text?: string;
56
52
  foil: boolean;
53
+ frame: '1993' | '1997' | '2003' | '2015' | 'Future';
54
+ frame_effects?: (keyof typeof FrameEffect)[];
55
+ full_art: boolean;
56
+ games: (keyof typeof Game)[];
57
57
  hand_modifier?: string;
58
+ highres_image: boolean;
59
+ id: string;
60
+ illustration_id?: string;
61
+ image_uris?: ImageUris;
62
+ lang: string;
58
63
  layout: keyof typeof Layout;
59
64
  legalities: Legalities;
60
65
  life_modifier?: string;
61
66
  loyalty?: string;
62
67
  mana_cost?: string;
68
+ mtgo_foil_id?: number;
69
+ mtgo_id?: number;
70
+ multiverse_ids?: number[];
63
71
  name: string;
64
72
  nonfoil: boolean;
73
+ object: 'card';
74
+ oracle_id: string;
65
75
  oracle_text?: string;
66
76
  oversized: boolean;
67
77
  power?: string;
68
- reserved: boolean;
69
- toughness?: string;
70
- type_line: string;
71
- artist?: string;
72
- artist_ids?: string[];
73
- booster: boolean;
74
- border_color: keyof typeof Border;
75
- card_back_id: string;
76
- collector_number: string;
77
- digital: boolean;
78
- flavor_text?: string;
79
- frame_effects?: (keyof typeof FrameEffect)[];
80
- frame: '1993' | '1997' | '2003' | '2015' | 'Future';
81
- full_art: boolean;
82
- games: (keyof typeof Game)[];
83
- highres_image: boolean;
84
- illustration_id?: string;
85
- image_uris?: ImageUris;
78
+ preview?: Preview;
86
79
  prices: Prices;
87
80
  printed_name?: string;
88
81
  printed_text?: string;
89
82
  printed_type_line?: string;
83
+ prints_search_uri: string;
90
84
  promo: boolean;
91
85
  promo_types?: (keyof typeof PromoType)[];
92
86
  purchase_uris: PurchaseUris;
@@ -94,22 +88,27 @@ export declare interface Card {
94
88
  related_uris: RelatedUris;
95
89
  released_at: string;
96
90
  reprint: boolean;
91
+ reserved: boolean;
92
+ rulings_uri: string;
97
93
  scryfall_set_uri: string;
94
+ scryfall_uri: string;
95
+ set: string;
98
96
  set_name: string;
99
97
  set_search_uri: string;
100
98
  set_type: Set_2['set_type'];
101
99
  set_uri: string;
102
- set: string;
103
100
  story_spotlight: boolean;
101
+ tcgplayer_id?: number;
104
102
  textless: boolean;
103
+ toughness?: string;
104
+ type_line: string;
105
+ uri: string;
105
106
  variation: boolean;
106
107
  variation_of?: string;
107
108
  watermark?: string;
108
- preview?: Preview;
109
109
  }
110
110
 
111
111
  export declare interface CardFace {
112
- object: 'card_face';
113
112
  artist?: string;
114
113
  color_indicator?: Color[];
115
114
  colors: Color[];
@@ -119,6 +118,7 @@ export declare interface CardFace {
119
118
  loyalty?: string;
120
119
  mana_cost: string;
121
120
  name: string;
121
+ object: 'card_face';
122
122
  oracle_text?: string;
123
123
  power?: string;
124
124
  printed_name?: string;
@@ -130,14 +130,14 @@ export declare interface CardFace {
130
130
  }
131
131
 
132
132
  export declare interface CardIdentifier {
133
+ collector_number?: string;
133
134
  id?: string;
135
+ illustration_id?: string;
134
136
  mtgo_id?: number;
135
137
  multiverse_id?: number;
136
- oracle_id?: string;
137
- illustration_id?: string;
138
138
  name?: string;
139
+ oracle_id?: string;
139
140
  set?: string;
140
- collector_number?: string;
141
141
  }
142
142
 
143
143
  export declare class CardIdentifierBuilder {
@@ -168,16 +168,16 @@ declare class Cards_2 extends MagicQuery {
168
168
  }
169
169
 
170
170
  export declare interface CardSymbol {
171
- symbol: string;
172
- loose_variant?: string;
173
- english: string;
174
- transposable: boolean;
175
- represents_mana: boolean;
176
- converted_mana_cost?: number;
177
- colors: Color[];
178
171
  appears_in_mana_costs: boolean;
172
+ colors: Color[];
173
+ converted_mana_cost?: number;
174
+ english: string;
179
175
  funny: boolean;
180
176
  gatherer_alternates?: string[];
177
+ loose_variant?: string;
178
+ represents_mana: boolean;
179
+ symbol: string;
180
+ transposable: boolean;
181
181
  }
182
182
 
183
183
  export declare const Catalog: Catalog_2;
@@ -249,22 +249,22 @@ export declare enum Game {
249
249
  }
250
250
 
251
251
  export declare interface HomepageLink {
252
- id: number;
252
+ badge?: string;
253
253
  created_at: string;
254
- updated_at: string;
254
+ id: number;
255
255
  priority: number;
256
256
  text: string;
257
+ updated_at: string;
257
258
  uri: string;
258
- badge?: string;
259
259
  }
260
260
 
261
261
  export declare interface ImageUris {
262
- small: string;
263
- normal: string;
264
- large: string;
265
- png: string;
266
262
  art_crop: string;
267
263
  border_crop: string;
264
+ large: string;
265
+ normal: string;
266
+ png: string;
267
+ small: string;
268
268
  }
269
269
 
270
270
  export declare enum Layout {
@@ -306,8 +306,8 @@ declare class MagicPageResult<T, Q extends MagicQuery, P = unknown> {
306
306
  private readonly apiPath;
307
307
  private readonly query;
308
308
  private readonly post?;
309
- private _hasMore;
310
309
  private _count;
310
+ private _hasMore;
311
311
  constructor(q: Q, apiPath: string, query: PageQuery, post?: P | undefined);
312
312
  get count(): number;
313
313
  get hasMore(): boolean;
@@ -336,10 +336,10 @@ export declare class MagicQueryError extends Error {
336
336
  }
337
337
 
338
338
  export declare interface ManaCost {
339
- cost: string;
340
339
  cmc: number;
341
- colors: Color[];
342
340
  colorless: boolean;
341
+ colors: Color[];
342
+ cost: string;
343
343
  monocolored: boolean;
344
344
  multicolored: boolean;
345
345
  }
@@ -351,15 +351,15 @@ export declare type PageQuery = {
351
351
 
352
352
  export declare interface Preview {
353
353
  previewed_at?: string;
354
- source_uri?: string;
355
354
  source?: string;
355
+ source_uri?: string;
356
356
  }
357
357
 
358
358
  export declare interface Prices {
359
- usd?: string;
360
- usd_foil?: string;
361
359
  eur?: string;
362
360
  tix?: string;
361
+ usd?: string;
362
+ usd_foil?: string;
363
363
  }
364
364
 
365
365
  export declare enum PromoType {
@@ -391,10 +391,10 @@ export declare enum PromoType {
391
391
  }
392
392
 
393
393
  export declare interface PurchaseUris {
394
- tcgplayer?: string;
395
- cardmarket?: string;
396
- cardhoarder?: string;
397
394
  [key: string]: string | undefined;
395
+ cardhoarder?: string;
396
+ cardmarket?: string;
397
+ tcgplayer?: string;
398
398
  }
399
399
 
400
400
  export declare type Query = {
@@ -427,11 +427,11 @@ export declare enum RelatedCardComponent {
427
427
  }
428
428
 
429
429
  export declare interface RelatedUris {
430
- gatherer?: string;
431
- tcgplayer_decks?: string;
430
+ [key: string]: string | undefined;
432
431
  edhrec?: string;
432
+ gatherer?: string;
433
433
  mtgtop8?: string;
434
- [key: string]: string | undefined;
434
+ tcgplayer_decks?: string;
435
435
  }
436
436
 
437
437
  export declare type ResultCatalog = ResultData<string>;
@@ -450,19 +450,19 @@ export declare interface ResultList<T, NOT_FOUND = never> extends ResultData<T,
450
450
 
451
451
  export declare interface RetryStrategy {
452
452
  attempts: number;
453
- timeout?: number;
454
453
  /**
455
454
  * Whether even `not_found` and `bad_request` errors should be retried.
456
455
  * @deprecated Don't use this, this is for unit tests
457
456
  */
458
457
  forced?: boolean;
458
+ timeout?: number;
459
459
  canRetry?(error?: SearchError): boolean;
460
460
  }
461
461
 
462
462
  export declare interface Ruling {
463
- source: string;
464
- published_at: string;
465
463
  comment: string;
464
+ published_at: string;
465
+ source: string;
466
466
  }
467
467
 
468
468
  export declare const Rulings: Rulings_2;
@@ -476,44 +476,44 @@ declare class Rulings_2 extends MagicQuery {
476
476
  }
477
477
 
478
478
  export declare interface SearchError {
479
- object: 'error';
480
479
  code: string;
481
- status: number;
482
480
  details: string;
481
+ object: 'error';
482
+ status: number;
483
483
  warnings?: string[];
484
484
  }
485
485
 
486
486
  export declare interface SearchOptions {
487
- unique?: keyof typeof UniqueStrategy;
488
- order?: keyof typeof Sort;
489
487
  dir?: keyof typeof SortDirection;
490
488
  include_extras?: boolean;
491
489
  include_multilingual?: boolean;
492
490
  include_variations?: boolean;
491
+ order?: keyof typeof Sort;
493
492
  /**
494
493
  * The page to start on. Defaults to `1`, for first page. A page is 175 cards.
495
494
  */
496
495
  page?: number;
496
+ unique?: keyof typeof UniqueStrategy;
497
497
  }
498
498
 
499
499
  declare interface Set_2 {
500
- id: string;
501
- code: string;
502
- mtgo_code?: string;
503
- tcgplayer_id?: number;
504
- name: string;
505
- set_type: keyof typeof SetType;
506
- released_at?: string;
507
- block_code?: string;
508
500
  block?: string;
509
- parent_set_code?: string;
501
+ block_code?: string;
510
502
  card_count: number;
503
+ code: string;
511
504
  digital: boolean;
512
505
  foil_only: boolean;
513
- scryfall_uri: string;
514
- uri: string;
515
506
  icon_svg_uri: string;
507
+ id: string;
508
+ mtgo_code?: string;
509
+ name: string;
510
+ parent_set_code?: string;
511
+ released_at?: string;
512
+ scryfall_uri: string;
516
513
  search_uri: string;
514
+ set_type: keyof typeof SetType;
515
+ tcgplayer_id?: number;
516
+ uri: string;
517
517
  }
518
518
  export { Set_2 as Set }
519
519
 
@@ -546,7 +546,9 @@ export declare enum SetType {
546
546
  box = 16,
547
547
  promo = 17,
548
548
  token = 18,
549
- memorabilia = 19
549
+ memorabilia = 19,
550
+ alchemy = 20,
551
+ arsenal = 21
550
552
  }
551
553
 
552
554
  export declare enum Sort {
@@ -1,33 +1,33 @@
1
1
  import g from "axios";
2
2
  class J {
3
- static byId(e) {
4
- return { id: e };
3
+ static byId(a) {
4
+ return { id: a };
5
5
  }
6
- static byIllustrationId(e) {
7
- return { illustration_id: e };
6
+ static byIllustrationId(a) {
7
+ return { illustration_id: a };
8
8
  }
9
- static byMtgoId(e) {
10
- return { mtgo_id: e };
9
+ static byMtgoId(a) {
10
+ return { mtgo_id: a };
11
11
  }
12
- static byMultiverseId(e) {
13
- return { multiverse_id: e };
12
+ static byMultiverseId(a) {
13
+ return { multiverse_id: a };
14
14
  }
15
- static byName(e, a) {
16
- return a ? { name: e, set: a } : { name: e };
15
+ static byName(a, e) {
16
+ return e ? { name: a, set: e } : { name: a };
17
17
  }
18
- static byOracleId(e) {
19
- return { oracle_id: e };
18
+ static byOracleId(a) {
19
+ return { oracle_id: a };
20
20
  }
21
- static bySet(e, a) {
22
- return { collector_number: `${a}`, set: e };
21
+ static bySet(a, e) {
22
+ return { collector_number: `${e}`, set: a };
23
23
  }
24
24
  }
25
25
  class w {
26
- constructor(e, a, t, n) {
27
- this.q = e, this.apiPath = a, this.query = t, this.post = n, this._hasMore = !0, this._count = 0;
26
+ constructor(a, e, r, n) {
27
+ this.q = a, this.apiPath = e, this.query = r, this.post = n, this._hasMore = !0, this._count = 0;
28
28
  }
29
- _hasMore;
30
29
  _count;
30
+ _hasMore;
31
31
  get count() {
32
32
  return this._count;
33
33
  }
@@ -35,41 +35,41 @@ class w {
35
35
  return this._hasMore;
36
36
  }
37
37
  async all() {
38
- const e = [];
38
+ const a = [];
39
39
  for (; this._hasMore; ) {
40
- const a = await this.next();
41
- e.push(...a);
40
+ const e = await this.next();
41
+ a.push(...e);
42
42
  }
43
- return e;
43
+ return a;
44
44
  }
45
- async get(e) {
46
- const a = [];
45
+ async get(a) {
46
+ const e = [];
47
47
  for (; this._hasMore; ) {
48
- const t = await this.next();
49
- if (a.push(...t), a.length === e)
50
- return a;
51
- if (a.length > e)
52
- return a.slice(0, e);
48
+ const r = await this.next();
49
+ if (e.push(...r), e.length === a)
50
+ return e;
51
+ if (e.length > a)
52
+ return e.slice(0, a);
53
53
  }
54
- return a;
54
+ return e;
55
55
  }
56
56
  async next() {
57
- const e = await this.q.query(this.apiPath, this.query, this.post);
58
- return this._hasMore = e?.has_more ?? !1, this._count = Number.parseInt(`${e?.total_cards ?? 0}`, 10), this._hasMore && this.setNextPage(), e?.data ?? [];
57
+ const a = await this.q.query(this.apiPath, this.query, this.post);
58
+ return this._hasMore = a?.has_more ?? !1, this._count = Number.parseInt(`${a?.total_cards ?? 0}`, 10), this._hasMore && this.setNextPage(), a?.data ?? [];
59
59
  }
60
- async page(e) {
61
- return this.query.page = e, this.next();
60
+ async page(a) {
61
+ return this.query.page = a, this.next();
62
62
  }
63
63
  setNextPage() {
64
64
  this.query.page = this.query.page + 1;
65
65
  }
66
66
  }
67
67
  class d extends Error {
68
- constructor(e) {
69
- super(typeof e == "string" ? e : e?.details), this.data = e, Object.setPrototypeOf(this, d.prototype);
68
+ constructor(a) {
69
+ super(typeof a == "string" ? a : a?.details), this.data = a, Object.setPrototypeOf(this, d.prototype);
70
70
  }
71
71
  }
72
- class r {
72
+ class t {
73
73
  static retry = { attempts: 1 };
74
74
  // the path to the api
75
75
  static endpoint = "https://api.scryfall.com";
@@ -77,30 +77,30 @@ class r {
77
77
  static lastQuery = 100;
78
78
  // the api requests 50-100 ms between calls, we go on the generous side and never wait less than 100 ms between calls
79
79
  static rateLimit = 100;
80
- static canRetry(e) {
81
- return typeof e == "string" || e?.code === "not_found" || e?.code === "bad_request" ? !1 : !r.retry.canRetry || r.retry.canRetry(e);
80
+ static canRetry(a) {
81
+ return typeof a == "string" || a?.code === "not_found" || a?.code === "bad_request" ? !1 : !t.retry.canRetry || t.retry.canRetry(a);
82
82
  }
83
83
  static async debounce() {
84
- const e = Date.now(), a = e - r.lastQuery;
85
- if (a >= r.rateLimit)
86
- r.lastQuery = e;
84
+ const a = Date.now(), e = a - t.lastQuery;
85
+ if (e >= t.rateLimit)
86
+ t.lastQuery = a;
87
87
  else {
88
- const t = r.rateLimit - a;
89
- r.lastQuery += t, await r.sleep(t);
88
+ const r = t.rateLimit - e;
89
+ t.lastQuery += r, await t.sleep(r);
90
90
  }
91
91
  }
92
- static async sleep(e = 0) {
93
- return new Promise((a) => {
94
- setTimeout(a, e);
92
+ static async sleep(a = 0) {
93
+ return new Promise((e) => {
94
+ setTimeout(e, a);
95
95
  });
96
96
  }
97
- static async tryQuery(e, a, t, n) {
98
- await r.debounce();
97
+ static async tryQuery(a, e, r, n) {
98
+ await t.debounce();
99
99
  const c = {
100
- data: t,
101
- method: t ? "POST" : "GET",
102
- params: a,
103
- url: `${r.endpoint}/${e}`,
100
+ data: r,
101
+ method: r ? "POST" : "GET",
102
+ params: e,
103
+ url: `${t.endpoint}/${a}`,
104
104
  headers: { "Accept-Encoding": "gzip,deflate,compress" },
105
105
  ...n
106
106
  };
@@ -114,83 +114,83 @@ class r {
114
114
  throw i;
115
115
  }
116
116
  }
117
- async query(e, a, t, n) {
117
+ async query(a, e, r, n) {
118
118
  let c = "";
119
- typeof e == "number" || typeof e == "string" ? c = e : e && (c = e.join("/"));
119
+ typeof a == "number" || typeof a == "string" ? c = a : a && (c = a.join("/"));
120
120
  let i, l;
121
- for (i = 0; i < r.retry.attempts; i++) {
121
+ for (i = 0; i < t.retry.attempts; i++) {
122
122
  let h;
123
123
  try {
124
- l = await r.tryQuery(`${c}`, a, t, n);
124
+ l = await t.tryQuery(`${c}`, e, r, n);
125
125
  } catch (u) {
126
126
  if (u instanceof d)
127
127
  h = u.data;
128
128
  else
129
129
  throw u;
130
130
  }
131
- if (l || !r.canRetry(h))
131
+ if (l || !t.canRetry(h))
132
132
  break;
133
- await r.sleep(r.retry.timeout);
133
+ await t.sleep(t.retry.timeout);
134
134
  }
135
135
  return l?.data;
136
136
  }
137
137
  }
138
- class o extends r {
139
- async autoCompleteName(e) {
138
+ class o extends t {
139
+ async autoCompleteName(a) {
140
140
  return (await this.query("cards/autocomplete", {
141
- q: e
141
+ q: a
142
142
  }))?.data ?? [];
143
143
  }
144
- async byArenaId(e) {
145
- return this.query(["cards/arena", e]);
144
+ async byArenaId(a) {
145
+ return this.query(["cards/arena", a]);
146
146
  }
147
- async byId(e) {
148
- return this.query(["cards", e]);
147
+ async byId(a) {
148
+ return this.query(["cards", a]);
149
149
  }
150
- async byMtgoId(e) {
151
- return this.query(["cards/mtgo", e]);
150
+ async byMtgoId(a) {
151
+ return this.query(["cards/mtgo", a]);
152
152
  }
153
- async byMultiverseId(e) {
154
- return this.query(["cards/multiverse", e]);
153
+ async byMultiverseId(a) {
154
+ return this.query(["cards/multiverse", a]);
155
155
  }
156
- async byName(e, a, t = !1) {
157
- let n = t, c = a;
158
- return typeof a == "boolean" && (n = a, c = void 0), this.query("cards/named", {
159
- [n ? "fuzzy" : "exact"]: e,
156
+ async byName(a, e, r = !1) {
157
+ let n = r, c = e;
158
+ return typeof e == "boolean" && (n = e, c = void 0), this.query("cards/named", {
159
+ [n ? "fuzzy" : "exact"]: a,
160
160
  set: c
161
161
  });
162
162
  }
163
- async bySet(e, a, t) {
164
- const n = ["cards", e, a];
165
- return t && n.push(t), this.query(n);
163
+ async bySet(a, e, r) {
164
+ const n = ["cards", a, e];
165
+ return r && n.push(r), this.query(n);
166
166
  }
167
- async byTcgPlayerId(e) {
168
- return this.query(["cards/tcgplayer", e]);
167
+ async byTcgPlayerId(a) {
168
+ return this.query(["cards/tcgplayer", a]);
169
169
  }
170
- async collection(...e) {
171
- const a = [];
172
- for (let t = 0; t < e.length; t += 75) {
173
- const n = { identifiers: e.slice(t, t + 75) }, c = await this.query(
170
+ async collection(...a) {
171
+ const e = [];
172
+ for (let r = 0; r < a.length; r += 75) {
173
+ const n = { identifiers: a.slice(r, r + 75) }, c = await this.query(
174
174
  "cards/collection",
175
175
  void 0,
176
176
  n
177
177
  );
178
- a.push(...c?.data ?? []);
178
+ e.push(...c?.data ?? []);
179
179
  }
180
- return a;
180
+ return e;
181
181
  }
182
182
  async random() {
183
183
  return this.query("cards/random");
184
184
  }
185
- search(e, a) {
185
+ search(a, e) {
186
186
  return new w(this, "cards/search", {
187
- q: e,
188
- ...typeof a == "number" ? { page: a } : { page: 1, ...a }
187
+ q: a,
188
+ ...typeof e == "number" ? { page: e } : { page: 1, ...e }
189
189
  });
190
190
  }
191
191
  }
192
192
  const K = new o();
193
- class b extends r {
193
+ class b extends t {
194
194
  async artifactTypes() {
195
195
  return (await this.query("catalog/artifact-types"))?.data ?? [];
196
196
  }
@@ -232,64 +232,64 @@ class b extends r {
232
232
  }
233
233
  }
234
234
  const V = new b();
235
- class v extends r {
236
- async byArenaId(e) {
237
- return (await this.query(["cards/arena", e, "rulings"]))?.data ?? [];
235
+ class v extends t {
236
+ async byArenaId(a) {
237
+ return (await this.query(["cards/arena", a, "rulings"]))?.data ?? [];
238
238
  }
239
- async byId(e) {
240
- return (await this.query(["cards", e, "rulings"]))?.data ?? [];
239
+ async byId(a) {
240
+ return (await this.query(["cards", a, "rulings"]))?.data ?? [];
241
241
  }
242
- async byMtgoId(e) {
243
- return (await this.query(["cards/mtgo", e, "rulings"]))?.data ?? [];
242
+ async byMtgoId(a) {
243
+ return (await this.query(["cards/mtgo", a, "rulings"]))?.data ?? [];
244
244
  }
245
- async byMultiverseId(e) {
246
- return (await this.query(["cards/multiverse", e, "rulings"]))?.data ?? [];
245
+ async byMultiverseId(a) {
246
+ return (await this.query(["cards/multiverse", a, "rulings"]))?.data ?? [];
247
247
  }
248
- async bySet(e, a) {
248
+ async bySet(a, e) {
249
249
  return (await this.query([
250
250
  "cards",
251
- e,
252
- `${a}`,
251
+ a,
252
+ `${e}`,
253
253
  "rulings"
254
254
  ]))?.data ?? [];
255
255
  }
256
256
  }
257
257
  const W = new v();
258
- class q extends r {
258
+ class q extends t {
259
259
  async all() {
260
260
  return (await this.query("sets"))?.data ?? [];
261
261
  }
262
- async byCode(e) {
263
- return await this.query(["sets", e]);
262
+ async byCode(a) {
263
+ return await this.query(["sets", a]);
264
264
  }
265
- async byId(e) {
266
- return this.query(["sets", e]);
265
+ async byId(a) {
266
+ return this.query(["sets", a]);
267
267
  }
268
- async byTcgPlayerId(e) {
269
- return this.query(["sets/tcgplayer", e]);
268
+ async byTcgPlayerId(a) {
269
+ return this.query(["sets/tcgplayer", a]);
270
270
  }
271
271
  }
272
272
  const X = new q();
273
- class _ extends r {
273
+ class _ extends t {
274
274
  async all() {
275
275
  return (await this.query("symbology"))?.data ?? [];
276
276
  }
277
- async parseMana(e) {
277
+ async parseMana(a) {
278
278
  return await this.query("symbology/parse-mana", {
279
- cost: e
279
+ cost: a
280
280
  });
281
281
  }
282
282
  }
283
283
  const Y = new _();
284
- var x = /* @__PURE__ */ ((s) => (s[s.black = 0] = "black", s[s.borderless = 1] = "borderless", s[s.gold = 2] = "gold", s[s.silver = 3] = "silver", s[s.white = 4] = "white", s))(x || {}), k = /* @__PURE__ */ ((s) => (s[s.oracle_cards = 0] = "oracle_cards", s[s.unique_artwork = 1] = "unique_artwork", s[s.default_cards = 2] = "default_cards", s[s.all_cards = 3] = "all_cards", s[s.rulings = 4] = "rulings", s))(k || {}), y = /* @__PURE__ */ ((s) => (s[s.standard = 0] = "standard", s[s.future = 1] = "future", s[s.historic = 2] = "historic", s[s.pioneer = 3] = "pioneer", s[s.modern = 4] = "modern", s[s.legacy = 5] = "legacy", s[s.pauper = 6] = "pauper", s[s.vintage = 7] = "vintage", s[s.penny = 8] = "penny", s[s.commander = 9] = "commander", s[s.brawl = 10] = "brawl", s[s.duel = 11] = "duel", s[s.oldschool = 12] = "oldschool", s))(y || {}), m = /* @__PURE__ */ ((s) => (s[s.legendary = 0] = "legendary", s[s.miracle = 1] = "miracle", s[s.nyxtouched = 2] = "nyxtouched", s[s.draft = 3] = "draft", s[s.devoid = 4] = "devoid", s[s.tombstone = 5] = "tombstone", s[s.colorshifted = 6] = "colorshifted", s[s.inverted = 7] = "inverted", s[s.sunmoondfc = 8] = "sunmoondfc", s[s.compasslanddfc = 9] = "compasslanddfc", s[s.originpwdfc = 10] = "originpwdfc", s[s.mooneldrazidfc = 11] = "mooneldrazidfc", s[s.moonreversemoondfc = 12] = "moonreversemoondfc", s[s.showcase = 13] = "showcase", s[s.extendedart = 14] = "extendedart", s))(m || {}), f = /* @__PURE__ */ ((s) => (s[s.paper = 0] = "paper", s[s.arena = 1] = "arena", s[s.mtgo = 2] = "mtgo", s))(f || {}), I = /* @__PURE__ */ ((s) => (s[s.normal = 0] = "normal", s[s.split = 1] = "split", s[s.flip = 2] = "flip", s[s.transform = 3] = "transform", s[s.modal_dfc = 4] = "modal_dfc", s[s.meld = 5] = "meld", s[s.leveler = 6] = "leveler", s[s.class = 7] = "class", s[s.saga = 8] = "saga", s[s.adventure = 9] = "adventure", s[s.planar = 10] = "planar", s[s.scheme = 11] = "scheme", s[s.vanguard = 12] = "vanguard", s[s.token = 13] = "token", s[s.double_faced_token = 14] = "double_faced_token", s[s.emblem = 15] = "emblem", s[s.augment = 16] = "augment", s[s.host = 17] = "host", s[s.art_series = 18] = "art_series", s[s.reversible_card = 19] = "reversible_card", s))(I || {}), p = /* @__PURE__ */ ((s) => (s[s.legal = 0] = "legal", s[s.not_legal = 1] = "not_legal", s[s.restricted = 2] = "restricted", s[s.banned = 3] = "banned", s))(p || {}), $ = /* @__PURE__ */ ((s) => (s[s.tourney = 0] = "tourney", s[s.prerelease = 1] = "prerelease", s[s.datestamped = 2] = "datestamped", s[s.planeswalkerdeck = 3] = "planeswalkerdeck", s[s.buyabox = 4] = "buyabox", s[s.judgegift = 5] = "judgegift", s[s.event = 6] = "event", s[s.convention = 7] = "convention", s[s.starterdeck = 8] = "starterdeck", s[s.instore = 9] = "instore", s[s.setpromo = 10] = "setpromo", s[s.fnm = 11] = "fnm", s[s.openhouse = 12] = "openhouse", s[s.league = 13] = "league", s[s.draftweekend = 14] = "draftweekend", s[s.gameday = 15] = "gameday", s[s.release = 16] = "release", s[s.intropack = 17] = "intropack", s[s.giftbox = 18] = "giftbox", s[s.duels = 19] = "duels", s[s.wizardsplaynetwork = 20] = "wizardsplaynetwork", s[s.premiereshop = 21] = "premiereshop", s[s.playerrewards = 22] = "playerrewards", s[s.gateway = 23] = "gateway", s[s.arenaleague = 24] = "arenaleague", s))($ || {}), N = /* @__PURE__ */ ((s) => (s[s.common = 0] = "common", s[s.uncommon = 1] = "uncommon", s[s.rare = 2] = "rare", s[s.mythic = 3] = "mythic", s))(N || {}), z = /* @__PURE__ */ ((s) => (s[s.token = 0] = "token", s[s.meld_part = 1] = "meld_part", s[s.meld_result = 2] = "meld_result", s[s.combo_piece = 3] = "combo_piece", s))(z || {}), A = /* @__PURE__ */ ((s) => (s[s.core = 0] = "core", s[s.expansion = 1] = "expansion", s[s.masters = 2] = "masters", s[s.masterpiece = 3] = "masterpiece", s[s.from_the_vault = 4] = "from_the_vault", s[s.spellbook = 5] = "spellbook", s[s.premium_deck = 6] = "premium_deck", s[s.duel_deck = 7] = "duel_deck", s[s.draft_innovation = 8] = "draft_innovation", s[s.treasure_chest = 9] = "treasure_chest", s[s.commander = 10] = "commander", s[s.planechase = 11] = "planechase", s[s.archenemy = 12] = "archenemy", s[s.vanguard = 13] = "vanguard", s[s.funny = 14] = "funny", s[s.starter = 15] = "starter", s[s.box = 16] = "box", s[s.promo = 17] = "promo", s[s.token = 18] = "token", s[s.memorabilia = 19] = "memorabilia", s))(A || {}), j = /* @__PURE__ */ ((s) => (s[s.name = 0] = "name", s[s.set = 1] = "set", s[s.released = 2] = "released", s[s.rarity = 3] = "rarity", s[s.color = 4] = "color", s[s.usd = 5] = "usd", s[s.tix = 6] = "tix", s[s.eur = 7] = "eur", s[s.cmc = 8] = "cmc", s[s.power = 9] = "power", s[s.toughness = 10] = "toughness", s[s.edhrec = 11] = "edhrec", s[s.artist = 12] = "artist", s))(j || {}), O = /* @__PURE__ */ ((s) => (s[s.auto = 0] = "auto", s[s.asc = 1] = "asc", s[s.desc = 2] = "desc", s))(O || {}), M = /* @__PURE__ */ ((s) => (s[s.cards = 0] = "cards", s[s.art = 1] = "art", s[s.prints = 2] = "prints", s))(M || {});
284
+ var x = /* @__PURE__ */ ((s) => (s[s.black = 0] = "black", s[s.borderless = 1] = "borderless", s[s.gold = 2] = "gold", s[s.silver = 3] = "silver", s[s.white = 4] = "white", s))(x || {}), k = /* @__PURE__ */ ((s) => (s[s.oracle_cards = 0] = "oracle_cards", s[s.unique_artwork = 1] = "unique_artwork", s[s.default_cards = 2] = "default_cards", s[s.all_cards = 3] = "all_cards", s[s.rulings = 4] = "rulings", s))(k || {}), m = /* @__PURE__ */ ((s) => (s[s.standard = 0] = "standard", s[s.future = 1] = "future", s[s.historic = 2] = "historic", s[s.pioneer = 3] = "pioneer", s[s.modern = 4] = "modern", s[s.legacy = 5] = "legacy", s[s.pauper = 6] = "pauper", s[s.vintage = 7] = "vintage", s[s.penny = 8] = "penny", s[s.commander = 9] = "commander", s[s.brawl = 10] = "brawl", s[s.duel = 11] = "duel", s[s.oldschool = 12] = "oldschool", s))(m || {}), y = /* @__PURE__ */ ((s) => (s[s.legendary = 0] = "legendary", s[s.miracle = 1] = "miracle", s[s.nyxtouched = 2] = "nyxtouched", s[s.draft = 3] = "draft", s[s.devoid = 4] = "devoid", s[s.tombstone = 5] = "tombstone", s[s.colorshifted = 6] = "colorshifted", s[s.inverted = 7] = "inverted", s[s.sunmoondfc = 8] = "sunmoondfc", s[s.compasslanddfc = 9] = "compasslanddfc", s[s.originpwdfc = 10] = "originpwdfc", s[s.mooneldrazidfc = 11] = "mooneldrazidfc", s[s.moonreversemoondfc = 12] = "moonreversemoondfc", s[s.showcase = 13] = "showcase", s[s.extendedart = 14] = "extendedart", s))(y || {}), f = /* @__PURE__ */ ((s) => (s[s.paper = 0] = "paper", s[s.arena = 1] = "arena", s[s.mtgo = 2] = "mtgo", s))(f || {}), I = /* @__PURE__ */ ((s) => (s[s.normal = 0] = "normal", s[s.split = 1] = "split", s[s.flip = 2] = "flip", s[s.transform = 3] = "transform", s[s.modal_dfc = 4] = "modal_dfc", s[s.meld = 5] = "meld", s[s.leveler = 6] = "leveler", s[s.class = 7] = "class", s[s.saga = 8] = "saga", s[s.adventure = 9] = "adventure", s[s.planar = 10] = "planar", s[s.scheme = 11] = "scheme", s[s.vanguard = 12] = "vanguard", s[s.token = 13] = "token", s[s.double_faced_token = 14] = "double_faced_token", s[s.emblem = 15] = "emblem", s[s.augment = 16] = "augment", s[s.host = 17] = "host", s[s.art_series = 18] = "art_series", s[s.reversible_card = 19] = "reversible_card", s))(I || {}), p = /* @__PURE__ */ ((s) => (s[s.legal = 0] = "legal", s[s.not_legal = 1] = "not_legal", s[s.restricted = 2] = "restricted", s[s.banned = 3] = "banned", s))(p || {}), $ = /* @__PURE__ */ ((s) => (s[s.tourney = 0] = "tourney", s[s.prerelease = 1] = "prerelease", s[s.datestamped = 2] = "datestamped", s[s.planeswalkerdeck = 3] = "planeswalkerdeck", s[s.buyabox = 4] = "buyabox", s[s.judgegift = 5] = "judgegift", s[s.event = 6] = "event", s[s.convention = 7] = "convention", s[s.starterdeck = 8] = "starterdeck", s[s.instore = 9] = "instore", s[s.setpromo = 10] = "setpromo", s[s.fnm = 11] = "fnm", s[s.openhouse = 12] = "openhouse", s[s.league = 13] = "league", s[s.draftweekend = 14] = "draftweekend", s[s.gameday = 15] = "gameday", s[s.release = 16] = "release", s[s.intropack = 17] = "intropack", s[s.giftbox = 18] = "giftbox", s[s.duels = 19] = "duels", s[s.wizardsplaynetwork = 20] = "wizardsplaynetwork", s[s.premiereshop = 21] = "premiereshop", s[s.playerrewards = 22] = "playerrewards", s[s.gateway = 23] = "gateway", s[s.arenaleague = 24] = "arenaleague", s))($ || {}), N = /* @__PURE__ */ ((s) => (s[s.common = 0] = "common", s[s.uncommon = 1] = "uncommon", s[s.rare = 2] = "rare", s[s.mythic = 3] = "mythic", s))(N || {}), z = /* @__PURE__ */ ((s) => (s[s.token = 0] = "token", s[s.meld_part = 1] = "meld_part", s[s.meld_result = 2] = "meld_result", s[s.combo_piece = 3] = "combo_piece", s))(z || {}), A = /* @__PURE__ */ ((s) => (s[s.core = 0] = "core", s[s.expansion = 1] = "expansion", s[s.masters = 2] = "masters", s[s.masterpiece = 3] = "masterpiece", s[s.from_the_vault = 4] = "from_the_vault", s[s.spellbook = 5] = "spellbook", s[s.premium_deck = 6] = "premium_deck", s[s.duel_deck = 7] = "duel_deck", s[s.draft_innovation = 8] = "draft_innovation", s[s.treasure_chest = 9] = "treasure_chest", s[s.commander = 10] = "commander", s[s.planechase = 11] = "planechase", s[s.archenemy = 12] = "archenemy", s[s.vanguard = 13] = "vanguard", s[s.funny = 14] = "funny", s[s.starter = 15] = "starter", s[s.box = 16] = "box", s[s.promo = 17] = "promo", s[s.token = 18] = "token", s[s.memorabilia = 19] = "memorabilia", s[s.alchemy = 20] = "alchemy", s[s.arsenal = 21] = "arsenal", s))(A || {}), j = /* @__PURE__ */ ((s) => (s[s.name = 0] = "name", s[s.set = 1] = "set", s[s.released = 2] = "released", s[s.rarity = 3] = "rarity", s[s.color = 4] = "color", s[s.usd = 5] = "usd", s[s.tix = 6] = "tix", s[s.eur = 7] = "eur", s[s.cmc = 8] = "cmc", s[s.power = 9] = "power", s[s.toughness = 10] = "toughness", s[s.edhrec = 11] = "edhrec", s[s.artist = 12] = "artist", s))(j || {}), O = /* @__PURE__ */ ((s) => (s[s.auto = 0] = "auto", s[s.asc = 1] = "asc", s[s.desc = 2] = "desc", s))(O || {}), M = /* @__PURE__ */ ((s) => (s[s.cards = 0] = "cards", s[s.art = 1] = "art", s[s.prints = 2] = "prints", s))(M || {});
285
285
  export {
286
286
  x as Border,
287
287
  k as BulkDataTypes,
288
288
  J as CardIdentifierBuilder,
289
289
  K as Cards,
290
290
  V as Catalog,
291
- y as Format,
292
- m as FrameEffect,
291
+ m as Format,
292
+ y as FrameEffect,
293
293
  f as Game,
294
294
  I as Layout,
295
295
  p as Legality,
@@ -1 +1 @@
1
- (function(t,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],u):(t=typeof globalThis<"u"?globalThis:t||self,u(t.Scryfall={},t.Axios))})(this,function(t,u){"use strict";class z{static byId(e){return{id:e}}static byIllustrationId(e){return{illustration_id:e}}static byMtgoId(e){return{mtgo_id:e}}static byMultiverseId(e){return{multiverse_id:e}}static byName(e,a){return a?{name:e,set:a}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,a){return{collector_number:`${a}`,set:e}}}class j{constructor(e,a,n,i){this.q=e,this.apiPath=a,this.query=n,this.post=i,this._hasMore=!0,this._count=0}_hasMore;_count;get count(){return this._count}get hasMore(){return this._hasMore}async all(){const e=[];for(;this._hasMore;){const a=await this.next();e.push(...a)}return e}async get(e){const a=[];for(;this._hasMore;){const n=await this.next();if(a.push(...n),a.length===e)return a;if(a.length>e)return a.slice(0,e)}return a}async next(){const e=await this.q.query(this.apiPath,this.query,this.post);return this._hasMore=e?.has_more??!1,this._count=Number.parseInt(`${e?.total_cards??0}`,10),this._hasMore&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page=this.query.page+1}}class h extends Error{constructor(e){super(typeof e=="string"?e:e?.details),this.data=e,Object.setPrototypeOf(this,h.prototype)}}class r{static retry={attempts:1};static endpoint="https://api.scryfall.com";static lastQuery=100;static rateLimit=100;static canRetry(e){return typeof e=="string"||e?.code==="not_found"||e?.code==="bad_request"?!1:!r.retry.canRetry||r.retry.canRetry(e)}static async debounce(){const e=Date.now(),a=e-r.lastQuery;if(a>=r.rateLimit)r.lastQuery=e;else{const n=r.rateLimit-a;r.lastQuery+=n,await r.sleep(n)}}static async sleep(e=0){return new Promise(a=>{setTimeout(a,e)})}static async tryQuery(e,a,n,i){await r.debounce();const c={data:n,method:n?"POST":"GET",params:a,url:`${r.endpoint}/${e}`,headers:{"Accept-Encoding":"gzip,deflate,compress"},...i};try{return await u.request(c)}catch(l){if(l.isAxiosError){const d=l;throw new h(d.response?.data??d.message)}else throw l}}async query(e,a,n,i){let c="";typeof e=="number"||typeof e=="string"?c=e:e&&(c=e.join("/"));let l,d;for(l=0;l<r.retry.attempts;l++){let p;try{d=await r.tryQuery(`${c}`,a,n,i)}catch(g){if(g instanceof h)p=g.data;else throw g}if(d||!r.canRetry(p))break;await r.sleep(r.retry.timeout)}return d?.data}}class A extends r{async autoCompleteName(e){return(await this.query("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return this.query(["cards/arena",e])}async byId(e){return this.query(["cards",e])}async byMtgoId(e){return this.query(["cards/mtgo",e])}async byMultiverseId(e){return this.query(["cards/multiverse",e])}async byName(e,a,n=!1){let i=n,c=a;return typeof a=="boolean"&&(i=a,c=void 0),this.query("cards/named",{[i?"fuzzy":"exact"]:e,set:c})}async bySet(e,a,n){const i=["cards",e,a];return n&&i.push(n),this.query(i)}async byTcgPlayerId(e){return this.query(["cards/tcgplayer",e])}async collection(...e){const a=[];for(let n=0;n<e.length;n+=75){const i={identifiers:e.slice(n,n+75)},c=await this.query("cards/collection",void 0,i);a.push(...c?.data??[])}return a}async random(){return this.query("cards/random")}search(e,a){return new j(this,"cards/search",{q:e,...typeof a=="number"?{page:a}:{page:1,...a}})}}const O=new A;class M extends r{async artifactTypes(){return(await this.query("catalog/artifact-types"))?.data??[]}async artistNames(){return(await this.query("catalog/artist-names"))?.data??[]}async cardNames(){return(await this.query("catalog/card-names"))?.data??[]}async creatureTypes(){return(await this.query("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await this.query("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await this.query("catalog/land-types"))?.data??[]}async loyalties(){return(await this.query("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await this.query("catalog/planeswalker-types"))?.data??[]}async powers(){return(await this.query("catalog/powers"))?.data??[]}async spellTypes(){return(await this.query("catalog/spell-types"))?.data??[]}async toughnesses(){return(await this.query("catalog/toughnesses"))?.data??[]}async watermarks(){return(await this.query("catalog/watermarks"))?.data??[]}async wordBank(){return(await this.query("catalog/word-bank"))?.data??[]}}const H=new M;class J extends r{async byArenaId(e){return(await this.query(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await this.query(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await this.query(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await this.query(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,a){return(await this.query(["cards",e,`${a}`,"rulings"]))?.data??[]}}const K=new J;class V extends r{async all(){return(await this.query("sets"))?.data??[]}async byCode(e){return await this.query(["sets",e])}async byId(e){return this.query(["sets",e])}async byTcgPlayerId(e){return this.query(["sets/tcgplayer",e])}}const W=new V;class X extends r{async all(){return(await this.query("symbology"))?.data??[]}async parseMana(e){return await this.query("symbology/parse-mana",{cost:e})}}const Y=new X;var w=(s=>(s[s.black=0]="black",s[s.borderless=1]="borderless",s[s.gold=2]="gold",s[s.silver=3]="silver",s[s.white=4]="white",s))(w||{}),o=(s=>(s[s.oracle_cards=0]="oracle_cards",s[s.unique_artwork=1]="unique_artwork",s[s.default_cards=2]="default_cards",s[s.all_cards=3]="all_cards",s[s.rulings=4]="rulings",s))(o||{}),b=(s=>(s[s.standard=0]="standard",s[s.future=1]="future",s[s.historic=2]="historic",s[s.pioneer=3]="pioneer",s[s.modern=4]="modern",s[s.legacy=5]="legacy",s[s.pauper=6]="pauper",s[s.vintage=7]="vintage",s[s.penny=8]="penny",s[s.commander=9]="commander",s[s.brawl=10]="brawl",s[s.duel=11]="duel",s[s.oldschool=12]="oldschool",s))(b||{}),v=(s=>(s[s.legendary=0]="legendary",s[s.miracle=1]="miracle",s[s.nyxtouched=2]="nyxtouched",s[s.draft=3]="draft",s[s.devoid=4]="devoid",s[s.tombstone=5]="tombstone",s[s.colorshifted=6]="colorshifted",s[s.inverted=7]="inverted",s[s.sunmoondfc=8]="sunmoondfc",s[s.compasslanddfc=9]="compasslanddfc",s[s.originpwdfc=10]="originpwdfc",s[s.mooneldrazidfc=11]="mooneldrazidfc",s[s.moonreversemoondfc=12]="moonreversemoondfc",s[s.showcase=13]="showcase",s[s.extendedart=14]="extendedart",s))(v||{}),q=(s=>(s[s.paper=0]="paper",s[s.arena=1]="arena",s[s.mtgo=2]="mtgo",s))(q||{}),_=(s=>(s[s.normal=0]="normal",s[s.split=1]="split",s[s.flip=2]="flip",s[s.transform=3]="transform",s[s.modal_dfc=4]="modal_dfc",s[s.meld=5]="meld",s[s.leveler=6]="leveler",s[s.class=7]="class",s[s.saga=8]="saga",s[s.adventure=9]="adventure",s[s.planar=10]="planar",s[s.scheme=11]="scheme",s[s.vanguard=12]="vanguard",s[s.token=13]="token",s[s.double_faced_token=14]="double_faced_token",s[s.emblem=15]="emblem",s[s.augment=16]="augment",s[s.host=17]="host",s[s.art_series=18]="art_series",s[s.reversible_card=19]="reversible_card",s))(_||{}),y=(s=>(s[s.legal=0]="legal",s[s.not_legal=1]="not_legal",s[s.restricted=2]="restricted",s[s.banned=3]="banned",s))(y||{}),f=(s=>(s[s.tourney=0]="tourney",s[s.prerelease=1]="prerelease",s[s.datestamped=2]="datestamped",s[s.planeswalkerdeck=3]="planeswalkerdeck",s[s.buyabox=4]="buyabox",s[s.judgegift=5]="judgegift",s[s.event=6]="event",s[s.convention=7]="convention",s[s.starterdeck=8]="starterdeck",s[s.instore=9]="instore",s[s.setpromo=10]="setpromo",s[s.fnm=11]="fnm",s[s.openhouse=12]="openhouse",s[s.league=13]="league",s[s.draftweekend=14]="draftweekend",s[s.gameday=15]="gameday",s[s.release=16]="release",s[s.intropack=17]="intropack",s[s.giftbox=18]="giftbox",s[s.duels=19]="duels",s[s.wizardsplaynetwork=20]="wizardsplaynetwork",s[s.premiereshop=21]="premiereshop",s[s.playerrewards=22]="playerrewards",s[s.gateway=23]="gateway",s[s.arenaleague=24]="arenaleague",s))(f||{}),k=(s=>(s[s.common=0]="common",s[s.uncommon=1]="uncommon",s[s.rare=2]="rare",s[s.mythic=3]="mythic",s))(k||{}),m=(s=>(s[s.token=0]="token",s[s.meld_part=1]="meld_part",s[s.meld_result=2]="meld_result",s[s.combo_piece=3]="combo_piece",s))(m||{}),I=(s=>(s[s.core=0]="core",s[s.expansion=1]="expansion",s[s.masters=2]="masters",s[s.masterpiece=3]="masterpiece",s[s.from_the_vault=4]="from_the_vault",s[s.spellbook=5]="spellbook",s[s.premium_deck=6]="premium_deck",s[s.duel_deck=7]="duel_deck",s[s.draft_innovation=8]="draft_innovation",s[s.treasure_chest=9]="treasure_chest",s[s.commander=10]="commander",s[s.planechase=11]="planechase",s[s.archenemy=12]="archenemy",s[s.vanguard=13]="vanguard",s[s.funny=14]="funny",s[s.starter=15]="starter",s[s.box=16]="box",s[s.promo=17]="promo",s[s.token=18]="token",s[s.memorabilia=19]="memorabilia",s))(I||{}),x=(s=>(s[s.name=0]="name",s[s.set=1]="set",s[s.released=2]="released",s[s.rarity=3]="rarity",s[s.color=4]="color",s[s.usd=5]="usd",s[s.tix=6]="tix",s[s.eur=7]="eur",s[s.cmc=8]="cmc",s[s.power=9]="power",s[s.toughness=10]="toughness",s[s.edhrec=11]="edhrec",s[s.artist=12]="artist",s))(x||{}),$=(s=>(s[s.auto=0]="auto",s[s.asc=1]="asc",s[s.desc=2]="desc",s))($||{}),N=(s=>(s[s.cards=0]="cards",s[s.art=1]="art",s[s.prints=2]="prints",s))(N||{});t.Border=w,t.BulkDataTypes=o,t.CardIdentifierBuilder=z,t.Cards=O,t.Catalog=H,t.Format=b,t.FrameEffect=v,t.Game=q,t.Layout=_,t.Legality=y,t.MagicQueryError=h,t.PromoType=f,t.Rarity=k,t.RelatedCardComponent=m,t.Rulings=K,t.SetType=I,t.Sets=W,t.Sort=x,t.SortDirection=$,t.Symbology=Y,t.UniqueStrategy=N,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],u):(t=typeof globalThis<"u"?globalThis:t||self,u(t.Scryfall={},t.Axios))})(this,function(t,u){"use strict";class j{static byId(e){return{id:e}}static byIllustrationId(e){return{illustration_id:e}}static byMtgoId(e){return{mtgo_id:e}}static byMultiverseId(e){return{multiverse_id:e}}static byName(e,a){return a?{name:e,set:a}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,a){return{collector_number:`${a}`,set:e}}}class A{constructor(e,a,n,i){this.q=e,this.apiPath=a,this.query=n,this.post=i,this._hasMore=!0,this._count=0}_count;_hasMore;get count(){return this._count}get hasMore(){return this._hasMore}async all(){const e=[];for(;this._hasMore;){const a=await this.next();e.push(...a)}return e}async get(e){const a=[];for(;this._hasMore;){const n=await this.next();if(a.push(...n),a.length===e)return a;if(a.length>e)return a.slice(0,e)}return a}async next(){const e=await this.q.query(this.apiPath,this.query,this.post);return this._hasMore=e?.has_more??!1,this._count=Number.parseInt(`${e?.total_cards??0}`,10),this._hasMore&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page=this.query.page+1}}class h extends Error{constructor(e){super(typeof e=="string"?e:e?.details),this.data=e,Object.setPrototypeOf(this,h.prototype)}}class r{static retry={attempts:1};static endpoint="https://api.scryfall.com";static lastQuery=100;static rateLimit=100;static canRetry(e){return typeof e=="string"||e?.code==="not_found"||e?.code==="bad_request"?!1:!r.retry.canRetry||r.retry.canRetry(e)}static async debounce(){const e=Date.now(),a=e-r.lastQuery;if(a>=r.rateLimit)r.lastQuery=e;else{const n=r.rateLimit-a;r.lastQuery+=n,await r.sleep(n)}}static async sleep(e=0){return new Promise(a=>{setTimeout(a,e)})}static async tryQuery(e,a,n,i){await r.debounce();const c={data:n,method:n?"POST":"GET",params:a,url:`${r.endpoint}/${e}`,headers:{"Accept-Encoding":"gzip,deflate,compress"},...i};try{return await u.request(c)}catch(l){if(l.isAxiosError){const d=l;throw new h(d.response?.data??d.message)}else throw l}}async query(e,a,n,i){let c="";typeof e=="number"||typeof e=="string"?c=e:e&&(c=e.join("/"));let l,d;for(l=0;l<r.retry.attempts;l++){let z;try{d=await r.tryQuery(`${c}`,a,n,i)}catch(g){if(g instanceof h)z=g.data;else throw g}if(d||!r.canRetry(z))break;await r.sleep(r.retry.timeout)}return d?.data}}class O extends r{async autoCompleteName(e){return(await this.query("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return this.query(["cards/arena",e])}async byId(e){return this.query(["cards",e])}async byMtgoId(e){return this.query(["cards/mtgo",e])}async byMultiverseId(e){return this.query(["cards/multiverse",e])}async byName(e,a,n=!1){let i=n,c=a;return typeof a=="boolean"&&(i=a,c=void 0),this.query("cards/named",{[i?"fuzzy":"exact"]:e,set:c})}async bySet(e,a,n){const i=["cards",e,a];return n&&i.push(n),this.query(i)}async byTcgPlayerId(e){return this.query(["cards/tcgplayer",e])}async collection(...e){const a=[];for(let n=0;n<e.length;n+=75){const i={identifiers:e.slice(n,n+75)},c=await this.query("cards/collection",void 0,i);a.push(...c?.data??[])}return a}async random(){return this.query("cards/random")}search(e,a){return new A(this,"cards/search",{q:e,...typeof a=="number"?{page:a}:{page:1,...a}})}}const M=new O;class p extends r{async artifactTypes(){return(await this.query("catalog/artifact-types"))?.data??[]}async artistNames(){return(await this.query("catalog/artist-names"))?.data??[]}async cardNames(){return(await this.query("catalog/card-names"))?.data??[]}async creatureTypes(){return(await this.query("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await this.query("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await this.query("catalog/land-types"))?.data??[]}async loyalties(){return(await this.query("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await this.query("catalog/planeswalker-types"))?.data??[]}async powers(){return(await this.query("catalog/powers"))?.data??[]}async spellTypes(){return(await this.query("catalog/spell-types"))?.data??[]}async toughnesses(){return(await this.query("catalog/toughnesses"))?.data??[]}async watermarks(){return(await this.query("catalog/watermarks"))?.data??[]}async wordBank(){return(await this.query("catalog/word-bank"))?.data??[]}}const H=new p;class J extends r{async byArenaId(e){return(await this.query(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await this.query(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await this.query(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await this.query(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,a){return(await this.query(["cards",e,`${a}`,"rulings"]))?.data??[]}}const K=new J;class V extends r{async all(){return(await this.query("sets"))?.data??[]}async byCode(e){return await this.query(["sets",e])}async byId(e){return this.query(["sets",e])}async byTcgPlayerId(e){return this.query(["sets/tcgplayer",e])}}const W=new V;class X extends r{async all(){return(await this.query("symbology"))?.data??[]}async parseMana(e){return await this.query("symbology/parse-mana",{cost:e})}}const Y=new X;var w=(s=>(s[s.black=0]="black",s[s.borderless=1]="borderless",s[s.gold=2]="gold",s[s.silver=3]="silver",s[s.white=4]="white",s))(w||{}),o=(s=>(s[s.oracle_cards=0]="oracle_cards",s[s.unique_artwork=1]="unique_artwork",s[s.default_cards=2]="default_cards",s[s.all_cards=3]="all_cards",s[s.rulings=4]="rulings",s))(o||{}),b=(s=>(s[s.standard=0]="standard",s[s.future=1]="future",s[s.historic=2]="historic",s[s.pioneer=3]="pioneer",s[s.modern=4]="modern",s[s.legacy=5]="legacy",s[s.pauper=6]="pauper",s[s.vintage=7]="vintage",s[s.penny=8]="penny",s[s.commander=9]="commander",s[s.brawl=10]="brawl",s[s.duel=11]="duel",s[s.oldschool=12]="oldschool",s))(b||{}),v=(s=>(s[s.legendary=0]="legendary",s[s.miracle=1]="miracle",s[s.nyxtouched=2]="nyxtouched",s[s.draft=3]="draft",s[s.devoid=4]="devoid",s[s.tombstone=5]="tombstone",s[s.colorshifted=6]="colorshifted",s[s.inverted=7]="inverted",s[s.sunmoondfc=8]="sunmoondfc",s[s.compasslanddfc=9]="compasslanddfc",s[s.originpwdfc=10]="originpwdfc",s[s.mooneldrazidfc=11]="mooneldrazidfc",s[s.moonreversemoondfc=12]="moonreversemoondfc",s[s.showcase=13]="showcase",s[s.extendedart=14]="extendedart",s))(v||{}),q=(s=>(s[s.paper=0]="paper",s[s.arena=1]="arena",s[s.mtgo=2]="mtgo",s))(q||{}),_=(s=>(s[s.normal=0]="normal",s[s.split=1]="split",s[s.flip=2]="flip",s[s.transform=3]="transform",s[s.modal_dfc=4]="modal_dfc",s[s.meld=5]="meld",s[s.leveler=6]="leveler",s[s.class=7]="class",s[s.saga=8]="saga",s[s.adventure=9]="adventure",s[s.planar=10]="planar",s[s.scheme=11]="scheme",s[s.vanguard=12]="vanguard",s[s.token=13]="token",s[s.double_faced_token=14]="double_faced_token",s[s.emblem=15]="emblem",s[s.augment=16]="augment",s[s.host=17]="host",s[s.art_series=18]="art_series",s[s.reversible_card=19]="reversible_card",s))(_||{}),f=(s=>(s[s.legal=0]="legal",s[s.not_legal=1]="not_legal",s[s.restricted=2]="restricted",s[s.banned=3]="banned",s))(f||{}),y=(s=>(s[s.tourney=0]="tourney",s[s.prerelease=1]="prerelease",s[s.datestamped=2]="datestamped",s[s.planeswalkerdeck=3]="planeswalkerdeck",s[s.buyabox=4]="buyabox",s[s.judgegift=5]="judgegift",s[s.event=6]="event",s[s.convention=7]="convention",s[s.starterdeck=8]="starterdeck",s[s.instore=9]="instore",s[s.setpromo=10]="setpromo",s[s.fnm=11]="fnm",s[s.openhouse=12]="openhouse",s[s.league=13]="league",s[s.draftweekend=14]="draftweekend",s[s.gameday=15]="gameday",s[s.release=16]="release",s[s.intropack=17]="intropack",s[s.giftbox=18]="giftbox",s[s.duels=19]="duels",s[s.wizardsplaynetwork=20]="wizardsplaynetwork",s[s.premiereshop=21]="premiereshop",s[s.playerrewards=22]="playerrewards",s[s.gateway=23]="gateway",s[s.arenaleague=24]="arenaleague",s))(y||{}),m=(s=>(s[s.common=0]="common",s[s.uncommon=1]="uncommon",s[s.rare=2]="rare",s[s.mythic=3]="mythic",s))(m||{}),k=(s=>(s[s.token=0]="token",s[s.meld_part=1]="meld_part",s[s.meld_result=2]="meld_result",s[s.combo_piece=3]="combo_piece",s))(k||{}),I=(s=>(s[s.core=0]="core",s[s.expansion=1]="expansion",s[s.masters=2]="masters",s[s.masterpiece=3]="masterpiece",s[s.from_the_vault=4]="from_the_vault",s[s.spellbook=5]="spellbook",s[s.premium_deck=6]="premium_deck",s[s.duel_deck=7]="duel_deck",s[s.draft_innovation=8]="draft_innovation",s[s.treasure_chest=9]="treasure_chest",s[s.commander=10]="commander",s[s.planechase=11]="planechase",s[s.archenemy=12]="archenemy",s[s.vanguard=13]="vanguard",s[s.funny=14]="funny",s[s.starter=15]="starter",s[s.box=16]="box",s[s.promo=17]="promo",s[s.token=18]="token",s[s.memorabilia=19]="memorabilia",s[s.alchemy=20]="alchemy",s[s.arsenal=21]="arsenal",s))(I||{}),x=(s=>(s[s.name=0]="name",s[s.set=1]="set",s[s.released=2]="released",s[s.rarity=3]="rarity",s[s.color=4]="color",s[s.usd=5]="usd",s[s.tix=6]="tix",s[s.eur=7]="eur",s[s.cmc=8]="cmc",s[s.power=9]="power",s[s.toughness=10]="toughness",s[s.edhrec=11]="edhrec",s[s.artist=12]="artist",s))(x||{}),$=(s=>(s[s.auto=0]="auto",s[s.asc=1]="asc",s[s.desc=2]="desc",s))($||{}),N=(s=>(s[s.cards=0]="cards",s[s.art=1]="art",s[s.prints=2]="prints",s))(N||{});t.Border=w,t.BulkDataTypes=o,t.CardIdentifierBuilder=j,t.Cards=M,t.Catalog=H,t.Format=b,t.FrameEffect=v,t.Game=q,t.Layout=_,t.Legality=f,t.MagicQueryError=h,t.PromoType=y,t.Rarity=m,t.RelatedCardComponent=k,t.Rulings=K,t.SetType=I,t.Sets=W,t.Sort=x,t.SortDirection=$,t.Symbology=Y,t.UniqueStrategy=N,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scryfall-api",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "A Javascript library for https://scryfall.com/docs/api written in Typescript.",
5
5
  "keywords": [
6
6
  "magic the gathering",
@@ -46,28 +46,21 @@
46
46
  "typecheck": "tsc --noEmit",
47
47
  "version": "yarn changeset version && yarn install --mode update-lockfile"
48
48
  },
49
- "engines": {
50
- "node": ">=18"
51
- },
52
49
  "peerDependencies": {
53
50
  "axios": "^0 || ^1"
54
51
  },
55
52
  "devDependencies": {
56
53
  "@changesets/cli": "2.26.0",
57
- "@hexatool/eslint-config-typescript": "1.0.1",
54
+ "@hexatool/eslint-config-typescript": "1.0.3",
58
55
  "@hexatool/tsconfig": "18.0.0",
59
56
  "@types/node": "18.11.18",
60
- "@vitest/coverage-c8": "^0.28.0",
57
+ "@vitest/coverage-c8": "0.28.3",
61
58
  "axios": "1.2.6",
62
59
  "eslint": "8.33.0",
63
- "typescript": "4.9.4",
60
+ "typescript": "4.9.5",
64
61
  "vite": "4.0.4",
65
- "vite-plugin-dts": "1.7.1",
66
- "vitest": "0.28.1"
67
- },
68
- "lint-staged": {
69
- "*.{ts,tsx}": "eslint --fix",
70
- "*": "prettier --ignore-unknown --write"
62
+ "vite-plugin-dts": "1.7.2",
63
+ "vitest": "0.28.3"
71
64
  },
72
65
  "volta": {
73
66
  "node": "18.13.0",