(id: string, success: boolean = true)
| 67 | } |
| 68 | |
| 69 | complete(id: string, success: boolean = true): void { |
| 70 | const execution = this.executions.get(id); |
| 71 | if (!execution) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | execution.completed = true; |
| 76 | |
| 77 | const lastMessage = execution.messages[execution.messages.length - 1]; |
| 78 | const completionMessage: ProgressMessage = { |
| 79 | timestamp: new Date().toISOString(), |
| 80 | message: success ? "Completed successfully" : "Completed with errors", |
| 81 | type: success ? "success" : "error", |
| 82 | }; |
| 83 | |
| 84 | if (lastMessage && lastMessage.message === completionMessage.message && lastMessage.type === completionMessage.type) { |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | execution.messages.push(completionMessage); |
| 89 | |
| 90 | // Notify all subscribers |
| 91 | execution.subscribers.forEach((callback) => callback(completionMessage)); |
| 92 | } |
| 93 | |
| 94 | subscribe(id: string, callback: (message: ProgressMessage) => void, sendExisting: boolean = true): () => void { |
| 95 | const execution = this.executions.get(id); |
no outgoing calls
no test coverage detected