Skip to content
← Public packages

@kentcdodds/bluesky

Bluesky and AT Protocol helpers using package-storage handle plus blueskyAppPassword.

src/reply-post.ts

27 lines · 1.0 KB · TypeScript
import { createPost } from './client.ts'
import { parseReplyPostInput } from './create-post-input.ts'

/**
 * Create or dry-run a Bluesky **reply**; refuses without parent/root refs.
 * Prefer this over create-post when the user asked to reply — it will not
 * silently publish a standalone post if reply refs are missing.
 *
 * Required: `reply: { root: { uri, cid }, parent: { uri, cid } }` or aliases
 * `replyTo` / `parent`+`root` / `parentUri`+`parentCid`+`rootUri`+`rootCid` /
 * `replyToUri`+`replyToCid`. Unknown keys are rejected. Publishing still
 * requires `confirm: true`.
 *
 * @example
 * import replyPost from 'kody:@kentcdodds/bluesky/reply-post'
 * const draft = await replyPost({
 *   text: 'Thanks!',
 *   replyToUri: 'at://did:plc:.../app.bsky.feed.post/...',
 *   replyToCid: 'bafy...',
 *   dryRun: true,
 * })
 * // => { dryRun: true, mode: 'reply', parentUri: '...', ... }
 */
export default async function replyPostEntrypoint(params: Record<string, unknown> = {}) {
	const input = parseReplyPostInput(params)
	return await createPost(input)
}