import { type NetworkOptions, type Session } from './atproto.ts'; import { type Value } from './repo.ts'; import type { StrongRef } from './attestation.ts'; import type { ListingRecord } from './listing.ts'; /** The collection a like is a record in. */ export declare const LIKE = "com.pipobscure.bundle.like"; /** A like, as it is written. */ export interface LikeRecord { $type: typeof LIKE; /** The `at://` address of the app's listing. */ subject: string; /** How many times the account has liked it: one for each post, and on past the posts kept. */ count: number; /** The posts that say so, oldest first: the newest `KEPT_POSTS` of them. */ posts: StrongRef[]; /** The first like. */ createdAt: string; /** The latest. */ updatedAt?: string | undefined; } /** How many of its posts a like lists; `count` counts on past them. */ export declare const KEPT_POSTS = 100; /** The longest post the Atmosphere's microblog takes, in characters. */ export declare const POST_GRAPHEMES = 300; /** …and in bytes of UTF-8. */ export declare const POST_BYTES = 3000; /** Where an account's like of the listing at `subject` is kept: the hash of the address. */ export declare function likeKey(subject: string): string; /** A listing, as liking one needs it. */ export interface Likeable { /** Its `at://` address. */ uri: string; record: ListingRecord; /** What it installs as. */ name: string; /** * The link the post gives: its install link, `nzip:/` * — or, for bundle itself, which nobody can install by an nzip: link * before they have it, its page. */ link: string; } /** * The link a like's post gives for the app listed at `uri`: its `nzip:` * install link, by `who` — the handle the person named it by, else the DID — * except for `self`, bundle's own listing, whose link is its page: an `nzip:` * link opens bundle, and whoever reads about bundle may not have it yet. */ export declare function likeLink(uri: string, who: string, name: string, self: { listing: string; home: string; }): string; /** * The post a like proposes: the person's own words if they give some, * otherwise a line saying what they like — the app's title and its * description, as its listing gives them — and then the app's install link, * as a link. The description is shortened to fit; the person's words are not, * and too many of them is an error. */ export declare function likePost(listing: Likeable, note?: string | undefined): Post; /** A post, as the Atmosphere's microblog takes one: its text, and where the links in it are. */ export interface Post { text: string; facets: Record[]; } /** * The post `text` makes, with `link` marked as a link wherever it stands in * it, as a word of its own — the whole text is the person's, and they may * have moved the link, or said it twice, or taken it out, which leaves no * facets. Offsets are of UTF-8 bytes, as facets count them. */ export declare function postOf(text: string, link: string): Post; /** Why `text` is too long for a post, or undefined when it fits. */ export declare function postTooLong(text: string): string | undefined; /** * Like the app listed at `listing`, from `session`'s account, once more: the * post first, so the like can point at it, then the like, counting one more * and listing the post. The like is written over the one read, by its CID, so * a like from another machine meanwhile is not lost: that refused, it is read * again and written once more. The post is taken down again when the like * cannot be written. The post is `post` — the text as the person settled it — * or else the one `likePost()` proposes, with `note`. */ export declare function like(session: Session, listing: Likeable, { note, post: given, ...options }?: NetworkOptions & { note?: string | undefined; post?: Post | undefined; }): Promise<{ uri: string; post: StrongRef; count: number; }>; /** * Take back a like of the listing at `subject`: the record goes, and the * posts it made stay up, as posts — unless `all`, when each of them in the * account's own repository is taken down too, as far as it can be. Null when * there was no like; otherwise how many posts are gone and how many stay. */ export declare function unlike(session: Session, subject: string, { all, ...options }?: NetworkOptions & { all?: boolean | undefined; }): Promise<{ removed: number; kept: number; } | null>; /** * The account `did`'s like of the listing at `subject`, as its repository * has it, verified; null when it has none. A read anyone can make, so asking * needs no sign-in. */ export declare function ownLike(did: string, subject: string, options?: NetworkOptions): Promise; /** * A like, if `value` is one of `subject`, in the shape the lexicon gives. A * field that is not what the lexicon says is dropped, never a reason to * refuse the like. A like written by 0.2.0 or 0.2.1 has one `post` and no * count, and reads as a like counted once, with that post. */ export declare function readLike(value: Value, subject: string): LikeRecord | null; /** * How many accounts like the app listed at `subject`, by a backlink index: * accounts, not records, so one account writing many counts once. A count, not * a verification — `likers()` is that. */ export declare function countLikes(subject: string, options: NetworkOptions & { index: string; }): Promise; /** One account that likes an app, as `likers()` found and verified it. */ export interface Liker { did: string; /** The handle its DID document claims, for display only. */ handle?: string | undefined; /** Its first like of the app. */ createdAt: string; /** Its latest, when it has liked more than once. */ updatedAt?: string | undefined; /** How many times it has liked the app. */ count: number; /** Its posts saying so, oldest first, as its like lists them. */ posts: StrongRef[]; /** The latest of them. */ post?: StrongRef | undefined; /** The latest post's text, when it could be fetched. */ text?: string | undefined; } /** * The accounts that like the app listed at `subject`, the latest like first, * up to `limit`: found through the backlink index, then each like fetched from * its author's own PDS and verified, and its latest post read. A like that * does not check out, or is not at the key a like of this app is kept at, is * left out. */ export declare function likers(subject: string, { index, limit, ...options }: NetworkOptions & { index: string; limit?: number | undefined; }): Promise; //# sourceMappingURL=like.d.ts.map