@esri/hub-common 9.45.3 → 9.45.4
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/_internal/ipredicate-utils.js +38 -0
- package/dist/es2017/search/_internal/ipredicate-utils.js.map +1 -0
- package/dist/es2017/search/_internal/portalSearchGroups.js +2 -1
- package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchItems.js +2 -1
- package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchUsers.js +2 -1
- package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/es2017/search/{_internal/ifilter-utils.js → ifilter-utils.js} +1 -37
- package/dist/es2017/search/ifilter-utils.js.map +1 -0
- package/dist/es2017/search/index.js +1 -0
- package/dist/es2017/search/index.js.map +1 -1
- package/dist/esm/search/_internal/ipredicate-utils.js +40 -0
- package/dist/esm/search/_internal/ipredicate-utils.js.map +1 -0
- package/dist/esm/search/_internal/portalSearchGroups.js +2 -1
- package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchItems.js +2 -1
- package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchUsers.js +2 -1
- package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/esm/search/{_internal/ifilter-utils.js → ifilter-utils.js} +1 -38
- package/dist/esm/search/ifilter-utils.js.map +1 -0
- package/dist/esm/search/index.js +1 -0
- package/dist/esm/search/index.js.map +1 -1
- package/dist/node/search/_internal/ipredicate-utils.js +42 -0
- package/dist/node/search/_internal/ipredicate-utils.js.map +1 -0
- package/dist/node/search/_internal/portalSearchGroups.js +3 -2
- package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/node/search/_internal/portalSearchItems.js +3 -2
- package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/node/search/_internal/portalSearchUsers.js +3 -2
- package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/node/search/{_internal/ifilter-utils.js → ifilter-utils.js} +3 -40
- package/dist/node/search/ifilter-utils.js.map +1 -0
- package/dist/node/search/index.js +1 -0
- package/dist/node/search/index.js.map +1 -1
- package/dist/types/search/_internal/ipredicate-utils.d.ts +2 -0
- package/dist/types/search/{_internal/ifilter-utils.d.ts → ifilter-utils.d.ts} +1 -2
- package/dist/types/search/index.d.ts +1 -0
- package/dist/umd/common.umd.js +137 -135
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/es2017/search/_internal/ifilter-utils.js.map +0 -1
- package/dist/esm/search/_internal/ifilter-utils.js.map +0 -1
- package/dist/node/search/_internal/ifilter-utils.js.map +0 -1
|
@@ -1,44 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeQueryForPortal =
|
|
4
|
-
const
|
|
5
|
-
const util_1 = require("../../util");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
function expandPredicate(predicate) {
|
|
8
|
-
const result = {};
|
|
9
|
-
const dateProps = ["created", "modified", "lastlogin"];
|
|
10
|
-
const copyProps = [
|
|
11
|
-
"filterType",
|
|
12
|
-
"term",
|
|
13
|
-
"searchUserAccess",
|
|
14
|
-
"isopendata",
|
|
15
|
-
"searchUserName",
|
|
16
|
-
];
|
|
17
|
-
const nonMatchOptionsFields = [...dateProps, ...copyProps];
|
|
18
|
-
// Do the conversion
|
|
19
|
-
Object.entries(predicate).forEach(([key, value]) => {
|
|
20
|
-
// Handle MatchOptions fields
|
|
21
|
-
if (!nonMatchOptionsFields.includes(key)) {
|
|
22
|
-
objects_1.setProp(key, utils_1.valueToMatchOptions(value), result);
|
|
23
|
-
}
|
|
24
|
-
// Handle Date fields
|
|
25
|
-
if (dateProps.includes(key)) {
|
|
26
|
-
const dateFieldValue = util_1.cloneObject(objects_1.getProp(predicate, key));
|
|
27
|
-
if (objects_1.getProp(predicate, `${key}.type`) === "relative-date") {
|
|
28
|
-
objects_1.setProp(key, utils_1.relativeDateToDateRange(dateFieldValue), result);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
objects_1.setProp(key, dateFieldValue, result);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Handle fields that are just copied forward
|
|
35
|
-
if (copyProps.includes(key) && predicate.hasOwnProperty(key)) {
|
|
36
|
-
objects_1.setProp(key, value, result);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
exports.expandPredicate = expandPredicate;
|
|
3
|
+
exports.serializeQueryForPortal = void 0;
|
|
4
|
+
const ipredicate_utils_1 = require("./_internal/ipredicate-utils");
|
|
42
5
|
function serializeQueryForPortal(query) {
|
|
43
6
|
const filterSearchOptions = query.filters.map(serializeFilter);
|
|
44
7
|
const result = mergeSearchOptions(filterSearchOptions, "AND");
|
|
@@ -70,7 +33,7 @@ function mergeSearchOptions(options, operation) {
|
|
|
70
33
|
*/
|
|
71
34
|
function serializeFilter(filter) {
|
|
72
35
|
const operation = filter.operation || "AND";
|
|
73
|
-
const predicates = filter.predicates.map(expandPredicate);
|
|
36
|
+
const predicates = filter.predicates.map(ipredicate_utils_1.expandPredicate);
|
|
74
37
|
const predicateSearchOptions = predicates.map(serializePredicate);
|
|
75
38
|
// combine these searchOptions
|
|
76
39
|
const searchOptions = mergeSearchOptions(predicateSearchOptions, operation);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifilter-utils.js","sourceRoot":"","sources":["../../../src/search/ifilter-utils.ts"],"names":[],"mappings":";;;AAQA,mEAA+D;AAE/D,SAAgB,uBAAuB,CAAC,KAAa;IACnD,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAE/D,MAAM,MAAM,G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AM;YACJ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChC,GAAG,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;KACtD;IACD,IAAI,KAAK,CAAC,GAAG,EAAE;QACb,qCAAqC;QACrC,MAAM;YACJ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChC,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;KAC3D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,GAAW,EAAE,KAAyB;IAChE,OAAO,GAAG,GAAG,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,GAAG,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAC7B,IAAkB,EAClB,GAAW,EACX,KAAwB;IAExB,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,CAAC,GAAG,GAAG,GAAG,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;QACnD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;SACd;KACF;SAAM;QACL,CAAC,GAAG,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;KACzB;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -13,5 +13,6 @@ tslib_1.__exportStar(require("./types"), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require("./collectionState"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./convertCatalog"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./filter-utils"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./ifilter-utils"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./hubSearch"), exports);
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,0DAAgC;AAChC,wDAA8B;AAC9B,uDAA6B;AAC7B,kDAAwB;AACxB,2DAAiC;AACjC,0DAAgC;AAChC,yDAA+B;AAC/B,kDAAwB;AACxB,4DAAkC;AAClC,2DAAiC;AACjC,yDAA+B;AAC/B,sDAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,0DAAgC;AAChC,wDAA8B;AAC9B,uDAA6B;AAC7B,kDAAwB;AACxB,2DAAiC;AACjC,0DAAgC;AAChC,yDAA+B;AAC/B,kDAAwB;AACxB,4DAAkC;AAClC,2DAAiC;AACjC,yDAA+B;AAC/B,0DAAgC;AAChC,sDAA4B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ISearchOptions } from "@esri/arcgis-rest-portal";
|
|
2
|
-
import {
|
|
3
|
-
export declare function expandPredicate(predicate: IPredicate): IPredicate;
|
|
2
|
+
import { IQuery } from "./types";
|
|
4
3
|
export declare function serializeQueryForPortal(query: IQuery): ISearchOptions;
|
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.45.
|
|
2
|
+
* @esri/hub-common - v9.45.3 - Fri Jul 01 2022 14:51:47 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -15006,140 +15006,6 @@
|
|
|
15006
15006
|
}
|
|
15007
15007
|
}
|
|
15008
15008
|
|
|
15009
|
-
/**
|
|
15010
|
-
* Generic Hub Error with an Error stack as well
|
|
15011
|
-
* as an optional serialized OperationStack.
|
|
15012
|
-
*
|
|
15013
|
-
* Also accepts a `rootCause` Error object
|
|
15014
|
-
*/
|
|
15015
|
-
var HubError = /** @class */ (function (_super) {
|
|
15016
|
-
__extends(HubError, _super);
|
|
15017
|
-
/**
|
|
15018
|
-
* Creates an instance of HubError.
|
|
15019
|
-
* @param {string} operation
|
|
15020
|
-
* @param {string} [message]
|
|
15021
|
-
* @param {Error} [rootCause]
|
|
15022
|
-
* @memberof HubError
|
|
15023
|
-
*/
|
|
15024
|
-
function HubError(operation, message, rootCause) {
|
|
15025
|
-
var _this = this;
|
|
15026
|
-
message = message || "UNKNOWN_ERROR";
|
|
15027
|
-
// if the rootCause has a .rootCause, use that so we don't deeply nest
|
|
15028
|
-
rootCause = getWithDefault$1(rootCause, "rootCause", rootCause);
|
|
15029
|
-
/* Skip coverage on super(...) as per:
|
|
15030
|
-
https://github.com/Microsoft/TypeScript/issues/13029
|
|
15031
|
-
https://github.com/SitePen/remap-istanbul/issues/106
|
|
15032
|
-
*/
|
|
15033
|
-
/* istanbul ignore next */
|
|
15034
|
-
_this = _super.call(this, operation, message, rootCause) || this;
|
|
15035
|
-
_this.name = "HubError";
|
|
15036
|
-
// if the original error has a stack use it, otherwise create a new
|
|
15037
|
-
// stack. Note: a new Stack will make it look like the error origninated
|
|
15038
|
-
// in the HubError constructor. This is only an issue in tests but
|
|
15039
|
-
// it can be confusing to debug
|
|
15040
|
-
_this.stack = getWithDefault$1(rootCause, "stack", new Error().stack);
|
|
15041
|
-
return _this;
|
|
15042
|
-
}
|
|
15043
|
-
return HubError;
|
|
15044
|
-
}(OperationError$1));
|
|
15045
|
-
var HubError$1 = HubError;
|
|
15046
|
-
|
|
15047
|
-
/**
|
|
15048
|
-
* Generic search that returns Hub Entity types converted from items
|
|
15049
|
-
* by the passed in `ItemToEntityFunction`
|
|
15050
|
-
*
|
|
15051
|
-
* This abstraction is used to ensure that searching from any of the
|
|
15052
|
-
* entity managers / modules is consistent, and returns the entity
|
|
15053
|
-
* types, instead of `IItem` or `IHubContent`
|
|
15054
|
-
*
|
|
15055
|
-
* @param filter
|
|
15056
|
-
* @param convertFn
|
|
15057
|
-
* @param options
|
|
15058
|
-
* @returns
|
|
15059
|
-
*/
|
|
15060
|
-
function searchContentEntities(filter, convertFn, options) {
|
|
15061
|
-
var _a, _b;
|
|
15062
|
-
// expand filter so we can serialize to either api
|
|
15063
|
-
var expanded = expandContentFilter(filter);
|
|
15064
|
-
var searchOptions = serializeContentFilterForPortal(expanded);
|
|
15065
|
-
// DEPRECATION
|
|
15066
|
-
/* istanbul ignore next */
|
|
15067
|
-
if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
15068
|
-
// tslint:disable-next-line:no-console
|
|
15069
|
-
console.warn("IHubSearchOptions.aggregations is deprecated. Please use .aggFields instead.");
|
|
15070
|
-
searchOptions.countFields = options.aggregations.join(",");
|
|
15071
|
-
searchOptions.countSize = options.aggLimit || 10;
|
|
15072
|
-
}
|
|
15073
|
-
// Aggregations
|
|
15074
|
-
if ((_b = options.aggFields) === null || _b === void 0 ? void 0 : _b.length) {
|
|
15075
|
-
searchOptions.countFields = options.aggFields.join(",");
|
|
15076
|
-
searchOptions.countSize = options.aggLimit || 10;
|
|
15077
|
-
}
|
|
15078
|
-
// properties to copy from IHubSearchOptions to the ISearchOptions
|
|
15079
|
-
var props = [
|
|
15080
|
-
"authentication",
|
|
15081
|
-
"num",
|
|
15082
|
-
"sortField",
|
|
15083
|
-
"sortOrder",
|
|
15084
|
-
"site",
|
|
15085
|
-
"start",
|
|
15086
|
-
];
|
|
15087
|
-
// Include "start" here
|
|
15088
|
-
// copy the props over
|
|
15089
|
-
props.forEach(function (prop) {
|
|
15090
|
-
if (options.hasOwnProperty(prop)) {
|
|
15091
|
-
searchOptions[prop] = options[prop];
|
|
15092
|
-
}
|
|
15093
|
-
});
|
|
15094
|
-
// create the entitySearchFn
|
|
15095
|
-
var searchFn = createContentEntitySearchFn(convertFn);
|
|
15096
|
-
// execute the search
|
|
15097
|
-
// Add ArcGIS API
|
|
15098
|
-
if (options.api && !options.authentication) {
|
|
15099
|
-
var expandedApi = expandApi(options.api);
|
|
15100
|
-
searchOptions.portal = expandedApi.url;
|
|
15101
|
-
}
|
|
15102
|
-
return searchFn(searchOptions);
|
|
15103
|
-
}
|
|
15104
|
-
/**
|
|
15105
|
-
* Return a function that holds a closure containing
|
|
15106
|
-
* a hub entity specific conversion function. This
|
|
15107
|
-
* allows the `.next()` function to use the function on
|
|
15108
|
-
* subsequent calls
|
|
15109
|
-
* @param convertFn
|
|
15110
|
-
* @returns
|
|
15111
|
-
*/
|
|
15112
|
-
function createContentEntitySearchFn(convertFn) {
|
|
15113
|
-
// Return a function that does the search, with a closure over the
|
|
15114
|
-
// conversion function. Naming this function is important as it's
|
|
15115
|
-
// referenced in the `next` section below
|
|
15116
|
-
return function searchEntities(searchOptions) {
|
|
15117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15118
|
-
var response, entities, facets;
|
|
15119
|
-
return __generator(this, function (_a) {
|
|
15120
|
-
switch (_a.label) {
|
|
15121
|
-
case 0: return [4 /*yield*/, searchItems(searchOptions)];
|
|
15122
|
-
case 1:
|
|
15123
|
-
response = _a.sent();
|
|
15124
|
-
return [4 /*yield*/, Promise.all(response.results.map(function (itm) {
|
|
15125
|
-
return convertFn(itm, searchOptions);
|
|
15126
|
-
}))];
|
|
15127
|
-
case 2:
|
|
15128
|
-
entities = _a.sent();
|
|
15129
|
-
facets = convertPortalResponseToFacets(response);
|
|
15130
|
-
return [2 /*return*/, {
|
|
15131
|
-
total: response.total,
|
|
15132
|
-
results: entities,
|
|
15133
|
-
facets: facets,
|
|
15134
|
-
hasNext: response.nextStart > -1,
|
|
15135
|
-
next: getNextFunction(searchOptions, response.nextStart, response.total, searchEntities),
|
|
15136
|
-
}];
|
|
15137
|
-
}
|
|
15138
|
-
});
|
|
15139
|
-
});
|
|
15140
|
-
};
|
|
15141
|
-
}
|
|
15142
|
-
|
|
15143
15009
|
function expandPredicate(predicate) {
|
|
15144
15010
|
var result = {};
|
|
15145
15011
|
var dateProps = ["created", "modified", "lastlogin"];
|
|
@@ -15175,6 +15041,7 @@
|
|
|
15175
15041
|
});
|
|
15176
15042
|
return result;
|
|
15177
15043
|
}
|
|
15044
|
+
|
|
15178
15045
|
function serializeQueryForPortal(query) {
|
|
15179
15046
|
var filterSearchOptions = query.filters.map(serializeFilter);
|
|
15180
15047
|
var result = mergeSearchOptions(filterSearchOptions, "AND");
|
|
@@ -15358,6 +15225,140 @@
|
|
|
15358
15225
|
return q;
|
|
15359
15226
|
}
|
|
15360
15227
|
|
|
15228
|
+
/**
|
|
15229
|
+
* Generic Hub Error with an Error stack as well
|
|
15230
|
+
* as an optional serialized OperationStack.
|
|
15231
|
+
*
|
|
15232
|
+
* Also accepts a `rootCause` Error object
|
|
15233
|
+
*/
|
|
15234
|
+
var HubError = /** @class */ (function (_super) {
|
|
15235
|
+
__extends(HubError, _super);
|
|
15236
|
+
/**
|
|
15237
|
+
* Creates an instance of HubError.
|
|
15238
|
+
* @param {string} operation
|
|
15239
|
+
* @param {string} [message]
|
|
15240
|
+
* @param {Error} [rootCause]
|
|
15241
|
+
* @memberof HubError
|
|
15242
|
+
*/
|
|
15243
|
+
function HubError(operation, message, rootCause) {
|
|
15244
|
+
var _this = this;
|
|
15245
|
+
message = message || "UNKNOWN_ERROR";
|
|
15246
|
+
// if the rootCause has a .rootCause, use that so we don't deeply nest
|
|
15247
|
+
rootCause = getWithDefault$1(rootCause, "rootCause", rootCause);
|
|
15248
|
+
/* Skip coverage on super(...) as per:
|
|
15249
|
+
https://github.com/Microsoft/TypeScript/issues/13029
|
|
15250
|
+
https://github.com/SitePen/remap-istanbul/issues/106
|
|
15251
|
+
*/
|
|
15252
|
+
/* istanbul ignore next */
|
|
15253
|
+
_this = _super.call(this, operation, message, rootCause) || this;
|
|
15254
|
+
_this.name = "HubError";
|
|
15255
|
+
// if the original error has a stack use it, otherwise create a new
|
|
15256
|
+
// stack. Note: a new Stack will make it look like the error origninated
|
|
15257
|
+
// in the HubError constructor. This is only an issue in tests but
|
|
15258
|
+
// it can be confusing to debug
|
|
15259
|
+
_this.stack = getWithDefault$1(rootCause, "stack", new Error().stack);
|
|
15260
|
+
return _this;
|
|
15261
|
+
}
|
|
15262
|
+
return HubError;
|
|
15263
|
+
}(OperationError$1));
|
|
15264
|
+
var HubError$1 = HubError;
|
|
15265
|
+
|
|
15266
|
+
/**
|
|
15267
|
+
* Generic search that returns Hub Entity types converted from items
|
|
15268
|
+
* by the passed in `ItemToEntityFunction`
|
|
15269
|
+
*
|
|
15270
|
+
* This abstraction is used to ensure that searching from any of the
|
|
15271
|
+
* entity managers / modules is consistent, and returns the entity
|
|
15272
|
+
* types, instead of `IItem` or `IHubContent`
|
|
15273
|
+
*
|
|
15274
|
+
* @param filter
|
|
15275
|
+
* @param convertFn
|
|
15276
|
+
* @param options
|
|
15277
|
+
* @returns
|
|
15278
|
+
*/
|
|
15279
|
+
function searchContentEntities(filter, convertFn, options) {
|
|
15280
|
+
var _a, _b;
|
|
15281
|
+
// expand filter so we can serialize to either api
|
|
15282
|
+
var expanded = expandContentFilter(filter);
|
|
15283
|
+
var searchOptions = serializeContentFilterForPortal(expanded);
|
|
15284
|
+
// DEPRECATION
|
|
15285
|
+
/* istanbul ignore next */
|
|
15286
|
+
if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
15287
|
+
// tslint:disable-next-line:no-console
|
|
15288
|
+
console.warn("IHubSearchOptions.aggregations is deprecated. Please use .aggFields instead.");
|
|
15289
|
+
searchOptions.countFields = options.aggregations.join(",");
|
|
15290
|
+
searchOptions.countSize = options.aggLimit || 10;
|
|
15291
|
+
}
|
|
15292
|
+
// Aggregations
|
|
15293
|
+
if ((_b = options.aggFields) === null || _b === void 0 ? void 0 : _b.length) {
|
|
15294
|
+
searchOptions.countFields = options.aggFields.join(",");
|
|
15295
|
+
searchOptions.countSize = options.aggLimit || 10;
|
|
15296
|
+
}
|
|
15297
|
+
// properties to copy from IHubSearchOptions to the ISearchOptions
|
|
15298
|
+
var props = [
|
|
15299
|
+
"authentication",
|
|
15300
|
+
"num",
|
|
15301
|
+
"sortField",
|
|
15302
|
+
"sortOrder",
|
|
15303
|
+
"site",
|
|
15304
|
+
"start",
|
|
15305
|
+
];
|
|
15306
|
+
// Include "start" here
|
|
15307
|
+
// copy the props over
|
|
15308
|
+
props.forEach(function (prop) {
|
|
15309
|
+
if (options.hasOwnProperty(prop)) {
|
|
15310
|
+
searchOptions[prop] = options[prop];
|
|
15311
|
+
}
|
|
15312
|
+
});
|
|
15313
|
+
// create the entitySearchFn
|
|
15314
|
+
var searchFn = createContentEntitySearchFn(convertFn);
|
|
15315
|
+
// execute the search
|
|
15316
|
+
// Add ArcGIS API
|
|
15317
|
+
if (options.api && !options.authentication) {
|
|
15318
|
+
var expandedApi = expandApi(options.api);
|
|
15319
|
+
searchOptions.portal = expandedApi.url;
|
|
15320
|
+
}
|
|
15321
|
+
return searchFn(searchOptions);
|
|
15322
|
+
}
|
|
15323
|
+
/**
|
|
15324
|
+
* Return a function that holds a closure containing
|
|
15325
|
+
* a hub entity specific conversion function. This
|
|
15326
|
+
* allows the `.next()` function to use the function on
|
|
15327
|
+
* subsequent calls
|
|
15328
|
+
* @param convertFn
|
|
15329
|
+
* @returns
|
|
15330
|
+
*/
|
|
15331
|
+
function createContentEntitySearchFn(convertFn) {
|
|
15332
|
+
// Return a function that does the search, with a closure over the
|
|
15333
|
+
// conversion function. Naming this function is important as it's
|
|
15334
|
+
// referenced in the `next` section below
|
|
15335
|
+
return function searchEntities(searchOptions) {
|
|
15336
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15337
|
+
var response, entities, facets;
|
|
15338
|
+
return __generator(this, function (_a) {
|
|
15339
|
+
switch (_a.label) {
|
|
15340
|
+
case 0: return [4 /*yield*/, searchItems(searchOptions)];
|
|
15341
|
+
case 1:
|
|
15342
|
+
response = _a.sent();
|
|
15343
|
+
return [4 /*yield*/, Promise.all(response.results.map(function (itm) {
|
|
15344
|
+
return convertFn(itm, searchOptions);
|
|
15345
|
+
}))];
|
|
15346
|
+
case 2:
|
|
15347
|
+
entities = _a.sent();
|
|
15348
|
+
facets = convertPortalResponseToFacets(response);
|
|
15349
|
+
return [2 /*return*/, {
|
|
15350
|
+
total: response.total,
|
|
15351
|
+
results: entities,
|
|
15352
|
+
facets: facets,
|
|
15353
|
+
hasNext: response.nextStart > -1,
|
|
15354
|
+
next: getNextFunction(searchOptions, response.nextStart, response.total, searchEntities),
|
|
15355
|
+
}];
|
|
15356
|
+
}
|
|
15357
|
+
});
|
|
15358
|
+
});
|
|
15359
|
+
};
|
|
15360
|
+
}
|
|
15361
|
+
|
|
15361
15362
|
/**
|
|
15362
15363
|
* Fetch Page specific Enrichments
|
|
15363
15364
|
* @param item
|
|
@@ -20610,6 +20611,7 @@
|
|
|
20610
20611
|
exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
|
|
20611
20612
|
exports.serializeMatchOptions = serializeMatchOptions$1;
|
|
20612
20613
|
exports.serializeModel = serializeModel;
|
|
20614
|
+
exports.serializeQueryForPortal = serializeQueryForPortal;
|
|
20613
20615
|
exports.serializeSpatialReference = serializeSpatialReference;
|
|
20614
20616
|
exports.serializeStringOrArray = serializeStringOrArray$1;
|
|
20615
20617
|
exports.serializeUserFilterForPortal = serializeUserFilterForPortal;
|