Skip to content

Commit

Permalink
Merge cc39a05 into e7f7462
Browse files Browse the repository at this point in the history
  • Loading branch information
oshi97 committed Mar 23, 2023
2 parents e7f7462 + cc39a05 commit b5d0489
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/models/autocompleteservice/AutocompleteResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ export interface AutocompleteResult {
* Any vertical keys associated with a prompt.
* This only shows up on universal autocomplete requests.
**/
verticalKeys?: string[]
verticalKeys?: string[],
/**
* {@link SearchIntent}s corresponding to the autocomplete result.
*/
queryIntents: SearchIntent[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function createAutocompleteResponse(data: any): AutocompleteResponse {

const response = data.response;
const responseResults = response.results.map(createAutocompleteResult);
const inputIntents = response.input ? response.input.queryIntents : [];
const inputIntents = response.input?.queryIntents ?? [];

return {
results: responseResults,
queryId: response.queryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function createAutocompleteResult(result: any): AutocompleteResult {
matchedSubstrings: result.matchedSubstrings || [],
value: result.value,
relatedItem: relatedItem,
verticalKeys: result.verticalKeys
verticalKeys: result.verticalKeys,
queryIntents: result.queryIntents ?? []
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ describe('AutocompleteResponse', () => {
results: [
{
value: 'salesforce',
queryIntents: [
SearchIntent.NearMe
],
matchedSubstrings: [
{
offset: 0,
Expand All @@ -33,6 +36,7 @@ describe('AutocompleteResponse', () => {
results: [
{
value: 'Virginia Beach',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down Expand Up @@ -77,6 +81,7 @@ describe('AutocompleteResponse', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data'
Expand Down Expand Up @@ -110,6 +115,7 @@ describe('AutocompleteResponse', () => {
fieldId: 'name2'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('AutocompleteResult', () => {
const expectedResult = {
key: 'key',
value: 'salesforce',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down Expand Up @@ -69,6 +70,7 @@ describe('AutocompleteResult', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
relatedItem: {
rawData: {
mock: 'data'
Expand Down Expand Up @@ -106,6 +108,7 @@ describe('AutocompleteResult', () => {
fieldId: 'name'
},
key: 'name',
queryIntents: [],
matchedSubstrings: [
{
offset: 0,
Expand Down

0 comments on commit b5d0489

Please sign in to comment.