Skip to content

Commit

Permalink
v4.2.0, add Catalog.supertypes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiriVulpes committed Oct 22, 2023
1 parent 1f86352 commit 37f633e
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v4.2.0 (October 23rd, 2023)
- Fixed [Cards.search](./DOCUMENTATION.md#cardssearch-query-string-options-searchoptions--number-magicemittercard-) not working with an explicit page number, thanks to [thejoecode](https://github.com/thejoecode) via [#68](https://github.com/ChiriVulpes/scryfall-sdk/pull/68).
- Workaround some bundlers [doing dumb things still](https://github.com/ChiriVulpes/scryfall-sdk/issues/65)
- Added many missing or modified fields returned by Scryfall.
- Added support for [Catalog.supertypes](./DOCUMENTATION#catalogsupertypes--promisestring-)

# v4.1.1 (February 25th, 2023)
- Workaround some bundlers [doing dumb things](https://github.com/ChiriVulpes/scryfall-sdk/issues/61)

Expand Down
8 changes: 8 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
- [`Catalog.keywordAbilities (): Promise<string[]>;` ](#catalogkeywordabilities--promisestring-)
- [`Catalog.keywordActions (): Promise<string[]>;` ](#catalogkeywordactions--promisestring-)
- [`Catalog.abilityWords (): Promise<string[]>;` ](#catalogabilitywords--promisestring-)
- [`Catalog.supertypes (): Promise<string[]>;` ](#catalogsupertypes--promisestring-)
- [Bulk Data](#bulk-data-)
- [`BulkData.downloadByType (type: BulkDataType): Promise<Stream | undefined>;`](#bulkdatadownloadbytype-type-bulkdatatype-promisestream--undefined-)
- [`BulkData.downloadById (id: string): Promise<Stream | undefined>;`](#bulkdatadownloadbyid-id-string-promisestream--undefined-)
Expand Down Expand Up @@ -640,6 +641,13 @@ const abilityWords = await Scry.Catalog.abilityWords();
console.log(abilityWords.length); // 49
```

### `Catalog.supertypes (): Promise<string[]>;` [🡅](#table-of-contents)

```ts
const supertypes = await Scry.Catalog.supertypes();
console.log(supertypes.length); // 7
```


## Bulk Data [🡅](#table-of-contents)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

A Node.js SDK for [Scryfall](https://scryfall.com/docs/api) written in Typescript.

As of [February 2nd, 2023](./CHANGELOG.md), 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!
As of [October 23rd, 2023](./CHANGELOG.md), 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!


## Installation
Expand Down
1 change: 1 addition & 0 deletions ROUTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
| [`/catalog/keyword-abilities`](./DOCUMENTATION.md#catalogwatermarks--promisestring-) | Catalog |
| [`/catalog/keyword-actions`](./DOCUMENTATION.md#catalogwatermarks--promisestring-) | Catalog |
| [`/catalog/ability-words`](./DOCUMENTATION.md#catalogwatermarks--promisestring-) | Catalog |
| [`/catalog/supertypes`](./DOCUMENTATION.md#catalogsupertypes--promisestring-) | Catalog |
| [`/bulk-data`](./DOCUMENTATION.md#bulkdatadefinitions--promisebulkdatadefinition-) | List\<BulkDataDefinition\> |
| [`/bulk-data/:type`](./DOCUMENTATION.md#bulkdatadefinitionbytype-type-bulkdatatype-promisebulkdatadefinition-) | BulkDataDefinition |
| [`/bulk-data/:id`](./DOCUMENTATION.md#bulkdatadefinitionbyid-id-string-promisebulkdatadefinition-) | BulkDataDefinition |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scryfall-sdk",
"version": "4.1.1",
"version": "4.2.0",
"main": "./out/Scry.js",
"types": "./out/Scry.d.ts",
"description": "A Node.js SDK for https://scryfall.com/docs/api written in Typescript.",
Expand Down
6 changes: 3 additions & 3 deletions src/api/BulkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export interface BulkDataDefinition {
object: "bulk_data";

id: string;
type: BulkDataType;
updated_at: string;
uri: string;
type: BulkDataType;
name: string;
description: string;
size: number;
download_uri: string;
updated_at: string;
size: number;
content_type: string;
content_encoding: string;
}
Expand Down
42 changes: 33 additions & 9 deletions src/api/Cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export enum FrameEffect {
moonreversemoondfc,
showcase,
extendedart,
companion,
etched,
snow,
lesson,
shatteredglass,
convertdfc,
fandfc,
upsidedowndfc,
}

export enum Game {
Expand Down Expand Up @@ -120,15 +128,22 @@ export enum Format {
standard,
future,
historic,
gladiator,
pioneer,
explorer,
modern,
legacy,
pauper,
vintage,
penny,
commander,
oathbreaker,
brawl,
historicbrawl,
alchemy,
paupercommander,
duel,
premodern,
oldschool,
}

Expand Down Expand Up @@ -211,13 +226,15 @@ export interface CardFace extends CardFaceMethods {
object: "card_face";

artist?: string | null;
artist_id?: string | null;
cmc?: number | null;
color_indicator?: Color[] | null;
colors?: Color[] | null;
defense?: string | null;
flavor_text?: string | null;
illustration_id?: string | null;
image_uris?: ImageUris | null;
layout?: string;
layout?: string | null;
loyalty?: string | null;
mana_cost?: string | null;
name: string;
Expand All @@ -228,7 +245,7 @@ export interface CardFace extends CardFaceMethods {
printed_text?: string | null;
printed_type_line?: string | null;
toughness?: string | null;
type_line: string;
type_line?: string | null;
watermark?: string | null;
}

Expand Down Expand Up @@ -292,7 +309,9 @@ export enum CardSecurityStamp {
oval,
triangle,
acorn,
circle,
arena,
heart,
}

export interface CardIdentifier {
Expand Down Expand Up @@ -369,6 +388,8 @@ function transform (self: Card,

export type Modifier = `+${bigint}` | `-${bigint}`;

export type AttractionLight = 1 | 2 | 3 | 4 | 5 | 6;

export class Card implements CardFaceMethods {
object: "card";

Expand All @@ -383,6 +404,7 @@ export class Card implements CardFaceMethods {
tcgplayer_etched_id?: number | null;
cardmarket_id?: number | null;
oracle_id: string;
layout: keyof typeof Layout;
prints_search_uri: string;
rulings_uri: string;
scryfall_uri: string;
Expand All @@ -398,14 +420,13 @@ export class Card implements CardFaceMethods {
edhrec_rank?: number | null;
hand_modifier?: Modifier | null;
keywords: string[];
layout: keyof typeof Layout;
legalities: Legalities;
life_modifier?: Modifier | null;
loyalty?: string | null;
mana_cost?: string | null;
name: string;
oracle_text?: string | null;
oversized: boolean;
penny_rank?: number | null;
power?: string | null;
produced_mana?: Color[] | null;
reserved: boolean;
Expand All @@ -414,6 +435,8 @@ export class Card implements CardFaceMethods {

// print fields
artist?: string | null;
artist_ids?: string[] | null;
attraction_lights?: AttractionLight[] | null;
booster: boolean;
border_color: keyof typeof Border;
card_back_id: string;
Expand All @@ -423,10 +446,6 @@ export class Card implements CardFaceMethods {
finishes: (keyof typeof CardFinish)[];
flavor_name?: string | null;
flavor_text?: string | null;
/**
* Note: This may return other values, I can't check if the possible strings have changed because the Scryfall docs
* no longer list the possible frame effects.
*/
frame_effects?: (keyof typeof FrameEffect)[] | null;
frame: keyof typeof CardFrame;
full_art: boolean;
Expand All @@ -435,13 +454,18 @@ export class Card implements CardFaceMethods {
illustration_id?: string | null;
image_status: keyof typeof CardStatus;
image_uris?: ImageUris | null;
oversized: boolean;
prices: Prices;
printed_name?: string | null;
printed_text?: string | null;
printed_type_line?: string | null;
promo: boolean;
/**
* Note: This may return other values, I can't check if the possible strings have changed because the Scryfall docs
* no longer list the possible promo types.
*/
promo_types?: (keyof typeof PromoType)[] | null;
purchase_uris: PurchaseUris;
purchase_uris?: PurchaseUris | null;
rarity: keyof typeof Rarity;
related_uris: RelatedUris;
released_at: string;
Expand Down
5 changes: 5 additions & 0 deletions src/api/Catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class Catalog extends MagicQuerier {
public async abilityWords () {
return (await this.query<ApiCatalog>("catalog/ability-words")).data;
}

@Cached
public async supertypes () {
return (await this.query<ApiCatalog>("catalog/supertypes")).data;
}
}

export default new Catalog;
6 changes: 6 additions & 0 deletions src/api/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ export enum MigrationStrategy {
}

export interface Migration {
object: "migration";

uri: string;
id: string;
performed_at: string;
migration_strategy: MigrationStrategy;
old_scryfall_id: string;
new_scryfall_id?: string | null;
note?: string | null;
/**
* Do not rely on this data. This is additional context Scryfall has provided for this migration, designed to be human-read only.
*/
metadata?: unknown;
}

class Migrations extends MagicQuerier {
Expand Down
8 changes: 8 additions & 0 deletions src/api/Sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ enum SetType {
core,
expansion,
masters,
alchemy,
masterpiece,
arsenal,
from_the_vault,
spellbook,
premium_deck,
Expand All @@ -24,16 +26,20 @@ enum SetType {
promo,
token,
memorabilia,
minigame,
}

type SetSearchOptions = Omit<SearchOptions, "page">;

let Scry!: typeof import("../Scry");

export class Set {
object: "set";

id: string;
code: string;
mtgo_code?: string | null;
arena_code?: string | null;
tcgplayer_id?: number | null;
name: string;
set_type: keyof typeof SetType;
Expand All @@ -42,8 +48,10 @@ export class Set {
block?: string | null;
parent_set_code?: string | null;
card_count: number;
printed_size?: number | null;
digital: boolean;
foil_only: boolean;
nonfoil_only: boolean;
scryfall_uri: string;
uri: string;
icon_svg_uri: string;
Expand Down
10 changes: 7 additions & 3 deletions src/api/Symbology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ import Cached from "../util/Cached";
import MagicQuerier, { List } from "../util/MagicQuerier";

export interface CardSymbol {
object: "card_symbol";

symbol: string;
loose_variant?: string | null;
english: string;
transposable: boolean;
represents_mana: boolean;
converted_mana_cost?: number | null;
colors: Color[];
mana_value?: number | null;
appears_in_mana_costs: boolean;
funny: boolean;
colors: Color[];
gatherer_alternates?: string[] | null;
svg_uri: string;
svg_uri?: string | null;
}

export interface ManaCost {
object: "mana_cost";

cost: string;
cmc: number;
colors: Color[];
Expand Down
5 changes: 5 additions & 0 deletions src/tests/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ describe("Scry", function () {
const result = await Scry.Catalog.abilityWords();
expect(result.length).gte(49);
});

it("supertypes", async () => {
const result = await Scry.Catalog.supertypes();
expect(result.length).gte(7);
});
});

describe("Bulk Data", () => {
Expand Down

0 comments on commit 37f633e

Please sign in to comment.