@@ -942,235 +942,3 @@ export const getAllDiscourseNodes = (): DiscourseNodeSettings[] => {
942942
943943 return nodes ;
944944} ;
945-
946- type DualReadProbeCase = { keys : string [ ] } ;
947-
948- type DualReadProbeNodeCase = {
949- nodeType : string ;
950- keys : string [ ] ;
951- } ;
952-
953- type DualReadProbeItem = {
954- scope : "personal" | "global" | "discourseNode" ;
955- keys : string [ ] ;
956- nodeType ?: string ;
957- legacyValue ?: unknown ;
958- blockPropsValue ?: unknown ;
959- legacyError ?: string ;
960- blockPropsError ?: string ;
961- match : boolean ;
962- } ;
963-
964- const normalizeProbeError = ( error : unknown ) : string => {
965- return error instanceof Error ? error . message : String ( error ) ;
966- } ;
967-
968- const safeSerialize = ( value : unknown ) : string => {
969- try {
970- return JSON . stringify ( value ) ;
971- } catch {
972- return String ( value ) ;
973- }
974- } ;
975-
976- const normalizeForComparison = ( value : unknown ) : unknown => {
977- if ( Array . isArray ( value ) ) {
978- return value . map ( normalizeForComparison ) ;
979- }
980- if ( isRecord ( value ) ) {
981- return Object . keys ( value )
982- . sort ( )
983- . reduce < Record < string , unknown > > ( ( acc , key ) => {
984- acc [ key ] = normalizeForComparison ( value [ key ] ) ;
985- return acc ;
986- } , { } ) ;
987- }
988- return value ;
989- } ;
990-
991- const runProbeRead = (
992- reader : ( ) => unknown ,
993- ) : {
994- value ?: unknown ;
995- error ?: string ;
996- } => {
997- try {
998- return { value : reader ( ) } ;
999- } catch ( error ) {
1000- return { error : normalizeProbeError ( error ) } ;
1001- }
1002- } ;
1003-
1004- const hasProbeMatch = ( {
1005- legacyError,
1006- blockPropsError,
1007- legacyValue,
1008- blockPropsValue,
1009- } : {
1010- legacyError ?: string ;
1011- blockPropsError ?: string ;
1012- legacyValue ?: unknown ;
1013- blockPropsValue ?: unknown ;
1014- } ) : boolean => {
1015- if ( legacyError || blockPropsError ) return false ;
1016- return (
1017- safeSerialize ( normalizeForComparison ( legacyValue ) ) ===
1018- safeSerialize ( normalizeForComparison ( blockPropsValue ) )
1019- ) ;
1020- } ;
1021-
1022- const DEFAULT_DISCOURSE_NODE_PROBE_TYPE = "Claim" ;
1023- const DEFAULT_DISCOURSE_NODE_PROBE_KEYS : string [ ] [ ] = [
1024- [ "description" ] ,
1025- [ "shortcut" ] ,
1026- [ "tag" ] ,
1027- [ "index" ] ,
1028- [ "format" ] ,
1029- [ "specification" , "enabled" ] ,
1030- [ "specification" , "query" ] ,
1031- [ "template" ] ,
1032- [ "attributes" ] ,
1033- [ "overlay" ] ,
1034- [ "canvasSettings" , "color" ] ,
1035- [ "canvasSettings" , "alias" ] ,
1036- [ "canvasSettings" , "key-image" ] ,
1037- [ "canvasSettings" , "key-image-option" ] ,
1038- [ "canvasSettings" , "query-builder-alias" ] ,
1039- [ "graphOverview" ] ,
1040- [ "suggestiveRules" , "embeddingRef" ] ,
1041- [ "suggestiveRules" , "isFirstChild" ] ,
1042- ] ;
1043-
1044- export const runDualReadProbe = ( {
1045- personalCases = [
1046- { keys : [ "Discourse context overlay" ] } ,
1047- { keys : [ "Suggestive mode overlay" ] } ,
1048- { keys : [ "Text selection popup" ] } ,
1049- { keys : [ "Disable sidebar open" ] } ,
1050- { keys : [ "Page preview" ] } ,
1051- { keys : [ "Hide feedback button" ] } ,
1052- { keys : [ "Auto canvas relations" ] } ,
1053- { keys : [ "Overlay in canvas" ] } ,
1054- { keys : [ "Streamline styling" ] } ,
1055- { keys : [ "Disable product diagnostics" ] } ,
1056- { keys : [ "Discourse tool shortcut" ] } ,
1057- { keys : [ "Personal node menu trigger" ] } ,
1058- { keys : [ "Node search menu trigger" ] } ,
1059- { keys : [ "Query" ] } ,
1060- { keys : [ "Query" , "Hide query metadata" ] } ,
1061- { keys : [ "Query" , "Default page size" ] } ,
1062- { keys : [ "Query" , "Query pages" ] } ,
1063- { keys : [ "Query" , "Default filters" ] } ,
1064- { keys : [ "Left sidebar" ] } ,
1065- ] ,
1066- globalCases = [
1067- { keys : [ "Trigger" ] } ,
1068- { keys : [ "Canvas page format" ] } ,
1069- { keys : [ "Left sidebar" ] } ,
1070- { keys : [ "Left sidebar" , "Children" ] } ,
1071- { keys : [ "Left sidebar" , "Settings" , "Collapsable" ] } ,
1072- { keys : [ "Left sidebar" , "Settings" , "Folded" ] } ,
1073- { keys : [ "Export" ] } ,
1074- { keys : [ "Export" , "Remove special characters" ] } ,
1075- { keys : [ "Export" , "Resolve block references" ] } ,
1076- { keys : [ "Export" , "Resolve block embeds" ] } ,
1077- { keys : [ "Export" , "Append referenced node" ] } ,
1078- { keys : [ "Export" , "Link type" ] } ,
1079- { keys : [ "Export" , "Max filename length" ] } ,
1080- { keys : [ "Export" , "Frontmatter" ] } ,
1081- { keys : [ "Suggestive mode" ] } ,
1082- { keys : [ "Suggestive mode" , "Include current page relations" ] } ,
1083- { keys : [ "Suggestive mode" , "Include parent and child blocks" ] } ,
1084- { keys : [ "Suggestive mode" , "Page groups" ] } ,
1085- { keys : [ "Relations" ] } ,
1086- ] ,
1087- discourseNodeCases = DEFAULT_DISCOURSE_NODE_PROBE_KEYS . map ( ( keys ) => ( {
1088- nodeType : DEFAULT_DISCOURSE_NODE_PROBE_TYPE ,
1089- keys,
1090- } ) ) ,
1091- } : {
1092- personalCases ?: DualReadProbeCase [ ] ;
1093- globalCases ?: DualReadProbeCase [ ] ;
1094- discourseNodeCases ?: DualReadProbeNodeCase [ ] ;
1095- } = { } ) => {
1096- const rows : DualReadProbeItem [ ] = [ ] ;
1097-
1098- personalCases . forEach ( ( { keys } ) => {
1099- const legacy = runProbeRead ( ( ) => getLegacyPersonalSetting ( keys ) ) ;
1100- const blockProps = runProbeRead ( ( ) =>
1101- readPathValue ( getPersonalSettings ( ) , keys ) ,
1102- ) ;
1103- rows . push ( {
1104- scope : "personal" ,
1105- keys,
1106- legacyValue : legacy . value ,
1107- blockPropsValue : blockProps . value ,
1108- legacyError : legacy . error ,
1109- blockPropsError : blockProps . error ,
1110- match : hasProbeMatch ( {
1111- legacyError : legacy . error ,
1112- blockPropsError : blockProps . error ,
1113- legacyValue : legacy . value ,
1114- blockPropsValue : blockProps . value ,
1115- } ) ,
1116- } ) ;
1117- } ) ;
1118-
1119- globalCases . forEach ( ( { keys } ) => {
1120- const legacy = runProbeRead ( ( ) => getLegacyGlobalSetting ( keys ) ) ;
1121- const blockProps = runProbeRead ( ( ) =>
1122- readPathValue ( getGlobalSettings ( ) , keys ) ,
1123- ) ;
1124- rows . push ( {
1125- scope : "global" ,
1126- keys,
1127- legacyValue : legacy . value ,
1128- blockPropsValue : blockProps . value ,
1129- legacyError : legacy . error ,
1130- blockPropsError : blockProps . error ,
1131- match : hasProbeMatch ( {
1132- legacyError : legacy . error ,
1133- blockPropsError : blockProps . error ,
1134- legacyValue : legacy . value ,
1135- blockPropsValue : blockProps . value ,
1136- } ) ,
1137- } ) ;
1138- } ) ;
1139-
1140- discourseNodeCases . forEach ( ( { nodeType, keys } ) => {
1141- const legacy = runProbeRead ( ( ) =>
1142- getLegacyDiscourseNodeSetting ( nodeType , keys ) ,
1143- ) ;
1144- const blockProps = runProbeRead ( ( ) =>
1145- readPathValue ( getDiscourseNodeSettings ( nodeType ) , keys ) ,
1146- ) ;
1147- rows . push ( {
1148- scope : "discourseNode" ,
1149- nodeType,
1150- keys,
1151- legacyValue : legacy . value ,
1152- blockPropsValue : blockProps . value ,
1153- legacyError : legacy . error ,
1154- blockPropsError : blockProps . error ,
1155- match : hasProbeMatch ( {
1156- legacyError : legacy . error ,
1157- blockPropsError : blockProps . error ,
1158- legacyValue : legacy . value ,
1159- blockPropsValue : blockProps . value ,
1160- } ) ,
1161- } ) ;
1162- } ) ;
1163-
1164- const mismatches = rows . filter ( ( row ) => ! row . match ) ;
1165-
1166- return {
1167- dualReadEnabled : isDualReadEnabled ( ) ,
1168- summary : {
1169- total : rows . length ,
1170- matches : rows . filter ( ( row ) => row . match ) . length ,
1171- mismatches : mismatches . length ,
1172- } ,
1173- rows,
1174- mismatches,
1175- } ;
1176- } ;
0 commit comments