import { AppEvent , StringMap , ValueDisplay } from "./api" ; interface AllowedValueDisplays { [ eventType ] : StringMap < boolean > ; } const ALLOWED_VALUE_DISPLAY = { action : { state : true , result : true , data : true , "call-overview" : true , "debugger-state" : true } , function : { args : true , result : true , "call-overview" : true , "debugger-state" : true } , init : { state : true , "debugger-state" : true } , message : { message : true , "debugger-state" : true } } ; export const VALUE_DISPLAYS = { action : [ "state" , "call-overview" , "result" , "data" , "debugger-state" ] , function : [ "call-overview" , "args" , "result" , "debugger-state" ] , init : [ "state" , "debugger-state" ] , message : [ "message" , "debugger-state" ] } ; const DEFAULT_VALUE_DISPLAYS = { action : "state" , function : "call-overview" , init : "state" , message : "message" } ; export function sanitizeValueDisplay ( valueDisplay , event ) { if ( ! ALLOWED_VALUE_DISPLAY [ event . type ] [ valueDisplay ] ) { return DEFAULT_VALUE_DISPLAYS [ event . type ] ; } if ( valueDisplay === "state" && event [ "error" ] ) { return "result" ; } return valueDisplay ; }