@blizzard-api/core 3.0.2 → 4.1.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.ts CHANGED
@@ -67,6 +67,10 @@ interface Faction {
67
67
  * The playable factions in World of Warcraft.
68
68
  */
69
69
  type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';
70
+ /**
71
+ * The playable factions at max level in World of Warcraft.
72
+ */
73
+ type NonNeutralFactions = 'ALLIANCE' | 'HORDE';
70
74
  /**
71
75
  * The gender associated with a character or entity in World of Warcraft.
72
76
  */
@@ -220,15 +224,6 @@ type Resource<Response, SearchOptions extends object = Record<string, unknown>,
220
224
  parameters?: SearchOptions;
221
225
  path: string;
222
226
  };
223
- /**
224
- * Represents the response of a resource
225
- * @param T The response type of the resource
226
- * @example
227
- * type response = ResourceResponse<{ id: number }>;
228
- * const response: response = Promise.resolve({ id: 1 });
229
- * response.then((data) => console.log(data.id));
230
- */
231
- type ResourceResponse<T = unknown> = Promise<T>;
232
227
  //#endregion
233
228
  //#region src/search.d.ts
234
229
  /**
@@ -254,5 +249,5 @@ interface SearchResponseWithoutResults {
254
249
  resultCountCapped?: boolean;
255
250
  }
256
251
  //#endregion
257
- export { BaseSearchParameters, BlizzardNamespaces, Character, Color, ExtractResourceType, Faction, Factions, Gender, GenderName, Href, KeyBase, Locales, MediaAsset, NameId, NameIdKey, NullishNameIdKey, Origins, ProtectedResource, Realm, Resource, ResourceResponse, ResponseBase, SearchResponseWithoutResults, d3BasePath, d3GameDataBasePath, d3ProfileBasePath, getBlizzardApi, wowBasePath, wowCharacterBasePath, wowMediaBasePath, wowSearchBasePath };
252
+ export { BaseSearchParameters, BlizzardNamespaces, Character, Color, ExtractResourceType, Faction, Factions, Gender, GenderName, Href, KeyBase, Locales, MediaAsset, NameId, NameIdKey, NonNeutralFactions, NullishNameIdKey, Origins, ProtectedResource, Realm, Resource, ResponseBase, SearchResponseWithoutResults, d3BasePath, d3GameDataBasePath, d3ProfileBasePath, getBlizzardApi, wowBasePath, wowCharacterBasePath, wowMediaBasePath, wowSearchBasePath };
258
253
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/base.ts","../src/blizzard-api.ts"],"sourcesContent":["/**\n * The base request path for the D3 API in the Blizzard API.\n */\nexport const d3BasePath = 'd3/data';\n\n/**\n * The base request path for profile APIs in the D3 API.\n */\nexport const d3ProfileBasePath = `d3/profile`;\n\n/**\n * The base request path for game data APIs in the D3 API.\n */\nexport const d3GameDataBasePath = `data/d3`;\n\n/**\n * The base request path for the Blizzard API for world of warcraft.\n */\nexport const wowBasePath = '/data/wow';\n\n/**\n * The base request path for the character API for Classic World of Warcraft.\n */\nexport const wowCharacterBasePath = 'profile/wow/character';\n\n/**\n * The base request path for media in the Blizzard API for world of warcraft.\n */\nexport const wowMediaBasePath = `${wowBasePath}/media` as const;\n\n/**\n * The base request path for search in the Blizzard API for world of warcraft.\n */\nexport const wowSearchBasePath = `${wowBasePath}/search` as const;\n\n/**\n * Base search parameters\n * orderby The field to order results by.\n * _page The page number to return.\n * @example\n * const params: BaseSearchParameters = {\n * orderby: 'name',\n * _page: 1,\n * };\n */\nexport interface BaseSearchParameters {\n _page?: number;\n orderby?: Array<string> | string;\n}\n/**\n * The standard structure to represent a World of Warcraft Character.\n */\nexport interface Character extends NameIdKey {\n realm: Realm;\n}\n\n/**\n * A record containing the RGBA values of a color.\n */\nexport interface Color {\n a: number;\n b: number;\n g: number;\n r: number;\n}\n\n/**\n * The faction associated with a character or entity in World of Warcraft.\n */\nexport interface Faction {\n name: string;\n type: Factions;\n}\n\n/**\n * The playable factions in World of Warcraft.\n */\nexport type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';\n\n/**\n * The gender associated with a character or entity in World of Warcraft.\n */\nexport interface Gender {\n name: string;\n type: 'FEMALE' | 'MALE';\n}\n\n/**\n * The playable gender names/descriptions in World of Warcraft.\n */\nexport interface GenderName {\n female: null | string;\n male: null | string;\n}\n\nexport interface Href {\n href: string;\n}\n\n/**\n * Base record interface containing key.href property that often appear in Blizzard API responses.\n */\nexport interface KeyBase {\n key: Href;\n}\n\n/**\n * The media asset associated with a character or entity in World of Warcraft.\n */\nexport interface MediaAsset {\n file_data_id?: number;\n key: string;\n value: string;\n}\n\n/**\n * Base record interface containing name and id properties that often appear together in Blizzard API responses.\n */\nexport interface NameId {\n id: number;\n name: string;\n}\n\n/**\n * Base record containing both {@link KeyBase} and {@link NameId} interfaces.\n */\nexport interface NameIdKey extends KeyBase, NameId {}\n\nexport interface NullishNameIdKey extends Omit<NameIdKey, 'name'> {\n name: null | string;\n}\n\n/**\n * The standard structure to represent a World of Warcraft Realm.\n */\nexport interface Realm extends KeyBase {\n id: number;\n name?: string;\n slug: string;\n}\n\n/**\n * Base interface for Blizzard API responses.\n */\nexport interface ResponseBase {\n _links: {\n self: Href;\n };\n}\n","import type { Locales, Origins } from './locales';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst _regionLocaleMap = {\r\n cn: ['zh_CN'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'it_IT'],\r\n kr: ['ko_KR', 'en_GB', 'en_US'],\r\n tw: ['zh_TW', 'en_GB', 'en_US'],\r\n us: ['en_US', 'es_MX', 'pt_BR'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\n/**\r\n * A record of Blizzard API configurations by region.\r\n */\r\ninterface BlizzardApiByRegion {\r\n cn: BlizzardApiDefault<'cn'>;\r\n eu: BlizzardApiDefault<'eu'>;\r\n kr: BlizzardApiDefault<'kr'>;\r\n tw: BlizzardApiDefault<'tw'>;\r\n us: BlizzardApiDefault<'us'>;\r\n}\r\n\r\n/**\r\n * The default Blizzard API configuration for each region.\r\n */\r\ninterface BlizzardApiDefault<T extends Origins> {\r\n defaultLocale: (typeof _regionLocaleMap)[T][number];\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n}\r\n\r\nconst endpoints: BlizzardApiByRegion = {\r\n cn: {\r\n defaultLocale: 'zh_CN',\r\n hostname: 'https://gateway.battlenet.com.cn',\r\n },\r\n eu: {\r\n defaultLocale: 'en_GB',\r\n hostname: 'https://eu.api.blizzard.com',\r\n },\r\n kr: {\r\n defaultLocale: 'ko_KR',\r\n hostname: 'https://kr.api.blizzard.com',\r\n },\r\n tw: {\r\n defaultLocale: 'zh_TW',\r\n hostname: 'https://tw.api.blizzard.com',\r\n },\r\n us: {\r\n defaultLocale: 'en_US',\r\n hostname: 'https://us.api.blizzard.com',\r\n },\r\n};\r\n\r\n/**\r\n * A Blizzard API configuration object.\r\n * @template T The region of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\r\n locale: (typeof _regionLocaleMap)[T][number];\r\n origin: Origins;\r\n}\r\n\r\n/**\r\n * Get the Blizzard API configuration for a given region.\r\n * @template T The region of the Blizzard API.\r\n * @param origin The region of the Blizzard API.\r\n * @param locale The locale of the Blizzard API.\r\n * @returns The Blizzard API configuration for the given region.\r\n * @example\r\n * const api = getBlizzardApi('us', 'en_US');\r\n * console.log(api.hostname); // 'https://us.api.blizzard.com'\r\n * console.log(api.locale); // 'en_US'\r\n * console.log(api.origin); // 'us'\r\n */\r\nexport function getBlizzardApi<T extends Origins>(\r\n origin: T,\r\n locale?: (typeof _regionLocaleMap)[typeof origin][number],\r\n): BlizzardApi<typeof origin> {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n origin,\r\n };\r\n}\r\n"],"mappings":";;;;AAGA,MAAa,aAAa;;;;AAK1B,MAAa,oBAAoB;;;;AAKjC,MAAa,qBAAqB;;;;AAKlC,MAAa,cAAc;;;;AAK3B,MAAa,uBAAuB;;;;AAKpC,MAAa,mBAAmB,GAAG,YAAY;;;;AAK/C,MAAa,oBAAoB,GAAG,YAAY;;;ACDhD,MAAM,YAAiC;CACrC,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACF;;;;;;;;;;;;;AAwBD,SAAgB,eACd,QACA,QAC4B;CAC5B,MAAM,WAAW,UAAU;AAE3B,QAAO;EACL,UAAU,SAAS;EACnB,QAAQ,UAAU,SAAS;EAC3B;EACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/base.ts","../src/blizzard-api.ts"],"sourcesContent":["/**\n * The base request path for the D3 API in the Blizzard API.\n */\nexport const d3BasePath = 'd3/data';\n\n/**\n * The base request path for profile APIs in the D3 API.\n */\nexport const d3ProfileBasePath = `d3/profile`;\n\n/**\n * The base request path for game data APIs in the D3 API.\n */\nexport const d3GameDataBasePath = `data/d3`;\n\n/**\n * The base request path for the Blizzard API for world of warcraft.\n */\nexport const wowBasePath = '/data/wow';\n\n/**\n * The base request path for the character API for Classic World of Warcraft.\n */\nexport const wowCharacterBasePath = 'profile/wow/character';\n\n/**\n * The base request path for media in the Blizzard API for world of warcraft.\n */\nexport const wowMediaBasePath = `${wowBasePath}/media` as const;\n\n/**\n * The base request path for search in the Blizzard API for world of warcraft.\n */\nexport const wowSearchBasePath = `${wowBasePath}/search` as const;\n\n/**\n * Base search parameters\n * orderby The field to order results by.\n * _page The page number to return.\n * @example\n * const params: BaseSearchParameters = {\n * orderby: 'name',\n * _page: 1,\n * };\n */\nexport interface BaseSearchParameters {\n _page?: number;\n orderby?: Array<string> | string;\n}\n/**\n * The standard structure to represent a World of Warcraft Character.\n */\nexport interface Character extends NameIdKey {\n realm: Realm;\n}\n\n/**\n * A record containing the RGBA values of a color.\n */\nexport interface Color {\n a: number;\n b: number;\n g: number;\n r: number;\n}\n\n/**\n * The faction associated with a character or entity in World of Warcraft.\n */\nexport interface Faction {\n name: string;\n type: Factions;\n}\n\n/**\n * The playable factions in World of Warcraft.\n */\nexport type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';\n\n/**\n * The playable factions at max level in World of Warcraft.\n */\nexport type NonNeutralFactions = 'ALLIANCE' | 'HORDE';\n\n/**\n * The gender associated with a character or entity in World of Warcraft.\n */\nexport interface Gender {\n name: string;\n type: 'FEMALE' | 'MALE';\n}\n\n/**\n * The playable gender names/descriptions in World of Warcraft.\n */\nexport interface GenderName {\n female: null | string;\n male: null | string;\n}\n\nexport interface Href {\n href: string;\n}\n\n/**\n * Base record interface containing key.href property that often appear in Blizzard API responses.\n */\nexport interface KeyBase {\n key: Href;\n}\n\n/**\n * The media asset associated with a character or entity in World of Warcraft.\n */\nexport interface MediaAsset {\n file_data_id?: number;\n key: string;\n value: string;\n}\n\n/**\n * Base record interface containing name and id properties that often appear together in Blizzard API responses.\n */\nexport interface NameId {\n id: number;\n name: string;\n}\n\n/**\n * Base record containing both {@link KeyBase} and {@link NameId} interfaces.\n */\nexport interface NameIdKey extends KeyBase, NameId {}\n\nexport interface NullishNameIdKey extends Omit<NameIdKey, 'name'> {\n name: null | string;\n}\n\n/**\n * The standard structure to represent a World of Warcraft Realm.\n */\nexport interface Realm extends KeyBase {\n id: number;\n name?: string;\n slug: string;\n}\n\n/**\n * Base interface for Blizzard API responses.\n */\nexport interface ResponseBase {\n _links: {\n self: Href;\n };\n}\n","import type { Locales, Origins } from './locales';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst _regionLocaleMap = {\r\n cn: ['zh_CN'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'it_IT'],\r\n kr: ['ko_KR', 'en_GB', 'en_US'],\r\n tw: ['zh_TW', 'en_GB', 'en_US'],\r\n us: ['en_US', 'es_MX', 'pt_BR'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\n/**\r\n * A record of Blizzard API configurations by region.\r\n */\r\ninterface BlizzardApiByRegion {\r\n cn: BlizzardApiDefault<'cn'>;\r\n eu: BlizzardApiDefault<'eu'>;\r\n kr: BlizzardApiDefault<'kr'>;\r\n tw: BlizzardApiDefault<'tw'>;\r\n us: BlizzardApiDefault<'us'>;\r\n}\r\n\r\n/**\r\n * The default Blizzard API configuration for each region.\r\n */\r\ninterface BlizzardApiDefault<T extends Origins> {\r\n defaultLocale: (typeof _regionLocaleMap)[T][number];\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n}\r\n\r\nconst endpoints: BlizzardApiByRegion = {\r\n cn: {\r\n defaultLocale: 'zh_CN',\r\n hostname: 'https://gateway.battlenet.com.cn',\r\n },\r\n eu: {\r\n defaultLocale: 'en_GB',\r\n hostname: 'https://eu.api.blizzard.com',\r\n },\r\n kr: {\r\n defaultLocale: 'ko_KR',\r\n hostname: 'https://kr.api.blizzard.com',\r\n },\r\n tw: {\r\n defaultLocale: 'zh_TW',\r\n hostname: 'https://tw.api.blizzard.com',\r\n },\r\n us: {\r\n defaultLocale: 'en_US',\r\n hostname: 'https://us.api.blizzard.com',\r\n },\r\n};\r\n\r\n/**\r\n * A Blizzard API configuration object.\r\n * @template T The region of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\r\n locale: (typeof _regionLocaleMap)[T][number];\r\n origin: Origins;\r\n}\r\n\r\n/**\r\n * Get the Blizzard API configuration for a given region.\r\n * @template T The region of the Blizzard API.\r\n * @param origin The region of the Blizzard API.\r\n * @param locale The locale of the Blizzard API.\r\n * @returns The Blizzard API configuration for the given region.\r\n * @example\r\n * const api = getBlizzardApi('us', 'en_US');\r\n * console.log(api.hostname); // 'https://us.api.blizzard.com'\r\n * console.log(api.locale); // 'en_US'\r\n * console.log(api.origin); // 'us'\r\n */\r\nexport function getBlizzardApi<T extends Origins>(\r\n origin: T,\r\n locale?: (typeof _regionLocaleMap)[typeof origin][number],\r\n): BlizzardApi<typeof origin> {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n origin,\r\n };\r\n}\r\n"],"mappings":";;;;AAGA,MAAa,aAAa;;;;AAK1B,MAAa,oBAAoB;;;;AAKjC,MAAa,qBAAqB;;;;AAKlC,MAAa,cAAc;;;;AAK3B,MAAa,uBAAuB;;;;AAKpC,MAAa,mBAAmB,GAAG,YAAY;;;;AAK/C,MAAa,oBAAoB,GAAG,YAAY;;;ACDhD,MAAM,YAAiC;CACrC,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACD,IAAI;EACF,eAAe;EACf,UAAU;EACX;CACF;;;;;;;;;;;;;AAwBD,SAAgB,eACd,QACA,QAC4B;CAC5B,MAAM,WAAW,UAAU;CAE3B,OAAO;EACL,UAAU,SAAS;EACnB,QAAQ,UAAU,SAAS;EAC3B;EACD"}
package/package.json CHANGED
@@ -1,19 +1,23 @@
1
1
  {
2
2
  "name": "@blizzard-api/core",
3
- "version": "3.0.2",
3
+ "version": "4.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Putro",
6
6
  "description": "The core helpers used by all @blizzard-api/* packages.",
7
- "repository": "https://github.com/Pewtro/blizzard-api/tree/main/packages/core",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Pewtro/blizzard-api.git",
10
+ "directory": "packages/core"
11
+ },
8
12
  "type": "module",
9
13
  "engines": {
10
- "node": "^20.19.0 || ^22.13.0 || >=24"
14
+ "node": "^22.13.0 || ^24 || ^26"
11
15
  },
12
16
  "module": "./dist/index.js",
13
17
  "types": "./dist/index.d.ts",
14
18
  "exports": {
15
19
  "import": {
16
- "@blizzard-api/core-local": "./src/index.ts",
20
+ "@blizzard-api/source": "./src/index.ts",
17
21
  "types": "./dist/index.d.ts",
18
22
  "default": "./dist/index.js"
19
23
  }