@retroachievements/api 0.0.0-development

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 (225) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +103 -0
  3. package/dist/__playground.d.ts +7 -0
  4. package/dist/achievement/getAchievementUnlocks.d.ts +45 -0
  5. package/dist/achievement/index.d.ts +2 -0
  6. package/dist/achievement/models/achievement-unlock-entity.model.d.ts +6 -0
  7. package/dist/achievement/models/get-achievement-unlocks-response.model.d.ts +8 -0
  8. package/dist/achievement/models/index.d.ts +2 -0
  9. package/dist/api.cjs.development.js +2363 -0
  10. package/dist/api.cjs.development.js.map +1 -0
  11. package/dist/api.cjs.production.min.js +2 -0
  12. package/dist/api.cjs.production.min.js.map +1 -0
  13. package/dist/api.esm.js +2333 -0
  14. package/dist/api.esm.js.map +1 -0
  15. package/dist/console/getConsoleIds.d.ts +22 -0
  16. package/dist/console/getGameList.d.ts +52 -0
  17. package/dist/console/index.d.ts +3 -0
  18. package/dist/console/models/console-id.model.d.ts +4 -0
  19. package/dist/console/models/game-list.model.d.ts +15 -0
  20. package/dist/console/models/get-console-ids-response.model.d.ts +4 -0
  21. package/dist/console/models/get-game-list-response.model.d.ts +15 -0
  22. package/dist/console/models/index.d.ts +4 -0
  23. package/dist/feed/getAchievementOfTheWeek.d.ts +48 -0
  24. package/dist/feed/getActiveClaims.d.ts +38 -0
  25. package/dist/feed/getTicketData.d.ts +158 -0
  26. package/dist/feed/getTopTenUsers.d.ts +24 -0
  27. package/dist/feed/index.d.ts +5 -0
  28. package/dist/feed/models/achievement-of-the-week.model.d.ts +32 -0
  29. package/dist/feed/models/achievement-ticket-stats-response.model.d.ts +7 -0
  30. package/dist/feed/models/achievement-ticket-stats.model.d.ts +7 -0
  31. package/dist/feed/models/active-claim.model.d.ts +49 -0
  32. package/dist/feed/models/game-ticket-stats.model.d.ts +9 -0
  33. package/dist/feed/models/game-tickets-response.model.d.ts +7 -0
  34. package/dist/feed/models/get-achievement-of-the-week-response.model.d.ts +32 -0
  35. package/dist/feed/models/get-active-claims-response.model.d.ts +19 -0
  36. package/dist/feed/models/get-top-ten-users-response.model.d.ts +10 -0
  37. package/dist/feed/models/index.d.ts +19 -0
  38. package/dist/feed/models/most-ticketed-games-response.model.d.ts +12 -0
  39. package/dist/feed/models/most-ticketed-games.model.d.ts +12 -0
  40. package/dist/feed/models/recent-tickets-response.model.d.ts +6 -0
  41. package/dist/feed/models/recent-tickets.model.d.ts +6 -0
  42. package/dist/feed/models/response-ticket-entity.model.d.ts +24 -0
  43. package/dist/feed/models/ticket-entity.model.d.ts +24 -0
  44. package/dist/feed/models/tickets-by-user-response.model.d.ts +8 -0
  45. package/dist/feed/models/top-ten-users-entity.model.d.ts +5 -0
  46. package/dist/feed/models/top-ten-users.model.d.ts +2 -0
  47. package/dist/feed/models/user-ticket-stats.model.d.ts +8 -0
  48. package/dist/game/getAchievementCount.d.ts +31 -0
  49. package/dist/game/getAchievementDistribution.d.ts +57 -0
  50. package/dist/game/getGame.d.ts +48 -0
  51. package/dist/game/getGameExtended.d.ts +68 -0
  52. package/dist/game/getGameRankAndScore.d.ts +38 -0
  53. package/dist/game/getGameRating.d.ts +38 -0
  54. package/dist/game/index.d.ts +7 -0
  55. package/dist/game/models/achievement-count.model.d.ts +4 -0
  56. package/dist/game/models/achievement-distribution-flags.model.d.ts +4 -0
  57. package/dist/game/models/game-extended-achievement-entity.model.d.ts +15 -0
  58. package/dist/game/models/game-extended-claim-entity.model.d.ts +7 -0
  59. package/dist/game/models/game-extended.model.d.ts +25 -0
  60. package/dist/game/models/game-rank-and-score-entity.model.d.ts +6 -0
  61. package/dist/game/models/game-rating.model.d.ts +9 -0
  62. package/dist/game/models/game.model.d.ts +19 -0
  63. package/dist/game/models/get-achievement-count-response.model.d.ts +4 -0
  64. package/dist/game/models/get-achievement-distribution-response.model.d.ts +1 -0
  65. package/dist/game/models/get-game-extended-response.model.d.ts +50 -0
  66. package/dist/game/models/get-game-rank-and-score-response.model.d.ts +8 -0
  67. package/dist/game/models/get-game-rating-response.model.d.ts +9 -0
  68. package/dist/game/models/get-game-response.model.d.ts +19 -0
  69. package/dist/game/models/index.d.ts +14 -0
  70. package/dist/index.d.ts +6 -0
  71. package/dist/index.js +8 -0
  72. package/dist/user/getAchievementsEarnedBetween.d.ts +59 -0
  73. package/dist/user/getAchievementsEarnedOnDay.d.ts +57 -0
  74. package/dist/user/getGameInfoAndUserProgress.d.ts +80 -0
  75. package/dist/user/getUserGameRankAndScore.d.ts +44 -0
  76. package/dist/user/getUserPoints.d.ts +30 -0
  77. package/dist/user/getUserProgress.d.ts +49 -0
  78. package/dist/user/getUserRecentlyPlayedGames.d.ts +50 -0
  79. package/dist/user/getUserSummary.d.ts +32 -0
  80. package/dist/user/index.d.ts +9 -0
  81. package/dist/user/models/dated-user-achievement.model.d.ts +17 -0
  82. package/dist/user/models/dated-user-achievements-response.model.d.ts +19 -0
  83. package/dist/user/models/game-info-and-user-progress.model.d.ts +12 -0
  84. package/dist/user/models/get-game-info-and-user-progress-response.model.d.ts +14 -0
  85. package/dist/user/models/get-user-game-rank-and-score-response.model.d.ts +8 -0
  86. package/dist/user/models/get-user-points-response.model.d.ts +4 -0
  87. package/dist/user/models/get-user-progress-response.model.d.ts +10 -0
  88. package/dist/user/models/get-user-recently-played-games-response.model.d.ts +16 -0
  89. package/dist/user/models/get-user-summary-response.model.d.ts +82 -0
  90. package/dist/user/models/index.d.ts +14 -0
  91. package/dist/user/models/user-game-rank-and-score.model.d.ts +8 -0
  92. package/dist/user/models/user-points.model.d.ts +4 -0
  93. package/dist/user/models/user-progress.model.d.ts +10 -0
  94. package/dist/user/models/user-recently-played-games.model.d.ts +16 -0
  95. package/dist/user/models/user-summary.model.d.ts +83 -0
  96. package/dist/utils/internal/apiBaseUrl.d.ts +1 -0
  97. package/dist/utils/internal/buildRequestUrl.d.ts +2 -0
  98. package/dist/utils/internal/call.d.ts +20 -0
  99. package/dist/utils/internal/index.d.ts +4 -0
  100. package/dist/utils/internal/serializeProperties.d.ts +4 -0
  101. package/dist/utils/public/buildAuthorization.d.ts +22 -0
  102. package/dist/utils/public/index.d.ts +3 -0
  103. package/dist/utils/public/models/auth-object.model.d.ts +19 -0
  104. package/dist/utils/public/models/index.d.ts +1 -0
  105. package/package.json +117 -0
  106. package/src/__playground.ts +27 -0
  107. package/src/achievement/getAchievementUnlocks.test.ts +71 -0
  108. package/src/achievement/getAchievementUnlocks.ts +80 -0
  109. package/src/achievement/index.ts +2 -0
  110. package/src/achievement/models/achievement-unlock-entity.model.ts +6 -0
  111. package/src/achievement/models/get-achievement-unlocks-response.model.ts +8 -0
  112. package/src/achievement/models/index.ts +2 -0
  113. package/src/console/getConsoleIds.test.ts +53 -0
  114. package/src/console/getConsoleIds.ts +43 -0
  115. package/src/console/getGameList.test.ts +82 -0
  116. package/src/console/getGameList.ts +94 -0
  117. package/src/console/index.ts +3 -0
  118. package/src/console/models/console-id.model.ts +4 -0
  119. package/src/console/models/game-list.model.ts +16 -0
  120. package/src/console/models/get-console-ids-response.model.ts +1 -0
  121. package/src/console/models/get-game-list-response.model.ts +16 -0
  122. package/src/console/models/index.ts +4 -0
  123. package/src/feed/getAchievementOfTheWeek.test.ts +167 -0
  124. package/src/feed/getAchievementOfTheWeek.ts +80 -0
  125. package/src/feed/getActiveClaims.test.ts +81 -0
  126. package/src/feed/getActiveClaims.ts +68 -0
  127. package/src/feed/getTicketData.test.ts +349 -0
  128. package/src/feed/getTicketData.ts +286 -0
  129. package/src/feed/getTopTenUsers.test.ts +101 -0
  130. package/src/feed/getTopTenUsers.ts +51 -0
  131. package/src/feed/index.ts +5 -0
  132. package/src/feed/models/achievement-of-the-week.model.ts +27 -0
  133. package/src/feed/models/achievement-ticket-stats-response.model.ts +7 -0
  134. package/src/feed/models/achievement-ticket-stats.model.ts +7 -0
  135. package/src/feed/models/active-claim.model.ts +66 -0
  136. package/src/feed/models/game-ticket-stats.model.ts +11 -0
  137. package/src/feed/models/game-tickets-response.model.ts +7 -0
  138. package/src/feed/models/get-achievement-of-the-week-response.model.ts +27 -0
  139. package/src/feed/models/get-active-claims-response.model.ts +19 -0
  140. package/src/feed/models/get-top-ten-users-response.model.ts +12 -0
  141. package/src/feed/models/index.ts +19 -0
  142. package/src/feed/models/most-ticketed-games-response.model.ts +12 -0
  143. package/src/feed/models/most-ticketed-games.model.ts +12 -0
  144. package/src/feed/models/recent-tickets-response.model.ts +7 -0
  145. package/src/feed/models/recent-tickets.model.ts +7 -0
  146. package/src/feed/models/response-ticket-entity.model.ts +25 -0
  147. package/src/feed/models/ticket-entity.model.ts +24 -0
  148. package/src/feed/models/tickets-by-user-response.model.ts +8 -0
  149. package/src/feed/models/top-ten-users-entity.model.ts +5 -0
  150. package/src/feed/models/top-ten-users.model.ts +3 -0
  151. package/src/feed/models/user-ticket-stats.model.ts +8 -0
  152. package/src/game/getAchievementCount.test.ts +49 -0
  153. package/src/game/getAchievementCount.ts +52 -0
  154. package/src/game/getAchievementDistribution.test.ts +187 -0
  155. package/src/game/getAchievementDistribution.ts +88 -0
  156. package/src/game/getGame.test.ts +81 -0
  157. package/src/game/getGame.ts +74 -0
  158. package/src/game/getGameExtended.test.ts +121 -0
  159. package/src/game/getGameExtended.ts +103 -0
  160. package/src/game/getGameRankAndScore.test.ts +62 -0
  161. package/src/game/getGameRankAndScore.ts +66 -0
  162. package/src/game/getGameRating.test.ts +59 -0
  163. package/src/game/getGameRating.ts +59 -0
  164. package/src/game/index.ts +7 -0
  165. package/src/game/models/achievement-count.model.ts +4 -0
  166. package/src/game/models/achievement-distribution-flags.model.ts +4 -0
  167. package/src/game/models/game-extended-achievement-entity.model.ts +15 -0
  168. package/src/game/models/game-extended-claim-entity.model.ts +7 -0
  169. package/src/game/models/game-extended.model.ts +26 -0
  170. package/src/game/models/game-rank-and-score-entity.model.ts +6 -0
  171. package/src/game/models/game-rating.model.ts +9 -0
  172. package/src/game/models/game.model.ts +19 -0
  173. package/src/game/models/get-achievement-count-response.model.ts +4 -0
  174. package/src/game/models/get-achievement-distribution-response.model.ts +1 -0
  175. package/src/game/models/get-game-extended-response.model.ts +56 -0
  176. package/src/game/models/get-game-rank-and-score-response.model.ts +8 -0
  177. package/src/game/models/get-game-rating-response.model.ts +9 -0
  178. package/src/game/models/get-game-response.model.ts +19 -0
  179. package/src/game/models/index.ts +14 -0
  180. package/src/index.ts +8 -0
  181. package/src/user/getAchievementsEarnedBetween.test.ts +84 -0
  182. package/src/user/getAchievementsEarnedBetween.ts +88 -0
  183. package/src/user/getAchievementsEarnedOnDay.test.ts +83 -0
  184. package/src/user/getAchievementsEarnedOnDay.ts +87 -0
  185. package/src/user/getGameInfoAndUserProgress.test.ts +135 -0
  186. package/src/user/getGameInfoAndUserProgress.ts +118 -0
  187. package/src/user/getUserGameRankAndScore.test.ts +60 -0
  188. package/src/user/getUserGameRankAndScore.ts +69 -0
  189. package/src/user/getUserPoints.test.ts +49 -0
  190. package/src/user/getUserPoints.ts +51 -0
  191. package/src/user/getUserProgress.test.ts +80 -0
  192. package/src/user/getUserProgress.ts +78 -0
  193. package/src/user/getUserRecentlyPlayedGames.test.ts +76 -0
  194. package/src/user/getUserRecentlyPlayedGames.ts +93 -0
  195. package/src/user/getUserSummary.test.ts +251 -0
  196. package/src/user/getUserSummary.ts +96 -0
  197. package/src/user/index.ts +9 -0
  198. package/src/user/models/dated-user-achievement.model.ts +17 -0
  199. package/src/user/models/dated-user-achievements-response.model.ts +20 -0
  200. package/src/user/models/game-info-and-user-progress.model.ts +19 -0
  201. package/src/user/models/get-game-info-and-user-progress-response.model.ts +28 -0
  202. package/src/user/models/get-user-game-rank-and-score-response.model.ts +9 -0
  203. package/src/user/models/get-user-points-response.model.ts +4 -0
  204. package/src/user/models/get-user-progress-response.model.ts +13 -0
  205. package/src/user/models/get-user-recently-played-games-response.model.ts +17 -0
  206. package/src/user/models/get-user-summary-response.model.ts +92 -0
  207. package/src/user/models/index.ts +14 -0
  208. package/src/user/models/user-game-rank-and-score.model.ts +8 -0
  209. package/src/user/models/user-points.model.ts +4 -0
  210. package/src/user/models/user-progress.model.ts +10 -0
  211. package/src/user/models/user-recently-played-games.model.ts +16 -0
  212. package/src/user/models/user-summary.model.ts +92 -0
  213. package/src/utils/internal/apiBaseUrl.ts +1 -0
  214. package/src/utils/internal/buildRequestUrl.test.ts +51 -0
  215. package/src/utils/internal/buildRequestUrl.ts +32 -0
  216. package/src/utils/internal/call.test.ts +39 -0
  217. package/src/utils/internal/call.ts +29 -0
  218. package/src/utils/internal/index.ts +4 -0
  219. package/src/utils/internal/serializeProperties.test.ts +141 -0
  220. package/src/utils/internal/serializeProperties.ts +75 -0
  221. package/src/utils/public/buildAuthorization.test.ts +36 -0
  222. package/src/utils/public/buildAuthorization.ts +40 -0
  223. package/src/utils/public/index.ts +3 -0
  224. package/src/utils/public/models/auth-object.model.ts +20 -0
  225. package/src/utils/public/models/index.ts +1 -0
