@esri/hub-common 9.39.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/content/_internal.js +83 -0
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +7 -11
- package/dist/es2017/content/compose.js.map +1 -1
- package/dist/es2017/core/types/IHubContent.js +7 -0
- package/dist/es2017/core/types/IHubContent.js.map +1 -1
- package/dist/es2017/index.js +2 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/items/_enrichments.js +21 -0
- package/dist/es2017/items/_enrichments.js.map +1 -1
- package/dist/es2017/org/fetch-org.js +21 -0
- package/dist/es2017/org/fetch-org.js.map +1 -0
- package/dist/es2017/org/index.js +2 -0
- package/dist/es2017/org/index.js.map +1 -0
- 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/filter-utils.js +59 -26
- package/dist/es2017/search/filter-utils.js.map +1 -1
- 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/content/_internal.js +85 -0
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +5 -11
- package/dist/esm/content/compose.js.map +1 -1
- package/dist/esm/core/types/IHubContent.js +7 -0
- package/dist/esm/core/types/IHubContent.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/items/_enrichments.js +21 -0
- package/dist/esm/items/_enrichments.js.map +1 -1
- package/dist/esm/org/fetch-org.js +22 -0
- package/dist/esm/org/fetch-org.js.map +1 -0
- package/dist/esm/org/index.js +2 -0
- package/dist/esm/org/index.js.map +1 -0
- 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/filter-utils.js +60 -27
- package/dist/esm/search/filter-utils.js.map +1 -1
- 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/content/_internal.js +84 -1
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +6 -10
- package/dist/node/content/compose.js.map +1 -1
- package/dist/node/core/types/IHubContent.js +8 -0
- package/dist/node/core/types/IHubContent.js.map +1 -1
- package/dist/node/index.js +2 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/items/_enrichments.js +21 -0
- package/dist/node/items/_enrichments.js.map +1 -1
- package/dist/node/org/fetch-org.js +24 -0
- package/dist/node/org/fetch-org.js.map +1 -0
- package/dist/node/org/index.js +5 -0
- package/dist/node/org/index.js.map +1 -0
- 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/filter-utils.js +59 -26
- package/dist/node/search/filter-utils.js.map +1 -1
- 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/content/_internal.d.ts +54 -5
- package/dist/types/core/types/IHubContent.d.ts +21 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/org/fetch-org.d.ts +9 -0
- package/dist/types/org/index.d.ts +1 -0
- package/dist/types/search/_internal/portalSearchUsers.d.ts +8 -0
- package/dist/types/search/types/types.d.ts +18 -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 +477 -69
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.portalSearchUsers = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const HubError_1 = require("../../HubError");
|
|
7
|
+
const filter_utils_1 = require("../filter-utils");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
* Portal Search implementation for Users
|
|
12
|
+
* @param filterGroups
|
|
13
|
+
* @param options
|
|
14
|
+
*/
|
|
15
|
+
async function portalSearchUsers(filterGroups, options) {
|
|
16
|
+
// requestOptions is always required and user must be authd
|
|
17
|
+
if (!options.requestOptions) {
|
|
18
|
+
throw new HubError_1.default("portalSearchUsers", "requestOptions: IHubRequestOptions is required.");
|
|
19
|
+
}
|
|
20
|
+
if (!options.requestOptions.authentication) {
|
|
21
|
+
throw new HubError_1.default("portalSearchUsers", "requestOptions must pass authentication.");
|
|
22
|
+
}
|
|
23
|
+
// Expand the individual filters in each of the groups
|
|
24
|
+
const expandedGroups = filterGroups.map((fg) => {
|
|
25
|
+
fg.filters = fg.filters.map(filter_utils_1.expandFilter);
|
|
26
|
+
return fg;
|
|
27
|
+
});
|
|
28
|
+
// Serialize the all the groups for portal
|
|
29
|
+
const so = filter_utils_1.serializeFilterGroupsForPortal(expandedGroups);
|
|
30
|
+
// Array of properties we want to copy from IHubSearchOptions to the ISearchOptions
|
|
31
|
+
const props = [
|
|
32
|
+
"num",
|
|
33
|
+
"sortField",
|
|
34
|
+
"sortOrder",
|
|
35
|
+
"include",
|
|
36
|
+
"start",
|
|
37
|
+
"requestOptions",
|
|
38
|
+
];
|
|
39
|
+
// copy the props over
|
|
40
|
+
props.forEach((prop) => {
|
|
41
|
+
if (options.hasOwnProperty(prop)) {
|
|
42
|
+
so[prop] = options[prop];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// Ensure authentication gets sent
|
|
46
|
+
so.authentication = options.requestOptions.authentication;
|
|
47
|
+
// Execute search
|
|
48
|
+
return searchPortal(so);
|
|
49
|
+
}
|
|
50
|
+
exports.portalSearchUsers = portalSearchUsers;
|
|
51
|
+
/**
|
|
52
|
+
* Internal portal search, which then converts `IGroup`s to `IHubSearchResult`s
|
|
53
|
+
* handling enrichments & includes along the way
|
|
54
|
+
*
|
|
55
|
+
* @param searchOptions
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
async function searchPortal(searchOptions) {
|
|
59
|
+
// Execute portal search
|
|
60
|
+
const resp = await arcgis_rest_portal_1.searchUsers(searchOptions);
|
|
61
|
+
// create mappable fn that will close
|
|
62
|
+
// over the includes and requestOptions
|
|
63
|
+
const fn = (user) => {
|
|
64
|
+
return userToSearchResult(user, searchOptions.include, searchOptions.requestOptions);
|
|
65
|
+
};
|
|
66
|
+
// map over results
|
|
67
|
+
const results = await Promise.all(resp.results.map(fn));
|
|
68
|
+
// Group Search does not support aggregations
|
|
69
|
+
// Construct the return
|
|
70
|
+
return {
|
|
71
|
+
total: resp.total,
|
|
72
|
+
results,
|
|
73
|
+
facets: [],
|
|
74
|
+
hasNext: resp.nextStart > -1,
|
|
75
|
+
next: utils_1.getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Convert an Item to a IHubSearchResult
|
|
80
|
+
* Fetches the includes and attaches them to the item
|
|
81
|
+
* @param item
|
|
82
|
+
* @param includes
|
|
83
|
+
* @param requestOptions
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
async function userToSearchResult(user, includes = [], requestOptions) {
|
|
87
|
+
// Delegate to HubGroups module
|
|
88
|
+
// This layer of indirection is not necessary but
|
|
89
|
+
// aligns with how the items search works and
|
|
90
|
+
// allows for future specialization
|
|
91
|
+
return __1.enrichUserSearchResult(user, includes, requestOptions);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=portalSearchUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portalSearchUsers.js","sourceRoot":"","sources":["../../../../src/search/_internal/portalSearchUsers.ts"],"names":[],"mappings":";;;AAAA,iEAIkC;AAElC,6BAAuD;AAEvD,6CAAsC;AAGtC,kDAA+E;AAQ/E,oCAAsD;AAEtD;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAAyC,EACzC,OAA0B;IAE1B,2DAA2D;IA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,IAAW,EAAE,EAAE;QACzB,OAAO,kBAAkB,CACvB,IAAI,EACJ,aAAa,CAAC,OAAO,EACrB,aAAa,CAAC,cAAc,CAC7B,CAAC;IACJ,CAAC,CAAC;IAEF,mBAAmB;IACnB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAExD,6CAA6C;IAC7C,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;QACP,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAC5B,IAAI,EAAE,uBAAe,CACnB,aAAa,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,EACV,YAAY,CACb;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,kBAAkB,CAC/B,IAAW,EACX,WAAqB,EAAE,EACvB,cAAmC;IAEnC,+BAA+B;IAC/B,iDAAiD;IACjD,6CAA6C;IAC7C,mCAAmC;IACnC,OAAO,0BAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -16,7 +16,13 @@ const utils_1 = require("./utils");
|
|
|
16
16
|
function expandFilter(filter) {
|
|
17
17
|
const result = {};
|
|
18
18
|
const dateProps = ["created", "modified", "lastlogin"];
|
|
19
|
-
const copyProps = [
|
|
19
|
+
const copyProps = [
|
|
20
|
+
"filterType",
|
|
21
|
+
"term",
|
|
22
|
+
"searchUserAccess",
|
|
23
|
+
"isopendata",
|
|
24
|
+
"searchUserName",
|
|
25
|
+
];
|
|
20
26
|
const nonMatchOptionsFields = [...dateProps, ...copyProps];
|
|
21
27
|
// Do the conversion
|
|
22
28
|
Object.entries(filter).forEach(([key, value]) => {
|
|
@@ -49,28 +55,27 @@ exports.expandFilter = expandFilter;
|
|
|
49
55
|
* @returns
|
|
50
56
|
*/
|
|
51
57
|
function serializeFilterGroupsForPortal(filterGroups) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
filter: "",
|
|
55
|
-
};
|
|
56
|
-
result.q = filterGroups.map(serializeGroup).join(" AND ");
|
|
58
|
+
const groupSearchOptions = filterGroups.map(serializeGroup);
|
|
59
|
+
const result = mergeSearchOptions(groupSearchOptions, "AND");
|
|
57
60
|
return result;
|
|
58
61
|
}
|
|
59
62
|
exports.serializeFilterGroupsForPortal = serializeFilterGroupsForPortal;
|
|
60
63
|
/**
|
|
61
64
|
* Serialize the filters in a FitlerGroup into a Portal Query
|
|
62
|
-
* @param
|
|
65
|
+
* @param filterGroup
|
|
63
66
|
* @returns
|
|
64
67
|
*/
|
|
65
|
-
function serializeGroup(
|
|
66
|
-
const operation =
|
|
67
|
-
const filters =
|
|
68
|
-
|
|
69
|
-
//
|
|
68
|
+
function serializeGroup(filterGroup) {
|
|
69
|
+
const operation = filterGroup.operation || "AND";
|
|
70
|
+
const filters = filterGroup.filters.map(expandFilter);
|
|
71
|
+
const filterSearchOptions = filters.map(serializeFilter);
|
|
72
|
+
// combine these searchOptions
|
|
73
|
+
const groupSearchOptions = mergeSearchOptions(filterSearchOptions, operation);
|
|
74
|
+
//
|
|
70
75
|
if (filters.length > 1) {
|
|
71
|
-
q = `(${q})`;
|
|
76
|
+
groupSearchOptions.q = `(${groupSearchOptions.q})`;
|
|
72
77
|
}
|
|
73
|
-
return
|
|
78
|
+
return groupSearchOptions;
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
76
81
|
* Serialize a Filter into a Portal Query
|
|
@@ -80,37 +85,65 @@ function serializeGroup(group) {
|
|
|
80
85
|
function serializeFilter(filter) {
|
|
81
86
|
const dateProps = ["created", "modified"];
|
|
82
87
|
const boolProps = ["isopendata"];
|
|
88
|
+
const passThroughProps = ["searchUserAccess", "searchUserName"];
|
|
83
89
|
const specialProps = [
|
|
84
90
|
"filterType",
|
|
85
|
-
"searchUserAccess",
|
|
86
91
|
"term",
|
|
87
92
|
...dateProps,
|
|
88
93
|
...boolProps,
|
|
94
|
+
...passThroughProps,
|
|
89
95
|
];
|
|
96
|
+
let qCount = 0;
|
|
90
97
|
// TODO: Look at using reduce vs .map and remove the `.filter`
|
|
91
|
-
const
|
|
98
|
+
const opts = Object.entries(filter)
|
|
92
99
|
.map(([key, value]) => {
|
|
100
|
+
const so = { q: "" };
|
|
93
101
|
if (!specialProps.includes(key)) {
|
|
94
|
-
|
|
102
|
+
qCount++;
|
|
103
|
+
so.q = serializeMatchOptions(key, value);
|
|
95
104
|
}
|
|
96
105
|
if (dateProps.includes(key)) {
|
|
97
|
-
|
|
106
|
+
qCount++;
|
|
107
|
+
so.q = serializeDateRange(key, value);
|
|
98
108
|
}
|
|
99
109
|
if (boolProps.includes(key)) {
|
|
100
|
-
|
|
110
|
+
qCount++;
|
|
111
|
+
so.q = `${key}:${value}`;
|
|
112
|
+
}
|
|
113
|
+
if (passThroughProps.includes(key)) {
|
|
114
|
+
so[key] = value;
|
|
101
115
|
}
|
|
102
116
|
if (key === "term") {
|
|
103
|
-
|
|
117
|
+
qCount++;
|
|
118
|
+
so.q = value;
|
|
104
119
|
}
|
|
120
|
+
return so;
|
|
105
121
|
})
|
|
106
122
|
.filter((e) => e !== undefined);
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
else {
|
|
112
|
-
return stringFilters[0];
|
|
123
|
+
// merge up all the searchOptions
|
|
124
|
+
const searchOptions = mergeSearchOptions(opts, "AND");
|
|
125
|
+
if (qCount > 1) {
|
|
126
|
+
searchOptions.q = `(${searchOptions.q})`;
|
|
113
127
|
}
|
|
128
|
+
return searchOptions;
|
|
129
|
+
}
|
|
130
|
+
function mergeSearchOptions(options, operation) {
|
|
131
|
+
const result = options.reduce((acc, entry) => {
|
|
132
|
+
// walk the props
|
|
133
|
+
Object.entries(entry).forEach(([key, value]) => {
|
|
134
|
+
// if prop exists
|
|
135
|
+
if (acc[key]) {
|
|
136
|
+
// combine via operation
|
|
137
|
+
acc[key] = `${acc[key]} ${operation} ${value}`;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// just copy the value
|
|
141
|
+
acc[key] = value;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return acc;
|
|
145
|
+
}, { q: "" });
|
|
146
|
+
return result;
|
|
114
147
|
}
|
|
115
148
|
/**
|
|
116
149
|
* Serialize MatchOptions into portal syntax
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-utils.js","sourceRoot":"","sources":["../../../src/search/filter-utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"filter-utils.js","sourceRoot":"","sources":["../../../src/search/filter-utils.ts"],"names":[],"mappings":";;;AAEA,wCAA8C;AAC9C,kCAAsC;AAQtC,mCAAuE;AAEvE;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAI,MAAS;IACvC,MAAM,MAAM,GAAG,EAAmB,CAAC;IACnC,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG;QAChB,YAAY;QACZ,MAAM;QACN,kBAAkB;QAClB,YAAY;QACZ,gBAAgB;KACjB,CAAC;IACF,MAAM,qBAAqB,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,SAAS,CAAC,CAAC;IAC3D,oBAAoB;IACpB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9C,6BAA6B;QAC7B,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxC,4CAA4C;YAC5C,iBAAO,CAAC,GAAG,EAAE,2BAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;SAClD;QACD,qBAAqB;QACrB,IAAI,SAAS,CAAC,QAA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d;KACF;SAAM;QACL,CAAC,GAAG,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;KACzB;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hubSearch = void 0;
|
|
4
4
|
const HubError_1 = require("../HubError");
|
|
5
5
|
const objects_1 = require("../objects");
|
|
6
|
+
const util_1 = require("../util");
|
|
6
7
|
const utils_1 = require("./utils");
|
|
7
8
|
const _internal_1 = require("./_internal");
|
|
9
|
+
const portalSearchUsers_1 = require("./_internal/portalSearchUsers");
|
|
8
10
|
/**
|
|
9
11
|
* Main Search function for ArcGIS Hub
|
|
10
12
|
*
|
|
@@ -37,6 +39,7 @@ async function hubSearch(filterGroups, options) {
|
|
|
37
39
|
arcgis: {
|
|
38
40
|
item: _internal_1.portalSearchItems,
|
|
39
41
|
group: _internal_1.portalSearchGroups,
|
|
42
|
+
user: portalSearchUsers_1.portalSearchUsers,
|
|
40
43
|
},
|
|
41
44
|
"arcgis-hub": {
|
|
42
45
|
item: _internal_1.hubSearchItems,
|
|
@@ -46,7 +49,7 @@ async function hubSearch(filterGroups, options) {
|
|
|
46
49
|
if (!fn) {
|
|
47
50
|
throw new HubError_1.default(`hubSearch`, `Search via "${filterType}" filter against "${apiType}" api is not implemented`);
|
|
48
51
|
}
|
|
49
|
-
return fn(filterGroups, options);
|
|
52
|
+
return fn(util_1.cloneObject(filterGroups), options);
|
|
50
53
|
}
|
|
51
54
|
exports.hubSearch = hubSearch;
|
|
52
55
|
//# sourceMappingURL=hubSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hubSearch.js","sourceRoot":"","sources":["../../../src/search/hubSearch.ts"],"names":[],"mappings":";;;AAAA,0CAAmC;AACnC,wCAAqC;
|
|
1
|
+
{"version":3,"file":"hubSearch.js","sourceRoot":"","sources":["../../../src/search/hubSearch.ts"],"names":[],"mappings":";;;AAAA,0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O,EAAE,CAAC,kBAAW,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAtDD,8BAsDC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserHomeUrl = void 0;
|
|
4
|
+
const get_portal_url_1 = require("./get-portal-url");
|
|
5
|
+
/**
|
|
6
|
+
* Return the URL of the user's page in the Portal Home application
|
|
7
|
+
* @param username The username
|
|
8
|
+
* @param portalUrlOrObject a portal base or API URL, a portal object, or request options containing either of those
|
|
9
|
+
* @returns URL to the user's profile, defaults to `https://www.arcgis.com/home/user.html?user={username}`
|
|
10
|
+
*/
|
|
11
|
+
function getUserHomeUrl(username, portalUrlOrObject) {
|
|
12
|
+
const portalUrl = get_portal_url_1.getPortalUrl(portalUrlOrObject);
|
|
13
|
+
return `${portalUrl}/home/user.html?user=${username}`;
|
|
14
|
+
}
|
|
15
|
+
exports.getUserHomeUrl = getUserHomeUrl;
|
|
16
|
+
//# sourceMappingURL=getUserHomeUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserHomeUrl.js","sourceRoot":"","sources":["../../../src/urls/getUserHomeUrl.ts"],"names":[],"mappings":";;;AAGA,qDAAgD;AAEhD;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,QAAgB,EAChB,iBAA2E;IAE3E,MAAM,SAAS,GAAG,6BAAY,CAAC,iBAAiB,CAAC,CAAC;IAClD,OAAO,GAAG,SAAS,wBAAwB,QAAQ,EAAE,CAAC;AACxD,CAAC;AAND,wCAMC"}
|
package/dist/node/urls/index.js
CHANGED
|
@@ -21,6 +21,7 @@ tslib_1.__exportStar(require("./convert-urls-to-anchor-tags"), exports);
|
|
|
21
21
|
tslib_1.__exportStar(require("./getHubApiFromPortalUrl"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./getPortalBaseFromOrgUrl"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./getGroupHomeUrl"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./getUserHomeUrl"), exports);
|
|
24
25
|
const MAP_OR_FEATURE_SERVER_URL_REGEX = /\/(map|feature)server/i;
|
|
25
26
|
/**
|
|
26
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/urls/index.ts"],"names":[],"mappings":";;;;AAAA,kCAAqC;AACrC,sDAA4B;AAC5B,qEAA2C;AAC3C,+DAAqC;AACrC,2DAAiC;AACjC,2DAAiC;AACjC,6DAAmC;AACnC,2DAAiC;AACjC,qEAA2C;AAC3C,0DAAgC;AAChC,wEAA8C;AAC9C,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAC9C,mEAAyC;AACzC,oEAA0C;AAC1C,4DAAkC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/urls/index.ts"],"names":[],"mappings":";;;;AAAA,kCAAqC;AACrC,sDAA4B;AAC5B,qEAA2C;AAC3C,+DAAqC;AACrC,2DAAiC;AACjC,2DAAiC;AACjC,6DAAmC;AACnC,2DAAiC;AACjC,qEAA2C;AAC3C,0DAAgC;AAChC,wEAA8C;AAC9C,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAC9C,mEAAyC;AACzC,oEAA0C;AAC1C,4DAAkC;AAClC,2DAAiC;AAEjC,MAAM,+BAA+B,GAAG,wBAAwB,CAAC;AAEjE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,CAAC,GAAW,EAAE,EAAE;IACrD,OAAO,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,YAAY,IAAI,GAAG,iBAAU,CAAC,YAAY,CAAC,UAAU,CAAC;AAC/D,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrichUserSearchResult = void 0;
|
|
4
|
+
const enrichments_1 = require("./_internal/enrichments");
|
|
5
|
+
const objects_1 = require("../objects");
|
|
6
|
+
const search_1 = require("../search");
|
|
7
|
+
const parseInclude_1 = require("../search/_internal/parseInclude");
|
|
8
|
+
const urls_1 = require("../urls");
|
|
9
|
+
const util_1 = require("../util");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
/**
|
|
12
|
+
* Enrich a User object
|
|
13
|
+
* @param user
|
|
14
|
+
* @param includes
|
|
15
|
+
* @param requestOptions
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
async function enrichUserSearchResult(user, include, requestOptions) {
|
|
19
|
+
// Create the basic structure
|
|
20
|
+
const result = {
|
|
21
|
+
access: user.access,
|
|
22
|
+
id: user.username,
|
|
23
|
+
type: "User",
|
|
24
|
+
name: user.fullName,
|
|
25
|
+
owner: user.username,
|
|
26
|
+
summary: user.description,
|
|
27
|
+
createdDate: new Date(user.created),
|
|
28
|
+
createdDateSource: "user.created",
|
|
29
|
+
updatedDate: new Date(user.modified),
|
|
30
|
+
updatedDateSource: "user.modified",
|
|
31
|
+
family: "people",
|
|
32
|
+
links: {
|
|
33
|
+
self: "not-implemented",
|
|
34
|
+
siteRelative: "not-implemented",
|
|
35
|
+
thumbnail: "not-implemented",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
// Informal Enrichments - basically adding type-specific props
|
|
39
|
+
// derived directly from the entity
|
|
40
|
+
// default includes
|
|
41
|
+
const DEFAULTS = ["org.name AS orgName"];
|
|
42
|
+
// merge includes
|
|
43
|
+
include = [...DEFAULTS, ...include].filter(util_1.unique);
|
|
44
|
+
// Parse the includes into a valid set of enrichments
|
|
45
|
+
const specs = include.map(parseInclude_1.parseInclude);
|
|
46
|
+
// Extract out the low-level enrichments needed
|
|
47
|
+
const enrichments = utils_1.mapBy("enrichment", specs).filter(util_1.unique);
|
|
48
|
+
// fetch the enrichments
|
|
49
|
+
let enriched = {};
|
|
50
|
+
// Ignoring the else, because we currently have defaults, but want the guards
|
|
51
|
+
// so if we remove that in the future, we don't call the fn
|
|
52
|
+
/* istanbul ignore else */
|
|
53
|
+
if (enrichments.length) {
|
|
54
|
+
enriched = await enrichments_1.fetchUserEnrichments(user, enrichments, requestOptions);
|
|
55
|
+
}
|
|
56
|
+
// map the enriched props onto the result
|
|
57
|
+
specs.forEach((spec) => {
|
|
58
|
+
result[spec.prop] = objects_1.getProp(enriched, spec.path);
|
|
59
|
+
});
|
|
60
|
+
const token = requestOptions.authentication.token;
|
|
61
|
+
// Handle links
|
|
62
|
+
result.links.thumbnail = search_1.getUserThumbnailUrl(requestOptions.portal, user, token);
|
|
63
|
+
result.links.self = urls_1.getUserHomeUrl(result.id, requestOptions);
|
|
64
|
+
result.links.siteRelative = `/people/${result.id}`;
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
exports.enrichUserSearchResult = enrichUserSearchResult;
|
|
68
|
+
//# sourceMappingURL=HubUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubUsers.js","sourceRoot":"","sources":["../../../src/users/HubUsers.ts"],"names":[],"mappings":";;;AACA,yDAA+D;AAC/D,wCAAqC;AACrC,sCAAkE;AAClE,mEAAgE;AAEhE,kCAAyC;AACzC,kCAAiC;AACjC,oCAAiC;AAGjC;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAC1C,IAAW,EACX,OAAiB,EACjB,cAAkC;IAElC,6BAA6B;IAC7B,MAA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EAAE;QACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,iBAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC;IAElD,eAAe;IACf,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,4BAAmB,CAC1C,cAAc,CAAC,MAAM,EACrB,IAAI,EACJ,KAAK,CACN,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,qBAAc,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC9D,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,WAAW,MAAM,CAAC,EAAE,EAAE,CAAC;IAEnD,OAAO,MAAM,CAAC;AAChB,CAAC;AA/DD,wDA+DC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchUserEnrichments = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
const _enrichments_1 = require("../../items/_enrichments");
|
|
6
|
+
const OperationStack_1 = require("../../OperationStack");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const enrichUserOrg = (input) => {
|
|
9
|
+
const { data, stack, requestOptions } = input;
|
|
10
|
+
const opId = stack.start("enrichUserOrg");
|
|
11
|
+
const options = Object.assign(Object.assign({}, requestOptions), {
|
|
12
|
+
// In order to get the correct response, we must pass options.portal
|
|
13
|
+
// as a base portal url (e.g., www.arcgis.com, qaext.arcgis.com, etc)
|
|
14
|
+
// **not** an org portal (i.e. org.maps.arcgis.com).
|
|
15
|
+
portal: `${__1.getPortalBaseFromOrgUrl(requestOptions.portal)}/sharing/rest` });
|
|
16
|
+
// TODO: Add Caching
|
|
17
|
+
// Had implemented a simple caching system, but it leads to unstable
|
|
18
|
+
// tests because we can't deterministically clear it
|
|
19
|
+
// if (!orgCache[data.user.orgId]) {
|
|
20
|
+
// orgCache[data.user.orgId] = fetchOrg(data.user.orgId, options);
|
|
21
|
+
// }
|
|
22
|
+
// return (orgCache[data.user.orgId] as Promise<IPortal>)
|
|
23
|
+
return __1.fetchOrg(data.user.orgId, options)
|
|
24
|
+
.then((results) => {
|
|
25
|
+
stack.finish(opId);
|
|
26
|
+
return {
|
|
27
|
+
data: Object.assign(Object.assign({}, data), {
|
|
28
|
+
org: results,
|
|
29
|
+
}),
|
|
30
|
+
stack,
|
|
31
|
+
requestOptions,
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => handleEnrichmentError(error, input, opId));
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Simple cache for user org's. This does not expire
|
|
38
|
+
* but that seems reasonable as Org props rarely change
|
|
39
|
+
*/
|
|
40
|
+
// This works find at run-time, but it's a problem in tests
|
|
41
|
+
// where we are validating calls. Will work with Randy to
|
|
42
|
+
// create something that's more robust
|
|
43
|
+
// const orgCache: Record<string, any> = {};
|
|
44
|
+
// add the error to the content.errors,
|
|
45
|
+
// log current stack operation as finished with an error
|
|
46
|
+
// and return output that can be piped into the next operation
|
|
47
|
+
const handleEnrichmentError = (error, input, opId) => {
|
|
48
|
+
const { data, stack, requestOptions } = input;
|
|
49
|
+
stack.finish(opId, { error });
|
|
50
|
+
return {
|
|
51
|
+
data: Object.assign(Object.assign({}, data), { errors: _enrichments_1.getEnrichmentErrors(error, data.errors) }),
|
|
52
|
+
stack,
|
|
53
|
+
requestOptions,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Available enrichments for Groups
|
|
58
|
+
*/
|
|
59
|
+
const groupEnrichementOperations = {
|
|
60
|
+
org: enrichUserOrg,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Fetch enrichments for Users
|
|
64
|
+
* @param group
|
|
65
|
+
* @param enrichments
|
|
66
|
+
* @param requestOptions
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function fetchUserEnrichments(user, enrichments, requestOptions) {
|
|
70
|
+
// create a pipeline of enrichment operations
|
|
71
|
+
const operations = enrichments.reduce((ops, enrichment) => {
|
|
72
|
+
const operation = groupEnrichementOperations[enrichment];
|
|
73
|
+
// only include the enrichments that we know how to fetch
|
|
74
|
+
operation && ops.push(operation);
|
|
75
|
+
return ops;
|
|
76
|
+
}, []);
|
|
77
|
+
const pipeline = utils_1.createOperationPipeline(operations);
|
|
78
|
+
// execute pipeline and return the item and enrichments
|
|
79
|
+
return pipeline({
|
|
80
|
+
data: { user },
|
|
81
|
+
stack: new OperationStack_1.default(),
|
|
82
|
+
requestOptions,
|
|
83
|
+
}).then((output) => {
|
|
84
|
+
// TODO: send telemetry so we have info on what enrichments are requested and possible errors
|
|
85
|
+
return output.data;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.fetchUserEnrichments = fetchUserEnrichments;
|
|
89
|
+
//# sourceMappingURL=enrichments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichments.js","sourceRoot":"","sources":["../../../../src/users/_internal/enrichments.ts"],"names":[],"mappings":";;;AACA,6BAA0D;AAC1D,2DAA+D;AAC/D,yDAAkD;AAElD,uCAAiE;AAgCjE,MAAM,aAAa,GAAG,CACpB,KAAqC,EACI,EAAE;IAC3C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC1C,MAAM,OAAO,mCACR,cAAc;QACjB,oEAAoE;QACpE,qEAAqE;QACrE,oDAAoD;QACpD,MAAM,EAAE,GAAG,2BAAuB,CAAC,cAAc,CAAC,MAAM,CAAC,eAAe,GACzE,CAAC;IACF,oBAAoB;IACpB,oEAAoE;IACpE,oDAAoD;IACpD,oCAAoC;IACpC,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,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACzD,yDAAyD;QACzD,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,QAAQ,GAAG,+BAAuB,CAAsB,UAAU,CAAC,CAAC;IAC1E,uDAAuD;IACvD,OAAO,QAAQ,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE;QACd,KAAK,EAAE,IAAI,wBAAc,EAAE;QAC3B,cAAc;KACf,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACjB,6FAA6F;QAC7F,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,oDAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/users/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IItem } from "@esri/arcgis-rest-portal";
|
|
2
|
-
import { ILayerDefinition, ISpatialReference } from "@esri/arcgis-rest-types";
|
|
3
|
-
import { IHubContent } from "../core";
|
|
1
|
+
import { IItem, IPortal } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { ILayerDefinition, ISpatialReference, IUser } from "@esri/arcgis-rest-types";
|
|
3
|
+
import { IHubContent, PublisherSource } from "../core";
|
|
4
4
|
import { IHubGeography, GeographyProvenance, IHubRequestOptions } from "../types";
|
|
5
5
|
import { IHubAdditionalResource } from "../core/types/IHubAdditionalResource";
|
|
6
6
|
/**
|
|
@@ -49,6 +49,14 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
|
|
|
49
49
|
publishedDate: Date;
|
|
50
50
|
publishedDateSource?: string;
|
|
51
51
|
updateFrequency?: string;
|
|
52
|
+
publisher?: {
|
|
53
|
+
name?: string;
|
|
54
|
+
username?: string;
|
|
55
|
+
nameSource: PublisherSource;
|
|
56
|
+
organization?: string;
|
|
57
|
+
orgId?: string;
|
|
58
|
+
organizationSource: PublisherSource;
|
|
59
|
+
};
|
|
52
60
|
portalHomeUrl?: string;
|
|
53
61
|
portalApiUrl?: string;
|
|
54
62
|
portalDataUrl?: string;
|
|
@@ -85,8 +93,8 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
|
|
|
85
93
|
};
|
|
86
94
|
metadata?: any;
|
|
87
95
|
groupIds?: string[];
|
|
88
|
-
ownerUser?:
|
|
89
|
-
org?: Partial<
|
|
96
|
+
ownerUser?: IUser;
|
|
97
|
+
org?: Partial<IPortal>;
|
|
90
98
|
errors?: import("../types").IEnrichmentErrorInfo[];
|
|
91
99
|
server?: Partial<import("@esri/arcgis-rest-feature-layer").IFeatureServiceDefinition>;
|
|
92
100
|
layers?: Partial<ILayerDefinition>[];
|
|
@@ -284,4 +292,45 @@ export declare const getAdditionalResourceUrl: (resource: IAGOAdditionalResource
|
|
|
284
292
|
* @returns the correct extent in a bbox format, or undefined
|
|
285
293
|
*/
|
|
286
294
|
export declare const determineExtent: (item: IItem, extentEnrichment?: any, layer?: ILayerDefinition) => any;
|
|
295
|
+
/**
|
|
296
|
+
* @private
|
|
297
|
+
*
|
|
298
|
+
* Extracts the first contact from a given formal item metadata path.
|
|
299
|
+
* This is particularly helpful if the contact path is either an object or an array.
|
|
300
|
+
*
|
|
301
|
+
* Note: the raw contact object must have the following properties:
|
|
302
|
+
* - `rpIndName`: name of the individual
|
|
303
|
+
* - `rpOrgName`: name of the individual's organization
|
|
304
|
+
*
|
|
305
|
+
* @param metadata formal item metadata
|
|
306
|
+
* @param path path to the contact object/array
|
|
307
|
+
* @returns
|
|
308
|
+
*/
|
|
309
|
+
export declare const extractFirstContact: (metadata: any, path: string) => {
|
|
310
|
+
individualName: any;
|
|
311
|
+
organizationName: any;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Determines the correct orgId for an item.
|
|
315
|
+
* Note: it's undocumented, but the portal API will return orgId for items... sometimes.
|
|
316
|
+
*
|
|
317
|
+
* @param item
|
|
318
|
+
* @param ownerUser item owner's hydrated user object
|
|
319
|
+
*/
|
|
320
|
+
export declare const getItemOrgId: (item: IItem, ownerUser?: IUser) => any;
|
|
321
|
+
/**
|
|
322
|
+
* Calculates the Publisher display info for the given item.
|
|
323
|
+
* Utilizes this fallback pattern:
|
|
324
|
+
* 1) Formal Item Metadata > Resource > Citation > Contact
|
|
325
|
+
* 2) Formal Item Metadata > Resource > Contact
|
|
326
|
+
* 3) Item’s Owner and Org Name
|
|
327
|
+
* 4) Undefined (Item Owner / Org are private and we can't access additional info)
|
|
328
|
+
*
|
|
329
|
+
* @param item
|
|
330
|
+
* @param metadata
|
|
331
|
+
* @param org portal info of the item's organization
|
|
332
|
+
* @param ownerUser the item owner's hydrated user
|
|
333
|
+
* @returns
|
|
334
|
+
*/
|
|
335
|
+
export declare const getPublisherInfo: (item: IItem, metadata?: any, org?: Partial<IPortal>, ownerUser?: IUser) => any;
|
|
287
336
|
export {};
|
|
@@ -5,6 +5,12 @@ import { IStructuredLicense } from "../../items/get-structured-license";
|
|
|
5
5
|
import { IHubItemEntity } from ".";
|
|
6
6
|
import { IHubContentEnrichments } from "./IHubContentEnrichments";
|
|
7
7
|
import { IHubAdditionalResource } from "./IHubAdditionalResource";
|
|
8
|
+
export declare enum PublisherSource {
|
|
9
|
+
CitationContact = "metadata.resource.citation.contact",
|
|
10
|
+
ResourceContact = "metadata.resource.contact",
|
|
11
|
+
ItemOwner = "item.owner",
|
|
12
|
+
None = "none"
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
15
|
* Data model for content
|
|
10
16
|
*/
|
|
@@ -61,6 +67,21 @@ export interface IHubContent extends IHubItemEntity, IHubContentEnrichments, IIt
|
|
|
61
67
|
publishedDateSource?: string;
|
|
62
68
|
/** Frequency at which the content is updated */
|
|
63
69
|
updateFrequency?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Info to display about the content's publisher. Follows this fallback pattern:
|
|
72
|
+
* 1) Formal Item Metadata > Resource > Citation > Contact
|
|
73
|
+
* 2) Formal Item Metadata > Resource > Contact
|
|
74
|
+
* 3) Item’s Owner and Org Name
|
|
75
|
+
* 4) Undefined (Item Owner / Org are private and we can't access additional info)
|
|
76
|
+
*/
|
|
77
|
+
publisher?: {
|
|
78
|
+
name?: string;
|
|
79
|
+
username?: string;
|
|
80
|
+
nameSource: PublisherSource;
|
|
81
|
+
organization?: string;
|
|
82
|
+
orgId?: string;
|
|
83
|
+
organizationSource: PublisherSource;
|
|
84
|
+
};
|
|
64
85
|
/** URL of the resource's page in the Portal Home application */
|
|
65
86
|
portalHomeUrl?: string;
|
|
66
87
|
/** URL of the Portal API endpoint for the resource */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export * from "./util";
|
|
|
25
25
|
export * from "./utils";
|
|
26
26
|
export * from "./Hub";
|
|
27
27
|
export * from "./pages";
|
|
28
|
+
export * from "./org";
|
|
29
|
+
export * from "./users";
|
|
28
30
|
import OperationStack from "./OperationStack";
|
|
29
31
|
import OperationError from "./OperationError";
|
|
30
32
|
import HubError from "./HubError";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IRequestOptions } from "@esri/arcgis-rest-request";
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the portal for a given org.
|
|
4
|
+
*
|
|
5
|
+
* @param orgId
|
|
6
|
+
* @param options request options
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const fetchOrg: (orgId: string, options?: IRequestOptions) => Promise<import("@esri/arcgis-rest-portal").IPortal>;
|