speedruncom.js 1.2.1 → 1.2.3
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/dist/BaseClient.d.ts +5 -12
- package/dist/BaseClient.js +1 -25
- package/dist/Client.d.ts +5 -12
- package/dist/Client.js +1 -25
- package/dist/endpoints/endpoints.get.d.ts +15 -1
- package/dist/responses.d.ts +0 -24
- package/package.json +3 -3
- package/src/responses.ts +1 -28
package/dist/BaseClient.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
interface config {
|
|
2
|
+
export interface config {
|
|
3
3
|
PHPSESSID?: string;
|
|
4
4
|
userAgent?: string;
|
|
5
5
|
}
|
|
6
|
+
export declare class APIError extends Error {
|
|
7
|
+
status: number;
|
|
8
|
+
constructor(message: string, status: number);
|
|
9
|
+
}
|
|
6
10
|
export default class Client {
|
|
7
11
|
/**
|
|
8
12
|
* `AxiosInstance` used on instance-called methods (called with `POST`).
|
|
@@ -19,19 +23,8 @@ export default class Client {
|
|
|
19
23
|
config(config: config): void;
|
|
20
24
|
request<T>(endpoint: string, params?: object): Promise<T>;
|
|
21
25
|
static request<T>(endpoint: string, params?: object): Promise<T>;
|
|
22
|
-
/**
|
|
23
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise.
|
|
24
|
-
* If the account has two factor authentication, you have to use `setToken` with the token sent to the account's email address.
|
|
25
|
-
*/
|
|
26
|
-
login(username: string, password: string): Promise<unknown>;
|
|
27
|
-
/**
|
|
28
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise, with the token that `login()` sent to the account's email address.
|
|
29
|
-
* @param token The 5-digit code sent to your email after a successful `login()`.
|
|
30
|
-
*/
|
|
31
|
-
setToken(token: string): Promise<unknown>;
|
|
32
26
|
/**
|
|
33
27
|
* Attempts to remove the PHPSESSID cookie if using a browser, otherwise removes your Client's authentication.
|
|
34
28
|
*/
|
|
35
29
|
logout(): Promise<unknown>;
|
|
36
30
|
}
|
|
37
|
-
export {};
|
package/dist/BaseClient.js
CHANGED
|
@@ -10,7 +10,7 @@ const objectToBase64 = (obj) => {
|
|
|
10
10
|
const jsonString = JSON.stringify(obj).replace(/\s+/g, '');
|
|
11
11
|
return Buffer.from(jsonString).toString('base64');
|
|
12
12
|
};
|
|
13
|
-
class APIError extends Error {
|
|
13
|
+
export class APIError extends Error {
|
|
14
14
|
constructor(message, status) {
|
|
15
15
|
super(message);
|
|
16
16
|
this.message = message;
|
|
@@ -58,30 +58,6 @@ class Client {
|
|
|
58
58
|
static async request(endpoint, params = {}) {
|
|
59
59
|
return (await this.axiosClient.get(`${endpoint}?_r=${objectToBase64(params)}`)).data;
|
|
60
60
|
}
|
|
61
|
-
//Built-in endpoints for auth
|
|
62
|
-
/**
|
|
63
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise.
|
|
64
|
-
* If the account has two factor authentication, you have to use `setToken` with the token sent to the account's email address.
|
|
65
|
-
*/
|
|
66
|
-
async login(username, password) {
|
|
67
|
-
this.username = username;
|
|
68
|
-
this.password = password;
|
|
69
|
-
return await this.request('PutAuthLogin', {
|
|
70
|
-
name: username,
|
|
71
|
-
password
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise, with the token that `login()` sent to the account's email address.
|
|
76
|
-
* @param token The 5-digit code sent to your email after a successful `login()`.
|
|
77
|
-
*/
|
|
78
|
-
async setToken(token) {
|
|
79
|
-
return await this.request('PutAuthLogin', {
|
|
80
|
-
name: this.username,
|
|
81
|
-
password: this.password,
|
|
82
|
-
token
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
61
|
/**
|
|
86
62
|
* Attempts to remove the PHPSESSID cookie if using a browser, otherwise removes your Client's authentication.
|
|
87
63
|
*/
|
package/dist/Client.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { AxiosInstance } from 'axios';
|
|
|
2
2
|
import * as GetEndpoints from './endpoints/endpoints.get.js';
|
|
3
3
|
import * as PostEndpoints from './endpoints/endpoints.post.js';
|
|
4
4
|
import * as Responses from './responses.js';
|
|
5
|
-
interface config {
|
|
5
|
+
export interface config {
|
|
6
6
|
PHPSESSID?: string;
|
|
7
7
|
userAgent?: string;
|
|
8
8
|
}
|
|
9
|
+
export declare class APIError extends Error {
|
|
10
|
+
status: number;
|
|
11
|
+
constructor(message: string, status: number);
|
|
12
|
+
}
|
|
9
13
|
export default class Client {
|
|
10
14
|
/**
|
|
11
15
|
* `AxiosInstance` used on instance-called methods (called with `POST`).
|
|
@@ -22,16 +26,6 @@ export default class Client {
|
|
|
22
26
|
config(config: config): void;
|
|
23
27
|
request<T>(endpoint: string, params?: object): Promise<T>;
|
|
24
28
|
static request<T>(endpoint: string, params?: object): Promise<T>;
|
|
25
|
-
/**
|
|
26
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise.
|
|
27
|
-
* If the account has two factor authentication, you have to use `setToken` with the token sent to the account's email address.
|
|
28
|
-
*/
|
|
29
|
-
login(username: string, password: string): Promise<unknown>;
|
|
30
|
-
/**
|
|
31
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise, with the token that `login()` sent to the account's email address.
|
|
32
|
-
* @param token The 5-digit code sent to your email after a successful `login()`.
|
|
33
|
-
*/
|
|
34
|
-
setToken(token: string): Promise<unknown>;
|
|
35
29
|
/**
|
|
36
30
|
* Attempts to remove the PHPSESSID cookie if using a browser, otherwise removes your Client's authentication.
|
|
37
31
|
*/
|
|
@@ -224,4 +218,3 @@ export default class Client {
|
|
|
224
218
|
PutThreadSticky(params?: PostEndpoints.PutThreadSticky): Promise<void>;
|
|
225
219
|
PutThreadDelete(params?: PostEndpoints.PutThreadDelete): Promise<void>;
|
|
226
220
|
}
|
|
227
|
-
export {};
|
package/dist/Client.js
CHANGED
|
@@ -10,7 +10,7 @@ const objectToBase64 = (obj) => {
|
|
|
10
10
|
const jsonString = JSON.stringify(obj).replace(/\s+/g, '');
|
|
11
11
|
return Buffer.from(jsonString).toString('base64');
|
|
12
12
|
};
|
|
13
|
-
class APIError extends Error {
|
|
13
|
+
export class APIError extends Error {
|
|
14
14
|
constructor(message, status) {
|
|
15
15
|
super(message);
|
|
16
16
|
this.message = message;
|
|
@@ -58,30 +58,6 @@ class Client {
|
|
|
58
58
|
static async request(endpoint, params = {}) {
|
|
59
59
|
return (await this.axiosClient.get(`${endpoint}?_r=${objectToBase64(params)}`)).data;
|
|
60
60
|
}
|
|
61
|
-
//Built-in endpoints for auth
|
|
62
|
-
/**
|
|
63
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise.
|
|
64
|
-
* If the account has two factor authentication, you have to use `setToken` with the token sent to the account's email address.
|
|
65
|
-
*/
|
|
66
|
-
async login(username, password) {
|
|
67
|
-
this.username = username;
|
|
68
|
-
this.password = password;
|
|
69
|
-
return await this.request('PutAuthLogin', {
|
|
70
|
-
name: username,
|
|
71
|
-
password
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Attempts to authorize your cookies if using a browser, or authorizes this Client if otherwise, with the token that `login()` sent to the account's email address.
|
|
76
|
-
* @param token The 5-digit code sent to your email after a successful `login()`.
|
|
77
|
-
*/
|
|
78
|
-
async setToken(token) {
|
|
79
|
-
return await this.request('PutAuthLogin', {
|
|
80
|
-
name: this.username,
|
|
81
|
-
password: this.password,
|
|
82
|
-
token
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
61
|
/**
|
|
86
62
|
* Attempts to remove the PHPSESSID cookie if using a browser, otherwise removes your Client's authentication.
|
|
87
63
|
*/
|
|
@@ -531,14 +531,28 @@ export interface GetUserModeration {
|
|
|
531
531
|
userId: string;
|
|
532
532
|
}
|
|
533
533
|
/**
|
|
534
|
-
* Get a list of comments on an item.
|
|
534
|
+
* Get a list of comments on an item, and data of the parent.
|
|
535
535
|
*/
|
|
536
536
|
export interface GetCommentList {
|
|
537
|
+
/**
|
|
538
|
+
* ID of the parent item to fetch.
|
|
539
|
+
*/
|
|
537
540
|
itemId: string;
|
|
538
541
|
/**
|
|
539
542
|
* `ItemType` of the item referenced in `itemId`.
|
|
540
543
|
*/
|
|
541
544
|
itemType: Enums.ItemType;
|
|
545
|
+
/**
|
|
546
|
+
* The maximum amount of `Comment`s per page.
|
|
547
|
+
*
|
|
548
|
+
* @max 100
|
|
549
|
+
* @default 100
|
|
550
|
+
*/
|
|
551
|
+
limit?: number;
|
|
552
|
+
/**
|
|
553
|
+
* The comment page, in relation to `limit`.
|
|
554
|
+
*/
|
|
555
|
+
page?: number;
|
|
542
556
|
}
|
|
543
557
|
/**
|
|
544
558
|
* Get a specific thread.
|
package/dist/responses.d.ts
CHANGED
|
@@ -260,30 +260,6 @@ export interface GetRun {
|
|
|
260
260
|
values: Interfaces.Value[];
|
|
261
261
|
variables: Interfaces.Variable[];
|
|
262
262
|
}
|
|
263
|
-
export interface GetSearch {
|
|
264
|
-
gameList: Interfaces.Game[];
|
|
265
|
-
newsList: Interfaces.GameNews[];
|
|
266
|
-
pageList: Interfaces.Article[];
|
|
267
|
-
seriesList: Interfaces.Series[];
|
|
268
|
-
userList: Interfaces.User[];
|
|
269
|
-
challengeList: Interfaces.Challenge[];
|
|
270
|
-
}
|
|
271
|
-
export interface GetSeriesList {
|
|
272
|
-
seriesList: Interfaces.Series[];
|
|
273
|
-
pagination: Interfaces.Pagination;
|
|
274
|
-
}
|
|
275
|
-
export interface GetSeriesSummary {
|
|
276
|
-
series: Interfaces.Series;
|
|
277
|
-
forum: Interfaces.Forum;
|
|
278
|
-
gameList: Interfaces.Game[];
|
|
279
|
-
moderatorList: Interfaces.SeriesModerator[];
|
|
280
|
-
theme: Interfaces.Theme;
|
|
281
|
-
threadList: Interfaces.Thread[];
|
|
282
|
-
userList: Interfaces.User[];
|
|
283
|
-
gameCount: number;
|
|
284
|
-
streamCount: number;
|
|
285
|
-
threadCount: number;
|
|
286
|
-
}
|
|
287
263
|
export interface GetStreamList {
|
|
288
264
|
gameList: Interfaces.Game[];
|
|
289
265
|
streamList: Interfaces.Stream[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speedruncom.js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "WIP NodeJS module for Speedrun's version 2 API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "rimraf dist src/Client.ts",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"prepare": "tsx src/build-client.ts && npm run build"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^22.15.24",
|
package/src/responses.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface GetGameRecordHistory {
|
|
|
61
61
|
runList: Interfaces.GameRun[];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export interface GetSearch {
|
|
64
|
+
export interface GetSearch {
|
|
65
65
|
gameList: Interfaces.Game[];
|
|
66
66
|
newsList: Interfaces.GameNews[];
|
|
67
67
|
pageList: Interfaces.Article[];
|
|
@@ -302,33 +302,6 @@ export interface GetRun {
|
|
|
302
302
|
variables: Interfaces.Variable[];
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
export interface GetSearch {
|
|
306
|
-
gameList: Interfaces.Game[];
|
|
307
|
-
newsList: Interfaces.GameNews[];
|
|
308
|
-
pageList: Interfaces.Article[];
|
|
309
|
-
seriesList: Interfaces.Series[];
|
|
310
|
-
userList: Interfaces.User[];
|
|
311
|
-
challengeList: Interfaces.Challenge[];
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export interface GetSeriesList {
|
|
315
|
-
seriesList: Interfaces.Series[];
|
|
316
|
-
pagination: Interfaces.Pagination;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export interface GetSeriesSummary {
|
|
320
|
-
series: Interfaces.Series;
|
|
321
|
-
forum: Interfaces.Forum;
|
|
322
|
-
gameList: Interfaces.Game[];
|
|
323
|
-
moderatorList: Interfaces.SeriesModerator[];
|
|
324
|
-
theme: Interfaces.Theme;
|
|
325
|
-
threadList: Interfaces.Thread[];
|
|
326
|
-
userList: Interfaces.User[];
|
|
327
|
-
gameCount: number;
|
|
328
|
-
streamCount: number;
|
|
329
|
-
threadCount: number;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
305
|
export interface GetStreamList {
|
|
333
306
|
gameList: Interfaces.Game[];
|
|
334
307
|
streamList: Interfaces.Stream[];
|