File size: 825 Bytes
46252cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
 * Search resource — cross-session message search via the active search provider.
 *
 * Backed by `src/modules/search/search.controller.ts` (`GET /search`).
 * @packageDocumentation
 */

import type { OpenWAClient } from '../client.js';
import type { SearchParams, SearchResults } from '../types.js';

export class SearchResource {
  constructor(private readonly client: OpenWAClient) {}

  /**
   * Search persisted messages across sessions via the active search provider
   * (built-in DB full-text or a configured plugin). Requires an OPERATOR-level
   * API key; a scoped key's reach is bounded by its `allowedSessions`.
   */
  search(params: SearchParams): Promise<SearchResults> {
    return this.client.request<SearchResults>({
      method: 'GET',
      path: '/api/search',
      query: params,
    });
  }
}