@blizzard-api/hs 3.1.1 → 3.2.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 CHANGED
@@ -1,75 +1,75 @@
1
- # @blizzard-api/hs
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/hs
9
- ```
10
-
11
- ## Usage
12
-
13
- You can get paths, namespaces, parameters and more for a specific endpoint by calling it from the `hs` export.
14
-
15
- ```ts
16
- import { hs } from "@blizzard-api/hs"
17
- //or
18
- import hs from "@blizzard-api/hs"
19
-
20
- const season = hs.allMetadata(123);
21
- ^ Resource<AllMetadataResponse>
22
- ```
23
-
24
- If you don't want to use the exported hs object, you can also access the functions directly:
25
-
26
- ```ts
27
- import { allMetadata } from "@blizzard-api/hs"
28
-
29
- const seasonI = season(123);
30
- ^ Resource<AllMetadataResponse>
31
- ```
32
-
33
- ### Types
34
-
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:
36
-
37
- ```ts
38
- import type { SeasonResponse } from '@blizzard-api/hs';
39
- ```
40
-
41
- If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:
42
-
43
- ```ts
44
- import { hs } from "@blizzard-api/hs"
45
-
46
- const season = hs.allMetadata();
47
- ^ Resource<AllMetadataResponse>
48
-
49
- type AllMetadataResponse = ExtractResourceType<typeof season>;
50
- ```
51
-
52
- ## Notes on Types
53
-
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 to be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.
55
-
56
- ### Client
57
-
58
- 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.
59
-
60
- ```ts
61
- import { createBlizzardApiClient } from '@blizzard-api/client';
62
- import { hs } from '@blizzard-api/hs';
63
-
64
- const client = await createBlizzardApiClient({
65
- key: 'environment.blizzardClientId',
66
- secret: 'environment.blizzardClientSecret',
67
- origin: 'eu',
68
- });
69
-
70
- //Response will automatically be typed with the appropriate values
71
- const response = await client.sendRequest(hs.allMetadata());
72
-
73
- console.log(response);
74
- ^ typeof AllMetadataResponse
75
- ```
1
+ # @blizzard-api/hs
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/hs
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ You can get paths, namespaces, parameters and more for a specific endpoint by calling it from the `hs` export.
14
+
15
+ ```ts
16
+ import { hs } from "@blizzard-api/hs"
17
+ //or
18
+ import hs from "@blizzard-api/hs"
19
+
20
+ const season = hs.allMetadata(123);
21
+ ^ Resource<AllMetadataResponse>
22
+ ```
23
+
24
+ If you don't want to use the exported hs object, you can also access the functions directly:
25
+
26
+ ```ts
27
+ import { allMetadata } from "@blizzard-api/hs"
28
+
29
+ const seasonI = season(123);
30
+ ^ Resource<AllMetadataResponse>
31
+ ```
32
+
33
+ ### Types
34
+
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:
36
+
37
+ ```ts
38
+ import type { SeasonResponse } from '@blizzard-api/hs';
39
+ ```
40
+
41
+ If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:
42
+
43
+ ```ts
44
+ import { hs } from "@blizzard-api/hs"
45
+
46
+ const season = hs.allMetadata();
47
+ ^ Resource<AllMetadataResponse>
48
+
49
+ type AllMetadataResponse = ExtractResourceType<typeof season>;
50
+ ```
51
+
52
+ ## Notes on Types
53
+
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 to be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.
55
+
56
+ ### Client
57
+
58
+ 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.
59
+
60
+ ```ts
61
+ import { createBlizzardApiClient } from '@blizzard-api/client';
62
+ import { hs } from '@blizzard-api/hs';
63
+
64
+ const client = await createBlizzardApiClient({
65
+ key: 'environment.blizzardClientId',
66
+ secret: 'environment.blizzardClientSecret',
67
+ origin: 'eu',
68
+ });
69
+
70
+ //Response will automatically be typed with the appropriate values
71
+ const response = await client.sendRequest(hs.allMetadata());
72
+
73
+ console.log(response);
74
+ ^ typeof AllMetadataResponse
75
+ ```
@@ -1,2 +1,2 @@
1
- import { n as fetchOneCard, t as cardSearch } from "../index-D6Vnhl2r.js";
1
+ import { n as fetchOneCard, t as cardSearch } from "../index-DN5jIXcl.js";
2
2
  export { cardSearch, fetchOneCard };
@@ -1,2 +1,2 @@
1
- import { t as getDeck } from "../index-DctpuvUj.js";
1
+ import { t as getDeck } from "../index-BqB5vnYO.js";
2
2
  export { getDeck };
@@ -12,7 +12,8 @@ function getDeck(options) {
12
12
  return {
13
13
  parameters: {
14
14
  hero: options.hero?.toString(),
15
- ids: options.ids?.join(",")
15
+ ids: options.ids?.join(","),
16
+ sideboardCards: Array.isArray(options.sideboardCards) ? options.sideboardCards.join(",") : options.sideboardCards
16
17
  },
17
18
  path: "hearthstone/deck"
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/decks/index.ts"],"sourcesContent":["import type { Resource } from '@blizzard-api/core';\nimport type { DeckResponse, DeckSearchParameters } from './types';\n\n/**\n * Returns a deck based on the code provided.\n * @param options The options for fetching a deck.\n * @returns The deck resource. See {@link DeckResponse}.\n */\nexport function getDeck(\n options: { code: string } | { hero?: number | string; ids: Array<number | string> },\n): Resource<DeckResponse, DeckSearchParameters> {\n if ('code' in options) {\n return {\n parameters: {\n code: encodeURI(options.code),\n },\n path: 'hearthstone/deck',\n };\n }\n\n return {\n parameters: {\n hero: options.hero?.toString(),\n ids: options.ids?.join(','),\n },\n path: 'hearthstone/deck',\n };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,QACd,SAC8C;CAC9C,IAAI,UAAU,SACZ,OAAO;EACL,YAAY,EACV,MAAM,UAAU,QAAQ,IAAI,EAC9B;EACA,MAAM;CACR;CAGF,OAAO;EACL,YAAY;GACV,MAAM,QAAQ,MAAM,SAAS;GAC7B,KAAK,QAAQ,KAAK,KAAK,GAAG;EAC5B;EACA,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/decks/index.ts"],"sourcesContent":["import type { Resource } from '@blizzard-api/core';\nimport type { DeckResponse, DeckSearchParameters } from './types';\n\n/**\n * Returns a deck based on the code provided.\n * @param options The options for fetching a deck.\n * @returns The deck resource. See {@link DeckResponse}.\n */\nexport function getDeck(\n options:\n | { code: string }\n | {\n hero?: number | string;\n ids: Array<number | string>;\n //Undocumented parameter used for sideboard cards for Zilliax Deluxe 3000 and E.T.C., Band Manager.\n sideboardCards?: `${number}:${number}` | Array<`${number}:${number}`>;\n },\n): Resource<DeckResponse, DeckSearchParameters> {\n if ('code' in options) {\n return {\n parameters: {\n code: encodeURI(options.code),\n },\n path: 'hearthstone/deck',\n };\n }\n\n return {\n parameters: {\n hero: options.hero?.toString(),\n ids: options.ids?.join(','),\n sideboardCards: Array.isArray(options.sideboardCards) ? options.sideboardCards.join(',') : options.sideboardCards,\n },\n path: 'hearthstone/deck',\n };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,QACd,SAQ8C;CAC9C,IAAI,UAAU,SACZ,OAAO;EACL,YAAY,EACV,MAAM,UAAU,QAAQ,IAAI,EAC9B;EACA,MAAM;CACR;CAGF,OAAO;EACL,YAAY;GACV,MAAM,QAAQ,MAAM,SAAS;GAC7B,KAAK,QAAQ,KAAK,KAAK,GAAG;GAC1B,gBAAgB,MAAM,QAAQ,QAAQ,cAAc,IAAI,QAAQ,eAAe,KAAK,GAAG,IAAI,QAAQ;EACrG;EACA,MAAM;CACR;AACF"}
@@ -15,6 +15,7 @@ type DeckSearchParameters = {
15
15
  } | {
16
16
  hero?: string;
17
17
  ids: string;
18
+ sideboardCards?: string;
18
19
  };
19
20
  interface Card {
20
21
  armor?: number;
@@ -88,7 +89,8 @@ declare function getDeck(options: {
88
89
  } | {
89
90
  hero?: number | string;
90
91
  ids: Array<number | string>;
92
+ sideboardCards?: `${number}:${number}` | Array<`${number}:${number}`>;
91
93
  }): Resource<DeckResponse, DeckSearchParameters>;
92
94
  //#endregion
93
95
  export { DeckResponse as n, DeckSearchParameters as r, getDeck as t };
94
- //# sourceMappingURL=index-DctpuvUj.d.ts.map
96
+ //# sourceMappingURL=index-BqB5vnYO.d.ts.map
@@ -35,6 +35,7 @@ interface FetchOneCardResponse {
35
35
  collectible: number;
36
36
  copyOfCardId?: Array<number>;
37
37
  cropImage: null | string;
38
+ factionId?: Array<number>;
38
39
  flavorText: Record<Locales, string> | string;
39
40
  health?: number;
40
41
  id: number;
@@ -88,6 +89,7 @@ interface Card {
88
89
  armor?: number;
89
90
  artistName: null | string;
90
91
  attack?: number;
92
+ bannedFromSideboard?: number;
91
93
  battlegrounds?: Battlegrounds;
92
94
  cardSetId: number;
93
95
  cardTypeId: number;
@@ -96,6 +98,7 @@ interface Card {
96
98
  collectible: number;
97
99
  copyOfCardId?: Array<number>;
98
100
  cropImage: null | string;
101
+ factionId?: Array<number>;
99
102
  flavorText: string;
100
103
  health?: number;
101
104
  id: number;
@@ -112,9 +115,21 @@ interface Card {
112
115
  name: string;
113
116
  parentId?: number;
114
117
  rarityId: null | number;
118
+ runeCost?: {
119
+ blood: number;
120
+ frost: number;
121
+ unholy: number;
122
+ };
123
+ sideboard?: {
124
+ maxSideboardCards: number;
125
+ sideboardCardsCountAsMax: boolean;
126
+ sideboardIgnoresClass: boolean;
127
+ sideboardSubset: string;
128
+ };
115
129
  slug: string;
116
130
  spellSchoolId?: number;
117
131
  text: string;
132
+ touristClassId?: number;
118
133
  }
119
134
  interface MercenaryHero {
120
135
  collectible: number;
@@ -157,4 +172,4 @@ declare function fetchOneCard(id: string, options?: {
157
172
  }>;
158
173
  //#endregion
159
174
  export { CardSearchResponse as a, CardSearchParameters as i, fetchOneCard as n, FetchOneCardResponse as o, BlizzardCardSearchParameters as r, GameMode as s, cardSearch as t };
160
- //# sourceMappingURL=index-D6Vnhl2r.d.ts.map
175
+ //# sourceMappingURL=index-DN5jIXcl.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as SearchOptions, i as CardBackSearchResponse, n as fetchOneCardBack, o as SingleCardBackSearchResponse, r as CardBackSearchParameters, s as SortOptions, t as cardBackSearch } from "./index-DISoZUa9.js";
2
- import { a as CardSearchResponse, i as CardSearchParameters, n as fetchOneCard, o as FetchOneCardResponse, r as BlizzardCardSearchParameters, s as GameMode, t as cardSearch } from "./index-D6Vnhl2r.js";
3
- import { n as DeckResponse, r as DeckSearchParameters, t as getDeck } from "./index-DctpuvUj.js";
2
+ import { a as CardSearchResponse, i as CardSearchParameters, n as fetchOneCard, o as FetchOneCardResponse, r as BlizzardCardSearchParameters, s as GameMode, t as cardSearch } from "./index-DN5jIXcl.js";
3
+ import { n as DeckResponse, r as DeckSearchParameters, t as getDeck } from "./index-BqB5vnYO.js";
4
4
  import { i as SpecificMetadataResponse, n as specificMetadata, r as AllMetadataResponse, t as allMetadata } from "./index-hPXfx360.js";
5
5
  //#region src/index.d.ts
6
6
  declare const hs: {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { cardBackSearch, fetchOneCardBack } from './card-backs/index';\r\nimport { cardSearch, fetchOneCard } from './cards/index';\r\nimport { getDeck } from './decks/index';\r\nimport { allMetadata, specificMetadata } from './metadata/index';\r\n\r\nconst hs = {\r\n //Card Backs\r\n cardBackSearch,\r\n fetchOneCardBack,\r\n //Cards\r\n cardSearch,\r\n fetchOneCard,\r\n //Decks\r\n getDeck,\r\n //Metadata\r\n allMetadata,\r\n specificMetadata,\r\n};\r\nexport default hs;\r\nexport { hs };\r\n\r\n//Card Backs\r\nexport * from './card-backs/index';\r\nexport type * from './card-backs/types';\r\n//Cards\r\nexport * from './cards/index';\r\nexport type * from './cards/types';\r\n//Decks\r\nexport * from './decks/index';\r\nexport type * from './decks/types';\r\n//Metadata\r\nexport * from './metadata/index';\r\nexport type * from './metadata/types';\r\n"],"mappings":";;;;;AAKA,MAAM,KAAK;CAET;CACA;CAEA;CACA;CAEA;CAEA;CACA;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { cardBackSearch, fetchOneCardBack } from './card-backs/index';\nimport { cardSearch, fetchOneCard } from './cards/index';\nimport { getDeck } from './decks/index';\nimport { allMetadata, specificMetadata } from './metadata/index';\n\nconst hs = {\n //Card Backs\n cardBackSearch,\n fetchOneCardBack,\n //Cards\n cardSearch,\n fetchOneCard,\n //Decks\n getDeck,\n //Metadata\n allMetadata,\n specificMetadata,\n};\nexport default hs;\nexport { hs };\n\n//Card Backs\nexport * from './card-backs/index';\nexport type * from './card-backs/types';\n//Cards\nexport * from './cards/index';\nexport type * from './cards/types';\n//Decks\nexport * from './decks/index';\nexport type * from './decks/types';\n//Metadata\nexport * from './metadata/index';\nexport type * from './metadata/types';\n"],"mappings":";;;;;AAKA,MAAM,KAAK;CAET;CACA;CAEA;CACA;CAEA;CAEA;CACA;AACF"}
package/package.json CHANGED
@@ -1,18 +1,28 @@
1
1
  {
2
2
  "name": "@blizzard-api/hs",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
+ "description": "A series of helpers to interact with the Hearthstone Blizzard API",
5
+ "keywords": [
6
+ "api",
7
+ "battle.net",
8
+ "battlenet",
9
+ "blizzard",
10
+ "bnet",
11
+ "hearthstone",
12
+ "hs"
13
+ ],
4
14
  "license": "MIT",
5
15
  "author": "Putro",
6
- "description": "A series of helpers to interact with the Hearthstone Blizzard API",
7
16
  "repository": {
8
17
  "type": "git",
9
18
  "url": "git+https://github.com/Pewtro/blizzard-api.git",
10
19
  "directory": "packages/hs"
11
20
  },
21
+ "files": [
22
+ "dist"
23
+ ],
12
24
  "type": "module",
13
- "engines": {
14
- "node": "^22.13.0 || ^24 || ^26"
15
- },
25
+ "sideEffects": false,
16
26
  "module": "./dist/index.js",
17
27
  "types": "./dist/index.d.ts",
18
28
  "exports": {
@@ -27,25 +37,15 @@
27
37
  "default": "./dist/*/index.js"
28
38
  }
29
39
  },
30
- "files": [
31
- "dist"
32
- ],
33
- "sideEffects": false,
34
- "keywords": [
35
- "blizzard",
36
- "battlenet",
37
- "battle.net",
38
- "bnet",
39
- "api",
40
- "hs",
41
- "hearthstone"
42
- ],
43
40
  "dependencies": {},
41
+ "devDependencies": {
42
+ "@blizzard-api/core": "4.1.3"
43
+ },
44
44
  "peerDependencies": {
45
- "@blizzard-api/core": "4.1.2"
45
+ "@blizzard-api/core": "4.1.3"
46
46
  },
47
- "devDependencies": {
48
- "@blizzard-api/core": "4.1.2"
47
+ "engines": {
48
+ "node": "^22.13.0 || ^24 || ^26"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsdown",