Skip to content

Commit

Permalink
add featured snippet DA interfaces for the builtin fieldType (#207)
Browse files Browse the repository at this point in the history
- add `MultiLineTextFeaturedSnippetDirectAnswer` and `RichTextFeaturedSnippetDirectAnswer` for the two types that fieldType of featured snippet direct answer can be.
  - `multi_line_text` for feature snippet DA have non optional `value` field of type string
  - `rich_text` for feature snippet DA does not have `value` field so that is omitted in the interface
- the old `FeaturedSnippetDirectAnswer` is now the base interface `BaseFeaturedSnippetDirectAnswer` that the specific interfaces extend from. The new `FeaturedSnippetDirectAnswer` is the union type.

J=SLAP-2330
TEST=auto&manual

oshi confirmed the structure of multi_line_text and rich_text through examples listed in the [comments under this item](https://yexttest.atlassian.net/browse/SLAP-2317) where rich_text does NOT provide `value` field and `multi_line_text` does.

tested locally that:
- 'value' field is not present in IDE for the switch case 'richtext'
<img width="300" alt="Screen Shot 2022-08-15 at 1 19 51 PM" src="https://user-images.githubusercontent.com/36055303/184686077-a6ac524a-43f6-427f-a777-c0d044f542b3.png">
- 'value' field is present, of type string, and NOT optional in IDE for the switch case 'multi_line_text'
<img width="300" alt="Screen Shot 2022-08-15 at 1 21 57 PM" src="https://user-images.githubusercontent.com/36055303/184686123-2bf731ca-755d-4d17-9b73-4c33f6091787.png">
  • Loading branch information
yen-tt committed Aug 15, 2022
1 parent a3306d8 commit 3126bfa
Show file tree
Hide file tree
Showing 23 changed files with 215 additions and 59 deletions.
13 changes: 13 additions & 0 deletions docs/search-core.basefeaturedsnippetdirectanswer.fieldtype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) &gt; [fieldType](./search-core.basefeaturedsnippetdirectanswer.fieldtype.md)

## BaseFeaturedSnippetDirectAnswer.fieldType property

The field type of the direct answer.

<b>Signature:</b>

```typescript
fieldType: EnumOrLiteral<BuiltInFieldType.MultiLineText | BuiltInFieldType.RichText>;
```
23 changes: 23 additions & 0 deletions docs/search-core.basefeaturedsnippetdirectanswer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md)

## BaseFeaturedSnippetDirectAnswer interface

A direct answer which was found within a document.

<b>Signature:</b>

```typescript
export interface BaseFeaturedSnippetDirectAnswer<T = unknown> extends DirectAnswer<T>
```
<b>Extends:</b> [DirectAnswer](./search-core.directanswer.md)<!-- -->&lt;T&gt;
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [fieldType](./search-core.basefeaturedsnippetdirectanswer.fieldtype.md) | [EnumOrLiteral](./search-core.enumorliteral.md)<!-- -->&lt;[BuiltInFieldType.MultiLineText](./search-core.builtinfieldtype.md) \| [BuiltInFieldType.RichText](./search-core.builtinfieldtype.md)<!-- -->&gt; | The field type of the direct answer. |
| [snippet](./search-core.basefeaturedsnippetdirectanswer.snippet.md) | [Snippet](./search-core.snippet.md) | The snippet where the direct answer was found. |
| [type](./search-core.basefeaturedsnippetdirectanswer.type.md) | [DirectAnswerType.FeaturedSnippet](./search-core.directanswertype.md) | Indicates that the DirectAnswer is a [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md)<!-- -->. |
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md) &gt; [snippet](./search-core.featuredsnippetdirectanswer.snippet.md)
[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) &gt; [snippet](./search-core.basefeaturedsnippetdirectanswer.snippet.md)

## FeaturedSnippetDirectAnswer.snippet property
## BaseFeaturedSnippetDirectAnswer.snippet property

The snippet where the direct answer was found.

