scryfall-api 4.0.1 → 4.0.3

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
@@ -10,10 +10,10 @@
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://www.npmjs.com/package/scryfall-api" rel="nofollow">
13
- <img src="https://camo.githubusercontent.com/a172c58fbefc7103cb230b872119a85914a463f32958ea9e4e1f3ad9d7e1a100/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f7363727966616c6c2d6170693f7374796c653d666c61742d737175617265" alt="npm" data-canonical-src="https://img.shields.io/npm/v/scryfall-api?style=flat-square" style="max-width: 100%;">
13
+ <img src="https://img.shields.io/npm/v/scryfall-api?style=flat-square" alt="npm" style="max-width: 100%;">
14
14
  </a>
15
15
  <a href="https://github.com/MarioMH8/scryfall-api">
16
- <img src="https://camo.githubusercontent.com/93378eea577b6b00f04b1fbfa5dc6871778ff3f6b4de76833a6211d35770f6c4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d6172696f6d68382f7363727966616c6c2d6170693f7374796c653d666c61742d737175617265" alt="GitHub issues" data-canonical-src="https://img.shields.io/github/issues/mariomh8/scryfall-api?style=flat-square" style="max-width: 100%;">
16
+ <img src="https://img.shields.io/github/issues/mariomh8/scryfall-api?style=flat-square" alt="GitHub issues" style="max-width: 100%;">
17
17
  </a>
18
18
  </p>
19
19
 
@@ -79,8 +79,7 @@ function createDebounceFetcher(fetcher2 = fetch) {
79
79
  }
80
80
 
81
81
  // src/fetcher/retry.fetcher.ts
