@blizzard-api/core 1.1.0 → 1.1.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.cjs CHANGED
@@ -1,62 +1,37 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- getBlizzardApi: () => getBlizzardApi
24
- });
25
- module.exports = __toCommonJS(src_exports);
1
+ 'use strict';
26
2
 
27
3
  // src/blizzard-api.ts
28
4
  var endpoints = {
29
- us: {
30
- hostname: "https://us.api.blizzard.com",
31
- defaultLocale: "en_US"
5
+ cn: {
6
+ defaultLocale: "zh_CN",
7
+ hostname: "https://gateway.battlenet.com.cn"
32
8
  },
33
9
  eu: {
34
- hostname: "https://eu.api.blizzard.com",
35
- defaultLocale: "en_GB"
10
+ defaultLocale: "en_GB",
11
+ hostname: "https://eu.api.blizzard.com"
36
12
  },
37
13
  kr: {
38
- hostname: "https://kr.api.blizzard.com",
39
- defaultLocale: "ko_KR"
14
+ defaultLocale: "ko_KR",
15
+ hostname: "https://kr.api.blizzard.com"
40
16
  },
41
17
  tw: {
42
- hostname: "https://tw.api.blizzard.com",
43
- defaultLocale: "zh_TW"
18
+ defaultLocale: "zh_TW",
19
+ hostname: "https://tw.api.blizzard.com"
44
20
  },
45
- cn: {
46
- hostname: "https://gateway.battlenet.com.cn",
47
- defaultLocale: "zh_CN"
21
+ us: {
22
+ defaultLocale: "en_US",
23
+ hostname: "https://us.api.blizzard.com"
48
24
  }
49
25
  };
50
26
  function getBlizzardApi(origin, locale) {
51
27
  const endpoint = endpoints[origin];
52
28
  return {
53
- origin,
54
29
  hostname: endpoint.hostname,
55
- locale: locale ?? endpoint.defaultLocale
30
+ locale: locale ?? endpoint.defaultLocale,
31
+ origin
56
32
  };
57
33
  }
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
60
- getBlizzardApi
61
- });
34
+
35
+ exports.getBlizzardApi = getBlizzardApi;
36
+ //# sourceMappingURL=out.js.map
62
37
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/blizzard-api.ts"],"sourcesContent":["//Blizzard API\r\nexport * from './blizzard-api';\r\n\r\n//Namespace\r\nexport * from './namespace';\r\n\r\n//Resource\r\nexport * from './resource';\r\n\r\n//Search\r\nexport * from './search';\r\n","/**\r\n * Possible regions for use within the Blizzard API.\r\n */\r\nexport type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';\r\n/**\r\n * Possible locales for use within the Blizzard API.\r\n */\r\nexport type Locales =\r\n | 'en_US'\r\n | 'es_MX'\r\n | 'pt_BR'\r\n | 'en_GB'\r\n | 'es_ES'\r\n | 'fr_FR'\r\n | 'ru_RU'\r\n | 'de_DE'\r\n | 'pt_PT'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'zh_TW'\r\n | 'zh_CN'\r\n | 'multi';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst locales = {\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n cn: ['zh_CN'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\n/**\r\n * The default Blizzard API configuration for each region.\r\n */\r\ninterface BlizzardApiDefault<T extends Origins> {\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n defaultLocale: (typeof locales)[T][number];\r\n}\r\n\r\n/**\r\n * A record of Blizzard API configurations by region.\r\n */\r\ninterface BlizzardApiByRegion {\r\n us: BlizzardApiDefault<'us'>;\r\n eu: BlizzardApiDefault<'eu'>;\r\n kr: BlizzardApiDefault<'kr'>;\r\n tw: BlizzardApiDefault<'tw'>;\r\n cn: BlizzardApiDefault<'cn'>;\r\n}\r\n\r\nconst endpoints: BlizzardApiByRegion = {\r\n us: {\r\n hostname: 'https://us.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n eu: {\r\n hostname: 'https://eu.api.blizzard.com',\r\n defaultLocale: 'en_GB',\r\n },\r\n kr: {\r\n hostname: 'https://kr.api.blizzard.com',\r\n defaultLocale: 'ko_KR',\r\n },\r\n tw: {\r\n hostname: 'https://tw.api.blizzard.com',\r\n defaultLocale: 'zh_TW',\r\n },\r\n cn: {\r\n hostname: 'https://gateway.battlenet.com.cn',\r\n defaultLocale: 'zh_CN',\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 * @property origin The region of the Blizzard API.\r\n * @property locale The locale of the Blizzard API.\r\n * @property hostname The hostname of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n origin: Origins;\r\n locale: (typeof locales)[T][number];\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\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 locales)[typeof origin][number],\r\n): BlizzardApi<typeof origin> {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n origin,\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n };\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqDA,IAAM,YAAiC;AAAA,EACrC,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AA2BO,SAAS,eACd,QACA,QAC4B;AAC5B,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,EAC7B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/blizzard-api.ts"],"names":[],"mappings":";AAqDA,IAAM,YAAiC;AAAA,EACrC,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AACF;AA2BO,SAAS,eACd,QACA,QAC4B;AAC5B,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,IAC3B;AAAA,EACF;AACF","sourcesContent":["/**\r\n * Possible regions for use within the Blizzard API.\r\n */\r\nexport type Origins = 'cn' | 'eu' | 'kr' | 'tw' | 'us';\r\n/**\r\n * Possible locales for use within the Blizzard API.\r\n */\r\nexport type Locales =\r\n | 'de_DE'\r\n | 'en_GB'\r\n | 'en_US'\r\n | 'es_ES'\r\n | 'es_MX'\r\n | 'fr_FR'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'multi'\r\n | 'pt_BR'\r\n | 'pt_PT'\r\n | 'ru_RU'\r\n | 'zh_CN'\r\n | 'zh_TW';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst locales = {\r\n cn: ['zh_CN'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\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 locales)[T][number];\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n}\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\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 * @property origin The region of the Blizzard API.\r\n * @property locale The locale of the Blizzard API.\r\n * @property hostname The hostname of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\r\n locale: (typeof locales)[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 locales)[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"]}
package/dist/index.d.cts CHANGED
@@ -1,27 +1,27 @@
1
1
  /**
2
2
  * Possible regions for use within the Blizzard API.
3
3
  */
