Skip to content

Commit 1a615dd

Browse files
committedOct 11, 2023
expand documentation, readme, and exports
1 parent 6a32011 commit 1a615dd

28 files changed

+1612
-58
lines changed
 

‎README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@ This library documents the definitive comprehensive typings of [the Scryfall API
44

55
This library uses [semver] for versioning. These versions only describe this library, not the Scryfall API as a whole.
66

7-
[semver]: https://semver.org/
8-
[api]: https://scryfall.com/docs/api
9-
107
## Usage
118

12-
Each object or type exported by this library corresponds to a Scryfall API object.
9+
Each type and enum exported by this library corresponds to a Scryfall API object and its values.
10+
11+
Points of interest:
1312

14-
-
13+
- [ScryfallCard](src/objects/Card/Card.ts) describes [Cards](https://scryfall.com/docs/api/cards) and their faces. Each individual card layout is managed via type narrowing on the `layout` field.
14+
- [ScryfallCatalog](src/objects/Catalog/Catalog.ts) describes [the catalogs](https://scryfall.com/docs/api/catalogs).
15+
- [ScryfallError](src/objects/Error/Error.ts) describes [error responses](https://scryfall.com/docs/api/errors).
16+
- [ScryfallList](src/objects/List/List.ts) describes [lists](https://scryfall.com/docs/api/lists), and provides shortcuts to describe the common types of lists.
17+
- [ScryfallMigration](src/objects/Migration/Migration.ts) describes [migrations](https://scryfall.com/docs/api/migrations).
18+
- [ScryfallSet](src/objects/Set/Set.ts) describes [card sets](https://scryfall.com/docs/api/sets).
1519

16-
## Details
20+
If the API provides an object, this library provides it as well. (If it doesn't, please [tell us][issues]!)
1721

18-
All exported types are prefixed with `Scryfall`, so that we can declare e.g. `ScryfallSet`, `ScryfallObject`, and `ScryfallError` without clashing with the built-in `Set`, `Object`, and `Error` types.
22+
All primary types and values are prefixed with `Scryfall` to avoid conflict with the standard library (e.g. `Object`, `Error`, `Set`) and to minimise conflict with your other libraries and dependencies (e.g. `Color`, `LanguageCode`). If we didn't have the prefix you'd be forced to append one yourself one on import, so we've defaulted to including it.
1923

20-
Enum fields are always defined in two ways: as the Enum, and as an Enum-like string. This permits you to interact with this system using our enums, just strings, or your own enums—whatever you'd prefer.
24+
Enum fields are described both in terms of an enum and a set of strings in order to give you the option of interacting with that field with either one.
25+
26+
[semver]: https://semver.org/
27+
[api]: https://scryfall.com/docs/api
28+
[issues]: https://github.com/scryfall/api-types/issues
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
import { ScryfallCard } from "src";
2+
3+
const Undercity: ScryfallCard.DoubleFacedToken = {
4+
object: "card",
5+
id: "2c65185b-6cf0-451d-985e-56aa45d9a57d",
6+
oracle_id: "36b61021-72f0-4c22-a41d-9b2f093d7ca8",
7+
multiverse_ids: [],
8+
name: "The Initiative // Undercity",
9+
lang: "en",
10+
released_at: "2022-06-10",
11+
uri: "https://api.scryfall.com/cards/2c65185b-6cf0-451d-985e-56aa45d9a57d",
12+
scryfall_uri: "https://scryfall.com/card/tclb/20/the-initiative-undercity?utm_source=api",
13+
layout: "double_faced_token",
14+
highres_image: true,
15+
image_status: "highres_scan",
16+
cmc: 0.0,
17+
type_line: "Card // Dungeon — Undercity",
18+
color_identity: [],
19+
keywords: ["Goad", "Treasure", "Scry"],
20+
card_faces: [
21+
{
22+
object: "card_face",
23+
name: "The Initiative",
24+
mana_cost: "",
25+
type_line: "Card",
26+
oracle_text:
27+
"Whenever one or more creatures a player controls deal combat damage to you, that player takes the initiative.\nWhenever you take the initiative and at the beginning of your upkeep, venture into Undercity. (If you're in a dungeon, advance to the next room. If you're not, enter Undercity. You can take the initiative even if you already have it.)",
28+
colors: [],
29+
artist: "Ioannis Fiore",
30+
artist_id: "0af22200-d1b0-41dc-bb3f-386e661c3ad5",
31+
illustration_id: "8b197591-b8b8-47b5-9b0d-ce9d0bcb2ec0",
32+
image_uris: {
33+
small: "https://cards.scryfall.io/small/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
34+
normal: "https://cards.scryfall.io/normal/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
35+
large: "https://cards.scryfall.io/large/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
36+
png: "https://cards.scryfall.io/png/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.png?1676232820",
37+
art_crop: "https://cards.scryfall.io/art_crop/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
38+
border_crop:
39+
"https://cards.scryfall.io/border_crop/front/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
40+
},
41+
},
42+
{
43+
object: "card_face",
44+
name: "Undercity",
45+
flavor_name: "",
46+
mana_cost: "",
47+
type_line: "Dungeon — Undercity",
48+
oracle_text:
49+
'You can\'t enter this dungeon unless you "venture into Undercity."\nSecret Entrance — Search your library for a basic land card, reveal it, put it into your hand, then shuffle. (Leads to: Forge, Lost Well)\nForge — Put two +1/+1 counters on target creature. (Leads to: Trap!, Arena)\nLost Well — Scry 2. (Leads to: Arena, Stash)\nTrap! — Target player loses 5 life. (Leads to: Archives)\nArena — Goad target creature. (Leads to: Archives, Catacombs)\nStash — Create a Treasure token. (Leads to: Catacombs)\nArchives — Draw a card. (Leads to: Throne of the Dead Three)\nCatacombs — Create a 4/1 black Skeleton creature token with menace. (Leads to: Throne of the Dead Three)\nThrone of the Dead Three — Reveal the top ten cards of your library. Put a creature card from among them onto the battlefield with three +1/+1 counters on it. It gains hexproof until your next turn. Then shuffle.',
50+
colors: [],
51+
artist: "Ioannis Fiore",
52+
artist_id: "0af22200-d1b0-41dc-bb3f-386e661c3ad5",
53+
illustration_id: "67f7437e-458e-4b5a-8d51-5d06e93b282f",
54+
image_uris: {
55+
small: "https://cards.scryfall.io/small/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
56+
normal: "https://cards.scryfall.io/normal/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
57+
large: "https://cards.scryfall.io/large/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
58+
png: "https://cards.scryfall.io/png/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.png?1676232820",
59+
art_crop: "https://cards.scryfall.io/art_crop/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
60+
border_crop:
61+
"https://cards.scryfall.io/border_crop/back/2/c/2c65185b-6cf0-451d-985e-56aa45d9a57d.jpg?1676232820",
62+
},
63+
},
64+
],
65+
all_parts: [
66+
{
67+
object: "related_card",
68+
id: "0cbf06f5-d1c7-474c-8f09-72f5ad0c8120",
69+
component: "combo_piece",
70+
name: "Explore the Underdark",
71+
type_line: "Sorcery",
72+
uri: "https://api.scryfall.com/cards/0cbf06f5-d1c7-474c-8f09-72f5ad0c8120",
73+
},
74+
{
75+
object: "related_card",
76+
id: "47a6569e-ab96-4c84-8985-57769be3cc35",
77+
component: "combo_piece",
78+
name: "Ravenloft Adventurer",
79+
type_line: "Creature — Human Rogue Assassin",
80+
uri: "https://api.scryfall.com/cards/47a6569e-ab96-4c84-8985-57769be3cc35",
81+
},
82+
{
83+
object: "related_card",
84+
id: "0c4f76ae-e93b-4ca1-ac62-753707f6319e",
85+
component: "combo_piece",
86+
name: "Trailblazer's Torch",
87+
type_line: "Artifact — Equipment",
88+
uri: "https://api.scryfall.com/cards/0c4f76ae-e93b-4ca1-ac62-753707f6319e",
89+
},
90+
{
91+
object: "related_card",
92+
id: "d06d9d83-d1e6-4499-a1ac-6f865159f6b6",
93+
component: "combo_piece",
94+
name: "Stirring Bard",
95+
type_line: "Creature — Dragon Bard",
96+
uri: "https://api.scryfall.com/cards/d06d9d83-d1e6-4499-a1ac-6f865159f6b6",
97+
},
98+
{
99+
object: "related_card",
100+
id: "ab8324aa-f356-42bc-9664-46803bc8a93b",
101+
component: "combo_piece",
102+
name: "Goliath Paladin",
103+
type_line: "Creature — Giant Knight",
104+
uri: "https://api.scryfall.com/cards/ab8324aa-f356-42bc-9664-46803bc8a93b",
105+
},
106+
{
107+
object: "related_card",
108+
id: "f8ca369b-4e04-4c80-923b-1212183419d8",
109+
component: "combo_piece",
110+
name: "Undercellar Sweep",
111+
type_line: "Enchantment",
112+
uri: "https://api.scryfall.com/cards/f8ca369b-4e04-4c80-923b-1212183419d8",
113+
},
114+
{
115+
object: "related_card",
116+
id: "8aeee54a-5e16-4519-b04a-49eaaf896b9a",
117+
component: "combo_piece",
118+
name: "Passageway Seer",
119+
type_line: "Creature — Tiefling Warlock",
120+
uri: "https://api.scryfall.com/cards/8aeee54a-5e16-4519-b04a-49eaaf896b9a",
121+
},
122+
{
123+
object: "related_card",
124+
id: "d68382cd-da62-4c85-a5b3-3594a3302280",
125+
component: "combo_piece",
126+
name: "Undermountain Adventurer",
127+
type_line: "Creature — Giant Warrior",
128+
uri: "https://api.scryfall.com/cards/d68382cd-da62-4c85-a5b3-3594a3302280",
129+
},
130+
{
131+
object: "related_card",
132+
id: "2c65185b-6cf0-451d-985e-56aa45d9a57d",
133+
component: "combo_piece",
134+
name: "The Initiative // Undercity",
135+
type_line: "Card // Dungeon — Undercity",
136+
uri: "https://api.scryfall.com/cards/2c65185b-6cf0-451d-985e-56aa45d9a57d",
137+
},
138+
{
139+
object: "related_card",
140+
id: "770b988d-4f31-4746-8c23-4ed8d9a6b393",
141+
component: "token",
142+
name: "Treasure",
143+
type_line: "Token Artifact — Treasure",
144+
uri: "https://api.scryfall.com/cards/770b988d-4f31-4746-8c23-4ed8d9a6b393",
145+
},
146+
{
147+
object: "related_card",
148+
id: "6f9de8d1-03f9-491b-8871-d297a0543de9",
149+
component: "combo_piece",
150+
name: "Tomb of Horrors Adventurer",
151+
type_line: "Creature — Elf Monk",
152+
uri: "https://api.scryfall.com/cards/6f9de8d1-03f9-491b-8871-d297a0543de9",
153+
},
154+
{
155+
object: "related_card",
156+
id: "95ec8866-8374-4b17-93db-f3cf9f01fec3",
157+
component: "combo_piece",
158+
name: "White Plume Adventurer",
159+
type_line: "Creature — Orc Cleric",
160+
uri: "https://api.scryfall.com/cards/95ec8866-8374-4b17-93db-f3cf9f01fec3",
161+
},
162+
{
163+
object: "related_card",
164+
id: "c909c8d2-72c3-40b5-a74c-e78b0e8fceda",
165+
component: "combo_piece",
166+
name: "Rilsa Rael, Kingpin",
167+
type_line: "Legendary Creature — Human Rogue",
168+
uri: "https://api.scryfall.com/cards/c909c8d2-72c3-40b5-a74c-e78b0e8fceda",
169+
},
170+
{
171+
object: "related_card",
172+
id: "7fee3f76-20a8-4621-84fb-ddf79c955532",
173+
component: "combo_piece",
174+
name: "Seasoned Dungeoneer",
175+
type_line: "Creature — Human Warrior",
176+
uri: "https://api.scryfall.com/cards/7fee3f76-20a8-4621-84fb-ddf79c955532",
177+
},
178+
{
179+
object: "related_card",
180+
id: "5a470690-a05d-4311-963c-50cbf779846d",
181+
component: "combo_piece",
182+
name: "Sarevok's Tome",
183+
type_line: "Artifact",
184+
uri: "https://api.scryfall.com/cards/5a470690-a05d-4311-963c-50cbf779846d",
185+
},
186+
{
187+
object: "related_card",
188+
id: "a2bf9736-b5f5-4fd4-8406-9f57fefd86e7",
189+
component: "combo_piece",
190+
name: "Underdark Explorer",
191+
type_line: "Creature — Lizard Warrior",
192+
uri: "https://api.scryfall.com/cards/a2bf9736-b5f5-4fd4-8406-9f57fefd86e7",
193+
},
194+
{
195+
object: "related_card",
196+
id: "0669a2bb-11c7-45d8-9299-09246ff4e72c",
197+
component: "combo_piece",
198+
name: "Loot Dispute",
199+
type_line: "Enchantment",
200+
uri: "https://api.scryfall.com/cards/0669a2bb-11c7-45d8-9299-09246ff4e72c",
201+
},
202+
{
203+
object: "related_card",
204+
id: "cf4c245f-af2f-46a7-81f3-670a04940901",
205+
component: "token",
206+
name: "Skeleton",
207+
type_line: "Token Creature — Skeleton",
208+
uri: "https://api.scryfall.com/cards/cf4c245f-af2f-46a7-81f3-670a04940901",
209+
},
210+
{
211+
object: "related_card",
212+
id: "0bdf1222-2fc5-4dae-a7a5-6ba774b02843",
213+
component: "combo_piece",
214+
name: "Bloodboil Sorcerer",
215+
type_line: "Creature — Human Shaman",
216+
uri: "https://api.scryfall.com/cards/0bdf1222-2fc5-4dae-a7a5-6ba774b02843",
217+
},
218+
{
219+
object: "related_card",
220+
id: "20f939d8-3d41-4d8b-baea-7f022104c704",
221+
component: "combo_piece",
222+
name: "Vicious Battlerager",
223+
type_line: "Creature — Dwarf Barbarian",
224+
uri: "https://api.scryfall.com/cards/20f939d8-3d41-4d8b-baea-7f022104c704",
225+
},
226+
{
227+
object: "related_card",
228+
id: "2a83882c-3e03-4e85-aaac-97fa1d08a772",
229+
component: "combo_piece",
230+
name: "Aarakocra Sneak",
231+
type_line: "Creature — Bird Rogue",
232+
uri: "https://api.scryfall.com/cards/2a83882c-3e03-4e85-aaac-97fa1d08a772",
233+
},
234+
{
235+
object: "related_card",
236+
id: "aa74e656-480a-4c1b-963d-1b207075c27f",
237+
component: "combo_piece",
238+
name: "Dungeoneer's Pack",
239+
type_line: "Artifact",
240+
uri: "https://api.scryfall.com/cards/aa74e656-480a-4c1b-963d-1b207075c27f",
241+
},
242+
{
243+
object: "related_card",
244+
id: "08737950-4662-4d36-a1ea-6fd87e38c02b",
245+
component: "combo_piece",
246+
name: "From the Catacombs",
247+
type_line: "Sorcery",
248+
uri: "https://api.scryfall.com/cards/08737950-4662-4d36-a1ea-6fd87e38c02b",
249+
},
250+
{
251+
object: "related_card",
252+
id: "f4072640-0f9b-4f0a-84cc-eda415cc92e7",
253+
component: "combo_piece",
254+
name: "Avenging Hunter",
255+
type_line: "Creature — Dragon Ranger",
256+
uri: "https://api.scryfall.com/cards/f4072640-0f9b-4f0a-84cc-eda415cc92e7",
257+
},
258+
{
259+
object: "related_card",
260+
id: "e909fe36-e95c-4094-9029-a292a8fcf73a",
261+
component: "combo_piece",
262+
name: "Caves of Chaos Adventurer",
263+
type_line: "Creature — Human Barbarian",
264+
uri: "https://api.scryfall.com/cards/e909fe36-e95c-4094-9029-a292a8fcf73a",
265+
},
266+
{
267+
object: "related_card",
268+
id: "c959ab97-0727-4589-bfd9-d78dd8ebd86b",
269+
component: "combo_piece",
270+
name: "Feywild Caretaker",
271+
type_line: "Creature — Orc Wizard",
272+
uri: "https://api.scryfall.com/cards/c959ab97-0727-4589-bfd9-d78dd8ebd86b",
273+
},
274+
],
275+
legalities: {
276+
standard: "not_legal",
277+
future: "not_legal",
278+
historic: "not_legal",
279+
gladiator: "not_legal",
280+
pioneer: "not_legal",
281+
explorer: "not_legal",
282+
modern: "not_legal",
283+
legacy: "not_legal",
284+
pauper: "not_legal",
285+
vintage: "not_legal",
286+
penny: "not_legal",
287+
commander: "not_legal",
288+
oathbreaker: "not_legal",
289+
brawl: "not_legal",
290+
historicbrawl: "not_legal",
291+
alchemy: "not_legal",
292+
paupercommander: "not_legal",
293+
duel: "not_legal",
294+
oldschool: "not_legal",
295+
premodern: "not_legal",
296+
predh: "not_legal",
297+
},
298+
games: ["paper"],
299+
reserved: false,
300+
foil: true,
301+
nonfoil: true,
302+
finishes: ["nonfoil", "foil"],
303+
oversized: false,
304+
promo: false,
305+
reprint: false,
306+
variation: false,
307+
set_id: "942706db-55db-4d8b-8337-deca3a4b522c",
308+
set: "tclb",
309+
set_name: "Battle for Baldur's Gate Tokens",
310+
set_type: "token",
311+
set_uri: "https://api.scryfall.com/sets/942706db-55db-4d8b-8337-deca3a4b522c",
312+
set_search_uri: "https://api.scryfall.com/cards/search?order=set&q=e%3Atclb&unique=prints",
313+
scryfall_set_uri: "https://scryfall.com/sets/tclb?utm_source=api",
314+
rulings_uri: "https://api.scryfall.com/cards/2c65185b-6cf0-451d-985e-56aa45d9a57d/rulings",
315+
prints_search_uri:
316+
"https://api.scryfall.com/cards/search?order=released&q=oracleid%3A36b61021-72f0-4c22-a41d-9b2f093d7ca8&unique=prints",
317+
collector_number: "20",
318+
digital: false,
319+
rarity: "common",
320+
artist: "Ioannis Fiore",
321+
artist_ids: ["0af22200-d1b0-41dc-bb3f-386e661c3ad5"],
322+
border_color: "black",
323+
frame: "2015",
324+
frame_effects: ["inverted"],
325+
full_art: false,
326+
textless: false,
327+
booster: false,
328+
story_spotlight: false,
329+
preview: {
330+
source: "Wizards of the Coast",
331+
source_uri: "https://www.twitch.tv/videos/1486418408",
332+
previewed_at: "2022-05-17",
333+
},
334+
prices: {
335+
usd: null,
336+
usd_foil: null,
337+
usd_etched: null,
338+
eur: null,
339+
eur_foil: null,
340+
tix: null,
341+
},
342+
related_uris: {
343+
tcgplayer_infinite_articles:
344+
"https://infinite.tcgplayer.com/search?contentMode=article&game=magic&partner=scryfall&q=The+Initiative+%2F%2F+Undercity&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall",
345+
tcgplayer_infinite_decks:
346+
"https://infinite.tcgplayer.com/search?contentMode=deck&game=magic&partner=scryfall&q=The+Initiative+%2F%2F+Undercity&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall",
347+
edhrec: "https://edhrec.com/route/?cc=The+Initiative+%2F%2F+Undercity",
348+
},
349+
purchase_uris: {
350+
tcgplayer:
351+
"https://www.tcgplayer.com/search/magic/product?productLineName=magic&q=The+Initiative+%2F%2F+Undercity&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall&view=grid",
352+
cardmarket:
353+
"https://www.cardmarket.com/en/Magic/Products/Search?referrer=scryfall&searchString=The+Initiative+%2F%2F+Undercity&utm_campaign=card_prices&utm_medium=text&utm_source=scryfall",
354+
cardhoarder:
355+
"https://www.cardhoarder.com/cards?affiliate_id=scryfall&data%5Bsearch%5D=The+Initiative+%2F%2F+Undercity&ref=card-profile&utm_campaign=affiliate&utm_medium=card&utm_source=scryfall",
356+
},
357+
};

‎__test__/Card/layouts/Normal/Other/Dungeon.ts

+422
Large diffs are not rendered by default.

‎__test__/Card/layouts/Token/Monarch.ts

+448
Large diffs are not rendered by default.

‎__test__/Card/localized/Phyrexian.ts

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { ScryfallCard } from "src";
2+
3+
const PhyrexianArena: ScryfallCard.Any = {
4+
object: "card",
5+
id: "3b18d219-efde-4cc0-b955-cb71ead88023",
6+
oracle_id: "ee579a32-a048-4335-b966-231ba731cdea",
7+
multiverse_ids: [604746],
8+
tcgplayer_id: 479647,
9+
cardmarket_id: 694789,
10+
name: "Phyrexian Arena",
11+
printed_name: "|fyrs,CebDZFst.",
12+
lang: "ph",
13+
released_at: "2023-02-03",
14+
uri: "https://api.scryfall.com/cards/3b18d219-efde-4cc0-b955-cb71ead88023",
15+
scryfall_uri: "https://scryfall.com/card/one/283/%7Cfyrscebdzfst?utm_source=api",
16+
layout: "normal",
17+
highres_image: true,
18+
image_status: "highres_scan",
19+
image_uris: {
20+
small: "https://cards.scryfall.io/small/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.jpg?1689411727",
21+
normal: "https://cards.scryfall.io/normal/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.jpg?1689411727",
22+
large: "https://cards.scryfall.io/large/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.jpg?1689411727",
23+
png: "https://cards.scryfall.io/png/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.png?1689411727",
24+
art_crop: "https://cards.scryfall.io/art_crop/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.jpg?1689411727",
25+
border_crop: "https://cards.scryfall.io/border_crop/front/3/b/3b18d219-efde-4cc0-b955-cb71ead88023.jpg?1689411727",
26+
},
27+
mana_cost: "{1}{B}{B}",
28+
cmc: 3.0,
29+
type_line: "Enchantment",
30+
printed_type_line: "|myZJ.",
31+
oracle_text: "At the beginning of your upkeep, you draw a card and you lose 1 life.",
32+
printed_text: "|besYf,dceb&CpOnYA DEEstiYDC,co,GvEng mpreLYv,cosF,LFr1 QYCOt.",
33+
colors: ["B"],
34+
color_identity: ["B"],
35+
keywords: [],
36+
legalities: {
37+
standard: "legal",
38+
future: "legal",
39+
historic: "legal",
40+
gladiator: "legal",
41+
pioneer: "legal",
42+
explorer: "legal",
43+
modern: "legal",
44+
legacy: "legal",
45+
pauper: "not_legal",
46+
vintage: "legal",
47+
penny: "legal",
48+
commander: "legal",
49+
oathbreaker: "legal",
50+
brawl: "legal",
51+
historicbrawl: "legal",
52+
alchemy: "legal",
53+
paupercommander: "not_legal",
54+
duel: "legal",
55+
oldschool: "not_legal",
56+
premodern: "legal",
57+
predh: "legal",
58+
},
59+
games: ["paper", "mtgo", "arena"],
60+
reserved: false,
61+
foil: true,
62+
nonfoil: false,
63+
finishes: ["foil"],
64+
oversized: false,
65+
promo: true,
66+
reprint: true,
67+
variation: false,
68+
set_id: "04bef644-343f-4230-95ee-255f29aa67a2",
69+
set: "one",
70+
set_name: "Phyrexia: All Will Be One",
71+
set_type: "expansion",
72+
set_uri: "https://api.scryfall.com/sets/04bef644-343f-4230-95ee-255f29aa67a2",
73+
set_search_uri: "https://api.scryfall.com/cards/search?order=set&q=e%3Aone&unique=prints",
74+
scryfall_set_uri: "https://scryfall.com/sets/one?utm_source=api",
75+
rulings_uri: "https://api.scryfall.com/cards/3b18d219-efde-4cc0-b955-cb71ead88023/rulings",
76+
prints_search_uri:
77+
"https://api.scryfall.com/cards/search?order=released&q=oracleid%3Aee579a32-a048-4335-b966-231ba731cdea&unique=prints",
78+
collector_number: "283",
79+
digital: false,
80+
rarity: "rare",
81+
watermark: "phyrexian",
82+
card_back_id: "0aeebaf5-8c7d-4636-9e82-8c27447861f7",
83+
artist: "Martina Fačková",
84+
artist_ids: ["6338124e-8e53-498d-8bf9-93a55db2f61c"],
85+
illustration_id: "282c97de-1967-4d6c-924d-6d139eb70b93",
86+
border_color: "black",
87+
frame: "2015",
88+
security_stamp: "oval",
89+
full_art: false,
90+
textless: false,
91+
booster: false,
92+
story_spotlight: false,
93+
promo_types: ["bundle"],
94+
edhrec_rank: 110,
95+
penny_rank: 175,
96+
preview: {
97+
source: "Wizards of the Coast",
98+
source_uri: "https://www.twitch.tv/videos/1710211245",
99+
previewed_at: "2023-01-17",
100+
},
101+
prices: {
102+
usd: null,
103+
usd_foil: "1.54",
104+
usd_etched: null,
105+
eur: null,
106+
eur_foil: "3.76",
107+
tix: null,
108+
},
109+
related_uris: {
110+
gatherer: "https://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=604746",
111+
tcgplayer_infinite_articles:
112+
"https://infinite.tcgplayer.com/search?contentMode=article&game=magic&partner=scryfall&q=Phyrexian+Arena&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall",
113+
tcgplayer_infinite_decks:
114+
"https://infinite.tcgplayer.com/search?contentMode=deck&game=magic&partner=scryfall&q=Phyrexian+Arena&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall",
115+
edhrec: "https://edhrec.com/route/?cc=Phyrexian+Arena",
116+
},
117+
purchase_uris: {
118+
tcgplayer:
119+
"https://www.tcgplayer.com/product/479647?page=1&utm_campaign=affiliate&utm_medium=api&utm_source=scryfall",
120+
cardmarket:
121+
"https://www.cardmarket.com/en/Magic/Products/Search?referrer=scryfall&searchString=Phyrexian+Arena&utm_campaign=card_prices&utm_medium=text&utm_source=scryfall",
122+
cardhoarder:
123+
"https://www.cardhoarder.com/cards?affiliate_id=scryfall&data%5Bsearch%5D=Phyrexian+Arena&ref=card-profile&utm_campaign=affiliate&utm_medium=card&utm_source=scryfall",
124+
},
125+
};
File renamed without changes.

‎__test__/Symbology/ManaCost.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ScryfallManaCost } from "src";
2+
3+
const _RUX: ScryfallManaCost = {
4+
object: "mana_cost",
5+
cost: "{X}{U}{R}",
6+
colors: ["U", "R"],
7+
cmc: 2,
8+
colorless: false,
9+
monocolored: false,
10+
multicolored: true,
11+
};
12+
13+
const _8CC: ScryfallManaCost = {
14+
object: "mana_cost",
15+
cost: "{8}{C}{C}",
16+
colors: [],
17+
cmc: 10.0,
18+
colorless: true,
19+
monocolored: false,
20+
multicolored: false,
21+
};
22+
23+
const _WUBRG: ScryfallManaCost = {
24+
object: "mana_cost",
25+
cost: "{W}{U}{B}{R}{G}",
26+
colors: ["W", "U", "B", "R", "G"],
27+
cmc: 5.0,
28+
colorless: false,
29+
monocolored: false,
30+
multicolored: true,
31+
};
32+
33+
const _3gg: ScryfallManaCost = {
34+
object: "mana_cost",
35+
cost: "{3}{G}{G}",
36+
colors: ["G"],
37+
cmc: 5.0,
38+
colorless: false,
39+
monocolored: true,
40+
multicolored: false,
41+
};

‎package.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@
88
"test:lib": "tsc -p tsconfig.lib.json --noEmit",
99
"test:tests": "tsc -p tsconfig.test.json --noEmit --isolatedModules"
1010
},
11+
"files": [
12+
"index.ts",
13+
"src/**/*"
14+
],
15+
"author": "scarletcs",
16+
"license": "MIT",
17+
"homepage": "https://github.com/scryfall/api-types#readme",
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/scryfall/api-types.git"
21+
},
22+
"bugs": {
23+
"url": "https://github.com/scryfall/api-types/issues"
24+
},
1125
"keywords": [
1226
"scryfall",
1327
"api",
1428
"types",
1529
"typescript"
1630
],
17-
"author": "scarletcs",
18-
"license": "MIT",
1931
"devDependencies": {
2032
"@typescript-eslint/eslint-plugin": "^6.7.4",
2133
"@typescript-eslint/parser": "^6.7.4",

‎src/objects/Card/Card.ts

+10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ type Layout<T extends ScryfallLayout> = Pick<ScryfallCardFields.Core.All, "layou
88
};
99

1010
/**
11+
* A collection of types representing Scryfall cards of each possible layout.
1112
*
13+
* @see {@link https://scryfall.com/docs/api/cards}
14+
* @see {@link https://scryfall.com/docs/api/layouts}
1215
*/
1316
export namespace ScryfallCard {
1417
/** The abstract root implementation of cards. */
@@ -124,6 +127,13 @@ export namespace ScryfallCard {
124127
ScryfallCardFields.Print.RootProperties &
125128
ScryfallCardFields.Print.CardSpecific;
126129

130+
/**
131+
* A card with an indeterminate layout.
132+
*
133+
* An object of this value may be any card at all.
134+
*
135+
* Since this may be of any layout, common fields are available, but layout-specific fields (e.g. card_faces) will be unavailable until you perform type narrowing on
136+
*/
127137
export type Any =
128138
| Normal
129139
| Meld

‎src/objects/Card/CardFace.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { ScryfallObject } from "../Object";
22
import { ScryfallCardFields } from "./CardFields";
33

4+
/**
5+
* A collection of types representing card faces of each possible type.
6+
*
7+
* @see {@link https://scryfall.com/docs/api/layouts#card-faces}
8+
*/
49
export namespace ScryfallCardFace {
10+
/**
11+
* The abstract root implementation of card faces.
12+
*/
513
export type AbstractCardFace = ScryfallObject.Object<ScryfallObject.ObjectType.CardFace>;
614

715
/**

‎src/objects/Card/CardFields.ts

+24-46
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
import {
2-
ScryfallFormat,
3-
ScryfallLegalityLike,
4-
ScryfallLanguageCodeLike,
5-
ScryfallLayoutLike,
6-
ScryfallColors,
7-
ScryfallImageSize,
8-
ScryfallBorderColorLike,
92
ScryfallBasicFinishLike,
3+
ScryfallBorderColorLike,
4+
ScryfallColors,
5+
ScryfallFormat,
106
ScryfallFrameEffectLike,
117
ScryfallFrameLike,
128
ScryfallGameLike,
139
ScryfallImageStatusLike,
10+
ScryfallImageUris,
11+
ScryfallLanguageCodeLike,
12+
ScryfallLayoutLike,
13+
ScryfallLegalityLike,
14+
ScryfallPrices,
1415
ScryfallPromoType,
16+
ScryfallPurchaseUris,
1517
ScryfallRarityLike,
18+
ScryfallRelatedUris,
1619
ScryfallSecurityStampLike,
1720
} from "./values";
1821
import { ScryfallCardFace } from "./CardFace";
1922
import { Uuid, Uri, Integer, Decimal, IsoDate } from "../../internal";
2023
import { SetTypeLike } from "../Set/values";
2124
import { ScryfallRelatedCard } from "./RelatedCard";
25+
import { ScryfallManaTypes } from "./values/ManaType";
2226

2327
type LegalityRecord = Record<ScryfallFormat, ScryfallLegalityLike>;
2428

29+
/**
30+
* A collection of types related to each possible card field.
31+
*/
2532
export namespace ScryfallCardFields {}
2633

2734
export namespace ScryfallCardFields.Core {
@@ -32,7 +39,11 @@ export namespace ScryfallCardFields.Core {
3239
oracle_id: Uuid;
3340
/** A language code for this printing. */
3441
lang: ScryfallLanguageCodeLike;
35-
/** A code for this card’s layout. */
42+
/**
43+
* A code for this card’s layout.
44+
*
45+
* @see {@link https://scryfall.com/docs/api/layouts}
46+
*/
3647
layout: ScryfallLayoutLike;
3748
/** A link to where you can begin paginating all re/prints for this card on Scryfall’s API. */
3849
prints_search_uri: Uri;
@@ -171,7 +182,7 @@ export namespace ScryfallCardFields.Gameplay {
171182
/** This card’s rank/popularity on Penny Dreadful. Not all cards are ranked. */
172183
penny_rank?: Integer;
173184
/** Colors of mana that this card could produce. */
174-
produced_mana?: ScryfallColors;
185+
produced_mana?: ScryfallManaTypes;
175186
/** True if this card is on the Reserved List. */
176187
reserved: boolean;
177188
/** The type line of this card. */
@@ -189,39 +200,6 @@ export namespace ScryfallCardFields.Print {
189200
source: string;
190201
};
191202

192-
// URIs for various image sizes of this card.
193-
type ImageUris = Record<ScryfallImageSize, Uri>;
194-
195-
// Card prices.
196-
type Prices = {
197-
usd: string | null;
198-
usd_foil: string | null;
199-
usd_etched: string | null;
200-
eur: string | null;
201-
eur_foil: string | null;
202-
tix: string | null;
203-
};
204-
205-
type PurchaseUris = {
206-
/** This card's purchase page on TCGPlayer. */
207-
tcgplayer: Uri;
208-
/** This card's purchase page on Cardmarket. Often inexact due to how Cardmarket links work. */
209-
cardmarket: Uri;
210-
/** This card's purchase page on Cardhoarder. */
211-
cardhoarder: Uri;
212-
};
213-
214-
type RelatedUris = {
215-
/** This card's Gatherer page. */
216-
gatherer?: Uri;
217-
/** TCGPlayer Infinite articles related to this card. */
218-
tcgplayer_infinite_articles?: Uri;
219-
/** TCGPlayer Infinite decks with this card. */
220-
tcgplayer_infinite_decks?: Uri;
221-
/** EDHREC's page for this card. */
222-
edhrec?: Uri;
223-
};
224-
225203
export type RootProperties = {
226204
/**
227205
* Whether the card is foil.
@@ -277,17 +255,17 @@ export namespace ScryfallCardFields.Print {
277255
/** True if this card is oversized. */
278256
oversized: boolean;
279257
/** An object containing daily price information for this card, including usd, usd_foil, usd_etched, eur, eur_foil, eur_etched, and tix prices, as strings. */
280-
prices: Prices;
258+
prices: ScryfallPrices;
281259
/** True if this card is a promotional print. */
282260
promo: boolean;
283261
/** An array of strings describing what categories of promo cards this card falls into. */
284262
promo_types?: ScryfallPromoType[];
285263
/** An object providing URIs to this card’s listing on major marketplaces. Omitted if the card is unpurchaseable. */
286-
purchase_uris?: PurchaseUris;
264+
purchase_uris?: ScryfallPurchaseUris;
287265
/** This card’s rarity. */
288266
rarity: ScryfallRarityLike;
289267
/** An object providing URIs to this card’s listing on other Magic: The Gathering online resources. */
290-
related_uris: RelatedUris;
268+
related_uris: ScryfallRelatedUris;
291269
/** The date this card was first released. */
292270
released_at: IsoDate;
293271
/** True if this card is a reprint. */
@@ -332,7 +310,7 @@ export namespace ScryfallCardFields.Print {
332310
*/
333311
export type CardSideSpecific = {
334312
/** An object listing available imagery for this card. See the Card Imagery article for more information. */
335-
image_uris?: ImageUris;
313+
image_uris?: ScryfallImageUris;
336314
};
337315

338316
/**

‎src/objects/Card/RelatedCard.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { ScryfallObject } from "../Object";
22
import { Uri, Uuid } from "../../internal";
33

4+
/**
5+
* A related card entry.
6+
*/
47
export type ScryfallRelatedCard = ScryfallObject.Object<ScryfallObject.ObjectType.RelatedCard> & {
58
/**
69
* An unique ID for this card in Scryfall’s database.
710
*/
811
id: Uuid;
912
/**
10-
* A field explaining what role this card plays in this relationship, one of token, meld_part, meld_result, or combo_piece.
13+
* A field explaining what role this card plays in this relationship.
1114
*/
1215
component: "token" | "meld_part" | "meld_result" | "combo_piece";
1316
/**

‎src/objects/Card/values/ImageUris.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Uri } from "src/internal";
2+
import { ScryfallImageSize } from "./ImageSize";
3+
4+
/**
5+
* URIs for various image sizes of this card.
6+
*/
7+
export type ScryfallImageUris = Record<ScryfallImageSize, Uri>;

‎src/objects/Card/values/ManaType.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
enum ScryfallManaType {
2+
White = "W",
3+
Blue = "U",
4+
Black = "B",
5+
Red = "R",
6+
Green = "G",
7+
Colorless = "C",
8+
}
9+
10+
export type ScryfallManaTypeLike = ScryfallManaType | `${ScryfallManaType}`;
11+
12+
export type ScryfallManaTypes = ScryfallManaTypeLike[];

‎src/objects/Card/values/Prices.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Prices for a card in various treatments.
3+
*/
4+
export type ScryfallPrices = {
5+
usd: string | null;
6+
usd_foil: string | null;
7+
usd_etched: string | null;
8+
eur: string | null;
9+
eur_foil: string | null;
10+
tix: string | null;
11+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Uri } from "src/internal";
2+
3+
/**
4+
* Possible purchase URIs for a card.
5+
*/
6+
export type ScryfallPurchaseUris = {
7+
/** This card's purchase page on TCGPlayer. */
8+
tcgplayer: Uri;
9+
/** This card's purchase page on Cardmarket. Often inexact due to how Cardmarket links work. */
10+
cardmarket: Uri;
11+
/** This card's purchase page on Cardhoarder. */
12+
cardhoarder: Uri;
13+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Uri } from "src/internal";
2+
3+
/**
4+
* Related URIs for a card.
5+
*/
6+
export type ScryfallRelatedUris = {
7+
/** This card's Gatherer page. */
8+
gatherer?: Uri;
9+
/** TCGPlayer Infinite articles related to this card. */
10+
tcgplayer_infinite_articles?: Uri;
11+
/** TCGPlayer Infinite decks with this card. */
12+
tcgplayer_infinite_decks?: Uri;
13+
/** EDHREC's page for this card. */
14+
edhrec?: Uri;
15+
};

‎src/objects/Card/values/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
export * from "./BorderColor";
22
export * from "./Color";
33
export * from "./Finishes";
4+
export * from "./Format";
45
export * from "./Frame";
56
export * from "./FrameEffect";
67
export * from "./Game";
78
export * from "./ImageSize";
89
export * from "./ImageStatus";
9-
export * from "./Format";
10+
export * from "./ImageUris";
1011
export * from "./LanguageCode";
1112
export * from "./Layout";
1213
export * from "./Legality";
14+
export * from "./ManaType";
15+
export * from "./Prices";
1316
export * from "./PrintAttribute";
17+
export * from "./PurchaseUris";
1418
export * from "./Rarity";
19+
export * from "./RelatedUris";
1520
export * from "./SecurityStamp";

‎src/objects/Catalog/Catalog.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { ScryfallObject } from "../Object";
22
import { Uri, Integer } from "../../internal";
33

4+
/**
5+
* A catalog of values.
6+
*
7+
* @see {@link https://scryfall.com/docs/api/catalogs}
8+
*/
49
export type ScryfallCatalog = ScryfallObject.Object<ScryfallObject.ObjectType.Catalog> & {
510
/** A link to the current catalog on Scryfall’s API */
611
uri: Uri;

‎src/objects/Error/Error.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { ScryfallObject } from "../Object";
22
import { Integer } from "../../internal";
33

4+
/**
5+
* An error response from the Scryfall API.
6+
*
7+
* Scryfall API responses may return this if something goes wrong.
8+
*
9+
* @see {@link https://scryfall.com/docs/api/errors}
10+
*/
411
export type ScryfallError = ScryfallObject.Object<ScryfallObject.ObjectType.Error> & {
512
/**
613
* An integer HTTP status code for this error.

‎src/objects/List/List.ts

+34
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { ScryfallRuling } from "../Ruling";
66
import { ScryfallSet } from "../Set";
77
import { ScryfallCardSymbol } from "../Symbology";
88

9+
/**
10+
* A list of Scryfall objects.
11+
*
12+
* @see {@link https://scryfall.com/docs/api/lists}
13+
*/
914
export namespace ScryfallList {
1015
/**
1116
* A list of objects of type T.
@@ -55,9 +60,38 @@ export namespace ScryfallList {
5560
total_cards?: undefined;
5661
});
5762

63+
/**
64+
* A list of cards.
65+
*
66+
* @see {@link ScryfallCard}
67+
*/
5868
export type Cards = List<ScryfallCard.Any>;
69+
70+
/**
71+
* A list of sets.
72+
*
73+
* @see {@link ScryfallSet}
74+
*/
5975
export type Sets = List<ScryfallSet>;
76+
77+
/**
78+
* A list of rulings.
79+
*
80+
* @see {@link ScryfallRuling}
81+
*/
6082
export type Rulings = List<ScryfallRuling>;
83+
84+
/**
85+
* A list of card symbols.
86+
*
87+
* @see {@link ScryfallCardSymbol}
88+
*/
6189
export type CardSymbols = List<ScryfallCardSymbol>;
90+
91+
/**
92+
* A list of migrations.
93+
*
94+
* @see {@link ScryfallMigration}
95+
*/
6296
export type Migrations = List<ScryfallMigration>;
6397
}

‎src/objects/Migration/Migration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export enum ScryfallMigrationStrategy {
88

99
export type ScryfallMigrationStrategyLike = ScryfallMigrationStrategy | `${ScryfallMigrationStrategy}`;
1010

11+
/**
12+
* A data migration.
13+
*
14+
* @see {@link https://scryfall.com/docs/api/migrations}
15+
*/
1116
export type ScryfallMigration = ScryfallObject.Object<ScryfallObject.ObjectType.Migration> & {
1217
/** A link to the current object on Scryfall's API */
1318
uri: Uri;

‎src/objects/Object/Object.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
export namespace ScryfallObject {
2+
/**
3+
* The type of object.
4+
*/
25
export enum ObjectType {
36
/**
47
* A card.
@@ -48,6 +51,9 @@ export namespace ScryfallObject {
4851

4952
export type ObjectTypeLike = ObjectType | `${ObjectType}`;
5053

54+
/**
55+
* The abstract base type of Scryfall objects.
56+
*/
5157
export type Object<T extends ObjectType> = {
5258
/** A content type for this object. */
5359
object: T | `${T}`;

‎src/objects/Ruling/Ruling.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { ScryfallObject } from "../Object";
22
import { IsoDate, Uuid } from "../../internal";
33

4+
/**
5+
* Rulings made on a card by the rules manager.
6+
*
7+
* @see {@link https://scryfall.com/docs/api/rulings}
8+
*/
49
export type ScryfallRuling = ScryfallObject.Object<ScryfallObject.ObjectType.Ruling> & {
510
/**
611
* The Oracle ID of the card this ruling is associated with.

‎src/objects/Set/Set.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { ScryfallObject } from "../Object";
22
import { Uuid, Integer, Uri, IsoDate } from "../../internal";
33
import { SetTypeLike } from "./values";
44

5+
/**
6+
* Description of a Magic card set.
7+
*
8+
* @see {@link https://scryfall.com/docs/api/sets}
9+
*/
510
export type ScryfallSet = ScryfallObject.Object<ScryfallObject.ObjectType.Set> & {
611
/**
712
* A unique ID for this set on Scryfall that will not change.

‎src/objects/Set/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export * from "./Set";
2+
3+
export * from "./values";

‎src/objects/Symbology/CardSymbol.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { ScryfallObject } from "../Object";
22
import { Decimal, Uri } from "../../internal";
33
import { ScryfallColors } from "../Card/values";
44

5+
/**
6+
* Description of a card symbol.
7+
*
8+
* @see {@link https://scryfall.com/docs/api/card-symbols}
9+
*/
510
export type ScryfallCardSymbol = ScryfallObject.Object<ScryfallObject.ObjectType.CardSymbol> & {
611
/**
712
* The plaintext symbol. Often surrounded with curly braces {}. Note that not all symbols are ASCII text (for example, {∞}).

‎src/objects/Symbology/ManaCost.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { ScryfallObject } from "../Object";
22
import { Decimal } from "../../internal";
33
import { ScryfallColors } from "../Card/values";
44

5+
/**
6+
* Description of a mana cost.
7+
*
8+
* @see {@link https://scryfall.com/docs/api/card-symbols/parse-mana}
9+
*/
510
export type ScryfallManaCost = ScryfallObject.Object<ScryfallObject.ObjectType.ManaCost> & {
611
/**
712
* The normalized cost, with correctly-ordered and wrapped mana symbols

0 commit comments

Comments
 (0)
Please sign in to comment.