New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

commander-spellbook

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commander-spellbook - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

dist/get-all-combos.d.ts

33

CHANGELOG.md

@@ -0,1 +1,34 @@

# 0.6.0
- `search`
- Add ability to search for coloreless color identity with `ci:c` and `ci:colorless`
- Add human readable message to describe query
- Add error messages for errors in query parsing
- Add ability to search by number of cards in a combo
- Add ability to search by number of prerequisites in a combo
- Add ability to search by number of steps in a combo
- Add ability to search by number of results in a combo
- Support `cards` as alias for `card`
- Support `-cards` as alias for `-card`
- Support `res` as alias for `result`
- Support `-res` as alias for `-result`
- Add `getAllCombos` method
_Breaking Changes_
- `search`
- Drop support for searching by id
- Now returns a result object instead of an array of combos
- Combos array found on the `combos` property of the result object
- Errors in query are found in the `errors` property of the result object
- `ColorIdentity`
- Remove `numberOfColors` in favor of `size`
- `CardGrouping`
- Remove `matchesAll`
- Remove `matchesAny`
- `List`
- Remove `matchesAll`
- Remove `matchesAny`
- Remove methods that return HTML Elements
# 0.5.2

@@ -2,0 +35,0 @@

2

dist/index.d.ts
import search from "./search";
import random from "./random";
import getAllCombos from "./get-all-combos";
import findById from "./find-by-id";

@@ -9,2 +10,3 @@ import makeFakeCombo from "./make-fake-combo";

random: typeof random;
getAllCombos: typeof getAllCombos;
findById: typeof findById;

@@ -11,0 +13,0 @@ makeFakeCombo: typeof makeFakeCombo;

@@ -7,2 +7,3 @@ "use strict";

var random_1 = __importDefault(require("./random"));
var get_all_combos_1 = __importDefault(require("./get-all-combos"));
var find_by_id_1 = __importDefault(require("./find-by-id"));

@@ -14,2 +15,3 @@ var make_fake_combo_1 = __importDefault(require("./make-fake-combo"));

random: random_1.default,
getAllCombos: get_all_combos_1.default,
findById: find_by_id_1.default,

@@ -16,0 +18,0 @@ makeFakeCombo: make_fake_combo_1.default,

9

dist/models/card-grouping.d.ts

@@ -5,9 +5,6 @@ import Card from "./card";

static create(items?: string[]): CardGrouping;
matchesAll(cardNames: string[]): boolean;
matchesAny(cardNames: string[]): boolean;
size(): number;
includesValue(cardName: string): boolean;
includesValueExactly(cardName: string): boolean;
toString(): string;
toHTMLOrderedList(): HTMLOListElement;
toHTMLUnorderedList(): HTMLUListElement;
toMarkdown(): string;
private toHTMLList;
}

@@ -34,39 +34,16 @@ "use strict";

};
CardGrouping.prototype.matchesAll = function (cardNames) {
var _this = this;
return cardNames.every(function (card) { return _this.find(function (c) { return c.matches(card); }); });
CardGrouping.prototype.size = function () {
return this.length;
};
CardGrouping.prototype.matchesAny = function (cardNames) {
var _this = this;
return Boolean(cardNames.find(function (card) { return _this.find(function (c) { return c.matches(card); }); }));
CardGrouping.prototype.includesValue = function (cardName) {
return Boolean(this.find(function (c) { return c.matchesName(cardName); }));
};
CardGrouping.prototype.includesValueExactly = function (cardName) {
return Boolean(this.find(function (c) { return c.matchesNameExactly(cardName); }));
};
CardGrouping.prototype.toString = function () {
return this.join(" | ");
};
CardGrouping.prototype.toHTMLOrderedList = function () {
return this.toHTMLList("ol");
};
CardGrouping.prototype.toHTMLUnorderedList = function () {
return this.toHTMLList("ul");
};
CardGrouping.prototype.toMarkdown = function () {
return this.reduce(function (md, item) {
if (md) {
md = md + "\n";
}
return md + "- " + item.name;
}, "");
};
CardGrouping.prototype.toHTMLList = function (kind) {
var lis = this.map(function (item) {
var li = document.createElement("li");
li.appendChild(item.toHTML());
return li;
});
var container = document.createElement(kind);
lis.forEach(function (li) { return container.appendChild(li); });
return container;
};
return CardGrouping;
}(Array));
exports.default = CardGrouping;
import scryfall from "scryfall-client";
declare type ToHTMLOptions = {
skipName?: boolean;
skipTooltip?: boolean;
className?: string;
};
export default class Card {

@@ -11,13 +6,8 @@ name: string;

private cardImageURI;
static HAS_TOOLTIP: boolean;
static clearTooltipCache(): void;
static generateTooltip(): HTMLDivElement;
constructor(cardName: string);
matches(cardName: string): boolean;
matchesName(cardName: string): boolean;
matchesNameExactly(cardName: string): boolean;
getScryfallData(): ReturnType<typeof scryfall.getCard>;
getScryfallImageUrl(version?: string): string;
toString(): string;
toImage(version?: string): HTMLImageElement;
toHTML(options?: ToHTMLOptions): HTMLSpanElement;
}
export {};