4
- type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';
4
+ type Origins = 'cn' | 'eu' | 'kr' | 'tw' | 'us';
5
5
  /**
6
6
  * Possible locales for use within the Blizzard API.
7
7
  */
8
- type Locales = 'en_US' | 'es_MX' | 'pt_BR' | 'en_GB' | 'es_ES' | 'fr_FR' | 'ru_RU' | 'de_DE' | 'pt_PT' | 'it_IT' | 'ko_KR' | 'zh_TW' | 'zh_CN' | 'multi';
8
+ type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_IT' | 'ko_KR' | 'multi' | 'pt_BR' | 'pt_PT' | 'ru_RU' | 'zh_CN' | 'zh_TW';
9
9
  /**
10
10
  * A record of regions and their supported locales.
11
11
  */
12
12
  declare const locales: {
13
- readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
13
+ readonly cn: ["zh_CN"];
14
14
  readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
15
15
  readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
16
16
  readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
17
- readonly cn: ["zh_CN"];
17
+ readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
18
18
  };
19
19
  /**
20
20
  * The default Blizzard API configuration for each region.
21
21
  */
22
22
  interface BlizzardApiDefault<T extends Origins> {
23
- hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
24
23
  defaultLocale: (typeof locales)[T][number];
24
+ hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
25
25
  }
26
26
  /**
27
27
  * A Blizzard API configuration object.
@@ -31,9 +31,9 @@ interface BlizzardApiDefault<T extends Origins> {
31
31
  * @property hostname The hostname of the Blizzard API.
32
32
  */
33
33
  interface BlizzardApi<T extends Origins> {
34
- origin: Origins;
35
- locale: (typeof locales)[T][number];
36
34
  hostname: BlizzardApiDefault<Origins>['hostname'];
35
+ locale: (typeof locales)[T][number];
36
+ origin: Origins;
37
37
  }
38
38
  /**
39
39
  * Get the Blizzard API configuration for a given region.
@@ -53,7 +53,7 @@ declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof l
53
53
  * Blizzard API namespaces.
54
54
  * @see https://develop.battle.net/documentation/world-of-warcraft/guides/namespaces
55
55
  */
