UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

203 lines 6.87 kB
import { CommentCollectionState, CommentsActions, CommentsState } from './commentReducer'; import { Comment, CommentModule, CommentSortCriteria, GetCommentResult, GetMultipleCommentsResult } from './index'; import { Thunk, XcapJsonErrors } from '../api'; import SortOrder from '../api/SortOrder'; import { LikesByCurrentUser } from '../like'; /** * Get the key used to look up comments * @param action * @returns {string} */ export declare function _getCommentsStateKey<T extends { module: CommentModule; referenceGroupId: number; commentSortCriteria: CommentSortCriteria; order: SortOrder; }>(action: T): string; /** * Get the key used to look up comments * @param module * @param referenceGroupId * @param commentSortCriteria * @param order * @returns {string} */ export declare function getCommentsStateKey(module: CommentModule, referenceGroupId: number, commentSortCriteria: CommentSortCriteria, order: SortOrder): string; /** * Add comments to the redux store (typically run by the fetch-methods) * @param module * @param referenceGroupId * @param json * @param commentSortCriteria * @param order */ export declare function receiveGroupComments(module: CommentModule, referenceGroupId: number, json: { comments: any; likesByCurrentUser: any; }, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentsActions; /** * Request comments from the server * @param module * @param referenceGroupId * @param commentSortCriteria * @param order */ export declare function requestGroupComments(module: CommentModule, referenceGroupId: number, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentsActions; /** * Requests and receive comments and store them in redux-state * @param module * @param referenceIds * @param referenceGroupId * @param p * @param pageSize * @param commentSortCriteria * @param order */ export declare function fetchMultipleComments({ module, referenceIds, referenceGroupId, p, pageSize, commentSortCriteria, order }: { module: CommentModule; referenceIds: Array<number>; referenceGroupId: number; p?: number; pageSize?: number; commentSortCriteria?: CommentSortCriteria; order?: SortOrder.DESCENDING; }): Thunk<Promise<GetMultipleCommentsResult>>; export interface ReceiveCommentsJson { comments: { entries: Array<Comment>; }; likesByCurrentUser: LikesByCurrentUser; error?: XcapJsonErrors; } /** * Add comments into the redux store (typically run by the fetch-methods) * @param module * @param referenceId * @param referenceGroupId * @param json * @param commentSortCriteria * @param order */ export declare function receiveComments(module: CommentModule, referenceId: number, referenceGroupId: number, json: ReceiveCommentsJson, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentsActions; /** * Request comments from the server */ export declare function requestComments(module: CommentModule, referenceId: number, referenceGroupId: number, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentsActions; /** * Remove comments from the redux store (but not from the backend storage) */ export declare function invalidateComments({ module, referenceGroupId, commentSortCriteria, order }: { module: CommentModule; referenceGroupId: number; commentSortCriteria: CommentSortCriteria; order: SortOrder; }): CommentsActions; /** * When loading comments receive is run when the server has responded * @param id * @param module * @param referenceId * @param referenceGroupId * @param json * @param commentSortCriteria * @param order */ export declare function updateComment(id: number, module: CommentModule, referenceId: number, referenceGroupId: number, json: Comment, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentsActions; export interface FetchComments { module: CommentModule; /** * Reference id to fetch comments for ex: blogEntryId */ referenceId: number; /** * Reference group id, for example blog id (optional) */ referenceGroupId?: number; /** * Sort */ commentSortCriteria?: CommentSortCriteria; /** * Sort order */ order?: SortOrder; /** * Page number in paginated collection */ p?: number; /** * Number of entries per page */ pageSize?: number; /** * Fetch vote/rating data? */ useVotes?: boolean; } /** * Requests and receive comments and store them in redux-state */ export declare function fetchComments({ module, referenceId, referenceGroupId, commentSortCriteria, order, p, pageSize, useVotes }: FetchComments): Thunk<Promise<GetCommentResult | null>>; /** * Fetch a single comment * @param module * @param id * @param referenceId * @param referenceGroupId * @param commentSortCriteria * @param order * @param useVotes */ export declare function fetchComment({ module, id, referenceId, referenceGroupId, commentSortCriteria, order, useVotes }: { module: CommentModule; id: number; referenceId: number; referenceGroupId: number; commentSortCriteria?: CommentSortCriteria; order?: SortOrder; useVotes?: boolean; }): Thunk<Promise<GetCommentResult>>; /** * Remove a comment from the store. * @param module * @param id * @param referenceId * @param referenceGroupId * @param commentSortCriteria * @param order */ export declare function removeCommentFromStore({ module, id, referenceId, referenceGroupId, commentSortCriteria, order }: { module: CommentModule; id: number; referenceId: number; referenceGroupId?: number; commentSortCriteria: CommentSortCriteria; order: SortOrder; }): Thunk<void>; /** * Get comments from the redux store * @param commentsState * @param commentType * @param referenceGroupId * @param referenceId * @param commentSortCriteria * @param order * @returns a CommentCollectionState or null, if not loaded */ export declare function getCommentsFromStore(commentsState: CommentsState, commentType: CommentModule, referenceGroupId: number, referenceId: number, commentSortCriteria: CommentSortCriteria, order: SortOrder): CommentCollectionState | null; /** * Get the number of minutes to edit a comment, or -1 for eternal. * @param commentsState * @param commentType * @param referenceGroupId * @param referenceId * @param commentSortCriteria * @param order */ export declare function getMinutesToEdit(commentsState: CommentsState, commentType: CommentModule, referenceGroupId: number, referenceId: number, commentSortCriteria: CommentSortCriteria, order: SortOrder): number; /** * Update the comments likes in the redux store * @param json */ export declare function receiveCommentLikes(json: ReceiveCommentsJson): Thunk<void>; //# sourceMappingURL=commentAction.d.ts.map