@yext/answers-headless
Advanced tools
Comparing version
@@ -55,2 +55,7 @@ import { AnswersCore, QueryTrigger, QuerySource, QuestionSubmissionRequest, AutocompleteResponse, UniversalSearchResponse, QuestionSubmissionResponse, VerticalResults, FacetOption, DisplayableFacet, SortBy, Context, LatLong, SearchParameterField, FilterSearchResponse, UniversalLimit, VerticalSearchResponse } from '@yext/answers-core'; | ||
/** | ||
* Resets the direct answer, filters, query rules, search status, vertical, and universal states | ||
* to their initial values. | ||
*/ | ||
private _resetSearcherStates; | ||
/** | ||
* Sets {@link VerticalSearchState.limit} to the specified limit. | ||
@@ -57,0 +62,0 @@ * |
@@ -36,2 +36,8 @@ "use strict"; | ||
const searchType_1 = require("./models/utils/searchType"); | ||
const vertical_1 = require("./slices/vertical"); | ||
const universal_1 = require("./slices/universal"); | ||
const filters_1 = require("./slices/filters"); | ||
const directanswer_1 = require("./slices/directanswer"); | ||
const queryrules_1 = require("./slices/queryrules"); | ||
const searchstatus_1 = require("./slices/searchstatus"); | ||
/** | ||
@@ -85,2 +91,3 @@ * Provides the functionality for interacting with an Answers Search experience. | ||
setVertical(verticalKey) { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', verticalKey); | ||
@@ -93,2 +100,3 @@ this.stateManager.dispatchEvent('meta/setSearchType', searchType_1.SearchTypeEnum.Vertical); | ||
setUniversal() { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', undefined); | ||
@@ -98,2 +106,9 @@ this.stateManager.dispatchEvent('meta/setSearchType', searchType_1.SearchTypeEnum.Universal); | ||
/** | ||
* Resets the direct answer, filters, query rules, search status, vertical, and universal states | ||
* to their initial values. | ||
*/ | ||
_resetSearcherStates() { | ||
this.stateManager.dispatchEvent('set-state', Object.assign(Object.assign({}, this.state), { directAnswer: directanswer_1.initialState, filters: filters_1.initialState, queryRules: queryrules_1.initialState, searchStatus: searchstatus_1.initialState, vertical: vertical_1.initialState, universal: universal_1.initialState })); | ||
} | ||
/** | ||
* Sets {@link VerticalSearchState.limit} to the specified limit. | ||
@@ -100,0 +115,0 @@ * |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { FeaturedSnippetDirectAnswer, FieldValueDirectAnswer } from '@yext/answers-core'; | ||
import { DirectAnswerState } from '../models/slices/directanswer'; | ||
export declare const initialState: DirectAnswerState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setResult: (state: DirectAnswerState, action: PayloadAction<FeaturedSnippetDirectAnswer | FieldValueDirectAnswer | undefined>) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const initialState = {}; | ||
exports.initialState = {}; | ||
const reducers = { | ||
@@ -16,3 +17,3 @@ setResult: (state, action) => { | ||
name: prefix + 'directAnswer', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -19,0 +20,0 @@ }); |
@@ -5,2 +5,3 @@ import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SelectableFilter } from '../models/utils/selectablefilter'; | ||
export declare const initialState: FiltersState; | ||
interface FacetPayload { | ||
@@ -7,0 +8,0 @@ fieldId: string; |
@@ -14,5 +14,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const filter_utils_1 = require("../utils/filter-utils"); | ||
const initialState = {}; | ||
exports.initialState = {}; | ||
const reducers = { | ||
@@ -86,3 +87,3 @@ setStatic: (state, action) => { | ||
name: prefix + 'filters', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -89,0 +90,0 @@ }); |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { QueryRulesActionsData } from '@yext/answers-core'; | ||
import { QueryRulesState } from '../models/slices/queryrules'; | ||
export declare const initialState: QueryRulesState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setActions: (state: any, action: PayloadAction<QueryRulesActionsData[]>) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const initialState = { actions: [] }; | ||
exports.initialState = { actions: [] }; | ||
const reducers = { | ||
@@ -17,3 +18,3 @@ setActions: (state, action) => { | ||
name: prefix + 'queryRules', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -20,0 +21,0 @@ }); |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SearchStatusState } from '../models/slices/searchstatus'; | ||
export declare const initialState: SearchStatusState; | ||
declare const reducers: { | ||
@@ -4,0 +5,0 @@ setIsLoading: (state: any, action: PayloadAction<boolean>) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const initialState = {}; | ||
exports.initialState = {}; | ||
const reducers = { | ||
@@ -17,3 +18,3 @@ setIsLoading: (state, action) => { | ||
name: prefix + 'searchStatus', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -20,0 +21,0 @@ }); |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { UniversalLimit, VerticalResults } from '@yext/answers-core'; | ||
import { UniversalSearchState } from '../models/slices/universal'; | ||
export declare const initialState: UniversalSearchState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setVerticals: (state: UniversalSearchState, action: PayloadAction<VerticalResults[]>) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const initialState = {}; | ||
exports.initialState = {}; | ||
const reducers = { | ||
@@ -23,3 +24,3 @@ setVerticals: (state, action) => { | ||
name: prefix + 'universal', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -26,0 +27,0 @@ }); |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SortBy, VerticalSearchResponse } from '@yext/answers-core'; | ||
import { VerticalSearchState } from '../models/slices/vertical'; | ||
export declare const initialState: VerticalSearchState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ handleSearchResponse: (state: VerticalSearchState, action: PayloadAction<VerticalSearchResponse>) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initialState = void 0; | ||
const toolkit_1 = require("@reduxjs/toolkit"); | ||
const initialState = {}; | ||
exports.initialState = {}; | ||
const reducers = { | ||
@@ -52,3 +53,3 @@ handleSearchResponse: (state, action) => { | ||
name: prefix + 'vertical', | ||
initialState, | ||
initialState: exports.initialState, | ||
reducers | ||
@@ -55,0 +56,0 @@ }); |
@@ -55,2 +55,7 @@ import { AnswersCore, QueryTrigger, QuerySource, QuestionSubmissionRequest, AutocompleteResponse, UniversalSearchResponse, QuestionSubmissionResponse, VerticalResults, FacetOption, DisplayableFacet, SortBy, Context, LatLong, SearchParameterField, FilterSearchResponse, UniversalLimit, VerticalSearchResponse } from '@yext/answers-core'; | ||
/** | ||
* Resets the direct answer, filters, query rules, search status, vertical, and universal states | ||
* to their initial values. | ||
*/ | ||
private _resetSearcherStates; | ||
/** | ||
* Sets {@link VerticalSearchState.limit} to the specified limit. | ||
@@ -57,0 +62,0 @@ * |
@@ -15,2 +15,8 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { SearchTypeEnum } from './models/utils/searchType'; | ||
import { initialState as initialVerticalState } from './slices/vertical'; | ||
import { initialState as initialUniversalState } from './slices/universal'; | ||
import { initialState as initialFiltersState } from './slices/filters'; | ||
import { initialState as initialDirectAnswerState } from './slices/directanswer'; | ||
import { initialState as initialQueryRulesState } from './slices/queryrules'; | ||
import { initialState as initialSearchStatusState } from './slices/searchstatus'; | ||
/** | ||
@@ -64,2 +70,3 @@ * Provides the functionality for interacting with an Answers Search experience. | ||
setVertical(verticalKey) { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', verticalKey); | ||
@@ -72,2 +79,3 @@ this.stateManager.dispatchEvent('meta/setSearchType', SearchTypeEnum.Vertical); | ||
setUniversal() { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', undefined); | ||
@@ -77,2 +85,9 @@ this.stateManager.dispatchEvent('meta/setSearchType', SearchTypeEnum.Universal); | ||
/** | ||
* Resets the direct answer, filters, query rules, search status, vertical, and universal states | ||
* to their initial values. | ||
*/ | ||
_resetSearcherStates() { | ||
this.stateManager.dispatchEvent('set-state', Object.assign(Object.assign({}, this.state), { directAnswer: initialDirectAnswerState, filters: initialFiltersState, queryRules: initialQueryRulesState, searchStatus: initialSearchStatusState, vertical: initialVerticalState, universal: initialUniversalState })); | ||
} | ||
/** | ||
* Sets {@link VerticalSearchState.limit} to the specified limit. | ||
@@ -79,0 +94,0 @@ * |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { FeaturedSnippetDirectAnswer, FieldValueDirectAnswer } from '@yext/answers-core'; | ||
import { DirectAnswerState } from '../models/slices/directanswer'; | ||
export declare const initialState: DirectAnswerState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setResult: (state: DirectAnswerState, action: PayloadAction<FeaturedSnippetDirectAnswer | FieldValueDirectAnswer | undefined>) => void; |
import { createSlice } from '@reduxjs/toolkit'; | ||
const initialState = {}; | ||
export const initialState = {}; | ||
const reducers = { | ||
@@ -4,0 +4,0 @@ setResult: (state, action) => { |
@@ -5,2 +5,3 @@ import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SelectableFilter } from '../models/utils/selectablefilter'; | ||
export declare const initialState: FiltersState; | ||
interface FacetPayload { | ||
@@ -7,0 +8,0 @@ fieldId: string; |
@@ -14,3 +14,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { areFiltersEqual } from '../utils/filter-utils'; | ||
const initialState = {}; | ||
export const initialState = {}; | ||
const reducers = { | ||
@@ -17,0 +17,0 @@ setStatic: (state, action) => { |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { QueryRulesActionsData } from '@yext/answers-core'; | ||
import { QueryRulesState } from '../models/slices/queryrules'; | ||
export declare const initialState: QueryRulesState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setActions: (state: any, action: PayloadAction<QueryRulesActionsData[]>) => void; |
import { createSlice } from '@reduxjs/toolkit'; | ||
const initialState = { actions: [] }; | ||
export const initialState = { actions: [] }; | ||
const reducers = { | ||
@@ -4,0 +4,0 @@ setActions: (state, action) => { |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SearchStatusState } from '../models/slices/searchstatus'; | ||
export declare const initialState: SearchStatusState; | ||
declare const reducers: { | ||
@@ -4,0 +5,0 @@ setIsLoading: (state: any, action: PayloadAction<boolean>) => void; |
import { createSlice } from '@reduxjs/toolkit'; | ||
const initialState = {}; | ||
export const initialState = {}; | ||
const reducers = { | ||
@@ -4,0 +4,0 @@ setIsLoading: (state, action) => { |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { UniversalLimit, VerticalResults } from '@yext/answers-core'; | ||
import { UniversalSearchState } from '../models/slices/universal'; | ||
export declare const initialState: UniversalSearchState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ setVerticals: (state: UniversalSearchState, action: PayloadAction<VerticalResults[]>) => void; |
import { createSlice } from '@reduxjs/toolkit'; | ||
const initialState = {}; | ||
export const initialState = {}; | ||
const reducers = { | ||
@@ -4,0 +4,0 @@ setVerticals: (state, action) => { |
import { PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SortBy, VerticalSearchResponse } from '@yext/answers-core'; | ||
import { VerticalSearchState } from '../models/slices/vertical'; | ||
export declare const initialState: VerticalSearchState; | ||
declare const reducers: { | ||
@@ -5,0 +6,0 @@ handleSearchResponse: (state: VerticalSearchState, action: PayloadAction<VerticalSearchResponse>) => void; |
import { createSlice } from '@reduxjs/toolkit'; | ||
const initialState = {}; | ||
export const initialState = {}; | ||
const reducers = { | ||
@@ -4,0 +4,0 @@ handleSearchResponse: (state, action) => { |
{ | ||
"name": "@yext/answers-headless", | ||
"version": "1.1.0-beta.3", | ||
"version": "1.1.0-beta.4", | ||
"description": "", | ||
@@ -14,4 +14,3 @@ "author": "slapshot@yext.com", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && npm run api-extractor && npm run generate-docs", | ||
"build-ci": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && npm run api-extractor-ci && npm run generate-docs", | ||
"build": "rm -rf lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && npm run api-extractor && npm run generate-docs", | ||
"lint": "eslint .", | ||
@@ -21,3 +20,2 @@ "prepublishOnly": "npm run build", | ||
"api-extractor": "api-extractor run --local --verbose", | ||
"api-extractor-ci": "api-extractor run --verbose", | ||
"generate-docs": "api-documenter markdown --input-folder temp --output-folder docs && rm -rf temp", | ||
@@ -24,0 +22,0 @@ "generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite" |
@@ -30,2 +30,8 @@ import { | ||
import { SearchTypeEnum } from './models/utils/searchType'; | ||
import { initialState as initialVerticalState } from './slices/vertical'; | ||
import { initialState as initialUniversalState } from './slices/universal'; | ||
import { initialState as initialFiltersState } from './slices/filters'; | ||
import { initialState as initialDirectAnswerState } from './slices/directanswer'; | ||
import { initialState as initialQueryRulesState } from './slices/queryrules'; | ||
import { initialState as initialSearchStatusState } from './slices/searchstatus'; | ||
@@ -85,2 +91,3 @@ /** | ||
setVertical(verticalKey: string): void { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', verticalKey); | ||
@@ -94,2 +101,3 @@ this.stateManager.dispatchEvent('meta/setSearchType', SearchTypeEnum.Vertical); | ||
setUniversal(): void { | ||
this._resetSearcherStates(); | ||
this.stateManager.dispatchEvent('vertical/setVerticalKey', undefined); | ||
@@ -100,2 +108,18 @@ this.stateManager.dispatchEvent('meta/setSearchType', SearchTypeEnum.Universal); | ||
/** | ||
* Resets the direct answer, filters, query rules, search status, vertical, and universal states | ||
* to their initial values. | ||
*/ | ||
private _resetSearcherStates() { | ||
this.stateManager.dispatchEvent('set-state', { | ||
...this.state, | ||
directAnswer: initialDirectAnswerState, | ||
filters: initialFiltersState, | ||
queryRules: initialQueryRulesState, | ||
searchStatus: initialSearchStatusState, | ||
vertical: initialVerticalState, | ||
universal: initialUniversalState | ||
}); | ||
} | ||
/** | ||
* Sets {@link VerticalSearchState.limit} to the specified limit. | ||
@@ -102,0 +126,0 @@ * |
@@ -5,3 +5,3 @@ import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
const initialState: DirectAnswerState = {}; | ||
export const initialState: DirectAnswerState = {}; | ||
@@ -8,0 +8,0 @@ const reducers = { |
@@ -7,3 +7,3 @@ import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
const initialState: FiltersState = {}; | ||
export const initialState: FiltersState = {}; | ||
@@ -10,0 +10,0 @@ interface FacetPayload { |
@@ -5,3 +5,3 @@ import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
const initialState: QueryRulesState = { actions: [] }; | ||
export const initialState: QueryRulesState = { actions: [] }; | ||
@@ -8,0 +8,0 @@ const reducers = { |
import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
import { SearchStatusState } from '../models/slices/searchstatus'; | ||
const initialState: SearchStatusState = {}; | ||
export const initialState: SearchStatusState = {}; | ||
@@ -6,0 +6,0 @@ const reducers = { |
@@ -5,3 +5,3 @@ import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
const initialState: UniversalSearchState = {}; | ||
export const initialState: UniversalSearchState = {}; | ||
@@ -8,0 +8,0 @@ const reducers = { |
@@ -8,3 +8,3 @@ import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit'; | ||
const initialState: VerticalSearchState = {}; | ||
export const initialState: VerticalSearchState = {}; | ||
@@ -11,0 +11,0 @@ const reducers = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2
-33.33%379480
-11.78%390
-19.75%6919
-8.04%