mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 23:09:47 +02:00
Everything in messages now
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user