import * as z from "zod" import { defineAction } from "../../../automation/actions" import { getGmailApi } from "@automate.ax/integration-contracts/gmail" import { GMAIL_COMPOSE_REQUIREMENT } from "../lib/scopes" /** Permanently deletes a Gmail draft and returns the deleted draft ID. */ export const deleteGmailDraft = defineAction("Delete Gmail draft") .describe("Permanently deletes a Gmail draft.") .account("google", GMAIL_COMPOSE_REQUIREMENT) .input( z.object({ /** Immutable Gmail draft ID to delete permanently. */ draftId: z.string().min(1), }), ) .output(z.string()) .retry({ replaySafety: "unsafe" }) .handler(async ({ account, input }) => { await getGmailApi(account.secret).users.drafts.delete({ id: input.draftId, userId: "me", }) return input.draftId })