@retroachievements/api 2.7.0 → 2.9.0

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.
Files changed (38) hide show
  1. package/README.md +2 -0
  2. package/dist/api.cjs +1 -1
  3. package/dist/api.cjs.map +1 -1
  4. package/dist/api.modern.js +1 -1
  5. package/dist/api.modern.js.map +1 -1
  6. package/dist/api.module.js +1 -1
  7. package/dist/api.module.js.map +1 -1
  8. package/dist/api.umd.js +1 -1
  9. package/dist/api.umd.js.map +1 -1
  10. package/dist/game/getGameProgression.d.ts +83 -0
  11. package/dist/game/getGameProgression.test.d.ts +1 -0
  12. package/dist/game/index.d.ts +1 -0
  13. package/dist/game/models/game-progression.model.d.ts +32 -0
  14. package/dist/game/models/get-game-progression-response.model.d.ts +32 -0
  15. package/dist/game/models/index.d.ts +2 -0
  16. package/dist/leaderboard/getUserGameLeaderboards.d.ts +1 -1
  17. package/dist/leaderboard/index.d.ts +1 -0
  18. package/dist/user/getUsersIFollow.d.ts +46 -0
  19. package/dist/user/getUsersIFollow.test.d.ts +1 -0
  20. package/dist/user/index.d.ts +1 -0
  21. package/dist/user/models/get-users-i-follow-response.model.d.ts +11 -0
  22. package/dist/user/models/index.d.ts +2 -0
  23. package/dist/user/models/users-i-follow.model.d.ts +11 -0
  24. package/package.json +1 -1
  25. package/src/game/getGameProgression.test.ts +114 -0
  26. package/src/game/getGameProgression.ts +112 -0
  27. package/src/game/index.ts +1 -0
  28. package/src/game/models/game-progression.model.ts +32 -0
  29. package/src/game/models/get-game-progression-response.model.ts +32 -0
  30. package/src/game/models/index.ts +2 -0
  31. package/src/leaderboard/getUserGameLeaderboards.ts +2 -4
  32. package/src/leaderboard/index.ts +1 -0
  33. package/src/user/getUsersIFollow.test.ts +124 -0
  34. package/src/user/getUsersIFollow.ts +75 -0
  35. package/src/user/index.ts +1 -0
  36. package/src/user/models/get-users-i-follow-response.model.ts +11 -0
  37. package/src/user/models/index.ts +2 -0
  38. package/src/user/models/users-i-follow.model.ts +11 -0
