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