( appState: AppState, sessionId: string, event: HookEvent, matcher: string, hook: HookCommand | FunctionHook, )
| 395 | * Get the full hook entry (including callbacks) for a specific session hook |
| 396 | */ |
| 397 | export function getSessionHookCallback( |
| 398 | appState: AppState, |
| 399 | sessionId: string, |
| 400 | event: HookEvent, |
| 401 | matcher: string, |
| 402 | hook: HookCommand | FunctionHook, |
| 403 | ): |
| 404 | | { |
| 405 | hook: HookCommand | FunctionHook |
| 406 | onHookSuccess?: OnHookSuccess |
| 407 | } |
| 408 | | undefined { |
| 409 | const store = appState.sessionHooks.get(sessionId) |
| 410 | if (!store) { |
| 411 | return undefined |
| 412 | } |
| 413 | |
| 414 | const eventMatchers = store.hooks[event] |
| 415 | if (!eventMatchers) { |
| 416 | return undefined |
| 417 | } |
| 418 | |
| 419 | // Find the hook in the matchers |
| 420 | for (const matcherEntry of eventMatchers) { |
| 421 | if (matcherEntry.matcher === matcher || matcher === '') { |
| 422 | const hookEntry = matcherEntry.hooks.find(h => isHookEqual(h.hook, hook)) |
| 423 | if (hookEntry) { |
| 424 | return hookEntry |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | return undefined |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Clear all session hooks for a specific session |
no test coverage detected