@wfcd/profile-parser 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/package.json +104 -0
  4. package/src/Ability.js +21 -0
  5. package/src/ArchonCrystal.js +8 -0
  6. package/src/ChallengeProgress.js +15 -0
  7. package/src/Enemy.js +45 -0
  8. package/src/Intrinsics.js +69 -0
  9. package/src/ItemConfig.js +51 -0
  10. package/src/LoadOutInventory.js +43 -0
  11. package/src/LoadOutItem.js +135 -0
  12. package/src/Mission.js +40 -0
  13. package/src/OperatorLoadOuts.js +68 -0
  14. package/src/Polarity.js +17 -0
  15. package/src/Profile.js +189 -0
  16. package/src/ProfileParser.js +32 -0
  17. package/src/Pvp.js +27 -0
  18. package/src/Race.js +15 -0
  19. package/src/Scan.js +15 -0
  20. package/src/Stats.js +339 -0
  21. package/src/Syndicate.js +30 -0
  22. package/src/Util.js +12 -0
  23. package/src/Weapon.js +51 -0
  24. package/src/WeaponSkin.js +9 -0
  25. package/src/XpInfo.js +23 -0
  26. package/types/Ability.d.ts +19 -0
  27. package/types/ArchonCrystal.d.ts +5 -0
  28. package/types/ChallengeProgress.d.ts +13 -0
  29. package/types/Enemy.d.ts +39 -0
  30. package/types/Intrinsics.d.ts +56 -0
  31. package/types/ItemConfig.d.ts +19 -0
  32. package/types/LoadOutInventory.d.ts +36 -0
  33. package/types/LoadOutItem.d.ts +78 -0
  34. package/types/Mission.d.ts +21 -0
  35. package/types/OperatorLoadOuts.d.ts +26 -0
  36. package/types/Polarity.d.ts +13 -0
  37. package/types/Profile.d.ts +143 -0
  38. package/types/ProfileParser.d.ts +19 -0
  39. package/types/Pvp.d.ts +23 -0
  40. package/types/Race.d.ts +13 -0
  41. package/types/Scan.d.ts +13 -0
  42. package/types/Stats.d.ts +258 -0
  43. package/types/Syndicate.d.ts +24 -0
  44. package/types/Util.d.ts +6 -0
  45. package/types/Weapon.d.ts +43 -0
  46. package/types/WeaponSkin.d.ts +8 -0
  47. package/types/XpInfo.d.ts +18 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Warframe Community Developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # profile-parser
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@wfcd/profile-parser",
3
+ "version": "1.0.0",
4
+ "description": "Parser for Digital Extreme's profile data",
5
+ "type": "module",
6
+ "main": "src/ProfileParser.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./src/ProfileParser.js",
10
+ "types": "./types/index.d.ts"
11
+ }
12
+ },
13
+ "public": true,
14
+ "files": [
15
+ "src",
16
+ "LICENSE",
17
+ "README.md",
18
+ "types"
19
+ ],
20
+ "devDependencies": {
21
+ "@types/chai": "^4.3.14",
22
+ "@wfcd/eslint-config": "^1.6.1",
23
+ "c8": "^9.1.0",
24
+ "chai": "^5.1.0",
25
+ "chai-json-equal": "^0.0.1",
26
+ "coveralls": "^3.1.1",
27
+ "husky": "^9.0.11",
28
+ "install-peerdeps": "^3.0.3",
29
+ "lint-staged": "^15.2.2",
30
+ "mocha": "^10.3.0",
31
+ "typescript": "^5.4.3"
32
+ },
33
+ "scripts": {
34
+ "test": "c8 mocha",
35
+ "coverage": "npm test && c8 report --reporter=text-lcov | coveralls",
36
+ "lint": "eslint src/",
37
+ "lint:fix": "eslint src/ test/ --fix",
38
+ "prepublishOnly": "npm run build:types",
39
+ "build:docs": "jsdoc -c .github/docs/conf.json -d docs",
40
+ "build:types": "tsc -p tsconfig.declaration.json",
41
+ "postinstall": "if [ \"$NODE_ENV\" = \"dev\" ] ; then npx -p install-peerdeps@latest install-peerdeps @wfcd/eslint-config@latest -S ; fi",
42
+ "prepare": "husky"
43
+ },
44
+ "author": "",
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "eslintConfig": {
50
+ "extends": "@wfcd/eslint-config/esm",
51
+ "parser": "@babel/eslint-parser",
52
+ "parserOptions": {
53
+ "sourceType": "module",
54
+ "ecmaVersion": 6,
55
+ "ecmaFeatures": {
56
+ "modules": true
57
+ },
58
+ "babelOptions": {
59
+ "plugins": [
60
+ "@babel/plugin-transform-class-properties",
61
+ "@babel/plugin-transform-private-methods"
62
+ ]
63
+ }
64
+ }
65
+ },
66
+ "babel": {
67
+ "presets": [
68
+ "@babel/preset-env"
69
+ ],
70
+ "plugins": [
71
+ "@babel/plugin-transform-class-properties",
72
+ "@babel/plugin-transform-private-methods"
73
+ ]
74
+ },
75
+ "prettier": "@wfcd/eslint-config/prettier",
76
+ "mocha": {
77
+ "exit": true,
78
+ "spec": "test/**/*.spec.js"
79
+ },
80
+ "c8": {
81
+ "reporter": [
82
+ "lcov",
83
+ "text"
84
+ ],
85
+ "skip-full": true
86
+ },
87
+ "peerDependencies": {
88
+ "warframe-items": "^1.1262.30",
89
+ "warframe-worldstate-data": "^2.5.0"
90
+ },
91
+ "lint-staged": {
92
+ "*.js": [
93
+ "eslint --cache --fix",
94
+ "npm test"
95
+ ],
96
+ "package*.json": [
97
+ "prettier --write",
98
+ "npm -q --no-progress dedupe"
99
+ ],
100
+ "*.{json,md,yaml}": [
101
+ "prettier --write"
102
+ ]
103
+ }
104
+ }
package/src/Ability.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Represents an ability used by the player
3
+ */
4
+ export default class Ability {
5
+ /**
6
+ * @param {Object} ability The ability
7
+ */
8
+ constructor(ability) {
9
+ /**
10
+ * The ability unique name
11
+ * @type {String}
12
+ */
13
+ this.uniqueName = ability.type;
14
+
15
+ /**
16
+ * How many time the ability was used in the player's lifetime
17
+ * @type {number}
18
+ */
19
+ this.used = ability.used;
20
+ }
21
+ }
@@ -0,0 +1,8 @@
1
+ import { archonShardColor, archonShardUpgradeType } from 'warframe-worldstate-data/utilities';
2
+
3
+ export default class ArchonCrystal {
4
+ constructor(crystal, local) {
5
+ this.color = archonShardColor(crystal.Color, local);
6
+ this.modifier = archonShardUpgradeType(crystal.Color, crystal.UpgradeType, local);
7
+ }
8
+ }
@@ -0,0 +1,15 @@
1
+ export default class ChallengeProgress {
2
+ constructor(challenge) {
3
+ /**
4
+ * Name of the challenge
5
+ * @type {String}
6
+ */
7
+ this.name = challenge.Name;
8
+
9
+ /**
10
+ * Progress towards completing this challenge
11
+ * @type {number}
12
+ */
13
+ this.progress = challenge.Progress;
14
+ }
15
+ }
package/src/Enemy.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Represents the enemies killed
3
+ */
4
+ export default class Enemy {
5
+ /**
6
+ * @param {Object} enemy The enemy
7
+ */
8
+ constructor(enemy) {
9
+ /**
10
+ * Enenmy's unique name
11
+ * @type {String}
12
+ */
13
+ this.uniqueName = enemy.type;
14
+
15
+ /**
16
+ * How many times the player has killed this enemy type
17
+ * @type {number}
18
+ */
19
+ this.kills = enemy.kills;
20
+
21
+ /**
22
+ * The amount of kills that were headshots
23
+ * @type {number}
24
+ */
25
+ this.headshots = enemy.headshots;
26
+
27
+ /**
28
+ * The amount of kills that were finishers
29
+ * @type {number}
30
+ */
31
+ this.executions = enemy.executions;
32
+
33
+ /**
34
+ * The amount of kills that were assits
35
+ * @type {number}
36
+ */
37
+ this.assists = enemy.assists;
38
+
39
+ /**
40
+ * How many times tis enemy type has killed the player
41
+ * @type {number}
42
+ */
43
+ this.deaths = enemy.deaths;
44
+ }
45
+ }
@@ -0,0 +1,69 @@
1
+ export default class Intrinsics {
2
+ constructor(skills) {
3
+ // I know this is railjack but I'm not sure what the context is
4
+ /**
5
+ * @type {number}
6
+ */
7
+ this.space = skills.LPP_SPACE;
8
+
9
+ /**
10
+ * Railjack engineering rank
11
+ * @type {number}
12
+ */
13
+ this.engineering = skills.LPS_ENGINEERING;
14
+
15
+ /**
16
+ * Railjack gunnery rank
17
+ * @type {number}
18
+ */
19
+ this.gunnery = skills.LPS_GUNNERY;
20
+
21
+ /**
22
+ * Railjack piloting rank
23
+ * @type {number}
24
+ */
25
+ this.piloting = skills.LPS_PILOTING;
26
+
27
+ /**
28
+ * Railjack tactical rank
29
+ * @type {number}
30
+ */
31
+ this.tactical = skills.LPS_TACTICAL;
32
+
33
+ /**
34
+ * Railjack command rank
35
+ * @type {number}
36
+ */
37
+ this.command = skills.LPS_COMMAND;
38
+
39
+ // Not sure what the context for this one is either
40
+ /**
41
+ * @type {number}
42
+ */
43
+ this.drifter = skills.LPP_DRIFTER;
44
+
45
+ /**
46
+ * Drifter riding rank
47
+ * @type {number}
48
+ */
49
+ this.riding = skills.LPS_DRIFT_RIDING;
50
+
51
+ /**
52
+ * Drifter combat rank
53
+ * @type {number}
54
+ */
55
+ this.combat = skills.LPS_DRIFT_COMBAT;
56
+
57
+ /**
58
+ * Drifter opportunity rank
59
+ * @type {number}
60
+ */
61
+ this.opportunity = skills.LPS_DRIFT_OPPORTUNITY;
62
+
63
+ /**
64
+ * Drifter endurance rank
65
+ * @type {number}
66
+ */
67
+ this.endurance = skills.LPS_DRIFT_ENDURANCE;
68
+ }
69
+ }
@@ -0,0 +1,51 @@
1
+ import { colors, find } from 'warframe-items/utilities';
2
+
3
+ import mapToHex from './Util.js';
4
+
5
+ /**
6
+ * Represents the data configuration for an item
7
+ */
8
+ export default class ItemConfig {
9
+ /**
10
+ * @param {Object} config The configuration
11
+ */
12
+ constructor(config) {
13
+ /**
14
+ * Array of unique names for the skins applied to item
15
+ * @type {Array<String>}
16
+ */
17
+ this.skins = config.Skins.filter(Boolean)
18
+ .map((s) => find.findItem(s))
19
+ .filter(Boolean);
20
+
21
+ /**
22
+ * Array of PVP unique name upgrades applied
23
+ * @type {Array<String>}
24
+ */
25
+ if (config.PvpUpgrades) this.conclaveUpgrades = config.PvpUpgrades;
26
+
27
+ /**
28
+ * Primary colors applied to item if they exist
29
+ * @type {module:"warframe-items".ColorMap}
30
+ */
31
+ if (config.pricol) this.primaryColor = colors.mapColors(mapToHex(config.pricol));
32
+
33
+ /**
34
+ * Sigil colors applied to item if they exist
35
+ * @type {module:"warframe-items".ColorMap}
36
+ */
37
+ if (config.sigcol) this.sigilColor = colors.mapColors(mapToHex(config.sigcol));
38
+
39
+ /**
40
+ * Attachment colors applied to item if they exist
41
+ * @type {module:"warframe-items".ColorMap}
42
+ */
43
+ if (config.attcol) this.attachmentsColor = colors.mapColors(mapToHex(config.attcol));
44
+
45
+ /**
46
+ * Syandana colors applied to item if they exist
47
+ * @type {module:"warframe-items".ColorMap}
48
+ */
49
+ if (config.syancol) this.syandanaColor = colors.mapColors(mapToHex(config.syancol));
50
+ }
51
+ }
@@ -0,0 +1,43 @@
1
+ import LoadOutItem from './LoadOutItem.js';
2
+ import WeaponSkin from './WeaponSkin.js';
3
+ import XpInfo from './XpInfo.js';
4
+
5
+ export default class LoadOutInventory {
6
+ constructor(item) {
7
+ /**
8
+ * Skins applied to weapons
9
+ * @type {WeaponSkin}
10
+ */
11
+ this.weaponSkins = item.WeaponSkins.map((s) => new WeaponSkin(s));
12
+
13
+ /**
14
+ * An array of the player's currently equiped Warframe (or powersuits)
15
+ * @type {LoadOutItem}
16
+ */
17
+ this.suits = item.Suits.map((s) => new LoadOutItem(s));
18
+
19
+ /**
20
+ * An array of the player's currently equiped secondary weapon
21
+ * @type {LoadOutItem}
22
+ */
23
+ this.secondary = item.Pistols.map((p) => new LoadOutItem(p));
24
+
25
+ /**
26
+ * An array of the player's currently equiped primary weapon
27
+ * @type {LoadOutItem}
28
+ */
29
+ this.primary = item.LongGuns.map((lg) => new LoadOutItem(lg));
30
+
31
+ /**
32
+ * An array of the player's currently equiped melee weapon
33
+ * @type {LoadOutItem}
34
+ */
35
+ this.melee = item.Melee.map((m) => new LoadOutItem(m));
36
+
37
+ /**
38
+ * Items that have counted towards the players mastery rank
39
+ * @type {XpInfo}
40
+ */
41
+ this.xpInfo = item.XPInfo.map((xp) => new XpInfo(xp));
42
+ }
43
+ }
@@ -0,0 +1,135 @@
1
+ import { colors, find } from 'warframe-items/utilities';
2
+ import { parseDate, toTitleCase } from 'warframe-worldstate-data/utilities';
3
+
4
+ import ItemConfig from './ItemConfig.js';
5
+ import Polarity from './Polarity.js';
6
+
7
+ export default class LoadOutItem {
8
+ constructor(weapon) {
9
+ /**
10
+ * Item ID
11
+ * @type {String}
12
+ */
13
+ this.itemId = weapon.ItemId.$oid;
14
+
15
+ /**
16
+ * Item unique name
17
+ * @type {String}
18
+ */
19
+ this.uniqueName = weapon.ItemType;
20
+
21
+ const item = find.findItem(weapon.ItemType);
22
+ if (item) {
23
+ /**
24
+ * Item in-game name
25
+ * @type {String}
26
+ */
27
+ this.name = item.name;
28
+
29
+ /**
30
+ * Complete item from Warframe-items
31
+ * @type {module:"warframe-items".Item}
32
+ */
33
+ this.item = item;
34
+ }
35
+
36
+ if (weapon.ItemName) {
37
+ const [, nemesis] = weapon.ItemName.split('|');
38
+
39
+ /**
40
+ * Item lich name
41
+ * @type {String}
42
+ */
43
+ this.nemesis = toTitleCase(nemesis);
44
+ }
45
+
46
+ /**
47
+ * Configuration for this weapon. Such as colors and skins applied by the player
48
+ * @type {Array<ItemConfig>}
49
+ */
50
+ this.configs = weapon.Configs.map((c) => new ItemConfig(c));
51
+
52
+ /**
53
+ * The upgrade that was applied to this weapon
54
+ * @type {String}
55
+ */
56
+ if (weapon.upgradeType) this.upgradeType = weapon.UpgradeType;
57
+
58
+ /**
59
+ * Information on the upgradeType that was applied
60
+ * TODO need model for for fingerprint
61
+ */
62
+ this.upgradeFingerprint = weapon.UpgradeFingerprint;
63
+
64
+ /**
65
+ * @type {number}
66
+ */
67
+ this.features = weapon.Features;
68
+
69
+ // Not sure what this is for
70
+ /**
71
+ * @type {number}
72
+ */
73
+ this.upgradeVer = weapon.UpgradeVer;
74
+
75
+ /**
76
+ * XP earned with this weapon
77
+ * @type {number}
78
+ */
79
+ this.xp = weapon.XP;
80
+
81
+ /**
82
+ * How many mod slots are currently polarized.
83
+ * @type {number}
84
+ */
85
+ this.polarized = weapon.Polarized;
86
+
87
+ /**
88
+ * Which polarity types exist on the weapon
89
+ * @type {Array<Polarity>}
90
+ */
91
+ this.polarity = weapon.Polarity.map((p) => new Polarity(p));
92
+
93
+ /**
94
+ * Focus lens applied
95
+ * @type {String}
96
+ */
97
+ this.focuseLens = weapon.FocusLens;
98
+
99
+ // Not sure what this is for
100
+ /**
101
+ * @type {number}
102
+ */
103
+ this.customizationSlotPurchases = weapon.CustomizationSlotPurchases;
104
+
105
+ /**
106
+ * Primary colors applied to item if they exist
107
+ * @type {ColorMap}
108
+ */
109
+ if (weapon.pricol) this.primaryColor = colors.mapColors(weapon.pricol);
110
+
111
+ /**
112
+ * Sigil colors applied to item if they exist
113
+ * @type {ColorMap}
114
+ */
115
+ if (weapon.sigcol) this.sigilColor = colors.mapColors(weapon.sigcol.toString(16));
116
+
117
+ /**
118
+ * Attachment colors applied to item if they exist
119
+ * @type {ColorMap}
120
+ */
121
+ if (weapon.attcol) this.attachmentsColor = colors.mapColors(weapon.attcol.toString(16));
122
+
123
+ /**
124
+ * Syandana colors applied to item if they exist
125
+ * @type {ColorMap}
126
+ */
127
+ if (weapon.syancol) this.syandanaColor = colors.mapColors(weapon.syancol.toString(16));
128
+
129
+ /**
130
+ * If set will show when the player's warframe was infested.
131
+ * @type {ColorMap}
132
+ */
133
+ if (weapon.InfestationDate) this.infestationDate = parseDate(weapon.InfestationDate);
134
+ }
135
+ }
package/src/Mission.js ADDED
@@ -0,0 +1,40 @@
1
+ import { node, nodeEnemy, nodeMissionType } from 'warframe-worldstate-data/utilities';
2
+
3
+ export default class Mission {
4
+ constructor(mission, locale) {
5
+ const uniqueName = mission.Type || mission.Tag;
6
+
7
+ /**
8
+ * Node name
9
+ * @type {String}
10
+ */
11
+ this.node = node(uniqueName, locale);
12
+
13
+ /**
14
+ * Node mission type
15
+ * @type {String}
16
+ */
17
+ this.misstionType = nodeMissionType(uniqueName, locale);
18
+
19
+ /**
20
+ * Node faction
21
+ * @type {String}
22
+ */
23
+ this.faction = nodeEnemy(uniqueName, locale);
24
+
25
+ /**
26
+ * Highest score earned in this mission
27
+ * @type {number}
28
+ */
29
+ if (mission.highScore) this.highScore = mission.HighScore;
30
+
31
+ /**
32
+ * How many times the mission was completed
33
+ * @type {number}
34
+ */
35
+ if (mission.Completes) this.completes = mission.Completes;
36
+
37
+ // Not sure.
38
+ if (mission.Tier) this.tier = mission.Tier;
39
+ }
40
+ }
@@ -0,0 +1,68 @@
1
+ import { colors } from 'warframe-items/utilities';
2
+
3
+ import mapToHex from './Util.js';
4
+
5
+ export default class OperatorLoadOuts {
6
+ constructor(loadout) {
7
+ /**
8
+ * Skins that have been applied to the player's operator.
9
+ * @type {Array<String>}
10
+ */
11
+ this.skins = loadout.Skins;
12
+
13
+ /**
14
+ * Operator amp ID
15
+ * @type {String}
16
+ */
17
+ this.operatorAmp = loadout.OperatorAmp.$oid;
18
+
19
+ /**
20
+ * Applied upgrade IDs
21
+ * @type {Array<String>}
22
+ */
23
+ this.upgrades = loadout.Upgrades;
24
+ this.abilityOverride = loadout.AbilityOverride;
25
+
26
+ /**
27
+ * Operator primary colors
28
+ * @type {module:"warframe-items".ColorMap}
29
+ */
30
+ if (loadout.pricol) this.primaryColor = colors.mapColors(mapToHex(loadout.pricol));
31
+
32
+ /**
33
+ * Operator sigil colors
34
+ * @type {module:"warframe-items".ColorMap}
35
+ */
36
+ if (loadout.sigcol) this.sigilColor = colors.mapColors(mapToHex(loadout.sigcol));
37
+
38
+ /**
39
+ * Operator attachment colors
40
+ * @type {module:"warframe-items".ColorMap}
41
+ */
42
+ if (loadout.attcol) this.attachmentsColor = colors.mapColors(mapToHex(loadout.attcol));
43
+
44
+ /**
45
+ * Operator syandana colors
46
+ * @type {module:"warframe-items".ColorMap}
47
+ */
48
+ if (loadout.syancol) this.syandanaColor = colors.mapColors(mapToHex(loadout.syancol));
49
+
50
+ /**
51
+ * Operator eye colors
52
+ * @type {module:"warframe-items".ColorMap}
53
+ */
54
+ if (loadout.eyecol) this.eyeColor = colors.mapColors(mapToHex(loadout.eyecol));
55
+
56
+ /**
57
+ * Operator facial colors
58
+ * @type {module:"warframe-items".ColorMap}
59
+ */
60
+ if (loadout.facial) this.facial = colors.mapColors(mapToHex(loadout.facial));
61
+
62
+ /**
63
+ * Operator cloth colors
64
+ * @type {module:"warframe-items".ColorMap}
65
+ */
66
+ if (loadout.cloth) this.cloth = colors.mapColors(mapToHex(loadout.cloth));
67
+ }
68
+ }
@@ -0,0 +1,17 @@
1
+ import { translatePolarity } from 'warframe-worldstate-data/utilities';
2
+
3
+ export default class Polarity {
4
+ constructor(polarity) {
5
+ /**
6
+ * Polarity name
7
+ * @type {String}
8
+ */
9
+ this.polarity = translatePolarity(polarity.Value);
10
+
11
+ /**
12
+ * Polarized slot
13
+ * @type {number}
14
+ */
15
+ this.slot = polarity.Slot;
16
+ }
17
+ }