@@ -0,0 +1,2363 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var unfetch = require('isomorphic-unfetch');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var unfetch__default = /*#__PURE__*/_interopDefaultLegacy(unfetch);
10
+
11
+ function _regeneratorRuntime() {
12
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
13
+
14
+ _regeneratorRuntime = function () {
15
+ return exports;
16
+ };
17
+
18
+ var exports = {},
19
+ Op = Object.prototype,
20
+ hasOwn = Op.hasOwnProperty,
21
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
22
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
23
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
24
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
25
+
26
+ function define(obj, key, value) {
27
+ return Object.defineProperty(obj, key, {
28
+ value: value,
29
+ enumerable: !0,
30
+ configurable: !0,
31
+ writable: !0
32
+ }), obj[key];
33
+ }
34
+
35
+ try {
36
+ define({}, "");
37
+ } catch (err) {
38
+ define = function (obj, key, value) {
39
+ return obj[key] = value;
40
+ };
41
+ }
42
+
43
+ function wrap(innerFn, outerFn, self, tryLocsList) {
44
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
45
+ generator = Object.create(protoGenerator.prototype),
46
+ context = new Context(tryLocsList || []);
47
+ return generator._invoke = function (innerFn, self, context) {
48
+ var state = "suspendedStart";
49
+ return function (method, arg) {
50
+ if ("executing" === state) throw new Error("Generator is already running");
51
+
52
+ if ("completed" === state) {
53
+ if ("throw" === method) throw arg;
54
+ return doneResult();
55
+ }
56
+
57
+ for (context.method = method, context.arg = arg;;) {
58
+ var delegate = context.delegate;
59
+
60
+ if (delegate) {
61
+ var delegateResult = maybeInvokeDelegate(delegate, context);
62
+
63
+ if (delegateResult) {
64
+ if (delegateResult === ContinueSentinel) continue;
65
+ return delegateResult;
66
+ }
67
+ }
68
+
69
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
70
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
71
+ context.dispatchException(context.arg);
72
+ } else "return" === context.method && context.abrupt("return", context.arg);
73
+ state = "executing";
74
+ var record = tryCatch(innerFn, self, context);
75
+
76
+ if ("normal" === record.type) {
77
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
78
+ return {
79
+ value: record.arg,
80
+ done: context.done
81
+ };
82
+ }
83
+
84
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
85
+ }
86
+ };
87
+ }(innerFn, self, context), generator;
88
+ }
89
+
90
+ function tryCatch(fn, obj, arg) {
91
+ try {
92
+ return {
93
+ type: "normal",
94
+ arg: fn.call(obj, arg)
95
+ };
96
+ } catch (err) {
97
+ return {
98
+ type: "throw",
99
+ arg: err
100
+ };
101
+ }
102
+ }
103
+
104
+ exports.wrap = wrap;
105
+ var ContinueSentinel = {};
106
+
107
+ function Generator() {}
108
+
109
+ function GeneratorFunction() {}
110
+
111
+ function GeneratorFunctionPrototype() {}
112
+
113
+ var IteratorPrototype = {};
114
+ define(IteratorPrototype, iteratorSymbol, function () {
115
+ return this;
116
+ });
117
+ var getProto = Object.getPrototypeOf,
118
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
119
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
120
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
121
+
122
+ function defineIteratorMethods(prototype) {
123
+ ["next", "throw", "return"].forEach(function (method) {
124
+ define(prototype, method, function (arg) {
125
+ return this._invoke(method, arg);
126
+ });
127
+ });
128
+ }
129
+
130
+ function AsyncIterator(generator, PromiseImpl) {
131
+ function invoke(method, arg, resolve, reject) {
132
+ var record = tryCatch(generator[method], generator, arg);
133
+
134
+ if ("throw" !== record.type) {
135
+ var result = record.arg,
136
+ value = result.value;
137
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
138
+ invoke("next", value, resolve, reject);
139
+ }, function (err) {
140
+ invoke("throw", err, resolve, reject);
141
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
142
+ result.value = unwrapped, resolve(result);
143
+ }, function (error) {
144
+ return invoke("throw", error, resolve, reject);
145
+ });
146
+ }
147
+
148
+ reject(record.arg);
149
+ }
150
+
151
+ var previousPromise;
152
+
153
+ this._invoke = function (method, arg) {
154
+ function callInvokeWithMethodAndArg() {
155
+ return new PromiseImpl(function (resolve, reject) {
156
+ invoke(method, arg, resolve, reject);
157
+ });
158
+ }
159
+
160
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
161
+ };
162
+ }
163
+
164
+ function maybeInvokeDelegate(delegate, context) {
165
+ var method = delegate.iterator[context.method];
166
+
167
+ if (undefined === method) {
168
+ if (context.delegate = null, "throw" === context.method) {
169
+ if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
170
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
171
+ }
172
+
173
+ return ContinueSentinel;
174
+ }
175
+
176
+ var record = tryCatch(method, delegate.iterator, context.arg);
177
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
178
+ var info = record.arg;
179
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
180
+ }
181
+
182
+ function pushTryEntry(locs) {
183
+ var entry = {
184
+ tryLoc: locs[0]
185
+ };
186
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
187
+ }
188
+
189
+ function resetTryEntry(entry) {
190
+ var record = entry.completion || {};
191
+ record.type = "normal", delete record.arg, entry.completion = record;
192
+ }
193
+
194
+ function Context(tryLocsList) {
195
+ this.tryEntries = [{
196
+ tryLoc: "root"
197
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
198
+ }
199
+
200
+ function values(iterable) {
201
+ if (iterable) {
202
+ var iteratorMethod = iterable[iteratorSymbol];
203
+ if (iteratorMethod) return iteratorMethod.call(iterable);
204
+ if ("function" == typeof iterable.next) return iterable;
205
+
206
+ if (!isNaN(iterable.length)) {
207
+ var i = -1,
208
+ next = function next() {
209
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
210
+
211
+ return next.value = undefined, next.done = !0, next;
212
+ };
213
+
214
+ return next.next = next;
215
+ }
216
+ }
217
+
218
+ return {
219
+ next: doneResult
220
+ };
221
+ }
222
+
223
+ function doneResult() {
224
+ return {
225
+ value: undefined,
226
+ done: !0
227
+ };
228
+ }
229
+
230
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
231
+ var ctor = "function" == typeof genFun && genFun.constructor;
232
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
233
+ }, exports.mark = function (genFun) {
234
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
235
+ }, exports.awrap = function (arg) {
236
+ return {
237
+ __await: arg
238
+ };
239
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
240
+ return this;
241
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
242
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
243
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
244
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
245
+ return result.done ? result.value : iter.next();
246
+ });
247
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
248
+ return this;
249
+ }), define(Gp, "toString", function () {
250
+ return "[object Generator]";
251
+ }), exports.keys = function (object) {
252
+ var keys = [];
253
+
254
+ for (var key in object) keys.push(key);
255
+
256
+ return keys.reverse(), function next() {
257
+ for (; keys.length;) {
258
+ var key = keys.pop();
259
+ if (key in object) return next.value = key, next.done = !1, next;
260
+ }
261
+
262
+ return next.done = !0, next;
263
+ };
264
+ }, exports.values = values, Context.prototype = {
265
+ constructor: Context,
266
+ reset: function (skipTempReset) {
267
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
268
+ },
269
+ stop: function () {
270
+ this.done = !0;
271
+ var rootRecord = this.tryEntries[0].completion;
272
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
273
+ return this.rval;
274
+ },
275
+ dispatchException: function (exception) {
276
+ if (this.done) throw exception;
277
+ var context = this;
278
+
279
+ function handle(loc, caught) {
280
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
281
+ }
282
+
283
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
284
+ var entry = this.tryEntries[i],
285
+ record = entry.completion;
286
+ if ("root" === entry.tryLoc) return handle("end");
287
+
288
+ if (entry.tryLoc <= this.prev) {
289
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
290
+ hasFinally = hasOwn.call(entry, "finallyLoc");
291
+
292
+ if (hasCatch && hasFinally) {
293
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
294
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
295
+ } else if (hasCatch) {
296
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
297
+ } else {
298
+ if (!hasFinally) throw new Error("try statement without catch or finally");
299
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
300
+ }
301
+ }
302
+ }
303
+ },
304
+ abrupt: function (type, arg) {
305
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
306
+ var entry = this.tryEntries[i];
307
+
308
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
309
+ var finallyEntry = entry;
310
+ break;
311
+ }
312
+ }
313
+
314
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
315
+ var record = finallyEntry ? finallyEntry.completion : {};
316
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
317
+ },
318
+ complete: function (record, afterLoc) {
319
+ if ("throw" === record.type) throw record.arg;
320
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
321
+ },
322
+ finish: function (finallyLoc) {
323
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
324
+ var entry = this.tryEntries[i];
325
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
326
+ }
327
+ },
328
+ catch: function (tryLoc) {
329
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
330
+ var entry = this.tryEntries[i];
331
+
332
+ if (entry.tryLoc === tryLoc) {
333
+ var record = entry.completion;
334
+
335
+ if ("throw" === record.type) {
336
+ var thrown = record.arg;
337
+ resetTryEntry(entry);
338
+ }
339
+
340
+ return thrown;
341
+ }
342
+ }
343
+
344
+ throw new Error("illegal catch attempt");
345
+ },
346
+ delegateYield: function (iterable, resultName, nextLoc) {
347
+ return this.delegate = {
348
+ iterator: values(iterable),
349
+ resultName: resultName,
350
+ nextLoc: nextLoc
351
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
352
+ }
353
+ }, exports;
354
+ }
355
+
356
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
357
+ try {
358
+ var info = gen[key](arg);
359
+ var value = info.value;
360
+ } catch (error) {
361
+ reject(error);
362
+ return;
363
+ }
364
+
365
+ if (info.done) {
366
+ resolve(value);
367
+ } else {
368
+ Promise.resolve(value).then(_next, _throw);
369
+ }
370
+ }
371
+
372
+ function _asyncToGenerator(fn) {
373
+ return function () {
374
+ var self = this,
375
+ args = arguments;
376
+ return new Promise(function (resolve, reject) {
377
+ var gen = fn.apply(self, args);
378
+
379
+ function _next(value) {
380
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
381
+ }
382
+
383
+ function _throw(err) {
384
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
385
+ }
386
+
387
+ _next(undefined);
388
+ });
389
+ };
390
+ }
391
+
392
+ function _extends() {
393
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
394
+ for (var i = 1; i < arguments.length; i++) {
395
+ var source = arguments[i];
396
+
397
+ for (var key in source) {
398
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
399
+ target[key] = source[key];
400
+ }
401
+ }
402
+ }
403
+
404
+ return target;
405
+ };
406
+ return _extends.apply(this, arguments);
407
+ }
408
+
409
+ function _unsupportedIterableToArray(o, minLen) {
410
+ if (!o) return;
411
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
412
+ var n = Object.prototype.toString.call(o).slice(8, -1);
413
+ if (n === "Object" && o.constructor) n = o.constructor.name;
414
+ if (n === "Map" || n === "Set") return Array.from(o);
415
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
416
+ }
417
+
418
+ function _arrayLikeToArray(arr, len) {
419
+ if (len == null || len > arr.length) len = arr.length;
420
+
421
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
422
+
423
+ return arr2;
424
+ }
425
+
426
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
427
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
428
+ if (it) return (it = it.call(o)).next.bind(it);
429
+
430
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
431
+ if (it) o = it;
432
+ var i = 0;
433
+ return function () {
434
+ if (i >= o.length) return {
435
+ done: true
436
+ };
437
+ return {
438
+ done: false,
439
+ value: o[i++]
440
+ };
441
+ };
442
+ }
443
+
444
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
445
+ }
446
+
447
+ var apiBaseUrl = "https://retroachievements.org/API";
448
+
449
+ var buildRequestUrl = function buildRequestUrl(baseUrl, endpointUrl, authObject, args) {
450
+ if (args === void 0) {
451
+ args = {};
452
+ }
453
+
454
+ var concatenated = baseUrl + "/" + endpointUrl;
455
+ var withoutDoubleSlashes = concatenated.replace(/([^:]\/)\/+/g, "$1");
456
+ var withArgs = withoutDoubleSlashes; // `z` and `y` are expected query params from the RA API.
457
+ // Authentication is handled purely by query params.
458
+
459
+ var queryParamValues = {
460
+ z: authObject.userName,
461
+ y: authObject.webApiKey
462
+ };
463
+
464
+ for (var _i = 0, _Object$entries = Object.entries(args); _i < _Object$entries.length; _i++) {
465
+ var _Object$entries$_i = _Object$entries[_i],
466
+ argKey = _Object$entries$_i[0],
467
+ argValue = _Object$entries$_i[1];
468
+
469
+ // "abc.com/some-route/:foo/some-path" & {"foo": 4} --> "abc.com/some-route/4/some-path"
470
+ if (withArgs.includes(":" + argKey)) {
471
+ withArgs = withArgs.replace(":" + argKey, String(argValue));
472
+ } else if (argValue !== undefined) {
473
+ queryParamValues[argKey] = String(argValue);
474
+ }
475
+ }
476
+
477
+ var queryString = new URLSearchParams(queryParamValues).toString();
478
+ return withArgs + "?" + queryString;
479
+ };
480
+
481
+ /**
482
+ * Fetch an HTTP resource. This is publicly exposed in the
483
+ * event you would like to access an endpoint that this
484
+ * library does not currently support.
485
+ *
486
+ * UNLESS YOU'RE SURE OF WHAT YOU'RE DOING, YOU PROBABLY
487
+ * SHOULDN'T USE THIS FUNCTION.
488
+ *
489
+ * 2022-10-09: At the time of writing, Node.js LTS (16.x)
490
+ * does not yet support fetch. As a result, we pull in
491
+ * isomorphic-unfetch for Node.js compatibility. Our support
492
+ * matrix includes 14.x and 16.x.
493
+ *
494
+ * @FIXME - When Node.js 20.x is released, remove the
495
+ * isomorphic-unfetch dependency. At that point we will have
496
+ * two major LTS versions that include a native fetch API.
497
+ */
498
+
499
+ var call = /*#__PURE__*/function () {
500
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
501
+ var url, rawResponse;
502
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
503
+ while (1) {
504
+ switch (_context.prev = _context.next) {
505
+ case 0:
506
+ url = config.url;
507
+ _context.next = 3;
508
+ return unfetch__default["default"](url);
509
+
510
+ case 3:
511
+ rawResponse = _context.sent;
512
+ _context.next = 6;
513
+ return rawResponse.json();
514
+
515
+ case 6:
516
+ return _context.abrupt("return", _context.sent);
517
+
518
+ case 7:
519
+ case "end":
520
+ return _context.stop();
521
+ }
522
+ }
523
+ }, _callee);
524
+ }));
525
+
526
+ return function call(_x) {
527
+ return _ref.apply(this, arguments);
528
+ };
529
+ }();
530
+
531
+ /* eslint-disable sonarjs/cognitive-complexity */
532
+
533
+ /* eslint-disable sonarjs/prefer-immediate-return */
534
+ var serializeProperties = function serializeProperties(originalData, options) {
535
+ if (options === void 0) {
536
+ options = {};
537
+ }
538
+
539
+ var _options = options,
540
+ shouldCastToNumbers = _options.shouldCastToNumbers,
541
+ shouldMapToBooleans = _options.shouldMapToBooleans;
542
+ var returnValue = originalData;
543
+
544
+ if (Array.isArray(originalData)) {
545
+ var cleanedArray = [];
546
+
547
+ for (var _iterator = _createForOfIteratorHelperLoose(originalData), _step; !(_step = _iterator()).done;) {
548
+ var entity = _step.value;
549
+ cleanedArray.push(serializeProperties(entity, options));
550
+ }
551
+
552
+ returnValue = cleanedArray;
553
+ } else if (!Array.isArray(originalData) && originalData instanceof Object) {
554
+ var cleanedObject = {};
555
+
556
+ for (var _i = 0, _Object$entries = Object.entries(originalData); _i < _Object$entries.length; _i++) {
557
+ var _extends2;
558
+
559
+ var _Object$entries$_i = _Object$entries[_i],
560
+ originalKey = _Object$entries$_i[0],
561
+ originalValue = _Object$entries$_i[1];
562
+ var sanitizedValue = originalValue;
563
+
564
+ if (shouldCastToNumbers != null && shouldCastToNumbers.includes(originalKey)) {
565
+ sanitizedValue = Number(originalValue);
566
+ }
567
+
568
+ if (shouldMapToBooleans != null && shouldMapToBooleans.includes(originalKey)) {
569
+ if (originalValue === null) {
570
+ sanitizedValue = null;
571
+ } else {
572
+ sanitizedValue = originalValue === "1" ? true : false;
573
+ }
574
+ }
575
+
576
+ cleanedObject = _extends({}, cleanedObject, (_extends2 = {}, _extends2[naiveCamelCase(originalKey)] = serializeProperties(sanitizedValue, options), _extends2));
577
+ }
578
+
579
+ returnValue = cleanedObject;
580
+ }
581
+
582
+ return returnValue;
583
+ };
584
+
585
+ var naiveCamelCase = function naiveCamelCase(originalValue) {
586
+ // "ID" --> "id", "URL" --> "url"
587
+ if (originalValue.toUpperCase() === originalValue) {
588
+ return originalValue.toLowerCase();
589
+ } // "GameID" -> "gameID"
590
+
591
+
592
+ var camelCased = originalValue.charAt(0).toLowerCase() + originalValue.slice(1); // "gameID" -> "gameId"
593
+
594
+ camelCased = camelCased.replace(/ID/g, "Id"); // "badgeURL" --> "badgeUrl"
595
+
596
+ camelCased = camelCased.replace(/URL/g, "Url"); // "rAPoints" -> "raPoints"
597
+
598
+ camelCased = camelCased.replace(/rA/g, "ra");
599
+ return camelCased;
600
+ };
601
+
602
+ /**
603
+ * A call to this function will retrieve a list of users who
604
+ * have earned the given achievementId.
605
+ *
606
+ * @param authorization An object containing your userName and webApiKey.
607
+ * This can be constructed with `buildAuthorization()`.
608
+ *
609
+ * @param payload.achievementId The target achievement we want to
610
+ * retrieve the unlocks list for. If unknown, this can be found
611
+ * by navigating to the achievement's page on the RetroAchievements.org
612
+ * website. eg: https://retroachievements.org/achievement/13876 has an
613
+ * ID of 13876.
614
+ *
615
+ * @param payload.offset Defaults to 0. The number of entries to skip.
616
+ *
617
+ * @param payload.count Defaults to 50, has a max of 500.
618
+ *
619
+ * @example
620
+ * ```
621
+ * const achievementUnlocks = await getAchievementUnlocks(
622
+ * authorization,
623
+ * { achievementId: 13876 }
624
+ * );
625
+ * ```
626
+ *
627
+ * @returns An array containing metadata about unlocks for
628
+ * the target achievement.
629
+ * ```
630
+ * [
631
+ * {
632
+ * user: 'Podgicus0305',
633
+ * raPoints: 15544,
634
+ * dateAwarded: '2022-07-12 19:06:34',
635
+ * hardcoreMode: true
636
+ * }
637
+ * ]
638
+ * ```
639
+ */
640
+
641
+ var getAchievementUnlocks = /*#__PURE__*/function () {
642
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
643
+ var achievementId, offset, count, queryParams, url, rawResponse;
644
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
645
+ while (1) {
646
+ switch (_context.prev = _context.next) {
647
+ case 0:
648
+ achievementId = payload.achievementId, offset = payload.offset, count = payload.count;
649
+ queryParams = {
650
+ a: achievementId
651
+ };
652
+
653
+ if (offset) {
654
+ queryParams.o = offset;
655
+ }
656
+
657
+ if (count) {
658
+ queryParams.c = count;
659
+ }
660
+
661
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementUnlocks.php", authorization, queryParams);
662
+ _context.next = 7;
663
+ return call({
664
+ url: url
665
+ });
666
+
667
+ case 7:
668
+ rawResponse = _context.sent;
669
+ return _context.abrupt("return", serializeProperties(rawResponse, {
670
+ shouldCastToNumbers: ["RAPoints"],
671
+ shouldMapToBooleans: ["HardcoreMode"]
672
+ }));
673
+
674
+ case 9:
675
+ case "end":
676
+ return _context.stop();
677
+ }
678
+ }
679
+ }, _callee);
680
+ }));
681
+
682
+ return function getAchievementUnlocks(_x, _x2) {
683
+ return _ref.apply(this, arguments);
684
+ };
685
+ }();
686
+
687
+ /**
688
+ * A call to this function will retrieve the complete list
689
+ * of console ID and name pairs on the RetroAchievements.org
690
+ * platform.
691
+ *
692
+ * @param authorization An object containing your userName and webApiKey.
693
+ * This can be constructed with `buildAuthorization()`.
694
+ *
695
+ * @example
696
+ * ```
697
+ * const consoleIds = await getConsoleIds(authorization);
698
+ * ```
699
+ *
700
+ * @returns An array containing a complete list of console ID
701
+ * and name pairs for RetroAchievements.org.
702
+ * ```
703
+ * { id: "1", name: "Mega Drive" }
704
+ * ```
705
+ */
706
+
707
+ var getConsoleIds = /*#__PURE__*/function () {
708
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization) {
709
+ var url, rawResponse;
710
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
711
+ while (1) {
712
+ switch (_context.prev = _context.next) {
713
+ case 0:
714
+ url = buildRequestUrl(apiBaseUrl, "/API_GetConsoleIDs.php", authorization);
715
+ _context.next = 3;
716
+ return call({
717
+ url: url
718
+ });
719
+
720
+ case 3:
721
+ rawResponse = _context.sent;
722
+ return _context.abrupt("return", serializeProperties(rawResponse, {
723
+ shouldCastToNumbers: ["ID"]
724
+ }));
725
+
726
+ case 5:
727
+ case "end":
728
+ return _context.stop();
729
+ }
730
+ }
731
+ }, _callee);
732
+ }));
733
+
734
+ return function getConsoleIds(_x) {
735
+ return _ref.apply(this, arguments);
736
+ };
737
+ }();
738
+
739
+ /**
740
+ * A call to this function will retrieve the complete list
741
+ * of games for a specified console on the RetroAchievements.org
742
+ * platform.
743
+ *
744
+ * @param authorization An object containing your userName and webApiKey.
745
+ * This can be constructed with `buildAuthorization()`.
746
+ *
747
+ * @param payload.consoleId The unique console ID to retrieve a list of
748
+ * games from. The list of consoleIds can be retrieved using the `getConsoleIds()`
749
+ * function provided by this library.
750
+ *
751
+ * @param payload.shouldOnlyRetrieveGamesWithAchievements If truthy, will not
752
+ * return games that do not have achievements.
753
+ *
754
+ * @param payload.shouldRetrieveGameHashes If truthy, will return valid
755
+ * hashes for game ROMs in an array attached to each game in the list.
756
+ *
757
+ * @example
758
+ * ```
759
+ * const gameList = await getGameList(
760
+ * authorization,
761
+ * { consoleId: 1, shouldOnlyRetrieveGamesWithAchievements: true }
762
+ * );
763
+ * ```
764
+ *
765
+ * @returns An array containing a list of games for a given consoleId.
766
+ * ```
767
+ * [
768
+ * {
769
+ * title: "Elemental Master",
770
+ * id: 4247,
771
+ * consoleId: 1,
772
+ * consoleName: "Mega Drive",
773
+ * imageIcon: "/Images/048245.png",
774
+ * numAchievements: 44,
775
+ * numLeaderboards: 0,
776
+ * points: 500,
777
+ * dateModified: "2021-12-09 17:05:39",
778
+ * forumTopicId: 1972,
779
+ * hashes: ["32e1a15161ef1f070b023738353bde51"]
780
+ * }
781
+ * ]
782
+ * ```
783
+ */
784
+
785
+ var getGameList = /*#__PURE__*/function () {
786
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
787
+ var consoleId, shouldOnlyRetrieveGamesWithAchievements, shouldRetrieveGameHashes, callPayload, url, rawResponse;
788
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
789
+ while (1) {
790
+ switch (_context.prev = _context.next) {
791
+ case 0:
792
+ consoleId = payload.consoleId, shouldOnlyRetrieveGamesWithAchievements = payload.shouldOnlyRetrieveGamesWithAchievements, shouldRetrieveGameHashes = payload.shouldRetrieveGameHashes;
793
+ callPayload = {
794
+ i: consoleId
795
+ };
796
+
797
+ if (shouldOnlyRetrieveGamesWithAchievements !== undefined) {
798
+ callPayload = _extends({}, callPayload, {
799
+ f: shouldOnlyRetrieveGamesWithAchievements ? 1 : 0
800
+ });
801
+ }
802
+
803
+ if (shouldRetrieveGameHashes) {
804
+ callPayload = _extends({}, callPayload, {
805
+ h: shouldRetrieveGameHashes ? 1 : 0
806
+ });
807
+ }
808
+
809
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGameList.php", authorization, callPayload);
810
+ _context.next = 7;
811
+ return call({
812
+ url: url
813
+ });
814
+
815
+ case 7:
816
+ rawResponse = _context.sent;
817
+ return _context.abrupt("return", serializeProperties(rawResponse, {
818
+ shouldCastToNumbers: ["ID", "ConsoleID"]
819
+ }));
820
+
821
+ case 9:
822
+ case "end":
823
+ return _context.stop();
824
+ }
825
+ }
826
+ }, _callee);
827
+ }));
828
+
829
+ return function getGameList(_x, _x2) {
830
+ return _ref.apply(this, arguments);
831
+ };
832
+ }();
833
+
834
+ /**
835
+ * A call to this function will retrieve comprehensive
836
+ * metadata about the current Achievement of the Week.
837
+ *
838
+ * @param authorization An object containing your userName and webApiKey.
839
+ * This can be constructed with `buildAuthorization()`.
840
+ *
841
+ * @example
842
+ * ```
843
+ * const achievementOfTheWeek = await getAchievementOfTheWeek(
844
+ * authorization
845
+ * );
846
+ * ```
847
+ *
848
+ * @returns An object containing comprehensive metadata
849
+ * about the current Achievement of the Week.
850
+ * ```
851
+ * {
852
+ * achievement: {
853
+ * id: "165062",
854
+ * title: "The True Hero",
855
+ * description: "Receive any Ending as Han [Normal or Hard]",
856
+ * points: "10",
857
+ * trueRatio: "22",
858
+ * author: "BigWeedSmokerMan",
859
+ * dateCreated: "2021-08-08 17:47:46",
860
+ * dateModified: "2021-08-09 12:20:05"
861
+ * },
862
+ * console: { id: "39", title: "Saturn" },
863
+ * forumTopic: { id: "14767" },
864
+ * game: { id: "14513", title: "Guardian Heroes" },
865
+ * startAt: "2022-10-10 00:00:00",
866
+ * totalPlayers: "219",
867
+ * unlocks: [
868
+ * {
869
+ * user: "Tirbaba2",
870
+ * rAPoints: "72",
871
+ * dateAwarded: "2022-10-10 01:42:19",
872
+ * hardcoreMode: "1"
873
+ * }
874
+ * ],
875
+ * unlocksCount: "40"
876
+ * }
877
+ * ```
878
+ */
879
+
880
+ var getAchievementOfTheWeek = /*#__PURE__*/function () {
881
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization) {
882
+ var url, rawResponse;
883
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
884
+ while (1) {
885
+ switch (_context.prev = _context.next) {
886
+ case 0:
887
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementOfTheWeek.php", authorization);
888
+ _context.next = 3;
889
+ return call({
890
+ url: url
891
+ });
892
+
893
+ case 3:
894
+ rawResponse = _context.sent;
895
+ return _context.abrupt("return", serializeProperties(rawResponse, {
896
+ shouldCastToNumbers: ["ID", "Points", "TrueRatio", "TotalPlayers", "RAPoints", "UnlocksCount"],
897
+ shouldMapToBooleans: ["HardcoreMode"]
898
+ }));
899
+
900
+ case 5:
901
+ case "end":
902
+ return _context.stop();
903
+ }
904
+ }
905
+ }, _callee);
906
+ }));
907
+
908
+ return function getAchievementOfTheWeek(_x) {
909
+ return _ref.apply(this, arguments);
910
+ };
911
+ }();
912
+
913
+ /**
914
+ * A call to this function returns information about all
915
+ * (1000 max) active set claims.
916
+ *
917
+ * @param authorization An object containing your userName and webApiKey.
918
+ * This can be constructed with `buildAuthorization()`.
919
+ *
920
+ * @example
921
+ * ```
922
+ * const activeClaims = await getActiveClaims(authorization);
923
+ * ```
924
+ *
925
+ * @returns An array containing metadata about all active claims.
926
+ * ```
927
+ * [
928
+ * {
929
+ * id: 7044,
930
+ * user: "blendedsea",
931
+ * gameId: 19212,
932
+ * gameTitle: "SpongeBob SquarePants: Battle for Bikini Bottom",
933
+ * gameIcon: "/Images/059776.png",
934
+ * consoleName: "PlayStation 2",
935
+ * claimType: 0,
936
+ * setType: 0,
937
+ * status: 0,
938
+ * extension: 0,
939
+ * special: 0,
940
+ * created: "2022-10-04 00:25:06",
941
+ * doneTime: "2023-01-04 00:25:06",
942
+ * updated: "2022-10-04 00:25:06",
943
+ * minutesLeft: 112523
944
+ * }
945
+ * ]
946
+ * ```
947
+ */
948
+
949
+ var getActiveClaims = /*#__PURE__*/function () {
950
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization) {
951
+ var url, rawResponse;
952
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
953
+ while (1) {
954
+ switch (_context.prev = _context.next) {
955
+ case 0:
956
+ url = buildRequestUrl(apiBaseUrl, "/API_GetActiveClaims.php", authorization);
957
+ _context.next = 3;
958
+ return call({
959
+ url: url
960
+ });
961
+
962
+ case 3:
963
+ rawResponse = _context.sent;
964
+ return _context.abrupt("return", serializeProperties(rawResponse, {
965
+ shouldCastToNumbers: ["ID", "GameID", "ClaimType", "SetType", "Status", "Extension", "Special", "MinutesLeft"]
966
+ }));
967
+
968
+ case 5:
969
+ case "end":
970
+ return _context.stop();
971
+ }
972
+ }
973
+ }, _callee);
974
+ }));
975
+
976
+ return function getActiveClaims(_x) {
977
+ return _ref.apply(this, arguments);
978
+ };
979
+ }();
980
+
981
+ /**
982
+ * END: Function overload definitions
983
+ */
984
+
985
+ function getTicketData(_x, _x2) {
986
+ return _getTicketData.apply(this, arguments);
987
+ }
988
+
989
+ function _getTicketData() {
990
+ _getTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
991
+ var queryParams, url, rawResponse;
992
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
993
+ while (1) {
994
+ switch (_context.prev = _context.next) {
995
+ case 0:
996
+ if (payload === void 0) {
997
+ payload = {};
998
+ }
999
+
1000
+ queryParams = buildGetTicketDataQueryParams(payload);
1001
+ url = buildRequestUrl(apiBaseUrl, "/API_GetTicketData.php", authorization, queryParams);
1002
+ _context.next = 5;
1003
+ return call({
1004
+ url: url
1005
+ });
1006
+
1007
+ case 5:
1008
+ rawResponse = _context.sent;
1009
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1010
+ shouldCastToNumbers: ["ID", "AchievementID", "Points", "GameID", "ReportType", "ReportState", "OpenTickets"],
1011
+ shouldMapToBooleans: ["Hardcore"]
1012
+ }));
1013
+
1014
+ case 7:
1015
+ case "end":
1016
+ return _context.stop();
1017
+ }
1018
+ }
1019
+ }, _callee);
1020
+ }));
1021
+ return _getTicketData.apply(this, arguments);
1022
+ }
1023
+
1024
+ var buildGetTicketDataQueryParams = function buildGetTicketDataQueryParams(payload) {
1025
+ var ticketId = payload.ticketId,
1026
+ isGettingMostTicketedGames = payload.isGettingMostTicketedGames,
1027
+ userName = payload.userName,
1028
+ gameId = payload.gameId,
1029
+ isGettingTicketsForUnofficialAchievements = payload.isGettingTicketsForUnofficialAchievements,
1030
+ shouldReturnTicketsList = payload.shouldReturnTicketsList,
1031
+ achievementId = payload.achievementId;
1032
+ var queryParams = {};
1033
+
1034
+ if (ticketId !== undefined) {
1035
+ queryParams["i"] = ticketId;
1036
+ } else if (isGettingMostTicketedGames) {
1037
+ queryParams["f"] = "1";
1038
+ queryParams = applyPaginationQueryParams(queryParams, payload);
1039
+ } else if (userName) {
1040
+ queryParams["u"] = userName;
1041
+ } else if (gameId) {
1042
+ queryParams["g"] = gameId;
1043
+
1044
+ if (isGettingTicketsForUnofficialAchievements) {
1045
+ queryParams["f"] = "5";
1046
+ }
1047
+
1048
+ if (shouldReturnTicketsList) {
1049
+ queryParams["d"] = "1";
1050
+ }
1051
+ } else if (achievementId) {
1052
+ queryParams["a"] = achievementId;
1053
+ } else {
1054
+ queryParams = applyPaginationQueryParams(queryParams, payload);
1055
+ }
1056
+
1057
+ return queryParams;
1058
+ };
1059
+
1060
+ var applyPaginationQueryParams = function applyPaginationQueryParams(currentParams, payload) {
1061
+ var modifiedParams = _extends({}, currentParams);
1062
+
1063
+ if (payload.count !== undefined) {
1064
+ modifiedParams["c"] = payload.count;
1065
+ }
1066
+
1067
+ if (payload.offset !== undefined) {
1068
+ modifiedParams["o"] = payload.offset;
1069
+ }
1070
+
1071
+ return modifiedParams;
1072
+ };
1073
+
1074
+ /**
1075
+ * A call to this function will retrieve the current top ten users
1076
+ * on the site.
1077
+ *
1078
+ * @param authorization An object containing your userName and webApiKey.
1079
+ * This can be constructed with `buildAuthorization()`.
1080
+ *
1081
+ * @example
1082
+ * ```
1083
+ * const topTenUsers = await getTopTenUsers(authorization);
1084
+ * ```
1085
+ *
1086
+ * @returns An array containing the list of top ten users.
1087
+ * ```json
1088
+ * [
1089
+ * { userName: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
1090
+ * { userName: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
1091
+ * ...
1092
+ * ]
1093
+ * ```
1094
+ */
1095
+
1096
+ var getTopTenUsers = /*#__PURE__*/function () {
1097
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization) {
1098
+ var url, rawTopTenUsers, sanitizedTopTenUsers, _iterator, _step, rawUser;
1099
+
1100
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1101
+ while (1) {
1102
+ switch (_context.prev = _context.next) {
1103
+ case 0:
1104
+ url = buildRequestUrl(apiBaseUrl, "/API_GetTopTenUsers.php", authorization);
1105
+ _context.next = 3;
1106
+ return call({
1107
+ url: url
1108
+ });
1109
+
1110
+ case 3:
1111
+ rawTopTenUsers = _context.sent;
1112
+ sanitizedTopTenUsers = [];
1113
+
1114
+ for (_iterator = _createForOfIteratorHelperLoose(rawTopTenUsers); !(_step = _iterator()).done;) {
1115
+ rawUser = _step.value;
1116
+ sanitizedTopTenUsers.push({
1117
+ userName: rawUser["1"],
1118
+ totalPoints: Number(rawUser["2"]),
1119
+ totalRatioPoints: Number(rawUser["3"])
1120
+ });
1121
+ }
1122
+
1123
+ return _context.abrupt("return", sanitizedTopTenUsers);
1124
+
1125
+ case 7:
1126
+ case "end":
1127
+ return _context.stop();
1128
+ }
1129
+ }
1130
+ }, _callee);
1131
+ }));
1132
+
1133
+ return function getTopTenUsers(_x) {
1134
+ return _ref.apply(this, arguments);
1135
+ };
1136
+ }();
1137
+
1138
+ exports.ClaimType = void 0;
1139
+
1140
+ (function (ClaimType) {
1141
+ ClaimType[ClaimType["Primary"] = 0] = "Primary";
1142
+ ClaimType[ClaimType["Collaboration"] = 1] = "Collaboration";
1143
+ })(exports.ClaimType || (exports.ClaimType = {}));
1144
+
1145
+ exports.ClaimSetType = void 0;
1146
+
1147
+ (function (ClaimSetType) {
1148
+ ClaimSetType[ClaimSetType["NewSet"] = 0] = "NewSet";
1149
+ ClaimSetType[ClaimSetType["Revision"] = 1] = "Revision";
1150
+ })(exports.ClaimSetType || (exports.ClaimSetType = {}));
1151
+
1152
+ exports.ClaimStatus = void 0;
1153
+
1154
+ (function (ClaimStatus) {
1155
+ ClaimStatus[ClaimStatus["Active"] = 0] = "Active";
1156
+ ClaimStatus[ClaimStatus["Complete"] = 1] = "Complete";
1157
+ ClaimStatus[ClaimStatus["Dropped"] = 2] = "Dropped";
1158
+ })(exports.ClaimStatus || (exports.ClaimStatus = {}));
1159
+
1160
+ /**
1161
+ * A call to this function will retrieve the list of
1162
+ * achievement IDs for a game.
1163
+ *
1164
+ * @param authorization An object containing your userName and webApiKey.
1165
+ * This can be constructed with `buildAuthorization()`.
1166
+ *
1167
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1168
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1169
+ * URL is https://retroachievements.org/game/14402. We can see from the
1170
+ * URL that the game ID is "14402".
1171
+ *
1172
+ * @example
1173
+ * ```
1174
+ * const achievementCount = await getAchievementCount(
1175
+ * authorization,
1176
+ * { gameId: 14402 }
1177
+ * );
1178
+ * ```
1179
+ *
1180
+ * @returns An object containing a gameId and a list of
1181
+ * achievementIds.
1182
+ * ```
1183
+ * { gameId: 14402, achievementIds: [1,2,3,4,5] }
1184
+ * ```
1185
+ */
1186
+
1187
+ var getAchievementCount = /*#__PURE__*/function () {
1188
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1189
+ var gameId, url, rawResponse;
1190
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1191
+ while (1) {
1192
+ switch (_context.prev = _context.next) {
1193
+ case 0:
1194
+ gameId = payload.gameId;
1195
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementCount.php", authorization, {
1196
+ i: gameId
1197
+ });
1198
+ _context.next = 4;
1199
+ return call({
1200
+ url: url
1201
+ });
1202
+
1203
+ case 4:
1204
+ rawResponse = _context.sent;
1205
+ return _context.abrupt("return", serializeProperties(rawResponse));
1206
+
1207
+ case 6:
1208
+ case "end":
1209
+ return _context.stop();
1210
+ }
1211
+ }
1212
+ }, _callee);
1213
+ }));
1214
+
1215
+ return function getAchievementCount(_x, _x2) {
1216
+ return _ref.apply(this, arguments);
1217
+ };
1218
+ }();
1219
+
1220
+ /**
1221
+ * A call to this function will retrieve a dictionary
1222
+ * of the number of players who have earned a specific
1223
+ * number of achievements for a given game ID.
1224
+ *
1225
+ * @param authorization An object containing your userName and webApiKey.
1226
+ * This can be constructed with `buildAuthorization()`.
1227
+ *
1228
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1229
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1230
+ * URL is https://retroachievements.org/game/14402. We can see from the
1231
+ * URL that the game ID is "14402".
1232
+ *
1233
+ * @param payload.flags Optional. By default, only official achievement
1234
+ * tallies are returned in the response. Import the `AchievementDistributionFlags`
1235
+ * enum for possible values. This lets you see the count of players who have
1236
+ * unlocked unofficial achievements.
1237
+ *
1238
+ * @param payload.hardcore Optional. By default, set to false, with both
1239
+ * softcore and hardcore tallies returned in the response. If this option
1240
+ * is set to true, only hardcore unlocks will be included in the totals.
1241
+ *
1242
+ * @example
1243
+ * ```
1244
+ * const achievementDistribution = await getAchievementDistribution(
1245
+ * authorization,
1246
+ * { gameId: 14402, hardcore: true }
1247
+ * );
1248
+ * ```
1249
+ *
1250
+ * @returns A dictionary where the keys represent the earned achievement
1251
+ * count and the values represent the number of players who have unlocked
1252
+ * that many achievements.
1253
+ * ```
1254
+ * {
1255
+ * '1': 64,
1256
+ * '2': 19,
1257
+ * '3': 11,
1258
+ * '4': 18,
1259
+ * '5': 25,
1260
+ * '6': 20,
1261
+ * '7': 26,
1262
+ * '8': 29,
1263
+ * '9': 54,
1264
+ * '10': 17,
1265
+ * '11': 29,
1266
+ * '12': 4
1267
+ * }
1268
+ * ```
1269
+ */
1270
+
1271
+ var getAchievementDistribution = /*#__PURE__*/function () {
1272
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1273
+ var gameId, flags, hardcore, queryParams, url;
1274
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1275
+ while (1) {
1276
+ switch (_context.prev = _context.next) {
1277
+ case 0:
1278
+ gameId = payload.gameId, flags = payload.flags, hardcore = payload.hardcore;
1279
+ queryParams = {
1280
+ i: gameId
1281
+ };
1282
+
1283
+ if (flags !== undefined) {
1284
+ queryParams["f"] = flags;
1285
+ }
1286
+
1287
+ if (hardcore !== undefined) {
1288
+ queryParams["h"] = hardcore === true ? 1 : 0;
1289
+ }
1290
+
1291
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementDistribution.php", authorization, queryParams);
1292
+ _context.next = 7;
1293
+ return call({
1294
+ url: url
1295
+ });
1296
+
1297
+ case 7:
1298
+ return _context.abrupt("return", _context.sent);
1299
+
1300
+ case 8:
1301
+ case "end":
1302
+ return _context.stop();
1303
+ }
1304
+ }
1305
+ }, _callee);
1306
+ }));
1307
+
1308
+ return function getAchievementDistribution(_x, _x2) {
1309
+ return _ref.apply(this, arguments);
1310
+ };
1311
+ }();
1312
+
1313
+ /**
1314
+ * A call to this function will retrieve basic metadata about
1315
+ * a game, targeted via its unique ID.
1316
+ *
1317
+ * @param authorization An object containing your userName and webApiKey.
1318
+ * This can be constructed with `buildAuthorization()`.
1319
+ *
1320
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1321
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1322
+ * URL is https://retroachievements.org/game/14402. We can see from the
1323
+ * URL that the game ID is "14402".
1324
+ *
1325
+ * @example
1326
+ * ```
1327
+ * const game = await getGame(
1328
+ * authorization,
1329
+ * { gameId: 14402 }
1330
+ * );
1331
+ * ```
1332
+ *
1333
+ * @returns An object containing basic metadata about a target game.
1334
+ * ```json
1335
+ * {
1336
+ * id: 14402,
1337
+ * title: "Dragster",
1338
+ * forumTopicId: 9145,
1339
+ * consoleId: 25,
1340
+ * consoleName: "Atari 2600",
1341
+ * flags: 0,
1342
+ * imageIcon: "/Images/026368.png",
1343
+ * gameIcon: "/Images/026368.png",
1344
+ * imageTitle: "/Images/026366.png",
1345
+ * imageIngame: "/Images/026367.png",
1346
+ * imageBoxArt: "/Images/026365.png",
1347
+ * publisher: "Activision",
1348
+ * developer: "David Crane",
1349
+ * genre: "Racing",
1350
+ * released: 1980,
1351
+ * gameTitle: "Dragster",
1352
+ * console: "Atari 2600"
1353
+ * }
1354
+ * ```
1355
+ */
1356
+
1357
+ var getGame = /*#__PURE__*/function () {
1358
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1359
+ var gameId, url, rawResponse;
1360
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1361
+ while (1) {
1362
+ switch (_context.prev = _context.next) {
1363
+ case 0:
1364
+ gameId = payload.gameId;
1365
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGame.php", authorization, {
1366
+ i: gameId
1367
+ });
1368
+ _context.next = 4;
1369
+ return call({
1370
+ url: url
1371
+ });
1372
+
1373
+ case 4:
1374
+ rawResponse = _context.sent;
1375
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1376
+ shouldCastToNumbers: ["ID", "ForumTopicID", "ConsoleID", "Flags", "Released"]
1377
+ }));
1378
+
1379
+ case 6:
1380
+ case "end":
1381
+ return _context.stop();
1382
+ }
1383
+ }
1384
+ }, _callee);
1385
+ }));
1386
+
1387
+ return function getGame(_x, _x2) {
1388
+ return _ref.apply(this, arguments);
1389
+ };
1390
+ }();
1391
+
1392
+ /**
1393
+ * A call to this function will retrieve extended metadata
1394
+ * about a game, targeted via its unique ID.
1395
+ *
1396
+ * @param authorization An object containing your userName and webApiKey.
1397
+ * This can be constructed with `buildAuthorization()`.
1398
+ *
1399
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1400
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1401
+ * URL is https://retroachievements.org/game/14402. We can see from the
1402
+ * URL that the game ID is "14402".
1403
+ *
1404
+ * @example
1405
+ * ```
1406
+ * const gameExtended = await getGameExtended(
1407
+ * authorization,
1408
+ * { gameId: 14402 }
1409
+ * );
1410
+ * ```
1411
+ *
1412
+ * @returns An object containing extended metadata about a target game.
1413
+ * ```json
1414
+ * {
1415
+ * id: 14402,
1416
+ * title: "Dragster",
1417
+ * consoleId: 25,
1418
+ * forumTopicId: 9145,
1419
+ * flags: 0,
1420
+ * imageIcon: "/Images/026368.png",
1421
+ * imageTitle: "/Images/026366.png",
1422
+ * imageIngame: "/Images/026367.png",
1423
+ * imageBoxArt: "/Images/026365.png",
1424
+ * publisher: "Activision",
1425
+ * developer: "David Crane",
1426
+ * genre: "Racing",
1427
+ * released: 1980,
1428
+ * isFinal: false,
1429
+ * consoleName: "Atari 2600",
1430
+ * richPresencePatch: "2b92fa1bf9635c303b3b7f8feea3ed3c",
1431
+ * numAchievements: 12,
1432
+ * numDistinctPlayersCasual: 454,
1433
+ * numDistinctPlayersHardcore, 323
1434
+ * claims: [],
1435
+ * achievements: {
1436
+ * '79434': {
1437
+ * id: 79434,
1438
+ * numAwarded: 338,
1439
+ * numAwardedHardcore: 253,
1440
+ * title: "Novice Dragster Driver 1",
1441
+ * description: "Complete your very first race in game 1.",
1442
+ * points: 1,
1443
+ * trueRatio: 1,
1444
+ * author: "Boldewin",
1445
+ * dateModified: "2019-08-01 19:03:46",
1446
+ * dateCreated: "2019-07-31 18:49:57",
1447
+ * badgeName: "85541",
1448
+ * displayOrder: 0,
1449
+ * memAddr: "f5c41fa0b5fa0d5fbb8a74c598f18582"
1450
+ * }
1451
+ * }
1452
+ * }
1453
+ * ```
1454
+ */
1455
+
1456
+ var getGameExtended = /*#__PURE__*/function () {
1457
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1458
+ var gameId, url, rawResponse;
1459
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1460
+ while (1) {
1461
+ switch (_context.prev = _context.next) {
1462
+ case 0:
1463
+ gameId = payload.gameId;
1464
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGameExtended.php", authorization, {
1465
+ i: gameId
1466
+ });
1467
+ _context.next = 4;
1468
+ return call({
1469
+ url: url
1470
+ });
1471
+
1472
+ case 4:
1473
+ rawResponse = _context.sent;
1474
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1475
+ shouldCastToNumbers: ["ID", "NumAwarded", "NumAwardedHardcore", "Points", "TrueRatio", "DisplayOrder", "NumDistinctPlayersCasual", "NumDistinctPlayersHardcore", "Released"]
1476
+ }));
1477
+
1478
+ case 6:
1479
+ case "end":
1480
+ return _context.stop();
1481
+ }
1482
+ }
1483
+ }, _callee);
1484
+ }));
1485
+
1486
+ return function getGameExtended(_x, _x2) {
1487
+ return _ref.apply(this, arguments);
1488
+ };
1489
+ }();
1490
+
1491
+ /**
1492
+ * A call to this function will retrieve metadata about
1493
+ * either the latest masters for a game, or the highest
1494
+ * points earners for a game. The game is targeted via
1495
+ * its unique ID.
1496
+ *
1497
+ * @param authorization An object containing your userName and webApiKey.
1498
+ * This can be constructed with `buildAuthorization()`.
1499
+ *
1500
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1501
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1502
+ * URL is https://retroachievements.org/game/14402. We can see from the
1503
+ * URL that the game ID is "14402".
1504
+ *
1505
+ * @param payload.type Can either be "latest-masters" or "high-scores".
1506
+ *
1507
+ * @example
1508
+ * ```
1509
+ * const gameRankAndScore = await getGameRankAndScore(
1510
+ * authorization,
1511
+ * { gameId: 14402, type: "latest-masters" }
1512
+ * );
1513
+ * ```
1514
+ *
1515
+ * @returns An array containing a list of latest masters or
1516
+ * high score earners for a given game ID.
1517
+ * ```json
1518
+ * [
1519
+ * { user: 'Arekdias', totalScore: 189, lastAward: '2020-10-10 22:43:32' }
1520
+ * ]
1521
+ * ```
1522
+ */
1523
+
1524
+ var getGameRankAndScore = /*#__PURE__*/function () {
1525
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1526
+ var gameId, type, url, rawResponse;
1527
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1528
+ while (1) {
1529
+ switch (_context.prev = _context.next) {
1530
+ case 0:
1531
+ gameId = payload.gameId, type = payload.type;
1532
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGameRankAndScore.php", authorization, {
1533
+ g: gameId,
1534
+ t: type === "latest-masters" ? 1 : 0
1535
+ });
1536
+ _context.next = 4;
1537
+ return call({
1538
+ url: url
1539
+ });
1540
+
1541
+ case 4:
1542
+ rawResponse = _context.sent;
1543
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1544
+ shouldCastToNumbers: ["TotalScore"]
1545
+ }));
1546
+
1547
+ case 6:
1548
+ case "end":
1549
+ return _context.stop();
1550
+ }
1551
+ }
1552
+ }, _callee);
1553
+ }));
1554
+
1555
+ return function getGameRankAndScore(_x, _x2) {
1556
+ return _ref.apply(this, arguments);
1557
+ };
1558
+ }();
1559
+
1560
+ /**
1561
+ * A call to this function will retrieve metadata about
1562
+ * how users have rated the game and its set.
1563
+ *
1564
+ * @param authorization An object containing your userName and webApiKey.
1565
+ * This can be constructed with `buildAuthorization()`.
1566
+ *
1567
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1568
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1569
+ * URL is https://retroachievements.org/game/14402. We can see from the
1570
+ * URL that the game ID is "14402".
1571
+ *
1572
+ * @example
1573
+ * ```
1574
+ * const gameRating = await getGameRating(
1575
+ * authorization,
1576
+ * { gameId: 14402 }
1577
+ * );
1578
+ * ```
1579
+ *
1580
+ * @returns An object with game rating metadata.
1581
+ * ```json
1582
+ * {
1583
+ * gameId: 14402,
1584
+ * ratings: {
1585
+ * game: 3.1875,
1586
+ * achievements: 0,
1587
+ * gameNumVotes: 16,
1588
+ * achievementsNumVotes: 0
1589
+ * }
1590
+ * }
1591
+ * ```
1592
+ */
1593
+
1594
+ var getGameRating = /*#__PURE__*/function () {
1595
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1596
+ var gameId, url, rawResponse;
1597
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1598
+ while (1) {
1599
+ switch (_context.prev = _context.next) {
1600
+ case 0:
1601
+ gameId = payload.gameId;
1602
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGameRating.php", authorization, {
1603
+ i: gameId
1604
+ });
1605
+ _context.next = 4;
1606
+ return call({
1607
+ url: url
1608
+ });
1609
+
1610
+ case 4:
1611
+ rawResponse = _context.sent;
1612
+ return _context.abrupt("return", serializeProperties(rawResponse));
1613
+
1614
+ case 6:
1615
+ case "end":
1616
+ return _context.stop();
1617
+ }
1618
+ }
1619
+ }, _callee);
1620
+ }));
1621
+
1622
+ return function getGameRating(_x, _x2) {
1623
+ return _ref.apply(this, arguments);
1624
+ };
1625
+ }();
1626
+
1627
+ exports.AchievementDistributionFlags = void 0;
1628
+
1629
+ (function (AchievementDistributionFlags) {
1630
+ AchievementDistributionFlags[AchievementDistributionFlags["CoreAchievements"] = 3] = "CoreAchievements";
1631
+ AchievementDistributionFlags[AchievementDistributionFlags["UnofficialAchievements"] = 5] = "UnofficialAchievements";
1632
+ })(exports.AchievementDistributionFlags || (exports.AchievementDistributionFlags = {}));
1633
+
1634
+ // NOTE: This cannot be a true extension of the `GetGameResponse`
1635
+ // interface because the return types for many of these fields
1636
+ // are different from the actual RA API.
1637
+ var GameExtendedClaimType;
1638
+
1639
+ (function (GameExtendedClaimType) {
1640
+ GameExtendedClaimType["Primary"] = "0";
1641
+ GameExtendedClaimType["Collaboration"] = "1";
1642
+ })(GameExtendedClaimType || (GameExtendedClaimType = {}));
1643
+
1644
+ /**
1645
+ * A call to this function will retrieve a list of achievements
1646
+ * earned by a given user between two provided dates.
1647
+ *
1648
+ * @param authorization An object containing your userName and webApiKey.
1649
+ * This can be constructed with `buildAuthorization()`.
1650
+ *
1651
+ * @param payload.userName The user for which to retrieve the
1652
+ * list of achievements for.
1653
+ *
1654
+ * @param payload.fromDate A Date object specifying when
1655
+ * the list itself should begin.
1656
+ *
1657
+ * @param payload.toDate A Date object specifying when
1658
+ * the list itself should end.
1659
+ *
1660
+ * @example
1661
+ * ```
1662
+ * const achievementsEarnedBetween = await getAchievementsEarnedBetween(
1663
+ * authorization,
1664
+ * {
1665
+ * userName: "xelnia",
1666
+ * fromDate: new Date("2022-10-12"),
1667
+ * toDate: new Date("2022-10-13")
1668
+ * }
1669
+ * );
1670
+ * ```
1671
+ *
1672
+ * @returns An array containing metadata about the user
1673
+ * achievements earned during the specified date range.
1674
+ * ```
1675
+ * [
1676
+ * {
1677
+ * date: '2022-10-12 07:58:05',
1678
+ * hardcoreMode: true,
1679
+ * achievementId: 173315,
1680
+ * title: 'Your Puny Human Weapons',
1681
+ * description: 'Collect all objects in the Weapons Category.',
1682
+ * badgeName: '193756',
1683
+ * points: 10,
1684
+ * author: 'blendedsea',
1685
+ * gameTitle: 'Me & My Katamari',
1686
+ * gameIcon: '/Images/047357.png',
1687
+ * gameId: 3571,
1688
+ * consoleName: 'PlayStation Portable',
1689
+ * cumulScore: 120,
1690
+ * badgeUrl: '/Badge/193756.png',
1691
+ * gameUrl: '/game/3571'
1692
+ * }
1693
+ * ]
1694
+ * ```
1695
+ */
1696
+
1697
+ var getAchievementsEarnedBetween = /*#__PURE__*/function () {
1698
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1699
+ var userName, fromDate, toDate, url, rawResponse;
1700
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1701
+ while (1) {
1702
+ switch (_context.prev = _context.next) {
1703
+ case 0:
1704
+ userName = payload.userName, fromDate = payload.fromDate, toDate = payload.toDate;
1705
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementsEarnedBetween.php", authorization, {
1706
+ u: userName,
1707
+ f: (fromDate.getTime() / 1000).toFixed(0),
1708
+ t: (toDate.getTime() / 1000).toFixed(0)
1709
+ });
1710
+ _context.next = 4;
1711
+ return call({
1712
+ url: url
1713
+ });
1714
+
1715
+ case 4:
1716
+ rawResponse = _context.sent;
1717
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1718
+ shouldCastToNumbers: ["AchievementID", "Points", "GameID"],
1719
+ shouldMapToBooleans: ["HardcoreMode"]
1720
+ }));
1721
+
1722
+ case 6:
1723
+ case "end":
1724
+ return _context.stop();
1725
+ }
1726
+ }
1727
+ }, _callee);
1728
+ }));
1729
+
1730
+ return function getAchievementsEarnedBetween(_x, _x2) {
1731
+ return _ref.apply(this, arguments);
1732
+ };
1733
+ }();
1734
+
1735
+ /**
1736
+ * A call to this function will retrieve a list of achievements
1737
+ * earned by a given user on a specified date.
1738
+ *
1739
+ * @param authorization An object containing your userName and webApiKey.
1740
+ * This can be constructed with `buildAuthorization()`.
1741
+ *
1742
+ * @param payload.userName The user for which to retrieve the
1743
+ * list of achievements for.
1744
+ *
1745
+ * @param payload.fromDate A Date object specifying when
1746
+ * the list itself should begin.
1747
+ *
1748
+ * @param payload.onDate A Date object specifying the day
1749
+ * to query for a user's earned achievements.
1750
+ *
1751
+ * @example
1752
+ * ```
1753
+ * const achievementsEarnedOnDay = await getAchievementsEarnedOnDay(
1754
+ * authorization,
1755
+ * {
1756
+ * userName: "xelnia",
1757
+ * onDate: new Date("2022-10-13")
1758
+ * }
1759
+ * );
1760
+ * ```
1761
+ *
1762
+ * @returns An array containing metadata about the user
1763
+ * achievements earned on the specified day.
1764
+ * ```
1765
+ * [
1766
+ * {
1767
+ * date: '2022-10-12 07:58:05',
1768
+ * hardcoreMode: true,
1769
+ * achievementId: 173315,
1770
+ * title: 'Your Puny Human Weapons',
1771
+ * description: 'Collect all objects in the Weapons Category.',
1772
+ * badgeName: '193756',
1773
+ * points: 10,
1774
+ * author: 'blendedsea',
1775
+ * gameTitle: 'Me & My Katamari',
1776
+ * gameIcon: '/Images/047357.png',
1777
+ * gameId: 3571,
1778
+ * consoleName: 'PlayStation Portable',
1779
+ * cumulScore: 120,
1780
+ * badgeUrl: '/Badge/193756.png',
1781
+ * gameUrl: '/game/3571'
1782
+ * }
1783
+ * ]
1784
+ * ```
1785
+ */
1786
+
1787
+ var getAchievementsEarnedOnDay = /*#__PURE__*/function () {
1788
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1789
+ var userName, onDate, url, rawResponse;
1790
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1791
+ while (1) {
1792
+ switch (_context.prev = _context.next) {
1793
+ case 0:
1794
+ userName = payload.userName, onDate = payload.onDate;
1795
+ url = buildRequestUrl(apiBaseUrl, "/API_GetAchievementsEarnedOnDay.php", authorization, {
1796
+ u: userName,
1797
+ // YYYY-MM-DD
1798
+ d: onDate.getFullYear() + "-" + (onDate.getMonth() + 1) + "-" + onDate.getDate()
1799
+ });
1800
+ _context.next = 4;
1801
+ return call({
1802
+ url: url
1803
+ });
1804
+
1805
+ case 4:
1806
+ rawResponse = _context.sent;
1807
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1808
+ shouldCastToNumbers: ["AchievementID", "Points", "GameID"],
1809
+ shouldMapToBooleans: ["HardcoreMode"]
1810
+ }));
1811
+
1812
+ case 6:
1813
+ case "end":
1814
+ return _context.stop();
1815
+ }
1816
+ }
1817
+ }, _callee);
1818
+ }));
1819
+
1820
+ return function getAchievementsEarnedOnDay(_x, _x2) {
1821
+ return _ref.apply(this, arguments);
1822
+ };
1823
+ }();
1824
+
1825
+ /**
1826
+ * A call to this function will retrieve extended metadata
1827
+ * about a game, in addition to a user's progress about a game.
1828
+ * This is targeted via a game's unique ID and a given username.
1829
+ *
1830
+ * @param authorization An object containing your userName and webApiKey.
1831
+ * This can be constructed with `buildAuthorization()`.
1832
+ *
1833
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1834
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1835
+ * URL is https://retroachievements.org/game/14402. We can see from the
1836
+ * URL that the game ID is "14402".
1837
+ *
1838
+ * @param payload.userName The user for which to retrieve the
1839
+ * game progress for.
1840
+ *
1841
+ * @example
1842
+ * ```
1843
+ * const gameInfoAndUserProgress = await getGameInfoAndUserProgress(
1844
+ * authorization,
1845
+ * { gameId: 14402, userName: "wv_pinball" }
1846
+ * );
1847
+ * ```
1848
+ *
1849
+ * @returns An object containing extended metadata about a target game,
1850
+ * with attached progress for a target username.
1851
+ * ```json
1852
+ * {
1853
+ * id: 14402,
1854
+ * title: "Dragster",
1855
+ * consoleId: 25,
1856
+ * forumTopicId: 9145,
1857
+ * flags: 0,
1858
+ * imageIcon: "/Images/026368.png",
1859
+ * imageTitle: "/Images/026366.png",
1860
+ * imageIngame: "/Images/026367.png",
1861
+ * imageBoxArt: "/Images/026365.png",
1862
+ * publisher: "Activision",
1863
+ * developer: "David Crane",
1864
+ * genre: "Racing",
1865
+ * released: 1980,
1866
+ * isFinal: false,
1867
+ * consoleName: "Atari 2600",
1868
+ * richPresencePatch: "2b92fa1bf9635c303b3b7f8feea3ed3c",
1869
+ * numAchievements: 12,
1870
+ * numDistinctPlayersCasual: 454,
1871
+ * numDistinctPlayersHardcore, 323
1872
+ * claims: [],
1873
+ * achievements: {
1874
+ * '79434': {
1875
+ * id: 79434,
1876
+ * numAwarded: 338,
1877
+ * numAwardedHardcore: 253,
1878
+ * title: "Novice Dragster Driver 1",
1879
+ * description: "Complete your very first race in game 1.",
1880
+ * points: 1,
1881
+ * trueRatio: 1,
1882
+ * author: "Boldewin",
1883
+ * dateModified: "2019-08-01 19:03:46",
1884
+ * dateCreated: "2019-07-31 18:49:57",
1885
+ * badgeName: "85541",
1886
+ * displayOrder: 0,
1887
+ * memAddr: "f5c41fa0b5fa0d5fbb8a74c598f18582",
1888
+ * dateEarned: '2022-08-23 22:56:38',
1889
+ * dateEarnedHardcore: '2022-08-23 22:56:38'
1890
+ * }
1891
+ * },
1892
+ * numAwardedToUser: 12,
1893
+ * numAwardedToUserHardcore: 12,
1894
+ * userCompletion: "100.00%",
1895
+ * userCompletionHardcore: "100.00%"
1896
+ * }
1897
+ * ```
1898
+ */
1899
+
1900
+ var getGameInfoAndUserProgress = /*#__PURE__*/function () {
1901
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1902
+ var gameId, userName, url, rawResponse;
1903
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1904
+ while (1) {
1905
+ switch (_context.prev = _context.next) {
1906
+ case 0:
1907
+ gameId = payload.gameId, userName = payload.userName;
1908
+ url = buildRequestUrl(apiBaseUrl, "/API_GetGameInfoAndUserProgress.php", authorization, {
1909
+ g: gameId,
1910
+ u: userName
1911
+ });
1912
+ _context.next = 4;
1913
+ return call({
1914
+ url: url
1915
+ });
1916
+
1917
+ case 4:
1918
+ rawResponse = _context.sent;
1919
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1920
+ shouldCastToNumbers: ["ID", "NumAwarded", "NumAwardedHardcore", "Points", "TrueRatio", "DisplayOrder", "NumDistinctPlayersCasual", "NumDistinctPlayersHardcore", "Released"]
1921
+ }));
1922
+
1923
+ case 6:
1924
+ case "end":
1925
+ return _context.stop();
1926
+ }
1927
+ }
1928
+ }, _callee);
1929
+ }));
1930
+
1931
+ return function getGameInfoAndUserProgress(_x, _x2) {
1932
+ return _ref.apply(this, arguments);
1933
+ };
1934
+ }();
1935
+
1936
+ /**
1937
+ * A call to this function will retrieve metadata about
1938
+ * how a particular user has performed/ranked on a particular
1939
+ * game, targeted by game ID.
1940
+ *
1941
+ * @param authorization An object containing your userName and webApiKey.
1942
+ * This can be constructed with `buildAuthorization()`.
1943
+ *
1944
+ * @param payload.gameId The unique game ID. If you are unsure, open the
1945
+ * game's page on the RetroAchievements.org website. For example, Dragster's
1946
+ * URL is https://retroachievements.org/game/14402. We can see from the
1947
+ * URL that the game ID is "14402".
1948
+ *
1949
+ * @param payload.userName The user for which to retrieve the
1950
+ * game ranking metadata for.
1951
+ *
1952
+ * @example
1953
+ * ```
1954
+ * const userGameRankAndScore = await getUserGameRankAndScore(
1955
+ * authorization,
1956
+ * { gameId: 14402, userName: "xelnia" }
1957
+ * );
1958
+ * ```
1959
+ *
1960
+ * @returns An array containing metadata about the user's
1961
+ * rank and score for the target game ID. If metadata
1962
+ * cannot be found, the array is empty.
1963
+ * ```
1964
+ * [
1965
+ * {
1966
+ * user: "xelnia",
1967
+ * totalScore: 378,
1968
+ * lastAward: "2022-09-01 21:51:23",
1969
+ * userRank: 3
1970
+ * }
1971
+ * ]
1972
+ * ```
1973
+ */
1974
+
1975
+ var getUserGameRankAndScore = /*#__PURE__*/function () {
1976
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
1977
+ var gameId, userName, url, rawResponse;
1978
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1979
+ while (1) {
1980
+ switch (_context.prev = _context.next) {
1981
+ case 0:
1982
+ gameId = payload.gameId, userName = payload.userName;
1983
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserGameRankAndScore.php", authorization, {
1984
+ g: gameId,
1985
+ u: userName
1986
+ });
1987
+ _context.next = 4;
1988
+ return call({
1989
+ url: url
1990
+ });
1991
+
1992
+ case 4:
1993
+ rawResponse = _context.sent;
1994
+ return _context.abrupt("return", serializeProperties(rawResponse, {
1995
+ shouldCastToNumbers: ["TotalScore", "UserRank"]
1996
+ }));
1997
+
1998
+ case 6:
1999
+ case "end":
2000
+ return _context.stop();
2001
+ }
2002
+ }
2003
+ }, _callee);
2004
+ }));
2005
+
2006
+ return function getUserGameRankAndScore(_x, _x2) {
2007
+ return _ref.apply(this, arguments);
2008
+ };
2009
+ }();
2010
+
2011
+ /**
2012
+ * A call to this function will retrieve a given user's hardcore
2013
+ * and softcore points.
2014
+ *
2015
+ * @param authorization An object containing your userName and webApiKey.
2016
+ * This can be constructed with `buildAuthorization()`.
2017
+ *
2018
+ * @param payload.userName The user for which to retrieve the points for.
2019
+ *
2020
+ * @example
2021
+ * ```
2022
+ * const userPoints = await getUserPoints(
2023
+ * authorization,
2024
+ * { userName: "xelnia" }
2025
+ * );
2026
+ * ```
2027
+ *
2028
+ * @returns An object containing metadata about a target user's points.
2029
+ * ```json
2030
+ * {
2031
+ * points: 7640,
2032
+ * softcorePoints: 25
2033
+ * }
2034
+ * ```
2035
+ */
2036
+
2037
+ var getUserPoints = /*#__PURE__*/function () {
2038
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
2039
+ var userName, url, rawResponse;
2040
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2041
+ while (1) {
2042
+ switch (_context.prev = _context.next) {
2043
+ case 0:
2044
+ userName = payload.userName;
2045
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserPoints.php", authorization, {
2046
+ u: userName
2047
+ });
2048
+ _context.next = 4;
2049
+ return call({
2050
+ url: url
2051
+ });
2052
+
2053
+ case 4:
2054
+ rawResponse = _context.sent;
2055
+ return _context.abrupt("return", serializeProperties(rawResponse));
2056
+
2057
+ case 6:
2058
+ case "end":
2059
+ return _context.stop();
2060
+ }
2061
+ }
2062
+ }, _callee);
2063
+ }));
2064
+
2065
+ return function getUserPoints(_x, _x2) {
2066
+ return _ref.apply(this, arguments);
2067
+ };
2068
+ }();
2069
+
2070
+ /**
2071
+ * A call to this function will retrieve a given user's
2072
+ * progress on a given set of games, targeted by game ID.
2073
+ *
2074
+ * @param authorization An object containing your userName and webApiKey.
2075
+ * This can be constructed with `buildAuthorization()`.
2076
+ *
2077
+ * @param payload.userName The user for which to retrieve the progress for.
2078
+ *
2079
+ * @param payload.gameIds An array of RetroAchievements Game IDs. If you aren't
2080
+ * sure of the game ID, visit the game's page on the website and copy the number
2081
+ * at the end of the URL.
2082
+ *
2083
+ * @example
2084
+ * ```
2085
+ * const userProgress = await getUserProgress(
2086
+ * authorization,
2087
+ * { userName: "xelnia", gameIds: [14402, 1] }
2088
+ * );
2089
+ * ```
2090
+ *
2091
+ * @returns An object which is a map of summarized progress for games.
2092
+ * ```json
2093
+ * {
2094
+ * "1": {
2095
+ * numPossibleAchievements: 24,
2096
+ * possibleScore: 255,
2097
+ * numAchieved: 0,
2098
+ * scoreAchieved: 0,
2099
+ * numAchievedHardcore: 0,
2100
+ * scoreAchievedHardcore: 0
2101
+ * },
2102
+ * "14402": {
2103
+ * numPossibleAchievements: 24,
2104
+ * possibleScore: 255,
2105
+ * numAchieved: 0,
2106
+ * scoreAchieved: 0,
2107
+ * numAchievedHardcore: 0,
2108
+ * scoreAchievedHardcore: 0
2109
+ * }
2110
+ * }
2111
+ * ```
2112
+ */
2113
+
2114
+ var getUserProgress = /*#__PURE__*/function () {
2115
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
2116
+ var userName, gameIds, url, rawResponse;
2117
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2118
+ while (1) {
2119
+ switch (_context.prev = _context.next) {
2120
+ case 0:
2121
+ userName = payload.userName, gameIds = payload.gameIds;
2122
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserProgress.php", authorization, {
2123
+ u: userName,
2124
+ i: gameIds.join(",")
2125
+ });
2126
+ _context.next = 4;
2127
+ return call({
2128
+ url: url
2129
+ });
2130
+
2131
+ case 4:
2132
+ rawResponse = _context.sent;
2133
+ return _context.abrupt("return", serializeProperties(rawResponse, {
2134
+ shouldCastToNumbers: ["NumPossibleAchievements", "PossibleScore", "NumAchieved", "ScoreAchieved", "NumAchievedHardcore", "ScoreAchievedHardcore"]
2135
+ }));
2136
+
2137
+ case 6:
2138
+ case "end":
2139
+ return _context.stop();
2140
+ }
2141
+ }
2142
+ }, _callee);
2143
+ }));
2144
+
2145
+ return function getUserProgress(_x, _x2) {
2146
+ return _ref.apply(this, arguments);
2147
+ };
2148
+ }();
2149
+
2150
+ /**
2151
+ * A call to this function will retrieve a list of a target user's
2152
+ * recently played games, targeted by username.
2153
+ *
2154
+ * @param authorization An object containing your userName and webApiKey.
2155
+ * This can be constructed with `buildAuthorization()`.
2156
+ *
2157
+ * @param payload.userName The user for which to retrieve the summary for.
2158
+ *
2159
+ * @param payload.count Optional. Defaults to 10. Max is 50. How many
2160
+ * recently played games for the user to retrieve.
2161
+ *
2162
+ * @param payload.offset Optional. Defaults to 0. Number of recently played
2163
+ * game entries to skip. This can be used for pagination.
2164
+ *
2165
+ * @example
2166
+ * ```
2167
+ * const userRecentlyPlayedGames = await getUserRecentlyPlayedGames(
2168
+ * authorization,
2169
+ * { userName: "xelnia" }
2170
+ * );
2171
+ * ```
2172
+ *
2173
+ * @returns An array containing metadata about a user's recently played games.
2174
+ * ```json
2175
+ * [
2176
+ * {
2177
+ * gameId: 19010,
2178
+ * consoleId: 21,
2179
+ * consoleName: "PlayStation 2",
2180
+ * title: "Simpsons, The: Hit & Run",
2181
+ * imageIcon: "/Images/066024.png",
2182
+ * lastPlayed: "2022-10-24 22:05:12",
2183
+ * numPossibleAchievements: 131,
2184
+ * possibleScore: 865,
2185
+ * numAchieved: 23,
2186
+ * scoreAchieved: 84,
2187
+ * numAchievedHardcore: 23,
2188
+ * scoreAchievedHardcore: 84
2189
+ * }
2190
+ * ]
2191
+ * ```
2192
+ */
2193
+
2194
+ var getUserRecentlyPlayedGames = /*#__PURE__*/function () {
2195
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
2196
+ var userName, offset, count, queryParams, url, rawResponse;
2197
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2198
+ while (1) {
2199
+ switch (_context.prev = _context.next) {
2200
+ case 0:
2201
+ userName = payload.userName, offset = payload.offset, count = payload.count;
2202
+ queryParams = {
2203
+ u: userName
2204
+ };
2205
+
2206
+ if (offset !== undefined) {
2207
+ queryParams["o"] = offset;
2208
+ }
2209
+
2210
+ if (count !== undefined) {
2211
+ queryParams["c"] = count;
2212
+ }
2213
+
2214
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserRecentlyPlayedGames.php", authorization, queryParams);
2215
+ _context.next = 7;
2216
+ return call({
2217
+ url: url
2218
+ });
2219
+
2220
+ case 7:
2221
+ rawResponse = _context.sent;
2222
+ return _context.abrupt("return", serializeProperties(rawResponse, {
2223
+ shouldCastToNumbers: ["GameID", "ConsoleID", "NumPossibleAchievements", "PossibleScore", "NumAchieved", "ScoreAchieved", "NumAchievedHardcore", "ScoreAchievedHardcore"]
2224
+ }));
2225
+
2226
+ case 9:
2227
+ case "end":
2228
+ return _context.stop();
2229
+ }
2230
+ }
2231
+ }, _callee);
2232
+ }));
2233
+
2234
+ return function getUserRecentlyPlayedGames(_x, _x2) {
2235
+ return _ref.apply(this, arguments);
2236
+ };
2237
+ }();
2238
+
2239
+ /**
2240
+ * A call to this function will retrieve summary information about
2241
+ * a given user, targeted by username.
2242
+ *
2243
+ * @param authorization An object containing your userName and webApiKey.
2244
+ * This can be constructed with `buildAuthorization()`.
2245
+ *
2246
+ * @param payload.userName The user for which to retrieve the summary for.
2247
+ *
2248
+ * @param payload.recentGamesCount Optional. The number of recent games to return.
2249
+ * This defaults to 5.
2250
+ *
2251
+ * @param payload.recentAchievementsCount Optional. The number of recent achievements
2252
+ * to return. This defaults to 5.
2253
+ *
2254
+ * @example
2255
+ * ```
2256
+ * const userSummary = await getUserSummary(
2257
+ * authorization,
2258
+ * { userName: "xelnia" }
2259
+ * );
2260
+ * ```
2261
+ *
2262
+ * @returns An object containing summary metadata about a target user.
2263
+ */
2264
+
2265
+ var getUserSummary = /*#__PURE__*/function () {
2266
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authorization, payload) {
2267
+ var userName, recentGamesCount, recentAchievementsCount, queryParams, url, rawResponse;
2268
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2269
+ while (1) {
2270
+ switch (_context.prev = _context.next) {
2271
+ case 0:
2272
+ userName = payload.userName, recentGamesCount = payload.recentGamesCount, recentAchievementsCount = payload.recentAchievementsCount;
2273
+ queryParams = {
2274
+ u: userName
2275
+ };
2276
+
2277
+ if (recentGamesCount !== undefined) {
2278
+ queryParams["g"] = recentGamesCount;
2279
+ }
2280
+
2281
+ if (recentAchievementsCount !== undefined) {
2282
+ queryParams["a"] = recentAchievementsCount;
2283
+ }
2284
+
2285
+ url = buildRequestUrl(apiBaseUrl, "/API_GetUserSummary.php", authorization, queryParams);
2286
+ _context.next = 7;
2287
+ return call({
2288
+ url: url
2289
+ });
2290
+
2291
+ case 7:
2292
+ rawResponse = _context.sent;
2293
+ return _context.abrupt("return", serializeProperties(rawResponse, {
2294
+ shouldCastToNumbers: ["GameID", "ConsoleID", "ID", "LastGameID", "ForumTopicID", "activitytype", "ContribCount", "ContribYield", "TotalPoints", "TotalSoftcorePoints", "TotalTruePoints", "Permissions", "NumPossibleAchievements", "PossibleScore", "NumAchieved", "ScoreAchieved", "NumAchievedHardcore", "ScoreAchievedHardcore", "Points", "SoftcorePoints"],
2295
+ shouldMapToBooleans: ["Untracked", "UserWallActive", "IsAwarded", "HardcoreAchieved"]
2296
+ }));
2297
+
2298
+ case 9:
2299
+ case "end":
2300
+ return _context.stop();
2301
+ }
2302
+ }
2303
+ }, _callee);
2304
+ }));
2305
+
2306
+ return function getUserSummary(_x, _x2) {
2307
+ return _ref.apply(this, arguments);
2308
+ };
2309
+ }(); // TODO: add test for this
2310
+
2311
+ /**
2312
+ * Accepts your RetroAchievements.org userName and web API key. After
2313
+ * receiving these inputs, the function returns you a value that can be
2314
+ * used for the authentication parameter by any of the async calls in this
2315
+ * library.
2316
+ *
2317
+ * Your account's personal Web API Key can be found on the Settings page
2318
+ * of RetroAchievements.org. Do not use a Web API Key that is not associated
2319
+ * with your account.
2320
+ *
2321
+ * @returns An `AuthObject` that you can pass to any of the API call functions.
2322
+ *
2323
+ * @example
2324
+ * ```
2325
+ * const authorization = buildAuthorization({
2326
+ * userName: "Scott",
2327
+ * webApiKey: "LtjCwW16nJI7cqOyPIQtXk8v1cfF0tmO"
2328
+ * });
2329
+ * ```
2330
+ */
2331
+ var buildAuthorization = function buildAuthorization(options) {
2332
+ if (!options.userName || !options.webApiKey) {
2333
+ 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 ");
2334
+ }
2335
+
2336
+ return options;
2337
+ }; // This function simply returns what it's given, however the return
2338
+ // value has the added benefit of type safety.
2339
+
2340
+ exports.buildAuthorization = buildAuthorization;
2341
+ exports.getAchievementCount = getAchievementCount;
2342
+ exports.getAchievementDistribution = getAchievementDistribution;
2343
+ exports.getAchievementOfTheWeek = getAchievementOfTheWeek;
2344
+ exports.getAchievementUnlocks = getAchievementUnlocks;
2345
+ exports.getAchievementsEarnedBetween = getAchievementsEarnedBetween;
2346
+ exports.getAchievementsEarnedOnDay = getAchievementsEarnedOnDay;
2347
+ exports.getActiveClaims = getActiveClaims;
2348
+ exports.getConsoleIds = getConsoleIds;
2349
+ exports.getGame = getGame;
2350
+ exports.getGameExtended = getGameExtended;
2351
+ exports.getGameInfoAndUserProgress = getGameInfoAndUserProgress;
2352
+ exports.getGameList = getGameList;
2353
+ exports.getGameRankAndScore = getGameRankAndScore;
2354
+ exports.getGameRating = getGameRating;
2355
+ exports.getTicketData = getTicketData;
2356
+ exports.getTopTenUsers = getTopTenUsers;
2357
+ exports.getUserGameRankAndScore = getUserGameRankAndScore;
2358
+ exports.getUserPoints = getUserPoints;
2359
+ exports.getUserProgress = getUserProgress;
2360
+ exports.getUserRecentlyPlayedGames = getUserRecentlyPlayedGames;
2361
+ exports.getUserSummary = getUserSummary;
2362
+ exports.unsafe_call = call;
2363
+ //# sourceMappingURL=api.cjs.development.js.map