tornapi-typescript 4.3.2 → 4.3.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/index.d.ts +6 -7
- package/dist/index.js +8 -6
- package/dist/index.ts +17 -16
- package/dist/openapi.json +14 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -6622,7 +6622,7 @@ export interface FactionV2 extends BaseSchema {
|
|
|
6622
6622
|
};
|
|
6623
6623
|
balance: {
|
|
6624
6624
|
response: FactionBalanceResponse;
|
|
6625
|
-
params: "timestamp";
|
|
6625
|
+
params: "cat" | "timestamp";
|
|
6626
6626
|
};
|
|
6627
6627
|
basic: {
|
|
6628
6628
|
response: FactionBasicResponse;
|
|
@@ -7068,19 +7068,18 @@ export type CacheV2<Sec extends SectionV2, Sel extends keyof SectionsV2Map[Sec][
|
|
|
7068
7068
|
set: (key: GetArgumentV2<Sec, Sel>, value: GetResponseV2<Sec, Sel>, expiry: number) => void | Promise<void>;
|
|
7069
7069
|
};
|
|
7070
7070
|
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
7071
|
-
export type HTTPClientCapabilities = "abort";
|
|
7072
7071
|
export declare abstract class HTTPClient {
|
|
7073
|
-
abstract getJson(url:
|
|
7072
|
+
abstract getJson(url: string): Promise<any>;
|
|
7074
7073
|
canAbort(): this is AbortableHTTPClient;
|
|
7075
7074
|
}
|
|
7076
7075
|
export declare abstract class AbortableHTTPClient extends HTTPClient {
|
|
7077
|
-
abstract getJson(url:
|
|
7078
|
-
abstract getJson(url:
|
|
7079
|
-
abstract getJson(url:
|
|
7076
|
+
abstract getJson(url: string): Promise<any>;
|
|
7077
|
+
abstract getJson(url: string, timeout: number): Promise<any>;
|
|
7078
|
+
abstract getJson(url: string, timeout: number | undefined): Promise<any>;
|
|
7080
7079
|
canAbort(): this is AbortableHTTPClient;
|
|
7081
7080
|
}
|
|
7082
7081
|
export declare class FetchHTTPClient extends AbortableHTTPClient {
|
|
7083
|
-
getJson(url:
|
|
7082
|
+
getJson(url: string, timeout?: number | undefined): Promise<any>;
|
|
7084
7083
|
}
|
|
7085
7084
|
interface ClientOptions {
|
|
7086
7085
|
httpClient?: HTTPClient;
|
package/dist/index.js
CHANGED
|
@@ -78,8 +78,8 @@ export class TornApiClient {
|
|
|
78
78
|
});
|
|
79
79
|
if (cached)
|
|
80
80
|
return cached;
|
|
81
|
-
|
|
82
|
-
this.populateUrl(url, key, (selections ?? []), comment, params ?? {});
|
|
81
|
+
let url = `https://api.torn.com/${section}/${id ?? ""}`;
|
|
82
|
+
url = this.populateUrl(url, key, (selections ?? []), comment, params ?? {});
|
|
83
83
|
if (this.httpClient.canAbort() && typeof timeout === "number") {
|
|
84
84
|
return this.httpClient
|
|
85
85
|
.getJson(url, timeout)
|
|
@@ -115,8 +115,8 @@ export class TornApiClient {
|
|
|
115
115
|
});
|
|
116
116
|
if (cached)
|
|
117
117
|
return cached;
|
|
118
|
-
|
|
119
|
-
this.populateUrl(url, key, (selections ?? []), comment, params ?? {});
|
|
118
|
+
let url = `https://api.torn.com/v2/${section}/${id ?? ""}`;
|
|
119
|
+
url = this.populateUrl(url, key, (selections ?? []), comment, params ?? {});
|
|
120
120
|
if (this.httpClient.canAbort() && typeof timeout === "number") {
|
|
121
121
|
return this.httpClient
|
|
122
122
|
.getJson(url, timeout)
|
|
@@ -166,8 +166,10 @@ export class TornApiClient {
|
|
|
166
166
|
selections: selections.length ? selections.join(",") : undefined,
|
|
167
167
|
...params,
|
|
168
168
|
};
|
|
169
|
-
Object.entries(allParams)
|
|
169
|
+
const query = Object.entries(allParams)
|
|
170
170
|
.filter((entry) => !!entry[1])
|
|
171
|
-
.
|
|
171
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
172
|
+
.join("&");
|
|
173
|
+
return `${url}?${query}`;
|
|
172
174
|
}
|
|
173
175
|
}
|
package/dist/index.ts
CHANGED
|
@@ -12384,7 +12384,7 @@ export interface FactionV2 extends BaseSchema {
|
|
|
12384
12384
|
};
|
|
12385
12385
|
balance: {
|
|
12386
12386
|
response: FactionBalanceResponse;
|
|
12387
|
-
params: "timestamp";
|
|
12387
|
+
params: "cat" | "timestamp";
|
|
12388
12388
|
};
|
|
12389
12389
|
basic: {
|
|
12390
12390
|
response: FactionBasicResponse;
|
|
@@ -12951,10 +12951,8 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
|
|
|
12951
12951
|
? I
|
|
12952
12952
|
: never;
|
|
12953
12953
|
|
|
12954
|
-
export type HTTPClientCapabilities = "abort";
|
|
12955
|
-
|
|
12956
12954
|
export abstract class HTTPClient {
|
|
12957
|
-
abstract getJson(url:
|
|
12955
|
+
abstract getJson(url: string): Promise<any>;
|
|
12958
12956
|
|
|
12959
12957
|
canAbort(): this is AbortableHTTPClient {
|
|
12960
12958
|
return false;
|
|
@@ -12962,9 +12960,9 @@ export abstract class HTTPClient {
|
|
|
12962
12960
|
}
|
|
12963
12961
|
|
|
12964
12962
|
export abstract class AbortableHTTPClient extends HTTPClient {
|
|
12965
|
-
abstract getJson(url:
|
|
12966
|
-
abstract getJson(url:
|
|
12967
|
-
abstract getJson(url:
|
|
12963
|
+
abstract getJson(url: string): Promise<any>;
|
|
12964
|
+
abstract getJson(url: string, timeout: number): Promise<any>;
|
|
12965
|
+
abstract getJson(url: string, timeout: number | undefined): Promise<any>;
|
|
12968
12966
|
|
|
12969
12967
|
canAbort(): this is AbortableHTTPClient {
|
|
12970
12968
|
return true;
|
|
@@ -12973,7 +12971,7 @@ export abstract class AbortableHTTPClient extends HTTPClient {
|
|
|
12973
12971
|
|
|
12974
12972
|
export class FetchHTTPClient extends AbortableHTTPClient {
|
|
12975
12973
|
async getJson(
|
|
12976
|
-
url:
|
|
12974
|
+
url: string,
|
|
12977
12975
|
timeout: number | undefined = undefined,
|
|
12978
12976
|
): Promise<any> {
|
|
12979
12977
|
let response: Response;
|
|
@@ -13031,8 +13029,8 @@ export class TornApiClient {
|
|
|
13031
13029
|
} as GetArgumentV1<Sec, Sel>);
|
|
13032
13030
|
if (cached) return cached;
|
|
13033
13031
|
|
|
13034
|
-
|
|
13035
|
-
this.populateUrl(
|
|
13032
|
+
let url = `https://api.torn.com/${section}/${id ?? ""}`;
|
|
13033
|
+
url = this.populateUrl(
|
|
13036
13034
|
url,
|
|
13037
13035
|
key,
|
|
13038
13036
|
(selections ?? []) as string[],
|
|
@@ -13094,8 +13092,8 @@ export class TornApiClient {
|
|
|
13094
13092
|
} as GetArgumentV2<Sec, Sel>);
|
|
13095
13093
|
if (cached) return cached;
|
|
13096
13094
|
|
|
13097
|
-
|
|
13098
|
-
this.populateUrl(
|
|
13095
|
+
let url = `https://api.torn.com/v2/${section}/${id ?? ""}`;
|
|
13096
|
+
url = this.populateUrl(
|
|
13099
13097
|
url,
|
|
13100
13098
|
key,
|
|
13101
13099
|
(selections ?? []) as string[],
|
|
@@ -13153,12 +13151,12 @@ export class TornApiClient {
|
|
|
13153
13151
|
}
|
|
13154
13152
|
|
|
13155
13153
|
private populateUrl(
|
|
13156
|
-
url:
|
|
13154
|
+
url: string,
|
|
13157
13155
|
key: string,
|
|
13158
13156
|
selections: string[],
|
|
13159
13157
|
comment: string | undefined,
|
|
13160
13158
|
params: Record<string, string | undefined>,
|
|
13161
|
-
):
|
|
13159
|
+
): string {
|
|
13162
13160
|
const allParams: Record<string, string | undefined> = {
|
|
13163
13161
|
key,
|
|
13164
13162
|
comment: comment ?? this.defaultComment,
|
|
@@ -13166,10 +13164,13 @@ export class TornApiClient {
|
|
|
13166
13164
|
...params,
|
|
13167
13165
|
};
|
|
13168
13166
|
|
|
13169
|
-
Object.entries(allParams)
|
|
13167
|
+
const query = Object.entries(allParams)
|
|
13170
13168
|
.filter<[string, string]>(
|
|
13171
13169
|
(entry): entry is [string, string] => !!entry[1],
|
|
13172
13170
|
)
|
|
13173
|
-
.
|
|
13171
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
13172
|
+
.join("&");
|
|
13173
|
+
|
|
13174
|
+
return `${url}?${query}`;
|
|
13174
13175
|
}
|
|
13175
13176
|
}
|
package/dist/openapi.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Torn API",
|
|
5
5
|
"description": "\n * The development of Torn's API v2 is still ongoing.\n * If selections remain unaltered, they will default to the API v1 version.\n * Unlike API v1, API v2 accepts both selections and IDs as path and query parameters.\n * If any discrepancies or errors are found, please submit a [bug report](https://www.torn.com/forums.php#/p=forums&f=19&b=0&a=0) on the Torn Forums.\n * In case you're using bots to check for changes on openapi.json file, make sure to specificy a custom user-agent header - CloudFlare sometimes prevents requests from default user-agents.",
|
|
6
|
-
"version": "4.3.
|
|
6
|
+
"version": "4.3.3"
|
|
7
7
|
},
|
|
8
8
|
"servers": [
|
|
9
9
|
{
|
|
@@ -3543,6 +3543,19 @@
|
|
|
3543
3543
|
"description": "Requires limited access key with faction API access permissions. <br>",
|
|
3544
3544
|
"operationId": "3ca2c0319f960b728ffece8e322cf40f",
|
|
3545
3545
|
"parameters": [
|
|
3546
|
+
{
|
|
3547
|
+
"name": "cat",
|
|
3548
|
+
"in": "query",
|
|
3549
|
+
"description": "By default, this selection will return only current faction's member balances, and the option 'all' will return all current members balances + additionally those of ex-members which do have money or points on their balance.",
|
|
3550
|
+
"required": false,
|
|
3551
|
+
"schema": {
|
|
3552
|
+
"type": "string",
|
|
3553
|
+
"enum": [
|
|
3554
|
+
"all",
|
|
3555
|
+
"current"
|
|
3556
|
+
]
|
|
3557
|
+
}
|
|
3558
|
+
},
|
|
3546
3559
|
{
|
|
3547
3560
|
"$ref": "#/components/parameters/ApiTimestamp"
|
|
3548
3561
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tornapi-typescript",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.3",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"generate-types": "tsc && node build/index.js"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@scalar/openapi-types": "^0.5.1",
|
|
10
|
-
"@types/node": "^24.10.
|
|
10
|
+
"@types/node": "^24.10.1",
|
|
11
11
|
"prettier": "^3.6.2",
|
|
12
12
|
"typeconv": "^2.3.1",
|
|
13
13
|
"typescript": "^5.9.3"
|