Skip to content
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

Merged
merged 4 commits into from
Aug 15, 2022
Merged

Conversation

tmeyer2115
Copy link
Contributor

@tmeyer2115 tmeyer2115 commented Aug 15, 2022

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 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 TextValueDirectAnswer.

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`.
@tmeyer2115 tmeyer2115 requested a review from a team as a code owner August 15, 2022 14:35
@coveralls
Copy link

coveralls commented Aug 15, 2022

Pull Request Test Coverage Report for Build 2863024396

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.408%

Totals Coverage Status
Change from base Build 2861902935: 0.0%
Covered Lines: 214
Relevant Lines: 231

💛 - Coveralls

@oshi97
Copy link
Contributor

oshi97 commented Aug 15, 2022

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

*
* @public
*/
export interface StringValueDirectAnswer extends BaseFieldValueDirectAnswer<string | string[]> {
Copy link
Contributor

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.

Copy link
Contributor Author

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>.

@tmeyer2115 tmeyer2115 changed the title Add StringValueDirectAnswer interface. Add TextValueDirectAnswer interface. Aug 15, 2022
@tmeyer2115 tmeyer2115 merged commit a3306d8 into develop Aug 15, 2022
@tmeyer2115 tmeyer2115 deleted the dev/string-value-da branch August 15, 2022 19:38
@yen-tt yen-tt mentioned this pull request Sep 6, 2022
yen-tt added a commit that referenced this pull request Sep 8, 2022
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants