moeralib
Version:
Library to interact with Moera decentralized social network
1,197 lines (1,196 loc) • 127 kB
JavaScript
"use strict";
// This file is generated
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoeraNode = void 0;
const caller_1 = require("./caller");
const util_1 = require("../util");
/**
* Node API interface.
*/
class MoeraNode extends caller_1.Caller {
/**
* @param {string | null} nodeUrl - the node URL
*/
constructor(nodeUrl = null) {
super();
if (nodeUrl != null) {
this.nodeUrl(nodeUrl);
}
}
/**
* Get the list of all reactions performed by the node, filtered by some criteria.
*
* @param {API.ActivityReactionFilter} filter
* @return {Promise<API.ActivityReactionInfo[]>}
*/
searchActivityReactions(filter) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/activity/reactions/search";
return yield this.call("searchActivityReactions", location, {
method: "POST", body: filter, schema: "ActivityReactionInfoArray"
});
});
}
/**
* Get a list of previously executed search queries, optionally filtered by the given ``prefix`` and limited by the
* given ``limit``. The node may decide to return fewer queries than the given ``limit``. The queries are always
* sorted by creation timestamp, descending.
*
* @param {string | null} prefix - find queries with the specified prefix (case-insensitive)
* @param {number | null} limit - maximum number of queries returned
* @return {Promise<API.SearchHistoryInfo[]>}
*/
getSearchHistory() {
return __awaiter(this, arguments, void 0, function* (prefix = null, limit = null) {
const location = (0, util_1.ut) `/activity/search`;
const params = { prefix, limit };
return yield this.call("getSearchHistory", location, {
method: "GET", params, schema: "SearchHistoryInfoArray"
});
});
}
/**
* Save a search query in the registry.
*
* @param {API.SearchHistoryText} historyText
* @return {Promise<API.SearchHistoryInfo>}
*/
saveToSearchHistory(historyText) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/activity/search";
return yield this.call("saveToSearchHistory", location, {
method: "POST", body: historyText, schema: "SearchHistoryInfo"
});
});
}
/**
* Delete a search query from the registry.
*
* @param {string} query - the query to be deleted
* @return {Promise<API.Result>}
*/
deleteFromSearchHistory(query) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/activity/search`;
const params = { query };
return yield this.call("deleteFromSearchHistory", location, {
method: "DELETE", params, schema: "Result"
});
});
}
/**
* Get a slice of the list of all orders sent by the sheriff, delimited by the ``before`` or ``after`` moment and
* the given ``limit``. If neither ``before`` nor ``after`` are provided, the latest orders are returned. The node
* may decide to return fewer orders than the given ``limit``. The orders are always sorted by moment, descending.
*
* @param {number | null} after - filter orders posted strongly after this moment
* @param {number | null} before - filter orders posted at or before this moment
* @param {number | null} limit - maximum number of orders returned
* @return {Promise<API.SheriffOrdersSliceInfo>}
*/
getRemoteSheriffOrdersSlice() {
return __awaiter(this, arguments, void 0, function* (after = null, before = null, limit = null) {
const location = (0, util_1.ut) `/activity/sheriff/orders`;
const params = { after, before, limit };
return yield this.call("getRemoteSheriffOrdersSlice", location, {
method: "GET", params, schema: "SheriffOrdersSliceInfo"
});
});
}
/**
* Get the status of the asynchronous operation that performs verification of a remote posting signature.
*
* @param {string} id - asynchronous operation ID
* @return {Promise<API.RemotePostingVerificationInfo>}
*/
getRemotePostingVerificationStatus(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/async-operations/remote-posting-verification/${id}`;
return yield this.call("getRemotePostingVerificationStatus", location, {
method: "GET", schema: "RemotePostingVerificationInfo"
});
});
}
/**
* Get the status of the asynchronous operation that performs verification of the signature of a reaction to a
* remote posting.
*
* @param {string} id - asynchronous operation ID
* @return {Promise<API.RemoteReactionVerificationInfo>}
*/
getRemoteReactionVerificationStatus(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/async-operations/remote-reaction-verification/${id}`;
return yield this.call("getRemoteReactionVerificationStatus", location, {
method: "GET", schema: "RemoteReactionVerificationInfo"
});
});
}
/**
* Get the list of avatars in the ascending order of their ordinals.
*
* @return {Promise<API.AvatarInfo[]>}
*/
getAvatars() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/avatars";
return yield this.call("getAvatars", location, {
method: "GET", schema: "AvatarInfoArray"
});
});
}
/**
* Create a new avatar from a public media file that exists on the node. A new public media file is created for the
* avatar. If the avatar's ordinal is not provided in the input, the avatar is assigned an ordinal that is greater
* than ordinals of all existing avatars.
*
* @param {API.AvatarAttributes} avatar
* @return {Promise<API.AvatarInfo>}
*/
createAvatar(avatar) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/avatars";
return yield this.call("createAvatar", location, {
method: "POST", body: avatar, schema: "AvatarInfo"
});
});
}
/**
* Get an individual avatar.
*
* @param {string} id - avatar ID
* @return {Promise<API.AvatarInfo>}
*/
getAvatar(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/avatars/${id}`;
return yield this.call("getAvatar", location, {
method: "GET", schema: "AvatarInfo"
});
});
}
/**
* Delete an avatar.
*
* @param {string} id - avatar ID
* @return {Promise<API.Result>}
*/
deleteAvatar(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/avatars/${id}`;
return yield this.call("deleteAvatar", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Reorder avatars. Every avatar mentioned in the input is assigned an ordinal in ascending order as they appear in
* the input. Ordinals of avatars not mentioned in the input are not touched.
*
* @param {API.AvatarsOrdered} order
* @return {Promise<API.AvatarOrdinal[]>}
*/
reorderAvatars(order) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/avatars/reorder";
return yield this.call("reorderAvatars", location, {
method: "POST", body: order, schema: "AvatarOrdinalArray"
});
});
}
/**
* Blocks creation of instants of the given story type, related to the given entry, optionally unblocking at the
* given time in the future.
*
* @param {API.BlockedInstantAttributes} instant
* @return {Promise<API.BlockedInstantInfo>}
*/
blockInstant(instant) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/blocked-instants";
return yield this.call("blockInstant", location, {
method: "POST", body: instant, schema: "BlockedInstantInfo"
});
});
}
/**
* Get details about the given blocked instant.
*
* @param {string} id - ID of the blocked instant
* @return {Promise<API.BlockedInstantInfo>}
*/
getBlockedInstant(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/blocked-instants/${id}`;
return yield this.call("getBlockedInstant", location, {
method: "GET", schema: "BlockedInstantInfo"
});
});
}
/**
* Unblock the given instant.
*
* @param {string} id - ID of the blocked instant
* @return {Promise<API.Result>}
*/
unblockInstant(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/blocked-instants/${id}`;
return yield this.call("unblockInstant", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Search blocked instants by the given criteria.
*
* @param {API.BlockedInstantFilter} filter
* @return {Promise<API.BlockedInstantInfo[]>}
*/
searchBlockedInstants(filter) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/blocked-instants/search";
return yield this.call("searchBlockedInstants", location, {
method: "POST", body: filter, schema: "BlockedInstantInfoArray"
});
});
}
/**
* Blocks the given node from performing the given operations, in a particular posting or globally, optionally
* unblocking at the given time in the future.
*
* @param {API.BlockedUserAttributes} user
* @return {Promise<API.BlockedUserInfo>}
*/
blockUser(user) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/blocked-users";
return yield this.call("blockUser", location, {
method: "POST", body: user, schema: "BlockedUserInfo"
});
});
}
/**
* Get details about the given blocked user.
*
* @param {string} id - ID of the blocked user
* @return {Promise<API.BlockedUserInfo>}
*/
getBlockedUser(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/people/blocked-users/${id}`;
return yield this.call("getBlockedUser", location, {
method: "GET", schema: "BlockedUserInfo"
});
});
}
/**
* Unblock the given user.
*
* @param {string} id - ID of the blocked user
* @return {Promise<API.Result>}
*/
unblockUser(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/people/blocked-users/${id}`;
return yield this.call("unblockUser", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Search blocked users by the given criteria.
*
* @param {API.BlockedUserFilter} filter
* @return {Promise<API.BlockedUserInfo[]>}
*/
searchBlockedUsers(filter) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/blocked-users/search";
return yield this.call("searchBlockedUsers", location, {
method: "POST", body: filter, schema: "BlockedUserInfoArray"
});
});
}
/**
* Get checksums of the information about the blocked users. This request may be used to quickly detect the changes
* in the blocked users list to update the cache on the client side.
*
* @return {Promise<API.BlockedUsersChecksums>}
*/
getBlockedUsersChecksums() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/blocked-users/checksums";
return yield this.call("getBlockedUsersChecksums", location, {
method: "GET", schema: "BlockedUsersChecksums"
});
});
}
/**
* Get details about the given node that blocked this node.
*
* @param {string} id - ID of the blocked-by user
* @return {Promise<API.BlockedByUserInfo>}
*/
getBlockedByUser(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/people/blocked-by-users/${id}`;
return yield this.call("getBlockedByUser", location, {
method: "GET", schema: "BlockedByUserInfo"
});
});
}
/**
* Search nodes that blocked this node, by the given criteria.
*
* @param {API.BlockedByUserFilter} filter
* @return {Promise<API.BlockedByUserInfo[]>}
*/
searchBlockedByUsers(filter) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/blocked-by-users/search";
return yield this.call("searchBlockedByUsers", location, {
method: "POST", body: filter, schema: "BlockedByUserInfoArray"
});
});
}
/**
* Create a set of cartes with the given attributes. Cartes in the sequence correspond to successive periods of
* time.
*
* @param {API.CarteAttributes} attributes
* @return {Promise<API.CarteSet>}
*/
createCartes(attributes) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/cartes";
return yield this.call("createCartes", location, {
method: "POST", body: attributes, schema: "CarteSet"
});
});
}
/**
* Verify if the given carte may be used for authentication on this node. Additionally, if ``clientName`` is
* provided, it is compared to the carte owner's name.
*
* @param {API.ClientCarte} clientCarte
* @return {Promise<API.CarteVerificationInfo>}
*/
verifyCarte(clientCarte) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/cartes/verify";
return yield this.call("verifyCarte", location, {
method: "POST", body: clientCarte, schema: "CarteVerificationInfo"
});
});
}
/**
* Get a slice of the list of comments, delimited by ``before`` or ``after`` moments (but not both) and the given
* ``limit``. If neither ``before`` nor ``after`` are provided, the latest comments are returned. The node may
* decide to return fewer comments than the given ``limit``. The stories are always sorted by moment, ascending.
*
* @param {string} postingId - ID of the posting
* @param {number | null} after - filter comments posted strongly after this moment
* @param {number | null} before - filter comments posted at or before this moment
* @param {number | null} limit - maximum number of comments returned
* @return {Promise<API.CommentsSliceInfo>}
*/
getCommentsSlice(postingId_1) {
return __awaiter(this, arguments, void 0, function* (postingId, after = null, before = null, limit = null) {
const location = (0, util_1.ut) `/postings/${postingId}/comments`;
const params = { after, before, limit };
return yield this.call("getCommentsSlice", location, {
method: "GET", params, schema: "CommentsSliceInfo", bodies: true
});
});
}
/**
* Create a comment from the given text and add it to the given posting. The comment owner must authenticate in
* some way. If the comment is not signed, it will be kept for a limited period of time and then erased. If
* authenticated as admin, the node signs the comment.
*
* @param {string} postingId - ID of the posting
* @param {API.CommentText} comment
* @return {Promise<API.CommentCreated>}
*/
createComment(postingId, comment) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments`;
return yield this.call("createComment", location, {
method: "POST", body: comment, schema: "CommentCreated", bodies: true, srcBodies: true
});
});
}
/**
* Get an individual comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {boolean} withSource - include source text of the comment
* @return {Promise<API.CommentInfo>}
*/
getComment(postingId_1, commentId_1) {
return __awaiter(this, arguments, void 0, function* (postingId, commentId, withSource = false) {
const include = (0, util_1.commaSeparatedFlags)({ "source": withSource });
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}`;
const params = { include };
return yield this.call("getComment", location, {
method: "GET", params, schema: "CommentInfo", bodies: true
});
});
}
/**
* Update operation overrides for all comments in the posting.
*
* @param {string} postingId - ID of the posting
* @param {API.CommentMassAttributes} attributes
* @return {Promise<API.Result>}
*/
updateAllComments(postingId, attributes) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments`;
return yield this.call("updateAllComments", location, {
method: "PUT", body: attributes, schema: "Result"
});
});
}
/**
* Update the comment, creating a new revision of it. The text is processed just like in the ``POST`` request.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {API.CommentText} comment
* @return {Promise<API.CommentInfo>}
*/
updateComment(postingId, commentId, comment) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}`;
return yield this.call("updateComment", location, {
method: "PUT", body: comment, schema: "CommentInfo", bodies: true, srcBodies: true
});
});
}
/**
* Delete the comment. The comment may not be purged from the database immediately, but preserved for some period
* of time to give a chance to restore it.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @return {Promise<API.CommentTotalInfo>}
*/
deleteComment(postingId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}`;
return yield this.call("deleteComment", location, {
method: "DELETE", schema: "CommentTotalInfo"
});
});
}
/**
* Get all postings linked to media attached to the given comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @return {Promise<API.PostingInfo[]>}
*/
getPostingsAttachedToComment(postingId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/attached`;
return yield this.call("getPostingsAttachedToComment", location, {
method: "GET", schema: "PostingInfoArray", bodies: true
});
});
}
/**
* Get all revisions of the comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @return {Promise<API.CommentRevisionInfo[]>}
*/
getCommentRevisions(postingId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/revisions`;
return yield this.call("getCommentRevisions", location, {
method: "GET", schema: "CommentRevisionInfoArray", bodies: true
});
});
}
/**
* Get an individual revision of the comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {string} id - ID of the revision
* @return {Promise<API.CommentRevisionInfo>}
*/
getCommentRevision(postingId, commentId, id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/revisions/${id}`;
return yield this.call("getCommentRevision", location, {
method: "GET", schema: "CommentRevisionInfo", bodies: true
});
});
}
/**
* Add a reaction to the given comment. The reaction owner must authenticate in some way. Only one reaction is
* allowed from each owner to a particular comment. If a reaction from the same owner to this comment already
* exists, it is overwritten. If the reaction is not signed, the reaction will be kept for a limited period of time
* and then erased (the previous reaction of the same owner will be restored, if any).
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {API.ReactionDescription} reaction
* @return {Promise<API.ReactionCreated>}
*/
createCommentReaction(postingId, commentId, reaction) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions`;
return yield this.call("createCommentReaction", location, {
method: "POST", body: reaction, schema: "ReactionCreated"
});
});
}
/**
* Update the reaction's operations or set operations' overrides.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {string} ownerName - reaction owner node name
* @param {API.ReactionOverride} reaction
* @return {Promise<API.ReactionInfo>}
*/
updateCommentReaction(postingId, commentId, ownerName, reaction) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions/${ownerName}`;
return yield this.call("updateCommentReaction", location, {
method: "PUT", body: reaction, schema: "ReactionInfo"
});
});
}
/**
* Get a slice of the list of reactions to the given comment, optionally filtered by reaction type, delimited by
* ``before`` moment and the given ``limit``. If ``before`` is not provided, the latest reactions are returned. The
* node may decide to return fewer reactions than the given ``limit``. The reactions are always sorted by moment,
* descending.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {boolean | null} negative - ``true``, to filter negative reactions, ``false``, to filter positive ones
* @param {number | null} emoji - filter by reaction code, usually interpreted by clients as emoji code point
* @param {number | null} before - filter reactions created at or before this moment
* @param {number | null} limit - maximum number of reactions returned
* @return {Promise<API.ReactionsSliceInfo>}
*/
getCommentReactionsSlice(postingId_1, commentId_1) {
return __awaiter(this, arguments, void 0, function* (postingId, commentId, negative = null, emoji = null, before = null, limit = null) {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions`;
const params = { negative, emoji, before, limit };
return yield this.call("getCommentReactionsSlice", location, {
method: "GET", params, schema: "ReactionsSliceInfo"
});
});
}
/**
* Get the detailed information about the reaction of the given owner to the given comment. If no reaction with
* such an owner exists, an empty structure with just ``commentId`` is returned.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {string} ownerName - reaction owner node name
* @return {Promise<API.ReactionInfo>}
*/
getCommentReaction(postingId, commentId, ownerName) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions/${ownerName}`;
return yield this.call("getCommentReaction", location, {
method: "GET", schema: "ReactionInfo"
});
});
}
/**
* Delete all reactions to the given comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @return {Promise<API.Result>}
*/
deleteAllCommentReactions(postingId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions`;
return yield this.call("deleteAllCommentReactions", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Delete the reaction of the given owner to the given comment.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @param {string} ownerName - reaction owner node name
* @return {Promise<API.ReactionTotalsInfo>}
*/
deleteCommentReaction(postingId, commentId, ownerName) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reactions/${ownerName}`;
return yield this.call("deleteCommentReaction", location, {
method: "DELETE", schema: "ReactionTotalsInfo"
});
});
}
/**
* Get a summary of reactions to the comment given.
*
* @param {string} postingId - ID of the posting
* @param {string} commentId - ID of the comment
* @return {Promise<API.ReactionTotalsInfo>}
*/
getCommentReactionTotals(postingId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/comments/${commentId}/reaction-totals`;
return yield this.call("getCommentReactionTotals", location, {
method: "GET", schema: "ReactionTotalsInfo"
});
});
}
/**
* Search for contacts matching the search ``query``. Every space-delimited word in the query must match
* case-insensitively a beginning of the contact's node name or a beginning of any space-delimited word in the
* contact's full name. The order of words is not significant. \
* \
* The node may decide to return fewer contacts than the given ``limit``. \
* \
* The contacts are sorted by *social distance* from the node, which depends on their subscription and friendship
* status and the number of recent reactions and comments.
*
* @param {string | null} query - the search query
* @param {number | null} limit - maximum number of contacts returned
* @return {Promise<API.ContactInfo[]>}
*/
getContacts() {
return __awaiter(this, arguments, void 0, function* (query = null, limit = null) {
const location = (0, util_1.ut) `/people/contacts`;
const params = { query, limit };
return yield this.call("getContacts", location, {
method: "GET", params, schema: "ContactInfoArray"
});
});
}
/**
* Check whether the credentials are initialized already.
*
* @return {Promise<API.CredentialsCreated>}
*/
checkCredentials() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/credentials";
return yield this.call("checkCredentials", location, {
method: "GET", schema: "CredentialsCreated"
});
});
}
/**
* Initialize credentials if they are not set yet. Note that this operation can be executed without authentication,
* so this should be done as soon as possible after the node installation. Sign in is not allowed until the
* credentials are set.
*
* @param {API.Credentials} credentials
* @return {Promise<API.Result>}
*/
createCredentials(credentials) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/credentials";
return yield this.call("createCredentials", location, {
method: "POST", body: credentials, schema: "Result"
});
});
}
/**
* Update credentials. Either old password or credentials reset token should be set in the input for the operation
* to succeed. Credentials reset token is not related to the authentication token and usually is sent to the user
* by E-mail.
*
* @param {API.CredentialsChange} credentials
* @return {Promise<API.Result>}
*/
updateCredentials(credentials) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/credentials";
return yield this.call("updateCredentials", location, {
method: "PUT", body: credentials, schema: "Result"
});
});
}
/**
* Delete credentials.
*
* @return {Promise<API.Result>}
*/
deleteCredentials() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/credentials";
return yield this.call("deleteCredentials", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* The node generates credentials reset token that is sent to the node admin by E-mail or using any other way that
* is defined for recovery of credentials. This token then may be used to change the credentials without knowing
* the password.
*
* @return {Promise<API.EmailHint>}
*/
resetCredentials() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/credentials/reset";
return yield this.call("resetCredentials", location, {
method: "POST", schema: "EmailHint"
});
});
}
/**
* Get the list of deleted postings, page by page. The node may decide to use a smaller page size than the given
* ``limit``. The postings are always sorted by the deletion timestamp, descending.
*
* @param {number | null} page - page number, 0 by default
* @param {number | null} limit - page size (maximum number of postings returned), the default is defined by the
* node
* @return {Promise<API.PostingInfo[]>}
*/
getDeletedPostings() {
return __awaiter(this, arguments, void 0, function* (page = null, limit = null) {
const location = (0, util_1.ut) `/deleted-postings`;
const params = { page, limit };
return yield this.call("getDeletedPostings", location, {
method: "GET", params, schema: "PostingInfoArray", bodies: true
});
});
}
/**
* Get an individual deleted posting.
*
* @param {string} id - ID of the posting
* @return {Promise<API.PostingInfo>}
*/
getDeletedPosting(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/deleted-postings/${id}`;
return yield this.call("getDeletedPosting", location, {
method: "GET", schema: "PostingInfo", bodies: true
});
});
}
/**
* Restore a posting. A new revision is created with the same content as in the latest revision.
*
* @param {string} id - ID of the posting
* @return {Promise<API.PostingInfo>}
*/
restoreDeletedPosting(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/deleted-postings/${id}/restore`;
return yield this.call("restoreDeletedPosting", location, {
method: "POST", schema: "PostingInfo", bodies: true
});
});
}
/**
* Get all revisions of the deleted posting, but not more than ``limit``. The node may decide to return fewer
* revisions than the given ``limit``.
*
* @param {string} postingId - ID of the posting
* @param {number | null} limit - maximum number of revisions returned
* @return {Promise<API.PostingRevisionInfo[]>}
*/
getDeletePostingRevisions(postingId_1) {
return __awaiter(this, arguments, void 0, function* (postingId, limit = null) {
const location = (0, util_1.ut) `/deleted-postings/${postingId}/revisions`;
const params = { limit };
return yield this.call("getDeletePostingRevisions", location, {
method: "GET", params, schema: "PostingRevisionInfoArray", bodies: true
});
});
}
/**
* Get an individual revision of the deleted posting.
*
* @param {string} postingId - ID of the posting
* @param {string} id - ID of the revision
* @return {Promise<API.PostingRevisionInfo>}
*/
getDeletedPostingRevision(postingId, id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/deleted-postings/${postingId}/revisions/${id}`;
return yield this.call("getDeletedPostingRevision", location, {
method: "GET", schema: "PostingRevisionInfo", bodies: true
});
});
}
/**
* Restore a posting at a particular revision. A new revision is created with the same content as in the given
* revision.
*
* @param {string} postingId - ID of the posting
* @param {string} id - ID of the revision
* @return {Promise<API.PostingRevisionInfo>}
*/
restoreDeletedPostingRevision(postingId, id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/postings/${postingId}/revisions/${id}/restore`;
return yield this.call("restoreDeletedPostingRevision", location, {
method: "POST", schema: "PostingRevisionInfo", bodies: true
});
});
}
/**
* Get the list of registered domains.
*
* @return {Promise<API.DomainInfo[]>}
*/
getDomains() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/domains";
return yield this.call("getDomains", location, {
method: "GET", schema: "DomainInfoArray"
});
});
}
/**
* Get information about the domain with the given hostname. If domain registration for this server is public, this
* request does not require authentication.
*
* @param {string} name - domain name
* @return {Promise<API.DomainInfo>}
*/
getDomain(name) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/domains/${name}`;
return yield this.call("getDomain", location, {
method: "GET", schema: "DomainInfo"
});
});
}
/**
* Create a new domain with the given hostname. If ``nodeId`` is not passed, it is generated automatically. If
* domain registration for this server is public, this request does not require authentication.
*
* @param {API.DomainAttributes} domain
* @return {Promise<API.DomainInfo>}
*/
createDomain(domain) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/domains";
return yield this.call("createDomain", location, {
method: "POST", body: domain, schema: "DomainInfo"
});
});
}
/**
* Update the domain with the given hostname. If the new hostname is not passed, the old hostname is preserved.
* (Note that you cannot pass a new name for the default hostname, because it cannot be renamed and ``_default_``
* is not a valid hostname. Skip this field if you want to update the default hostname.) If ``nodeId`` is not
* passed, it is generated automatically.
*
* @param {string} name - domain's hostname
* @param {API.DomainAttributes} domain
* @return {Promise<API.DomainInfo>}
*/
updateDomain(name, domain) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/domains/${name}`;
return yield this.call("updateDomain", location, {
method: "PUT", body: domain, schema: "DomainInfo"
});
});
}
/**
* Delete the domain with the given hostname. This operation deletes the domain record only, the user's data
* related to the domain is preserved.
*
* @param {string} name - domain name
* @return {Promise<API.Result>}
*/
deleteDomain(name) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/domains/${name}`;
return yield this.call("deleteDomain", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Get an available domain name recommended for the given node name. The domain name is usually chosen to be close
* to the node name in English transcription. If domain registration for this server is not public, this request is
* not accessible.
*
* @param {string} remoteNodeName - node name
* @return {Promise<API.DomainAvailable>}
*/
isDomainAvailable(remoteNodeName) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/domains/available`;
const params = { nodeName: remoteNodeName };
return yield this.call("isDomainAvailable", location, {
method: "GET", params, schema: "DomainAvailable"
});
});
}
/**
* Get the list of drafts, page by page, filtered by the given criteria. The node may decide to use a smaller page
* size than the given ``limit``. The drafts are always sorted by the creation timestamp, descending.
*
* @param {API.DraftType} draftType - type of the drafts
* @param {string} remoteNodeName - name of the node the drafts are related to
* @param {string | null} postingId - ID of the posting, mandatory for all types, except ``new-posting``
* @param {string | null} commentId - ID of the comment, mandatory for ``comment-update`` type
* @param {number | null} page - page number, 0 by default
* @param {number | null} limit - page size (maximum number of postings returned), the default is defined by the
* node
* @return {Promise<API.DraftInfo[]>}
*/
getDrafts(draftType_1, remoteNodeName_1) {
return __awaiter(this, arguments, void 0, function* (draftType, remoteNodeName, postingId = null, commentId = null, page = null, limit = null) {
const location = (0, util_1.ut) `/drafts`;
const params = { draftType, nodeName: remoteNodeName, postingId, commentId, page, limit };
return yield this.call("getDrafts", location, {
method: "GET", params, schema: "DraftInfoArray", bodies: true
});
});
}
/**
* Create a new draft from the text given.
*
* @param {API.DraftText} draft
* @return {Promise<API.DraftInfo>}
*/
createDraft(draft) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/drafts";
return yield this.call("createDraft", location, {
method: "POST", body: draft, schema: "DraftInfo", bodies: true, srcBodies: true
});
});
}
/**
* Get an individual draft.
*
* @param {string} id - ID of the draft
* @return {Promise<API.DraftInfo>}
*/
getDraft(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/drafts/${id}`;
return yield this.call("getDraft", location, {
method: "GET", schema: "DraftInfo", bodies: true
});
});
}
/**
* Update the draft.
*
* @param {string} id - ID of the draft
* @param {API.DraftText} draft
* @return {Promise<API.DraftInfo>}
*/
updateDraft(id, draft) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/drafts/${id}`;
return yield this.call("updateDraft", location, {
method: "PUT", body: draft, schema: "DraftInfo", bodies: true, srcBodies: true
});
});
}
/**
* Delete the draft.
*
* @param {string} id - ID of the draft
* @return {Promise<API.Result>}
*/
deleteDraft(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/drafts/${id}`;
return yield this.call("deleteDraft", location, {
method: "DELETE", schema: "Result"
});
});
}
/**
* Get information about features supported by the node.
*
* @return {Promise<API.Features>}
*/
getFeatures() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/features";
return yield this.call("getFeatures", location, {
method: "GET", schema: "Features"
});
});
}
/**
* Get general information about all feeds accessible by client.
*
* @return {Promise<API.FeedInfo[]>}
*/
getFeeds() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/feeds";
return yield this.call("getFeeds", location, {
method: "GET", schema: "FeedInfoArray"
});
});
}
/**
* Get general information about the feed.
*
* @param {string} feedName - name of the feed
* @return {Promise<API.FeedInfo>}
*/
getFeedGeneral(feedName) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/feeds/${feedName}`;
return yield this.call("getFeedGeneral", location, {
method: "GET", schema: "FeedInfo"
});
});
}
/**
* Get information about the total number and number of non-read and non-viewed stories in the feed.
*
* @param {string} feedName - name of the feed
* @return {Promise<API.FeedStatus>}
*/
getFeedStatus(feedName) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/feeds/${feedName}/status`;
return yield this.call("getFeedStatus", location, {
method: "GET", schema: "FeedStatus"
});
});
}
/**
* Update information about non-read and non-viewed stories in the feed.
*
* @param {string} feedName - name of the feed
* @param {API.FeedStatusChange} change
* @return {Promise<API.FeedStatus>}
*/
updateFeedStatus(feedName, change) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/feeds/${feedName}/status`;
return yield this.call("updateFeedStatus", location, {
method: "PUT", body: change, schema: "FeedStatus"
});
});
}
/**
* Get a slice of the feed, delimited by ``before`` or ``after`` moments (but not both) and the given ``limit``. If
* neither ``before`` nor ``after`` are provided, the latest stories are returned. The node may decide to return
* fewer stories than the given ``limit``. The stories are always sorted by moment, descending.
*
* @param {string} feedName - name of the feed
* @param {number | null} after - filter stories posted strongly after this moment
* @param {number | null} before - filter stories posted at or before this moment
* @param {number | null} limit - maximum number of stories returned
* @return {Promise<API.FeedSliceInfo>}
*/
getFeedSlice(feedName_1) {
return __awaiter(this, arguments, void 0, function* (feedName, after = null, before = null, limit = null) {
const location = (0, util_1.ut) `/feeds/${feedName}/stories`;
const params = { after, before, limit };
return yield this.call("getFeedSlice", location, {
method: "GET", params, schema: "FeedSliceInfo", bodies: true
});
});
}
/**
* Delete all stories from the feed with optional filtering.
*
* @param {string} feedName - name of the feed
* @param {API.StoryType | null} type - delete only the stories of the given type
* @param {string | null} receiver - delete only the stories about postings located at the given node
* @param {boolean | null} recommended - delete only the stories about recommended postings
* @return {Promise<API.Result>}
*/
deleteFeedStories(feedName_1) {
return __awaiter(this, arguments, void 0, function* (feedName, type = null, receiver = null, recommended = null) {
const location = (0, util_1.ut) `/feeds/${feedName}/stories`;
const params = { type, receiver, recommended };
return yield this.call("deleteFeedStories", location, {
method: "DELETE", params, schema: "Result"
});
});
}
/**
* Get the list of all groups of friends that exist on the node.
*
* @return {Promise<API.FriendGroupInfo[]>}
*/
getFriendGroups() {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/friends/groups";
return yield this.call("getFriendGroups", location, {
method: "GET", schema: "FriendGroupInfoArray"
});
});
}
/**
* Get the information about the group of friends.
*
* @param {string} id - ID of the group of friends
* @return {Promise<API.FriendGroupInfo>}
*/
getFriendGroup(id) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/people/friends/groups/${id}`;
return yield this.call("getFriendGroup", location, {
method: "GET", schema: "FriendGroupInfo"
});
});
}
/**
* Create a group of friends.
*
* @param {API.FriendGroupDescription} friendGroup
* @return {Promise<API.FriendGroupInfo>}
*/
createFriendGroup(friendGroup) {
return __awaiter(this, void 0, void 0, function* () {
const location = "/people/friends/groups";
return yield this.call("createFriendGroup", location, {
method: "POST", body: friendGroup, schema: "FriendGroupInfo"
});
});
}
/**
* Update the details of the group of friends.
*
* @param {string} id - ID of the group of friends
* @param {API.FriendGroupDescription} friendGroup
* @return {Promise<API.FriendGroupInfo>}
*/
updateFriendGroup(id, friendGroup) {
return __awaiter(this, void 0, void 0, function* () {
const location = (0, util_1.ut) `/people/friends/groups/${id}`;
return yield this.call("updateFriendGroup", location, {
method: "PUT", body: friendGroup, schema: "FriendGroupInfo"
});
});
}
/**
* Delete the group of friends.
*
* @param {string} id - ID of the group of friends
* @return {Promise<API.Result>}
*/