@wumx-labs/noxaeapi-sdk 0.3.5 → 0.4.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.cts CHANGED
@@ -268,6 +268,41 @@ interface NetworkHealthResponse {
268
268
  }
269
269
  /** Per-server "success" | "error" result, keyed by network server ID. */
270
270
  type NetworkBroadcastResponse = Record<string, "success" | "error">;
271
+ /** Last-known state of one backend node, as tracked by the network hub. */
272
+ interface NetworkHubNode {
273
+ id: string;
274
+ label: string;
275
+ online: boolean;
276
+ tps: string;
277
+ onlinePlayers: number;
278
+ maxPlayers: number;
279
+ /** Opaque payload the backend reported in its last heartbeat. Shape isn't fixed by the hub. */
280
+ health: unknown;
281
+ /** Unix epoch ms of the last heartbeat received, or 0 if never. */
282
+ lastHeartbeatAt: number;
283
+ }
284
+ interface NetworkHubStatusResponse {
285
+ network: NetworkHubNode[];
286
+ }
287
+ /** A player as seen directly by the proxy (not reported by a backend). */
288
+ interface NetworkHubPlayer {
289
+ uuid: string;
290
+ name: string;
291
+ /** Backend server ID the player is currently connected to, if known. */
292
+ server?: string;
293
+ }
294
+ interface NetworkHubPlayersResponse {
295
+ total: number;
296
+ players: NetworkHubPlayer[];
297
+ }
298
+ interface NetworkHubFindPlayerResponse {
299
+ found: boolean;
300
+ player?: NetworkHubPlayer;
301
+ }
302
+ /** Result of a proxy-wide broadcast: how many connected players received the message. */
303
+ interface NetworkHubBroadcastResponse {
304
+ delivered: number;
305
+ }
271
306
 
272
307
  declare class PlayersModule {
273
308
  private readonly http;
@@ -670,6 +705,69 @@ declare class NetworkModule {
670
705
  }): Promise<T>;
671
706
  }
672
707
 
708
+ /**
709
+ * Wraps the `/v1/network/*` routes exposed by the **NoxAeApi-Velocity**
710
+ * network hub — a separate plugin/process from NoxAeApi-main, run on the
711
+ * Velocity proxy and listening on its own port (`NetworkHubConfig`'s
712
+ * `api-port`, distinct from any individual backend's own REST port).
713
+ *
714
+ * Point a `NoxAeApiNetworkHubClient` (not the regular `NoxAeApiClient`) at
715
+ * that port to use this module. Backend Paper/Bukkit servers connect out
716
+ * to the hub over WebSocket (`/network/register`) and push register /
717
+ * heartbeat / player-join / player-quit events; the hub answers every
718
+ * method below from its own in-memory registry, so calls here are cheap
719
+ * and don't block on a live round trip to each backend the way the older
720
+ * `NetworkModule` (NoxAeApi-main's built-in aggregator) does.
721
+ *
722
+ * Response shapes differ from `NetworkModule` even where the route names
723
+ * match — e.g. `players()` returns one flat proxy-wide player list here,
724
+ * not a per-server breakdown — so the two modules' types aren't
725
+ * interchangeable. There's also no hub equivalent of `/v1/network/health`;
726
+ * each node's last-reported health is embedded in `status*()`'s
727
+ * `NetworkHubNode.health` field instead.
728
+ */
729
+ declare class NetworkHubModule {
730
+ private readonly http;
731
+ constructor(http: HttpEngine);
732
+ /** Get last-known status (from the registry) for every backend node that has ever registered. */
733
+ statusAll(): Promise<NetworkHubStatusResponse>;
734
+ /** Get last-known status for a single node by its configured ID. */
735
+ statusById(id: string): Promise<NetworkHubNode>;
736
+ /**
737
+ * List every player currently connected to the proxy, read straight from
738
+ * Velocity's own player registry (not reported by backends), along with
739
+ * which backend server each is on.
740
+ */
741
+ players(): Promise<NetworkHubPlayersResponse>;
742
+ /** Find which backend server a player is currently on by UUID (proxy-authoritative). */
743
+ findPlayer(uuid: string): Promise<NetworkHubFindPlayerResponse>;
744
+ /**
745
+ * Broadcast a message directly to every player connected to the proxy.
746
+ * Unlike `NetworkModule.broadcast`, this doesn't forward to each
747
+ * backend's `/v1/chat/broadcast` — the proxy already has every player
748
+ * in hand — so it still delivers even to servers with no REST API of
749
+ * their own reachable from the hub.
750
+ */
751
+ broadcast(message: string): Promise<NetworkHubBroadcastResponse>;
752
+ /**
753
+ * Forward an arbitrary request to a specific backend node's own REST
754
+ * API, e.g. `hub.forward("survival", "POST", "server/exec", { body:
755
+ * { command: "say hi" }, form: true })` reaches that backend's
756
+ * `POST /v1/server/exec` directly. Useful for endpoints the hub doesn't
757
+ * have a dedicated method for (economy, worlds, etc) without
758
+ * instantiating a second client pointed at that backend directly.
759
+ *
760
+ * The target backend responds according to its own route's expected
761
+ * encoding (form vs JSON) — pass `form: true` the same way you would for
762
+ * a direct call to that endpoint.
763
+ */
764
+ forward<T = unknown>(id: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", path: string, opts?: {
765
+ body?: unknown;
766
+ query?: Record<string, QueryValue>;
767
+ form?: boolean;
768
+ }): Promise<T>;
769
+ }
770
+
673
771
  type NoxAeApiWsEvent = "open" | "close" | "error" | "console" | "event" | "message";
