import { z } from 'zod';

/**
 * Trigger rule for a DAG node.
 *
 * Determines when a node should run based on the completion status of its
 * dependencies. Mirrors Airflow's trigger rules.
 */
export const triggerRuleSchema = z.enum([
  /** All dependencies must have completed successfully. */
  'all_success',
  /** At least one dependency must have completed successfully. */
  'one_success',
  /** All dependencies must have finished (any status). */
  'all_done',
  /** No dependency failed AND at least one succeeded. */
  'none_failed_min_one_success',
]);

export type TriggerRule = z.infer<typeof triggerRuleSchema>;

/** All valid trigger rule values. */
export const TRIGGER_RULES: TriggerRule[] = triggerRuleSchema.options;

/** Default trigger rule used when none is specified. */
export const DEFAULT_TRIGGER_RULE: TriggerRule = 'all_success';