UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

382 lines 11.4 kB
import { Thunk, XcapJsonResult, XcapOptionalParameters } from '../api'; import * as event from '../event'; import { CurrentUserRsvpStatuses } from '../event'; import { Poll } from '../poll'; import * as group from '../group'; import { Request } from '../request'; import { Category } from '../category'; import { VoteSummary } from '../vote'; import { Image } from '../media'; import { AuthObject } from '../user/privileges'; import { PaginatedCollection } from '../api/PaginatedCollection'; import { LikeDataMap } from '../like'; import CreatedDateAware from '../api/CreatedDateAware'; import CreatorUserIdAware from '../api/CreatorUserIdAware'; import XcapObject from '../api/XcapObject'; import NameAware from '../api/NameAware'; import DescriptionAware from '../api/DescriptionAware'; import PermalinkAware from '../api/PermalinkAware'; import ModifiedDateAware from '../api/ModifiedDateAware'; import ReferenceAble from '../api/ReferenceAble'; import PublishDateAware from '../api/PublishDateAware'; import ModerationAware from '../api/ModerationAware'; import ReferenceIdAware from '../api/ReferenceIdAware'; import { RsvpUserResponses } from '../event/eventReducer'; /** * Xcap Blog api constants and methods. * * @since 6 feb 2017 */ /** * The default blog key * @type {string} */ export declare const DEFAULT_BLOG_KEY = "news"; /** * Default context for the blog * @type {string} */ export declare const DEFAULT_CONTEXT = "news"; /** * Component class (used to look up privileges, etc) */ export declare const COMPONENT_CLASS = "net.josh.community.blog.BlogManager"; /** * Component name * @type {string} */ export declare const COMPONENT_NAME = "blog"; /** * Blog entry class name */ export declare const BLOG_ENTRY_CLASS = "net.josh.community.blog.BlogEntry"; /** * Statuses of a blog entry */ export declare enum BlogEntryStatus { PUBLISHED = "PUBLISHED", DRAFT = "DRAFT", DELETED = "DELETED" } export declare type FeedType = 'groups' | 'blog' | 'discussion'; /** * Blog entry definition */ export declare type SlideId = number; export declare type SlideHtml = string; export declare type Slide = SlideId | SlideHtml; export interface Slideshow { frame: boolean; shadow: boolean; hasImageSlide: boolean; hasVideoSlide: boolean; empty: boolean; slides: Array<{ slide: Slide; }>; } export interface BlogEntry extends XcapObject, NameAware, DescriptionAware, PermalinkAware, CreatorUserIdAware, CreatedDateAware, ModifiedDateAware, ModerationAware, ReferenceAble, PublishDateAware { __type: 'net.josh.community.blog.BlogEntry'; blogId: number; blogRef: Blog; type: string; body: string; plainTextBody: string; categoryRef: Array<any>; slideshow?: Slideshow; eventRef?: event.Event; pollRef?: Poll; numberOfComments: number; numberOfLikes: number; tags?: string[]; pageId?: number; } /** * Blog definition */ export interface Blog extends XcapObject, NameAware, DescriptionAware, PermalinkAware, CreatedDateAware, ModifiedDateAware, ModerationAware, ReferenceIdAware<XcapObject>, ReferenceAble { __type: 'net.josh.community.blog.Blog'; creatorUserRef: any; categoryRef: any; css: number; cssName: string; /** * Number of entries */ entrySize: number; groupRef: group.Group /** Owning group */; publishedEntrySize: number; subtype: number; type: number; } /** * Blog with auth information */ export interface AuthBlog extends Blog { auth: AuthObject; } export interface BlogEntries { __relatedObjects: any; blogId: number; blogKey: string; likesByCurrentUser: any; resultPaginated: { entries: Array<BlogEntry>; }; userRsvpStatuses: any; } /** * Get the first image of the slideshow * @param slideshow * @returns {*} */ export declare function getFirstSlideshowImageUrl(slideshow: Slideshow | null): string | null; /** * returns the url to a specific Blog Entry */ export declare function getBlogEntryUrl({ request, entry }: { request: Request; entry: BlogEntry; }): string; /** * Create a new blogEntry that is ok to save. * @returns BlogEntry */ export declare function newBlogEntry(blogKey: string): SaveBlogEntryInput; export interface GetBlogParams extends XcapOptionalParameters { blogId?: number; blogKey?: string; } export interface GetBlogResult extends XcapJsonResult { blog: Blog | null; authBlog: AuthBlog | AuthObject | null; } /** * Get a blog given blogId or blogKey * @param parameters */ export declare function getBlog({ blogId, blogKey }: GetBlogParams): Thunk<Promise<GetBlogResult>>; export interface BlogEntryListingResult extends XcapJsonResult { resultPaginated: PaginatedCollection<BlogEntry>; } export interface GetEntriesResult extends BlogEntryListingResult { likes: LikeDataMap; userRsvpStatuses: CurrentUserRsvpStatuses; /** Maps from event id to status to list */ rsvpUserIds: RsvpUserResponses; likesByCurrentUser: LikeDataMap; categories: Array<Category>; blog: Blog | null; authBlog: AuthBlog | null; auth: AuthObject | null; } /** * List blog entries. * * @param q Search expression (optional) * @param blogKey List entries from a specific blog (optional, default: all) * @param blogId List entries from a specific blog (optional, default: all) * @param creatorUserId List entries by a specific user (optional, default all) * @param author List entries by a specific user alias (optional, default all) * @param p Page number (optional) * @param pageSize Page size (optional) * @param categoryPermaLink (optional) * @param categoryId (optional) * @param goToBlogEntry Start the pagination at the entry permalink (optional) * @returns {Thunk} */ export declare function getEntries({ q, blogKey, blogId, creatorUserId, author, p, pageSize, categoryPermaLink, categoryId, goToBlogEntry, tags }: XcapOptionalParameters & { q?: string; blogKey?: string; blogId?: number; creatorUserId?: number; author?: string; p?: number; pageSize?: number; categoryPermaLink?: string; categoryId?: number; goToBlogEntry?: string; tags?: string[]; }): Thunk<Promise<GetEntriesResult>>; /** * List blog entries that the current user has written. * * @param p Page number (optional) * @param pageSize Page size (optional) * @returns {Thunk} */ export declare function getMyEntries({ p, pageSize }: { p?: number; pageSize?: number; } & XcapOptionalParameters): Thunk<Promise<BlogEntryListingResult>>; /** * List the most popular blog entries. * * @param p Page number (optional) * @param pageSize Page size (optional) * @returns {Promise} */ export declare function getMostPopularEntries({ p, pageSize }: { p?: number; pageSize?: number; } & XcapOptionalParameters): Thunk<Promise<BlogEntryListingResult>>; export interface GetMostCommentedEntriesResult extends XcapJsonResult { mostCommentedPaginated: PaginatedCollection<BlogEntry>; } /** * List the blog entries with most comments. * * Specify either daysBack or startDate and endDate. * * @param daysBack {Number} statistics interval (optional) * @param startDate {Date} statistics interval (optional) * @param endDate {Date} statistics interval (optional) * @param p Page number (optional) * @param pageSize Page size (optional) * @returns {Promise} */ export declare function getMostCommentedEntries({ daysBack, startDate, endDate, p, pageSize }: { daysBack?: number; startDate?: any; endDate?: any; p?: number; pageSize?: number; } & XcapOptionalParameters): Thunk<Promise<GetMostCommentedEntriesResult>>; /** * List recommended blog entries. * * @param p Page number (optional) * @param pageSize Page size (optional) * @returns {Promise} */ export declare function getRecommendedEntries({ p, pageSize }: { p?: number; pageSize?: number; } & XcapOptionalParameters): Thunk<Promise<BlogEntryListingResult>>; export interface GetBlogEntryResult extends XcapJsonResult { likes: LikeDataMap; tags: Array<string>; categories: Array<Category>; voteSummary: VoteSummary; pinned: boolean; numberOfComments: number; blogKey: string; isEditAllowed: boolean; views: number; mainArticleImages: Array<Image>; blogEntry: BlogEntry | null; } /** * Get a blog entry. * * @param id Blog entry id (required) * @param permalink */ export declare function getEntry({ id, entryPermaLink, blogKey, blogId }: { id?: number; entryPermaLink?: string; blogKey?: string; blogId?: number; } & XcapOptionalParameters): Thunk<Promise<GetBlogEntryResult>>; export interface SetEntryStatusResult extends XcapJsonResult { entry: BlogEntry; categories: Array<Category>; blog: Blog; authBlog: AuthBlog; } export interface SetEntryStatus extends XcapOptionalParameters { blogKey: string; id: number; status: BlogEntryStatus; } /** * Set the status of the blog entry. * * @param id * @param blogKey * @param status * @returns {Promise} */ export declare function setEntryStatus({ blogKey, id, status }: SetEntryStatus): Thunk<Promise<SetEntryStatusResult>>; export interface SaveEntryResult extends XcapJsonResult { permalink: string | null; blogKey: string | null; draftId: number; entry: BlogEntry | null; } export interface SaveBlogEntryPollAnswer { id: number; answer: string; } export interface SaveBlogEntryPoll { description: string; answers: Array<SaveBlogEntryPollAnswer>; } export interface SaveBlogEntrySlideshow { slides: Array<string>; frame: boolean; shadow: boolean; hasImageSlide?: boolean; hasVideoSlide?: boolean; empty?: boolean; } export interface SaveBlogEntryEvent { title: string; /** Start date yyyy-MM-dd HH:mm (time part discarded) */ startDate: string; /** Start time: HH:mm */ startTime: string; /** End date yyyy-MM-dd HH:mm (time part discarded) */ endDate: string; /** End time: HH:mm */ endTime: string; location: string; link: string; } export interface SaveBlogEntryInput { id: number; __type: 'net.josh.community.blog.BlogEntry'; blogKey: string; title: string; description: string; body: string; /** Publish date yyyy-MM-dd HH:mm */ publishDate: string | null; allowComments: boolean; categories?: Array<number>; poll?: SaveBlogEntryPoll; event?: SaveBlogEntryEvent; slideshow?: SaveBlogEntrySlideshow; tags?: Array<string>; pageId?: number; /** old deprecated stuff */ headerStyle?: any; } /** * Save a blog entry. * @param blogEntryJson * @param type * @param draftId * @param blogKey * @returns {Promise} */ export declare function saveEntry({ blogEntryInput, type, draftId, blogKey }: { blogEntryInput: SaveBlogEntryInput; type: any; draftId?: number; blogKey: string; } & XcapOptionalParameters): Thunk<Promise<SaveEntryResult>>; /** * Get a composite blog key that consists of the normal blog key plus eventual tags in the form: * groups/social/feed/tags/mytag * * Use this to fetch from redux whn using tags * * @param blogKey * @param tags */ export declare function getCompositeBlogKey({ blogKey, tags }: { blogKey: string; tags?: string[]; }): string; //# sourceMappingURL=index.d.ts.map