speedruncom.js 2.0.2 → 2.0.4

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/lib/Client.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import GETEndpoints from './endpoints/endpoints.get';
3
- import POSTEndpoints from './endpoints/endpoints.post';
4
- import Responses from './responses';
2
+ import GETEndpoints from './endpoints/endpoints.get.js';
3
+ import POSTEndpoints from './endpoints/endpoints.post.js';
4
+ import Responses from './responses.js';
5
5
  type Endpoints = GETEndpoints & POSTEndpoints;
6
6
  export default class Client {
7
7
  axiosClient: import("axios").AxiosInstance;
8
- get<T extends keyof GETEndpoints, A extends GETEndpoints[T]>(endpoint: T, params: A, axiosConfig?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<Responses[T], any>>;
9
- post<T extends keyof Endpoints, A extends Endpoints[T]>(endpoint: T, params: A, axiosConfig?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<T extends keyof Responses ? Responses[T] : void, any>>;
8
+ get<E extends keyof GETEndpoints, P extends GETEndpoints[E]>(endpoint: E, params: P, axiosConfig?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<Responses[E], any>>;
9
+ post<E extends keyof Endpoints, P extends Endpoints[E]>(endpoint: E, params: P, axiosConfig?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<E extends keyof Responses ? Responses[E] : void, any>>;
10
10
  }
11
11
  export {};
@@ -1,5 +1,5 @@
1
- import * as Enums from '../enums';
2
- import * as Interfaces from '../interfaces';
1
+ import * as Enums from '../enums.js';
2
+ import * as Interfaces from '../interfaces.js';
3
3
  export default interface GETEndpoints {
4
4
  /**
5
5
  * Gets a leaderboard, with Players included.
@@ -23,6 +23,17 @@ export default interface GETEndpoints {
23
23
  */
24
24
  page?: number;
25
25
  };
26
+ GetGameData: {
27
+ /**
28
+ * ID of the game.
29
+ */
30
+ gameId: string;
31
+ } | {
32
+ /**
33
+ * Game page URL.
34
+ */
35
+ gameUrl: string;
36
+ };
26
37
  /**
27
38
  * Gets a specific site article.
28
39
  */
@@ -1,6 +1,6 @@
1
- import * as Enums from '../enums';
2
- import * as Interfaces from '../interfaces';
3
- import { AtLeastOne } from '../types';
1
+ import * as Enums from '../enums.js';
2
+ import * as Interfaces from '../interfaces.js';
3
+ import { AtLeastOne } from '../types.js';
4
4
  export default interface POSTEndpoints {
5
5
  /**
6
6
  * Logs in by giving a `set-cookie` header in a response with a `PHPSESSID` cookie.
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './enums';
2
- export * from './interfaces';
3
- import Client from './Client';
1
+ export * from './enums.js';
2
+ export * from './interfaces.js';
3
+ import Client from './Client.js';
4
4
  export default Client;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './enums';
2
- export * from './interfaces';
3
- import Client from './Client';
1
+ export * from './enums.js';
2
+ export * from './interfaces.js';
3
+ import Client from './Client.js';
4
4
  export default Client;
@@ -1,4 +1,4 @@
1
- import * as Enums from './enums';
1
+ import * as Enums from './enums.js';
2
2
  /**
3
3
  * A Category item.
4
4
  */
@@ -1,4 +1,4 @@
1
- import * as Interfaces from './interfaces';
1
+ import * as Interfaces from './interfaces.js';
2
2
  export default interface Responses {
3
3
  GetGameLeaderboard2: {
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedruncom.js",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "WIP NodeJS module for Speedrun's version 2 API.",
5
5
  "type": "module",
6
6
  "author": {
package/src/Client.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import axios, { AxiosRequestConfig } from 'axios';
2
- import GETEndpoints from './endpoints/endpoints.get';
3
- import POSTEndpoints from './endpoints/endpoints.post'
4
- import Responses from './responses';
2
+ import GETEndpoints from './endpoints/endpoints.get.js';
3
+ import POSTEndpoints from './endpoints/endpoints.post.js'
4
+ import Responses from './responses.js';
5
5
 
6
6
  type Endpoints = GETEndpoints & POSTEndpoints;
7
7
 
@@ -20,11 +20,11 @@ export default class Client {
20
20
  withCredentials: true
21
21
  });
22
22
 
23
- async get<T extends keyof GETEndpoints, A extends GETEndpoints[T]>(endpoint: T, params: A, axiosConfig?: AxiosRequestConfig) {
24
- return await this.axiosClient.get<Responses[T]>(`${endpoint}?_r=${objectToBase64(params)}`, axiosConfig);
23
+ async get<E extends keyof GETEndpoints, P extends GETEndpoints[E]>(endpoint: E, params: P, axiosConfig?: AxiosRequestConfig) {
24
+ return await this.axiosClient.get<Responses[E]>(`${endpoint}?_r=${objectToBase64(params)}`, axiosConfig);
25
25
  }
26
26
 
27
- async post<T extends keyof Endpoints, A extends Endpoints[T]>(endpoint: T, params: A, axiosConfig?: AxiosRequestConfig) {
28
- return await this.axiosClient.post<T extends keyof Responses ? Responses[T] : void>(endpoint, params, axiosConfig);
27
+ async post<E extends keyof Endpoints, P extends Endpoints[E]>(endpoint: E, params: P, axiosConfig?: AxiosRequestConfig) {
28
+ return await this.axiosClient.post<E extends keyof Responses ? Responses[E] : void>(endpoint, params, axiosConfig);
29
29
  }
30
30
  }
@@ -1,7 +1,7 @@
1
1
  //Endpoints that don't give the "Method Not Allowed" error when called with `GET`.
2
2
 
3
- import * as Enums from '../enums';
4
- import * as Interfaces from '../interfaces';
3
+ import * as Enums from '../enums.js';
4
+ import * as Interfaces from '../interfaces.js';
5
5
 
6
6
  export default interface GETEndpoints {
7
7
 
@@ -31,6 +31,20 @@ export default interface GETEndpoints {
31
31
  page?: number;
32
32
  };
33
33
 
34
+ GetGameData: {
35
+
36
+ /**
37
+ * ID of the game.
38
+ */
39
+ gameId: string;
40
+ } | {
41
+
42
+ /**
43
+ * Game page URL.
44
+ */
45
+ gameUrl: string;
46
+ }
47
+
34
48
  /**
35
49
  * Gets a specific site article.
36
50
  */
@@ -1,8 +1,8 @@
1
1
  //Endpoints that would give the "Method Not Allowed" error when called with GET.
2
2
 
3
- import * as Enums from '../enums';
4
- import * as Interfaces from '../interfaces';
5
- import { AtLeastOne } from '../types';
3
+ import * as Enums from '../enums.js';
4
+ import * as Interfaces from '../interfaces.js';
5
+ import { AtLeastOne } from '../types.js';
6
6
 
7
7
  export default interface POSTEndpoints {
8
8
 
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './enums';
2
- export * from './interfaces';
1
+ export * from './enums.js';
2
+ export * from './interfaces.js';
3
3
 
4
- import Client from './Client';
4
+ import Client from './Client.js';
5
5
 
6
6
  export default Client;
package/src/interfaces.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as Enums from './enums';
1
+ import * as Enums from './enums.js';
2
2
 
3
3
  /**
4
4
  * A Category item.
package/src/responses.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as Interfaces from './interfaces';
1
+ import * as Interfaces from './interfaces.js';
2
2
 
3
3
  export default interface Responses {
4
4
  GetGameLeaderboard2: {