@fluid-topics/ft-search-context 1.1.82 → 1.1.83
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 +3 -2
- package/build/ft-search-context.js +14 -6
- package/build/ft-search-context.light.js +5 -5
- package/build/ft-search-context.min.js +15 -15
- package/build/store/FtSearchStateManager.d.ts +4 -1
- package/build/store/FtSearchStateManager.js +9 -1
- package/build/store/redux.js +3 -1
- package/build/store/utils/FtSearchService.d.ts +1 -1
- package/build/store/utils/FtSearchService.js +6 -7
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FtSearchPageState } from "./model";
|
|
2
2
|
import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtSearchPageStateReducers } from "./redux";
|
|
4
|
-
import { FtPublicClusterSortCriterion, FtSearchFilter, FtSearchRequest, FtSearchScope, FtSearchSortCriterion } from "@fluid-topics/public-api";
|
|
4
|
+
import { FtPublicClusterSortCriterion, FtSearchFilter, FtSearchRequest, FtSearchScope, FtSearchSortCriterion, FtVirtualField } from "@fluid-topics/public-api";
|
|
5
5
|
import { FtSearchService } from "./utils/FtSearchService";
|
|
6
6
|
import { FtPeriodFilter } from "@fluid-topics/public-api/dist/mjs/types/ft-common/public";
|
|
7
7
|
export declare const searchInDocumentTitlesOnlySelector: (s: FtSearchPageState) => boolean;
|
|
@@ -26,6 +26,7 @@ export declare class FtSearchStateManager {
|
|
|
26
26
|
setFilters(filters: FtSearchFilter[]): void;
|
|
27
27
|
setClusterSortCriterion(criterions: FtPublicClusterSortCriterion[]): void;
|
|
28
28
|
setSearchInDocumentTitlesOnly(searchInDocumentTitleOnly: boolean): void;
|
|
29
|
+
setVirtualField(virtualField: FtVirtualField): void;
|
|
29
30
|
get searchInDocumentTitlesOnly(): boolean;
|
|
30
31
|
get periodFilter(): FtPeriodFilter | undefined;
|
|
31
32
|
clearAllFilters(): void;
|
|
@@ -40,6 +41,8 @@ export declare class FtSearchStateManager {
|
|
|
40
41
|
setIgnoreEmptyQuery(ignoreEmptyQuery: boolean): void;
|
|
41
42
|
setOpenExternalDocumentInNewTab(openExternalDocumentInNewTab: boolean): void;
|
|
42
43
|
setPeriodFilter(periodFilter?: FtPeriodFilter): void;
|
|
44
|
+
private localesDebouncer;
|
|
45
|
+
updateLocales(): Promise<boolean>;
|
|
43
46
|
private searchDebouncer;
|
|
44
47
|
launchSearch(): Promise<boolean>;
|
|
45
48
|
private suggestDebouncer;
|
|
@@ -19,12 +19,13 @@ export class FtSearchStateManager {
|
|
|
19
19
|
this.store = store;
|
|
20
20
|
this.ignoreEmptyQuery = false;
|
|
21
21
|
this.openExternalDocumentInNewTab = false;
|
|
22
|
+
this.localesDebouncer = new Debouncer(10);
|
|
22
23
|
this.searchDebouncer = new Debouncer(100);
|
|
23
24
|
this.suggestDebouncer = new Debouncer(300);
|
|
24
25
|
this.service = service !== null && service !== void 0 ? service : new FtSearchService();
|
|
25
26
|
}
|
|
26
27
|
async initService() {
|
|
27
|
-
this.
|
|
28
|
+
this.updateLocales();
|
|
28
29
|
return this.launchSearch();
|
|
29
30
|
}
|
|
30
31
|
setQuery(query) {
|
|
@@ -89,6 +90,10 @@ export class FtSearchStateManager {
|
|
|
89
90
|
}
|
|
90
91
|
this.launchSearch();
|
|
91
92
|
}
|
|
93
|
+
setVirtualField(virtualField) {
|
|
94
|
+
this.store.actions.setRequestVirtualField(virtualField);
|
|
95
|
+
this.launchSearch();
|
|
96
|
+
}
|
|
92
97
|
get searchInDocumentTitlesOnly() {
|
|
93
98
|
return searchInDocumentTitlesOnlySelector(this.store.getState());
|
|
94
99
|
}
|
|
@@ -152,6 +157,9 @@ export class FtSearchStateManager {
|
|
|
152
157
|
this.store.actions.setPageNumber(1);
|
|
153
158
|
this.launchSearch();
|
|
154
159
|
}
|
|
160
|
+
updateLocales() {
|
|
161
|
+
return this.localesDebouncer.run(async () => this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales));
|
|
162
|
+
}
|
|
155
163
|
launchSearch() {
|
|
156
164
|
return this.searchDebouncer.run(() => this.fetchSearchData());
|
|
157
165
|
}
|
package/build/store/redux.js
CHANGED
|
@@ -31,7 +31,8 @@ const searchPageStateReducers = {
|
|
|
31
31
|
state.request.scope = action.payload;
|
|
32
32
|
},
|
|
33
33
|
setRequestClusterSortCriterion: (state, action) => {
|
|
34
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
state.request.clusterSortCriterions = (_a = action.payload) !== null && _a !== void 0 ? _a : [];
|
|
35
36
|
},
|
|
36
37
|
setResults: (state, action) => {
|
|
37
38
|
state.results = action.payload;
|
|
@@ -63,6 +64,7 @@ export const createSearchPageStore = (id) => FtReduxStore.get({
|
|
|
63
64
|
initialState: {
|
|
64
65
|
request: {
|
|
65
66
|
query: "",
|
|
67
|
+
clusterSortCriterions: [],
|
|
66
68
|
filters: [],
|
|
67
69
|
facets: [],
|
|
68
70
|
sort: [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { 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
|
-
constructor();
|
|
5
4
|
launchSearch(request: FtSearchRequest): Promise<FtSearchResults>;
|
|
6
5
|
launchSuggest(request: FtSuggestRequest): Promise<FtSuggestResults>;
|
|
7
6
|
getAvailableSearchLocales(): Promise<FtSearchLocales>;
|
|
7
|
+
hash(object: any): string;
|
|
8
8
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
2
|
export class FtSearchService extends FtServiceWithCache {
|
|
3
|
-
constructor() {
|
|
4
|
-
super();
|
|
5
|
-
this.cache.registerFinal("available-locales", () => this.api.getAvailableSearchLocales());
|
|
6
|
-
}
|
|
7
3
|
async launchSearch(request) {
|
|
8
|
-
return this.
|
|
4
|
+
return this.cache.get(this.hash(request), async () => (await this.awaitApi).search(request), 2 * 60 * 1000);
|
|
9
5
|
}
|
|
10
6
|
async launchSuggest(request) {
|
|
11
|
-
return this.
|
|
7
|
+
return this.cache.get(this.hash(request), async () => (await this.awaitApi).getSuggestions(request), 2 * 60 * 1000);
|
|
12
8
|
}
|
|
13
9
|
async getAvailableSearchLocales() {
|
|
14
|
-
return this.cache.get("available-locales");
|
|
10
|
+
return this.cache.get("available-locales", async () => (await this.awaitApi).getAvailableSearchLocales());
|
|
11
|
+
}
|
|
12
|
+
hash(object) {
|
|
13
|
+
return "" + Array.from(JSON.stringify(object)).reduce((hash, char) => 0 | (31 * hash + char.charCodeAt(0)), 0);
|
|
15
14
|
}
|
|
16
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-context",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.83",
|
|
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.1.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.1.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.1.83",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.1.83",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@fluid-topics/public-api": "1.0.71"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "2ca7449aa6df93b0b6ba0794e695aa3f605f38bf"
|
|
30
30
|
}
|