From f61022cf257a9350f66ab22fbf8d643044db0975 Mon Sep 17 00:00:00 2001 From: Oliver Shi Date: Tue, 16 Aug 2022 14:16:01 -0400 Subject: [PATCH 1/9] update search-headless to v2 alpha (#151) Had to update the msw mocks to intercept the new search endpoints. J=None TEST=manual unit tests pass again with no errors before this there would be an "Invalid API Key" error --- THIRD-PARTY-NOTICES | 4 ++-- package-lock.json | 34 +++++++++++++++++----------------- package.json | 4 ++-- tests/setup/server.ts | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 3240536..9a6d5c2 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.9.0 + - @yext/search-core@2.0.0-alpha.204 This package contains the following license and notice below: @@ -106,7 +106,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The following NPM package may be included in this product: - - @yext/search-headless@1.4.0 + - @yext/search-headless@2.0.0-alpha.130 This package contains the following license and notice below: diff --git a/package-lock.json b/package-lock.json index 332c95a..45c998b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@yext/search-headless-react", - "version": "1.4.0", + "version": "2.0.0-alpha.151", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "1.4.0", + "version": "2.0.0-alpha.151", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "^1.4.0", + "@yext/search-headless": "^2.0.0-alpha.130", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.9.0.tgz", - "integrity": "sha512-HiAF+8D00ZYl3CbC7E6nc4cNWpJgm93WFARHhSzMeN9Ht8XVqdLKkNZN8vCpg2K2jht2IYhCIuJfpW80kDD62w==", + "version": "2.0.0-alpha.204", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.204.tgz", + "integrity": "sha512-ouV1ZmqrEmwLXBDjxB/Jou3LbkPmHDAKvSyD9E5beO1D+GOmc8BDkGiQ6c9STgYoXH3L58X+NMHiGf3yFNFWgw==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-1.4.0.tgz", - "integrity": "sha512-7lEYYw2+rpP3cFn2ecHbEEPYX1fHd6aYe0FBSqXffXpbBTShuDjsfq4fyvehIu8PSdJsWpqA3RedxRC3q5nQWw==", + "version": "2.0.0-alpha.130", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.130.tgz", + "integrity": "sha512-27dxGT4WHNXhhqkD3NKQdw3Qy4NA7rbLWNUGv+kmF80o+WWw1JLmF8hdy9Os5TdRKwioTK9LwaIciyysuQt+dg==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^1.9.0", + "@yext/search-core": "^2.0.0-alpha.204", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-1.9.0.tgz", - "integrity": "sha512-HiAF+8D00ZYl3CbC7E6nc4cNWpJgm93WFARHhSzMeN9Ht8XVqdLKkNZN8vCpg2K2jht2IYhCIuJfpW80kDD62w==", + "version": "2.0.0-alpha.204", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.204.tgz", + "integrity": "sha512-ouV1ZmqrEmwLXBDjxB/Jou3LbkPmHDAKvSyD9E5beO1D+GOmc8BDkGiQ6c9STgYoXH3L58X+NMHiGf3yFNFWgw==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-1.4.0.tgz", - "integrity": "sha512-7lEYYw2+rpP3cFn2ecHbEEPYX1fHd6aYe0FBSqXffXpbBTShuDjsfq4fyvehIu8PSdJsWpqA3RedxRC3q5nQWw==", + "version": "2.0.0-alpha.130", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.130.tgz", + "integrity": "sha512-27dxGT4WHNXhhqkD3NKQdw3Qy4NA7rbLWNUGv+kmF80o+WWw1JLmF8hdy9Os5TdRKwioTK9LwaIciyysuQt+dg==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^1.9.0", + "@yext/search-core": "^2.0.0-alpha.204", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index 175fbc5..280448e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-headless-react", - "version": "1.4.0", + "version": "2.0.0-alpha.151", "description": "The official React UI Bindings layer for Search Headless", "main": "./lib/esm/src/index.js", "license": "BSD-3-Clause", @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "^1.4.0", + "@yext/search-headless": "^2.0.0-alpha.130", "use-sync-external-store": "^1.1.0" }, "devDependencies": { diff --git a/tests/setup/server.ts b/tests/setup/server.ts index 29a06c0..3c4db23 100644 --- a/tests/setup/server.ts +++ b/tests/setup/server.ts @@ -5,7 +5,7 @@ import { universalQueryResponse, universalQueryResponseWithFilters } from './res // Any unhandled requests are dropped and logged as warnings const handlers = [ - rest.get(/answers\/vertical\/query/, (req, res, ctx) => { + rest.get(/search\/vertical\/query/, (req, res, ctx) => { const input = req.url.searchParams.get('input'); switch (input) { case 'resultsWithNlpFilter': @@ -18,7 +18,7 @@ const handlers = [ ); } }), - rest.get(/answers\/query/, (req, res, ctx) => { + rest.get(/search\/query/, (req, res, ctx) => { const input = req.url.searchParams.get('input'); switch (input) { case 'resultsWithFilter': From 6002bf97f361d49943612c236551bd8de966cc98 Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Wed, 17 Aug 2022 13:34:21 -0400 Subject: [PATCH 2/9] update headless version for DA changes (#152) update headless version for direct answer related changes --- THIRD-PARTY-NOTICES | 4 ++-- package-lock.json | 34 +++++++++++++++++----------------- package.json | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 9a6d5c2..53eb2fc 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@2.0.0-alpha.204 + - @yext/search-core@2.0.0-alpha.215 This package contains the following license and notice below: @@ -106,7 +106,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The following NPM package may be included in this product: - - @yext/search-headless@2.0.0-alpha.130 + - @yext/search-headless@2.0.0-alpha.133 This package contains the following license and notice below: diff --git a/package-lock.json b/package-lock.json index 45c998b..cc04013 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.151", + "version": "2.0.0-alpha.152", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.151", + "version": "2.0.0-alpha.152", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "^2.0.0-alpha.130", + "@yext/search-headless": "^2.0.0-alpha.133", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "2.0.0-alpha.204", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.204.tgz", - "integrity": "sha512-ouV1ZmqrEmwLXBDjxB/Jou3LbkPmHDAKvSyD9E5beO1D+GOmc8BDkGiQ6c9STgYoXH3L58X+NMHiGf3yFNFWgw==", + "version": "2.0.0-alpha.215", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.215.tgz", + "integrity": "sha512-KUB4SFzjmCYFnz2m0z3iPCMKstvbgpzW9gOFdYAscWdq0SNw0+Ch5gPUy3D+4eAPRA0vj7i4/YEL1CEeRtfShA==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "2.0.0-alpha.130", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.130.tgz", - "integrity": "sha512-27dxGT4WHNXhhqkD3NKQdw3Qy4NA7rbLWNUGv+kmF80o+WWw1JLmF8hdy9Os5TdRKwioTK9LwaIciyysuQt+dg==", + "version": "2.0.0-alpha.133", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.133.tgz", + "integrity": "sha512-VqKPLEEn+6vXB6JexgLcFQjKCGQreLtYcVvqun16qNt9MDcFgcWoeP2CcWD6rlSv9IrORmEbaf4BX+FlPQbXhg==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^2.0.0-alpha.204", + "@yext/search-core": "^2.0.0-alpha.215", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "2.0.0-alpha.204", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.204.tgz", - "integrity": "sha512-ouV1ZmqrEmwLXBDjxB/Jou3LbkPmHDAKvSyD9E5beO1D+GOmc8BDkGiQ6c9STgYoXH3L58X+NMHiGf3yFNFWgw==", + "version": "2.0.0-alpha.215", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.215.tgz", + "integrity": "sha512-KUB4SFzjmCYFnz2m0z3iPCMKstvbgpzW9gOFdYAscWdq0SNw0+Ch5gPUy3D+4eAPRA0vj7i4/YEL1CEeRtfShA==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "2.0.0-alpha.130", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.130.tgz", - "integrity": "sha512-27dxGT4WHNXhhqkD3NKQdw3Qy4NA7rbLWNUGv+kmF80o+WWw1JLmF8hdy9Os5TdRKwioTK9LwaIciyysuQt+dg==", + "version": "2.0.0-alpha.133", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.133.tgz", + "integrity": "sha512-VqKPLEEn+6vXB6JexgLcFQjKCGQreLtYcVvqun16qNt9MDcFgcWoeP2CcWD6rlSv9IrORmEbaf4BX+FlPQbXhg==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^2.0.0-alpha.204", + "@yext/search-core": "^2.0.0-alpha.215", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index 280448e..f406f88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.151", + "version": "2.0.0-alpha.152", "description": "The official React UI Bindings layer for Search Headless", "main": "./lib/esm/src/index.js", "license": "BSD-3-Clause", @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "^2.0.0-alpha.130", + "@yext/search-headless": "^2.0.0-alpha.133", "use-sync-external-store": "^1.1.0" }, "devDependencies": { From f73a135e14e10f931b6ff9783877fe8079a5abd6 Mon Sep 17 00:00:00 2001 From: juliannzhou <65748924+juliannzhou@users.noreply.github.com> Date: Fri, 19 Aug 2022 13:14:52 -0400 Subject: [PATCH 3/9] remove deprecated code (#153) This PR removes any code deprecated as part of renaming and uses the newest alpha of headless (without ^) where all deprecated code is removed and bump the alpha version of headless to 2.0.0-alpha.134. J=SLAP-2339 TEST=manual Test: removed any code tagged deprecated and deprecate.ts as well as its export in index.ts, updated the documentations, and searched 'deprecate', 'answers', as well as all identifiers in Cindy's renaming PRs. Also renamed answers to search for internal function names and changed answersConfig to searchConfig, since it has been renamed in headless. --- THIRD-PARTY-NOTICES | 4 +-- package-lock.json | 30 ++++++++-------- package.json | 2 +- src/SearchHeadlessProvider.tsx | 12 +++---- src/deprecated.ts | 51 -------------------------- src/index.ts | 3 -- src/subscribeToStateUpdates.tsx | 52 --------------------------- tests/SearchHeadlessProvider.test.tsx | 2 +- tests/useSearchState.test.tsx | 38 ++++++++++---------- 9 files changed, 44 insertions(+), 150 deletions(-) delete mode 100644 src/deprecated.ts delete mode 100644 src/subscribeToStateUpdates.tsx diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 53eb2fc..614d2c0 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@2.0.0-alpha.215 + - @yext/search-core@2.0.0-alpha.218 This package contains the following license and notice below: @@ -106,7 +106,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The following NPM package may be included in this product: - - @yext/search-headless@2.0.0-alpha.133 + - @yext/search-headless@2.0.0-alpha.134 This package contains the following license and notice below: diff --git a/package-lock.json b/package-lock.json index cc04013..27b29eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "2.0.0-alpha.152", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "^2.0.0-alpha.133", + "@yext/search-headless": "2.0.0-alpha.134", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "2.0.0-alpha.215", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.215.tgz", - "integrity": "sha512-KUB4SFzjmCYFnz2m0z3iPCMKstvbgpzW9gOFdYAscWdq0SNw0+Ch5gPUy3D+4eAPRA0vj7i4/YEL1CEeRtfShA==", + "version": "2.0.0-alpha.218", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.218.tgz", + "integrity": "sha512-G53E3tUjYzGrLzBeAnXwaovGl682QyKGzDveB+QfzZMpfOspdukxRFVmoEfePii86aNNbBLOF8vJZ/J/cwzCjg==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "2.0.0-alpha.133", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.133.tgz", - "integrity": "sha512-VqKPLEEn+6vXB6JexgLcFQjKCGQreLtYcVvqun16qNt9MDcFgcWoeP2CcWD6rlSv9IrORmEbaf4BX+FlPQbXhg==", + "version": "2.0.0-alpha.134", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.134.tgz", + "integrity": "sha512-QRt8gsbrSteOYubYpXS88Sf7pOLxI1s/vK3ngOOYTlbL/w3BA3ScDbhTuS8hcKnWByl9I1FgcRxWMuB3ePI7dg==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^2.0.0-alpha.215", + "@yext/search-core": "2.0.0-alpha.218", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "2.0.0-alpha.215", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.215.tgz", - "integrity": "sha512-KUB4SFzjmCYFnz2m0z3iPCMKstvbgpzW9gOFdYAscWdq0SNw0+Ch5gPUy3D+4eAPRA0vj7i4/YEL1CEeRtfShA==", + "version": "2.0.0-alpha.218", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.218.tgz", + "integrity": "sha512-G53E3tUjYzGrLzBeAnXwaovGl682QyKGzDveB+QfzZMpfOspdukxRFVmoEfePii86aNNbBLOF8vJZ/J/cwzCjg==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "2.0.0-alpha.133", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.133.tgz", - "integrity": "sha512-VqKPLEEn+6vXB6JexgLcFQjKCGQreLtYcVvqun16qNt9MDcFgcWoeP2CcWD6rlSv9IrORmEbaf4BX+FlPQbXhg==", + "version": "2.0.0-alpha.134", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.134.tgz", + "integrity": "sha512-QRt8gsbrSteOYubYpXS88Sf7pOLxI1s/vK3ngOOYTlbL/w3BA3ScDbhTuS8hcKnWByl9I1FgcRxWMuB3ePI7dg==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "^2.0.0-alpha.215", + "@yext/search-core": "2.0.0-alpha.218", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index f406f88..ca37f30 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "^2.0.0-alpha.133", + "@yext/search-headless": "2.0.0-alpha.134", "use-sync-external-store": "^1.1.0" }, "devDependencies": { diff --git a/src/SearchHeadlessProvider.tsx b/src/SearchHeadlessProvider.tsx index 6348446..fc2a69f 100644 --- a/src/SearchHeadlessProvider.tsx +++ b/src/SearchHeadlessProvider.tsx @@ -12,22 +12,22 @@ type Props = HeadlessConfig & { }; export function SearchHeadlessProvider(props: PropsWithChildren): JSX.Element { - const { children, verticalKey, sessionTrackingEnabled=true, ...answersConfig } = props; + const { children, verticalKey, sessionTrackingEnabled=true, ...searchConfig } = props; const additionalHttpHeaders = { 'Client-SDK': { ANSWERS_HEADLESS_REACT: version } }; - const answers: SearchHeadless = provideHeadless(answersConfig, additionalHttpHeaders); + const search: SearchHeadless = provideHeadless(searchConfig, additionalHttpHeaders); - verticalKey && answers.setVertical(verticalKey); - answers.setSessionTrackingEnabled(sessionTrackingEnabled); + verticalKey && search.setVertical(verticalKey); + search.setSessionTrackingEnabled(sessionTrackingEnabled); if (sessionTrackingEnabled) { const sessionId = acquireSessionId(); - sessionId && answers.setSessionId(sessionId); + sessionId && search.setSessionId(sessionId); } return ( - + {children} ); diff --git a/src/deprecated.ts b/src/deprecated.ts deleted file mode 100644 index 0661235..0000000 --- a/src/deprecated.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { useSearchActions, SearchActions } from './useSearchActions'; -import { StateSelector, useSearchState } from './useSearchState'; -import { useSearchUtilities, SearchUtilities } from './useSearchUtilities'; -import { SearchHeadlessProvider } from './SearchHeadlessProvider'; -import { SearchHeadlessContext } from './SearchHeadlessContext'; -import { PropsWithChildren } from 'react'; -import { HeadlessConfig } from '@yext/search-headless'; - -type Props = HeadlessConfig & { - verticalKey?: string, - sessionTrackingEnabled?: boolean -}; - -/** - * @deprecated AnswersHeadlessContext has been deprecated and replaced by SearchHeadlessContext - */ -export const AnswersHeadlessContext = SearchHeadlessContext; - -/** - * @deprecated AnswersActions has been deprecated and replaced by SearchActions - */ -export type AnswersActions = SearchActions; - -/** - * @deprecated AnswersUtilities has been deprecated and replaced by SearchUtilities - */ -export type AnswersUtilities = SearchUtilities; - -/** - * @deprecated useAnswersActions has been deprecated and replaced by useSearchActions - */ -export function useAnswersActions(): SearchActions { return useSearchActions(); } - -/** - * @deprecated useAnswersState has been deprecated and replaced by useSearchState - */ -export function useAnswersState(stateSelector: StateSelector): T { - return useSearchState(stateSelector); -} - -/** - * @deprecated useAnswersUtilities has been deprecated and replaced by useSearchUtilities - */ -export function useAnswersUtilities(): SearchUtilities { return useSearchUtilities(); } - -/** - * @deprecated AnswersHeadlessProvider has been deprecated and replaced by SearchHeadlessProvider - */ -export function AnswersHeadlessProvider(props: PropsWithChildren): JSX.Element { - return SearchHeadlessProvider(props); -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index bbc95ac..c0e0972 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,12 @@ import { useSearchActions, SearchActions } from './useSearchActions'; import { useSearchState, StateSelector } from './useSearchState'; import { useSearchUtilities, SearchUtilities } from './useSearchUtilities'; -import { subscribeToStateUpdates } from './subscribeToStateUpdates'; import { SearchHeadlessProvider } from './SearchHeadlessProvider'; import { SearchHeadlessContext } from './SearchHeadlessContext'; export * from '@yext/search-headless'; -export * from './deprecated'; export { SearchHeadlessContext, - subscribeToStateUpdates, useSearchActions, useSearchState, useSearchUtilities, diff --git a/src/subscribeToStateUpdates.tsx b/src/subscribeToStateUpdates.tsx deleted file mode 100644 index 5681e95..0000000 --- a/src/subscribeToStateUpdates.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { ComponentType, useReducer, useEffect, useContext } from 'react'; -import { State } from '@yext/search-headless'; -import { SearchHeadlessContext } from './SearchHeadlessContext'; -import isShallowEqual from './utils/isShallowEqual'; - -type SubscriberGenerator = (WrappedComponent: ComponentType) => (props: any) => JSX.Element; - -/** - * Generates a HOC that updates a given Component's props based on the current - * search-headless state and a given mapping function. - * - * @deprecated - * For class components, use `SearchHeadlessContext` directly to dispatch actions and receive state updates. - * For functional components, use `useSearchActions` and `useSearchState` instead. - */ -export function subscribeToStateUpdates( - mapStateToProps: (s: State) => Record -): SubscriberGenerator { - const generateSubscriberHOC: SubscriberGenerator = WrappedComponent => { - /** - * Keep manual track of the props mapped from state instead of storing - * it in the SearchHeadlessSubscriber's state. This avoids react's batching - * of state updates, which can result in mappedState not updating immediately. - * This can, in turn, result in extra search-headless listener invocations. - */ - let previousPropsFromState = {}; - return function AnswersHeadlessSubscriber(props: Record) { - const answers = useContext(SearchHeadlessContext); - const [mergedProps, dispatch] = useReducer(() => { - return { - ...props, - ...previousPropsFromState - }; - }, { ...props, ...mapStateToProps(answers.state) }); - - useEffect(() => { - return answers.addListener({ - valueAccessor: (state: State) => mapStateToProps(state), - callback: newPropsFromState => { - if (!isShallowEqual(previousPropsFromState, newPropsFromState)) { - previousPropsFromState = newPropsFromState; - dispatch(); - } - } - }); - }); - return ; - }; - }; - return generateSubscriberHOC; -} diff --git a/tests/SearchHeadlessProvider.test.tsx b/tests/SearchHeadlessProvider.test.tsx index 234a5f1..b1d9ee0 100644 --- a/tests/SearchHeadlessProvider.test.tsx +++ b/tests/SearchHeadlessProvider.test.tsx @@ -9,7 +9,7 @@ jest.mock('@yext/search-headless', () => ({ })) })); -it('correctly passes through an answers config with sandbox endpoints', () => { +it('correctly passes through a search config with sandbox endpoints', () => { const config = { apiKey: '', experienceKey: '', diff --git a/tests/useSearchState.test.tsx b/tests/useSearchState.test.tsx index 5e82d49..dee3c69 100644 --- a/tests/useSearchState.test.tsx +++ b/tests/useSearchState.test.tsx @@ -19,9 +19,9 @@ it('invoke useSearchState outside of SearchHeadlessProvider', () => { }); it('Retrieves state snapshot during server side rendering and hydration process', () => { - const answers = createAnswersHeadless(); + const search = createSearchHeadless(); const mockedOnClick= jest.fn().mockImplementation(() => { - answers.setVertical('anotherFakeKey'); + search.setVertical('anotherFakeKey'); }); function Test(): JSX.Element { const verticalKey = useSearchState(state => state.vertical.verticalKey); @@ -29,7 +29,7 @@ it('Retrieves state snapshot during server side rendering and hydration process' } function App(): JSX.Element { return ( - + ); @@ -86,13 +86,13 @@ it('does not perform extra renders/listener registrations for nested components' ); } - const answers = createAnswersHeadless(); - const addListenerSpy = jest.spyOn(answers, 'addListener'); + const search = createSearchHeadless(); + const addListenerSpy = jest.spyOn(search, 'addListener'); expect(addListenerSpy).toHaveBeenCalledTimes(0); expect(parentStateUpdates).toHaveLength(0); expect(childStateUpdates).toHaveLength(0); render( - + ); @@ -129,16 +129,16 @@ it('does not trigger render on unmounted component', async () => { return
child component
; } - const answers = createAnswersHeadless(); + const search = createSearchHeadless(); render( - + ); - act(() => answers.setQuery('resultsWithFilter')); - await act( async () => { await answers.executeUniversalQuery(); }); - act(() => answers.setQuery('default')); - await act( async () => { await answers.executeUniversalQuery(); }); + act(() => search.setQuery('resultsWithFilter')); + await act( async () => { await search.executeUniversalQuery(); }); + act(() => search.setQuery('default')); + await act( async () => { await search.executeUniversalQuery(); }); expect(consoleSpy).not.toHaveBeenCalledWith( expect.stringMatching('Can\'t perform a React state update on an unmounted component'), expect.anything(), @@ -161,9 +161,9 @@ describe('uses the most recent selector', () => { ); } - const answers = createAnswersHeadless(); + const search = createSearchHeadless(); render( - + ); @@ -194,11 +194,11 @@ describe('uses the most recent selector', () => { ); } - const answers = createAnswersHeadless(); - answers.setQuery('initial value'); + const search = createSearchHeadless(); + search.setQuery('initial value'); expect(stateUpdates).toHaveLength(0); render( - + ); @@ -213,13 +213,13 @@ describe('uses the most recent selector', () => { expect(stateUpdates).toEqual(['initial value', 1]); act(() => { - answers.setContext('trigger a state update that would not update the initial selector'); + search.setContext('trigger a state update that would not update the initial selector'); }); expect(stateUpdates).toEqual(['initial value', 1, 3]); }); }); -function createAnswersHeadless() { +function createSearchHeadless() { return provideHeadless({ apiKey: 'fake api key', experienceKey: 'fake exp key', From 9df8dd9e601132931577c98be913ced58d8e046e Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Mon, 22 Aug 2022 13:27:10 -0400 Subject: [PATCH 4/9] beta version for QA related to DA and StaticFilters changes (#154) beta version for QA related to DA and StaticFilters changes --- THIRD-PARTY-NOTICES | 4 ++-- package-lock.json | 34 +++++++++++++++++----------------- package.json | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 614d2c0..213649e 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@2.0.0-alpha.218 + - @yext/search-core@2.0.0-beta.219 This package contains the following license and notice below: @@ -106,7 +106,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The following NPM package may be included in this product: - - @yext/search-headless@2.0.0-alpha.134 + - @yext/search-headless@2.0.0-beta.135 This package contains the following license and notice below: diff --git a/package-lock.json b/package-lock.json index 27b29eb..fffbb76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.152", + "version": "2.0.0-beta.154", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.152", + "version": "2.0.0-beta.154", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "2.0.0-alpha.134", + "@yext/search-headless": "2.0.0-beta.135", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "2.0.0-alpha.218", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.218.tgz", - "integrity": "sha512-G53E3tUjYzGrLzBeAnXwaovGl682QyKGzDveB+QfzZMpfOspdukxRFVmoEfePii86aNNbBLOF8vJZ/J/cwzCjg==", + "version": "2.0.0-beta.219", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-beta.219.tgz", + "integrity": "sha512-upanja5Z6sn9/bWyuV9vpKfSBZg2mnWThnY7pT+a3/X/IeWOy5y3w4ycBP+weYxZuu1+GZTyyO5KI/IeayC6hg==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "2.0.0-alpha.134", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.134.tgz", - "integrity": "sha512-QRt8gsbrSteOYubYpXS88Sf7pOLxI1s/vK3ngOOYTlbL/w3BA3ScDbhTuS8hcKnWByl9I1FgcRxWMuB3ePI7dg==", + "version": "2.0.0-beta.135", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-beta.135.tgz", + "integrity": "sha512-dIgseFAYZMa/VpuEA8mk0hcJeQNrjZ4oT9ecCO3LB5X0H/ANRcyviRDFywUeuzVO9MOxZBmh0TuaSlmIi8nzkw==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-alpha.218", + "@yext/search-core": "2.0.0-beta.219", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "2.0.0-alpha.218", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.218.tgz", - "integrity": "sha512-G53E3tUjYzGrLzBeAnXwaovGl682QyKGzDveB+QfzZMpfOspdukxRFVmoEfePii86aNNbBLOF8vJZ/J/cwzCjg==", + "version": "2.0.0-beta.219", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-beta.219.tgz", + "integrity": "sha512-upanja5Z6sn9/bWyuV9vpKfSBZg2mnWThnY7pT+a3/X/IeWOy5y3w4ycBP+weYxZuu1+GZTyyO5KI/IeayC6hg==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "2.0.0-alpha.134", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.134.tgz", - "integrity": "sha512-QRt8gsbrSteOYubYpXS88Sf7pOLxI1s/vK3ngOOYTlbL/w3BA3ScDbhTuS8hcKnWByl9I1FgcRxWMuB3ePI7dg==", + "version": "2.0.0-beta.135", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-beta.135.tgz", + "integrity": "sha512-dIgseFAYZMa/VpuEA8mk0hcJeQNrjZ4oT9ecCO3LB5X0H/ANRcyviRDFywUeuzVO9MOxZBmh0TuaSlmIi8nzkw==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-alpha.218", + "@yext/search-core": "2.0.0-beta.219", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index ca37f30..71a5410 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.152", + "version": "2.0.0-beta.154", "description": "The official React UI Bindings layer for Search Headless", "main": "./lib/esm/src/index.js", "license": "BSD-3-Clause", @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "2.0.0-alpha.134", + "@yext/search-headless": "2.0.0-beta.135", "use-sync-external-store": "^1.1.0" }, "devDependencies": { From b2f7a58c8fff2082dbf88da80fce40249f7df57b Mon Sep 17 00:00:00 2001 From: Tom Meyer Date: Thu, 1 Sep 2022 12:04:03 -0400 Subject: [PATCH 5/9] Rework the `SearchHeadlessProvider` to be a pass-through. (#156) Per Product's request, the `SearchHeadlessProvider` is now a mere pass-through to the `SearchHeadlessContext.Provider`. Users will need to create and initialize a `Headless` instance themselves. This PR also removed the `Client-SDK` header for Headless React. Product and I determined that it was not useful to track the Headless React version. The `acquireSessionId` utility will be moved to either the Component Library or Headless, TBD. The Jest test that was added ensures the `Provider` does not touch anything in the `Headless` instance. TEST=auto Ran all unit tests. --- THIRD-PARTY-NOTICES | 166 +++++++++++++------------- src/SearchHeadlessProvider.tsx | 27 +---- src/utils/acquireSessionId.ts | 22 ---- tests/SearchHeadlessProvider.test.tsx | 33 +++-- tests/utils/acquireSessionId.test.ts | 36 ------ 5 files changed, 110 insertions(+), 174 deletions(-) delete mode 100644 src/utils/acquireSessionId.ts delete mode 100644 tests/utils/acquireSessionId.test.ts diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 213649e..f94f9ac 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -1,4 +1,7 @@ -The following NPM packages may be included in this product: +This file was generated with the generate-license-file npm package! +https://www.npmjs.com/package/generate-license-file + +The following npm packages may be included in this product: - @babel/runtime-corejs3@7.16.3 - @babel/runtime@7.16.3 @@ -30,37 +33,37 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - @reduxjs/toolkit@1.8.1 This package contains the following license and notice below: -MIT License - -Copyright (c) 2018 Mark Erikson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +MIT License + +Copyright (c) 2018 Mark Erikson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - @yext/search-core@2.0.0-beta.219 @@ -104,7 +107,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - @yext/search-headless@2.0.0-beta.135 @@ -148,7 +151,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - core-js-pure@3.19.3 @@ -176,7 +179,7 @@ THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - cross-fetch@3.1.5 @@ -206,7 +209,7 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - immer@9.0.14 @@ -236,7 +239,7 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - js-levenshtein@1.1.6 @@ -266,7 +269,7 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - js-tokens@4.0.0 @@ -296,7 +299,7 @@ THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - lodash@4.17.21 @@ -352,7 +355,7 @@ terms above. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - loose-envify@1.4.0 @@ -382,7 +385,7 @@ THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - node-fetch@2.6.7 @@ -412,7 +415,7 @@ SOFTWARE. ----------- -The following NPM packages may be included in this product: +The following npm packages may be included in this product: - react@18.1.0 - use-sync-external-store@1.1.0 @@ -443,37 +446,37 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - redux-thunk@2.4.1 This package contains the following license and notice below: -The MIT License (MIT) - -Copyright (c) 2015-present Dan Abramov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +The MIT License (MIT) + +Copyright (c) 2015-present Dan Abramov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - redux@4.1.2 @@ -503,7 +506,7 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - regenerator-runtime@0.13.9 @@ -533,37 +536,37 @@ SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - reselect@4.1.5 This package contains the following license and notice below: -The MIT License (MIT) - -Copyright (c) 2015-2018 Reselect Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +The MIT License (MIT) + +Copyright (c) 2015-2018 Reselect Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - tr46@0.0.3 @@ -573,7 +576,7 @@ This package contains the following license and notice below: ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - webidl-conversions@3.0.1 @@ -594,7 +597,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ----------- -The following NPM package may be included in this product: +The following npm package may be included in this product: - whatwg-url@5.0.0 @@ -624,4 +627,5 @@ THE SOFTWARE. ----------- -This file was generated with generate-license-file! https://www.npmjs.com/package/generate-license-file +This file was generated with the generate-license-file npm package! +https://www.npmjs.com/package/generate-license-file diff --git a/src/SearchHeadlessProvider.tsx b/src/SearchHeadlessProvider.tsx index fc2a69f..70d0d72 100644 --- a/src/SearchHeadlessProvider.tsx +++ b/src/SearchHeadlessProvider.tsx @@ -1,33 +1,14 @@ import { PropsWithChildren } from 'react'; -import { provideHeadless, SearchHeadless, HeadlessConfig } from '@yext/search-headless'; +import { SearchHeadless } from '@yext/search-headless'; import { SearchHeadlessContext } from './SearchHeadlessContext'; -import acquireSessionId from './utils/acquireSessionId'; -import packageJson from '../package.json'; -const { version } = packageJson; - -type Props = HeadlessConfig & { - verticalKey?: string, - sessionTrackingEnabled?: boolean -}; +type Props = { searcher: SearchHeadless }; export function SearchHeadlessProvider(props: PropsWithChildren): JSX.Element { - const { children, verticalKey, sessionTrackingEnabled=true, ...searchConfig } = props; - const additionalHttpHeaders = { - 'Client-SDK': { - ANSWERS_HEADLESS_REACT: version - } - }; - const search: SearchHeadless = provideHeadless(searchConfig, additionalHttpHeaders); + const { children, searcher } = props; - verticalKey && search.setVertical(verticalKey); - search.setSessionTrackingEnabled(sessionTrackingEnabled); - if (sessionTrackingEnabled) { - const sessionId = acquireSessionId(); - sessionId && search.setSessionId(sessionId); - } return ( - + {children} ); diff --git a/src/utils/acquireSessionId.ts b/src/utils/acquireSessionId.ts deleted file mode 100644 index c2e6359..0000000 --- a/src/utils/acquireSessionId.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { v4 as uuidv4 } from 'uuid'; -/** - * Retrieves session id from local storage, or generates a new uuid to use as session id. - * The new id is then stored in local storage. Returns null if the sessionStorage API is - * unavailable. (e.g. The function is running on the server for SSR). - */ -export default function acquireSessionId(): string | null { - if (typeof(window) === 'undefined') { - return null; - } - try { - let sessionId = window.sessionStorage.getItem('sessionId'); - if (!sessionId) { - sessionId = uuidv4(); - window.sessionStorage.setItem('sessionId', sessionId); - } - return sessionId; - } catch (err) { - console.warn('Unable to use browser sessionStorage for sessionId.\n', err); - return null; - } -} \ No newline at end of file diff --git a/tests/SearchHeadlessProvider.test.tsx b/tests/SearchHeadlessProvider.test.tsx index b1d9ee0..1b5ef5f 100644 --- a/tests/SearchHeadlessProvider.test.tsx +++ b/tests/SearchHeadlessProvider.test.tsx @@ -1,23 +1,32 @@ -import { SearchHeadlessProvider, SandboxEndpoints } from '../src'; +import { SearchHeadlessProvider } from '../src'; import { render } from '@testing-library/react'; -import { provideHeadless } from '@yext/search-headless'; +import { provideHeadless, SearchHeadless } from '@yext/search-headless'; jest.mock('@yext/search-headless', () => ({ - provideHeadless: jest.fn(() => ({ - setSessionTrackingEnabled: jest.fn(), - setSessionId: jest.fn() - })) + provideHeadless: jest.fn(() => { return {}; }) })); -it('correctly passes through a search config with sandbox endpoints', () => { +it('Provider does not invoke any methods or attributes of the Searcher', () => { const config = { apiKey: '', experienceKey: '', - locale: 'en', - endpoints: SandboxEndpoints + locale: 'en' }; + const searcher: SearchHeadless = provideHeadless(config); - render(); - expect(provideHeadless).toHaveBeenCalledTimes(1); - expect(provideHeadless).toHaveBeenCalledWith(config, expect.anything()); + expect( + () => render()).not.toThrowError(); +}); + +it('Provider does decorate any methods in the Searcher', () => { + const config = { + apiKey: '', + experienceKey: '', + locale: 'en' + }; + const searcher: SearchHeadless = provideHeadless(config); + const searcherProxy = new Proxy(searcher, { set() { throw new Error(); } }); + + expect(() => render( + )).not.toThrowError(); }); \ No newline at end of file diff --git a/tests/utils/acquireSessionId.test.ts b/tests/utils/acquireSessionId.test.ts deleted file mode 100644 index 875f0ec..0000000 --- a/tests/utils/acquireSessionId.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import acquireSessionId from '../../src/utils/acquireSessionId'; - -const uuidString = 'some-uuid-value'; -const mockUuid = jest.fn(() => uuidString); -jest.mock('uuid', () => ({ - v4: () => mockUuid() -})); - -describe('handle session id properly', () => { - beforeEach(() => { - window.sessionStorage.clear(); - }); - - it('session id exist in session storage', () => { - window.sessionStorage.setItem('sessionId', 'some-uuid-in-storage'); - expect(acquireSessionId()).toEqual('some-uuid-in-storage'); - }); - - it('session id does not exist in session storage', () => { - expect(acquireSessionId()).toEqual(uuidString); - expect(window.sessionStorage.getItem('sessionId')).toEqual(uuidString); - }); - - it('error using session storage', () => { - Object.defineProperty(window, 'sessionStorage', { - value: { getItem: () => { throw Error(); } } - }); - const consoleWarnSpy = jest.spyOn(global.console, 'warn').mockImplementation(); - expect(acquireSessionId()).toEqual(null); - expect(consoleWarnSpy).toHaveBeenLastCalledWith( - expect.stringContaining('Unable to use browser sessionStorage for sessionId.'), - expect.anything() - ); - consoleWarnSpy.mockClear(); - }); -}); From 848aefe90b13b0bdbfcab9e32dfb008faba44b4b Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Tue, 6 Sep 2022 16:37:55 -0400 Subject: [PATCH 6/9] alpha version for SearchHeadlessProvider and HoursDirectAnswer changes (#157) alpha version for SearchHeadlessProvider and HoursDirectAnswer changes --- THIRD-PARTY-NOTICES | 170 +++++++++++++++++++++----------------------- package-lock.json | 34 ++++----- package.json | 6 +- 3 files changed, 103 insertions(+), 107 deletions(-) diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index f94f9ac..bf52b72 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -1,7 +1,4 @@ -This file was generated with the generate-license-file npm package! -https://www.npmjs.com/package/generate-license-file - -The following npm packages may be included in this product: +The following NPM packages may be included in this product: - @babel/runtime-corejs3@7.16.3 - @babel/runtime@7.16.3 @@ -33,39 +30,39 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - @reduxjs/toolkit@1.8.1 This package contains the following license and notice below: -MIT License - -Copyright (c) 2018 Mark Erikson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +MIT License + +Copyright (c) 2018 Mark Erikson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - - @yext/search-core@2.0.0-beta.219 + - @yext/search-core@2.0.0-alpha.221 This package contains the following license and notice below: @@ -107,9 +104,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - - @yext/search-headless@2.0.0-beta.135 + - @yext/search-headless@2.0.0-alpha.136 This package contains the following license and notice below: @@ -151,7 +148,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - core-js-pure@3.19.3 @@ -179,7 +176,7 @@ THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - cross-fetch@3.1.5 @@ -209,7 +206,7 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - immer@9.0.14 @@ -239,7 +236,7 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - js-levenshtein@1.1.6 @@ -269,7 +266,7 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - js-tokens@4.0.0 @@ -299,7 +296,7 @@ THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - lodash@4.17.21 @@ -355,7 +352,7 @@ terms above. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - loose-envify@1.4.0 @@ -385,7 +382,7 @@ THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - node-fetch@2.6.7 @@ -415,7 +412,7 @@ SOFTWARE. ----------- -The following npm packages may be included in this product: +The following NPM packages may be included in this product: - react@18.1.0 - use-sync-external-store@1.1.0 @@ -446,37 +443,37 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - redux-thunk@2.4.1 This package contains the following license and notice below: -The MIT License (MIT) - -Copyright (c) 2015-present Dan Abramov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +The MIT License (MIT) + +Copyright (c) 2015-present Dan Abramov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - redux@4.1.2 @@ -506,7 +503,7 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - regenerator-runtime@0.13.9 @@ -536,37 +533,37 @@ SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - reselect@4.1.5 This package contains the following license and notice below: -The MIT License (MIT) - -Copyright (c) 2015-2018 Reselect Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +The MIT License (MIT) + +Copyright (c) 2015-2018 Reselect Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - tr46@0.0.3 @@ -576,7 +573,7 @@ This package contains the following license and notice below: ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - webidl-conversions@3.0.1 @@ -597,7 +594,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ----------- -The following npm package may be included in this product: +The following NPM package may be included in this product: - whatwg-url@5.0.0 @@ -627,5 +624,4 @@ THE SOFTWARE. ----------- -This file was generated with the generate-license-file npm package! -https://www.npmjs.com/package/generate-license-file +This file was generated with generate-license-file! https://www.npmjs.com/package/generate-license-file diff --git a/package-lock.json b/package-lock.json index fffbb76..80c23b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-beta.154", + "version": "2.0.0-alpha.157", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "2.0.0-beta.154", + "version": "2.0.0-alpha.157", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "2.0.0-beta.135", + "@yext/search-headless": "2.0.0-alpha.136", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "2.0.0-beta.219", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-beta.219.tgz", - "integrity": "sha512-upanja5Z6sn9/bWyuV9vpKfSBZg2mnWThnY7pT+a3/X/IeWOy5y3w4ycBP+weYxZuu1+GZTyyO5KI/IeayC6hg==", + "version": "2.0.0-alpha.221", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.221.tgz", + "integrity": "sha512-zMWT+UObHEwl+FY6euhHR1VYHcC9Ie9k+CjZUX0qKRZsUlGuWO3rbQ4GqkfUaEPqZuRBGZGBPSRB84VmoDKF5w==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "2.0.0-beta.135", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-beta.135.tgz", - "integrity": "sha512-dIgseFAYZMa/VpuEA8mk0hcJeQNrjZ4oT9ecCO3LB5X0H/ANRcyviRDFywUeuzVO9MOxZBmh0TuaSlmIi8nzkw==", + "version": "2.0.0-alpha.136", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.136.tgz", + "integrity": "sha512-cuPhi0KXbe9QjnuYLcffSBkWVaPE9I+4TttfvFuWl9MgPfIDe40WHff6s48jUWuyY+Fm/3R//59SNEAKeb2beA==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-beta.219", + "@yext/search-core": "2.0.0-alpha.221", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "2.0.0-beta.219", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-beta.219.tgz", - "integrity": "sha512-upanja5Z6sn9/bWyuV9vpKfSBZg2mnWThnY7pT+a3/X/IeWOy5y3w4ycBP+weYxZuu1+GZTyyO5KI/IeayC6hg==", + "version": "2.0.0-alpha.221", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.221.tgz", + "integrity": "sha512-zMWT+UObHEwl+FY6euhHR1VYHcC9Ie9k+CjZUX0qKRZsUlGuWO3rbQ4GqkfUaEPqZuRBGZGBPSRB84VmoDKF5w==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "2.0.0-beta.135", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-beta.135.tgz", - "integrity": "sha512-dIgseFAYZMa/VpuEA8mk0hcJeQNrjZ4oT9ecCO3LB5X0H/ANRcyviRDFywUeuzVO9MOxZBmh0TuaSlmIi8nzkw==", + "version": "2.0.0-alpha.136", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.136.tgz", + "integrity": "sha512-cuPhi0KXbe9QjnuYLcffSBkWVaPE9I+4TttfvFuWl9MgPfIDe40WHff6s48jUWuyY+Fm/3R//59SNEAKeb2beA==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-beta.219", + "@yext/search-core": "2.0.0-alpha.221", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index 71a5410..d27113b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-beta.154", + "version": "2.0.0-alpha.157", "description": "The official React UI Bindings layer for Search Headless", "main": "./lib/esm/src/index.js", "license": "BSD-3-Clause", @@ -22,7 +22,7 @@ "THIRD-PARTY-NOTICES" ], "scripts": { - "build": "rm -rf lib/** && npm run build:esm && npm run build:cjs", + "build": "rm -rf lib/** && npm run build:esm && npm run build:cjs && npm run generate-notices", "build:esm": "tsc -p tsconfig.esm.json", "build:cjs": "tsc -p tsconfig.cjs.json", "prepublishOnly": "npm run build", @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "2.0.0-beta.135", + "@yext/search-headless": "2.0.0-alpha.136", "use-sync-external-store": "^1.1.0" }, "devDependencies": { From 34a77e6b64b000c32f404402050ff4738ea95a26 Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Tue, 6 Sep 2022 17:32:08 -0400 Subject: [PATCH 7/9] update package json (#158) Update all the entry points in package.json to omit the `src` directory. The removal of `package.json` import [here](https://github.com/yext/search-headless-react/pull/156/files#diff-e08419e5b1bb742eaecd92aeeb58a12baa6250e1f1d28d3a35c3bb0f72aa5224L5) means the src/ is no longer generated in the lib folder. --- package-lock.json | 4 ++-- package.json | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80c23b3..3b24f64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.157", + "version": "2.0.0-alpha.158", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.157", + "version": "2.0.0-alpha.158", "license": "BSD-3-Clause", "dependencies": { "@yext/search-headless": "2.0.0-alpha.136", diff --git a/package.json b/package.json index d27113b..12621ad 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.157", + "version": "2.0.0-alpha.158", "description": "The official React UI Bindings layer for Search Headless", - "main": "./lib/esm/src/index.js", + "main": "./lib/esm/index.js", "license": "BSD-3-Clause", - "types": "./lib/esm/src/index.d.ts", + "types": "./lib/esm/index.d.ts", "keywords": [ "search", "react", @@ -13,8 +13,8 @@ "yext" ], "exports": { - "import": "./lib/esm/src/index.js", - "require": "./lib/commonjs/src/index.js" + "import": "./lib/esm/index.js", + "require": "./lib/commonjs/index.js" }, "files": [ "lib", From 331292e9b470bbaa74f9fcd4cfe3377a9ffb115e Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Wed, 7 Sep 2022 12:59:53 -0400 Subject: [PATCH 8/9] update readme to reflect SearchHeadlessProvider changes (#159) update readme wording now that `SearchHeadlessProvider` requires a `SearchHeadless` instance instead of directly passing in the credentials. --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ccabd0..ff37867 100644 --- a/README.md +++ b/README.md @@ -25,21 +25,19 @@ npm install @yext/search-headless-react ## Getting Started - `SearchHeadlessProvider` -Search Headless React includes an `` component, which instantiates an SearchHeadless instance and makes it available to the rest of your app. +Search Headless React includes an `` component, which takes in a `SearchHeadless` instance and makes it available to the rest of your app. `SearchHeadless` instance is created using `provideHeadless(...)` with the appropriate credentials: ```tsx -import { SearchHeadlessProvider } from '@yext/search-headless-react'; +import { provideHeadless, SearchHeadlessProvider } from '@yext/search-headless-react'; import SearchBar from './SearchBar'; import MostRecentSearch from './MostRecentSearch'; import UniversalResults from './UniversalResults'; +const searcher = provideHeadless(config); + function MyApp() { return ( - + {/* Add components that use Search as children */} From e85b1d1139e6ddd286c6ad7b099c99243c2aa42a Mon Sep 17 00:00:00 2001 From: Yen Truong Date: Thu, 8 Sep 2022 16:54:18 -0400 Subject: [PATCH 9/9] update version --- THIRD-PARTY-NOTICES | 4 ++-- package-lock.json | 34 +++++++++++++++++----------------- package.json | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index bf52b72..7bd3965 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@2.0.0-alpha.221 + - @yext/search-core@2.0.0 This package contains the following license and notice below: @@ -106,7 +106,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The following NPM package may be included in this product: - - @yext/search-headless@2.0.0-alpha.136 + - @yext/search-headless@2.0.0 This package contains the following license and notice below: diff --git a/package-lock.json b/package-lock.json index 3b24f64..b5a63b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.158", + "version": "2.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.158", + "version": "2.0.0", "license": "BSD-3-Clause", "dependencies": { - "@yext/search-headless": "2.0.0-alpha.136", + "@yext/search-headless": "^2.0.0", "use-sync-external-store": "^1.1.0" }, "devDependencies": { @@ -4244,9 +4244,9 @@ } }, "node_modules/@yext/search-core": { - "version": "2.0.0-alpha.221", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.221.tgz", - "integrity": "sha512-zMWT+UObHEwl+FY6euhHR1VYHcC9Ie9k+CjZUX0qKRZsUlGuWO3rbQ4GqkfUaEPqZuRBGZGBPSRB84VmoDKF5w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0.tgz", + "integrity": "sha512-V5Z8aJrNAtuagB4y/ipzGUCfFBPdhXt3NTrGgUS5cguxCFM+AjlNyCZCjQyMa9BiITqWUBnSjIWVvCjnpsBf0w==", "dependencies": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" @@ -4256,12 +4256,12 @@ } }, "node_modules/@yext/search-headless": { - "version": "2.0.0-alpha.136", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.136.tgz", - "integrity": "sha512-cuPhi0KXbe9QjnuYLcffSBkWVaPE9I+4TttfvFuWl9MgPfIDe40WHff6s48jUWuyY+Fm/3R//59SNEAKeb2beA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0.tgz", + "integrity": "sha512-+YWcpH30ghDoM0G4WCmo5c6NzSNZ4gkOjXis67WlOQ9wOf6+EWsi/H0o3PR0Vrri45LKXFYEpS5oNVet7z1dGg==", "dependencies": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-alpha.221", + "@yext/search-core": "^2.0.0", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } @@ -15706,21 +15706,21 @@ } }, "@yext/search-core": { - "version": "2.0.0-alpha.221", - "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0-alpha.221.tgz", - "integrity": "sha512-zMWT+UObHEwl+FY6euhHR1VYHcC9Ie9k+CjZUX0qKRZsUlGuWO3rbQ4GqkfUaEPqZuRBGZGBPSRB84VmoDKF5w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@yext/search-core/-/search-core-2.0.0.tgz", + "integrity": "sha512-V5Z8aJrNAtuagB4y/ipzGUCfFBPdhXt3NTrGgUS5cguxCFM+AjlNyCZCjQyMa9BiITqWUBnSjIWVvCjnpsBf0w==", "requires": { "@babel/runtime-corejs3": "^7.12.5", "cross-fetch": "^3.1.5" } }, "@yext/search-headless": { - "version": "2.0.0-alpha.136", - "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0-alpha.136.tgz", - "integrity": "sha512-cuPhi0KXbe9QjnuYLcffSBkWVaPE9I+4TttfvFuWl9MgPfIDe40WHff6s48jUWuyY+Fm/3R//59SNEAKeb2beA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@yext/search-headless/-/search-headless-2.0.0.tgz", + "integrity": "sha512-+YWcpH30ghDoM0G4WCmo5c6NzSNZ4gkOjXis67WlOQ9wOf6+EWsi/H0o3PR0Vrri45LKXFYEpS5oNVet7z1dGg==", "requires": { "@reduxjs/toolkit": "^1.8.1", - "@yext/search-core": "2.0.0-alpha.221", + "@yext/search-core": "^2.0.0", "js-levenshtein": "^1.1.6", "lodash": "^4.17.21" } diff --git a/package.json b/package.json index 12621ad..324d319 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-headless-react", - "version": "2.0.0-alpha.158", + "version": "2.0.0", "description": "The official React UI Bindings layer for Search Headless", "main": "./lib/esm/index.js", "license": "BSD-3-Clause", @@ -32,7 +32,7 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" }, "dependencies": { - "@yext/search-headless": "2.0.0-alpha.136", + "@yext/search-headless": "^2.0.0", "use-sync-external-store": "^1.1.0" }, "devDependencies": {