All files / src/types/playbooks stepRelations.ts

100% Statements 9/9
100% Branches 6/6
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82        1x 1x 1x 1x     1x 1x     1x 1x 1x                                                                                                                                  
import { OperatorOptionType } from "../../utils/conditionals/types/operatorOptionTypes.ts";
import { LowercaseString } from "../common/lowercaseString.ts";
import { Step } from "./steps/step.ts";
 
export enum LogicalOperator {
  AND_LO = "AND_LO",
  OR_LO = "OR_LO",
  NOT_LO = "NOT_LO",
}
 
export enum StepRuleTypes {
  COMPARE_TIME_WITH_CRON = "COMPARE_TIME_WITH_CRON",
}
 
enum RuleType {
  TIMESERIES = "timeseries",
  TABLE = "table",
}
 
export type RelationEvaluation = {
  evaluation_result: boolean;
  evaluation_output: any;
};
 
export type StepRelationUIRequirement = {
  playbookRelationId?: string;
  evaluation?: RelationEvaluation;
};
 
export type ConditionRule = {
  type: string;
  task: {
    reference_id?: string;
    id?: string;
  };
} & {
  [key in RuleType]?: any;
};
 
export type StepRuleType = {
  [key in StepRuleTypes as LowercaseString<StepRuleTypes>]: {
    operator: OperatorOptionType;
    rule: string;
    within_seconds: number;
  };
};
 
export type StepRule = {
  type: StepRuleTypes;
} & StepRuleType;
 
export type ConditionRuleSet = {
  rules: ConditionRule[];
  step_rules?: StepRule[];
  logical_operator: LogicalOperator;
};
 
type StepCondition = {
  rule_sets: ConditionRuleSet[];
  logical_operator: LogicalOperator;
};
 
export type StepRelationContract = {
  id: string;
  parent: {
    reference_id: string;
  };
  child?: {
    reference_id: string;
  };
  condition?: StepCondition;
  ui_requirement?: StepRelationUIRequirement;
};
 
export type StepRelation = {
  id: string;
  parent: Step | string;
  child: Step;
  condition?: StepCondition;
  ui_requirement?: StepRelationUIRequirement;
};