From e19047838f00255986e1a1c3ad51ff7ab734e39b Mon Sep 17 00:00:00 2001 From: Guillermo Cacheda Date: Thu, 12 Oct 2023 11:51:24 +0200 Subject: [PATCH] Revert "(feat) Implement config utils in the modules with config (#1321)" This reverts commit 393d7588d19e01d7b012b8a6b92f01babb080f3e. --- .../src/store/utils/config-store.utils.ts | 9 +++++---- .../src/x-modules/empathize/store/module.ts | 5 +---- .../src/x-modules/empathize/store/types.ts | 3 +-- .../facets/store/__tests__/getters.spec.ts | 2 +- .../src/x-modules/facets/store/module.ts | 13 +++++++------ .../src/x-modules/facets/store/types.ts | 9 +++++++-- .../src/x-modules/history-queries/store/module.ts | 3 --- .../src/x-modules/history-queries/store/types.ts | 5 +---- .../x-modules/identifier-results/store/module.ts | 5 +---- .../src/x-modules/identifier-results/store/types.ts | 6 +----- .../src/x-modules/next-queries/store/module.ts | 5 +---- .../src/x-modules/next-queries/store/types.ts | 10 ++++------ .../src/x-modules/popular-searches/store/module.ts | 7 ++----- .../src/x-modules/popular-searches/store/types.ts | 5 +---- .../src/x-modules/queries-preview/store/module.ts | 5 +---- .../src/x-modules/queries-preview/store/types.ts | 3 +-- .../src/x-modules/query-suggestions/store/module.ts | 5 +---- .../src/x-modules/query-suggestions/store/types.ts | 6 +----- .../src/x-modules/recommendations/store/module.ts | 5 +---- .../src/x-modules/recommendations/store/types.ts | 5 +---- .../src/x-modules/related-tags/store/module.ts | 5 +---- .../src/x-modules/related-tags/store/types.ts | 6 +----- .../src/x-modules/search/store/module.ts | 6 +++--- .../src/x-modules/search/store/types.ts | 12 +++++++----- .../src/x-modules/semantic-queries/store/module.ts | 5 +---- .../src/x-modules/semantic-queries/store/types.ts | 5 +++-- .../__tests__/pdp-add-to-cart.service.spec.ts | 2 +- .../src/x-modules/tagging/store/module.ts | 6 +++--- .../src/x-modules/tagging/store/types.ts | 10 ++++++++-- .../x-components/src/x-modules/tagging/wiring.ts | 2 +- 30 files changed, 68 insertions(+), 107 deletions(-) diff --git a/packages/x-components/src/store/utils/config-store.utils.ts b/packages/x-components/src/store/utils/config-store.utils.ts index ee6210fcee..fdde8e4105 100644 --- a/packages/x-components/src/store/utils/config-store.utils.ts +++ b/packages/x-components/src/store/utils/config-store.utils.ts @@ -1,5 +1,3 @@ -import Vue from 'vue'; - /** * Config mutations, containing a method to change the current config and other to merge * a new one. @@ -30,7 +28,7 @@ export interface ConfigMutations { * @public */ export function setConfig(state: T, config: T['config']): void { - Vue.set(state, 'config', config); + state.config = config; } /** @@ -45,5 +43,8 @@ export function mergeConfig( state: T, config: Partial ): void { - Object.assign(state.config, config); + state.config = { + ...state.config, + ...config + }; } diff --git a/packages/x-components/src/x-modules/empathize/store/module.ts b/packages/x-components/src/x-modules/empathize/store/module.ts index 70fd0e4b06..d53bb61691 100644 --- a/packages/x-components/src/x-modules/empathize/store/module.ts +++ b/packages/x-components/src/x-modules/empathize/store/module.ts @@ -1,4 +1,3 @@ -import { setConfig, mergeConfig } from '../../../store/utils/config-store.utils'; import { EmpathizeXStoreModule } from './types'; /** @@ -15,9 +14,7 @@ export const empathizeXStoreModule: EmpathizeXStoreModule = { mutations: { setIsOpen(state, isOpen) { state.isOpen = isOpen; - }, - setConfig, - mergeConfig + } }, actions: {} }; diff --git a/packages/x-components/src/x-modules/empathize/store/types.ts b/packages/x-components/src/x-modules/empathize/store/types.ts index 7a79a8afb3..414cd5211e 100644 --- a/packages/x-components/src/x-modules/empathize/store/types.ts +++ b/packages/x-components/src/x-modules/empathize/store/types.ts @@ -1,6 +1,5 @@ import { XStoreModule } from '../../../store'; import { EmpathizeConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Empathize store state. @@ -34,7 +33,7 @@ export interface EmpathizeGetters {} * * @public */ -export interface EmpathizeMutations extends ConfigMutations { +export interface EmpathizeMutations { /** * Sets the isOpen state of the module, which is used in the Alias API. * diff --git a/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts b/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts index ede77ce1d7..a8b8b63b0a 100644 --- a/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts +++ b/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts @@ -239,7 +239,7 @@ describe('testing facets module getters', () => { ); const store = createFacetsStore([parentFilter, childFilter, parentFilterWithoutChild], []); - store.commit('setConfig', { + store.commit('setFacetsConfig', { filtersStrategyForRequest: 'leaves-only' }); diff --git a/packages/x-components/src/x-modules/facets/store/module.ts b/packages/x-components/src/x-modules/facets/store/module.ts index c4e6a0df50..3c6b55f875 100644 --- a/packages/x-components/src/x-modules/facets/store/module.ts +++ b/packages/x-components/src/x-modules/facets/store/module.ts @@ -1,11 +1,9 @@ import { Facet } from '@empathyco/x-types'; import Vue from 'vue'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; -import { setQuery } from '../../../store/utils/query.utils'; import { facets } from './getters/facets.getter'; import { selectedFiltersByFacet } from './getters/selected-filters-by-facet.getter'; import { selectedFilters } from './getters/selected-filters.getter'; -import { FacetGroupEntry, FacetsXStoreModule } from './types'; +import { FacetGroupEntry, FacetsConfig, FacetsXStoreModule } from './types'; import { selectedFiltersForRequest } from './getters/selected-filters-for-request.getter'; /** @@ -57,9 +55,12 @@ export const facetsXStoreModule: FacetsXStoreModule = { setFacet(state, facet: Facet) { Vue.set(state.facets, facet.id, facet); }, - setConfig, - mergeConfig, - setQuery, + setFacetsConfig(state, config: FacetsConfig) { + state.config = config; + }, + setQuery(state, query) { + state.query = query; + }, setStickyFilter(state, filter) { if (!state.stickyFilters[filter.id]) { Vue.set(state.stickyFilters, filter.id, filter); diff --git a/packages/x-components/src/x-modules/facets/store/types.ts b/packages/x-components/src/x-modules/facets/store/types.ts index 231a1c428f..713259e405 100644 --- a/packages/x-components/src/x-modules/facets/store/types.ts +++ b/packages/x-components/src/x-modules/facets/store/types.ts @@ -1,6 +1,5 @@ import { Facet, Filter, RawFilter } from '@empathyco/x-types'; import { XActionContext, XStoreModule } from '../../../store'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Facets store state. @@ -53,7 +52,7 @@ export interface FacetsGetters { * * @public */ -export interface FacetsMutations extends ConfigMutations { +export interface FacetsMutations { /** * Updates the state of a filter. * @@ -110,6 +109,12 @@ export interface FacetsMutations extends ConfigMutations { * @param facet - The facet to set in the store. */ setFacet(facet: Facet): void; + /** + * Sets the {@link FacetsState.facets | facets} config. + * + * @param config - The new config. + */ + setFacetsConfig(config: FacetsConfig): void; /** * Adds the filter to the {@link FacetsState.stickyFilters | sticky filters} record. * diff --git a/packages/x-components/src/x-modules/history-queries/store/module.ts b/packages/x-components/src/x-modules/history-queries/store/module.ts index 07ac71e705..03f769cf6c 100644 --- a/packages/x-components/src/x-modules/history-queries/store/module.ts +++ b/packages/x-components/src/x-modules/history-queries/store/module.ts @@ -1,6 +1,5 @@ import { setQuery } from '../../../store/utils/query.utils'; import { localStorageService } from '../../../utils/storage'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { addQueryToHistory } from './actions/add-query-to-history.action'; // eslint-disable-next-line max-len import { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action'; @@ -52,8 +51,6 @@ export const historyQueriesXStoreModule: HistoryQueriesXStoreModule = { state.sessionTimeStampInMs = sessionTimeStamp; }, setQuery, - setConfig, - mergeConfig, setIsEnabled(state, isEnabled) { state.isEnabled = isEnabled; }, diff --git a/packages/x-components/src/x-modules/history-queries/store/types.ts b/packages/x-components/src/x-modules/history-queries/store/types.ts index e018d20875..7013c4693c 100644 --- a/packages/x-components/src/x-modules/history-queries/store/types.ts +++ b/packages/x-components/src/x-modules/history-queries/store/types.ts @@ -4,7 +4,6 @@ import { QueryMutations, QueryState } from '../../../store/utils/query.utils'; import { UrlParams } from '../../../types/url-params'; import { HistoryQueriesConfig } from '../config.types'; import { InternalSearchResponse } from '../../search/index'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * HistoryQueries store state. @@ -69,9 +68,7 @@ export interface HistoryQueriesGetters { * * @public */ -export interface HistoryQueriesMutations - extends QueryMutations, - ConfigMutations { +export interface HistoryQueriesMutations extends QueryMutations { /** * Sets the {@link HistoryQueriesState.historyQueries} property. * diff --git a/packages/x-components/src/x-modules/identifier-results/store/module.ts b/packages/x-components/src/x-modules/identifier-results/store/module.ts index 6f3872b5a6..0ad6f3c0e5 100644 --- a/packages/x-components/src/x-modules/identifier-results/store/module.ts +++ b/packages/x-components/src/x-modules/identifier-results/store/module.ts @@ -1,6 +1,5 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveIdentifierResults, fetchAndSaveIdentifierResults @@ -48,9 +47,7 @@ export const identifierResultsXStoreModule: IdentifierResultsXStoreModule = { state.params = params; }, setQuery, - setStatus, - setConfig, - mergeConfig + setStatus }, actions: { cancelFetchAndSaveIdentifierResults, diff --git a/packages/x-components/src/x-modules/identifier-results/store/types.ts b/packages/x-components/src/x-modules/identifier-results/store/types.ts index cd070f1cbe..e89b229086 100644 --- a/packages/x-components/src/x-modules/identifier-results/store/types.ts +++ b/packages/x-components/src/x-modules/identifier-results/store/types.ts @@ -5,7 +5,6 @@ import { QueryMutations, QueryState } from '../../../store/utils/query.utils'; import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; import { QueryOrigin, QueryOriginInit } from '../../../types/origin'; import { IdentifierResultsConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * IdentifierResults store state. @@ -50,10 +49,7 @@ export interface IdentifierResultsGetters { * * @public */ -export interface IdentifierResultsMutations - extends StatusMutations, - QueryMutations, - ConfigMutations { +export interface IdentifierResultsMutations extends StatusMutations, QueryMutations { /** * Sets the identifier results of the module. * diff --git a/packages/x-components/src/x-modules/next-queries/store/module.ts b/packages/x-components/src/x-modules/next-queries/store/module.ts index cc8278bbd4..e12a5e6b4c 100644 --- a/packages/x-components/src/x-modules/next-queries/store/module.ts +++ b/packages/x-components/src/x-modules/next-queries/store/module.ts @@ -1,6 +1,5 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveNextQueries, fetchAndSaveNextQueries @@ -55,9 +54,7 @@ export const nextQueriesXStoreModule: NextQueriesXStoreModule = { }, resetResultsPreview(state) { state.resultsPreview = {}; - }, - setConfig, - mergeConfig + } }, actions: { cancelFetchAndSaveNextQueries, diff --git a/packages/x-components/src/x-modules/next-queries/store/types.ts b/packages/x-components/src/x-modules/next-queries/store/types.ts index c1973c47b8..082c7c6a8a 100644 --- a/packages/x-components/src/x-modules/next-queries/store/types.ts +++ b/packages/x-components/src/x-modules/next-queries/store/types.ts @@ -12,7 +12,6 @@ import { StatusMutations, StatusState } from '../../../store/utils/status-store. import { UrlParams } from '../../../types/url-params'; import { NextQueriesConfig } from '../config.types'; import { FeatureLocation } from '../../../types/index'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Next queries module state. @@ -43,7 +42,7 @@ export interface NextQueriesState extends StatusState, QueryState { export interface NextQueriesGetters { /** * Request object to retrieve the next queries using the search adapter, or null if there is - * no valid data to conform a valid request. + * not valid data to conform a valid request. */ request: NextQueriesRequest | null; /** List of next queries that have not been searched before. */ @@ -55,10 +54,7 @@ export interface NextQueriesGetters { * * @public */ -export interface NextQueriesMutations - extends StatusMutations, - QueryMutations, - ConfigMutations { +export interface NextQueriesMutations extends StatusMutations, QueryMutations { /** * Sets the query of the module, which is used to retrieve the next-queries. * @@ -83,6 +79,7 @@ export interface NextQueriesMutations * @param params - The new extra params. */ setParams(params: Dictionary): void; + /** * Adds a new entry to the result's dictionary. * @@ -90,6 +87,7 @@ export interface NextQueriesMutations * the totalResults and the results to add. */ setResultsPreview(resultsPreview: Dictionary): void; + /** * Resets the result's dictionary. */ diff --git a/packages/x-components/src/x-modules/popular-searches/store/module.ts b/packages/x-components/src/x-modules/popular-searches/store/module.ts index 5df9abb1e5..92caeed7e4 100644 --- a/packages/x-components/src/x-modules/popular-searches/store/module.ts +++ b/packages/x-components/src/x-modules/popular-searches/store/module.ts @@ -1,5 +1,4 @@ import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveSuggestions, fetchAndSaveSuggestions @@ -36,12 +35,10 @@ export const popularSearchesXStoreModule: PopularSearchesXStoreModule = { setSearchedQueries(state, searchedQueries) { state.searchedQueries = searchedQueries; }, + setStatus, setParams(state, params) { state.params = params; - }, - setStatus, - setConfig, - mergeConfig + } }, actions: { cancelFetchAndSaveSuggestions, diff --git a/packages/x-components/src/x-modules/popular-searches/store/types.ts b/packages/x-components/src/x-modules/popular-searches/store/types.ts index 992dc6a395..bffb74824b 100644 --- a/packages/x-components/src/x-modules/popular-searches/store/types.ts +++ b/packages/x-components/src/x-modules/popular-searches/store/types.ts @@ -3,7 +3,6 @@ import { Dictionary } from '@empathyco/x-utils'; import { XActionContext, XStoreModule } from '../../../store'; import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; import { PopularSearchesConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Popular searches module state. @@ -39,9 +38,7 @@ export interface PopularSearchesGetters { * * @public */ -export interface PopularSearchesMutations - extends StatusMutations, - ConfigMutations { +export interface PopularSearchesMutations extends StatusMutations { /** * Sets the suggestions of the module. * diff --git a/packages/x-components/src/x-modules/queries-preview/store/module.ts b/packages/x-components/src/x-modules/queries-preview/store/module.ts index 17a42791a1..04f6fb377c 100644 --- a/packages/x-components/src/x-modules/queries-preview/store/module.ts +++ b/packages/x-components/src/x-modules/queries-preview/store/module.ts @@ -1,5 +1,4 @@ import Vue from 'vue'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { QueriesPreviewXStoreModule } from './types'; import { fetchQueryPreview } from './actions/fetch-query-preview.action'; import { fetchAndSaveQueryPreview } from './actions/fetch-and-save-query-preview.action'; @@ -39,9 +38,7 @@ export const queriesPreviewXStoreModule: QueriesPreviewXStoreModule = { }, setSelectedQueryPreview(state, selectedQueryPreview) { state.selectedQueryPreview = selectedQueryPreview; - }, - setConfig, - mergeConfig + } }, actions: { fetchQueryPreview, diff --git a/packages/x-components/src/x-modules/queries-preview/store/types.ts b/packages/x-components/src/x-modules/queries-preview/store/types.ts index 0b78414632..7e562242f8 100644 --- a/packages/x-components/src/x-modules/queries-preview/store/types.ts +++ b/packages/x-components/src/x-modules/queries-preview/store/types.ts @@ -4,7 +4,6 @@ import { XActionContext } from '../../../store/actions.types'; import { XStoreModule } from '../../../store/store.types'; import { RequestStatus, StatusState } from '../../../store/utils/status-store.utils'; import { QueriesPreviewConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * QueriesPreview store state. @@ -76,7 +75,7 @@ export interface QueriesPreviewGetters { * * @public */ -export interface QueriesPreviewMutations extends ConfigMutations { +export interface QueriesPreviewMutations { /** * Removes a query preview entry from the queries preview's dictionary. * diff --git a/packages/x-components/src/x-modules/query-suggestions/store/module.ts b/packages/x-components/src/x-modules/query-suggestions/store/module.ts index 91bce9cfdc..39982eeecf 100644 --- a/packages/x-components/src/x-modules/query-suggestions/store/module.ts +++ b/packages/x-components/src/x-modules/query-suggestions/store/module.ts @@ -1,6 +1,5 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveSuggestions, fetchAndSaveSuggestions @@ -42,9 +41,7 @@ export const querySuggestionsXStoreModule: QuerySuggestionsXStoreModule = { setStatus, setParams(state, params) { state.params = params; - }, - setConfig, - mergeConfig + } }, actions: { cancelFetchAndSaveSuggestions, diff --git a/packages/x-components/src/x-modules/query-suggestions/store/types.ts b/packages/x-components/src/x-modules/query-suggestions/store/types.ts index c27e283719..9f2cfbc802 100644 --- a/packages/x-components/src/x-modules/query-suggestions/store/types.ts +++ b/packages/x-components/src/x-modules/query-suggestions/store/types.ts @@ -5,7 +5,6 @@ import { QueryMutations, QueryState } from '../../../store/utils/query.utils'; import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; import { UrlParams } from '../../../types/url-params'; import { QuerySuggestionsConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * QuerySuggestions store state. @@ -45,10 +44,7 @@ export interface QuerySuggestionsGetters { * * @public */ -export interface QuerySuggestionsMutations - extends StatusMutations, - QueryMutations, - ConfigMutations { +export interface QuerySuggestionsMutations extends StatusMutations, QueryMutations { /** * Sets the query of the query suggestions module. * diff --git a/packages/x-components/src/x-modules/recommendations/store/module.ts b/packages/x-components/src/x-modules/recommendations/store/module.ts index b077a4b0d5..9e32221408 100644 --- a/packages/x-components/src/x-modules/recommendations/store/module.ts +++ b/packages/x-components/src/x-modules/recommendations/store/module.ts @@ -1,5 +1,4 @@ import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveRecommendations, fetchAndSaveRecommendations @@ -42,9 +41,7 @@ export const recommendationsXStoreModule: RecommendationsXStoreModule = { if (stateRecommendation) { Object.assign(stateRecommendation, recommendation); } - }, - setConfig, - mergeConfig + } }, actions: { cancelFetchAndSaveRecommendations, diff --git a/packages/x-components/src/x-modules/recommendations/store/types.ts b/packages/x-components/src/x-modules/recommendations/store/types.ts index 8234b7e774..bb65e7ffd3 100644 --- a/packages/x-components/src/x-modules/recommendations/store/types.ts +++ b/packages/x-components/src/x-modules/recommendations/store/types.ts @@ -3,7 +3,6 @@ import { Dictionary } from '@empathyco/x-utils'; import { XActionContext, XStoreModule } from '../../../store'; import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; import { RecommendationsConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Recommendations store state. @@ -36,9 +35,7 @@ export interface RecommendationsGetters { * * @public */ -export interface RecommendationsMutations - extends StatusMutations, - ConfigMutations { +export interface RecommendationsMutations extends StatusMutations { /** * Sets the recommendations of the module. * diff --git a/packages/x-components/src/x-modules/related-tags/store/module.ts b/packages/x-components/src/x-modules/related-tags/store/module.ts index 7ad62ce2f4..1f6d793be5 100644 --- a/packages/x-components/src/x-modules/related-tags/store/module.ts +++ b/packages/x-components/src/x-modules/related-tags/store/module.ts @@ -1,6 +1,5 @@ import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { cancelFetchAndSaveRelatedTags, fetchAndSaveRelatedTags @@ -46,9 +45,7 @@ export const relatedTagsXStoreModule: RelatedTagsXStoreModule = { setStatus, setParams(state, params) { state.params = params; - }, - setConfig, - mergeConfig + } }, actions: { cancelFetchAndSaveRelatedTags, diff --git a/packages/x-components/src/x-modules/related-tags/store/types.ts b/packages/x-components/src/x-modules/related-tags/store/types.ts index 99e157a386..dbc83a9d8e 100644 --- a/packages/x-components/src/x-modules/related-tags/store/types.ts +++ b/packages/x-components/src/x-modules/related-tags/store/types.ts @@ -5,7 +5,6 @@ import { QueryMutations, QueryState } from '../../../store/utils/query.utils'; import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; import { UrlParams } from '../../../types/url-params'; import { RelatedTagsConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * RelatedTags store state. @@ -46,10 +45,7 @@ export interface RelatedTagsGetters { * * @public */ -export interface RelatedTagsMutations - extends StatusMutations, - QueryMutations, - ConfigMutations { +export interface RelatedTagsMutations extends StatusMutations, QueryMutations { /** * Sets the related tags of the module. * diff --git a/packages/x-components/src/x-modules/search/store/module.ts b/packages/x-components/src/x-modules/search/store/module.ts index 506b194f46..864ff08f98 100644 --- a/packages/x-components/src/x-modules/search/store/module.ts +++ b/packages/x-components/src/x-modules/search/store/module.ts @@ -2,7 +2,6 @@ import { isFacetFilter } from '@empathyco/x-types'; import { setQuery } from '../../../store/utils/query.utils'; import { setStatus } from '../../../store/utils/status-store.utils'; import { groupItemsBy } from '../../../utils/array'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; // eslint-disable-next-line max-len import { cancelFetchAndSaveSearchResponse, @@ -82,8 +81,9 @@ export const searchXStoreModule: SearchXStoreModule = { setPage(state, page) { state.page = page; }, - setConfig, - mergeConfig, + setPageSize(state, pageSize) { + state.config.pageSize = pageSize; + }, setIsAppendResults(state, isAppendResults) { state.isAppendResults = isAppendResults; }, diff --git a/packages/x-components/src/x-modules/search/store/types.ts b/packages/x-components/src/x-modules/search/store/types.ts index db6d386e34..f651ce4820 100644 --- a/packages/x-components/src/x-modules/search/store/types.ts +++ b/packages/x-components/src/x-modules/search/store/types.ts @@ -20,7 +20,6 @@ import { QueryOrigin, QueryOriginInit } from '../../../types/origin'; import { UrlParams } from '../../../types/url-params'; import { SearchConfig } from '../config.types'; import { InternalSearchRequest, WatchedInternalSearchRequest } from '../types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Search store state. @@ -93,10 +92,7 @@ export interface SearchGetters { * * @public */ -export interface SearchMutations - extends StatusMutations, - QueryMutations, - ConfigMutations { +export interface SearchMutations extends StatusMutations, QueryMutations { /** * Append the results to the results state. * @@ -150,6 +146,12 @@ export interface SearchMutations * @param page - The new page. */ setPage(page: number): void; + /** + * Sets the page size of the module. + * + * @param pageSize - The new page size. + */ + setPageSize(pageSize: number): void; /** * Sets the extra params of the module. * diff --git a/packages/x-components/src/x-modules/semantic-queries/store/module.ts b/packages/x-components/src/x-modules/semantic-queries/store/module.ts index 8c578b86f8..38e6108c4e 100644 --- a/packages/x-components/src/x-modules/semantic-queries/store/module.ts +++ b/packages/x-components/src/x-modules/semantic-queries/store/module.ts @@ -1,4 +1,3 @@ -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { SemanticQueriesXStoreModule } from './types'; import { fetchSemanticQuery } from './actions/fetch-semantic-query.action'; import { fetchAndSaveSemanticQuery } from './actions/fetch-and-save-semantic-query.action'; @@ -37,9 +36,7 @@ export const semanticQueriesXStoreModule: SemanticQueriesXStoreModule = { }, setTotalResults(state, totalResults) { state.totalResults = totalResults; - }, - setConfig, - mergeConfig + } }, actions: { fetchSemanticQuery, diff --git a/packages/x-components/src/x-modules/semantic-queries/store/types.ts b/packages/x-components/src/x-modules/semantic-queries/store/types.ts index 9325950ded..f86196b085 100644 --- a/packages/x-components/src/x-modules/semantic-queries/store/types.ts +++ b/packages/x-components/src/x-modules/semantic-queries/store/types.ts @@ -3,7 +3,6 @@ import { Dictionary } from '@empathyco/x-utils'; import { XActionContext } from '../../../store/actions.types'; import { XStoreModule } from '../../../store/store.types'; import { SemanticQueriesConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * SemanticQueries store state. @@ -45,11 +44,12 @@ export interface SemanticQueriesGetters { * * @public */ -export interface SemanticQueriesMutations extends ConfigMutations { +export interface SemanticQueriesMutations { /** * Sets the {@link SemanticQueriesState.query} property. */ setQuery(query: string): void; + /** * Sets the {@link SemanticQueriesState.totalResults} property. */ @@ -60,6 +60,7 @@ export interface SemanticQueriesMutations extends ConfigMutations): void; + /** * Sets the {@link SemanticQueriesState.semanticQueries} property. */ diff --git a/packages/x-components/src/x-modules/tagging/service/__tests__/pdp-add-to-cart.service.spec.ts b/packages/x-components/src/x-modules/tagging/service/__tests__/pdp-add-to-cart.service.spec.ts index ebdc764851..4b0395d488 100644 --- a/packages/x-components/src/x-modules/tagging/service/__tests__/pdp-add-to-cart.service.spec.ts +++ b/packages/x-components/src/x-modules/tagging/service/__tests__/pdp-add-to-cart.service.spec.ts @@ -37,7 +37,7 @@ function commitTaggingConfig( store: Store, taggingConfig: Partial ): void { - store.commit('x/tagging/mergeConfig', taggingConfig); + store.commit('x/tagging/setTaggingConfig', taggingConfig); } describe('testing pdp add to cart', () => { diff --git a/packages/x-components/src/x-modules/tagging/store/module.ts b/packages/x-components/src/x-modules/tagging/store/module.ts index 9b199c9dfa..cca5e6778e 100644 --- a/packages/x-components/src/x-modules/tagging/store/module.ts +++ b/packages/x-components/src/x-modules/tagging/store/module.ts @@ -1,5 +1,4 @@ import { TaggingRequest } from '@empathyco/x-types'; -import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { track } from './actions/track.action'; import { TaggingXStoreModule } from './types'; @@ -27,8 +26,9 @@ export const taggingXStoreModule: TaggingXStoreModule = { setQueryTaggingInfo(state, queryTaggingInfo: TaggingRequest) { state.queryTaggingInfo = queryTaggingInfo; }, - setConfig, - mergeConfig + setTaggingConfig(state, taggingConfig) { + Object.assign(state.config, taggingConfig); + } }, actions: { track diff --git a/packages/x-components/src/x-modules/tagging/store/types.ts b/packages/x-components/src/x-modules/tagging/store/types.ts index 909fe8d928..47e51530ae 100644 --- a/packages/x-components/src/x-modules/tagging/store/types.ts +++ b/packages/x-components/src/x-modules/tagging/store/types.ts @@ -1,7 +1,6 @@ import { TaggingRequest } from '@empathyco/x-types'; import { XStoreModule } from '../../../store'; import { TaggingConfig } from '../config.types'; -import { ConfigMutations } from '../../../store/utils/config-store.utils'; /** * Tagging store state. * @@ -34,7 +33,7 @@ export interface TaggingGetters {} * * @public */ -export interface TaggingMutations extends ConfigMutations { +export interface TaggingMutations { /** * Sets the {@link TaggingState.consent } property. * @@ -47,6 +46,13 @@ export interface TaggingMutations extends ConfigMutations { * @param queryTaggingInfo - The new {@link TaggingState.queryTaggingInfo}. */ setQueryTaggingInfo(queryTaggingInfo: TaggingRequest): void; + + /** + * Sets the {@link TaggingState.config} property. + * + * @param taggingConfig - The new {@link TaggingState.config}. + */ + setTaggingConfig(taggingConfig: TaggingConfig): void; } /** diff --git a/packages/x-components/src/x-modules/tagging/wiring.ts b/packages/x-components/src/x-modules/tagging/wiring.ts index fd5d9570ee..9012cdc670 100644 --- a/packages/x-components/src/x-modules/tagging/wiring.ts +++ b/packages/x-components/src/x-modules/tagging/wiring.ts @@ -97,7 +97,7 @@ export const setConsent = wireCommit('setConsent'); * * @public */ -export const setTaggingConfig = wireCommit('mergeConfig'); +export const setTaggingConfig = wireCommit('setTaggingConfig'); /** * Tracks the tagging of the query.