( result: Record<string, unknown>, action: 'exists' | 'wait' | 'get_text' | 'get_attrs', )
| 2 | import { SessionStore } from './session-store.ts'; |
| 3 | |
| 4 | export function buildFindRecordResult( |
| 5 | result: Record<string, unknown>, |
| 6 | action: 'exists' | 'wait' | 'get_text' | 'get_attrs', |
| 7 | ): Record<string, unknown> { |
| 8 | if (action === 'exists') return { found: true }; |
| 9 | if (action === 'wait') { |
| 10 | return { found: true, waitedMs: result.waitedMs }; |
| 11 | } |
| 12 | const ref = typeof result.ref === 'string' ? result.ref : undefined; |
| 13 | if (action === 'get_attrs') return { ref, action: 'get attrs' }; |
| 14 | return { |
| 15 | ref, |
| 16 | action: 'get text', |
| 17 | text: typeof result.text === 'string' ? result.text : '', |
| 18 | }; |
| 19 | } |
| 20 | |
| 21 | export function toDaemonFindData(result: Record<string, unknown>): Record<string, unknown> { |
| 22 | if (result.kind === 'found') { |
no outgoing calls
no test coverage detected