@retroachievements/api 1.0.0-rc.4 → 1.0.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 (101) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +101 -60
  3. package/dist/achievement/getAchievementUnlocks.d.ts +1 -1
  4. package/dist/achievement/getAchievementUnlocks.test.d.ts +1 -0
  5. package/dist/api.cjs +2 -0
  6. package/dist/api.cjs.map +1 -0
  7. package/dist/api.modern.js +2 -0
  8. package/dist/api.modern.js.map +1 -0
  9. package/dist/api.module.js +2 -0
  10. package/dist/api.module.js.map +1 -0
  11. package/dist/api.umd.js +2 -0
  12. package/dist/api.umd.js.map +1 -0
  13. package/dist/console/getConsoleIds.test.d.ts +1 -0
  14. package/dist/console/getGameList.test.d.ts +1 -0
  15. package/dist/feed/getAchievementOfTheWeek.test.d.ts +1 -0
  16. package/dist/feed/getActiveClaims.test.d.ts +1 -0
  17. package/dist/feed/getTopTenUsers.d.ts +1 -1
  18. package/dist/feed/getTopTenUsers.test.d.ts +1 -0
  19. package/dist/feed/index.d.ts +0 -1
  20. package/dist/feed/models/index.d.ts +0 -12
  21. package/dist/game/getAchievementCount.d.ts +1 -1
  22. package/dist/game/getAchievementCount.test.d.ts +1 -0
  23. package/dist/game/getAchievementDistribution.test.d.ts +1 -0
  24. package/dist/game/getGame.test.d.ts +1 -0
  25. package/dist/game/getGameExtended.d.ts +1 -1
  26. package/dist/game/getGameExtended.test.d.ts +1 -0
  27. package/dist/game/getGameRankAndScore.test.d.ts +1 -0
  28. package/dist/game/getGameRating.test.d.ts +1 -0
  29. package/dist/game/models/game-rank-and-score-entity.model.d.ts +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.esm.js +2 -0
  32. package/dist/index.esm.js.map +1 -0
  33. package/dist/index.js +2 -8
  34. package/dist/index.js.map +1 -0
  35. package/dist/index.umd.js +2 -0
  36. package/dist/index.umd.js.map +1 -0
  37. package/dist/{feed → ticket}/getTicketData.d.ts +3 -3
  38. package/dist/ticket/getTicketData.test.d.ts +1 -0
  39. package/dist/ticket/index.d.ts +2 -0
  40. package/dist/{feed → ticket}/models/achievement-ticket-stats-response.model.d.ts +0 -0
  41. package/dist/{feed → ticket}/models/achievement-ticket-stats.model.d.ts +0 -0
  42. package/dist/{feed → ticket}/models/game-ticket-stats.model.d.ts +0 -0
  43. package/dist/{feed → ticket}/models/game-tickets-response.model.d.ts +0 -0
  44. package/dist/ticket/models/index.d.ts +12 -0
  45. package/dist/{feed → ticket}/models/most-ticketed-games-response.model.d.ts +0 -0
  46. package/dist/{feed → ticket}/models/most-ticketed-games.model.d.ts +0 -0
  47. package/dist/{feed → ticket}/models/recent-tickets-response.model.d.ts +0 -0
  48. package/dist/{feed → ticket}/models/recent-tickets.model.d.ts +0 -0
  49. package/dist/{feed → ticket}/models/response-ticket-entity.model.d.ts +0 -0
  50. package/dist/{feed → ticket}/models/ticket-entity.model.d.ts +0 -0
  51. package/dist/{feed → ticket}/models/tickets-by-user-response.model.d.ts +0 -0
  52. package/dist/{feed → ticket}/models/user-ticket-stats.model.d.ts +0 -0
  53. package/dist/user/getAchievementsEarnedBetween.test.d.ts +1 -0
  54. package/dist/user/getAchievementsEarnedOnDay.test.d.ts +1 -0
  55. package/dist/user/getGameInfoAndUserProgress.test.d.ts +1 -0
  56. package/dist/user/getUserClaims.test.d.ts +1 -0
  57. package/dist/user/getUserCompletedGames.test.d.ts +1 -0
  58. package/dist/user/getUserGameRankAndScore.test.d.ts +1 -0
  59. package/dist/user/getUserPoints.test.d.ts +1 -0
  60. package/dist/user/getUserProgress.test.d.ts +1 -0
  61. package/dist/user/getUserRecentlyPlayedGames.d.ts +1 -1
  62. package/dist/user/getUserRecentlyPlayedGames.test.d.ts +1 -0
  63. package/dist/user/getUserSummary.test.d.ts +1 -0
  64. package/dist/utils/internal/buildRequestUrl.test.d.ts +1 -0
  65. package/dist/utils/internal/call.test.d.ts +1 -0
  66. package/dist/utils/internal/serializeProperties.test.d.ts +1 -0
  67. package/dist/utils/public/buildAuthorization.d.ts +1 -1
  68. package/dist/utils/public/buildAuthorization.test.d.ts +1 -0
  69. package/package.json +21 -15
  70. package/src/achievement/getAchievementUnlocks.ts +1 -1
  71. package/src/feed/getTopTenUsers.ts +1 -1
  72. package/src/feed/index.ts +0 -1
  73. package/src/feed/models/index.ts +0 -12
  74. package/src/game/getAchievementCount.ts +1 -1
  75. package/src/game/getGameExtended.ts +1 -1
  76. package/src/game/models/game-rank-and-score-entity.model.ts +2 -1
  77. package/src/index.ts +1 -0
  78. package/src/{feed → ticket}/getTicketData.test.ts +0 -0
  79. package/src/{feed → ticket}/getTicketData.ts +3 -3
  80. package/src/ticket/index.ts +2 -0
  81. package/src/{feed → ticket}/models/achievement-ticket-stats-response.model.ts +0 -0
  82. package/src/{feed → ticket}/models/achievement-ticket-stats.model.ts +0 -0
  83. package/src/{feed → ticket}/models/game-ticket-stats.model.ts +0 -0
  84. package/src/{feed → ticket}/models/game-tickets-response.model.ts +0 -0
  85. package/src/ticket/models/index.ts +12 -0
  86. package/src/{feed → ticket}/models/most-ticketed-games-response.model.ts +0 -0
  87. package/src/{feed → ticket}/models/most-ticketed-games.model.ts +0 -0
  88. package/src/{feed → ticket}/models/recent-tickets-response.model.ts +0 -0
  89. package/src/{feed → ticket}/models/recent-tickets.model.ts +0 -0
  90. package/src/{feed → ticket}/models/response-ticket-entity.model.ts +0 -0
  91. package/src/{feed → ticket}/models/ticket-entity.model.ts +0 -0
  92. package/src/{feed → ticket}/models/tickets-by-user-response.model.ts +0 -0
  93. package/src/{feed → ticket}/models/user-ticket-stats.model.ts +0 -0
  94. package/src/user/getUserRecentlyPlayedGames.ts +1 -1
  95. package/src/utils/public/buildAuthorization.ts +1 -1
  96. package/dist/api.cjs.development.js +0 -2255
  97. package/dist/api.cjs.development.js.map +0 -1
  98. package/dist/api.cjs.production.min.js +0 -2
  99. package/dist/api.cjs.production.min.js.map +0 -1
  100. package/dist/api.esm.js +0 -2223
  101. package/dist/api.esm.js.map +0 -1
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 RetroAchievements.org
3
+ Copyright (c) 2023 RetroAchievements.org
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,103 +1,144 @@
1
- # DTS User Guide
1
+ <h1 align="center">@retroachievements/api</h1>
2
2
 
3
- Congrats! You just saved yourself hours of work by bootstrapping this project with DTS. Let’s get you oriented with what’s here and how to use it.
3
+ <p align="center">
4
+ <i>A JavaScript library that lets you get achievement, user, and game data from RetroAchievements.</i>
5
+ <br /><br />
6
+ </p>
4
7
 
5
- > This DTS setup is meant for developing libraries (not apps!) that can be published to NPM. If you’re looking to build a Node app, you could use `ts-node-dev`, plain `ts-node`, or simple `tsc`.
8
+ <p align="center">
9
+ <a href="https://retroachievements-api-js.vercel.app/getting-started.html"><strong>Documentation: Get Started</strong></a>
10
+ <br />
11
+ </p>
6
12
 
