@esri/hub-common 9.41.0 → 9.41.1
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/dist/es2017/search/filter-utils.js +59 -26
- package/dist/es2017/search/filter-utils.js.map +1 -1
- package/dist/esm/search/filter-utils.js +60 -27
- package/dist/esm/search/filter-utils.js.map +1 -1
- package/dist/node/search/filter-utils.js +59 -26
- package/dist/node/search/filter-utils.js.map +1 -1
- package/dist/types/search/types/types.d.ts +1 -0
- package/dist/umd/common.umd.js +71 -38
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.
|
|
2
|
+
* @esri/hub-common - v9.41.0 - Mon Jun 13 2022 14:36:13 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -13535,7 +13535,7 @@
|
|
|
13535
13535
|
* @param join
|
|
13536
13536
|
* @returns
|
|
13537
13537
|
*/
|
|
13538
|
-
function mergeSearchOptions(so1, so2, join) {
|
|
13538
|
+
function mergeSearchOptions$1(so1, so2, join) {
|
|
13539
13539
|
// TODO: Remove with _searchContent
|
|
13540
13540
|
Logger.warn("DEPRECATION: mergeSearchOptions will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
|
|
13541
13541
|
var result = cloneObject$1(so1);
|
|
@@ -14131,12 +14131,12 @@
|
|
|
14131
14131
|
// from hitting the else
|
|
14132
14132
|
/* istanbul ignore else */
|
|
14133
14133
|
if (typeof entry === "object") {
|
|
14134
|
-
acc = mergeSearchOptions(acc, convertContentFilterToSearchOptions(entry), "OR");
|
|
14134
|
+
acc = mergeSearchOptions$1(acc, convertContentFilterToSearchOptions(entry), "OR");
|
|
14135
14135
|
}
|
|
14136
14136
|
return acc;
|
|
14137
14137
|
}, { q: "", filter: "" });
|
|
14138
14138
|
// merge with searchOptions using AND
|
|
14139
|
-
searchOptions = mergeSearchOptions(searchOptions, subFilterOptions, "AND");
|
|
14139
|
+
searchOptions = mergeSearchOptions$1(searchOptions, subFilterOptions, "AND");
|
|
14140
14140
|
}
|
|
14141
14141
|
// term is always last, and pre-pended on searchOptions.q
|
|
14142
14142
|
if (filter.term) {
|
|
@@ -14164,11 +14164,11 @@
|
|
|
14164
14164
|
var key = _a[0], value = _a[1];
|
|
14165
14165
|
// MatchOptions may go into either q or filter
|
|
14166
14166
|
if (!specialProps.includes(key)) {
|
|
14167
|
-
result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
|
|
14167
|
+
result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
|
|
14168
14168
|
}
|
|
14169
14169
|
// Dates only go into q
|
|
14170
14170
|
if (dateProps.includes(key)) {
|
|
14171
|
-
result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
|
|
14171
|
+
result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
|
|
14172
14172
|
}
|
|
14173
14173
|
});
|
|
14174
14174
|
return result;
|
|
@@ -14299,11 +14299,11 @@
|
|
|
14299
14299
|
var key = _a[0], value = _a[1];
|
|
14300
14300
|
// MatchOptions fields
|
|
14301
14301
|
if (!specialProps.includes(key)) {
|
|
14302
|
-
result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
|
|
14302
|
+
result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
|
|
14303
14303
|
}
|
|
14304
14304
|
// Dates only go into q
|
|
14305
14305
|
if (dateProps.includes(key)) {
|
|
14306
|
-
result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
|
|
14306
|
+
result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
|
|
14307
14307
|
}
|
|
14308
14308
|
});
|
|
14309
14309
|
// searchUserAccess is also a top-level property
|
|
@@ -14439,11 +14439,11 @@
|
|
|
14439
14439
|
var key = _a[0], value = _a[1];
|
|
14440
14440
|
// MatchOptions fields
|
|
14441
14441
|
if (!specialProps.includes(key)) {
|
|
14442
|
-
result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
|
|
14442
|
+
result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
|
|
14443
14443
|
}
|
|
14444
14444
|
// Dates only go into q
|
|
14445
14445
|
if (dateProps.includes(key)) {
|
|
14446
|
-
result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
|
|
14446
|
+
result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
|
|
14447
14447
|
}
|
|
14448
14448
|
});
|
|
14449
14449
|
// disabled is also a top-level property
|
|
@@ -14971,7 +14971,13 @@
|
|
|
14971
14971
|
function expandFilter(filter) {
|
|
14972
14972
|
var result = {};
|
|
14973
14973
|
var dateProps = ["created", "modified", "lastlogin"];
|
|
14974
|
-
var copyProps = [
|
|
14974
|
+
var copyProps = [
|
|
14975
|
+
"filterType",
|
|
14976
|
+
"term",
|
|
14977
|
+
"searchUserAccess",
|
|
14978
|
+
"isopendata",
|
|
14979
|
+
"searchUserName",
|
|
14980
|
+
];
|
|
14975
14981
|
var nonMatchOptionsFields = __spreadArrays(dateProps, copyProps);
|
|
14976
14982
|
// Do the conversion
|
|
14977
14983
|
Object.entries(filter).forEach(function (_a) {
|
|
@@ -15004,27 +15010,26 @@
|
|
|
15004
15010
|
* @returns
|
|
15005
15011
|
*/
|
|
15006
15012
|
function serializeFilterGroupsForPortal(filterGroups) {
|
|
15007
|
-
var
|
|
15008
|
-
|
|
15009
|
-
filter: "",
|
|
15010
|
-
};
|
|
15011
|
-
result.q = filterGroups.map(serializeGroup).join(" AND ");
|
|
15013
|
+
var groupSearchOptions = filterGroups.map(serializeGroup);
|
|
15014
|
+
var result = mergeSearchOptions(groupSearchOptions, "AND");
|
|
15012
15015
|
return result;
|
|
15013
15016
|
}
|
|
15014
15017
|
/**
|
|
15015
15018
|
* Serialize the filters in a FitlerGroup into a Portal Query
|
|
15016
|
-
* @param
|
|
15019
|
+
* @param filterGroup
|
|
15017
15020
|
* @returns
|
|
15018
15021
|
*/
|
|
15019
|
-
function serializeGroup(
|
|
15020
|
-
var operation =
|
|
15021
|
-
var filters =
|
|
15022
|
-
var
|
|
15023
|
-
//
|
|
15022
|
+
function serializeGroup(filterGroup) {
|
|
15023
|
+
var operation = filterGroup.operation || "AND";
|
|
15024
|
+
var filters = filterGroup.filters.map(expandFilter);
|
|
15025
|
+
var filterSearchOptions = filters.map(serializeFilter);
|
|
15026
|
+
// combine these searchOptions
|
|
15027
|
+
var groupSearchOptions = mergeSearchOptions(filterSearchOptions, operation);
|
|
15028
|
+
//
|
|
15024
15029
|
if (filters.length > 1) {
|
|
15025
|
-
q = "(" + q + ")";
|
|
15030
|
+
groupSearchOptions.q = "(" + groupSearchOptions.q + ")";
|
|
15026
15031
|
}
|
|
15027
|
-
return
|
|
15032
|
+
return groupSearchOptions;
|
|
15028
15033
|
}
|
|
15029
15034
|
/**
|
|
15030
15035
|
* Serialize a Filter into a Portal Query
|
|
@@ -15034,36 +15039,64 @@
|
|
|
15034
15039
|
function serializeFilter(filter) {
|
|
15035
15040
|
var dateProps = ["created", "modified"];
|
|
15036
15041
|
var boolProps = ["isopendata"];
|
|
15042
|
+
var passThroughProps = ["searchUserAccess", "searchUserName"];
|
|
15037
15043
|
var specialProps = __spreadArrays([
|
|
15038
15044
|
"filterType",
|
|
15039
|
-
"searchUserAccess",
|
|
15040
15045
|
"term"
|
|
15041
|
-
], dateProps, boolProps);
|
|
15046
|
+
], dateProps, boolProps, passThroughProps);
|
|
15047
|
+
var qCount = 0;
|
|
15042
15048
|
// TODO: Look at using reduce vs .map and remove the `.filter`
|
|
15043
|
-
var
|
|
15049
|
+
var opts = Object.entries(filter)
|
|
15044
15050
|
.map(function (_a) {
|
|
15045
15051
|
var key = _a[0], value = _a[1];
|
|
15052
|
+
var so = { q: "" };
|
|
15046
15053
|
if (!specialProps.includes(key)) {
|
|
15047
|
-
|
|
15054
|
+
qCount++;
|
|
15055
|
+
so.q = serializeMatchOptions(key, value);
|
|
15048
15056
|
}
|
|
15049
15057
|
if (dateProps.includes(key)) {
|
|
15050
|
-
|
|
15058
|
+
qCount++;
|
|
15059
|
+
so.q = serializeDateRange(key, value);
|
|
15051
15060
|
}
|
|
15052
15061
|
if (boolProps.includes(key)) {
|
|
15053
|
-
|
|
15062
|
+
qCount++;
|
|
15063
|
+
so.q = key + ":" + value;
|
|
15064
|
+
}
|
|
15065
|
+
if (passThroughProps.includes(key)) {
|
|
15066
|
+
so[key] = value;
|
|
15054
15067
|
}
|
|
15055
15068
|
if (key === "term") {
|
|
15056
|
-
|
|
15069
|
+
qCount++;
|
|
15070
|
+
so.q = value;
|
|
15057
15071
|
}
|
|
15072
|
+
return so;
|
|
15058
15073
|
})
|
|
15059
15074
|
.filter(function (e) { return e !== undefined; });
|
|
15060
|
-
//
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
else {
|
|
15065
|
-
return stringFilters[0];
|
|
15075
|
+
// merge up all the searchOptions
|
|
15076
|
+
var searchOptions = mergeSearchOptions(opts, "AND");
|
|
15077
|
+
if (qCount > 1) {
|
|
15078
|
+
searchOptions.q = "(" + searchOptions.q + ")";
|
|
15066
15079
|
}
|
|
15080
|
+
return searchOptions;
|
|
15081
|
+
}
|
|
15082
|
+
function mergeSearchOptions(options, operation) {
|
|
15083
|
+
var result = options.reduce(function (acc, entry) {
|
|
15084
|
+
// walk the props
|
|
15085
|
+
Object.entries(entry).forEach(function (_a) {
|
|
15086
|
+
var key = _a[0], value = _a[1];
|
|
15087
|
+
// if prop exists
|
|
15088
|
+
if (acc[key]) {
|
|
15089
|
+
// combine via operation
|
|
15090
|
+
acc[key] = acc[key] + " " + operation + " " + value;
|
|
15091
|
+
}
|
|
15092
|
+
else {
|
|
15093
|
+
// just copy the value
|
|
15094
|
+
acc[key] = value;
|
|
15095
|
+
}
|
|
15096
|
+
});
|
|
15097
|
+
return acc;
|
|
15098
|
+
}, { q: "" });
|
|
15099
|
+
return result;
|
|
15067
15100
|
}
|
|
15068
15101
|
/**
|
|
15069
15102
|
* Serialize MatchOptions into portal syntax
|
|
@@ -20205,7 +20238,7 @@
|
|
|
20205
20238
|
exports.mergeGroupFilters = mergeGroupFilters;
|
|
20206
20239
|
exports.mergeMatchOptions = mergeMatchOptions;
|
|
20207
20240
|
exports.mergeObjects = mergeObjects;
|
|
20208
|
-
exports.mergeSearchOptions = mergeSearchOptions;
|
|
20241
|
+
exports.mergeSearchOptions = mergeSearchOptions$1;
|
|
20209
20242
|
exports.mergeUserFilters = mergeUserFilters;
|
|
20210
20243
|
exports.normalizeItemType = normalizeItemType;
|
|
20211
20244
|
exports.normalizeSolutionTemplateItem = normalizeSolutionTemplateItem;
|