Expand Down
13 changes: 13 additions & 0 deletions docs/search-core.basefeaturedsnippetdirectanswer.type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) &gt; [type](./search-core.basefeaturedsnippetdirectanswer.type.md)

## BaseFeaturedSnippetDirectAnswer.type property

Indicates that the DirectAnswer is a [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md)<!-- -->.

<b>Signature:</b>

```typescript
type: DirectAnswerType.FeaturedSnippet;
```
2 changes: 1 addition & 1 deletion docs/search-core.basefieldvaluedirectanswer.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export interface BaseFieldValueDirectAnswer<T = unknown> extends DirectAnswer<T>
| [entityName](./search-core.basefieldvaluedirectanswer.entityname.md) | string | The name of the entity that direct answer came from. |
| [fieldApiName](./search-core.basefieldvaluedirectanswer.fieldapiname.md) | string | The field api name of the direct answer. |
| [fieldName](./search-core.basefieldvaluedirectanswer.fieldname.md) | string | The field name of the direct answer. |
| [type](./search-core.basefieldvaluedirectanswer.type.md) | [DirectAnswerType.FieldValue](./search-core.directanswertype.md) | [DirectAnswerType](./search-core.directanswertype.md)<!-- -->.FieldValue. |
| [type](./search-core.basefieldvaluedirectanswer.type.md) | [DirectAnswerType.FieldValue](./search-core.directanswertype.md) | Indicates that the DirectAnswer is a [FieldValueDirectAnswer](./search-core.fieldvaluedirectanswer.md)<!-- -->. |
| [value](./search-core.basefieldvaluedirectanswer.value.md) | T | The result of the direct answer. |
2 changes: 1 addition & 1 deletion docs/search-core.basefieldvaluedirectanswer.type.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## BaseFieldValueDirectAnswer.type property

[DirectAnswerType](./search-core.directanswertype.md)<!-- -->.FieldValue.
Indicates that the DirectAnswer is a [FieldValueDirectAnswer](./search-core.fieldvaluedirectanswer.md)<!-- -->.

<b>Signature:</b>

Expand Down
13 changes: 0 additions & 13 deletions docs/search-core.featuredsnippetdirectanswer.fieldtype.md

This file was deleted.

16 changes: 4 additions & 12 deletions docs/search-core.featuredsnippetdirectanswer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md)

## FeaturedSnippetDirectAnswer interface
## FeaturedSnippetDirectAnswer type

A direct answer which was found within a document.
All possible built-in [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) interfaces.

<b>Signature:</b>

```typescript
export interface FeaturedSnippetDirectAnswer<T = unknown> extends DirectAnswer<T>
export declare type FeaturedSnippetDirectAnswer = MultiLineTextFeaturedSnippetDirectAnswer | RichTextFeaturedSnippetDirectAnswer;
```
<b>Extends:</b> [DirectAnswer](./search-core.directanswer.md)<!-- -->&lt;T&gt;
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [fieldType](./search-core.featuredsnippetdirectanswer.fieldtype.md) | [BuiltInFieldType.MultiLineText](./search-core.builtinfieldtype.md) \| [BuiltInFieldType.RichText](./search-core.builtinfieldtype.md) | The field type of the direct answer. |
| [snippet](./search-core.featuredsnippetdirectanswer.snippet.md) | [Snippet](./search-core.snippet.md) | The snippet where the direct answer was found. |
| [type](./search-core.featuredsnippetdirectanswer.type.md) | [DirectAnswerType.FeaturedSnippet](./search-core.directanswertype.md) | [DirectAnswerType](./search-core.directanswertype.md)<!-- -->.FeaturedSnippet |
<b>References:</b> [MultiLineTextFeaturedSnippetDirectAnswer](./search-core.multilinetextfeaturedsnippetdirectanswer.md)<!-- -->, [RichTextFeaturedSnippetDirectAnswer](./search-core.richtextfeaturedsnippetdirectanswer.md)

13 changes: 0 additions & 13 deletions docs/search-core.featuredsnippetdirectanswer.type.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/search-core.fieldvaluedirectanswer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## FieldValueDirectAnswer type

