scryfall-api 1.0.7 → 2.1.0

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +5 -7
  2. package/README.md +9 -6
  3. package/lib/api/CardIdfentifier.d.ts +9 -0
  4. package/lib/api/Cards.d.ts +15 -323
  5. package/lib/api/Cards.spec.d.ts +1 -0
  6. package/lib/api/Catalog.d.ts +9 -9
  7. package/lib/api/Catalog.spec.d.ts +1 -0
  8. package/lib/api/Misc.d.ts +3 -11
  9. package/lib/api/Misc.spec.d.ts +1 -0
  10. package/lib/api/Rulings.d.ts +6 -10
  11. package/lib/api/Rulings.spec.d.ts +1 -0
  12. package/lib/api/Sets.d.ts +6 -46
  13. package/lib/api/Sets.spec.d.ts +1 -0
  14. package/lib/api/Symbology.d.ts +4 -24
  15. package/lib/api/Symbology.spec.d.ts +1 -0
  16. package/lib/error/MagicQueryError.d.ts +5 -0
  17. package/lib/index.d.ts +0 -25
  18. package/lib/query/MagicPageResult.d.ts +17 -0
  19. package/lib/query/MagicQuery.d.ts +13 -0
  20. package/lib/skryfall.es5.js +148 -639
  21. package/lib/skryfall.es5.js.map +1 -1
  22. package/lib/skryfall.es5.min.js +2 -2
  23. package/lib/skryfall.es5.min.js.map +1 -1
  24. package/lib/skryfall.umd.js +152 -651
  25. package/lib/skryfall.umd.js.map +1 -1
  26. package/lib/skryfall.umd.min.js +2 -2
  27. package/lib/skryfall.umd.min.js.map +1 -1
  28. package/lib/types/Border.d.ts +7 -0
  29. package/lib/types/BulkDataDefinition.d.ts +14 -0
  30. package/lib/types/BulkDataType.d.ts +2 -0
  31. package/lib/types/BulkDataTypes.d.ts +7 -0
  32. package/lib/types/Card.d.ts +91 -0
  33. package/lib/types/CardFace.d.ts +22 -0
  34. package/lib/types/CardIdentifier.d.ts +10 -0
  35. package/lib/types/CardSymbol.d.ts +13 -0
  36. package/lib/{util → types}/Color.d.ts +0 -0
  37. package/lib/types/Format.d.ts +15 -0
  38. package/lib/types/FrameEffect.d.ts +17 -0
  39. package/lib/types/Game.d.ts +5 -0
  40. package/lib/types/HomepageLink.d.ts +9 -0
  41. package/lib/types/ImageUris.d.ts +8 -0
  42. package/lib/types/Layout.d.ts +20 -0
  43. package/lib/types/Legalties.d.ts +5 -0
  44. package/lib/types/Legalty.d.ts +6 -0
  45. package/lib/types/ManaCost.d.ts +9 -0
  46. package/lib/types/PageQuery.d.ts +5 -0
  47. package/lib/types/PageQueryValue.d.ts +1 -0
  48. package/lib/types/Preview.d.ts +5 -0
  49. package/lib/types/Prices.d.ts +6 -0
  50. package/lib/types/PromoType.d.ts +27 -0
  51. package/lib/types/PurchaseUris.d.ts +6 -0
  52. package/lib/types/Query.d.ts +4 -0
  53. package/lib/types/Rarity.d.ts +6 -0
  54. package/lib/types/RelatedCard.d.ts +9 -0
  55. package/lib/types/RelatedCardComponent.d.ts +6 -0
  56. package/lib/types/RelatedUris.d.ts +7 -0
  57. package/lib/types/ResultCatalog.d.ts +2 -0
  58. package/lib/types/ResultData.d.ts +4 -0
  59. package/lib/types/ResultList.d.ts +7 -0
  60. package/lib/types/RetryStrategy.d.ts +11 -0
  61. package/lib/types/Ruling.d.ts +5 -0
  62. package/lib/types/SearchError.d.ts +7 -0
  63. package/lib/types/SearchOptions.d.ts +15 -0
  64. package/lib/types/Set.d.ts +20 -0
  65. package/lib/types/SetType.d.ts +22 -0
  66. package/lib/types/Sort.d.ts +15 -0
  67. package/lib/types/SortDirection.d.ts +5 -0
  68. package/lib/types/TOrArrayOfT.d.ts +1 -0
  69. package/lib/types/UniqueStrategy.d.ts +5 -0
  70. package/lib/types/index.d.ts +42 -0
  71. package/package.json +37 -29
  72. package/lib/api/BulkData.d.ts +0 -46
  73. package/lib/util/MagicEmitter.d.ts +0 -31
  74. package/lib/util/MagicQuerier.d.ts +0 -44