@@ -1,2 +1,2 @@
1
- const e="https://retroachievements.org/API",t=(e,t,o,s={})=>{let r=`${e}/${t}`.replaceAll(/([^:]\/)\/+/g,"$1");const n={z:o.username,y:o.webApiKey};for(const[e,t]of Object.entries(s))r.includes(`:${e}`)?r=r.replace(`:${e}`,String(t)):void 0!==t&&(n[e]=String(t));return`${r}?${new URLSearchParams(n).toString()}`};var o,s;const r=null!=(o=null==(s=process.env)?void 0:s.PACKAGE_VERSION)?o:"Unknown",n=async e=>{const{url:t}=e,o=new Headers({"User-Agent":`RetroAchievements-api-js/${r}`}),s=await fetch(t,{headers:o});if(!s.ok)throw new Error(`HTTP Error: Status ${s.status} ${s.statusText}`);return await s.json()};function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e},a.apply(this,arguments)}const i=(e,t={})=>{const{shouldCastToNumbers:o,shouldMapToBooleans:s}=t;let r=e;if(Array.isArray(e)){const o=[];for(const s of e)o.push(i(s,t));r=o}else if(!Array.isArray(e)&&e instanceof Object){let n={};for(const[r,c]of Object.entries(e)){let e=c;null!=o&&o.includes(r)&&(e=null===c?null:Number(c)),null!=s&&s.includes(r)&&(e=null===c?null:"1"===String(c)),n=a({},n,{[u(r)]:i(e,t)})}r=n}return r},u=e=>{if(e.toUpperCase()===e)return e.toLowerCase();let t=e.charAt(0).toLowerCase()+e.slice(1);return t=t.replaceAll("ULID","Ulid"),t=t.replaceAll("ID","Id"),t=t.replaceAll("URL","Url"),t=t.replaceAll("rA","ra"),t=t.replaceAll("visibleUserawards","visibleUserAwards"),t},c=async(o,s)=>{const{achievementId:r,offset:a,count:u}=s,c={a:r};a&&(c.o=a),u&&(c.c=u);const l=t(e,"/API_GetAchievementUnlocks.php",o,c),d=await n({url:l});return i(d,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints","RASoftcorePoints"],shouldMapToBooleans:["HardcoreMode"]})},l={game:1,achievement:2,user:3},d=async(o,s)=>{const{identifier:r,kind:a,offset:u,count:c}=s,d={i:r};if(a)d.t=l[a];else if("number"==typeof r)throw new TypeError("'kind' must be specified when looking up an achievement or game.");u&&(d.o=u),c&&(d.c=c);const m=t(e,"/API_GetComments.php",o,d),h=await n({url:m});return i(h,{shouldCastToNumbers:["Count","Total"]})},m=async(o,s)=>{let r;null!=s&&s.shouldOnlyRetrieveActiveSystems&&(r=a({},r,{a:1})),null!=s&&s.shouldOnlyRetrieveGameSystems&&(r=a({},r,{g:1}));const u=t(e,"/API_GetConsoleIDs.php",o,r),c=await n({url:u});return i(c,{shouldCastToNumbers:["ID"]})},h=async(o,s)=>{const{consoleId:r,shouldOnlyRetrieveGamesWithAchievements:u,shouldRetrieveGameHashes:c}=s;let l={i:r};void 0!==u&&(l=a({},l,{f:u?1:0})),c&&(l=a({},l,{h:c?1:0}));const d=t(e,"/API_GetGameList.php",o,l),m=await n({url:d});return i(m,{shouldCastToNumbers:["ID","ConsoleID"]})},p=async o=>{const s=t(e,"/API_GetAchievementOfTheWeek.php",o),r=await n({url:s});return i(r,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","RASoftcorePoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})},A=async o=>{const s=t(e,"/API_GetActiveClaims.php",o),r=await n({url:s});return i(r,{shouldMapToBooleans:["UserIsJrDev"]})},I=async(o,s)=>{const{claimKind:r}=s,a=t(e,"/API_GetClaims.php",o,{k:P[r]}),u=await n({url:a});return i(u,{shouldMapToBooleans:["UserIsJrDev"]})},P={completed:"1",dropped:"2",expired:"3"},f=async(o,s)=>{const r={};null!=s&&s.startDate&&(r.d=s.startDate),null!=s&&s.offset&&(r.o=s.offset),null!=s&&s.count&&(r.c=s.count),null!=s&&s.desiredAwardKinds&&(r.k=s.desiredAwardKinds.join(","));const a=t(e,"/API_GetRecentGameAwards.php",o,r),u=await n({url:a});return i(u)},y=async o=>{const s=t(e,"/API_GetTopTenUsers.php",o),r=await n({url:s}),a=[];for(const e of r)a.push({username:e[1],totalPoints:Number(e[2]),totalRatioPoints:Number(e[3])});return a};var v,w,T;!function(e){e[e.NewSet=0]="NewSet",e[e.Revision=1]="Revision"}(v||(v={})),function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Dropped=2]="Dropped"}(w||(w={})),function(e){e[e.Primary=0]="Primary",e[e.Collaboration=1]="Collaboration"}(T||(T={}));const G=async(o,s)=>{const{gameId:r}=s,a=t(e,"/API_GetAchievementCount.php",o,{i:r}),u=await n({url:a});return i(u)},b=async(o,s)=>{const{gameId:r,flags:a,hardcore:i}=s,u={i:r};void 0!==a&&(u.f=a),void 0!==i&&(u.h=!0===i?1:0);const c=t(e,"/API_GetAchievementDistribution.php",o,u);return await n({url:c})},C=async(o,s)=>{const{gameId:r}=s,a=t(e,"/API_GetGame.php",o,{i:r}),u=await n({url:a});return i(u,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags"]})},D=async(o,s)=>{const{gameId:r,isRequestingUnofficialAchievements:a}=s,u={i:r};a&&(u.f=5);const c=t(e,"/API_GetGameExtended.php",o,u),l=await n({url:c});return i(l,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})},g=async(o,s)=>{const{gameId:r}=s,a=t(e,"/API_GetGameHashes.php",o,{i:r}),u=await n({url:a});return i(u)},N=async(o,s)=>{const{gameId:r,type:a}=s,u=t(e,"/API_GetGameRankAndScore.php",o,{g:r,t:"latest-masters"===a?1:0}),c=await n({url:u});return i(c,{shouldCastToNumbers:["TotalScore"]})},U=async(o,s)=>{const{gameId:r}=s,a=t(e,"/API_GetGameRating.php",o,{i:r}),u=await n({url:a});return i(u)};var _,S;!function(e){e[e.CoreAchievements=3]="CoreAchievements",e[e.UnofficialAchievements=5]="UnofficialAchievements"}(_||(_={})),function(e){e.Primary="0",e.Collaboration="1"}(S||(S={}));const R=async(o,s)=>{const r={};r.i=s.leaderboardId,null!=s&&s.offset&&(r.o=s.offset),null!=s&&s.count&&(r.c=s.count);const a=t(e,"/API_GetLeaderboardEntries.php",o,r),u=await n({url:a});return i(u)};async function M(o,s={}){const r=H(s),a=t(e,"/API_GetTicketData.php",o,r),u=await n({url:a});return i(u,{shouldCastToNumbers:["ID","AchievementID","Points","GameID","ReportType","ReportState","OpenTickets"],shouldMapToBooleans:["Hardcore"]})}const H=e=>{const{ticketId:t,isGettingMostTicketedGames:o,username:s,gameId:r,isGettingTicketsForUnofficialAchievements:n,shouldReturnTicketsList:a,achievementId:i}=e;let u={};return void 0!==t?u.i=t:o?(u.f="1",u=k(u,e)):s?u.u=s:r?(u.g=r,n&&(u.f="5"),a&&(u.d="1")):i?u.a=i:u=k(u,e),u},k=(e,t)=>{const o=a({},e);return void 0!==t.count&&(o.c=t.count),void 0!==t.offset&&(o.o=t.offset),o},O=async(o,s)=>{const{username:r,fromDate:a,toDate:u}=s,c=t(e,"/API_GetAchievementsEarnedBetween.php",o,{u:r,f:(a.getTime()/1e3).toFixed(0),t:(u.getTime()/1e3).toFixed(0)}),l=await n({url:c});return i(l,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},B=async(o,s)=>{const{username:r,onDate:a}=s,u=t(e,"/API_GetAchievementsEarnedOnDay.php",o,{u:r,d:`${a.getFullYear()}-${a.getMonth()+1}-${a.getDate()}`}),c=await n({url:u});return i(c,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},$=async(o,s)=>{const{gameId:r,username:a,shouldIncludeHighestAwardMetadata:u}=s,c={g:r,u:a};u&&(c.a=1);const l=t(e,"/API_GetGameInfoAndUserProgress.php",o,c),d=await n({url:l});return i(d,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})},j=async(o,s)=>{const{username:r}=s,a=t(e,"/API_GetUserAwards.php",o,{u:r}),u=await n({url:a});return i(u)},E=async(o,s)=>{const{username:r}=s,a=t(e,"/API_GetUserClaims.php",o,{u:r}),u=await n({url:a});return i(u,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})},L=async(o,s)=>{const{username:r}=s,a=t(e,"/API_GetUserCompletedGames.php",o,{u:r}),u=await n({url:a});return i(u,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})},K=async(o,s)=>{const{username:r,offset:a,count:u}=s,c={u:r};a&&(c.o=a),u&&(c.c=u);const l=t(e,"/API_GetUserCompletionProgress.php",o,c),d=await n({url:l});return i(d)},x=async(o,s)=>{const{gameId:r,username:a}=s,u=t(e,"/API_GetUserGameRankAndScore.php",o,{g:r,u:a}),c=await n({url:u});return i(c,{shouldCastToNumbers:["TotalScore","UserRank"]})},F=async(o,s)=>{const{username:r}=s,a=t(e,"/API_GetUserPoints.php",o,{u:r}),u=await n({url:a});return i(u)},W=async(o,s)=>{const{username:r}=s,a=t(e,"/API_GetUserProfile.php",o,{u:r}),u=await n({url:a});return i(u,{shouldCastToNumbers:["TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions"],shouldMapToBooleans:["Untracked","UserWallActive"]})},z=async(o,s)=>{const{username:r,gameIds:a}=s,u=t(e,"/API_GetUserProgress.php",o,{u:r,i:a.join(",")}),c=await n({url:u});return i(c,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})},q=async(o,s)=>{const{username:r,recentMinutes:a}=s,u={u:r};void 0!==a&&(u.m=a);const c=t(e,"/API_GetUserRecentAchievements.php",o,u),l=await n({url:c});return i(l,{shouldMapToBooleans:["HardcoreMode"]})},J=async(o,s)=>{const{username:r,offset:a,count:u}=s,c={u:r};void 0!==a&&(c.o=a),void 0!==u&&(c.c=u);const l=t(e,"/API_GetUserRecentlyPlayedGames.php",o,c),d=await n({url:l});return i(d,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})},V=async(o,s)=>{const{username:r,recentGamesCount:a,recentAchievementsCount:u}=s,c={u:r};void 0!==a&&(c.g=a),void 0!==u&&(c.a=u);const l=t(e,"/API_GetUserSummary.php",o,c),d=await n({url:l});return i(d,{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"]})},Y=async(o,s)=>{const r={};r.u=s.username,null!=s&&s.offset&&(r.o=s.offset),null!=s&&s.count&&(r.c=s.count);const a=t(e,"/API_GetUserWantToPlayList.php",o,r),u=await n({url:a});return i(u)},Q=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};export{_ as AchievementDistributionFlags,v as ClaimSetType,w as ClaimStatus,T as ClaimType,Q as buildAuthorization,G as getAchievementCount,b as getAchievementDistribution,p as getAchievementOfTheWeek,c as getAchievementUnlocks,O as getAchievementsEarnedBetween,B as getAchievementsEarnedOnDay,A as getActiveClaims,I as getClaims,d as getComments,m as getConsoleIds,C as getGame,D as getGameExtended,g as getGameHashes,$ as getGameInfoAndUserProgress,h as getGameList,N as getGameRankAndScore,U as getGameRating,R as getLeaderboardEntries,f as getRecentGameAwards,M as getTicketData,y as getTopTenUsers,j as getUserAwards,E as getUserClaims,L as getUserCompletedGames,K as getUserCompletionProgress,x as getUserGameRankAndScore,F as getUserPoints,W as getUserProfile,z as getUserProgress,q as getUserRecentAchievements,J as getUserRecentlyPlayedGames,V as getUserSummary,Y as getUserWantToPlayList,n as unsafe_call};
1
+ const e="https://retroachievements.org/API",t=(e,t,o,s={})=>{let n=`${e}/${t}`.replaceAll(/([^:]\/)\/+/g,"$1");const r={z:o.username,y:o.webApiKey};for(const[e,t]of Object.entries(s))n.includes(`:${e}`)?n=n.replace(`:${e}`,String(t)):void 0!==t&&(r[e]=String(t));return`${n}?${new URLSearchParams(r).toString()}`};var o,s;const n=null!=(o=null==(s=process.env)?void 0:s.PACKAGE_VERSION)?o:"Unknown",r=async e=>{const{url:t}=e,o=new Headers({"User-Agent":`RetroAchievements-api-js/${n}`}),s=await fetch(t,{headers:o});if(!s.ok)throw new Error(`HTTP Error: Status ${s.status} ${s.statusText}`);return await s.json()};function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e},a.apply(this,arguments)}const i=(e,t={})=>{const{shouldCastToNumbers:o,shouldMapToBooleans:s}=t;let n=e;if(Array.isArray(e)){const o=[];for(const s of e)o.push(i(s,t));n=o}else if(!Array.isArray(e)&&e instanceof Object){let r={};for(const[n,c]of Object.entries(e)){let e=c;null!=o&&o.includes(n)&&(e=null===c?null:Number(c)),null!=s&&s.includes(n)&&(e=null===c?null:"1"===String(c)),r=a({},r,{[u(n)]:i(e,t)})}n=r}return n},u=e=>{if(e.toUpperCase()===e)return e.toLowerCase();let t=e.charAt(0).toLowerCase()+e.slice(1);return t=t.replaceAll("ULID","Ulid"),t=t.replaceAll("ID","Id"),t=t.replaceAll("URL","Url"),t=t.replaceAll("rA","ra"),t=t.replaceAll("visibleUserawards","visibleUserAwards"),t},c=async(o,s)=>{const{achievementId:n,offset:a,count:u}=s,c={a:n};a&&(c.o=a),u&&(c.c=u);const l=t(e,"/API_GetAchievementUnlocks.php",o,c),d=await r({url:l});return i(d,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints","RASoftcorePoints"],shouldMapToBooleans:["HardcoreMode"]})},l={game:1,achievement:2,user:3},d=async(o,s)=>{const{identifier:n,kind:a,offset:u,count:c}=s,d={i:n};if(a)d.t=l[a];else if("number"==typeof n)throw new TypeError("'kind' must be specified when looking up an achievement or game.");u&&(d.o=u),c&&(d.c=c);const m=t(e,"/API_GetComments.php",o,d),h=await r({url:m});return i(h,{shouldCastToNumbers:["Count","Total"]})},m=async(o,s)=>{let n;null!=s&&s.shouldOnlyRetrieveActiveSystems&&(n=a({},n,{a:1})),null!=s&&s.shouldOnlyRetrieveGameSystems&&(n=a({},n,{g:1}));const u=t(e,"/API_GetConsoleIDs.php",o,n),c=await r({url:u});return i(c,{shouldCastToNumbers:["ID"]})},h=async(o,s)=>{const{consoleId:n,shouldOnlyRetrieveGamesWithAchievements:u,shouldRetrieveGameHashes:c}=s;let l={i:n};void 0!==u&&(l=a({},l,{f:u?1:0})),c&&(l=a({},l,{h:c?1:0}));const d=t(e,"/API_GetGameList.php",o,l),m=await r({url:d});return i(m,{shouldCastToNumbers:["ID","ConsoleID"]})},p=async o=>{const s=t(e,"/API_GetAchievementOfTheWeek.php",o),n=await r({url:s});return i(n,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","RASoftcorePoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})},A=async o=>{const s=t(e,"/API_GetActiveClaims.php",o),n=await r({url:s});return i(n,{shouldMapToBooleans:["UserIsJrDev"]})},I=async(o,s)=>{const{claimKind:n}=s,a=t(e,"/API_GetClaims.php",o,{k:P[n]}),u=await r({url:a});return i(u,{shouldMapToBooleans:["UserIsJrDev"]})},P={completed:"1",dropped:"2",expired:"3"},f=async(o,s)=>{const n={};null!=s&&s.startDate&&(n.d=s.startDate),null!=s&&s.offset&&(n.o=s.offset),null!=s&&s.count&&(n.c=s.count),null!=s&&s.desiredAwardKinds&&(n.k=s.desiredAwardKinds.join(","));const a=t(e,"/API_GetRecentGameAwards.php",o,n),u=await r({url:a});return i(u)},y=async o=>{const s=t(e,"/API_GetTopTenUsers.php",o),n=await r({url:s}),a=[];for(const e of n)a.push({username:e[1],totalPoints:Number(e[2]),totalRatioPoints:Number(e[3])});return a};var v,w,T;!function(e){e[e.NewSet=0]="NewSet",e[e.Revision=1]="Revision"}(v||(v={})),function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Dropped=2]="Dropped"}(w||(w={})),function(e){e[e.Primary=0]="Primary",e[e.Collaboration=1]="Collaboration"}(T||(T={}));const G=async(o,s)=>{const{gameId:n}=s,a=t(e,"/API_GetAchievementCount.php",o,{i:n}),u=await r({url:a});return i(u)},b=async(o,s)=>{const{gameId:n,flags:a,hardcore:i}=s,u={i:n};void 0!==a&&(u.f=a),void 0!==i&&(u.h=!0===i?1:0);const c=t(e,"/API_GetAchievementDistribution.php",o,u);return await r({url:c})},C=async(o,s)=>{const{gameId:n}=s,a=t(e,"/API_GetGame.php",o,{i:n}),u=await r({url:a});return i(u,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags"]})},g=async(o,s)=>{const{gameId:n,isRequestingUnofficialAchievements:a}=s,u={i:n};a&&(u.f=5);const c=t(e,"/API_GetGameExtended.php",o,u),l=await r({url:c});return i(l,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})},D=async(o,s)=>{const{gameId:n}=s,a=t(e,"/API_GetGameHashes.php",o,{i:n}),u=await r({url:a});return i(u)},N=async(o,s)=>{const{gameId:n,hardcore:a}=s,u={i:n};void 0!==a&&(u.h=!0===a?1:0);const c=t(e,"/API_GetGameProgression.php",o,u),l=await r({url:c});return i(l)},U=async(o,s)=>{const{gameId:n,type:a}=s,u=t(e,"/API_GetGameRankAndScore.php",o,{g:n,t:"latest-masters"===a?1:0}),c=await r({url:u});return i(c,{shouldCastToNumbers:["TotalScore"]})},_=async(o,s)=>{const{gameId:n}=s,a=t(e,"/API_GetGameRating.php",o,{i:n}),u=await r({url:a});return i(u)};var S,R;!function(e){e[e.CoreAchievements=3]="CoreAchievements",e[e.UnofficialAchievements=5]="UnofficialAchievements"}(S||(S={})),function(e){e.Primary="0",e.Collaboration="1"}(R||(R={}));const M=async(o,s)=>{const n={};n.i=s.leaderboardId,null!=s&&s.offset&&(n.o=s.offset),null!=s&&s.count&&(n.c=s.count);const a=t(e,"/API_GetLeaderboardEntries.php",o,n),u=await r({url:a});return i(u)},H=async(o,s)=>{const n={};n.i=s.gameId,n.u=s.username,null!=s&&s.offset&&(n.o=s.offset),null!=s&&s.count&&(n.c=s.count);const a=t(e,"/API_GetUserGameLeaderboards.php",o,n),u=await r({url:a});return i(u)};async function k(o,s={}){const n=O(s),a=t(e,"/API_GetTicketData.php",o,n),u=await r({url:a});return i(u,{shouldCastToNumbers:["ID","AchievementID","Points","GameID","ReportType","ReportState","OpenTickets"],shouldMapToBooleans:["Hardcore"]})}const O=e=>{const{ticketId:t,isGettingMostTicketedGames:o,username:s,gameId:n,isGettingTicketsForUnofficialAchievements:r,shouldReturnTicketsList:a,achievementId:i}=e;let u={};return void 0!==t?u.i=t:o?(u.f="1",u=B(u,e)):s?u.u=s:n?(u.g=n,r&&(u.f="5"),a&&(u.d="1")):i?u.a=i:u=B(u,e),u},B=(e,t)=>{const o=a({},e);return void 0!==t.count&&(o.c=t.count),void 0!==t.offset&&(o.o=t.offset),o},$=async(o,s)=>{const{username:n,fromDate:a,toDate:u}=s,c=t(e,"/API_GetAchievementsEarnedBetween.php",o,{u:n,f:(a.getTime()/1e3).toFixed(0),t:(u.getTime()/1e3).toFixed(0)}),l=await r({url:c});return i(l,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},L=async(o,s)=>{const{username:n,onDate:a}=s,u=t(e,"/API_GetAchievementsEarnedOnDay.php",o,{u:n,d:`${a.getFullYear()}-${a.getMonth()+1}-${a.getDate()}`}),c=await r({url:u});return i(c,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},j=async(o,s)=>{const{gameId:n,username:a,shouldIncludeHighestAwardMetadata:u}=s,c={g:n,u:a};u&&(c.a=1);const l=t(e,"/API_GetGameInfoAndUserProgress.php",o,c),d=await r({url:l});return i(d,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore"]})},E=async(o,s)=>{const{username:n}=s,a=t(e,"/API_GetUserAwards.php",o,{u:n}),u=await r({url:a});return i(u)},F=async(o,s)=>{const{username:n}=s,a=t(e,"/API_GetUserClaims.php",o,{u:n}),u=await r({url:a});return i(u,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})},K=async(o,s)=>{const{username:n}=s,a=t(e,"/API_GetUserCompletedGames.php",o,{u:n}),u=await r({url:a});return i(u,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})},x=async(o,s)=>{const{username:n,offset:a,count:u}=s,c={u:n};a&&(c.o=a),u&&(c.c=u);const l=t(e,"/API_GetUserCompletionProgress.php",o,c),d=await r({url:l});return i(d)},W=async(o,s)=>{const{gameId:n,username:a}=s,u=t(e,"/API_GetUserGameRankAndScore.php",o,{g:n,u:a}),c=await r({url:u});return i(c,{shouldCastToNumbers:["TotalScore","UserRank"]})},z=async(o,s)=>{const{username:n}=s,a=t(e,"/API_GetUserPoints.php",o,{u:n}),u=await r({url:a});return i(u)},q=async(o,s)=>{const{username:n}=s,a=t(e,"/API_GetUserProfile.php",o,{u:n}),u=await r({url:a});return i(u,{shouldCastToNumbers:["TotalPoints","TotalSoftcorePoints","TotalTruePoints","Permissions"],shouldMapToBooleans:["Untracked","UserWallActive"]})},J=async(o,s)=>{const{username:n,gameIds:a}=s,u=t(e,"/API_GetUserProgress.php",o,{u:n,i:a.join(",")}),c=await r({url:u});return i(c,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})},V=async(o,s)=>{const{username:n,recentMinutes:a}=s,u={u:n};void 0!==a&&(u.m=a);const c=t(e,"/API_GetUserRecentAchievements.php",o,u),l=await r({url:c});return i(l,{shouldMapToBooleans:["HardcoreMode"]})},Y=async(o,s)=>{const{username:n,offset:a,count:u}=s,c={u:n};void 0!==a&&(c.o=a),void 0!==u&&(c.c=u);const l=t(e,"/API_GetUserRecentlyPlayedGames.php",o,c),d=await r({url:l});return i(d,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})},Q=async(o,s)=>{const n={};null!=(null==s?void 0:s.offset)&&(n.o=s.offset),null!=(null==s?void 0:s.count)&&(n.c=s.count);const a=t(e,"/API_GetUsersIFollow.php",o,n),u=await r({url:a});return i(u,{shouldCastToNumbers:["Points","PointsSoftcore"],shouldMapToBooleans:["IsFollowingMe"]})},X=async(o,s)=>{const{username:n,recentGamesCount:a,recentAchievementsCount:u}=s,c={u:n};void 0!==a&&(c.g=a),void 0!==u&&(c.a=u);const l=t(e,"/API_GetUserSummary.php",o,c),d=await r({url:l});return i(d,{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"]})},Z=async(o,s)=>{const n={};n.u=s.username,null!=s&&s.offset&&(n.o=s.offset),null!=s&&s.count&&(n.c=s.count);const a=t(e,"/API_GetUserWantToPlayList.php",o,n),u=await r({url:a});return i(u)},ee=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};export{S as AchievementDistributionFlags,v as ClaimSetType,w as ClaimStatus,T as ClaimType,ee as buildAuthorization,G as getAchievementCount,b as getAchievementDistribution,p as getAchievementOfTheWeek,c as getAchievementUnlocks,$ as getAchievementsEarnedBetween,L as getAchievementsEarnedOnDay,A as getActiveClaims,I as getClaims,d as getComments,m as getConsoleIds,C as getGame,g as getGameExtended,D as getGameHashes,j as getGameInfoAndUserProgress,h as getGameList,N as getGameProgression,U as getGameRankAndScore,_ as getGameRating,M as getLeaderboardEntries,f as getRecentGameAwards,k as getTicketData,y as getTopTenUsers,E as getUserAwards,F as getUserClaims,K as getUserCompletedGames,x as getUserCompletionProgress,H as getUserGameLeaderboards,W as getUserGameRankAndScore,z as getUserPoints,q as getUserProfile,J as getUserProgress,V as getUserRecentAchievements,Y as getUserRecentlyPlayedGames,X as getUserSummary,Z as getUserWantToPlayList,Q as getUsersIFollow,r as unsafe_call};
2
2
  //# sourceMappingURL=api.modern.js.map