@@ -8,6 +8,3 @@ "use strict";

var normalize_string_input_1 = __importDefault(require("../normalize-string-input"));
var CARD_BACK = "https://c2.scryfall.com/file/scryfall-errors/missing.jpg";
var CARD_IMAGE_NAMED_BASE_URL = "https://api.scryfall.com/cards/named?format=image&exact=";
var tooltip;
var cardImg;
var Card = /** @class */ (function () {

@@ -20,24 +17,8 @@ function Card(cardName) {

}
Card.clearTooltipCache = function () {
Card.HAS_TOOLTIP = false;
if (tooltip) {
tooltip.style.display == "none";
}
Card.prototype.matchesName = function (cardName) {
return this.normalizedName.indexOf(normalize_string_input_1.default(cardName)) > -1;
};
Card.generateTooltip = function () {
var tooltip = document.createElement("div");
tooltip.classList.add("commander-spellbook-tooltip");
tooltip.style.display = "none";
tooltip.style.pointerEvents = "none";
tooltip.style.position = "fixed";
tooltip.style.zIndex = "9000000";
tooltip.style.borderRadius = "4.75% / 3.5%";
tooltip.style.height = "340px";
tooltip.style.width = "244px";
tooltip.style.overflow = "hidden";
return tooltip;
Card.prototype.matchesNameExactly = function (cardName) {
return this.normalizedName === normalize_string_input_1.default(cardName);
};
Card.prototype.matches = function (cardName) {
return this.normalizedName.indexOf(normalize_string_input_1.default(cardName)) > -1;
};
Card.prototype.getScryfallData = function () {

@@ -56,52 +37,4 @@ return scryfall_client_1.default.getCard(this.name, "exactName");

};
Card.prototype.toImage = function (version) {
var img = document.createElement("img");
img.alt = this.name;
img.src = this.getScryfallImageUrl(version);
return img;
};
Card.prototype.toHTML = function (options) {
var _this = this;
if (options === void 0) { options = {}; }
var span = document.createElement("span");
if (!options.skipName) {
span.innerText = this.name;
}
if (options.className) {
span.className = options.className;
}
if (!options.skipTooltip) {
span.addEventListener("mousemove", function (event) {
if (window.innerWidth < 768) {
// window is too small to bother with presenting card image
return;
}
if (!Card.HAS_TOOLTIP) {
Card.HAS_TOOLTIP = true;
tooltip = Card.generateTooltip();
cardImg = document.createElement("img");
cardImg.src = CARD_BACK;
tooltip.appendChild(cardImg);
document.body.appendChild(tooltip);
}
if (tooltip.style.display !== "block") {
tooltip.style.display = "block";
}
tooltip.style.left = event.clientX + 50 + "px";
tooltip.style.top = event.clientY - 30 + "px";
if (cardImg.src !== _this.cardImageURI) {
cardImg.src = _this.cardImageURI;
}
});
span.addEventListener("mouseout", function () {
if (Card.HAS_TOOLTIP) {
tooltip.style.display = "none";
}
});
}
return span;
};
Card.HAS_TOOLTIP = false;
return Card;
}());
exports.default = Card;

@@ -7,3 +7,3 @@ import type { ColorIdentityColors } from "../types";

private isColorless;
numberOfColors(): number;
size(): number;
isWithin(colors: ColorIdentityColors[]): boolean;

@@ -13,4 +13,2 @@ is(colors: ColorIdentityColors[]): boolean;

toString(): string;
toMarkdown(): string;
toHTML(): DocumentFragment;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var scryfall_client_1 = __importDefault(require("scryfall-client"));
var WUBRG_ORDER = ["w", "u", "b", "r", "g"];

@@ -21,3 +17,3 @@ var ColorIdentity = /** @class */ (function () {

};
ColorIdentity.prototype.numberOfColors = function () {
ColorIdentity.prototype.size = function () {
if (this.isColorless()) {

@@ -47,16 +43,4 @@ return 0;

};
ColorIdentity.prototype.toMarkdown = function () {
return this.colors.map(function (color) { return ":mana" + color + ":"; }).join("");
};
ColorIdentity.prototype.toHTML = function () {
var fragment = document.createDocumentFragment();
this.colors.forEach(function (color) {
var img = document.createElement("img");
img.src = scryfall_client_1.default.getSymbolUrl(color);
fragment.appendChild(img);
});
return fragment;
};
return ColorIdentity;
}());
exports.default = ColorIdentity;

@@ -1,4 +0,1 @@

declare type HTMLListOptions = {
className?: string;
};
export default class SpellbookList extends Array<string> {

@@ -8,12 +5,6 @@ private rawString;

static create(items?: string): SpellbookList;
private findItem;
matchesAll(items: string[]): boolean;
matchesAny(items: string[]): boolean;
size(): number;
includesValue(value: string): boolean;
includesValueExactly(value: string): boolean;
toString(): string;
toHTMLOrderedList(options?: HTMLListOptions): HTMLOListElement;
toHTMLUnorderedList(options?: HTMLListOptions): HTMLUListElement;
toMarkdown(): string;
private replaceManaEmoijiWithHTMLImageString;
private toHTMLList;
}
export {};

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var scryfall_client_1 = __importDefault(require("scryfall-client"));
var normalize_string_input_1 = __importDefault(require("../normalize-string-input"));
// based on https://blog.simontest.net/extend-array-with-typescript-965cc1134b3

@@ -38,12 +38,14 @@ var SpellbookList = /** @class */ (function (_super) {

};
SpellbookList.prototype.findItem = function (item) {
return this.find(function (i) { return i.toLowerCase().indexOf(item.toLowerCase()) > -1; });
SpellbookList.prototype.size = function () {
return this.length;
};
SpellbookList.prototype.matchesAll = function (items) {
var _this = this;
return items.every(function (item) { return _this.findItem(item); });
SpellbookList.prototype.includesValue = function (value) {
value = normalize_string_input_1.default(value);
var foundItem = this.map(normalize_string_input_1.default).find(function (item) { return item.indexOf(value) > -1; });
return Boolean(foundItem);
};
SpellbookList.prototype.matchesAny = function (items) {
var _this = this;
return Boolean(items.find(function (item) { return _this.findItem(item); }));
SpellbookList.prototype.includesValueExactly = function (value) {
value = normalize_string_input_1.default(value);
var foundItem = this.map(normalize_string_input_1.default).find(function (item) { return item === value; });
return Boolean(foundItem);
};

@@ -53,45 +55,4 @@ SpellbookList.prototype.toString = function () {

};
SpellbookList.prototype.toHTMLOrderedList = function (options) {
if (options === void 0) { options = {}; }
return this.toHTMLList("ol", options);
};
SpellbookList.prototype.toHTMLUnorderedList = function (options) {
if (options === void 0) { options = {}; }
return this.toHTMLList("ul", options);
};
SpellbookList.prototype.toMarkdown = function () {
return this.reduce(function (md, item) {
if (md) {
md = md + "\n";
}
return md + "- " + item;
}, "");
};
SpellbookList.prototype.replaceManaEmoijiWithHTMLImageString = function (item) {
return item.replace(/:mana([^:]+):/g, function (_, manaSymbol) {
var url = scryfall_client_1.default.getSymbolUrl(manaSymbol);
return "<img src=\"" + url + "\" />";
});
};
SpellbookList.prototype.toHTMLList = function (kind, options) {
var _this = this;
if (options === void 0) { options = {}; }
var root = "<" + kind;
if (options.className) {
root += " class=\"" + options.className + "\"";
}
root += ">";
var items = this.map(function (item) {
return "<li>" + _this.replaceManaEmoijiWithHTMLImageString(item) + "</li>";
}).join("");
var htmlString = root + "\n " + items + "\n</" + kind + ">";
var fragment = document.createDocumentFragment();
var parser = new window.DOMParser();
var parsed = parser.parseFromString(htmlString, "text/html");
var elements = parsed.getElementsByTagName("body")[0].children;
Array.from(elements).forEach(function (e) { return fragment.appendChild(e); });
return fragment.firstElementChild;
};
return SpellbookList;
}(Array));
exports.default = SpellbookList;

@@ -7,2 +7,3 @@ "use strict";

var parse_color_identity_1 = __importDefault(require("./parse-color-identity"));
var parse_combo_data_1 = __importDefault(require("./parse-combo-data"));
var OPERATORS = [":", "=", ">=", "<=", "<", ">"];

@@ -27,3 +28,3 @@ var OPERATOR_REGEX = new RegExp("(" + OPERATORS.join("|") + ")");

var pair = group.split(operator);
var key = (_a = pair[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
var key = (_a = pair[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase().replace(/_/g, "");
var value = pair[1];

@@ -39,55 +40,35 @@ if (value.length > 2) {

switch (key) {
case "id":
params.id = value;
break;
case "ci":
case "color_identity":
case "-ci":
case "coloridentity":
if (Number(value) >= 0 && Number(value) < 6) {
params.colorIdentity.sizeFilter.method = operator;
params.colorIdentity.sizeFilter.value = Number(value);
}
else {
params.colorIdentity.colorFilter.method = operator;
params.colorIdentity.colorFilter.value = parse_color_identity_1.default(value);
}
case "-coloridentity":
parse_color_identity_1.default(params, key, operator, value);
break;
case "card":
params.cards.include.push(value);
break;
case "cards":
case "-card":
params.cards.exclude.push(value);
break;
case "-cards":
case "pre":
case "prerequisite":
case "prerequisites":
params.prerequisites.include.push(value);
break;
case "-pre":
case "-prerequisite":
case "-prerequisites":
params.prerequisites.exclude.push(value);
break;
case "step":
case "steps":
params.steps.include.push(value);
break;
case "-step":
case "-steps":
params.steps.exclude.push(value);
break;
case "res":
case "result":
case "results":
params.results.include.push(value);
break;
case "-res":
case "-result":
case "-results":
params.results.exclude.push(value);
parse_combo_data_1.default(params, key, operator, value);
break;
default:
params.errors = params.errors || [];
params.errors.push({
key: key,
value: value,
message: "Could not parse keyword \"" + key + "\" with value \"" + value + "\"",
message: "Could not parse keyword \"" + key + "\" with value \"" + value + "\".",
});

@@ -108,3 +89,3 @@ }

queries.forEach(function (value) {
params.cards.include.push(value.trim());
parse_combo_data_1.default(params, "card", ":", value.trim());
});

@@ -115,26 +96,25 @@ }

cards: {
include: [],
exclude: [],
sizeFilters: [],
includeFilters: [],
excludeFilters: [],
},
colorIdentity: {
colorFilter: {
method: "none",
value: [],
},
sizeFilter: {
method: "none",
value: 5,
},
includeFilters: [],
excludeFilters: [],
sizeFilters: [],
},
prerequisites: {
include: [],
exclude: [],
sizeFilters: [],
includeFilters: [],
excludeFilters: [],
},
steps: {
include: [],
exclude: [],
sizeFilters: [],
includeFilters: [],
excludeFilters: [],
},
results: {
include: [],
exclude: [],
sizeFilters: [],
includeFilters: [],
excludeFilters: [],
},

@@ -141,0 +121,0 @@ errors: [],

@@ -1,2 +0,2 @@

import type { ColorIdentityColors } from "../types";
export default function parseColorIdentity(val: string): ColorIdentityColors[];
import type { SearchParameters } from "../types";
export default function parseColorIdentity(params: SearchParameters, key: string, operator: string, value: string): void;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
function parseColorIdentity(val) {
var normalizedValue = val.replace(/[\s-]/g, "").toLowerCase();
switch (normalizedValue) {
case "white":
case "monowhite":
return ["w"];
case "blue":
case "monoblue":
return ["u"];
case "black":
case "monoblack":
return ["b"];
case "red":
case "monored":
return ["r"];
case "green":
case "monogreen":
return ["g"];
case "azorius":
return ["w", "u"];
case "dimir":
return ["u", "b"];
case "rakdos":
return ["b", "r"];
case "gruul":
return ["r", "g"];
case "selesnya":
return ["w", "g"];
case "orzhov":
return ["w", "b"];
case "izzet":
return ["u", "r"];
case "golgari":
return ["b", "g"];
case "boros":
return ["w", "r"];
case "simic":
return ["u", "g"];
case "naya":
return ["w", "r", "g"];
case "esper":
return ["w", "u", "b"];
case "grixis":
return ["u", "b", "r"];
case "jund":
return ["b", "r", "g"];
case "bant":
return ["w", "u", "g"];
case "abzan":
return ["w", "b", "g"];
case "temur":
return ["u", "r", "g"];
case "jeskai":
return ["w", "u", "r"];
case "mardu":
return ["w", "b", "r"];
case "sultai":
return ["b", "u", "g"];
case "glint":
case "sanswhite":
return ["u", "b", "r", "g"];
case "dune":
case "sansblue":
return ["w", "b", "r", "g"];
case "ink":
case "sansblack":
return ["w", "u", "r", "g"];
case "witch":
case "sansred":
return ["w", "u", "b", "g"];
case "yore":
case "sansgreen":
return ["w", "u", "b", "r"];
case "fivecolor":
return ["w", "u", "b", "r", "g"];
var parse_color_from_value_1 = __importDefault(require("./parse-color-from-value"));
function parseColorIdentity(params, key, operator, value) {
var isNegativeKey = key.charAt(0) === "-";
if (Number(value) >= 0 && Number(value) < 6) {
if (isNegativeKey) {
params.errors.push({
key: key,
value: value,
message: "The key \"" + key + "\" does not support operator \"" + operator + "\".",
});
return;
}
params.colorIdentity.sizeFilters.push({
method: operator,
value: Number(value),
});
return;
}
var matches = normalizedValue.match(/[wubrg]/g);
if (!matches) {
return [];
if (isNegativeKey) {
params.colorIdentity.excludeFilters.push({
method: operator,
value: parse_color_from_value_1.default(value),
});
return;
}
var uniqueMatches = new Set(matches);
return Array.from(uniqueMatches);
params.colorIdentity.includeFilters.push({
method: operator,
value: parse_color_from_value_1.default(value),
});
}
exports.default = parseColorIdentity;

@@ -1,2 +0,2 @@

import type { FormattedApiResponse } from "./types";
export default function search(query?: string): Promise<FormattedApiResponse[]>;
import type { SearchResults } from "./types";
export default function search(query?: string): Promise<SearchResults>;

@@ -44,7 +44,10 @@ "use strict";

var parse_query_1 = __importDefault(require("./parse-query"));
var normalize_string_input_1 = __importDefault(require("./normalize-string-input"));
var color_identity_1 = __importDefault(require("./search-filters/color-identity"));
var combo_data_1 = __importDefault(require("./search-filters/combo-data"));
var size_1 = __importDefault(require("./search-filters/size"));
var create_message_1 = __importDefault(require("./parse-query/create-message"));
function search(query) {
if (query === void 0) { query = ""; }
return __awaiter(this, void 0, void 0, function () {
var searchParams, cards, colorIdentityFilter, combos, matchingCombo, sizeValue_1;
var searchParams, errors, combos;
return __generator(this, function (_a) {

@@ -54,96 +57,14 @@ switch (_a.label) {

searchParams = parse_query_1.default(query);
cards = searchParams.cards;
colorIdentityFilter = searchParams.colorIdentity.colorFilter.value;
if (colorIdentityFilter) {
colorIdentityFilter = colorIdentityFilter.map(function (color) {
return normalize_string_input_1.default(color);
});
}
errors = searchParams.errors;
return [4 /*yield*/, spellbook_api_1.default()];
case 1:
combos = _a.sent();
if (searchParams.id) {
matchingCombo = combos.find(function (combo) { return combo.commanderSpellbookId === searchParams.id; });
if (matchingCombo) {
return [2 /*return*/, [matchingCombo]];
}
return [2 /*return*/, []];
}
if (cards.include.length > 0) {
combos = combos.filter(function (combo) { return combo.cards.matchesAll(cards.include); });
}
if (cards.exclude.length > 0) {
combos = combos.filter(function (combo) { return !combo.cards.matchesAny(cards.exclude); });
}
if (colorIdentityFilter.length > 0) {
combos = combos.filter(function (combo) {
switch (searchParams.colorIdentity.colorFilter.method) {
case "=":
return combo.colorIdentity.is(colorIdentityFilter);
case ">":
return (combo.colorIdentity.includes(colorIdentityFilter) &&
!combo.colorIdentity.is(colorIdentityFilter));
case ">=":
return combo.colorIdentity.includes(colorIdentityFilter);
case "<":
return (combo.colorIdentity.isWithin(colorIdentityFilter) &&
!combo.colorIdentity.is(colorIdentityFilter));
case "<=":
case ":":
return combo.colorIdentity.isWithin(colorIdentityFilter);
default:
return true;
}
});
}
if (searchParams.colorIdentity.sizeFilter.method !== "none") {
sizeValue_1 = searchParams.colorIdentity.sizeFilter.value;
combos = combos.filter(function (combo) {
var numberOfColors = combo.colorIdentity.numberOfColors();
switch (searchParams.colorIdentity.sizeFilter.method) {
case ":":
case "=":
return numberOfColors === sizeValue_1;
case ">":
return numberOfColors > sizeValue_1;
case ">=":
return numberOfColors >= sizeValue_1;
case "<":
return numberOfColors < sizeValue_1;
case "<=":
return numberOfColors <= sizeValue_1;
default:
return true;
}
});
}
if (searchParams.prerequisites.include.length > 0) {
combos = combos.filter(function (combo) {
return combo.prerequisites.matchesAll(searchParams.prerequisites.include);
});
}
if (searchParams.prerequisites.exclude.length > 0) {
combos = combos.filter(function (combo) {
return !combo.prerequisites.matchesAny(searchParams.prerequisites.exclude);
});
}
if (searchParams.steps.include.length > 0) {
combos = combos.filter(function (combo) {
return combo.steps.matchesAll(searchParams.steps.include);
});
}
if (searchParams.steps.exclude.length > 0) {
combos = combos.filter(function (combo) { return !combo.steps.matchesAny(searchParams.steps.exclude); });
}
if (searchParams.results.include.length > 0) {
combos = combos.filter(function (combo) {
return combo.results.matchesAll(searchParams.results.include);
});
}
if (searchParams.results.exclude.length > 0) {
combos = combos.filter(function (combo) {
return !combo.results.matchesAny(searchParams.results.exclude);
});
}
return [2 /*return*/, combos];
combos = color_identity_1.default(combos, searchParams);
combos = combo_data_1.default(combos, searchParams);
combos = size_1.default(combos, searchParams);
return [2 /*return*/, {
errors: errors,
combos: combos,
message: create_message_1.default(combos, searchParams),
}];
}

@@ -150,0 +71,0 @@ });

@@ -15,2 +15,7 @@ import type CardGrouping from "./models/card-grouping";

};
export declare type SearchResults = {
combos: FormattedApiResponse[];
errors: SearchError[];
message: string;
};
export declare type FormattedApiResponse = {

@@ -31,23 +36,31 @@ commanderSpellbookId: string;

};
export declare type IncludeExclude = {
include: string[];
exclude: string[];
declare type SizeFilter = {
method: string;
value: number;
};
declare type ValueFilter = {
method: string;
value: string;
};
export declare type Filters = {
sizeFilters: SizeFilter[];
includeFilters: ValueFilter[];
excludeFilters: ValueFilter[];
};
export interface ColorIdentityValueFilter {
method: string;
value: ColorIdentityColors[];
}
export declare type SearchParameters = {
cards: IncludeExclude;
prerequisites: IncludeExclude;
steps: IncludeExclude;
results: IncludeExclude;
id?: string;
cards: Filters;
prerequisites: Filters;
steps: Filters;
results: Filters;
colorIdentity: {
colorFilter: {
method: string;
value: ColorIdentityColors[];
};
sizeFilter: {
method: string;
value: number;
};
sizeFilters: SizeFilter[];
includeFilters: ColorIdentityValueFilter[];
excludeFilters: ColorIdentityValueFilter[];
};
errors: SearchError[];
};
export {};
{
"name": "commander-spellbook",
"version": "0.5.2",
"version": "0.6.0",
"description": "A wrapper for parsing the commander spellbook api.",

@@ -11,7 +11,4 @@ "main": "dist/index.js",

"prepublishOnly": "npm run typescript",
"prebuild": "npm run pretty",
"pretypescript": "rimraf dist",
"pretypescript": "rimraf dist && npm run pretty",
"typescript": "tsc --declaration --project tsconfig.production.json",
"build": "webpack",
"build:watch": "webpack serve",
"predemo": "npm run build",

@@ -44,24 +41,15 @@ "demo": "http-server docs -p 3001",

"check-ecmascript-version-compatibility": "^0.1.1",
"css-loader": "^5.0.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"http-server": "^0.12.3",
"jest": "^26.6.3",
"mkdirp": "^1.0.4",
"postcss": "^8.1.7",
"postcss-loader": "^4.0.4",
"prettier": "^2.1.1",
"rimraf": "^3.0.2",
"style-loader": "^2.0.0",
"tailwindcss": "^1.9.6",
"ts-jest": "^26.4.4",
"ts-loader": "^8.0.11",
"typescript": "^4.0.5",
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
"webpack": "^5.4.0"
},
"dependencies": {
"scryfall-client": "^0.18.5",
"scryfall-client": "^0.18.6",
"superagent": "^6.1.0"

@@ -74,2 +62,3 @@ },

"restoreMocks": true,
"clearMocks": true,
"setupFilesAfterEnv": [

@@ -76,0 +65,0 @@ "./test/helpers/setup.ts"

@@ -80,4 +80,4 @@ ## Commander Spellbook

```js
spellbook.seach().then((combos) => {
// loop over the array of combos
spellbook.search().then((result) => {
result.combos; // loop over the array of combos
});

@@ -89,4 +89,4 @@ ```

```js
spellbook.seach("sydri scepter").then((combos) => {
// all combos that include cards with the name sydri and scepter in them
spellbook.search("sydri scepter").then((result) => {
result.combos; // all combos that include cards with the name sydri and scepter in them
});

@@ -99,5 +99,5 @@ ```

spellbook
.seach("card:'Arjun, the Shifting Flame' card:\"Thought Reflection\"")
.then((combos) => {
// all combos that include cards with the name Arjun, the Shifting Flrame and Thought Reflection
.search("card:'Arjun, the Shifting Flame' card:\"Thought Reflection\"")
.then((result) => {
result.combos; // all combos that include cards with the name Arjun, the Shifting Flrame and Thought Reflection
});

@@ -109,4 +109,4 @@ ```

```js
spellbook.seach("Kiki ci:wbr").then((combos) => {
// all combos that include cards with the name Kiki and have a white/black/red color identity
spellbook.search("Kiki ci:wbr").then((result) => {
result.combos; // all combos that include cards with the name Kiki and have a white/black/red color identity
});

@@ -118,12 +118,12 @@ ```

```js
spellbook.seach("Kiki ci=wbr").then((combos) => {
// all combos that include cards with the name Kiki and have an identity of exactly white/black/red
spellbook.search("Kiki ci=wbr").then((result) => {
result.combos; // all combos that include cards with the name Kiki and have an identity of exactly white/black/red
});
```
Using numbers are also supported:
Using numbers to restrict the number of colors is also supported:
```js
spellbook.seach("Kiki ci>2").then((combos) => {
// all combos that include cards with the name Kiki and have 3 or more colors in her identity
spellbook.search("Kiki ci>2").then((result) => {
result.combos; // all combos that include cards with the name Kiki and have 3 or more colors in her identity
});

@@ -136,10 +136,30 @@ ```

spellbook
.seach(
.search(
"prequisites:'all permanents' steps:'Untap all' results:'infinite' results:'mana'"
)
.then((combos) => {
// all combos that include the prerequisites, steps and results
.then((result) => {
result.combos; // all combos that include the prerequisites, steps and results from the query
});
```
Errors in search can be found in an array of errors:
```js
spellbook.search("unknownkey:value card:Arjun").then((result) => {
const error = result.errors[0];
error.key; // "unknownkey"
error.value; // "value"
error.message; // 'Could not parse keyword "unknownkey" with value "value"'
});
```
A human readable explanation of the search query can be found on the `message` property.
```js
spellbook.search("card:breath result:infinite").then((result) => {
result.message; // 8 combos where cards have a value containing "breath" and results have a value containing "infinite".
});
```
## Random

@@ -150,3 +170,3 @@

```js
spellbook.seach().then((combo) => {
spellbook.random().then((combo) => {
combo; // a randomly chosen combo

@@ -156,2 +176,12 @@ });

## Get All Combos
Look up a all combos using the `getAllCombos` method:
```js
spellbook.getAllCombos().then((combos) => {
combos; // an array of combo results
});
```
## Make Fake Combo

@@ -234,47 +264,2 @@

### toImage
Returns a `img` tag of the card.
```js
card.toImage(); // <img src="https://api.scryfall.com/cards/named?format=image&exact=Rashmi,%2C%20Eternities%20Crafter" />
```
A string may be passed as an argument to specify what kind of image you would like. See the [Scryfyall `version` documentation](https://scryfall.com/docs/api/cards/named) for more details. The possible values are:
- small
- normal
- large
- png
- art_crop
- border_crop
```js
card.toImage("art_crop"); // <img src="https://api.scryfall.com/cards/named?format=image&exact=Rashmi,%2C%20Eternities%20Crafter&version=art_crop" />
```
### toHTML
Returns a `span` tag of the card name that displays the card image when hovered over.
```js
card.toHTML(); // <span>Rashmi, Eternities Crafter</span>
```
It takes an options object:
```
{
skipName?: boolean;
skipTooltip?: boolean;
className?: string;
}
```
`skipName` will not include the name of the card in the span, but will still attach the listeners for display the card image tooltip.
`skipTooltip` will skip adding code to generate the tooltip when hovering over the card name.
`className` will add any classes as the `className` attribute on the `span`.
### ColorIdentity

@@ -300,18 +285,2 @@

### toMarkdown
Returns a string that renders teh color identity as markdown.
```js
ci.toMarkdown(); // :manaw::manau:
```
### toHTML
Returns a document fragment that includes the colors as mana symbols in img tags.
```js
ci.toHTML(); // <img src="https://c2.scryfall.com/file/scryfall-symbols/card-symbols/W.svg"><img src="https://c2.scryfall.com/file/scryfall-symbols/card-symbols/U.svg">
```
### SpellbookList

@@ -361,85 +330,2 @@

#### toHTMLUnorderedList
Provides the list as an `HTMLUListElement`.
```js
list.toHTMLUnorderedList();
// <ul>
// <li>Step 1</li>
// <li>Step 2</li>
// <li>Step 3</li>
// </ul>
```
If a step includes a mana symbol, it is automatically converted to an svg:
```js
list[1] === "Step 2 :manaw:";
list.toHTMLUnorderedList();
// <ul>
// <li>Step 1</li>
// <li>Step 2 <img src="https://c2.scryfall.com/file/scryfall-symbols/card-symbols/W.svg"></li>
// <li>Step 3</li>
// </ul>
```
An options object can be passed when creating the list:
```
{
className?: string;
}
```
`className` will apply a class name string to the `ul` element.
#### toHTMLOrderedList
Provides the list as an `HTMLOListElement`.
```js
list.toHTMLOrderedList();
// <ol>
// <li>Step 1</li>
// <li>Step 2</li>
// <li>Step 3</li>
// </ol>
```
If a step includes a mana symbol, it is automatically converted to an svg:
```js
list[1] === "Step 2 :manaw:";
list.toHTMLOrderedList();
// <ol>
// <li>Step 1</li>
// <li>Step 2 <img src="https://c2.scryfall.com/file/scryfall-symbols/card-symbols/W.svg"></li>
// <li>Step 3</li>
// </ol>
```
An options object can be passed when creating the list:
```
{
className?: string;
}
```
`className` will apply a class name string to the `ol` element.
#### toMarkdown
Provides the list as a markdown string.
```js
list.toMarkdown();
// * Step 1
// * Step 2
// * Step 3
```
If a step includes a mana symbol, it is assumed that your markdown parser will handle the conversion.
# Browser Support

@@ -446,0 +332,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc