@esri/hub-common 9.40.0 → 9.41.0
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/index.js +1 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchUsers.js +89 -0
- package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -0
- package/dist/es2017/search/hubSearch.js +4 -1
- package/dist/es2017/search/hubSearch.js.map +1 -1
- package/dist/es2017/urls/getUserHomeUrl.js +12 -0
- package/dist/es2017/urls/getUserHomeUrl.js.map +1 -0
- package/dist/es2017/urls/index.js +1 -0
- package/dist/es2017/urls/index.js.map +1 -1
- package/dist/es2017/users/HubUsers.js +64 -0
- package/dist/es2017/users/HubUsers.js.map +1 -0
- package/dist/es2017/users/_internal/enrichments.js +85 -0
- package/dist/es2017/users/_internal/enrichments.js.map +1 -0
- package/dist/es2017/users/index.js +2 -0
- package/dist/es2017/users/index.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchUsers.js +104 -0
- package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -0
- package/dist/esm/search/hubSearch.js +4 -1
- package/dist/esm/search/hubSearch.js.map +1 -1
- package/dist/esm/urls/getUserHomeUrl.js +12 -0
- package/dist/esm/urls/getUserHomeUrl.js.map +1 -0
- package/dist/esm/urls/index.js +1 -0
- package/dist/esm/urls/index.js.map +1 -1
- package/dist/esm/users/HubUsers.js +66 -0
- package/dist/esm/users/HubUsers.js.map +1 -0
- package/dist/esm/users/_internal/enrichments.js +86 -0
- package/dist/esm/users/_internal/enrichments.js.map +1 -0
- package/dist/esm/users/index.js +2 -0
- package/dist/esm/users/index.js.map +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/node/search/_internal/portalSearchUsers.js +93 -0
- package/dist/node/search/_internal/portalSearchUsers.js.map +1 -0
- package/dist/node/search/hubSearch.js +4 -1
- package/dist/node/search/hubSearch.js.map +1 -1
- package/dist/node/urls/getUserHomeUrl.js +16 -0
- package/dist/node/urls/getUserHomeUrl.js.map +1 -0
- package/dist/node/urls/index.js +1 -0
- package/dist/node/urls/index.js.map +1 -1
- package/dist/node/users/HubUsers.js +68 -0
- package/dist/node/users/HubUsers.js.map +1 -0
- package/dist/node/users/_internal/enrichments.js +89 -0
- package/dist/node/users/_internal/enrichments.js.map +1 -0
- package/dist/node/users/index.js +5 -0
- package/dist/node/users/index.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/search/_internal/portalSearchUsers.d.ts +8 -0
- package/dist/types/search/types/types.d.ts +17 -1
- package/dist/types/urls/getUserHomeUrl.d.ts +10 -0
- package/dist/types/urls/index.d.ts +1 -0
- package/dist/types/users/HubUsers.d.ts +11 -0
- package/dist/types/users/_internal/enrichments.d.ts +28 -0
- package/dist/types/users/index.d.ts +1 -0
- package/dist/umd/common.umd.js +274 -23
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IUser } from "@esri/arcgis-rest-types";
|
|
2
|
+
import { IHubSearchResult } from "../search";
|
|
3
|
+
import { IHubRequestOptions } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Enrich a User object
|
|
6
|
+
* @param user
|
|
7
|
+
* @param includes
|
|
8
|
+
* @param requestOptions
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function enrichUserSearchResult(user: IUser, include: string[], requestOptions: IHubRequestOptions): Promise<IHubSearchResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IUser, IPortal } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { IEnrichmentErrorInfo, IHubRequestOptions } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Possible additional properties available through enrichments
|
|
5
|
+
*/
|
|
6
|
+
export interface IUserEnrichments {
|
|
7
|
+
org?: IPortal;
|
|
8
|
+
/**
|
|
9
|
+
* Any errors encountered when fetching enrichments
|
|
10
|
+
* see https://github.com/ArcGIS/hub-indexer/blob/master/docs/errors.md#response-formatting-for-errors
|
|
11
|
+
*/
|
|
12
|
+
errors?: IEnrichmentErrorInfo[];
|
|
13
|
+
}
|
|
14
|
+
export declare type UserEnrichment = keyof IUserEnrichments;
|
|
15
|
+
/**
|
|
16
|
+
* Merging of the Enrichment and the User
|
|
17
|
+
*/
|
|
18
|
+
export interface IUserAndEnrichments extends IUserEnrichments {
|
|
19
|
+
user: IUser;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch enrichments for Users
|
|
23
|
+
* @param group
|
|
24
|
+
* @param enrichments
|
|
25
|
+
* @param requestOptions
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchUserEnrichments(user: IUser, enrichments: UserEnrichment[], requestOptions?: IHubRequestOptions): Promise<IUserAndEnrichments>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HubUsers";
|
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.
|
|
2
|
+
* @esri/hub-common - v9.40.0 - Fri Jun 10 2022 19:52:59 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -5444,6 +5444,17 @@
|
|
|
5444
5444
|
return portalUrl + "/home/group.html?id=" + groupId;
|
|
5445
5445
|
}
|
|
5446
5446
|
|
|
5447
|
+
/**
|
|
5448
|
+
* Return the URL of the user's page in the Portal Home application
|
|
5449
|
+
* @param username The username
|
|
5450
|
+
* @param portalUrlOrObject a portal base or API URL, a portal object, or request options containing either of those
|
|
5451
|
+
* @returns URL to the user's profile, defaults to `https://www.arcgis.com/home/user.html?user={username}`
|
|
5452
|
+
*/
|
|
5453
|
+
function getUserHomeUrl(username, portalUrlOrObject) {
|
|
5454
|
+
var portalUrl = getPortalUrl(portalUrlOrObject);
|
|
5455
|
+
return portalUrl + "/home/user.html?user=" + username;
|
|
5456
|
+
}
|
|
5457
|
+
|
|
5447
5458
|
var MAP_OR_FEATURE_SERVER_URL_REGEX = /\/(map|feature)server/i;
|
|
5448
5459
|
/**
|
|
5449
5460
|
*
|
|
@@ -10032,7 +10043,7 @@
|
|
|
10032
10043
|
requestOptions: requestOptions,
|
|
10033
10044
|
};
|
|
10034
10045
|
})
|
|
10035
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10046
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); });
|
|
10036
10047
|
};
|
|
10037
10048
|
var enrichMetadata = function (input) {
|
|
10038
10049
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
@@ -10064,7 +10075,7 @@
|
|
|
10064
10075
|
requestOptions: requestOptions,
|
|
10065
10076
|
};
|
|
10066
10077
|
})
|
|
10067
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10078
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); });
|
|
10068
10079
|
};
|
|
10069
10080
|
// Note, this MUST be run after `enrichOwnerUser` to access the correct orgId during
|
|
10070
10081
|
// processing. `item.orgId` is only SOMETIMES returned by Portal, so we need to have
|
|
@@ -10082,7 +10093,7 @@
|
|
|
10082
10093
|
requestOptions: requestOptions,
|
|
10083
10094
|
};
|
|
10084
10095
|
})
|
|
10085
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10096
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); });
|
|
10086
10097
|
};
|
|
10087
10098
|
var enrichData = function (input) {
|
|
10088
10099
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
@@ -10092,7 +10103,7 @@
|
|
|
10092
10103
|
stack.finish(opId);
|
|
10093
10104
|
return { data: __assign(__assign({}, data), { data: itemData }), stack: stack, requestOptions: requestOptions };
|
|
10094
10105
|
})
|
|
10095
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10106
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); });
|
|
10096
10107
|
};
|
|
10097
10108
|
var enrichServer = function (input) {
|
|
10098
10109
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
@@ -10104,7 +10115,7 @@
|
|
|
10104
10115
|
stack.finish(opId);
|
|
10105
10116
|
return { data: __assign(__assign({}, data), { server: server }), stack: stack, requestOptions: requestOptions };
|
|
10106
10117
|
})
|
|
10107
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10118
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); });
|
|
10108
10119
|
};
|
|
10109
10120
|
var enrichLayers = function (input) {
|
|
10110
10121
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
@@ -10122,12 +10133,12 @@
|
|
|
10122
10133
|
stack.finish(opId);
|
|
10123
10134
|
return { data: __assign(__assign({}, data), { layers: layers }), stack: stack, requestOptions: requestOptions };
|
|
10124
10135
|
})
|
|
10125
|
-
.catch(function (error) { return handleEnrichmentError$
|
|
10136
|
+
.catch(function (error) { return handleEnrichmentError$2(error, input, opId); }));
|
|
10126
10137
|
};
|
|
10127
10138
|
// add the error to the content.errors,
|
|
10128
10139
|
// log current stack operation as finished with an error
|
|
10129
10140
|
// and return output that can be piped into the next operation
|
|
10130
|
-
var handleEnrichmentError$
|
|
10141
|
+
var handleEnrichmentError$2 = function (error, input, opId) {
|
|
10131
10142
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
10132
10143
|
stack.finish(opId, { error: error });
|
|
10133
10144
|
return {
|
|
@@ -13222,7 +13233,7 @@
|
|
|
13222
13233
|
requestOptions: requestOptions,
|
|
13223
13234
|
};
|
|
13224
13235
|
})
|
|
13225
|
-
.catch(function (error) { return handleEnrichmentError(error, input, opId); });
|
|
13236
|
+
.catch(function (error) { return handleEnrichmentError$1(error, input, opId); });
|
|
13226
13237
|
};
|
|
13227
13238
|
/**
|
|
13228
13239
|
* Create a summary of the Group membership by searching for members,
|
|
@@ -13247,12 +13258,12 @@
|
|
|
13247
13258
|
requestOptions: requestOptions,
|
|
13248
13259
|
};
|
|
13249
13260
|
})
|
|
13250
|
-
.catch(function (error) { return handleEnrichmentError(error, input, opId); });
|
|
13261
|
+
.catch(function (error) { return handleEnrichmentError$1(error, input, opId); });
|
|
13251
13262
|
};
|
|
13252
13263
|
// add the error to the content.errors,
|
|
13253
13264
|
// log current stack operation as finished with an error
|
|
13254
13265
|
// and return output that can be piped into the next operation
|
|
13255
|
-
var handleEnrichmentError = function (error, input, opId) {
|
|
13266
|
+
var handleEnrichmentError$1 = function (error, input, opId) {
|
|
13256
13267
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
13257
13268
|
stack.finish(opId, { error: error });
|
|
13258
13269
|
return {
|
|
@@ -13264,7 +13275,7 @@
|
|
|
13264
13275
|
/**
|
|
13265
13276
|
* Available enrichments for Groups
|
|
13266
13277
|
*/
|
|
13267
|
-
var groupEnrichementOperations = {
|
|
13278
|
+
var groupEnrichementOperations$1 = {
|
|
13268
13279
|
membershipSummary: enrichGroupMembershipSummary,
|
|
13269
13280
|
contentCount: enrichGroupContentCount,
|
|
13270
13281
|
};
|
|
@@ -13278,7 +13289,7 @@
|
|
|
13278
13289
|
function fetchGroupEnrichments(group, enrichments, requestOptions) {
|
|
13279
13290
|
// create a pipeline of enrichment operations
|
|
13280
13291
|
var operations = enrichments.reduce(function (ops, enrichment) {
|
|
13281
|
-
var operation = groupEnrichementOperations[enrichment];
|
|
13292
|
+
var operation = groupEnrichementOperations$1[enrichment];
|
|
13282
13293
|
// only include the enrichments that we know how to fetch
|
|
13283
13294
|
operation && ops.push(operation);
|
|
13284
13295
|
return ops;
|
|
@@ -14494,7 +14505,7 @@
|
|
|
14494
14505
|
so_1.countFields = options.aggFields.join(",");
|
|
14495
14506
|
so_1.countSize = options.aggLimit || 10;
|
|
14496
14507
|
}
|
|
14497
|
-
searchPromise = searchPortal$
|
|
14508
|
+
searchPromise = searchPortal$3(so_1);
|
|
14498
14509
|
}
|
|
14499
14510
|
else {
|
|
14500
14511
|
// Hub API Search
|
|
@@ -14522,7 +14533,7 @@
|
|
|
14522
14533
|
* @param site
|
|
14523
14534
|
* @returns
|
|
14524
14535
|
*/
|
|
14525
|
-
function searchPortal$
|
|
14536
|
+
function searchPortal$3(searchOptions) {
|
|
14526
14537
|
var _a;
|
|
14527
14538
|
var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
|
|
14528
14539
|
var token;
|
|
@@ -14553,7 +14564,7 @@
|
|
|
14553
14564
|
results: content,
|
|
14554
14565
|
facets: facets,
|
|
14555
14566
|
hasNext: hasNext,
|
|
14556
|
-
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$
|
|
14567
|
+
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$3),
|
|
14557
14568
|
};
|
|
14558
14569
|
});
|
|
14559
14570
|
}
|
|
@@ -17803,7 +17814,7 @@
|
|
|
17803
17814
|
so.countFields = options.aggFields.join(",");
|
|
17804
17815
|
so.countSize = options.aggLimit || 10;
|
|
17805
17816
|
}
|
|
17806
|
-
return [2 /*return*/, searchPortal$
|
|
17817
|
+
return [2 /*return*/, searchPortal$2(so)];
|
|
17807
17818
|
});
|
|
17808
17819
|
});
|
|
17809
17820
|
}
|
|
@@ -17814,7 +17825,7 @@
|
|
|
17814
17825
|
* @param searchOptions
|
|
17815
17826
|
* @returns
|
|
17816
17827
|
*/
|
|
17817
|
-
function searchPortal$
|
|
17828
|
+
function searchPortal$2(searchOptions) {
|
|
17818
17829
|
return __awaiter(this, void 0, void 0, function () {
|
|
17819
17830
|
var resp, fn, results, facets;
|
|
17820
17831
|
return __generator(this, function (_a) {
|
|
@@ -17835,7 +17846,7 @@
|
|
|
17835
17846
|
results: results,
|
|
17836
17847
|
facets: facets,
|
|
17837
17848
|
hasNext: resp.nextStart > -1,
|
|
17838
|
-
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$
|
|
17849
|
+
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$2),
|
|
17839
17850
|
}];
|
|
17840
17851
|
}
|
|
17841
17852
|
});
|
|
@@ -18123,7 +18134,7 @@
|
|
|
18123
18134
|
if (!so.authentication) {
|
|
18124
18135
|
so.portal = so.requestOptions.portal || api.url + "/sharing/rest";
|
|
18125
18136
|
}
|
|
18126
|
-
return [2 /*return*/, searchPortal(so)];
|
|
18137
|
+
return [2 /*return*/, searchPortal$1(so)];
|
|
18127
18138
|
});
|
|
18128
18139
|
});
|
|
18129
18140
|
}
|
|
@@ -18134,7 +18145,7 @@
|
|
|
18134
18145
|
* @param searchOptions
|
|
18135
18146
|
* @returns
|
|
18136
18147
|
*/
|
|
18137
|
-
function searchPortal(searchOptions) {
|
|
18148
|
+
function searchPortal$1(searchOptions) {
|
|
18138
18149
|
return __awaiter(this, void 0, void 0, function () {
|
|
18139
18150
|
var resp, fn, results;
|
|
18140
18151
|
return __generator(this, function (_a) {
|
|
@@ -18155,7 +18166,7 @@
|
|
|
18155
18166
|
results: results,
|
|
18156
18167
|
facets: [],
|
|
18157
18168
|
hasNext: resp.nextStart > -1,
|
|
18158
|
-
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal),
|
|
18169
|
+
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$1),
|
|
18159
18170
|
}];
|
|
18160
18171
|
}
|
|
18161
18172
|
});
|
|
@@ -18182,6 +18193,104 @@
|
|
|
18182
18193
|
});
|
|
18183
18194
|
}
|
|
18184
18195
|
|
|
18196
|
+
/**
|
|
18197
|
+
* @private
|
|
18198
|
+
* Portal Search implementation for Users
|
|
18199
|
+
* @param filterGroups
|
|
18200
|
+
* @param options
|
|
18201
|
+
*/
|
|
18202
|
+
function portalSearchUsers(filterGroups, options) {
|
|
18203
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18204
|
+
var expandedGroups, so, props;
|
|
18205
|
+
return __generator(this, function (_a) {
|
|
18206
|
+
// requestOptions is always required and user must be authd
|
|
18207
|
+
if (!options.requestOptions) {
|
|
18208
|
+
throw new HubError$1("portalSearchUsers", "requestOptions: IHubRequestOptions is required.");
|
|
18209
|
+
}
|
|
18210
|
+
if (!options.requestOptions.authentication) {
|
|
18211
|
+
throw new HubError$1("portalSearchUsers", "requestOptions must pass authentication.");
|
|
18212
|
+
}
|
|
18213
|
+
expandedGroups = filterGroups.map(function (fg) {
|
|
18214
|
+
fg.filters = fg.filters.map(expandFilter);
|
|
18215
|
+
return fg;
|
|
18216
|
+
});
|
|
18217
|
+
so = serializeFilterGroupsForPortal(expandedGroups);
|
|
18218
|
+
props = [
|
|
18219
|
+
"num",
|
|
18220
|
+
"sortField",
|
|
18221
|
+
"sortOrder",
|
|
18222
|
+
"include",
|
|
18223
|
+
"start",
|
|
18224
|
+
"requestOptions",
|
|
18225
|
+
];
|
|
18226
|
+
// copy the props over
|
|
18227
|
+
props.forEach(function (prop) {
|
|
18228
|
+
if (options.hasOwnProperty(prop)) {
|
|
18229
|
+
so[prop] = options[prop];
|
|
18230
|
+
}
|
|
18231
|
+
});
|
|
18232
|
+
// Ensure authentication gets sent
|
|
18233
|
+
so.authentication = options.requestOptions.authentication;
|
|
18234
|
+
// Execute search
|
|
18235
|
+
return [2 /*return*/, searchPortal(so)];
|
|
18236
|
+
});
|
|
18237
|
+
});
|
|
18238
|
+
}
|
|
18239
|
+
/**
|
|
18240
|
+
* Internal portal search, which then converts `IGroup`s to `IHubSearchResult`s
|
|
18241
|
+
* handling enrichments & includes along the way
|
|
18242
|
+
*
|
|
18243
|
+
* @param searchOptions
|
|
18244
|
+
* @returns
|
|
18245
|
+
*/
|
|
18246
|
+
function searchPortal(searchOptions) {
|
|
18247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18248
|
+
var resp, fn, results;
|
|
18249
|
+
return __generator(this, function (_a) {
|
|
18250
|
+
switch (_a.label) {
|
|
18251
|
+
case 0: return [4 /*yield*/, searchUsers(searchOptions)];
|
|
18252
|
+
case 1:
|
|
18253
|
+
resp = _a.sent();
|
|
18254
|
+
fn = function (user) {
|
|
18255
|
+
return userToSearchResult(user, searchOptions.include, searchOptions.requestOptions);
|
|
18256
|
+
};
|
|
18257
|
+
return [4 /*yield*/, Promise.all(resp.results.map(fn))];
|
|
18258
|
+
case 2:
|
|
18259
|
+
results = _a.sent();
|
|
18260
|
+
// Group Search does not support aggregations
|
|
18261
|
+
// Construct the return
|
|
18262
|
+
return [2 /*return*/, {
|
|
18263
|
+
total: resp.total,
|
|
18264
|
+
results: results,
|
|
18265
|
+
facets: [],
|
|
18266
|
+
hasNext: resp.nextStart > -1,
|
|
18267
|
+
next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal),
|
|
18268
|
+
}];
|
|
18269
|
+
}
|
|
18270
|
+
});
|
|
18271
|
+
});
|
|
18272
|
+
}
|
|
18273
|
+
/**
|
|
18274
|
+
* Convert an Item to a IHubSearchResult
|
|
18275
|
+
* Fetches the includes and attaches them to the item
|
|
18276
|
+
* @param item
|
|
18277
|
+
* @param includes
|
|
18278
|
+
* @param requestOptions
|
|
18279
|
+
* @returns
|
|
18280
|
+
*/
|
|
18281
|
+
function userToSearchResult(user, includes, requestOptions) {
|
|
18282
|
+
if (includes === void 0) { includes = []; }
|
|
18283
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18284
|
+
return __generator(this, function (_a) {
|
|
18285
|
+
// Delegate to HubGroups module
|
|
18286
|
+
// This layer of indirection is not necessary but
|
|
18287
|
+
// aligns with how the items search works and
|
|
18288
|
+
// allows for future specialization
|
|
18289
|
+
return [2 /*return*/, enrichUserSearchResult(user, includes, requestOptions)];
|
|
18290
|
+
});
|
|
18291
|
+
});
|
|
18292
|
+
}
|
|
18293
|
+
|
|
18185
18294
|
/**
|
|
18186
18295
|
* Main Search function for ArcGIS Hub
|
|
18187
18296
|
*
|
|
@@ -18215,6 +18324,7 @@
|
|
|
18215
18324
|
arcgis: {
|
|
18216
18325
|
item: portalSearchItems,
|
|
18217
18326
|
group: portalSearchGroups,
|
|
18327
|
+
user: portalSearchUsers,
|
|
18218
18328
|
},
|
|
18219
18329
|
"arcgis-hub": {
|
|
18220
18330
|
item: hubSearchItems,
|
|
@@ -18224,7 +18334,7 @@
|
|
|
18224
18334
|
if (!fn) {
|
|
18225
18335
|
throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented");
|
|
18226
18336
|
}
|
|
18227
|
-
return [2 /*return*/, fn(filterGroups, options)];
|
|
18337
|
+
return [2 /*return*/, fn(cloneObject$1(filterGroups), options)];
|
|
18228
18338
|
});
|
|
18229
18339
|
});
|
|
18230
18340
|
}
|
|
@@ -19698,6 +19808,145 @@
|
|
|
19698
19808
|
return Hub;
|
|
19699
19809
|
}());
|
|
19700
19810
|
|
|
19811
|
+
var enrichUserOrg = function (input) {
|
|
19812
|
+
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
19813
|
+
var opId = stack.start("enrichUserOrg");
|
|
19814
|
+
var options = __assign(__assign({}, requestOptions), {
|
|
19815
|
+
// In order to get the correct response, we must pass options.portal
|
|
19816
|
+
// as a base portal url (e.g., www.arcgis.com, qaext.arcgis.com, etc)
|
|
19817
|
+
// **not** an org portal (i.e. org.maps.arcgis.com).
|
|
19818
|
+
portal: getPortalBaseFromOrgUrl(requestOptions.portal) + "/sharing/rest" });
|
|
19819
|
+
// TODO: Add Caching
|
|
19820
|
+
// Had implemented a simple caching system, but it leads to unstable
|
|
19821
|
+
// tests because we can't deterministically clear it
|
|
19822
|
+
// if (!orgCache[data.user.orgId]) {
|
|
19823
|
+
// orgCache[data.user.orgId] = fetchOrg(data.user.orgId, options);
|
|
19824
|
+
// }
|
|
19825
|
+
// return (orgCache[data.user.orgId] as Promise<IPortal>)
|
|
19826
|
+
return fetchOrg(data.user.orgId, options)
|
|
19827
|
+
.then(function (results) {
|
|
19828
|
+
stack.finish(opId);
|
|
19829
|
+
return {
|
|
19830
|
+
data: __assign(__assign({}, data), {
|
|
19831
|
+
org: results,
|
|
19832
|
+
}),
|
|
19833
|
+
stack: stack,
|
|
19834
|
+
requestOptions: requestOptions,
|
|
19835
|
+
};
|
|
19836
|
+
})
|
|
19837
|
+
.catch(function (error) { return handleEnrichmentError(error, input, opId); });
|
|
19838
|
+
};
|
|
19839
|
+
/**
|
|
19840
|
+
* Simple cache for user org's. This does not expire
|
|
19841
|
+
* but that seems reasonable as Org props rarely change
|
|
19842
|
+
*/
|
|
19843
|
+
// This works find at run-time, but it's a problem in tests
|
|
19844
|
+
// where we are validating calls. Will work with Randy to
|
|
19845
|
+
// create something that's more robust
|
|
19846
|
+
// const orgCache: Record<string, any> = {};
|
|
19847
|
+
// add the error to the content.errors,
|
|
19848
|
+
// log current stack operation as finished with an error
|
|
19849
|
+
// and return output that can be piped into the next operation
|
|
19850
|
+
var handleEnrichmentError = function (error, input, opId) {
|
|
19851
|
+
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
19852
|
+
stack.finish(opId, { error: error });
|
|
19853
|
+
return {
|
|
19854
|
+
data: __assign(__assign({}, data), { errors: getEnrichmentErrors(error, data.errors) }),
|
|
19855
|
+
stack: stack,
|
|
19856
|
+
requestOptions: requestOptions,
|
|
19857
|
+
};
|
|
19858
|
+
};
|
|
19859
|
+
/**
|
|
19860
|
+
* Available enrichments for Groups
|
|
19861
|
+
*/
|
|
19862
|
+
var groupEnrichementOperations = {
|
|
19863
|
+
org: enrichUserOrg,
|
|
19864
|
+
};
|
|
19865
|
+
/**
|
|
19866
|
+
* Fetch enrichments for Users
|
|
19867
|
+
* @param group
|
|
19868
|
+
* @param enrichments
|
|
19869
|
+
* @param requestOptions
|
|
19870
|
+
* @returns
|
|
19871
|
+
*/
|
|
19872
|
+
function fetchUserEnrichments(user, enrichments, requestOptions) {
|
|
19873
|
+
// create a pipeline of enrichment operations
|
|
19874
|
+
var operations = enrichments.reduce(function (ops, enrichment) {
|
|
19875
|
+
var operation = groupEnrichementOperations[enrichment];
|
|
19876
|
+
// only include the enrichments that we know how to fetch
|
|
19877
|
+
operation && ops.push(operation);
|
|
19878
|
+
return ops;
|
|
19879
|
+
}, []);
|
|
19880
|
+
var pipeline = createOperationPipeline(operations);
|
|
19881
|
+
// execute pipeline and return the item and enrichments
|
|
19882
|
+
return pipeline({
|
|
19883
|
+
data: { user: user },
|
|
19884
|
+
stack: new OperationStack$1(),
|
|
19885
|
+
requestOptions: requestOptions,
|
|
19886
|
+
}).then(function (output) {
|
|
19887
|
+
// TODO: send telemetry so we have info on what enrichments are requested and possible errors
|
|
19888
|
+
return output.data;
|
|
19889
|
+
});
|
|
19890
|
+
}
|
|
19891
|
+
|
|
19892
|
+
/**
|
|
19893
|
+
* Enrich a User object
|
|
19894
|
+
* @param user
|
|
19895
|
+
* @param includes
|
|
19896
|
+
* @param requestOptions
|
|
19897
|
+
* @returns
|
|
19898
|
+
*/
|
|
19899
|
+
function enrichUserSearchResult(user, include, requestOptions) {
|
|
19900
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19901
|
+
var result, DEFAULTS, specs, enrichments, enriched, token;
|
|
19902
|
+
return __generator(this, function (_a) {
|
|
19903
|
+
switch (_a.label) {
|
|
19904
|
+
case 0:
|
|
19905
|
+
result = {
|
|
19906
|
+
access: user.access,
|
|
19907
|
+
id: user.username,
|
|
19908
|
+
type: "User",
|
|
19909
|
+
name: user.fullName,
|
|
19910
|
+
owner: user.username,
|
|
19911
|
+
summary: user.description,
|
|
19912
|
+
createdDate: new Date(user.created),
|
|
19913
|
+
createdDateSource: "user.created",
|
|
19914
|
+
updatedDate: new Date(user.modified),
|
|
19915
|
+
updatedDateSource: "user.modified",
|
|
19916
|
+
family: "people",
|
|
19917
|
+
links: {
|
|
19918
|
+
self: "not-implemented",
|
|
19919
|
+
siteRelative: "not-implemented",
|
|
19920
|
+
thumbnail: "not-implemented",
|
|
19921
|
+
},
|
|
19922
|
+
};
|
|
19923
|
+
DEFAULTS = ["org.name AS orgName"];
|
|
19924
|
+
// merge includes
|
|
19925
|
+
include = __spreadArrays(DEFAULTS, include).filter(unique);
|
|
19926
|
+
specs = include.map(parseInclude);
|
|
19927
|
+
enrichments = mapBy("enrichment", specs).filter(unique);
|
|
19928
|
+
enriched = {};
|
|
19929
|
+
if (!enrichments.length) return [3 /*break*/, 2];
|
|
19930
|
+
return [4 /*yield*/, fetchUserEnrichments(user, enrichments, requestOptions)];
|
|
19931
|
+
case 1:
|
|
19932
|
+
enriched = _a.sent();
|
|
19933
|
+
_a.label = 2;
|
|
19934
|
+
case 2:
|
|
19935
|
+
// map the enriched props onto the result
|
|
19936
|
+
specs.forEach(function (spec) {
|
|
19937
|
+
result[spec.prop] = getProp(enriched, spec.path);
|
|
19938
|
+
});
|
|
19939
|
+
token = requestOptions.authentication.token;
|
|
19940
|
+
// Handle links
|
|
19941
|
+
result.links.thumbnail = getUserThumbnailUrl(requestOptions.portal, user, token);
|
|
19942
|
+
result.links.self = getUserHomeUrl(result.id, requestOptions);
|
|
19943
|
+
result.links.siteRelative = "/people/" + result.id;
|
|
19944
|
+
return [2 /*return*/, result];
|
|
19945
|
+
}
|
|
19946
|
+
});
|
|
19947
|
+
});
|
|
19948
|
+
}
|
|
19949
|
+
|
|
19701
19950
|
exports.ArcGISContext = ArcGISContext;
|
|
19702
19951
|
exports.ArcGISContextManager = ArcGISContextManager;
|
|
19703
19952
|
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
@@ -19825,6 +20074,7 @@
|
|
|
19825
20074
|
exports.enrichPageSearchResult = enrichPageSearchResult;
|
|
19826
20075
|
exports.enrichProjectSearchResult = enrichProjectSearchResult;
|
|
19827
20076
|
exports.enrichSiteSearchResult = enrichSiteSearchResult;
|
|
20077
|
+
exports.enrichUserSearchResult = enrichUserSearchResult;
|
|
19828
20078
|
exports.ensureProp = ensureProp;
|
|
19829
20079
|
exports.ensureUniqueDomainName = ensureUniqueDomainName;
|
|
19830
20080
|
exports.ensureUniqueString = ensureUniqueString;
|
|
@@ -19916,6 +20166,7 @@
|
|
|
19916
20166
|
exports.getUniqueDomainNamePortal = getUniqueDomainNamePortal;
|
|
19917
20167
|
exports.getUniqueItemTitle = getUniqueItemTitle;
|
|
19918
20168
|
exports.getUniqueSlug = getUniqueSlug;
|
|
20169
|
+
exports.getUserHomeUrl = getUserHomeUrl;
|
|
19919
20170
|
exports.getUserThumbnailUrl = getUserThumbnailUrl;
|
|
19920
20171
|
exports.getWithDefault = getWithDefault$1;
|
|
19921
20172
|
exports.hasBasePriv = hasBasePriv;
|