Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/bluesky

src/create-post.ts

27 lines · 1.2 KB · TypeScript
import { createPost } from './client.ts'
import type { CreatePostInput } from './types.ts'

/**
 * Create or dry-run a Bluesky post. Publishing requires `confirm: true`.
 * @param params.text - Post text body.
 * @param params.identifier - Optional session identifier; defaults to packageStorage `blueskyHandle`.
 * @param params.autoLinkFacets - Automatically make HTTP(S) URLs clickable; defaults to true when facets are not supplied.
 * @param params.externalCard - Optional external-link card metadata. A thumbnail URL is fetched, fitted under Bluesky's 1 MB blob limit when needed, and uploaded as a Bluesky blob.
 * @returns Created record or dry-run payload when `confirm` is omitted.
 * @example
 * import createPost from 'kody:@kody/bluesky/create-post'
 * const result = await createPost({
 *   text: 'Watch this: https://example.com',
 *   externalCard: {
 *     uri: 'https://example.com',
 *     title: 'Example video',
 *     description: 'A useful video.',
 *     thumbnailUrl: 'https://example.com/thumbnail.jpg',
 *   },
 *   dryRun: true,
 * })
 * // => { dryRun: true, action: 'create-post', payload: { ... } }
 */
export default async function createPostEntrypoint(params: CreatePostInput = {}) {
  return await createPost(params)
}