@wise-old-man/utils 2.0.5 → 2.0.6

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
@@ -1473,7 +1473,6 @@ declare type NameChangeDetails = {
1473
1473
  };
1474
1474
  };
1475
1475
 
1476
- declare type PlayerResolvable = Partial<Pick<Player, 'id' | 'username'>>;
1477
1476
  interface PlayerDetails extends Player {
1478
1477
  combatLevel: number;
1479
1478
  latestSnapshot: FormattedSnapshot;
@@ -1956,72 +1955,67 @@ declare class PlayersClient extends BaseAPIClient {
1956
1955
  * Updates/tracks a player.
1957
1956
  * @returns The player's new details, including the latest snapshot.
1958
1957
  */
1959
- updatePlayer(player: PlayerResolvable): Promise<PlayerDetails>;
1958
+ updatePlayer(username: string): Promise<PlayerDetails>;
1960
1959
  /**
1961
1960
  * Asserts (and attempts to fix, if necessary) a player's game-mode type.
1962
1961
  * @returns The updated player, and an indication of whether the type was changed.
1963
1962
  */
1964
- assertPlayerType(player: PlayerResolvable): Promise<AssertPlayerTypeResponse>;
1965
- /**
1966
- * Attempts to import a player's snapshot history from CrystalMathLabs.
1967
- * @returns The number of snapshots that were imported.
1968
- */
1969
- importPlayer(player: PlayerResolvable): Promise<GenericCountMessageResponse>;
1963
+ assertPlayerType(username: string): Promise<AssertPlayerTypeResponse>;
1970
1964
  /**
1971
1965
  * Fetches a player's details.
1972
1966
  * @returns The player's details, including the latest snapshot.
1973
1967
  */
1974
- getPlayerDetails(player: PlayerResolvable): Promise<PlayerDetails>;
1968
+ getPlayerDetails(username: string): Promise<PlayerDetails>;
1975
1969
  /**
1976
1970
  * Fetches a player's current achievements.
1977
1971
  * @returns A list of achievements.
1978
1972
  */
1979
- getPlayerAchievements(player: PlayerResolvable): Promise<ExtendedAchievement[]>;
1973
+ getPlayerAchievements(username: string): Promise<ExtendedAchievement[]>;
1980
1974
  /**
1981
1975
  * Fetches a player's current achievement progress.
1982
1976
  * @returns A list of achievements (completed or otherwise), with their respective relative/absolute progress percentage.
1983
1977
  */
1984
- getPlayerAchievementProgress(player: PlayerResolvable): Promise<AchievementProgress[]>;
1978
+ getPlayerAchievementProgress(username: string): Promise<AchievementProgress[]>;
1985
1979
  /**
1986
1980
  * Fetches all of the player's competition participations.
1987
1981
  * @returns A list of participations, with the respective competition included.
1988
1982
  */
1989
- getPlayerCompetitions(player: PlayerResolvable, filter?: PlayerCompetitionsFilter, pagination?: PaginationOptions): Promise<ParticipationWithCompetition[]>;
1983
+ getPlayerCompetitions(username: string, filter?: PlayerCompetitionsFilter, pagination?: PaginationOptions): Promise<ParticipationWithCompetition[]>;
1990
1984
  /**
1991
1985
  * Fetches all of the player's competition participations' standings.
1992
1986
  * @returns A list of participations, with the respective competition, rank and progress included.
1993
1987
  */
1994
- getPlayerCompetitionStandings(player: PlayerResolvable, filter: PlayerCompetitionsFilter): Promise<ParticipationWithCompetitionAndStandings[]>;
1988
+ getPlayerCompetitionStandings(username: string, filter: PlayerCompetitionsFilter): Promise<ParticipationWithCompetitionAndStandings[]>;
1995
1989
  /**
1996
1990
  * Fetches all of the player's group memberships.
1997
1991
  * @returns A list of memberships, with the respective group included.
1998
1992
  */
1999
- getPlayerGroups(player: PlayerResolvable, pagination?: PaginationOptions): Promise<MembershipWithGroup[]>;
1993
+ getPlayerGroups(username: string, pagination?: PaginationOptions): Promise<MembershipWithGroup[]>;
2000
1994
  /**
2001
1995
  * Fetches a player's gains, for a specific period or time range, as a [metric: data] map.
2002
1996
  * @returns A map of each metric's gained data.
2003
1997
  */
2004
- getPlayerGains(player: PlayerResolvable, options: TimeRangeFilter): Promise<GetPlayerGainsResponse<PlayerDeltasMap>>;
1998
+ getPlayerGains(username: string, options: TimeRangeFilter): Promise<GetPlayerGainsResponse<PlayerDeltasMap>>;
2005
1999
  /**
2006
2000
  * Fetches a player's gains, for a specific period or time range, as an array.
2007
2001
  * @returns An array of each metric's gained data.
2008
2002
  */
2009
- getPlayerGainsAsArray(player: PlayerResolvable, options: TimeRangeFilter): Promise<GetPlayerGainsResponse<PlayerDeltasArray>>;
2003
+ getPlayerGainsAsArray(username: string, options: TimeRangeFilter): Promise<GetPlayerGainsResponse<PlayerDeltasArray>>;
2010
2004
  /**
2011
2005
  * Fetches all of the player's records.
2012
2006
  * @returns A list of records.
2013
2007
  */
2014
- getPlayerRecords(player: PlayerResolvable, options?: PlayerRecordsFilter): Promise<Record[]>;
2008
+ getPlayerRecords(username: string, options?: PlayerRecordsFilter): Promise<Record[]>;
2015
2009
  /**
2016
2010
  * Fetches all of the player's past snapshots.
2017
2011
  * @returns A list of snapshots.
2018
2012
  */
2019
- getPlayerSnapshots(player: PlayerResolvable, options?: TimeRangeFilter, pagination?: PaginationOptions): Promise<FormattedSnapshot[]>;
2013
+ getPlayerSnapshots(username: string, options?: TimeRangeFilter, pagination?: PaginationOptions): Promise<FormattedSnapshot[]>;
2020
2014
  /**
2021
2015
  * Fetches all of the player's approved name changes.
2022
2016
  * @returns A list of name changes.
2023
2017
  */
2024
- getPlayerNames(player: PlayerResolvable): Promise<NameChange[]>;
2018
+ getPlayerNames(username: string): Promise<NameChange[]>;
2025
2019
  }
2026
2020
 
2027
2021
  declare class RecordsClient extends BaseAPIClient {
@@ -2143,4 +2137,4 @@ declare class WOMClient {
2143
2137
  constructor(options?: WOMClientOptions);
2144
2138
  }
2145
2139
 
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 };
2140
+ 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, 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
@@ -321,109 +321,93 @@ class PlayersClient extends BaseAPIClient {
321
321
  * Updates/tracks a player.
322
322
  * @returns The player's new details, including the latest snapshot.
323
323
  */
324
- updatePlayer(player) {
325
- return this.postRequest(getPlayerURL(player));
324
+ updatePlayer(username) {
325
+ return this.postRequest(`/players/${username}`);
326
326
  }
327
327
  /**
328
328
  * Asserts (and attempts to fix, if necessary) a player's game-mode type.
329
329
  * @returns The updated player, and an indication of whether the type was changed.
330
330
  */
331
- assertPlayerType(player) {
332
- return this.postRequest(`${getPlayerURL(player)}/assert-type`);
333
- }
334
- /**
335
- * Attempts to import a player's snapshot history from CrystalMathLabs.
336
- * @returns The number of snapshots that were imported.
337
- */
338
- importPlayer(player) {
339
- return this.postRequest(`${getPlayerURL(player)}/import-history`);
331
+ assertPlayerType(username) {
332
+ return this.postRequest(`/players/${username}/assert-type`);
340
333
  }
341
334
  /**
342
335
  * Fetches a player's details.
343
336
  * @returns The player's details, including the latest snapshot.
344
337
  */
345
- getPlayerDetails(player) {
346
- return this.getRequest(getPlayerURL(player));
338
+ getPlayerDetails(username) {
339
+ return this.getRequest(`/players/${username}`);
347
340
  }
348
341
  /**
349
342
  * Fetches a player's current achievements.
350
343
  * @returns A list of achievements.
351
344
  */
352
- getPlayerAchievements(player) {
353
- return this.getRequest(`${getPlayerURL(player)}/achievements`);
345
+ getPlayerAchievements(username) {
346
+ return this.getRequest(`/players/${username}/achievements`);
354
347
  }
355
348
  /**
356
349
  * Fetches a player's current achievement progress.
357
350
  * @returns A list of achievements (completed or otherwise), with their respective relative/absolute progress percentage.
358
351
  */
359
- getPlayerAchievementProgress(player) {
360
- return this.getRequest(`${getPlayerURL(player)}/achievements/progress`);
352
+ getPlayerAchievementProgress(username) {
353
+ return this.getRequest(`/players/${username}/achievements/progress`);
361
354
  }
362
355
  /**
363
356
  * Fetches all of the player's competition participations.
364
357
  * @returns A list of participations, with the respective competition included.
365
358
  */
366
- getPlayerCompetitions(player, filter, pagination) {
367
- return this.getRequest(`${getPlayerURL(player)}/competitions`, Object.assign(Object.assign({}, filter), pagination));
359
+ getPlayerCompetitions(username, filter, pagination) {
360
+ return this.getRequest(`/players/${username}/competitions`, Object.assign(Object.assign({}, filter), pagination));
368
361
  }
369
362
  /**
370
363
  * Fetches all of the player's competition participations' standings.
371
364
  * @returns A list of participations, with the respective competition, rank and progress included.
372
365
  */
373
- getPlayerCompetitionStandings(player, filter) {
374
- return this.getRequest(`${getPlayerURL(player)}/competitions/standings`, filter);
366
+ getPlayerCompetitionStandings(username, filter) {
367
+ return this.getRequest(`/players/${username}/competitions/standings`, filter);
375
368
  }
376
369
  /**
377
370
  * Fetches all of the player's group memberships.
378
371
  * @returns A list of memberships, with the respective group included.
379
372
  */
380
- getPlayerGroups(player, pagination) {
381
- return this.getRequest(`${getPlayerURL(player)}/groups`, pagination);
373
+ getPlayerGroups(username, pagination) {
374
+ return this.getRequest(`/players/${username}/groups`, pagination);
382
375
  }
383
376
  /**
384
377
  * Fetches a player's gains, for a specific period or time range, as a [metric: data] map.
385
378
  * @returns A map of each metric's gained data.
386
379
  */
387
- getPlayerGains(player, options) {
388
- return this.getRequest(`${getPlayerURL(player)}/gained`, options);
380
+ getPlayerGains(username, options) {
381
+ return this.getRequest(`/players/${username}/gained`, options);
389
382
  }
390
383
  /**
391
384
  * Fetches a player's gains, for a specific period or time range, as an array.
392
385
  * @returns An array of each metric's gained data.
393
386
  */
394
- getPlayerGainsAsArray(player, options) {
395
- return this.getRequest(`${getPlayerURL(player)}/gained`, Object.assign(Object.assign({}, options), { formatting: 'array' }));
387
+ getPlayerGainsAsArray(username, options) {
388
+ return this.getRequest(`/players/${username}/gained`, Object.assign(Object.assign({}, options), { formatting: 'array' }));
396
389
  }
397
390
  /**
398
391
  * Fetches all of the player's records.
399
392
  * @returns A list of records.
400
393
  */
401
- getPlayerRecords(player, options) {
402
- return this.getRequest(`${getPlayerURL(player)}/records`, options);
394
+ getPlayerRecords(username, options) {
395
+ return this.getRequest(`/players/${username}/records`, options);
403
396
  }
404
397
  /**
405
398
  * Fetches all of the player's past snapshots.
406
399
  * @returns A list of snapshots.
407
400
  */
408
- getPlayerSnapshots(player, options, pagination) {
409
- return this.getRequest(`${getPlayerURL(player)}/snapshots`, Object.assign(Object.assign({}, options), pagination));
401
+ getPlayerSnapshots(username, options, pagination) {
402
+ return this.getRequest(`/players/${username}/snapshots`, Object.assign(Object.assign({}, options), pagination));
410
403
  }
411
404
  /**
412
405
  * Fetches all of the player's approved name changes.
413
406
  * @returns A list of name changes.
414
407
  */
415
- getPlayerNames(player) {
416
- return this.getRequest(`${getPlayerURL(player)}/names`);
417
- }
418
- }
419
- function getPlayerURL(player) {
420
- if (typeof player === 'string') {
421
- return `/players/${player}`;
422
- }
423
- if (player.id) {
424
- return `/players/id/${player.id}`;
408
+ getPlayerNames(username) {
409
+ return this.getRequest(`/players/${username}/names`);
425
410
  }
426
- return `/players/${player.username}`;
427
411
  }
428
412
 
429
413
  class RecordsClient extends BaseAPIClient {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise-old-man/utils",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",