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