@yuuvis/client-core 2.1.26 → 2.1.28
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.
|
@@ -1866,7 +1866,7 @@ class SearchService {
|
|
|
1866
1866
|
* @returns Observable of a SearchResult
|
|
1867
1867
|
*/
|
|
1868
1868
|
search(query) {
|
|
1869
|
-
return this.searchRaw(query).pipe(map((res) => this.toSearchResult(res)));
|
|
1869
|
+
return this.searchRaw(query).pipe(map((res) => this.toSearchResult(res, query.size || SearchService.DEFAULT_QUERY_SIZE, query.from || 0)));
|
|
1870
1870
|
}
|
|
1871
1871
|
/**
|
|
1872
1872
|
* Execute a raw search query and return the result as is.
|
|
@@ -1884,20 +1884,23 @@ class SearchService {
|
|
|
1884
1884
|
* @param size The number of items to return
|
|
1885
1885
|
* @returns Observable of a SearchResult
|
|
1886
1886
|
*/
|
|
1887
|
-
searchCmis(statement, size =
|
|
1887
|
+
searchCmis(statement, size = SearchService.DEFAULT_QUERY_SIZE) {
|
|
1888
|
+
return this.#executeCmisSearch(statement, size);
|
|
1889
|
+
}
|
|
1890
|
+
#executeCmisSearch(statement, maxItems, skipCount = 0) {
|
|
1888
1891
|
return this.#backend
|
|
1889
|
-
.post('/dms/objects/
|
|
1892
|
+
.post('/dms/objects/cmisSearch', {
|
|
1890
1893
|
query: {
|
|
1891
1894
|
statement,
|
|
1892
|
-
skipCount
|
|
1893
|
-
maxItems
|
|
1895
|
+
skipCount,
|
|
1896
|
+
maxItems,
|
|
1894
1897
|
handleDeletedDocuments: 'DELETED_DOCUMENTS_EXCLUDE'
|
|
1895
1898
|
}
|
|
1896
1899
|
}
|
|
1897
1900
|
// Using API-WEB because it enriches the response with additional information (resolved user names, etc.)
|
|
1898
1901
|
// ApiBase.core
|
|
1899
1902
|
)
|
|
1900
|
-
.pipe(map((res) => this.toSearchResult(res)));
|
|
1903
|
+
.pipe(map((res) => this.toSearchResult(res, maxItems, skipCount)));
|
|
1901
1904
|
}
|
|
1902
1905
|
/**
|
|
1903
1906
|
* Fetch aggragations for a given query.
|
|
@@ -1935,18 +1938,24 @@ class SearchService {
|
|
|
1935
1938
|
}
|
|
1936
1939
|
/**
|
|
1937
1940
|
* Go to a page of a search result.
|
|
1938
|
-
* @param
|
|
1941
|
+
* @param query SearchQuery or CMIS query statement
|
|
1939
1942
|
* @param page The number of the page to go to
|
|
1940
1943
|
*/
|
|
1941
|
-
getPage(query, page) {
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
+
getPage(query, page, pageSize = SearchService.DEFAULT_QUERY_SIZE) {
|
|
1945
|
+
const isCmis = typeof query === 'string';
|
|
1946
|
+
if (isCmis) {
|
|
1947
|
+
return this.#executeCmisSearch(query, pageSize, (page - 1) * pageSize);
|
|
1948
|
+
}
|
|
1949
|
+
else {
|
|
1950
|
+
query.from = (page - 1) * (query.size || pageSize);
|
|
1951
|
+
return this.search(query);
|
|
1952
|
+
}
|
|
1944
1953
|
}
|
|
1945
1954
|
/**
|
|
1946
1955
|
* Map search result from the backend to applications SearchResult object
|
|
1947
1956
|
* @param searchResponse The backend response
|
|
1948
1957
|
*/
|
|
1949
|
-
toSearchResult(searchResponse) {
|
|
1958
|
+
toSearchResult(searchResponse, pageSize = SearchService.DEFAULT_QUERY_SIZE, skipCount = 0) {
|
|
1950
1959
|
const resultListItems = [];
|
|
1951
1960
|
const objectTypes = [];
|
|
1952
1961
|
searchResponse.objects.forEach((o) => {
|
|
@@ -2012,11 +2021,14 @@ class SearchService {
|
|
|
2012
2021
|
permissions: o.permissions
|
|
2013
2022
|
});
|
|
2014
2023
|
});
|
|
2024
|
+
const totalPages = Math.ceil(searchResponse.totalNumItems / pageSize);
|
|
2025
|
+
const page = (!skipCount ? 0 : skipCount / pageSize) + 1;
|
|
2015
2026
|
const result = {
|
|
2016
2027
|
hasMoreItems: searchResponse.hasMoreItems,
|
|
2017
2028
|
totalNumItems: searchResponse.totalNumItems,
|
|
2018
2029
|
items: resultListItems,
|
|
2019
|
-
objectTypes
|
|
2030
|
+
objectTypes: objectTypes,
|
|
2031
|
+
paging: !!totalPages ? { page, totalPages } : undefined
|
|
2020
2032
|
};
|
|
2021
2033
|
return result;
|
|
2022
2034
|
}
|
|
@@ -2089,7 +2101,7 @@ class SearchService {
|
|
|
2089
2101
|
f: property,
|
|
2090
2102
|
o: rv.operator,
|
|
2091
2103
|
v1: this.#dateToISOString(v1, 'start'),
|
|
2092
|
-
v2: v2 ? this.#dateToISOString(v2, 'end') : ''
|
|
2104
|
+
v2: v2 ? this.#dateToISOString(v2, 'end') : ''
|
|
2093
2105
|
};
|
|
2094
2106
|
}
|
|
2095
2107
|
default:
|