tornapi-typescript 4.3.2 → 4.3.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/dist/index.d.ts CHANGED
@@ -126,7 +126,7 @@ export type UserGenderEnum = "Male" | "Female" | "Enby";
126
126
  export type HonorRarityEnum = "Extremely Rare" | "Very Rare" | "Rare" | "Limited" | "Uncommon" | "Common" | "Very Common" | "Unknown" | "Unknown Rarity";
127
127
  export type Parameters = string;
128
128
  export type ReviveSetting = "Everyone" | "Friends & faction" | "No one" | "Unknown";
129
- export type FactionWarfareTypeEnum = "ranked" | "territory" | "raid" | "chain" | "db";
129
+ export type FactionWarfareTypeEnum = "ranked" | "territory" | "raid" | "chain" | "chainOngoing" | "db";
130
130
  export type PropertyModificationEnum = "Hot Tub" | "Sauna" | "Open Bar" | "Small Pool" | "Medium Pool" | "Large Pool" | "Small Vault" | "Medium Vault" | "Large Vault" | "Extra Large Vault" | "Medical Facility" | "Advanced Shooting Range" | "Airstrip" | "Private Yacht" | "Sufficient Interior Modification" | "Superior Interior Modification";
131
131
  export type PropertyStaffEnum = "Maid" | "Guard" | "Doctor" | "Pilot" | "Butler";
132
132
  export type FactionCrimeStatusEnum = "Recruiting" | "Planning" | "Successful" | "Failure" | "Expired";
@@ -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: URL): Promise<any>;
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: URL): Promise<any>;
7078
- abstract getJson(url: URL, timeout: number): Promise<any>;
7079
- abstract getJson(url: URL, timeout: number | undefined): Promise<any>;
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: URL, timeout?: number | undefined): Promise<any>;
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
- const url = new URL(`https://api.torn.com/${section}/${id ?? ""}`);
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
- const url = new URL(`https://api.torn.com/v2/${section}/${id ?? ""}`);
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
- .forEach(([key, value]) => url.searchParams.set(key, value));
171
+ .map(([key, value]) => `${key}=${value}`)
172
+ .join("&");
173
+ return `${url}?${query}`;
172
174
  }
173
175
  }
package/dist/index.ts CHANGED
@@ -4865,6 +4865,7 @@ export type FactionWarfareTypeEnum =
4865
4865
  | "territory"
4866
4866
  | "raid"
4867
4867
  | "chain"
4868
+ | "chainOngoing"
4868
4869
  | "db";
4869
4870
 
4870
4871
  export type PropertyModificationEnum =
@@ -12384,7 +12385,7 @@ export interface FactionV2 extends BaseSchema {
12384
12385
  };
12385
12386
  balance: {
12386
12387
  response: FactionBalanceResponse;
12387
- params: "timestamp";
12388
+ params: "cat" | "timestamp";
12388
12389
  };
12389
12390
  basic: {
12390
12391
  response: FactionBasicResponse;
@@ -12951,10 +12952,8 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
12951
12952
  ? I
12952
12953
  : never;
12953
12954
 
12954
- export type HTTPClientCapabilities = "abort";
12955
-
12956
12955
  export abstract class HTTPClient {
12957
- abstract getJson(url: URL): Promise<any>;
12956
+ abstract getJson(url: string): Promise<any>;
12958
12957
 
12959
12958
  canAbort(): this is AbortableHTTPClient {
12960
12959
  return false;
@@ -12962,9 +12961,9 @@ export abstract class HTTPClient {
12962
12961
  }
12963
12962
 
12964
12963
  export abstract class AbortableHTTPClient extends HTTPClient {
12965
- abstract getJson(url: URL): Promise<any>;
12966
- abstract getJson(url: URL, timeout: number): Promise<any>;
12967
- abstract getJson(url: URL, timeout: number | undefined): Promise<any>;
12964
+ abstract getJson(url: string): Promise<any>;
12965
+ abstract getJson(url: string, timeout: number): Promise<any>;
12966
+ abstract getJson(url: string, timeout: number | undefined): Promise<any>;
12968
12967
 
12969
12968
  canAbort(): this is AbortableHTTPClient {
12970
12969
  return true;
@@ -12973,7 +12972,7 @@ export abstract class AbortableHTTPClient extends HTTPClient {
12973
12972
 
12974
12973
  export class FetchHTTPClient extends AbortableHTTPClient {
12975
12974
  async getJson(
12976
- url: URL,
12975
+ url: string,
12977
12976
  timeout: number | undefined = undefined,
12978
12977
  ): Promise<any> {
12979
12978
  let response: Response;
@@ -13031,8 +13030,8 @@ export class TornApiClient {
13031
13030
  } as GetArgumentV1<Sec, Sel>);
13032
13031
  if (cached) return cached;
13033
13032
 
13034
- const url = new URL(`https://api.torn.com/${section}/${id ?? ""}`);
13035
- this.populateUrl(
13033
+ let url = `https://api.torn.com/${section}/${id ?? ""}`;
13034
+ url = this.populateUrl(
13036
13035
  url,
13037
13036
  key,
13038
13037
  (selections ?? []) as string[],
@@ -13094,8 +13093,8 @@ export class TornApiClient {
13094
13093
  } as GetArgumentV2<Sec, Sel>);
13095
13094
  if (cached) return cached;
13096
13095
 
13097
- const url = new URL(`https://api.torn.com/v2/${section}/${id ?? ""}`);
13098
- this.populateUrl(
13096
+ let url = `https://api.torn.com/v2/${section}/${id ?? ""}`;
13097
+ url = this.populateUrl(
13099
13098
  url,
13100
13099
  key,
13101
13100
  (selections ?? []) as string[],
@@ -13153,12 +13152,12 @@ export class TornApiClient {
13153
13152
  }
13154
13153
 
13155
13154
  private populateUrl(
13156
- url: URL,
13155
+ url: string,
13157
13156
  key: string,
13158
13157
  selections: string[],
13159
13158
  comment: string | undefined,
13160
13159
  params: Record<string, string | undefined>,
13161
- ): void {
13160
+ ): string {
13162
13161
  const allParams: Record<string, string | undefined> = {
13163
13162
  key,
13164
13163
  comment: comment ?? this.defaultComment,
@@ -13166,10 +13165,13 @@ export class TornApiClient {
13166
13165
  ...params,
13167
13166
  };
13168
13167
 
13169
- Object.entries(allParams)
13168
+ const query = Object.entries(allParams)
13170
13169
  .filter<[string, string]>(
13171
13170
  (entry): entry is [string, string] => !!entry[1],
13172
13171
  )
13173
- .forEach(([key, value]) => url.searchParams.set(key, value));
13172
+ .map(([key, value]) => `${key}=${value}`)
13173
+ .join("&");
13174
+
13175
+ return `${url}?${query}`;
13174
13176
  }
13175
13177
  }
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.2"
6
+ "version": "4.3.4"
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
  },
@@ -14263,6 +14276,7 @@
14263
14276
  "territory",
14264
14277
  "raid",
14265
14278
  "chain",
14279
+ "chainOngoing",
14266
14280
  "db"
14267
14281
  ]
14268
14282
  },
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "tornapi-typescript",
3
3
  "type": "module",
4
- "version": "4.3.2",
4
+ "version": "4.3.4",
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.0",
10
+ "@types/node": "^24.10.1",
11
11
  "prettier": "^3.6.2",
12
12
  "typeconv": "^2.3.1",
13
13
  "typescript": "^5.9.3"