UNPKG

scryfall-sdk

Version:

A Node.js SDK for https://scryfall.com/docs/api written in Typescript.

97 lines (96 loc) 4.63 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.setFuzzySearch = exports.setCacheLimit = exports.setCacheDuration = exports.clearCache = exports.setTimeout = exports.setRetry = exports.setAgent = exports.Symbology = exports.Sets = exports.Rulings = exports.Migrations = exports.Catalog = exports.Cards = exports.BulkData = void 0; const Cards_1 = require("./api/Cards"); const Sets_1 = require("./api/Sets"); const IScry_1 = require("./IScry"); const Cached_1 = require("./util/Cached"); const MagicQuerier_1 = require("./util/MagicQuerier"); __exportStar(require("./api/BulkData"), exports); var BulkData_1 = require("./api/BulkData"); Object.defineProperty(exports, "BulkData", { enumerable: true, get: function () { return BulkData_1.default; } }); __exportStar(require("./api/Cards"), exports); var Cards_2 = require("./api/Cards"); Object.defineProperty(exports, "Cards", { enumerable: true, get: function () { return Cards_2.default; } }); __exportStar(require("./api/Catalog"), exports); var Catalog_1 = require("./api/Catalog"); Object.defineProperty(exports, "Catalog", { enumerable: true, get: function () { return Catalog_1.default; } }); __exportStar(require("./api/Migrations"), exports); var Migrations_1 = require("./api/Migrations"); Object.defineProperty(exports, "Migrations", { enumerable: true, get: function () { return Migrations_1.default; } }); __exportStar(require("./api/Rulings"), exports); var Rulings_1 = require("./api/Rulings"); Object.defineProperty(exports, "Rulings", { enumerable: true, get: function () { return Rulings_1.default; } }); __exportStar(require("./api/Sets"), exports); var Sets_2 = require("./api/Sets"); Object.defineProperty(exports, "Sets", { enumerable: true, get: function () { return Sets_2.default; } }); __exportStar(require("./api/Symbology"), exports); var Symbology_1 = require("./api/Symbology"); Object.defineProperty(exports, "Symbology", { enumerable: true, get: function () { return Symbology_1.default; } }); __exportStar(require("./IScry"), exports); Cards_1.default["Scry"] = exports; Sets_1.default["Scry"] = exports; /** * Sets the name and version of this agent. This is required for all non-browser applications. */ function setAgent(agent, version) { MagicQuerier_1.default.agent = `${agent}/${version}`; } exports.setAgent = setAgent; /** * Sets the API calls to retry if they fail, for any reason. * @param attempts The number of attempts that can be made (includes the initial call). * @param timeout The time that the query should wait before attempting the request again. */ function setRetry(attempts, timeout, canRetry) { MagicQuerier_1.default.retry = { attempts, timeout, canRetry }; } exports.setRetry = setRetry; /** * Sets the API calls to be spaced by at least this amount of time. Respects the minimum requested timeout provided by Scryfall. */ function setTimeout(timeout) { MagicQuerier_1.default.timeout = Math.max(MagicQuerier_1.minimumRequestTimeout, timeout); } exports.setTimeout = setTimeout; /** * Clears the cache */ function clearCache() { Cached_1.default.clear(); } exports.clearCache = clearCache; /** * Sets the duration that most API calls will be cached. By default, the cache duration is 1 day. * To disable caching entirely, set the timeout to `0` */ function setCacheDuration(ms) { Cached_1.default.setDuration(ms); } exports.setCacheDuration = setCacheDuration; /** * Sets the maximum number of query results that can be cached at one time. By default, the maximum is 500 objects. * To disable caching entirely, set the amount to `0` */ function setCacheLimit(amount) { Cached_1.default.setLimit(amount); } exports.setCacheLimit = setCacheLimit; function setFuzzySearch(search) { IScry_1.IScry.fuzzySearch = search; } exports.setFuzzySearch = setFuzzySearch;