UNPKG

@amityco/ts-sdk-react-native

Version:

Amity Social Cloud Typescript SDK

157 lines (140 loc) 4.65 kB
export const PostContentType = Object.freeze({ TEXT: 'text', IMAGE: 'image', FILE: 'file', VIDEO: 'video', LIVESTREAM: 'liveStream', POLL: 'poll', CLIP: 'clip', }); declare global { namespace Amity { // bad hack until we get proper feed objects in backend type PostTargetType = Amity.Feed['targetType'] | 'content' | 'all'; type PostContentType = ValueOf<typeof PostContentType> | string; type PostActionType = | 'onFetch' | 'onCreate' | 'onUpdate' | 'onDelete' | 'onApproved' | 'onDeclined' | 'onFlagged' | 'onUnflagged' | 'onReactionAdded' | 'onReactionRemoved'; type RawPost<T extends PostContentType = any> = { postId: string; postedUserId: Amity.RawUser['userId']; parentId: Amity.RawPost['postId']; parentPostId: Amity.RawPost['postId']; targetType: PostTargetType; targetId: string; feedId: Amity.Feed['feedId']; children: Amity.RawPost['postId'][]; comments: Amity.InternalComment['commentId'][]; commentsCount: number; // API-FIX: backend doesn't follow its own convention hasFlaggedChildren: false; hasFlaggedComment: false; editedAt: Amity.timestamp; // Amity.Metadata metadata?: Record<string, any>; // Amity.Flaggable flagCount: number; hashFlag: { bits: number; hashes: number; hash: string; } | null; // Amity.Taggable tags?: string[]; // Amity.Timestamps createdAt: Amity.timestamp; updatedAt?: Amity.timestamp; // Amity.SoftDelete isDeleted?: boolean; // Amity.Subscribable path: string; // Amity.AnalyticPostData impression: number; reach: number; // Amity.Reactable reactionsCount: number; reactions: Record<string, number>; myReactions?: string[]; hashtags?: string[]; } & Amity.Content<T> & Amity.Mentionable<'user'>; type InternalPost<T extends PostContentType = any> = RawPost<T> & { feedType?: 'reviewing' | 'published'; }; type PostLinkObject = { childrenPosts: Amity.Post[]; latestComments: (Amity.Comment | null)[]; creator: Amity.User | undefined; analytics: { markAsViewed: () => void; }; getImageInfo: () => Amity.File<'image'> | undefined; getVideoInfo: () => Amity.File<'video'> | undefined; getVideoThumbnailInfo: () => Amity.File<'image'> | undefined; getFileInfo: () => Amity.File<'file'> | undefined; getPollInfo: () => Amity.Poll | undefined; getLivestreamInfo: () => Amity.Stream | undefined; getClipInfo: () => Amity.File<'clip'> | undefined; }; type Post<T extends PostContentType = any> = Amity.InternalPost<T> & Amity.PostLinkObject; type ClipDisplayMode = 'fill' | 'fit'; type QueryPosts = { targetId: string; targetType: Amity.InternalPost['targetType']; sortBy?: 'lastCreated' | 'firstCreated'; dataTypes?: Exclude<Amity.PostContentType, 'text'>[]; includeDeleted?: boolean; hasFlag?: boolean; feedType?: 'reviewing' | 'published'; tags?: Amity.Taggable['tags']; matchingOnlyParentPost?: boolean; page?: string; limit?: number; }; type QueryPostsWithHashtags = { dataTypes?: Exclude<Amity.PostContentType, 'text'>[]; targetType: Amity.InternalPost['targetType']; hashtags: string[]; matchingOnlyParentPost?: boolean; page?: string; limit?: number; }; // Omit sortBy explained in asc-3398 type PostLiveCollection = Amity.LiveCollectionParams< Omit<QueryPosts, 'sortBy' | 'page'> & { sortBy?: 'lastCreated' | 'firstCreated'; } >; type SearchPostWithHashtagLiveCollection = Amity.LiveCollectionParams< Omit<QueryPostsWithHashtags, 'page'> & { sortBy?: 'lastCreated' | 'firstCreated'; } >; type PostLiveCollectionCache = Amity.LiveCollectionCache< Amity.InternalPost['postId'], Pick<QueryPosts, 'page'> >; type QuerySemanticSearchPosts = { query: string; targetId?: string; targetType?: Amity.InternalPost['targetType']; dataTypes?: string[]; matchingOnlyParentPost?: boolean; limit?: number; }; type SemanticSearchPostLiveCollection = Amity.LiveCollectionParams< Omit<QuerySemanticSearchPosts, 'page'> >; type SemanticSearchPostLiveCollectionCache = Amity.LiveCollectionCache< Amity.InternalPost['postId'], // postId:score QuerySemanticSearchPosts >; } }