Skip to content
← Public packages

@danj/hey-email

HEY.com email for Kody: search threads, read messages, download PDF attachments, and write drafts. Sending is barred until you allow it.

src/reply.js

47 lines · 1.4 KB · JavaScript
Raw
import * as drafts from './drafts.js'

/**
 * Save a reply as a HEY draft. Never sends. Same as `createReplyDraft` in
 * `./drafts`.
 *
 * Without `to`, `cc`, or `bcc`, the draft goes to the thread's recipients
 * from the prefill. Passing any of them replaces those.
 *
 * @param {{
 *   entryId?: number|string,
 *   topicId?: number|string,
 *   text?: string,
 *   html?: string,
 *   subject?: string,
 *   to?: string|string[],
 *   cc?: string|string[],
 *   bcc?: string|string[],
 * }} input
 * @returns {Promise<{ id: number, status: number, subject: string, url: string, edit_url: string, topic_url: string|null, to: string[], cc: string[], bcc: string[] }>}
 *
 * @example
 * import createReplyDraft from 'kody:@danj/hey-email/reply'
 * const draft = await createReplyDraft({ entryId: 123456789, text: 'Thanks, sounds good.' })
 */
export async function createReplyDraft(input) {
  return drafts.createReplyDraft(input)
}

/**
 * Prefill a reply (subject, quote, recipients, acting sender). Does not
 * write. Same as `getReplyPrefill` in `./drafts`.
 *
 * @param {{ entryId?: number|string, topicId?: number|string }} input
 */
export async function getReplyPrefill(input) {
  return drafts.getReplyPrefill(input)
}

/**
 * Default export: `createReplyDraft`.
 *
 * @param {Parameters<typeof createReplyDraft>[0]} input
 */
export default async function reply(input) {
  return drafts.createReplyDraft(input)
}