@wise-old-man/utils 2.0.2 → 2.0.5

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/dist/index.d.ts CHANGED
@@ -1677,8 +1677,9 @@ declare function isSkill(metric: Metric | string): metric is Skill;
1677
1677
  declare function isActivity(metric: Metric | string): metric is Activity;
1678
1678
  declare function isBoss(metric: Metric | string): metric is Boss;
1679
1679
  declare function isComputedMetric(metric: Metric | string): metric is ComputedMetric;
1680
- declare function getMetricRankKey(metric: Metric): string;
1681
- declare function getMetricValueKey(metric: Metric): string;
1680
+ declare function getMetricRankKey<T extends Metric>(metric: T): `${T}Rank`;
1681
+ declare type MetricValueKey = `${Skill}Experience` | `${Boss}Kills` | `${Activity}Score` | `${ComputedMetric}Value`;
1682
+ declare function getMetricValueKey(metric: Metric): MetricValueKey;
1682
1683
  declare function getMetricMeasure(metric: Metric): MetricMeasure;
1683
1684
  declare function getMetricName(metric: Metric): string;
1684
1685
  declare function getMinimumValue(metric: Metric): number;
@@ -1752,10 +1753,7 @@ interface CreateGroupResponse {
1752
1753
  group: GroupDetails;
1753
1754
  verificationCode: string;
1754
1755
  }
1755
- interface ChangeMemberRolePayload {
1756
- username: string;
1757
- role: GroupRole;
1758
- }
1756
+ declare type ChangeMemberRolePayload = Required<GroupMemberFragment>;
1759
1757
  declare type GetGroupGainsFilter = {
1760
1758
  metric: Metric;
1761
1759
  } & TimeRangeFilter;
