Skip to content

Commit

Permalink
Version 1.4.0
Browse files Browse the repository at this point in the history
## Version 1.4.0
### Changes
- `matchedSubstrings` from `spellCheck` is now accessible in state (#126)
    - An array of objects with properties `offset` and `length` that represent the matching substrings between the `originalQuery` and the `correctedQuery`
  • Loading branch information
alextaing authored Jul 27, 2022
2 parents 1a4ecf4 + 4ffdc28 commit 0b91808
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 32 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ A library for powering UI components for Yext Search integrations.

[Full Documentation](./docs/search-headless.md)

<a href='https://coveralls.io/github/yext/search-headless?branch=main'>
<img src='https://coveralls.io/repos/github/yext/search-headless/badge.svg?branch=main' alt='Coverage Status' />
</a>
<div>
<a href="https://npmjs.org/package/@yext/search-headless">
<img src="https://img.shields.io/npm/v/@yext/search-headless" alt="NPM version"/>
</a>
<a href="./LICENSE">
<img src="https://img.shields.io/badge/License-BSD%203--Clause-blue.svg" alt="License"/>
</a>
<a href='https://coveralls.io/github/yext/search-headless?branch=main'>
<img src='https://coveralls.io/repos/github/yext/search-headless/badge.svg?branch=main' alt='Coverage Status' />
</a>
</div>
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SOFTWARE.

The following NPM package may be included in this product:

- @yext/search-core@1.8.0
- @yext/search-core@1.9.0

This package contains the following license and notice below:

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

## Result.entityType property

The entity type of the result
The entity type of the result.

<b>Signature:</b>

Expand Down
6 changes: 3 additions & 3 deletions docs/search-headless.result.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ An individual search result.
<b>Signature:</b>

```typescript
export declare interface Result
export declare interface Result<T = Record<string, unknown>>
```

## Properties
Expand All @@ -19,12 +19,12 @@ export declare interface Result
| [description?](./search-headless.result.description.md) | string | <i>(Optional)</i> A description of the result. |
| [distance?](./search-headless.result.distance.md) | number | <i>(Optional)</i> The distance from the user to the result in meters. |
| [distanceFromFilter?](./search-headless.result.distancefromfilter.md) | number | <i>(Optional)</i> The distance from a [AppliedQueryFilter](./search-headless.appliedqueryfilter.md) location to the result in meters. |
| [entityType?](./search-headless.result.entitytype.md) | string | <i>(Optional)</i> The entity type of the result |
| [entityType?](./search-headless.result.entitytype.md) | string | <i>(Optional)</i> The entity type of the result. |
| [highlightedFields?](./search-headless.result.highlightedfields.md) | [HighlightedFields](./search-headless.highlightedfields.md) | <i>(Optional)</i> The [highlighted fields](./search-headless.highlightedfields.md) emphasized by the api. |
| [id?](./search-headless.result.id.md) | string | <i>(Optional)</i> The result ID which depends on the Result Source. |
| [index?](./search-headless.result.index.md) | number | <i>(Optional)</i> The index of the result among the other results in the search. |
| [link?](./search-headless.result.link.md) | string | <i>(Optional)</i> A hyperlink associated with the result. |
| [name?](./search-headless.result.name.md) | string | <i>(Optional)</i> The name of the result. |
| [rawData](./search-headless.result.rawdata.md) | Record&lt;string, unknown&gt; | Raw entity profile data in the shape of key-value pairs. |
| [rawData](./search-headless.result.rawdata.md) | T | Raw entity profile data in the shape of key-value pairs. |
| [source](./search-headless.result.source.md) | [Source](./search-headless.source.md) | Represents the source of a [Result](./search-headless.result.md)<!-- -->. |

2 changes: 1 addition & 1 deletion docs/search-headless.result.rawdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Raw entity profile data in the shape of key-value pairs.
<b>Signature:</b>

```typescript
rawData: Record<string, unknown>;
rawData: T;
```
16 changes: 16 additions & 0 deletions docs/search-headless.spellcheck.matchedsubstrings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/search-headless](./search-headless.md) &gt; [SpellCheck](./search-headless.spellcheck.md) &gt; [matchedSubstrings](./search-headless.spellcheck.matchedsubstrings.md)

## SpellCheck.matchedSubstrings property

An array of substring matches which correspond to the highlighting. Offset indicates the index of the match, and the length indicates the number of characters of the match.

<b>Signature:</b>

```typescript
matchedSubstrings: {
length: number;
offset: number;
}[];
```
1 change: 1 addition & 0 deletions docs/search-headless.spellcheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export declare interface SpellCheck
| Property | Type | Description |
| --- | --- | --- |
| [correctedQuery](./search-headless.spellcheck.correctedquery.md) | string | The corrected version of the originalQuery. |
| [matchedSubstrings](./search-headless.spellcheck.matchedsubstrings.md) | { length: number; offset: number; }\[\] | An array of substring matches which correspond to the highlighting. Offset indicates the index of the match, and the length indicates the number of characters of the match. |
| [originalQuery](./search-headless.spellcheck.originalquery.md) | string | The query that was input into the spell checker. |
| [type](./search-headless.spellcheck.type.md) | [SpellCheckType](./search-headless.spellchecktype.md) | The type of spell check. |

8 changes: 6 additions & 2 deletions etc/search-headless.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export interface RangeBoundary<T> {
}

// @public
export interface Result {
export interface Result<T = Record<string, unknown>> {
description?: string;
distance?: number;
distanceFromFilter?: number;
Expand All @@ -502,7 +502,7 @@ export interface Result {
index?: number;
link?: string;
name?: string;
rawData: Record<string, unknown>;
rawData: T;
source: Source;
}

Expand Down Expand Up @@ -677,6 +677,10 @@ export enum Source {
// @public
export interface SpellCheck {
correctedQuery: string;
matchedSubstrings: {
length: number;
offset: number;
}[];
originalQuery: string;
type: SpellCheckType;
}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/search-headless",
"version": "1.3.0",
"version": "1.4.0",
"description": "A library for powering UI components for Yext Search integrations",
"author": "[email protected]",
"license": "BSD-3-Clause",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.8.1",
"@yext/search-core": "^1.8.0",
"@yext/search-core": "^1.9.0",
"js-levenshtein": "^1.1.6",
"lodash": "^4.17.21"
},
Expand Down
16 changes: 8 additions & 8 deletions test-site-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion tests/integration/spellcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const initialState = {
const spellCheckResult = {
correctedQuery: 'yext',
originalQuery: 'yeet',
type: 'SUGGEST'
type: 'SUGGEST',
matchedSubstrings: [{
offset: 0,
length: 4
}]
};

function mockSearchWithSpellcheck() {
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/slices/spellcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ describe('spellCheck slice reducer works as expected', () => {
const spellCheck: SpellCheck = {
correctedQuery: 'yext',
originalQuery: 'yeet',
type: SpellCheckType.Suggest
type: SpellCheckType.Suggest,
matchedSubstrings: [{
offset: 0,
length: 4
}]
};
const expectedState = { ...initialState, ...spellCheck };
const actualState = reducer({ enabled: true }, setResult(spellCheck));
Expand Down

0 comments on commit 0b91808

Please sign in to comment.