diff --git a/README.md b/README.md index 8b50ca2..3cd784a 100644 --- a/README.md +++ b/README.md @@ -1 +1,29 @@ -# profile-parser \ No newline at end of file +# profile-parser + +Parse warframe profile data into useable javascript objects. + +[![Supported by the Warframe Community Developers](https://img.shields.io/badge/Warframe_Comm_Devs-supported-blue.svg?color=2E96EF&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOTgiIGhlaWdodD0iMTczIiB2aWV3Qm94PSIwIDAgMjk4IDE3MyI%2BPHBhdGggZD0iTTE4NSA2N2MxNSA4IDI4IDE2IDMxIDE5czIzIDE4LTcgNjBjMCAwIDM1LTMxIDI2LTc5LTE0LTctNjItMzYtNzAtNDUtNC01LTEwLTEyLTE1LTIyLTUgMTAtOSAxNC0xNSAyMi0xMyAxMy01OCAzOC03MiA0NS05IDQ4IDI2IDc5IDI2IDc5LTMwLTQyLTEwLTU3LTctNjBsMzEtMTkgMzYtMjIgMzYgMjJ6TTU1IDE3M2wtMTctM2MtOC0xOS0yMC00NC0yNC01MC01LTctNy0xMS0xNC0xNWwxOC0yYzE2LTMgMjItNyAzMi0xMyAxIDYgMCA5IDIgMTQtNiA0LTIxIDEwLTI0IDE2IDMgMTQgNSAyNyAyNyA1M3ptMTYtMTFsLTktMi0xNC0yOWEzMCAzMCAwIDAgMC04LThoN2wxMy00IDQgN2MtMyAyLTcgMy04IDZhODYgODYgMCAwIDAgMTUgMzB6bTE3MiAxMWwxNy0zYzgtMTkgMjAtNDQgMjQtNTAgNS03IDctMTEgMTQtMTVsLTE4LTJjLTE2LTMtMjItNy0zMi0xMy0xIDYgMCA5LTIgMTQgNiA0IDIxIDEwIDI0IDE2LTMgMTQtNSAyNy0yNyA1M3ptLTE2LTExbDktMiAxNC0yOWEzMCAzMCAwIDAgMSA4LThoLTdsLTEzLTQtNCA3YzMgMiA3IDMgOCA2YTg2IDg2IDAgMCAxLTE1IDMwem0tNzktNDBsLTYtNmMtMSAzLTMgNi02IDdsNSA1YTUgNSAwIDAgMSAyIDB6bS0xMy0yYTQgNCAwIDAgMSAxLTJsMi0yYTQgNCAwIDAgMSAyLTFsNC0xNy0xNy0xMC04IDcgMTMgOC0yIDctNyAyLTgtMTItOCA4IDEwIDE3em0xMiAxMWE1IDUgMCAwIDAtNC0yIDQgNCAwIDAgMC0zIDFsLTMwIDI3YTUgNSAwIDAgMCAwIDdsNCA0YTYgNiAwIDAgMCA0IDIgNSA1IDAgMCAwIDMtMWwyNy0zMWMyLTIgMS01LTEtN3ptMzkgMjZsLTMwLTI4LTYgNmE1IDUgMCAwIDEgMCAzbDI2IDI5YTEgMSAwIDAgMCAxIDBsNS0yIDItMmMxLTIgMy01IDItNnptNS00NWEyIDIgMCAwIDAtNCAwbC0xIDEtMi00YzEtMy01LTktNS05LTEzLTE0LTIzLTE0LTI3LTEzLTIgMS0yIDEgMCAyIDE0IDIgMTUgMTAgMTMgMTNhNCA0IDAgMCAwLTEgMyAzIDMgMCAwIDAgMSAxbC0yMSAyMmE3IDcgMCAwIDEgNCAyIDggOCAwIDAgMSAyIDNsMjAtMjFhNyA3IDAgMCAwIDEgMSA0IDQgMCAwIDAgNCAwYzEtMSA2IDMgNyA0aC0xYTMgMyAwIDAgMCAwIDQgMiAyIDAgMCAwIDQgMGw2LTZhMyAzIDAgMCAwIDAtM3oiIGZpbGw9IiMyZTk2ZWYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg%3D%3D)](https://github.com/WFCD/banner/blob/master/PROJECTS.md) +[![Coverage Status](https://coveralls.io/repos/github/WFCD/warframe-worldstate-parser/badge.svg?branch=master)](https://coveralls.io/github/WFCD/profile-parser?branch=master) +[![Discord](https://img.shields.io/discord/256087517353213954.svg?logo=discord)](https://discord.gg/jGZxH9f) +[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) + +## Documentation + +You can find the documentation [here](https://wfcd.github.io/profile-parser/) + +## Installation + +```shell +$ npm i -S profile-parser +``` + +## Example usage + +```javascript +import { ProfileParser } from 'profile-parser'; + +const profileData = await fetch('https://content.warframe.com/dynamic/getProfileViewingData.php?n=${username}'); +const user = new ProfileParser(await profileData.text()); + +console.log(user.profile.displayName); +``` diff --git a/package-lock.json b/package-lock.json index 646e638..9417834 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "@wfcd/profile-parser", "version": "0.0.0", - "hasInstallScript": true, "license": "MIT", "devDependencies": { "@types/chai": "^4.3.14", diff --git a/package.json b/package.json index 4b4497d..62e69f0 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,9 @@ "prepublishOnly": "npm run build:types", "build:docs": "jsdoc -c .github/docs/conf.json -d docs", "build:types": "tsc -p tsconfig.declaration.json", - "postinstall": "if [ \"$NODE_ENV\" = \"dev\" ] ; then npx -p install-peerdeps@latest install-peerdeps @wfcd/eslint-config@latest -S ; fi", - "prepare": "husky" + "prepare": "husky && if [ \"$NODE_ENV\" = \"dev\" ] ; then npx -p install-peerdeps@latest install-peerdeps @wfcd/eslint-config@latest -S ; fi" }, - "author": "", + "author": "SlayerOrnstein", "license": "MIT", "engines": { "node": ">=18.0.0" diff --git a/src/Ability.js b/src/Ability.js index 5bf5eb9..1c23fe5 100644 --- a/src/Ability.js +++ b/src/Ability.js @@ -1,5 +1,6 @@ /** - * Represents an ability used by the player + * Represents a players used ability + * @module */ export default class Ability { /** diff --git a/src/ArchonCrystal.js b/src/ArchonCrystal.js index 5ce72a1..5e01325 100644 --- a/src/ArchonCrystal.js +++ b/src/ArchonCrystal.js @@ -1,8 +1,21 @@ import { archonShardColor, archonShardUpgradeType } from 'warframe-worldstate-data/utilities'; +/** + * Represents an Archon shard + * @module + */ export default class ArchonCrystal { constructor(crystal, local) { + /** + * Archon shard color + * @type {String} + */ this.color = archonShardColor(crystal.Color, local); + + /** + * Archon shard modifier + * @type {String} + */ this.modifier = archonShardUpgradeType(crystal.Color, crystal.UpgradeType, local); } } diff --git a/src/ChallengeProgress.js b/src/ChallengeProgress.js index b9d999e..9ef35eb 100644 --- a/src/ChallengeProgress.js +++ b/src/ChallengeProgress.js @@ -1,3 +1,7 @@ +/** + * Player completed or in progress challenges + * @module + */ export default class ChallengeProgress { constructor(challenge) { /** diff --git a/src/Enemy.js b/src/Enemy.js index 74fc1a9..1be6b9f 100644 --- a/src/Enemy.js +++ b/src/Enemy.js @@ -1,5 +1,6 @@ /** - * Represents the enemies killed + * An enemy killed/executed by player + * @module */ export default class Enemy { /** @@ -37,7 +38,7 @@ export default class Enemy { this.assists = enemy.assists; /** - * How many times tis enemy type has killed the player + * How many times this enemy type has killed the player * @type {number} */ this.deaths = enemy.deaths; diff --git a/src/Intrinsics.js b/src/Intrinsics.js index 09e5cfa..f2a862b 100644 --- a/src/Intrinsics.js +++ b/src/Intrinsics.js @@ -1,3 +1,7 @@ +/** + * Player's intrinsics ranks + * @module + */ export default class Intrinsics { constructor(skills) { // I know this is railjack but I'm not sure what the context is diff --git a/src/ItemConfig.js b/src/ItemConfig.js index 401a8bb..4f7edb0 100644 --- a/src/ItemConfig.js +++ b/src/ItemConfig.js @@ -3,7 +3,8 @@ import { colors, find } from 'warframe-items/utilities'; import mapToHex from './Util.js'; /** - * Represents the data configuration for an item + * Item customizations such as colors and applied skins + * @module */ export default class ItemConfig { /** diff --git a/src/LoadOutInventory.js b/src/LoadOutInventory.js index 663e48a..ca4168f 100644 --- a/src/LoadOutInventory.js +++ b/src/LoadOutInventory.js @@ -2,6 +2,10 @@ import LoadOutItem from './LoadOutItem.js'; import WeaponSkin from './WeaponSkin.js'; import XpInfo from './XpInfo.js'; +/** + * Player loudout + * @module + */ export default class LoadOutInventory { constructor(item) { /** diff --git a/src/LoadOutItem.js b/src/LoadOutItem.js index 24d845a..102ea9d 100644 --- a/src/LoadOutItem.js +++ b/src/LoadOutItem.js @@ -4,6 +4,10 @@ import { parseDate, toTitleCase } from 'warframe-worldstate-data/utilities'; import ItemConfig from './ItemConfig.js'; import Polarity from './Polarity.js'; +/** + * An an item in LoadOutInventory + * @module + */ export default class LoadOutItem { constructor(weapon) { /** diff --git a/src/Mission.js b/src/Mission.js index 61a78b6..ef00bf4 100644 --- a/src/Mission.js +++ b/src/Mission.js @@ -1,5 +1,9 @@ import { node, nodeEnemy, nodeMissionType } from 'warframe-worldstate-data/utilities'; +/** + * A mission completed by the player + * @module + */ export default class Mission { constructor(mission, locale) { const uniqueName = mission.Type || mission.Tag; diff --git a/src/OperatorLoadOuts.js b/src/OperatorLoadOuts.js index 7555f94..f52207a 100644 --- a/src/OperatorLoadOuts.js +++ b/src/OperatorLoadOuts.js @@ -2,6 +2,10 @@ import { colors } from 'warframe-items/utilities'; import mapToHex from './Util.js'; +/** + * Player's operator loadout + * @module + */ export default class OperatorLoadOuts { constructor(loadout) { /** diff --git a/src/Polarity.js b/src/Polarity.js index 94c87c4..0665f18 100644 --- a/src/Polarity.js +++ b/src/Polarity.js @@ -1,5 +1,9 @@ import { translatePolarity } from 'warframe-worldstate-data/utilities'; +/** + * A polarity in a LoadOutItem + * @module + */ export default class Polarity { constructor(polarity) { /** diff --git a/src/Profile.js b/src/Profile.js index 70fb30e..539a3f0 100644 --- a/src/Profile.js +++ b/src/Profile.js @@ -7,6 +7,10 @@ import Mission from './Mission.js'; import OperatorLoadOuts from './OperatorLoadOuts.js'; import Syndicate from './Syndicate.js'; +/** + * A player's profile + * @module + */ export default class Profile { constructor(profile, locale) { /** diff --git a/src/ProfileParser.js b/src/ProfileParser.js index 574c7f3..523160f 100644 --- a/src/ProfileParser.js +++ b/src/ProfileParser.js @@ -3,6 +3,10 @@ import { parseDate } from 'warframe-worldstate-data/utilities'; import Profile from './Profile.js'; import Stats from './Stats.js'; +/** + * Parser entry point + * @module + */ export default class ProfileParser { constructor(data, locale) { /** @@ -11,16 +15,24 @@ export default class ProfileParser { */ this.profile = new Profile(data.Results[0], locale); - // N/A + /** + * @type {number} + */ this.techProjects = data.TechProjects; - // N/A + /** + * @type {number} + */ this.xpComponents = data.XpCompoents; - // N/A + /** + * @type {number} + */ this.xpCacheExpiryDate = parseDate(data.XpCacheExpiryDate); - // N/A + /** + * @type {number} + */ this.ceremonyResetDate = parseDate(data.CeremonyResetDate); /** diff --git a/src/Pvp.js b/src/Pvp.js index 6339eb6..f5e565a 100644 --- a/src/Pvp.js +++ b/src/Pvp.js @@ -1,3 +1,7 @@ +/** + * Player's conclave stats + * @module + */ export default class Pvp { constructor(pvp) { /** diff --git a/src/Race.js b/src/Race.js index d3aec73..9cb0668 100644 --- a/src/Race.js +++ b/src/Race.js @@ -1,3 +1,7 @@ +/** + * Represents a k-drive race + * @module + */ export default class Race { constructor(race) { /** diff --git a/src/Scan.js b/src/Scan.js index c505d96..0d237ed 100644 --- a/src/Scan.js +++ b/src/Scan.js @@ -1,3 +1,7 @@ +/** + * Represents an enemy scanned to the codex + * @module + */ export default class Scan { constructor(scan) { /** diff --git a/src/Stats.js b/src/Stats.js index 3ef5f53..4f0df1c 100644 --- a/src/Stats.js +++ b/src/Stats.js @@ -7,7 +7,8 @@ import Scan from './Scan.js'; import Weapon from './Weapon.js'; /** - * Player stats + * A player's overall career stats + * @module */ export default class Stats { /** diff --git a/src/Syndicate.js b/src/Syndicate.js index 252bd5f..0d42882 100644 --- a/src/Syndicate.js +++ b/src/Syndicate.js @@ -1,11 +1,15 @@ +import { syndicate } from 'warframe-worldstate-data/utilities'; + /** - * Represents a player's progress with a Syndicate + * Represents a syndicate + * @module */ export default class Syndicate { /** * @param {Object} affiliation The syndicate data + * @param {string} locale locale code */ - constructor(affiliation) { + constructor(affiliation, locale) { // TODO: name is readable but still might want to clean them up // i.e "NewLokaSyndicate" can be "New Loka"" instead @@ -13,7 +17,7 @@ export default class Syndicate { * Name of the syndicate * @type {String} */ - this.name = affiliation.Tag; + this.name = syndicate(affiliation.Tag, locale); /** * Current standing the player has with the syndicate diff --git a/src/Util.js b/src/Util.js index d925dc5..358ffeb 100644 --- a/src/Util.js +++ b/src/Util.js @@ -1,3 +1,5 @@ +/** @module */ + /** * Map base10 int colors to hex color strings * @param {Record} colors color map diff --git a/src/Weapon.js b/src/Weapon.js index 6dfaafe..31b9043 100644 --- a/src/Weapon.js +++ b/src/Weapon.js @@ -1,3 +1,7 @@ +/** + * Represents a player's used weapon stats + * @module + */ export default class Weapon { constructor(weapon) { /** diff --git a/src/WeaponSkin.js b/src/WeaponSkin.js index 3d58e02..0078e60 100644 --- a/src/WeaponSkin.js +++ b/src/WeaponSkin.js @@ -1,3 +1,7 @@ +/** + * A weapon skin + * @module + */ export default class WeaponSkin { constructor(skin) { /** diff --git a/src/XpInfo.js b/src/XpInfo.js index 540b7c6..e9cdb16 100644 --- a/src/XpInfo.js +++ b/src/XpInfo.js @@ -1,5 +1,9 @@ import { find } from 'warframe-items/utilities'; +/** + * An item that has contributed to a player's mastery rank + * @module + */ export default class XpInfo { constructor(info) { /**