Possible built-in and custom [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) interfaces
Possible built-in and custom [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) interfaces.

<b>Signature:</b>

Expand Down
7 changes: 5 additions & 2 deletions docs/search-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
| [AutocompleteResult](./search-core.autocompleteresult.md) | An autocomplete suggestion. |
| [AutocompleteService](./search-core.autocompleteservice.md) | A service for autocomplete requests. |
| [BaseAnswersConfig](./search-core.baseanswersconfig.md) | |
| [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) | A direct answer which was found within a document. |
| [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) | A direct answer where the answer came from a field from the knowledge graph. |
| [BaseSearchConfig](./search-core.basesearchconfig.md) | The base configuration options for [SearchCore](./search-core.searchcore.md)<!-- -->. |
| [ClientSDKHeaderValues](./search-core.clientsdkheadervalues.md) | Additional agents and their versions used to create the Search experience. The information for these agents is added to the Client-SDK HTTP header along with that of the ANSWERS\_CORE agent. |
Expand All @@ -63,7 +64,6 @@
| [Facet](./search-core.facet.md) | Represents dynamic filter options for the Search API. |
| [FacetOption](./search-core.facetoption.md) | A filter associated with the facet. |
| [FailedVertical](./search-core.failedvertical.md) | Error information from when a vertical fails to return results. |
| [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md) | A direct answer which was found within a document. |
| [FieldValueFilter](./search-core.fieldvaluefilter.md) | Represents a filter which compares values to a single field. |
| [FieldValueStaticFilter](./search-core.fieldvaluestaticfilter.md) | A [FieldValueFilter](./search-core.fieldvaluefilter.md) with the kind of filter specified to discriminate between static filter types. |
| [FilterSearchRequest](./search-core.filtersearchrequest.md) | Options for a filtersearch request. |
Expand All @@ -74,13 +74,15 @@
| [LocationBoundingBox](./search-core.locationboundingbox.md) | Location boundaries for a filter with "Place" for its [AppliedQueryFilterType](./search-core.appliedqueryfiltertype.md)<!-- -->. (e.g. boundary for a locality or region specific location filter) |
| [LocationFilterDetails](./search-core.locationfilterdetails.md) | Additional details relevant to the filter with "PLACE" for its [AppliedQueryFilterType](./search-core.appliedqueryfiltertype.md)<!-- -->. |
| [LowerNumberRangeLimit](./search-core.lowernumberrangelimit.md) | The start limit of [NumberRangeValue](./search-core.numberrangevalue.md)<!-- -->. |
| [MultiLineTextFeaturedSnippetDirectAnswer](./search-core.multilinetextfeaturedsnippetdirectanswer.md) | A [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) with 'multi\_line\_text' field type. |
| [NearFilterValue](./search-core.nearfiltervalue.md) | A filter value for a filter with a $near [Matcher](./search-core.matcher.md)<!-- -->. |
| [NumberRangeValue](./search-core.numberrangevalue.md) | A filter value for a filter with a $between [Matcher](./search-core.matcher.md)<!-- -->. |
| [QueryRulesActionsData](./search-core.queryrulesactionsdata.md) | Data returned from the Search query rules system. |
| [QuestionSubmissionRequest](./search-core.questionsubmissionrequest.md) | Options for a QuestionSubmission request. |
| [QuestionSubmissionResponse](./search-core.questionsubmissionresponse.md) | A representation of a question submission response. |
| [QuestionSubmissionService](./search-core.questionsubmissionservice.md) | Submits a custom question to the Search API. |
| [Result](./search-core.result.md) | An individual search result. |
| [RichTextFeaturedSnippetDirectAnswer](./search-core.richtextfeaturedsnippetdirectanswer.md) | A [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) with 'rich\_text' field type. "value" field is omitted for featured snippet direct answer of this field type. |
| [SearchConfigWithApiKey](./search-core.searchconfigwithapikey.md) | Configuration options for [SearchCore](./search-core.searchcore.md)<!-- -->, which includes the options from [BaseSearchConfig](./search-core.basesearchconfig.md)<!-- -->, but requires apiKey. |
| [SearchConfigWithToken](./search-core.searchconfigwithtoken.md) | Configuration options for [SearchCore](./search-core.searchcore.md)<!-- -->, which includes the options from [BaseSearchConfig](./search-core.basesearchconfig.md)<!-- -->, but requires token. |
| [SearchParameterField](./search-core.searchparameterfield.md) | Indicates which entity field to perform the autocomplete request on. |
Expand Down Expand Up @@ -114,7 +116,8 @@
| [AnswersConfig](./search-core.answersconfig.md) | |
| [Context](./search-core.context.md) | Used to trigger Search [Query Rules](https://hitchhikers.yext.com/tracks/answers-advanced/ans302-query-rules/)<!-- -->. |
| [EnumOrLiteral](./search-core.enumorliteral.md) | Produces a union type from the enum passed as a generic which consists of the enum values and the string literals of the enum. |
| [FieldValueDirectAnswer](./search-core.fieldvaluedirectanswer.md) | Possible built-in and custom [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) interfaces |
| [FeaturedSnippetDirectAnswer](./search-core.featuredsnippetdirectanswer.md) | All possible built-in [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) interfaces. |
| [FieldValueDirectAnswer](./search-core.fieldvaluedirectanswer.md) | Possible built-in and custom [BaseFieldValueDirectAnswer](./search-core.basefieldvaluedirectanswer.md) interfaces. |
| [HighlightedFields](./search-core.highlightedfields.md) | A mapping of fields to the values emphasized by the Search API. |
| [SearchConfig](./search-core.searchconfig.md) | The main configuration options for [SearchCore](./search-core.searchcore.md)<!-- -->. For a full description of the options, see [BaseSearchConfig](./search-core.basesearchconfig.md)<!-- -->. The config requires either an apiKey or a token. |
| [StaticFilter](./search-core.staticfilter.md) | Represents a static filter that will be used to refine results. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [MultiLineTextFeaturedSnippetDirectAnswer](./search-core.multilinetextfeaturedsnippetdirectanswer.md) &gt; [fieldType](./search-core.multilinetextfeaturedsnippetdirectanswer.fieldtype.md)

## MultiLineTextFeaturedSnippetDirectAnswer.fieldType property

The field type of the direct answer.

<b>Signature:</b>

```typescript
fieldType: EnumOrLiteral<BuiltInFieldType.MultiLineText>;
```
22 changes: 22 additions & 0 deletions docs/search-core.multilinetextfeaturedsnippetdirectanswer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [MultiLineTextFeaturedSnippetDirectAnswer](./search-core.multilinetextfeaturedsnippetdirectanswer.md)

## MultiLineTextFeaturedSnippetDirectAnswer interface

A [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) with 'multi\_line\_text' field type.

<b>Signature:</b>

```typescript
export interface MultiLineTextFeaturedSnippetDirectAnswer extends BaseFeaturedSnippetDirectAnswer<string>
```
<b>Extends:</b> [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md)<!-- -->&lt;string&gt;
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [fieldType](./search-core.multilinetextfeaturedsnippetdirectanswer.fieldtype.md) | [EnumOrLiteral](./search-core.enumorliteral.md)<!-- -->&lt;[BuiltInFieldType.MultiLineText](./search-core.builtinfieldtype.md)<!-- -->&gt; | The field type of the direct answer. |
| [value](./search-core.multilinetextfeaturedsnippetdirectanswer.value.md) | string | The value of the direct answer. |
13 changes: 13 additions & 0 deletions docs/search-core.multilinetextfeaturedsnippetdirectanswer.value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [MultiLineTextFeaturedSnippetDirectAnswer](./search-core.multilinetextfeaturedsnippetdirectanswer.md) &gt; [value](./search-core.multilinetextfeaturedsnippetdirectanswer.value.md)

## MultiLineTextFeaturedSnippetDirectAnswer.value property

The value of the direct answer.

<b>Signature:</b>

```typescript
value: string;
```
13 changes: 13 additions & 0 deletions docs/search-core.richtextfeaturedsnippetdirectanswer.fieldtype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [RichTextFeaturedSnippetDirectAnswer](./search-core.richtextfeaturedsnippetdirectanswer.md) &gt; [fieldType](./search-core.richtextfeaturedsnippetdirectanswer.fieldtype.md)

## RichTextFeaturedSnippetDirectAnswer.fieldType property

The field type of the direct answer.

<b>Signature:</b>

```typescript
fieldType: EnumOrLiteral<BuiltInFieldType.RichText>;
```
21 changes: 21 additions & 0 deletions docs/search-core.richtextfeaturedsnippetdirectanswer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-core](./search-core.md) &gt; [RichTextFeaturedSnippetDirectAnswer](./search-core.richtextfeaturedsnippetdirectanswer.md)

