-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TextValueDirectAnswer
interface.
#206
Conversation
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`.
Pull Request Test Coverage Report for Build 2863024396
💛 - Coveralls |
Would you mind committing the test-site changes you talked about? I think it could be nice if every PR we added extra switch cases onto it |
src/models/searchservice/response/directanswer/StringValueDirectAnswer.ts
Outdated
Show resolved
Hide resolved
src/models/searchservice/response/directanswer/StringValueDirectAnswer.ts
Outdated
Show resolved
Hide resolved
* | ||
* @public | ||
*/ | ||
export interface StringValueDirectAnswer extends BaseFieldValueDirectAnswer<string | string[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking a number of field types (instagram handle, facebook url, linkedin url, etc.) are better suited for the name StringValueDirectAnswer, since their values can truly only be string and never string[] (afaict anyways).
Is there some other name we could give for this interface? I had a hard time thinking of one besides say TextValueDirectAnswer
which didn't seem ideal for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also have an interface for those types and lock it down. For example, we'd have:
FacebookUrlDirectAnswer extends StringValueDirectAnswer<string>
.
StringValueDirectAnswer
interface.TextValueDirectAnswer
interface.
## Version 2.0.0 ### Changes - `additionalQueryParameter` is now a public field in `SearchConfig` models (#217) ### Breaking Changes - Updated default and sandbox URL endpoints from `../answers/..` to `../search/..` as part of rebranding process (#196 ) - Restructured StaticFilters models for better developer experience and enforce proper restriction in the kind of combinations of filters supported by the backend - Now, static filters can be either a field value filter or a nested object that is composed by combining field value filters. (#201 ) - `ConjunctionStaticFilter` and `DisjunctionStaticFilter` models were created to reflect such limitation. For example, ANDs of ORs combination is allowed, ORs of ANDs combination is not allowed. (#204 ) - Updated `FieldValueDirectAnswer` model to properly handle different `value` types. Previously, FieldValueDirectAnswer interface enforces that the `value` field will always be of type `string`. Now, `FieldValueDirectAnswer` is a union type of predefined interfaces with known `value` type and `UnknownFieldValueDirectAnswer` with a generic `value` type for other `fieldType` outside of `BuiltInFieldType`. (#200 #202 ) - The newly added built-in interfaces can be found in the document page [**here**](https://github.com/yext/search-core/blob/develop/docs/search-core.fieldvaluedirectanswer.md) (#206 #208 #210 #211 #205 #209 #203 #220 ) - Narrow down `FeaturedSnippetDirectAnswer` TypeScript model to be a union type of `MultiLineTextSnippetDirectAnswer` and `RichTextSnippetDirectAnswer` as a featured snippet direct answer can only be of fieldType `multi_line_text` or `rich_text`. (#207 #212 ) - All exports marked as `@deprecated` in previous version(s) as part of the rebranding process is now removed in V2 (#216 ) - For more details, the deprecated identifiers are listed in [v1.8 release notes](https://github.com/yext/search-core/releases/tag/v1.8.0)
This PR creates the
TextValueDirectAnswer
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 forsingle_line_text
andmulti_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 aTextValueDirectAnswer
.