@wumx-labs/noxaeapi-sdk 0.4.0 → 0.4.1

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
@@ -77,6 +77,11 @@ interface OfflinePlayer {
77
77
  balance: number | null;
78
78
  lastPlayed: number;
79
79
  }
80
+ /** Result of resolving a player name to their UUID via `GET /players/resolve/{name}`. */
81
+ interface PlayerResolveResult {
82
+ name: string;
83
+ uuid: string;
84
+ }
80
85
  interface ServerHealth {
81
86
  cpus: number;
82
87
  uptime: number;
@@ -234,6 +239,61 @@ interface LeaderboardEntry {
234
239
  value: number;
235
240
  [key: string]: unknown;
236
241
  }
242
+ /** Ban details for a player, as reported by `GET /v1/players/{uuid}/profile`'s `status.ban`. */
243
+ interface PlayerProfileBan {
244
+ banned: boolean;
245
+ /** Only present when `banned` is true. */
246
+ reason?: string;
247
+ /** Only present when `banned` is true. */
248
+ source?: string;
249
+ /** Only present when `banned` is true. Serialized server-side as a locale-formatted date string, not ISO-8601. */
250
+ created?: string;
251
+ /** Only present when `banned` is true. `null`/absent means a permanent ban. Same date-string format as `created`. */
252
+ expires?: string | null;
253
+ }
254
+ /** Whitelist + ban status for a player, as reported by `GET /v1/players/{uuid}/profile`'s `status` field. */
255
+ interface PlayerProfileStatus {
256
+ whitelisted: boolean;
257
+ ban: PlayerProfileBan;
258
+ }
259
+ /**
260
+ * Vault economy info for a player, as reported by `GET /v1/players/{uuid}/profile`'s `economy`
261
+ * field. Single-currency (Vault), not ExcellentEconomy's multi-currency system - see
262
+ * `EconomyModule.getCurrencyBalance` for that.
263
+ */
264
+ interface PlayerProfileEconomy {
265
+ available: boolean;
266
+ /** Only present when `available` is true. */
267
+ balance?: number;
268
+ }
269
+ /** One leaderboard source's contribution to a player profile's `stats` array. */
270
+ interface PlayerProfileStatTile {
271
+ id: string;
272
+ label: string;
273
+ status: "ranked" | "not_ranked" | "unavailable";
274
+ /** Only present when `status` is "ranked". */
275
+ value?: number;
276
+ /** Only present when `status` is "ranked" and the source reports a positive rank. */
277
+ rank?: number;
278
+ }
279
+ /**
280
+ * One-call player profile combining identity, whitelist/ban status, Vault balance, and this
281
+ * player's entry in every registered leaderboard source. Returned by
282
+ * `GET /v1/players/{uuid}/profile` and (as the `players` array) by `GET /v1/players/profiles`.
283
+ */
284
+ interface PlayerProfile {
285
+ name: string | null;
286
+ uuid: string;
287
+ online: boolean;
288
+ status: PlayerProfileStatus;
289
+ economy: PlayerProfileEconomy;
290
+ stats: PlayerProfileStatTile[];
291
+ }
292
+ /** Response shape of `GET /v1/players/profiles` (bulk player profiles). */
293
+ interface PlayerProfilesResponse {
294
+ count: number;
295
+ players: PlayerProfile[];
296
+ }
237
297
  interface NetworkServerStatus {
238
298
  id: string;
239
299
  label: string;
@@ -313,6 +373,16 @@ declare class PlayersModule {
313
373
  listAll(): Promise<OfflinePlayer[]>;
314
374
  /** Get a single player by UUID (works for online or offline players). */
315
375
  get(uuid: string): Promise<OnlinePlayer | OfflinePlayer>;
376
+ /**
377
+ * Resolve a player name to their UUID using the server's own local player
378
+ * cache (works on both online-mode and offline-mode servers, unlike
379
+ * Mojang's public API - the UUID returned matches whatever this server
380
+ * actually uses for that player's stats/economy/etc). Checks currently
381
+ * online players first, then falls back to the server's offline player
382
+ * cache. Throws `NoxAeApiNotFoundError` if no known player with that name
383
+ * has ever joined.
384
+ */
385
+ resolve(name: string): Promise<PlayerResolveResult>;
316
386
  /** Get a player's inventory in a specific world. */
317
387
  getInventory(playerUuid: string, worldUuid: string): Promise<InventoryItem[]>;
318
388
  /** Kick an online player, optionally with a reason. */
@@ -644,6 +714,10 @@ declare class SkillsModule {
644
714
  * (e.g. the backing plugin isn't loaded) throw `NoxAeApiError` with the
645
715
  * source's own unavailable status (424 for economy currencies, 503 for
646
716
  * mcMMO/AuraSkills) when you call `getTop`.
717
+ *
718
+ * This module also wraps the player-profile routes (`/v1/players/{uuid}/profile`
719
+ * and `/v1/players/profiles`), which live server-side alongside the
720
+ * leaderboard sources since they're built on top of them.
647
721
  */
648
722
  declare class LeaderboardModule {
649
723
  private readonly http;
@@ -652,6 +726,33 @@ declare class LeaderboardModule {
652
726
  list(): Promise<LeaderboardSourceInfo[]>;
653
727
  /** Get ranked entries for one leaderboard source (see `list()` for valid IDs). */
654
728
  getTop(id: string, limit?: number): Promise<LeaderboardEntry[]>;
729
+ /**
730
+ * One-call player profile: identity, whitelist/ban status, Vault balance,
731
+ * and this player's entry in every registered leaderboard source. Built so
732
+ * clients never have to know how many leaderboard sources exist or scan
733
+ * top-N lists themselves.
734
+ *
735
+ * Throws `NoxAeApiNotFoundError` if no known player with that UUID has
736
+ * ever joined.
737
+ */
738
+ getPlayerProfile(uuid: string): Promise<PlayerProfile>;
739
+ /**
740
+ * Bulk player profiles — same shape as `getPlayerProfile`, for many
741
+ * players at once. Computes each leaderboard source's full ranking
742
+ * exactly once for the whole batch rather than once per player, so this
743
+ * is far cheaper than calling `getPlayerProfile` in a loop.
744
+ *
745
+ * Pass `uuids` to fetch an exact, specific set of players — unknown UUIDs
746
+ * are silently skipped rather than throwing. Omit `uuids` to page through
747
+ * every known player instead, using `page`/`limit`, optionally narrowed
748
+ * to only currently-online players via `onlineOnly`.
749
+ */
750
+ getPlayerProfiles(opts?: {
751
+ uuids?: string[];
752
+ page?: number;
753
+ limit?: number;
754
+ onlineOnly?: boolean;
755
+ }): Promise<PlayerProfilesResponse>;
655
756
  }
656
757
 
657
758
  /**
@@ -940,4 +1041,4 @@ declare class NoxAeApiNetworkError extends Error {
940
1041
  constructor(message: string, method: string, path: string, cause?: unknown);
941
1042
  }
942
1043
 
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 };
1044
+ 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 PlayerProfile, type PlayerProfileBan, type PlayerProfileEconomy, type PlayerProfileStatTile, type PlayerProfileStatus, type PlayerProfilesResponse, type PlayerResolveResult, 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
@@ -77,6 +77,11 @@ interface OfflinePlayer {
77
77
  balance: number | null;
78
78
  lastPlayed: number;
79
79
  }
80
+ /** Result of resolving a player name to their UUID via `GET /players/resolve/{name}`. */
81
+ interface PlayerResolveResult {
82
+ name: string;
83
+ uuid: string;
84
+ }
80
85
  interface ServerHealth {
81
86
  cpus: number;
82
87
  uptime: number;
@@ -234,6 +239,61 @@ interface LeaderboardEntry {
234
239
  value: number;
235
240
  [key: string]: unknown;
236
241
  }
242
+ /** Ban details for a player, as reported by `GET /v1/players/{uuid}/profile`'s `status.ban`. */
243
+ interface PlayerProfileBan {
244
+ banned: boolean;
245
+ /** Only present when `banned` is true. */
246
+ reason?: string;
247
+ /** Only present when `banned` is true. */
248
+ source?: string;
249
+ /** Only present when `banned` is true. Serialized server-side as a locale-formatted date string, not ISO-8601. */
250
+ created?: string;
251
+ /** Only present when `banned` is true. `null`/absent means a permanent ban. Same date-string format as `created`. */
252
+ expires?: string | null;
253
+ }
254
+ /** Whitelist + ban status for a player, as reported by `GET /v1/players/{uuid}/profile`'s `status` field. */
255
+ interface PlayerProfileStatus {
256
+ whitelisted: boolean;
257
+ ban: PlayerProfileBan;
258
+ }
259
+ /**
260
+ * Vault economy info for a player, as reported by `GET /v1/players/{uuid}/profile`'s `economy`
261
+ * field. Single-currency (Vault), not ExcellentEconomy's multi-currency system - see
262
+ * `EconomyModule.getCurrencyBalance` for that.
263
+ */
264
+ interface PlayerProfileEconomy {
265
+ available: boolean;
266
+ /** Only present when `available` is true. */
267
+ balance?: number;
268
+ }
269
+ /** One leaderboard source's contribution to a player profile's `stats` array. */
270
+ interface PlayerProfileStatTile {
271
+ id: string;
272
+ label: string;
273
+ status: "ranked" | "not_ranked" | "unavailable";
274
+ /** Only present when `status` is "ranked". */
275
+ value?: number;
276
+ /** Only present when `status` is "ranked" and the source reports a positive rank. */
277
+ rank?: number;
278
+ }
279
+ /**
280
+ * One-call player profile combining identity, whitelist/ban status, Vault balance, and this
281
+ * player's entry in every registered leaderboard source. Returned by
282
+ * `GET /v1/players/{uuid}/profile` and (as the `players` array) by `GET /v1/players/profiles`.
283
+ */
284
+ interface PlayerProfile {
285
+ name: string | null;
286
+ uuid: string;
287
+ online: boolean;
288
+ status: PlayerProfileStatus;
289
+ economy: PlayerProfileEconomy;
290
+ stats: PlayerProfileStatTile[];
291
+ }
292
+ /** Response shape of `GET /v1/players/profiles` (bulk player profiles). */
293
+ interface PlayerProfilesResponse {
294
+ count: number;
295
+ players: PlayerProfile[];
296
+ }
237
297
  interface NetworkServerStatus {
238
298
  id: string;
239
299
  label: string;
@@ -313,6 +373,16 @@ declare class PlayersModule {
313
373
  listAll(): Promise<OfflinePlayer[]>;
314
374
  /** Get a single player by UUID (works for online or offline players). */
315
375
  get(uuid: string): Promise<OnlinePlayer | OfflinePlayer>;
376
+ /**
377
+ * Resolve a player name to their UUID using the server's own local player
378
+ * cache (works on both online-mode and offline-mode servers, unlike
379
+ * Mojang's public API - the UUID returned matches whatever this server
380
+ * actually uses for that player's stats/economy/etc). Checks currently
381
+ * online players first, then falls back to the server's offline player
382
+ * cache. Throws `NoxAeApiNotFoundError` if no known player with that name
383
+ * has ever joined.
384
+ */
385
+ resolve(name: string): Promise<PlayerResolveResult>;
316
386
  /** Get a player's inventory in a specific world. */
317
387
  getInventory(playerUuid: string, worldUuid: string): Promise<InventoryItem[]>;
318
388
  /** Kick an online player, optionally with a reason. */
@@ -644,6 +714,10 @@ declare class SkillsModule {
644
714
  * (e.g. the backing plugin isn't loaded) throw `NoxAeApiError` with the
645
715
  * source's own unavailable status (424 for economy currencies, 503 for
646
716
  * mcMMO/AuraSkills) when you call `getTop`.
717
+ *
718
+ * This module also wraps the player-profile routes (`/v1/players/{uuid}/profile`
719
+ * and `/v1/players/profiles`), which live server-side alongside the
720
+ * leaderboard sources since they're built on top of them.
647
721
  */
648
722
  declare class LeaderboardModule {
649
723
  private readonly http;
@@ -652,6 +726,33 @@ declare class LeaderboardModule {
652
726
  list(): Promise<LeaderboardSourceInfo[]>;
653
727
  /** Get ranked entries for one leaderboard source (see `list()` for valid IDs). */
654
728
  getTop(id: string, limit?: number): Promise<LeaderboardEntry[]>;
729
+ /**
730
+ * One-call player profile: identity, whitelist/ban status, Vault balance,
731
+ * and this player's entry in every registered leaderboard source. Built so
732
+ * clients never have to know how many leaderboard sources exist or scan
733
+ * top-N lists themselves.
734
+ *
735
+ * Throws `NoxAeApiNotFoundError` if no known player with that UUID has
736
+ * ever joined.
737
+ */
738
+ getPlayerProfile(uuid: string): Promise<PlayerProfile>;
739
+ /**
740
+ * Bulk player profiles — same shape as `getPlayerProfile`, for many
741
+ * players at once. Computes each leaderboard source's full ranking
742
+ * exactly once for the whole batch rather than once per player, so this
743
+ * is far cheaper than calling `getPlayerProfile` in a loop.
744
+ *
745
+ * Pass `uuids` to fetch an exact, specific set of players — unknown UUIDs
746
+ * are silently skipped rather than throwing. Omit `uuids` to page through
747
+ * every known player instead, using `page`/`limit`, optionally narrowed
748
+ * to only currently-online players via `onlineOnly`.
749
+ */
750
+ getPlayerProfiles(opts?: {
751
+ uuids?: string[];
752
+ page?: number;
753
+ limit?: number;
754
+ onlineOnly?: boolean;
755
+ }): Promise<PlayerProfilesResponse>;
655
756
  }
656
757
 
657
758
  /**
@@ -940,4 +1041,4 @@ declare class NoxAeApiNetworkError extends Error {
940
1041
  constructor(message: string, method: string, path: string, cause?: unknown);
941
1042
  }
942
1043
 
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 };
1044
+ 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 PlayerProfile, type PlayerProfileBan, type PlayerProfileEconomy, type PlayerProfileStatTile, type PlayerProfileStatus, type PlayerProfilesResponse, type PlayerResolveResult, 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
@@ -248,6 +248,18 @@ var PlayersModule = class {
248
248
  get(uuid) {
249
249
  return this.http.request("GET", `players/${encodeURIComponent(uuid)}`);
250
250
  }
251
+ /**
252
+ * Resolve a player name to their UUID using the server's own local player
253
+ * cache (works on both online-mode and offline-mode servers, unlike
254
+ * Mojang's public API - the UUID returned matches whatever this server
255
+ * actually uses for that player's stats/economy/etc). Checks currently
256
+ * online players first, then falls back to the server's offline player
257
+ * cache. Throws `NoxAeApiNotFoundError` if no known player with that name
258
+ * has ever joined.
259
+ */
260
+ resolve(name) {
261
+ return this.http.request("GET", `players/resolve/${encodeURIComponent(name)}`);
262
+ }
251
263
  /** Get a player's inventory in a specific world. */
252
264
  getInventory(playerUuid, worldUuid) {
253
265
  return this.http.request(
@@ -775,6 +787,39 @@ var LeaderboardModule = class {
775
787
  query: { limit }
776
788
  });
777
789
  }
790
+ /**
791
+ * One-call player profile: identity, whitelist/ban status, Vault balance,
792
+ * and this player's entry in every registered leaderboard source. Built so
793
+ * clients never have to know how many leaderboard sources exist or scan
794
+ * top-N lists themselves.
795
+ *
796
+ * Throws `NoxAeApiNotFoundError` if no known player with that UUID has
797
+ * ever joined.
798
+ */
799
+ getPlayerProfile(uuid) {
800
+ return this.http.request("GET", `players/${encodeURIComponent(uuid)}/profile`);
801
+ }
802
+ /**
803
+ * Bulk player profiles — same shape as `getPlayerProfile`, for many
804
+ * players at once. Computes each leaderboard source's full ranking
805
+ * exactly once for the whole batch rather than once per player, so this
806
+ * is far cheaper than calling `getPlayerProfile` in a loop.
807
+ *
808
+ * Pass `uuids` to fetch an exact, specific set of players — unknown UUIDs
809
+ * are silently skipped rather than throwing. Omit `uuids` to page through
810
+ * every known player instead, using `page`/`limit`, optionally narrowed
811
+ * to only currently-online players via `onlineOnly`.
812
+ */
813
+ getPlayerProfiles(opts = {}) {
814
+ return this.http.request("GET", "players/profiles", {
815
+ query: {
816
+ uuids: opts.uuids?.length ? opts.uuids.join(",") : void 0,
817
+ page: opts.page,
818
+ limit: opts.limit,
819
+ onlineOnly: opts.onlineOnly
820
+ }
821
+ });
822
+ }
778
823
  };
779
824
 
780
825
  // src/modules/network.ts