@blizzard-api/core 2.1.1 → 3.0.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/README.md +25 -25
- package/dist/index.d.ts +138 -28
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# @blizzard-api/core
|
|
2
|
-
|
|
3
|
-
This package provides core functionality to the other `@blizzard-api/*` packages.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm i @blizzard-api/core
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
The package includes a series of types that define values that are allowed to be passed to Battle.net API.
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import type { BlizzardNamespaces, Locales, Origins } from '@blizzard-api/core';
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
It also includes a helper function to get the origin, hostname and locale easily accessible based off a single origin.
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import type { getBlizzardApi } from '@blizzard-api/core';
|
|
23
|
-
|
|
24
|
-
const { origin, hostname, locale } = getBlizzardApi('eu'); // "kr" | "tw" | "us"
|
|
25
|
-
```
|
|
1
|
+
# @blizzard-api/core
|
|
2
|
+
|
|
3
|
+
This package provides core functionality to the other `@blizzard-api/*` packages.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i @blizzard-api/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The package includes a series of types that define values that are allowed to be passed to Battle.net API.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { BlizzardNamespaces, Locales, Origins } from '@blizzard-api/core';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
It also includes a helper function to get the origin, hostname and locale easily accessible based off a single origin.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import type { getBlizzardApi } from '@blizzard-api/core';
|
|
23
|
+
|
|
24
|
+
const { origin, hostname, locale } = getBlizzardApi('eu'); // "kr" | "tw" | "us"
|
|
25
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,151 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/base.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The base request path for the D3 API in the Blizzard API.
|
|
4
|
+
*/
|
|
5
|
+
declare const d3BasePath = "d3/data";
|
|
6
|
+
/**
|
|
7
|
+
* The base request path for profile APIs in the D3 API.
|
|
8
|
+
*/
|
|
9
|
+
declare const d3ProfileBasePath = "d3/profile";
|
|
10
|
+
/**
|
|
11
|
+
* The base request path for game data APIs in the D3 API.
|
|
12
|
+
*/
|
|
13
|
+
declare const d3GameDataBasePath = "data/d3";
|
|
14
|
+
/**
|
|
15
|
+
* The base request path for the Blizzard API for world of warcraft.
|
|
16
|
+
*/
|
|
17
|
+
declare const wowBasePath = "/data/wow";
|
|
18
|
+
/**
|
|
19
|
+
* The base request path for the character API for Classic World of Warcraft.
|
|
20
|
+
*/
|
|
21
|
+
declare const wowCharacterBasePath = "profile/wow/character";
|
|
22
|
+
/**
|
|
23
|
+
* The base request path for media in the Blizzard API for world of warcraft.
|
|
24
|
+
*/
|
|
25
|
+
declare const wowMediaBasePath: "/data/wow/media";
|
|
26
|
+
/**
|
|
27
|
+
* The base request path for search in the Blizzard API for world of warcraft.
|
|
28
|
+
*/
|
|
29
|
+
declare const wowSearchBasePath: "/data/wow/search";
|
|
30
|
+
/**
|
|
31
|
+
* Base search parameters
|
|
32
|
+
* orderby The field to order results by.
|
|
33
|
+
* _page The page number to return.
|
|
34
|
+
* @example
|
|
35
|
+
* const params: BaseSearchParameters = {
|
|
36
|
+
* orderby: 'name',
|
|
37
|
+
* _page: 1,
|
|
38
|
+
* };
|
|
39
|
+
*/
|
|
40
|
+
interface BaseSearchParameters {
|
|
41
|
+
_page?: number;
|
|
42
|
+
orderby?: Array<string> | string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The standard structure to represent a World of Warcraft Character.
|
|
46
|
+
*/
|
|
47
|
+
interface Character extends NameIdKey {
|
|
48
|
+
realm: Realm;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A record containing the RGBA values of a color.
|
|
52
|
+
*/
|
|
53
|
+
interface Color {
|
|
54
|
+
a: number;
|
|
55
|
+
b: number;
|
|
56
|
+
g: number;
|
|
57
|
+
r: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The faction associated with a character or entity in World of Warcraft.
|
|
61
|
+
*/
|
|
62
|
+
interface Faction {
|
|
63
|
+
name: string;
|
|
64
|
+
type: Factions;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The playable factions in World of Warcraft.
|
|
68
|
+
*/
|
|
69
|
+
type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';
|
|
70
|
+
/**
|
|
71
|
+
* The gender associated with a character or entity in World of Warcraft.
|
|
72
|
+
*/
|
|
73
|
+
interface Gender {
|
|
74
|
+
name: string;
|
|
75
|
+
type: 'FEMALE' | 'MALE';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The playable gender names/descriptions in World of Warcraft.
|
|
79
|
+
*/
|
|
80
|
+
interface GenderName {
|
|
81
|
+
female: null | string;
|
|
82
|
+
male: null | string;
|
|
83
|
+
}
|
|
84
|
+
interface Href {
|
|
85
|
+
href: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Base record interface containing key.href property that often appear in Blizzard API responses.
|
|
89
|
+
*/
|
|
90
|
+
interface KeyBase {
|
|
91
|
+
key: Href;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The media asset associated with a character or entity in World of Warcraft.
|
|
95
|
+
*/
|
|
96
|
+
interface MediaAsset {
|
|
97
|
+
file_data_id?: number;
|
|
98
|
+
key: string;
|
|
99
|
+
value: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Base record interface containing name and id properties that often appear together in Blizzard API responses.
|
|
103
|
+
*/
|
|
104
|
+
interface NameId {
|
|
105
|
+
id: number;
|
|
106
|
+
name: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Base record containing both {@link KeyBase} and {@link NameId} interfaces.
|
|
110
|
+
*/
|
|
111
|
+
interface NameIdKey extends KeyBase, NameId {}
|
|
112
|
+
/**
|
|
113
|
+
* The standard structure to represent a World of Warcraft Realm.
|
|
114
|
+
*/
|
|
115
|
+
interface Realm extends KeyBase {
|
|
116
|
+
id: number;
|
|
117
|
+
name?: string;
|
|
118
|
+
slug: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Base interface for Blizzard API responses.
|
|
122
|
+
*/
|
|
123
|
+
interface ResponseBase {
|
|
124
|
+
_links: {
|
|
125
|
+
self: Href;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/locales.d.ts
|
|
2
130
|
/**
|
|
3
131
|
* Possible locales for use within the Blizzard API.
|
|
4
132
|
*/
|
|
5
|
-
type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_IT' | 'ko_KR' | '
|
|
133
|
+
type Locales = 'de_DE' | 'en_GB' | 'en_US' | 'es_ES' | 'es_MX' | 'fr_FR' | 'it_IT' | 'ko_KR' | 'pt_BR' | 'ru_RU' | 'zh_CN' | 'zh_TW';
|
|
6
134
|
/**
|
|
7
135
|
* Possible regions for use within the Blizzard API.
|
|
8
136
|
*/
|
|
9
137
|
type Origins = 'cn' | 'eu' | 'kr' | 'tw' | 'us';
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/blizzard-api.d.ts
|
|
10
140
|
/**
|
|
11
141
|
* A record of regions and their supported locales.
|
|
12
142
|
*/
|
|
13
143
|
declare const _regionLocaleMap: {
|
|
14
144
|
readonly cn: ["zh_CN"];
|
|
15
|
-
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "
|
|
16
|
-
readonly kr: ["ko_KR", "en_GB", "en_US"
|
|
17
|
-
readonly tw: ["zh_TW", "en_GB", "en_US"
|
|
18
|
-
readonly us: ["en_US", "es_MX", "pt_BR"
|
|
145
|
+
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "it_IT"];
|
|
146
|
+
readonly kr: ["ko_KR", "en_GB", "en_US"];
|
|
147
|
+
readonly tw: ["zh_TW", "en_GB", "en_US"];
|
|
148
|
+
readonly us: ["en_US", "es_MX", "pt_BR"];
|
|
19
149
|
};
|
|
20
150
|
/**
|
|
21
151
|
* The default Blizzard API configuration for each region.
|
|
@@ -46,7 +176,6 @@ interface BlizzardApi<T extends Origins> {
|
|
|
46
176
|
* console.log(api.origin); // 'us'
|
|
47
177
|
*/
|
|
48
178
|
declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _regionLocaleMap)[typeof origin][number]): BlizzardApi<typeof origin>;
|
|
49
|
-
|
|
50
179
|
//#endregion
|
|
51
180
|
//#region src/namespace.d.ts
|
|
52
181
|
/**
|
|
@@ -54,7 +183,6 @@ declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _
|
|
|
54
183
|
* @see https://develop.battle.net/documentation/world-of-warcraft/guides/namespaces
|
|
55
184
|
*/
|
|
56
185
|
type BlizzardNamespaces = 'dynamic' | 'dynamic-classic1x' | 'dynamic-classic' | 'profile' | 'profile-classic1x' | 'profile-classic' | 'static' | 'static-classic1x' | 'static-classic';
|
|
57
|
-
|
|
58
186
|
//#endregion
|
|
59
187
|
//#region src/resource.d.ts
|
|
60
188
|
/**
|
|
@@ -98,23 +226,8 @@ type Resource<Response, SearchOptions extends object = Record<string, unknown>,
|
|
|
98
226
|
* response.then((data) => console.log(data.id));
|
|
99
227
|
*/
|
|
100
228
|
type ResourceResponse<T = unknown> = Promise<T>;
|
|
101
|
-
|
|
102
229
|
//#endregion
|
|
103
230
|
//#region src/search.d.ts
|
|
104
|
-
/**
|
|
105
|
-
* Base search parameters
|
|
106
|
-
* orderby The field to order results by.
|
|
107
|
-
* _page The page number to return.
|
|
108
|
-
* @example
|
|
109
|
-
* const params: BaseSearchParameters = {
|
|
110
|
-
* orderby: 'name',
|
|
111
|
-
* _page: 1,
|
|
112
|
-
* };
|
|
113
|
-
*/
|
|
114
|
-
interface BaseSearchParameters {
|
|
115
|
-
_page?: number;
|
|
116
|
-
orderby?: Array<string> | string;
|
|
117
|
-
}
|
|
118
231
|
/**
|
|
119
232
|
* Search response
|
|
120
233
|
* page The current page number.
|
|
@@ -128,18 +241,15 @@ interface BaseSearchParameters {
|
|
|
128
241
|
* pageSize: 20,
|
|
129
242
|
* maxPageSize: 100,
|
|
130
243
|
* pageCount: 10,
|
|
131
|
-
* results: [],
|
|
132
244
|
* };
|
|
133
245
|
*/
|
|
134
|
-
interface
|
|
246
|
+
interface SearchResponseWithoutResults {
|
|
135
247
|
maxPageSize: number;
|
|
136
248
|
page: number;
|
|
137
249
|
pageCount: number;
|
|
138
250
|
pageSize: number;
|
|
139
251
|
resultCountCapped?: boolean;
|
|
140
|
-
results: Array<T>;
|
|
141
252
|
}
|
|
142
|
-
|
|
143
253
|
//#endregion
|
|
144
|
-
export { BaseSearchParameters, BlizzardNamespaces, ExtractResourceType, Locales, Origins, ProtectedResource, Resource, ResourceResponse,
|
|
254
|
+
export { BaseSearchParameters, BlizzardNamespaces, Character, Color, ExtractResourceType, Faction, Factions, Gender, GenderName, Href, KeyBase, Locales, MediaAsset, NameId, NameIdKey, Origins, ProtectedResource, Realm, Resource, ResourceResponse, ResponseBase, SearchResponseWithoutResults, d3BasePath, d3GameDataBasePath, d3ProfileBasePath, getBlizzardApi, wowBasePath, wowCharacterBasePath, wowMediaBasePath, wowSearchBasePath };
|
|
145
255
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
//#region src/base.ts
|
|
2
|
+
/**
|
|
3
|
+
* The base request path for the D3 API in the Blizzard API.
|
|
4
|
+
*/
|
|
5
|
+
const d3BasePath = "d3/data";
|
|
6
|
+
/**
|
|
7
|
+
* The base request path for profile APIs in the D3 API.
|
|
8
|
+
*/
|
|
9
|
+
const d3ProfileBasePath = `d3/profile`;
|
|
10
|
+
/**
|
|
11
|
+
* The base request path for game data APIs in the D3 API.
|
|
12
|
+
*/
|
|
13
|
+
const d3GameDataBasePath = `data/d3`;
|
|
14
|
+
/**
|
|
15
|
+
* The base request path for the Blizzard API for world of warcraft.
|
|
16
|
+
*/
|
|
17
|
+
const wowBasePath = "/data/wow";
|
|
18
|
+
/**
|
|
19
|
+
* The base request path for the character API for Classic World of Warcraft.
|
|
20
|
+
*/
|
|
21
|
+
const wowCharacterBasePath = "profile/wow/character";
|
|
22
|
+
/**
|
|
23
|
+
* The base request path for media in the Blizzard API for world of warcraft.
|
|
24
|
+
*/
|
|
25
|
+
const wowMediaBasePath = `${wowBasePath}/media`;
|
|
26
|
+
/**
|
|
27
|
+
* The base request path for search in the Blizzard API for world of warcraft.
|
|
28
|
+
*/
|
|
29
|
+
const wowSearchBasePath = `${wowBasePath}/search`;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
1
32
|
//#region src/blizzard-api.ts
|
|
2
33
|
const endpoints = {
|
|
3
34
|
cn: {
|
|
@@ -22,27 +53,16 @@ const endpoints = {
|
|
|
22
53
|
}
|
|
23
54
|
};
|
|
24
55
|
/**
|
|
25
|
-
|
|
26
56
|
* Get the Blizzard API configuration for a given region.
|
|
27
|
-
|
|
28
57
|
* @template T The region of the Blizzard API.
|
|
29
|
-
|
|
30
58
|
* @param origin The region of the Blizzard API.
|
|
31
|
-
|
|
32
59
|
* @param locale The locale of the Blizzard API.
|
|
33
|
-
|
|
34
60
|
* @returns The Blizzard API configuration for the given region.
|
|
35
|
-
|
|
36
61
|
* @example
|
|
37
|
-
|
|
38
62
|
* const api = getBlizzardApi('us', 'en_US');
|
|
39
|
-
|
|
40
63
|
* console.log(api.hostname); // 'https://us.api.blizzard.com'
|
|
41
|
-
|
|
42
64
|
* console.log(api.locale); // 'en_US'
|
|
43
|
-
|
|
44
65
|
* console.log(api.origin); // 'us'
|
|
45
|
-
|
|
46
66
|
*/
|
|
47
67
|
function getBlizzardApi(origin, locale) {
|
|
48
68
|
const endpoint = endpoints[origin];
|
|
@@ -54,5 +74,5 @@ function getBlizzardApi(origin, locale) {
|
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
//#endregion
|
|
57
|
-
export { getBlizzardApi };
|
|
77
|
+
export { d3BasePath, d3GameDataBasePath, d3ProfileBasePath, getBlizzardApi, wowBasePath, wowCharacterBasePath, wowMediaBasePath, wowSearchBasePath };
|
|
58
78
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/base.ts","../src/blizzard-api.ts"],"sourcesContent":["/**\r\n * The base request path for the D3 API in the Blizzard API.\r\n */\r\nexport const d3BasePath = 'd3/data';\r\n\r\n/**\r\n * The base request path for profile APIs in the D3 API.\r\n */\r\nexport const d3ProfileBasePath = `d3/profile`;\r\n\r\n/**\r\n * The base request path for game data APIs in the D3 API.\r\n */\r\nexport const d3GameDataBasePath = `data/d3`;\r\n\r\n/**\r\n * The base request path for the Blizzard API for world of warcraft.\r\n */\r\nexport const wowBasePath = '/data/wow';\r\n\r\n/**\r\n * The base request path for the character API for Classic World of Warcraft.\r\n */\r\nexport const wowCharacterBasePath = 'profile/wow/character';\r\n\r\n/**\r\n * The base request path for media in the Blizzard API for world of warcraft.\r\n */\r\nexport const wowMediaBasePath = `${wowBasePath}/media` as const;\r\n\r\n/**\r\n * The base request path for search in the Blizzard API for world of warcraft.\r\n */\r\nexport const wowSearchBasePath = `${wowBasePath}/search` as const;\r\n\r\n/**\r\n * Base search parameters\r\n * orderby The field to order results by.\r\n * _page The page number to return.\r\n * @example\r\n * const params: BaseSearchParameters = {\r\n * orderby: 'name',\r\n * _page: 1,\r\n * };\r\n */\r\nexport interface BaseSearchParameters {\r\n _page?: number;\r\n orderby?: Array<string> | string;\r\n}\r\n/**\r\n * The standard structure to represent a World of Warcraft Character.\r\n */\r\nexport interface Character extends NameIdKey {\r\n realm: Realm;\r\n}\r\n\r\n/**\r\n * A record containing the RGBA values of a color.\r\n */\r\nexport interface Color {\r\n a: number;\r\n b: number;\r\n g: number;\r\n r: number;\r\n}\r\n\r\n/**\r\n * The faction associated with a character or entity in World of Warcraft.\r\n */\r\nexport interface Faction {\r\n name: string;\r\n type: Factions;\r\n}\r\n\r\n/**\r\n * The playable factions in World of Warcraft.\r\n */\r\nexport type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';\r\n\r\n/**\r\n * The gender associated with a character or entity in World of Warcraft.\r\n */\r\nexport interface Gender {\r\n name: string;\r\n type: 'FEMALE' | 'MALE';\r\n}\r\n\r\n/**\r\n * The playable gender names/descriptions in World of Warcraft.\r\n */\r\nexport interface GenderName {\r\n female: null | string;\r\n male: null | string;\r\n}\r\n\r\nexport interface Href {\r\n href: string;\r\n}\r\n\r\n/**\r\n * Base record interface containing key.href property that often appear in Blizzard API responses.\r\n */\r\nexport interface KeyBase {\r\n key: Href;\r\n}\r\n\r\n/**\r\n * The media asset associated with a character or entity in World of Warcraft.\r\n */\r\nexport interface MediaAsset {\r\n file_data_id?: number;\r\n key: string;\r\n value: string;\r\n}\r\n\r\n/**\r\n * Base record interface containing name and id properties that often appear together in Blizzard API responses.\r\n */\r\nexport interface NameId {\r\n id: number;\r\n name: string;\r\n}\r\n\r\n/**\r\n * Base record containing both {@link KeyBase} and {@link NameId} interfaces.\r\n */\r\nexport interface NameIdKey extends KeyBase, NameId {}\r\n\r\n/**\r\n * The standard structure to represent a World of Warcraft Realm.\r\n */\r\nexport interface Realm extends KeyBase {\r\n id: number;\r\n name?: string;\r\n slug: string;\r\n}\r\n\r\n/**\r\n * Base interface for Blizzard API responses.\r\n */\r\nexport interface ResponseBase {\r\n _links: {\r\n self: Href;\r\n };\r\n}\r\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"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blizzard-api/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Putro",
|
|
6
6
|
"description": "The core helpers used by all @blizzard-api/* packages.",
|
|
7
7
|
"repository": "https://github.com/Pewtro/blizzard-api/tree/main/packages/core",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "^
|
|
10
|
+
"node": "^20.19.0 || ^22.13.0 || >=24"
|
|
11
11
|
},
|
|
12
12
|
"module": "./dist/index.js",
|
|
13
13
|
"types": "./dist/index.d.ts",
|