@blizzard-api/d3 0.1.0 → 0.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/README.md +18 -14
- package/dist/index.cjs +37 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -213
- package/dist/index.d.ts +213 -213
- package/dist/index.js +13 -32
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -14,38 +14,42 @@ You can get paths, namespaces, parameters and more for a specific endpoint by ca
|
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { d3 } from "@blizzard-api/d3"
|
|
17
|
+
//or
|
|
18
|
+
import d3 from "@blizzard-api/d3"
|
|
17
19
|
|
|
18
20
|
const achievement = d3.achievement(123);
|
|
19
|
-
^ { path: string, namespace
|
|
21
|
+
^ { path: string, namespace?: string, parameters?: Record<string, never> }
|
|
20
22
|
```
|
|
21
23
|
|
|
24
|
+
If you don't want to use the exported d3 object, you can also access the functions directly:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { achievement } from "@blizzard-api/d3"
|
|
28
|
+
|
|
29
|
+
const achi = achievement(123);
|
|
30
|
+
^ { path: string, namespace?: string, parameters?: Record<string, never> }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Types
|
|
34
|
+
|
|
22
35
|
If you need the response types, they are also exported with "Response" appended, so to get the response type from the above code, you can import it like this:
|
|
23
36
|
|
|
24
37
|
```ts
|
|
25
38
|
import type { AchievementResponse } from '@blizzard-api/d3';
|
|
26
39
|
```
|
|
27
40
|
|
|
28
|
-
If you simply want to use the existing object, you can use the helper from `@blizzard-api/core` like so:
|
|
41
|
+
If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:
|
|
29
42
|
|
|
30
43
|
```ts
|
|
31
44
|
import { d3 } from "@blizzard-api/d3"
|
|
32
45
|
|
|
33
46
|
const achievement = d3.achievement(123);
|
|
34
|
-
^ { path: string, namespace
|
|
35
|
-
type AchievementResponse = ExtractResourceType<typeof achievement>;
|
|
36
|
-
```
|
|
47
|
+
^ { path: string, namespace?: string, parameters?: Record<string, never> }
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
import { achievement } from "@blizzard-api/d3"
|
|
42
|
-
|
|
43
|
-
const achi = achievement(123);
|
|
44
|
-
^ { path: string, namespace: string }
|
|
45
|
-
type AchievementResponse = ExtractResourceType<typeof achi>;
|
|
49
|
+
type AchievementResponse = ExtractResourceType<typeof achievement>;
|
|
46
50
|
```
|
|
47
51
|
|
|
48
|
-
## Types
|
|
52
|
+
## Notes on Types
|
|
49
53
|
|
|
50
54
|
The types are manually created from using the Blizzard API documentation, and are as accurate as possible with smoke testing each endpoint. However, no-one is perfect so there is likely be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.
|
|
51
55
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
account: () => account,
|
|
24
|
-
accountHero: () => accountHero,
|
|
25
|
-
accountHeroFollowerItems: () => accountHeroFollowerItems,
|
|
26
|
-
accountHeroItems: () => accountHeroItems,
|
|
27
|
-
act: () => act,
|
|
28
|
-
actIndex: () => actIndex,
|
|
29
|
-
artisan: () => artisan,
|
|
30
|
-
characterClass: () => characterClass,
|
|
31
|
-
d3: () => d3,
|
|
32
|
-
era: () => era,
|
|
33
|
-
eraIndex: () => eraIndex,
|
|
34
|
-
eraLeaderboard: () => eraLeaderboard,
|
|
35
|
-
follower: () => follower,
|
|
36
|
-
item: () => item,
|
|
37
|
-
itemType: () => itemType,
|
|
38
|
-
itemTypeIndex: () => itemTypeIndex,
|
|
39
|
-
recipe: () => recipe,
|
|
40
|
-
season: () => season,
|
|
41
|
-
seasonIndex: () => seasonIndex,
|
|
42
|
-
seasonLeaderboard: () => seasonLeaderboard,
|
|
43
|
-
skill: () => skill
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(src_exports);
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
46
4
|
|
|
47
5
|
// src/base.ts
|
|
48
6
|
var base = "d3/data";
|
|
@@ -124,13 +82,6 @@ function eraLeaderboard(id, leaderboard) {
|
|
|
124
82
|
};
|
|
125
83
|
}
|
|
126
84
|
|
|
127
|
-
// src/item/item.ts
|
|
128
|
-
function item(itemSlugAndId) {
|
|
129
|
-
return {
|
|
130
|
-
path: `${base}/item/${itemSlugAndId}`
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
85
|
// src/item-type/item-type.ts
|
|
135
86
|
function itemTypeIndex() {
|
|
136
87
|
return {
|
|
@@ -143,6 +94,13 @@ function itemType(itemTypeSlug) {
|
|
|
143
94
|
};
|
|
144
95
|
}
|
|
145
96
|
|
|
97
|
+
// src/item/item.ts
|
|
98
|
+
function item(itemSlugAndId) {
|
|
99
|
+
return {
|
|
100
|
+
path: `${base}/item/${itemSlugAndId}`
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
146
104
|
// src/profile/profile.ts
|
|
147
105
|
function account(battleTag) {
|
|
148
106
|
return {
|
|
@@ -184,40 +142,41 @@ var d3 = {
|
|
|
184
142
|
//Item
|
|
185
143
|
item,
|
|
186
144
|
//Profile
|
|
187
|
-
account,
|
|
188
|
-
accountHero,
|
|
189
|
-
accountHeroItems,
|
|
190
|
-
accountHeroFollowerItems,
|
|
191
|
-
//Game Data
|
|
192
|
-
seasonIndex,
|
|
193
|
-
season,
|
|
194
|
-
seasonLeaderboard,
|
|
195
|
-
eraIndex,
|
|
196
|
-
era,
|
|
197
|
-
eraLeaderboard
|
|
198
|
-
};
|
|
199
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
200
|
-
0 && (module.exports = {
|
|
201
145
|
account,
|
|
202
146
|
accountHero,
|
|
203
147
|
accountHeroFollowerItems,
|
|
204
148
|
accountHeroItems,
|
|
205
|
-
|
|
206
|
-
actIndex,
|
|
207
|
-
artisan,
|
|
208
|
-
characterClass,
|
|
209
|
-
d3,
|
|
149
|
+
//Game Data
|
|
210
150
|
era,
|
|
211
151
|
eraIndex,
|
|
212
152
|
eraLeaderboard,
|
|
213
|
-
follower,
|
|
214
|
-
item,
|
|
215
|
-
itemType,
|
|
216
|
-
itemTypeIndex,
|
|
217
|
-
recipe,
|
|
218
153
|
season,
|
|
219
154
|
seasonIndex,
|
|
220
|
-
seasonLeaderboard
|
|
221
|
-
|
|
222
|
-
|
|
155
|
+
seasonLeaderboard
|
|
156
|
+
};
|
|
157
|
+
var src_default = d3;
|
|
158
|
+
|
|
159
|
+
exports.account = account;
|
|
160
|
+
exports.accountHero = accountHero;
|
|
161
|
+
exports.accountHeroFollowerItems = accountHeroFollowerItems;
|
|
162
|
+
exports.accountHeroItems = accountHeroItems;
|
|
163
|
+
exports.act = act;
|
|
164
|
+
exports.actIndex = actIndex;
|
|
165
|
+
exports.artisan = artisan;
|
|
166
|
+
exports.characterClass = characterClass;
|
|
167
|
+
exports.d3 = d3;
|
|
168
|
+
exports.default = src_default;
|
|
169
|
+
exports.era = era;
|
|
170
|
+
exports.eraIndex = eraIndex;
|
|
171
|
+
exports.eraLeaderboard = eraLeaderboard;
|
|
172
|
+
exports.follower = follower;
|
|
173
|
+
exports.item = item;
|
|
174
|
+
exports.itemType = itemType;
|
|
175
|
+
exports.itemTypeIndex = itemTypeIndex;
|
|
176
|
+
exports.recipe = recipe;
|
|
177
|
+
exports.season = season;
|
|
178
|
+
exports.seasonIndex = seasonIndex;
|
|
179
|
+
exports.seasonLeaderboard = seasonLeaderboard;
|
|
180
|
+
exports.skill = skill;
|
|
181
|
+
//# sourceMappingURL=out.js.map
|
|
223
182
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/base.ts","../src/act/act.ts","../src/artisan-and-recipe/artisan-and-recipe.ts","../src/character-class-and-skill/character-class-and-skill.ts","../src/follower/follower.ts","../src/game-data/game-data.ts","../src/item-type/item-type.ts","../src/item/item.ts","../src/profile/profile.ts","../src/index.ts"],"names":[],"mappings":";AAAO,IAAM,OAAO;AAEb,IAAM,cAAc;AAGpB,IAAM,eAAe;;;ACDrB,SAAS,IAAI,OAAsC;AACxD,SAAO;AAAA,IACL,MAAM,GAAG,IAAI,QAAQ,KAAK;AAAA,EAC5B;AACF;AAEO,SAAS,WAAuC;AACrD,SAAO;AAAA,IACL,MAAM,GAAG,IAAI;AAAA,EACf;AACF;;;ACVO,SAAS,QAAQ,aAAgD;AACtE,SAAO;AAAA,IACL,MAAM,GAAG,IAAI,YAAY,WAAW;AAAA,EACtC;AACF;AAEO,SAAS,OAAO,aAAqB,YAA8C;AACxF,SAAO;AAAA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AAAA,EACrC;AACF;;;ACJO,SAAS,QAAQ,WAA8C;AACpE,SAAO;AAAA,IACL,MAAM,GAAG,WAAW,IAAI,SAAS;AAAA,EACnC;AACF;AAEO,SAAS,YAAY,WAAmB,QAA+C;AAC5F,SAAO;AAAA,IACL,MAAM,GAAG,WAAW,IAAI,SAAS,SAAS,MAAM;AAAA,EAClD;AACF;AAEO,SAAS,iBAAiB,WAAmB,QAA+C;AACjG,SAAO;AAAA,IACL,MAAM,GAAG,WAAW,IAAI,SAAS,SAAS,MAAM;AAAA,EAClD;AACF;AAEO,SAAS,yBACd,WACA,QAC4C;AAC5C,SAAO;AAAA,IACL,MAAM,GAAG,WAAW,IAAI,SAAS,SAAS,MAAM;AAAA,EAClD;AACF;;;ACpBO,IAAM,KAAK;AAAA;AAAA,EAEhB;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAO,cAAQ","sourcesContent":["export const base = 'd3/data';\r\n\r\nexport const profileBase = `d3/profile`;\r\n\r\n//Why is the game data APIs base root the reverse of the regular base?\r\nexport const gameDataBase = `data/d3`;\r\n\r\n/**\r\n * Base interface for Blizzard API responses.\r\n */\r\nexport interface ResponseBase {\r\n _links: {\r\n self: {\r\n href: string;\r\n };\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { ActIndexResponse, ActResponse } from './types';\r\n\r\nexport function act(actId: number): Resource<ActResponse> {\r\n return {\r\n path: `${base}/act/${actId}`,\r\n };\r\n}\r\n\r\nexport function actIndex(): Resource<ActIndexResponse> {\r\n return {\r\n path: `${base}/act`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { ArtisanResponse, RecipeResponse } from './types';\r\n\r\nexport function artisan(artisanSlug: string): Resource<ArtisanResponse> {\r\n return {\r\n path: `${base}/artisan/${artisanSlug}`,\r\n };\r\n}\r\n\r\nexport function recipe(artisanSlug: string, recipeSlug: string): Resource<RecipeResponse> {\r\n return {\r\n path: `${base}/artisan/${artisanSlug}/recipe/${recipeSlug}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { CharacterClassResponse, SkillResponse } from './types';\r\n\r\nexport function characterClass(characterClassSlug: string): Resource<CharacterClassResponse> {\r\n return {\r\n path: `${base}/character-class/${characterClassSlug}`,\r\n };\r\n}\r\n\r\nexport function skill(characterClassSlug: string, skillSlug: string): Resource<SkillResponse> {\r\n return {\r\n path: `${base}/hero/${characterClassSlug}/skill/${skillSlug}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { FollowerResponse } from './types';\r\n\r\nexport function follower(followerSlug: string): Resource<FollowerResponse> {\r\n return {\r\n path: `${base}/follower/${followerSlug}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { gameDataBase } from '../base';\r\nimport type {\r\n EraIndexResponse,\r\n EraLeaderboardResponse,\r\n EraResponse,\r\n SeasonIndexResponse,\r\n SeasonLeaderboardResponse,\r\n SeasonResponse,\r\n} from './types';\r\n\r\nexport function seasonIndex(): Resource<SeasonIndexResponse> {\r\n return {\r\n path: `${gameDataBase}/season`,\r\n };\r\n}\r\n\r\nexport function season(id: number): Resource<SeasonResponse> {\r\n return {\r\n path: `${gameDataBase}/season/${id}`,\r\n };\r\n}\r\n\r\nexport function seasonLeaderboard(id: number, leaderboard: string): Resource<SeasonLeaderboardResponse> {\r\n return {\r\n path: `${gameDataBase}/season/${id}/leaderboard/${leaderboard}`,\r\n };\r\n}\r\n\r\nexport function eraIndex(): Resource<EraIndexResponse> {\r\n return {\r\n path: `${gameDataBase}/era`,\r\n };\r\n}\r\n\r\nexport function era(id: number): Resource<EraResponse> {\r\n return {\r\n path: `${gameDataBase}/era/${id}`,\r\n };\r\n}\r\n\r\nexport function eraLeaderboard(id: number, leaderboard: string): Resource<EraLeaderboardResponse> {\r\n return {\r\n path: `${gameDataBase}/era/${id}/leaderboard/${leaderboard}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { ItemTypeIndexResponse, ItemTypeResponse } from './types';\r\n\r\nexport function itemTypeIndex(): Resource<Array<ItemTypeIndexResponse>> {\r\n return {\r\n path: `${base}/item-type`,\r\n };\r\n}\r\n\r\nexport function itemType(itemTypeSlug: string): Resource<Array<ItemTypeResponse>> {\r\n return {\r\n path: `${base}/item-type/${itemTypeSlug}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { base } from '../base';\r\nimport type { ItemResponse } from './types';\r\n\r\nexport function item(itemSlugAndId: string): Resource<ItemResponse> {\r\n return {\r\n path: `${base}/item/${itemSlugAndId}`,\r\n };\r\n}\r\n","import type { Resource } from '@blizzard-api/core';\r\nimport { profileBase } from '../base';\r\nimport type { AccountHeroFollowerItemsResponse, AccountHeroResponse, AccountResponse } from './types';\r\n\r\nexport function account(battleTag: string): Resource<AccountResponse> {\r\n return {\r\n path: `${profileBase}/${battleTag}`,\r\n };\r\n}\r\n\r\nexport function accountHero(battleTag: string, heroId: number): Resource<AccountHeroResponse> {\r\n return {\r\n path: `${profileBase}/${battleTag}/hero/${heroId}`,\r\n };\r\n}\r\n\r\nexport function accountHeroItems(battleTag: string, heroId: number): Resource<AccountHeroResponse> {\r\n return {\r\n path: `${profileBase}/${battleTag}/hero/${heroId}/items`,\r\n };\r\n}\r\n\r\nexport function accountHeroFollowerItems(\r\n battleTag: string,\r\n heroId: number,\r\n): Resource<AccountHeroFollowerItemsResponse> {\r\n return {\r\n path: `${profileBase}/${battleTag}/hero/${heroId}/follower-items`,\r\n };\r\n}\r\n","import { act, actIndex } from './act/act';\r\nimport { artisan, recipe } from './artisan-and-recipe/artisan-and-recipe';\r\nimport { characterClass, skill } from './character-class-and-skill/character-class-and-skill';\r\nimport { follower } from './follower/follower';\r\nimport { era, eraIndex, eraLeaderboard, season, seasonIndex, seasonLeaderboard } from './game-data/game-data';\r\nimport { itemType, itemTypeIndex } from './item-type/item-type';\r\nimport { item } from './item/item';\r\nimport { account, accountHero, accountHeroFollowerItems, accountHeroItems } from './profile/profile';\r\n\r\nexport const d3 = {\r\n //Act\r\n act,\r\n actIndex,\r\n //Artisan and Recipe\r\n artisan,\r\n recipe,\r\n //Follower\r\n follower,\r\n //Character Class and Skill\r\n characterClass,\r\n skill,\r\n //Item Type\r\n itemType,\r\n itemTypeIndex,\r\n //Item\r\n item,\r\n //Profile\r\n account,\r\n accountHero,\r\n accountHeroFollowerItems,\r\n accountHeroItems,\r\n //Game Data\r\n era,\r\n eraIndex,\r\n eraLeaderboard,\r\n season,\r\n seasonIndex,\r\n seasonLeaderboard,\r\n};\r\nexport default d3;\r\n\r\n//Act\r\nexport * from './act/act';\r\nexport type * from './act/types';\r\n//Artisan and Recipe\r\nexport * from './artisan-and-recipe/artisan-and-recipe';\r\nexport type * from './artisan-and-recipe/types';\r\n//Character Class and Skill\r\nexport * from './character-class-and-skill/character-class-and-skill';\r\nexport type * from './character-class-and-skill/types';\r\n//Follower\r\nexport * from './follower/follower';\r\nexport type * from './follower/types';\r\n//Game Data\r\nexport * from './game-data/game-data';\r\nexport type * from './game-data/types';\r\n//Item Type\r\nexport * from './item-type/item-type';\r\nexport type * from './item-type/types';\r\n//Item\r\nexport * from './item/item';\r\nexport type * from './item/types';\r\n//Profile\r\nexport * from './profile/profile';\r\nexport type * from './profile/types';\r\n"]}
|