@blizzard-api/d3 0.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/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @blizzard-api/d3
2
+
3
+ This package aims to make it easier for you to integrate with the Blizzard Battle.net API, specifically for Diablo 3.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm i @blizzard-api/core @blizzard-api/d3
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ You can get paths, namespaces, parameters and more for a specific endpoint by calling it from the `d3` export.
14
+
15
+ ```ts
16
+ import { d3 } from "@blizzard-api/d3"
17
+
18
+ const achievement = d3.achievement(123);
19
+ ^ { path: string, namespace: string }
20
+ ```
21
+
22
+ 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
+
24
+ ```ts
25
+ import type { AchievementResponse } from '@blizzard-api/d3';
26
+ ```
27
+
28
+ If you simply want to use the existing object, you can use the helper from `@blizzard-api/core` like so:
29
+
30
+ ```ts
31
+ import { d3 } from "@blizzard-api/d3"
32
+
33
+ const achievement = d3.achievement(123);
34
+ ^ { path: string, namespace: string }
35
+ type AchievementResponse = ExtractResourceType<typeof achievement>;
36
+ ```
37
+
38
+ If you don't want to use the exported d3 object, you can also access the functions directly:
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>;
46
+ ```
47
+
48
+ ## Types
49
+
50
+ 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
+
52
+ ### Client
53
+
54
+ While this package is made to function on it's own, it performs even better when combined with `@blizzard-api/client` where you can easily request data combining the two libraries.
55
+
56
+ ```ts
57
+ import { createBlizzardApiClient } from '@blizzard-api/client';
58
+ import { d3 } from '@blizzard-api/d3';
59
+
60
+ const client = await createBlizzardApiClient({
61
+ key: 'environment.blizzardClientId',
62
+ secret: 'environment.blizzardClientSecret',
63
+ origin: 'eu',
64
+ });
65
+
66
+ //Response will automatically be typed with the appropriate values
67
+ const response = await client.sendRequest(d3.commodities());
68
+
69
+ console.log(response.data);
70
+ ^ typeof AuctionHouseCommoditiesResponse
71
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,223 @@
1
+ "use strict";
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);
19
+
20
+ // src/index.ts
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);
46
+
47
+ // src/base.ts
48
+ var base = "d3/data";
49
+ var profileBase = `d3/profile`;
50
+ var gameDataBase = `data/d3`;
51
+
52
+ // src/act/act.ts
53
+ function act(actId) {
54
+ return {
55
+ path: `${base}/act/${actId}`
56
+ };
57
+ }
58
+ function actIndex() {
59
+ return {
60
+ path: `${base}/act`
61
+ };
62
+ }
63
+
64
+ // src/artisan-and-recipe/artisan-and-recipe.ts
65
+ function artisan(artisanSlug) {
66
+ return {
67
+ path: `${base}/artisan/${artisanSlug}`
68
+ };
69
+ }
70
+ function recipe(artisanSlug, recipeSlug) {
71
+ return {
72
+ path: `${base}/artisan/${artisanSlug}/recipe/${recipeSlug}`
73
+ };
74
+ }
75
+
76
+ // src/character-class-and-skill/character-class-and-skill.ts
77
+ function characterClass(characterClassSlug) {
78
+ return {
79
+ path: `${base}/character-class/${characterClassSlug}`
80
+ };
81
+ }
82
+ function skill(characterClassSlug, skillSlug) {
83
+ return {
84
+ path: `${base}/hero/${characterClassSlug}/skill/${skillSlug}`
85
+ };
86
+ }
87
+
88
+ // src/follower/follower.ts
89
+ function follower(followerSlug) {
90
+ return {
91
+ path: `${base}/follower/${followerSlug}`
92
+ };
93
+ }
94
+
95
+ // src/game-data/game-data.ts
96
+ function seasonIndex() {
97
+ return {
98
+ path: `${gameDataBase}/season`
99
+ };
100
+ }
101
+ function season(id) {
102
+ return {
103
+ path: `${gameDataBase}/season/${id}`
104
+ };
105
+ }
106
+ function seasonLeaderboard(id, leaderboard) {
107
+ return {
108
+ path: `${gameDataBase}/season/${id}/leaderboard/${leaderboard}`
109
+ };
110
+ }
111
+ function eraIndex() {
112
+ return {
113
+ path: `${gameDataBase}/era`
114
+ };
115
+ }
116
+ function era(id) {
117
+ return {
118
+ path: `${gameDataBase}/era/${id}`
119
+ };
120
+ }
121
+ function eraLeaderboard(id, leaderboard) {
122
+ return {
123
+ path: `${gameDataBase}/era/${id}/leaderboard/${leaderboard}`
124
+ };
125
+ }
126
+
127
+ // src/item/item.ts
128
+ function item(itemSlugAndId) {
129
+ return {
130
+ path: `${base}/item/${itemSlugAndId}`
131
+ };
132
+ }
133
+
134
+ // src/item-type/item-type.ts
135
+ function itemTypeIndex() {
136
+ return {
137
+ path: `${base}/item-type`
138
+ };
139
+ }
140
+ function itemType(itemTypeSlug) {
141
+ return {
142
+ path: `${base}/item-type/${itemTypeSlug}`
143
+ };
144
+ }
145
+
146
+ // src/profile/profile.ts
147
+ function account(battleTag) {
148
+ return {
149
+ path: `${profileBase}/${battleTag}`
150
+ };
151
+ }
152
+ function accountHero(battleTag, heroId) {
153
+ return {
154
+ path: `${profileBase}/${battleTag}/hero/${heroId}`
155
+ };
156
+ }
157
+ function accountHeroItems(battleTag, heroId) {
158
+ return {
159
+ path: `${profileBase}/${battleTag}/hero/${heroId}/items`
160
+ };
161
+ }
162
+ function accountHeroFollowerItems(battleTag, heroId) {
163
+ return {
164
+ path: `${profileBase}/${battleTag}/hero/${heroId}/follower-items`
165
+ };
166
+ }
167
+
168
+ // src/index.ts
169
+ var d3 = {
170
+ //Act
171
+ act,
172
+ actIndex,
173
+ //Artisan and Recipe
174
+ artisan,
175
+ recipe,
176
+ //Follower
177
+ follower,
178
+ //Character Class and Skill
179
+ characterClass,
180
+ skill,
181
+ //Item Type
182
+ itemType,
183
+ itemTypeIndex,
184
+ //Item
185
+ item,
186
+ //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
+ account,
202
+ accountHero,
203
+ accountHeroFollowerItems,
204
+ accountHeroItems,
205
+ act,
206
+ actIndex,
207
+ artisan,
208
+ characterClass,
209
+ d3,
210
+ era,
211
+ eraIndex,
212
+ eraLeaderboard,
213
+ follower,
214
+ item,
215
+ itemType,
216
+ itemTypeIndex,
217
+ recipe,
218
+ season,
219
+ seasonIndex,
220
+ seasonLeaderboard,
221
+ skill
222
+ });
223
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../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/item.ts","../src/item-type/item-type.ts","../src/profile/profile.ts"],"sourcesContent":["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 { item } from './item/item';\r\nimport { itemType, itemTypeIndex } from './item-type/item-type';\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 accountHeroItems,\r\n accountHeroFollowerItems,\r\n //Game Data\r\n seasonIndex,\r\n season,\r\n seasonLeaderboard,\r\n eraIndex,\r\n era,\r\n eraLeaderboard,\r\n};\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//Follower\r\nexport * from './follower/follower';\r\nexport type * from './follower/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//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//Game Data\r\nexport * from './game-data/game-data';\r\nexport type * from './game-data/types';\r\n","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 { 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 { 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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,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,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