@retroachievements/api 2.8.0 → 2.9.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
@@ -98,6 +98,7 @@ Click the function names to open their complete docs on the docs site.
98
98
  - [`getGame()`](https://api-docs.retroachievements.org/v1/get-game.html) - Get basic metadata about a game.
99
99
  - [`getGameExtended()`](https://api-docs.retroachievements.org/v1/get-game-extended.html) - Get extended metadata about a game.
100
100
  - [`getGameHashes()`](https://api-docs.retroachievements.org/v1/get-game-hashes.html) - Get a list of hashes linked to a game.
101
+ - [`getGameProgression()`](https://api-docs.retroachievements.org/v1/get-game-progression.html) - Get information about the average time to unlock achievements in a game.
101
102
  - [`getAchievementCount()`](https://api-docs.retroachievements.org/v1/get-achievement-count.html) - Get the list of achievement IDs for a game.
102
103
  - [`getAchievementDistribution()`](https://api-docs.retroachievements.org/v1/get-achievement-distribution.html) - Get how many players have unlocked how many achievements for a game.
103
104
  - [`getGameRankAndScore()`](https://api-docs.retroachievements.org/v1/get-game-rank-and-score.html) - Get a list of either the latest masters or highest hardcore points earners for a game.
package/dist/api.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e,r,t="https://retroachievements.org/API",o=function(e,r,t,o){void 0===o&&(o={});for(var n=(e+"/"+r).replaceAll(/([^:]\/)\/+/g,"$1"),s={z:t.username,y:t.webApiKey},i=0,a=Object.entries(o);i<a.length;i++){var u=a[i],c=u[0],l=u[1];n.includes(":"+c)?n=n.replace(":"+c,String(l)):void 0!==l&&(s[c]=String(l))}return n+"?"+new URLSearchParams(s).toString()},n=null!=(e=null==(r=process.env)?void 0:r.PACKAGE_VERSION)?e:"Unknown",s=function(e){try{var r=e.url,t=new Headers({"User-Agent":"RetroAchievements-api-js/"+n});return Promise.resolve(fetch(r,{headers:t})).then(function(e){if(!e.ok)throw new Error("HTTP Error: Status "+e.status+" "+e.statusText);return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},i.apply(this,arguments)}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function u(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,l,m,h,d,v=function e(r,t){void 0===t&&(t={});var o=t.shouldCastToNumbers,n=t.shouldMapToBooleans,s=r;if(Array.isArray(r)){for(var a,c=[],l=u(r);!(a=l()).done;)c.push(e(a.value,t));s=c}else if(!Array.isArray(r)&&r instanceof Object){for(var m={},h=0,d=Object.entries(r);h<d.length;h++){var v,P=d[h],f=P[0],A=P[1],y=A;null!=o&&o.includes(f)&&(y=null===A?null:Number(A)),null!=n&&n.includes(f)&&(y=null===A?null:"1"===String(A)),m=i({},m,((v={})[p(f)]=e(y,t),v))}s=m}return s},p=function(e){if(e.toUpperCase()===e)return e.toLowerCase();var r=e.charAt(0).toLowerCase()+e.slice(1);return(r=(r=(r=(r=r.replaceAll("ULID","Ulid")).replaceAll("ID","Id")).replaceAll("URL","Url")).replaceAll("rA","ra")).replaceAll("visibleUserawards","visibleUserAwards")},P={game:1,achievement:2,user:3},f={completed:"1",dropped:"2",expired:"3"};exports.ClaimSetType=void 0,(c=exports.ClaimSetType||(exports.ClaimSetType={}))[c.NewSet=0]="NewSet",c[c.Revision=1]="Revision",exports.ClaimStatus=void 0,(l=exports.ClaimStatus||(exports.ClaimStatus={}))[l.Active=0]="Active",l[l.Complete=1]="Complete",l[l.Dropped=2]="Dropped",exports.ClaimType=void 0,(m=exports.ClaimType||(exports.ClaimType={}))[m.Primary=0]="Primary",m[m.Collaboration=1]="Collaboration",exports.AchievementDistributionFlags=void 0,(h=exports.AchievementDistributionFlags||(exports.AchievementDistributionFlags={}))[h.CoreAchievements=3]="CoreAchievements",h[h.UnofficialAchievements=5]="UnofficialAchievements",function(e){e.Primary="0",e.Collaboration="1"}(d||(d={}));var A=function(e,r){var t=i({},e);return void 0!==r.count&&(t.c=r.count),void 0!==r.offset&&(t.o=r.offset),t};exports.buildAuthorization=function(e){if(!e.username||!e.webApiKey)throw new Error('\n buildAuthorization() requires an object containing a\n username and webApiKey. eg:\n\n const authorization = buildAuthorization({\n username: "myUserName",\n webApiKey: "myWebApiKey"\n })\n ');return e},exports.getAchievementCount=function(e,r){try{var n=o(t,"/API_GetAchievementCount.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getAchievementDistribution=function(e,r){try{var n=r.flags,i=r.hardcore,a={i:r.gameId};void 0!==n&&(a.f=n),void 0!==i&&(a.h=!0===i?1:0);var u=o(t,"/API_GetAchievementDistribution.php",e,a);return Promise.resolve(s({url:u}))}catch(e){return Promise.reject(e)}},exports.getAchievementOfTheWeek=function(e){try{var r=o(t,"/API_GetAchievementOfTheWeek.php",e);return Promise.resolve(s({url:r})).then(function(e){return v(e,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","RASoftcorePoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementUnlocks=function(e,r){try{var n=r.offset,i=r.count,a={a:r.achievementId};n&&(a.o=n),i&&(a.c=i);var u=o(t,"/API_GetAchievementUnlocks.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints","RASoftcorePoints"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedBetween=function(e,r){try{var n=r.toDate,i=o(t,"/API_GetAchievementsEarnedBetween.php",e,{u:r.username,f:(r.fromDate.getTime()/1e3).toFixed(0),t:(n.getTime()/1e3).toFixed(0)});return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedOnDay=function(e,r){try{var n=r.onDate,i=o(t,"/API_GetAchievementsEarnedOnDay.php",e,{u:r.username,d:n.getFullYear()+"-"+(n.getMonth()+1)+"-"+n.getDate()});return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getActiveClaims=function(e){try{var r=o(t,"/API_GetActiveClaims.php",e);return Promise.resolve(s({url:r})).then(function(e){return v(e,{shouldMapToBooleans:["UserIsJrDev"]})})}catch(e){return Promise.reject(e)}},exports.getClaims=function(e,r){try{var n=o(t,"/API_GetClaims.php",e,{k:f[r.claimKind]});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldMapToBooleans:["UserIsJrDev"]})})}catch(e){return Promise.reject(e)}},exports.getComments=function(e,r){try{var n=r.identifier,i=r.kind,a=r.offset,u=r.count,c={i:n};if(i)c.t=P[i];else if("number"==typeof n)throw new TypeError("'kind' must be specified when looking up an achievement or game.");a&&(c.o=a),u&&(c.c=u);var l=o(t,"/API_GetComments.php",e,c);return Promise.resolve(s({url:l})).then(function(e){return v(e,{shouldCastToNumbers:["Count","Total"]})})}catch(e){return Promise.reject(e)}},exports.getConsoleIds=function(e,r){try{var n;null!=r&&r.shouldOnlyRetrieveActiveSystems&&(n=i({},n,{a:1})),null!=r&&r.shouldOnlyRetrieveGameSystems&&(n=i({},n,{g:1}));var a=o(t,"/API_GetConsoleIDs.php",e,n);return Promise.resolve(s({url:a})).then(function(e){return v(e,{shouldCastToNumbers:["ID"]})})}catch(e){return Promise.reject(e)}},exports.getGame=function(e,r){try{var n=o(t,"/API_GetGame.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags"]})})}catch(e){return Promise.reject(e)}},exports.getGameExtended=function(e,r){try{var n={i:r.gameId};r.isRequestingUnofficialAchievements&&(n.f=5);var i=o(t,"/API_GetGameExtended.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getGameHashes=function(e,r){try{var n=o(t,"/API_GetGameHashes.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getGameInfoAndUserProgress=function(e,r){try{var n={g:r.gameId,u:r.username};r.shouldIncludeHighestAwardMetadata&&(n.a=1);var i=o(t,"/API_GetGameInfoAndUserProgress.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getGameList=function(e,r){try{var n=r.shouldOnlyRetrieveGamesWithAchievements,a=r.shouldRetrieveGameHashes,u={i:r.consoleId};void 0!==n&&(u=i({},u,{f:n?1:0})),a&&(u=i({},u,{h:a?1:0}));var c=o(t,"/API_GetGameList.php",e,u);return Promise.resolve(s({url:c})).then(function(e){return v(e,{shouldCastToNumbers:["ID","ConsoleID"]})})}catch(e){return Promise.reject(e)}},exports.getGameRankAndScore=function(e,r){try{var n=o(t,"/API_GetGameRankAndScore.php",e,{g:r.gameId,t:"latest-masters"===r.type?1:0});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalScore"]})})}catch(e){return Promise.reject(e)}},exports.getGameRating=function(e,r){try{var n=o(t,"/API_GetGameRating.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getLeaderboardEntries=function(e,r){try{var n={};n.i=r.leaderboardId,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetLeaderboardEntries.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getRecentGameAwards=function(e,r){try{var n={};null!=r&&r.startDate&&(n.d=r.startDate),null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count),null!=r&&r.desiredAwardKinds&&(n.k=r.desiredAwardKinds.join(","));var i=o(t,"/API_GetRecentGameAwards.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getTicketData=function(e,r){void 0===r&&(r={});try{var n=function(e){var r=e.ticketId,t=e.isGettingMostTicketedGames,o=e.username,n=e.gameId,s=e.isGettingTicketsForUnofficialAchievements,i=e.shouldReturnTicketsList,a=e.achievementId,u={};return void 0!==r?u.i=r:t?(u.f="1",u=A(u,e)):o?u.u=o:n?(u.g=n,s&&(u.f="5"),i&&(u.d="1")):a?u.a=a:u=A(u,e),u}(r),i=o(t,"/API_GetTicketData.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","AchievementID","Points","GameID","ReportType","ReportState","OpenTickets"],shouldMapToBooleans:["Hardcore"]})})}catch(e){return Promise.reject(e)}},exports.getTopTenUsers=function(e){try{var r=o(t,"/API_GetTopTenUsers.php",e);return Promise.resolve(s({url:r})).then(function(e){for(var r,t=[],o=u(e);!(r=o()).done;){var n=r.value;t.push({username:n[1],totalPoints:Number(n[2]),totalRatioPoints:Number(n[3])})}return t})}catch(e){return Promise.reject(e)}},exports.getUserAwards=function(e,r){try{var n=o(t,"/API_GetUserAwards.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserClaims=function(e,r){try{var n=o(t,"/API_GetUserClaims.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})})}catch(e){return Promise.reject(e)}},exports.getUserCompletedGames=function(e,r){try{var n=o(t,"/API_GetUserCompletedGames.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getUserCompletionProgress=function(e,r){try{var n=r.offset,i=r.count,a={u:r.username};n&&(a.o=n),i&&(a.c=i);var u=o(t,"/API_GetUserCompletionProgress.php",e,a);return Promise.resolve(s({url:u})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserGameLeaderboards=function(e,r){try{var n={};n.i=r.gameId,n.u=r.username,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetUserGameLeaderboards.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserGameRankAndScore=function(e,r){try{var n=o(t,"/API_GetUserGameRankAndScore.php",e,{g:r.gameId,u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalScore","UserRank"]})})}catch(e){return Promise.reject(e)}},exports.getUserPoints=function(e,r){try{var n=o(t,"/API_GetUserPoints.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserProfile=function(e,r){try{var n=o(t,"/API_GetUserProfile.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions"],shouldMapToBooleans:["Untracked","UserWallActive"]})})}catch(e){return Promise.reject(e)}},exports.getUserProgress=function(e,r){try{var n=o(t,"/API_GetUserProgress.php",e,{u:r.username,i:r.gameIds.join(",")});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getUserRecentAchievements=function(e,r){try{var n=r.recentMinutes,i={u:r.username};void 0!==n&&(i.m=n);var a=o(t,"/API_GetUserRecentAchievements.php",e,i);return Promise.resolve(s({url:a})).then(function(e){return v(e,{shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getUserRecentlyPlayedGames=function(e,r){try{var n=r.offset,i=r.count,a={u:r.username};void 0!==n&&(a.o=n),void 0!==i&&(a.c=i);var u=o(t,"/API_GetUserRecentlyPlayedGames.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})})}catch(e){return Promise.reject(e)}},exports.getUserSummary=function(e,r){try{var n=r.recentGamesCount,i=r.recentAchievementsCount,a={u:r.username};void 0!==n&&(a.g=n),void 0!==i&&(a.a=i);var u=o(t,"/API_GetUserSummary.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","ID","LastGameID","ForumTopicID","activitytype","ContribCount","ContribYield","TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","Points","SoftcorePoints"],shouldMapToBooleans:["Untracked","UserWallActive","IsAwarded","HardcoreAchieved"]})})}catch(e){return Promise.reject(e)}},exports.getUserWantToPlayList=function(e,r){try{var n={};n.u=r.username,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetUserWantToPlayList.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getUsersIFollow=function(e,r){try{var n={};null!=(null==r?void 0:r.offset)&&(n.o=r.offset),null!=(null==r?void 0:r.count)&&(n.c=r.count);var i=o(t,"/API_GetUsersIFollow.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["Points","PointsSoftcore"],shouldMapToBooleans:["IsFollowingMe"]})})}catch(e){return Promise.reject(e)}},exports.unsafe_call=s;
1
+ var e,r,t="https://retroachievements.org/API",o=function(e,r,t,o){void 0===o&&(o={});for(var n=(e+"/"+r).replaceAll(/([^:]\/)\/+/g,"$1"),s={z:t.username,y:t.webApiKey},i=0,a=Object.entries(o);i<a.length;i++){var u=a[i],c=u[0],l=u[1];n.includes(":"+c)?n=n.replace(":"+c,String(l)):void 0!==l&&(s[c]=String(l))}return n+"?"+new URLSearchParams(s).toString()},n=null!=(e=null==(r=process.env)?void 0:r.PACKAGE_VERSION)?e:"Unknown",s=function(e){try{var r=e.url,t=new Headers({"User-Agent":"RetroAchievements-api-js/"+n});return Promise.resolve(fetch(r,{headers:t})).then(function(e){if(!e.ok)throw new Error("HTTP Error: Status "+e.status+" "+e.statusText);return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},i.apply(this,arguments)}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function u(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,l,m,h,d,v=function e(r,t){void 0===t&&(t={});var o=t.shouldCastToNumbers,n=t.shouldMapToBooleans,s=r;if(Array.isArray(r)){for(var a,c=[],l=u(r);!(a=l()).done;)c.push(e(a.value,t));s=c}else if(!Array.isArray(r)&&r instanceof Object){for(var m={},h=0,d=Object.entries(r);h<d.length;h++){var v,P=d[h],f=P[0],A=P[1],y=A;if(null!=o&&o.includes(f)&&(y=null===A?null:Number(A)),null!=n&&n.includes(f))if(null===A)y=null;else{var g=String(A);y="1"===g||"true"===g}m=i({},m,((v={})[p(f)]=e(y,t),v))}s=m}return s},p=function(e){if(e.toUpperCase()===e)return e.toLowerCase();var r=e.charAt(0).toLowerCase()+e.slice(1);return(r=(r=(r=(r=r.replaceAll("ULID","Ulid")).replaceAll("ID","Id")).replaceAll("URL","Url")).replaceAll("rA","ra")).replaceAll("visibleUserawards","visibleUserAwards")},P={game:1,achievement:2,user:3},f={completed:"1",dropped:"2",expired:"3"};exports.ClaimSetType=void 0,(c=exports.ClaimSetType||(exports.ClaimSetType={}))[c.NewSet=0]="NewSet",c[c.Revision=1]="Revision",exports.ClaimStatus=void 0,(l=exports.ClaimStatus||(exports.ClaimStatus={}))[l.Active=0]="Active",l[l.Complete=1]="Complete",l[l.Dropped=2]="Dropped",exports.ClaimType=void 0,(m=exports.ClaimType||(exports.ClaimType={}))[m.Primary=0]="Primary",m[m.Collaboration=1]="Collaboration",exports.AchievementDistributionFlags=void 0,(h=exports.AchievementDistributionFlags||(exports.AchievementDistributionFlags={}))[h.CoreAchievements=3]="CoreAchievements",h[h.UnofficialAchievements=5]="UnofficialAchievements",function(e){e.Primary="0",e.Collaboration="1"}(d||(d={}));var A=function(e,r){var t=i({},e);return void 0!==r.count&&(t.c=r.count),void 0!==r.offset&&(t.o=r.offset),t};exports.buildAuthorization=function(e){if(!e.username||!e.webApiKey)throw new Error('\n buildAuthorization() requires an object containing a\n username and webApiKey. eg:\n\n const authorization = buildAuthorization({\n username: "myUserName",\n webApiKey: "myWebApiKey"\n })\n ');return e},exports.getAchievementCount=function(e,r){try{var n=o(t,"/API_GetAchievementCount.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getAchievementDistribution=function(e,r){try{var n=r.flags,i=r.hardcore,a={i:r.gameId};void 0!==n&&(a.f=n),void 0!==i&&(a.h=!0===i?1:0);var u=o(t,"/API_GetAchievementDistribution.php",e,a);return Promise.resolve(s({url:u}))}catch(e){return Promise.reject(e)}},exports.getAchievementOfTheWeek=function(e){try{var r=o(t,"/API_GetAchievementOfTheWeek.php",e);return Promise.resolve(s({url:r})).then(function(e){return v(e,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","RASoftcorePoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementUnlocks=function(e,r){try{var n=r.offset,i=r.count,a={a:r.achievementId};n&&(a.o=n),i&&(a.c=i);var u=o(t,"/API_GetAchievementUnlocks.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints","RASoftcorePoints"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedBetween=function(e,r){try{var n=r.toDate,i=o(t,"/API_GetAchievementsEarnedBetween.php",e,{u:r.username,f:(r.fromDate.getTime()/1e3).toFixed(0),t:(n.getTime()/1e3).toFixed(0)});return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedOnDay=function(e,r){try{var n=r.onDate,i=o(t,"/API_GetAchievementsEarnedOnDay.php",e,{u:r.username,d:n.getFullYear()+"-"+(n.getMonth()+1)+"-"+n.getDate()});return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getActiveClaims=function(e){try{var r=o(t,"/API_GetActiveClaims.php",e);return Promise.resolve(s({url:r})).then(function(e){return v(e,{shouldMapToBooleans:["UserIsJrDev"]})})}catch(e){return Promise.reject(e)}},exports.getClaims=function(e,r){try{var n=o(t,"/API_GetClaims.php",e,{k:f[r.claimKind]});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldMapToBooleans:["UserIsJrDev"]})})}catch(e){return Promise.reject(e)}},exports.getComments=function(e,r){try{var n=r.identifier,i=r.kind,a=r.offset,u=r.count,c={i:n};if(i)c.t=P[i];else if("number"==typeof n)throw new TypeError("'kind' must be specified when looking up an achievement or game.");a&&(c.o=a),u&&(c.c=u);var l=o(t,"/API_GetComments.php",e,c);return Promise.resolve(s({url:l})).then(function(e){return v(e,{shouldCastToNumbers:["Count","Total"]})})}catch(e){return Promise.reject(e)}},exports.getConsoleIds=function(e,r){try{var n;null!=r&&r.shouldOnlyRetrieveActiveSystems&&(n=i({},n,{a:1})),null!=r&&r.shouldOnlyRetrieveGameSystems&&(n=i({},n,{g:1}));var a=o(t,"/API_GetConsoleIDs.php",e,n);return Promise.resolve(s({url:a})).then(function(e){return v(e,{shouldCastToNumbers:["ID"]})})}catch(e){return Promise.reject(e)}},exports.getGame=function(e,r){try{var n=o(t,"/API_GetGame.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags"]})})}catch(e){return Promise.reject(e)}},exports.getGameExtended=function(e,r){try{var n={i:r.gameId};r.isRequestingUnofficialAchievements&&(n.f=5);var i=o(t,"/API_GetGameExtended.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getGameHashes=function(e,r){try{var n=o(t,"/API_GetGameHashes.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getGameInfoAndUserProgress=function(e,r){try{var n={g:r.gameId,u:r.username};r.shouldIncludeHighestAwardMetadata&&(n.a=1);var i=o(t,"/API_GetGameInfoAndUserProgress.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getGameList=function(e,r){try{var n=r.shouldOnlyRetrieveGamesWithAchievements,a=r.shouldRetrieveGameHashes,u={i:r.consoleId};void 0!==n&&(u=i({},u,{f:n?1:0})),a&&(u=i({},u,{h:a?1:0}));var c=o(t,"/API_GetGameList.php",e,u);return Promise.resolve(s({url:c})).then(function(e){return v(e,{shouldCastToNumbers:["ID","ConsoleID"]})})}catch(e){return Promise.reject(e)}},exports.getGameProgression=function(e,r){try{var n=r.hardcore,i={i:r.gameId};void 0!==n&&(i.h=!0===n?1:0);var a=o(t,"/API_GetGameProgression.php",e,i);return Promise.resolve(s({url:a})).then(v)}catch(e){return Promise.reject(e)}},exports.getGameRankAndScore=function(e,r){try{var n=o(t,"/API_GetGameRankAndScore.php",e,{g:r.gameId,t:"latest-masters"===r.type?1:0});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalScore"]})})}catch(e){return Promise.reject(e)}},exports.getGameRating=function(e,r){try{var n=o(t,"/API_GetGameRating.php",e,{i:r.gameId});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getLeaderboardEntries=function(e,r){try{var n={};n.i=r.leaderboardId,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetLeaderboardEntries.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getRecentGameAwards=function(e,r){try{var n={};null!=r&&r.startDate&&(n.d=r.startDate),null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count),null!=r&&r.desiredAwardKinds&&(n.k=r.desiredAwardKinds.join(","));var i=o(t,"/API_GetRecentGameAwards.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getTicketData=function(e,r){void 0===r&&(r={});try{var n=function(e){var r=e.ticketId,t=e.isGettingMostTicketedGames,o=e.username,n=e.gameId,s=e.isGettingTicketsForUnofficialAchievements,i=e.shouldReturnTicketsList,a=e.achievementId,u={};return void 0!==r?u.i=r:t?(u.f="1",u=A(u,e)):o?u.u=o:n?(u.g=n,s&&(u.f="5"),i&&(u.d="1")):a?u.a=a:u=A(u,e),u}(r),i=o(t,"/API_GetTicketData.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["ID","AchievementID","Points","GameID","ReportType","ReportState","OpenTickets"],shouldMapToBooleans:["Hardcore"]})})}catch(e){return Promise.reject(e)}},exports.getTopTenUsers=function(e){try{var r=o(t,"/API_GetTopTenUsers.php",e);return Promise.resolve(s({url:r})).then(function(e){for(var r,t=[],o=u(e);!(r=o()).done;){var n=r.value;t.push({username:n[1],totalPoints:Number(n[2]),totalRatioPoints:Number(n[3])})}return t})}catch(e){return Promise.reject(e)}},exports.getUserAwards=function(e,r){try{var n=o(t,"/API_GetUserAwards.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserClaims=function(e,r){try{var n=o(t,"/API_GetUserClaims.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})})}catch(e){return Promise.reject(e)}},exports.getUserCompletedGames=function(e,r){try{var n=o(t,"/API_GetUserCompletedGames.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getUserCompletionProgress=function(e,r){try{var n=r.offset,i=r.count,a={u:r.username};n&&(a.o=n),i&&(a.c=i);var u=o(t,"/API_GetUserCompletionProgress.php",e,a);return Promise.resolve(s({url:u})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserGameLeaderboards=function(e,r){try{var n={};n.i=r.gameId,n.u=r.username,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetUserGameLeaderboards.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserGameRankAndScore=function(e,r){try{var n=o(t,"/API_GetUserGameRankAndScore.php",e,{g:r.gameId,u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalScore","UserRank"]})})}catch(e){return Promise.reject(e)}},exports.getUserPoints=function(e,r){try{var n=o(t,"/API_GetUserPoints.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(v)}catch(e){return Promise.reject(e)}},exports.getUserProfile=function(e,r){try{var n=o(t,"/API_GetUserProfile.php",e,{u:r.username});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions"],shouldMapToBooleans:["Untracked","UserWallActive"]})})}catch(e){return Promise.reject(e)}},exports.getUserProgress=function(e,r){try{var n=o(t,"/API_GetUserProgress.php",e,{u:r.username,i:r.gameIds.join(",")});return Promise.resolve(s({url:n})).then(function(e){return v(e,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getUserRecentAchievements=function(e,r){try{var n=r.recentMinutes,i={u:r.username};void 0!==n&&(i.m=n);var a=o(t,"/API_GetUserRecentAchievements.php",e,i);return Promise.resolve(s({url:a})).then(function(e){return v(e,{shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getUserRecentlyPlayedGames=function(e,r){try{var n=r.offset,i=r.count,a={u:r.username};void 0!==n&&(a.o=n),void 0!==i&&(a.c=i);var u=o(t,"/API_GetUserRecentlyPlayedGames.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})})}catch(e){return Promise.reject(e)}},exports.getUserSummary=function(e,r){try{var n=r.recentGamesCount,i=r.recentAchievementsCount,a={u:r.username};void 0!==n&&(a.g=n),void 0!==i&&(a.a=i);var u=o(t,"/API_GetUserSummary.php",e,a);return Promise.resolve(s({url:u})).then(function(e){return v(e,{shouldCastToNumbers:["GameID","ConsoleID","ID","LastGameID","ForumTopicID","activitytype","ContribCount","ContribYield","TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","Points","SoftcorePoints"],shouldMapToBooleans:["Untracked","UserWallActive","IsAwarded","HardcoreAchieved"]})})}catch(e){return Promise.reject(e)}},exports.getUserWantToPlayList=function(e,r){try{var n={};n.u=r.username,null!=r&&r.offset&&(n.o=r.offset),null!=r&&r.count&&(n.c=r.count);var i=o(t,"/API_GetUserWantToPlayList.php",e,n);return Promise.resolve(s({url:i})).then(v)}catch(e){return Promise.reject(e)}},exports.getUsersIFollow=function(e,r){try{var n={};null!=(null==r?void 0:r.offset)&&(n.o=r.offset),null!=(null==r?void 0:r.count)&&(n.c=r.count);var i=o(t,"/API_GetUsersIFollow.php",e,n);return Promise.resolve(s({url:i})).then(function(e){return v(e,{shouldCastToNumbers:["Points","PointsSoftcore"],shouldMapToBooleans:["IsFollowingMe"]})})}catch(e){return Promise.reject(e)}},exports.unsafe_call=s;
2
2
  //# sourceMappingURL=api.cjs.map