github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/ui/dashboard/src/components/dashboards/check/common/index.ts (about) 1 import Benchmark from "./Benchmark"; 2 import { 3 BasePrimitiveProps, 4 ExecutablePrimitiveProps, 5 LeafNodeData, 6 } from "../../common"; 7 import { DashboardRunState } from "../../../../types"; 8 9 export type CheckNodeType = 10 | "benchmark" 11 | "control" 12 | "dimension" 13 | "empty_result" 14 | "error" 15 | "reason" 16 | "resource" 17 | "result" 18 | "running" 19 | "root" 20 | "severity" 21 | "status" 22 | "tag"; 23 24 export type CheckNode = { 25 sort: string; 26 name: string; 27 title: string; 28 type: CheckNodeType; 29 status: CheckNodeStatus; 30 severity?: CheckSeverity; 31 severity_summary: CheckSeveritySummary; 32 summary: CheckSummary; 33 children?: CheckNode[]; 34 data?: LeafNodeData; 35 error?: string; 36 merge?: (other: CheckNode) => void; 37 }; 38 39 export type CheckNodeStatus = "running" | "complete"; 40 41 export type CheckSeverity = "none" | "low" | "medium" | "high" | "critical"; 42 43 export type CheckSeveritySummary = 44 | {} 45 | { 46 [key in CheckSeverity]: number; 47 }; 48 49 export type CheckSummary = { 50 alarm: number; 51 ok: number; 52 info: number; 53 skip: number; 54 error: number; 55 }; 56 57 export type CheckDynamicValueMap = { 58 [dimension: string]: boolean; 59 }; 60 61 export type CheckDynamicColsMap = { 62 dimensions: CheckDynamicValueMap; 63 tags: CheckDynamicValueMap; 64 }; 65 66 export type CheckTags = { 67 [key: string]: string; 68 }; 69 70 type CheckResultDimension = { 71 key: string; 72 value: string; 73 }; 74 75 export type CheckResultStatus = 76 | "alarm" 77 | "ok" 78 | "info" 79 | "skip" 80 | "error" 81 | "empty"; 82 83 export type CheckResultType = "loading" | "error" | "empty" | "result"; 84 85 export type CheckResult = { 86 dimensions: CheckResultDimension[]; 87 tags: CheckTags; 88 control: CheckNode; 89 benchmark_trunk: Benchmark[]; 90 status: CheckResultStatus; 91 reason: string; 92 resource: string; 93 severity?: CheckSeverity; 94 error?: string; 95 type: CheckResultType; 96 }; 97 98 type CheckControlRunProperties = { 99 severity?: CheckSeverity | undefined; 100 }; 101 102 export type CheckControlRun = { 103 name: string; 104 title?: string; 105 description?: string; 106 panel_type: "control"; 107 properties?: CheckControlRunProperties; 108 severity?: CheckSeverity | undefined; 109 tags?: CheckTags; 110 data: LeafNodeData; 111 summary: CheckSummary; 112 status: DashboardRunState; 113 error?: string; 114 }; 115 116 export type CheckDisplayGroupType = 117 | "benchmark" 118 | "control" 119 | "result" 120 | "tag" 121 | "dimension" 122 | "reason" 123 | "resource" 124 | "severity" 125 | "status"; 126 127 export type CheckDisplayGroup = { 128 type: CheckDisplayGroupType; 129 value?: string; 130 }; 131 132 export type BenchmarkTreeProps = BasePrimitiveProps & 133 ExecutablePrimitiveProps & { 134 properties: { 135 grouping: CheckNode; 136 first_child_summaries: CheckSummary[]; 137 }; 138 }; 139 140 export type AddControlResultsAction = (results: CheckResult[]) => void; 141 142 export const findDimension = ( 143 dimensions?: CheckResultDimension[], 144 key?: string 145 ) => { 146 if (!dimensions || !key) { 147 return undefined; 148 } 149 return dimensions.find((d) => d.key === key); 150 };