@blizzard-api/core 0.1.2 → 1.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.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/blizzard-api.ts"],"sourcesContent":["//Blizzard API\r\nexport * from './blizzard-api
|
|
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":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Possible regions for use within the Blizzard API.
|
|
3
3
|
*/
|
|
4
|
-
type Origins = 'us' | 'eu' | 'kr' | 'tw';
|
|
4
|
+
type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';
|
|
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' | 'multi';
|
|
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';
|
|
9
9
|
/**
|
|
10
10
|
* A record of regions and their supported locales.
|
|
11
11
|
*/
|
|
@@ -14,12 +14,13 @@ declare const locales: {
|
|
|
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
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* The default Blizzard API configuration for each region.
|
|
20
21
|
*/
|
|
21
22
|
interface BlizzardApiDefault<T extends Origins> {
|
|
22
|
-
hostname: `https://${T}.api.blizzard.com`;
|
|
23
|
+
hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
|
|
23
24
|
defaultLocale: (typeof locales)[T][number];
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
@@ -57,6 +58,7 @@ type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' |
|
|
|
57
58
|
/**
|
|
58
59
|
* Represents a resource that can be requested from the Blizzard API
|
|
59
60
|
* @param _Response The response type of the resource
|
|
61
|
+
* @param SearchOptions The search options that can be passed to the resource
|
|
60
62
|
* @param ProtectedResource Whether the resource requires a token to be requested
|
|
61
63
|
*/
|
|
62
64
|
type Resource<Response, SearchOptions extends object = Record<string, never>, ProtectedResource extends boolean = false> = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Possible regions for use within the Blizzard API.
|
|
3
3
|
*/
|
|
4
|
-
type Origins = 'us' | 'eu' | 'kr' | 'tw';
|
|
4
|
+
type Origins = 'us' | 'eu' | 'kr' | 'tw' | 'cn';
|
|
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' | 'multi';
|
|
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';
|
|
9
9
|
/**
|
|
10
10
|
* A record of regions and their supported locales.
|
|
11
11
|
*/
|
|
@@ -14,12 +14,13 @@ declare const locales: {
|
|
|
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
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* The default Blizzard API configuration for each region.
|
|
20
21
|
*/
|
|
21
22
|
interface BlizzardApiDefault<T extends Origins> {
|
|
22
|
-
hostname: `https://${T}.api.blizzard.com`;
|
|
23
|
+
hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;
|
|
23
24
|
defaultLocale: (typeof locales)[T][number];
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
@@ -57,6 +58,7 @@ type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' |
|
|
|
57
58
|
/**
|
|
58
59
|
* Represents a resource that can be requested from the Blizzard API
|
|
59
60
|
* @param _Response The response type of the resource
|
|
61
|
+
* @param SearchOptions The search options that can be passed to the resource
|
|
60
62
|
* @param ProtectedResource Whether the resource requires a token to be requested
|
|
61
63
|
*/
|
|
62
64
|
type Resource<Response, SearchOptions extends object = Record<string, never>, ProtectedResource extends boolean = false> = {
|
package/dist/index.js
CHANGED
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';\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 | '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} 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: `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}\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};\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":";
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blizzard-api/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Putro",
|
|
6
6
|
"description": "The core helpers used by all @blizzard-api/* packages.",
|
|
@@ -39,9 +39,7 @@
|
|
|
39
39
|
"diablo",
|
|
40
40
|
"d3",
|
|
41
41
|
"hs",
|
|
42
|
-
"hearthstone"
|
|
43
|
-
"ow",
|
|
44
|
-
"overwatch"
|
|
42
|
+
"hearthstone"
|
|
45
43
|
],
|
|
46
44
|
"dependencies": {},
|
|
47
45
|
"devDependencies": {},
|