Skip to content

Commit 08960ac

Browse files
committed
enhance @/valorant-api.com endpoints and @/riot-api region
1 parent 417243a commit 08960ac

File tree

25 files changed

+285
-62
lines changed

25 files changed

+285
-62
lines changed

packages/@valapi/auth/src/__tests__/login.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { randomBytes } from "node:crypto";
88

99
describe("auth.login", () => {
1010
const myClient = new AuthClient({
11-
region: <Region.Identify>env.VAL_REGION
11+
region: <Region.ID>env.VAL_REGION
1212
});
1313

1414
test("new client", () => {
@@ -27,7 +27,7 @@ describe("auth.login", () => {
2727
entitlements_token: "",
2828
region: {
2929
pbe: Region.Default.North_America,
30-
live: <Region.Identify>env.VAL_REGION
30+
live: <Region.ID>env.VAL_REGION
3131
}
3232
});
3333

@@ -70,7 +70,7 @@ describe("auth.login", () => {
7070

7171
test("cookie auth", async () => {
7272
const cookieClient = await AuthClient.fromCookie(myClient.cookie, {
73-
region: <Region.Identify>env.VAL_REGION
73+
region: <Region.ID>env.VAL_REGION
7474
});
7575

7676
expect(cookieClient.toJSON().authenticationInfo).toMatchObject<Partial<AuthCore.JsonAuthenticationInfo>>({

packages/@valapi/auth/src/client/AuthCore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Region, ValEncryption } from "@valapi/lib";
99

1010
export namespace AuthCore {
1111
export interface JsonRegion {
12-
pbe: Region.Identify;
13-
live: Region.Identify;
12+
pbe: Region.ID;
13+
live: Region.ID;
1414
}
1515

1616
export type JsonAuthenticationInfoMessage = `${"load" | "fail" | "success"};${string};`;
@@ -70,7 +70,7 @@ export namespace AuthCore {
7070
/**
7171
* Region
7272
*/
73-
region?: Region.Identify;
73+
region?: Region.ID;
7474
}
7575
}
7676

packages/@valapi/auth/src/client/AuthService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ export class AuthService extends AuthCore {
146146
const RegionResponse: AxiosResponse<{
147147
token: string;
148148
affinities: {
149-
pbe: Region.Identify;
150-
live: Region.Identify;
149+
pbe: Region.ID;
150+
live: Region.ID;
151151
};
152152
}> = await this.axios.put(
153153
"https://riot-geo.pas.si.riotgames.com/pas/v1/product/valorant",

packages/@valapi/lib/src/resources/QueueId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const Default = <const>{
1212
Custom_Tournament: "tournamentmode",
1313

1414
// * change when having a new map
15-
New_Map: null
15+
New_Map: undefined
1616
};
1717

1818
export type Name = keyof typeof Default;

packages/@valapi/riot-api/CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
# 4.0.0
2+
3+
**Change**
4+
5+
- ~~`RiotApiRegion.riotRegion`~~ **-->** `RiotApiRegion.continent`
6+
- ~~`RiotApiRegion.url.api`~~ **-->** `RiotApiRegion.url.continent`
7+
- ~~`RiotApiRegion.url.server`~~ **-->** `RiotApiRegion.url.region`
8+
9+
### Typescript
10+
11+
**Add**
12+
13+
- `MatchV1.MatchInfoDto`
14+
- `MatchV1.AbilityCastsDto`
15+
- `MatchV1.PlayerStatsDto`
16+
- `MatchV1.PlayerDto`
17+
- `MatchV1.CoachDto`
18+
- `MatchV1.TeamDto`
19+
- `MatchV1.LocationDto`
20+
- `MatchV1.PlayerLocationsDto`
21+
- `MatchV1.FinishingDamageDto`
22+
- `MatchV1.KillDto`
23+
- `MatchV1.DamageDto`
24+
- `MatchV1.EconomyDto`
25+
- `MatchV1.AbilityDto`
26+
- `MatchV1.PlayerRoundStatsDto`
27+
- `MatchV1.RoundResultDto`
28+
- `MatchV1.MatchDto`
29+
- `MatchV1.MatchlistEntryDto`
30+
- `MatchV1.MatchlistDto`
31+
- `MatchV1.RecentMatchesDto`
32+
133
# 3.2.0
234

335
**Add**

packages/@valapi/riot-api/src/__tests__/region.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ describe("riotapi.region", () => {
66
const _region = new RiotApiRegion(Region.Default.Public_Beta_Environment);
77

88
const id = "na";
9-
const riotRegion = "pbe1";
9+
const continent = "pbe1";
1010

1111
expect(_region.id).toBe(id);
12-
expect(_region.riotRegion).toBe(riotRegion);
12+
expect(_region.continent).toBe(continent);
1313

1414
expect(_region.url).toMatchObject({
15-
api: `https://${riotRegion}.api.riotgames.com`,
15+
api: `https://${continent}.api.riotgames.com`,
1616
server: `https://${id}.api.riotgames.com`
1717
});
1818
});

packages/@valapi/riot-api/src/client/RiotApiRegion.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ import { ValRegion } from "@valapi/lib";
22
import type { Region } from "@valapi/lib";
33

44
export class RiotApiRegion extends ValRegion {
5-
public readonly riotRegion: string;
5+
public readonly continent: string;
66
public readonly url: {
77
/**
88
* $.api.riotgames.com
99
*/
10-
api: string;
10+
region: string;
1111
/**
12-
* esports.api.riotgames.com
12+
* $.api.riotgames.com
1313
*/
14-
esports: string;
14+
continent: string;
1515
/**
16-
* $.api.riotgames.com
16+
* esports.api.riotgames.com
1717
*/
18-
server: string;
18+
esports: string;
1919
};
2020

2121
/**
@@ -25,7 +25,7 @@ export class RiotApiRegion extends ValRegion {
2525
public constructor(region?: Region.ID) {
2626
super(region);
2727

28-
this.riotRegion = "americas";
28+
this.continent = "americas";
2929
switch (region) {
3030
case "na": {
3131
break;
@@ -37,27 +37,27 @@ export class RiotApiRegion extends ValRegion {
3737
break;
3838
}
3939
case "pbe": {
40-
this.riotRegion = "pbe1";
40+
this.continent = "pbe1";
4141
break;
4242
}
4343
case "eu": {
44-
this.riotRegion = "europe";
44+
this.continent = "europe";
4545
break;
4646
}
4747
case "kr": {
48-
this.riotRegion = "asia";
48+
this.continent = "asia";
4949
break;
5050
}
5151
case "ap": {
52-
this.riotRegion = "asia";
52+
this.continent = "asia";
5353
break;
5454
}
5555
}
5656

5757
this.url = {
58-
api: `https://${this.riotRegion}.api.riotgames.com`,
59-
esports: `https://esports.api.riotgames.com`,
60-
server: `https://${this.id}.api.riotgames.com`
58+
region: `https://${this.id}.api.riotgames.com`,
59+
continent: `https://${this.continent}.api.riotgames.com`,
60+
esports: `https://esports.api.riotgames.com`
6161
};
6262
}
6363
}

packages/@valapi/riot-api/src/service/AccountV1.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class AccountV1 extends RiotApiService {
3131
* @returns {Promise<AxiosResponse<AccountV1.AccountDto>>}
3232
*/
3333
public byPuuid(puuid: string): Promise<AxiosResponse<AccountV1.AccountDto>> {
34-
return this.axios.get(`${this.apiRegion.url.api}/riot/account/v1/accounts/by-puuid/${puuid}`);
34+
return this.axios.get(`${this.apiRegion.url.continent}/riot/account/v1/accounts/by-puuid/${puuid}`);
3535
}
3636

3737
/**
@@ -41,28 +41,27 @@ export class AccountV1 extends RiotApiService {
4141
* @returns {Promise<AxiosResponse<AccountV1.AccountDto>>}
4242
*/
4343
public byRiotId(gameName: string, tagLine: string): Promise<AxiosResponse<AccountV1.AccountDto>> {
44-
return this.axios.get(`${this.apiRegion.url.api}/riot/account/v1/accounts/by-riot-id/${gameName}/${tagLine}`);
44+
return this.axios.get(`${this.apiRegion.url.continent}/riot/account/v1/accounts/by-riot-id/${gameName}/${tagLine}`);
4545
}
4646

4747
/**
4848
* Get active shard for a player
4949
* @param {string} puuid Player UUID
50-
* @param {string} game Game (default: val)
5150
* @returns {Promise<AxiosResponse<AccountV1.ActiveShardDto>>}
5251
*/
53-
public activeShardsByGameAndPuuid(puuid: string, game: "val" | "lor" = "val"): Promise<AxiosResponse<AccountV1.ActiveShardDto>> {
54-
return this.axios.get(`${this.apiRegion.url.api}/riot/account/v1/active-shards/by-game/${game}/by-puuid/${puuid}`);
52+
public activeShardsByGameAndPuuid(puuid: string): Promise<AxiosResponse<AccountV1.ActiveShardDto>> {
53+
return this.axios.get(`${this.apiRegion.url.continent}/riot/account/v1/active-shards/by-game/val/by-puuid/${puuid}`);
5554
}
5655

5756
/**
58-
* ! Not For Public Use
57+
* ! This API service is required your project to be registered by Riot Games.
5958
*
6059
* Get account by access token
6160
* @param {string} authorization (Header Parameters)
6261
* @returns {Promise<AxiosResponse<AccountV1.AccountDto>>}
6362
*/
6463
public byAccessToken(authorization: string): Promise<AxiosResponse<AccountV1.AccountDto>> {
65-
return this.axios.get(`${this.apiRegion.url.api}/riot/account/v1/accounts/me`, {
64+
return this.axios.get(`${this.apiRegion.url.continent}/riot/account/v1/accounts/me`, {
6665
headers: {
6766
Authorization: authorization
6867
}

packages/@valapi/riot-api/src/service/ContentV1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ export class ContentV1 extends RiotApiService {
6161
* @returns {Promise<AxiosResponse<ContentV1.ContentDto>>}
6262
*/
6363
public contents(locale: Locale.ID = "en-US"): Promise<AxiosResponse<ContentV1.ContentDto>> {
64-
return this.axios.get(`${this.apiRegion.url.server}/val/content/v1/contents?locale=${locale}`);
64+
return this.axios.get(`${this.apiRegion.url.region}/val/content/v1/contents?locale=${locale}`);
6565
}
6666
}

0 commit comments

Comments
 (0)