@pinta365/blizzard_api 0.7.1 → 0.8.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.
Files changed (60) hide show
  1. package/README.md +40 -4
  2. package/esm/mod.d.ts +4 -2
  3. package/esm/mod.js +2 -0
  4. package/esm/src/client.d.ts +9 -1
  5. package/esm/src/client.js +2 -0
  6. package/esm/src/generated/wow_forever_api.d.ts +939 -0
  7. package/esm/src/generated/wow_forever_api.js +2 -0
  8. package/esm/src/shared/context.d.ts +13 -2
  9. package/esm/src/shared/context.js +24 -9
  10. package/esm/src/shared/types.d.ts +1 -1
  11. package/esm/src/wow/game_data/achievement.d.ts +4 -0
  12. package/esm/src/wow/game_data/item.d.ts +29 -6
  13. package/esm/src/wow/game_data/mount.d.ts +2 -1
  14. package/esm/src/wow/game_data/reputations.d.ts +7 -1
  15. package/esm/src/wow/game_data/talent.d.ts +6 -2
  16. package/esm/src/wow/profile/character_statistics.d.ts +4 -0
  17. package/esm/src/wow_forever/account.d.ts +42 -0
  18. package/esm/src/wow_forever/account.js +24 -0
  19. package/esm/src/wow_forever/character.d.ts +342 -0
  20. package/esm/src/wow_forever/character.js +269 -0
  21. package/esm/src/wow_forever/game_data.d.ts +196 -0
  22. package/esm/src/wow_forever/game_data.js +166 -0
  23. package/esm/src/wow_forever/guild.d.ts +88 -0
  24. package/esm/src/wow_forever/guild.js +57 -0
  25. package/esm/src/wow_forever/index.d.ts +39 -0
  26. package/esm/src/wow_forever/index.js +45 -0
  27. package/esm/src/wow_forever/ruleset.d.ts +32 -0
  28. package/esm/src/wow_forever/ruleset.js +30 -0
  29. package/esm/src/wow_forever/types.d.ts +5 -0
  30. package/esm/src/wow_forever/types.js +1 -0
  31. package/package.json +5 -1
  32. package/script/mod.d.ts +4 -2
  33. package/script/mod.js +3 -1
  34. package/script/src/client.d.ts +9 -1
  35. package/script/src/client.js +2 -0
  36. package/script/src/generated/wow_forever_api.d.ts +939 -0
  37. package/script/src/generated/wow_forever_api.js +3 -0
  38. package/script/src/shared/context.d.ts +13 -2
  39. package/script/src/shared/context.js +24 -9
  40. package/script/src/shared/types.d.ts +1 -1
  41. package/script/src/wow/game_data/achievement.d.ts +4 -0
  42. package/script/src/wow/game_data/item.d.ts +29 -6
  43. package/script/src/wow/game_data/mount.d.ts +2 -1
  44. package/script/src/wow/game_data/reputations.d.ts +7 -1
  45. package/script/src/wow/game_data/talent.d.ts +6 -2
  46. package/script/src/wow/profile/character_statistics.d.ts +4 -0
  47. package/script/src/wow_forever/account.d.ts +42 -0
  48. package/script/src/wow_forever/account.js +28 -0
  49. package/script/src/wow_forever/character.d.ts +342 -0
  50. package/script/src/wow_forever/character.js +296 -0
  51. package/script/src/wow_forever/game_data.d.ts +196 -0
  52. package/script/src/wow_forever/game_data.js +185 -0
  53. package/script/src/wow_forever/guild.d.ts +88 -0
  54. package/script/src/wow_forever/guild.js +63 -0
  55. package/script/src/wow_forever/index.d.ts +39 -0
  56. package/script/src/wow_forever/index.js +180 -0
  57. package/script/src/wow_forever/ruleset.d.ts +32 -0
  58. package/script/src/wow_forever/ruleset.js +34 -0
  59. package/script/src/wow_forever/types.d.ts +5 -0
  60. package/script/src/wow_forever/types.js +2 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Generated by scripts/gen_api.ts from src/wow_forever/index.ts. Do not edit; run `deno task gen:api`.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -12,6 +12,12 @@ export interface ClientConfig {
12
12
  locale?: Locales;
13
13
  clientId: string;
14
14
  clientSecret: string;
15
+ /**
16
+ * Static namespace version for WoW: Forever, e.g. "1.60.1_70399". When set, `wowForever` static requests use
17
+ * `static-<version>-forever-<region>` instead of `static-forever-<region>` (which serves the current version). Use it
18
+ * to pin a version; the current one is in the `self` link of any static response.
19
+ */
20
+ foreverStaticVersion?: string;
15
21
  }
