@@ -160,6 +160,26 @@ export const WorkflowActionSchema = z.discriminatedUnion('type', [
160160 CustomScriptActionSchema ,
161161] ) ;
162162
163+ /**
164+ * Time Trigger Definition
165+ * Schedules actions to run relative to a specific time or date field.
166+ */
167+ export const TimeTriggerSchema = z . object ( {
168+ id : z . string ( ) . optional ( ) . describe ( 'Unique identifier' ) ,
169+
170+ /** Timing Logic */
171+ timeLength : z . number ( ) . int ( ) . describe ( 'Duration amount (e.g. 1, 30)' ) ,
172+ timeUnit : z . enum ( [ 'minutes' , 'hours' , 'days' ] ) . describe ( 'Unit of time' ) ,
173+
174+ /** Reference Point */
175+ offsetDirection : z . enum ( [ 'before' , 'after' ] ) . describe ( 'Before or After the reference date' ) ,
176+ offsetFrom : z . enum ( [ 'trigger_date' , 'date_field' ] ) . describe ( 'Basis for calculation' ) ,
177+ dateField : z . string ( ) . optional ( ) . describe ( 'Date field to calculate from (required if offsetFrom is date_field)' ) ,
178+
179+ /** Actions */
180+ actions : z . array ( WorkflowActionSchema ) . describe ( 'Actions to execute at the scheduled time' ) ,
181+ } ) ;
182+
163183/**
164184 * Schema for Workflow Rules (Automation)
165185 */
@@ -182,8 +202,18 @@ export const WorkflowRuleSchema = z.object({
182202 /** Actions to execute immediately */
183203 actions : z . array ( WorkflowActionSchema ) . optional ( ) . describe ( 'Immediate actions' ) ,
184204
205+ /**
206+ * Time-Dependent Actions
207+ * Actions scheduled to run in the future.
208+ */
209+ timeTriggers : z . array ( TimeTriggerSchema ) . optional ( ) . describe ( 'Scheduled actions relative to trigger or date field' ) ,
210+
185211 /** Active status */
186212 active : z . boolean ( ) . default ( true ) . describe ( 'Whether this workflow is active' ) ,
213+
214+ /** Recursion Control */
215+ reevaluateOnChange : z . boolean ( ) . default ( false ) . describe ( 'Re-evaluate rule if field updates change the record validity' ) ,
187216} ) ;
188217
189218export type WorkflowRule = z . infer < typeof WorkflowRuleSchema > ;
219+ export type TimeTrigger = z . infer < typeof TimeTriggerSchema > ;
0 commit comments