@blizzard-api/core 1.1.1 → 1.1.2

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
@@ -33,5 +33,5 @@ function getBlizzardApi(origin, locale) {
33
33
  }
34
34
 
35
35
  exports.getBlizzardApi = getBlizzardApi;
36
- //# sourceMappingURL=out.js.map
36
+ //# sourceMappingURL=index.cjs.map
37
37
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["../src/blizzard-api.ts"],"names":[],"mappings":";;;AAqDA,IAAM,SAAiC,GAAA;AAAA,EACrC,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,kCAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AACF,CAAA,CAAA;AA2BO,SAAS,cAAA,CACd,QACA,MAC4B,EAAA;AAC5B,EAAM,MAAA,QAAA,GAAW,UAAU,MAAM,CAAA,CAAA;AAEjC,EAAO,OAAA;AAAA,IACL,UAAU,QAAS,CAAA,QAAA;AAAA,IACnB,MAAA,EAAQ,UAAU,QAAS,CAAA,aAAA;AAAA,IAC3B,MAAA;AAAA,GACF,CAAA;AACF","file":"index.cjs","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 _regionLocaleMap = {\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 _regionLocaleMap)[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 _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"]}
package/dist/index.d.cts CHANGED
@@ -9,7 +9,7 @@ type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_I
9
9
  /**
10
10
  * A record of regions and their supported locales.
11
11
  */
12
- declare const locales: {
12
+ declare const _regionLocaleMap: {
13
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"];
@@ -20,7 +20,7 @@ declare const locales: {
20
20
  * The default Blizzard API configuration for each region.
21
21
  */
22
22
  interface BlizzardApiDefault<T extends Origins> {
23
- defaultLocale: (typeof locales)[T][number];
23
+ defaultLocale: (typeof _regionLocaleMap)[T][number];
24
24
  hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
25
25
  }
26
26
  /**
@@ -32,7 +32,7 @@ interface BlizzardApiDefault<T extends Origins> {
32
32
  */
33
33
  interface BlizzardApi<T extends Origins> {
34
34
  hostname: BlizzardApiDefault<Origins>['hostname'];
35
- locale: (typeof locales)[T][number];
35
+ locale: (typeof _regionLocaleMap)[T][number];
36
36
  origin: Origins;
37
37
  }
38
38
  /**
@@ -47,7 +47,7 @@ interface BlizzardApi<T extends Origins> {
47
47
  * console.log(api.locale); // 'en_US'
48
48
  * console.log(api.origin); // 'us'
49
49
  */
50
- declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof locales)[typeof origin][number]): BlizzardApi<typeof origin>;
50
+ declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _regionLocaleMap)[typeof origin][number]): BlizzardApi<typeof origin>;
51
51
 
52
52
  /**
53
53
  * Blizzard API namespaces.
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_I
9
9
  /**
10
10
  * A record of regions and their supported locales.
11
11
  */
12
- declare const locales: {
12
+ declare const _regionLocaleMap: {
13
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"];
@@ -20,7 +20,7 @@ declare const locales: {
20
20
  * The default Blizzard API configuration for each region.
21
21
  */
22
22
  interface BlizzardApiDefault<T extends Origins> {
23
- defaultLocale: (typeof locales)[T][number];
23
+ defaultLocale: (typeof _regionLocaleMap)[T][number];
24
24
  hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
25
25
  }
26
26
  /**
@@ -32,7 +32,7 @@ interface BlizzardApiDefault<T extends Origins> {
32
32
  */
33
33
  interface BlizzardApi<T extends Origins> {
34
34
  hostname: BlizzardApiDefault<Origins>['hostname'];
35
- locale: (typeof locales)[T][number];
35
+ locale: (typeof _regionLocaleMap)[T][number];
36
36
  origin: Origins;
37
37
  }
38
38
  /**
@@ -47,7 +47,7 @@ interface BlizzardApi<T extends Origins> {
47
47
  * console.log(api.locale); // 'en_US'
48
48
  * console.log(api.origin); // 'us'
49
49
  */
50
- declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof locales)[typeof origin][number]): BlizzardApi<typeof origin>;
50
+ declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _regionLocaleMap)[typeof origin][number]): BlizzardApi<typeof origin>;
51
51
 
52
52
  /**
53
53
  * Blizzard API namespaces.
package/dist/index.js CHANGED
@@ -31,5 +31,5 @@ function getBlizzardApi(origin, locale) {
31
31
  }
32
32
 
33
33
  export { getBlizzardApi };
34
- //# sourceMappingURL=out.js.map
34
+ //# sourceMappingURL=index.js.map
35
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["../src/blizzard-api.ts"],"names":[],"mappings":";AAqDA,IAAM,SAAiC,GAAA;AAAA,EACrC,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,kCAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AAAA,EACA,EAAI,EAAA;AAAA,IACF,aAAe,EAAA,OAAA;AAAA,IACf,QAAU,EAAA,6BAAA;AAAA,GACZ;AACF,CAAA,CAAA;AA2BO,SAAS,cAAA,CACd,QACA,MAC4B,EAAA;AAC5B,EAAM,MAAA,QAAA,GAAW,UAAU,MAAM,CAAA,CAAA;AAEjC,EAAO,OAAA;AAAA,IACL,UAAU,QAAS,CAAA,QAAA;AAAA,IACnB,MAAA,EAAQ,UAAU,QAAS,CAAA,aAAA;AAAA,IAC3B,MAAA;AAAA,GACF,CAAA;AACF","file":"index.js","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 _regionLocaleMap = {\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 _regionLocaleMap)[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 _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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blizzard-api/core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "license": "MIT",
5
5
  "author": "Putro",
6
6
  "description": "The core helpers used by all @blizzard-api/* packages.",