56
- type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
56
+ type BlizzardNamespaces = 'dynamic-classic' | 'dynamic-classic1x' | 'dynamic' | 'profile' | 'static-classic' | 'static-classic1x' | 'static';
57
57
 
58
58
  /**
59
59
  * Represents a resource that can be requested from the Blizzard API
@@ -62,14 +62,14 @@ type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' |
62
62
  * @param ProtectedResource Whether the resource requires a token to be requested
63
63
  */
64
64
  type Resource<Response, SearchOptions extends object = Record<string, never>, ProtectedResource extends boolean = false> = {
65
- path: string;
66
- namespace?: BlizzardNamespaces;
67
- parameters?: SearchOptions;
68
65
  /**
69
66
  * The response type of the resource
70
67
  * @private @internal This is an internal property and should not be used as it will not be populated
71
68
  */
72
69
  _responseType?: Response;
70
+ namespace?: BlizzardNamespaces;
71
+ parameters?: SearchOptions;
72
+ path: string;
73
73
  } & (ProtectedResource extends true ? {
74
74
  token: string;
75
75
  } : unknown);
@@ -103,8 +103,8 @@ type ExtractResourceType<Type> = Type extends Resource<infer R, infer _SearchOpt
103
103
  * };
104
104
  */
105
105
  interface BaseSearchParameters {
106
- orderby?: string | Array<string>;
107
106
  _page?: number;
107
+ orderby?: Array<string> | string;
108
108
  }
109
109
  /**
110
110
  * Search response
@@ -124,10 +124,10 @@ interface BaseSearchParameters {
124
124
  * };
125
125
  */
126
126
  interface SearchResponse<T> {
127
- page: number;
128
- pageSize: number;
129
127
  maxPageSize: number;
128
+ page: number;
130
129
  pageCount: number;
130
+ pageSize: number;
131
131
  resultCountCapped?: boolean;
132
132
  results: Array<T>;
133
133
  }
package/dist/index.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  /**
2
2
  * Possible regions for use within the Blizzard API.
3
3
  */
4
- type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';
4
+ type Origins = 'cn' | 'eu' | 'kr' | 'tw' | 'us';
5
5
  /**
6
6
  * Possible locales for use within the Blizzard API.
7
7
  */
8
- type Locales = 'en_US' | 'es_MX' | 'pt_BR' | 'en_GB' | 'es_ES' | 'fr_FR' | 'ru_RU' | 'de_DE' | 'pt_PT' | 'it_IT' | 'ko_KR' | 'zh_TW' | 'zh_CN' | 'multi';
8
+ type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_IT' | 'ko_KR' | 'multi' | 'pt_BR' | 'pt_PT' | 'ru_RU' | 'zh_CN' | 'zh_TW';
9
9
  /**
10
10
  * A record of regions and their supported locales.
11
11
  */
12
12
  declare const locales: {
13
- readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
13
+ readonly cn: ["zh_CN"];
14
14
  readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
15
15
  readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
16
16
  readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
17
- readonly cn: ["zh_CN"];
17
+ readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
18
18
  };
19
19
  /**
20
20
  * The default Blizzard API configuration for each region.
21
21
  */
22
22
  interface BlizzardApiDefault<T extends Origins> {
23
- hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
24
23
  defaultLocale: (typeof locales)[T][number];
24
+ hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
25
25
  }
26
26
  /**
27
27
  * A Blizzard API configuration object.
@@ -31,9 +31,9 @@ interface BlizzardApiDefault<T extends Origins> {
31
31
  * @property hostname The hostname of the Blizzard API.
32
32
  */
33
33
  interface BlizzardApi<T extends Origins> {
34
- origin: Origins;
35
- locale: (typeof locales)[T][number];
36
34
  hostname: BlizzardApiDefault<Origins>['hostname'];
35
+ locale: (typeof locales)[T][number];
36
+ origin: Origins;
37
37
  }
38
38
  /**
39
39
  * Get the Blizzard API configuration for a given region.
@@ -53,7 +53,7 @@ declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof l
53
53
  * Blizzard API namespaces.
54
54
  * @see https://develop.battle.net/documentation/world-of-warcraft/guides/namespaces
55
55
  */
