UNPKG

@solarpunkltd/comment-system

Version:

A library for writing and reading comments from the Swarm network.

77 lines 4.46 kB
import { FeedIndex, UploadResult } from '@ethersphere/bee-js'; import { CommentNode, MessageData } from './model/comment.model'; import { Options } from './model/options.model'; /** * Write a comment to the next index of the feed with the given options. * * @param comment The comment object to write to the feed. * @param options The options to use for writing the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * @throws StampError if no valid stamp is found. * * @returns An UploadResult object returned by the feed update or undefined in case of failure. */ export declare function writeComment(comment: MessageData, options?: Options): Promise<UploadResult | undefined>; /** * Write a comment to a specific index of the feed with the given options. * Defaults to @writeComment if no index is provided. * * @param comment The comment object to write to the feed. * @param index The index to write the comment to. * @param options The options to use for writing the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * @throws StampError if no valid stamp is found. * * @returns An UploadResult object returned by the feed update or undefined in case of failure. */ export declare function writeCommentToIndex(comment: MessageData, index?: FeedIndex, options?: Options): Promise<UploadResult | undefined>; /** * Read comments in succession until the latest index of the feed with the given options. * * @param options The options to use for reading the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * * @returns The the array of comment objects that were read from the feed or undefined in case of failure. */ export declare function readComments(options?: Options): Promise<MessageData[] | undefined>; /** * Read nested comments in succession until the latest index of the feed with the given options. * * @param start The start index of the range. * @param end The end index of the range. * @param options The options to use for reading the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * * @returns The the array of nested comment objects that were read from the feed or undefined in case of failure. */ export declare function readCommentsAsTree(start?: FeedIndex, end?: FeedIndex, options?: Options): Promise<CommentNode[] | undefined>; /** * Read comments in parallel within the provided range of indices of the feed with the given options. * Defaults to @readComments if no start or end index is provided. * * @param start The start index of the range. * @param end The end index of the range. * @param options The options to use for reading the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * * @returns The the array of comment objects that were read from the feed or undefined in case of failure. */ export declare function readCommentsInRange(start?: FeedIndex, end?: FeedIndex, options?: Options): Promise<MessageData[] | undefined>; /** * Read a single comment at the provided index of the feed with the given options. * Reads the latest comment if no index is provided, in which case the next index is also returned. * * @param index The index of the comment to read. * @param options The options to use for reading the comment. * @throws PrivateKeyError if no privatekey is provided and it cannot be generated from the url. * @throws IdentifierError if no identifier is provided and it cannot be generated from the privatekey. * * @returns The the comment object that was read from the feed or undefined in case of failure. */ export declare function readSingleComment(index?: FeedIndex, options?: Options): Promise<MessageData | undefined>; //# sourceMappingURL=comments.d.ts.map