## RichTextFeaturedSnippetDirectAnswer interface

A [BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md) with 'rich\_text' field type. "value" field is omitted for featured snippet direct answer of this field type.

<b>Signature:</b>

```typescript
export interface RichTextFeaturedSnippetDirectAnswer extends Omit<BaseFeaturedSnippetDirectAnswer<string>, 'value'>
```
<b>Extends:</b> Omit&lt;[BaseFeaturedSnippetDirectAnswer](./search-core.basefeaturedsnippetdirectanswer.md)<!-- -->&lt;string&gt;, 'value'&gt;
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [fieldType](./search-core.richtextfeaturedsnippetdirectanswer.fieldtype.md) | [EnumOrLiteral](./search-core.enumorliteral.md)<!-- -->&lt;[BuiltInFieldType.RichText](./search-core.builtinfieldtype.md)<!-- -->&gt; | The field type of the direct answer. |
24 changes: 19 additions & 5 deletions etc/search-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ export interface AutocompleteService {
export interface BaseAnswersConfig extends BaseSearchConfig {
}

// @public
export interface BaseFeaturedSnippetDirectAnswer<T = unknown> extends DirectAnswer<T> {
fieldType: EnumOrLiteral<BuiltInFieldType.MultiLineText | BuiltInFieldType.RichText>;
snippet: Snippet;
type: DirectAnswerType.FeaturedSnippet;
}

// @public
export interface BaseFieldValueDirectAnswer<T = unknown> extends DirectAnswer<T> {
entityName: string;
Expand Down Expand Up @@ -223,11 +230,7 @@ export interface FailedVertical {
}

// @public
export interface FeaturedSnippetDirectAnswer<T = unknown> extends DirectAnswer<T> {
fieldType: BuiltInFieldType.MultiLineText | BuiltInFieldType.RichText;
snippet: Snippet;
type: DirectAnswerType.FeaturedSnippet;
}
export type FeaturedSnippetDirectAnswer = MultiLineTextFeaturedSnippetDirectAnswer | RichTextFeaturedSnippetDirectAnswer;

// @public
export type FieldValueDirectAnswer = UnknownFieldValueDirectAnswer;
Expand Down Expand Up @@ -341,6 +344,12 @@ export enum Matcher {
NotEquals = "!$eq"
}

// @public
export interface MultiLineTextFeaturedSnippetDirectAnswer extends BaseFeaturedSnippetDirectAnswer<string> {
fieldType: EnumOrLiteral<BuiltInFieldType.MultiLineText>;
value: string;
}

// @public
export interface NearFilterValue {
lat: number;
Expand Down Expand Up @@ -416,6 +425,11 @@ export interface Result<T = Record<string, unknown>> {
source: Source;
}

// @public
export interface RichTextFeaturedSnippetDirectAnswer extends Omit<BaseFeaturedSnippetDirectAnswer<string>, 'value'> {
fieldType: EnumOrLiteral<BuiltInFieldType.RichText>;
}

// @public
export const SandboxEndpoints: Required<Endpoints>;

Expand Down

0 comments on commit 3126bfa

Please sign in to comment.