torn-client 0.1.9 → 0.2.0

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.mts CHANGED
@@ -4006,7 +4006,7 @@ declare class FactionEndpoint {
4006
4006
  to?: number;
4007
4007
  cat?: "all" | "current" | "all" | "recruiting" | "planning" | "failure" | "successful" | "expired" | "available" | "completed" | FactionNewsCategory | FactionRankedWarsCategoryEnum | ReportTypeEnum | FactionWarfareTypeEnum | FactionTerritoryWarsCategoryEnum;
4008
4008
  stat?: FactionStatEnum;
4009
- filters?: "created_at" | "executed_at" | "ready_at" | "expired_at";
4009
+ filters?: "created_at" | "executed_at" | "ready_at" | "expired_at" | "incoming" | "outgoing";
4010
4010
  striptags?: "true" | "false";
4011
4011
  sort?: "DESC" | "ASC";
4012
4012
  offset?: number;
@@ -5086,6 +5086,7 @@ declare class UserEndpoint {
5086
5086
  sort?: "DESC" | "ASC";
5087
5087
  cat?: ReportTypeEnum | UserListEnum | PersonalStatsCategoryEnum | RacingRaceTypeEnum;
5088
5088
  stat?: PersonalStatsStatName[];
5089
+ filters?: "incoming" | "outgoing";
5089
5090
  striptags?: "true" | "false";
5090
5091
  offset?: number;
5091
5092
  timestamp?: string;
package/dist/index.d.ts CHANGED
@@ -4006,7 +4006,7 @@ declare class FactionEndpoint {
4006
4006
  to?: number;
4007
4007
  cat?: "all" | "current" | "all" | "recruiting" | "planning" | "failure" | "successful" | "expired" | "available" | "completed" | FactionNewsCategory | FactionRankedWarsCategoryEnum | ReportTypeEnum | FactionWarfareTypeEnum | FactionTerritoryWarsCategoryEnum;
4008
4008
  stat?: FactionStatEnum;
4009
- filters?: "created_at" | "executed_at" | "ready_at" | "expired_at";
4009
+ filters?: "created_at" | "executed_at" | "ready_at" | "expired_at" | "incoming" | "outgoing";
4010
4010
  striptags?: "true" | "false";
4011
4011
  sort?: "DESC" | "ASC";
4012
4012
  offset?: number;
@@ -5086,6 +5086,7 @@ declare class UserEndpoint {
5086
5086
  sort?: "DESC" | "ASC";
5087
5087
  cat?: ReportTypeEnum | UserListEnum | PersonalStatsCategoryEnum | RacingRaceTypeEnum;
5088
5088
  stat?: PersonalStatsStatName[];
5089
+ filters?: "incoming" | "outgoing";
5089
5090
  striptags?: "true" | "false";
5090
5091
  offset?: number;
5091
5092
  timestamp?: string;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var a=class{requester;constructor(e){this.requester=e;}async applications(e){let t="/faction/applications",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacks(e){let t="/faction/attacks",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacksfull(e){let t="/faction/attacksfull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async balance(e){let t="/faction/balance",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async basic(e){let t="/faction/basic",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chain(e){let t="/faction/chain",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chains(e){let t="/faction/chains",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chainreport(e){let t="/faction/chainreport",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async contributors(e){let t="/faction/contributors",s={...e?.stat!==void 0&&{stat:e.stat},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async crimes(e){let t="/faction/crimes",s={...e?.cat!==void 0&&{cat:e.cat},...e?.filters!==void 0&&{filters:e.filters},...e?.offset!==void 0&&{offset:e.offset},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/faction/hof",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async members(e){let t="/faction/members",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async news(e){let t="/faction/news",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async positions(e){let t="/faction/positions",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rackets(e){let t="/faction/rackets",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async raids(e){let t="/faction/raids",s={...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rankedwars(e){let t="/faction/rankedwars",s={...e?.cat!==void 0&&{cat:e.cat},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async reports(e){let t="/faction/reports",s={...e?.cat!==void 0&&{cat:e.cat},...e?.target!==void 0&&{target:e.target},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revives(e){let t="/faction/revives",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revivesfull(e){let t="/faction/revivesFull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async search(e){let t="/faction/search",s={...e?.name!==void 0&&{name:e.name},...e?.filters&&{filters:e.filters.join(",")},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async stats(e){let t="/faction/stats",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t="/faction/territory",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territoryownership(e){let t="/faction/territoryownership",s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territorywars(e){let t="/faction/territorywars",s={...e?.cat!==void 0&&{cat:e.cat},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async upgrades(e){let t="/faction/upgrades",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async warfare(e){let t="/faction/warfare",s={...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async wars(e){let t="/faction/wars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/faction/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/faction/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/faction",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.cat!==void 0&&{cat:e.cat},...e?.stat!==void 0&&{stat:e.stat},...e?.filters!==void 0&&{filters:e.filters},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.sort!==void 0&&{sort:e.sort},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new F(this.requester,e)}withChainId(e){return new T(this.requester,e)}withCrimeId(e){return new I(this.requester,e)}withRaidWarId(e){return new k(this.requester,e)}withRankedWarId(e){return new C(this.requester,e)}withTerritoryWarId(e){return new x(this.requester,e)}},F=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async basic(e){let t=`/faction/${this.contextId}/basic`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chain(e){let t=`/faction/${this.contextId}/chain`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chains(e){let t=`/faction/${this.contextId}/chains`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t=`/faction/${this.contextId}/hof`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async members(e){let t=`/faction/${this.contextId}/members`,s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async raids(e){let t=`/faction/${this.contextId}/raids`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rankedwars(e){let t=`/faction/${this.contextId}/rankedwars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t=`/faction/${this.contextId}/territory`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territorywars(e){let t=`/faction/${this.contextId}/territorywars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async wars(e){let t=`/faction/${this.contextId}/wars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(){let e=`/faction/${this.contextId}`,t={};return this.requester(e,t)}},T=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async chainreport(e){let t=`/faction/${this.contextId}/chainreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},I=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async crime(e){let t=`/faction/${this.contextId}/crime`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},k=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async raidreport(e){let t=`/faction/${this.contextId}/raidreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},C=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async rankedwarreport(e){let t=`/faction/${this.contextId}/rankedwarreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},x=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async territorywarreport(e){let t=`/faction/${this.contextId}/territorywarreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var f=class{requester;constructor(e){this.requester=e;}async categories(e){let t="/forum/categories",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async threads(e){let t="/forum/threads",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/forum/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/forum/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/forum",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withThreadId(e){return new v(this.requester,e)}withCategoryIds(e){return new S(this.requester,e)}},v=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async posts(e){let t=`/forum/${this.contextId}/posts`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async thread(e){let t=`/forum/${this.contextId}/thread`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},S=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async threads(e){let t=`/forum/${this.contextId}/threads`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var l=class{requester;constructor(e){this.requester=e;}async log(e){let t="/key/log",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async info(e){let t="/key/info",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/key",s={...e?.selections&&{selections:e.selections.join(",")},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var h=class{requester;constructor(e){this.requester=e;}async bazaar(e){let t="/market/bazaar",s={...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/market/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/market/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/market",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.cat!==void 0&&{cat:e.cat},...e?.bonus!==void 0&&{bonus:e.bonus},...e?.sort!==void 0&&{sort:e.sort},...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new w(this.requester,e)}withPropertyTypeId(e){return new E(this.requester,e)}},w=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async bazaar(e){let t=`/market/${this.contextId}/bazaar`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmarket(e){let t=`/market/${this.contextId}/itemmarket`,s={...e?.bonus!==void 0&&{bonus:e.bonus},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},E=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async properties(e){let t=`/market/${this.contextId}/properties`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rentals(e){let t=`/market/${this.contextId}/rentals`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var g=class{requester;constructor(e){this.requester=e;}withId(e){return new U(this.requester,e)}async lookup(e){let t="/property/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/property/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/property",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},U=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async get(e){let t=`/property/${this.contextId}/property`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var y=class{requester;constructor(e){this.requester=e;}async cars(e){let t="/racing/cars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async carupgrades(e){let t="/racing/carupgrades",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async races(e){let t="/racing/races",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async tracks(e){let t="/racing/tracks",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/racing/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/racing/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/racing",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withRaceId(e){return new A(this.requester,e)}withTrackId(e){return new L(this.requester,e)}},A=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async race(e){let t=`/racing/${this.contextId}/race`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},L=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async records(e){let t=`/racing/${this.contextId}/records`,s={...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var R=class{requester;constructor(e){this.requester=e;}async attacklog(e){let t="/torn/attacklog",s={...e?.log!==void 0&&{log:e.log},...e?.offset!==void 0&&{offset:e.offset},...e?.sort!==void 0&&{sort:e.sort},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async bounties(e){let t="/torn/bounties",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async calendar(e){let t="/torn/calendar",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async crimes(e){let t="/torn/crimes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async education(e){let t="/torn/education",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factionhof(e){let t="/torn/factionhof",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factiontree(e){let t="/torn/factiontree",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/torn/hof",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemammo(e){let t="/torn/itemammo",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmods(e){let t="/torn/itemmods",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async items(e){let t="/torn/items",s={...e?.cat!==void 0&&{cat:e.cat},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async logcategories(e){let t="/torn/logcategories",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async logtypes(e){let t="/torn/logtypes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async organizedcrimes(e){let t="/torn/organizedcrimes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t="/torn/properties",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t="/torn/territory",s={...e?.ids&&{ids:e.ids.join(",")},...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/torn/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/torn/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/torn",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.sort!==void 0&&{sort:e.sort},...e?.cat!==void 0&&{cat:e.cat},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withIds(e){return new M(this.requester,e)}withLogCategoryId(e){return new K(this.requester,e)}withCrimeId(e){return new D(this.requester,e)}},M=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async items(e){let t=`/torn/${this.contextId}/items`,s={...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},K=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async logtypes(e){let t=`/torn/${this.contextId}/logtypes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},D=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async subcrimes(e){let t=`/torn/${this.contextId}/subcrimes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var b=class{requester;constructor(e){this.requester=e;}async attacks(e){let t="/user/attacks",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacksfull(e){let t="/user/attacksfull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async bounties(e){let t="/user/bounties",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async calendar(e){let t="/user/calendar",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async education(e){let t="/user/education",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async enlistedcars(e){let t="/user/enlistedcars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factionbalance(e){let t="/user/factionbalance",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumfeed(e){let t="/user/forumfeed",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumfriends(e){let t="/user/forumfriends",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumposts(e){let t="/user/forumposts",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumsubscribedthreads(e){let t="/user/forumsubscribedthreads",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumthreads(e){let t="/user/forumthreads",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/user/hof",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmarket(e){let t="/user/itemmarket",s={...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async jobranks(e){let t="/user/jobranks",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async list(e){let t="/user/list",s={...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async log(e){let t="/user/log",s={...e?.log&&{log:e.log.join(",")},...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async organizedcrime(e){let t="/user/organizedcrime",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async personalstats(e){let t="/user/personalstats",s={...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t="/user/properties",s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async property(e){let t="/user/property",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async races(e){let t="/user/races",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async racingrecords(e){let t="/user/racingrecords",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async reports(e){let t="/user/reports",s={...e?.cat!==void 0&&{cat:e.cat},...e?.target!==void 0&&{target:e.target},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revives(e){let t="/user/revives",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revivesfull(e){let t="/user/revivesFull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/user/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/user/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/user",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new W(this.requester,e)}withCrimeId(e){return new $(this.requester,e)}},W=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async bounties(e){let t=`/user/${this.contextId}/bounties`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumposts(e){let t=`/user/${this.contextId}/forumposts`,s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumthreads(e){let t=`/user/${this.contextId}/forumthreads`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t=`/user/${this.contextId}/hof`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async personalstats(e){let t=`/user/${this.contextId}/personalstats`,s={...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t=`/user/${this.contextId}/properties`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async property(e){let t=`/user/${this.contextId}/property`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(){let e=`/user/${this.contextId}`,t={};return this.requester(e,t)}},$=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async crimes(e){let t=`/user/${this.contextId}/crimes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var c=class extends Error{code;constructor(e){super(e.error),this.name="TornApiError",this.code=e.code;}},d=class extends Error{constructor(e){super(e),this.name="TornRateLimitError";}};var q=class{nextUrl;prevUrl;requester;constructor(e,t,s,r){Object.assign(this,e),this.nextUrl=t,this.prevUrl=s,this.requester=r;}async fetchPage(e){if(!e)return null;let t=new URL(e),s=t.pathname.substring(3),r={};for(let[u,n]of t.searchParams.entries())r[u]=n;return this.requester(s,r)}next(){return this.fetchPage(this.nextUrl)}prev(){return this.fetchPage(this.prevUrl)}};var j=i=>i instanceof Error,z=i=>typeof i=="object"&&i!==null&&"error"in i&&typeof i.error=="object"&&i.error!==null&&"code"in i.error&&"error"in i.error,N=i=>typeof i=="object"&&i!==null&&"_metadata"in i&&typeof i._metadata=="object"&&i._metadata!==null&&"links"in i._metadata,P=class{apiKeys;rateLimitMode;comment;headers;apiUrl;apiKeyBalancing;verbose;apiKeyIndex=0;requestTimestamps=new Map;constructor(e){if(!e.apiKeys||e.apiKeys.length===0)throw new Error("At least one API key must be provided.");this.apiKeys=e.apiKeys,this.rateLimitMode=e.rateLimitMode??"autoDelay",this.comment=e.comment,this.headers=e.headers??{},this.apiUrl=e.apiUrl??"https://api.torn.com/v2",this.apiKeyBalancing=e.apiKeyBalancing??"roundRobin",this.verbose=!!e.verbose;for(let t of this.apiKeys)this.requestTimestamps.set(t,[]);}log(...e){this.verbose&&console.log("[TornClient]",...e);}requester=this.makeRequest.bind(this);isKeyAvailable(e){if(this.rateLimitMode==="ignore")return true;let s=Date.now()-6e4,r=(this.requestTimestamps.get(e)??[]).filter(u=>u>s);return this.requestTimestamps.set(e,r),r.length<100}findAvailableKey(){for(let e=0;e<this.apiKeys.length;e++){let t=this.getApiKey();if(this.isKeyAvailable(t))return t}return null}getMinWaitTime(){let e=Date.now(),t=60100;for(let s of this.apiKeys){let r=this.requestTimestamps.get(s)??[];if(r.length>=100){let u=r[0],n=6e4-(e-u)+100;n<t&&(t=n);}}return Math.max(0,t)}getApiKey(){if(this.apiKeys.length===1)return this.apiKeys[0];if(this.apiKeyBalancing==="random"){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}let e=this.apiKeys[this.apiKeyIndex];return this.apiKeyIndex=(this.apiKeyIndex+1)%this.apiKeys.length,e}async makeRequest(e,t){this.log("Request received:",e,t);let s=this.findAvailableKey();if(!s){if(this.rateLimitMode==="autoDelay"){let n=this.getMinWaitTime();this.log(`All keys are on cooldown. Delaying for ${n}ms...`),await new Promise(o=>setTimeout(o,n)),s=this.findAvailableKey();}if(!s){let n=new d("Rate limit of 100 requests/minute exceeded for all available keys");throw this.log("Rate limit exceeded for all keys"),n}}this.log(`Using API key: ${s.slice(0,5)}...`);let r=new URL(`${this.apiUrl}${e}`);for(let[n,o]of Object.entries(t))o!=null&&n!=="key"&&n!=="comment"&&r.searchParams.set(n,String(o));this.comment&&r.searchParams.set("comment",this.comment);let u={headers:{Accept:"application/json",Authorization:`ApiKey ${s}`,...this.headers}};try{this.log("Fetching:",r.toString());let n=await fetch(r.toString(),u);if(this.rateLimitMode!=="ignore"){let p=this.requestTimestamps.get(s)??[];p.push(Date.now()),this.requestTimestamps.set(s,p);}if(!n.ok)throw new Error(`Request failed with status ${n.status}: ${n.statusText}`);let o=await n.json();if(z(o))throw new c(o.error);let m;return N(o)?m=new q(o,o._metadata.links.next,o._metadata.links.prev,this.requester):m=o,this.log("Response data:",m),m}catch(n){let o=j(n)?n:new Error("An unknown error occurred");throw this.log("Request failed:",o.message),o}}getRateLimitInfo(){let e=Date.now(),t=e-6e4,s={};for(let r of this.apiKeys){let u=(this.requestTimestamps.get(r)??[]).filter(H=>H>t),n=u.length,o=Math.max(0,100-n),m=u[0]??null,p=m?Math.max(0,6e4-(e-m)):0;s[r.slice(0,5)]={used:n,remaining:o,resetInMs:p};}return s}};var B=class{user;faction;market;property;racing;forum;key;torn;rateLimitMode;requestHandler;constructor(e){if(!e.apiKeys||e.apiKeys.length===0)throw new Error("At least one API key is required to initialize the client.");this.rateLimitMode=e.rateLimitMode??"autoDelay",this.requestHandler=new P(e);let t=this.requestHandler.requester;this.user=new b(t),this.faction=new a(t),this.market=new h(t),this.property=new g(t),this.racing=new y(t),this.forum=new f(t),this.torn=new R(t),this.key=new l(t);}getRateLimitInfo(){return this.requestHandler.getRateLimitInfo()}};
2
- exports.FactionChainIdContext=T;exports.FactionCrimeIdContext=I;exports.FactionEndpoint=a;exports.FactionIdContext=F;exports.FactionRaidWarIdContext=k;exports.FactionRankedWarIdContext=C;exports.FactionTerritoryWarIdContext=x;exports.ForumCategoryIdsContext=S;exports.ForumEndpoint=f;exports.ForumThreadIdContext=v;exports.KeyEndpoint=l;exports.MarketEndpoint=h;exports.MarketIdContext=w;exports.MarketPropertyTypeIdContext=E;exports.PaginatedResponse=q;exports.PropertyEndpoint=g;exports.PropertyIdContext=U;exports.RacingEndpoint=y;exports.RacingRaceIdContext=A;exports.RacingTrackIdContext=L;exports.TornAPI=B;exports.TornApiError=c;exports.TornCrimeIdContext=D;exports.TornEndpoint=R;exports.TornIdsContext=M;exports.TornLogCategoryIdContext=K;exports.TornRateLimitError=d;exports.UserCrimeIdContext=$;exports.UserEndpoint=b;exports.UserIdContext=W;//# sourceMappingURL=index.js.map
1
+ 'use strict';var a=class{requester;constructor(e){this.requester=e;}async applications(e){let t="/faction/applications",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacks(e){let t="/faction/attacks",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacksfull(e){let t="/faction/attacksfull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async balance(e){let t="/faction/balance",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async basic(e){let t="/faction/basic",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chain(e){let t="/faction/chain",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chains(e){let t="/faction/chains",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chainreport(e){let t="/faction/chainreport",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async contributors(e){let t="/faction/contributors",s={...e?.stat!==void 0&&{stat:e.stat},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async crimes(e){let t="/faction/crimes",s={...e?.cat!==void 0&&{cat:e.cat},...e?.filters!==void 0&&{filters:e.filters},...e?.offset!==void 0&&{offset:e.offset},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/faction/hof",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async members(e){let t="/faction/members",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async news(e){let t="/faction/news",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async positions(e){let t="/faction/positions",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rackets(e){let t="/faction/rackets",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async raids(e){let t="/faction/raids",s={...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rankedwars(e){let t="/faction/rankedwars",s={...e?.cat!==void 0&&{cat:e.cat},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async reports(e){let t="/faction/reports",s={...e?.cat!==void 0&&{cat:e.cat},...e?.target!==void 0&&{target:e.target},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revives(e){let t="/faction/revives",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revivesfull(e){let t="/faction/revivesFull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async search(e){let t="/faction/search",s={...e?.name!==void 0&&{name:e.name},...e?.filters&&{filters:e.filters.join(",")},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async stats(e){let t="/faction/stats",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t="/faction/territory",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territoryownership(e){let t="/faction/territoryownership",s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territorywars(e){let t="/faction/territorywars",s={...e?.cat!==void 0&&{cat:e.cat},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async upgrades(e){let t="/faction/upgrades",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async warfare(e){let t="/faction/warfare",s={...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async wars(e){let t="/faction/wars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/faction/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/faction/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/faction",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.cat!==void 0&&{cat:e.cat},...e?.stat!==void 0&&{stat:e.stat},...e?.filters!==void 0&&{filters:e.filters},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.sort!==void 0&&{sort:e.sort},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new F(this.requester,e)}withChainId(e){return new T(this.requester,e)}withCrimeId(e){return new I(this.requester,e)}withRaidWarId(e){return new k(this.requester,e)}withRankedWarId(e){return new C(this.requester,e)}withTerritoryWarId(e){return new x(this.requester,e)}},F=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async basic(e){let t=`/faction/${this.contextId}/basic`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chain(e){let t=`/faction/${this.contextId}/chain`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async chains(e){let t=`/faction/${this.contextId}/chains`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t=`/faction/${this.contextId}/hof`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async members(e){let t=`/faction/${this.contextId}/members`,s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async raids(e){let t=`/faction/${this.contextId}/raids`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rankedwars(e){let t=`/faction/${this.contextId}/rankedwars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t=`/faction/${this.contextId}/territory`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territorywars(e){let t=`/faction/${this.contextId}/territorywars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async wars(e){let t=`/faction/${this.contextId}/wars`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(){let e=`/faction/${this.contextId}`,t={};return this.requester(e,t)}},T=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async chainreport(e){let t=`/faction/${this.contextId}/chainreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},I=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async crime(e){let t=`/faction/${this.contextId}/crime`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},k=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async raidreport(e){let t=`/faction/${this.contextId}/raidreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},C=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async rankedwarreport(e){let t=`/faction/${this.contextId}/rankedwarreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},x=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async territorywarreport(e){let t=`/faction/${this.contextId}/territorywarreport`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var f=class{requester;constructor(e){this.requester=e;}async categories(e){let t="/forum/categories",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async threads(e){let t="/forum/threads",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/forum/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/forum/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/forum",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withThreadId(e){return new v(this.requester,e)}withCategoryIds(e){return new S(this.requester,e)}},v=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async posts(e){let t=`/forum/${this.contextId}/posts`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async thread(e){let t=`/forum/${this.contextId}/thread`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},S=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async threads(e){let t=`/forum/${this.contextId}/threads`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var l=class{requester;constructor(e){this.requester=e;}async log(e){let t="/key/log",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async info(e){let t="/key/info",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/key",s={...e?.selections&&{selections:e.selections.join(",")},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var g=class{requester;constructor(e){this.requester=e;}async bazaar(e){let t="/market/bazaar",s={...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/market/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/market/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/market",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.cat!==void 0&&{cat:e.cat},...e?.bonus!==void 0&&{bonus:e.bonus},...e?.sort!==void 0&&{sort:e.sort},...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new w(this.requester,e)}withPropertyTypeId(e){return new E(this.requester,e)}},w=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async bazaar(e){let t=`/market/${this.contextId}/bazaar`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmarket(e){let t=`/market/${this.contextId}/itemmarket`,s={...e?.bonus!==void 0&&{bonus:e.bonus},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},E=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async properties(e){let t=`/market/${this.contextId}/properties`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async rentals(e){let t=`/market/${this.contextId}/rentals`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var h=class{requester;constructor(e){this.requester=e;}withId(e){return new U(this.requester,e)}async lookup(e){let t="/property/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/property/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/property",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},U=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async get(e){let t=`/property/${this.contextId}/property`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var y=class{requester;constructor(e){this.requester=e;}async cars(e){let t="/racing/cars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async carupgrades(e){let t="/racing/carupgrades",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async races(e){let t="/racing/races",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async tracks(e){let t="/racing/tracks",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/racing/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/racing/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/racing",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.cat!==void 0&&{cat:e.cat},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withRaceId(e){return new A(this.requester,e)}withTrackId(e){return new L(this.requester,e)}},A=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async race(e){let t=`/racing/${this.contextId}/race`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},L=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async records(e){let t=`/racing/${this.contextId}/records`,s={...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var R=class{requester;constructor(e){this.requester=e;}async attacklog(e){let t="/torn/attacklog",s={...e?.log!==void 0&&{log:e.log},...e?.offset!==void 0&&{offset:e.offset},...e?.sort!==void 0&&{sort:e.sort},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async bounties(e){let t="/torn/bounties",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async calendar(e){let t="/torn/calendar",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async crimes(e){let t="/torn/crimes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async education(e){let t="/torn/education",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factionhof(e){let t="/torn/factionhof",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factiontree(e){let t="/torn/factiontree",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/torn/hof",s={...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemammo(e){let t="/torn/itemammo",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmods(e){let t="/torn/itemmods",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async items(e){let t="/torn/items",s={...e?.cat!==void 0&&{cat:e.cat},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async logcategories(e){let t="/torn/logcategories",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async logtypes(e){let t="/torn/logtypes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async organizedcrimes(e){let t="/torn/organizedcrimes",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t="/torn/properties",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async territory(e){let t="/torn/territory",s={...e?.ids&&{ids:e.ids.join(",")},...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/torn/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/torn/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/torn",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.sort!==void 0&&{sort:e.sort},...e?.cat!==void 0&&{cat:e.cat},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withIds(e){return new M(this.requester,e)}withLogCategoryId(e){return new K(this.requester,e)}withCrimeId(e){return new D(this.requester,e)}},M=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async items(e){let t=`/torn/${this.contextId}/items`,s={...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},K=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async logtypes(e){let t=`/torn/${this.contextId}/logtypes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}},D=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async subcrimes(e){let t=`/torn/${this.contextId}/subcrimes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var b=class{requester;constructor(e){this.requester=e;}async attacks(e){let t="/user/attacks",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async attacksfull(e){let t="/user/attacksfull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async bounties(e){let t="/user/bounties",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async calendar(e){let t="/user/calendar",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async education(e){let t="/user/education",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async enlistedcars(e){let t="/user/enlistedcars",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async factionbalance(e){let t="/user/factionbalance",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumfeed(e){let t="/user/forumfeed",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumfriends(e){let t="/user/forumfriends",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumposts(e){let t="/user/forumposts",s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumsubscribedthreads(e){let t="/user/forumsubscribedthreads",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumthreads(e){let t="/user/forumthreads",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t="/user/hof",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async itemmarket(e){let t="/user/itemmarket",s={...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async jobranks(e){let t="/user/jobranks",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async list(e){let t="/user/list",s={...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.sort!==void 0&&{sort:e.sort},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async log(e){let t="/user/log",s={...e?.log&&{log:e.log.join(",")},...e?.cat!==void 0&&{cat:e.cat},...e?.limit!==void 0&&{limit:e.limit},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async organizedcrime(e){let t="/user/organizedcrime",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async personalstats(e){let t="/user/personalstats",s={...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t="/user/properties",s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async property(e){let t="/user/property",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async races(e){let t="/user/races",s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.cat!==void 0&&{cat:e.cat},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async racingrecords(e){let t="/user/racingrecords",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async reports(e){let t="/user/reports",s={...e?.cat!==void 0&&{cat:e.cat},...e?.target!==void 0&&{target:e.target},...e?.limit!==void 0&&{limit:e.limit},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revives(e){let t="/user/revives",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async revivesfull(e){let t="/user/revivesFull",s={...e?.filters!==void 0&&{filters:e.filters},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.to!==void 0&&{to:e.to},...e?.from!==void 0&&{from:e.from},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async lookup(e){let t="/user/lookup",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async timestamp(e){let t="/user/timestamp",s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(e){let t="/user",s={...e?.selections&&{selections:e.selections.join(",")},...e?.id!==void 0&&{id:e.id},...e?.limit!==void 0&&{limit:e.limit},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.sort!==void 0&&{sort:e.sort},...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.filters!==void 0&&{filters:e.filters},...e?.striptags!==void 0&&{striptags:e.striptags},...e?.offset!==void 0&&{offset:e.offset},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}withId(e){return new W(this.requester,e)}withCrimeId(e){return new $(this.requester,e)}},W=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async bounties(e){let t=`/user/${this.contextId}/bounties`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumposts(e){let t=`/user/${this.contextId}/forumposts`,s={...e?.striptags!==void 0&&{striptags:e.striptags},...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async forumthreads(e){let t=`/user/${this.contextId}/forumthreads`,s={...e?.limit!==void 0&&{limit:e.limit},...e?.sort!==void 0&&{sort:e.sort},...e?.from!==void 0&&{from:e.from},...e?.to!==void 0&&{to:e.to},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async hof(e){let t=`/user/${this.contextId}/hof`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async personalstats(e){let t=`/user/${this.contextId}/personalstats`,s={...e?.cat!==void 0&&{cat:e.cat},...e?.stat&&{stat:e.stat.join(",")},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async properties(e){let t=`/user/${this.contextId}/properties`,s={...e?.offset!==void 0&&{offset:e.offset},...e?.limit!==void 0&&{limit:e.limit},...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async property(e){let t=`/user/${this.contextId}/property`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}async get(){let e=`/user/${this.contextId}`,t={};return this.requester(e,t)}},$=class{requester;contextId;constructor(e,t){this.requester=e,this.contextId=t;}async crimes(e){let t=`/user/${this.contextId}/crimes`,s={...e?.timestamp!==void 0&&{timestamp:e.timestamp}};return this.requester(t,s)}};var c=class extends Error{code;constructor(e){super(e.error),this.name="TornApiError",this.code=e.code;}},d=class extends Error{constructor(e){super(e),this.name="TornRateLimitError";}};var q=class{nextUrl;prevUrl;requester;constructor(e,t,s,r){Object.assign(this,e),this.nextUrl=t,this.prevUrl=s,this.requester=r;}async fetchPage(e){if(!e)return null;let t=new URL(e),s=t.pathname.substring(3),r={};for(let[u,n]of t.searchParams.entries())r[u]=n;return this.requester(s,r)}next(){return this.fetchPage(this.nextUrl)}prev(){return this.fetchPage(this.prevUrl)}};var j=i=>i instanceof Error,z=i=>typeof i=="object"&&i!==null&&"error"in i&&typeof i.error=="object"&&i.error!==null&&"code"in i.error&&"error"in i.error,N=i=>typeof i=="object"&&i!==null&&"_metadata"in i&&typeof i._metadata=="object"&&i._metadata!==null&&"links"in i._metadata,P=class{apiKeys;rateLimitMode;comment;headers;apiUrl;apiKeyBalancing;verbose;apiKeyIndex=0;requestTimestamps=new Map;constructor(e){if(!e.apiKeys||e.apiKeys.length===0)throw new Error("At least one API key must be provided.");this.apiKeys=e.apiKeys,this.rateLimitMode=e.rateLimitMode??"autoDelay",this.comment=e.comment,this.headers=e.headers??{},this.apiUrl=e.apiUrl??"https://api.torn.com/v2",this.apiKeyBalancing=e.apiKeyBalancing??"roundRobin",this.verbose=!!e.verbose;for(let t of this.apiKeys)this.requestTimestamps.set(t,[]);}log(...e){this.verbose&&console.log("[TornClient]",...e);}requester=this.makeRequest.bind(this);isKeyAvailable(e){if(this.rateLimitMode==="ignore")return true;let s=Date.now()-6e4,r=(this.requestTimestamps.get(e)??[]).filter(u=>u>s);return this.requestTimestamps.set(e,r),r.length<100}findAvailableKey(){for(let e=0;e<this.apiKeys.length;e++){let t=this.getApiKey();if(this.isKeyAvailable(t))return t}return null}getMinWaitTime(){let e=Date.now(),t=60100;for(let s of this.apiKeys){let r=this.requestTimestamps.get(s)??[];if(r.length>=100){let u=r[0],n=6e4-(e-u)+100;n<t&&(t=n);}}return Math.max(0,t)}getApiKey(){if(this.apiKeys.length===1)return this.apiKeys[0];if(this.apiKeyBalancing==="random"){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}let e=this.apiKeys[this.apiKeyIndex];return this.apiKeyIndex=(this.apiKeyIndex+1)%this.apiKeys.length,e}async makeRequest(e,t){this.log("Request received:",e,t);let s=this.findAvailableKey();if(!s){if(this.rateLimitMode==="autoDelay"){let n=this.getMinWaitTime();this.log(`All keys are on cooldown. Delaying for ${n}ms...`),await new Promise(o=>setTimeout(o,n)),s=this.findAvailableKey();}if(!s){let n=new d("Rate limit of 100 requests/minute exceeded for all available keys");throw this.log("Rate limit exceeded for all keys"),n}}this.log(`Using API key: ${s.slice(0,5)}...`);let r=new URL(`${this.apiUrl}${e}`);for(let[n,o]of Object.entries(t))o!=null&&n!=="key"&&n!=="comment"&&r.searchParams.set(n,String(o));this.comment&&r.searchParams.set("comment",this.comment);let u={headers:{Accept:"application/json",Authorization:`ApiKey ${s}`,...this.headers}};try{this.log("Fetching:",r.toString());let n=await fetch(r.toString(),u);if(this.rateLimitMode!=="ignore"){let p=this.requestTimestamps.get(s)??[];p.push(Date.now()),this.requestTimestamps.set(s,p);}if(!n.ok)throw new Error(`Request failed with status ${n.status}: ${n.statusText}`);let o=await n.json();if(z(o))throw new c(o.error);let m;return N(o)?m=new q(o,o._metadata.links.next,o._metadata.links.prev,this.requester):m=o,this.log("Response data:",m),m}catch(n){let o=j(n)?n:new Error("An unknown error occurred");throw this.log("Request failed:",o.message),o}}getRateLimitInfo(){let e=Date.now(),t=e-6e4,s={};for(let r of this.apiKeys){let u=(this.requestTimestamps.get(r)??[]).filter(H=>H>t),n=u.length,o=Math.max(0,100-n),m=u[0]??null,p=m?Math.max(0,6e4-(e-m)):0;s[r.slice(0,5)]={used:n,remaining:o,resetInMs:p};}return s}};var B=class{user;faction;market;property;racing;forum;key;torn;rateLimitMode;requestHandler;constructor(e){if(!e.apiKeys||e.apiKeys.length===0)throw new Error("At least one API key is required to initialize the client.");this.rateLimitMode=e.rateLimitMode??"autoDelay",this.requestHandler=new P(e);let t=this.requestHandler.requester;this.user=new b(t),this.faction=new a(t),this.market=new g(t),this.property=new h(t),this.racing=new y(t),this.forum=new f(t),this.torn=new R(t),this.key=new l(t);}getRateLimitInfo(){return this.requestHandler.getRateLimitInfo()}};
2
+ exports.FactionChainIdContext=T;exports.FactionCrimeIdContext=I;exports.FactionEndpoint=a;exports.FactionIdContext=F;exports.FactionRaidWarIdContext=k;exports.FactionRankedWarIdContext=C;exports.FactionTerritoryWarIdContext=x;exports.ForumCategoryIdsContext=S;exports.ForumEndpoint=f;exports.ForumThreadIdContext=v;exports.KeyEndpoint=l;exports.MarketEndpoint=g;exports.MarketIdContext=w;exports.MarketPropertyTypeIdContext=E;exports.PaginatedResponse=q;exports.PropertyEndpoint=h;exports.PropertyIdContext=U;exports.RacingEndpoint=y;exports.RacingRaceIdContext=A;exports.RacingTrackIdContext=L;exports.TornAPI=B;exports.TornApiError=c;exports.TornCrimeIdContext=D;exports.TornEndpoint=R;exports.TornIdsContext=M;exports.TornLogCategoryIdContext=K;exports.TornRateLimitError=d;exports.UserCrimeIdContext=$;exports.UserEndpoint=b;exports.UserIdContext=W;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map