@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
92 lines • 3.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSuggestionsResource = createSuggestionsResource;
exports.createSuggestionsDataResource = createSuggestionsDataResource;
const schemas_1 = require("../schemas");
/**
* Creates the suggestions resource methods
* OpenAPI Path: /suggestions → suggestions.*
* @description Search suggestions for autocomplete functionality
*/
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: schemas_1.SuggestionsListParamsSchema,
responseSchema: schemas_1.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: schemas_1.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: schemas_1.SuggestionsSuggestParamsSchema,
responseSchema: schemas_1.SuggestionsListResponseSchema,
}, params);
},
},
};
}
/**
* Creates the suggestionsData resource methods (data-only versions)
*/
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