import { googleTriggerDefinitions as triggerDefinitions } from "@automate.ax/catalog/triggers/google" import { createTrigger } from "../../../automation/create-trigger" import type { GoogleCalendarEventTriggerOptions } from "./lib" export { GOOGLE_CALENDAR_EVENT_CHANGED_SCHEMA, GOOGLE_CALENDAR_EVENT_DELETED_SCHEMA, } from "@automate.ax/integration-contracts/google-calendar" /** Options for subscribing to every Google Calendar event lifecycle change. */ export interface OnGoogleCalendarEventChangedOptions extends GoogleCalendarEventTriggerOptions {} /** * Subscribes to created, updated, and deleted events in a Google Calendar. * * The signal uses `changeType` to discriminate the lifecycle. Deleted events * include the last synchronized representation when available. * * @param options - Calendar and Google account selection. */ export const onGoogleCalendarEventChanged = createTrigger( triggerDefinitions.googleCalendarEventChanged, (options: OnGoogleCalendarEventChangedOptions = {}) => ({ account: options.account, calendarId: options.calendarId?.trim() || "primary", }), ) /** Options for subscribing to newly observed Google Calendar events. */ export interface OnGoogleCalendarEventCreatedOptions extends GoogleCalendarEventTriggerOptions {} /** * Subscribes to events created after the calendar's initial synchronization. * * @param options - Calendar and Google account selection. */ export const onGoogleCalendarEventCreated = createTrigger( triggerDefinitions.googleCalendarEventCreated, (options: OnGoogleCalendarEventCreatedOptions = {}) => ({ account: options.account, calendarId: options.calendarId?.trim() || "primary", }), ) /** Options for subscribing to updates to existing Google Calendar events. */ export interface OnGoogleCalendarEventUpdatedOptions extends GoogleCalendarEventTriggerOptions {} /** * Subscribes to updates to events in a Google Calendar. * * @param options - Calendar and Google account selection. */ export const onGoogleCalendarEventUpdated = createTrigger( triggerDefinitions.googleCalendarEventUpdated, (options: OnGoogleCalendarEventUpdatedOptions = {}) => ({ account: options.account, calendarId: options.calendarId?.trim() || "primary", }), ) /** Options for subscribing to deleted Google Calendar events. */ export interface OnGoogleCalendarEventDeletedOptions extends GoogleCalendarEventTriggerOptions {} /** * Subscribes to event deletions in a Google Calendar. * * The last synchronized event representation is included when it was observed * before deletion. * * @param options - Calendar and Google account selection. */ export const onGoogleCalendarEventDeleted = createTrigger( triggerDefinitions.googleCalendarEventDeleted, (options: OnGoogleCalendarEventDeletedOptions = {}) => ({ account: options.account, calendarId: options.calendarId?.trim() || "primary", }), )