import '../../../core/api_gateway.dart'; import '../domain/search_models.dart'; /// Search protocol requests over the application's shared gateway. /// /// The request body is exactly `SearchRequest{query, kind, limit}` with /// `limit: 0`, so the server applies its own default cap (`SearchDefaultLimit`, /// 50) instead of the client choosing a larger one. class SearchRepository { SearchRepository(this._gateway); final ApiGateway _gateway; /// Returns the bounded `search_results` body, or null when an older server /// answered without it (its default `pong`) so the caller can report the /// "cannot search" sentence rather than showing a false empty success. Future search({ required String query, required SearchKind kind, }) async { final reply = await _gateway.call('search', { 'search': {'query': query, 'kind': kind.wire, 'limit': 0}, }); final results = reply['search_results']; if (results is! Map) return null; return SearchResponse.fromJson(Map.from(results)); } }