@@ -0,0 +1 @@
1
+ export declare type QueryValue = string | number | boolean | undefined;
@@ -0,0 +1,5 @@
1
+ export interface Preview {
2
+ previewed_at?: string;
3
+ source_uri?: string;
4
+ source?: string;
5
+ }
@@ -0,0 +1,6 @@
1
+ export interface Prices {
2
+ usd?: string;
3
+ usd_foil?: string;
4
+ eur?: string;
5
+ tix?: string;
6
+ }
@@ -0,0 +1,27 @@
1
+ export declare enum PromoType {
2
+ tourney = 0,
3
+ prerelease = 1,
4
+ datestamped = 2,
5
+ planeswalkerdeck = 3,
6
+ buyabox = 4,
7
+ judgegift = 5,
8
+ event = 6,
9
+ convention = 7,
10
+ starterdeck = 8,
11
+ instore = 9,
12
+ setpromo = 10,
13
+ fnm = 11,
14
+ openhouse = 12,
15
+ league = 13,
16
+ draftweekend = 14,
17
+ gameday = 15,
18
+ release = 16,
19
+ intropack = 17,
20
+ giftbox = 18,
21
+ duels = 19,
22
+ wizardsplaynetwork = 20,
23
+ premiereshop = 21,
24
+ playerrewards = 22,
25
+ gateway = 23,
26
+ arenaleague = 24
27
+ }
@@ -0,0 +1,6 @@
1
+ export interface PurchaseUris {
2
+ tcgplayer?: string;
3
+ cardmarket?: string;
4
+ cardhoarder?: string;
5
+ [key: string]: string | undefined;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { QueryValue } from './PageQueryValue';
2
+ export declare type Query = {
3
+ [key: string]: QueryValue;
4
+ };
@@ -0,0 +1,6 @@
1
+ export declare enum Rarity {
2
+ common = 0,
3
+ uncommon = 1,
4
+ rare = 2,
5
+ mythic = 3
6
+ }
@@ -0,0 +1,9 @@
1
+ import { RelatedCardComponent } from './RelatedCardComponent';
2
+ export interface RelatedCard {
3
+ component: keyof typeof RelatedCardComponent;
4
+ id: string;
5
+ name: string;
6
+ object: 'related_card';
7
+ type_line: string;
8
+ uri: string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum RelatedCardComponent {
2
+ token = 0,
3
+ meld_part = 1,
4
+ meld_result = 2,
5
+ combo_piece = 3
6
+ }
@@ -0,0 +1,7 @@
1
+ export interface RelatedUris {
2
+ gatherer?: string;
3
+ tcgplayer_decks?: string;
4
+ edhrec?: string;
5
+ mtgtop8?: string;
6
+ [key: string]: string | undefined;
7
+ }
@@ -0,0 +1,2 @@
1
+ import { ResultData } from './ResultData';
2
+ export declare type ResultCatalog = ResultData<string>;
@@ -0,0 +1,4 @@
1
+ export interface ResultData<T, NOT_FOUND = never> {
2
+ data: T[];
3
+ not_found?: NOT_FOUND[];
4
+ }
@@ -0,0 +1,7 @@
1
+ import { ResultData } from './ResultData';
2
+ export interface ResultList<T, NOT_FOUND = never> extends ResultData<T, NOT_FOUND> {
3
+ has_more: boolean;
4
+ next_page: string;
5
+ total_cards: string;
6
+ warnings: string[];
7
+ }
@@ -0,0 +1,11 @@
1
+ import { SearchError } from './SearchError';
2
+ export interface RetryStrategy {
3
+ attempts: number;
4
+ timeout?: number;
5
+ /**
6
+ * Whether even `not_found` and `bad_request` errors should be retried.
7
+ * @deprecated Don't use this, this is for unit tests
8
+ */
9
+ forced?: boolean;
10
+ canRetry?(error?: SearchError): boolean;
11
+ }
@@ -0,0 +1,5 @@
1
+ export interface Ruling {
2
+ source: string;
3
+ published_at: string;
4
+ comment: string;
5
+ }
@@ -0,0 +1,7 @@
1
+ export interface SearchError {
2
+ object: 'error';
3
+ code: string;
4
+ status: number;
5
+ details: string;
6
+ warnings?: string[];
7
+ }
@@ -0,0 +1,15 @@
1
+ import { Sort } from './Sort';
2
+ import { SortDirection } from './SortDirection';
3
+ import { UniqueStrategy } from './UniqueStrategy';
4
+ export interface SearchOptions {
5
+ unique?: keyof typeof UniqueStrategy;
6
+ order?: keyof typeof Sort;
7
+ dir?: keyof typeof SortDirection;
8
+ include_extras?: boolean;
9
+ include_multilingual?: boolean;
10
+ include_variations?: boolean;
11
+ /**
12
+ * The page to start on. Defaults to `1`, for first page. A page is 175 cards.
13
+ */
14
+ page?: number;
15
+ }
@@ -0,0 +1,20 @@
1
+ import { SetType } from './SetType';
2
+ export interface Set {
3
+ id: string;
4
+ code: string;
5
+ mtgo_code?: string;
6
+ tcgplayer_id?: number;
7
+ name: string;
8
+ set_type: keyof typeof SetType;
9
+ released_at?: string;
10
+ block_code?: string;
11
+ block?: string;
12
+ parent_set_code?: string;
13
+ card_count: number;
14
+ digital: boolean;
15
+ foil_only: boolean;
16
+ scryfall_uri: string;
17
+ uri: string;
18
+ icon_svg_uri: string;
19
+ search_uri: string;
20
+ }
@@ -0,0 +1,22 @@
1
+ export declare enum SetType {
2
+ core = 0,
3
+ expansion = 1,
4
+ masters = 2,
5
+ masterpiece = 3,
6
+ from_the_vault = 4,
7
+ spellbook = 5,
8
+ premium_deck = 6,
9
+ duel_deck = 7,
10
+ draft_innovation = 8,
11
+ treasure_chest = 9,
12
+ commander = 10,
13
+ planechase = 11,
14
+ archenemy = 12,
15
+ vanguard = 13,
16
+ funny = 14,
17
+ starter = 15,
18
+ box = 16,
19
+ promo = 17,
20
+ token = 18,
21
+ memorabilia = 19
22
+ }
@@ -0,0 +1,15 @@
1
+ export declare enum Sort {
2
+ name = 0,
3
+ set = 1,
4
+ released = 2,
5
+ rarity = 3,
6
+ color = 4,
7
+ usd = 5,
8
+ tix = 6,
9
+ eur = 7,
10
+ cmc = 8,
11
+ power = 9,
12
+ toughness = 10,
13
+ edhrec = 11,
14
+ artist = 12
15
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum SortDirection {
2
+ auto = 0,
3
+ asc = 1,
4
+ desc = 2
5
+ }
@@ -0,0 +1 @@
1
+ export declare type TOrArrayOfT<T> = T | T[];
@@ -0,0 +1,5 @@
1
+ export declare enum UniqueStrategy {
2
+ cards = 0,
3
+ art = 1,
4
+ prints = 2
5
+ }
@@ -0,0 +1,42 @@
1
+ export * from './Border';
2
+ export * from './BulkDataDefinition';
3
+ export * from './BulkDataType';
4
+ export * from './BulkDataTypes';
5
+ export * from './Card';
6
+ export * from './CardFace';
7
+ export * from './CardIdentifier';
8
+ export * from './CardSymbol';
9
+ export * from './Color';
10
+ export * from './Format';
11
+ export * from './FrameEffect';
12
+ export * from './Game';
13
+ export * from './HomepageLink';
14
+ export * from './ImageUris';
15
+ export * from './Layout';
16
+ export * from './Legalties';
17
+ export * from './Legalty';
18
+ export * from './ManaCost';
19
+ export * from './PageQuery';
20
+ export * from './PageQueryValue';
21
+ export * from './Preview';
22
+ export * from './Prices';
23
+ export * from './PromoType';
24
+ export * from './PurchaseUris';
25
+ export * from './Query';
26
+ export * from './Rarity';
27
+ export * from './RelatedCard';
28
+ export * from './RelatedCardComponent';
29
+ export * from './RelatedUris';
30
+ export * from './ResultCatalog';
31
+ export * from './ResultData';
32
+ export * from './ResultList';
33
+ export * from './RetryStrategy';
34
+ export * from './Ruling';
35
+ export * from './SearchError';
36
+ export * from './SearchOptions';
37
+ export * from './Set';
38
+ export * from './SetType';
39
+ export * from './Sort';
40
+ export * from './SortDirection';
41
+ export * from './TOrArrayOfT';
42
+ export * from './UniqueStrategy';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scryfall-api",
3
- "version": "1.0.7",
3
+ "version": "2.1.0",
4
4
  "description": "A Node.js SDK for https://scryfall.com/docs/api written in Typescript.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,50 +36,58 @@
36
36
  "clean": "rimraf lib tsconfig.tsbuildinfo",
37
37
  "clean:deps": "rimraf node_modules",
38
38
  "commit": "git-cz",
39
- "lint": "eslint . --ext .ts",
40
- "lint:fix": "npm run lint -- --fix",
41
- "release": "standard-version"
39
+ "lint": "eslint --cache --ext ts .",
40
+ "lint:fix": "eslint --fix --cache --ext ts .",
41
+ "release": "standard-version",
42
+ "prettier": "prettier --check .",
43
+ "prettier:fix": "prettier --write .",
44
+ "prepare": "husky install",
45
+ "test": "jest"
42
46
  },
43
47
  "dependencies": {
44
- "axios": "^0.21.1",
45
- "eventemitter3": "^4.0.7"
48
+ "axios": "^0.23.0"
46
49
  },
47
50
  "devDependencies": {
48
- "@commitlint/cli": "^11.0.0",
49
- "@commitlint/config-conventional": "^11.0.0",
50
- "@rollup/plugin-commonjs": "^17.0.0",
51
+ "@commitlint/cli": "^13.2.1",
52
+ "@commitlint/config-conventional": "^13.2.0",
53
+ "@rollup/plugin-commonjs": "^21.0.0",
51
54
  "@rollup/plugin-json": "^4.1.0",
52
- "@rollup/plugin-node-resolve": "^11.1.0",
55
+ "@rollup/plugin-node-resolve": "^13.0.5",
53
56
  "@types/axios": "^0.14.0",
54
- "@typescript-eslint/eslint-plugin": "^4.13.0",
55
- "@typescript-eslint/parser": "^4.13.0",
56
- "commitizen": "^4.2.2",
57
+ "@types/jest": "^27.0.2",
58
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
59
+ "@typescript-eslint/parser": "^5.0.0",
60
+ "commitizen": "^4.2.4",
57
61
  "cz-conventional-changelog": "^3.3.0",
58
- "eslint": "^7.17.0",
59
- "eslint-config-prettier": "^7.1.0",
60
- "eslint-plugin-prettier": "^3.3.1",
61
- "husky": "^4.3.7",
62
- "lint-staged": "^10.5.3",
63
- "prettier": "^2.2.1",
62
+ "eslint": "^8.0.1",
63
+ "eslint-config-prettier": "^8.3.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "husky": "^7.0.0",
66
+ "jest": "^27.2.5",
67
+ "lint-staged": "^11.2.3",
68
+ "prettier": "^2.4.1",
64
69
  "rimraf": "^3.0.2",
65
- "rollup": "^2.37.0",
70
+ "rollup": "^2.58.0",
66
71
  "rollup-plugin-sourcemaps": "^0.6.3",
67
72
  "rollup-plugin-terser": "^7.0.2",
68
- "rollup-plugin-typescript2": "^0.29.0",
69
- "standard-version": "^9.2.0",
70
- "typescript": "^4.1.3"
73
+ "rollup-plugin-typescript2": "^0.30.0",
74
+ "standard-version": "^9.3.1",
75
+ "ts-jest": "^27.0.5",
76
+ "typescript": "^4.4.4"
71
77
  },
72
78
  "config": {
79
+ "unsafe-perm": true,
73
80
  "commitizen": {
74
81
  "path": "cz-conventional-changelog"
75
82
  }
76
83
  },
77
- "husky": {
78
- "hooks": {
79
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
80
- }
81
- },
82
84
  "lint-staged": {
83
- "*.{ts, tsx}": "eslint --cache --fix"
85
+ "*.{ts, tsx}": [
86
+ "eslint --fix --cache --ext ts .",
87
+ "prettier --write"
88
+ ]
89
+ },
90
+ "standard": {
91
+ "releaseCommitMessageFormat": "chore(release): {{currentTag}} [skip ci]"
84
92
  }
85
93
  }
@@ -1,46 +0,0 @@
1
- /// <reference types="node" />
2
- import { Stream } from 'stream';
3
- import MagicQuerier from '../util/MagicQuerier';
4
- declare enum BulkDataTypes {
5
- oracle_cards = 0,
6
- unique_artwork = 1,
7
- default_cards = 2,
8
- all_cards = 3,
9
- rulings = 4
10
- }
11
- export declare type BulkDataType = keyof typeof BulkDataTypes;
12
- export interface BulkDataDefinition {
13
- object: 'bulk_data';
14
- id: string;
15
- type: BulkDataType;
16
- updated_at: string;
17
- uri: string;
18
- name: string;
19
- description: string;
20
- compressed_size: number;
21
- download_uri: string;
22
- content_type: string;
23
- content_encoding: string;
24
- }
25
- declare class BulkData extends MagicQuerier {
26
- /**
27
- * Returns a stream for the given bulk data if it has been updated since the last download time. If it hasn't, returns `undefined`
28
- * @param type The BulkDataType.
29
- * @param lastDownload The last time this bulk data was downloaded. If you want to re-download the data regardless of
30
- * the last time it was downloaded, set this to `0`.
31
- */
32
- downloadByType(type: BulkDataType, lastDownload: string | number | Date): Promise<Stream | undefined>;
33
- /**
34
- * Returns a stream for the given bulk data if it has been updated since the last download time. If it hasn't, returns `undefined`
35
- * @param lastDownload The last time this bulk data was downloaded. If you want to re-download the data regardless of
36
- * the last time it was downloaded, set this to `0`.
37
- */
38
- downloadById(id: string, lastDownload: string | number | Date): Promise<Stream | undefined>;
39
- definitions(): Promise<BulkDataDefinition[]>;
40
- definitionByType(type: BulkDataType): Promise<BulkDataDefinition>;
41
- definitionById(id: string): Promise<BulkDataDefinition>;
42
- private download;
43
- private definition;
44
- }
45
- declare const _default: BulkData;
46
- export default _default;
@@ -1,31 +0,0 @@
1
- import { EventEmitter } from 'eventemitter3';
2
- export default class MagicEmitter<T, NOT_FOUND = never> extends EventEmitter {
3
- private _ended;
4
- get ended(): boolean;
5
- private _cancelled;
6
- get cancelled(): boolean;
7
- private _willCancelAfterPage;
8
- get willCancelAfterPage(): boolean;
9
- constructor();
10
- on(event: 'data', listener: (data: T) => any): this;
11
- on(event: 'not_found', listener: (data: NOT_FOUND) => any): this;
12
- on(event: 'end', listener: (...args: any[]) => any): this;
13
- on(event: 'cancel', listener: (...args: any[]) => any): this;
14
- on(event: 'error', listener: (err: Error) => any): this;
15
- on(event: 'done', listener: (...args: any[]) => any): this;
16
- emit(event: 'data', data: T): boolean;
17
- emit(event: 'not_found', data: NOT_FOUND): boolean;
18
- emit(event: 'end'): boolean;
19
- emit(event: 'cancel'): boolean;
20
- emit(event: 'error', error: Error): boolean;
21
- emit(event: 'done'): boolean;
22
- emitAll(event: 'data', ...data: T[]): void;
23
- emitAll(event: 'not_found', ...data: NOT_FOUND[]): void;
24
- cancel(): this;
25
- cancelAfterPage(): this;
26
- waitForAll(): Promise<any>;
27
- [Symbol.asyncIterator](): AsyncGenerator<T, void, unknown>;
28
- all(): AsyncGenerator<T, void, unknown>;
29
- notFound(): AsyncGenerator<NOT_FOUND, void, unknown>;
30
- private generate;
31
- }
@@ -1,44 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import MagicEmitter from './MagicEmitter';
3
- declare type TOrArrayOfT<T> = T | T[];
4
- export interface Data<T, NOT_FOUND = never> {
5
- data: T[];
6
- not_found?: NOT_FOUND[];
7
- }
8
- export interface List<T, NOT_FOUND = never> extends Data<T, NOT_FOUND> {
9
- has_more: boolean;
10
- next_page: string | null;
11
- total_cards: string | null;
12
- warnings: string[];
13
- }
14
- export declare type ApiCatalog = Data<string>;
15
- export interface SearchError {
16
- object: 'error';
17
- code: string;
18
- status: number;
19
- details: string;
20
- warnings?: string[];
21
- }
22
- export interface RetryStrategy {
23
- attempts: number;
24
- timeout?: number;
25
- /**
26
- * Whether even `not_found` and `bad_request` errors should be retried.
27
- * @deprecated Don't use this, this is for unit tests
28
- */
29
- forced?: boolean;
30
- canRetry?(error: SearchError): boolean;
31
- }
32
- export default class MagicQuerier {
33
- static lastQuery: number;
34
- static lastError: SearchError | undefined;
35
- static lastRetries: number;
36
- static retry: RetryStrategy;
37
- protected query<T>(apiPath: TOrArrayOfT<string | number | undefined>, query?: {
38
- [key: string]: any;
39
- }, post?: any, requestOptions?: AxiosRequestConfig): Promise<T>;
40
- protected queryPage<T>(emitter: MagicEmitter<T>, apiPath: string, query: any, page?: number): Promise<void>;
41
- private tryQuery;
42
- private canRetry;
43
- }
44
- export {};