@fluid-topics/ft-search-context 1.3.16 → 1.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ft-search-context.d.ts +1 -0
- package/build/ft-search-context.js +9 -2
- package/build/ft-search-context.light.js +8 -8
- package/build/ft-search-context.min.js +18 -18
- package/build/store/FtSearchStateManager.d.ts +2 -0
- package/build/store/FtSearchStateManager.js +19 -1
- package/build/store/model.d.ts +2 -1
- package/build/store/redux.d.ts +2 -0
- package/build/store/redux.js +5 -0
- package/build/store/utils/FtSearchService.d.ts +2 -1
- package/build/store/utils/FtSearchService.js +8 -4
- package/package.json +5 -5
|
@@ -24,7 +24,9 @@ export declare class FtSearchStateManager {
|
|
|
24
24
|
forceContentLocale(contentLocale?: string): void;
|
|
25
25
|
setPageSize(pageSize: number): void;
|
|
26
26
|
setPageNumber(pageNumber: number): void;
|
|
27
|
+
get sortOptions(): import("@fluid-topics/public-api").FtSearchSortOption[];
|
|
27
28
|
setSort(sort: FtSearchSortCriterion[]): void;
|
|
29
|
+
setSortId(sortId?: string): string | undefined;
|
|
28
30
|
setFilters(filters: FtMetadataFilter[]): void;
|
|
29
31
|
setClusterSortCriterion(criterions: FtPublicClusterSortCriterion[]): void;
|
|
30
32
|
setSearchInDocumentTitlesOnly(searchInDocumentTitleOnly: boolean): void;
|
|
@@ -35,10 +35,12 @@ export class FtSearchStateManager {
|
|
|
35
35
|
return this.suggestDebouncer.run(() => this.fetchSuggestData(request !== null && request !== void 0 ? request : this.buildSuggestRequest(this.store.getState())));
|
|
36
36
|
};
|
|
37
37
|
this.buildSuggestRequest = (state) => {
|
|
38
|
+
var _a;
|
|
38
39
|
return {
|
|
39
40
|
input: state.liveQuery,
|
|
40
41
|
metadataFilters: state.request.metadataFilters,
|
|
41
|
-
sort: state.request.sort,
|
|
42
|
+
sort: (_a = state.request.sort) !== null && _a !== void 0 ? _a : [],
|
|
43
|
+
sortId: state.request.sortId,
|
|
42
44
|
contentLocale: state.request.contentLocale,
|
|
43
45
|
scope: state.request.scope,
|
|
44
46
|
};
|
|
@@ -54,6 +56,7 @@ export class FtSearchStateManager {
|
|
|
54
56
|
}
|
|
55
57
|
async initService() {
|
|
56
58
|
this.updateLocales();
|
|
59
|
+
this.service.getConfiguration().then((conf) => this.store.actions.configuration(conf));
|
|
57
60
|
return this.launchSearch();
|
|
58
61
|
}
|
|
59
62
|
setQuery(query) {
|
|
@@ -87,10 +90,25 @@ export class FtSearchStateManager {
|
|
|
87
90
|
setPageNumber(pageNumber) {
|
|
88
91
|
this.store.actions.setPageNumber(pageNumber);
|
|
89
92
|
}
|
|
93
|
+
get sortOptions() {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
return (_b = (_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.sortOptions) !== null && _b !== void 0 ? _b : [];
|
|
96
|
+
}
|
|
90
97
|
setSort(sort) {
|
|
91
98
|
this.store.actions.setRequestSort(sort);
|
|
92
99
|
this.store.actions.setPageNumber(1);
|
|
93
100
|
}
|
|
101
|
+
setSortId(sortId) {
|
|
102
|
+
var _a;
|
|
103
|
+
this.store.actions.setPageNumber(1);
|
|
104
|
+
if (sortId == undefined || this.sortOptions.length == 0) {
|
|
105
|
+
this.store.actions.setRequestSortId(sortId);
|
|
106
|
+
return sortId;
|
|
107
|
+
}
|
|
108
|
+
const selectedSort = (_a = this.sortOptions.find((option) => option.id == sortId)) !== null && _a !== void 0 ? _a : this.sortOptions[0];
|
|
109
|
+
this.store.actions.setRequestSortId(selectedSort.id);
|
|
110
|
+
return selectedSort.id;
|
|
111
|
+
}
|
|
94
112
|
setFilters(filters) {
|
|
95
113
|
const cleanFilters = filters.filter((f) => !f.valueFilter || f.valueFilter.values.length > 0);
|
|
96
114
|
this.store.actions.setRequestFilters(cleanFilters);
|
package/build/store/model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FtSearchFacet, FtSearchLocale, FtSearchResultAnnouncement, FtSearchResultCluster, FtSearchResultsPageInfo, FtSpellcheck, FtSuggestResult } from "@fluid-topics/public-api";
|
|
1
|
+
import { FtSearchConfiguration, FtSearchFacet, FtSearchLocale, FtSearchResultAnnouncement, FtSearchResultCluster, FtSearchResultsPageInfo, FtSpellcheck, FtSuggestResult } from "@fluid-topics/public-api";
|
|
2
2
|
import { EnrichedFtSearchRequest } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
export interface FtSearchPageState {
|
|
4
|
+
configuration: FtSearchConfiguration | undefined;
|
|
4
5
|
locales: Array<FtSearchLocale> | undefined;
|
|
5
6
|
request: EnrichedFtSearchRequest;
|
|
6
7
|
results: Array<FtSearchResultCluster> | undefined;
|
package/build/store/redux.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const searchPageStateReducers: {
|
|
|
8
8
|
setPageSize: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["perPage"]>) => void;
|
|
9
9
|
setPageNumber: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["page"]>) => void;
|
|
10
10
|
setRequestSort: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sort"]>) => void;
|
|
11
|
+
setRequestSortId: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sortId"]>) => void;
|
|
11
12
|
setRequestFilters: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["metadataFilters"]>) => void;
|
|
12
13
|
setRequestFacets: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["facets"]>) => void;
|
|
13
14
|
setRequestVirtualField: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["virtualField"]>) => void;
|
|
@@ -23,6 +24,7 @@ export declare const createSearchPageStore: (id: string) => FtReduxStore<FtSearc
|
|
|
23
24
|
setPageSize: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["perPage"]>) => void;
|
|
24
25
|
setPageNumber: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["page"]>) => void;
|
|
25
26
|
setRequestSort: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sort"]>) => void;
|
|
27
|
+
setRequestSortId: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sortId"]>) => void;
|
|
26
28
|
setRequestFilters: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["metadataFilters"]>) => void;
|
|
27
29
|
setRequestFacets: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["facets"]>) => void;
|
|
28
30
|
setRequestVirtualField: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["virtualField"]>) => void;
|
package/build/store/redux.js
CHANGED
|
@@ -20,6 +20,9 @@ const searchPageStateReducers = {
|
|
|
20
20
|
setRequestSort: (state, action) => {
|
|
21
21
|
state.request.sort = action.payload;
|
|
22
22
|
},
|
|
23
|
+
setRequestSortId: (state, action) => {
|
|
24
|
+
state.request.sortId = action.payload;
|
|
25
|
+
},
|
|
23
26
|
setRequestFilters: (state, action) => {
|
|
24
27
|
state.request.metadataFilters = action.payload;
|
|
25
28
|
},
|
|
@@ -49,6 +52,7 @@ export const createSearchPageStore = (id) => FtReduxStore.get({
|
|
|
49
52
|
metadataFilters: [],
|
|
50
53
|
facets: [],
|
|
51
54
|
sort: [],
|
|
55
|
+
sortId: undefined,
|
|
52
56
|
paging: {
|
|
53
57
|
page: 1,
|
|
54
58
|
perPage: 20,
|
|
@@ -62,6 +66,7 @@ export const createSearchPageStore = (id) => FtReduxStore.get({
|
|
|
62
66
|
results: undefined,
|
|
63
67
|
announcements: undefined,
|
|
64
68
|
suggestResults: undefined,
|
|
69
|
+
configuration: undefined,
|
|
65
70
|
},
|
|
66
71
|
reducers: searchPageStateReducers,
|
|
67
72
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type FluidTopicsApi, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults } from "@fluid-topics/public-api";
|
|
1
|
+
import { type FluidTopicsApi, FtSearchConfiguration, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
3
3
|
export declare class FtSearchService extends FtServiceWithCache {
|
|
4
4
|
constructor(overrideApi?: FluidTopicsApi);
|
|
5
5
|
launchSearch(request: FtSearchRequest): Promise<FtSearchResults>;
|
|
6
6
|
launchSuggest(request: FtSuggestRequest): Promise<FtSuggestResults>;
|
|
7
7
|
getAvailableSearchLocales(): Promise<FtSearchLocales>;
|
|
8
|
+
getConfiguration(): Promise<FtSearchConfiguration>;
|
|
8
9
|
private sortFilters;
|
|
9
10
|
}
|
|
@@ -2,6 +2,7 @@ import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
|
2
2
|
export class FtSearchService extends FtServiceWithCache {
|
|
3
3
|
constructor(overrideApi) {
|
|
4
4
|
super(true, overrideApi);
|
|
5
|
+
this.cache.registerFinal("search-configuration", async () => (await this.awaitApi).getSearchConfiguration());
|
|
5
6
|
}
|
|
6
7
|
async launchSearch(request) {
|
|
7
8
|
const sortedRequest = {
|
|
@@ -14,21 +15,24 @@ export class FtSearchService extends FtServiceWithCache {
|
|
|
14
15
|
async launchSuggest(request) {
|
|
15
16
|
const sortedRequest = {
|
|
16
17
|
...request,
|
|
17
|
-
metadataFilters: this.sortFilters(request.metadataFilters)
|
|
18
|
+
metadataFilters: this.sortFilters(request.metadataFilters),
|
|
18
19
|
};
|
|
19
20
|
return this.cache.get("suggest-" + this.hash(sortedRequest), async () => (await this.awaitApi).getSuggestions(request), 2 * 60 * 1000);
|
|
20
21
|
}
|
|
21
22
|
async getAvailableSearchLocales() {
|
|
22
23
|
return this.cache.get("available-locales", async () => (await this.awaitApi).getAvailableSearchLocales());
|
|
23
24
|
}
|
|
25
|
+
async getConfiguration() {
|
|
26
|
+
return this.cache.get("search-configuration");
|
|
27
|
+
}
|
|
24
28
|
sortFilters(filters) {
|
|
25
29
|
return filters
|
|
26
|
-
.map(f => f.valueFilter == null ? f : {
|
|
30
|
+
.map((f) => f.valueFilter == null ? f : {
|
|
27
31
|
...f,
|
|
28
32
|
valueFilter: {
|
|
29
33
|
...f.valueFilter,
|
|
30
|
-
values: [...f.valueFilter.values].sort((a, b) => a.localeCompare(b))
|
|
31
|
-
}
|
|
34
|
+
values: [...f.valueFilter.values].sort((a, b) => a.localeCompare(b)),
|
|
35
|
+
},
|
|
32
36
|
})
|
|
33
37
|
.sort((a, b) => a.key.localeCompare(b.key));
|
|
34
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.18",
|
|
4
4
|
"description": "Context block for integrated search components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.3.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.3.18",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.18",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-topics/public-api": "1.0.
|
|
27
|
+
"@fluid-topics/public-api": "1.0.102"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "f0b88802ac4978bfb8561ded6af8de7c559051a2"
|
|
30
30
|
}
|