anilink-api-wrapper 1.18.2 → 1.18.3

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
@@ -110,6 +110,8 @@ List of methods in `anilist.mutation`:
110
110
 
111
111
  ## Error Handling
112
112
 
113
+ ### Anilist Errors
114
+
113
115
  AniLink will throw an error if the AniList API returns an error. You can catch these errors using a try-catch block.
114
116
 
115
117
  ```typescript
@@ -123,7 +125,7 @@ try {
123
125
 
124
126
  This includes status codes and error messages returned by the AniList API. Here is an example rate limit handler to catch the errors thrown by AniLink:
125
127
 
126
- ### Typescript
128
+ #### Typescript
127
129
 
128
130
  ```typescript
129
131
  async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
@@ -153,7 +155,7 @@ async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
153
155
  }
154
156
  ```
155
157
 
156
- ### Javascript
158
+ #### Javascript
157
159
 
158
160
  ```javascript
159
161
  async function handleRateLimit(apiCall, retryAfter = 60) {
@@ -170,7 +172,7 @@ The possible error codes returned by the AniList API are:
170
172
 
171
173
  ### Missing or Invalid Variables
172
174
 
173
- AniLink will also throw an error if any variables are missing or invalid. For example, if you try to query a user providing a string instead of ID, AniLink will throw an error. Most variables are optional however there a few that are required.
175
+ AniLink will also throw an error if any variables are missing or invalid. For example, if you try to query a user providing a string instead of a number for ID, AniLink will throw an error. Most variables are optional however there a few that are required.
174
176
  ```typescript
175
177
  try {
176
178
  const user = await aniLink.anilist.query.user({id: '542244'});
@@ -39,6 +39,12 @@ class SaveMediaListEntryMutation extends APIWrapper_1.APIWrapper {
39
39
  */
40
40
  saveMediaListEntry(variables) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
+ if (Object.keys(variables).length === 0) {
43
+ throw new Error('No variables were provided');
44
+ }
45
+ if (variables.mediaId === undefined) {
46
+ throw new Error('mediaId is required for SaveMediaListEntryMutation');
47
+ }
42
48
  const variableTypeMappings = {
43
49
  id: 'number',
44
50
  mediaId: 'number',
@@ -39,6 +39,12 @@ class UpdateMediaListEntriesMutation extends APIWrapper_1.APIWrapper {
39
39
  * */
40
40
  updateMediaListEntries(variables) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
+ if (Object.keys(variables).length === 0) {
43
+ throw new Error('No variables were provided');
44
+ }
45
+ if (!variables.ids || variables.ids.length === 0) {
46
+ throw new Error('ids must be an array of at least one number');
47
+ }
42
48
  const variableTypeMappings = {
43
49
  status: MediaListStatus_1.MediaListStatusMappings,
44
50
  score: 'number',
@@ -42,6 +42,9 @@ class UpdateUserMutation extends APIWrapper_1.APIWrapper {
42
42
  */
43
43
  updateUser(variables) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
+ if (Object.keys(variables).length === 0) {
46
+ throw new Error('No variables were provided');
47
+ }
45
48
  const variableTypeMappings = {
46
49
  about: 'string',
47
50
  titleLanguage: UserTitleLanguage_1.UserTitleLanguageMapping,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anilink-api-wrapper",
3
- "version": "1.18.2",
3
+ "version": "1.18.3",
4
4
  "description": "Anilist API Wrapper",
5
5
  "main": "dist/AniLink.js",
6
6
  "scripts": {