UNPKG

@wise-old-man/utils

Version:

A JavaScript/TypeScript client that interfaces and consumes the Wise Old Man API, an API that tracks and measures players' progress in Old School Runescape.

1,587 lines (1,548 loc) 88.3 kB
'use strict'; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function traverseTransform(input, transformation) { if (Array.isArray(input)) { return input.map(item => traverseTransform(item, transformation)); } if (input !== null && typeof input === 'object') { return Object.fromEntries(Object.keys(input).map(key => [key, traverseTransform(input[key], transformation)])); } return transformation(input); } function isValidISODate(input) { if (!input || typeof input !== 'string') return false; // Validate this input string is a ISO 8601 date return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(input); } function transformDates(input) { return traverseTransform(input, val => (isValidISODate(val) ? new Date(val) : val)); } function handleError(status, path, data) { if (!data) return; if (status === 400) { throw new BadRequestError(path, data.message, data.data); } if (status === 403) { throw new ForbiddenError(path, data.message, data.data); } if (status === 404) { throw new NotFoundError(path, data.message); } if (status === 429) { throw new RateLimitError(path, data.message); } if (status === 500) { throw new InternalServerError(path, data.message); } } class BadRequestError extends Error { constructor(resource, message, data) { super(message); this.name = 'BadRequestError'; this.resource = resource; this.statusCode = 400; this.data = data; } } class ForbiddenError extends Error { constructor(resource, message, data) { super(message); this.name = 'ForbiddenError'; this.resource = resource; this.statusCode = 403; this.data = data; } } class NotFoundError extends Error { constructor(resource, message) { super(message); this.name = 'NotFoundError'; this.resource = resource; this.statusCode = 404; } } class RateLimitError extends Error { constructor(resource, message) { super(message); this.name = 'RateLimitError'; this.resource = resource; this.statusCode = 429; } } class InternalServerError extends Error { constructor(resource, message) { super(message); this.name = 'InternalServerError'; this.resource = resource; this.statusCode = 500; } } class BaseAPIClient { constructor(headers, baseUrl) { this.baseUrl = baseUrl; this.headers = Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, headers); } buildParams(_a) { var params = __rest(_a, []); const builder = new URLSearchParams(); Object.keys(params) .filter(k => params[k] !== undefined) .forEach(k => builder.set(k, params[k])); const query = builder.toString(); return query ? `?${query}` : ''; } fetch(_a) { return __awaiter(this, arguments, void 0, function* ({ method, path, body, params }) { const req = { method, body: undefined, headers: this.headers }; let query = ''; if (body) { req.body = JSON.stringify(body); } if (params) { query = this.buildParams(params); } return yield fetch(this.baseUrl + path + query, req); }); } request(_a) { return __awaiter(this, arguments, void 0, function* ({ method, path, body, params }) { const res = yield this.fetch({ method, path, body, params }); const data = yield res.json(); if (res.ok) { return transformDates(data); } handleError(res.status, path, data); }); } requestText(_a) { return __awaiter(this, arguments, void 0, function* ({ method, path, body, params }) { const res = yield this.fetch({ method, path, body, params }); const text = yield res.text(); if (res.ok) { return text; } handleError(res.status, path, JSON.parse(text)); }); } postRequest(path, body) { return __awaiter(this, void 0, void 0, function* () { return yield this.request({ method: 'POST', path, body: body || {} }); }); } putRequest(path, body) { return __awaiter(this, void 0, void 0, function* () { return yield this.request({ method: 'PUT', path, body: body || {} }); }); } deleteRequest(path, body) { return __awaiter(this, void 0, void 0, function* () { return yield this.request({ method: 'DELETE', path, body: body || {} }); }); } getRequest(path, params) { return __awaiter(this, void 0, void 0, function* () { return yield this.request({ method: 'GET', path, params }); }); } getText(path, params) { return __awaiter(this, void 0, void 0, function* () { return yield this.requestText({ method: 'GET', path, params }); }); } } class CompetitionsClient extends BaseAPIClient { /** * Searches for competitions that match a title, type, metric and status filter. * @returns A list of competitions. */ searchCompetitions(filter, pagination) { return this.getRequest('/competitions', Object.assign(Object.assign({}, filter), pagination)); } /** * Fetches the competition's full details, including all the participants and their progress. * @returns A competition with a list of participants. */ getCompetitionDetails(id, previewMetric) { return this.getRequest(`/competitions/${id}`, { metric: previewMetric }); } /** * Fetches the competition's participant list in CSV format. * @returns A string containing the CSV content. */ getCompetitionDetailsCSV(id, params) { return this.getText(`/competitions/${id}/csv`, Object.assign({ metric: params.previewMetric }, params)); } /** * Fetches all the values (exp, kc, etc) in chronological order within the bounds * of the competition, for the top 5 participants. * @returns A list of competition progress objects, including the player and their value history over time. */ getCompetitionTopHistory(id, previewMetric) { return this.getRequest(`/competitions/${id}/top-history`, { metric: previewMetric }); } /** * Creates a new competition. * @returns The newly created competition, and the verification code that authorizes future changes to it. */ createCompetition(payload) { return this.postRequest('/competitions', payload); } /** * Edits an existing competition. * @returns The updated competition. */ editCompetition(id, payload, verificationCode) { return this.putRequest(`/competitions/${id}`, Object.assign(Object.assign({}, payload), { verificationCode })); } /** * Deletes an existing competition. * @returns A confirmation message. */ deleteCompetition(id, verificationCode) { return this.deleteRequest(`/competitions/${id}`, { verificationCode }); } /** * Adds all (valid) given participants to a competition, ignoring duplicates. * @returns The number of participants added and a confirmation message. */ addParticipants(id, participants, verificationCode) { return this.postRequest(`/competitions/${id}/participants`, { verificationCode, participants }); } /** * Remove all given usernames from a competition, ignoring usernames that aren't competing. * @returns The number of participants removed and a confirmation message. */ removeParticipants(id, participants, verificationCode) { return this.deleteRequest(`/competitions/${id}/participants`, { verificationCode, participants }); } /** * Adds all (valid) given teams to a team competition, ignoring duplicates. * @returns The number of participants added and a confirmation message. */ addTeams(id, teams, verificationCode) { return this.postRequest(`/competitions/${id}/teams`, { verificationCode, teams }); } /** * Remove all given team names from a competition, ignoring names that don't exist. * @returns The number of participants removed and a confirmation message. */ removeTeams(id, teamNames, verificationCode) { return this.deleteRequest(`/competitions/${id}/teams`, { verificationCode, teamNames }); } /** * Adds an "update" request to the queue, for each outdated competition participant. * @returns The number of players to be updated and a confirmation message. */ updateAll(id, verificationCode) { return this.postRequest(`/competitions/${id}/update-all`, { verificationCode }); } } class DeltasClient extends BaseAPIClient { /** * Fetches the current top leaderboard for a specific metric, period, playerType, playerBuild and country. * @returns A list of deltas, with their respective players, values and dates included. */ getDeltaLeaderboard(filter) { return this.getRequest('/deltas/leaderboard', filter); } } exports.CompetitionCSVTableType = void 0; (function (CompetitionCSVTableType) { CompetitionCSVTableType["TEAM"] = "team"; CompetitionCSVTableType["TEAMS"] = "teams"; CompetitionCSVTableType["PARTICIPANTS"] = "participants"; })(exports.CompetitionCSVTableType || (exports.CompetitionCSVTableType = {})); exports.CompetitionStatus = void 0; (function (CompetitionStatus) { CompetitionStatus["UPCOMING"] = "upcoming"; CompetitionStatus["ONGOING"] = "ongoing"; CompetitionStatus["FINISHED"] = "finished"; })(exports.CompetitionStatus || (exports.CompetitionStatus = {})); const COMPETITION_STATUSES = Object.values(exports.CompetitionStatus); const CompetitionTimeEventStatus = { WAITING: 'waiting', EXECUTING: 'executing', COMPLETED: 'completed', FAILED: 'failed', CANCELED: 'canceled' }; const CompetitionTimeEventType = { AFTER_START: 'after_start', BEFORE_START: 'before_start', BEFORE_END: 'before_end', DURING: 'during' }; const CompetitionType = { CLASSIC: 'classic', TEAM: 'team' }; const COMPETITION_TYPES = Object.values(CompetitionType); const Country = { AD: 'AD', AE: 'AE', AF: 'AF', AG: 'AG', AI: 'AI', AL: 'AL', AM: 'AM', AO: 'AO', AQ: 'AQ', AR: 'AR', AS: 'AS', AT: 'AT', AU: 'AU', AW: 'AW', AX: 'AX', AZ: 'AZ', BA: 'BA', BB: 'BB', BD: 'BD', BE: 'BE', BF: 'BF', BG: 'BG', BH: 'BH', BI: 'BI', BJ: 'BJ', BL: 'BL', BM: 'BM', BN: 'BN', BO: 'BO', BQ: 'BQ', BR: 'BR', BS: 'BS', BT: 'BT', BV: 'BV', BW: 'BW', BY: 'BY', BZ: 'BZ', CA: 'CA', CC: 'CC', CD: 'CD', CF: 'CF', CG: 'CG', CH: 'CH', CI: 'CI', CK: 'CK', CL: 'CL', CM: 'CM', CN: 'CN', CO: 'CO', CR: 'CR', CU: 'CU', CV: 'CV', CW: 'CW', CX: 'CX', CY: 'CY', CZ: 'CZ', DE: 'DE', DJ: 'DJ', DK: 'DK', DM: 'DM', DO: 'DO', DZ: 'DZ', EC: 'EC', EE: 'EE', EG: 'EG', EH: 'EH', ER: 'ER', ES: 'ES', ET: 'ET', FI: 'FI', FJ: 'FJ', FK: 'FK', FM: 'FM', FO: 'FO', FR: 'FR', GA: 'GA', GB: 'GB', GB_ENG: 'GB_ENG', GB_NIR: 'GB_NIR', GB_SCT: 'GB_SCT', GB_WLS: 'GB_WLS', GD: 'GD', GE: 'GE', GF: 'GF', GG: 'GG', GH: 'GH', GI: 'GI', GL: 'GL', GM: 'GM', GN: 'GN', GP: 'GP', GQ: 'GQ', GR: 'GR', GS: 'GS', GT: 'GT', GU: 'GU', GW: 'GW', GY: 'GY', HK: 'HK', HM: 'HM', HN: 'HN', HR: 'HR', HT: 'HT', HU: 'HU', ID: 'ID', IE: 'IE', IL: 'IL', IM: 'IM', IN: 'IN', IO: 'IO', IQ: 'IQ', IR: 'IR', IS: 'IS', IT: 'IT', JE: 'JE', JM: 'JM', JO: 'JO', JP: 'JP', KE: 'KE', KG: 'KG', KH: 'KH', KI: 'KI', KM: 'KM', KN: 'KN', KP: 'KP', KR: 'KR', KW: 'KW', KY: 'KY', KZ: 'KZ', LA: 'LA', LB: 'LB', LC: 'LC', LI: 'LI', LK: 'LK', LR: 'LR', LS: 'LS', LT: 'LT', LU: 'LU', LV: 'LV', LY: 'LY', MA: 'MA', MC: 'MC', MD: 'MD', ME: 'ME', MF: 'MF', MG: 'MG', MH: 'MH', MK: 'MK', ML: 'ML', MM: 'MM', MN: 'MN', MO: 'MO', MP: 'MP', MQ: 'MQ', MR: 'MR', MS: 'MS', MT: 'MT', MU: 'MU', MV: 'MV', MW: 'MW', MX: 'MX', MY: 'MY', MZ: 'MZ', NA: 'NA', NC: 'NC', NE: 'NE', NF: 'NF', NG: 'NG', NI: 'NI', NL: 'NL', NO: 'NO', NP: 'NP', NR: 'NR', NU: 'NU', NZ: 'NZ', OM: 'OM', PA: 'PA', PE: 'PE', PF: 'PF', PG: 'PG', PH: 'PH', PK: 'PK', PL: 'PL', PM: 'PM', PN: 'PN', PR: 'PR', PS: 'PS', PT: 'PT', PW: 'PW', PY: 'PY', QA: 'QA', RE: 'RE', RO: 'RO', RS: 'RS', RU: 'RU', RW: 'RW', SA: 'SA', SB: 'SB', SC: 'SC', SD: 'SD', SE: 'SE', SG: 'SG', SH: 'SH', SI: 'SI', SJ: 'SJ', SK: 'SK', SL: 'SL', SM: 'SM', SN: 'SN', SO: 'SO', SR: 'SR', SS: 'SS', ST: 'ST', SV: 'SV', SX: 'SX', SY: 'SY', SZ: 'SZ', TC: 'TC', TD: 'TD', TF: 'TF', TG: 'TG', TH: 'TH', TJ: 'TJ', TK: 'TK', TL: 'TL', TM: 'TM', TN: 'TN', TO: 'TO', TR: 'TR', TT: 'TT', TV: 'TV', TW: 'TW', TZ: 'TZ', UA: 'UA', UG: 'UG', UM: 'UM', US: 'US', UY: 'UY', UZ: 'UZ', VA: 'VA', VC: 'VC', VE: 'VE', VG: 'VG', VI: 'VI', VN: 'VN', VU: 'VU', WF: 'WF', WS: 'WS', YE: 'YE', YT: 'YT', ZA: 'ZA', ZM: 'ZM', ZW: 'ZW' }; const COUNTRY_CODES = Object.values(Country); exports.EfficiencyAlgorithmType = void 0; (function (EfficiencyAlgorithmType) { EfficiencyAlgorithmType["MAIN"] = "main"; EfficiencyAlgorithmType["IRONMAN"] = "ironman"; EfficiencyAlgorithmType["ULTIMATE"] = "ultimate"; EfficiencyAlgorithmType["LVL3"] = "lvl3"; EfficiencyAlgorithmType["F2P"] = "f2p"; EfficiencyAlgorithmType["F2P_LVL3"] = "f2p_lvl3"; EfficiencyAlgorithmType["F2P_IRONMAN"] = "f2p_ironman"; EfficiencyAlgorithmType["F2P_LVL3_IRONMAN"] = "f2p_lvl3_ironman"; EfficiencyAlgorithmType["DEF1"] = "def1"; })(exports.EfficiencyAlgorithmType || (exports.EfficiencyAlgorithmType = {})); const GroupRole = { ACHIEVER: 'achiever', ADAMANT: 'adamant', ADEPT: 'adept', ADMINISTRATOR: 'administrator', ADMIRAL: 'admiral', ADVENTURER: 'adventurer', AIR: 'air', ANCHOR: 'anchor', APOTHECARY: 'apothecary', ARCHER: 'archer', ARMADYLEAN: 'armadylean', ARTILLERY: 'artillery', ARTISAN: 'artisan', ASGARNIAN: 'asgarnian', ASSASSIN: 'assassin', ASSISTANT: 'assistant', ASTRAL: 'astral', ATHLETE: 'athlete', ATTACKER: 'attacker', BANDIT: 'bandit', BANDOSIAN: 'bandosian', BARBARIAN: 'barbarian', BATTLEMAGE: 'battlemage', BEAST: 'beast', BERSERKER: 'berserker', BLISTERWOOD: 'blisterwood', BLOOD: 'blood', BLUE: 'blue', BOB: 'bob', BODY: 'body', BRASSICAN: 'brassican', BRAWLER: 'brawler', BRIGADIER: 'brigadier', BRIGAND: 'brigand', BRONZE: 'bronze', BRUISER: 'bruiser', BULWARK: 'bulwark', BURGLAR: 'burglar', BURNT: 'burnt', CADET: 'cadet', CAPTAIN: 'captain', CARRY: 'carry', CHAMPION: 'champion', CHAOS: 'chaos', CLERIC: 'cleric', COLLECTOR: 'collector', COLONEL: 'colonel', COMMANDER: 'commander', COMPETITOR: 'competitor', COMPLETIONIST: 'completionist', CONSTRUCTOR: 'constructor', COOK: 'cook', COORDINATOR: 'coordinator', CORPORAL: 'corporal', COSMIC: 'cosmic', COUNCILLOR: 'councillor', CRAFTER: 'crafter', CREW: 'crew', CRUSADER: 'crusader', CUTPURSE: 'cutpurse', DEATH: 'death', DEFENDER: 'defender', DEFILER: 'defiler', DEPUTY_OWNER: 'deputy_owner', DESTROYER: 'destroyer', DIAMOND: 'diamond', DISEASED: 'diseased', DOCTOR: 'doctor', DOGSBODY: 'dogsbody', DRAGON: 'dragon', DRAGONSTONE: 'dragonstone', DRUID: 'druid', DUELLIST: 'duellist', EARTH: 'earth', ELITE: 'elite', EMERALD: 'emerald', ENFORCER: 'enforcer', EPIC: 'epic', EXECUTIVE: 'executive', EXPERT: 'expert', EXPLORER: 'explorer', FARMER: 'farmer', FEEDER: 'feeder', FIGHTER: 'fighter', FIRE: 'fire', FIREMAKER: 'firemaker', FIRESTARTER: 'firestarter', FISHER: 'fisher', FLETCHER: 'fletcher', FORAGER: 'forager', FREMENNIK: 'fremennik', GAMER: 'gamer', GATHERER: 'gatherer', GENERAL: 'general', GNOME_CHILD: 'gnome_child', GNOME_ELDER: 'gnome_elder', GOBLIN: 'goblin', GOLD: 'gold', GOON: 'goon', GREEN: 'green', GREY: 'grey', GUARDIAN: 'guardian', GUTHIXIAN: 'guthixian', HARPOON: 'harpoon', HEALER: 'healer', HELLCAT: 'hellcat', HELPER: 'helper', HERBOLOGIST: 'herbologist', HERO: 'hero', HOLY: 'holy', HOARDER: 'hoarder', HUNTER: 'hunter', IGNITOR: 'ignitor', ILLUSIONIST: 'illusionist', IMP: 'imp', INFANTRY: 'infantry', INQUISITOR: 'inquisitor', IRON: 'iron', JADE: 'jade', JUSTICIAR: 'justiciar', KANDARIN: 'kandarin', KARAMJAN: 'karamjan', KHARIDIAN: 'kharidian', KITTEN: 'kitten', KNIGHT: 'knight', LABOURER: 'labourer', LAW: 'law', LEADER: 'leader', LEARNER: 'learner', LEGACY: 'legacy', LEGEND: 'legend', LEGIONNAIRE: 'legionnaire', LIEUTENANT: 'lieutenant', LOOTER: 'looter', LUMBERJACK: 'lumberjack', MAGIC: 'magic', MAGICIAN: 'magician', MAJOR: 'major', MAPLE: 'maple', MARSHAL: 'marshal', MASTER: 'master', MAXED: 'maxed', MEDIATOR: 'mediator', MEDIC: 'medic', MENTOR: 'mentor', MEMBER: 'member', MERCHANT: 'merchant', MIND: 'mind', MINER: 'miner', MINION: 'minion', MISTHALINIAN: 'misthalinian', MITHRIL: 'mithril', MODERATOR: 'moderator', MONARCH: 'monarch', MORYTANIAN: 'morytanian', MYSTIC: 'mystic', MYTH: 'myth', NATURAL: 'natural', NATURE: 'nature', NECROMANCER: 'necromancer', NINJA: 'ninja', NOBLE: 'noble', NOVICE: 'novice', NURSE: 'nurse', OAK: 'oak', OFFICER: 'officer', ONYX: 'onyx', OPAL: 'opal', ORACLE: 'oracle', ORANGE: 'orange', OWNER: 'owner', PAGE: 'page', PALADIN: 'paladin', PAWN: 'pawn', PILGRIM: 'pilgrim', PINE: 'pine', PINK: 'pink', PREFECT: 'prefect', PRIEST: 'priest', PRIVATE: 'private', PRODIGY: 'prodigy', PROSELYTE: 'proselyte', PROSPECTOR: 'prospector', PROTECTOR: 'protector', PURE: 'pure', PURPLE: 'purple', PYROMANCER: 'pyromancer', QUESTER: 'quester', RACER: 'racer', RAIDER: 'raider', RANGER: 'ranger', RECORD_CHASER: 'record_chaser', RECRUIT: 'recruit', RECRUITER: 'recruiter', RED_TOPAZ: 'red_topaz', RED: 'red', ROGUE: 'rogue', RUBY: 'ruby', RUNE: 'rune', RUNECRAFTER: 'runecrafter', SAGE: 'sage', SAPPHIRE: 'sapphire', SARADOMINIST: 'saradominist', SAVIOUR: 'saviour', SCAVENGER: 'scavenger', SCHOLAR: 'scholar', SCOURGE: 'scourge', SCOUT: 'scout', SCRIBE: 'scribe', SEER: 'seer', SENATOR: 'senator', SENTRY: 'sentry', SERENIST: 'serenist', SERGEANT: 'sergeant', SHAMAN: 'shaman', SHERIFF: 'sheriff', SHORT_GREEN_GUY: 'short_green_guy', SKILLER: 'skiller', SKULLED: 'skulled', SLAYER: 'slayer', SMITER: 'smiter', SMITH: 'smith', SMUGGLER: 'smuggler', SNIPER: 'sniper', SOUL: 'soul', SPECIALIST: 'specialist', SPEED_RUNNER: 'speed_runner', SPELLCASTER: 'spellcaster', SQUIRE: 'squire', STAFF: 'staff', STEEL: 'steel', STRIDER: 'strider', STRIKER: 'striker', SUMMONER: 'summoner', SUPERIOR: 'superior', SUPERVISOR: 'supervisor', TEACHER: 'teacher', TEMPLAR: 'templar', THERAPIST: 'therapist', THIEF: 'thief', TIRANNIAN: 'tirannian', TRIALIST: 'trialist', TRICKSTER: 'trickster', TZKAL: 'tzkal', TZTOK: 'tztok', UNHOLY: 'unholy', VAGRANT: 'vagrant', VANGUARD: 'vanguard', WALKER: 'walker', WANDERER: 'wanderer', WARDEN: 'warden', WARLOCK: 'warlock', WARRIOR: 'warrior', WATER: 'water', WILD: 'wild', WILLOW: 'willow', WILY: 'wily', WINTUMBER: 'wintumber', WITCH: 'witch', WIZARD: 'wizard', WORKER: 'worker', WRATH: 'wrath', XERICIAN: 'xerician', YELLOW: 'yellow', YEW: 'yew', ZAMORAKIAN: 'zamorakian', ZAROSIAN: 'zarosian', ZEALOT: 'zealot', ZENYTE: 'zenyte' }; const GROUP_ROLES = Object.values(GroupRole); const MemberActivityType = { JOINED: 'joined', LEFT: 'left', CHANGED_ROLE: 'changed_role' }; exports.MetricMeasure = void 0; (function (MetricMeasure) { MetricMeasure["EXPERIENCE"] = "experience"; MetricMeasure["KILLS"] = "kills"; MetricMeasure["SCORE"] = "score"; MetricMeasure["VALUE"] = "value"; })(exports.MetricMeasure || (exports.MetricMeasure = {})); exports.MetricType = void 0; (function (MetricType) { MetricType["SKILL"] = "skill"; MetricType["BOSS"] = "boss"; MetricType["ACTIVITY"] = "activity"; MetricType["COMPUTED"] = "computed"; })(exports.MetricType || (exports.MetricType = {})); const Skill = { OVERALL: 'overall', ATTACK: 'attack', DEFENCE: 'defence', STRENGTH: 'strength', HITPOINTS: 'hitpoints', RANGED: 'ranged', PRAYER: 'prayer', MAGIC: 'magic', COOKING: 'cooking', WOODCUTTING: 'woodcutting', FLETCHING: 'fletching', FISHING: 'fishing', FIREMAKING: 'firemaking', CRAFTING: 'crafting', SMITHING: 'smithing', MINING: 'mining', HERBLORE: 'herblore', AGILITY: 'agility', THIEVING: 'thieving', SLAYER: 'slayer', FARMING: 'farming', RUNECRAFTING: 'runecrafting', HUNTER: 'hunter', CONSTRUCTION: 'construction', SAILING: 'sailing' }; const Activity = { BOUNTY_HUNTER_HUNTER: 'bounty_hunter_hunter', BOUNTY_HUNTER_ROGUE: 'bounty_hunter_rogue', CLUE_SCROLLS_ALL: 'clue_scrolls_all', CLUE_SCROLLS_BEGINNER: 'clue_scrolls_beginner', CLUE_SCROLLS_EASY: 'clue_scrolls_easy', CLUE_SCROLLS_MEDIUM: 'clue_scrolls_medium', CLUE_SCROLLS_HARD: 'clue_scrolls_hard', CLUE_SCROLLS_ELITE: 'clue_scrolls_elite', CLUE_SCROLLS_MASTER: 'clue_scrolls_master', LAST_MAN_STANDING: 'last_man_standing', PVP_ARENA: 'pvp_arena', SOUL_WARS_ZEAL: 'soul_wars_zeal', GUARDIANS_OF_THE_RIFT: 'guardians_of_the_rift', COLOSSEUM_GLORY: 'colosseum_glory', COLLECTIONS_LOGGED: 'collections_logged' }; const Boss = { ABYSSAL_SIRE: 'abyssal_sire', ALCHEMICAL_HYDRA: 'alchemical_hydra', AMOXLIATL: 'amoxliatl', ARAXXOR: 'araxxor', ARTIO: 'artio', BARROWS_CHESTS: 'barrows_chests', BRUTUS: 'brutus', BRYOPHYTA: 'bryophyta', CALLISTO: 'callisto', CALVARION: 'calvarion', CERBERUS: 'cerberus', CHAMBERS_OF_XERIC: 'chambers_of_xeric', CHAMBERS_OF_XERIC_CM: 'chambers_of_xeric_challenge_mode', CHAOS_ELEMENTAL: 'chaos_elemental', CHAOS_FANATIC: 'chaos_fanatic', COMMANDER_ZILYANA: 'commander_zilyana', CORPOREAL_BEAST: 'corporeal_beast', CRAZY_ARCHAEOLOGIST: 'crazy_archaeologist', DAGANNOTH_PRIME: 'dagannoth_prime', DAGANNOTH_REX: 'dagannoth_rex', DAGANNOTH_SUPREME: 'dagannoth_supreme', DERANGED_ARCHAEOLOGIST: 'deranged_archaeologist', DOOM_OF_MOKHAIOTL: 'doom_of_mokhaiotl', DUKE_SUCELLUS: 'duke_sucellus', GENERAL_GRAARDOR: 'general_graardor', GIANT_MOLE: 'giant_mole', GROTESQUE_GUARDIANS: 'grotesque_guardians', HESPORI: 'hespori', KALPHITE_QUEEN: 'kalphite_queen', KING_BLACK_DRAGON: 'king_black_dragon', KRAKEN: 'kraken', KREEARRA: 'kreearra', KRIL_TSUTSAROTH: 'kril_tsutsaroth', LUNAR_CHESTS: 'lunar_chests', MAGGOT_KING: 'maggot_king', MIMIC: 'mimic', NEX: 'nex', NIGHTMARE: 'nightmare', PHOSANIS_NIGHTMARE: 'phosanis_nightmare', OBOR: 'obor', PHANTOM_MUSPAH: 'phantom_muspah', SARACHNIS: 'sarachnis', SCORPIA: 'scorpia', SCURRIUS: 'scurrius', SHELLBANE_GRYPHON: 'shellbane_gryphon', SKOTIZO: 'skotizo', SOL_HEREDIT: 'sol_heredit', SPINDEL: 'spindel', TEMPOROSS: 'tempoross', THE_GAUNTLET: 'the_gauntlet', THE_CORRUPTED_GAUNTLET: 'the_corrupted_gauntlet', THE_HUEYCOATL: 'the_hueycoatl', THE_LEVIATHAN: 'the_leviathan', THE_ROYAL_TITANS: 'the_royal_titans', THE_WHISPERER: 'the_whisperer', THEATRE_OF_BLOOD: 'theatre_of_blood', THEATRE_OF_BLOOD_HARD_MODE: 'theatre_of_blood_hard_mode', THERMONUCLEAR_SMOKE_DEVIL: 'thermonuclear_smoke_devil', TOMBS_OF_AMASCUT: 'tombs_of_amascut', TOMBS_OF_AMASCUT_EXPERT: 'tombs_of_amascut_expert', TZKAL_ZUK: 'tzkal_zuk', TZTOK_JAD: 'tztok_jad', VARDORVIS: 'vardorvis', VENENATIS: 'venenatis', VETION: 'vetion', VORKATH: 'vorkath', WINTERTODT: 'wintertodt', YAMA: 'yama', ZALCANO: 'zalcano', ZULRAH: 'zulrah' }; const ComputedMetric = { EHP: 'ehp', EHB: 'ehb' }; const Metric = Object.assign(Object.assign(Object.assign(Object.assign({}, Skill), Activity), Boss), ComputedMetric); const METRICS = Object.values(Metric); const SKILLS = Object.values(Skill); const BOSSES = Object.values(Boss); const ACTIVITIES = Object.values(Activity); const COMPUTED_METRICS = Object.values(ComputedMetric); const NameChangeStatus = { PENDING: 'pending', DENIED: 'denied', APPROVED: 'approved' }; const Period = { FIVE_MIN: 'five_min', DAY: 'day', WEEK: 'week', MONTH: 'month', YEAR: 'year' }; const PERIODS = Object.values(Period); const PlayerAnnotationType = { OPT_OUT: 'opt_out', OPT_OUT_GROUPS: 'opt_out_groups', OPT_OUT_COMPETITIONS: 'opt_out_competitions', BLOCKED: 'blocked', FAKE_F2P: 'fake_f2p' }; const PlayerBuild = { MAIN: 'main', F2P: 'f2p', F2P_LVL3: 'f2p_lvl3', LVL3: 'lvl3', ZERKER: 'zerker', DEF1: 'def1', HP10: 'hp10' }; const PLAYER_BUILDS = Object.values(PlayerBuild); const PlayerStatus = { ACTIVE: 'active', UNRANKED: 'unranked', FLAGGED: 'flagged', ARCHIVED: 'archived', BANNED: 'banned' }; const PLAYER_STATUSES = Object.values(PlayerStatus); const PlayerType = { UNKNOWN: 'unknown', REGULAR: 'regular', IRONMAN: 'ironman', HARDCORE: 'hardcore', ULTIMATE: 'ultimate' }; const PLAYER_TYPES = Object.values(PlayerType); class EfficiencyClient extends BaseAPIClient { /** * Fetches the current efficiency leaderboard for a specific efficiency metric, playerType, playerBuild and country. * @returns A list of players. */ getEfficiencyLeaderboards(filter, pagination) { return this.getRequest('/efficiency/leaderboard', Object.assign(Object.assign({}, filter), pagination)); } /** * Fetches the top EHP (Efficient Hours Played) rates. * @returns A list of skilling methods and their bonus exp ratios. */ getEHPRates(algorithmType) { return this.getRequest('/efficiency/rates', { metric: Metric.EHP, type: algorithmType }); } /** * Fetches the top EHB (Efficient Hours Bossed) rates. * @returns A list of bosses and their respective "per-hour" kill rates. */ getEHBRates(algorithmType) { return this.getRequest('/efficiency/rates', { metric: Metric.EHB, type: algorithmType }); } } class GroupsClient extends BaseAPIClient { /** * Searches for groups that match a partial name. * @returns A list of groups. */ searchGroups(name, pagination) { return this.getRequest('/groups', Object.assign({ name }, pagination)); } /** * Fetches a group's details, including a list of membership objects. * @returns A group details object. */ getGroupDetails(id) { return this.getRequest(`/groups/${id}`); } /** * Creates a new group. * @returns The newly created group, and the verification code that authorizes future changes to it. */ createGroup(payload) { return this.postRequest('/groups', payload); } /** * Edits an existing group. * @returns The updated group. */ editGroup(id, payload, verificationCode) { return this.putRequest(`/groups/${id}`, Object.assign(Object.assign({}, payload), { verificationCode })); } /** * Deletes an existing group. * @returns A confirmation message. */ deleteGroup(id, verificationCode) { return this.deleteRequest(`/groups/${id}`, { verificationCode }); } /** * Adds all (valid) given usernames (and roles) to a group, ignoring duplicates. * @returns The number of members added and a confirmation message. */ addMembers(id, members, verificationCode) { return this.postRequest(`/groups/${id}/members`, { verificationCode, members }); } /** * Remove all given usernames from a group, ignoring usernames that aren't members. * @returns The number of members removed and a confirmation message. */ removeMembers(id, usernames, verificationCode) { return this.deleteRequest(`/groups/${id}/members`, { verificationCode, members: usernames }); } /** * Changes a player's role in a given group. * @returns The updated membership, with player included. */ changeRole(id, payload, verificationCode) { return this.putRequest(`/groups/${id}/role`, Object.assign(Object.assign({}, payload), { verificationCode })); } /** * Adds an "update" request to the queue, for each outdated group member. * @returns The number of players to be updated and a confirmation message. */ updateAll(id, verificationCode) { return this.postRequest(`/groups/${id}/update-all`, { verificationCode }); } /** * Fetches all of the groups's competitions * @returns A list of competitions. */ getGroupCompetitions(id, pagination) { return this.getRequest(`/groups/${id}/competitions`, Object.assign({}, pagination)); } /** * Fetches a group's gains for a specific metric, over a given time period or date range. * * **Note:** If you need gains for more than one metric, use {@link getBulkGroupGains} instead * of calling this once per metric - it fetches every metric's gains in a single request. * @returns A list of players and their gains. */ getGroupGains(id, filter) { return this.getRequest(`/groups/${id}/gained`, filter); } /** * Fetches a group's gains for every metric, over a given time period or date range. * @returns A list of players and their gains, broken down by metric. */ getBulkGroupGains(id, filter) { return this.getRequest(`/groups/${id}/bulk-gained`, filter); } /** * Fetches a group members' latest achievements. * @returns A list of achievements. */ getGroupAchievements(id, pagination) { return this.getRequest(`/groups/${id}/achievements`, Object.assign({}, pagination)); } /** * Fetches a group's record leaderboard for a specific metric and period. * @returns A list of records, including their respective players. */ getGroupRecords(id, filter, pagination) { return this.getRequest(`/groups/${id}/records`, Object.assign(Object.assign({}, pagination), filter)); } /** * Fetches a group's hiscores for a specific metric. * @returns A list of hiscores entries (value, rank), including their respective players. */ getGroupHiscores(id, metric) { return this.getRequest(`/groups/${id}/hiscores`, { metric }); } /** * Fetches every group member's stats in a single request. * @returns A list of players and their latest snapshot data. */ getGroupBulkHiscores(id) { return this.getRequest(`/groups/${id}/bulk-hiscores`); } /** * Fetches a group members' latest name changes. * @returns A list of name change (approved) requests. */ getGroupNameChanges(id, pagination) { return this.getRequest(`/groups/${id}/name-changes`, Object.assign({}, pagination)); } /** * Fetches a group's general statistics. * @returns An object with a few statistic values and an average stats snapshot. */ getGroupStatistics(id) { return this.getRequest(`/groups/${id}/statistics`); } /** * Fetches a group's activity. * @returns A list of a group's (join, leave and role changed) activity. */ getGroupActivity(id, pagination) { return this.getRequest(`/groups/${id}/activity`, Object.assign({}, pagination)); } /** * Fetches the groups's member list in CSV format. * @returns A string containing the CSV content. */ getMembersCSV(id) { return this.getText(`/groups/${id}/csv`); } } class NameChangesClient extends BaseAPIClient { /** * Searches for name changes that match a name and/or status filter. * @returns A list of name changes. */ searchNameChanges(filter, pagination) { return this.getRequest('/names', Object.assign(Object.assign({}, filter), pagination)); } /** * Submits a name change request between two usernames (old and new). * @returns A pending name change request, to be reviewed and resolved at a later date. */ submitNameChange(oldName, newName) { return this.postRequest('/names', { oldName, newName }); } } class PlayersClient extends BaseAPIClient { /** * Searches players by partial username. * @returns A list of players. */ searchPlayers(partialUsername, pagination) { return this.getRequest('/players/search', Object.assign({ username: partialUsername }, pagination)); } /** * Updates/tracks a player. * @returns The player's new details, including the latest snapshot. */ updatePlayer(username) { return this.postRequest(`/players/${username}`); } /** * Asserts (and attempts to fix, if necessary) a player's game-mode type. * @returns The updated player, and an indication of whether the type was changed. */ assertPlayerType(username) { return this.postRequest(`/players/${username}/assert-type`); } /** * Fetches a player's details. * @returns The player's details, including the latest snapshot. */ getPlayerDetails(username) { return this.getRequest(`/players/${username}`); } /** * Fetches a player's details by ID. * @returns The player's details, including the latest snapshot. */ getPlayerDetailsById(id) { return this.getRequest(`/players/id/${id}`); } /** * Fetches a player's current achievements. * @returns A list of achievements. */ getPlayerAchievements(username) { return this.getRequest(`/players/${username}/achievements`); } /** * Fetches a player's current achievement progress. * @returns A list of achievements (completed or otherwise), with their respective relative/absolute progress percentage. */ getPlayerAchievementProgress(username) { return this.getRequest(`/players/${username}/achievements/progress`); } /** * Fetches all of the player's competition participations. * @returns A list of participations, with the respective competition included. */ getPlayerCompetitions(username, filter, pagination) { return this.getRequest(`/players/${username}/competitions`, Object.assign(Object.assign({}, filter), pagination)); } /** * Fetches all of the player's competition participations' standings. * @returns A list of participations, with the respective competition, rank and progress included. */ getPlayerCompetitionStandings(username, filter) { return this.getRequest(`/players/${username}/competitions/standings`, filter); } /** * Fetches all of the player's group memberships. * @returns A list of memberships, with the respective group included. */ getPlayerGroups(username, pagination) { return this.getRequest(`/players/${username}/groups`, pagination); } /** * Fetches a player's gains, for a specific period or time range, as a [metric: data] map. * @returns A map of each metric's gained data. */ getPlayerGains(username, options) { return this.getRequest(`/players/${username}/gained`, options); } /** * Fetches all of the player's records. * @returns A list of records. */ getPlayerRecords(username, options) { return this.getRequest(`/players/${username}/records`, options); } /** * Fetches all of the player's past snapshots. * @returns A list of snapshots. */ getPlayerSnapshots(username, filter, pagination) { return this.getRequest(`/players/${username}/snapshots`, Object.assign(Object.assign({}, filter), pagination)); } /** * Fetches all of the player's past snapshots' timeline. * @returns A list of timeseries data (value, rank, date) */ getPlayerSnapshotTimeline(username, metric, options) { return this.getRequest(`/players/${username}/snapshots/timeline`, Object.assign(Object.assign({}, options), { metric })); } /** * Fetches all of the player's approved name changes. * @returns A list of name changes. */ getPlayerNames(username) { return this.getRequest(`/players/${username}/names`); } /** * Fetches all of archived players that previously held this username. * @returns A list of player archives. */ getPlayerArchives(username) { return this.getRequest(`/players/${username}/archives`); } } class RecordsClient extends BaseAPIClient { /** * Fetches the current records leaderboard for a specific metric, period, playerType, playerBuild and country. * @returns A list of records, with their respective players, dates and values included. */ getRecordLeaderboard(filter) { return this.getRequest('/records/leaderboard', filter); } } var config = { defaultUserAgent: `WiseOldMan JS Client v${process.env.npm_package_version}`, baseAPIUrl: 'https://api.wiseoldman.net/v2' }; class WOMClient extends BaseAPIClient { constructor(options) { const baseApiUrl = (options === null || options === void 0 ? void 0 : options.baseAPIUrl) || config.baseAPIUrl; const headers = { 'x-user-agent': (options === null || options === void 0 ? void 0 : options.userAgent) || config.defaultUserAgent }; if (options === null || options === void 0 ? void 0 : options.apiKey) { headers['x-api-key'] = options.apiKey; } super(headers, baseApiUrl); this.deltas = new DeltasClient(headers, baseApiUrl); this.groups = new GroupsClient(headers, baseApiUrl); this.players = new PlayersClient(headers, baseApiUrl); this.records = new RecordsClient(headers, baseApiUrl); this.efficiency = new EfficiencyClient(headers, baseApiUrl); this.nameChanges = new NameChangesClient(headers, baseApiUrl); this.competitions = new CompetitionsClient(headers, baseApiUrl); } } const CompetitionStatusProps = { [exports.CompetitionStatus.UPCOMING]: { name: 'Upcoming' }, [exports.CompetitionStatus.ONGOING]: { name: 'Ongoing' }, [exports.CompetitionStatus.FINISHED]: { name: 'Finished' } }; const CompetitionTypeProps = { [CompetitionType.CLASSIC]: { name: 'Classic' }, [CompetitionType.TEAM]: { name: 'Team' } }; const CountryProps = { [Country.AD]: { code: 'AD', name: 'Andorra' }, [Country.AE]: { code: 'AE', name: 'United Arab Emirates' }, [Country.AF]: { code: 'AF', name: 'Afghanistan' }, [Country.AG]: { code: 'AG', name: 'Antigua and Barbuda' }, [Country.AI]: { code: 'AI', name: 'Anguilla' }, [Country.AL]: { code: 'AL', name: 'Albania' }, [Country.AM]: { code: 'AM', name: 'Armenia' }, [Country.AO]: { code: 'AO', name: 'Angola' }, [Country.AQ]: { code: 'AQ', name: 'Antarctica' }, [Country.AR]: { code: 'AR', name: 'Argentina' }, [Country.AS]: { code: 'AS', name: 'American Samoa' }, [Country.AT]: { code: 'AT', name: 'Austria' }, [Country.AU]: { code: 'AU', name: 'Australia' }, [Country.AW]: { code: 'AW', name: 'Aruba' }, [Country.AX]: { code: 'AX', name: 'Åland Islands' }, [Country.AZ]: { code: 'AZ', name: 'Azerbaijan' }, [Country.BA]: { code: 'BA', name: 'Bosnia and Herzegovina' }, [Country.BB]: { code: 'BB', name: 'Barbados' }, [Country.BD]: { code: 'BD', name: 'Bangladesh' }, [Country.BE]: { code: 'BE', name: 'Belgium' }, [Country.BF]: { code: 'BF', name: 'Burkina Faso' }, [Country.BG]: { code: 'BG', name: 'Bulgaria' }, [Country.BH]: { code: 'BH', name: 'Bahrain' }, [Country.BI]: { code: 'BI', name: 'Burundi' }, [Country.BJ]: { code: 'BJ', name: 'Benin' }, [Country.BL]: { code: 'BL', name: 'Saint Barthélemy' }, [Country.BM]: { code: 'BM', name: 'Bermuda' }, [Country.BN]: { code: 'BN', name: 'Brunei Darussalam' }, [Country.BO]: { code: 'BO', name: 'Bolivia' }, [Country.BQ]: { code: 'BQ', name: 'Bonaire' }, [Country.BR]: { code: 'BR', name: 'Brazil' }, [Country.BS]: { code: 'BS', name: 'Bahamas' }, [Country.BT]: { code: 'BT', name: 'Bhutan' }, [Country.BV]: { code: 'BV', name: 'Bouvet Island' }, [Country.BW]: { code: 'BW', name: 'Botswana' }, [Country.BY]: { code: 'BY', name: 'Belarus' }, [Country.BZ]: { code: 'BZ', name: 'Belize' }, [Country.CA]: { code: 'CA', name: 'Canada' }, [Country.CC]: { code: 'CC', name: 'Cocos (Keeling) Islands' }, [Country.CD]: { code: 'CD', name: 'Congo' }, [Country.CF]: { code: 'CF', name: 'Central African Republic' }, [Country.CG]: { code: 'CG', name: 'Congo' }, [Country.CH]: { code: 'CH', name: 'Switzerland' }, [Country.CI]: { code: 'CI', name: "Côte d'Ivoire" }, [Country.CK]: { code: 'CK', name: 'Cook Islands' }, [Country.CL]: { code: 'CL', name: 'Chile' }, [Country.CM]: { code: 'CM', name: 'Cameroon' }, [Country.CN]: { code: 'CN', name: 'China' }, [Country.CO]: { code: 'CO', name: 'Colombia' }, [Country.CR]: { code: 'CR', name: 'Costa Rica' }, [Country.CU]: { code: 'CU', name: 'Cuba' }, [Country.CV]: { code: 'CV', name: 'Cabo Verde' }, [Country.CW]: { code: 'CW', name: 'Curaçao' }, [Country.CX]: { code: 'CX', name: 'Christmas Island' }, [Country.CY]: { code: 'CY', name: 'Cyprus' }, [Country.CZ]: { code: 'CZ', name: 'Czechia' }, [Country.DE]: { code: 'DE', name: 'Germany' }, [Country.DJ]: { code: 'DJ', name: 'Djibouti' }, [Country.DK]: { code: 'DK', name: 'Denmark' }, [Country.DM]: { code: 'DM', name: 'Dominica' }, [Country.DO]: { code: 'DO', name: 'Dominican Republic' }, [Country.DZ]: { code: 'DZ', name: 'Algeria' }, [Country.EC]: { code: 'EC', name: 'Ecuador' }, [Country.EE]: { code: 'EE', name: 'Estonia' }, [Country.EG]: { code: 'EG', name: 'Egypt' }, [Country.EH]: { code: 'EH', name: 'Western Sahara' }, [Country.ER]: { code: 'ER', name: 'Eritrea' }, [Country.ES]: { code: 'ES', name: 'Spain' }, [Country.ET]: { code: 'ET', name: 'Ethiopia' }, [Country.FI]: { code: 'FI', name: 'Finland' }, [Country.FJ]: { code: 'FJ', name: 'Fiji' }, [Country.FK]: { code: 'FK', name: 'Falkland Islands (Malvinas)' }, [Country.FM]: { code: 'FM', name: 'Micronesia (Federated States of)' }, [Country.FO]: { code: 'FO', name: 'Faroe Islands' }, [Country.FR]: { code: 'FR', name: 'France' }, [Country.GA]: { code: 'GA', name: 'Gabon' }, [Country.GB]: { code: 'GB', name: 'United Kingdom' }, [Country.GB_ENG]: { code: 'GB_ENG', name: 'England' }, [Country.GB_NIR]: { code: 'GB_NIR', name: 'Northern Ireland' }, [Country.GB_SCT]: { code: 'GB_SCT', name: 'Scotland' }, [Country.GB_WLS]: { code: 'GB_WLS', name: 'Wales' }, [Country.GD]: { code: 'GD', name: 'Grenada' }, [Country.GE]: { code: 'GE', name: 'Georgia' }, [Country.GF]: { code: 'GF', name: 'French Guiana' }, [Country.GG]: { code: 'GG', name: 'Guernsey' }, [Country.GH]: { code: 'GH', name: 'Ghana' }, [Country.GI]: { code: 'GI', name: 'Gibraltar' }, [Country.GL]: { code: 'GL', name: 'Greenland' }, [Country.GM]: { code: 'GM', name: 'Gambia' }, [Country.GN]: { code: 'GN', name: 'Guinea' }, [Country.GP]: { code: 'GP', name: 'Guadeloupe' }, [Country.GQ]: { code: 'GQ', name: 'Equatorial Guinea' }, [Country.GR]: { code: 'GR', name: 'Greece' }, [Country.GS]: { code: 'GS', name: 'South Georgia and the South Sandwich Islands' }, [Country.GT]: { code: 'GT', name: 'Guatemala' }, [Country.GU]: { code: 'GU', name: 'Guam' }, [Country.GW]: { code: 'GW', name: 'Guinea-Bissau' }, [Country.GY]: { code: 'GY', name: 'Guyana' }, [Country.HK]: { code: 'HK', name: 'Hong Kong' }, [Country.HM]: { code: 'HM', name: 'Heard Island and McDonald Islands' }, [Country.HN]: { code: 'HN', name: 'Honduras' }, [Country.HR]: { code: 'HR', name: 'Croatia' }, [Country.HT]: { code: 'HT', name: 'Haiti' }, [Country.HU]: { code: 'HU', name: 'Hungary' }, [Country.ID]: { code: 'ID', name: 'Indonesia' }, [Country.IE]: { code: 'IE', name: 'Ireland' }, [Country.IL]: { code: 'IL', name: 'Israel' }, [Country.IM]: { code: 'IM', name: 'Isle of Man' }, [Country.IN]: { code: 'IN', name: 'India' }, [Country.IO]: { code: 'IO', name: 'British Indian Ocean Territory' }, [Country.IQ]: { code: 'IQ', name: 'Iraq' }, [Country.IR]: { code: 'IR', name: 'Iran (Islamic Republic of)' }, [Country.IS]: { code: 'IS', name: 'Iceland' }, [Country.IT]: { code: 'IT', name: 'Italy' }, [Country.JE]: { code: 'JE', name: 'Jersey' }, [Country.JM]: { code: 'JM', name: 'Jamaica' }, [Country.JO]: { code: 'JO', name: 'Jordan' }, [Country.JP]: { code: 'JP', name: 'Japan' }, [Country.KE]: { code: 'KE', name: 'Kenya' }, [Country.KG]: { code: 'KG', name: 'Kyrgyzstan' }, [Country.KH]: { code: 'KH', name: 'Cambodia' }, [Country.KI]: { code: 'KI', name: 'Kiribati' }, [Country.KM]: { code: 'KM', name: 'Comoros' }, [Country.KN]: { code: 'KN', name: 'Saint Kitts and Nevis' }, [Country.KP]: { code: 'KP', name: "Korea (Democratic People's Republic of)" }, [Country.KR]: { code: 'KR', name: 'Korea' }, [Country.KW]: { code: 'KW', name: 'Kuwait' }, [Country.KY]: { code: 'KY', name: 'Cayman Islands' }, [Country.KZ]: { code: 'KZ', name: 'Kazakhstan' }, [Country.LA]: { code: 'LA', name