@retroachievements/api 2.8.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/api.cjs +1 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.modern.js +1 -1
- package/dist/api.modern.js.map +1 -1
- package/dist/api.module.js +1 -1
- package/dist/api.module.js.map +1 -1
- package/dist/api.umd.js +1 -1
- package/dist/api.umd.js.map +1 -1
- package/dist/game/getGameProgression.d.ts +83 -0
- package/dist/game/getGameProgression.test.d.ts +1 -0
- package/dist/game/index.d.ts +1 -0
- package/dist/game/models/game-progression.model.d.ts +32 -0
- package/dist/game/models/get-game-progression-response.model.d.ts +32 -0
- package/dist/game/models/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/game/getGameProgression.test.ts +114 -0
- package/src/game/getGameProgression.ts +112 -0
- package/src/game/index.ts +1 -0
- package/src/game/models/game-progression.model.ts +32 -0
- package/src/game/models/get-game-progression-response.model.ts +32 -0
- package/src/game/models/index.ts +2 -0
- package/src/utils/internal/serializeProperties.test.ts +30 -24
- package/src/utils/internal/serializeProperties.ts +5 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
2
|
+
import type { AuthObject } from "../utils/public";
|
|
3
|
+
import type { GameProgression } from "./models";
|
|
4
|
+
/**
|
|
5
|
+
* A call to this function will retrieve information about the average time to unlock achievements in a game.
|
|
6
|
+
*
|
|
7
|
+
* @param authorization An object containing your username and webApiKey.
|
|
8
|
+
* This can be constructed with `buildAuthorization()`.
|
|
9
|
+
*
|
|
10
|
+
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
11
|
+
* game's page on the RetroAchievements.org website. For example, Dragster's
|
|
12
|
+
* URL is https://retroachievements.org/game/14402. We can see from the
|
|
13
|
+
* URL that the game ID is "14402".
|
|
14
|
+
*
|
|
15
|
+
* @param payload.hardcore Optional. If set to true, the player sampling
|
|
16
|
+
* for median calculations will prefer players based on their hardcore
|
|
17
|
+
* unlock count rather than their total unlock count.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```
|
|
21
|
+
* const game = await getGameProgression(
|
|
22
|
+
* authorization,
|
|
23
|
+
* { gameId: 14402, hardcore: true }
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @returns An object containing information about the average time to unlock achievements in a game.
|
|
28
|
+
* ```json
|
|
29
|
+
* {
|
|
30
|
+
* "id": 228,
|
|
31
|
+
* "title": "Super Mario World",
|
|
32
|
+
* "consoleId": 3,
|
|
33
|
+
* "consoleName": "SNES/Super Famicom",
|
|
34
|
+
* "imageIcon": "/Images/112443.png",
|
|
35
|
+
* "numDistinctPlayers": 79281,
|
|
36
|
+
* "timesUsedInBeatMedian": 4493,
|
|
37
|
+
* "timesUsedInHardcoreBeatMedian": 8249,
|
|
38
|
+
* "medianTimeToBeat": 17878,
|
|
39
|
+
* "medianTimeToBeatHardcore": 19224,
|
|
40
|
+
* "timesUsedInCompletionMedian": 155,
|
|
41
|
+
* "timesUsedInMasteryMedian": 1091,
|
|
42
|
+
* "medianTimeToComplete": 67017,
|
|
43
|
+
* "medianTimeToMaster": 79744,
|
|
44
|
+
* "numAchievements": 89,
|
|
45
|
+
* "achievements": [
|
|
46
|
+
* {
|
|
47
|
+
* "id": 342,
|
|
48
|
+
* "title": "Giddy Up!",
|
|
49
|
+
* "description": "Catch a ride with a friend",
|
|
50
|
+
* "points": 1,
|
|
51
|
+
* "trueRatio": 1,
|
|
52
|
+
* "type": null,
|
|
53
|
+
* "badgeName": "46580",
|
|
54
|
+
* "numAwarded": 75168,
|
|
55
|
+
* "numAwardedHardcore": 37024,
|
|
56
|
+
* "timesUsedInUnlockMedian": 63,
|
|
57
|
+
* "timesUsedInHardcoreUnlockMedian": 69,
|
|
58
|
+
* "medianTimeToUnlock": 274,
|
|
59
|
+
* "medianTimeToUnlockHardcore": 323
|
|
60
|
+
* },
|
|
61
|
+
* {
|
|
62
|
+
* "id": 341,
|
|
63
|
+
* "title": "Unleash The Dragon",
|
|
64
|
+
* "description": "Collect 5 Dragon Coins in a level",
|
|
65
|
+
* "points": 2,
|
|
66
|
+
* "trueRatio": 2,
|
|
67
|
+
* "type": null,
|
|
68
|
+
* "badgeName": "46591",
|
|
69
|
+
* "numAwarded": 66647,
|
|
70
|
+
* "numAwardedHardcore": 34051,
|
|
71
|
+
* "timesUsedInUnlockMedian": 66,
|
|
72
|
+
* "timesUsedInHardcoreUnlockMedian": 70,
|
|
73
|
+
* "medianTimeToUnlock": 290,
|
|
74
|
+
* "medianTimeToUnlockHardcore": 333
|
|
75
|
+
* }
|
|
76
|
+
* ]
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare const getGameProgression: (authorization: AuthObject, payload: {
|
|
81
|
+
gameId: ID;
|
|
82
|
+
hardcore?: boolean;
|
|
83
|
+
}) => Promise<GameProgression>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/game/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./getAchievementDistribution";
|
|
|
3
3
|
export * from "./getGame";
|
|
4
4
|
export * from "./getGameExtended";
|
|
5
5
|
export * from "./getGameHashes";
|
|
6
|
+
export * from "./getGameProgression";
|
|
6
7
|
export * from "./getGameRankAndScore";
|
|
7
8
|
export * from "./getGameRating";
|
|
8
9
|
export * from "./models";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface GameProgression {
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
consoleId: number;
|
|
5
|
+
consoleName: string;
|
|
6
|
+
imageIcon: string;
|
|
7
|
+
numDistinctPlayers: number;
|
|
8
|
+
timesUsedInBeatMedian: number;
|
|
9
|
+
timesUsedInHardcoreBeatMedian: number;
|
|
10
|
+
medianTimeToBeat: number | null;
|
|
11
|
+
medianTimeToBeatHardcore: number | null;
|
|
12
|
+
timesUsedInCompletionMedian: number;
|
|
13
|
+
timesUsedInMasteryMedian: number;
|
|
14
|
+
medianTimeToComplete: number | null;
|
|
15
|
+
medianTimeToMaster: number | null;
|
|
16
|
+
numAchievements: number;
|
|
17
|
+
achievements: Array<{
|
|
18
|
+
id: number;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
points: number;
|
|
22
|
+
trueRatio: number;
|
|
23
|
+
type: string | null;
|
|
24
|
+
badgeName: string;
|
|
25
|
+
numAwarded: number;
|
|
26
|
+
numAwardedHardcore: number;
|
|
27
|
+
timesUsedInUnlockMedian: number;
|
|
28
|
+
timesUsedInHardcoreUnlockMedian: number;
|
|
29
|
+
medianTimeToUnlock: number;
|
|
30
|
+
medianTimeToUnlockHardcore: number;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface GetGameProgressionResponse {
|
|
2
|
+
ID: number;
|
|
3
|
+
Title: string;
|
|
4
|
+
ConsoleID: number;
|
|
5
|
+
ConsoleName: string;
|
|
6
|
+
ImageIcon: string;
|
|
7
|
+
NumDistinctPlayers: number;
|
|
8
|
+
TimesUsedInBeatMedian: number;
|
|
9
|
+
TimesUsedInHardcoreBeatMedian: number;
|
|
10
|
+
MedianTimeToBeat: number | null;
|
|
11
|
+
MedianTimeToBeatHardcore: number | null;
|
|
12
|
+
TimesUsedInCompletionMedian: number;
|
|
13
|
+
TimesUsedInMasteryMedian: number;
|
|
14
|
+
MedianTimeToComplete: number | null;
|
|
15
|
+
MedianTimeToMaster: number | null;
|
|
16
|
+
NumAchievements: number;
|
|
17
|
+
Achievements: Array<{
|
|
18
|
+
ID: number;
|
|
19
|
+
Title: string;
|
|
20
|
+
Description: string;
|
|
21
|
+
Points: number;
|
|
22
|
+
TrueRatio: number;
|
|
23
|
+
Type: string | null;
|
|
24
|
+
BadgeName: string;
|
|
25
|
+
NumAwarded: number;
|
|
26
|
+
NumAwardedHardcore: number;
|
|
27
|
+
TimesUsedInUnlockMedian: number;
|
|
28
|
+
TimesUsedInHardcoreUnlockMedian: number;
|
|
29
|
+
MedianTimeToUnlock: number;
|
|
30
|
+
MedianTimeToUnlockHardcore: number;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
@@ -5,12 +5,14 @@ export * from "./game-extended.model";
|
|
|
5
5
|
export * from "./game-extended-achievement-entity.model";
|
|
6
6
|
export * from "./game-extended-claim-entity.model";
|
|
7
7
|
export * from "./game-hashes.model";
|
|
8
|
+
export * from "./game-progression.model";
|
|
8
9
|
export * from "./game-rank-and-score-entity.model";
|
|
9
10
|
export * from "./game-rating.model";
|
|
10
11
|
export * from "./get-achievement-count-response.model";
|
|
11
12
|
export * from "./get-achievement-distribution-response.model";
|
|
12
13
|
export * from "./get-game-extended-response.model";
|
|
13
14
|
export * from "./get-game-hashes-response.model";
|
|
15
|
+
export * from "./get-game-progression-response.model";
|
|
14
16
|
export * from "./get-game-rank-and-score-response.model";
|
|
15
17
|
export * from "./get-game-rating-response.model";
|
|
16
18
|
export * from "./get-game-response.model";
|
package/package.json
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* eslint-disable sonarjs/no-duplicate-string */
|
|
2
|
+
|
|
3
|
+
import { http, HttpResponse } from "msw";
|
|
4
|
+
import { setupServer } from "msw/node";
|
|
5
|
+
|
|
6
|
+
import { apiBaseUrl } from "../utils/internal";
|
|
7
|
+
import { buildAuthorization } from "../utils/public";
|
|
8
|
+
import { getGameProgression } from "./getGameProgression";
|
|
9
|
+
import type { GetGameProgressionResponse } from "./models";
|
|
10
|
+
|
|
11
|
+
const server = setupServer();
|
|
12
|
+
|
|
13
|
+
describe("Function: getGameProgression", () => {
|
|
14
|
+
// MSW Setup
|
|
15
|
+
beforeAll(() => server.listen());
|
|
16
|
+
afterEach(() => server.resetHandlers());
|
|
17
|
+
afterAll(() => server.close());
|
|
18
|
+
|
|
19
|
+
it("is defined #sanity", () => {
|
|
20
|
+
// ASSERT
|
|
21
|
+
expect(getGameProgression).toBeDefined();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("given a game ID, retrieves information about the average time to unlock achievements in a game", async () => {
|
|
25
|
+
// ARRANGE
|
|
26
|
+
const authorization = buildAuthorization({
|
|
27
|
+
username: "mockUserName",
|
|
28
|
+
webApiKey: "mockWebApiKey",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const mockResponse: GetGameProgressionResponse = {
|
|
32
|
+
ID: 228,
|
|
33
|
+
Title: "Super Mario World",
|
|
34
|
+
ConsoleID: 3,
|
|
35
|
+
ConsoleName: "SNES/Super Famicom",
|
|
36
|
+
ImageIcon: "/Images/112443.png",
|
|
37
|
+
NumDistinctPlayers: 79_281,
|
|
38
|
+
TimesUsedInBeatMedian: 4493,
|
|
39
|
+
TimesUsedInHardcoreBeatMedian: 8249,
|
|
40
|
+
MedianTimeToBeat: 17_878,
|
|
41
|
+
MedianTimeToBeatHardcore: 19_224,
|
|
42
|
+
TimesUsedInCompletionMedian: 155,
|
|
43
|
+
TimesUsedInMasteryMedian: 1091,
|
|
44
|
+
MedianTimeToComplete: 67_017,
|
|
45
|
+
MedianTimeToMaster: 79_744,
|
|
46
|
+
NumAchievements: 89,
|
|
47
|
+
Achievements: [
|
|
48
|
+
{
|
|
49
|
+
ID: 342,
|
|
50
|
+
Title: "Giddy Up!",
|
|
51
|
+
Description: "Catch a ride with a friend",
|
|
52
|
+
Points: 1,
|
|
53
|
+
TrueRatio: 1,
|
|
54
|
+
Type: null,
|
|
55
|
+
BadgeName: "46580",
|
|
56
|
+
NumAwarded: 75_168,
|
|
57
|
+
NumAwardedHardcore: 37_024,
|
|
58
|
+
TimesUsedInUnlockMedian: 63,
|
|
59
|
+
TimesUsedInHardcoreUnlockMedian: 69,
|
|
60
|
+
MedianTimeToUnlock: 274,
|
|
61
|
+
MedianTimeToUnlockHardcore: 323,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
server.use(
|
|
67
|
+
http.get(`${apiBaseUrl}/API_GetGameProgression.php`, () =>
|
|
68
|
+
HttpResponse.json(mockResponse)
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// ACT
|
|
73
|
+
const response = await getGameProgression(authorization, {
|
|
74
|
+
gameId: 104_370,
|
|
75
|
+
hardcore: true,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// ASSERT
|
|
79
|
+
expect(response).toEqual({
|
|
80
|
+
id: 228,
|
|
81
|
+
title: "Super Mario World",
|
|
82
|
+
consoleId: 3,
|
|
83
|
+
consoleName: "SNES/Super Famicom",
|
|
84
|
+
imageIcon: "/Images/112443.png",
|
|
85
|
+
numDistinctPlayers: 79_281,
|
|
86
|
+
timesUsedInBeatMedian: 4493,
|
|
87
|
+
timesUsedInHardcoreBeatMedian: 8249,
|
|
88
|
+
medianTimeToBeat: 17_878,
|
|
89
|
+
medianTimeToBeatHardcore: 19_224,
|
|
90
|
+
timesUsedInCompletionMedian: 155,
|
|
91
|
+
timesUsedInMasteryMedian: 1091,
|
|
92
|
+
medianTimeToComplete: 67_017,
|
|
93
|
+
medianTimeToMaster: 79_744,
|
|
94
|
+
numAchievements: 89,
|
|
95
|
+
achievements: [
|
|
96
|
+
{
|
|
97
|
+
id: 342,
|
|
98
|
+
title: "Giddy Up!",
|
|
99
|
+
description: "Catch a ride with a friend",
|
|
100
|
+
points: 1,
|
|
101
|
+
trueRatio: 1,
|
|
102
|
+
type: null,
|
|
103
|
+
badgeName: "46580",
|
|
104
|
+
numAwarded: 75_168,
|
|
105
|
+
numAwardedHardcore: 37_024,
|
|
106
|
+
timesUsedInUnlockMedian: 63,
|
|
107
|
+
timesUsedInHardcoreUnlockMedian: 69,
|
|
108
|
+
medianTimeToUnlock: 274,
|
|
109
|
+
medianTimeToUnlockHardcore: 323,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
2
|
+
import {
|
|
3
|
+
apiBaseUrl,
|
|
4
|
+
buildRequestUrl,
|
|
5
|
+
call,
|
|
6
|
+
serializeProperties,
|
|
7
|
+
} from "../utils/internal";
|
|
8
|
+
import type { AuthObject } from "../utils/public";
|
|
9
|
+
import type { GameProgression, GetGameProgressionResponse } from "./models";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A call to this function will retrieve information about the average time to unlock achievements in a game.
|
|
13
|
+
*
|
|
14
|
+
* @param authorization An object containing your username and webApiKey.
|
|
15
|
+
* This can be constructed with `buildAuthorization()`.
|
|
16
|
+
*
|
|
17
|
+
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
18
|
+
* game's page on the RetroAchievements.org website. For example, Dragster's
|
|
19
|
+
* URL is https://retroachievements.org/game/14402. We can see from the
|
|
20
|
+
* URL that the game ID is "14402".
|
|
21
|
+
*
|
|
22
|
+
* @param payload.hardcore Optional. If set to true, the player sampling
|
|
23
|
+
* for median calculations will prefer players based on their hardcore
|
|
24
|
+
* unlock count rather than their total unlock count.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```
|
|
28
|
+
* const game = await getGameProgression(
|
|
29
|
+
* authorization,
|
|
30
|
+
* { gameId: 14402, hardcore: true }
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @returns An object containing information about the average time to unlock achievements in a game.
|
|
35
|
+
* ```json
|
|
36
|
+
* {
|
|
37
|
+
* "id": 228,
|
|
38
|
+
* "title": "Super Mario World",
|
|
39
|
+
* "consoleId": 3,
|
|
40
|
+
* "consoleName": "SNES/Super Famicom",
|
|
41
|
+
* "imageIcon": "/Images/112443.png",
|
|
42
|
+
* "numDistinctPlayers": 79281,
|
|
43
|
+
* "timesUsedInBeatMedian": 4493,
|
|
44
|
+
* "timesUsedInHardcoreBeatMedian": 8249,
|
|
45
|
+
* "medianTimeToBeat": 17878,
|
|
46
|
+
* "medianTimeToBeatHardcore": 19224,
|
|
47
|
+
* "timesUsedInCompletionMedian": 155,
|
|
48
|
+
* "timesUsedInMasteryMedian": 1091,
|
|
49
|
+
* "medianTimeToComplete": 67017,
|
|
50
|
+
* "medianTimeToMaster": 79744,
|
|
51
|
+
* "numAchievements": 89,
|
|
52
|
+
* "achievements": [
|
|
53
|
+
* {
|
|
54
|
+
* "id": 342,
|
|
55
|
+
* "title": "Giddy Up!",
|
|
56
|
+
* "description": "Catch a ride with a friend",
|
|
57
|
+
* "points": 1,
|
|
58
|
+
* "trueRatio": 1,
|
|
59
|
+
* "type": null,
|
|
60
|
+
* "badgeName": "46580",
|
|
61
|
+
* "numAwarded": 75168,
|
|
62
|
+
* "numAwardedHardcore": 37024,
|
|
63
|
+
* "timesUsedInUnlockMedian": 63,
|
|
64
|
+
* "timesUsedInHardcoreUnlockMedian": 69,
|
|
65
|
+
* "medianTimeToUnlock": 274,
|
|
66
|
+
* "medianTimeToUnlockHardcore": 323
|
|
67
|
+
* },
|
|
68
|
+
* {
|
|
69
|
+
* "id": 341,
|
|
70
|
+
* "title": "Unleash The Dragon",
|
|
71
|
+
* "description": "Collect 5 Dragon Coins in a level",
|
|
72
|
+
* "points": 2,
|
|
73
|
+
* "trueRatio": 2,
|
|
74
|
+
* "type": null,
|
|
75
|
+
* "badgeName": "46591",
|
|
76
|
+
* "numAwarded": 66647,
|
|
77
|
+
* "numAwardedHardcore": 34051,
|
|
78
|
+
* "timesUsedInUnlockMedian": 66,
|
|
79
|
+
* "timesUsedInHardcoreUnlockMedian": 70,
|
|
80
|
+
* "medianTimeToUnlock": 290,
|
|
81
|
+
* "medianTimeToUnlockHardcore": 333
|
|
82
|
+
* }
|
|
83
|
+
* ]
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const getGameProgression = async (
|
|
88
|
+
authorization: AuthObject,
|
|
89
|
+
payload: {
|
|
90
|
+
gameId: ID;
|
|
91
|
+
hardcore?: boolean;
|
|
92
|
+
}
|
|
93
|
+
): Promise<GameProgression> => {
|
|
94
|
+
const { gameId, hardcore } = payload;
|
|
95
|
+
|
|
96
|
+
const queryParams: Record<string, any> = { i: gameId };
|
|
97
|
+
|
|
98
|
+
if (hardcore !== undefined) {
|
|
99
|
+
queryParams["h"] = hardcore === true ? 1 : 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const url = buildRequestUrl(
|
|
103
|
+
apiBaseUrl,
|
|
104
|
+
"/API_GetGameProgression.php",
|
|
105
|
+
authorization,
|
|
106
|
+
queryParams
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const rawResponse = await call<GetGameProgressionResponse>({ url });
|
|
110
|
+
|
|
111
|
+
return serializeProperties(rawResponse);
|
|
112
|
+
};
|
package/src/game/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./getAchievementDistribution";
|
|
|
3
3
|
export * from "./getGame";
|
|
4
4
|
export * from "./getGameExtended";
|
|
5
5
|
export * from "./getGameHashes";
|
|
6
|
+
export * from "./getGameProgression";
|
|
6
7
|
export * from "./getGameRankAndScore";
|
|
7
8
|
export * from "./getGameRating";
|
|
8
9
|
export * from "./models";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface GameProgression {
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
consoleId: number;
|
|
5
|
+
consoleName: string;
|
|
6
|
+
imageIcon: string;
|
|
7
|
+
numDistinctPlayers: number;
|
|
8
|
+
timesUsedInBeatMedian: number;
|
|
9
|
+
timesUsedInHardcoreBeatMedian: number;
|
|
10
|
+
medianTimeToBeat: number | null;
|
|
11
|
+
medianTimeToBeatHardcore: number | null;
|
|
12
|
+
timesUsedInCompletionMedian: number;
|
|
13
|
+
timesUsedInMasteryMedian: number;
|
|
14
|
+
medianTimeToComplete: number | null;
|
|
15
|
+
medianTimeToMaster: number | null;
|
|
16
|
+
numAchievements: number;
|
|
17
|
+
achievements: Array<{
|
|
18
|
+
id: number;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
points: number;
|
|
22
|
+
trueRatio: number;
|
|
23
|
+
type: string | null;
|
|
24
|
+
badgeName: string;
|
|
25
|
+
numAwarded: number;
|
|
26
|
+
numAwardedHardcore: number;
|
|
27
|
+
timesUsedInUnlockMedian: number;
|
|
28
|
+
timesUsedInHardcoreUnlockMedian: number;
|
|
29
|
+
medianTimeToUnlock: number;
|
|
30
|
+
medianTimeToUnlockHardcore: number;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface GetGameProgressionResponse {
|
|
2
|
+
ID: number;
|
|
3
|
+
Title: string;
|
|
4
|
+
ConsoleID: number;
|
|
5
|
+
ConsoleName: string;
|
|
6
|
+
ImageIcon: string;
|
|
7
|
+
NumDistinctPlayers: number;
|
|
8
|
+
TimesUsedInBeatMedian: number;
|
|
9
|
+
TimesUsedInHardcoreBeatMedian: number;
|
|
10
|
+
MedianTimeToBeat: number | null;
|
|
11
|
+
MedianTimeToBeatHardcore: number | null;
|
|
12
|
+
TimesUsedInCompletionMedian: number;
|
|
13
|
+
TimesUsedInMasteryMedian: number;
|
|
14
|
+
MedianTimeToComplete: number | null;
|
|
15
|
+
MedianTimeToMaster: number | null;
|
|
16
|
+
NumAchievements: number;
|
|
17
|
+
Achievements: Array<{
|
|
18
|
+
ID: number;
|
|
19
|
+
Title: string;
|
|
20
|
+
Description: string;
|
|
21
|
+
Points: number;
|
|
22
|
+
TrueRatio: number;
|
|
23
|
+
Type: string | null;
|
|
24
|
+
BadgeName: string;
|
|
25
|
+
NumAwarded: number;
|
|
26
|
+
NumAwardedHardcore: number;
|
|
27
|
+
TimesUsedInUnlockMedian: number;
|
|
28
|
+
TimesUsedInHardcoreUnlockMedian: number;
|
|
29
|
+
MedianTimeToUnlock: number;
|
|
30
|
+
MedianTimeToUnlockHardcore: number;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
package/src/game/models/index.ts
CHANGED
|
@@ -5,12 +5,14 @@ export * from "./game-extended.model";
|
|
|
5
5
|
export * from "./game-extended-achievement-entity.model";
|
|
6
6
|
export * from "./game-extended-claim-entity.model";
|
|
7
7
|
export * from "./game-hashes.model";
|
|
8
|
+
export * from "./game-progression.model";
|
|
8
9
|
export * from "./game-rank-and-score-entity.model";
|
|
9
10
|
export * from "./game-rating.model";
|
|
10
11
|
export * from "./get-achievement-count-response.model";
|
|
11
12
|
export * from "./get-achievement-distribution-response.model";
|
|
12
13
|
export * from "./get-game-extended-response.model";
|
|
13
14
|
export * from "./get-game-hashes-response.model";
|
|
15
|
+
export * from "./get-game-progression-response.model";
|
|
14
16
|
export * from "./get-game-rank-and-score-response.model";
|
|
15
17
|
export * from "./get-game-rating-response.model";
|
|
16
18
|
export * from "./get-game-response.model";
|
|
@@ -114,28 +114,34 @@ describe("Util: serializeProperties", () => {
|
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
it(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
117
|
+
it.each([
|
|
118
|
+
{ hardcoreMode: "0", isCoolGuy: "1" },
|
|
119
|
+
{ hardcoreMode: false, isCoolGuy: true },
|
|
120
|
+
])(
|
|
121
|
+
"can be instructed to map values of certain keys to booleans such as the value '$hardcoreMode' and '$isCoolGuy'",
|
|
122
|
+
({ hardcoreMode, isCoolGuy }) => {
|
|
123
|
+
// ARRANGE
|
|
124
|
+
const originalObject = {
|
|
125
|
+
UserName: "xelnia",
|
|
126
|
+
HardcoreMode: hardcoreMode,
|
|
127
|
+
Metadata: {
|
|
128
|
+
IsCoolGuy: isCoolGuy,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// ACT
|
|
133
|
+
const sanitizedObject = serializeProperties(originalObject, {
|
|
134
|
+
shouldMapToBooleans: ["HardcoreMode", "IsCoolGuy"],
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// ASSERT
|
|
138
|
+
expect(sanitizedObject).toEqual({
|
|
139
|
+
userName: "xelnia",
|
|
140
|
+
hardcoreMode: false,
|
|
141
|
+
metadata: {
|
|
142
|
+
isCoolGuy: true,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
);
|
|
141
147
|
});
|
|
@@ -33,7 +33,11 @@ export const serializeProperties = (
|
|
|
33
33
|
if (originalValue === null) {
|
|
34
34
|
sanitizedValue = null;
|
|
35
35
|
} else {
|
|
36
|
-
|
|
36
|
+
const originalValueAsString = String(originalValue);
|
|
37
|
+
sanitizedValue =
|
|
38
|
+
originalValueAsString === "1" || originalValueAsString === "true"
|
|
39
|
+
? true
|
|
40
|
+
: false;
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|