@wfcd/profile-parser 1.2.3 → 1.3.1
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.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/LoadOutInventory.js +3 -2
- package/src/LoadOutPreset.js +90 -0
- package/src/Profile.js +19 -5
- package/src/ProfileParser.js +3 -2
- package/src/Stats.js +1 -1
- package/src/Utils.js +2 -0
- package/src/XpInfo.js +9 -6
- package/types/LoadOutInventory.d.ts +2 -1
- package/types/LoadOutPreset.d.ts +45 -0
- package/types/Profile.d.ts +12 -3
- package/types/ProfileParser.d.ts +2 -1
- package/types/Stats.d.ts +1 -6
- package/types/Utils.d.ts +1 -0
- package/types/XpInfo.d.ts +2 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wfcd/profile-parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Parser for Digital Extreme's profile data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/ProfileParser.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"author": "SlayerOrnstein",
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": ">=20.0.0"
|
|
59
59
|
},
|
|
60
60
|
"eslintConfig": {
|
|
61
61
|
"extends": "@wfcd/eslint-config/esm",
|
package/src/LoadOutInventory.js
CHANGED
|
@@ -11,8 +11,9 @@ export default class LoadOutInventory {
|
|
|
11
11
|
*
|
|
12
12
|
* @param {Object} item The loadout data
|
|
13
13
|
* @param {string} [locale='en'] The locale to return loudout items in
|
|
14
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
14
15
|
*/
|
|
15
|
-
constructor(item, locale = 'en') {
|
|
16
|
+
constructor(item, locale = 'en', withItem = false) {
|
|
16
17
|
/**
|
|
17
18
|
* Skins applied to weapons
|
|
18
19
|
* @type {WeaponSkin}
|
|
@@ -47,6 +48,6 @@ export default class LoadOutInventory {
|
|
|
47
48
|
* Items that have counted towards the players mastery rank
|
|
48
49
|
* @type {XpInfo}
|
|
49
50
|
*/
|
|
50
|
-
this.xpInfo = item.XPInfo.map((xp) => new XpInfo(xp, locale));
|
|
51
|
+
this.xpInfo = item.XPInfo.map((xp) => new XpInfo(xp, locale, withItem));
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { translatePolarity } from 'warframe-worldstate-data/utilities';
|
|
2
|
+
|
|
3
|
+
import { numberToLetter } from './Utils.js';
|
|
4
|
+
|
|
5
|
+
class SlotPreset {
|
|
6
|
+
constructor(slot) {
|
|
7
|
+
if (slot?.ItemId?.$oid) this.id = slot.ItemId.$oid;
|
|
8
|
+
|
|
9
|
+
if (slot?.mod !== undefined) this.modPreset = numberToLetter(slot.mod);
|
|
10
|
+
|
|
11
|
+
if (slot?.cus !== undefined) this.appearancePreset = numberToLetter(slot.cus);
|
|
12
|
+
|
|
13
|
+
this.isHidden = slot?.hide ?? false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class LoadOutPreset {
|
|
18
|
+
constructor(preset) {
|
|
19
|
+
/**
|
|
20
|
+
* Focus School
|
|
21
|
+
* @type {String}
|
|
22
|
+
*/
|
|
23
|
+
this.focusSchool = translatePolarity(preset.FocusSchool);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Preset icon
|
|
27
|
+
*
|
|
28
|
+
* Note:
|
|
29
|
+
* Icon in-game seems to be an image of whatever Warframe is equipped on it
|
|
30
|
+
* @type {String}
|
|
31
|
+
*/
|
|
32
|
+
this.icon = preset.PresetIcon;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether this preset is a favorite
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
this.isFavorite = preset.Favorite;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Preset name
|
|
42
|
+
* @type {String}
|
|
43
|
+
*/
|
|
44
|
+
this.name = preset.n;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Warframe equipped in preset
|
|
48
|
+
* @type {SlotPreset}
|
|
49
|
+
*/
|
|
50
|
+
this.warframe = new SlotPreset(preset.s);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Primary equipped in preset
|
|
54
|
+
* @type {SlotPreset}
|
|
55
|
+
*/
|
|
56
|
+
if (preset.l) this.primary = new SlotPreset(preset.l);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Secondary equipped in preset
|
|
60
|
+
* @type {SlotPreset}
|
|
61
|
+
*/
|
|
62
|
+
if (preset.p) this.secondary = new SlotPreset(preset.p);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Heavy equipped in preset
|
|
66
|
+
* @type {SlotPreset}
|
|
67
|
+
*/
|
|
68
|
+
if (preset.h) this.heavy = new SlotPreset(preset.h);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Melee equiped in preset
|
|
72
|
+
* @type {SlotPreset}
|
|
73
|
+
*/
|
|
74
|
+
if (preset.m) this.melee = new SlotPreset(preset.m);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Exalted ability
|
|
78
|
+
* @type {SlotPreset}
|
|
79
|
+
*/
|
|
80
|
+
if (preset.a) this.exalted = new SlotPreset(preset.a);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Secondary exalted ability
|
|
84
|
+
*
|
|
85
|
+
* i.e Sevagoth has his shadow and his shadow's claws both of which can be modded separately
|
|
86
|
+
* @type {SlotPreset}
|
|
87
|
+
*/
|
|
88
|
+
if (preset.b) this.exaltedB = new SlotPreset(preset.b);
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/Profile.js
CHANGED
|
@@ -6,6 +6,7 @@ import LoadOutInventory from './LoadOutInventory.js';
|
|
|
6
6
|
import Mission from './Mission.js';
|
|
7
7
|
import OperatorLoadOuts from './OperatorLoadOuts.js';
|
|
8
8
|
import Syndicate from './Syndicate.js';
|
|
9
|
+
import LoadOutPreset from './LoadOutPreset.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A player's profile
|
|
@@ -16,8 +17,9 @@ export default class Profile {
|
|
|
16
17
|
*
|
|
17
18
|
* @param {Object} profile The profile data to parse
|
|
18
19
|
* @param {string} locale The locale to return in where possible
|
|
20
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
19
21
|
*/
|
|
20
|
-
constructor(profile, locale = 'en') {
|
|
22
|
+
constructor(profile, locale = 'en', withItem = false) {
|
|
21
23
|
/**
|
|
22
24
|
* Player's acount ID
|
|
23
25
|
* @type {Stirng}
|
|
@@ -30,17 +32,29 @@ export default class Profile {
|
|
|
30
32
|
*/
|
|
31
33
|
this.displayName = profile.DisplayName;
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* List of usernames across supported platforms
|
|
37
|
+
* @type {Array<String>}
|
|
38
|
+
*/
|
|
39
|
+
this.platformNames = profile.PlatformNames;
|
|
40
|
+
|
|
33
41
|
/**
|
|
34
42
|
* Mastery rank
|
|
35
43
|
* @type {String}
|
|
36
44
|
*/
|
|
37
45
|
this.masteryRank = profile.PlayerLevel;
|
|
38
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Load out preset equiped
|
|
49
|
+
* @type {LoadOutPreset | undefined}
|
|
50
|
+
*/
|
|
51
|
+
if (profile.LoadOutPreset) this.preset = new LoadOutPreset(profile.LoadOutPreset);
|
|
52
|
+
|
|
39
53
|
/**
|
|
40
54
|
* Current loadout
|
|
41
55
|
* @type {LoadOutInventory}
|
|
42
56
|
*/
|
|
43
|
-
this.loadout = new LoadOutInventory(profile.LoadOutInventory, locale);
|
|
57
|
+
this.loadout = new LoadOutInventory(profile.LoadOutInventory, locale, withItem);
|
|
44
58
|
|
|
45
59
|
/**
|
|
46
60
|
* Railjack and drifter Intrinsics
|
|
@@ -50,7 +64,7 @@ export default class Profile {
|
|
|
50
64
|
|
|
51
65
|
/**
|
|
52
66
|
* Nightwave challenges progress
|
|
53
|
-
* @type {}
|
|
67
|
+
* @type {Array<ChallengeProgress>}
|
|
54
68
|
*/
|
|
55
69
|
this.challengeProgress = profile.ChallengeProgress.map((c) => new ChallengeProgress(c));
|
|
56
70
|
|
|
@@ -92,9 +106,9 @@ export default class Profile {
|
|
|
92
106
|
|
|
93
107
|
/**
|
|
94
108
|
* Alliance ID
|
|
95
|
-
* @type {String}
|
|
109
|
+
* @type {String | undefined}
|
|
96
110
|
*/
|
|
97
|
-
if (profile.AllianceId
|
|
111
|
+
if (profile.AllianceId?.$oid) this.allianceId = profile.AllianceId.$oid;
|
|
98
112
|
|
|
99
113
|
/**
|
|
100
114
|
* Assassins currently asfter the player
|
package/src/ProfileParser.js
CHANGED
|
@@ -12,13 +12,14 @@ export default class ProfileParser {
|
|
|
12
12
|
*
|
|
13
13
|
* @param {Object} data The data returned by getProfile endpoint
|
|
14
14
|
* @param {string} locale The locale to return where possible
|
|
15
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
15
16
|
*/
|
|
16
|
-
constructor(data, locale = 'en') {
|
|
17
|
+
constructor(data, locale = 'en', withItem = false) {
|
|
17
18
|
/**
|
|
18
19
|
* Player's profile
|
|
19
20
|
* @type {Profile}
|
|
20
21
|
*/
|
|
21
|
-
this.profile = new Profile(data.Results[0], locale);
|
|
22
|
+
this.profile = new Profile(data.Results[0], locale, withItem);
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @type {number}
|
package/src/Stats.js
CHANGED
package/src/Utils.js
CHANGED
package/src/XpInfo.js
CHANGED
|
@@ -9,8 +9,9 @@ export default class XpInfo {
|
|
|
9
9
|
*
|
|
10
10
|
* @param {Object} info The info for a given ranked item
|
|
11
11
|
* @param {string} locale langauge to return item in
|
|
12
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
12
13
|
*/
|
|
13
|
-
constructor(info, locale = 'en') {
|
|
14
|
+
constructor(info, locale = 'en', withItem = false) {
|
|
14
15
|
/**
|
|
15
16
|
* Unique name
|
|
16
17
|
* @type {String}
|
|
@@ -23,10 +24,12 @@ export default class XpInfo {
|
|
|
23
24
|
*/
|
|
24
25
|
this.xp = info.XP;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (withItem) {
|
|
28
|
+
/**
|
|
29
|
+
* The item corrosponding to the unique name.
|
|
30
|
+
* @type {module:"warframe-items".Item | undefined}
|
|
31
|
+
*/
|
|
32
|
+
this.item = find(info.ItemType, locale);
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -7,8 +7,9 @@ export default class LoadOutInventory {
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} item The loadout data
|
|
9
9
|
* @param {string} [locale='en'] The locale to return loudout items in
|
|
10
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
10
11
|
*/
|
|
11
|
-
constructor(item: any, locale?: string);
|
|
12
|
+
constructor(item: any, locale?: string, withItem?: boolean);
|
|
12
13
|
/**
|
|
13
14
|
* Skins applied to weapons
|
|
14
15
|
* @type {WeaponSkin}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default class LoadOutPreset {
|
|
2
|
+
constructor(preset: any);
|
|
3
|
+
/**
|
|
4
|
+
* Focus School
|
|
5
|
+
* @type {String}
|
|
6
|
+
*/
|
|
7
|
+
focusSchool: string;
|
|
8
|
+
/**
|
|
9
|
+
* Preset icon
|
|
10
|
+
*
|
|
11
|
+
* Note:
|
|
12
|
+
* Icon in-game seems to be an image of whatever Warframe is equipped on it
|
|
13
|
+
* @type {String}
|
|
14
|
+
*/
|
|
15
|
+
icon: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether this preset is a favorite
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
isFavorite: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Preset name
|
|
23
|
+
* @type {String}
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Warframe equipped in preset
|
|
28
|
+
* @type {SlotPreset}
|
|
29
|
+
*/
|
|
30
|
+
warframe: SlotPreset;
|
|
31
|
+
primary: SlotPreset;
|
|
32
|
+
secondary: SlotPreset;
|
|
33
|
+
heavy: SlotPreset;
|
|
34
|
+
melee: SlotPreset;
|
|
35
|
+
exalted: SlotPreset;
|
|
36
|
+
exaltedB: SlotPreset;
|
|
37
|
+
}
|
|
38
|
+
declare class SlotPreset {
|
|
39
|
+
constructor(slot: any);
|
|
40
|
+
id: any;
|
|
41
|
+
modPreset: string;
|
|
42
|
+
appearancePreset: string;
|
|
43
|
+
isHidden: any;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
package/types/Profile.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export default class Profile {
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} profile The profile data to parse
|
|
9
9
|
* @param {string} locale The locale to return in where possible
|
|
10
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
10
11
|
*/
|
|
11
|
-
constructor(profile: any, locale?: string);
|
|
12
|
+
constructor(profile: any, locale?: string, withItem?: boolean);
|
|
12
13
|
/**
|
|
13
14
|
* Player's acount ID
|
|
14
15
|
* @type {Stirng}
|
|
@@ -19,11 +20,17 @@ export default class Profile {
|
|
|
19
20
|
* @type {String}
|
|
20
21
|
*/
|
|
21
22
|
displayName: string;
|
|
23
|
+
/**
|
|
24
|
+
* List of usernames across supported platforms
|
|
25
|
+
* @type {Array<String>}
|
|
26
|
+
*/
|
|
27
|
+
platformNames: Array<string>;
|
|
22
28
|
/**
|
|
23
29
|
* Mastery rank
|
|
24
30
|
* @type {String}
|
|
25
31
|
*/
|
|
26
32
|
masteryRank: string;
|
|
33
|
+
preset: LoadOutPreset;
|
|
27
34
|
/**
|
|
28
35
|
* Current loadout
|
|
29
36
|
* @type {LoadOutInventory}
|
|
@@ -36,9 +43,9 @@ export default class Profile {
|
|
|
36
43
|
intrinsics: Intrinsics;
|
|
37
44
|
/**
|
|
38
45
|
* Nightwave challenges progress
|
|
39
|
-
* @type {}
|
|
46
|
+
* @type {Array<ChallengeProgress>}
|
|
40
47
|
*/
|
|
41
|
-
challengeProgress:
|
|
48
|
+
challengeProgress: Array<ChallengeProgress>;
|
|
42
49
|
/**
|
|
43
50
|
* Guild ID
|
|
44
51
|
* @type {String}
|
|
@@ -142,7 +149,9 @@ export default class Profile {
|
|
|
142
149
|
*/
|
|
143
150
|
alignment: Map<string, number>;
|
|
144
151
|
}
|
|
152
|
+
import LoadOutPreset from './LoadOutPreset.js';
|
|
145
153
|
import LoadOutInventory from './LoadOutInventory.js';
|
|
146
154
|
import Intrinsics from './Intrinsics.js';
|
|
155
|
+
import ChallengeProgress from './ChallengeProgress.js';
|
|
147
156
|
import Syndicate from './Syndicate.js';
|
|
148
157
|
import OperatorLoadOuts from './OperatorLoadOuts.js';
|
package/types/ProfileParser.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export default class ProfileParser {
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} data The data returned by getProfile endpoint
|
|
9
9
|
* @param {string} locale The locale to return where possible
|
|
10
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
10
11
|
*/
|
|
11
|
-
constructor(data: any, locale?: string);
|
|
12
|
+
constructor(data: any, locale?: string, withItem?: boolean);
|
|
12
13
|
/**
|
|
13
14
|
* Player's profile
|
|
14
15
|
* @type {Profile}
|
package/types/Stats.d.ts
CHANGED
|
@@ -161,11 +161,7 @@ export default class Stats {
|
|
|
161
161
|
* Score for Operation: Eyes of Blight
|
|
162
162
|
*/
|
|
163
163
|
fomorianEventScore: any;
|
|
164
|
-
|
|
165
|
-
* Conclave scores
|
|
166
|
-
* @type {Array<Pvp>}
|
|
167
|
-
*/
|
|
168
|
-
pvp: Array<Pvp>;
|
|
164
|
+
pvp: any;
|
|
169
165
|
/**
|
|
170
166
|
* Lunaro stats
|
|
171
167
|
* @type {Map<String,number>}
|
|
@@ -256,5 +252,4 @@ import Weapon from './Weapon.js';
|
|
|
256
252
|
import Enemy from './Enemy.js';
|
|
257
253
|
import Mission from './Mission.js';
|
|
258
254
|
import Scan from './Scan.js';
|
|
259
|
-
import Pvp from './Pvp.js';
|
|
260
255
|
import Race from './Race.js';
|
package/types/Utils.d.ts
CHANGED
package/types/XpInfo.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export default class XpInfo {
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} info The info for a given ranked item
|
|
9
9
|
* @param {string} locale langauge to return item in
|
|
10
|
+
* @param {boolean} [withItem=false] Whether or not to include items
|
|
10
11
|
*/
|
|
11
|
-
constructor(info: any, locale?: string);
|
|
12
|
+
constructor(info: any, locale?: string, withItem?: boolean);
|
|
12
13
|
/**
|
|
13
14
|
* Unique name
|
|
14
15
|
* @type {String}
|