guildwars2-ts 1.5.0 → 1.6.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/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  ISC License
2
2
 
3
- Copyright (c) 2023 Ivan Sosnov
4
- Copyright (c) 2021 Julio Sansossio (parts of request base code)
3
+ Copyright (c) 2022 Ivan Sosnov
5
4
 
6
5
  Permission to use, copy, modify, and/or distribute this software for any
7
6
  purpose with or without fee is hereby granted, provided that the above
package/README.md CHANGED
@@ -17,14 +17,19 @@ Full support of all endpoints listed in the [API:2 Wiki](https://wiki.guildwars2
17
17
  import { GW2Api, ApiLanguage, setLogLevel, LogLevel } from "guildwars2-ts";
18
18
 
19
19
  const api: GW2Api = new GW2Api({
20
- // Token is not required for all of the endpoints
20
+ // Some endpoints require authentication
21
21
  token: "YOUR-TOKEN-HERE",
22
22
  language: ApiLanguage.English,
23
+ // Optional, but recommended
23
24
  rateLimitRetry: true
25
+ // When using guildwars2-ts in a browser, setting this is required to avoid CORS errors. Can be omitted otherwise
26
+ inBrowser: true
24
27
  });
25
28
 
26
29
  // Set to error by default, so you can set it to info for extra verbosity
27
30
  setLogLevel(LogLevel.info);
31
+ // Set to true by default, but recommended to be turned off, if your log does not render correctly
32
+ enableLogColors(false);
28
33
 
29
34
  (async () => {
30
35
  // Obtain names of all characters on the account
@@ -35,6 +40,11 @@ setLogLevel(LogLevel.info);
35
40
  await api.characters.getCore(character).then(console.log);
36
41
  });
37
42
  });
43
+
44
+ // Types are automatically inferred for any function calls, like shown above
45
+ // If explicit types are preferred, it can be done as well
46
+ // Zod@^4 is required for this. In the future, this will be simplified
47
+ const emblems: z.infer<typeof EmblemDTO> = await api.emblem.get("foregrounds", [1, 2, 3]);
38
48
  })();
39
49
  ```
40
50
 
@@ -44,6 +54,12 @@ If you encounter any kinds of errors, or wish to add/update the functionality pr
44
54
 
45
55
  Otherwise, please check open [issue reports](https://gitlab.com/dinckelman/guildwars2-ts/-/issues/), to see if there is an existing discussion on the issue, or open a new request. In case of runtime errors, request validation error logs are extremely helpful, so please include them in the report, as guided by the template.
46
56
 
57
+ ## Planned features
58
+
59
+ * Request caching (under consideration)
60
+ * Support for pagination
61
+ * Support for different/older schema version
62
+
47
63
  [npm-image]: https://img.shields.io/npm/v/guildwars2-ts
48
64
  [npm-link]: https://www.npmjs.com/package/guildwars2-ts
49
65
  [license]: https://img.shields.io/gitlab/license/dinckelman%2Fguildwars2-ts