Everything in messages now

This commit is contained in:
Gregory Schier
2024-02-22 19:51:30 -08:00
parent e6c0317b37
commit f2955c26c1
10 changed files with 231 additions and 205 deletions

View File

@@ -1,8 +1,12 @@
import xmlFormat from 'xml-formatter';
const INDENT = ' ';
export function tryFormatJson(text: string, pretty = true): string {
if (text === '') return text;
try {
if (pretty) return JSON.stringify(JSON.parse(text), null, 2);
if (pretty) return JSON.stringify(JSON.parse(text), null, INDENT);
else return JSON.stringify(JSON.parse(text));
} catch (_) {
return text;
@@ -10,8 +14,10 @@ export function tryFormatJson(text: string, pretty = true): string {
}
export function tryFormatXml(text: string): string {
if (text === '') return text;
try {
return xmlFormat(text, { throwOnFailure: true, strictMode: false });
return xmlFormat(text, { throwOnFailure: true, strictMode: false, indentation: INDENT });
} catch (_) {
return text;
}

View File

@@ -133,7 +133,15 @@ export interface GrpcEvent extends BaseModel {
readonly connectionId: string;
readonly model: 'grpc_event';
content: string;
eventType: 'info' | 'error' | 'client_message' | 'server_message' | 'connection_response';
status: number | null;
error: string | null;
eventType:
| 'info'
| 'error'
| 'client_message'
| 'server_message'
| 'connection_start'
| 'connection_end';
metadata: Record<string, string>;
}