@wfcd/profile-parser 1.2.0 → 1.2.2
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/package.json +1 -1
- package/src/ArchonCrystal.js +4 -4
- package/src/Intrinsics.js +4 -4
- package/src/ItemConfig.js +1 -1
- package/src/LoadOutInventory.js +7 -6
- package/src/LoadOutItem.js +5 -3
- package/src/Mission.js +1 -1
- package/src/OperatorLoadOuts.js +1 -1
- package/src/Profile.js +2 -2
- package/src/ProfileParser.js +1 -1
- package/src/Skin.js +4 -3
- package/src/Syndicate.js +1 -1
- package/src/Utils.js +64 -0
- package/src/XpInfo.js +4 -3
- package/types/ArchonCrystal.d.ts +2 -2
- package/types/Intrinsics.d.ts +3 -1
- package/types/LoadOutInventory.d.ts +2 -1
- package/types/LoadOutItem.d.ts +2 -1
- package/types/Mission.d.ts +1 -1
- package/types/Profile.d.ts +1 -1
- package/types/ProfileParser.d.ts +1 -1
- package/types/Skin.d.ts +2 -1
- package/types/Syndicate.d.ts +1 -1
- package/types/Utils.d.ts +2 -0
- package/types/XpInfo.d.ts +2 -1
- package/src/Util.js +0 -14
- package/types/Util.d.ts +0 -7
package/package.json
CHANGED
package/src/ArchonCrystal.js
CHANGED
|
@@ -8,19 +8,19 @@ export default class ArchonCrystal {
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {Object} crystal The archon crystal object
|
|
11
|
-
* @param {string}
|
|
11
|
+
* @param {string} locale The locale to get translations in
|
|
12
12
|
*/
|
|
13
|
-
constructor(crystal,
|
|
13
|
+
constructor(crystal, locale = 'en') {
|
|
14
14
|
/**
|
|
15
15
|
* Archon shard color
|
|
16
16
|
* @type {String}
|
|
17
17
|
*/
|
|
18
|
-
this.color = archonShardColor(crystal.Color,
|
|
18
|
+
this.color = archonShardColor(crystal.Color, locale);
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Archon shard modifier
|
|
22
22
|
* @type {String}
|
|
23
23
|
*/
|
|
24
|
-
this.modifier = archonShardUpgradeType(crystal.Color, crystal.UpgradeType,
|
|
24
|
+
this.modifier = archonShardUpgradeType(crystal.Color, crystal.UpgradeType, locale);
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/Intrinsics.js
CHANGED
|
@@ -8,11 +8,11 @@ export default class Intrinsics {
|
|
|
8
8
|
* @param {Object} skills The intrinsics object
|
|
9
9
|
*/
|
|
10
10
|
constructor(skills) {
|
|
11
|
-
// I know this is railjack but I'm not sure what the context is
|
|
12
11
|
/**
|
|
12
|
+
* Intrinsic points for railjack
|
|
13
13
|
* @type {number}
|
|
14
14
|
*/
|
|
15
|
-
this.
|
|
15
|
+
this.railjack = Math.floor(skills.LPP_SPACE / 1000);
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Railjack engineering rank
|
|
@@ -44,11 +44,11 @@ export default class Intrinsics {
|
|
|
44
44
|
*/
|
|
45
45
|
this.command = skills.LPS_COMMAND;
|
|
46
46
|
|
|
47
|
-
// Not sure what the context for this one is either
|
|
48
47
|
/**
|
|
48
|
+
* Intrinsic points for railjack
|
|
49
49
|
* @type {number}
|
|
50
50
|
*/
|
|
51
|
-
this.drifter = skills.LPP_DRIFTER;
|
|
51
|
+
this.drifter = Math.floor(skills.LPP_DRIFTER / 1000);
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Drifter riding rank
|
package/src/ItemConfig.js
CHANGED
package/src/LoadOutInventory.js
CHANGED
|
@@ -10,8 +10,9 @@ export default class LoadOutInventory {
|
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @param {Object} item The loadout data
|
|
13
|
+
* @param {string} [locale='en'] The locale to return loudout items in
|
|
13
14
|
*/
|
|
14
|
-
constructor(item) {
|
|
15
|
+
constructor(item, locale = 'en') {
|
|
15
16
|
/**
|
|
16
17
|
* Skins applied to weapons
|
|
17
18
|
* @type {WeaponSkin}
|
|
@@ -22,30 +23,30 @@ export default class LoadOutInventory {
|
|
|
22
23
|
* An array of the player's currently equiped Warframe (or powersuits)
|
|
23
24
|
* @type {LoadOutItem}
|
|
24
25
|
*/
|
|
25
|
-
this.suits = item.Suits.map((s) => new LoadOutItem(s));
|
|
26
|
+
this.suits = item.Suits.map((s) => new LoadOutItem(s, locale));
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* An array of the player's currently equiped secondary weapon
|
|
29
30
|
* @type {LoadOutItem | undefined}
|
|
30
31
|
*/
|
|
31
|
-
this.secondary = item.Pistols?.map((p) => new LoadOutItem(p));
|
|
32
|
+
this.secondary = item.Pistols?.map((p) => new LoadOutItem(p, locale));
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* An array of the player's currently equiped primary weapon
|
|
35
36
|
* @type {LoadOutItem | undefined}
|
|
36
37
|
*/
|
|
37
|
-
this.primary = item.LongGuns?.map((lg) => new LoadOutItem(lg));
|
|
38
|
+
this.primary = item.LongGuns?.map((lg) => new LoadOutItem(lg, locale));
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* An array of the player's currently equiped melee weapon
|
|
41
42
|
* @type {LoadOutItem | undefined}
|
|
42
43
|
*/
|
|
43
|
-
this.melee = item.Melee?.map((m) => new LoadOutItem(m));
|
|
44
|
+
this.melee = item.Melee?.map((m) => new LoadOutItem(m, locale));
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Items that have counted towards the players mastery rank
|
|
47
48
|
* @type {XpInfo}
|
|
48
49
|
*/
|
|
49
|
-
this.xpInfo = item.XPInfo.map((xp) => new XpInfo(xp));
|
|
50
|
+
this.xpInfo = item.XPInfo.map((xp) => new XpInfo(xp, locale));
|
|
50
51
|
}
|
|
51
52
|
}
|
package/src/LoadOutItem.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { colors
|
|
1
|
+
import { colors } from 'warframe-items/utilities';
|
|
2
2
|
import { parseDate, toTitleCase } from 'warframe-worldstate-data/utilities';
|
|
3
3
|
|
|
4
4
|
import ItemConfig from './ItemConfig.js';
|
|
5
5
|
import Polarity from './Polarity.js';
|
|
6
|
+
import { find } from './Utils.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* An an item in LoadOutInventory
|
|
@@ -12,8 +13,9 @@ export default class LoadOutItem {
|
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
14
15
|
* @param {Object} weapon The loadout item from LoadoutInventory
|
|
16
|
+
* @param {string} [locale='en'] The locale to return item in
|
|
15
17
|
*/
|
|
16
|
-
constructor(weapon) {
|
|
18
|
+
constructor(weapon, locale = 'en') {
|
|
17
19
|
/**
|
|
18
20
|
* Item ID
|
|
19
21
|
* @type {String}
|
|
@@ -26,7 +28,7 @@ export default class LoadOutItem {
|
|
|
26
28
|
*/
|
|
27
29
|
this.uniqueName = weapon.ItemType;
|
|
28
30
|
|
|
29
|
-
const item = find
|
|
31
|
+
const item = find(weapon.ItemType, locale);
|
|
30
32
|
if (item) {
|
|
31
33
|
/**
|
|
32
34
|
* Item in-game name
|
package/src/Mission.js
CHANGED
|
@@ -10,7 +10,7 @@ export default class Mission {
|
|
|
10
10
|
* @param {Object} mission The mission data
|
|
11
11
|
* @param {string} locale The locale to return in
|
|
12
12
|
*/
|
|
13
|
-
constructor(mission, locale) {
|
|
13
|
+
constructor(mission, locale = 'en') {
|
|
14
14
|
const uniqueName = mission.type || mission.Tag;
|
|
15
15
|
|
|
16
16
|
/**
|
package/src/OperatorLoadOuts.js
CHANGED
package/src/Profile.js
CHANGED
|
@@ -17,7 +17,7 @@ export default class Profile {
|
|
|
17
17
|
* @param {Object} profile The profile data to parse
|
|
18
18
|
* @param {string} locale The locale to return in where possible
|
|
19
19
|
*/
|
|
20
|
-
constructor(profile, locale) {
|
|
20
|
+
constructor(profile, locale = 'en') {
|
|
21
21
|
/**
|
|
22
22
|
* Player's acount ID
|
|
23
23
|
* @type {Stirng}
|
|
@@ -40,7 +40,7 @@ export default class Profile {
|
|
|
40
40
|
* Current loadout
|
|
41
41
|
* @type {LoadOutInventory}
|
|
42
42
|
*/
|
|
43
|
-
this.loadout = new LoadOutInventory(profile.LoadOutInventory);
|
|
43
|
+
this.loadout = new LoadOutInventory(profile.LoadOutInventory, locale);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Railjack and drifter Intrinsics
|
package/src/ProfileParser.js
CHANGED
|
@@ -13,7 +13,7 @@ export default class ProfileParser {
|
|
|
13
13
|
* @param {Object} data The data returned by getProfile endpoint
|
|
14
14
|
* @param {string} locale The locale to return where possible
|
|
15
15
|
*/
|
|
16
|
-
constructor(data, locale) {
|
|
16
|
+
constructor(data, locale = 'en') {
|
|
17
17
|
/**
|
|
18
18
|
* Player's profile
|
|
19
19
|
* @type {Profile}
|
package/src/Skin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { find } from '
|
|
1
|
+
import { find } from './Utils.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A skin class
|
|
@@ -8,15 +8,16 @@ export default class Skin {
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {Object} skin The skin data to parse
|
|
11
|
+
* @param {string} [locale='en'] The locale to return skin item in
|
|
11
12
|
*/
|
|
12
|
-
constructor(skin) {
|
|
13
|
+
constructor(skin, locale = 'en') {
|
|
13
14
|
/**
|
|
14
15
|
* Unique name
|
|
15
16
|
* @type {String}
|
|
16
17
|
*/
|
|
17
18
|
this.uniqueName = skin.ItemType;
|
|
18
19
|
|
|
19
|
-
const item = find
|
|
20
|
+
const item = find(skin.ItemType, locale);
|
|
20
21
|
/**
|
|
21
22
|
* The Warframe item that matches the unique name
|
|
22
23
|
*/
|
package/src/Syndicate.js
CHANGED
|
@@ -9,7 +9,7 @@ export default class Syndicate {
|
|
|
9
9
|
* @param {Object} affiliation The syndicate data
|
|
10
10
|
* @param {string} locale locale code
|
|
11
11
|
*/
|
|
12
|
-
constructor(affiliation, locale) {
|
|
12
|
+
constructor(affiliation, locale = 'en') {
|
|
13
13
|
// TODO: name is readable but still might want to clean them up
|
|
14
14
|
// i.e "NewLokaSyndicate" can be "New Loka"" instead
|
|
15
15
|
|
package/src/Utils.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Items from 'warframe-items';
|
|
2
|
+
|
|
3
|
+
/** @module */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Map base10 int colors to hex color strings
|
|
7
|
+
* @param {Record<string, number | undefined>} colors color map
|
|
8
|
+
* @returns {Record<string, string>}
|
|
9
|
+
*/
|
|
10
|
+
export const mapToHex = (colors) => {
|
|
11
|
+
const hex = {};
|
|
12
|
+
Object.entries(colors).forEach(([key, /** @type {undefined | number} */ value]) => {
|
|
13
|
+
hex[key] = Math.abs(value).toString(16).toUpperCase();
|
|
14
|
+
});
|
|
15
|
+
return hex;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const categories = [
|
|
19
|
+
'Skins',
|
|
20
|
+
'Primary',
|
|
21
|
+
'Secondary',
|
|
22
|
+
'Melee',
|
|
23
|
+
'Arch-Melee',
|
|
24
|
+
'Arch-Gun',
|
|
25
|
+
'Warframes',
|
|
26
|
+
'Archwing',
|
|
27
|
+
'Sentinels',
|
|
28
|
+
'Pets',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Find an item by Item#uniqueName
|
|
33
|
+
* @param {string} name string with which to query
|
|
34
|
+
* @param {string} [locale='en'] locale to use for internationalization
|
|
35
|
+
* @returns {Item}
|
|
36
|
+
*/
|
|
37
|
+
export const find = (name, locale = 'en') => {
|
|
38
|
+
const items = new Items({
|
|
39
|
+
category: categories,
|
|
40
|
+
i18n: locale,
|
|
41
|
+
i18nOnObject: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const item = items.find((i) => i.uniqueName === name);
|
|
45
|
+
|
|
46
|
+
let itemClone = { ...item };
|
|
47
|
+
if (locale !== 'en' && itemClone.i18n[locale] && itemClone.i18n[locale]) {
|
|
48
|
+
itemClone = { ...itemClone, ...itemClone.i18n[locale] };
|
|
49
|
+
|
|
50
|
+
if (itemClone.abilities) {
|
|
51
|
+
itemClone.abilities = itemClone.abilities.map((ability) => ({
|
|
52
|
+
uniqueName: ability.abilityUniqueName || ability.uniqueName || undefined,
|
|
53
|
+
name: ability.abilityName || ability.name,
|
|
54
|
+
description: ability.abilityDescription || ability.description,
|
|
55
|
+
imageName: ability.imageName ?? undefined,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
delete itemClone.i18n;
|
|
60
|
+
return itemClone;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return item;
|
|
64
|
+
};
|
package/src/XpInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { find } from '
|
|
1
|
+
import { find } from './Utils.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An item that has contributed to a player's mastery rank
|
|
@@ -8,8 +8,9 @@ export default class XpInfo {
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {Object} info The info for a given ranked item
|
|
11
|
+
* @param {string} locale langauge to return item in
|
|
11
12
|
*/
|
|
12
|
-
constructor(info) {
|
|
13
|
+
constructor(info, locale = 'en') {
|
|
13
14
|
/**
|
|
14
15
|
* Unique name
|
|
15
16
|
* @type {String}
|
|
@@ -26,6 +27,6 @@ export default class XpInfo {
|
|
|
26
27
|
* The item corrosponding to the unique name.
|
|
27
28
|
* @type {module:"warframe-items".Item | undefined}
|
|
28
29
|
*/
|
|
29
|
-
this.item = find
|
|
30
|
+
this.item = find(info.ItemType, locale);
|
|
30
31
|
}
|
|
31
32
|
}
|
package/types/ArchonCrystal.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export default class ArchonCrystal {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} crystal The archon crystal object
|
|
9
|
-
* @param {string}
|
|
9
|
+
* @param {string} locale The locale to get translations in
|
|
10
10
|
*/
|
|
11
|
-
constructor(crystal: any,
|
|
11
|
+
constructor(crystal: any, locale?: string);
|
|
12
12
|
/**
|
|
13
13
|
* Archon shard color
|
|
14
14
|
* @type {String}
|
package/types/Intrinsics.d.ts
CHANGED
|
@@ -9,9 +9,10 @@ export default class Intrinsics {
|
|
|
9
9
|
*/
|
|
10
10
|
constructor(skills: any);
|
|
11
11
|
/**
|
|
12
|
+
* Intrinsic points for railjack
|
|
12
13
|
* @type {number}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
railjack: number;
|
|
15
16
|
/**
|
|
16
17
|
* Railjack engineering rank
|
|
17
18
|
* @type {number}
|
|
@@ -38,6 +39,7 @@ export default class Intrinsics {
|
|
|
38
39
|
*/
|
|
39
40
|
command: number;
|
|
40
41
|
/**
|
|
42
|
+
* Intrinsic points for railjack
|
|
41
43
|
* @type {number}
|
|
42
44
|
*/
|
|
43
45
|
drifter: number;
|
|
@@ -6,8 +6,9 @@ export default class LoadOutInventory {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} item The loadout data
|
|
9
|
+
* @param {string} [locale='en'] The locale to return loudout items in
|
|
9
10
|
*/
|
|
10
|
-
constructor(item: any);
|
|
11
|
+
constructor(item: any, locale?: string);
|
|
11
12
|
/**
|
|
12
13
|
* Skins applied to weapons
|
|
13
14
|
* @type {WeaponSkin}
|
package/types/LoadOutItem.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export default class LoadOutItem {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} weapon The loadout item from LoadoutInventory
|
|
9
|
+
* @param {string} [locale='en'] The locale to return item in
|
|
9
10
|
*/
|
|
10
|
-
constructor(weapon: any);
|
|
11
|
+
constructor(weapon: any, locale?: string);
|
|
11
12
|
/**
|
|
12
13
|
* Item ID
|
|
13
14
|
* @type {String}
|
package/types/Mission.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default class Mission {
|
|
|
8
8
|
* @param {Object} mission The mission data
|
|
9
9
|
* @param {string} locale The locale to return in
|
|
10
10
|
*/
|
|
11
|
-
constructor(mission: any, locale
|
|
11
|
+
constructor(mission: any, locale?: string);
|
|
12
12
|
/**
|
|
13
13
|
* Node name
|
|
14
14
|
* @type {String}
|
package/types/Profile.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default class Profile {
|
|
|
8
8
|
* @param {Object} profile The profile data to parse
|
|
9
9
|
* @param {string} locale The locale to return in where possible
|
|
10
10
|
*/
|
|
11
|
-
constructor(profile: any, locale
|
|
11
|
+
constructor(profile: any, locale?: string);
|
|
12
12
|
/**
|
|
13
13
|
* Player's acount ID
|
|
14
14
|
* @type {Stirng}
|
package/types/ProfileParser.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default class ProfileParser {
|
|
|
8
8
|
* @param {Object} data The data returned by getProfile endpoint
|
|
9
9
|
* @param {string} locale The locale to return where possible
|
|
10
10
|
*/
|
|
11
|
-
constructor(data: any, locale
|
|
11
|
+
constructor(data: any, locale?: string);
|
|
12
12
|
/**
|
|
13
13
|
* Player's profile
|
|
14
14
|
* @type {Profile}
|
package/types/Skin.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export default class Skin {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} skin The skin data to parse
|
|
9
|
+
* @param {string} [locale='en'] The locale to return skin item in
|
|
9
10
|
*/
|
|
10
|
-
constructor(skin: any);
|
|
11
|
+
constructor(skin: any, locale?: string);
|
|
11
12
|
/**
|
|
12
13
|
* Unique name
|
|
13
14
|
* @type {String}
|
package/types/Syndicate.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default class Syndicate {
|
|
|
7
7
|
* @param {Object} affiliation The syndicate data
|
|
8
8
|
* @param {string} locale locale code
|
|
9
9
|
*/
|
|
10
|
-
constructor(affiliation: any, locale
|
|
10
|
+
constructor(affiliation: any, locale?: string);
|
|
11
11
|
/**
|
|
12
12
|
* Name of the syndicate
|
|
13
13
|
* @type {String}
|
package/types/Utils.d.ts
ADDED
package/types/XpInfo.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export default class XpInfo {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} info The info for a given ranked item
|
|
9
|
+
* @param {string} locale langauge to return item in
|
|
9
10
|
*/
|
|
10
|
-
constructor(info: any);
|
|
11
|
+
constructor(info: any, locale?: string);
|
|
11
12
|
/**
|
|
12
13
|
* Unique name
|
|
13
14
|
* @type {String}
|
package/src/Util.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** @module */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Map base10 int colors to hex color strings
|
|
5
|
-
* @param {Record<string, number | undefined>} colors color map
|
|
6
|
-
* @returns {Record<string, string>}
|
|
7
|
-
*/
|
|
8
|
-
export default function mapToHex(colors) {
|
|
9
|
-
const hex = {};
|
|
10
|
-
Object.entries(colors).forEach(([key, /** @type {undefined | number} */ value]) => {
|
|
11
|
-
hex[key] = Math.abs(value).toString(16).toUpperCase();
|
|
12
|
-
});
|
|
13
|
-
return hex;
|
|
14
|
-
}
|
package/types/Util.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** @module */
|
|
2
|
-
/**
|
|
3
|
-
* Map base10 int colors to hex color strings
|
|
4
|
-
* @param {Record<string, number | undefined>} colors color map
|
|
5
|
-
* @returns {Record<string, string>}
|
|
6
|
-
*/
|
|
7
|
-
export default function mapToHex(colors: Record<string, number | undefined>): Record<string, string>;
|