7
- > If you’re new to TypeScript, checkout [this handy cheatsheet](https://devhints.io/typescript)
13
+ <hr />
8
14
 
9
- ## Commands
15
+ ## Features
10
16
 
11
- DTS scaffolds your new library inside `/src`.
17
+ &nbsp;Modular by design and supports tree-shaking.
18
+ ✅ &nbsp;Officially-supported, aligns 1:1 with the RAWeb API.
19
+ ✅ &nbsp;Backwards-compatible, easy migration path to API v2.
20
+ ✅ &nbsp;Supports Node environments (16 and above).
21
+ ✅ &nbsp;Ships with TypeScript support and types.
22
+ ✅ &nbsp;Correctly maps types and properties from RAWeb PHP calls.
23
+ ✅ &nbsp;Small, <3Kb.
12
24
 
13
- To run DTS, use:
25
+ <hr />
14
26
 
15
- ```bash
16
- npm start # or yarn start
17
- ```
27
+ ## Documentation
28
+
29
+ Learn how to authenticate and start pulling data from RetroAchievements on our documentation website.
18
30
 
19
- This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
31
+ - [Get started](https://retroachievements-api-js.vercel.app/getting-started.html)
32
+ - [Get a user's profile information](https://retroachievements-api-js.vercel.app/v1/users/get-user-summary.html)
33
+ - [Look up games a user has completed](https://retroachievements-api-js.vercel.app/v1/users/get-user-completed-games.html)
34
+ - [Get a game's metadata](https://retroachievements-api-js.vercel.app/v1/games/get-game-extended.html)
20
35
 
21
- To do a one-off build, use `npm run build` or `yarn build`.
36
+ ## Installation
22
37
 
23
- To run tests, use `npm test` or `yarn test`.
38
+ Run the following command:
24
39
 
25
- ## Configuration
40
+ ```bash
41
+ npm install --save @retroachievements/api
42
+ ```
26
43
 
27
- Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
44
+ ## How to begin making API calls
28
45
 
29
- ### Jest
46
+ To use any endpoint function in the API, you must first be authorized by RetroAchievements. Fortunately, this is a fairly straightforward process.
30
47
 
31
- Jest tests are set up to run with `npm test` or `yarn test`.
48
+ 1. Visit [your control panel](https://retroachievements.org/controlpanel.php) on the RA website.
32
49
 
33
- ### Bundle Analysis
50
+ 2. Find the "Keys" section on the page. Copy the web API key value. **Do not expose your API key anywhere publicly.**
34
51
 
35
- [`size-limit`](https://github.com/ai/size-limit) is set up to calculate the real cost of your library with `npm run size` and visualize the bundle with `npm run analyze`.
52
+ 3. You can now create your authorization object using your web API key.
36
53
 
37
- #### Setup Files
54
+ ```ts
55
+ import { buildAuthorization } from "@retroachievements/api";
38
56
 
39
- This is the folder structure we set up for you:
57
+ const userName = "<your username on RA>";
58
+ const webApiKey = "<your web API key>";
40
59
 
41
- ```txt
42
- /src
43
- index.ts # EDIT THIS
44
- /test
45
- index.test.ts # EDIT THIS
46
- .gitignore
47
- package.json
48
- README.md # EDIT THIS
49
- tsconfig.json
60
+ const authorization = buildAuthorization({ userName, webApiKey });
50
61
  ```
51
62
 
52
- ### Rollup
63
+ 4. You now have all you need to use any function in the API. Each function takes this authorization object as its first argument. Here's an example:
53
64
 
54
- DTS uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
65
+ ```ts
66
+ import { getGame } from "@retroachievements/api";
55
67
 
56
- ### TypeScript
68
+ // This returns basic metadata about the game on this page:
69
+ // https://retroachievements.org/game/14402
70
+ const game = await getGame(authorization, { gameId: 14402 });
71
+ ```
57
72
 
58
- `tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
73
+ ## API
59
74
 
60
- ## Continuous Integration
75
+ Click the function names to open their complete docs on the docs site.
61
76
 
62
- ### GitHub Actions
77
+ ### Users
63
78
 
64
- Two actions are added by default:
79
+ - [`getAchievementsEarnedBetween()`](https://retroachievements-api-js.vercel.app/v1/users/get-achievements-earned-between.html) - Get a list of achievements earned by a user between two dates.
80
+ - [`getAchievementsEarnedOnDay()`](https://retroachievements-api-js.vercel.app/v1/users/get-achievements-earned-on-day.html) - Get a list of achievements earned by a user on a given date.
81
+ - [`getGameInfoAndUserProgress()`](https://retroachievements-api-js.vercel.app/v1/users/get-game-info-and-user-progress.html) - Get metadata about a game as well as a user's progress on that game.
82
+ - [`getUserClaims()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-claims.html) - Get a list of set claims made over the lifetime of a user.
83
+ - [`getUserCompletedGames()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-completed-games.html) - Get hardcore and softcore completion metadata about games a user has played.
84
+ - [`getUserGameRankAndScore()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-game-rank-and-score.html) - Get metadata about how a user has performed on a given game.
85
+ - [`getUserPoints()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-points.html) - Get a user's total hardcore and softcore points.
86
+ - [`getUserProgress()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-progress.html) - Get a user's progress on a list of specified games.
87
+ - [`getUserRecentlyPlayedGames()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-recently-played-games.html) - Get a list of games a user has recently played.
88
+ - [`getUserSummary()`](https://retroachievements-api-js.vercel.app/v1/users/get-user-summary.html) - Get a user's profile metadata.
65
89
 
66
- - `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
67
- - `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
90
+ ### Games
68
91
 
69
- ## Optimizations
92
+ - [`getAchievementCount()`](https://retroachievements-api-js.vercel.app/v1/games/get-achievement-count.html) - Get the list of achievement IDs for a game.
93
+ - [`getAchievementDistribution()`](https://retroachievements-api-js.vercel.app/v1/games/get-achievement-distribution.html) - Get how many players have unlocked how many achievements for a game.
94
+ - [`getGame()`](https://retroachievements-api-js.vercel.app/v1/games/get-game.html) - Get basic metadata about a game.
95
+ - [`getGameExtended()`](https://retroachievements-api-js.vercel.app/v1/games/get-game-extended.html) - Get extended metadata about a game.
96
+ - [`getGameRankAndScore()`](https://retroachievements-api-js.vercel.app/v1/games/get-game-rank-and-score.html) - Get a list of either the latest masters or highest points earners for a game.
97
+ - [`getGameRating()`](https://retroachievements-api-js.vercel.app/v1/games/get-game-rating.html) - Get how users have rated a game.
70
98
 
71
- Please see the main `dts` [optimizations docs](https://github.com/weiran-zsd/dts-cli#optimizations). In particular, know that you can take advantage of development-only optimizations:
99
+ ### Achievements
72
100
 
73
- ```js
74
- // ./types/index.d.ts
75
- declare var __DEV__: boolean;
101
+ - [`getAchievementUnlocks()`](https://retroachievements-api-js.vercel.app/v1/achievements/get-achievement-unlocks.html) - Get a list of users who have earned an achievement.
76
102
 
77
- // inside your code...
78
- if (__DEV__) {
79
- console.log("foo");
80
- }
81
- ```
103
+ ### Consoles
104
+
105
+ - [`getConsoleIds()`](https://retroachievements-api-js.vercel.app/v1/consoles/get-console-ids.html) - Get the complete list of console ID and name pairs on the site.
106
+ - [`getGameList()`](https://retroachievements-api-js.vercel.app/v1/consoles/get-game-list.html) - Get the complete list of games for a console.
107
+
108
+ ### Feed
82
109
 
83
- You can also choose to install and use [invariant](https://github.com/weiran-zsd/dts-cli#invariant) and [warning](https://github.com/weiran-zsd/dts-cli#warning) functions.
110
+ - [`getAchievementOfTheWeek()`](https://retroachievements-api-js.vercel.app/v1/feed/get-achievement-of-the-week.html) - Get comprehensive metadata about the current Achievement of the Week.
111
+ - [`getActiveClaims()`](https://retroachievements-api-js.vercel.app/v1/feed/get-active-claims.html) - Get all current set claims on the site.
112
+ - [`getTopTenUsers()`](https://retroachievements-api-js.vercel.app/v1/feed/get-top-ten-users.html) - Get the list of top ten points earners.
84
113
 
85
- ## Module Formats
114
+ ### Tickets
86
115
 
87
- CJS, ESModules, and UMD module formats are supported.
116
+ - [Get Ticket by ID](https://retroachievements-api-js.vercel.app/v1/tickets/get-ticket-by-id.html)
117
+ - [Get Most Ticketed Games](https://retroachievements-api-js.vercel.app/v1/tickets/get-most-ticketed-games.html)
118
+ - [Get Most Recent Tickets](https://retroachievements-api-js.vercel.app/v1/tickets/get-most-recent-tickets.html)
119
+ - [Get Game Ticket Stats](https://retroachievements-api-js.vercel.app/v1/tickets/get-game-ticket-stats.html)
120
+ - [Get Developer Ticket Stats](https://retroachievements-api-js.vercel.app/v1/tickets/get-developer-ticket-stats.html)
88
121
 
89
- The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
122
+ ## Examples
90
123
 
91
- ## Named Exports
124
+ TODO
92
125
 
93
- Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
126
+ ## Projects Using @retroachievements/api
94
127
 
95
- ## Including Styles
128
+ Let us know about yours by [opening an issue](https://github.com/RetroAchievements/retroachievements-api-js/issues/new)!
96
129
 
97
- There are many ways to ship styles, including with CSS-in-JS. DTS has no opinion on this, configure how you like.
130
+ ## How to Contribute
98
131
 
99
- For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
132
+ Check out [CONTRIBUTING.md](https://github.com/RetroAchievements/retroachievements-api-js/blob/main/CONTRIBUTING.md) for how to get started.
100
133
 
101
- ## Publishing to NPM
134
+ ## Contributors
102
135
 
103
- We recommend using [np](https://github.com/sindresorhus/np).
136
+ <!-- prettier-ignore-start -->
137
+ <!-- markdownlint-disable -->
138
+ <table>
139
+ <tbody>
140
+ <tr>
141
+ <td align="center"><a href="https://github.com/wescopeland"><img src="https://avatars.githubusercontent.com/u/3984985?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wes Copeland</b></sub></a><br /><a href="https://github.com/achievements-app/psn-api/commits?author=wescopeland" title="Code">💻</a> <a href="#example-wescopeland" title="Examples">💡</a> <a href="https://github.com/achievements-app/psn-api/commits?author=wescopeland" title="Documentation">📖</a></td>
142
+ </tr>
143
+ </tbody>
144
+ </table>
@@ -3,7 +3,7 @@ import type { AuthObject } from "../utils/public";
3
3
  import type { AchievementUnlocksMetadata } from "./models";
4
4
  /**
5
5
  * A call to this function will retrieve a list of users who
6
- * have earned the given achievementId.
6
+ * have earned a given achievement, targeted by the achievement's ID.
7
7
  *
8
8
  * @param authorization An object containing your userName and webApiKey.
9
9
  * This can be constructed with `buildAuthorization()`.
@@ -0,0 +1 @@
1
+ export {};
package/dist/api.cjs ADDED
@@ -0,0 +1,2 @@
1
+ function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/e(require("isomorphic-unfetch")),t="https://retroachievements.org/API",o=function(e,r,t,o){void 0===o&&(o={});for(var n=(e+"/"+r).replace(/([^:]\/)\/+/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=function(e){try{return Promise.resolve(r.default(e.url)).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function s(){return s=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},s.apply(this,arguments)}function i(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 a(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 i(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)?i(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 u,c,l,m,h,d=function e(r,t){void 0===t&&(t={});var o=t.shouldCastToNumbers,n=t.shouldMapToBooleans,i=r;if(Array.isArray(r)){for(var u,c=[],l=a(r);!(u=l()).done;)c.push(e(u.value,t));i=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"===A),m=s({},m,((v={})[p(f)]=e(y,t),v))}i=m}return i},p=function(e){if(e.toUpperCase()===e)return e.toLowerCase();var r=e.charAt(0).toLowerCase()+e.slice(1);return(r=(r=r.replace(/ID/g,"Id")).replace(/URL/g,"Url")).replace(/rA/g,"ra")};exports.ClaimType=void 0,(u=exports.ClaimType||(exports.ClaimType={}))[u.Primary=0]="Primary",u[u.Collaboration=1]="Collaboration",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.AchievementDistributionFlags=void 0,(m=exports.AchievementDistributionFlags||(exports.AchievementDistributionFlags={}))[m.CoreAchievements=3]="CoreAchievements",m[m.UnofficialAchievements=5]="UnofficialAchievements",function(e){e.Primary="0",e.Collaboration="1"}(h||(h={}));var v=function(e,r){var t=s({},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 s=o(t,"/API_GetAchievementCount.php",e,{i:r.gameId});return Promise.resolve(n({url:s})).then(d)}catch(e){return Promise.reject(e)}},exports.getAchievementDistribution=function(e,r){try{var s=r.flags,i=r.hardcore,a={i:r.gameId};void 0!==s&&(a.f=s),void 0!==i&&(a.h=!0===i?1:0);var u=o(t,"/API_GetAchievementDistribution.php",e,a);return Promise.resolve(n({url:u}))}catch(e){return Promise.reject(e)}},exports.getAchievementOfTheWeek=function(e){try{var r=o(t,"/API_GetAchievementOfTheWeek.php",e);return Promise.resolve(n({url:r})).then(function(e){return d(e,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementUnlocks=function(e,r){try{var s=r.offset,i=r.count,a={a:r.achievementId};s&&(a.o=s),i&&(a.c=i);var u=o(t,"/API_GetAchievementUnlocks.php",e,a);return Promise.resolve(n({url:u})).then(function(e){return d(e,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedBetween=function(e,r){try{var s=r.toDate,i=o(t,"/API_GetAchievementsEarnedBetween.php",e,{u:r.userName,f:(r.fromDate.getTime()/1e3).toFixed(0),t:(s.getTime()/1e3).toFixed(0)});return Promise.resolve(n({url:i})).then(function(e){return d(e,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getAchievementsEarnedOnDay=function(e,r){try{var s=r.onDate,i=o(t,"/API_GetAchievementsEarnedOnDay.php",e,{u:r.userName,d:s.getFullYear()+"-"+(s.getMonth()+1)+"-"+s.getDate()});return Promise.resolve(n({url:i})).then(function(e){return d(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(n({url:r})).then(function(e){return d(e,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})})}catch(e){return Promise.reject(e)}},exports.getConsoleIds=function(e){try{var r=o(t,"/API_GetConsoleIDs.php",e);return Promise.resolve(n({url:r})).then(function(e){return d(e,{shouldCastToNumbers:["ID"]})})}catch(e){return Promise.reject(e)}},exports.getGame=function(e,r){try{var s=o(t,"/API_GetGame.php",e,{i:r.gameId});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags","Released"]})})}catch(e){return Promise.reject(e)}},exports.getGameExtended=function(e,r){try{var s=o(t,"/API_GetGameExtended.php",e,{i:r.gameId});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore","Released"]})})}catch(e){return Promise.reject(e)}},exports.getGameInfoAndUserProgress=function(e,r){try{var s=o(t,"/API_GetGameInfoAndUserProgress.php",e,{g:r.gameId,u:r.userName});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore","Released"]})})}catch(e){return Promise.reject(e)}},exports.getGameList=function(e,r){try{var i=r.shouldOnlyRetrieveGamesWithAchievements,a=r.shouldRetrieveGameHashes,u={i:r.consoleId};void 0!==i&&(u=s({},u,{f:i?1:0})),a&&(u=s({},u,{h:a?1:0}));var c=o(t,"/API_GetGameList.php",e,u);return Promise.resolve(n({url:c})).then(function(e){return d(e,{shouldCastToNumbers:["ID","ConsoleID"]})})}catch(e){return Promise.reject(e)}},exports.getGameRankAndScore=function(e,r){try{var s=o(t,"/API_GetGameRankAndScore.php",e,{g:r.gameId,t:"latest-masters"===r.type?1:0});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["TotalScore"]})})}catch(e){return Promise.reject(e)}},exports.getGameRating=function(e,r){try{var s=o(t,"/API_GetGameRating.php",e,{i:r.gameId});return Promise.resolve(n({url:s})).then(d)}catch(e){return Promise.reject(e)}},exports.getTicketData=function(e,r){void 0===r&&(r={});try{var s=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=v(u,e)):o?u.u=o:n?(u.g=n,s&&(u.f="5"),i&&(u.d="1")):a?u.a=a:u=v(u,e),u}(r),i=o(t,"/API_GetTicketData.php",e,s);return Promise.resolve(n({url:i})).then(function(e){return d(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(n({url:r})).then(function(e){for(var r,t=[],o=a(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.getUserClaims=function(e,r){try{var s=o(t,"/API_GetUserClaims.php",e,{u:r.userName});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})})}catch(e){return Promise.reject(e)}},exports.getUserCompletedGames=function(e,r){try{var s=o(t,"/API_GetUserCompletedGames.php",e,{u:r.userName});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})})}catch(e){return Promise.reject(e)}},exports.getUserGameRankAndScore=function(e,r){try{var s=o(t,"/API_GetUserGameRankAndScore.php",e,{g:r.gameId,u:r.userName});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["TotalScore","UserRank"]})})}catch(e){return Promise.reject(e)}},exports.getUserPoints=function(e,r){try{var s=o(t,"/API_GetUserPoints.php",e,{u:r.userName});return Promise.resolve(n({url:s})).then(d)}catch(e){return Promise.reject(e)}},exports.getUserProgress=function(e,r){try{var s=o(t,"/API_GetUserProgress.php",e,{u:r.userName,i:r.gameIds.join(",")});return Promise.resolve(n({url:s})).then(function(e){return d(e,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})})}catch(e){return Promise.reject(e)}},exports.getUserRecentlyPlayedGames=function(e,r){try{var s=r.offset,i=r.count,a={u:r.userName};void 0!==s&&(a.o=s),void 0!==i&&(a.c=i);var u=o(t,"/API_GetUserRecentlyPlayedGames.php",e,a);return Promise.resolve(n({url:u})).then(function(e){return d(e,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})})}catch(e){return Promise.reject(e)}},exports.getUserSummary=function(e,r){try{var s=r.recentGamesCount,i=r.recentAchievementsCount,a={u:r.userName};void 0!==s&&(a.g=s),void 0!==i&&(a.a=i);var u=o(t,"/API_GetUserSummary.php",e,a);return Promise.resolve(n({url:u})).then(function(e){return d(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.unsafe_call=n;
2
+ //# sourceMappingURL=api.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.cjs","sources":["../src/utils/internal/apiBaseUrl.ts","../src/utils/internal/buildRequestUrl.ts","../src/utils/internal/call.ts","../src/utils/internal/serializeProperties.ts","../src/feed/models/active-claim.model.ts","../src/game/models/achievement-distribution-flags.model.ts","../src/game/models/get-game-extended-response.model.ts","../src/ticket/getTicketData.ts","../src/utils/public/buildAuthorization.ts","../src/game/getAchievementCount.ts","../src/game/getAchievementDistribution.ts","../src/feed/getAchievementOfTheWeek.ts","../src/achievement/getAchievementUnlocks.ts","../src/user/getAchievementsEarnedBetween.ts","../src/user/getAchievementsEarnedOnDay.ts","../src/feed/getActiveClaims.ts","../src/console/getConsoleIds.ts","../src/game/getGame.ts","../src/game/getGameExtended.ts","../src/user/getGameInfoAndUserProgress.ts","../src/console/getGameList.ts","../src/game/getGameRankAndScore.ts","../src/game/getGameRating.ts","../src/feed/getTopTenUsers.ts","../src/user/getUserClaims.ts","../src/user/getUserCompletedGames.ts","../src/user/getUserGameRankAndScore.ts","../src/user/getUserPoints.ts","../src/user/getUserProgress.ts","../src/user/getUserRecentlyPlayedGames.ts","../src/user/getUserSummary.ts"],"sourcesContent":["export const apiBaseUrl = \"https://retroachievements.org/API\";\n","import type { AuthObject } from \"../public/models\";\n\nexport const buildRequestUrl = (\n baseUrl: string,\n endpointUrl: string,\n authObject: AuthObject,\n args: Record<string, string | number> = {}\n) => {\n const concatenated = `${baseUrl}/${endpointUrl}`;\n const withoutDoubleSlashes = concatenated.replace(/([^:]\\/)\\/+/g, \"$1\");\n\n let withArgs = withoutDoubleSlashes;\n\n // `z` and `y` are expected query params from the RA API.\n // Authentication is handled purely by query params.\n const queryParamValues: Record<string, string> = {\n z: authObject.userName,\n y: authObject.webApiKey\n };\n\n for (const [argKey, argValue] of Object.entries(args)) {\n // \"abc.com/some-route/:foo/some-path\" & {\"foo\": 4} --> \"abc.com/some-route/4/some-path\"\n if (withArgs.includes(`:${argKey}`)) {\n withArgs = withArgs.replace(`:${argKey}`, String(argValue));\n } else if (argValue !== undefined) {\n queryParamValues[argKey] = String(argValue);\n }\n }\n\n const queryString = new URLSearchParams(queryParamValues).toString();\n return `${withArgs}?${queryString}`;\n};\n","import unfetch from \"isomorphic-unfetch\";\n\n/**\n * Fetch an HTTP resource. This is publicly exposed in the\n * event you would like to access an endpoint that this\n * library does not currently support.\n *\n * UNLESS YOU'RE SURE OF WHAT YOU'RE DOING, YOU PROBABLY\n * SHOULDN'T USE THIS FUNCTION.\n *\n * 2022-10-09: At the time of writing, Node.js LTS (16.x)\n * does not yet support fetch. As a result, we pull in\n * isomorphic-unfetch for Node.js compatibility. Our support\n * matrix includes 14.x and 16.x.\n *\n * @FIXME - When Node.js 20.x is released, remove the\n * isomorphic-unfetch dependency. At that point we will have\n * two major LTS versions that include a native fetch API.\n */\nexport const call = async <\n T extends readonly any[] | Record<string, any>\n>(config: {\n url: string;\n}) => {\n const { url } = config;\n\n const rawResponse = await unfetch(url);\n return (await rawResponse.json()) as T;\n};\n","/* eslint-disable sonarjs/cognitive-complexity */\n/* eslint-disable sonarjs/prefer-immediate-return */\n\nexport const serializeProperties = (\n originalData: any,\n options: Partial<{\n shouldCastToNumbers: string[];\n shouldMapToBooleans: string[];\n }> = {}\n) => {\n const { shouldCastToNumbers, shouldMapToBooleans } = options;\n\n let returnValue = originalData;\n\n if (Array.isArray(originalData)) {\n const cleanedArray: any[] = [];\n\n for (const entity of originalData) {\n cleanedArray.push(serializeProperties(entity, options));\n }\n\n returnValue = cleanedArray;\n } else if (!Array.isArray(originalData) && originalData instanceof Object) {\n let cleanedObject: Record<string, any> = {};\n\n for (const [originalKey, originalValue] of Object.entries(originalData)) {\n let sanitizedValue = originalValue;\n if (shouldCastToNumbers?.includes(originalKey)) {\n sanitizedValue = originalValue === null ? null : Number(originalValue);\n }\n\n if (shouldMapToBooleans?.includes(originalKey)) {\n if (originalValue === null) {\n sanitizedValue = null;\n } else {\n sanitizedValue = originalValue === \"1\" ? true : false;\n }\n }\n\n cleanedObject = {\n ...cleanedObject,\n [naiveCamelCase(originalKey)]: serializeProperties(\n sanitizedValue,\n options\n )\n };\n }\n\n returnValue = cleanedObject;\n }\n\n return returnValue;\n};\n\nconst naiveCamelCase = (originalValue: string) => {\n // \"ID\" --> \"id\", \"URL\" --> \"url\"\n if (originalValue.toUpperCase() === originalValue) {\n return originalValue.toLowerCase();\n }\n\n // \"GameID\" -> \"gameID\"\n let camelCased =\n originalValue.charAt(0).toLowerCase() + originalValue.slice(1);\n\n // \"gameID\" -> \"gameId\"\n camelCased = camelCased.replace(/ID/g, \"Id\");\n\n // \"badgeURL\" --> \"badgeUrl\"\n camelCased = camelCased.replace(/URL/g, \"Url\");\n\n // \"rAPoints\" -> \"raPoints\"\n camelCased = camelCased.replace(/rA/g, \"ra\");\n\n return camelCased;\n};\n","export enum ClaimType {\n Primary = 0,\n Collaboration = 1\n}\n\nexport enum ClaimSetType {\n NewSet = 0,\n Revision = 1\n}\n\nexport enum ClaimStatus {\n Active = 0,\n Complete = 1,\n Dropped = 2\n}\n\nexport interface ActiveClaim {\n /** Unique ID of the claim. */\n id: number;\n\n /** User who made the claim. */\n user: string;\n\n /** ID of the claimed game. */\n gameId: number;\n\n /** Title of the claimed game. */\n gameTitle: string;\n\n /** Site-relative path of the game's icon image. */\n gameIcon: string;\n\n /** Console name of the claimed game. */\n consoleName: string;\n\n /** Whether the claim is primary or a collaboration. */\n claimType: ClaimType;\n\n /** Whether the claim is for a new set or a revision. */\n setType: ClaimSetType;\n\n /** Whether the claim is active, complete, or dropped. */\n status: ClaimStatus;\n\n /** Number of times the claim has been extended. */\n extension: number;\n\n /** Flag indicating a special type of claim. */\n special: number;\n\n /** Date the claim was made. */\n created: string;\n\n /**\n * Date the claim is done. This is an expiration\n * date for active claims, completion date for complete\n * claims, and dropped date for dropped claims.\n */\n doneTime: string;\n\n /** Date the claim was updated. */\n updated: string;\n\n /** Time in minutes left until the claim expires. */\n minutesLeft: number;\n}\n","export enum AchievementDistributionFlags {\n CoreAchievements = 3,\n UnofficialAchievements = 5\n}\n","// NOTE: This cannot be a true extension of the `GetGameResponse`\n// interface because the return types for many of these fields\n// are different from the actual RA API.\n\nenum GameExtendedClaimType {\n Primary = \"0\",\n Collaboration = \"1\"\n}\n\nexport interface GameExtendedRawAchievementEntity {\n ID: string;\n NumAwarded: string;\n NumAwardedHardcore: string;\n Title: string;\n Description: string;\n Points: string;\n TrueRatio: string;\n Author: string;\n DateModified: string;\n DateCreated: string;\n BadgeName: string;\n DisplayOrder: string;\n MemAddr: string;\n}\n\ninterface GameExtendedRawClaimEntity {\n User: string;\n SetType: string;\n ClaimType: GameExtendedClaimType;\n Created: string;\n Expiration: string;\n}\n\nexport interface GetGameExtendedResponse {\n ID: number;\n Title: string;\n ConsoleID: number;\n ForumTopicID: number;\n Flags: number;\n ImageIcon: string;\n ImageTitle: string;\n ImageIngame: string;\n ImageBoxArt: string;\n Publisher: string;\n Developer: string;\n Genre: string;\n Released: string;\n IsFinal: boolean;\n ConsoleName: string;\n RichPresencePatch: string;\n NumAchievements: number;\n NumDistinctPlayersCasual: string;\n NumDistinctPlayersHardcore: string;\n Claims: GameExtendedRawClaimEntity[];\n Achievements: Record<number, GameExtendedRawAchievementEntity> | [];\n}\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n AchievementTicketStats,\n GameTicketStats,\n MostTicketedGames,\n RecentTickets,\n TicketEntity,\n UserTicketStats\n} from \"./models\";\n\ninterface GetTicketDataAllPayloadValues {\n ticketId?: string | number;\n offset?: number;\n count?: number;\n isGettingMostTicketedGames?: true;\n userName?: string;\n gameId?: string | number;\n isGettingTicketsForUnofficialAchievements?: true;\n shouldReturnTicketsList?: true;\n achievementId?: string | number;\n}\n\n/**\n * BEGIN: Function overload definitions\n */\n\n/**\n * A call to this function will retrieve ticket metadata information\n * about a single achievement ticket, targeted by its ticket ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.ticketId The ID of the ticket to get information about.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(\n * authorization,\n * { ticketId: 12345 }\n * );\n * ```\n *\n * @returns An object containing metadata about a target ticket.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload: { ticketId: ID }\n): Promise<TicketEntity>;\n\n/**\n * A call to this function will retrieve ticket metadata information\n * about the latest opened achievement tickets on RetroAchievements.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.count Optional. Defaults to 10. Max is 100.\n * How many tickets to retrieve.\n *\n * @param payload.offset Optional. Defaults to 0.\n * Number of tickets to skip. This can be used for pagination.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(authorization);\n * ```\n *\n * @returns A list of the most recently opened tickets on the site.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload?: Partial<{ offset: number; count: number }>\n): Promise<RecentTickets>;\n\n/**\n * A call to this function will retrieve the games on the site with\n * the highest count of opened achievement tickets.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.count Optional. Defaults to 10. Max is 100.\n * How many ticketed games to retrieve.\n *\n * @param payload.offset Optional. Defaults to 0.\n * Number of games to skip. This can be used for pagination.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(\n * authorization,\n * { isGettingMostTicketedGames: true }\n * );\n * ```\n *\n * @returns A list of the most recently opened tickets on the site.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload: { isGettingMostTicketedGames: true; offset?: number; count?: number }\n): Promise<MostTicketedGames>;\n\n/**\n * A call to this function will retrieve an achievement developer's\n * ticket stats, targeted by that developer's username.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The developer's account username to retrieve\n * ticket stats for.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(\n * authorization,\n * { userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An achievement developer's ticket stats.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload: { userName: string }\n): Promise<UserTicketStats>;\n\n/**\n * A call to this function will retrieve a game's ticket stats, targeted\n * by the game's ID. If you are unsure of a game's ID, visit its page\n * on the RetroAchievements website and copy the number at the end of the URL.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The game ID to fetch ticket stats for.\n *\n * @param payload.isGettingTicketsForUnofficialAchievements Optional. Fetch stats\n * for unofficial/non-core achievements that have tickets.\n *\n * @param payload.shouldReturnTicketsList Optional. If true, not only fetches a\n * game's ticket stats, but also returns a list of tickets for the game.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(\n * authorization,\n * { gameId: 14_402 }\n * );\n * ```\n *\n * @returns A game's ticket stats, potentially also including the ticket list.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload: {\n gameId: ID;\n isGettingTicketsForUnofficialAchievements?: true;\n shouldReturnTicketsList?: true;\n }\n): Promise<GameTicketStats>;\n\n/**\n * A call to this function will retrieve the an achievement's\n * ticket stats, targeted by the achievement's ID. If you are unsure\n * of an achievement's ID, open its page on the RetroAchievements\n * website and copy the number at the end of the URL.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.achievementId The ID of the achievement to fetch ticket\n * stats for.\n *\n * @example\n * ```\n * const ticketData = await getTicketData(\n * authorization,\n * { achievementId: 12345 }\n * );\n * ```\n *\n * @returns An achievement developer's ticket stats.\n */\nexport function getTicketData(\n authorization: AuthObject,\n payload: { achievementId: ID }\n): Promise<AchievementTicketStats>;\n\n/**\n * END: Function overload definitions\n */\n\nexport async function getTicketData(\n authorization: AuthObject,\n payload: GetTicketDataAllPayloadValues = {}\n) {\n const queryParams = buildGetTicketDataQueryParams(payload);\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetTicketData.php\",\n authorization,\n queryParams\n );\n\n const rawResponse = await call({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"AchievementID\",\n \"Points\",\n \"GameID\",\n \"ReportType\",\n \"ReportState\",\n \"OpenTickets\"\n ],\n shouldMapToBooleans: [\"Hardcore\"]\n });\n}\n\nconst buildGetTicketDataQueryParams = (\n payload: GetTicketDataAllPayloadValues\n) => {\n const {\n ticketId,\n isGettingMostTicketedGames,\n userName,\n gameId,\n isGettingTicketsForUnofficialAchievements,\n shouldReturnTicketsList,\n achievementId\n } = payload;\n\n let queryParams: Record<string, string | number> = {};\n\n if (ticketId !== undefined) {\n queryParams[\"i\"] = ticketId;\n } else if (isGettingMostTicketedGames) {\n queryParams[\"f\"] = \"1\";\n queryParams = applyPaginationQueryParams(queryParams, payload);\n } else if (userName) {\n queryParams[\"u\"] = userName;\n } else if (gameId) {\n queryParams[\"g\"] = gameId;\n\n if (isGettingTicketsForUnofficialAchievements) {\n queryParams[\"f\"] = \"5\";\n }\n\n if (shouldReturnTicketsList) {\n queryParams[\"d\"] = \"1\";\n }\n } else if (achievementId) {\n queryParams[\"a\"] = achievementId;\n } else {\n queryParams = applyPaginationQueryParams(queryParams, payload);\n }\n\n return queryParams;\n};\n\nconst applyPaginationQueryParams = (\n currentParams: Record<string, string | number>,\n payload: Partial<{ count: number; offset: number }>\n) => {\n const modifiedParams = { ...currentParams };\n\n if (payload.count !== undefined) {\n modifiedParams[\"c\"] = payload.count;\n }\n\n if (payload.offset !== undefined) {\n modifiedParams[\"o\"] = payload.offset;\n }\n\n return modifiedParams;\n};\n","import type { AuthObject } from \"./models\";\n\n/**\n * Accepts your RetroAchievements.org username and web API key. After\n * receiving these inputs, the function returns you a value that can be\n * used for the authentication parameter by any of the async calls in this\n * library.\n *\n * Your account's personal Web API Key can be found on the Settings page\n * of RetroAchievements.org. Do not use a Web API Key that is not associated\n * with your account.\n *\n * @returns An `AuthObject` that you can pass to any of the API call functions.\n *\n * @example\n * ```\n * const authorization = buildAuthorization({\n * userName: \"Scott\",\n * webApiKey: \"LtjCwW16nJI7cqOyPIQtXk8v1cfF0tmO\"\n * });\n * ```\n */\nexport const buildAuthorization = (options: AuthObject): AuthObject => {\n if (!options.userName || !options.webApiKey) {\n 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 `);\n }\n\n return options;\n};\n\n// This function simply returns what it's given, however the return\n// value has the added benefit of type safety.\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { AchievementCount, GetAchievementCountResponse } from \"./models\";\n\n/**\n * A call to this function will retrieve the list of\n * achievement IDs for a game, targeted by game ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @example\n * ```\n * const achievementCount = await getAchievementCount(\n * authorization,\n * { gameId: 14402 }\n * );\n * ```\n *\n * @returns An object containing a gameId and a list of\n * achievementIds.\n * ```\n * { gameId: 14402, achievementIds: [1,2,3,4,5] }\n * ```\n */\nexport const getAchievementCount = async (\n authorization: AuthObject,\n payload: { gameId: ID }\n): Promise<AchievementCount> => {\n const { gameId } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementCount.php\",\n authorization,\n { i: gameId }\n );\n\n const rawResponse = await call<GetAchievementCountResponse>({ url });\n\n return serializeProperties(rawResponse);\n};\n","import type { ID } from \"../utils/internal\";\nimport { apiBaseUrl, buildRequestUrl, call } from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n AchievementDistributionFlags,\n GetAchievementDistributionResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve a dictionary\n * of the number of players who have earned a specific\n * number of achievements for a given game ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @param payload.flags Optional. By default, only official achievement\n * tallies are returned in the response. Import the `AchievementDistributionFlags`\n * enum for possible values. This lets you see the count of players who have\n * unlocked unofficial achievements.\n *\n * @param payload.hardcore Optional. By default, set to false, with both\n * softcore and hardcore tallies returned in the response. If this option\n * is set to true, only hardcore unlocks will be included in the totals.\n *\n * @example\n * ```\n * const achievementDistribution = await getAchievementDistribution(\n * authorization,\n * { gameId: 14402, hardcore: true }\n * );\n * ```\n *\n * @returns A dictionary where the keys represent the earned achievement\n * count and the values represent the number of players who have unlocked\n * that many achievements.\n * ```\n * {\n * '1': 64,\n * '2': 19,\n * '3': 11,\n * '4': 18,\n * '5': 25,\n * '6': 20,\n * '7': 26,\n * '8': 29,\n * '9': 54,\n * '10': 17,\n * '11': 29,\n * '12': 4\n * }\n * ```\n */\nexport const getAchievementDistribution = async (\n authorization: AuthObject,\n payload: {\n gameId: ID;\n flags?: AchievementDistributionFlags;\n hardcore?: boolean;\n }\n) => {\n const { gameId, flags, hardcore } = payload;\n\n const queryParams: Record<string, any> = { i: gameId };\n\n if (flags !== undefined) {\n queryParams[\"f\"] = flags;\n }\n\n if (hardcore !== undefined) {\n queryParams[\"h\"] = hardcore === true ? 1 : 0;\n }\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementDistribution.php\",\n authorization,\n queryParams\n );\n\n return await call<GetAchievementDistributionResponse>({\n url\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n AchievementOfTheWeek,\n GetAchievementOfTheWeekResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve comprehensive\n * metadata about the current Achievement of the Week.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @example\n * ```\n * const achievementOfTheWeek = await getAchievementOfTheWeek(\n * authorization\n * );\n * ```\n *\n * @returns An object containing comprehensive metadata\n * about the current Achievement of the Week.\n * ```\n * {\n * achievement: {\n * id: \"165062\",\n * title: \"The True Hero\",\n * description: \"Receive any Ending as Han [Normal or Hard]\",\n * points: \"10\",\n * trueRatio: \"22\",\n * author: \"BigWeedSmokerMan\",\n * dateCreated: \"2021-08-08 17:47:46\",\n * dateModified: \"2021-08-09 12:20:05\"\n * },\n * console: { id: \"39\", title: \"Saturn\" },\n * forumTopic: { id: \"14767\" },\n * game: { id: \"14513\", title: \"Guardian Heroes\" },\n * startAt: \"2022-10-10 00:00:00\",\n * totalPlayers: \"219\",\n * unlocks: [\n * {\n * user: \"Tirbaba2\",\n * rAPoints: \"72\",\n * dateAwarded: \"2022-10-10 01:42:19\",\n * hardcoreMode: \"1\"\n * }\n * ],\n * unlocksCount: \"40\"\n * }\n * ```\n */\nexport const getAchievementOfTheWeek = async (\n authorization: AuthObject\n): Promise<AchievementOfTheWeek> => {\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementOfTheWeek.php\",\n authorization\n );\n\n const rawResponse = await call<GetAchievementOfTheWeekResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"Points\",\n \"TrueRatio\",\n \"TotalPlayers\",\n \"RAPoints\",\n \"UnlocksCount\"\n ],\n shouldMapToBooleans: [\"HardcoreMode\"]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n AchievementUnlocksMetadata,\n GetAchievementUnlocksResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve a list of users who\n * have earned a given achievement, targeted by the achievement's ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.achievementId The target achievement we want to\n * retrieve the unlocks list for. If unknown, this can be found\n * by navigating to the achievement's page on the RetroAchievements.org\n * website. eg: https://retroachievements.org/achievement/13876 has an\n * ID of 13876.\n *\n * @param payload.offset Defaults to 0. The number of entries to skip.\n *\n * @param payload.count Defaults to 50, has a max of 500.\n *\n * @example\n * ```\n * const achievementUnlocks = await getAchievementUnlocks(\n * authorization,\n * { achievementId: 13876 }\n * );\n * ```\n *\n * @returns An array containing metadata about unlocks for\n * the target achievement.\n * ```\n * [\n * {\n * user: 'Podgicus0305',\n * raPoints: 15544,\n * dateAwarded: '2022-07-12 19:06:34',\n * hardcoreMode: true\n * }\n * ]\n * ```\n */\nexport const getAchievementUnlocks = async (\n authorization: AuthObject,\n payload: { achievementId: ID; offset?: number; count?: number }\n): Promise<AchievementUnlocksMetadata> => {\n const { achievementId, offset, count } = payload;\n\n const queryParams: Record<string, number | string> = { a: achievementId };\n\n if (offset) {\n queryParams.o = offset;\n }\n\n if (count) {\n queryParams.c = count;\n }\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementUnlocks.php\",\n authorization,\n queryParams\n );\n\n const rawResponse = await call<GetAchievementUnlocksResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"ID\", \"Points\", \"TrueRatio\", \"RAPoints\"],\n shouldMapToBooleans: [\"HardcoreMode\"]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n DatedUserAchievement,\n DatedUserAchievementsResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve a list of achievements\n * earned by a given user between two provided dates.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the\n * list of achievements for.\n *\n * @param payload.fromDate A Date object specifying when\n * the list itself should begin.\n *\n * @param payload.toDate A Date object specifying when\n * the list itself should end.\n *\n * @example\n * ```\n * const achievementsEarnedBetween = await getAchievementsEarnedBetween(\n * authorization,\n * {\n * userName: \"xelnia\",\n * fromDate: new Date(\"2022-10-12\"),\n * toDate: new Date(\"2022-10-13\")\n * }\n * );\n * ```\n *\n * @returns An array containing metadata about the user\n * achievements earned during the specified date range.\n * ```\n * [\n * {\n * date: '2022-10-12 07:58:05',\n * hardcoreMode: true,\n * achievementId: 173315,\n * title: 'Your Puny Human Weapons',\n * description: 'Collect all objects in the Weapons Category.',\n * badgeName: '193756',\n * points: 10,\n * author: 'blendedsea',\n * gameTitle: 'Me & My Katamari',\n * gameIcon: '/Images/047357.png',\n * gameId: 3571,\n * consoleName: 'PlayStation Portable',\n * cumulScore: 120,\n * badgeUrl: '/Badge/193756.png',\n * gameUrl: '/game/3571'\n * }\n * ]\n * ```\n */\nexport const getAchievementsEarnedBetween = async (\n authorization: AuthObject,\n payload: { userName: string; fromDate: Date; toDate: Date }\n): Promise<DatedUserAchievement[]> => {\n const { userName, fromDate, toDate } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementsEarnedBetween.php\",\n authorization,\n {\n u: userName,\n f: (fromDate.getTime() / 1000).toFixed(0),\n t: (toDate.getTime() / 1000).toFixed(0)\n }\n );\n\n const rawResponse = await call<DatedUserAchievementsResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"AchievementID\", \"Points\", \"GameID\"],\n shouldMapToBooleans: [\"HardcoreMode\"]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n DatedUserAchievement,\n DatedUserAchievementsResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve a list of achievements\n * earned by a given user on a specified date.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the\n * list of achievements for.\n *\n * @param payload.fromDate A Date object specifying when\n * the list itself should begin.\n *\n * @param payload.onDate A Date object specifying the day\n * to query for a user's earned achievements.\n *\n * @example\n * ```\n * const achievementsEarnedOnDay = await getAchievementsEarnedOnDay(\n * authorization,\n * {\n * userName: \"xelnia\",\n * onDate: new Date(\"2022-10-13\")\n * }\n * );\n * ```\n *\n * @returns An array containing metadata about the user\n * achievements earned on the specified day.\n * ```\n * [\n * {\n * date: '2022-10-12 07:58:05',\n * hardcoreMode: true,\n * achievementId: 173315,\n * title: 'Your Puny Human Weapons',\n * description: 'Collect all objects in the Weapons Category.',\n * badgeName: '193756',\n * points: 10,\n * author: 'blendedsea',\n * gameTitle: 'Me & My Katamari',\n * gameIcon: '/Images/047357.png',\n * gameId: 3571,\n * consoleName: 'PlayStation Portable',\n * cumulScore: 120,\n * badgeUrl: '/Badge/193756.png',\n * gameUrl: '/game/3571'\n * }\n * ]\n * ```\n */\nexport const getAchievementsEarnedOnDay = async (\n authorization: AuthObject,\n payload: { userName: string; onDate: Date }\n): Promise<DatedUserAchievement[]> => {\n const { userName, onDate } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetAchievementsEarnedOnDay.php\",\n authorization,\n {\n u: userName,\n // YYYY-MM-DD\n d: `${onDate.getFullYear()}-${onDate.getMonth() + 1}-${onDate.getDate()}`\n }\n );\n\n const rawResponse = await call<DatedUserAchievementsResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"AchievementID\", \"Points\", \"GameID\"],\n shouldMapToBooleans: [\"HardcoreMode\"]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { ActiveClaim, GetActiveClaimsResponse } from \"./models\";\n\n/**\n * A call to this function returns information about all\n * (1000 max) active set claims.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @example\n * ```\n * const activeClaims = await getActiveClaims(authorization);\n * ```\n *\n * @returns An array containing metadata about all active claims.\n * ```\n * [\n * {\n * id: 7044,\n * user: \"blendedsea\",\n * gameId: 19212,\n * gameTitle: \"SpongeBob SquarePants: Battle for Bikini Bottom\",\n * gameIcon: \"/Images/059776.png\",\n * consoleName: \"PlayStation 2\",\n * claimType: 0,\n * setType: 0,\n * status: 0,\n * extension: 0,\n * special: 0,\n * created: \"2022-10-04 00:25:06\",\n * doneTime: \"2023-01-04 00:25:06\",\n * updated: \"2022-10-04 00:25:06\",\n * minutesLeft: 112523\n * }\n * ]\n * ```\n */\nexport const getActiveClaims = async (\n authorization: AuthObject\n): Promise<ActiveClaim[]> => {\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetActiveClaims.php\",\n authorization\n );\n\n const rawResponse = await call<GetActiveClaimsResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"GameID\",\n \"ClaimType\",\n \"SetType\",\n \"Status\",\n \"Extension\",\n \"Special\",\n \"MinutesLeft\"\n ]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { ConsoleId, GetConsoleIdsResponse } from \"./models\";\n\n/**\n * A call to this function will retrieve the complete list\n * of console ID and name pairs on the RetroAchievements.org\n * platform.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @example\n * ```\n * const consoleIds = await getConsoleIds(authorization);\n * ```\n *\n * @returns An array containing a complete list of console ID\n * and name pairs for RetroAchievements.org.\n * ```\n * { id: \"1\", name: \"Mega Drive\" }\n * ```\n */\nexport const getConsoleIds = async (\n authorization: AuthObject\n): Promise<ConsoleId[]> => {\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetConsoleIDs.php\",\n authorization\n );\n\n const rawResponse = await call<GetConsoleIdsResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"ID\"]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { Game, GetGameResponse } from \"./models\";\n\n/**\n * A call to this function will retrieve basic metadata about\n * a game, targeted via its unique ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @example\n * ```\n * const game = await getGame(\n * authorization,\n * { gameId: 14402 }\n * );\n * ```\n *\n * @returns An object containing basic metadata about a target game.\n * ```json\n * {\n * id: 14402,\n * title: \"Dragster\",\n * forumTopicId: 9145,\n * consoleId: 25,\n * consoleName: \"Atari 2600\",\n * flags: 0,\n * imageIcon: \"/Images/026368.png\",\n * gameIcon: \"/Images/026368.png\",\n * imageTitle: \"/Images/026366.png\",\n * imageIngame: \"/Images/026367.png\",\n * imageBoxArt: \"/Images/026365.png\",\n * publisher: \"Activision\",\n * developer: \"David Crane\",\n * genre: \"Racing\",\n * released: 1980,\n * gameTitle: \"Dragster\",\n * console: \"Atari 2600\"\n * }\n * ```\n */\nexport const getGame = async (\n authorization: AuthObject,\n payload: { gameId: ID }\n): Promise<Game> => {\n const { gameId } = payload;\n\n const url = buildRequestUrl(apiBaseUrl, \"/API_GetGame.php\", authorization, {\n i: gameId\n });\n\n const rawResponse = await call<GetGameResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"ForumTopicID\",\n \"ConsoleID\",\n \"Flags\",\n \"Released\"\n ]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GameExtended, GetGameExtendedResponse } from \"./models\";\n\n/**\n * A call to this function will retrieve extended metadata\n * about a game, targeted via its unique ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @example\n * ```\n * const gameExtended = await getGameExtended(\n * authorization,\n * { gameId: 14402 }\n * );\n * ```\n *\n * @returns An object containing extended metadata about a target game.\n * ```json\n * {\n * id: 14402,\n * title: \"Dragster\",\n * consoleId: 25,\n * forumTopicId: 9145,\n * flags: 0,\n * imageIcon: \"/Images/026368.png\",\n * imageTitle: \"/Images/026366.png\",\n * imageIngame: \"/Images/026367.png\",\n * imageBoxArt: \"/Images/026365.png\",\n * publisher: \"Activision\",\n * developer: \"David Crane\",\n * genre: \"Racing\",\n * released: 1980,\n * isFinal: false,\n * consoleName: \"Atari 2600\",\n * richPresencePatch: \"2b92fa1bf9635c303b3b7f8feea3ed3c\",\n * numAchievements: 12,\n * numDistinctPlayersCasual: 454,\n * numDistinctPlayersHardcore: 323,\n * claims: [],\n * achievements: {\n * '79434': {\n * id: 79434,\n * numAwarded: 338,\n * numAwardedHardcore: 253,\n * title: \"Novice Dragster Driver 1\",\n * description: \"Complete your very first race in game 1.\",\n * points: 1,\n * trueRatio: 1,\n * author: \"Boldewin\",\n * dateModified: \"2019-08-01 19:03:46\",\n * dateCreated: \"2019-07-31 18:49:57\",\n * badgeName: \"85541\",\n * displayOrder: 0,\n * memAddr: \"f5c41fa0b5fa0d5fbb8a74c598f18582\"\n * }\n * }\n * }\n * ```\n */\nexport const getGameExtended = async (\n authorization: AuthObject,\n payload: { gameId: ID }\n): Promise<GameExtended> => {\n const { gameId } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetGameExtended.php\",\n authorization,\n {\n i: gameId\n }\n );\n\n const rawResponse = await call<GetGameExtendedResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"NumAwarded\",\n \"NumAwardedHardcore\",\n \"Points\",\n \"TrueRatio\",\n \"DisplayOrder\",\n \"NumDistinctPlayersCasual\",\n \"NumDistinctPlayersHardcore\",\n \"Released\"\n ]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GameInfoAndUserProgress,\n GetGameInfoAndUserProgressResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve extended metadata\n * about a game, in addition to a user's progress about a game.\n * This is targeted via a game's unique ID and a given username.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @param payload.userName The user for which to retrieve the\n * game progress for.\n *\n * @example\n * ```\n * const gameInfoAndUserProgress = await getGameInfoAndUserProgress(\n * authorization,\n * { gameId: 14402, userName: \"wv_pinball\" }\n * );\n * ```\n *\n * @returns An object containing extended metadata about a target game,\n * with attached progress for a target username.\n * ```json\n * {\n * id: 14402,\n * title: \"Dragster\",\n * consoleId: 25,\n * forumTopicId: 9145,\n * flags: 0,\n * imageIcon: \"/Images/026368.png\",\n * imageTitle: \"/Images/026366.png\",\n * imageIngame: \"/Images/026367.png\",\n * imageBoxArt: \"/Images/026365.png\",\n * publisher: \"Activision\",\n * developer: \"David Crane\",\n * genre: \"Racing\",\n * released: 1980,\n * isFinal: false,\n * consoleName: \"Atari 2600\",\n * richPresencePatch: \"2b92fa1bf9635c303b3b7f8feea3ed3c\",\n * numAchievements: 12,\n * numDistinctPlayersCasual: 454,\n * numDistinctPlayersHardcore, 323\n * claims: [],\n * achievements: {\n * '79434': {\n * id: 79434,\n * numAwarded: 338,\n * numAwardedHardcore: 253,\n * title: \"Novice Dragster Driver 1\",\n * description: \"Complete your very first race in game 1.\",\n * points: 1,\n * trueRatio: 1,\n * author: \"Boldewin\",\n * dateModified: \"2019-08-01 19:03:46\",\n * dateCreated: \"2019-07-31 18:49:57\",\n * badgeName: \"85541\",\n * displayOrder: 0,\n * memAddr: \"f5c41fa0b5fa0d5fbb8a74c598f18582\",\n * dateEarned: '2022-08-23 22:56:38',\n * dateEarnedHardcore: '2022-08-23 22:56:38'\n * }\n * },\n * numAwardedToUser: 12,\n * numAwardedToUserHardcore: 12,\n * userCompletion: \"100.00%\",\n * userCompletionHardcore: \"100.00%\"\n * }\n * ```\n */\nexport const getGameInfoAndUserProgress = async (\n authorization: AuthObject,\n payload: { gameId: ID; userName: string }\n): Promise<GameInfoAndUserProgress> => {\n const { gameId, userName } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetGameInfoAndUserProgress.php\",\n authorization,\n {\n g: gameId,\n u: userName\n }\n );\n\n const rawResponse = await call<GetGameInfoAndUserProgressResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"NumAwarded\",\n \"NumAwardedHardcore\",\n \"Points\",\n \"TrueRatio\",\n \"DisplayOrder\",\n \"NumDistinctPlayersCasual\",\n \"NumDistinctPlayersHardcore\",\n \"Released\"\n ]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GameList, GetGameListResponse } from \"./models\";\n/**\n * A call to this function will retrieve the complete list\n * of games for a specified console on the RetroAchievements.org\n * platform.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.consoleId The unique console ID to retrieve a list of\n * games from. The list of consoleIds can be retrieved using the `getConsoleIds()`\n * function provided by this library.\n *\n * @param payload.shouldOnlyRetrieveGamesWithAchievements If truthy, will not\n * return games that do not have achievements.\n *\n * @param payload.shouldRetrieveGameHashes If truthy, will return valid\n * hashes for game ROMs in an array attached to each game in the list.\n *\n * @example\n * ```\n * const gameList = await getGameList(\n * authorization,\n * { consoleId: 1, shouldOnlyRetrieveGamesWithAchievements: true }\n * );\n * ```\n *\n * @returns An array containing a list of games for a given consoleId.\n * ```\n * [\n * {\n * title: \"Elemental Master\",\n * id: 4247,\n * consoleId: 1,\n * consoleName: \"Mega Drive\",\n * imageIcon: \"/Images/048245.png\",\n * numAchievements: 44,\n * numLeaderboards: 0,\n * points: 500,\n * dateModified: \"2021-12-09 17:05:39\",\n * forumTopicId: 1972,\n * hashes: [\"32e1a15161ef1f070b023738353bde51\"]\n * }\n * ]\n * ```\n */\nexport const getGameList = async (\n authorization: AuthObject,\n payload: {\n consoleId: ID;\n shouldOnlyRetrieveGamesWithAchievements?: boolean;\n shouldRetrieveGameHashes?: boolean;\n }\n): Promise<GameList> => {\n const {\n consoleId,\n shouldOnlyRetrieveGamesWithAchievements,\n shouldRetrieveGameHashes\n } = payload;\n\n let callPayload: Record<string, any> = { i: consoleId };\n\n if (shouldOnlyRetrieveGamesWithAchievements !== undefined) {\n callPayload = {\n ...callPayload,\n f: shouldOnlyRetrieveGamesWithAchievements ? 1 : 0\n };\n }\n\n if (shouldRetrieveGameHashes) {\n callPayload = { ...callPayload, h: shouldRetrieveGameHashes ? 1 : 0 };\n }\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetGameList.php\",\n authorization,\n callPayload\n );\n\n const rawResponse = await call<GetGameListResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"ID\", \"ConsoleID\"]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GameRankAndScoreEntity,\n GetGameRankAndScoreResponse\n} from \"./models\";\n\n/**\n * A call to this function will retrieve metadata about\n * either the latest masters for a game, or the highest\n * points earners for a game. The game is targeted via\n * its unique ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @param payload.type Can either be \"latest-masters\" or \"high-scores\".\n *\n * @example\n * ```\n * const gameRankAndScore = await getGameRankAndScore(\n * authorization,\n * { gameId: 14402, type: \"latest-masters\" }\n * );\n * ```\n *\n * @returns An array containing a list of latest masters or\n * high score earners for a given game ID.\n * ```json\n * [\n * { user: 'Arekdias', totalScore: 189, lastAward: '2020-10-10 22:43:32' }\n * ]\n * ```\n */\nexport const getGameRankAndScore = async (\n authorization: AuthObject,\n payload: { gameId: ID; type: \"latest-masters\" | \"high-scores\" }\n): Promise<GameRankAndScoreEntity[]> => {\n const { gameId, type } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetGameRankAndScore.php\",\n authorization,\n {\n g: gameId,\n t: type === \"latest-masters\" ? 1 : 0\n }\n );\n\n const rawResponse = await call<GetGameRankAndScoreResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"TotalScore\"]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GameRating, GetGameRatingResponse } from \"./models\";\n\n/**\n * A call to this function will retrieve metadata about\n * how users have rated the game and its set.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @example\n * ```\n * const gameRating = await getGameRating(\n * authorization,\n * { gameId: 14402 }\n * );\n * ```\n *\n * @returns An object with game rating metadata.\n * ```json\n * {\n * gameId: 14402,\n * ratings: {\n * game: 3.1875,\n * achievements: 0,\n * gameNumVotes: 16,\n * achievementsNumVotes: 0\n * }\n * }\n * ```\n */\nexport const getGameRating = async (\n authorization: AuthObject,\n payload: { gameId: ID }\n): Promise<GameRating> => {\n const { gameId } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetGameRating.php\",\n authorization,\n { i: gameId }\n );\n\n const rawResponse = await call<GetGameRatingResponse>({ url });\n\n return serializeProperties(rawResponse);\n};\n","import { apiBaseUrl, buildRequestUrl, call } from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GetTopTenUsersResponse,\n TopTenUsers,\n TopTenUsersEntity\n} from \"./models\";\n\n/**\n * A call to this function will retrieve the current top ten users\n * on the site.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @example\n * ```\n * const topTenUsers = await getTopTenUsers(authorization);\n * ```\n *\n * @returns An array containing the list of top ten users.\n * ```json\n * [\n * { userName: \"MockUser\", totalPoints: 350000, totalRatioPoints: 995000 },\n * { userName: \"MockUser2\", totalPoints: 345000, totalRatioPoints: 994000 },\n * // ...\n * ]\n * ```\n */\nexport const getTopTenUsers = async (\n authorization: AuthObject\n): Promise<TopTenUsers> => {\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetTopTenUsers.php\",\n authorization\n );\n\n const rawTopTenUsers = await call<GetTopTenUsersResponse>({ url });\n\n const sanitizedTopTenUsers: TopTenUsersEntity[] = [];\n for (const rawUser of rawTopTenUsers) {\n sanitizedTopTenUsers.push({\n userName: rawUser[\"1\"],\n totalPoints: Number(rawUser[\"2\"]),\n totalRatioPoints: Number(rawUser[\"3\"])\n });\n }\n\n return sanitizedTopTenUsers;\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GetUserClaimsResponse, UserClaims } from \"./models\";\n\n/**\n * A call to this function will retrieve a list of\n * achievement set claims made over the lifetime of a given\n * user, targeted by their username.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the historical\n * achievement set claims list for.\n *\n * @example\n * ```\n * const userClaims = await getUserClaims(\n * authorization,\n * { userName: \"Jamiras\" }\n * );\n * ```\n *\n * @returns An array containing all the achievement set claims\n * made over the lifetime of the given user.\n */\nexport const getUserClaims = async (\n authorization: AuthObject,\n payload: { userName: string }\n): Promise<UserClaims> => {\n const { userName } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserClaims.php\",\n authorization,\n { u: userName }\n );\n\n const rawResponse = await call<GetUserClaimsResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"ID\",\n \"GameID\",\n \"ClaimType\",\n \"SetType\",\n \"Status\",\n \"Extension\",\n \"Special\",\n \"MinutesLeft\"\n ]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GetUserCompletedGamesResponse,\n UserCompletedGames\n} from \"./models\";\n\n/**\n * A call to this function will retrieve completion metadata\n * about the games a given user has played. It returns two\n * entries per each game: one for the softcore completion and\n * one for the hardcore completion. These are designated by\n * the `hardcoreMode` property on each completion object.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the\n * completion metadata for.\n *\n * @example\n * ```\n * const userCompletedGames = await getUserCompletedGames(\n * authorization,\n * { userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An array containing completion metadata objects\n * for a given user. Each game contains two completion records,\n * one for softcore and another for hardcore.\n * ```json\n * [\n * {\n * gameId: 14976,\n * title: 'Mortal Kombat',\n * imageIcon: '/Images/036812.png',\n * consoleId: 27,\n * consoleName: 'Arcade',\n * maxPossible: 35,\n * numAwarded: 13,\n * pctWon: 0.3714,\n * hardcoreMode: false\n * },\n * {\n * gameId: 14976,\n * title: 'Mortal Kombat',\n * imageIcon: '/Images/036812.png',\n * consoleId: 27,\n * consoleName: 'Arcade',\n * maxPossible: 35,\n * numAwarded: 13,\n * pctWon: 0.3714,\n * hardcoreMode: true\n * },\n * ]\n * ```\n */\nexport const getUserCompletedGames = async (\n authorization: AuthObject,\n payload: { userName: string }\n): Promise<UserCompletedGames> => {\n const { userName } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserCompletedGames.php\",\n authorization,\n { u: userName }\n );\n\n const rawResponse = await call<GetUserCompletedGamesResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"GameID\",\n \"ConsoleID\",\n \"MaxPossible\",\n \"NumAwarded\",\n \"PctWon\"\n ],\n shouldMapToBooleans: [\"HardcoreMode\"]\n });\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GetUserGameRankAndScoreResponse,\n UserGameRankAndScore\n} from \"./models\";\n\n/**\n * A call to this function will retrieve metadata about\n * how a particular user has performed/ranked on a particular\n * game, targeted by game ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.gameId The unique game ID. If you are unsure, open the\n * game's page on the RetroAchievements.org website. For example, Dragster's\n * URL is https://retroachievements.org/game/14402. We can see from the\n * URL that the game ID is \"14402\".\n *\n * @param payload.userName The user for which to retrieve the\n * game ranking metadata for.\n *\n * @example\n * ```\n * const userGameRankAndScore = await getUserGameRankAndScore(\n * authorization,\n * { gameId: 14402, userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An array containing metadata about the user's\n * rank and score for the target game ID. If metadata\n * cannot be found, the array is empty.\n * ```json\n * [\n * {\n * user: \"xelnia\",\n * totalScore: 378,\n * lastAward: \"2022-09-01 21:51:23\",\n * userRank: 3\n * }\n * ]\n * ```\n */\nexport const getUserGameRankAndScore = async (\n authorization: AuthObject,\n payload: { gameId: ID; userName: string }\n): Promise<UserGameRankAndScore> => {\n const { gameId, userName } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserGameRankAndScore.php\",\n authorization,\n { g: gameId, u: userName }\n );\n\n const rawResponse = await call<GetUserGameRankAndScoreResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\"TotalScore\", \"UserRank\"]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GetUserPointsResponse, UserPoints } from \"./models\";\n\n/**\n * A call to this function will retrieve a given user's hardcore\n * and softcore points.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the point totals for.\n *\n * @example\n * ```\n * const userPoints = await getUserPoints(\n * authorization,\n * { userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An object containing metadata about a target user's points.\n * ```json\n * {\n * points: 7640,\n * softcorePoints: 25\n * }\n * ```\n */\nexport const getUserPoints = async (\n authorization: AuthObject,\n payload: { userName: string }\n): Promise<UserPoints> => {\n const { userName } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserPoints.php\",\n authorization,\n { u: userName }\n );\n\n const rawResponse = await call<GetUserPointsResponse>({ url });\n\n return serializeProperties(rawResponse);\n};\n","import type { ID } from \"../utils/internal\";\nimport {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GetUserProgressResponse, UserProgress } from \"./models\";\n\n/**\n * A call to this function will retrieve a given user's\n * progress on a given list of games, targeted by game ID.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the progress for.\n *\n * @param payload.gameIds An array of RetroAchievements game IDs. If you aren't\n * sure of the game ID, visit the game's page on the website and copy the number\n * at the end of the URL.\n *\n * @example\n * ```\n * const userProgress = await getUserProgress(\n * authorization,\n * { userName: \"xelnia\", gameIds: [1, 14402] }\n * );\n * ```\n *\n * @returns An object which is a map of summarized progress for games.\n * ```json\n * {\n * \"1\": {\n * numPossibleAchievements: 24,\n * possibleScore: 255,\n * numAchieved: 0,\n * scoreAchieved: 0,\n * numAchievedHardcore: 0,\n * scoreAchievedHardcore: 0\n * },\n * \"14402\": {\n * numPossibleAchievements: 24,\n * possibleScore: 255,\n * numAchieved: 0,\n * scoreAchieved: 0,\n * numAchievedHardcore: 0,\n * scoreAchievedHardcore: 0\n * }\n * }\n * ```\n */\nexport const getUserProgress = async (\n authorization: AuthObject,\n payload: { userName: string; gameIds: ID[] }\n): Promise<UserProgress> => {\n const { userName, gameIds } = payload;\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserProgress.php\",\n authorization,\n { u: userName, i: gameIds.join(\",\") }\n );\n\n const rawResponse = await call<GetUserProgressResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"NumPossibleAchievements\",\n \"PossibleScore\",\n \"NumAchieved\",\n \"ScoreAchieved\",\n \"NumAchievedHardcore\",\n \"ScoreAchievedHardcore\"\n ]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type {\n GetUserRecentlyPlayedGamesResponse,\n UserRecentlyPlayedGames\n} from \"./models\";\n\n/**\n * A call to this function will retrieve a list of a target user's\n * recently played games, via their username.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the summary for.\n *\n * @param payload.count Optional. Defaults to 10. Max is 50. How many\n * recently played games for the user to retrieve.\n *\n * @param payload.offset Optional. Defaults to 0. Number of recently played\n * game entries to skip. This can be used for pagination.\n *\n * @example\n * ```\n * const userRecentlyPlayedGames = await getUserRecentlyPlayedGames(\n * authorization,\n * { userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An array containing metadata about a user's recently played games.\n * ```json\n * [\n * {\n * gameId: 19010,\n * consoleId: 21,\n * consoleName: \"PlayStation 2\",\n * title: \"Simpsons, The: Hit & Run\",\n * imageIcon: \"/Images/066024.png\",\n * lastPlayed: \"2022-10-24 22:05:12\",\n * numPossibleAchievements: 131,\n * possibleScore: 865,\n * numAchieved: 23,\n * scoreAchieved: 84,\n * numAchievedHardcore: 23,\n * scoreAchievedHardcore: 84\n * }\n * ]\n * ```\n */\nexport const getUserRecentlyPlayedGames = async (\n authorization: AuthObject,\n payload: { userName: string; offset?: number; count?: number }\n): Promise<UserRecentlyPlayedGames> => {\n const { userName, offset, count } = payload;\n\n const queryParams: Record<string, string | number> = { u: userName };\n\n if (offset !== undefined) {\n queryParams[\"o\"] = offset;\n }\n\n if (count !== undefined) {\n queryParams[\"c\"] = count;\n }\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserRecentlyPlayedGames.php\",\n authorization,\n queryParams\n );\n\n const rawResponse = await call<GetUserRecentlyPlayedGamesResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"GameID\",\n \"ConsoleID\",\n \"NumPossibleAchievements\",\n \"PossibleScore\",\n \"NumAchieved\",\n \"ScoreAchieved\",\n \"NumAchievedHardcore\",\n \"ScoreAchievedHardcore\",\n \"MyVote\"\n ]\n });\n};\n","import {\n apiBaseUrl,\n buildRequestUrl,\n call,\n serializeProperties\n} from \"../utils/internal\";\nimport type { AuthObject } from \"../utils/public\";\nimport type { GetUserSummaryResponse, UserSummary } from \"./models\";\n\n/**\n * A call to this function will retrieve summary information about\n * a given user, targeted by username.\n *\n * @param authorization An object containing your userName and webApiKey.\n * This can be constructed with `buildAuthorization()`.\n *\n * @param payload.userName The user for which to retrieve the summary for.\n *\n * @param payload.recentGamesCount Optional. The number of recent games to return.\n * This defaults to 5.\n *\n * @param payload.recentAchievementsCount Optional. The number of recent achievements\n * to return. This defaults to 5.\n *\n * @example\n * ```\n * const userSummary = await getUserSummary(\n * authorization,\n * { userName: \"xelnia\" }\n * );\n * ```\n *\n * @returns An object containing summary metadata about a target user.\n */\nexport const getUserSummary = async (\n authorization: AuthObject,\n payload: {\n userName: string;\n recentGamesCount?: number;\n recentAchievementsCount?: number;\n }\n): Promise<UserSummary> => {\n const { userName, recentGamesCount, recentAchievementsCount } = payload;\n\n const queryParams: Record<string, string | number> = { u: userName };\n\n if (recentGamesCount !== undefined) {\n queryParams[\"g\"] = recentGamesCount;\n }\n\n if (recentAchievementsCount !== undefined) {\n queryParams[\"a\"] = recentAchievementsCount;\n }\n\n const url = buildRequestUrl(\n apiBaseUrl,\n \"/API_GetUserSummary.php\",\n authorization,\n queryParams\n );\n\n const rawResponse = await call<GetUserSummaryResponse>({ url });\n\n return serializeProperties(rawResponse, {\n shouldCastToNumbers: [\n \"GameID\",\n \"ConsoleID\",\n \"ID\",\n \"LastGameID\",\n \"ForumTopicID\",\n \"activitytype\",\n \"ContribCount\",\n \"ContribYield\",\n \"TotalPoints\",\n \"TotalSoftcorePoints\",\n \"TotalTruePoints\",\n \"Permissions\",\n \"NumPossibleAchievements\",\n \"PossibleScore\",\n \"NumAchieved\",\n \"ScoreAchieved\",\n \"NumAchievedHardcore\",\n \"ScoreAchievedHardcore\",\n \"Points\",\n \"SoftcorePoints\"\n ],\n shouldMapToBooleans: [\n \"Untracked\",\n \"UserWallActive\",\n \"IsAwarded\",\n \"HardcoreAchieved\"\n ]\n });\n};\n\n// TODO: add test for this\n"],"names":["apiBaseUrl","buildRequestUrl","baseUrl","endpointUrl","authObject","args","withArgs","replace","queryParamValues","z","userName","y","webApiKey","_i","_Object$entries","Object","entries","length","_Object$entries$_i","argKey","argValue","includes","String","undefined","URLSearchParams","toString","call","config","unfetch","url","rawResponse","json","e","Promise","reject","serializeProperties","ClaimType","ClaimSetType","ClaimStatus","AchievementDistributionFlags","GameExtendedClaimType","originalData","options","shouldCastToNumbers","shouldMapToBooleans","returnValue","Array","isArray","_step","cleanedArray","_iterator","_createForOfIteratorHelperLoose","done","push","cleanedObject","_extends2","originalKey","originalValue","sanitizedValue","Number","_extends","naiveCamelCase","toUpperCase","toLowerCase","camelCased","charAt","slice","getTicketData","applyPaginationQueryParams","currentParams","payload","count","modifiedParams","offset","Error","getAchievementCount","authorization","i","gameId","then","flags","hardcore","queryParams","resolve","getAchievementUnlocks","a","achievementId","o","c","toDate","u","f","fromDate","getTime","toFixed","t","onDate","d","getFullYear","getMonth","getDate","getGameExtended","g","shouldOnlyRetrieveGamesWithAchievements","shouldRetrieveGameHashes","callPayload","consoleId","h","getGameRankAndScore","type","getGameRating","ticketId","isGettingMostTicketedGames","isGettingTicketsForUnofficialAchievements","shouldReturnTicketsList","buildGetTicketDataQueryParams","rawTopTenUsers","sanitizedTopTenUsers","rawUser","value","totalPoints","totalRatioPoints","getUserPoints","gameIds","join","recentGamesCount","recentAchievementsCount"],"mappings":"4HAAuBA,EAAG,oCCEbC,EAAkB,SAC7BC,EACAC,EACAC,EACAC,QAAwC,IAAxCA,IAAAA,EAAwC,CAAE,GAc1C,IAZA,IAGYC,GAHYJ,EAAO,IAAIC,GACOI,QAAQ,eAAgB,MAM5CC,EAA2B,CAC/CC,EAAGL,EAAWM,SACdC,EAAGP,EAAWQ,WAGhBC,EAAA,EAAAC,EAAiCC,OAAOC,QAAQX,GAAKQ,EAAAC,EAAAG,OAAAJ,IAAE,CAAlD,IAAAK,EAAAJ,EAAAD,GAAOM,EAAMD,EAAA,GAAEE,EAAQF,EAAA,GAEtBZ,EAASe,aAAaF,GACxBb,EAAWA,EAASC,QAAO,IAAKY,EAAUG,OAAOF,SAC3BG,IAAbH,IACTZ,EAAiBW,GAAUG,OAAOF,GAErC,CAGD,OAAkBd,EAAA,IADE,IAAmBkB,gBAAChB,GAAkBiB,UAE5D,ECZaC,EAAAA,SAEXC,GAEG,IACoB,OAEGC,QAAAA,QAAAA,EAAAA,QAFVD,EAARE,MAEFC,KAAAA,SAAAA,0BACQA,EAAYC,SAC3B,CAAA,MAAAC,GAAA,OAAAC,QAAAC,OAAAF,EAAA,CAAA,4hCCzBYG,ICHDC,EAKAC,EAKAC,ECVAC,ECOXC,EHJYL,EAAsB,SAAHA,EAC9BM,EACAC,YAAAA,IAAAA,EAGK,CAAA,GAEL,IAAQC,EAA6CD,EAA7CC,oBAAqBC,EAAwBF,EAAxBE,oBAEdC,EAAGJ,EAElB,GAAIK,MAAMC,QAAQN,GAAe,CAG/B,IAFA,IAEiCO,EAFfC,EAAU,GAE5BC,EAA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,wBAE9B5C,EAA+C,CAAEQ,EAFSpB,EAAxD5D,eAIiBa,IAArBsG,IACF3C,EAAe,EAAI2C,QAGWtG,IAA5BuG,IACF5C,EAAe,EAAI4C,GAGrB,MAAY7H,EACVD,EACA,0BACA4E,EACAM,GACA,uBAEwBxD,EAA6B,CAAEG,IAAAA,KAAnDC,KAAAA,SAAAA,GAEN,OAAOK,EAAoBL,EAAa,CACtCa,oBAAqB,CACnB,SACA,YACA,KACA,aACA,eACA,eACA,eACA,eACA,cACA,sBACA,kBACA,cACA,0BACA,gBACA,cACA,gBACA,sBACA,wBACA,SACA,kBAEFC,oBAAqB,CACnB,YACA,iBACA,YACA,qBAED,EACJ,CAAA,MAAAZ,GAAA,OAAAC,QAAAC,OAAAF,EAAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ import e from"isomorphic-unfetch";const t="https://retroachievements.org/API",o=(e,t,o,s={})=>{let r=`${e}/${t}`.replace(/([^:]\/)\/+/g,"$1");const a={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&&(a[e]=String(t));return`${r}?${new URLSearchParams(a).toString()}`},s=async t=>{const{url:o}=t,s=await e(o);return await s.json()};function r(){return r=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},r.apply(this,arguments)}const a=(e,t={})=>{const{shouldCastToNumbers:o,shouldMapToBooleans:s}=t;let i=e;if(Array.isArray(e)){const o=[];for(const s of e)o.push(a(s,t));i=o}else if(!Array.isArray(e)&&e instanceof Object){let u={};for(const[i,c]of Object.entries(e)){let e=c;null!=o&&o.includes(i)&&(e=null===c?null:Number(c)),null!=s&&s.includes(i)&&(e=null===c?null:"1"===c),u=r({},u,{[n(i)]:a(e,t)})}i=u}return i},n=e=>{if(e.toUpperCase()===e)return e.toLowerCase();let t=e.charAt(0).toLowerCase()+e.slice(1);return t=t.replace(/ID/g,"Id"),t=t.replace(/URL/g,"Url"),t=t.replace(/rA/g,"ra"),t},i=async(e,r)=>{const{achievementId:n,offset:i,count:u}=r,c={a:n};i&&(c.o=i),u&&(c.c=u);const l=o(t,"/API_GetAchievementUnlocks.php",e,c),m=await s({url:l});return a(m,{shouldCastToNumbers:["ID","Points","TrueRatio","RAPoints"],shouldMapToBooleans:["HardcoreMode"]})},u=async e=>{const r=o(t,"/API_GetConsoleIDs.php",e),n=await s({url:r});return a(n,{shouldCastToNumbers:["ID"]})},c=async(e,n)=>{const{consoleId:i,shouldOnlyRetrieveGamesWithAchievements:u,shouldRetrieveGameHashes:c}=n;let l={i};void 0!==u&&(l=r({},l,{f:u?1:0})),c&&(l=r({},l,{h:c?1:0}));const m=o(t,"/API_GetGameList.php",e,l),d=await s({url:m});return a(d,{shouldCastToNumbers:["ID","ConsoleID"]})},l=async e=>{const r=o(t,"/API_GetAchievementOfTheWeek.php",e),n=await s({url:r});return a(n,{shouldCastToNumbers:["ID","Points","TrueRatio","TotalPlayers","RAPoints","UnlocksCount"],shouldMapToBooleans:["HardcoreMode"]})},m=async e=>{const r=o(t,"/API_GetActiveClaims.php",e),n=await s({url:r});return a(n,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})},d=async e=>{const r=o(t,"/API_GetTopTenUsers.php",e),a=await s({url:r}),n=[];for(const e of a)n.push({userName:e[1],totalPoints:Number(e[2]),totalRatioPoints:Number(e[3])});return n};var h,p,A;!function(e){e[e.Primary=0]="Primary",e[e.Collaboration=1]="Collaboration"}(h||(h={})),function(e){e[e.NewSet=0]="NewSet",e[e.Revision=1]="Revision"}(p||(p={})),function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Dropped=2]="Dropped"}(A||(A={}));const I=async(e,r)=>{const{gameId:n}=r,i=o(t,"/API_GetAchievementCount.php",e,{i:n}),u=await s({url:i});return a(u)},y=async(e,r)=>{const{gameId:a,flags:n,hardcore:i}=r,u={i:a};void 0!==n&&(u.f=n),void 0!==i&&(u.h=!0===i?1:0);const c=o(t,"/API_GetAchievementDistribution.php",e,u);return await s({url:c})},P=async(e,r)=>{const{gameId:n}=r,i=o(t,"/API_GetGame.php",e,{i:n}),u=await s({url:i});return a(u,{shouldCastToNumbers:["ID","ForumTopicID","ConsoleID","Flags","Released"]})},v=async(e,r)=>{const{gameId:n}=r,i=o(t,"/API_GetGameExtended.php",e,{i:n}),u=await s({url:i});return a(u,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore","Released"]})},N=async(e,r)=>{const{gameId:n,type:i}=r,u=o(t,"/API_GetGameRankAndScore.php",e,{g:n,t:"latest-masters"===i?1:0}),c=await s({url:u});return a(c,{shouldCastToNumbers:["TotalScore"]})},T=async(e,r)=>{const{gameId:n}=r,i=o(t,"/API_GetGameRating.php",e,{i:n}),u=await s({url:i});return a(u)};var f,b;async function C(e,r={}){const n=D(r),i=o(t,"/API_GetTicketData.php",e,n),u=await s({url:i});return a(u,{shouldCastToNumbers:["ID","AchievementID","Points","GameID","ReportType","ReportState","OpenTickets"],shouldMapToBooleans:["Hardcore"]})}!function(e){e[e.CoreAchievements=3]="CoreAchievements",e[e.UnofficialAchievements=5]="UnofficialAchievements"}(f||(f={})),function(e){e.Primary="0",e.Collaboration="1"}(b||(b={}));const D=e=>{const{ticketId:t,isGettingMostTicketedGames:o,userName:s,gameId:r,isGettingTicketsForUnofficialAchievements:a,shouldReturnTicketsList:n,achievementId:i}=e;let u={};return void 0!==t?u.i=t:o?(u.f="1",u=G(u,e)):s?u.u=s:r?(u.g=r,a&&(u.f="5"),n&&(u.d="1")):i?u.a=i:u=G(u,e),u},G=(e,t)=>{const o=r({},e);return void 0!==t.count&&(o.c=t.count),void 0!==t.offset&&(o.o=t.offset),o},w=async(e,r)=>{const{userName:n,fromDate:i,toDate:u}=r,c=o(t,"/API_GetAchievementsEarnedBetween.php",e,{u:n,f:(i.getTime()/1e3).toFixed(0),t:(u.getTime()/1e3).toFixed(0)}),l=await s({url:c});return a(l,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},g=async(e,r)=>{const{userName:n,onDate:i}=r,u=o(t,"/API_GetAchievementsEarnedOnDay.php",e,{u:n,d:`${i.getFullYear()}-${i.getMonth()+1}-${i.getDate()}`}),c=await s({url:u});return a(c,{shouldCastToNumbers:["AchievementID","Points","GameID"],shouldMapToBooleans:["HardcoreMode"]})},S=async(e,r)=>{const{gameId:n,userName:i}=r,u=o(t,"/API_GetGameInfoAndUserProgress.php",e,{g:n,u:i}),c=await s({url:u});return a(c,{shouldCastToNumbers:["ID","NumAwarded","NumAwardedHardcore","Points","TrueRatio","DisplayOrder","NumDistinctPlayersCasual","NumDistinctPlayersHardcore","Released"]})},R=async(e,r)=>{const{userName:n}=r,i=o(t,"/API_GetUserClaims.php",e,{u:n}),u=await s({url:i});return a(u,{shouldCastToNumbers:["ID","GameID","ClaimType","SetType","Status","Extension","Special","MinutesLeft"]})},_=async(e,r)=>{const{userName:n}=r,i=o(t,"/API_GetUserCompletedGames.php",e,{u:n}),u=await s({url:i});return a(u,{shouldCastToNumbers:["GameID","ConsoleID","MaxPossible","NumAwarded","PctWon"],shouldMapToBooleans:["HardcoreMode"]})},U=async(e,r)=>{const{gameId:n,userName:i}=r,u=o(t,"/API_GetUserGameRankAndScore.php",e,{g:n,u:i}),c=await s({url:u});return a(c,{shouldCastToNumbers:["TotalScore","UserRank"]})},M=async(e,r)=>{const{userName:n}=r,i=o(t,"/API_GetUserPoints.php",e,{u:n}),u=await s({url:i});return a(u)},H=async(e,r)=>{const{userName:n,gameIds:i}=r,u=o(t,"/API_GetUserProgress.php",e,{u:n,i:i.join(",")}),c=await s({url:u});return a(c,{shouldCastToNumbers:["NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore"]})},k=async(e,r)=>{const{userName:n,offset:i,count:u}=r,c={u:n};void 0!==i&&(c.o=i),void 0!==u&&(c.c=u);const l=o(t,"/API_GetUserRecentlyPlayedGames.php",e,c),m=await s({url:l});return a(m,{shouldCastToNumbers:["GameID","ConsoleID","NumPossibleAchievements","PossibleScore","NumAchieved","ScoreAchieved","NumAchievedHardcore","ScoreAchievedHardcore","MyVote"]})},O=async(e,r)=>{const{userName:n,recentGamesCount:i,recentAchievementsCount:u}=r,c={u:n};void 0!==i&&(c.g=i),void 0!==u&&(c.a=u);const l=o(t,"/API_GetUserSummary.php",e,c),m=await s({url:l});return a(m,{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"]})},$=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{f as AchievementDistributionFlags,p as ClaimSetType,A as ClaimStatus,h as ClaimType,$ as buildAuthorization,I as getAchievementCount,y as getAchievementDistribution,l as getAchievementOfTheWeek,i as getAchievementUnlocks,w as getAchievementsEarnedBetween,g as getAchievementsEarnedOnDay,m as getActiveClaims,u as getConsoleIds,P as getGame,v as getGameExtended,S as getGameInfoAndUserProgress,c as getGameList,N as getGameRankAndScore,T as getGameRating,C as getTicketData,d as getTopTenUsers,R as getUserClaims,_ as getUserCompletedGames,U as getUserGameRankAndScore,M as getUserPoints,H as getUserProgress,k as getUserRecentlyPlayedGames,O as getUserSummary,s as unsafe_call};
2
+ //# sourceMappingURL=api.modern.js.map