Skip to content

Commit

Permalink
Answers -> Search 2: rename imports (#144)
Browse files Browse the repository at this point in the history
* renamed answers-headless imports

* Automated update to THIRD-PARTY-NOTICES from github action's 3rd party notices check

* version update

* update license

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ElemelonWind and github-actions[bot] committed Jul 15, 2022
1 parent e0b5013 commit 4db446b
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Contains information from the language-subtag-registry JSON Database (https://github.com/mattcg/language-subtag-registry/tree/master/data/json)
which is made available under the ODC Attribution License (https://github.com/mattcg/language-subtag-registry/blob/master/LICENSE.md).

The Answers Headless React files listed in this repository are licensed under the below license. All other features and products are subject to
The Search Headless React files listed in this repository are licensed under the below license. All other features and products are subject to
separate agreements and certain functionality requires paid subscriptions to Yext products.

BSD 3-Clause License
Expand Down
10 changes: 5 additions & 5 deletions THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ SOFTWARE.

The following NPM package may be included in this product:

- @yext/answers-core@1.7.0
- @yext/search-core@1.8.0

This package contains the following license and notice below:

The Answers Core files listed in this repository are licensed under the below license.  All other features and products are subject to separate agreements
The Search Core files listed in this repository are licensed under the below license.  All other features and products are subject to separate agreements
and certain functionality requires paid subscriptions to Yext products.

Contains information from the language-subtag-registry JSON Database (https://github.com/mattcg/language-subtag-registry/tree/master/data/json)
Expand Down Expand Up @@ -106,19 +106,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The following NPM package may be included in this product:

- @yext/answers-headless@1.2.0
- @yext/search-headless@1.3.0

This package contains the following license and notice below:

The Answers Headless files listed in this repository are licensed under the below license.  All other features and products are subject to separate agreements
The Search Headless files listed in this repository are licensed under the below license.  All other features and products are subject to separate agreements
and certain functionality requires paid subscriptions to Yext products.

Contains information from the language-subtag-registry JSON Database (https://github.com/mattcg/language-subtag-registry/tree/master/data/json)
which is made available under the ODC Attribution License (https://github.com/mattcg/language-subtag-registry/blob/master/LICENSE.md).

BSD 3-Clause License

Copyright (c) 2021, Yext
Copyright (c) 2022, Yext
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
92 changes: 46 additions & 46 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/search-headless-react",
"version": "1.2.0",
"version": "1.3.0",
"description": "The official React UI Bindings layer for Search Headless",
"main": "./lib/esm/src/index.js",
"license": "BSD-3-Clause",
Expand Down Expand Up @@ -32,7 +32,7 @@
"generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite"
},
"dependencies": {
"@yext/answers-headless": "^1.2.0",
"@yext/search-headless": "^1.3.0",
"use-sync-external-store": "^1.1.0"
},
"devDependencies": {
Expand Down Expand Up @@ -84,7 +84,7 @@
"<rootDir>/tests/setup/setup-env.ts"
],
"transformIgnorePatterns": [
"/node_modules/(?!@yext/answers-headless)"
"/node_modules/(?!@yext/search-headless)"
],
"transform": {
"^.+\\.tsx?$": "ts-jest",
Expand Down
4 changes: 2 additions & 2 deletions src/SearchHeadlessContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnswersHeadless } from '@yext/answers-headless';
import { SearchHeadless } from '@yext/search-headless';
import { createContext } from 'react';

// The default is empty because we don't know the user's config yet
export const SearchHeadlessContext = createContext<AnswersHeadless>({} as AnswersHeadless);
export const SearchHeadlessContext = createContext<SearchHeadless>({} as SearchHeadless);
4 changes: 2 additions & 2 deletions src/SearchHeadlessProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PropsWithChildren } from 'react';
import { provideAnswersHeadless, AnswersHeadless, HeadlessConfig } from '@yext/answers-headless';
import { provideHeadless, SearchHeadless, HeadlessConfig } from '@yext/search-headless';
import { SearchHeadlessContext } from './SearchHeadlessContext';
import acquireSessionId from './utils/acquireSessionId';
import packageJson from '../package.json';
Expand All @@ -18,7 +18,7 @@ export function SearchHeadlessProvider(props: PropsWithChildren<Props>): JSX.Ele
ANSWERS_HEADLESS_REACT: version
}
};
const answers: AnswersHeadless = provideAnswersHeadless(answersConfig, additionalHttpHeaders);
const answers: SearchHeadless = provideHeadless(answersConfig, additionalHttpHeaders);

verticalKey && answers.setVertical(verticalKey);
answers.setSessionTrackingEnabled(sessionTrackingEnabled);
Expand Down
2 changes: 1 addition & 1 deletion src/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSearchUtilities, SearchUtilities } from './useSearchUtilities';
import { SearchHeadlessProvider } from './SearchHeadlessProvider';
import { SearchHeadlessContext } from './SearchHeadlessContext';
import { PropsWithChildren } from 'react';
import { HeadlessConfig } from '@yext/answers-headless';
import { HeadlessConfig } from '@yext/search-headless';

type Props = HeadlessConfig & {
verticalKey?: string,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { subscribeToStateUpdates } from './subscribeToStateUpdates';
import { SearchHeadlessProvider } from './SearchHeadlessProvider';
import { SearchHeadlessContext } from './SearchHeadlessContext';

export * from '@yext/answers-headless';
export * from '@yext/search-headless';
export * from './deprecated';
export {
SearchHeadlessContext,
Expand Down
2 changes: 1 addition & 1 deletion src/subscribeToStateUpdates.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { ComponentType, useReducer, useEffect, useContext } from 'react';
import { State } from '@yext/answers-headless';
import { State } from '@yext/search-headless';
import { SearchHeadlessContext } from './SearchHeadlessContext';
import isShallowEqual from './utils/isShallowEqual';

Expand Down
10 changes: 5 additions & 5 deletions src/useSearchActions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AnswersHeadless } from '@yext/answers-headless';
import { SearchHeadless } from '@yext/search-headless';
import { useContext } from 'react';
import { SearchHeadlessContext } from './SearchHeadlessContext';

export type SearchActions = AnswersHeadless;
export type SearchActions = SearchHeadless;

export function useSearchActions(): SearchActions {
const answersHeadless = useContext(SearchHeadlessContext);
if (answersHeadless.state === undefined) {
const searchHeadless = useContext(SearchHeadlessContext);
if (searchHeadless.state === undefined) {
throw new Error('Attempted to call useSearchActions() outside of SearchHeadlessProvider.'
+ ' Please ensure that \'useSearchActions()\' is called within an SearchHeadlessProvider component.');
}
return answersHeadless;
return searchHeadless;
}
2 changes: 1 addition & 1 deletion src/useSearchState.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useContext, useEffect, useRef } from 'react';
import { State } from '@yext/answers-headless';
import { State } from '@yext/search-headless';
import { SearchHeadlessContext } from './SearchHeadlessContext';
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';

Expand Down
4 changes: 2 additions & 2 deletions src/useSearchUtilities.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AnswersHeadless } from '@yext/answers-headless';
import { SearchHeadless } from '@yext/search-headless';
import { useContext } from 'react';
import { SearchHeadlessContext } from './SearchHeadlessContext';

export type SearchUtilities = AnswersHeadless['utilities'];
export type SearchUtilities = SearchHeadless['utilities'];

export function useSearchUtilities(): SearchUtilities {
return useContext(SearchHeadlessContext).utilities;
Expand Down
10 changes: 5 additions & 5 deletions tests/SearchHeadlessProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SearchHeadlessProvider, SandboxEndpoints } from '../src';
import { render } from '@testing-library/react';
import { provideAnswersHeadless } from '@yext/answers-headless';
import { provideHeadless } from '@yext/search-headless';

jest.mock('@yext/answers-headless', () => ({
provideAnswersHeadless: jest.fn(() => ({
jest.mock('@yext/search-headless', () => ({
provideHeadless: jest.fn(() => ({
setSessionTrackingEnabled: jest.fn(),
setSessionId: jest.fn()
}))
Expand All @@ -18,6 +18,6 @@ it('correctly passes through an answers config with sandbox endpoints', () => {
};

render(<SearchHeadlessProvider {...config}/>);
expect(provideAnswersHeadless).toHaveBeenCalledTimes(1);
expect(provideAnswersHeadless).toHaveBeenCalledWith(config, expect.anything());
expect(provideHeadless).toHaveBeenCalledTimes(1);
expect(provideHeadless).toHaveBeenCalledWith(config, expect.anything());
});
4 changes: 2 additions & 2 deletions tests/useSearchState.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { provideAnswersHeadless, Result, State } from '@yext/answers-headless';
import { provideHeadless, Result, State } from '@yext/search-headless';
import { useCallback, useReducer } from 'react';
import { SearchHeadlessContext, useSearchActions, useSearchState } from '../src';
import { renderToString } from 'react-dom/server';
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('uses the most recent selector', () => {
});

function createAnswersHeadless() {
return provideAnswersHeadless({
return provideHeadless({
apiKey: 'fake api key',
experienceKey: 'fake exp key',
locale: 'en',
Expand Down

0 comments on commit 4db446b

Please sign in to comment.