UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

195 lines 6.79 kB
import { Thunk, XcapJsonResult, XcapOptionalParameters } from '../api'; import SortOrder from '../api/SortOrder'; import UserApprovalStatus from '../api/UserApprovalStatus'; import { LikesByCurrentUser } from '../like'; import { PaginatedCollection } from '../api/PaginatedCollection'; import CreatedDateAware from '../api/CreatedDateAware'; import XcapObject from '../api/XcapObject'; import CreatorUserIdAware from '../api/CreatorUserIdAware'; import ModifiedDateAware from '../api/ModifiedDateAware'; import ModifiedByUserIdAware from '../api/ModifiedByUserIdAware'; import PermalinkAware from '../api/PermalinkAware'; import ModerationAware from '../api/ModerationAware'; import ExpirationDateAware from '../api/ExpirationDateAware'; import ReferenceIdAware from '../api/ReferenceIdAware'; import ReferenceGroupIdAware from '../api/ReferenceGroupIdAware'; import UserApprovalAware from '../api/UserApprovalAware'; import ReferenceAble from '../api/ReferenceAble'; /** * Comment class name */ export declare const COMMENT_CLASS = "se.josh.xcap.comment.impl.CommentImpl"; /** * Comment manager component class name */ export declare const COMPONENT_CLASS = "se.josh.xcap.comment.CommentManager"; /** * Component name */ export declare const COMPONENT_NAME = "comment"; /** * Definition of a comment */ export interface Comment extends XcapObject, CreatorUserIdAware, CreatedDateAware, ModifiedDateAware, ModifiedByUserIdAware, PermalinkAware, ModerationAware, ExpirationDateAware, ReferenceIdAware<XcapObject>, ReferenceGroupIdAware, UserApprovalAware, ReferenceAble { __type: 'se.josh.xcap.comment.impl.CommentImpl'; parentId: number /** parent id if reply */; subject: string; body: string; plainTextBody: string; numberOfLikes: number; type?: string; } /** * Sort criteria */ export declare enum CommentSortCriteria { /** * Sort by creation date. */ CREATED = "CREATED", /** * Sort after creation date, but preserving replies. The commenting system * supports one level of replies. */ CREATED_WITH_REPLIES = "CREATED_WITH_REPLIES" } /** * Is this comments instance tied to another function, or free standing? */ export declare enum CommentModule { /** * Free standing comments */ GENERIC = "", /** * Comments on blog entries */ BLOG = "blog", /** * Comments on forum entries */ FORUM = "forum", /** * Personal shopper (personal) comments */ PERSONAL_SHOPPER = "personal-shopper" } export interface BaseCommentRequest extends XcapOptionalParameters { module: CommentModule; useVotes?: boolean; } export interface ListRequest extends BaseCommentRequest { referenceId: number; p?: number | null; pageSize?: number | null; sortCriteria?: CommentSortCriteria; order?: SortOrder; } export interface BaseCommentsResult extends XcapJsonResult { likesByCurrentUser: LikesByCurrentUser; } export interface GetCommentResult extends BaseCommentsResult { comment: Comment | null; } export interface GetRequest extends BaseCommentRequest { id: number; } /** * Get a single comment * @param id * @param module * @param referenceId * @param useVotes */ export declare function getComment({ id, module, useVotes }: GetRequest): Thunk<Promise<GetCommentResult>>; export interface GetCommentsResult extends BaseCommentsResult { comments: PaginatedCollection<Comment>; minutesToEdit: number; commentsAllowed: boolean; } /** * Get comments for a reference id. * * @param module {CommentModule} optional module: "blog" to get blog comments * @param referenceId Reference id (required) * @param sortCriteria {CommentSortCriteria} (optional) * @param order {SortOrder} (optional) * @param p Page number (optional) * @param pageSize Page size (optional) * @param useVotes Fetch votes (optional) */ export declare function getComments({ module, referenceId, p, pageSize, sortCriteria, order, useVotes }: ListRequest): Thunk<Promise<GetCommentsResult>>; export interface GetMultipleCommentsResult extends XcapJsonResult { likesByCurrentUser: LikesByCurrentUser; /** Maps from reference id to comments */ comments: { [referenceId: string]: PaginatedCollection<Comment>; }; minutesToEdit: number; } /** * Get multiple comments given an array of reference ids. * * Pagination is not supported since we deal with multiple collections. * However, the page size can be set and applies to all collections. * * The result is returned as a map from reference Ids to PaginatedCollection of comments. * * Pagination for the separate comment lists can be implemented using {@link getComments}. * * @param module {CommentModule} optional module: "blog" to get blog comments * @param referenceIds {Array} of referenceIds * @param sortCriteria * @param order * @param p * @param pageSize */ export declare function getMultipleComments({ module, referenceIds, p, pageSize, sortCriteria, order }: { module: CommentModule; referenceIds: Array<number>; p: number | null | undefined; pageSize: number | null | undefined; sortCriteria?: CommentSortCriteria; order?: SortOrder; }): Thunk<Promise<GetMultipleCommentsResult>>; export interface PostCommentResult extends XcapJsonResult { comment: Comment; } /** * Post a comment. * @param commentId {number} Comment id, available on edit.. (Optional) * @param module {CommentModule} optional module: "blog" to get blog comments * @param referenceId {number} Reference id * @param referenceGroupId Optional reference group id * @param parentId Id of parent comment, if reply (Optional) * @param subject * @param body Body HTML. Up to 64KB. * @param extraInformation Application specific text. * @param referenceUrl Reference url */ export declare function postComment({ commentId, referenceId, referenceGroupId, module, parentId, subject, body, extraInformation, referenceUrl, createdDate }: { commentId?: number; referenceId: number; referenceGroupId?: number; module: CommentModule; parentId?: number; subject?: string; body: string; extraInformation?: any; referenceUrl?: string; createdDate?: number; } & XcapOptionalParameters): Thunk<Promise<PostCommentResult>>; /** * Set user approval status of a comment * @param id * @param status * @param commentModule * @param moduleId, optional module id for checking elevated privileges */ export declare function setCommentUserApprovalStatus({ id, status, commentModule, moduleId }: { id: number; status: UserApprovalStatus; commentModule: CommentModule; moduleId?: number; } & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>; //# sourceMappingURL=index.d.ts.map