56
- type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
56
+ type BlizzardNamespaces = 'dynamic-classic' | 'dynamic-classic1x' | 'dynamic' | 'profile' | 'static-classic' | 'static-classic1x' | 'static';
57
57
 
58
58
  /**
59
59
  * Represents a resource that can be requested from the Blizzard API
@@ -62,14 +62,14 @@ type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' |
62
62
  * @param ProtectedResource Whether the resource requires a token to be requested
63
63
  */
64
64
  type Resource<Response, SearchOptions extends object = Record<string, never>, ProtectedResource extends boolean = false> = {
65
- path: string;
66
- namespace?: BlizzardNamespaces;
67
- parameters?: SearchOptions;
68
65
  /**
69
66
  * The response type of the resource
70
67
  * @private @internal This is an internal property and should not be used as it will not be populated
71
68
  */
72
69
  _responseType?: Response;
70
+ namespace?: BlizzardNamespaces;
71
+ parameters?: SearchOptions;
72
+ path: string;
73
73
  } & (ProtectedResource extends true ? {
74
74
  token: string;
75
75
  } : unknown);
@@ -103,8 +103,8 @@ type ExtractResourceType<Type> = Type extends Resource<infer R, infer _SearchOpt
103
103
  * };
104
104
  */
105
105
  interface BaseSearchParameters {
106
- orderby?: string | Array<string>;
107
106
  _page?: number;
107
+ orderby?: Array<string> | string;
108
108
  }
109
109
  /**
110
110
  * Search response
@@ -124,10 +124,10 @@ interface BaseSearchParameters {
124
124
  * };
125
125
  */
126
126
  interface SearchResponse<T> {
127
- page: number;
128
- pageSize: number;
129
127
  maxPageSize: number;
128
+ page: number;
130
129
  pageCount: number;
130
+ pageSize: number;
131
131
  resultCountCapped?: boolean;
132
132
  results: Array<T>;
133
133
  }
package/dist/index.js CHANGED
@@ -1,35 +1,35 @@
1
1
  // src/blizzard-api.ts