82
- var defaultCanRetry = async (response) => {
83
- const object = await response.json();
82
+ var defaultCanRetry = (object) => {
84
83
  const status = "status" in object ? Number(object.status) : void 0;
85
84
  if (status && status >= 500) {
86
85
  return true;
@@ -108,7 +107,7 @@ function createRetryFetcher({ canRetry = defaultCanRetry, maxAttempts = 3 } = {}
108
107
  }
109
108
  throw new UnknownScryfallError(`Request failed with status ${response.status.toFixed(0)}`);
110
109
  }
111
- if (canRetry(response)) {
110
+ if (canRetry(object)) {
112
111
  return retryFetcher(...arguments_);
113
112
  }
114
113
  if (code && details && status) {
@@ -3,7 +3,7 @@
3
3
  * @type {T | null | undefined} The type can be T, null, or undefined.
4
4
  * @template T The type of the value that can be null or undefined.
5
5
  */
6
- type Nullable<T> = T | null | undefined;
6
+ type Nullable<T> = null | T | undefined;
7
7
 
8
8
  type QueryValue = boolean | number | string | undefined;
9
9
  interface PageQuery {
@@ -113,9 +113,7 @@ declare class SymbologyApi {
113
113
  }
114
114
  declare const symbology: SymbologyApi;
115
115
 
116
- type CardComponent = 'combo_piece' | 'meld_part' | 'meld_result' | 'token';
117
- type Legality = 'banned' | 'legal' | 'not_legal' | 'restricted';
118
- interface ImageUris$1 {
116
+ interface ImageUris {
119
117
  art_crop: string;
120
118
  border_crop: string;
121
119
  large: string;
@@ -123,6 +121,9 @@ interface ImageUris$1 {
123
121
  png: string;
124
122
  small: string;
125
123
  }
124
+
125
+ type CardComponent = 'combo_piece' | 'meld_part' | 'meld_result' | 'token';
126
+ type Legality = 'banned' | 'legal' | 'not_legal' | 'restricted';
126
127
  interface CardFace {
127
128
  artist?: Nullable<string>;
128
129
  artist_id?: Nullable<string>;
@@ -132,7 +133,7 @@ interface CardFace {
132
133
  defense?: Nullable<string>;
133
134
  flavor_text?: Nullable<string>;
134
135
  illustration_id?: Nullable<string>;
135
- image_uris?: Nullable<ImageUris$1>;
136
+ image_uris?: Nullable<ImageUris>;
136
137
  layout?: Nullable<string>;
137
138
  loyalty?: Nullable<string>;
138
139
  mana_cost: string;
@@ -244,14 +245,6 @@ type Frame = '1993' | '1997' | '2003' | '2015' | 'future';
244
245
  type FrameEffect = 'colorshifted' | 'companion' | 'compasslanddfc' | 'convertdfc' | 'devoid' | 'draft' | 'etched' | 'extendedart' | 'fandfc' | 'inverted' | 'legendary' | 'lesson' | 'miracle' | 'mooneldrazidfc' | 'nyxtouched' | 'originpwdfc' | 'shatteredglass' | 'showcase' | 'snow' | 'sunmoondfc' | 'tombstone' | 'upsidedowndfc' | 'waxingandwaningmoondfc';
245
246
  type Game = 'arena' | 'mtgo' | 'paper';
246
247
  type ImageStatus = 'highres_scan' | 'lowres' | 'missing' | 'placeholder';
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
248
  interface Preview {
256
249
  previewed_at: Date;
257
250
  source: string;
@@ -421,4 +414,4 @@ declare class ScryfallError extends Error {
421
414
  declare class UnknownScryfallError extends Error {
422
415
  }
423
416
 
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 CardSearchDirection, 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 };
417
+ export { type BorderColor, type Card, type CardComponent, type CardFace, type CardIdentifier, CardIdentifierApi as CardIdentifierBuilder, type CardIdentifierCollectorSet, type CardIdentifierId, type CardIdentifierIllustrationId, type CardIdentifierMtgGoId, type CardIdentifierMultiverseId, type CardIdentifierNameSet, type CardIdentifierOracleId, type CardLanguage, type CardLayout, type CardSearch, type CardSearchDirection, type CardSearchFormat, type CardSearchOrder, type CardSearchUnique, cards as Cards, type Catalog, catalog as Catalogs, type Color, type Finish, type Frame, type FrameEffect, type Game, type ImageStatus, type ImageUris, InvalidScryfallArgumentError, type Legalities, type Legality, MagicPageResult, type ManaCost, type Preview, type Prices, type PromoType, type PurchaseUris, type Rarity, type RelatedCard, type RelatedUris, type Ruling, rulings as Rulings, ScryfallError, type SecurityStamp, type Set, type SetType, set as Sets, type Symbology, symbology as SymbologyApi, UnknownScryfallError };
@@ -3,7 +3,7 @@
3
3
  * @type {T | null | undefined} The type can be T, null, or undefined.
4
4
  * @template T The type of the value that can be null or undefined.
5
5
  */
6
- type Nullable<T> = T | null | undefined;
6
+ type Nullable<T> = null | T | undefined;
7
7
 
8
8
  type QueryValue = boolean | number | string | undefined;
9
9
  interface PageQuery {
@@ -113,9 +113,7 @@ declare class SymbologyApi {
113
113
  }
114
114
  declare const symbology: SymbologyApi;
115
115
 
116
- type CardComponent = 'combo_piece' | 'meld_part' | 'meld_result' | 'token';
117
- type Legality = 'banned' | 'legal' | 'not_legal' | 'restricted';
118
- interface ImageUris$1 {
116
+ interface ImageUris {
119
117
  art_crop: string;
120
118
  border_crop: string;
121
119
  large: string;
@@ -123,6 +121,9 @@ interface ImageUris$1 {
123
121
  png: string;
124
122
  small: string;
125
123
  }
124
+
125
+ type CardComponent = 'combo_piece' | 'meld_part' | 'meld_result' | 'token';
126
+ type Legality = 'banned' | 'legal' | 'not_legal' | 'restricted';
126
127
  interface CardFace {
127
128
  artist?: Nullable<string>;
128
129
  artist_id?: Nullable<string>;
@@ -132,7 +133,7 @@ interface CardFace {
132
133
  defense?: Nullable<string>;
133
134
  flavor_text?: Nullable<string>;
134
135
  illustration_id?: Nullable<string>;
135
- image_uris?: Nullable<ImageUris$1>;
136
+ image_uris?: Nullable<ImageUris>;
136
137
  layout?: Nullable<string>;
137
138
  loyalty?: Nullable<string>;
138
139
  mana_cost: string;
@@ -244,14 +245,6 @@ type Frame = '1993' | '1997' | '2003' | '2015' | 'future';
244
245
  type FrameEffect = 'colorshifted' | 'companion' | 'compasslanddfc' | 'convertdfc' | 'devoid' | 'draft' | 'etched' | 'extendedart' | 'fandfc' | 'inverted' | 'legendary' | 'lesson' | 'miracle' | 'mooneldrazidfc' | 'nyxtouched' | 'originpwdfc' | 'shatteredglass' | 'showcase' | 'snow' | 'sunmoondfc' | 'tombstone' | 'upsidedowndfc' | 'waxingandwaningmoondfc';
245
246
  type Game = 'arena' | 'mtgo' | 'paper';
246
247
  type ImageStatus = 'highres_scan' | 'lowres' | 'missing' | 'placeholder';
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
248
  interface Preview {
256
249
  previewed_at: Date;
257
250
  source: string;
@@ -421,4 +414,4 @@ declare class ScryfallError extends Error {
421
414
  declare class UnknownScryfallError extends Error {
422
415
  }
423
416
 
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 CardSearchDirection, 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 };
417
+ export { type BorderColor, type Card, type CardComponent, type CardFace, type CardIdentifier, CardIdentifierApi as CardIdentifierBuilder, type CardIdentifierCollectorSet, type CardIdentifierId, type CardIdentifierIllustrationId, type CardIdentifierMtgGoId, type CardIdentifierMultiverseId, type CardIdentifierNameSet, type CardIdentifierOracleId, type CardLanguage, type CardLayout, type CardSearch, type CardSearchDirection, type CardSearchFormat, type CardSearchOrder, type CardSearchUnique, cards as Cards, type Catalog, catalog as Catalogs, type Color, type Finish, type Frame, type FrameEffect, type Game, type ImageStatus, type ImageUris, InvalidScryfallArgumentError, type Legalities, type Legality, MagicPageResult, type ManaCost, type Preview, type Prices, type PromoType, type PurchaseUris, type Rarity, type RelatedCard, type RelatedUris, type Ruling, rulings as Rulings, ScryfallError, type SecurityStamp, type Set, type SetType, set as Sets, type Symbology, symbology as SymbologyApi, UnknownScryfallError };
@@ -44,8 +44,7 @@ function createDebounceFetcher(fetcher2 = fetch) {
44
44
  }
45
45
 
46
46
  // src/fetcher/retry.fetcher.ts
47
- var defaultCanRetry = async (response) => {
48
- const object = await response.json();
47
+ var defaultCanRetry = (object) => {
49
48
  const status = "status" in object ? Number(object.status) : void 0;
50
49
  if (status && status >= 500) {
51
50
  return true;
@@ -73,7 +72,7 @@ function createRetryFetcher({ canRetry = defaultCanRetry, maxAttempts = 3 } = {}
73
72
  }
74
73
  throw new UnknownScryfallError(`Request failed with status ${response.status.toFixed(0)}`);
75
74
  }
76
- if (canRetry(response)) {
75
+ if (canRetry(object)) {
77
76
  return retryFetcher(...arguments_);
78
77
  }
79
78
  if (code && details && status) {
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var v=(s,e)=>{for(var t in e)b(s,t,{get:e[t],enumerable:!0})},D=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!O.call(s,o)&&o!==t&&b(s,o,{get:()=>e[o],enumerable:!(n=q(e,o))||n.enumerable});return s};var Q=s=>D(b({},"__esModule",{value:!0}),s);var Y={};v(Y,{CardIdentifierBuilder:()=>m,Cards:()=>P,Catalogs:()=>T,InvalidScryfallArgumentError:()=>d,MagicPageResult:()=>l,Rulings:()=>S,ScryfallError:()=>u,Sets:()=>L,SymbologyApi:()=>N,UnknownScryfallError:()=>p});module.exports=Q(Y);var d=class extends Error{};var u=class extends Error{constructor(t,n,o,a,c){super(n);this.code=t;this.status=o;this.type=a;this.warnings=c}};var p=class extends Error{};var h=100,j=100;async function z(s=0){return new Promise(e=>{setTimeout(e,s)})}async function $(){let s=Date.now(),e=s-h;if(e>=j)h=s;else{let t=j-e;h+=t,await z(t)}}function w(s=fetch){return async function(...t){return await $(),s(...t)}}var A=async s=>{let e=await s.json(),t="status"in e?Number(e.status):void 0;if(t&&t>=500)return!0;let n="code"in e&&typeof e.code=="string"?e.code:void 0;return n!=="not_found"&&n!=="bad_request"};function x({canRetry:s=A,maxAttempts:e=3}={},t=fetch){let n=0;return async function o(...a){n++;let c=await t(...a);if(c.ok)return c;let i=await c.json(),f="code"in i&&typeof i.code=="string"?i.code:void 0,y="status"in i?Number(i.status):void 0,g="details"in i&&typeof i.details=="string"?i.details:void 0,_="type"in i&&typeof i.type=="string"?i.type:void 0,k="warnings"in i&&Array.isArray(i.warnings)?i.warnings:void 0;if(n>=e)throw f&&g&&y?new u(f,g,y,_,k):new p(`Request failed with status ${c.status.toFixed(0)}`);if(s(c))return o(...a);throw f&&g&&y?new u(f,g,y,_,k):new p(`Request failed with status ${c.status.toFixed(0)}`)}}var U=w(x()),B="https://api.scryfall.com",G=/^\d{4}-\d{2}-\d{2}?$/,J=(s,e)=>typeof e=="string"&&G.test(e)?new Date(e):e;async function r(s,e,t){let n="";typeof s=="number"||typeof s=="string"?n=s:s&&(n=s.join("/"));let o=new URL(`${B}/${String(n)}`);if(e)for(let[a,c]of Object.entries(e))c!==void 0&&o.searchParams.append(a,c.toString());try{let a={method:t?"POST":"GET"};t&&(a.body=JSON.stringify(t),a.headers={"Content-Type":"application/json"});let i=await(await U(o,a)).text();return JSON.parse(i,J)}catch(a){if(a instanceof u&&(a.warnings&&console.warn(a.warnings),a.code==="not_found"||a.code==="bad_request"))return;throw a}}var l=class{constructor(e,t){this.apiPath=e;this.query=t;this.#e=!0,this.#t=0}#t;#e;get count(){return this.#t}get hasMore(){return this.#e}async all(){let e=[];for(;this.#e;){let t=await this.next();e.push(...t)}return e}async get(e){let t=[];for(;this.#e;){let n=await this.next();if(t.push(...n),t.length===e)return t;if(t.length>e)return t.slice(0,e)}return t}async next(){let e=await r(this.apiPath,this.query);return this.#e=e?.has_more??!1,this.#t=Number.parseInt(e?.total_cards?.toFixed(0)??"0",10),this.#e&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page+=1}};var C=class{async autoCompleteName(e){return(await r("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return r(["cards/arena",e])}async byId(e){return r(["cards",e])}async byMtgoId(e){return r(["cards/mtgo",e])}async byMultiverseId(e){return r(["cards/multiverse",e])}async byName(e,t,n=!1){let o=n,a=t;return typeof t=="boolean"&&(o=t,a=void 0),r("cards/named",{[o?"fuzzy":"exact"]:e,set:a})}async bySet(e,t,n){let o=["cards",e,t];return n&&o.push(n),r(o)}async byTcgPlayerId(e){return r(["cards/tcgplayer",e])}async collection(...e){let t=[];for(let n=0;n<e.length;n+=75){let o={identifiers:e.slice(n,n+75)},a=await r("cards/collection",void 0,o);t.push(...a?.data??[])}return t}async random(){return r("cards/random")}search(e,t){return new l("cards/search",{q:e,...typeof t=="number"?{page:t}:{...t,page:t?.page??1}})}},V=new C,P=V;var m=class{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,t){return t?{name:e,set:t}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,t){return{collector_number:String(t),set:e}}};var R=class{async artifactTypes(){return(await r("catalog/artifact-types"))?.data??[]}async artistNames(){return(await r("catalog/artist-names"))?.data??[]}async cardNames(){return(await r("catalog/card-names"))?.data??[]}async creatureTypes(){return(await r("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await r("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await r("catalog/land-types"))?.data??[]}async loyalties(){return(await r("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await r("catalog/planeswalker-types"))?.data??[]}async powers(){return(await r("catalog/powers"))?.data??[]}async spellTypes(){return(await r("catalog/spell-types"))?.data??[]}async toughnesses(){return(await r("catalog/toughnesses"))?.data??[]}async watermarks(){return(await r("catalog/watermarks"))?.data??[]}async wordBank(){return(await r("catalog/word-bank"))?.data??[]}},X=new R,T=X;var I=class{async byArenaId(e){return(await r(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await r(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await r(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await r(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,t){return(await r(["cards",e,String(t),"rulings"]))?.data??[]}},H=new I,S=H;var F=class{async all(){return(await r("sets"))?.data??[]}async byCode(e){return await r(["sets",e])}async byId(e){return r(["sets",e])}async byTcgPlayerId(e){return r(["sets/tcgplayer",e])}},K=new F,L=K;var M=class{async all(){return(await r("symbology"))?.data??[]}async parseMana(e){if(!e||typeof e!="string")throw new d("shorthand must be a string");return await r("symbology/parse-mana",{cost:e})??{cmc:0,colorless:!1,colors:[],cost:"",monocolored:!1,multicolored:!1,object:"mana_cost"}}},W=new M,N=W;0&&(module.exports={CardIdentifierBuilder,Cards,Catalogs,InvalidScryfallArgumentError,MagicPageResult,Rulings,ScryfallError,Sets,SymbologyApi,UnknownScryfallError});
1
+ "use strict";var b=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var D=(s,e)=>{for(var t in e)b(s,t,{get:e[t],enumerable:!0})},j=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!v.call(s,o)&&o!==t&&b(s,o,{get:()=>e[o],enumerable:!(n=E(e,o))||n.enumerable});return s};var Q=s=>j(b({},"__esModule",{value:!0}),s);var Y={};D(Y,{CardIdentifierBuilder:()=>m,Cards:()=>P,Catalogs:()=>R,InvalidScryfallArgumentError:()=>d,MagicPageResult:()=>l,Rulings:()=>S,ScryfallError:()=>u,Sets:()=>L,SymbologyApi:()=>N,UnknownScryfallError:()=>p});module.exports=Q(Y);var d=class extends Error{};var u=class extends Error{constructor(t,n,o,a,c){super(n);this.code=t;this.status=o;this.type=a;this.warnings=c}};var p=class extends Error{};var h=100,q=100;async function z(s=0){return new Promise(e=>{setTimeout(e,s)})}async function $(){let s=Date.now(),e=s-h;if(e>=q)h=s;else{let t=q-e;h+=t,await z(t)}}function w(s=fetch){return async function(...t){return await $(),s(...t)}}var A=s=>{let e="status"in s?Number(s.status):void 0;if(e&&e>=500)return!0;let t="code"in s&&typeof s.code=="string"?s.code:void 0;return t!=="not_found"&&t!=="bad_request"};function x({canRetry:s=A,maxAttempts:e=3}={},t=fetch){let n=0;return async function o(...a){n++;let c=await t(...a);if(c.ok)return c;let i=await c.json(),f="code"in i&&typeof i.code=="string"?i.code:void 0,y="status"in i?Number(i.status):void 0,g="details"in i&&typeof i.details=="string"?i.details:void 0,_="type"in i&&typeof i.type=="string"?i.type:void 0,k="warnings"in i&&Array.isArray(i.warnings)?i.warnings:void 0;if(n>=e)throw f&&g&&y?new u(f,g,y,_,k):new p(`Request failed with status ${c.status.toFixed(0)}`);if(s(i))return o(...a);throw f&&g&&y?new u(f,g,y,_,k):new p(`Request failed with status ${c.status.toFixed(0)}`)}}var U=w(x()),B="https://api.scryfall.com",G=/^\d{4}-\d{2}-\d{2}?$/,J=(s,e)=>typeof e=="string"&&G.test(e)?new Date(e):e;async function r(s,e,t){let n="";typeof s=="number"||typeof s=="string"?n=s:s&&(n=s.join("/"));let o=new URL(`${B}/${String(n)}`);if(e)for(let[a,c]of Object.entries(e))c!==void 0&&o.searchParams.append(a,c.toString());try{let a={method:t?"POST":"GET"};t&&(a.body=JSON.stringify(t),a.headers={"Content-Type":"application/json"});let i=await(await U(o,a)).text();return JSON.parse(i,J)}catch(a){if(a instanceof u&&(a.warnings&&console.warn(a.warnings),a.code==="not_found"||a.code==="bad_request"))return;throw a}}var l=class{constructor(e,t){this.apiPath=e;this.query=t;this.#e=!0,this.#t=0}#t;#e;get count(){return this.#t}get hasMore(){return this.#e}async all(){let e=[];for(;this.#e;){let t=await this.next();e.push(...t)}return e}async get(e){let t=[];for(;this.#e;){let n=await this.next();if(t.push(...n),t.length===e)return t;if(t.length>e)return t.slice(0,e)}return t}async next(){let e=await r(this.apiPath,this.query);return this.#e=e?.has_more??!1,this.#t=Number.parseInt(e?.total_cards?.toFixed(0)??"0",10),this.#e&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page+=1}};var C=class{async autoCompleteName(e){return(await r("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return r(["cards/arena",e])}async byId(e){return r(["cards",e])}async byMtgoId(e){return r(["cards/mtgo",e])}async byMultiverseId(e){return r(["cards/multiverse",e])}async byName(e,t,n=!1){let o=n,a=t;return typeof t=="boolean"&&(o=t,a=void 0),r("cards/named",{[o?"fuzzy":"exact"]:e,set:a})}async bySet(e,t,n){let o=["cards",e,t];return n&&o.push(n),r(o)}async byTcgPlayerId(e){return r(["cards/tcgplayer",e])}async collection(...e){let t=[];for(let n=0;n<e.length;n+=75){let o={identifiers:e.slice(n,n+75)},a=await r("cards/collection",void 0,o);t.push(...a?.data??[])}return t}async random(){return r("cards/random")}search(e,t){return new l("cards/search",{q:e,...typeof t=="number"?{page:t}:{...t,page:t?.page??1}})}},V=new C,P=V;var m=class{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,t){return t?{name:e,set:t}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,t){return{collector_number:String(t),set:e}}};var T=class{async artifactTypes(){return(await r("catalog/artifact-types"))?.data??[]}async artistNames(){return(await r("catalog/artist-names"))?.data??[]}async cardNames(){return(await r("catalog/card-names"))?.data??[]}async creatureTypes(){return(await r("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await r("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await r("catalog/land-types"))?.data??[]}async loyalties(){return(await r("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await r("catalog/planeswalker-types"))?.data??[]}async powers(){return(await r("catalog/powers"))?.data??[]}async spellTypes(){return(await r("catalog/spell-types"))?.data??[]}async toughnesses(){return(await r("catalog/toughnesses"))?.data??[]}async watermarks(){return(await r("catalog/watermarks"))?.data??[]}async wordBank(){return(await r("catalog/word-bank"))?.data??[]}},X=new T,R=X;var I=class{async byArenaId(e){return(await r(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await r(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await r(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await r(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,t){return(await r(["cards",e,String(t),"rulings"]))?.data??[]}},H=new I,S=H;var F=class{async all(){return(await r("sets"))?.data??[]}async byCode(e){return await r(["sets",e])}async byId(e){return r(["sets",e])}async byTcgPlayerId(e){return r(["sets/tcgplayer",e])}},K=new F,L=K;var M=class{async all(){return(await r("symbology"))?.data??[]}async parseMana(e){if(!e||typeof e!="string")throw new d("shorthand must be a string");return await r("symbology/parse-mana",{cost:e})??{cmc:0,colorless:!1,colors:[],cost:"",monocolored:!1,multicolored:!1,object:"mana_cost"}}},W=new M,N=W;0&&(module.exports={CardIdentifierBuilder,Cards,Catalogs,InvalidScryfallArgumentError,MagicPageResult,Rulings,ScryfallError,Sets,SymbologyApi,UnknownScryfallError});
@@ -1 +1 @@
1
- var d=class extends Error{};var u=class extends Error{constructor(t,n,i,a,c){super(n);this.code=t;this.status=i;this.type=a;this.warnings=c}};var p=class extends Error{};var b=100,F=100;async function j(s=0){return new Promise(e=>{setTimeout(e,s)})}async function q(){let s=Date.now(),e=s-b;if(e>=F)b=s;else{let t=F-e;b+=t,await j(t)}}function h(s=fetch){return async function(...t){return await q(),s(...t)}}var E=async s=>{let e=await s.json(),t="status"in e?Number(e.status):void 0;if(t&&t>=500)return!0;let n="code"in e&&typeof e.code=="string"?e.code:void 0;return n!=="not_found"&&n!=="bad_request"};function w({canRetry:s=E,maxAttempts:e=3}={},t=fetch){let n=0;return async function i(...a){n++;let c=await t(...a);if(c.ok)return c;let o=await c.json(),f="code"in o&&typeof o.code=="string"?o.code:void 0,y="status"in o?Number(o.status):void 0,g="details"in o&&typeof o.details=="string"?o.details:void 0,I="type"in o&&typeof o.type=="string"?o.type:void 0,S="warnings"in o&&Array.isArray(o.warnings)?o.warnings:void 0;if(n>=e)throw f&&g&&y?new u(f,g,y,I,S):new p(`Request failed with status ${c.status.toFixed(0)}`);if(s(c))return i(...a);throw f&&g&&y?new u(f,g,y,I,S):new p(`Request failed with status ${c.status.toFixed(0)}`)}}var O=h(w()),v="https://api.scryfall.com",D=/^\d{4}-\d{2}-\d{2}?$/,Q=(s,e)=>typeof e=="string"&&D.test(e)?new Date(e):e;async function r(s,e,t){let n="";typeof s=="number"||typeof s=="string"?n=s:s&&(n=s.join("/"));let i=new URL(`${v}/${String(n)}`);if(e)for(let[a,c]of Object.entries(e))c!==void 0&&i.searchParams.append(a,c.toString());try{let a={method:t?"POST":"GET"};t&&(a.body=JSON.stringify(t),a.headers={"Content-Type":"application/json"});let o=await(await O(i,a)).text();return JSON.parse(o,Q)}catch(a){if(a instanceof u&&(a.warnings&&console.warn(a.warnings),a.code==="not_found"||a.code==="bad_request"))return;throw a}}var l=class{constructor(e,t){this.apiPath=e;this.query=t;this.#e=!0,this.#t=0}#t;#e;get count(){return this.#t}get hasMore(){return this.#e}async all(){let e=[];for(;this.#e;){let t=await this.next();e.push(...t)}return e}async get(e){let t=[];for(;this.#e;){let n=await this.next();if(t.push(...n),t.length===e)return t;if(t.length>e)return t.slice(0,e)}return t}async next(){let e=await r(this.apiPath,this.query);return this.#e=e?.has_more??!1,this.#t=Number.parseInt(e?.total_cards?.toFixed(0)??"0",10),this.#e&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page+=1}};var x=class{async autoCompleteName(e){return(await r("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return r(["cards/arena",e])}async byId(e){return r(["cards",e])}async byMtgoId(e){return r(["cards/mtgo",e])}async byMultiverseId(e){return r(["cards/multiverse",e])}async byName(e,t,n=!1){let i=n,a=t;return typeof t=="boolean"&&(i=t,a=void 0),r("cards/named",{[i?"fuzzy":"exact"]:e,set:a})}async bySet(e,t,n){let i=["cards",e,t];return n&&i.push(n),r(i)}async byTcgPlayerId(e){return r(["cards/tcgplayer",e])}async collection(...e){let t=[];for(let n=0;n<e.length;n+=75){let i={identifiers:e.slice(n,n+75)},a=await r("cards/collection",void 0,i);t.push(...a?.data??[])}return t}async random(){return r("cards/random")}search(e,t){return new l("cards/search",{q:e,...typeof t=="number"?{page:t}:{...t,page:t?.page??1}})}},z=new x,L=z;var m=class{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,t){return t?{name:e,set:t}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,t){return{collector_number:String(t),set:e}}};var C=class{async artifactTypes(){return(await r("catalog/artifact-types"))?.data??[]}async artistNames(){return(await r("catalog/artist-names"))?.data??[]}async cardNames(){return(await r("catalog/card-names"))?.data??[]}async creatureTypes(){return(await r("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await r("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await r("catalog/land-types"))?.data??[]}async loyalties(){return(await r("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await r("catalog/planeswalker-types"))?.data??[]}async powers(){return(await r("catalog/powers"))?.data??[]}async spellTypes(){return(await r("catalog/spell-types"))?.data??[]}async toughnesses(){return(await r("catalog/toughnesses"))?.data??[]}async watermarks(){return(await r("catalog/watermarks"))?.data??[]}async wordBank(){return(await r("catalog/word-bank"))?.data??[]}},$=new C,M=$;var P=class{async byArenaId(e){return(await r(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await r(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await r(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await r(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,t){return(await r(["cards",e,String(t),"rulings"]))?.data??[]}},A=new P,N=A;var R=class{async all(){return(await r("sets"))?.data??[]}async byCode(e){return await r(["sets",e])}async byId(e){return r(["sets",e])}async byTcgPlayerId(e){return r(["sets/tcgplayer",e])}},U=new R,_=U;var T=class{async all(){return(await r("symbology"))?.data??[]}async parseMana(e){if(!e||typeof e!="string")throw new d("shorthand must be a string");return await r("symbology/parse-mana",{cost:e})??{cmc:0,colorless:!1,colors:[],cost:"",monocolored:!1,multicolored:!1,object:"mana_cost"}}},B=new T,k=B;export{m as CardIdentifierBuilder,L as Cards,M as Catalogs,d as InvalidScryfallArgumentError,l as MagicPageResult,N as Rulings,u as ScryfallError,_ as Sets,k as SymbologyApi,p as UnknownScryfallError};
1
+ var d=class extends Error{};var u=class extends Error{constructor(t,n,i,a,c){super(n);this.code=t;this.status=i;this.type=a;this.warnings=c}};var p=class extends Error{};var b=100,F=100;async function q(s=0){return new Promise(e=>{setTimeout(e,s)})}async function E(){let s=Date.now(),e=s-b;if(e>=F)b=s;else{let t=F-e;b+=t,await q(t)}}function h(s=fetch){return async function(...t){return await E(),s(...t)}}var O=s=>{let e="status"in s?Number(s.status):void 0;if(e&&e>=500)return!0;let t="code"in s&&typeof s.code=="string"?s.code:void 0;return t!=="not_found"&&t!=="bad_request"};function w({canRetry:s=O,maxAttempts:e=3}={},t=fetch){let n=0;return async function i(...a){n++;let c=await t(...a);if(c.ok)return c;let o=await c.json(),f="code"in o&&typeof o.code=="string"?o.code:void 0,y="status"in o?Number(o.status):void 0,g="details"in o&&typeof o.details=="string"?o.details:void 0,I="type"in o&&typeof o.type=="string"?o.type:void 0,S="warnings"in o&&Array.isArray(o.warnings)?o.warnings:void 0;if(n>=e)throw f&&g&&y?new u(f,g,y,I,S):new p(`Request failed with status ${c.status.toFixed(0)}`);if(s(o))return i(...a);throw f&&g&&y?new u(f,g,y,I,S):new p(`Request failed with status ${c.status.toFixed(0)}`)}}var v=h(w()),D="https://api.scryfall.com",j=/^\d{4}-\d{2}-\d{2}?$/,Q=(s,e)=>typeof e=="string"&&j.test(e)?new Date(e):e;async function r(s,e,t){let n="";typeof s=="number"||typeof s=="string"?n=s:s&&(n=s.join("/"));let i=new URL(`${D}/${String(n)}`);if(e)for(let[a,c]of Object.entries(e))c!==void 0&&i.searchParams.append(a,c.toString());try{let a={method:t?"POST":"GET"};t&&(a.body=JSON.stringify(t),a.headers={"Content-Type":"application/json"});let o=await(await v(i,a)).text();return JSON.parse(o,Q)}catch(a){if(a instanceof u&&(a.warnings&&console.warn(a.warnings),a.code==="not_found"||a.code==="bad_request"))return;throw a}}var l=class{constructor(e,t){this.apiPath=e;this.query=t;this.#e=!0,this.#t=0}#t;#e;get count(){return this.#t}get hasMore(){return this.#e}async all(){let e=[];for(;this.#e;){let t=await this.next();e.push(...t)}return e}async get(e){let t=[];for(;this.#e;){let n=await this.next();if(t.push(...n),t.length===e)return t;if(t.length>e)return t.slice(0,e)}return t}async next(){let e=await r(this.apiPath,this.query);return this.#e=e?.has_more??!1,this.#t=Number.parseInt(e?.total_cards?.toFixed(0)??"0",10),this.#e&&this.setNextPage(),e?.data??[]}async page(e){return this.query.page=e,this.next()}setNextPage(){this.query.page+=1}};var x=class{async autoCompleteName(e){return(await r("cards/autocomplete",{q:e}))?.data??[]}async byArenaId(e){return r(["cards/arena",e])}async byId(e){return r(["cards",e])}async byMtgoId(e){return r(["cards/mtgo",e])}async byMultiverseId(e){return r(["cards/multiverse",e])}async byName(e,t,n=!1){let i=n,a=t;return typeof t=="boolean"&&(i=t,a=void 0),r("cards/named",{[i?"fuzzy":"exact"]:e,set:a})}async bySet(e,t,n){let i=["cards",e,t];return n&&i.push(n),r(i)}async byTcgPlayerId(e){return r(["cards/tcgplayer",e])}async collection(...e){let t=[];for(let n=0;n<e.length;n+=75){let i={identifiers:e.slice(n,n+75)},a=await r("cards/collection",void 0,i);t.push(...a?.data??[])}return t}async random(){return r("cards/random")}search(e,t){return new l("cards/search",{q:e,...typeof t=="number"?{page:t}:{...t,page:t?.page??1}})}},z=new x,L=z;var m=class{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,t){return t?{name:e,set:t}:{name:e}}static byOracleId(e){return{oracle_id:e}}static bySet(e,t){return{collector_number:String(t),set:e}}};var C=class{async artifactTypes(){return(await r("catalog/artifact-types"))?.data??[]}async artistNames(){return(await r("catalog/artist-names"))?.data??[]}async cardNames(){return(await r("catalog/card-names"))?.data??[]}async creatureTypes(){return(await r("catalog/creature-types"))?.data??[]}async enchantmentTypes(){return(await r("catalog/enchantment-types"))?.data??[]}async landTypes(){return(await r("catalog/land-types"))?.data??[]}async loyalties(){return(await r("catalog/loyalties"))?.data??[]}async planeswalkerTypes(){return(await r("catalog/planeswalker-types"))?.data??[]}async powers(){return(await r("catalog/powers"))?.data??[]}async spellTypes(){return(await r("catalog/spell-types"))?.data??[]}async toughnesses(){return(await r("catalog/toughnesses"))?.data??[]}async watermarks(){return(await r("catalog/watermarks"))?.data??[]}async wordBank(){return(await r("catalog/word-bank"))?.data??[]}},$=new C,M=$;var P=class{async byArenaId(e){return(await r(["cards/arena",e,"rulings"]))?.data??[]}async byId(e){return(await r(["cards",e,"rulings"]))?.data??[]}async byMtgoId(e){return(await r(["cards/mtgo",e,"rulings"]))?.data??[]}async byMultiverseId(e){return(await r(["cards/multiverse",e,"rulings"]))?.data??[]}async bySet(e,t){return(await r(["cards",e,String(t),"rulings"]))?.data??[]}},A=new P,N=A;var T=class{async all(){return(await r("sets"))?.data??[]}async byCode(e){return await r(["sets",e])}async byId(e){return r(["sets",e])}async byTcgPlayerId(e){return r(["sets/tcgplayer",e])}},U=new T,_=U;var R=class{async all(){return(await r("symbology"))?.data??[]}async parseMana(e){if(!e||typeof e!="string")throw new d("shorthand must be a string");return await r("symbology/parse-mana",{cost:e})??{cmc:0,colorless:!1,colors:[],cost:"",monocolored:!1,multicolored:!1,object:"mana_cost"}}},B=new R,k=B;export{m as CardIdentifierBuilder,L as Cards,M as Catalogs,d as InvalidScryfallArgumentError,l as MagicPageResult,N as Rulings,u as ScryfallError,_ as Sets,k as SymbologyApi,p as UnknownScryfallError};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scryfall-api",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "A Javascript library for https://scryfall.com/docs/api written in Typescript.",
5
5
  "keywords": [
6
6
  "magic",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/MarioMH8/scryfall-api"
20
+ "url": "git+https://github.com/MarioMH8/scryfall-api.git"
21
21
  },
22
22
  "homepage": "https://github.com/MarioMH8/scryfall-api",
23
23
  "bugs": {
@@ -53,12 +53,12 @@
53
53
  "typecheck": "tsc --noEmit"
54
54
  },
55
55
  "devDependencies": {
56
- "@changesets/cli": "2.27.7",
57
- "@hexadrop/eslint-config": "0.0.1-beta.14",
56
+ "@changesets/cli": "2.29.0",
57
+ "@hexadrop/eslint-config": "0.1.2",
58
58
  "@hexadrop/tsconfig": "0.0.5",
59
- "@types/bun": "1.1.6",
60
- "eslint": "9.6.0",
61
- "tsup": "8.1.0",
62
- "typescript": "5.5.3"
59
+ "@types/bun": "1.2.9",
60
+ "eslint": "9.24.0",
61
+ "tsup": "8.4.0",
62
+ "typescript": "5.8.3"
63
63
  }
64
64
  }