diff --git a/README.md b/README.md index 70dd7d91..6459585c 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ A library for powering UI components for Yext Search integrations. [Full Documentation](./docs/search-headless.md) - - Coverage Status - +
+ + NPM version + + + License + + + Coverage Status + +
diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 8c826c40..9ebe1cc2 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -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: diff --git a/docs/search-headless.result.entitytype.md b/docs/search-headless.result.entitytype.md index 26c8978a..adf4315f 100644 --- a/docs/search-headless.result.entitytype.md +++ b/docs/search-headless.result.entitytype.md @@ -4,7 +4,7 @@ ## Result.entityType property -The entity type of the result +The entity type of the result. Signature: diff --git a/docs/search-headless.result.md b/docs/search-headless.result.md index 5a9a7853..5bd01582 100644 --- a/docs/search-headless.result.md +++ b/docs/search-headless.result.md @@ -9,7 +9,7 @@ An individual search result. Signature: ```typescript -export declare interface Result +export declare interface Result> ``` ## Properties @@ -19,12 +19,12 @@ export declare interface Result | [description?](./search-headless.result.description.md) | string | (Optional) A description of the result. | | [distance?](./search-headless.result.distance.md) | number | (Optional) The distance from the user to the result in meters. | | [distanceFromFilter?](./search-headless.result.distancefromfilter.md) | number | (Optional) The distance from a [AppliedQueryFilter](./search-headless.appliedqueryfilter.md) location to the result in meters. | -| [entityType?](./search-headless.result.entitytype.md) | string | (Optional) The entity type of the result | +| [entityType?](./search-headless.result.entitytype.md) | string | (Optional) The entity type of the result. | | [highlightedFields?](./search-headless.result.highlightedfields.md) | [HighlightedFields](./search-headless.highlightedfields.md) | (Optional) The [highlighted fields](./search-headless.highlightedfields.md) emphasized by the api. | | [id?](./search-headless.result.id.md) | string | (Optional) The result ID which depends on the Result Source. | | [index?](./search-headless.result.index.md) | number | (Optional) The index of the result among the other results in the search. | | [link?](./search-headless.result.link.md) | string | (Optional) A hyperlink associated with the result. | | [name?](./search-headless.result.name.md) | string | (Optional) The name of the result. | -| [rawData](./search-headless.result.rawdata.md) | Record<string, unknown> | 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). | diff --git a/docs/search-headless.result.rawdata.md b/docs/search-headless.result.rawdata.md index d01e62df..0e3e762f 100644 --- a/docs/search-headless.result.rawdata.md +++ b/docs/search-headless.result.rawdata.md @@ -9,5 +9,5 @@ Raw entity profile data in the shape of key-value pairs. Signature: ```typescript -rawData: Record; +rawData: T; ``` diff --git a/docs/search-headless.spellcheck.matchedsubstrings.md b/docs/search-headless.spellcheck.matchedsubstrings.md new file mode 100644 index 00000000..e99eb08b --- /dev/null +++ b/docs/search-headless.spellcheck.matchedsubstrings.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [@yext/search-headless](./search-headless.md) > [SpellCheck](./search-headless.spellcheck.md) > [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. + +Signature: + +```typescript +matchedSubstrings: { + length: number; + offset: number; + }[]; +``` diff --git a/docs/search-headless.spellcheck.md b/docs/search-headless.spellcheck.md index 5943a31e..dfae9760 100644 --- a/docs/search-headless.spellcheck.md +++ b/docs/search-headless.spellcheck.md @@ -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. | diff --git a/etc/search-headless.api.md b/etc/search-headless.api.md index c3b46e7e..33c29692 100644 --- a/etc/search-headless.api.md +++ b/etc/search-headless.api.md @@ -492,7 +492,7 @@ export interface RangeBoundary { } // @public -export interface Result { +export interface Result> { description?: string; distance?: number; distanceFromFilter?: number; @@ -502,7 +502,7 @@ export interface Result { index?: number; link?: string; name?: string; - rawData: Record; + rawData: T; source: Source; } @@ -677,6 +677,10 @@ export enum Source { // @public export interface SpellCheck { correctedQuery: string; + matchedSubstrings: { + length: number; + offset: number; + }[]; originalQuery: string; type: SpellCheckType; } diff --git a/package-lock.json b/package-lock.json index e253e957..8622c460 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@yext/search-headless", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless", - "version": "1.3.0", + "version": "1.4.0", "license": "BSD-3-Clause", "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" }, @@ -4686,9 +4686,9 @@ } }, "node_modules/@yext/search-core": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.8.0.tgz", - "integrity": "sha512-t7rg9JZ9K6pIt2nBZ1O+xhzG+zMFVAu9Vgwh8cTey8NA7878cQ6n6BauTwimVdbrNGHq3D2dPUno/kVtKAgPiQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.9.0.tgz", + "integrity": "sha512-HiAF+8D00ZYl3CbC7E6nc4cNWpJgm93WFARHhSzMeN9Ht8XVqdLKkNZN8vCpg2K2jht2IYhCIuJfpW80kDD62w==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -16349,9 +16349,9 @@ } }, "@yext/search-core": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.8.0.tgz", - "integrity": "sha512-t7rg9JZ9K6pIt2nBZ1O+xhzG+zMFVAu9Vgwh8cTey8NA7878cQ6n6BauTwimVdbrNGHq3D2dPUno/kVtKAgPiQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.9.0.tgz", + "integrity": "sha512-HiAF+8D00ZYl3CbC7E6nc4cNWpJgm93WFARHhSzMeN9Ht8XVqdLKkNZN8vCpg2K2jht2IYhCIuJfpW80kDD62w==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" diff --git a/package.json b/package.json index a9214bec..691907bf 100644 --- a/package.json +++ b/package.json @@ -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": "slapshot@yext.com", "license": "BSD-3-Clause", @@ -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" }, diff --git a/test-site-node/package-lock.json b/test-site-node/package-lock.json index 96c63d0d..c5814b21 100644 --- a/test-site-node/package-lock.json +++ b/test-site-node/package-lock.json @@ -14,11 +14,11 @@ }, "..": { "name": "@yext/search-headless", - "version": "1.2.0", - "license": "ISC", + "version": "1.3.0", + "license": "BSD-3-Clause", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^1.8.0", + "@yext/search-core": "^1.9.0-beta.193", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" }, @@ -32,11 +32,11 @@ "@types/node": "^16.11.12", "@typescript-eslint/eslint-plugin": "^5.16.0", "@typescript-eslint/parser": "^5.16.0", - "@yext/eslint-config-slapshot": "^0.2.0", + "@yext/eslint-config-slapshot": "^0.4.0", "@yext/eslint-plugin-export-star": "^1.0.0", "babel-jest": "^27.4.5", "eslint": "^8.11.0", - "eslint-config-react-app": "^7.0.0", + "eslint-config-react-app": "^7.0.1", "eslint-plugin-tsdoc": "^0.2.14", "generate-license-file": "^1.3.0", "jest": "^28.1.0", @@ -63,12 +63,12 @@ "@types/node": "^16.11.12", "@typescript-eslint/eslint-plugin": "^5.16.0", "@typescript-eslint/parser": "^5.16.0", - "@yext/search-core": "^1.8.0", - "@yext/eslint-config-slapshot": "^0.2.0", + "@yext/eslint-config-slapshot": "^0.4.0", "@yext/eslint-plugin-export-star": "^1.0.0", + "@yext/search-core": "^1.9.0-beta.193", "babel-jest": "^27.4.5", "eslint": "^8.11.0", - "eslint-config-react-app": "^7.0.0", + "eslint-config-react-app": "^7.0.1", "eslint-plugin-tsdoc": "^0.2.14", "generate-license-file": "^1.3.0", "jest": "^28.1.0", diff --git a/tests/integration/spellcheck.ts b/tests/integration/spellcheck.ts index e8a11a03..58021e98 100644 --- a/tests/integration/spellcheck.ts +++ b/tests/integration/spellcheck.ts @@ -16,7 +16,11 @@ const initialState = { const spellCheckResult = { correctedQuery: 'yext', originalQuery: 'yeet', - type: 'SUGGEST' + type: 'SUGGEST', + matchedSubstrings: [{ + offset: 0, + length: 4 + }] }; function mockSearchWithSpellcheck() { diff --git a/tests/unit/slices/spellcheck.ts b/tests/unit/slices/spellcheck.ts index 9a2b1924..b60d7e50 100644 --- a/tests/unit/slices/spellcheck.ts +++ b/tests/unit/slices/spellcheck.ts @@ -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));