From 317d961e94b0b7454cb4d858d401c4264c74cf0e Mon Sep 17 00:00:00 2001 From: Manuel Navarro <77450928+mnavarroespinosa@users.noreply.github.com> Date: Wed, 24 Aug 2022 10:58:16 +0200 Subject: [PATCH] feat(queries-preview): create `queriesPreview` module (#670) EX-6638 --- packages/x-components/src/index.ts | 1 + packages/x-components/src/store/x.module.ts | 1 + .../x-components/src/wiring/events.types.ts | 3 ++ .../src/x-modules/extra-params/x-module.ts | 4 +- .../x-modules/queries-preview/events.types.ts | 7 +++ .../src/x-modules/queries-preview/index.ts | 4 ++ .../queries-preview/store/emitters.ts | 9 ++++ .../x-modules/queries-preview/store/index.ts | 3 ++ .../x-modules/queries-preview/store/module.ts | 13 +++++ .../x-modules/queries-preview/store/types.ts | 53 +++++++++++++++++++ .../src/x-modules/queries-preview/wiring.ts | 8 +++ .../src/x-modules/queries-preview/x-module.ts | 25 +++++++++ .../src/x-modules/x-modules.types.ts | 8 ++- 13 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 packages/x-components/src/x-modules/queries-preview/events.types.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/index.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/store/emitters.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/store/index.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/store/module.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/store/types.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/wiring.ts create mode 100644 packages/x-components/src/x-modules/queries-preview/x-module.ts diff --git a/packages/x-components/src/index.ts b/packages/x-components/src/index.ts index da688048e5..c7ce34ec02 100644 --- a/packages/x-components/src/index.ts +++ b/packages/x-components/src/index.ts @@ -22,6 +22,7 @@ export * from './x-modules/history-queries'; export * from './x-modules/identifier-results'; export * from './x-modules/next-queries'; export * from './x-modules/popular-searches'; +export * from './x-modules/queries-preview'; export * from './x-modules/query-suggestions'; export * from './x-modules/recommendations'; export * from './x-modules/related-tags'; diff --git a/packages/x-components/src/store/x.module.ts b/packages/x-components/src/store/x.module.ts index 36ea0936b8..66ee8267a2 100644 --- a/packages/x-components/src/store/x.module.ts +++ b/packages/x-components/src/store/x.module.ts @@ -26,6 +26,7 @@ export const RootXStoreModule: Module = { identifierResults: null, nextQueries: null, popularSearches: null, + queriesPreview: null, querySuggestions: null, recommendations: null, relatedTags: null, diff --git a/packages/x-components/src/wiring/events.types.ts b/packages/x-components/src/wiring/events.types.ts index ad11e3b4d4..fdc4e206b6 100644 --- a/packages/x-components/src/wiring/events.types.ts +++ b/packages/x-components/src/wiring/events.types.ts @@ -9,6 +9,7 @@ import { HistoryQueriesXEvents } from '../x-modules/history-queries/events.types import { IdentifierResultsXEvents } from '../x-modules/identifier-results/events.types'; import { NextQueriesXEvents } from '../x-modules/next-queries/events.types'; import { PopularSearchesXEvents } from '../x-modules/popular-searches/events.types'; +import { QueriesPreviewXEvents } from '../x-modules/queries-preview/events.types'; import { QuerySuggestionsXEvents } from '../x-modules/query-suggestions/events.types'; import { RecommendationsXEvents } from '../x-modules/recommendations/events.types'; import { RelatedTagsXEvents } from '../x-modules/related-tags/events.types'; @@ -34,6 +35,7 @@ import { WireMetadata } from './wiring.types'; * {@link IdentifierResultsXEvents} * {@link NextQueriesXEvents} * {@link PopularSearchesXEvents} + * {@link QueriesPreviewXEvents}, * {@link QuerySuggestionsXEvents}, * {@link RecommendationsXEvents} * {@link RelatedTagsXEvents} @@ -54,6 +56,7 @@ export interface XEventsTypes IdentifierResultsXEvents, NextQueriesXEvents, PopularSearchesXEvents, + QueriesPreviewXEvents, QuerySuggestionsXEvents, RecommendationsXEvents, RelatedTagsXEvents, diff --git a/packages/x-components/src/x-modules/extra-params/x-module.ts b/packages/x-components/src/x-modules/extra-params/x-module.ts index 5a237e8b6c..241efc6bd8 100644 --- a/packages/x-components/src/x-modules/extra-params/x-module.ts +++ b/packages/x-components/src/x-modules/extra-params/x-module.ts @@ -1,5 +1,7 @@ import { XModule } from '../x-modules.types'; -import { extraParamsEmitters, ExtraParamsXStoreModule, extraParamsXStoreModule } from './store'; +import { extraParamsEmitters } from './store/emitters'; +import { extraParamsXStoreModule } from './store/module'; +import { ExtraParamsXStoreModule } from './store/types'; import { extraParamsWiring } from './wiring'; /** diff --git a/packages/x-components/src/x-modules/queries-preview/events.types.ts b/packages/x-components/src/x-modules/queries-preview/events.types.ts new file mode 100644 index 0000000000..f1b52f1cfe --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/events.types.ts @@ -0,0 +1,7 @@ +/** + * Dictionary of the events of QueriesPreview XModule, where each key is the event name, and the + * value is the event payload type or `void` if it has no payload. + * + * @public + */ +export interface QueriesPreviewXEvents {} diff --git a/packages/x-components/src/x-modules/queries-preview/index.ts b/packages/x-components/src/x-modules/queries-preview/index.ts new file mode 100644 index 0000000000..247e20b2ab --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/index.ts @@ -0,0 +1,4 @@ +export * from './events.types'; +export * from './store'; +export * from './x-module'; +export * from './wiring'; diff --git a/packages/x-components/src/x-modules/queries-preview/store/emitters.ts b/packages/x-components/src/x-modules/queries-preview/store/emitters.ts new file mode 100644 index 0000000000..7e2464970f --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/store/emitters.ts @@ -0,0 +1,9 @@ +import { createStoreEmitters } from '../../../store'; +import { queriesPreviewXStoreModule } from './module'; + +/** + * {@link StoreEmitters} For the queries-preview module. + * + * @internal + */ +export const queriesPreviewEmitters = createStoreEmitters(queriesPreviewXStoreModule, {}); diff --git a/packages/x-components/src/x-modules/queries-preview/store/index.ts b/packages/x-components/src/x-modules/queries-preview/store/index.ts new file mode 100644 index 0000000000..21e4a30020 --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/store/index.ts @@ -0,0 +1,3 @@ +export * from './emitters'; +export * from './module'; +export * from './types'; 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 new file mode 100644 index 0000000000..d3daabf338 --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/store/module.ts @@ -0,0 +1,13 @@ +import { QueriesPreviewXStoreModule } from './types'; + +/** + * {@link XStoreModule} For the queries-preview module. + * + * @internal + */ +export const queriesPreviewXStoreModule: QueriesPreviewXStoreModule = { + state: () => ({}), + getters: {}, + mutations: {}, + actions: {} +}; 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 new file mode 100644 index 0000000000..f669e95d72 --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/store/types.ts @@ -0,0 +1,53 @@ +import { XActionContext, XStoreModule } from '../../../store/index'; + +/** + * QueriesPreview store state. + * + * @public + */ +export interface QueriesPreviewState {} + +/** + * QueriesPreview store getters. + * + * @public + */ +export interface QueriesPreviewGetters {} + +/** + * QueriesPreview store mutations. + * + * @public + */ +export interface QueriesPreviewMutations {} + +/** + * QueriesPreview store actions. + * + * @public + */ +export interface QueriesPreviewActions {} + +/** + * QueriesPreview type safe store module. + * + * @public + */ +export type QueriesPreviewXStoreModule = XStoreModule< + QueriesPreviewState, + QueriesPreviewGetters, + QueriesPreviewMutations, + QueriesPreviewActions +>; + +/** + * Alias type for actions context of the {@link QueriesPreviewXStoreModule}. + * + * @public + */ +export type QueriesPreviewActionContext = XActionContext< + QueriesPreviewState, + QueriesPreviewGetters, + QueriesPreviewMutations, + QueriesPreviewActions +>; diff --git a/packages/x-components/src/x-modules/queries-preview/wiring.ts b/packages/x-components/src/x-modules/queries-preview/wiring.ts new file mode 100644 index 0000000000..8d1c4b41b5 --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/wiring.ts @@ -0,0 +1,8 @@ +import { createWiring } from '../../wiring/wiring.utils'; + +/** + * Wiring configuration for the {@link QueriesPreviewXModule | queriesPreview module}. + * + * @internal + */ +export const queriesPreviewWiring = createWiring({}); diff --git a/packages/x-components/src/x-modules/queries-preview/x-module.ts b/packages/x-components/src/x-modules/queries-preview/x-module.ts new file mode 100644 index 0000000000..ee1ce29cba --- /dev/null +++ b/packages/x-components/src/x-modules/queries-preview/x-module.ts @@ -0,0 +1,25 @@ +import { XModule } from '../x-modules.types'; +import { queriesPreviewEmitters } from './store/emitters'; +import { queriesPreviewXStoreModule } from './store/module'; +import { QueriesPreviewXStoreModule } from './store/types'; +import { queriesPreviewWiring } from './wiring'; + +/** + * QueriesPreview {@link XModule} alias. + * + * @public + */ +export type QueriesPreviewXModule = XModule; + +/** + * QueriesPreview {@link XModule} implementation. This module is auto-registered as soon as you + * import any component from the `queries-preview` entry point. + * + * @public + */ +export const queriesPreviewXModule: QueriesPreviewXModule = { + name: 'queriesPreview', + storeModule: queriesPreviewXStoreModule, + storeEmitters: queriesPreviewEmitters, + wiring: queriesPreviewWiring +}; diff --git a/packages/x-components/src/x-modules/x-modules.types.ts b/packages/x-components/src/x-modules/x-modules.types.ts index aa1935e370..6c2076afe7 100644 --- a/packages/x-components/src/x-modules/x-modules.types.ts +++ b/packages/x-components/src/x-modules/x-modules.types.ts @@ -9,6 +9,7 @@ import { HistoryQueriesXModule } from './history-queries/x-module'; import { IdentifierResultsXModule } from './identifier-results/x-module'; import { NextQueriesXModule } from './next-queries/x-module'; import { PopularSearchesXModule } from './popular-searches/x-module'; +import { QueriesPreviewXModule } from './queries-preview/x-module'; import { QuerySuggestionsXModule } from './query-suggestions/x-module'; import { RecommendationsXModule } from './recommendations/x-module'; import { RelatedTagsXModule } from './related-tags/x-module'; @@ -32,6 +33,7 @@ export interface XModulesTree { identifierResults: IdentifierResultsXModule; nextQueries: NextQueriesXModule; popularSearches: PopularSearchesXModule; + queriesPreview: QueriesPreviewXModule; querySuggestions: QuerySuggestionsXModule; recommendations: RecommendationsXModule; relatedTags: RelatedTagsXModule; @@ -62,8 +64,10 @@ export interface XModule { storeEmitters: StoreEmitters; /** The Vuex Store module associated to this module. */ storeModule: StoreModule; - /** The wiring associated to this module. It must only access to the store module of this - * XModule. */ + /** + * The wiring associated to this module. It must only access to the store module of this + * XModule. + */ wiring: Partial; }