( appState: AppState, sessionId: string, event?: HookEvent, )
| 300 | * @returns Hook matchers for the event, or all hooks if no event specified |
| 301 | */ |
| 302 | export function getSessionHooks( |
| 303 | appState: AppState, |
| 304 | sessionId: string, |
| 305 | event?: HookEvent, |
| 306 | ): Map<HookEvent, SessionDerivedHookMatcher[]> { |
| 307 | const store = appState.sessionHooks.get(sessionId) |
| 308 | if (!store) { |
| 309 | return new Map() |
| 310 | } |
| 311 | |
| 312 | const result = new Map<HookEvent, SessionDerivedHookMatcher[]>() |
| 313 | |
| 314 | if (event) { |
| 315 | const sessionMatchers = store.hooks[event] |
| 316 | if (sessionMatchers) { |
| 317 | result.set(event, convertToHookMatchers(sessionMatchers)) |
| 318 | } |
| 319 | return result |
| 320 | } |
| 321 | |
| 322 | for (const evt of HOOK_EVENTS) { |
| 323 | const sessionMatchers = store.hooks[evt] |
| 324 | if (sessionMatchers) { |
| 325 | result.set(evt, convertToHookMatchers(sessionMatchers)) |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | return result |
| 330 | } |
| 331 | |
| 332 | type FunctionHookMatcher = { |
| 333 | matcher: string |
no test coverage detected