@fluid-topics/ft-wc-utils 1.3.44 → 1.3.45
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.
|
@@ -15,7 +15,8 @@ export declare enum SearchPlaceQueryParams {
|
|
|
15
15
|
DATE_FILTERS = "date-filters",
|
|
16
16
|
RANGE_FILTERS = "range-filters",
|
|
17
17
|
SORT = "sort",
|
|
18
|
-
PER_PAGE = "per-page"
|
|
18
|
+
PER_PAGE = "per-page",
|
|
19
|
+
KEYWORD_MATCH = "keyword-match"
|
|
19
20
|
}
|
|
20
21
|
export declare function isSearchPlaceQueryParams(param: string): param is SearchPlaceQueryParams;
|
|
21
22
|
export declare class SearchPlaceConverter {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FtDateFilterType, isFtDateFilterType, isFtVirtualField } from "@fluid-topics/public-api";
|
|
1
|
+
import { FtDateFilterType, FtSearchKeywordMatch, isFtDateFilterType, isFtVirtualField } from "@fluid-topics/public-api";
|
|
2
2
|
import { minmax } from "./helpers";
|
|
3
3
|
function quote(value) {
|
|
4
4
|
return `"${value}"`;
|
|
@@ -26,6 +26,7 @@ export var SearchPlaceQueryParams;
|
|
|
26
26
|
SearchPlaceQueryParams["RANGE_FILTERS"] = "range-filters";
|
|
27
27
|
SearchPlaceQueryParams["SORT"] = "sort";
|
|
28
28
|
SearchPlaceQueryParams["PER_PAGE"] = "per-page";
|
|
29
|
+
SearchPlaceQueryParams["KEYWORD_MATCH"] = "keyword-match";
|
|
29
30
|
})(SearchPlaceQueryParams || (SearchPlaceQueryParams = {}));
|
|
30
31
|
const SearchPlaceQueryParamsValues = new Set(Object.values(SearchPlaceQueryParams));
|
|
31
32
|
export function isSearchPlaceQueryParams(param) {
|
|
@@ -107,6 +108,9 @@ export class SearchPlaceConverter {
|
|
|
107
108
|
if (((_h = request.paging) === null || _h === void 0 ? void 0 : _h.perPage) && ((_k = (_j = request.paging) === null || _j === void 0 ? void 0 : _j.perPage) !== null && _k !== void 0 ? _k : this.defaultPerPage) != this.defaultPerPage) {
|
|
108
109
|
params.append(SearchPlaceQueryParams.PER_PAGE, String(request.paging.perPage));
|
|
109
110
|
}
|
|
111
|
+
if (request.keywordMatch != undefined) {
|
|
112
|
+
params.append(SearchPlaceQueryParams.KEYWORD_MATCH, request.keywordMatch.toLowerCase());
|
|
113
|
+
}
|
|
110
114
|
const otherQueryParams = (_l = request.otherQueryParams) !== null && _l !== void 0 ? _l : {};
|
|
111
115
|
for (const key in otherQueryParams) {
|
|
112
116
|
params.append(key, otherQueryParams[key]);
|
|
@@ -146,6 +150,12 @@ export class SearchPlaceConverter {
|
|
|
146
150
|
const sortId = (_b = params.get(SearchPlaceQueryParams.SORT)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
147
151
|
const scope = (_c = params.get(SearchPlaceQueryParams.SCOPE)) !== null && _c !== void 0 ? _c : "default";
|
|
148
152
|
const perPage = +((_d = params.get(SearchPlaceQueryParams.PER_PAGE)) !== null && _d !== void 0 ? _d : this.defaultPerPage);
|
|
153
|
+
const keywordMatchParam = params.get(SearchPlaceQueryParams.KEYWORD_MATCH);
|
|
154
|
+
const keywordMatch = keywordMatchParam
|
|
155
|
+
? (keywordMatchParam.toUpperCase() === FtSearchKeywordMatch.MANDATORY
|
|
156
|
+
? FtSearchKeywordMatch.MANDATORY
|
|
157
|
+
: FtSearchKeywordMatch.OPTIONAL)
|
|
158
|
+
: undefined;
|
|
149
159
|
const otherQueryParams = {};
|
|
150
160
|
for (const key of params.keys()) {
|
|
151
161
|
if (!isSearchPlaceQueryParams(key)) {
|
|
@@ -164,6 +174,7 @@ export class SearchPlaceConverter {
|
|
|
164
174
|
page: 1,
|
|
165
175
|
perPage: minmax(1, isNaN(perPage) ? this.defaultPerPage : perPage, 1000),
|
|
166
176
|
},
|
|
177
|
+
keywordMatch: keywordMatch,
|
|
167
178
|
otherQueryParams,
|
|
168
179
|
};
|
|
169
180
|
}
|