import { googleTriggerDefinitions as triggerDefinitions } from "@automate.ax/catalog/triggers/google" import { createTrigger } from "../../../automation/create-trigger" import type { GmailTriggerOptions } from "./lib" export { MAILBOX_CHANGE_SCHEMA, MESSAGE_DELETED_SCHEMA, } from "@automate.ax/integration-contracts/gmail" /** Options for subscribing to every normalized Gmail history change. */ export interface OnGmailMailboxChangedOptions extends GmailTriggerOptions {} /** * Subscribes to the broad Gmail mailbox-history family. * * The signal discriminates message additions, permanent message deletions, * label additions, and label removals with `changeType`. * * @param options - Gmail account selection. */ export const onGmailMailboxChanged = createTrigger( triggerDefinitions.gmailMailboxChanged, ) /** Options for subscribing to messages added anywhere in Gmail. */ export interface OnGmailMessageAddedOptions extends GmailTriggerOptions {} /** * Subscribes to every fully parsed message added to the Gmail mailbox. * * This includes received, sent, inserted, imported, and draft messages. Use * {@link onGmailNewEmail} or {@link onGmailEmailSent} for those semantic * subsets. * * @param options - Gmail account selection. */ export const onGmailMessageAdded = createTrigger( triggerDefinitions.gmailMessageAdded, ) /** Options for subscribing to permanent Gmail message deletions. */ export interface OnGmailMessageDeletedOptions extends GmailTriggerOptions {} /** * Subscribes to messages permanently deleted from Gmail, not messages moved to * Trash. * * The signal contains stable message and thread IDs plus the reporting history * ID because Gmail can no longer return the deleted message. * * @param options - Gmail account selection. */ export const onGmailMessageDeleted = createTrigger( triggerDefinitions.gmailMessageDeleted, ) /** Options for subscribing to newly received Gmail messages. */ export interface OnGmailNewEmailOptions extends GmailTriggerOptions {} /** * Subscribes to messages newly added to the Gmail inbox. * * The signal contains the same fully parsed message shape returned by * {@link getGmailMessage}, including MIME bodies, headers, labels, and * attachments. * * @param options - Gmail account selection. * @throws When the account selection is dynamic or belongs to another service. */ export const onGmailNewEmail = createTrigger( triggerDefinitions.gmailMessageReceived, ) /** Options for subscribing to messages sent from Gmail. */ export interface OnGmailEmailSentOptions extends GmailTriggerOptions {} /** * Subscribes to messages sent from the watched Gmail mailbox. * * The signal contains the same fully parsed message shape returned by * {@link getGmailMessage}. Authenticated Automate.ax messages are withheld from * their originating automation to prevent recursive loops. * * @param options - Gmail account selection. */ export const onGmailEmailSent = createTrigger( triggerDefinitions.gmailMessageSent, ) /** Options for subscribing to Gmail label additions. */ export interface OnGmailLabelAddedOptions extends GmailTriggerOptions {} /** * Subscribes to labels added to messages in the watched Gmail mailbox. * * The signal contains the parsed message and every label added in the same * Gmail history change. * * @param options - Gmail account selection. */ export const onGmailLabelAdded = createTrigger( triggerDefinitions.gmailLabelAdded, ) /** Options for subscribing to Gmail label removals. */ export interface OnGmailLabelRemovedOptions extends GmailTriggerOptions {} /** * Subscribes to labels removed from messages in the watched Gmail mailbox. * * The signal contains the parsed message and every label removed in the same * Gmail history change. A removed label's name is omitted when the label no * longer exists in Gmail. * * @param options - Gmail account selection. */ export const onGmailLabelRemoved = createTrigger( triggerDefinitions.gmailLabelRemoved, )