674
772
  type Listener = (payload: unknown) => void;
675
773
  interface NoxAeApiWsOptions {
@@ -733,7 +831,17 @@ declare class NoxAeApiClient {
733
831
  readonly skills: SkillsModule;
734
832
  /** Generic ranked leaderboards (economy currencies, mcMMO, AuraSkills, ...). */
735
833
  readonly leaderboards: LeaderboardModule;
736
- /** Only works if `network.enabled: true` is set in the server config. */
834
+ /**
835
+ * Only works if `network.enabled: true` is set in the server config.
836
+ *
837
+ * This is NoxAeApi-main's built-in polling aggregator — it lives on the
838
+ * *same* backend server you're already connected to and fans requests
839
+ * out to the other backends listed in that server's own config. If the
840
+ * network is running NoxAeApi-Velocity instead, use
841
+ * `NoxAeApiNetworkHubClient` (pointed at the proxy's hub port) rather
842
+ * than this module — the hub replaces this aggregator with a push model
843
+ * and its response shapes differ.
844
+ */
737
845
  readonly network: NetworkModule;
738
846
  private readonly http;
739
847
  private readonly baseUrl;
@@ -752,6 +860,33 @@ declare class NoxAeApiClient {
752
860
  /** Open a WebSocket connection to the server (console tail or event stream). */
753
861
  connect(options?: Partial<NoxAeApiWsOptions>): NoxAeApiSocket;
754
862
  }
863
+ /**
864
+ * Client for the **NoxAeApi-Velocity** network hub — a separate plugin
865
+ * that runs on the Velocity proxy, not on any individual backend server.
866
+ * Point `baseUrl` at the hub's own REST port (`NetworkHubConfig`'s
867
+ * `api-port`), not a backend's port, and use `NOXAEAPI_HUB_*` env vars
868
+ * (via `fromEnv`) if you keep that separate from a regular backend's
869
+ * `NOXAEAPI_*` vars.
870
+ *
871
+ * Only exposes `.network` — the hub doesn't run any of the other REST
872
+ * modules (players, economy, worlds, ...) that a backend `NoxAeApiClient`
873
+ * does. To reach a specific backend's own routes through the hub, use
874
+ * `hub.network.forward(id, ...)`.
875
+ */
876
+ declare class NoxAeApiNetworkHubClient {
877
+ /** The network hub's aggregated view of every registered backend node. */
878
+ readonly network: NetworkHubModule;
879
+ constructor(options: NoxAeApiClientOptions);
880
+ /**
881
+ * Build a hub client from environment variables:
882
+ * `NOXAEAPI_HUB_BASE_URL` and `NOXAEAPI_HUB_KEY`.
883
+ *
884
+ * Same convenience as `NoxAeApiClient.fromEnv()`, under separate env var
885
+ * names so a process can hold both a backend client and a hub client at
886
+ * once without the two colliding.
887
+ */
888
+ static fromEnv(overrides?: Partial<NoxAeApiClientOptions>): NoxAeApiNetworkHubClient;
889
+ }
755
890
 
756
891
  interface NoxAeApiErrorInfo {
757
892
  status: number;
@@ -805,4 +940,4 @@ declare class NoxAeApiNetworkError extends Error {
805
940
  constructor(message: string, method: string, path: string, cause?: unknown);
806
941
  }
807
942
 
808
- export { type Advancement, type CurrencyBalance, type CurrencyTopEntry, type EconomyInfo, type GroupInfo, type InventoryItem, type LeaderboardEntry, type LeaderboardSourceInfo, type NetworkBroadcastResponse, type NetworkFindPlayerResponse, type NetworkHealthResponse, type NetworkHealthServerEntry, type NetworkPlayersResponse, type NetworkPlayersServerEntry, type NetworkServerStatus, NoxAeApiClient, type NoxAeApiClientOptions, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError, type NoxAeApiWsEvent, type NoxAeApiWsOptions, type NoxAuthPlayerInfo, type Objective, type OfflinePlayer, type OnlinePlayer, type PasswordCheckResult, type PermissionNode, type PlayerBalance, type PlayerStats, type Plugin, type RetryOptions, type Score, type Scoreboard, type ServerBan, type ServerHealth, type ServerInfo, type SkillInfo, type TopBalanceEntry, type WhitelistEntry, type World };
943
+ export { type Advancement, type CurrencyBalance, type CurrencyTopEntry, type EconomyInfo, type GroupInfo, type InventoryItem, type LeaderboardEntry, type LeaderboardSourceInfo, type NetworkBroadcastResponse, type NetworkFindPlayerResponse, type NetworkHealthResponse, type NetworkHealthServerEntry, type NetworkHubBroadcastResponse, type NetworkHubFindPlayerResponse, type NetworkHubNode, type NetworkHubPlayer, type NetworkHubPlayersResponse, type NetworkHubStatusResponse, type NetworkPlayersResponse, type NetworkPlayersServerEntry, type NetworkServerStatus, NoxAeApiClient, type NoxAeApiClientOptions, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNetworkHubClient, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError, type NoxAeApiWsEvent, type NoxAeApiWsOptions, type NoxAuthPlayerInfo, type Objective, type OfflinePlayer, type OnlinePlayer, type PasswordCheckResult, type PermissionNode, type PlayerBalance, type PlayerStats, type Plugin, type RetryOptions, type Score, type Scoreboard, type ServerBan, type ServerHealth, type ServerInfo, type SkillInfo, type TopBalanceEntry, type WhitelistEntry, type World };
package/dist/index.d.ts CHANGED
@@ -268,6 +268,41 @@ interface NetworkHealthResponse {
268
268
  }
269
269
  /** Per-server "success" | "error" result, keyed by network server ID. */
270
270
  type NetworkBroadcastResponse = Record<string, "success" | "error">;
271
+ /** Last-known state of one backend node, as tracked by the network hub. */
272
+ interface NetworkHubNode {
273
+ id: string;
274
+ label: string;
275
+ online: boolean;
276
+ tps: string;
277
+ onlinePlayers: number;
278
+ maxPlayers: number;
279
+ /** Opaque payload the backend reported in its last heartbeat. Shape isn't fixed by the hub. */
280
+ health: unknown;
281
+ /** Unix epoch ms of the last heartbeat received, or 0 if never. */
282
+ lastHeartbeatAt: number;
283
+ }
284
+ interface NetworkHubStatusResponse {
285
+ network: NetworkHubNode[];
286
+ }
287
+ /** A player as seen directly by the proxy (not reported by a backend). */
288
+ interface NetworkHubPlayer {
289
+ uuid: string;
290
+ name: string;
291
+ /** Backend server ID the player is currently connected to, if known. */
292
+ server?: string;
293
+ }
294
+ interface NetworkHubPlayersResponse {
295
+ total: number;
296
+ players: NetworkHubPlayer[];
297
+ }
298
+ interface NetworkHubFindPlayerResponse {
299
+ found: boolean;
300
+ player?: NetworkHubPlayer;
301
+ }
302
+ /** Result of a proxy-wide broadcast: how many connected players received the message. */
303
+ interface NetworkHubBroadcastResponse {
304
+ delivered: number;
305
+ }
271
306
 
272
307
  declare class PlayersModule {
273
308
  private readonly http;
@@ -670,6 +705,69 @@ declare class NetworkModule {
670
705
  }): Promise<T>;
671
706
  }
672
707
 
708
+ /**
709
+ * Wraps the `/v1/network/*` routes exposed by the **NoxAeApi-Velocity**
710
+ * network hub — a separate plugin/process from NoxAeApi-main, run on the
711
+ * Velocity proxy and listening on its own port (`NetworkHubConfig`'s
712
+ * `api-port`, distinct from any individual backend's own REST port).
713
+ *
714
+ * Point a `NoxAeApiNetworkHubClient` (not the regular `NoxAeApiClient`) at
715
+ * that port to use this module. Backend Paper/Bukkit servers connect out
716
+ * to the hub over WebSocket (`/network/register`) and push register /
717
+ * heartbeat / player-join / player-quit events; the hub answers every
718
+ * method below from its own in-memory registry, so calls here are cheap
719
+ * and don't block on a live round trip to each backend the way the older
720
+ * `NetworkModule` (NoxAeApi-main's built-in aggregator) does.
721
+ *
722
+ * Response shapes differ from `NetworkModule` even where the route names
723
+ * match — e.g. `players()` returns one flat proxy-wide player list here,
724
+ * not a per-server breakdown — so the two modules' types aren't
725
+ * interchangeable. There's also no hub equivalent of `/v1/network/health`;
726
+ * each node's last-reported health is embedded in `status*()`'s
727
+ * `NetworkHubNode.health` field instead.
728
+ */
729
+ declare class NetworkHubModule {
730
+ private readonly http;
731
+ constructor(http: HttpEngine);
732
+ /** Get last-known status (from the registry) for every backend node that has ever registered. */
733
+ statusAll(): Promise<NetworkHubStatusResponse>;
734
+ /** Get last-known status for a single node by its configured ID. */
735
+ statusById(id: string): Promise<NetworkHubNode>;
736
+ /**
737
+ * List every player currently connected to the proxy, read straight from
738
+ * Velocity's own player registry (not reported by backends), along with
739
+ * which backend server each is on.
740
+ */
741
+ players(): Promise<NetworkHubPlayersResponse>;
742
+ /** Find which backend server a player is currently on by UUID (proxy-authoritative). */
743
+ findPlayer(uuid: string): Promise<NetworkHubFindPlayerResponse>;
744
+ /**
745
+ * Broadcast a message directly to every player connected to the proxy.
746
+ * Unlike `NetworkModule.broadcast`, this doesn't forward to each
747
+ * backend's `/v1/chat/broadcast` — the proxy already has every player
748
+ * in hand — so it still delivers even to servers with no REST API of
749
+ * their own reachable from the hub.
750
+ */
751
+ broadcast(message: string): Promise<NetworkHubBroadcastResponse>;
752
+ /**
753
+ * Forward an arbitrary request to a specific backend node's own REST
754
+ * API, e.g. `hub.forward("survival", "POST", "server/exec", { body:
755
+ * { command: "say hi" }, form: true })` reaches that backend's
756
+ * `POST /v1/server/exec` directly. Useful for endpoints the hub doesn't
757
+ * have a dedicated method for (economy, worlds, etc) without
758
+ * instantiating a second client pointed at that backend directly.
759
+ *
760
+ * The target backend responds according to its own route's expected
761
+ * encoding (form vs JSON) — pass `form: true` the same way you would for
762
+ * a direct call to that endpoint.
763
+ */
764
+ forward<T = unknown>(id: string, method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", path: string, opts?: {
765
+ body?: unknown;
766
+ query?: Record<string, QueryValue>;
767
+ form?: boolean;
768
+ }): Promise<T>;
769
+ }
770
+
673
771
  type NoxAeApiWsEvent = "open" | "close" | "error" | "console" | "event" | "message";
674
772
  type Listener = (payload: unknown) => void;
675
773
  interface NoxAeApiWsOptions {
@@ -733,7 +831,17 @@ declare class NoxAeApiClient {
733
831
  readonly skills: SkillsModule;
734
832
  /** Generic ranked leaderboards (economy currencies, mcMMO, AuraSkills, ...). */
735
833
  readonly leaderboards: LeaderboardModule;
736
- /** Only works if `network.enabled: true` is set in the server config. */
834
+ /**
835
+ * Only works if `network.enabled: true` is set in the server config.
836
+ *
837
+ * This is NoxAeApi-main's built-in polling aggregator — it lives on the
838
+ * *same* backend server you're already connected to and fans requests
839
+ * out to the other backends listed in that server's own config. If the
840
+ * network is running NoxAeApi-Velocity instead, use
841
+ * `NoxAeApiNetworkHubClient` (pointed at the proxy's hub port) rather
842
+ * than this module — the hub replaces this aggregator with a push model
843
+ * and its response shapes differ.
844
+ */
737
845
  readonly network: NetworkModule;
738
846
  private readonly http;
739
847
  private readonly baseUrl;
@@ -752,6 +860,33 @@ declare class NoxAeApiClient {
752
860
  /** Open a WebSocket connection to the server (console tail or event stream). */
753
861
  connect(options?: Partial<NoxAeApiWsOptions>): NoxAeApiSocket;
754
862
  }
863
+ /**
864
+ * Client for the **NoxAeApi-Velocity** network hub — a separate plugin
865
+ * that runs on the Velocity proxy, not on any individual backend server.
866
+ * Point `baseUrl` at the hub's own REST port (`NetworkHubConfig`'s
867
+ * `api-port`), not a backend's port, and use `NOXAEAPI_HUB_*` env vars
868
+ * (via `fromEnv`) if you keep that separate from a regular backend's
869
+ * `NOXAEAPI_*` vars.
870
+ *
871
+ * Only exposes `.network` — the hub doesn't run any of the other REST
872
+ * modules (players, economy, worlds, ...) that a backend `NoxAeApiClient`
873
+ * does. To reach a specific backend's own routes through the hub, use
874
+ * `hub.network.forward(id, ...)`.
875
+ */
876
+ declare class NoxAeApiNetworkHubClient {
877
+ /** The network hub's aggregated view of every registered backend node. */
878
+ readonly network: NetworkHubModule;
879
+ constructor(options: NoxAeApiClientOptions);
880
+ /**
881
+ * Build a hub client from environment variables:
882
+ * `NOXAEAPI_HUB_BASE_URL` and `NOXAEAPI_HUB_KEY`.
883
+ *
884
+ * Same convenience as `NoxAeApiClient.fromEnv()`, under separate env var
885
+ * names so a process can hold both a backend client and a hub client at
886
+ * once without the two colliding.
887
+ */
888
+ static fromEnv(overrides?: Partial<NoxAeApiClientOptions>): NoxAeApiNetworkHubClient;
889
+ }
755
890
 
756
891
  interface NoxAeApiErrorInfo {
757
892
  status: number;
@@ -805,4 +940,4 @@ declare class NoxAeApiNetworkError extends Error {
805
940
  constructor(message: string, method: string, path: string, cause?: unknown);
806
941
  }
807
942
 
808
- export { type Advancement, type CurrencyBalance, type CurrencyTopEntry, type EconomyInfo, type GroupInfo, type InventoryItem, type LeaderboardEntry, type LeaderboardSourceInfo, type NetworkBroadcastResponse, type NetworkFindPlayerResponse, type NetworkHealthResponse, type NetworkHealthServerEntry, type NetworkPlayersResponse, type NetworkPlayersServerEntry, type NetworkServerStatus, NoxAeApiClient, type NoxAeApiClientOptions, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError, type NoxAeApiWsEvent, type NoxAeApiWsOptions, type NoxAuthPlayerInfo, type Objective, type OfflinePlayer, type OnlinePlayer, type PasswordCheckResult, type PermissionNode, type PlayerBalance, type PlayerStats, type Plugin, type RetryOptions, type Score, type Scoreboard, type ServerBan, type ServerHealth, type ServerInfo, type SkillInfo, type TopBalanceEntry, type WhitelistEntry, type World };
943
+ export { type Advancement, type CurrencyBalance, type CurrencyTopEntry, type EconomyInfo, type GroupInfo, type InventoryItem, type LeaderboardEntry, type LeaderboardSourceInfo, type NetworkBroadcastResponse, type NetworkFindPlayerResponse, type NetworkHealthResponse, type NetworkHealthServerEntry, type NetworkHubBroadcastResponse, type NetworkHubFindPlayerResponse, type NetworkHubNode, type NetworkHubPlayer, type NetworkHubPlayersResponse, type NetworkHubStatusResponse, type NetworkPlayersResponse, type NetworkPlayersServerEntry, type NetworkServerStatus, NoxAeApiClient, type NoxAeApiClientOptions, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNetworkHubClient, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError, type NoxAeApiWsEvent, type NoxAeApiWsOptions, type NoxAuthPlayerInfo, type Objective, type OfflinePlayer, type OnlinePlayer, type PasswordCheckResult, type PermissionNode, type PlayerBalance, type PlayerStats, type Plugin, type RetryOptions, type Score, type Scoreboard, type ServerBan, type ServerHealth, type ServerInfo, type SkillInfo, type TopBalanceEntry, type WhitelistEntry, type World };
package/dist/index.js CHANGED
@@ -828,6 +828,59 @@ var NetworkModule = class {
828
828
  }
829
829
  };
830
830
 
831
+ // src/modules/network-hub.ts
832
+ var NetworkHubModule = class {
833
+ constructor(http) {
834
+ this.http = http;
835
+ }
836
+ http;
837
+ /** Get last-known status (from the registry) for every backend node that has ever registered. */
838
+ statusAll() {
839
+ return this.http.request("GET", "network/status");
840
+ }
841
+ /** Get last-known status for a single node by its configured ID. */
842
+ statusById(id) {
843
+ return this.http.request("GET", `network/status/${encodeURIComponent(id)}`);
844
+ }
845
+ /**
846
+ * List every player currently connected to the proxy, read straight from
847
+ * Velocity's own player registry (not reported by backends), along with
848
+ * which backend server each is on.
849
+ */
850
+ players() {
851
+ return this.http.request("GET", "network/players");
852
+ }
853
+ /** Find which backend server a player is currently on by UUID (proxy-authoritative). */
854
+ findPlayer(uuid) {
855
+ return this.http.request("GET", `network/players/${encodeURIComponent(uuid)}`);
856
+ }
857
+ /**
858
+ * Broadcast a message directly to every player connected to the proxy.
859
+ * Unlike `NetworkModule.broadcast`, this doesn't forward to each
860
+ * backend's `/v1/chat/broadcast` — the proxy already has every player
861
+ * in hand — so it still delivers even to servers with no REST API of
862
+ * their own reachable from the hub.
863
+ */
864
+ broadcast(message) {
865
+ return this.http.request("POST", "network/broadcast", { body: { message }, form: true });
866
+ }
867
+ /**
868
+ * Forward an arbitrary request to a specific backend node's own REST
869
+ * API, e.g. `hub.forward("survival", "POST", "server/exec", { body:
870
+ * { command: "say hi" }, form: true })` reaches that backend's
871
+ * `POST /v1/server/exec` directly. Useful for endpoints the hub doesn't
872
+ * have a dedicated method for (economy, worlds, etc) without
873
+ * instantiating a second client pointed at that backend directly.
874
+ *
875
+ * The target backend responds according to its own route's expected
876
+ * encoding (form vs JSON) — pass `form: true` the same way you would for
877
+ * a direct call to that endpoint.
878
+ */
879
+ forward(id, method, path, opts = {}) {
880
+ return this.http.request(method, `network/${encodeURIComponent(id)}/${path.replace(/^\/+/, "")}`, opts);
881
+ }
882
+ };
883
+
831
884
  // src/socket.ts
832
885
  function toWsUrl(baseUrl, route, apiKey) {
833
886
  const url = new URL(`${baseUrl.replace(/\/+$/, "")}/v1/ws/${route.replace(/^\/+/, "")}`);
@@ -937,7 +990,17 @@ var NoxAeApiClient = class _NoxAeApiClient {
937
990
  skills;
938
991
  /** Generic ranked leaderboards (economy currencies, mcMMO, AuraSkills, ...). */
939
992
  leaderboards;
940
- /** Only works if `network.enabled: true` is set in the server config. */
993
+ /**
994
+ * Only works if `network.enabled: true` is set in the server config.
995
+ *
996
+ * This is NoxAeApi-main's built-in polling aggregator — it lives on the
997
+ * *same* backend server you're already connected to and fans requests
998
+ * out to the other backends listed in that server's own config. If the
999
+ * network is running NoxAeApi-Velocity instead, use
1000
+ * `NoxAeApiNetworkHubClient` (pointed at the proxy's hub port) rather
1001
+ * than this module — the hub replaces this aggregator with a push model
1002
+ * and its response shapes differ.
1003
+ */
941
1004
  network;
942
1005
  http;
943
1006
  baseUrl;
@@ -988,7 +1051,34 @@ var NoxAeApiClient = class _NoxAeApiClient {
988
1051
  });
989
1052
  }
990
1053
  };
1054
+ var NoxAeApiNetworkHubClient = class _NoxAeApiNetworkHubClient {
1055
+ /** The network hub's aggregated view of every registered backend node. */
1056
+ network;
1057
+ constructor(options) {
1058
+ const http = new HttpEngine(options);
1059
+ this.network = new NetworkHubModule(http);
1060
+ }
1061
+ /**
1062
+ * Build a hub client from environment variables:
1063
+ * `NOXAEAPI_HUB_BASE_URL` and `NOXAEAPI_HUB_KEY`.
1064
+ *
1065
+ * Same convenience as `NoxAeApiClient.fromEnv()`, under separate env var
1066
+ * names so a process can hold both a backend client and a hub client at
1067
+ * once without the two colliding.
1068
+ */
1069
+ static fromEnv(overrides = {}) {
1070
+ const env = globalThis.process?.env;
1071
+ const baseUrl = overrides.baseUrl ?? env?.NOXAEAPI_HUB_BASE_URL;
1072
+ const apiKey = overrides.apiKey ?? env?.NOXAEAPI_HUB_KEY;
1073
+ if (!baseUrl) {
1074
+ throw new Error(
1075
+ "NoxAeApiNetworkHubClient.fromEnv(): NOXAEAPI_HUB_BASE_URL is not set and no baseUrl override was given."
1076
+ );
1077
+ }
1078
+ return new _NoxAeApiNetworkHubClient({ ...overrides, baseUrl, apiKey });
1079
+ }
1080
+ };
991
1081
 
992
- export { NoxAeApiClient, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError };
1082
+ export { NoxAeApiClient, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNetworkHubClient, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError };
993
1083
  //# sourceMappingURL=index.js.map
994
1084
  //# sourceMappingURL=index.js.map