anilink-api-wrapper 1.29.2 → 2.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/LICENSE +21 -21
- package/README.md +71 -241
- package/dist/AniLink.d.ts +12329 -0
- package/dist/AniLink.mjs +7298 -0
- package/dist/anilist.d.ts +1 -0
- package/dist/anilist.mjs +5 -0
- package/dist/mal.d.ts +1 -0
- package/dist/mal.mjs +5 -0
- package/package.json +121 -46
- package/dist/AniLink.js +0 -248
- package/dist/apis/anilist/Custom.js +0 -42
- package/dist/apis/anilist/interfaces/Activity.js +0 -436
- package/dist/apis/anilist/interfaces/Basic.js +0 -33
- package/dist/apis/anilist/interfaces/CoverImage.js +0 -15
- package/dist/apis/anilist/interfaces/Distribution.js +0 -23
- package/dist/apis/anilist/interfaces/ExternalLink.js +0 -14
- package/dist/apis/anilist/interfaces/Favoured.js +0 -2
- package/dist/apis/anilist/interfaces/FuzzyDate.js +0 -12
- package/dist/apis/anilist/interfaces/Image.js +0 -13
- package/dist/apis/anilist/interfaces/ListScores.js +0 -2
- package/dist/apis/anilist/interfaces/Media.js +0 -13
- package/dist/apis/anilist/interfaces/Name.js +0 -15
- package/dist/apis/anilist/interfaces/NextAiringEpisode.js +0 -14
- package/dist/apis/anilist/interfaces/Notification.js +0 -25
- package/dist/apis/anilist/interfaces/Ranking.js +0 -19
- package/dist/apis/anilist/interfaces/SiteTrend.js +0 -33
- package/dist/apis/anilist/interfaces/Staff.js +0 -2
- package/dist/apis/anilist/interfaces/Stat.js +0 -2
- package/dist/apis/anilist/interfaces/Statistics.js +0 -2
- package/dist/apis/anilist/interfaces/StreamingEpisode.js +0 -15
- package/dist/apis/anilist/interfaces/Studio.js +0 -2
- package/dist/apis/anilist/interfaces/Tag.js +0 -18
- package/dist/apis/anilist/interfaces/Title.js +0 -15
- package/dist/apis/anilist/interfaces/Trailer.js +0 -14
- package/dist/apis/anilist/interfaces/UserStats.js +0 -23
- package/dist/apis/anilist/interfaces/responses/mutation/Favourites.js +0 -83
- package/dist/apis/anilist/interfaces/responses/query/AiringSchedule.js +0 -18
- package/dist/apis/anilist/interfaces/responses/query/AniChartUser.js +0 -2
- package/dist/apis/anilist/interfaces/responses/query/Character.js +0 -34
- package/dist/apis/anilist/interfaces/responses/query/ExternalLinkSourceCollection.js +0 -2
- package/dist/apis/anilist/interfaces/responses/query/Media.js +0 -217
- package/dist/apis/anilist/interfaces/responses/query/MediaList.js +0 -36
- package/dist/apis/anilist/interfaces/responses/query/MediaListCollectionResponse.js +0 -49
- package/dist/apis/anilist/interfaces/responses/query/MediaTagCollection.js +0 -2
- package/dist/apis/anilist/interfaces/responses/query/MediaTrend.js +0 -21
- package/dist/apis/anilist/interfaces/responses/query/Notification.js +0 -166
- package/dist/apis/anilist/interfaces/responses/query/Recommendation.js +0 -23
- package/dist/apis/anilist/interfaces/responses/query/Review.js +0 -30
- package/dist/apis/anilist/interfaces/responses/query/SiteStatistics.js +0 -31
- package/dist/apis/anilist/interfaces/responses/query/Staff.js +0 -59
- package/dist/apis/anilist/interfaces/responses/query/Studio.js +0 -60
- package/dist/apis/anilist/interfaces/responses/query/Thread.js +0 -44
- package/dist/apis/anilist/interfaces/responses/query/ThreadComment.js +0 -31
- package/dist/apis/anilist/interfaces/responses/query/User.js +0 -366
- package/dist/apis/anilist/mutation/DeleteActivity.js +0 -61
- package/dist/apis/anilist/mutation/DeleteActivityReply.js +0 -61
- package/dist/apis/anilist/mutation/DeleteCustomList.js +0 -63
- package/dist/apis/anilist/mutation/DeleteMediaListEntry.js +0 -61
- package/dist/apis/anilist/mutation/DeleteReview.js +0 -61
- package/dist/apis/anilist/mutation/DeleteThread.js +0 -61
- package/dist/apis/anilist/mutation/DeleteThreadComment.js +0 -61
- package/dist/apis/anilist/mutation/SaveActivityReply.js +0 -66
- package/dist/apis/anilist/mutation/SaveListActivity.js +0 -64
- package/dist/apis/anilist/mutation/SaveMediaListEntry.js +0 -97
- package/dist/apis/anilist/mutation/SaveMessageActivity.js +0 -68
- package/dist/apis/anilist/mutation/SaveRecommendation.js +0 -66
- package/dist/apis/anilist/mutation/SaveReview.js +0 -68
- package/dist/apis/anilist/mutation/SaveTextActivity.js +0 -65
- package/dist/apis/anilist/mutation/SaveThread.js +0 -69
- package/dist/apis/anilist/mutation/SaveThreadComment.js +0 -67
- package/dist/apis/anilist/mutation/ToggleActivityPin.js +0 -64
- package/dist/apis/anilist/mutation/ToggleActivitySubscription.js +0 -64
- package/dist/apis/anilist/mutation/ToggleFavourite.js +0 -66
- package/dist/apis/anilist/mutation/ToggleFollow.js +0 -62
- package/dist/apis/anilist/mutation/ToggleLike.js +0 -64
- package/dist/apis/anilist/mutation/ToggleLikeV2.js +0 -64
- package/dist/apis/anilist/mutation/ToggleThreadSubscription.js +0 -64
- package/dist/apis/anilist/mutation/UpdateAniChartHighlights.js +0 -58
- package/dist/apis/anilist/mutation/UpdateAniChartSettings.js +0 -58
- package/dist/apis/anilist/mutation/UpdateFavouriteOrder.js +0 -73
- package/dist/apis/anilist/mutation/UpdateMediaListEntries.js +0 -93
- package/dist/apis/anilist/mutation/UpdateUser.js +0 -127
- package/dist/apis/anilist/query/Activity.js +0 -86
- package/dist/apis/anilist/query/ActivityReply.js +0 -60
- package/dist/apis/anilist/query/AiringSchedule.js +0 -78
- package/dist/apis/anilist/query/AniChartUser.js +0 -56
- package/dist/apis/anilist/query/Character.js +0 -70
- package/dist/apis/anilist/query/ExternalLinkSourceCollection.js +0 -68
- package/dist/apis/anilist/query/Follower.js +0 -64
- package/dist/apis/anilist/query/Following.js +0 -64
- package/dist/apis/anilist/query/GenreCollection.js +0 -46
- package/dist/apis/anilist/query/Markdown.js +0 -57
- package/dist/apis/anilist/query/Media.js +0 -134
- package/dist/apis/anilist/query/MediaList.js +0 -90
- package/dist/apis/anilist/query/MediaListCollection.js +0 -76
- package/dist/apis/anilist/query/MediaTagCollection.js +0 -57
- package/dist/apis/anilist/query/MediaTrend.js +0 -84
- package/dist/apis/anilist/query/Notification.js +0 -65
- package/dist/apis/anilist/query/Recommendation.js +0 -68
- package/dist/apis/anilist/query/Review.js +0 -64
- package/dist/apis/anilist/query/SiteStatistics.js +0 -78
- package/dist/apis/anilist/query/Staff.js +0 -79
- package/dist/apis/anilist/query/Studio.js +0 -82
- package/dist/apis/anilist/query/Thread.js +0 -68
- package/dist/apis/anilist/query/ThreadComment.js +0 -63
- package/dist/apis/anilist/query/User.js +0 -68
- package/dist/apis/anilist/query/Viewer.js +0 -65
- package/dist/apis/anilist/query/page/Activities.js +0 -97
- package/dist/apis/anilist/query/page/ActivityReplies.js +0 -71
- package/dist/apis/anilist/query/page/AiringSchedules.js +0 -89
- package/dist/apis/anilist/query/page/Characters.js +0 -81
- package/dist/apis/anilist/query/page/Followers.js +0 -75
- package/dist/apis/anilist/query/page/Followings.js +0 -75
- package/dist/apis/anilist/query/page/Likes.js +0 -71
- package/dist/apis/anilist/query/page/MediaLists.js +0 -101
- package/dist/apis/anilist/query/page/MediaTrends.js +0 -95
- package/dist/apis/anilist/query/page/Medias.js +0 -143
- package/dist/apis/anilist/query/page/Notifications.js +0 -73
- package/dist/apis/anilist/query/page/Recommendations.js +0 -79
- package/dist/apis/anilist/query/page/Reviews.js +0 -75
- package/dist/apis/anilist/query/page/Staffs.js +0 -90
- package/dist/apis/anilist/query/page/Studios.js +0 -93
- package/dist/apis/anilist/query/page/ThreadCommments.js +0 -74
- package/dist/apis/anilist/query/page/Threads.js +0 -79
- package/dist/apis/anilist/query/page/Users.js +0 -79
- package/dist/apis/anilist/types/ActivityType.js +0 -14
- package/dist/apis/anilist/types/DisabledListActivity.js +0 -11
- package/dist/apis/anilist/types/Format.js +0 -30
- package/dist/apis/anilist/types/FuzzyDate.js +0 -12
- package/dist/apis/anilist/types/MediaListOptions.js +0 -16
- package/dist/apis/anilist/types/NotificationOptions.js +0 -29
- package/dist/apis/anilist/types/RecommendationRating.js +0 -12
- package/dist/apis/anilist/types/Season.js +0 -13
- package/dist/apis/anilist/types/Sort.js +0 -265
- package/dist/apis/anilist/types/Source.js +0 -25
- package/dist/apis/anilist/types/Status.js +0 -26
- package/dist/apis/anilist/types/Type.js +0 -44
- package/dist/apis/anilist/types/UserStaffNameLanguage.js +0 -15
- package/dist/apis/anilist/types/UserTitleLanguage.js +0 -15
- package/dist/base/APIWrapper.js +0 -17
- package/dist/base/RequestHandler.js +0 -48
- package/dist/base/ValidateVariables.js +0 -125
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DeleteThreadMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
/**
|
|
17
|
-
* `DeleteThreadMutation` is a class representing a mutation to delete a thread.
|
|
18
|
-
* It includes a method to delete a thread
|
|
19
|
-
*/
|
|
20
|
-
class DeleteThreadMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new `DeleteThreadMutation` instance.
|
|
23
|
-
*
|
|
24
|
-
* @param authToken - The authentication token.
|
|
25
|
-
*/
|
|
26
|
-
constructor(authToken) {
|
|
27
|
-
super('https://graphql.anilist.co');
|
|
28
|
-
this.authToken = authToken;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* `deleteThread` is a method that sends a mutation request to delete a thread.
|
|
32
|
-
*
|
|
33
|
-
* @param variables - An object of type `DeleteThreadVariables` representing the variables for the mutation.
|
|
34
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
35
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
36
|
-
* */
|
|
37
|
-
deleteThread(variables) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!this.authToken) {
|
|
40
|
-
throw new Error('DeleteThreadMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
41
|
-
}
|
|
42
|
-
if (!variables.id) {
|
|
43
|
-
throw new Error('id variable is required');
|
|
44
|
-
}
|
|
45
|
-
const variableTypeMappings = {
|
|
46
|
-
id: 'number'
|
|
47
|
-
};
|
|
48
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
49
|
-
const mutation = `
|
|
50
|
-
mutation ($id: Int) {
|
|
51
|
-
DeleteThread (id: $id) {
|
|
52
|
-
deleted
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
const data = { query: mutation, variables };
|
|
57
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.DeleteThreadMutation = DeleteThreadMutation;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DeleteThreadCommentMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
/**
|
|
17
|
-
* `DeleteThreadCommentMutation` is a class representing a mutation to delete a thread comment.
|
|
18
|
-
* It includes a method to delete a thread
|
|
19
|
-
*/
|
|
20
|
-
class DeleteThreadCommentMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new `DeleteThreadCommentMutation` instance.
|
|
23
|
-
*
|
|
24
|
-
* @param authToken - The authentication token.
|
|
25
|
-
*/
|
|
26
|
-
constructor(authToken) {
|
|
27
|
-
super('https://graphql.anilist.co');
|
|
28
|
-
this.authToken = authToken;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* `deleteThreadComment` is a method that sends a mutation request to delete a thread comment.
|
|
32
|
-
*
|
|
33
|
-
* @param variables - An object of type `DeleteThreadCommentVariables` representing the variables for the mutation.
|
|
34
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
35
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
36
|
-
* */
|
|
37
|
-
deleteThreadComment(variables) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!this.authToken) {
|
|
40
|
-
throw new Error('DeleteThreadCommentMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
41
|
-
}
|
|
42
|
-
if (!variables.id) {
|
|
43
|
-
throw new Error('id variable is required');
|
|
44
|
-
}
|
|
45
|
-
const variableTypeMappings = {
|
|
46
|
-
id: 'number'
|
|
47
|
-
};
|
|
48
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
49
|
-
const mutation = `
|
|
50
|
-
mutation ($id: Int) {
|
|
51
|
-
DeleteThreadComment (id: $id) {
|
|
52
|
-
deleted
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
const data = { query: mutation, variables };
|
|
57
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.DeleteThreadCommentMutation = DeleteThreadCommentMutation;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveActivityReplyMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
const Activity_1 = require("../interfaces/Activity");
|
|
17
|
-
/**
|
|
18
|
-
* `SaveActivityReplyMutation` is a class representing a mutation to save an activity reply.
|
|
19
|
-
* It includes a method to save an activity reply
|
|
20
|
-
*/
|
|
21
|
-
class SaveActivityReplyMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
-
/**
|
|
23
|
-
* Constructs a new `SaveActivityReplyMutation` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param authToken - The authentication token.
|
|
26
|
-
*/
|
|
27
|
-
constructor(authToken) {
|
|
28
|
-
super('https://graphql.anilist.co');
|
|
29
|
-
this.authToken = authToken;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* `SaveActivityReply` is a method that sends a mutation request to save an activity reply.
|
|
33
|
-
*
|
|
34
|
-
* @param variables - An object of type `SaveActivityReplyVariables` representing the variables for the mutation.
|
|
35
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
-
* */
|
|
38
|
-
saveActivityReply(variables) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.authToken) {
|
|
41
|
-
throw new Error('SaveActivityReplyMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
-
}
|
|
43
|
-
if (!variables.id && !variables.text) {
|
|
44
|
-
throw new Error('id or text variable is required');
|
|
45
|
-
}
|
|
46
|
-
const variableTypeMappings = {
|
|
47
|
-
id: 'number',
|
|
48
|
-
activityId: 'number',
|
|
49
|
-
text: 'string',
|
|
50
|
-
asMod: 'boolean',
|
|
51
|
-
asHtml: 'boolean'
|
|
52
|
-
};
|
|
53
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
54
|
-
const mutation = `
|
|
55
|
-
mutation ($id: Int, $activityId: Int, $text: String, $asMod: Boolean, $asHtml: Boolean) {
|
|
56
|
-
SaveActivityReply (id: $id, activityId: $activityId, text: $text, asMod: $asMod) {
|
|
57
|
-
${Activity_1.ActivityReplySchema}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
const data = { query: mutation, variables };
|
|
62
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.SaveActivityReplyMutation = SaveActivityReplyMutation;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveListActivityMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
const Activity_1 = require("../interfaces/Activity");
|
|
17
|
-
/**
|
|
18
|
-
* `SaveListActivityMutation` is a class representing a mutation to save a list activity.
|
|
19
|
-
* It includes a method to save a list activity
|
|
20
|
-
*/
|
|
21
|
-
class SaveListActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
-
/**
|
|
23
|
-
* Constructs a new `SaveListActivityMutation` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param authToken - The authentication token.
|
|
26
|
-
*/
|
|
27
|
-
constructor(authToken) {
|
|
28
|
-
super('https://graphql.anilist.co');
|
|
29
|
-
this.authToken = authToken;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* `saveListActivity` is a method that sends a mutation request to save a list activity.
|
|
33
|
-
*
|
|
34
|
-
* @param variables - An object of type `SaveListActivityVariables` representing the variables for the mutation.
|
|
35
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
-
* */
|
|
38
|
-
saveListActivity(variables) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.authToken) {
|
|
41
|
-
throw new Error('SaveListActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
-
}
|
|
43
|
-
if (!variables.id) {
|
|
44
|
-
throw new Error('id variable is required');
|
|
45
|
-
}
|
|
46
|
-
const variableTypeMappings = {
|
|
47
|
-
id: 'number',
|
|
48
|
-
locked: 'boolean',
|
|
49
|
-
asHtml: 'boolean'
|
|
50
|
-
};
|
|
51
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
52
|
-
const mutation = `
|
|
53
|
-
mutation ($id: Int, $locked: Boolean, $asHtml: Boolean) {
|
|
54
|
-
SaveListActivity(id: $id, locked:$locked)
|
|
55
|
-
${Activity_1.ListActivitySchema}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
const data = { query: mutation, variables };
|
|
60
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.SaveListActivityMutation = SaveListActivityMutation;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveMediaListEntryMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const FuzzyDate_1 = require("../interfaces/FuzzyDate");
|
|
16
|
-
const FuzzyDate_2 = require("../types/FuzzyDate");
|
|
17
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
18
|
-
const Status_1 = require("../types/Status");
|
|
19
|
-
/**
|
|
20
|
-
* `SaveMediaListEntryMutation` is a class representing a mutation to save a media list entry.
|
|
21
|
-
* It includes a method to save a media list entry.
|
|
22
|
-
*/
|
|
23
|
-
class SaveMediaListEntryMutation extends APIWrapper_1.APIWrapper {
|
|
24
|
-
/**
|
|
25
|
-
* Constructs a new `SaveMediaListEntryMutation` instance.
|
|
26
|
-
*
|
|
27
|
-
* @param authToken - The authentication token.
|
|
28
|
-
*/
|
|
29
|
-
constructor(authToken) {
|
|
30
|
-
super('https://graphql.anilist.co');
|
|
31
|
-
this.authToken = authToken;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* `saveMediaListEntry` is a method that sends a mutation request to save a media list entry.
|
|
35
|
-
*
|
|
36
|
-
* @param variables - An object of type `SaveMediaListEntryVariables` representing the variables for the mutation.
|
|
37
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
38
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
39
|
-
*/
|
|
40
|
-
saveMediaListEntry(variables) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
if (!this.authToken) {
|
|
43
|
-
throw new Error('SaveMediaListEntryMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
44
|
-
}
|
|
45
|
-
if (variables.mediaId === undefined) {
|
|
46
|
-
throw new Error('mediaId is required for SaveMediaListEntryMutation');
|
|
47
|
-
}
|
|
48
|
-
const variableTypeMappings = {
|
|
49
|
-
id: 'number',
|
|
50
|
-
mediaId: 'number',
|
|
51
|
-
status: Status_1.MediaListStatusMappings,
|
|
52
|
-
score: 'number',
|
|
53
|
-
scoreRaw: 'number',
|
|
54
|
-
progress: 'number',
|
|
55
|
-
progressVolumes: 'number',
|
|
56
|
-
repeat: 'number',
|
|
57
|
-
priority: 'number',
|
|
58
|
-
private: 'boolean',
|
|
59
|
-
notes: 'string',
|
|
60
|
-
hiddenFromStatusLists: 'boolean',
|
|
61
|
-
customLists: 'string[]',
|
|
62
|
-
advancedScores: 'number[]',
|
|
63
|
-
startedAt: FuzzyDate_2.FuzzyDateMappings,
|
|
64
|
-
completedAt: FuzzyDate_2.FuzzyDateMappings
|
|
65
|
-
};
|
|
66
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
67
|
-
const mutation = `
|
|
68
|
-
mutation ($id: Int, $mediaId: Int, $status: MediaListStatus, $score: Float, $scoreRaw: Int, $progress: Int, $progressVolumes: Int, $repeat: Int, $priority: Int, $private: Boolean, $notes: String, $hiddenFromStatusLists: Boolean, $customLists: [String], $advancedScores: [Float], $startedAt: FuzzyDateInput, $completedAt: FuzzyDateInput) {
|
|
69
|
-
SaveMediaListEntry(id: $id, mediaId: $mediaId, status: $status, score: $score, scoreRaw: $scoreRaw, progress: $progress, progressVolumes: $progressVolumes, repeat: $repeat, priority: $priority, private: $private, notes: $notes, hiddenFromStatusLists: $hiddenFromStatusLists, customLists: $customLists, advancedScores: $advancedScores, startedAt: $startedAt, completedAt: $completedAt) {
|
|
70
|
-
id
|
|
71
|
-
mediaId
|
|
72
|
-
status
|
|
73
|
-
score
|
|
74
|
-
progress
|
|
75
|
-
progressVolumes
|
|
76
|
-
repeat
|
|
77
|
-
priority
|
|
78
|
-
private
|
|
79
|
-
notes
|
|
80
|
-
hiddenFromStatusLists
|
|
81
|
-
customLists
|
|
82
|
-
advancedScores
|
|
83
|
-
startedAt {
|
|
84
|
-
${FuzzyDate_1.FuzzyDateSchema}
|
|
85
|
-
}
|
|
86
|
-
completedAt {
|
|
87
|
-
${FuzzyDate_1.FuzzyDateSchema}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
const data = { query: mutation, variables };
|
|
93
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.SaveMediaListEntryMutation = SaveMediaListEntryMutation;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveMessageActivityMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
const Activity_1 = require("../interfaces/Activity");
|
|
17
|
-
/**
|
|
18
|
-
* `SaveMessageActivityMutation` is a class representing a mutation to save a message activity.
|
|
19
|
-
* It includes a method to save a message activity
|
|
20
|
-
*/
|
|
21
|
-
class SaveMessageActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
-
/**
|
|
23
|
-
* Constructs a new `SaveMessageActivityMutation` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param authToken - The authentication token.
|
|
26
|
-
*/
|
|
27
|
-
constructor(authToken) {
|
|
28
|
-
super('https://graphql.anilist.co');
|
|
29
|
-
this.authToken = authToken;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* `saveMessageActivity` is a method that sends a mutation request to save a message activity.
|
|
33
|
-
*
|
|
34
|
-
* @param variables - An object of type `SaveMessageActivityVariables` representing the variables for the mutation.
|
|
35
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
-
* */
|
|
38
|
-
saveMessageActivity(variables) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.authToken) {
|
|
41
|
-
throw new Error('SaveMessageActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
-
}
|
|
43
|
-
if (!variables.id && !variables.message) {
|
|
44
|
-
throw new Error('id or text variable is required');
|
|
45
|
-
}
|
|
46
|
-
const variableTypeMappings = {
|
|
47
|
-
id: 'number',
|
|
48
|
-
message: 'string',
|
|
49
|
-
recipientId: 'number',
|
|
50
|
-
private: 'boolean',
|
|
51
|
-
locked: 'boolean',
|
|
52
|
-
asMod: 'boolean',
|
|
53
|
-
asHtml: 'boolean'
|
|
54
|
-
};
|
|
55
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
56
|
-
const mutation = `
|
|
57
|
-
mutation ($id: Int, $message: String, $recipientId: Int, $private: Boolean, $locked: Boolean, $asMod: Boolean, $asHtml: Boolean) {
|
|
58
|
-
SaveMessageActivity(id: $id, message: $message, recipientId: $recipientId, private: $private, locked:$locked, asMod: $asMod) {
|
|
59
|
-
${Activity_1.MessageActivitySchema}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
const data = { query: mutation, variables };
|
|
64
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.SaveMessageActivityMutation = SaveMessageActivityMutation;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveRecommendationMutation = void 0;
|
|
13
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
14
|
-
const Recommendation_1 = require("../interfaces/responses/query/Recommendation");
|
|
15
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
16
|
-
const RecommendationRating_1 = require("../types/RecommendationRating");
|
|
17
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
18
|
-
/**
|
|
19
|
-
* `SaveRecommendationMutation` is a class representing a mutation to save a recommendation.
|
|
20
|
-
* It includes a method to save a recommendation.
|
|
21
|
-
*/
|
|
22
|
-
class SaveRecommendationMutation extends APIWrapper_1.APIWrapper {
|
|
23
|
-
/**
|
|
24
|
-
* Constructs a new `SaveRecommendationMutation` instance.
|
|
25
|
-
*
|
|
26
|
-
* @param authToken - The authentication token.
|
|
27
|
-
*/
|
|
28
|
-
constructor(authToken) {
|
|
29
|
-
super('https://graphql.anilist.co');
|
|
30
|
-
this.authToken = authToken;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* `saveReview` is a method that sends a mutation request to save a recommendation.
|
|
34
|
-
*
|
|
35
|
-
* @param variables - An object of type `SaveRecommendationVariables` representing the variables for the mutation.
|
|
36
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
37
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
38
|
-
*/
|
|
39
|
-
saveRecommendation(variables) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (!this.authToken) {
|
|
42
|
-
throw new Error('SaveReviewMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
43
|
-
}
|
|
44
|
-
if (!variables.mediaId || !variables.mediaRecommendationId || !variables.rating) {
|
|
45
|
-
throw new Error('mediaId, mediaRecommendationId, and rating variables are required.');
|
|
46
|
-
}
|
|
47
|
-
const variableTypeMappings = {
|
|
48
|
-
mediaId: 'number',
|
|
49
|
-
mediaRecommendationId: 'number',
|
|
50
|
-
rating: RecommendationRating_1.RecommendationRatingMappings,
|
|
51
|
-
asHtml: 'boolean'
|
|
52
|
-
};
|
|
53
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
54
|
-
const mutation = `
|
|
55
|
-
mutation ($mediaId: Int, $mediaRecommendationId: Int, $rating: RecommendationRating, $asHtml: Boolean) {
|
|
56
|
-
SaveRecommendation(mediaId: $mediaId, mediaRecommendationId: $mediaRecommendationId, rating: $rating) {
|
|
57
|
-
${Recommendation_1.RecommendationSchema}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
const data = { query: mutation, variables };
|
|
62
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.SaveRecommendationMutation = SaveRecommendationMutation;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveReviewMutation = void 0;
|
|
13
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
14
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
15
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
16
|
-
const Review_1 = require("../interfaces/responses/query/Review");
|
|
17
|
-
/**
|
|
18
|
-
* `SaveReviewMutation` is a class representing a mutation to save a review.
|
|
19
|
-
* It includes a method to save a review.
|
|
20
|
-
*/
|
|
21
|
-
class SaveReviewMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
-
/**
|
|
23
|
-
* Constructs a new `SaveReviewMutation` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param authToken - The authentication token.
|
|
26
|
-
*/
|
|
27
|
-
constructor(authToken) {
|
|
28
|
-
super('https://graphql.anilist.co');
|
|
29
|
-
this.authToken = authToken;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* `saveReview` is a method that sends a mutation request to save a review.
|
|
33
|
-
*
|
|
34
|
-
* @param variables - An object of type `SaveReviewVariables` representing the variables for the mutation.
|
|
35
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
-
*/
|
|
38
|
-
saveReview(variables) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.authToken) {
|
|
41
|
-
throw new Error('SaveReviewMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
-
}
|
|
43
|
-
if (!variables.id && !variables.mediaId) {
|
|
44
|
-
throw new Error('id or mediaId variable is required');
|
|
45
|
-
}
|
|
46
|
-
const variableTypeMappings = {
|
|
47
|
-
id: 'number',
|
|
48
|
-
mediaId: 'number',
|
|
49
|
-
body: 'string',
|
|
50
|
-
summary: 'string',
|
|
51
|
-
score: 'number',
|
|
52
|
-
private: 'boolean',
|
|
53
|
-
asHtml: 'boolean'
|
|
54
|
-
};
|
|
55
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
56
|
-
const mutation = `
|
|
57
|
-
mutation ($id: Int, $mediaId: Int, $body: String, $summary: String, $score: Int, $private: Boolean, $asHtml: Boolean) {
|
|
58
|
-
SaveReview(id: $id, mediaId: $mediaId, body: $body, summary: $summary, score: $score, private: $private) {
|
|
59
|
-
${Review_1.ReviewSchema}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
const data = { query: mutation, variables };
|
|
64
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.SaveReviewMutation = SaveReviewMutation;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SaveTextActivityMutation = void 0;
|
|
13
|
-
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
-
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
-
const Activity_1 = require("../interfaces/Activity");
|
|
17
|
-
/**
|
|
18
|
-
* `SaveTextActivityMutation` is a class representing a mutation to save a text activity.
|
|
19
|
-
* It includes a method to save a text activity
|
|
20
|
-
*/
|
|
21
|
-
class SaveTextActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
-
/**
|
|
23
|
-
* Constructs a new `SaveTextActivityMutation` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param authToken - The authentication token.
|
|
26
|
-
*/
|
|
27
|
-
constructor(authToken) {
|
|
28
|
-
super('https://graphql.anilist.co');
|
|
29
|
-
this.authToken = authToken;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* `saveTextActivity` is a method that sends a mutation request to save a text activity.
|
|
33
|
-
*
|
|
34
|
-
* @param variables - An object of type `SaveTextActivityVariables` representing the variables for the mutation.
|
|
35
|
-
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
-
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
-
* */
|
|
38
|
-
saveTextActivity(variables) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.authToken) {
|
|
41
|
-
throw new Error('SaveTextActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
-
}
|
|
43
|
-
if (!variables.id && !variables.text) {
|
|
44
|
-
throw new Error('id or text variable is required');
|
|
45
|
-
}
|
|
46
|
-
const variableTypeMappings = {
|
|
47
|
-
id: 'number',
|
|
48
|
-
text: 'string',
|
|
49
|
-
locked: 'boolean',
|
|
50
|
-
asHtml: 'boolean'
|
|
51
|
-
};
|
|
52
|
-
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
53
|
-
const mutation = `
|
|
54
|
-
mutation ($id: Int, $text: String, $locked: Boolean, $asHtml: Boolean) {
|
|
55
|
-
SaveTextActivity(id: $id, text: $text, locked:$locked) {
|
|
56
|
-
${Activity_1.TextActivitySchema}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
const data = { query: mutation, variables };
|
|
61
|
-
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.SaveTextActivityMutation = SaveTextActivityMutation;
|