import type { ComAtprotoLabelDefs } from "@atcute/atproto"; import type { AppBskyFeedDefs } from "@atcute/bluesky"; import type { ResourceUri } from "@atcute/lexicons"; import type { Bot, BotGetPostOptions } from "../../bot/Bot.js"; import { Profile } from "../Profile.js"; import type { PostEmbed } from "./embed/PostEmbed.js"; import { Facet } from "./Facet.js"; import { PostReference, type PostReferenceData } from "./PostReference.js"; import { Threadgate } from "./Threadgate.js"; /** * Data used to construct a Post class. * @see Post */ export interface PostData extends PostReferenceData { text: string; author: Profile; facets?: Array | undefined; langs?: Array | undefined; embed?: PostEmbed | undefined; labels?: Array | undefined; tags?: Array | undefined; threadgate?: Threadgate | undefined; embeddingDisabled?: boolean | undefined; root?: Post | undefined; parent?: Post | undefined; children?: Array | undefined; createdAt?: Date | undefined; indexedAt?: Date | undefined; likeUri?: string | undefined; repostUri?: string | undefined; likeCount?: number | undefined; repostCount?: number | undefined; replyCount?: number | undefined; quoteCount?: number | undefined; } /** * Represents a post on Bluesky. */ export declare class Post extends PostReference { /** The post text. */ text: string; /** The post's author. */ author: Profile; /** * A facet represents a range within the post's text that has special meaning (e.g. mentions, links, tags). * @see [Links, mentions, and rich text | Bluesky](https://www.docs.bsky.app/docs/advanced-guides/post-richtext#rich-text-facets) */ facets?: Array; /** A list of two-letter language codes that the post is written in. */ langs?: Array; /** The embed attached to the post, if there is any. */ embed?: PostEmbed; /** The labels attached to the post, if there are any. */ labels?: Array; /** Additional non-inline tags attached to the post. */ tags?: Array; /** The threadgate attached to the post, if there is any. */ threadgate?: Threadgate; /** Whether embedding this post is disallowed by a postgate. */ embeddingDisabled?: boolean; /** The root post of this post's thread. */ root?: Post; /** The post's parent. */ parent?: Post; /** The post's children. */ children?: Array; /** The time the post was created. */ createdAt: Date; /** The time the post was indexed by the AppView. */ indexedAt?: Date; /** The post's like URI, if the bot has liked the post. */ likeUri?: ResourceUri; /** The post's repost URI, if the bot has reposted the post. */ repostUri?: ResourceUri; /** The post's like count. */ likeCount?: number; /** The post's repost count. */ repostCount?: number; /** The post's reply count. */ replyCount?: number; /** The post's quote count. */ quoteCount?: number; /** * @param data Post data. * @param bot The active Bot instance. */ constructor({ text, uri, cid, author, facets, replyRef, langs, embed, labels, tags, likeUri, repostUri, likeCount, replyCount, repostCount, quoteCount, threadgate, embeddingDisabled, createdAt, indexedAt, parent, root, children, }: PostData, bot: Bot); private fetchThreadView; /** * Refetch the post. * @param options Optional configuration. */ fetch(options?: BotGetPostOptions): Promise; /** * Fetch the root post of the thread. * @param options Optional configuration. */ fetchRoot({ force }?: PostFetchRootOptions): Promise; /** * Fetch the parent post. * @param options Optional configuration. */ fetchParent({ parentHeight, force }?: PostFetchParentOptions): Promise; /** * Fetch the children of the post. * @param options Optional configuration. */ fetchChildren({ depth, force }?: PostFetchChildrenOptions): Promise>; private setCounts; /** * Fetch the post's current like count. */ getLikeCount(): Promise; /** * Fetch the post's current repost count. */ getRepostCount(): Promise; /** * Fetch the post's current reply count. */ getReplyCount(): Promise; /** * Fetch the post's current quote count. */ getQuoteCount(): Promise; /** * Fetch a list of users who liked this post. * This method returns 100 likes at a time, alongside a cursor to fetch the next 100. * @param cursor The cursor to begin fetching from. */ getLikes(cursor?: string): Promise<{ cursor?: string; likes: Array; }>; /** * Iterate over the users who liked this post. * @param cursor The cursor to begin fetching from. */ iterateLikes(cursor?: string): AsyncIterableIterator; /** * Fetch a list of users who reposted this post. * This method returns 100 users at a time, alongside a cursor to fetch the next 100. * @param cursor The cursor to begin fetching from. */ getReposts(cursor?: string): Promise<{ cursor?: string; reposts: Array; }>; /** * Iterate over the users who reposted this post. * @param cursor The cursor to begin fetching from. */ iterateReposts(cursor?: string): AsyncIterableIterator; /** * Fetch a list of posts that quote this post. * This method returns 100 quotes at a time, alongside a cursor to fetch the next 100. * @param cursor The cursor to begin fetching from. */ getQuotes(cursor?: string): Promise<{ cursor?: string; quotes: Array; }>; /** * Iterate over the posts that quote this post. * @param cursor The cursor to begin fetching from. */ iterateQuotes(cursor?: string): AsyncIterableIterator; /** * Constructs an instance from a PostView. */ static fromView(view: AppBskyFeedDefs.PostView, bot: Bot): Post; /** * Constructs an instance from a ThreadViewPost. */ static fromThreadView(view: AppBskyFeedDefs.ThreadViewPost, bot: Bot): Post; } /** * Options for the {@link Post#fetchRoot} method. */ export interface PostFetchRootOptions { /** Whether to fetch the root post even if it's already cached. */ force?: boolean; } /** * Options for the {@link Post#fetchParent} method. */ export interface PostFetchParentOptions { /** How many levels up to fetch. */ parentHeight?: number; /** Whether to fetch the parent post even if it's already cached. */ force?: boolean; } /** * Options for the {@link Post#fetchChildren} method. */ export interface PostFetchChildrenOptions { /** How many levels of replies to fetch. */ depth?: number; /** Whether to fetch children even if they're already cached. */ force?: boolean; }