@empathyco/x-components
Version:
Empathy X Components
75 lines (72 loc) • 2.76 kB
JavaScript
import { namespacedWireCommit, namespacedWireCommitWithoutPayload, namespacedWireDispatch } from '../../wiring/namespaced-wires.factory.js';
import { filterTruthyPayload } from '../../wiring/wires.operators.js';
import { createWiring } from '../../wiring/wiring.utils.js';
/** AI XModule name. */
const moduleName = 'ai';
/** WireCommit for AiXModule. */
const wireCommit = namespacedWireCommit(moduleName);
/** WireCommitWithoutPayload for AiXModule. */
const wireCommitWithoutPayload = namespacedWireCommitWithoutPayload(moduleName);
/** WireDispatch for AiXModule.*/
const wireDispatch = namespacedWireDispatch(moduleName);
/** Sets the AI state from URL data. */
const setUrlParamsWire = wireDispatch('setUrlParams');
/** Sets the AI state `params`. */
const setExtraParamsWire = wireCommit('setParams');
/** Sets the AI state `query`. */
const setAiQueryWire = wireCommit('setQuery');
/** Sets the AI state `query` with the selectedQueryPreview's query. */
const setAiQueryFromPreviewWire = wireCommit('setQuery', ({ eventPayload: { query } }) => query);
/** Fetches the AI suggestions streaming response. */
const fetchAndSaveAiSuggestionsWire = wireDispatch('fetchAndSaveAiSuggestions');
/** Fetches and save the AI suggestions search response. */
const fetchAndSaveAiSuggestionsSearchWire = filterTruthyPayload(wireDispatch('fetchAndSaveAiSuggestionsSearch'));
/** Sets the AI state `relatedTags`.*/
const setAiRelatedTagsWire = wireCommit('setAiRelatedTags');
/** Resets the related prompts state. */
const resetAiStateWire = wireCommitWithoutPayload('resetAiState');
/** Sets the origin for the AI requests. */
const saveAiOriginWire = wireDispatch('saveOrigin', ({ metadata }) => metadata);
/** Sets the AI state `selectedFilters`. */
const setSelectedFiltersWire = wireCommit('setSelectedFilters');
/**
* Wiring configuration for the {@link AiXModule | AI module}.
*
* @internal
*/
const aiWiring = createWiring({
ParamsLoadedFromUrl: {
setUrlParamsWire,
},
ExtraParamsChanged: {
setExtraParamsWire,
},
UserAcceptedAQuery: {
setAiQueryWire,
},
UserAcceptedAQueryPreview: {
setAiQueryFromPreviewWire,
},
UserClearedQuery: {
setAiQueryWire,
},
AiSuggestionsRequestUpdated: {
resetAiStateWire,
fetchAndSaveAiSuggestionsWire,
},
// Formerly AiSuggestionsSearchRequestUpdated
UserClickedAiOverviewExpandButton: {
fetchAndSaveAiSuggestionsSearchWire,
},
SelectedRelatedTagsChanged: {
setAiRelatedTagsWire,
},
SelectedFiltersForRequestChanged: {
setSelectedFiltersWire,
},
AiOverviewMounted: {
saveAiOriginWire,
},
});
export { aiWiring };
//# sourceMappingURL=wiring.js.map