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.
- package/CHANGELOG.md +5 -7
- package/README.md +9 -6
- package/lib/api/CardIdfentifier.d.ts +9 -0
- package/lib/api/Cards.d.ts +15 -323
- package/lib/api/Cards.spec.d.ts +1 -0
- package/lib/api/Catalog.d.ts +9 -9
- package/lib/api/Catalog.spec.d.ts +1 -0
- package/lib/api/Misc.d.ts +3 -11
- package/lib/api/Misc.spec.d.ts +1 -0
- package/lib/api/Rulings.d.ts +6 -10
- package/lib/api/Rulings.spec.d.ts +1 -0
- package/lib/api/Sets.d.ts +6 -46
- package/lib/api/Sets.spec.d.ts +1 -0
- package/lib/api/Symbology.d.ts +4 -24
- package/lib/api/Symbology.spec.d.ts +1 -0
- package/lib/error/MagicQueryError.d.ts +5 -0
- package/lib/index.d.ts +0 -25
- package/lib/query/MagicPageResult.d.ts +17 -0
- package/lib/query/MagicQuery.d.ts +13 -0
- package/lib/skryfall.es5.js +148 -639
- package/lib/skryfall.es5.js.map +1 -1
- package/lib/skryfall.es5.min.js +2 -2
- package/lib/skryfall.es5.min.js.map +1 -1
- package/lib/skryfall.umd.js +152 -651
- package/lib/skryfall.umd.js.map +1 -1
- package/lib/skryfall.umd.min.js +2 -2
- package/lib/skryfall.umd.min.js.map +1 -1
- package/lib/types/Border.d.ts +7 -0
- package/lib/types/BulkDataDefinition.d.ts +14 -0
- package/lib/types/BulkDataType.d.ts +2 -0
- package/lib/types/BulkDataTypes.d.ts +7 -0
- package/lib/types/Card.d.ts +91 -0
- package/lib/types/CardFace.d.ts +22 -0
- package/lib/types/CardIdentifier.d.ts +10 -0
- package/lib/types/CardSymbol.d.ts +13 -0
- package/lib/{util → types}/Color.d.ts +0 -0
- package/lib/types/Format.d.ts +15 -0
- package/lib/types/FrameEffect.d.ts +17 -0
- package/lib/types/Game.d.ts +5 -0
- package/lib/types/HomepageLink.d.ts +9 -0
- package/lib/types/ImageUris.d.ts +8 -0
- package/lib/types/Layout.d.ts +20 -0
- package/lib/types/Legalties.d.ts +5 -0
- package/lib/types/Legalty.d.ts +6 -0
- package/lib/types/ManaCost.d.ts +9 -0
- package/lib/types/PageQuery.d.ts +5 -0
- package/lib/types/PageQueryValue.d.ts +1 -0
- package/lib/types/Preview.d.ts +5 -0
- package/lib/types/Prices.d.ts +6 -0
- package/lib/types/PromoType.d.ts +27 -0
- package/lib/types/PurchaseUris.d.ts +6 -0
- package/lib/types/Query.d.ts +4 -0
- package/lib/types/Rarity.d.ts +6 -0
- package/lib/types/RelatedCard.d.ts +9 -0
- package/lib/types/RelatedCardComponent.d.ts +6 -0
- package/lib/types/RelatedUris.d.ts +7 -0
- package/lib/types/ResultCatalog.d.ts +2 -0
- package/lib/types/ResultData.d.ts +4 -0
- package/lib/types/ResultList.d.ts +7 -0
- package/lib/types/RetryStrategy.d.ts +11 -0
- package/lib/types/Ruling.d.ts +5 -0
- package/lib/types/SearchError.d.ts +7 -0
- package/lib/types/SearchOptions.d.ts +15 -0
- package/lib/types/Set.d.ts +20 -0
- package/lib/types/SetType.d.ts +22 -0
- package/lib/types/Sort.d.ts +15 -0
- package/lib/types/SortDirection.d.ts +5 -0
- package/lib/types/TOrArrayOfT.d.ts +1 -0
- package/lib/types/UniqueStrategy.d.ts +5 -0
- package/lib/types/index.d.ts +42 -0
- package/package.json +37 -29
- package/lib/api/BulkData.d.ts +0 -46
- package/lib/util/MagicEmitter.d.ts +0 -31
- package/lib/util/MagicQuerier.d.ts +0 -44
package/lib/skryfall.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'axios'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.scryfall = {}, global.axios
|
|
5
|
-
}(this, (function (exports, Axios
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'axios'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.scryfall = {}, global.axios));
|
|
5
|
+
})(this, (function (exports, Axios) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -31,431 +31,182 @@
|
|
|
31
31
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
32
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
33
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function __await(v) {
|
|
37
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
41
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
42
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
43
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
44
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
45
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
46
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
47
|
-
function fulfill(value) { resume("next", value); }
|
|
48
|
-
function reject(value) { resume("throw", value); }
|
|
49
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
50
34
|
}
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
class MagicPageResult {
|
|
37
|
+
constructor(q, apiPath, query, post) {
|
|
38
|
+
this.q = q;
|
|
39
|
+
this.apiPath = apiPath;
|
|
40
|
+
this.query = query;
|
|
41
|
+
this.post = post;
|
|
42
|
+
this.hasMore = true;
|
|
43
|
+
}
|
|
44
|
+
get count() {
|
|
45
|
+
return this._count;
|
|
46
|
+
}
|
|
47
|
+
all() {
|
|
62
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
const r = [];
|
|
50
|
+
while (this.hasMore) {
|
|
51
|
+
const result = yield this.next();
|
|
52
|
+
r.push(...result);
|
|
65
53
|
}
|
|
66
|
-
|
|
67
|
-
let result;
|
|
68
|
-
let retries;
|
|
69
|
-
for (retries = 0; retries < MagicQuerier.retry.attempts; retries++) {
|
|
70
|
-
({ result, lastError } = yield this.tryQuery(`${apiPath}`, query, post, requestOptions));
|
|
71
|
-
if (result || (!this.canRetry(lastError) && !MagicQuerier.retry.forced))
|
|
72
|
-
break;
|
|
73
|
-
yield sleep(MagicQuerier.retry.timeout);
|
|
74
|
-
}
|
|
75
|
-
MagicQuerier.lastError = lastError;
|
|
76
|
-
MagicQuerier.lastRetries = retries;
|
|
77
|
-
return result ? result.data : { data: [], not_found: [] };
|
|
54
|
+
return r;
|
|
78
55
|
});
|
|
79
56
|
}
|
|
80
|
-
|
|
57
|
+
get(limit) {
|
|
81
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
emitter.cancel();
|
|
92
|
-
else
|
|
93
|
-
return this.queryPage(emitter, apiPath, query, page + 1).catch((err) => {
|
|
94
|
-
emitter.emit('error', err);
|
|
95
|
-
});
|
|
59
|
+
const r = [];
|
|
60
|
+
while (this.hasMore) {
|
|
61
|
+
const result = yield this.next();
|
|
62
|
+
r.push(...result);
|
|
63
|
+
if (r.length == limit) {
|
|
64
|
+
return r;
|
|
65
|
+
}
|
|
66
|
+
else if (r.length > limit) {
|
|
67
|
+
return r.slice(0, limit);
|
|
96
68
|
}
|
|
97
69
|
}
|
|
98
|
-
|
|
99
|
-
emitter.emit('end');
|
|
100
|
-
emitter.emit('done');
|
|
70
|
+
return r;
|
|
101
71
|
});
|
|
102
72
|
}
|
|
103
|
-
|
|
73
|
+
next() {
|
|
104
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
else {
|
|
111
|
-
const timeUntilNextQuery = rateLimit - timeSinceLastQuery;
|
|
112
|
-
lastQuery += timeUntilNextQuery;
|
|
113
|
-
yield sleep(timeUntilNextQuery);
|
|
75
|
+
const results = yield this.q.query(this.apiPath, this.query, this.post);
|
|
76
|
+
this.hasMore = (results === null || results === void 0 ? void 0 : results.has_more) || false;
|
|
77
|
+
this._count = Number.parseInt(((results === null || results === void 0 ? void 0 : results.total_cards) || 0) + '');
|
|
78
|
+
if (this.hasMore) {
|
|
79
|
+
this.setNextPage();
|
|
114
80
|
}
|
|
115
|
-
|
|
116
|
-
const result = (yield Axios__default['default'].request(Object.assign({ data: post, method: post ? 'POST' : 'GET', params: query, url: `${endpoint}/${apiPath}` }, requestOptions)).catch(({ response }) => {
|
|
117
|
-
lastError = response.data;
|
|
118
|
-
})) || undefined;
|
|
119
|
-
return { result, lastError };
|
|
81
|
+
return (results === null || results === void 0 ? void 0 : results.data) || [];
|
|
120
82
|
});
|
|
121
83
|
}
|
|
122
|
-
|
|
123
|
-
if (error.code == 'not_found' || error.code == 'bad_request')
|
|
124
|
-
return false;
|
|
125
|
-
return !MagicQuerier.retry.canRetry || MagicQuerier.retry.canRetry(error);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
MagicQuerier.lastQuery = 0;
|
|
129
|
-
MagicQuerier.lastRetries = 0;
|
|
130
|
-
MagicQuerier.retry = { attempts: 1 };
|
|
131
|
-
|
|
132
|
-
var BulkDataTypes;
|
|
133
|
-
(function (BulkDataTypes) {
|
|
134
|
-
BulkDataTypes[BulkDataTypes["oracle_cards"] = 0] = "oracle_cards";
|
|
135
|
-
BulkDataTypes[BulkDataTypes["unique_artwork"] = 1] = "unique_artwork";
|
|
136
|
-
BulkDataTypes[BulkDataTypes["default_cards"] = 2] = "default_cards";
|
|
137
|
-
BulkDataTypes[BulkDataTypes["all_cards"] = 3] = "all_cards";
|
|
138
|
-
BulkDataTypes[BulkDataTypes["rulings"] = 4] = "rulings";
|
|
139
|
-
})(BulkDataTypes || (BulkDataTypes = {}));
|
|
140
|
-
class BulkData extends MagicQuerier {
|
|
141
|
-
/**
|
|
142
|
-
* Returns a stream for the given bulk data if it has been updated since the last download time. If it hasn't, returns `undefined`
|
|
143
|
-
* @param type The BulkDataType.
|
|
144
|
-
* @param lastDownload The last time this bulk data was downloaded. If you want to re-download the data regardless of
|
|
145
|
-
* the last time it was downloaded, set this to `0`.
|
|
146
|
-
*/
|
|
147
|
-
downloadByType(type, lastDownload) {
|
|
84
|
+
page(page) {
|
|
148
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
|
|
86
|
+
this.query.page = page;
|
|
87
|
+
return this.next();
|
|
150
88
|
});
|
|
151
89
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* @param lastDownload The last time this bulk data was downloaded. If you want to re-download the data regardless of
|
|
155
|
-
* the last time it was downloaded, set this to `0`.
|
|
156
|
-
*/
|
|
157
|
-
downloadById(id, lastDownload) {
|
|
158
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
return this.download(id, lastDownload);
|
|
160
|
-
});
|
|
90
|
+
setNextPage() {
|
|
91
|
+
this.query.page = this.query.page + 1;
|
|
161
92
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
class MagicQueryError extends Error {
|
|
96
|
+
constructor(data) {
|
|
97
|
+
super(data === null || data === void 0 ? void 0 : data.details);
|
|
98
|
+
this.data = data;
|
|
99
|
+
Object.setPrototypeOf(this, MagicQueryError.prototype);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class MagicQuery {
|
|
104
|
+
static canRetry(error) {
|
|
105
|
+
if ((error === null || error === void 0 ? void 0 : error.code) == 'not_found' || (error === null || error === void 0 ? void 0 : error.code) == 'bad_request')
|
|
106
|
+
return false;
|
|
107
|
+
return !MagicQuery.retry.canRetry || MagicQuery.retry.canRetry(error);
|
|
169
108
|
}
|
|
170
|
-
|
|
109
|
+
static debounce() {
|
|
171
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
|
|
111
|
+
const now = Date.now();
|
|
112
|
+
const timeSinceLastQuery = now - MagicQuery.lastQuery;
|
|
113
|
+
if (timeSinceLastQuery >= MagicQuery.rateLimit) {
|
|
114
|
+
MagicQuery.lastQuery = now;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const timeUntilNextQuery = MagicQuery.rateLimit - timeSinceLastQuery;
|
|
118
|
+
MagicQuery.lastQuery += timeUntilNextQuery;
|
|
119
|
+
yield MagicQuery.sleep(timeUntilNextQuery);
|
|
120
|
+
}
|
|
173
121
|
});
|
|
174
122
|
}
|
|
175
|
-
|
|
123
|
+
static sleep(ms = 0) {
|
|
124
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
125
|
+
}
|
|
126
|
+
static tryQuery(apiPath, query, post, requestOptions) {
|
|
127
|
+
var _a;
|
|
176
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
|
|
129
|
+
yield MagicQuery.debounce();
|
|
130
|
+
const config = Object.assign({ data: post, method: post ? 'POST' : 'GET', params: query, url: `${MagicQuery.endpoint}/${apiPath}` }, requestOptions);
|
|
131
|
+
try {
|
|
132
|
+
return yield Axios__default["default"].request(config);
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
if (e['isAxiosError']) {
|
|
136
|
+
const error = e;
|
|
137
|
+
throw new MagicQueryError((_a = error.response) === null || _a === void 0 ? void 0 : _a.data);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
throw e;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
178
143
|
});
|
|
179
144
|
}
|
|
180
|
-
|
|
181
|
-
// Internals
|
|
182
|
-
//
|
|
183
|
-
download(idOrType, lastDownload) {
|
|
145
|
+
query(apiPath, query, post, requestOptions) {
|
|
184
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
147
|
+
if (Array.isArray(apiPath)) {
|
|
148
|
+
apiPath = apiPath.join('/');
|
|
149
|
+
}
|
|
150
|
+
let retries;
|
|
151
|
+
let result;
|
|
152
|
+
for (retries = 0; retries < MagicQuery.retry.attempts; retries++) {
|
|
153
|
+
let error;
|
|
154
|
+
try {
|
|
155
|
+
result = yield MagicQuery.tryQuery(`${apiPath}`, query, post, requestOptions);
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
if (e instanceof MagicQueryError) {
|
|
159
|
+
error = e.data;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (result || !MagicQuery.canRetry(error))
|
|
166
|
+
break;
|
|
167
|
+
yield MagicQuery.sleep(MagicQuery.retry.timeout);
|
|
168
|
+
}
|
|
169
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
195
170
|
});
|
|
196
171
|
}
|
|
197
|
-
definition(idOrType) {
|
|
198
|
-
return this.query(['bulk-data', idOrType]);
|
|
199
|
-
}
|
|
200
172
|
}
|
|
201
|
-
|
|
173
|
+
MagicQuery.retry = { attempts: 1 };
|
|
174
|
+
// the path to the api
|
|
175
|
+
MagicQuery.endpoint = 'https://api.scryfall.com';
|
|
176
|
+
// time where the last api call was made
|
|
177
|
+
MagicQuery.lastQuery = 100;
|
|
178
|
+
// the api requests 50-100 ms between calls, we go on the generous side and never wait less than 100 ms between calls
|
|
179
|
+
MagicQuery.rateLimit = 100;
|
|
202
180
|
|
|
203
|
-
class
|
|
204
|
-
|
|
205
|
-
super();
|
|
206
|
-
this._ended = false;
|
|
207
|
-
this._cancelled = false;
|
|
208
|
-
this._willCancelAfterPage = false;
|
|
209
|
-
this.on('end', () => {
|
|
210
|
-
this._ended = true;
|
|
211
|
-
});
|
|
212
|
-
this.on('cancel', () => {
|
|
213
|
-
this._ended = true;
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
get ended() {
|
|
217
|
-
return this._ended;
|
|
218
|
-
}
|
|
219
|
-
get cancelled() {
|
|
220
|
-
return this._cancelled;
|
|
221
|
-
}
|
|
222
|
-
get willCancelAfterPage() {
|
|
223
|
-
return this._willCancelAfterPage;
|
|
224
|
-
}
|
|
225
|
-
on(event, listener) {
|
|
226
|
-
super.on(event, listener);
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
emit(event, ...data) {
|
|
230
|
-
return super.emit(event, ...data);
|
|
231
|
-
}
|
|
232
|
-
emitAll(event, ...data) {
|
|
233
|
-
for (const item of data) {
|
|
234
|
-
super.emit(event, item);
|
|
235
|
-
if (this._cancelled)
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
cancel() {
|
|
240
|
-
this._cancelled = true;
|
|
241
|
-
this.emit('cancel');
|
|
242
|
-
return this;
|
|
243
|
-
}
|
|
244
|
-
cancelAfterPage() {
|
|
245
|
-
this._willCancelAfterPage = true;
|
|
246
|
-
return this;
|
|
247
|
-
}
|
|
248
|
-
waitForAll() {
|
|
181
|
+
class Cards extends MagicQuery {
|
|
182
|
+
autoCompleteName(name) {
|
|
249
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
results.not_found = [];
|
|
253
|
-
this.on('data', (result) => {
|
|
254
|
-
results.push(result);
|
|
255
|
-
});
|
|
256
|
-
this.on('not_found', (notFound) => {
|
|
257
|
-
results.not_found.push(notFound);
|
|
258
|
-
});
|
|
259
|
-
this.on('end', () => resolve(results));
|
|
260
|
-
this.on('error', reject);
|
|
184
|
+
const result = yield this.query('cards/autocomplete', {
|
|
185
|
+
q: name,
|
|
261
186
|
});
|
|
187
|
+
return (result === null || result === void 0 ? void 0 : result.data) || [];
|
|
262
188
|
});
|
|
263
189
|
}
|
|
264
|
-
|
|
265
|
-
return this
|
|
266
|
-
|
|
267
|
-
all() {
|
|
268
|
-
return this.generate('data');
|
|
269
|
-
}
|
|
270
|
-
notFound() {
|
|
271
|
-
return this.generate('not_found');
|
|
272
|
-
}
|
|
273
|
-
generate(event) {
|
|
274
|
-
return __asyncGenerator(this, arguments, function* generate_1() {
|
|
275
|
-
// save the new data on each event
|
|
276
|
-
const unYielded = [];
|
|
277
|
-
this.on(event, (data) => unYielded.push(data));
|
|
278
|
-
while (!this._ended) {
|
|
279
|
-
// wait for the next event before yielding any new data
|
|
280
|
-
yield __await(new Promise((resolve) => this.once(event, resolve)));
|
|
281
|
-
let data;
|
|
282
|
-
while ((data = unYielded.shift()))
|
|
283
|
-
yield yield __await(data);
|
|
284
|
-
}
|
|
190
|
+
byArenaId(id) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
return this.query(['cards/arena', id]);
|
|
285
193
|
});
|
|
286
194
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
UniqueStrategy[UniqueStrategy["cards"] = 0] = "cards";
|
|
292
|
-
UniqueStrategy[UniqueStrategy["art"] = 1] = "art";
|
|
293
|
-
UniqueStrategy[UniqueStrategy["prints"] = 2] = "prints";
|
|
294
|
-
})(UniqueStrategy || (UniqueStrategy = {}));
|
|
295
|
-
var Sort;
|
|
296
|
-
(function (Sort) {
|
|
297
|
-
Sort[Sort["name"] = 0] = "name";
|
|
298
|
-
Sort[Sort["set"] = 1] = "set";
|
|
299
|
-
Sort[Sort["released"] = 2] = "released";
|
|
300
|
-
Sort[Sort["rarity"] = 3] = "rarity";
|
|
301
|
-
Sort[Sort["color"] = 4] = "color";
|
|
302
|
-
Sort[Sort["usd"] = 5] = "usd";
|
|
303
|
-
Sort[Sort["tix"] = 6] = "tix";
|
|
304
|
-
Sort[Sort["eur"] = 7] = "eur";
|
|
305
|
-
Sort[Sort["cmc"] = 8] = "cmc";
|
|
306
|
-
Sort[Sort["power"] = 9] = "power";
|
|
307
|
-
Sort[Sort["toughness"] = 10] = "toughness";
|
|
308
|
-
Sort[Sort["edhrec"] = 11] = "edhrec";
|
|
309
|
-
Sort[Sort["artist"] = 12] = "artist";
|
|
310
|
-
})(Sort || (Sort = {}));
|
|
311
|
-
var SortDirection;
|
|
312
|
-
(function (SortDirection) {
|
|
313
|
-
SortDirection[SortDirection["auto"] = 0] = "auto";
|
|
314
|
-
SortDirection[SortDirection["asc"] = 1] = "asc";
|
|
315
|
-
SortDirection[SortDirection["desc"] = 2] = "desc";
|
|
316
|
-
})(SortDirection || (SortDirection = {}));
|
|
317
|
-
var Rarity;
|
|
318
|
-
(function (Rarity) {
|
|
319
|
-
Rarity[Rarity["common"] = 0] = "common";
|
|
320
|
-
Rarity[Rarity["uncommon"] = 1] = "uncommon";
|
|
321
|
-
Rarity[Rarity["rare"] = 2] = "rare";
|
|
322
|
-
Rarity[Rarity["mythic"] = 3] = "mythic";
|
|
323
|
-
})(Rarity || (Rarity = {}));
|
|
324
|
-
var FrameEffect;
|
|
325
|
-
(function (FrameEffect) {
|
|
326
|
-
FrameEffect[FrameEffect["legendary"] = 0] = "legendary";
|
|
327
|
-
FrameEffect[FrameEffect["miracle"] = 1] = "miracle";
|
|
328
|
-
FrameEffect[FrameEffect["nyxtouched"] = 2] = "nyxtouched";
|
|
329
|
-
FrameEffect[FrameEffect["draft"] = 3] = "draft";
|
|
330
|
-
FrameEffect[FrameEffect["devoid"] = 4] = "devoid";
|
|
331
|
-
FrameEffect[FrameEffect["tombstone"] = 5] = "tombstone";
|
|
332
|
-
FrameEffect[FrameEffect["colorshifted"] = 6] = "colorshifted";
|
|
333
|
-
FrameEffect[FrameEffect["inverted"] = 7] = "inverted";
|
|
334
|
-
FrameEffect[FrameEffect["sunmoondfc"] = 8] = "sunmoondfc";
|
|
335
|
-
FrameEffect[FrameEffect["compasslanddfc"] = 9] = "compasslanddfc";
|
|
336
|
-
FrameEffect[FrameEffect["originpwdfc"] = 10] = "originpwdfc";
|
|
337
|
-
FrameEffect[FrameEffect["mooneldrazidfc"] = 11] = "mooneldrazidfc";
|
|
338
|
-
FrameEffect[FrameEffect["moonreversemoondfc"] = 12] = "moonreversemoondfc";
|
|
339
|
-
FrameEffect[FrameEffect["showcase"] = 13] = "showcase";
|
|
340
|
-
FrameEffect[FrameEffect["extendedart"] = 14] = "extendedart";
|
|
341
|
-
})(FrameEffect || (FrameEffect = {}));
|
|
342
|
-
var Game;
|
|
343
|
-
(function (Game) {
|
|
344
|
-
Game[Game["paper"] = 0] = "paper";
|
|
345
|
-
Game[Game["arena"] = 1] = "arena";
|
|
346
|
-
Game[Game["mtgo"] = 2] = "mtgo";
|
|
347
|
-
})(Game || (Game = {}));
|
|
348
|
-
var Legality;
|
|
349
|
-
(function (Legality) {
|
|
350
|
-
Legality[Legality["legal"] = 0] = "legal";
|
|
351
|
-
Legality[Legality["not_legal"] = 1] = "not_legal";
|
|
352
|
-
Legality[Legality["restricted"] = 2] = "restricted";
|
|
353
|
-
Legality[Legality["banned"] = 3] = "banned";
|
|
354
|
-
})(Legality || (Legality = {}));
|
|
355
|
-
var Border;
|
|
356
|
-
(function (Border) {
|
|
357
|
-
Border[Border["black"] = 0] = "black";
|
|
358
|
-
Border[Border["borderless"] = 1] = "borderless";
|
|
359
|
-
Border[Border["gold"] = 2] = "gold";
|
|
360
|
-
Border[Border["silver"] = 3] = "silver";
|
|
361
|
-
Border[Border["white"] = 4] = "white";
|
|
362
|
-
})(Border || (Border = {}));
|
|
363
|
-
var Layout;
|
|
364
|
-
(function (Layout) {
|
|
365
|
-
Layout[Layout["normal"] = 0] = "normal";
|
|
366
|
-
Layout[Layout["split"] = 1] = "split";
|
|
367
|
-
Layout[Layout["flip"] = 2] = "flip";
|
|
368
|
-
Layout[Layout["transform"] = 3] = "transform";
|
|
369
|
-
Layout[Layout["meld"] = 4] = "meld";
|
|
370
|
-
Layout[Layout["leveler"] = 5] = "leveler";
|
|
371
|
-
Layout[Layout["saga"] = 6] = "saga";
|
|
372
|
-
Layout[Layout["adventure"] = 7] = "adventure";
|
|
373
|
-
Layout[Layout["planar"] = 8] = "planar";
|
|
374
|
-
Layout[Layout["scheme"] = 9] = "scheme";
|
|
375
|
-
Layout[Layout["vanguard"] = 10] = "vanguard";
|
|
376
|
-
Layout[Layout["token"] = 11] = "token";
|
|
377
|
-
Layout[Layout["double_faced_token"] = 12] = "double_faced_token";
|
|
378
|
-
Layout[Layout["emblem"] = 13] = "emblem";
|
|
379
|
-
Layout[Layout["augment"] = 14] = "augment";
|
|
380
|
-
Layout[Layout["host"] = 15] = "host";
|
|
381
|
-
Layout[Layout["art_series"] = 16] = "art_series";
|
|
382
|
-
Layout[Layout["double_sided"] = 17] = "double_sided";
|
|
383
|
-
})(Layout || (Layout = {}));
|
|
384
|
-
var Format;
|
|
385
|
-
(function (Format) {
|
|
386
|
-
Format[Format["standard"] = 0] = "standard";
|
|
387
|
-
Format[Format["future"] = 1] = "future";
|
|
388
|
-
Format[Format["historic"] = 2] = "historic";
|
|
389
|
-
Format[Format["pioneer"] = 3] = "pioneer";
|
|
390
|
-
Format[Format["modern"] = 4] = "modern";
|
|
391
|
-
Format[Format["legacy"] = 5] = "legacy";
|
|
392
|
-
Format[Format["pauper"] = 6] = "pauper";
|
|
393
|
-
Format[Format["vintage"] = 7] = "vintage";
|
|
394
|
-
Format[Format["penny"] = 8] = "penny";
|
|
395
|
-
Format[Format["commander"] = 9] = "commander";
|
|
396
|
-
Format[Format["brawl"] = 10] = "brawl";
|
|
397
|
-
Format[Format["duel"] = 11] = "duel";
|
|
398
|
-
Format[Format["oldschool"] = 12] = "oldschool";
|
|
399
|
-
})(Format || (Format = {}));
|
|
400
|
-
var RelatedCardComponent;
|
|
401
|
-
(function (RelatedCardComponent) {
|
|
402
|
-
RelatedCardComponent[RelatedCardComponent["token"] = 0] = "token";
|
|
403
|
-
RelatedCardComponent[RelatedCardComponent["meld_part"] = 1] = "meld_part";
|
|
404
|
-
RelatedCardComponent[RelatedCardComponent["meld_result"] = 2] = "meld_result";
|
|
405
|
-
RelatedCardComponent[RelatedCardComponent["combo_piece"] = 3] = "combo_piece";
|
|
406
|
-
})(RelatedCardComponent || (RelatedCardComponent = {}));
|
|
407
|
-
var PromoType;
|
|
408
|
-
(function (PromoType) {
|
|
409
|
-
PromoType[PromoType["tourney"] = 0] = "tourney";
|
|
410
|
-
PromoType[PromoType["prerelease"] = 1] = "prerelease";
|
|
411
|
-
PromoType[PromoType["datestamped"] = 2] = "datestamped";
|
|
412
|
-
PromoType[PromoType["planeswalkerdeck"] = 3] = "planeswalkerdeck";
|
|
413
|
-
PromoType[PromoType["buyabox"] = 4] = "buyabox";
|
|
414
|
-
PromoType[PromoType["judgegift"] = 5] = "judgegift";
|
|
415
|
-
PromoType[PromoType["event"] = 6] = "event";
|
|
416
|
-
PromoType[PromoType["convention"] = 7] = "convention";
|
|
417
|
-
PromoType[PromoType["starterdeck"] = 8] = "starterdeck";
|
|
418
|
-
PromoType[PromoType["instore"] = 9] = "instore";
|
|
419
|
-
PromoType[PromoType["setpromo"] = 10] = "setpromo";
|
|
420
|
-
PromoType[PromoType["fnm"] = 11] = "fnm";
|
|
421
|
-
PromoType[PromoType["openhouse"] = 12] = "openhouse";
|
|
422
|
-
PromoType[PromoType["league"] = 13] = "league";
|
|
423
|
-
PromoType[PromoType["draftweekend"] = 14] = "draftweekend";
|
|
424
|
-
PromoType[PromoType["gameday"] = 15] = "gameday";
|
|
425
|
-
PromoType[PromoType["release"] = 16] = "release";
|
|
426
|
-
PromoType[PromoType["intropack"] = 17] = "intropack";
|
|
427
|
-
PromoType[PromoType["giftbox"] = 18] = "giftbox";
|
|
428
|
-
PromoType[PromoType["duels"] = 19] = "duels";
|
|
429
|
-
PromoType[PromoType["wizardsplaynetwork"] = 20] = "wizardsplaynetwork";
|
|
430
|
-
PromoType[PromoType["premiereshop"] = 21] = "premiereshop";
|
|
431
|
-
PromoType[PromoType["playerrewards"] = 22] = "playerrewards";
|
|
432
|
-
PromoType[PromoType["gateway"] = 23] = "gateway";
|
|
433
|
-
PromoType[PromoType["arenaleague"] = 24] = "arenaleague";
|
|
434
|
-
})(PromoType || (PromoType = {}));
|
|
435
|
-
class CardIdentifier {
|
|
436
|
-
static byId(id) {
|
|
437
|
-
return { id };
|
|
438
|
-
}
|
|
439
|
-
static byMtgoId(id) {
|
|
440
|
-
return { mtgo_id: id };
|
|
441
|
-
}
|
|
442
|
-
static byMultiverseId(id) {
|
|
443
|
-
return { multiverse_id: id };
|
|
444
|
-
}
|
|
445
|
-
static byOracleId(id) {
|
|
446
|
-
return { oracle_id: id };
|
|
447
|
-
}
|
|
448
|
-
static byIllustrationId(id) {
|
|
449
|
-
return { illustration_id: id };
|
|
195
|
+
byId(id) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
return this.query(['cards', id]);
|
|
198
|
+
});
|
|
450
199
|
}
|
|
451
|
-
|
|
452
|
-
return
|
|
200
|
+
byMtgoId(id) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
return this.query(['cards/mtgo', id]);
|
|
203
|
+
});
|
|
453
204
|
}
|
|
454
|
-
|
|
455
|
-
return
|
|
205
|
+
byMultiverseId(id) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
return this.query(['cards/multiverse', id]);
|
|
208
|
+
});
|
|
456
209
|
}
|
|
457
|
-
}
|
|
458
|
-
class Cards extends MagicQuerier {
|
|
459
210
|
byName(name, set, fuzzy = false) {
|
|
460
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
461
212
|
if (typeof set === 'boolean') {
|
|
@@ -468,11 +219,6 @@
|
|
|
468
219
|
});
|
|
469
220
|
});
|
|
470
221
|
}
|
|
471
|
-
byId(id) {
|
|
472
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
473
|
-
return this.query(['cards', id]);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
222
|
bySet(setCode, collectorNumber, lang) {
|
|
477
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
478
224
|
const path = ['cards', setCode, collectorNumber];
|
|
@@ -481,285 +227,40 @@
|
|
|
481
227
|
return this.query(path);
|
|
482
228
|
});
|
|
483
229
|
}
|
|
484
|
-
byMultiverseId(id) {
|
|
485
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
486
|
-
return this.query(['cards/multiverse', id]);
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
byMtgoId(id) {
|
|
490
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
491
|
-
return this.query(['cards/mtgo', id]);
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
byArenaId(id) {
|
|
495
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
return this.query(['cards/arena', id]);
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
230
|
byTcgPlayerId(id) {
|
|
500
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
501
232
|
return this.query(['cards/tcgplayer', id]);
|
|
502
233
|
});
|
|
503
234
|
}
|
|
504
|
-
random() {
|
|
505
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
506
|
-
return this.query('cards/random');
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Returns a MagicEmitter of every card in the Scryfall database that matches the given query.
|
|
511
|
-
*/
|
|
512
|
-
search(query, options) {
|
|
513
|
-
const emitter = new MagicEmitter();
|
|
514
|
-
this.queryPage(emitter, 'cards/search', Object.assign({ q: query }, (typeof options === 'number' ? { page: options } : options))).catch((err) => emitter.emit('error', err));
|
|
515
|
-
return emitter;
|
|
516
|
-
}
|
|
517
|
-
autoCompleteName(name) {
|
|
518
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
519
|
-
return (yield this.query('cards/autocomplete', { q: name }))
|
|
520
|
-
.data;
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
235
|
collection(...identifiers) {
|
|
524
|
-
const emitter = new MagicEmitter();
|
|
525
|
-
void this.processCollection(emitter, identifiers);
|
|
526
|
-
return emitter;
|
|
527
|
-
}
|
|
528
|
-
processCollection(emitter, identifiers) {
|
|
529
236
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const cards = [];
|
|
530
238
|
for (let i = 0; i < identifiers.length; i += 75) {
|
|
531
|
-
if (emitter.cancelled)
|
|
532
|
-
break;
|
|
533
239
|
// the api only supports a max collection size of 75, so we take the list of identifiers (any length)
|
|
534
240
|
// and split it into 75 card-max requests
|
|
535
241
|
const collectionSection = { identifiers: identifiers.slice(i, i + 75) };
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
if (!emitter.cancelled)
|
|
539
|
-
emitter.emitAll('data', ...data);
|
|
540
|
-
if (emitter.willCancelAfterPage)
|
|
541
|
-
emitter.cancel();
|
|
242
|
+
const result = yield this.query('cards/collection', undefined, collectionSection);
|
|
243
|
+
cards.push(...((result === null || result === void 0 ? void 0 : result.data) || []));
|
|
542
244
|
}
|
|
543
|
-
|
|
544
|
-
emitter.emit('end');
|
|
545
|
-
emitter.emit('done');
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
var Cards$1 = new Cards();
|
|
550
|
-
|
|
551
|
-
class Catalog extends MagicQuerier {
|
|
552
|
-
cardNames() {
|
|
553
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
554
|
-
return (yield this.query('catalog/card-names')).data;
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
artistNames() {
|
|
558
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
-
return (yield this.query('catalog/artist-names')).data;
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
wordBank() {
|
|
563
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
-
return (yield this.query('catalog/word-bank')).data;
|
|
245
|
+
return cards;
|
|
565
246
|
});
|
|
566
247
|
}
|
|
567
|
-
|
|
568
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
569
|
-
return (yield this.query('catalog/creature-types')).data;
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
planeswalkerTypes() {
|
|
573
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
574
|
-
return (yield this.query('catalog/planeswalker-types')).data;
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
landTypes() {
|
|
578
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
579
|
-
return (yield this.query('catalog/land-types')).data;
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
artifactTypes() {
|
|
583
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
584
|
-
return (yield this.query('catalog/artifact-types')).data;
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
enchantmentTypes() {
|
|
588
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
589
|
-
return (yield this.query('catalog/enchantment-types')).data;
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
spellTypes() {
|
|
593
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
594
|
-
return (yield this.query('catalog/spell-types')).data;
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
powers() {
|
|
598
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
599
|
-
return (yield this.query('catalog/powers')).data;
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
toughnesses() {
|
|
603
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
604
|
-
return (yield this.query('catalog/toughnesses')).data;
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
loyalties() {
|
|
608
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
609
|
-
return (yield this.query('catalog/loyalties')).data;
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
watermarks() {
|
|
613
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
614
|
-
return (yield this.query('catalog/watermarks')).data;
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
var Catalog$1 = new Catalog();
|
|
619
|
-
|
|
620
|
-
class Misc extends MagicQuerier {
|
|
621
|
-
homepageLinks() {
|
|
622
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
623
|
-
return (yield this.query('homepage-links')).data;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
var Misc$1 = new Misc();
|
|
628
|
-
|
|
629
|
-
class Rulings extends MagicQuerier {
|
|
630
|
-
byId(id) {
|
|
631
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
632
|
-
return (yield this.query(['cards', id, 'rulings'])).data;
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
bySet(setCode, collectorNumber) {
|
|
636
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
637
|
-
return (yield this.query([
|
|
638
|
-
'cards',
|
|
639
|
-
setCode,
|
|
640
|
-
`${collectorNumber}`,
|
|
641
|
-
'rulings',
|
|
642
|
-
])).data;
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
byMultiverseId(id) {
|
|
646
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
647
|
-
return (yield this.query(['cards/multiverse', id, 'rulings']))
|
|
648
|
-
.data;
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
byMtgoId(id) {
|
|
652
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
-
return (yield this.query(['cards/mtgo', id, 'rulings'])).data;
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
byArenaId(id) {
|
|
657
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
-
return (yield this.query(['cards/arena', id, 'rulings']))
|
|
659
|
-
.data;
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
var Rulings$1 = new Rulings();
|
|
664
|
-
|
|
665
|
-
var SetType;
|
|
666
|
-
(function (SetType) {
|
|
667
|
-
SetType[SetType["core"] = 0] = "core";
|
|
668
|
-
SetType[SetType["expansion"] = 1] = "expansion";
|
|
669
|
-
SetType[SetType["masters"] = 2] = "masters";
|
|
670
|
-
SetType[SetType["masterpiece"] = 3] = "masterpiece";
|
|
671
|
-
SetType[SetType["from_the_vault"] = 4] = "from_the_vault";
|
|
672
|
-
SetType[SetType["spellbook"] = 5] = "spellbook";
|
|
673
|
-
SetType[SetType["premium_deck"] = 6] = "premium_deck";
|
|
674
|
-
SetType[SetType["duel_deck"] = 7] = "duel_deck";
|
|
675
|
-
SetType[SetType["draft_innovation"] = 8] = "draft_innovation";
|
|
676
|
-
SetType[SetType["treasure_chest"] = 9] = "treasure_chest";
|
|
677
|
-
SetType[SetType["commander"] = 10] = "commander";
|
|
678
|
-
SetType[SetType["planechase"] = 11] = "planechase";
|
|
679
|
-
SetType[SetType["archenemy"] = 12] = "archenemy";
|
|
680
|
-
SetType[SetType["vanguard"] = 13] = "vanguard";
|
|
681
|
-
SetType[SetType["funny"] = 14] = "funny";
|
|
682
|
-
SetType[SetType["starter"] = 15] = "starter";
|
|
683
|
-
SetType[SetType["box"] = 16] = "box";
|
|
684
|
-
SetType[SetType["promo"] = 17] = "promo";
|
|
685
|
-
SetType[SetType["token"] = 18] = "token";
|
|
686
|
-
SetType[SetType["memorabilia"] = 19] = "memorabilia";
|
|
687
|
-
})(SetType || (SetType = {}));
|
|
688
|
-
class Sets extends MagicQuerier {
|
|
689
|
-
all() {
|
|
690
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
691
|
-
return (yield this.query('sets')).data;
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
byCode(code) {
|
|
695
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
696
|
-
return this.query(['sets', code]);
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
byId(id) {
|
|
700
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
701
|
-
return this.query(['sets', id]);
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
byTcgPlayerId(id) {
|
|
705
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
706
|
-
return this.query(['sets/tcgplayer', id]);
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
var Sets$1 = new Sets();
|
|
711
|
-
|
|
712
|
-
class Symbology extends MagicQuerier {
|
|
713
|
-
all() {
|
|
248
|
+
random() {
|
|
714
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
715
|
-
return
|
|
250
|
+
return this.query('cards/random');
|
|
716
251
|
});
|
|
717
252
|
}
|
|
718
|
-
|
|
719
|
-
return
|
|
720
|
-
|
|
721
|
-
|
|
253
|
+
search(query, options) {
|
|
254
|
+
return new MagicPageResult(this, 'cards/search', Object.assign({ q: query }, (typeof options === 'number'
|
|
255
|
+
? { page: options }
|
|
256
|
+
: Object.assign({ page: 1 }, options))));
|
|
722
257
|
}
|
|
723
258
|
}
|
|
724
|
-
var
|
|
725
|
-
|
|
726
|
-
var Colors;
|
|
727
|
-
(function (Colors) {
|
|
728
|
-
Colors[Colors["W"] = 0] = "W";
|
|
729
|
-
Colors[Colors["B"] = 1] = "B";
|
|
730
|
-
Colors[Colors["R"] = 2] = "R";
|
|
731
|
-
Colors[Colors["U"] = 3] = "U";
|
|
732
|
-
Colors[Colors["G"] = 4] = "G";
|
|
733
|
-
})(Colors || (Colors = {}));
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Returns the last error thrown while querying.
|
|
737
|
-
*/
|
|
738
|
-
function error() {
|
|
739
|
-
return MagicQuerier.lastError;
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Sets the API calls to retry if they fail, for any reason.
|
|
743
|
-
* @param attempts The number of attempts that can be made (includes the initial call).
|
|
744
|
-
* @param timeout The time that the query should wait before attempting the request again.
|
|
745
|
-
* @param canRetry The function.
|
|
746
|
-
*/
|
|
747
|
-
function setRetry(attempts, timeout, canRetry) {
|
|
748
|
-
MagicQuerier.retry = { attempts, timeout, canRetry };
|
|
749
|
-
}
|
|
259
|
+
var Cards$1 = new Cards();
|
|
750
260
|
|
|
751
|
-
exports.BulkData = BulkData$1;
|
|
752
|
-
exports.CardIdentifier = CardIdentifier;
|
|
753
261
|
exports.Cards = Cards$1;
|
|
754
|
-
exports.Catalog = Catalog$1;
|
|
755
|
-
exports.Misc = Misc$1;
|
|
756
|
-
exports.Rulings = Rulings$1;
|
|
757
|
-
exports.Sets = Sets$1;
|
|
758
|
-
exports.Symbology = Symbology$1;
|
|
759
|
-
exports.error = error;
|
|
760
|
-
exports.setRetry = setRetry;
|
|
761
262
|
|
|
762
263
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
763
264
|
|
|
764
|
-
}))
|
|
265
|
+
}));
|
|
765
266
|
//# sourceMappingURL=skryfall.umd.js.map
|