@wfcd/profile-parser 1.3.1 → 1.4.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 CHANGED
@@ -23,7 +23,9 @@ $ npm i -S @wfcd/profile-parser
23
23
  import { ProfileParser } from 'profile-parser';
24
24
 
25
25
  const profileData = await fetch('https://content.warframe.com/dynamic/getProfileViewingData.php?n=${username}');
26
- const user = new ProfileParser(await profileData.text());
26
+ const user = new ProfileParser(await profileData.json());
27
27
 
28
28
  console.log(user.profile.displayName);
29
29
  ```
30
+
31
+ If this data is stale, you can check the `Cache-Control` header of the response from DE's server to see how long to wait for retry, and you could have the above retry after that amount of time. However, this may cause _significant_ delay if the data is not saved/hydrated in a fully asynchronous or event-based timeframe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wfcd/profile-parser",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Parser for Digital Extreme's profile data",
5
5
  "type": "module",
6
6
  "main": "src/ProfileParser.js",
package/src/Intrinsics.js CHANGED
@@ -12,66 +12,66 @@ export default class Intrinsics {
12
12
  * Intrinsic points for railjack
13
13
  * @type {number}
14
14
  */
15
- this.railjack = Math.floor(skills.LPP_SPACE / 1000);
15
+ this.railjack = Math.floor((skills.LPP_SPACE ?? 0) / 1000);
16
16
 
17
17
  /**
18
18
  * Railjack engineering rank
19
19
  * @type {number}
20
20
  */
21
- this.engineering = skills.LPS_ENGINEERING;
21
+ this.engineering = skills.LPS_ENGINEERING ?? 0;
22
22
 
23
23
  /**
24
24
  * Railjack gunnery rank
25
25
  * @type {number}
26
26
  */
27
- this.gunnery = skills.LPS_GUNNERY;
27
+ this.gunnery = skills.LPS_GUNNERY ?? 0;
28
28
 
29
29
  /**
30
30
  * Railjack piloting rank
31
31
  * @type {number}
32
32
  */
33
- this.piloting = skills.LPS_PILOTING;
33
+ this.piloting = skills.LPS_PILOTING ?? 0;
34
34
 
35
35
  /**
36
36
  * Railjack tactical rank
37
37
  * @type {number}
38
38
  */
39
- this.tactical = skills.LPS_TACTICAL;
39
+ this.tactical = skills.LPS_TACTICAL ?? 0;
40
40
 
41
41
  /**
42
42
  * Railjack command rank
43
43
  * @type {number}
44
44
  */
45
- this.command = skills.LPS_COMMAND;
45
+ this.command = skills.LPS_COMMAND ?? 0;
46
46
 
47
47
  /**
48
48
  * Intrinsic points for railjack
49
49
  * @type {number}
50
50
  */
51
- this.drifter = Math.floor(skills.LPP_DRIFTER / 1000);
51
+ this.drifter = Math.floor((skills.LPP_DRIFTER ?? 0) / 1000);
52
52
 
53
53
  /**
54
54
  * Drifter riding rank
55
55
  * @type {number}
56
56
  */
57
- this.riding = skills.LPS_DRIFT_RIDING;
57
+ this.riding = skills.LPS_DRIFT_RIDING ?? 0;
58
58
 
59
59
  /**
60
60
  * Drifter combat rank
61
61
  * @type {number}
62
62
  */
63
- this.combat = skills.LPS_DRIFT_COMBAT;
63
+ this.combat = skills.LPS_DRIFT_COMBAT ?? 0;
64
64
 
65
65
  /**
66
66
  * Drifter opportunity rank
67
67
  * @type {number}
68
68
  */
69
- this.opportunity = skills.LPS_DRIFT_OPPORTUNITY;
69
+ this.opportunity = skills.LPS_DRIFT_OPPORTUNITY ?? 0;
70
70
 
71
71
  /**
72
72
  * Drifter endurance rank
73
73
  * @type {number}
74
74
  */
75
- this.endurance = skills.LPS_DRIFT_ENDURANCE;
75
+ this.endurance = skills.LPS_DRIFT_ENDURANCE ?? 0;
76
76
  }
77
77
  }
@@ -46,11 +46,15 @@ export default class LoadOutItem {
46
46
  if (weapon.ItemName) {
47
47
  const [, nemesis] = weapon.ItemName.split('|');
48
48
 
49
- /**
50
- * Item lich name
51
- * @type {String}
52
- */
53
- this.nemesis = toTitleCase(nemesis);
49
+ if (nemesis !== undefined) {
50
+ /**
51
+ * The name of the Lich, Sister, or Technocyte
52
+ * @type {String}
53
+ */
54
+ this.nemesis = toTitleCase(nemesis);
55
+ } else {
56
+ this.name = weapon.ItemName;
57
+ }
54
58
  }
55
59
 
56
60
  /**
@@ -124,6 +128,12 @@ export default class LoadOutItem {
124
128
  */
125
129
  if (weapon.sigcol) this.sigilColor = colors.mapColors(weapon.sigcol.toString(16));
126
130
 
131
+ /**
132
+ * Whether prime details are enabled or not
133
+ * @type {boolean}
134
+ */
135
+ this.enablePrime = weapon.ugly ?? false;
136
+
127
137
  /**
128
138
  * Attachment colors applied to item if they exist
129
139
  * @type {module:"warframe-items".ColorMap | undefined}
package/src/Profile.js CHANGED
@@ -21,8 +21,8 @@ export default class Profile {
21
21
  */
22
22
  constructor(profile, locale = 'en', withItem = false) {
23
23
  /**
24
- * Player's acount ID
25
- * @type {Stirng}
24
+ * Player's account ID
25
+ * @type {String}
26
26
  */
27
27
  this.accountId = profile.AccountId.$oid;
28
28
 
@@ -45,7 +45,7 @@ export default class Profile {
45
45
  this.masteryRank = profile.PlayerLevel;
46
46
 
47
47
  /**
48
- * Load out preset equiped
48
+ * Load out preset equipped
49
49
  * @type {LoadOutPreset | undefined}
50
50
  */
51
51
  if (profile.LoadOutPreset) this.preset = new LoadOutPreset(profile.LoadOutPreset);
@@ -60,7 +60,7 @@ export default class Profile {
60
60
  * Railjack and drifter Intrinsics
61
61
  * @type {Intrinsics}
62
62
  */
63
- this.intrinsics = new Intrinsics(profile.PlayerSkills);
63
+ this.intrinsics = new Intrinsics(profile.PlayerSkills ?? {});
64
64
 
65
65
  /**
66
66
  * Nightwave challenges progress
@@ -72,7 +72,7 @@ export default class Profile {
72
72
  * Guild ID
73
73
  * @type {String}
74
74
  */
75
- this.guildId = profile.GuildId.$oid;
75
+ if (profile.GuildId?.$oid) this.guildId = profile.GuildId.$oid;
76
76
 
77
77
  /**
78
78
  * Guild name
@@ -118,13 +118,13 @@ export default class Profile {
118
118
 
119
119
  /**
120
120
  * Whether or not the player is qualified as a target for Zanuka
121
- * @type {bool}
121
+ * @type {boolean}
122
122
  */
123
123
  this.harvestable = profile.Harvestable;
124
124
 
125
125
  /**
126
126
  * Whether or not the player is qualified as a target for a syndicate death squad
127
- * @type {bool}
127
+ * @type {boolean}
128
128
  */
129
129
  this.deathSquadable = profile.DeathSquadable;
130
130
 
@@ -136,13 +136,13 @@ export default class Profile {
136
136
 
137
137
  /**
138
138
  * Whether the user has migrated to console or not
139
- * @type {bool}
139
+ * @type {boolean}
140
140
  */
141
141
  this.migratedToConsole = profile.MigratedToConsole;
142
142
 
143
143
  /**
144
144
  * List of completed missions and their completions
145
- * @type {MIssion}
145
+ * @type {Mission}
146
146
  */
147
147
  this.missions = profile.Missions.map((m) => new Mission(m, locale));
148
148
 
@@ -150,7 +150,7 @@ export default class Profile {
150
150
  * Player standing and title across all syndicates
151
151
  * @type {Array<Syndicate>}
152
152
  */
153
- this.syndicates = profile.Affiliations.map((a) => new Syndicate(a));
153
+ this.syndicates = profile.Affiliations?.map((a) => new Syndicate(a)) ?? [];
154
154
 
155
155
  /**
156
156
  * Daily standing per Syndicate
@@ -172,6 +172,7 @@ export default class Profile {
172
172
  holdfasts: profile.DailyAffiliationZariman,
173
173
  kahl: profile.DailyAffiliationKahl,
174
174
  cavia: profile.DailyAffiliationCavia,
175
+ hex: profile.DailyAffiliationHex,
175
176
  };
176
177
 
177
178
  /**
@@ -186,14 +187,14 @@ export default class Profile {
186
187
  this.wishList = profile.Wishlist;
187
188
 
188
189
  /**
189
- * Whhether the player has unlocked thier operator or not
190
- * @type {bool}
190
+ * Whether the player has unlocked their operator or not
191
+ * @type {boolean}
191
192
  */
192
193
  this.unlockedOperator = profile.UnlockedOperator;
193
194
 
194
195
  /**
195
- * Whether the player has unlocked their alignement or not
196
- * @type {bool}
196
+ * Whether the player has unlocked their alignment or not
197
+ * @type {boolean}
197
198
  */
198
199
  this.unlockedAlignment = profile.UnlockedAlignment;
199
200
 
@@ -205,8 +206,8 @@ export default class Profile {
205
206
 
206
207
  /**
207
208
  * Player's alignment
208
- * @type {Map<String,number>}
209
+ * @type {Map<String,number | undefined>}
209
210
  */
210
- this.alignment = { wisdom: profile.Alignment.Wisdom, alignment: profile.Alignment.Alignment };
211
+ this.alignment = { wisdom: profile.Alignment?.Wisdom, alignment: profile.Alignment?.Alignment };
211
212
  }
212
213
  }
package/src/Race.js CHANGED
@@ -28,6 +28,6 @@ export default class Race {
28
28
  * @returns {Race[]} An array of races formatted in a more consumable way.
29
29
  */
30
30
  static fromRaceObject(races) {
31
- return Object.entries(races).map(([type, { highScore }]) => new Race(type, highScore));
31
+ return Object.entries(races ?? []).map(([type, { highScore }]) => new Race(type, highScore));
32
32
  }
33
33
  }
package/src/Stats.js CHANGED
@@ -23,7 +23,7 @@ export default class Stats {
23
23
  this.guildName = stats.GuildName;
24
24
 
25
25
  /**
26
- * Player's total accumalted xp
26
+ * Player's total accumulated xp
27
27
  * @type {String}
28
28
  */
29
29
  this.xp = stats.XP;
@@ -35,25 +35,25 @@ export default class Stats {
35
35
  this.missionsCompleted = stats.MissionsCompleted;
36
36
 
37
37
  /**
38
- * MIssions quit
38
+ * Missions quit
39
39
  * @type {number}
40
40
  */
41
41
  this.missionsQuit = stats.MissionsQuit;
42
42
 
43
43
  /**
44
- * MIsions failed
44
+ * Misions failed
45
45
  * @type {number}
46
46
  */
47
47
  this.missionsFailed = stats.missionsFailed;
48
48
 
49
49
  /**
50
- * MIssions interrupted
50
+ * Missions interrupted
51
51
  * @type {number}
52
52
  */
53
53
  this.missionsInterrupted = stats.MissionsInterrupted;
54
54
 
55
55
  /**
56
- * MIssions dumped
56
+ * Missions dumped
57
57
  * @type {number}
58
58
  */
59
59
  this.missionsDumped = stats.MissionsDumped;
@@ -95,7 +95,7 @@ export default class Stats {
95
95
  this.forestEventScoreSum = stats.ForestEventScoreSum;
96
96
 
97
97
  /**
98
- * Melee kilss
98
+ * Melee kills
99
99
  * @type {number}
100
100
  */
101
101
  this.meleeKills = stats.MeleeKills;
@@ -107,7 +107,7 @@ export default class Stats {
107
107
  this.abilities = stats.Abilities.map((a) => new Ability(a));
108
108
 
109
109
  /**
110
- * Ciphers completed succefully
110
+ * Ciphers completed successfully
111
111
  * @type {number}
112
112
  */
113
113
  this.ciphersSolved = stats.CiphersSolved;
@@ -194,7 +194,7 @@ export default class Stats {
194
194
  * List of scanned Warframe objects
195
195
  * @type {Array<Scan>}
196
196
  */
197
- this.scans = stats.Scans.map((s) => new Scan(s));
197
+ this.scans = stats.Scans?.map((s) => new Scan(s)) ?? [];
198
198
 
199
199
  /**
200
200
  * Team revives
@@ -30,7 +30,7 @@ export default class LoadOutItem {
30
30
  */
31
31
  item: any;
32
32
  /**
33
- * Item lich name
33
+ * The name of the Lich, Sister, or Technocyte
34
34
  * @type {String}
35
35
  */
36
36
  nemesis: string;
@@ -79,6 +79,11 @@ export default class LoadOutItem {
79
79
  customizationSlotPurchases: number;
80
80
  primaryColor: any;
81
81
  sigilColor: any;
82
+ /**
83
+ * Whether prime details are enabled or not
84
+ * @type {boolean}
85
+ */
86
+ enablePrime: boolean;
82
87
  attachmentsColor: any;
83
88
  syandanaColor: any;
84
89
  infestationDate: any;
@@ -11,10 +11,10 @@ export default class Profile {
11
11
  */
12
12
  constructor(profile: any, locale?: string, withItem?: boolean);
13
13
  /**
14
- * Player's acount ID
15
- * @type {Stirng}
14
+ * Player's account ID
15
+ * @type {String}
16
16
  */
17
- accountId: Stirng;
17
+ accountId: string;
18
18
  /**
19
19
  * In-game name
20
20
  * @type {String}
@@ -46,11 +46,7 @@ export default class Profile {
46
46
  * @type {Array<ChallengeProgress>}
47
47
  */
48
48
  challengeProgress: Array<ChallengeProgress>;
49
- /**
50
- * Guild ID
51
- * @type {String}
52
- */
53
- guildId: string;
49
+ guildId: any;
54
50
  /**
55
51
  * Guild name
56
52
  * @type {String}
@@ -84,14 +80,14 @@ export default class Profile {
84
80
  deathMarks: Array<string>;
85
81
  /**
86
82
  * Whether or not the player is qualified as a target for Zanuka
87
- * @type {bool}
83
+ * @type {boolean}
88
84
  */
89
- harvestable: bool;
85
+ harvestable: boolean;
90
86
  /**
91
87
  * Whether or not the player is qualified as a target for a syndicate death squad
92
- * @type {bool}
88
+ * @type {boolean}
93
89
  */
94
- deathSquadable: bool;
90
+ deathSquadable: boolean;
95
91
  /**
96
92
  * Date the account was created
97
93
  * @type {Date}
@@ -99,14 +95,14 @@ export default class Profile {
99
95
  created: Date;
100
96
  /**
101
97
  * Whether the user has migrated to console or not
102
- * @type {bool}
98
+ * @type {boolean}
103
99
  */
104
- migratedToConsole: bool;
100
+ migratedToConsole: boolean;
105
101
  /**
106
102
  * List of completed missions and their completions
107
- * @type {MIssion}
103
+ * @type {Mission}
108
104
  */
109
- missions: MIssion;
105
+ missions: Mission;
110
106
  /**
111
107
  * Player standing and title across all syndicates
112
108
  * @type {Array<Syndicate>}
@@ -129,15 +125,15 @@ export default class Profile {
129
125
  */
130
126
  wishList: any;
131
127
  /**
132
- * Whhether the player has unlocked thier operator or not
133
- * @type {bool}
128
+ * Whether the player has unlocked their operator or not
129
+ * @type {boolean}
134
130
  */
135
- unlockedOperator: bool;
131
+ unlockedOperator: boolean;
136
132
  /**
137
- * Whether the player has unlocked their alignement or not
138
- * @type {bool}
133
+ * Whether the player has unlocked their alignment or not
134
+ * @type {boolean}
139
135
  */
140
- unlockedAlignment: bool;
136
+ unlockedAlignment: boolean;
141
137
  /**
142
138
  * Operator loadout
143
139
  * @type {OperatorLoadOuts | undefined}
@@ -145,13 +141,14 @@ export default class Profile {
145
141
  operatorLoadouts: OperatorLoadOuts | undefined;
146
142
  /**
147
143
  * Player's alignment
148
- * @type {Map<String,number>}
144
+ * @type {Map<String,number | undefined>}
149
145
  */
150
- alignment: Map<string, number>;
146
+ alignment: Map<string, number | undefined>;
151
147
  }
152
148
  import LoadOutPreset from './LoadOutPreset.js';
153
149
  import LoadOutInventory from './LoadOutInventory.js';
154
150
  import Intrinsics from './Intrinsics.js';
155
151
  import ChallengeProgress from './ChallengeProgress.js';
152
+ import Mission from './Mission.js';
156
153
  import Syndicate from './Syndicate.js';
157
154
  import OperatorLoadOuts from './OperatorLoadOuts.js';
package/types/Stats.d.ts CHANGED
@@ -14,7 +14,7 @@ export default class Stats {
14
14
  */
15
15
  guildName: string;
16
16
  /**
17
- * Player's total accumalted xp
17
+ * Player's total accumulated xp
18
18
  * @type {String}
19
19
  */
20
20
  xp: string;
@@ -24,22 +24,22 @@ export default class Stats {
24
24
  */
25
25
  missionsCompleted: number;
26
26
  /**
27
- * MIssions quit
27
+ * Missions quit
28
28
  * @type {number}
29
29
  */
30
30
  missionsQuit: number;
31
31
  /**
32
- * MIsions failed
32
+ * Misions failed
33
33
  * @type {number}
34
34
  */
35
35
  missionsFailed: number;
36
36
  /**
37
- * MIssions interrupted
37
+ * Missions interrupted
38
38
  * @type {number}
39
39
  */
40
40
  missionsInterrupted: number;
41
41
  /**
42
- * MIssions dumped
42
+ * Missions dumped
43
43
  * @type {number}
44
44
  */
45
45
  missionsDumped: number;
@@ -74,7 +74,7 @@ export default class Stats {
74
74
  */
75
75
  forestEventScoreSum: number;
76
76
  /**
77
- * Melee kilss
77
+ * Melee kills
78
78
  * @type {number}
79
79
  */
80
80
  meleeKills: number;
@@ -84,7 +84,7 @@ export default class Stats {
84
84
  */
85
85
  abilities: number;
86
86
  /**
87
- * Ciphers completed succefully
87
+ * Ciphers completed successfully
88
88
  * @type {number}
89
89
  */
90
90
  ciphersSolved: number;