@stackend/api
Version:
JS bindings to api.stackend.com
442 lines • 14.7 kB
TypeScript
import { Thunk, XcapJsonResult, XcapOptionalParameters } from '../api';
import * as categoryApi from '../category';
import { PaginatedCollection } from '../api/PaginatedCollection';
import { Request } from '../request';
import { VoteSummary } from '../vote';
import { LikeDataMap } from '../like';
import CreatedDateAware from '../api/CreatedDateAware';
import CreatorUserIdAware from '../api/CreatorUserIdAware';
import XcapObject from '../api/XcapObject';
import PermalinkAware from '../api/PermalinkAware';
import ReferenceAble from '../api/ReferenceAble';
import NameAware from '../api/NameAware';
import DescriptionAware from '../api/DescriptionAware';
import ModerationAware from '../api/ModerationAware';
import ModifiedDateAware from '../api/ModifiedDateAware';
import ModifiedByUserIdAware from '../api/ModifiedByUserIdAware';
/**
* Xcap Forum API constants and methods.
*
* @since 22 jun 2017
*/
export declare enum AnonymityLevel {
/**
* No anonymity
*/
NOT_ANONYMOUS = "NOT_ANONYMOUS",
/**
* Anonymity from other users only.
* Admins may still reveal the user id
*/
TRACEABLE_ANONYMITY = "TRACEABLE_ANONYMITY",
/**
* Completely anonymous
*/
ANONYMOUS = "ANONYMOUS"
}
export interface Forum extends XcapObject, CreatedDateAware, PermalinkAware, ReferenceAble, NameAware, DescriptionAware {
__type: 'net.josh.community.forum.impl.ForumImpl';
ruleTypeId: number;
anonymityLevel: AnonymityLevel;
lastThreadEntryCreatedDate: any;
lastThreadEntryId: number;
totalNrOfEntries: number;
totalThreads: number;
}
export interface ForumThreadEntry extends XcapObject, CreatedDateAware, CreatorUserIdAware, ModerationAware, ModifiedDateAware, ModifiedByUserIdAware, PermalinkAware, ReferenceAble, NameAware {
__type: 'net.josh.community.forum.impl.ForumThreadImpl';
categoriesRef: Array<categoryApi.Category>;
creatorName: string;
expiresDate: Date;
forumId: number;
forumRef: Forum;
lastEntryDate: Date;
lastEntryId: number;
nrOfEntries: number;
nrOfNeedHelp: number;
nrOfReplies: number;
numberOfLikes: number;
open: boolean;
plainText: string;
ruleTypeId: number;
solved: boolean;
sticky: boolean;
text: string;
threadRef: ForumThreadEntry;
url: string;
voteSummary: VoteSummary;
}
/**
* Forum Component name
* @type {string}
*/
export declare const COMPONENT_NAME = "forum";
export declare const FORUM_CLASS = "net.josh.community.forum.impl.ForumImpl";
export declare const FORUM_THREAD_CLASS = "net.josh.community.forum.impl.ForumThreadImpl";
export declare const FORUM_THREAD_ENTRY_CLASS = "net.josh.community.forum.impl.ForumThreadEntryImpl";
/**
* Component class (used to look up privileges, etc)
*/
export declare const COMPONENT_CLASS = "net.josh.community.forum.ForumManager";
/**
* Get the url to a forum or forum thread
* @param request
* @param forumPermalink
* @param threadPermalink
* @param absolute
* @param community
* @return {string}
* @deprecated Implement in frontend code
*/
export declare function getForumUrl({ request, forumPermalink, threadPermalink, community, absolute }: {
request: Request;
forumPermalink?: string;
threadPermalink?: string;
absolute?: boolean;
community?: string;
}): string;
/**
* Permalink for the QNA forum
*/
export declare const QNA_FORUM_PERMALINK = "question";
/**
* returns the url to Ask a question in the Qnas.
* @deprecated Implement in frontend code instead
*/
export declare function getCreateThreadUrl({ request, forumPermalink }: {
request: Request;
forumPermalink?: string;
}): string;
export interface ListForumsResult extends XcapJsonResult {
forumsPaginated: PaginatedCollection<Forum>;
forumCount: {
numberOfForums: number;
numberOfThreads: number;
numberOfEntries: number;
};
pageSize: number;
p: number;
}
/**
* Create a sorum thread
* @param subject
* @param text
* @param categoryId
* @param entryId
* @param forumThreadPermalink
* @param forumPermalink
*/
export declare function editForumThread({ subject, text, categoryId, forumThreadPermalink, forumPermalink, isAI }: {
subject: string;
text: string;
categoryId?: Array<number>;
forumThreadPermalink?: any;
forumPermalink: string;
isAI: boolean;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List forums
*
* @param p Page number (optional)
* @param pageSize Page size (optional)
* @returns {Promise}
*/
export declare function listForums({ p, pageSize }: {
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<ListForumsResult>>;
export interface ListThreadsResult extends XcapJsonResult {
threadsPaginated: PaginatedCollection<ForumThreadEntry>;
forumId: number;
forumPermalink: string | null;
forumThreadPermalink: string | null;
likes: LikeDataMap;
votes: {
[referenceId: string]: any;
};
pageSize: number;
p: number;
}
/**
* List threads of a forum.
*
* @param forumPermalink permalink of forum
* @param p Page number (optional)
* @param pageSize Page size (optional)
* @returns {Promise}
*/
export declare function listThreads({ forumPermalink, p, pageSize }: {
forumPermalink: string;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<ListThreadsResult>>;
interface ListEntries extends XcapOptionalParameters {
forumPermalink: string;
forumThreadPermalink: string;
p?: number;
pageSize?: number;
entryId?: number;
isQna?: boolean;
}
export interface ListEntriesResult extends XcapJsonResult {
likes: LikeDataMap;
entriesPaginated: PaginatedCollection<ForumThreadEntry>;
thread: any;
}
/**
* List entries of a thread.
*
* @param forumPermalink permalink of forum
* @param forumThreadPermalink permalink of forum thread
* @param entryId {number} Jump to the page of this entry (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
* @param isQna
*/
export declare function listEntries({ forumPermalink, forumThreadPermalink, entryId, p, pageSize, isQna }: ListEntries): Thunk<Promise<ListEntriesResult>>;
/**
* List threads the user is watching.
* @param watchesHavingNewEntriesOnly {boolean} Set to true to only list threads with new entries.
*/
export declare function listWatchedThreads({ watchesHavingNewEntriesOnly }: {
watchesHavingNewEntriesOnly?: boolean;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Watch/unwatch a thread for new activity.
*
* @param threadId {number} Thread id.
* @param watch {boolean} If set to true, the thread is watched, if false, the watch is removed
*/
export declare function setThreadWatch({ threadId, watch }: {
threadId: number;
watch: boolean;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Pin a forum thread to the top of the listing.
* Works as a toggle.
* Requires admin access.
* @param threadId {number} Thread id.
*/
export declare function pinForumThread({ threadId }: {
threadId: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Close a forum thread.
* Requires admin access.
* @param threadId {number} Thread id.
*/
export declare function closeForumThread({ threadId }: {
threadId: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
export interface RemoveForumThreadEntryResult extends XcapJsonResult {
entry: ForumThreadEntry | null;
}
/**
* Remove a forum thread entry using moderation.
* Requires admin access or that user is owner of entry.
* @param v {number} Forum thread entry id.
*/
export declare function removeForumThreadEntry({ entryId }: {
entryId: number;
} & XcapOptionalParameters): Thunk<Promise<RemoveForumThreadEntryResult>>;
/**
* Move a forum thread to a different forum.
* Requires admin access.
* @param threadId {number} Thread id.
* @param forumId {number} New forum id
*/
export declare function moveForumThread({ threadId, forumId }: {
threadId: number;
forumId: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Pin a forum entry to the top of the listing.
* Works as a toggle.
* Requires admin access.
* @param entryId {number} Entry id.
*/
export declare function pinForumEntry({ entryId }: {
entryId: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Move an entry to a different thread.
* Requires admin access.
* @param entryId {number} Entry id.
* @param threadId {number} New thread id
* @param includeReplies {boolean} Should replies also be moved?
*/
export declare function moveForumEntry({ entryId, threadId, includeReplies }: {
entryId: number;
threadId: number;
includeReplies: boolean;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List the last active threads.
*
* @param categoryIds {number[]} Category ids (optional)
* @param categoryPermalinks {string[]} Category permalinks (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
*/
export declare function listLastActiveThreads({ categoryIds, categoryPermalinks, p, pageSize }: {
categoryIds?: Array<number>;
categoryPermalinks?: Array<string>;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List the last created threads.
*
* @param categoryIds {number[]} Category ids (optional)
* @param categoryPermalinks {string[]} Category permalinks (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
*/
export declare function listLastCreatedThreads({ categoryIds, categoryPermalinks, p, pageSize }: {
categoryIds?: Array<number>;
categoryPermalinks?: Array<string>;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List the most active threads.
*
* @param daysBack {number} Number of days back. (optional)
* @param categoryIds {number[]} Category ids (optional)
* @param categoryPermalinks {string[]} Category permalinks (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
*/
export declare function listMostActiveThreds({ daysBack, categoryIds, categoryPermalinks, p, pageSize }: {
daysBack?: number;
categoryIds?: Array<number>;
categoryPermalinks?: Array<string>;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List the most viewed threads.
*
* @param daysBack {number} Number of days back. (optional)
* @param categoryIds {number[]} Category ids (optional)
* @param categoryPermalinks {string[]} Category permalinks (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
*/
export declare function listMostViewedThreds({ daysBack, categoryIds, categoryPermalinks, p, pageSize }: {
daysBack?: number;
categoryIds?: Array<number>;
categoryPermalinks?: Array<string>;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* List the the forums with most new entries during the specified period.
*
* @param daysBack {number} Number of days back. (optional)
* @param categoryIds {number[]} Category ids (optional)
* @param categoryPermalinks {string[]} Category permalinks (optional)
* @param p Page number (optional)
* @param pageSize Page size (optional)
*/
export declare function listMostActiveForums({ daysBack, categoryIds, categoryPermalinks, p, pageSize }: {
daysBack?: number;
categoryIds?: Array<number>;
categoryPermalinks?: Array<string>;
p?: number;
pageSize?: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Assign additional categories to a forum thread.
*
* Will not affect previously assigned categories.
* Requires moderator access.
*
* @param threadId {number} Entry id.
* @param categoryIds {number[]} Additional categories
*/
export declare function addThreadCategories({ threadId, categoryIds }: {
threadId: number;
categoryIds: Array<number>;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Remove categories from a forum thread.
*
* Requires moderator access.
*
* @param threadId {number} Entry id.
* @param categoryIds {number[]} Remove these categories
*/
export declare function removeThreadCategories({ threadId, categoryIds }: {
threadId: number;
categoryIds: Array<number>;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
export interface VoteReturn {
allowAnonymousVotes: boolean;
availableScores: Array<number>;
average: number;
averageAsInt: number;
hasEnoughVotes: boolean;
hasVoted: boolean;
maxScore: number;
mayVote: boolean;
minScore: number;
minimumRequiredVotes: number;
referenceGroupId: number;
referenceId: number;
score: number;
vote: {
ip: string;
refId: number;
referenceGroupId: number;
score: number;
voteDate: number;
voterId: number;
};
voteSummary: VoteSummary;
__relatedObjects: any;
}
/**
* Vote thumbs up/down for a forum entry.
*
*/
export declare function vote({ forumThreadEntry, score }: {
/** 1 for thumbs down, 2 for thumbs up */
score: number;
forumThreadEntry: ForumThreadEntry;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Get vote summary (number of votes per score and total) for an entry.
* @param entryId
*/
export declare function getVoteSummary({ entryId }: {
entryId: number;
} & XcapOptionalParameters): Thunk<Promise<XcapJsonResult>>;
/**
* Search the store for a ForumThreadEntry matching the id or permalink
* @param forumThreads
* @param id
* @param forumPermalink
* @param forumThreadPermalink
*/
export declare function getThreadEntryFromRedux({ forumThreads, id, forumPermalink, forumThreadPermalink }: {
forumThreads: any;
id?: number;
forumPermalink?: string;
forumThreadPermalink?: string;
} & XcapOptionalParameters): ForumThreadEntry | null;
/**
* Search the store for a ForumThread matching the id or permalink
* @param forumThreads
* @param id
* @param forumPermalink
* @param forumThreadPermalink
*/
export declare function getThreadFromRedux({ forumThreads, id, forumPermalink, forumThreadPermalink }: {
forumThreads: any;
id?: number;
forumPermalink: string;
forumThreadPermalink?: string;
} & XcapOptionalParameters): ForumThreadEntry | null;
export {};
//# sourceMappingURL=index.d.ts.map