UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

88 lines 3.24 kB
import { SuggestionsListParamsSchema, SuggestionsSuggestParamsSchema, SuggestionsResponseSchema, SuggestionsListResponseSchema, } from '../schemas'; /** * Creates the suggestions resource methods * OpenAPI Path: /suggestions → suggestions.* * @description Search suggestions for autocomplete functionality */ export function createSuggestionsResource(executeRequest) { return { /** * List all suggestions * @fullPath api.openSearch.suggestions.list * @service open-search * @domain search-suggestions * @dataMethod suggestionsData.list * @discoverable true * @searchTerms ["suggestions", "autocomplete", "search hints"] */ list: async (params) => { return executeRequest({ method: 'GET', path: '/suggestions', paramsSchema: SuggestionsListParamsSchema, responseSchema: SuggestionsListResponseSchema, }, params); }, /** * Get a suggestion by UID * @fullPath api.openSearch.suggestions.get * @service open-search * @domain search-suggestions * @dataMethod suggestionsData.get * @discoverable true * @searchTerms ["suggestion", "autocomplete"] */ get: async (suggestionsUid) => { return executeRequest({ method: 'GET', path: '/suggestions/{suggestionsUid}', responseSchema: SuggestionsResponseSchema, }, undefined, { suggestionsUid: String(suggestionsUid) }); }, /** * Nested suggest resource for autocomplete * @description Get search suggestions for autocomplete functionality */ suggest: { /** * Get autocomplete suggestions for a query * @fullPath api.openSearch.suggestions.suggest.list * @service open-search * @domain search-suggestions * @dataMethod suggestionsData.suggest.list * @discoverable true * @searchTerms ["autocomplete", "typeahead", "search suggestions"] */ list: async (params) => { return executeRequest({ method: 'GET', path: '/suggestions/suggest', paramsSchema: SuggestionsSuggestParamsSchema, responseSchema: SuggestionsListResponseSchema, }, params); }, }, }; } /** * Creates the suggestionsData resource methods (data-only versions) */ export function createSuggestionsDataResource(suggestions) { return { list: async (params) => { const response = await suggestions.list(params); return response.data; }, get: async (suggestionsUid) => { const response = await suggestions.get(suggestionsUid); return response.data; }, suggest: { list: async (params) => { const response = await suggestions.suggest.list(params); return response.data; }, }, }; } //# sourceMappingURL=suggestions.js.map