16
22
  /**
17
23
  * Represents the authentication state of the client credentials token.
@@ -56,7 +62,10 @@ export interface TokenResponse {
56
62
  interface ContextOptions {
57
63
  userToken?: string;
58
64
  namespaceVariant?: string;
65
+ staticVersion?: StaticVersion;
59
66
  }
67
+ /** Returns the static namespace version to insert before the variant, or undefined for the plain namespace. */
68
+ type StaticVersion = (config: Readonly<Partial<ClientConfig>>) => string | undefined;
60
69
  interface TokenState extends AuthConfig {
61
70
  pending?: Promise<string>;
62
71
  }
@@ -92,7 +101,7 @@ export declare class ApiContext {
92
101
  /**
93
102
  * @param {Partial<ClientConfig>} config - The client configuration. Shared by reference with derived contexts.
94
103
  * @param {TokenState} [token] - Token state to share (used by derived contexts).
95
- * @param {ContextOptions} [options] - User token and namespace variant.
104
+ * @param {ContextOptions} [options] - User token, namespace variant and static namespace version.
96
105
  */
97
106
  constructor(config?: Partial<ClientConfig>, token?: TokenState, options?: ContextOptions);
98
107
  /**
@@ -119,8 +128,10 @@ export declare class ApiContext {
119
128
  * inserted before the region, e.g. "classic1x" turns "static" into "static-classic1x-eu".
120
129
  * It shares configuration, tokens and the user token with this context.
121
130
  * @param {string} namespaceVariant - The namespace variant, e.g. "classic" or "classic1x".
131
+ * @param {StaticVersion} [staticVersion] - Reads a static namespace version from the configuration, e.g. "1.60.1_70399"
132
+ * turns "static" into "static-1.60.1_70399-forever-eu". When it returns undefined, the plain namespace is used.
122
133
  */
123
- withNamespaceVariant(namespaceVariant: string): ApiContext;
134
+ withNamespaceVariant(namespaceVariant: string, staticVersion?: StaticVersion): ApiContext;
124
135
  /**
125
136
  * Obtains a client credentials access token, reusing the cached one while it is valid.
126
137
  * Concurrent callers share a single token request.
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _ApiContext_instances, _ApiContext_config, _ApiContext_token, _ApiContext_userToken, _ApiContext_namespaceVariant, _ApiContext_namespaceHeader, _ApiContext_send, _ApiContext_requestToken;
13
+ var _ApiContext_instances, _ApiContext_config, _ApiContext_token, _ApiContext_userToken, _ApiContext_namespaceVariant, _ApiContext_staticVersion, _ApiContext_namespaceHeader, _ApiContext_send, _ApiContext_requestToken;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ApiContext = void 0;
16
16
  exports.defaultLocale = defaultLocale;
@@ -93,7 +93,7 @@ class ApiContext {
93
93
  /**
94
94
  * @param {Partial<ClientConfig>} config - The client configuration. Shared by reference with derived contexts.
95
95
  * @param {TokenState} [token] - Token state to share (used by derived contexts).
96
- * @param {ContextOptions} [options] - User token and namespace variant.
96
+ * @param {ContextOptions} [options] - User token, namespace variant and static namespace version.
97
97
  */
98
98
  constructor(config = {}, token, options = {}) {
99
99
  _ApiContext_instances.add(this);
@@ -101,10 +101,12 @@ class ApiContext {
101
101
  _ApiContext_token.set(this, void 0);
102
102
  _ApiContext_userToken.set(this, void 0);
103
103
  _ApiContext_namespaceVariant.set(this, void 0);
104
+ _ApiContext_staticVersion.set(this, void 0);
104
105
  __classPrivateFieldSet(this, _ApiContext_config, config, "f");
105
106
  __classPrivateFieldSet(this, _ApiContext_token, token ?? { accessToken: "", tokenExpiration: 0 }, "f");
106
107
  __classPrivateFieldSet(this, _ApiContext_userToken, options.userToken, "f");
107
108
  __classPrivateFieldSet(this, _ApiContext_namespaceVariant, options.namespaceVariant, "f");
109
+ __classPrivateFieldSet(this, _ApiContext_staticVersion, options.staticVersion, "f");
108
110
  }
109
111
  /**
110
112
  * The current configuration (may be partial if not fully set up).
@@ -136,16 +138,26 @@ class ApiContext {
136
138
  * @param {string} userToken - A user access token from the authorization code flow.
137
139
  */
138
140
  forUser(userToken) {
139
- return new ApiContext(__classPrivateFieldGet(this, _ApiContext_config, "f"), __classPrivateFieldGet(this, _ApiContext_token, "f"), { userToken, namespaceVariant: __classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f") });
141
+ return new ApiContext(__classPrivateFieldGet(this, _ApiContext_config, "f"), __classPrivateFieldGet(this, _ApiContext_token, "f"), {
142
+ userToken,
143
+ namespaceVariant: __classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f"),
144
+ staticVersion: __classPrivateFieldGet(this, _ApiContext_staticVersion, "f"),
145
+ });
140
146
  }
141
147
  /**
142
148
  * Returns a context for another game version: base namespaces ("static", "dynamic", "profile") get the variant
143
149
  * inserted before the region, e.g. "classic1x" turns "static" into "static-classic1x-eu".
144
150
  * It shares configuration, tokens and the user token with this context.
145
151
  * @param {string} namespaceVariant - The namespace variant, e.g. "classic" or "classic1x".
152
+ * @param {StaticVersion} [staticVersion] - Reads a static namespace version from the configuration, e.g. "1.60.1_70399"
153
+ * turns "static" into "static-1.60.1_70399-forever-eu". When it returns undefined, the plain namespace is used.
146
154
  */
147
- withNamespaceVariant(namespaceVariant) {
148
- return new ApiContext(__classPrivateFieldGet(this, _ApiContext_config, "f"), __classPrivateFieldGet(this, _ApiContext_token, "f"), { userToken: __classPrivateFieldGet(this, _ApiContext_userToken, "f"), namespaceVariant });
155
+ withNamespaceVariant(namespaceVariant, staticVersion) {
156
+ return new ApiContext(__classPrivateFieldGet(this, _ApiContext_config, "f"), __classPrivateFieldGet(this, _ApiContext_token, "f"), {
157
+ userToken: __classPrivateFieldGet(this, _ApiContext_userToken, "f"),
158
+ namespaceVariant,
159
+ staticVersion,
160
+ });
149
161
  }
150
162
  /**
151
163
  * Obtains a client credentials access token, reusing the cached one while it is valid.
@@ -246,11 +258,14 @@ class ApiContext {
246
258
  }
247
259
  }
248
260
  exports.ApiContext = ApiContext;
249
- _ApiContext_config = new WeakMap(), _ApiContext_token = new WeakMap(), _ApiContext_userToken = new WeakMap(), _ApiContext_namespaceVariant = new WeakMap(), _ApiContext_instances = new WeakSet(), _ApiContext_namespaceHeader = function _ApiContext_namespaceHeader(namespace, region) {
261
+ _ApiContext_config = new WeakMap(), _ApiContext_token = new WeakMap(), _ApiContext_userToken = new WeakMap(), _ApiContext_namespaceVariant = new WeakMap(), _ApiContext_staticVersion = new WeakMap(), _ApiContext_instances = new WeakSet(), _ApiContext_namespaceHeader = function _ApiContext_namespaceHeader(namespace, region) {
250
262
  const isBase = namespace === "static" || namespace === "dynamic" || namespace === "profile";
251
- return isBase && __classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f")
252
- ? `${namespace}-${__classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f")}-${region}`
253
- : `${namespace}-${region}`;
263
+ if (!isBase || !__classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f"))
264
+ return `${namespace}-${region}`;
265
+ const version = namespace === "static" ? __classPrivateFieldGet(this, _ApiContext_staticVersion, "f")?.call(this, __classPrivateFieldGet(this, _ApiContext_config, "f")) : undefined;
266
+ return version
267
+ ? `${namespace}-${version}-${__classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f")}-${region}`
268
+ : `${namespace}-${__classPrivateFieldGet(this, _ApiContext_namespaceVariant, "f")}-${region}`;
254
269
  }, _ApiContext_send = async function _ApiContext_send(url, namespaceHeader, userScoped) {
255
270
  if (userScoped && !__classPrivateFieldGet(this, _ApiContext_userToken, "f")) {
256
271
  throw new errors_js_1.MissingUserTokenError();
@@ -26,7 +26,7 @@ export type Locales = "en_US" | "es_MX" | "pt_BR" | "en_GB" | "es_ES" | "fr_FR"
26
26
  */
27
27
  export type Namespaces = "static" | "dynamic" | "profile" | //Retail
28
28
  "static-classic1x" | "dynamic-classic1x" | "profile-classic1x" | //Classic
29
- "static-classic" | "dynamic-classic" | "profile-classic";
29
+ "static-classic" | "dynamic-classic" | "profile-classic" | "static-forever" | "dynamic-forever" | "profile-forever";
30
30
  /**
31
31
  * Represents a reference (link) with a URL.
32
32
  */
@@ -25,6 +25,8 @@ export interface AchievementCategory extends LinkSelfHref {
25
25
  name: LocalizedString;
26
26
  achievements?: KeyNameId[];
27
27
  parent_category?: KeyNameId;
28
+ /** Absent when the category has no subcategories. */
29
+ subcategories?: KeyNameId[];
28
30
  is_guild_category: boolean;
29
31
  aggregates_by_faction: AggregatesByFaction;
30
32
  display_order: number;
@@ -45,6 +47,8 @@ export interface Achievement extends LinkSelfHref {
45
47
  amount: number;
46
48
  };
47
49
  next_achievement?: KeyNameId;
50
+ /** Absent when the achievement grants no reward. */
51
+ reward_description?: LocalizedString;
48
52
  media: KeyId;
49
53
  display_order: number;
50
54
  }
@@ -54,8 +54,10 @@ export interface Item extends LinkSelfHref {
54
54
  item_subclass: KeyNameId;
55
55
  inventory_type: TypeName;
56
56
  binding: TypeName;
57
- unique_equipped: string;
58
- weapon: {
57
+ /** Absent for items that are not unique-equipped. */
58
+ unique_equipped?: string;
59
+ /** Absent for non-weapon items. */
60
+ weapon?: {
59
61
  damage: {
60
62
  min_value: number;
61
63
  max_value: number;
@@ -77,10 +79,26 @@ export interface Item extends LinkSelfHref {
77
79
  display_string: LocalizedString;
78
80
  };
79
81
  };
80
- stats: {
82
+ /** Absent for non-armor items. */
83
+ armor?: {
84
+ value: number;
85
+ display: {
86
+ display_string: LocalizedString;
87
+ color: {
88
+ r: number;
89
+ g: number;
90
+ b: number;
91
+ a: number;
92
+ };
93
+ };
94
+ };
95
+ /** Absent for items without stats, such as non-equippable items. */
96
+ stats?: {
81
97
  type: TypeName;
82
98
  value: number;
83
99
  is_negated?: boolean;
100
+ /** Present on "Equip:" bonus stats, such as spell power. */
101
+ is_equip_bonus?: boolean;
84
102
  display: {
85
103
  display_string: LocalizedString;
86
104
  color: {
@@ -91,11 +109,13 @@ export interface Item extends LinkSelfHref {
91
109
  };
92
110
  };
93
111
  }[];
94
- spells: {
112
+ /** Absent for items without spells. */
113
+ spells?: {
95
114
  spell: KeyNameId;
96
115
  description: LocalizedString;
97
116
  }[];
98
- requirements: {
117
+ /** Absent for items without requirements. */
118
+ requirements?: {
99
119
  level: {
100
120
  value: number;
101
121
  display_string: LocalizedString;
@@ -105,10 +125,13 @@ export interface Item extends LinkSelfHref {
105
125
  value: number;
106
126
  display_string: LocalizedString;
107
127
  };
108
- durability: {
128
+ /** Absent for items without durability, such as non-equippable items. */
129
+ durability?: {
109
130
  value: number;
110
131
  display_string: LocalizedString;
111
132
  };
133
+ /** Present on some items, such as companion pets. */
134
+ is_subclass_hidden?: boolean;
112
135
  sell_price?: {
113
136
  value: number;
114
137
  display_strings: {
@@ -8,7 +8,8 @@ export interface Mount extends LinkSelfHref {
8
8
  id: number;
9
9
  name: LocalizedString;
10
10
  creature_displays: KeyId[];
11
- description: LocalizedString;
11
+ /** null for mounts without a description. */
12
+ description: LocalizedString | null;
12
13
  source: TypeName;
13
14
  faction?: TypeName;
14
15
  should_exclude_if_uncollected?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { ApiContext } from "../../shared/index.js";
2
- import type { KeyId, KeyNameId, LinkSelfHref, LocalizedString } from "../../shared/index.js";
2
+ import type { KeyId, KeyNameId, LinkSelfHref, LocalizedString, TypeName } from "../../shared/index.js";
3
3
  export interface ReputationFactions extends LinkSelfHref {
4
4
  factions: KeyNameId[];
5
5
  root_factions: KeyNameId[];
@@ -9,6 +9,12 @@ export interface ReputationFaction extends LinkSelfHref {
9
9
  name: LocalizedString;
10
10
  description: LocalizedString;
11
11
  reputation_tiers: KeyId;
12
+ /** Present for header factions, which group the sub-factions in `factions`. */
13
+ is_header?: boolean;
14
+ /** The sub-factions; present for header factions. */
15
+ factions?: KeyNameId[];
16
+ /** The faction's player faction; present for header factions. */
17
+ player_faction?: TypeName;
12
18
  }
13
19
  export interface ReputationTiers extends LinkSelfHref {
14
20
  reputation_tiers: {
@@ -9,7 +9,8 @@ export interface SpellTooltip {
9
9
  spell: KeyNameId;
10
10
  description: string;
11
11
  cast_time: string;
12
- power_cost?: string;
12
+ /** null for abilities without a power cost. */
13
+ power_cost?: string | null;
13
14
  range?: string;
14
15
  cooldown?: string;
15
16
  }
@@ -80,7 +81,10 @@ export interface Talent extends LinkSelfHref {
80
81
  description: LocalizedString | null;
81
82
  }[];
82
83
  spell: KeyNameId;
83
- playable_class: KeyId;
84
+ playable_class: KeyId & {
85
+ /** Absent when the talent is not tied to a class (id 0). */
86
+ name?: string;
87
+ };
84
88
  playable_specialization?: KeyNameId;
85
89
  }
86
90
  export interface PvpTalents extends LinkSelfHref {
@@ -76,6 +76,10 @@ export interface CharacterStatistics extends LinkSelfHref {
76
76
  base: number;
77
77
  effective: number;
78
78
  };
79
+ frost_resistance?: {
80
+ base: number;
81
+ effective: number;
82
+ };
79
83
  fire_resistance?: {
80
84
  base: number;
81
85
  effective: number;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WoW: Forever versions of the Retail account profile endpoints whose Forever responses differ from Retail.
3
+ * Each one makes the same request as the Retail endpoint, but returns a Forever type.
4
+ * Verified against the live API (EU) on 2026-11-02, before launch.
5
+ */
6
+ import type { ApiContext } from "../shared/index.js";
7
+ import type { AccountCharacter, AccountProfileSummary, AccountTransmogsCollection } from "../wow/profile/account_profile.js";
8
+ /**
9
+ * A Forever character in the account profile. Forever is realmless: characters have a two-part name (`name` and
10
+ * `surname`, unique per region) and no realm. The `character` link is realmless too
11
+ * (`/profile/wow/character/{name}-{surname}`). The hidden realm is the first part of the `protected_character` id.
12
+ */
13
+ export interface ForeverAccountCharacter extends Omit<AccountCharacter, "realm"> {
14
+ /** The second part of the character's name. */
15
+ surname: string;
16
+ }
17
+ /** Account profile summary as returned for Forever. */
18
+ export interface ForeverAccountProfileSummary extends Omit<AccountProfileSummary, "wow_accounts" | "houses"> {
19
+ wow_accounts: {
20
+ id: number;
21
+ characters: ForeverAccountCharacter[];
22
+ }[];
23
+ }
24
+ /** Account transmog collection as returned for Forever. */
25
+ export interface ForeverAccountTransmogsCollection extends Omit<AccountTransmogsCollection, "appearance_sets"> {
26
+ /** Absent when the account has collected no appearance sets. */
27
+ appearance_sets?: AccountTransmogsCollection["appearance_sets"];
28
+ }
29
+ /**
30
+ * Returns a profile summary for an account, including its WoW accounts and Forever characters.
31
+ * Requires a user access token (client.forUser(token)).
32
+ *
33
+ * @returns A promise that resolves to an object representing the account profile summary.
34
+ */
35
+ export declare function accountProfileSummary(ctx: ApiContext): Promise<ForeverAccountProfileSummary>;
36
+ /**
37
+ * Returns the transmog appearances and sets collected by an account.
38
+ * Requires a user access token (client.forUser(token)).
39
+ *
40
+ * @returns A promise that resolves to an object representing the account's transmogs.
41
+ */
42
+ export declare function accountTransmogsCollection(ctx: ApiContext): Promise<ForeverAccountTransmogsCollection>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * WoW: Forever versions of the Retail account profile endpoints whose Forever responses differ from Retail.
4
+ * Each one makes the same request as the Retail endpoint, but returns a Forever type.
5
+ * Verified against the live API (EU) on 2026-11-02, before launch.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.accountProfileSummary = accountProfileSummary;
9
+ exports.accountTransmogsCollection = accountTransmogsCollection;
10
+ const account_profile_js_1 = require("../wow/profile/account_profile.js");
11
+ /**
12
+ * Returns a profile summary for an account, including its WoW accounts and Forever characters.
13
+ * Requires a user access token (client.forUser(token)).
14
+ *
15
+ * @returns A promise that resolves to an object representing the account profile summary.
16
+ */
17
+ async function accountProfileSummary(ctx) {
18
+ return await (0, account_profile_js_1.accountProfileSummary)(ctx);
19
+ }
20
+ /**
21
+ * Returns the transmog appearances and sets collected by an account.
22
+ * Requires a user access token (client.forUser(token)).
23
+ *
24
+ * @returns A promise that resolves to an object representing the account's transmogs.
25
+ */
26
+ async function accountTransmogsCollection(ctx) {
27
+ return await (0, account_profile_js_1.accountTransmogsCollection)(ctx);
28
+ }