/**
 * Gmail Trigger Node - Version 1
 * Fetches emails from Gmail and starts the workflow on specified polling intervals.
 */


export interface GmailTriggerV1Params {
/**
 * Time at which polling should occur
 * @default {"item":[{"mode":"everyMinute"}]}
 */
    pollTimes?: {
        /** Item
     */
    item?: Array<{
      /** How often to trigger.
       * @default everyDay
       */
      mode?: 'everyMinute' | 'everyHour' | 'everyDay' | 'everyWeek' | 'everyMonth' | 'everyX' | 'custom' | Expression<string>;
      /** The hour of the day to trigger (24h format)
       * @displayOptions.hide { mode: ["custom", "everyHour", "everyMinute", "everyX"] }
       * @default 14
       */
      hour?: number | Expression<number>;
      /** The minute of the day to trigger
       * @displayOptions.hide { mode: ["custom", "everyMinute", "everyX"] }
       * @default 0
       */
      minute?: number | Expression<number>;
      /** The day of the month to trigger
       * @displayOptions.show { mode: ["everyMonth"] }
       * @default 1
       */
      dayOfMonth?: number | Expression<number>;
      /** The weekday to trigger
       * @displayOptions.show { mode: ["everyWeek"] }
       * @default 1
       */
      weekday?: '1' | '2' | '3' | '4' | '5' | '6' | '0' | Expression<string>;
      /** Use custom cron expression. Values and ranges as follows:&lt;ul&gt;&lt;li&gt;Seconds: 0-59&lt;/li&gt;&lt;li&gt;Minutes: 0 - 59&lt;/li&gt;&lt;li&gt;Hours: 0 - 23&lt;/li&gt;&lt;li&gt;Day of Month: 1 - 31&lt;/li&gt;&lt;li&gt;Months: 0 - 11 (Jan - Dec)&lt;/li&gt;&lt;li&gt;Day of Week: 0 - 6 (Sun - Sat)&lt;/li&gt;&lt;/ul&gt;
       * @displayOptions.show { mode: ["custom"] }
       * @default * * * * * *
       */
      cronExpression?: string | Expression<string> | PlaceholderValue;
      /** All how many X minutes/hours it should trigger
       * @displayOptions.show { mode: ["everyX"] }
       * @default 2
       */
      value?: number | Expression<number>;
      /** If it should trigger all X minutes or hours
       * @displayOptions.show { mode: ["everyX"] }
       * @default hours
       */
      unit?: 'minutes' | 'hours' | Expression<string>;
    }>;
  };
  authentication?: 'oAuth2' | 'serviceAccount' | Expression<string>;
  event?: 'messageReceived' | Expression<string>;
/**
 * Whether to return a simplified version of the response instead of the raw data
 * @builderHint Set to false when the email body is needed for AI analysis, summarization, or content processing. When true, only returns snippet (preview text). When false, returns full email with {id, threadId, labelIds, headers, html, text, textAsHtml, subject, date, to, from, messageId, replyTo}.
 * @default true
 */
    simple?: boolean | Expression<boolean>;
  filters?: {
    /** Whether to include messages from SPAM and TRASH in the results
     * @default false
     */
    includeSpamTrash?: boolean | Expression<boolean>;
    /** Whether to include email drafts in the results
     * @default false
     */
    includeDrafts?: boolean | Expression<boolean>;
    /** Only return messages with labels that match all of the specified label IDs. Choose from the list, or specify IDs using an &lt;a href="https://docs.n8n.io/code/expressions/"&gt;expression&lt;/a&gt;.
     * @default []
     */
    labelIds?: string[];
    /** Only return messages matching the specified query
     * @hint Use the same format as in the Gmail search box. &lt;a href="https://support.google.com/mail/answer/7190?hl=en"&gt;More info&lt;/a&gt;.
     * @builderHint Always set a search query to filter emails. Uses Gmail search syntax, e.g. "from:example@gmail.com", "subject:invoice", "has:attachment", "label:important", "newer_than:1d". Combine with spaces for AND: "from:shop@example.com subject:delivery". Without this filter, ALL incoming emails will trigger the workflow.
     */
    q?: string | Expression<string> | PlaceholderValue;
    /** Read Status
     * @hint Filter emails by whether they have been read or not
     * @default unread
     */
    readStatus?: 'both' | 'unread' | 'read' | Expression<string>;
    /** Sender name or email to filter by
     * @hint Enter an email or part of a sender name
     */
    sender?: string | Expression<string> | PlaceholderValue;
  };
/**
 * Options
 * @displayOptions.hide { simple: [true] }
 * @default {}
 */
    options?: {
    /** Prefix for name of the binary property to which to write the attachment. An index starting with 0 will be added. So if name is 'attachment_' the first attachment is saved to 'attachment_0'.
     * @default attachment_
     */
    dataPropertyAttachmentsPrefixName?: string | Expression<string> | PlaceholderValue;
    /** Whether the email's attachments will be downloaded
     * @default false
     */
    downloadAttachments?: boolean | Expression<boolean>;
  };
}

export interface GmailTriggerV1Credentials {
  googleApi: CredentialReference;
  gmailOAuth2: CredentialReference;
}

interface GmailTriggerV1NodeBase {
  type: 'n8n-nodes-base.gmailTrigger';
  version: 1;
  credentials?: GmailTriggerV1Credentials;
  isTrigger: true;
}

export type GmailTriggerV1ParamsNode = GmailTriggerV1NodeBase & {
  config: NodeConfig<GmailTriggerV1Params>;
};

export type GmailTriggerV1Node = GmailTriggerV1ParamsNode;