@blizzard-api/core 4.1.2 → 4.1.3
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 +27 -27
- package/dist/index.js.map +1 -1
- package/package.json +27 -27
package/dist/index.d.ts
CHANGED
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The base request path for the D3 API in the Blizzard API.
|
|
4
4
|
*/
|
|
5
|
-
declare const d3BasePath = "d3/data";
|
|
5
|
+
export declare const d3BasePath = "d3/data";
|
|
6
6
|
/**
|
|
7
7
|
* The base request path for profile APIs in the D3 API.
|
|
8
8
|
*/
|
|
9
|
-
declare const d3ProfileBasePath = "d3/profile";
|
|
9
|
+
export declare const d3ProfileBasePath = "d3/profile";
|
|
10
10
|
/**
|
|
11
11
|
* The base request path for game data APIs in the D3 API.
|
|
12
12
|
*/
|
|
13
|
-
declare const d3GameDataBasePath = "data/d3";
|
|
13
|
+
export declare const d3GameDataBasePath = "data/d3";
|
|
14
14
|
/**
|
|
15
15
|
* The base request path for the Blizzard API for world of warcraft.
|
|
16
16
|
*/
|
|
17
|
-
declare const wowBasePath = "/data/wow";
|
|
17
|
+
export declare const wowBasePath = "/data/wow";
|
|
18
18
|
/**
|
|
19
19
|
* The base request path for the character API for Classic World of Warcraft.
|
|
20
20
|
*/
|
|
21
|
-
declare const wowCharacterBasePath = "profile/wow/character";
|
|
21
|
+
export declare const wowCharacterBasePath = "profile/wow/character";
|
|
22
22
|
/**
|
|
23
23
|
* The base request path for media in the Blizzard API for world of warcraft.
|
|
24
24
|
*/
|
|
25
|
-
declare const wowMediaBasePath: "/data/wow/media";
|
|
25
|
+
export declare const wowMediaBasePath: "/data/wow/media";
|
|
26
26
|
/**
|
|
27
27
|
* The base request path for search in the Blizzard API for world of warcraft.
|
|
28
28
|
*/
|
|
29
|
-
declare const wowSearchBasePath: "/data/wow/search";
|
|
29
|
+
export declare const wowSearchBasePath: "/data/wow/search";
|
|
30
30
|
/**
|
|
31
31
|
* Base search parameters
|
|
32
32
|
* orderby The field to order results by.
|
|
@@ -37,20 +37,20 @@ declare const wowSearchBasePath: "/data/wow/search";
|
|
|
37
37
|
* _page: 1,
|
|
38
38
|
* };
|
|
39
39
|
*/
|
|
40
|
-
interface BaseSearchParameters {
|
|
40
|
+
export interface BaseSearchParameters {
|
|
41
41
|
_page?: number;
|
|
42
42
|
orderby?: Array<string> | string;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* The standard structure to represent a World of Warcraft Character.
|
|
46
46
|
*/
|
|
47
|
-
interface Character extends NameIdKey {
|
|
47
|
+
export interface Character extends NameIdKey {
|
|
48
48
|
realm: Realm;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* A record containing the RGBA values of a color.
|
|
52
52
|
*/
|
|
53
|
-
interface Color {
|
|
53
|
+
export interface Color {
|
|
54
54
|
a: number;
|
|
55
55
|
b: number;
|
|
56
56
|
g: number;
|
|
@@ -59,45 +59,45 @@ interface Color {
|
|
|
59
59
|
/**
|
|
60
60
|
* The faction associated with a character or entity in World of Warcraft.
|
|
61
61
|
*/
|
|
62
|
-
interface Faction {
|
|
62
|
+
export interface Faction {
|
|
63
63
|
name: string;
|
|
64
64
|
type: Factions;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* The playable factions in World of Warcraft.
|
|
68
68
|
*/
|
|
69
|
-
type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';
|
|
69
|
+
export type Factions = 'ALLIANCE' | 'HORDE' | 'NEUTRAL';
|
|
70
70
|
/**
|
|
71
71
|
* The playable factions at max level in World of Warcraft.
|
|
72
72
|
*/
|
|
73
|
-
type NonNeutralFactions = 'ALLIANCE' | 'HORDE';
|
|
73
|
+
export type NonNeutralFactions = 'ALLIANCE' | 'HORDE';
|
|
74
74
|
/**
|
|
75
75
|
* The gender associated with a character or entity in World of Warcraft.
|
|
76
76
|
*/
|
|
77
|
-
interface Gender {
|
|
77
|
+
export interface Gender {
|
|
78
78
|
name: string;
|
|
79
79
|
type: 'FEMALE' | 'MALE';
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* The playable gender names/descriptions in World of Warcraft.
|
|
83
83
|
*/
|
|
84
|
-
interface GenderName {
|
|
84
|
+
export interface GenderName {
|
|
85
85
|
female: null | string;
|
|
86
86
|
male: null | string;
|
|
87
87
|
}
|
|
88
|
-
interface Href {
|
|
88
|
+
export interface Href {
|
|
89
89
|
href: string;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Base record interface containing key.href property that often appear in Blizzard API responses.
|
|
93
93
|
*/
|
|
94
|
-
interface KeyBase {
|
|
94
|
+
export interface KeyBase {
|
|
95
95
|
key: Href;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* The media asset associated with a character or entity in World of Warcraft.
|
|
99
99
|
*/
|
|
100
|
-
interface MediaAsset {
|
|
100
|
+
export interface MediaAsset {
|
|
101
101
|
file_data_id?: number;
|
|
102
102
|
key: string;
|
|
103
103
|
value: string;
|
|
@@ -105,33 +105,33 @@ interface MediaAsset {
|
|
|
105
105
|
/**
|
|
106
106
|
* Base record interface containing name and id properties that often appear together in Blizzard API responses.
|
|
107
107
|
*/
|
|
108
|
-
interface NameId {
|
|
108
|
+
export interface NameId {
|
|
109
109
|
id: number;
|
|
110
110
|
name: string;
|
|
111
111
|
}
|
|
112
|
-
interface NullishNameId {
|
|
112
|
+
export interface NullishNameId {
|
|
113
113
|
id: number;
|
|
114
114
|
name: null | string;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Base record containing both {@link KeyBase} and {@link NameId} interfaces.
|
|
118
118
|
*/
|
|
119
|
-
interface NameIdKey extends KeyBase, NameId {}
|
|
120
|
-
interface NullishNameIdKey extends Omit<NameIdKey, 'name'> {
|
|
119
|
+
export interface NameIdKey extends KeyBase, NameId {}
|
|
120
|
+
export interface NullishNameIdKey extends Omit<NameIdKey, 'name'> {
|
|
121
121
|
name: null | string;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* The standard structure to represent a World of Warcraft Realm.
|
|
125
125
|
*/
|
|
126
|
-
interface Realm extends KeyBase {
|
|
126
|
+
export interface Realm extends KeyBase {
|
|
127
127
|
id: number;
|
|
128
|
-
name?: string;
|
|
128
|
+
name?: null | string;
|
|
129
129
|
slug: string;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Base interface for Blizzard API responses.
|
|
133
133
|
*/
|
|
134
|
-
interface ResponseBase {
|
|
134
|
+
export interface ResponseBase {
|
|
135
135
|
_links: {
|
|
136
136
|
self: Href;
|
|
137
137
|
};
|
|
@@ -186,7 +186,7 @@ interface BlizzardApi<T extends Origins> {
|
|
|
186
186
|
* console.log(api.locale); // 'en_US'
|
|
187
187
|
* console.log(api.origin); // 'us'
|
|
188
188
|
*/
|
|
189
|
-
declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _regionLocaleMap)[typeof origin][number]): BlizzardApi<typeof origin>;
|
|
189
|
+
export declare function getBlizzardApi<T extends Origins>(origin: T, locale?: (typeof _regionLocaleMap)[typeof origin][number]): BlizzardApi<typeof origin>;
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region src/namespace.d.ts
|
|
192
192
|
/**
|
|
@@ -253,5 +253,5 @@ interface SearchResponseWithoutResults {
|
|
|
253
253
|
resultCountCapped?: boolean;
|
|
254
254
|
}
|
|
255
255
|
//#endregion
|
|
256
|
-
export {
|
|
256
|
+
export type { BlizzardNamespaces, ExtractResourceType, Locales, Origins, ProtectedResource, Resource, SearchResponseWithoutResults };
|
|
257
257
|
//# 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 */\n// eslint-disable-next-line unicorn/consistent-compound-words\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\nexport interface NullishNameId {\n id: number;\n name: null | 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';\
|
|
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 */\n// eslint-disable-next-line unicorn/consistent-compound-words\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\nexport interface NullishNameId {\n id: number;\n name: null | 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?: null | 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';\n\n/**\n * A record of regions and their supported locales.\n */\nconst _regionLocaleMap = {\n cn: ['zh_CN'],\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'it_IT'],\n kr: ['ko_KR', 'en_GB', 'en_US'],\n tw: ['zh_TW', 'en_GB', 'en_US'],\n us: ['en_US', 'es_MX', 'pt_BR'],\n} as const satisfies Record<Origins, Array<Locales>>;\n\n/**\n * A record of Blizzard API configurations by region.\n */\ninterface BlizzardApiByRegion {\n cn: BlizzardApiDefault<'cn'>;\n eu: BlizzardApiDefault<'eu'>;\n kr: BlizzardApiDefault<'kr'>;\n tw: BlizzardApiDefault<'tw'>;\n us: BlizzardApiDefault<'us'>;\n}\n\n/**\n * The default Blizzard API configuration for each region.\n */\ninterface BlizzardApiDefault<T extends Origins> {\n defaultLocale: (typeof _regionLocaleMap)[T][number];\n hostname: T extends 'cn' ? 'https://gateway.battlenet.com.cn' : `https://${T}.api.blizzard.com`;\n}\n\nconst endpoints: BlizzardApiByRegion = {\n cn: {\n defaultLocale: 'zh_CN',\n hostname: 'https://gateway.battlenet.com.cn',\n },\n eu: {\n defaultLocale: 'en_GB',\n hostname: 'https://eu.api.blizzard.com',\n },\n kr: {\n defaultLocale: 'ko_KR',\n hostname: 'https://kr.api.blizzard.com',\n },\n tw: {\n defaultLocale: 'zh_TW',\n hostname: 'https://tw.api.blizzard.com',\n },\n us: {\n defaultLocale: 'en_US',\n hostname: 'https://us.api.blizzard.com',\n },\n};\n\n/**\n * A Blizzard API configuration object.\n * @template T The region of the Blizzard API.\n */\ninterface BlizzardApi<T extends Origins> {\n hostname: BlizzardApiDefault<Origins>['hostname'];\n locale: (typeof _regionLocaleMap)[T][number];\n origin: Origins;\n}\n\n/**\n * Get the Blizzard API configuration for a given region.\n * @template T The region of the Blizzard API.\n * @param origin The region of the Blizzard API.\n * @param locale The locale of the Blizzard API.\n * @returns The Blizzard API configuration for the given region.\n * @example\n * const api = getBlizzardApi('us', 'en_US');\n * console.log(api.hostname); // 'https://us.api.blizzard.com'\n * console.log(api.locale); // 'en_US'\n * console.log(api.origin); // 'us'\n */\nexport function getBlizzardApi<T extends Origins>(\n origin: T,\n locale?: (typeof _regionLocaleMap)[typeof origin][number],\n): BlizzardApi<typeof origin> {\n const endpoint = endpoints[origin];\n\n return {\n hostname: endpoint.hostname,\n locale: locale ?? endpoint.defaultLocale,\n origin,\n };\n}\n"],"mappings":";;;;AAGA,MAAa,aAAa;;;;AAK1B,MAAa,oBAAoB;;;;AAMjC,MAAa,qBAAqB;;;;AAKlC,MAAa,cAAc;;;;AAK3B,MAAa,uBAAuB;;;;AAKpC,MAAa,mBAAmB,GAAG,YAAY;;;;AAK/C,MAAa,oBAAoB,GAAG,YAAY;;;ACFhD,MAAM,YAAiC;CACrC,IAAI;EACF,eAAe;EACf,UAAU;CACZ;CACA,IAAI;EACF,eAAe;EACf,UAAU;CACZ;CACA,IAAI;EACF,eAAe;EACf,UAAU;CACZ;CACA,IAAI;EACF,eAAe;EACf,UAAU;CACZ;CACA,IAAI;EACF,eAAe;EACf,UAAU;CACZ;AACF;;;;;;;;;;;;;AAwBA,SAAgB,eACd,QACA,QAC4B;CAC5B,MAAM,WAAW,UAAU;CAE3B,OAAO;EACL,UAAU,SAAS;EACnB,QAAQ,UAAU,SAAS;EAC3B;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blizzard-api/core",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
|
+
"description": "The core helpers used by all @blizzard-api/* packages.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api",
|
|
7
|
+
"battle.net",
|
|
8
|
+
"battlenet",
|
|
9
|
+
"blizzard",
|
|
10
|
+
"bnet",
|
|
11
|
+
"classic",
|
|
12
|
+
"d3",
|
|
13
|
+
"diablo",
|
|
14
|
+
"hearthstone",
|
|
15
|
+
"hs",
|
|
16
|
+
"retail",
|
|
17
|
+
"sc2",
|
|
18
|
+
"starcraft",
|
|
19
|
+
"warcraft",
|
|
20
|
+
"world of warcraft",
|
|
21
|
+
"wow"
|
|
22
|
+
],
|
|
4
23
|
"license": "MIT",
|
|
5
24
|
"author": "Putro",
|
|
6
|
-
"description": "The core helpers used by all @blizzard-api/* packages.",
|
|
7
25
|
"repository": {
|
|
8
26
|
"type": "git",
|
|
9
27
|
"url": "git+https://github.com/Pewtro/blizzard-api.git",
|
|
10
28
|
"directory": "packages/core"
|
|
11
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
12
33
|
"type": "module",
|
|
13
|
-
"
|
|
14
|
-
"node": "^22.13.0 || ^24 || ^26"
|
|
15
|
-
},
|
|
34
|
+
"sideEffects": false,
|
|
16
35
|
"module": "./dist/index.js",
|
|
17
36
|
"types": "./dist/index.d.ts",
|
|
18
37
|
"exports": {
|
|
@@ -22,30 +41,11 @@
|
|
|
22
41
|
"default": "./dist/index.js"
|
|
23
42
|
}
|
|
24
43
|
},
|
|
25
|
-
"files": [
|
|
26
|
-
"dist"
|
|
27
|
-
],
|
|
28
|
-
"sideEffects": false,
|
|
29
|
-
"keywords": [
|
|
30
|
-
"blizzard",
|
|
31
|
-
"battlenet",
|
|
32
|
-
"battle.net",
|
|
33
|
-
"bnet",
|
|
34
|
-
"api",
|
|
35
|
-
"world of warcraft",
|
|
36
|
-
"warcraft",
|
|
37
|
-
"wow",
|
|
38
|
-
"classic",
|
|
39
|
-
"retail",
|
|
40
|
-
"starcraft",
|
|
41
|
-
"sc2",
|
|
42
|
-
"diablo",
|
|
43
|
-
"d3",
|
|
44
|
-
"hs",
|
|
45
|
-
"hearthstone"
|
|
46
|
-
],
|
|
47
44
|
"dependencies": {},
|
|
48
45
|
"devDependencies": {},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": "^22.13.0 || ^24 || ^26"
|
|
48
|
+
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown",
|
|
51
51
|
"dev": "tsdown --watch",
|