2
2
  var endpoints = {
3
- us: {
4
- hostname: "https://us.api.blizzard.com",
5
- defaultLocale: "en_US"
3
+ cn: {
4
+ defaultLocale: "zh_CN",
5
+ hostname: "https://gateway.battlenet.com.cn"
6
6
  },
7
7
  eu: {
8
- hostname: "https://eu.api.blizzard.com",
9
- defaultLocale: "en_GB"
8
+ defaultLocale: "en_GB",
9
+ hostname: "https://eu.api.blizzard.com"
10
10
  },
11
11
  kr: {
12
- hostname: "https://kr.api.blizzard.com",
13
- defaultLocale: "ko_KR"
12
+ defaultLocale: "ko_KR",
13
+ hostname: "https://kr.api.blizzard.com"
14
14
  },
15
15
  tw: {
16
- hostname: "https://tw.api.blizzard.com",
17
- defaultLocale: "zh_TW"
16
+ defaultLocale: "zh_TW",
17
+ hostname: "https://tw.api.blizzard.com"
18
18
  },
19
- cn: {
20
- hostname: "https://gateway.battlenet.com.cn",
21
- defaultLocale: "zh_CN"
19
+ us: {
20
+ defaultLocale: "en_US",
21
+ hostname: "https://us.api.blizzard.com"
22
22
  }
23
23
  };
24
24
  function getBlizzardApi(origin, locale) {
25
25
  const endpoint = endpoints[origin];
26
26
  return {
27
- origin,
28
27
  hostname: endpoint.hostname,
29
- locale: locale ?? endpoint.defaultLocale
28
+ locale: locale ?? endpoint.defaultLocale,
29
+ origin
30
30
  };
31
31
  }
32
- export {
33
- getBlizzardApi
34
- };
32
+
33
+ export { getBlizzardApi };
34
+ //# sourceMappingURL=out.js.map
35
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/blizzard-api.ts"],"sourcesContent":["/**\r\n * Possible regions for use within the Blizzard API.\r\n */\r\nexport type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';\r\n/**\r\n * Possible locales for use within the Blizzard API.\r\n */\r\nexport type Locales =\r\n | 'en_US'\r\n | 'es_MX'\r\n | 'pt_BR'\r\n | 'en_GB'\r\n | 'es_ES'\r\n | 'fr_FR'\r\n | 'ru_RU'\r\n | 'de_DE'\r\n | 'pt_PT'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'zh_TW'\r\n | 'zh_CN'\r\n | 'multi';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst locales = {\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n cn: ['zh_CN'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\n/**\r\n * The default Blizzard API configuration for each region.\r\n */\r\ninterface BlizzardApiDefault<T extends Origins> {\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n defaultLocale: (typeof locales)[T][number];\r\n}\r\n\r\n/**\r\n * A record of Blizzard API configurations by region.\r\n */\r\ninterface BlizzardApiByRegion {\r\n us: BlizzardApiDefault<'us'>;\r\n eu: BlizzardApiDefault<'eu'>;\r\n kr: BlizzardApiDefault<'kr'>;\r\n tw: BlizzardApiDefault<'tw'>;\r\n cn: BlizzardApiDefault<'cn'>;\r\n}\r\n\r\nconst endpoints: BlizzardApiByRegion = {\r\n us: {\r\n hostname: 'https://us.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n eu: {\r\n hostname: 'https://eu.api.blizzard.com',\r\n defaultLocale: 'en_GB',\r\n },\r\n kr: {\r\n hostname: 'https://kr.api.blizzard.com',\r\n defaultLocale: 'ko_KR',\r\n },\r\n tw: {\r\n hostname: 'https://tw.api.blizzard.com',\r\n defaultLocale: 'zh_TW',\r\n },\r\n cn: {\r\n hostname: 'https://gateway.battlenet.com.cn',\r\n defaultLocale: 'zh_CN',\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 * @property origin The region of the Blizzard API.\r\n * @property locale The locale of the Blizzard API.\r\n * @property hostname The hostname of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n origin: Origins;\r\n locale: (typeof locales)[T][number];\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\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 locales)[typeof origin][number],\r\n): BlizzardApi<typeof origin> {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n origin,\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n };\r\n}\r\n"],"mappings":";AAqDA,IAAM,YAAiC;AAAA,EACrC,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AA2BO,SAAS,eACd,QACA,QAC4B;AAC5B,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,EAC7B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/blizzard-api.ts"],"names":[],"mappings":";AAqDA,IAAM,YAAiC;AAAA,EACrC,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AAAA,EACA,IAAI;AAAA,IACF,eAAe;AAAA,IACf,UAAU;AAAA,EACZ;AACF;AA2BO,SAAS,eACd,QACA,QAC4B;AAC5B,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,IAC3B;AAAA,EACF;AACF","sourcesContent":["/**\r\n * Possible regions for use within the Blizzard API.\r\n */\r\nexport type Origins = 'cn' | 'eu' | 'kr' | 'tw' | 'us';\r\n/**\r\n * Possible locales for use within the Blizzard API.\r\n */\r\nexport type Locales =\r\n | 'de_DE'\r\n | 'en_GB'\r\n | 'en_US'\r\n | 'es_ES'\r\n | 'es_MX'\r\n | 'fr_FR'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'multi'\r\n | 'pt_BR'\r\n | 'pt_PT'\r\n | 'ru_RU'\r\n | 'zh_CN'\r\n | 'zh_TW';\r\n\r\n/**\r\n * A record of regions and their supported locales.\r\n */\r\nconst locales = {\r\n cn: ['zh_CN'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\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 locales)[T][number];\r\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\r\n}\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\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 * @property origin The region of the Blizzard API.\r\n * @property locale The locale of the Blizzard API.\r\n * @property hostname The hostname of the Blizzard API.\r\n */\r\ninterface BlizzardApi<T extends Origins> {\r\n hostname: BlizzardApiDefault<Origins>['hostname'];\r\n locale: (typeof locales)[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 locales)[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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blizzard-api/core",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "author": "Putro",
6
6
  "description": "The core helpers used by all @blizzard-api/* packages.",
@@ -9,7 +9,9 @@
9
9
  "engines": {
10
10
  "node": "^18.18 || ^20.9 || ^21.1 || ^22"
11
11
  },
12
- "main": "./dist/index.js",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
13
15
  "exports": {
14
16
  "import": {
15
17
  "types": "./dist/index.d.ts",