import type { FormField, FormFieldValues } from "@automate.ax/catalog"; import type { Encodable } from "@automate.ax/codec"; import type { HttpRequestBody, HttpRequestBodyType } from "@automate.ax/codec/http"; import type { StandardSchemaV1 } from "@standard-schema/spec"; import { type DashboardRunConfig } from "@automate.ax/catalog/triggers/core-dashboard"; import { type HttpTriggerScope } from "@automate.ax/catalog/triggers/core-http"; import { type MailhookScope } from "@automate.ax/catalog/triggers/core-mailhook"; import { type Signal } from "../../automation/signal-protocol.js"; export interface ScheduleConfig { /** Five-field cron expression describing the schedule. */ schedule: string; /** IANA time zone used to evaluate the schedule. Defaults to UTC. */ timeZone?: string; } export type ScheduleEvent = { /** Exact scheduled time represented by this event. */ scheduledAt: Date; }; export type HttpRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; type HttpRequestSubscriptionConfig = { /** Require a signed URL created by an action in this automation. */ protection: "callback"; /** Protected callbacks always use their unique trigger endpoint. */ scope?: "trigger"; waitForResponse?: boolean; } | { protection?: never; /** Scope at which HTTP requests are received. Defaults to this trigger. */ scope?: HttpTriggerScope; waitForResponse?: boolean; }; export type HttpRequestConfig = HttpRequestSubscriptionConfig & (TBodySchema extends StandardSchemaV1 ? { /** Standard Schema validator applied to the decoded request body. */ body: TBodySchema; } : { body?: never; }); export type HttpRequestEvent = { /** Request body decoded according to its content type. */ body: TBody; /** Representation selected from the request's content type. */ bodyType: HttpRequestBodyType; headers: Record; method: HttpRequestMethod; path: string; query: Record; /** Exact request bytes, preserved for signature verification. */ rawBody: Uint8Array; /** Stable identity passed to and emitted by `respondToHttpRequest`. */ requestId: string; url: string; }; export type HttpRequestTrigger = Signal> & { /** Public URL that receives requests for this trigger. */ readonly endpoint: string; }; export type { HttpRequestBody, HttpRequestBodyType, HttpRequestForm, HttpRequestFormValue, } from "@automate.ax/codec/http"; export interface MailhookConfig { /** Scope at which the inbound address is shared. Defaults to this trigger. */ scope?: MailhookScope; } export interface MailhookEvent { /** Other To, Cc, and Bcc recipients included on the message. */ additionalRecipients: string[]; /** Attached files, including inline MIME parts. */ attachments: File[]; /** Original message headers normalized to lowercase names. */ headers: Record; /** HTML message body, when present. */ html: string | null; /** * RFC 5322 Message-ID of this message's parent, from its In-Reply-To header. * Use `messageId`, not this value, when replying to this received message. */ inReplyTo: string | null; /** Whether the message has an In-Reply-To header. */ isReply: boolean; /** * On-the-wire RFC 5322 Message-ID supplied by the sender. Use this value as * In-Reply-To when replying to this received message. */ messageId: string; /** Routing suffix after `+` in the recipient address. */ plusPath: string | null; /** When Resend received the message. */ receivedAt: Date; /** * On-the-wire RFC 5322 Message-IDs in the conversation ancestry. Append this * message's `messageId` when building a reply's References header. When this * is empty, start with `inReplyTo` if present. */ references: string[]; /** Sender address, when supplied. */ senderAddress: string | null; /** Sender display name, when supplied. */ senderName: string | null; /** Message subject. */ subject: string; /** Plain-text message body, when present. */ text: string | null; } export type MailhookTrigger = Signal & { /** Unique inbound address for this mailhook scope. */ readonly address: string; }; export type DashboardRunValues = FormFieldValues; export interface DashboardRunUser { /** Authenticated member's email address. */ email: string; /** Authenticated member's user ID. */ id: string; /** Authenticated member's display name. */ name: string; } export interface DashboardRunEvent { /** Values collected from the configured fields. */ data: DashboardRunValues; /** Time at which Automate.ax started the run. */ triggeredAt: Date; /** Organization member who started the run. */ triggeredBy: DashboardRunUser; } export type DashboardRunTrigger = Signal>; export type { DashboardRunConfig } from "@automate.ax/catalog/triggers/core-dashboard"; export type { FormField } from "@automate.ax/catalog"; /** * Subscribes the current automation to a recurring cron schedule. * * @param config - Cron expression and optional IANA time zone. */ export declare function onSchedule(config: ScheduleConfig): Signal; /** * Subscribes the current automation to HTTP requests. * * @param config - HTTP request subscription options. * @throws When declared outside an automation invocation. */ export declare function onHttpRequest(config: HttpRequestConfig): HttpRequestTrigger>; /** @inheritdoc */ export declare function onHttpRequest(config?: HttpRequestConfig): HttpRequestTrigger; /** * Subscribes the current automation to email received at a unique address. * * Append `+suffix` before the `@` to receive the suffix as `plusPath`. Use the * trigger's address as `sendEmail({ replyTo })` to route replies back here. * * @param config - Mailhook address scope. * @throws When declared outside an automation invocation. */ export declare function onMailhook(config?: MailhookConfig): MailhookTrigger; /** * Adds an authenticated dashboard run form to the current automation. * * Only authenticated members of the owning organization can submit the run from * the Automations page. * * @param config - Form content and ordered field definitions. * @throws When declared outside an automation invocation. */ export declare function onDashboardRun(config: DashboardRunConfig): DashboardRunTrigger; /** * Subscribes the current automation to typed programmatic invocations. * * The type argument is compile-time only; invocation payloads accept any value * supported by the Automate.ax codec. Omit the entrypoint to use `"default"`. * Entrypoints beginning with `__$` are reserved by Automate.ax. * * @param entrypoint - Static name used to route invocations to this trigger. * @throws When the entrypoint is invalid, reserved, or already defined. */ export declare function onInvocation(entrypoint?: string): Signal; //# sourceMappingURL=triggers.d.ts.map