import type { BasicCursorPaginationOptions, BasicMetaSysProps, SysLink } from '../common-types'; export type AutomationDefinitionStatus = 'published'; export type AutomationDefinitionTriggerTopic = 'Workflow.create' | 'Workflow.save' | 'Workflow.complete' | 'Entry.create' | 'Entry.delete' | 'Entry.save' | 'Entry.publish' | 'Entry.unpublish' | 'Entry.archive' | 'Entry.unarchive'; export type AutomationDefinitionTrigger = { type: 'event'; topic: AutomationDefinitionTriggerTopic; constraints?: Record; } | { type: 'schedule'; rrule: string; constraints?: Record; }; export type AutomationDefinitionActionType = 'cma.aiAction.invoke' | 'cma.entry.get' | 'cma.entry.getMany' | 'cma.entry.create' | 'cma.entry.publish' | 'cma.entry.unpublish' | 'cma.entry.patch' | 'cma.entry.delete' | 'cma.entry.archive' | 'cma.entry.unarchive' | 'cma.workflow.update' | 'cma.workflow.create' | 'cma.workflow.complete' | 'cma.appActionCall.createWithResult'; export interface AutomationDefinitionAction { type: AutomationDefinitionActionType; parameters: Record; } export interface AutomationDefinitionConditionStepCondition { nextStepId: string | null; constraints: Record; } export interface AutomationDefinitionBaseStep { id: string; name: string; description?: string; nextStepId: string | null; } export interface AutomationDefinitionActionStep extends AutomationDefinitionBaseStep { type: 'action'; action: AutomationDefinitionAction; } export interface AutomationDefinitionConditionStep extends AutomationDefinitionBaseStep { type: 'condition'; conditions: AutomationDefinitionConditionStepCondition[]; } export interface AutomationDefinitionLoopStep extends AutomationDefinitionBaseStep { type: 'loop'; items: string; mode: 'sequential'; steps: AutomationDefinitionStep[]; } export type AutomationDefinitionStep = AutomationDefinitionActionStep | AutomationDefinitionConditionStep | AutomationDefinitionLoopStep; export type AutomationDefinitionSysProps = Pick & { type: 'AutomationDefinition'; space: SysLink; environment: SysLink; organization: SysLink; }; export interface AutomationDefinitionProps { sys: AutomationDefinitionSysProps; name: string; description?: string; triggers: AutomationDefinitionTrigger[]; steps: AutomationDefinitionStep[]; status: AutomationDefinitionStatus; } export type CreateAutomationDefinitionProps = Omit; export type UpdateAutomationDefinitionProps = Omit & { sys: Pick; }; export interface AutomationDefinitionQueryOptions extends BasicCursorPaginationOptions { order?: 'sys.createdAt' | '-sys.createdAt' | 'sys.updatedAt' | '-sys.updatedAt'; }