mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	refactor: proper websocket message types
This commit is contained in:
		| @@ -270,3 +270,96 @@ export interface EntityChangeRecord { | ||||
|     entityChange: EntityChange; | ||||
|     entity?: EntityRow; | ||||
| } | ||||
|  | ||||
| type TaskStatus<TypeT, DataT> = { | ||||
|     type: "taskProgressCount", | ||||
|     taskId: string; | ||||
|     taskType: TypeT; | ||||
|     data: DataT, | ||||
|     progressCount: number | ||||
| } | { | ||||
|     type: "taskError", | ||||
|     taskId: string; | ||||
|     taskType: TypeT; | ||||
|     data: DataT; | ||||
|     message: string; | ||||
| } | { | ||||
|     type: "taskSucceeded", | ||||
|     taskId: string; | ||||
|     taskType: TypeT; | ||||
|     data: DataT; | ||||
|     result?: string | Record<string, string | undefined> | ||||
| } | ||||
|  | ||||
| type TaskDefinitions = | ||||
|     TaskStatus<"protectNotes", { protect: boolean; }> | ||||
|     | TaskStatus<"importNotes", null> | ||||
|     | TaskStatus<"importAttachments", null> | ||||
|     | TaskStatus<"deleteNotes", null> | ||||
|     | TaskStatus<"undeleteNotes", null> | ||||
|     | TaskStatus<"export", null> | ||||
| ; | ||||
|  | ||||
| export interface OpenedFileUpdateStatus { | ||||
|     entityType: string; | ||||
|     entityId: string; | ||||
|     lastModifiedMs?: number; | ||||
|     filePath: string; | ||||
| } | ||||
|  | ||||
| export type WebSocketMessage = TaskDefinitions | { | ||||
|     type: "ping" | ||||
| } | { | ||||
|     type: "frontend-update", | ||||
|     data: { | ||||
|         lastSyncedPush: number, | ||||
|         entityChanges: EntityChange[] | ||||
|     } | ||||
| } | { | ||||
|     type: "openNote", | ||||
|     noteId: string | ||||
| } | OpenedFileUpdateStatus & { | ||||
|     type: "openedFileUpdated" | ||||
| } | { | ||||
|     type: "protectedSessionLogin" | ||||
| } | { | ||||
|     type: "protectedSessionLogout" | ||||
| } | { | ||||
|     type: "toast", | ||||
|     message: string; | ||||
| } | { | ||||
|     type: "api-log-messages", | ||||
|     noteId: string, | ||||
|     messages: string[] | ||||
| } | { | ||||
|     type: "execute-script"; | ||||
|     script: string; | ||||
|     params: unknown[]; | ||||
|     startNoteId?: string; | ||||
|     currentNoteId: string; | ||||
|     originEntityName: string; | ||||
|     originEntityId?: string | null; | ||||
| } | { | ||||
|     type: "reload-frontend"; | ||||
|     reason: string; | ||||
| } | { | ||||
|     type: "sync-pull-in-progress" | "sync-push-in-progress" | "sync-finished" | "sync-failed"; | ||||
|     lastSyncedPush: number; | ||||
| } | { | ||||
|     type: "consistency-checks-failed" | ||||
| } | { | ||||
|     type: "llm-stream", | ||||
|     chatNoteId: string; | ||||
|     done?: boolean; | ||||
|     error?: string; | ||||
|     thinking?: string; | ||||
|     content?: string; | ||||
|     toolExecution?: { | ||||
|         action?: string; | ||||
|         tool?: string; | ||||
|         toolCallId?: string; | ||||
|         result?: string | Record<string, any>; | ||||
|         error?: string; | ||||
|         args?: Record<string, unknown>; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user