@esri/hub-common 9.13.2 → 9.14.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/ArcGISContext.js +158 -147
- package/dist/es2017/ArcGISContext.js.map +1 -1
- package/dist/es2017/ArcGISContextManager.js +160 -0
- package/dist/es2017/ArcGISContextManager.js.map +1 -0
- package/dist/es2017/index.js +1 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/search/_searchContent.js +18 -7
- package/dist/es2017/search/_searchContent.js.map +1 -1
- package/dist/es2017/search/_searchGroups.js +1 -11
- package/dist/es2017/search/_searchGroups.js.map +1 -1
- package/dist/es2017/search/utils.js +1 -1
- package/dist/es2017/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/es2017/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/es2017/urls/index.js +2 -0
- package/dist/es2017/urls/index.js.map +1 -1
- package/dist/esm/ArcGISContext.js +251 -202
- package/dist/esm/ArcGISContext.js.map +1 -1
- package/dist/esm/ArcGISContextManager.js +204 -0
- package/dist/esm/ArcGISContextManager.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/_searchContent.js +18 -7
- package/dist/esm/search/_searchContent.js.map +1 -1
- package/dist/esm/search/_searchGroups.js +3 -13
- package/dist/esm/search/_searchGroups.js.map +1 -1
- package/dist/esm/search/utils.js +1 -1
- package/dist/esm/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/esm/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/esm/urls/index.js +2 -0
- package/dist/esm/urls/index.js.map +1 -1
- package/dist/node/ArcGISContext.js +158 -147
- package/dist/node/ArcGISContext.js.map +1 -1
- package/dist/node/ArcGISContextManager.js +164 -0
- package/dist/node/ArcGISContextManager.js.map +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/search/_searchContent.js +17 -6
- package/dist/node/search/_searchContent.js.map +1 -1
- package/dist/node/search/_searchGroups.js +1 -11
- package/dist/node/search/_searchGroups.js.map +1 -1
- package/dist/node/search/utils.js +1 -1
- package/dist/node/urls/getHubApiFromPortalUrl.js +25 -0
- package/dist/node/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js +29 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/node/urls/index.js +2 -0
- package/dist/node/urls/index.js.map +1 -1
- package/dist/types/ArcGISContext.d.ts +103 -77
- package/dist/types/ArcGISContextManager.d.ts +113 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/search/utils.d.ts +1 -1
- package/dist/types/urls/getHubApiFromPortalUrl.d.ts +8 -0
- package/dist/types/urls/getPortalBaseFromOrgUrl.d.ts +9 -0
- package/dist/types/urls/index.d.ts +2 -0
- package/dist/umd/common.umd.js +144 -125
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/es2017/ArcGISContextState.js +0 -203
- package/dist/es2017/ArcGISContextState.js.map +0 -1
- package/dist/esm/ArcGISContextState.js +0 -285
- package/dist/esm/ArcGISContextState.js.map +0 -1
- package/dist/node/ArcGISContextState.js +0 -207
- package/dist/node/ArcGISContextState.js.map +0 -1
- package/dist/types/ArcGISContextState.d.ts +0 -129
|
@@ -14,25 +14,20 @@ const __1 = require("..");
|
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
async function _searchGroups(filter, options) {
|
|
17
|
-
var _a;
|
|
18
17
|
// expand filter so we can serialize to either api
|
|
19
18
|
const expanded = group_utils_1.expandGroupFilter(filter);
|
|
20
19
|
// API
|
|
21
20
|
const api = _1.expandApi(options.api || "arcgis");
|
|
22
21
|
if (api.type === "arcgis") {
|
|
23
22
|
const so = group_utils_1.serializeGroupFilterForPortal(expanded);
|
|
24
|
-
let token = "";
|
|
25
23
|
// if we have auth, pass it forward
|
|
26
24
|
// otherwise set the portal property
|
|
27
25
|
if (options.authentication) {
|
|
28
26
|
so.authentication = options.authentication;
|
|
29
|
-
const us = options.authentication;
|
|
30
|
-
token = us.token;
|
|
31
27
|
}
|
|
32
28
|
else {
|
|
33
29
|
so.portal = `${api.url}/sharing/rest`;
|
|
34
30
|
}
|
|
35
|
-
// TODO: Dry this up - typscript makes this... inconvenient
|
|
36
31
|
if (options.num) {
|
|
37
32
|
so.num = options.num;
|
|
38
33
|
}
|
|
@@ -42,10 +37,6 @@ async function _searchGroups(filter, options) {
|
|
|
42
37
|
if (options.sortOrder) {
|
|
43
38
|
so.sortOrder = options.sortOrder;
|
|
44
39
|
}
|
|
45
|
-
let portalUrl = `${api.url}/sharing/rest`;
|
|
46
|
-
if ((_a = so.authentication) === null || _a === void 0 ? void 0 : _a.portal) {
|
|
47
|
-
portalUrl = so.authentication.portal;
|
|
48
|
-
}
|
|
49
40
|
if (options.site) {
|
|
50
41
|
so.site = __1.cloneObject(options.site);
|
|
51
42
|
}
|
|
@@ -67,8 +58,7 @@ function searchPortalGroups(searchOptions) {
|
|
|
67
58
|
group.siteTeamUrl = `${searchOptions.site.item.url}/teams/${group.id}/about`;
|
|
68
59
|
return group;
|
|
69
60
|
};
|
|
70
|
-
const portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) ||
|
|
71
|
-
"https://www.arcgis.com/sharing/rest";
|
|
61
|
+
const portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
|
|
72
62
|
let token;
|
|
73
63
|
if (searchOptions.authentication) {
|
|
74
64
|
const us = searchOptions.authentication;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_searchGroups.js","sourceRoot":"","sources":["../../../src/search/_searchGroups.ts"],"names":[],"mappings":";;;AAEA,iEAA6E;AAC7E,wBAA+C;AAC/C,+CAGuB;AAEvB,0BAAwE;AAMxE;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CACjC,MAAuB,EACvB,OAA0B
|
|
1
|
+
{"version":3,"file":"_searchGroups.js","sourceRoot":"","sources":["../../../src/search/_searchGroups.ts"],"names":[],"mappings":"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"}
|
|
@@ -366,7 +366,7 @@ exports.getNextFunction = getNextFunction;
|
|
|
366
366
|
* Construct a the full url to a group thumbnail
|
|
367
367
|
*
|
|
368
368
|
* - If the group has a thumbnail, construct the full url
|
|
369
|
-
* - If the group is not public, append on the token
|
|
369
|
+
* - If the group is not public, append on the token (if passed in)
|
|
370
370
|
* @param portalUrl
|
|
371
371
|
* @param group
|
|
372
372
|
* @param token
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cross-walk from a portalUrl to the corresponding Hub API Url
|
|
4
|
+
*
|
|
5
|
+
* If the passed url is not recognized, then this will return `undefined`
|
|
6
|
+
* @param portalUrl
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getHubApiFromPortalUrl = void 0;
|
|
11
|
+
function getHubApiFromPortalUrl(portalUrl) {
|
|
12
|
+
let result;
|
|
13
|
+
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
14
|
+
result = "https://hubqa.arcgis.com";
|
|
15
|
+
}
|
|
16
|
+
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
17
|
+
result = "https://hubdev.arcgis.com";
|
|
18
|
+
}
|
|
19
|
+
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
20
|
+
result = "https://hub.arcgis.com";
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
exports.getHubApiFromPortalUrl = getHubApiFromPortalUrl;
|
|
25
|
+
//# sourceMappingURL=getHubApiFromPortalUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHubApiFromPortalUrl.js","sourceRoot":"","sources":["../../../src/urls/getHubApiFromPortalUrl.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,SAAgB,sBAAsB,CAAC,SAAiB;IACtD,IAAI,MAAM,CAAC;IAEX,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,0BAA0B,CAAC;KACrC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,2BAA2B,CAAC;KACtC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,wBAAwB,CAAC;KACnC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,wDAYC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPortalBaseFromOrgUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Given an org url, get the portal base url
|
|
6
|
+
*
|
|
7
|
+
* i.e. https://myorg.maps.arcgis.com will return https://www.arcgis.com
|
|
8
|
+
*
|
|
9
|
+
* @param orgUrl
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function getPortalBaseFromOrgUrl(orgUrl) {
|
|
13
|
+
let result = orgUrl;
|
|
14
|
+
if (orgUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
15
|
+
result = "https://qaext.arcgis.com";
|
|
16
|
+
}
|
|
17
|
+
else if (orgUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
18
|
+
result = "https://devext.arcgis.com";
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
/* istanbul ignore else */
|
|
22
|
+
if (orgUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
23
|
+
result = "https://www.arcgis.com";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
|
|
29
|
+
//# sourceMappingURL=getPortalBaseFromOrgUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPortalBaseFromOrgUrl.js","sourceRoot":"","sources":["../../../src/urls/getPortalBaseFromOrgUrl.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,MAAc;IACpD,IAAI,MAAM,GAAG,MAAM,CAAC;IAEpB,IAAI,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QAChD,MAAM,GAAG,0BAA0B,CAAC;KACrC;SAAM,IAAI,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC5D,MAAM,GAAG,2BAA2B,CAAC;KACtC;SAAM;QACL,0BAA0B;QAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;YAC5C,MAAM,GAAG,wBAAwB,CAAC;SACnC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,0DAeC"}
|
package/dist/node/urls/index.js
CHANGED
|
@@ -18,6 +18,8 @@ tslib_1.__exportStar(require("./get-item-home-url"), exports);
|
|
|
18
18
|
tslib_1.__exportStar(require("./get-item-api-url"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./get-item-data-url"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./convert-urls-to-anchor-tags"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./getHubApiFromPortalUrl"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./getPortalBaseFromOrgUrl"), exports);
|
|
21
23
|
const MAP_OR_FEATURE_SERVER_URL_REGEX = /\/(map|feature)server/i;
|
|
22
24
|
/**
|
|
23
25
|
*
|
|
@@ -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;
|
|
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;AAE1C,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"}
|
|
@@ -1,110 +1,136 @@
|
|
|
1
|
+
import { IUser, IUserRequestOptions, UserSession } from "@esri/arcgis-rest-auth";
|
|
1
2
|
import { IPortal } from "@esri/arcgis-rest-portal";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { IRequestOptions } from "@esri/arcgis-rest-request";
|
|
4
|
+
import { IHubRequestOptions } from ".";
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* Defines the properties of the ArcGISContext.
|
|
7
|
+
* Typically components or functions will get an instance
|
|
8
|
+
* of `ArcGISContext` from `ArcGISContetManager`.
|
|
9
|
+
*
|
|
10
|
+
* `ArcGISContext` implements this interface, and uses
|
|
11
|
+
* getters to simplify the derivation of various complex properties.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export interface IArcGISContext {
|
|
15
|
+
id: number;
|
|
16
|
+
session: UserSession;
|
|
17
|
+
isAuthenticated: boolean;
|
|
18
|
+
userRequestOptions: IUserRequestOptions;
|
|
19
|
+
requestOptions: IRequestOptions;
|
|
20
|
+
hubRequestOptions: IHubRequestOptions;
|
|
21
|
+
portalUrl: string;
|
|
22
|
+
sharingApiUrl: string;
|
|
23
|
+
hubUrl: string;
|
|
24
|
+
isPortal: boolean;
|
|
25
|
+
discussionsServiceUrl: string;
|
|
26
|
+
hubSearchServiceUrl: string;
|
|
27
|
+
domainServiceUrl: string;
|
|
28
|
+
eventsConfig: any;
|
|
29
|
+
hubEnabled: boolean;
|
|
30
|
+
communityOrgId: string;
|
|
31
|
+
communityOrgHostname: string;
|
|
32
|
+
communityOrgUrl: string;
|
|
33
|
+
helperServices: any;
|
|
34
|
+
currentUser: IUser;
|
|
35
|
+
portal: IPortal;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
6
39
|
*/
|
|
7
40
|
export interface IArcGISContextOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
41
|
+
id: number;
|
|
42
|
+
portalUrl: string;
|
|
43
|
+
hubUrl: string;
|
|
12
44
|
authentication?: UserSession;
|
|
13
|
-
|
|
14
|
-
* ArcGIS Online or ArcGIS Enterprise portal url.
|
|
15
|
-
* Do not include `/sharing/rest`
|
|
16
|
-
* Defaults to `https://www.arcgis.com`
|
|
17
|
-
* For ArcGIS Enterprise, you must include the webadaptor name.
|
|
18
|
-
* i.e. https://gis.mytown.gov/portal
|
|
19
|
-
*
|
|
20
|
-
* When Authentication is present, the UserSession.portal value is
|
|
21
|
-
* used instead of this property.
|
|
22
|
-
*/
|
|
23
|
-
portalUrl?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Portal self for the authenticated user. If not passed into `.create`
|
|
26
|
-
* with the UserSession, it will be fetched
|
|
27
|
-
*/
|
|
28
|
-
portal?: IPortal;
|
|
29
|
-
/**
|
|
30
|
-
* Current user as `IUser`. If not passed into `.create` with the UserSession
|
|
31
|
-
* it will be fetched.
|
|
32
|
-
*/
|
|
45
|
+
portalSelf?: IPortal;
|
|
33
46
|
currentUser?: IUser;
|
|
34
|
-
/**
|
|
35
|
-
* If set to `true` additional logging will be sent to the console
|
|
36
|
-
* Defaults to false.
|
|
37
|
-
*/
|
|
38
|
-
debug?: boolean;
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
41
|
-
*
|
|
49
|
+
* ArcGISContext
|
|
42
50
|
*
|
|
43
|
-
* Abstraction that
|
|
44
|
-
*
|
|
45
|
-
*
|
|
51
|
+
* Abstraction that holds a UserSession, along with
|
|
52
|
+
* getters to streamline access to various platform
|
|
53
|
+
* urls, and common constructs like IRequestOptions
|
|
46
54
|
*
|
|
47
|
-
*
|
|
55
|
+
* Thin class just used to enable getters
|
|
48
56
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
57
|
+
* This class should not be used by anything other than
|
|
58
|
+
* the ArcGISContextManager class
|
|
51
59
|
*/
|
|
52
|
-
export declare class ArcGISContext {
|
|
53
|
-
/**
|
|
54
|
-
* Random identifier useful for debugging issues
|
|
55
|
-
* where race-conditions can result in multiple
|
|
56
|
-
* contexts getting created
|
|
57
|
-
*/
|
|
60
|
+
export declare class ArcGISContext implements IArcGISContext {
|
|
58
61
|
id: number;
|
|
59
|
-
private _state;
|
|
60
62
|
private _authentication;
|
|
61
63
|
private _portalUrl;
|
|
62
64
|
private _hubUrl;
|
|
63
65
|
private _portalSelf;
|
|
64
66
|
private _currentUser;
|
|
65
|
-
|
|
67
|
+
constructor(opts: IArcGISContextOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Return the UserSession if authenticated
|
|
70
|
+
*/
|
|
71
|
+
get session(): UserSession;
|
|
66
72
|
/**
|
|
67
|
-
*
|
|
68
|
-
* instantiate an instance
|
|
69
|
-
* @param opts
|
|
73
|
+
* Return boolean indicating if authenticatio is present
|
|
70
74
|
*/
|
|
71
|
-
|
|
75
|
+
get isAuthenticated(): boolean;
|
|
72
76
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
77
|
+
* Return `IUserRequestOptions`, which is used for REST-JS
|
|
78
|
+
* functions which require authentication information.
|
|
79
|
+
*
|
|
80
|
+
* If context is not authenticated, this function will throw
|
|
76
81
|
*/
|
|
77
|
-
|
|
82
|
+
get userRequestOptions(): IUserRequestOptions;
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
84
|
+
* Return `IRequestOptions`, which is used by REST-JS functions
|
|
85
|
+
* which *may* use authentication information if provided.
|
|
86
|
+
*
|
|
87
|
+
* If context is not authenticated, this function just returns
|
|
88
|
+
* the `portal` property, which informs REST-JS what Sharing API
|
|
89
|
+
* instance to use (i.e. AGO, Enterprise etc)
|
|
90
|
+
*/
|
|
91
|
+
get requestOptions(): IRequestOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Return a `IHubRequestOptions` object
|
|
94
|
+
*/
|
|
95
|
+
get hubRequestOptions(): IHubRequestOptions;
|
|
96
|
+
/**
|
|
97
|
+
* Return the portal url.
|
|
98
|
+
*
|
|
99
|
+
* If authenticated @ ArcGIS Online, it will return
|
|
100
|
+
* the https://org.env.arcgis.com
|
|
101
|
+
*
|
|
102
|
+
* If authenticated @ ArcGIS Enterprise, it will return
|
|
103
|
+
* https://portalHostname, which includes the web adaptor
|
|
83
104
|
*/
|
|
84
|
-
|
|
105
|
+
get portalUrl(): string;
|
|
85
106
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* the application continues running
|
|
107
|
+
* Returns the url to the sharing api
|
|
108
|
+
* i.e. https://myorg.maps.arcgis.com/sharing/rest
|
|
89
109
|
*/
|
|
90
|
-
|
|
110
|
+
get sharingApiUrl(): string;
|
|
111
|
+
get hubUrl(): string;
|
|
91
112
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* called, the state will be re-created. This is done so frameworks
|
|
95
|
-
* like React or Ember can detect changes.
|
|
113
|
+
* Returns boolean indicating if the backing system
|
|
114
|
+
* is ArcGIS Enterprise (formerly ArcGIS Portal) or not
|
|
96
115
|
*/
|
|
97
|
-
get
|
|
116
|
+
get isPortal(): boolean;
|
|
117
|
+
get discussionsServiceUrl(): string;
|
|
118
|
+
get hubSearchServiceUrl(): string;
|
|
119
|
+
get domainServiceUrl(): string;
|
|
120
|
+
get eventsConfig(): any;
|
|
98
121
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
122
|
+
* Returns boolean indicating if the current user
|
|
123
|
+
* belongs to an organization that has licensed
|
|
124
|
+
* ArcGIS Hub
|
|
102
125
|
*/
|
|
103
|
-
|
|
126
|
+
get hubEnabled(): boolean;
|
|
104
127
|
/**
|
|
105
|
-
*
|
|
106
|
-
* store that along with current user
|
|
128
|
+
* Return Hub Community Org Id, if defined
|
|
107
129
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
get communityOrgId(): string;
|
|
131
|
+
get communityOrgHostname(): string;
|
|
132
|
+
get communityOrgUrl(): string;
|
|
133
|
+
get helperServices(): any;
|
|
134
|
+
get currentUser(): IUser;
|
|
135
|
+
get portal(): IPortal;
|
|
110
136
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { IPortal } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { IUser, UserSession } from "@esri/arcgis-rest-auth";
|
|
3
|
+
import { IArcGISContext } from "./ArcGISContext";
|
|
4
|
+
import { Level } from ".";
|
|
5
|
+
/**
|
|
6
|
+
* Options that can be passed into `ArcGISContextManager.create`
|
|
7
|
+
*/
|
|
8
|
+
export interface IArcGISContextManagerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Existing user session, which may be created from Identity Manager
|
|
11
|
+
* `const session = UserSession.fromCredential(idMgr.getCredential());`
|
|
12
|
+
*/
|
|
13
|
+
authentication?: UserSession;
|
|
14
|
+
/**
|
|
15
|
+
* ArcGIS Online or ArcGIS Enterprise portal url.
|
|
16
|
+
* Do not include `/sharing/rest`
|
|
17
|
+
* Defaults to `https://www.arcgis.com`
|
|
18
|
+
* For ArcGIS Enterprise, you must include the webadaptor name.
|
|
19
|
+
* i.e. https://gis.mytown.gov/portal
|
|
20
|
+
*
|
|
21
|
+
* When Authentication is present, the UserSession.portal value is
|
|
22
|
+
* used instead of this property.
|
|
23
|
+
*/
|
|
24
|
+
portalUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Portal self for the authenticated user. If not passed into `.create`
|
|
27
|
+
* with the UserSession, it will be fetched
|
|
28
|
+
*/
|
|
29
|
+
portal?: IPortal;
|
|
30
|
+
/**
|
|
31
|
+
* Current user as `IUser`. If not passed into `.create` with the UserSession
|
|
32
|
+
* it will be fetched.
|
|
33
|
+
*/
|
|
34
|
+
currentUser?: IUser;
|
|
35
|
+
/**
|
|
36
|
+
* Logging level
|
|
37
|
+
* off > error > warn > info > debug > all
|
|
38
|
+
* defaults to 'error'
|
|
39
|
+
*/
|
|
40
|
+
logLevel?: Level;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* ArcGIS Context Manager
|
|
44
|
+
*
|
|
45
|
+
* The manager exposes context (`IArcGISContext`), which combines a `UserSession` with
|
|
46
|
+
* the `portal/self` and `user/self` responses to provide a central lookup for platform
|
|
47
|
+
* information, api urls, and other useful properties for developers such as IRequestOptions
|
|
48
|
+
* IUserRequestOptions, IHubRequestOptions etc.
|
|
49
|
+
*
|
|
50
|
+
* The context is exposed on gthe `.context` property, and as the authentication changes
|
|
51
|
+
* the `.context` is re-created. This is done to allow web frameworks to watch for
|
|
52
|
+
* changes on that single property, instead of having to leverage observers or events
|
|
53
|
+
* for change detection.
|
|
54
|
+
*
|
|
55
|
+
* This is a work-in-progress, and will likely expand over time.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export declare class ArcGISContextManager {
|
|
59
|
+
/**
|
|
60
|
+
* Random identifier useful for debugging issues
|
|
61
|
+
* where race-conditions can result in multiple
|
|
62
|
+
* contexts getting created
|
|
63
|
+
*/
|
|
64
|
+
id: number;
|
|
65
|
+
private _context;
|
|
66
|
+
private _authentication;
|
|
67
|
+
private _portalUrl;
|
|
68
|
+
private _hubUrl;
|
|
69
|
+
private _portalSelf;
|
|
70
|
+
private _currentUser;
|
|
71
|
+
private _logLevel;
|
|
72
|
+
/**
|
|
73
|
+
* Private constructor. Use `ArcGISContextManager.create(...)` to
|
|
74
|
+
* instantiate an instance
|
|
75
|
+
* @param opts
|
|
76
|
+
*/
|
|
77
|
+
private constructor();
|
|
78
|
+
/**
|
|
79
|
+
* Static async Factory
|
|
80
|
+
* @param opts
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
static create(opts?: IArcGISContextManagerOptions): Promise<ArcGISContextManager>;
|
|
84
|
+
/**
|
|
85
|
+
* Set the Authentication (UserSession) for the context.
|
|
86
|
+
* This should be called when a user signs into a running
|
|
87
|
+
* application.
|
|
88
|
+
* @param auth
|
|
89
|
+
*/
|
|
90
|
+
setAuthentication(auth: UserSession): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear the Authentication (UserSession). This should be
|
|
93
|
+
* called when a user signs out of an application, but
|
|
94
|
+
* the application continues running
|
|
95
|
+
*/
|
|
96
|
+
clearAuthentication(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Return a reference to the current state.
|
|
99
|
+
* When `.setAuthentication()` or `.clearAuthenentication()` are
|
|
100
|
+
* called, the state will be re-created. This is done so frameworks
|
|
101
|
+
* like React or Ember can detect changes.
|
|
102
|
+
*/
|
|
103
|
+
get context(): IArcGISContext;
|
|
104
|
+
/**
|
|
105
|
+
* If we have a UserSession, fetch portal/self and
|
|
106
|
+
* store that along with current user
|
|
107
|
+
*/
|
|
108
|
+
private initialize;
|
|
109
|
+
/**
|
|
110
|
+
* Getter to streamline the creation of updated Context instances
|
|
111
|
+
*/
|
|
112
|
+
private get contextOpts();
|
|
113
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./utils";
|
|
|
18
18
|
export * from "./i18n";
|
|
19
19
|
export * from "./request";
|
|
20
20
|
export * from "./surveys";
|
|
21
|
+
export * from "./ArcGISContextManager";
|
|
21
22
|
export * from "./ArcGISContext";
|
|
22
23
|
import OperationStack from "./OperationStack";
|
|
23
24
|
import OperationError from "./OperationError";
|
|
@@ -104,7 +104,7 @@ export declare function getNextFunction<T>(request: ISearchOptions, nextStart: n
|
|
|
104
104
|
* Construct a the full url to a group thumbnail
|
|
105
105
|
*
|
|
106
106
|
* - If the group has a thumbnail, construct the full url
|
|
107
|
-
* - If the group is not public, append on the token
|
|
107
|
+
* - If the group is not public, append on the token (if passed in)
|
|
108
108
|
* @param portalUrl
|
|
109
109
|
* @param group
|
|
110
110
|
* @param token
|
|
@@ -13,6 +13,8 @@ export * from "./get-item-home-url";
|
|
|
13
13
|
export * from "./get-item-api-url";
|
|
14
14
|
export * from "./get-item-data-url";
|
|
15
15
|
export * from "./convert-urls-to-anchor-tags";
|
|
16
|
+
export * from "./getHubApiFromPortalUrl";
|
|
17
|
+
export * from "./getPortalBaseFromOrgUrl";
|
|
16
18
|
/**
|
|
17
19
|
*
|
|
18
20
|
* @param url
|