Skip to content

Commit

Permalink
Add StringValueDirectAnswer interface.
Browse files Browse the repository at this point in the history
This PR creates the `StringValueDirectAnswer` interface, which
describes a direct answer sourced from a string (or string list) field
in the Knowledge Graph.

J=SLAP-2315
TEST=manual

I made a few code changes locally which are not included in this PR. These
changes allowed me to generate a switch statement on `fieldType`. I added
cases for `single_line_text` and `multi_line_text`. These cases were hit as
expected when getting direct answers for string and string list fields. In
these switch statements, I saw the IDE correctly inferring that the DA was a
`StringValueDirectAnswer`.
  • Loading branch information
tmeyer2115 committed Aug 15, 2022
1 parent 75a2d99 commit 5a84aba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/search-core.builtinfieldtype.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ export declare enum BuiltInFieldType
| Member | Value | Description |
| --- | --- | --- |
| Address | <code>&quot;address&quot;</code> | |
| MultiLineText | <code>&quot;multi_line_text&quot;</code> | |
| SingleLineText | <code>&quot;single_line_text&quot;</code> | |

6 changes: 5 additions & 1 deletion etc/search-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export interface BaseSearchConfig {
// @public
export enum BuiltInFieldType {
// (undocumented)
Address = "address"
Address = "address",
// (undocumented)
MultiLineText = "multi_line_text",
// (undocumented)
SingleLineText = "single_line_text"
}

// @public
Expand Down
4 changes: 2 additions & 2 deletions src/models/searchservice/response/BuiltInFieldType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export enum BuiltInFieldType {
// Hours = 'hours',
// Decimal = 'decimal',
// RichText = 'rich_text',
// SingleLineText = 'single_line_text',
// MultiLineText = 'multi_line_text'
SingleLineText = 'single_line_text',
MultiLineText = 'multi_line_text'
}
11 changes: 11 additions & 0 deletions src/models/searchservice/response/StringValueDirectAnswer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BuiltInFieldType } from './BuiltInFieldType';
import { FieldValueDirectAnswer } from './FieldValueDirectAnswer';

/**
* A direct answer whose source is a string or string list field in the knowledge graph.
*
* @public
*/
export interface StringValueDirectAnswer extends FieldValueDirectAnswer<string | string[]> {
fieldType: BuiltInFieldType.SingleLineText | BuiltInFieldType.MultiLineText
}

0 comments on commit 5a84aba

Please sign in to comment.