clashofclans.js 3.3.0-dev.2775232 → 3.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,173 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## 3.1.3 (24-12-2023)
6
+
7
+ ### Features
8
+
9
+ - Town Hall 16 updates.
10
+ - Removed deprecated builder base properties.
11
+
12
+ ## 3.1.3 (13-08-2023)
13
+
14
+ ### Features
15
+
16
+ - Switched to `undici` from `node-fetch` for better performance.
17
+
18
+ ## 3.1.0 (2023-07-28)
19
+
20
+ ### Features
21
+
22
+ - Builder base update and new troop levels.
23
+
24
+ ## 3.0.2 (2023-01-15)
25
+
26
+ ### Bug Fixes
27
+
28
+ - Conflict with the same name of builder base and home base troops. (#123)
29
+ - Fix the issue with the `Client#getLeagueWar()` method.
30
+ - Typings and documentation for clan capital.
31
+ - Fix the issue with the `Clan#clanCapital` property.
32
+
33
+ ### Features
34
+
35
+ - Added `Client#getCapitalRaidSeasons()` method.
36
+ - Added `Client#getCapitalLeagues()` method.
37
+ - Added `Client#getClanCapitalRanks()` method.
38
+ - Added new Super Troops in raw.json file.
39
+
40
+ ### Breaking Changes
41
+
42
+ - Using PascalCase instead of SCREAMING_SNAKE_CASE ([#115](https://github.com/clashperk/clashofclans.js/pull/115))
43
+ - `Client#events` and `EventManager` have been removed in favor of `PollingClient` ([#117](https://github.com/clashperk/clashofclans.js/pull/117), [#127](https://github.com/clashperk/clashofclans.js/pull/127))
44
+
45
+ ## 2.8.0 (2022-07-22)
46
+
47
+ ### Features
48
+
49
+ - Better Throttler with JS generator function. ([#111](https://github.com/clashperk/clashofclans.js/pull/111))
50
+ - Updated raw data from game files. ([#111](https://github.com/clashperk/clashofclans.js/pull/111))
51
+ - New method Util#parseArmyLink has been added. ([#110](https://github.com/clashperk/clashofclans.js/pull/110))
52
+
53
+ ## 2.7.0 (2022-05-22)
54
+
55
+ ### Features
56
+
57
+ - Some useful QOL methods have been added. ([#106](https://github.com/clashperk/clashofclans.js/pull/106))
58
+
59
+ ## 2.6.1 (2022-02-03)
60
+
61
+ ### Bug Fixes
62
+
63
+ - New value and typings `notInWar` added for `ClanWarLeagueGroup#state` ([#101](https://github.com/clashperk/clashofclans.js/pull/101))
64
+ - Throw error if `Util.formatTag` / `Util.parseTag` is called with invalid argument ([#102](https://github.com/clashperk/clashofclans.js/pull/101))
65
+
66
+ ## 2.6.0 (2022-01-29)
67
+
68
+ ## Features
69
+
70
+ - Replaced Keyv with customizable cache store ([#99](https://github.com/clashperk/clashofclans.js/pull/99))
71
+ - Guide for [Internal Caching](https://clashofclans.js.org/guide/internal-caching)
72
+
73
+ ## 2.5.2 (2022-01-23)
74
+
75
+ ### Bug Fixes
76
+
77
+ - Fix `ClanWar#attacksPerMembers` property ([#97](https://github.com/clashperk/clashofclans.js/pull/97))
78
+ - Bump `node-fetch` from 2.6.6 to 2.6.7 ([#96](https://github.com/clashperk/clashofclans.js/pull/96))
79
+
80
+ ## 2.5.1 (2022-01-11)
81
+
82
+ ### Bug Fixes
83
+
84
+ - Typings for `ClanWarLeagueGroup#state` property. ([#94](https://github.com/clashperk/clashofclans.js/pull/94))
85
+
86
+ ## 2.5.0 (2021-12-30)
87
+
88
+ ### Bug Fixes
89
+
90
+ - Fix caching issue with unnecessary/invalid query params. ([#91](https://github.com/clashperk/clashofclans.js/pull/91))
91
+ - Added necessary methods to `RESTManager` class. ([#92](https://github.com/clashperk/clashofclans.js/pull/92))
92
+
93
+ ## 2.4.0 (2021-12-28)
94
+
95
+ ### Features
96
+
97
+ - `ClanWar#getClanWarLeagueGroup`, `ClanWar#isCWL` and `ClanWar#isFriendly` are now available. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
98
+ - `RESTOptions#rejectIfNotValid` added to perform `res.ok` operations over `RESTManager` methods. [Know more?](https://clashofclans.js.org/guide/access-raw-data#easy-access) ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
99
+ - `Icon#fileName` and `Icon#sizes` are now available in `Icon` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
100
+ - `Badge#fileName` and `Badge#sizes` are now available in `Badge` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
101
+
102
+ ### Deprecations
103
+
104
+ - `ClanWarMember#previousBestOpponentAttack` has been deprecated. Use `ClanWarAttack#previousBestAttack` instead. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
105
+
106
+ ## 2.3.0 (2021-12-17)
107
+
108
+ ### Features
109
+
110
+ - BigInt literals issue fixed. ([#84](https://github.com/clashperk/clashofclans.js/pull/84))
111
+ - Some Utility methods renamed. ([#84](https://github.com/clashperk/clashofclans.js/pull/84))
112
+ - `Util.encodeTag()` to `Util.encodeURI()`
113
+ - `Util.encodeTagToId()` to `Util.encodeTag()`
114
+ - `Util.decodeIdToTag()` to `Util.decodeTag()`
115
+ - Added `dps`, `resourceType`, `trainingTime` and `regenerationTime` to the `Unit` class. ([#85](https://github.com/clashperk/clashofclans.js/pull/85))
116
+
117
+ ## 2.2.0 (2021-12-16)
118
+
119
+ ### Bug Fixes
120
+
121
+ - Show units as per in-game orders. ([#82](https://github.com/clashperk/clashofclans.js/pull/82)) ([6e23d2f](https://github.com/clashperk/clashofclans.js/commit/95cf3001059fd3ede9262e249814178631660d5b))
122
+ - Season end time utility method. ([#82](https://github.com/clashperk/clashofclans.js/pull/82)) ([6e23d2f](https://github.com/clashperk/clashofclans.js/commit/95cf3001059fd3ede9262e249814178631660d5b))
123
+ - Updated raw files for new Troops. ([#82](https://github.com/clashperk/clashofclans.js/pull/82)) ([6e23d2f](https://github.com/clashperk/clashofclans.js/commit/95cf3001059fd3ede9262e249814178631660d5b))
124
+
125
+ ### Features
126
+
127
+ - Added `seasonal`, `boostable` and `isLoaded` property to `Unit` class. ([#82](https://github.com/clashperk/clashofclans.js/pull/82)) ([6e23d2f](https://github.com/clashperk/clashofclans.js/commit/95cf3001059fd3ede9262e249814178631660d5b))
128
+
129
+ ## 2.1.0 (2021-12-06)
130
+
131
+ ### Bug Fixes
132
+
133
+ - Consistency of `ClanWar.attacksPerMember` property. ([#75](https://github.com/clashperk/clashofclans.js/pull/75)) ([6e23d2f](https://github.com/clashperk/clashofclans.js/commit/6e23d2fe0373f56268ffa55d5ac2807c9a2dc2fc))
134
+
135
+ ### Features
136
+
137
+ - More utility methods added to `Util` class. ([#76](https://github.com/clashperk/clashofclans.js/pull/76)) ([ff41115](https://github.com/clashperk/clashofclans.js/commit/ff4111530d6293ef1fc54aa916436130fc30a09c))
138
+
139
+ - `Util.formatTag(tag: string): string`
140
+ - `Util.formatDate(date: string): Date`
141
+ - `Util.isValidTag(tag: string): boolean`
142
+ - `Util.encodeTagToId(tag: string): string` (Removed on 2.3.0)
143
+ - `Util.decodeIdToTag(id: string): string` (Removed on 2.3.0)
144
+
145
+ - Support of async/await for custom events ([#79](https://github.com/clashperk/clashofclans.js/pull/79)) ([ff41115](https://github.com/clashperk/clashofclans.js/commit/a23db3786bcca44b8547c70f27773bdb1216f990))
146
+
147
+ ## 2.0.2 (2021-11-30)
148
+
149
+ ### Bug Fixes
150
+
151
+ - Return `null` for `RankedPlayer.clan` if they are not in the clan. ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
152
+ - `OverrideOptions` added for `Client#getClans` and `RESTManager#getClans` ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
153
+ - `SeasonRankedPlayer` class for legend league ranking. ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
154
+
155
+ ## 2.0.1 (2021-11-27)
156
+
157
+ ### Bug Fixes
158
+
159
+ - IP retrieval method and Event Loop ([#70](https://github.com/clashperk/clashofclans.js/issues/70)) ([82b84ba](https://github.com/clashperk/clashofclans.js/commit/82b84ba5d96505c43b75e53aa07f547ef0b77778))
160
+
161
+ ## 2.0.0 (2021-11-26)
162
+
163
+ This new version is a complete TypeScript rewrite to convert everything from plain (literal JSON) objects to class (constructor) objects and support a lot more features.
164
+
165
+ ### Features
166
+
167
+ - HTTP Request Request Retries ([#26](https://github.com/clashperk/clashofclans.js/issues/26)) ([94585f3](https://github.com/clashperk/clashofclans.js/commit/94585f3a84a7175b2d07872f9eb9e42372b95e12))
168
+ - Event Manager and Custom Events ([#37](https://github.com/clashperk/clashofclans.js/issues/37)) ([5027ae6](https://github.com/clashperk/clashofclans.js/commit/5027ae663a8e07175e17384c7e5706f4a1a7afb4))
169
+ - Email Password Login ([#31](https://github.com/clashperk/clashofclans.js/issues/31)) ([4153cd3](https://github.com/clashperk/clashofclans.js/commit/4153cd37ea0e1c71550b9e892105b84d5a407e23))
170
+ - Queue Throttler and Batch Throttler ([#34](https://github.com/clashperk/clashofclans.js/issues/34)) ([3a8f051](https://github.com/clashperk/clashofclans.js/commit/3a8f051552e93b98f89bc7d524acdecddf242718))
171
+ - Override Request Options ([#36](https://github.com/clashperk/clashofclans.js/issues/36)) ([42d7fdd](https://github.com/clashperk/clashofclans.js/commit/42d7fdd36262cc46f23b731f8cffb9daea19d3b0))
172
+ - Internal Caching Options ([#53](https://github.com/clashperk/clashofclans.js/issues/53)) ([984451d](https://github.com/clashperk/clashofclans.js/commit/30ea3240c11866008d0dae514468c0fdbb34ffd0))
173
+ - Additional Properties for Player Units ([#65](https://github.com/clashperk/clashofclans.js/pull/65)) ([aa1696](https://github.com/clashperk/clashofclans.js/commit/aa1696243d96d4fed0250b4282c60522a6482343))
package/README.md CHANGED
@@ -11,62 +11,52 @@
11
11
 
12
12
  ### Installation
13
13
 
14
- - **`npm i clashofclans.js`**
15
- - **Node.js v16 or newer is required.**
14
+ - **`npm i clashofclans.js`**
15
+ - **Node.js v16 or newer is required.**
16
16
 
17
17
  ### Links
18
18
 
19
- - [Documentation](https://clashofclans.js.org/docs/)
20
- - [Clash of Clans Developer Website](https://developer.clashofclans.com/)
21
- - [Clash of Clans API Community Discord](https://discord.gg/Eaja7gJ)
19
+ - [Documentation](https://clashofclans.js.org/docs/)
20
+ - [Clash of Clans Developer Website](https://developer.clashofclans.com/)
21
+ - [Clash of Clans API Community Discord](https://discord.gg/Eaja7gJ)
22
22
 
23
23
  ### Examples
24
24
 
25
25
  ```js
26
26
  const { Client } = require('clashofclans.js');
27
+ ```
28
+
29
+ #### Login with Email Password
30
+
31
+ ```js
27
32
  const client = new Client();
28
- // const client = new Client({ keys: [], cache: true, retryLimit: 2, restRequestTimeout: 5000 });
29
33
 
30
34
  (async function () {
31
- await client.login({ email: 'developer@email.com', password: '***' });
35
+ // This method should be called once when application starts.
36
+ await client.login({ email: 'developer@email.com', password: '***' });
32
37
 
33
- const clan = await client.getClan('#2PP');
34
- console.log(`${clan.name} (${clan.tag})`);
38
+ const clan = await client.getClan('#2PP');
39
+ console.log(`${clan.name} (${clan.tag})`);
35
40
  })();
36
41
  ```
37
42
 
38
- ### Custom Polling Event
39
-
40
- > **Warning** <br />
41
- > Events are neither real-time nor supported by the API. They are polled frequently and compared with the cached data. If there is a difference, the event is emitted.
43
+ #### Login with API Keys
42
44
 
43
45
  ```js
44
- const { PollingClient, BatchThrottler } = require('clashofclans.js');
45
- const pollingClient = new PollingClient({
46
- cache: true,
47
- retryLimit: 1,
48
- restRequestTimeout: 5000,
49
- throttler: new BatchThrottler(20)
50
- });
51
-
52
- pollingClient.addClans(['#8QU8J9LP', '#8P2QG08P']);
53
- pollingClient.setClanEvent({
54
- name: 'clanDescriptionChange',
55
- filter: (oldClan, newClan) => {
56
- return oldClan.description !== newClan.description;
57
- }
58
- });
59
-
60
- pollingClient.on('clanDescriptionChange', (oldClan, newClan) => {
61
- console.log(oldClan.description, newClan.description);
62
- });
46
+ const client = new Client({ keys: ['api_key_goes_here'] });
63
47
 
64
48
  (async function () {
65
- await pollingClient.login({ email: 'developer@email.com', password: '***' });
66
- await pollingClient.init();
49
+ const clan = await client.getClan('#2PP');
50
+ console.log(`${clan.name} (${clan.tag})`);
67
51
  })();
68
52
  ```
69
53
 
54
+ ### Events
55
+
56
+ The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
57
+ Pull data at specified intervals, compare with previous values, and emit events on change.
58
+ Consider using Node.js clusters and threads for efficient parallel processing.
59
+
70
60
  ### Disclaimer
71
61
 
72
62
  > This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see [Supercell's Fan Content Policy](https://supercell.com/en/fan-content-policy/).
@@ -8,6 +8,9 @@ import { Client } from './Client';
8
8
  * const { PollingClient } = require('clashofclans.js');
9
9
  * const pollingClient = new PollingClient({ keys: ['***'] });
10
10
  * ```
11
+ * @deprecated The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
12
+ * Pull data at specified intervals, compare with previous values, and emit events on change.
13
+ * Consider using Node.js clusters for efficient parallel processing.
11
14
  */
12
15
  export declare class PollingClient extends Client {
13
16
  private readonly _clanTags;
@@ -10,6 +10,9 @@ const Client_1 = require("./Client");
10
10
  * const { PollingClient } = require('clashofclans.js');
11
11
  * const pollingClient = new PollingClient({ keys: ['***'] });
12
12
  * ```
13
+ * @deprecated The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
14
+ * Pull data at specified intervals, compare with previous values, and emit events on change.
15
+ * Consider using Node.js clusters for efficient parallel processing.
13
16
  */
14
17
  class PollingClient extends Client_1.Client {
15
18
  constructor(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "3.3.0-dev.2775232",
3
+ "version": "3.3.0",
4
4
  "description": "JavaScript library for interacting with the Clash of Clans API",
5
5
  "author": "https://clashofclans.js.org",
6
6
  "license": "MIT",