@@ -1808,11 +1806,17 @@ declare type NameChangesSearchFilter = {
1808
1806
  */
1809
1807
  interface RecordLeaderboardFilter extends BasePlayerFilter {
1810
1808
  metric: Metric;
1811
- period: Period | string;
1809
+ period: Period;
1812
1810
  }
1813
1811
  /**
1814
1812
  * Player Client Types
1815
1813
  */
1814
+ interface PlayerCompetitionsFilter {
1815
+ status?: CompetitionStatus;
1816
+ }
1817
+ interface PlayerCompetitionStandingsFilter {
1818
+ status: Exclude<CompetitionStatus, CompetitionStatus.UPCOMING>;
1819
+ }
1816
1820
  interface PlayerRecordsFilter {
1817
1821
  period: Period | string;
1818
1822
  metric: Metric;
@@ -1982,12 +1986,12 @@ declare class PlayersClient extends BaseAPIClient {
1982
1986
  * Fetches all of the player's competition participations.
1983
1987
  * @returns A list of participations, with the respective competition included.
1984
1988
  */
1985
- getPlayerCompetitions(player: PlayerResolvable, pagination?: PaginationOptions): Promise<ParticipationWithCompetition[]>;
1989
+ getPlayerCompetitions(player: PlayerResolvable, filter?: PlayerCompetitionsFilter, pagination?: PaginationOptions): Promise<ParticipationWithCompetition[]>;
1986
1990
  /**
1987
1991
  * Fetches all of the player's competition participations' standings.
1988
1992
  * @returns A list of participations, with the respective competition, rank and progress included.
1989
1993
  */
1990
- getPlayerCompetitionStandings(player: PlayerResolvable): Promise<ParticipationWithCompetitionAndStandings[]>;
1994
+ getPlayerCompetitionStandings(player: PlayerResolvable, filter: PlayerCompetitionsFilter): Promise<ParticipationWithCompetitionAndStandings[]>;
1991
1995
  /**
1992
1996
  * Fetches all of the player's group memberships.
1993
1997
  * @returns A list of memberships, with the respective group included.
@@ -2012,7 +2016,7 @@ declare class PlayersClient extends BaseAPIClient {
2012
2016
  * Fetches all of the player's past snapshots.
2013
2017
  * @returns A list of snapshots.
2014
2018
  */
2015
- getPlayerSnapshots(player: PlayerResolvable, options?: TimeRangeFilter): Promise<FormattedSnapshot[]>;
2019
+ getPlayerSnapshots(player: PlayerResolvable, options?: TimeRangeFilter, pagination?: PaginationOptions): Promise<FormattedSnapshot[]>;
2016
2020
  /**
2017
2021
  * Fetches all of the player's approved name changes.
2018
2022
  * @returns A list of name changes.
@@ -2139,4 +2143,4 @@ declare class WOMClient {
2139
2143
  constructor(options?: WOMClientOptions);
2140
2144
  }
2141
2145
 
2142
- export { ACTIVITIES, Achievement, AchievementDefinition, AchievementProgress, AchievementTemplate, Activity, ActivityDelta, ActivityValue, AlgorithmCache, AssertPlayerTypeResponse, BOSSES, Bonus, BonusType, Boss, BossDelta, BossMetaConfig, BossValue, CAPPED_MAX_TOTAL_XP, CMLGroupData, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, ChangeMemberRolePayload, CompetitionDetails, CompetitionListItem, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, CompetitionWithParticipations, CompetitionsSearchFilter, ComputedMetric, ComputedMetricDelta, ComputedMetricValue, Country, CountryDetails, CountryProps, CreateCompetitionPayload, CreateCompetitionResponse, CreateGroupPayload, CreateGroupResponse, DeltaLeaderboardEntry, DeltaLeaderboardFilter, EditCompetitionPayload, EditGroupPayload, EfficiencyAlgorithm, EfficiencyAlgorithmType, EfficiencyAlgorithmTypeUnion, EfficiencyLeaderboardsFilter, EfficiencyMap, ExperienceMap, ExtendedAchievement, F2P_BOSSES, FormattedSnapshot, GROUP_ROLES, GenericCountMessageResponse, GenericMessageResponse, GetGroupGainsFilter, GetPlayerGainsResponse, GroupDetails, GroupHiscoresActivityItem, GroupHiscoresBossItem, GroupHiscoresComputedMetricItem, GroupHiscoresEntry, GroupHiscoresSkillItem, GroupListItem, GroupMemberFragment, GroupRecordsFilter, GroupRole, GroupRoleProps, GroupStatistics, KillcountMap, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MapOf, MeasuredDeltaProgress, MemberInput, MembershipWithGroup, MembershipWithPlayer, Metric, MetricMeasure, MetricProps, MetricType, MigrationDataSource, NameChangeDetails, NameChangeStatus, NameChangesSearchFilter, PERIODS, PLAYER_BUILDS, PLAYER_TYPES, PRIVELEGED_GROUP_ROLES, ParticipationWithCompetition, ParticipationWithCompetitionAndStandings, ParticipationWithPlayer, ParticipationWithPlayerAndProgress, Period, PeriodProps, Player, PlayerBuild, PlayerBuildProps, PlayerDeltasArray, PlayerDeltasMap, PlayerDetails, PlayerRecordsFilter, PlayerResolvable, PlayerType, PlayerTypeProps, REAL_SKILLS, Record, RecordLeaderboardEntry, RecordLeaderboardFilter, SKILLS, SKILL_EXP_AT_99, Skill, SkillDelta, SkillMetaConfig, SkillValue, Snapshot, SnapshotDataSource, SnapshotFragment, Team, TempleGroupData, TimeRangeFilter, Top5ProgressResult, WOMClient, findCountry, findCountryByCode, findCountryByName, findGroupRole, findMetric, findPeriod, findPlayerBuild, findPlayerType, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMetricMeasure, getMetricName, getMetricRankKey, getMetricValueKey, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isCompetitionStatus, isCompetitionType, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerType, isSkill, padNumber, parseMetricAbbreviation, parsePeriodExpression, round };
2146
+ export { ACTIVITIES, Achievement, AchievementDefinition, AchievementProgress, AchievementTemplate, Activity, ActivityDelta, ActivityValue, AlgorithmCache, AssertPlayerTypeResponse, BOSSES, Bonus, BonusType, Boss, BossDelta, BossMetaConfig, BossValue, CAPPED_MAX_TOTAL_XP, CMLGroupData, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, ChangeMemberRolePayload, CompetitionDetails, CompetitionListItem, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, CompetitionWithParticipations, CompetitionsSearchFilter, ComputedMetric, ComputedMetricDelta, ComputedMetricValue, Country, CountryDetails, CountryProps, CreateCompetitionPayload, CreateCompetitionResponse, CreateGroupPayload, CreateGroupResponse, DeltaLeaderboardEntry, DeltaLeaderboardFilter, EditCompetitionPayload, EditGroupPayload, EfficiencyAlgorithm, EfficiencyAlgorithmType, EfficiencyAlgorithmTypeUnion, EfficiencyLeaderboardsFilter, EfficiencyMap, ExperienceMap, ExtendedAchievement, F2P_BOSSES, FormattedSnapshot, GROUP_ROLES, GenericCountMessageResponse, GenericMessageResponse, GetGroupGainsFilter, GetPlayerGainsResponse, GroupDetails, GroupHiscoresActivityItem, GroupHiscoresBossItem, GroupHiscoresComputedMetricItem, GroupHiscoresEntry, GroupHiscoresSkillItem, GroupListItem, GroupMemberFragment, GroupRecordsFilter, GroupRole, GroupRoleProps, GroupStatistics, KillcountMap, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MapOf, MeasuredDeltaProgress, MemberInput, MembershipWithGroup, MembershipWithPlayer, Metric, MetricMeasure, MetricProps, MetricType, MetricValueKey, MigrationDataSource, NameChangeDetails, NameChangeStatus, NameChangesSearchFilter, PERIODS, PLAYER_BUILDS, PLAYER_TYPES, PRIVELEGED_GROUP_ROLES, ParticipationWithCompetition, ParticipationWithCompetitionAndStandings, ParticipationWithPlayer, ParticipationWithPlayerAndProgress, Period, PeriodProps, Player, PlayerBuild, PlayerBuildProps, PlayerCompetitionStandingsFilter, PlayerCompetitionsFilter, PlayerDeltasArray, PlayerDeltasMap, PlayerDetails, PlayerRecordsFilter, PlayerResolvable, PlayerType, PlayerTypeProps, REAL_SKILLS, Record, RecordLeaderboardEntry, RecordLeaderboardFilter, SKILLS, SKILL_EXP_AT_99, Skill, SkillDelta, SkillMetaConfig, SkillValue, Snapshot, SnapshotDataSource, SnapshotFragment, Team, TempleGroupData, TimeRangeFilter, Top5ProgressResult, WOMClient, findCountry, findCountryByCode, findCountryByName, findGroupRole, findMetric, findPeriod, findPlayerBuild, findPlayerType, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMetricMeasure, getMetricName, getMetricRankKey, getMetricValueKey, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isCompetitionStatus, isCompetitionType, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerType, isSkill, padNumber, parseMetricAbbreviation, parsePeriodExpression, round };
package/dist/index.js CHANGED
@@ -363,15 +363,15 @@ class PlayersClient extends BaseAPIClient {
363
363
  * Fetches all of the player's competition participations.
364
364
  * @returns A list of participations, with the respective competition included.
365
365
  */
366
- getPlayerCompetitions(player, pagination) {
367
- return this.getRequest(`${getPlayerURL(player)}/competitions`, pagination);
366
+ getPlayerCompetitions(player, filter, pagination) {
367
+ return this.getRequest(`${getPlayerURL(player)}/competitions`, Object.assign(Object.assign({}, filter), pagination));
368
368
  }
369
369
  /**
370
370
  * Fetches all of the player's competition participations' standings.
371
371
  * @returns A list of participations, with the respective competition, rank and progress included.
372
372
  */
373
- getPlayerCompetitionStandings(player) {
374
- return this.getRequest(`${getPlayerURL(player)}/competitions/standings`);
373
+ getPlayerCompetitionStandings(player, filter) {
374
+ return this.getRequest(`${getPlayerURL(player)}/competitions/standings`, filter);
375
375
  }
376
376
  /**
377
377
  * Fetches all of the player's group memberships.
@@ -405,8 +405,8 @@ class PlayersClient extends BaseAPIClient {
405
405
  * Fetches all of the player's past snapshots.
406
406
  * @returns A list of snapshots.
407
407
  */
408
- getPlayerSnapshots(player, options) {
409
- return this.getRequest(`${getPlayerURL(player)}/snapshots`, options);
408
+ getPlayerSnapshots(player, options, pagination) {
409
+ return this.getRequest(`${getPlayerURL(player)}/snapshots`, Object.assign(Object.assign({}, options), pagination));
410
410
  }
411
411
  /**
412
412
  * Fetches all of the player's approved name changes.
@@ -1925,8 +1925,18 @@ function isComputedMetric(metric) {
1925
1925
  function getMetricRankKey(metric) {
1926
1926
  return `${metric}Rank`;
1927
1927
  }
1928
+ // Maybe someday I'll be good enough with TS to restrict the return type to the input metric type
1928
1929
  function getMetricValueKey(metric) {
1929
- return `${metric}${lodash.capitalize(MetricProps[metric].measure)}`;
1930
+ if (isSkill(metric)) {
1931
+ return `${metric}Experience`;
1932
+ }
1933
+ if (isBoss(metric)) {
1934
+ return `${metric}Kills`;
1935
+ }
1936
+ if (isActivity(metric)) {
1937
+ return `${metric}Score`;
1938
+ }
1939
+ return `${metric}Value`;
1930
1940
  }
1931
1941
  function getMetricMeasure(metric) {
1932
1942
  return MetricProps[metric].measure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise-old-man/utils",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
+ "lint": "eslint . --ext .ts",
11
12
  "prepublish": "npm run build",
12
13
  "prebuild": "cd ../server && npm run prisma:generate",
13
14
  "build": "rm -rf ./dist && npx rollup -c && node prisma-transform.js && tsc dist/index.d.ts"
@@ -17,9 +18,12 @@
17
18
  "license": "ISC",
18
19
  "devDependencies": {
19
20
  "@rollup/plugin-typescript": "^8.3.4",
20
- "@typescript-eslint/eslint-plugin": "^5.34.0",
21
- "@typescript-eslint/parser": "^5.34.0",
22
- "eslint": "^8.22.0",
21
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
22
+ "@typescript-eslint/parser": "^5.40.1",
23
+ "eslint": "^8.26.0",
24
+ "eslint-config-prettier": "^8.5.0",
25
+ "eslint-plugin-prettier": "^4.2.1",
26
+ "prettier": "^2.7.1",
23
27
  "rollup": "^2.78.0",
24
28
  "rollup-plugin-dts": "^4.2.2",
25
29
  "tslib": "^2.4.0",