@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
package/package.json
CHANGED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { getProp, getWithDefault } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* Hash of Hub API end points so updates
|
|
4
|
-
* are centralized
|
|
5
|
-
*/
|
|
6
|
-
const hubApiEndpoints = {
|
|
7
|
-
domains: "/api/v3/domains",
|
|
8
|
-
search: "/api/v3/datasets",
|
|
9
|
-
discussions: "/api/discussions/v1",
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
* Thin class just used to enable getters
|
|
14
|
-
*
|
|
15
|
-
* This class should not be used by anything other than
|
|
16
|
-
* the ArcGISContext class
|
|
17
|
-
*/
|
|
18
|
-
export class ArcGISContextState {
|
|
19
|
-
constructor(opts) {
|
|
20
|
-
this._portalUrl = "https://www.arcgis.com";
|
|
21
|
-
this.id = opts.id;
|
|
22
|
-
this._portalUrl = opts.portalUrl;
|
|
23
|
-
this._hubUrl = opts.hubUrl;
|
|
24
|
-
if (opts.authentication) {
|
|
25
|
-
this._authentication = opts.authentication;
|
|
26
|
-
}
|
|
27
|
-
if (opts.portalSelf) {
|
|
28
|
-
this._portalSelf = opts.portalSelf;
|
|
29
|
-
}
|
|
30
|
-
if (opts.currentUser) {
|
|
31
|
-
this._currentUser = opts.currentUser;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Return the UserSession if authenticated
|
|
36
|
-
*/
|
|
37
|
-
get session() {
|
|
38
|
-
return this._authentication;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Return boolean indicating if authenticatio is present
|
|
42
|
-
*/
|
|
43
|
-
get isAuthenticated() {
|
|
44
|
-
return !!this._authentication;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Return `IUserRequestOptions`, which is used for REST-JS
|
|
48
|
-
* functions which require authentication information.
|
|
49
|
-
*
|
|
50
|
-
* If context is not authenticated, this function will throw
|
|
51
|
-
*/
|
|
52
|
-
get userRequestOptions() {
|
|
53
|
-
if (this.isAuthenticated) {
|
|
54
|
-
return {
|
|
55
|
-
authentication: this._authentication,
|
|
56
|
-
portal: this.sharingApiUrl,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Return `IRequestOptions`, which is used by REST-JS functions
|
|
62
|
-
* which *may* use authentication information if provided.
|
|
63
|
-
*
|
|
64
|
-
* If context is not authenticated, this function just returns
|
|
65
|
-
* the `portal` property, which informs REST-JS what Sharing API
|
|
66
|
-
* instance to use (i.e. AGO, Enterprise etc)
|
|
67
|
-
*/
|
|
68
|
-
get requestOptions() {
|
|
69
|
-
let ro = {
|
|
70
|
-
portal: this.sharingApiUrl,
|
|
71
|
-
};
|
|
72
|
-
if (this.isAuthenticated) {
|
|
73
|
-
ro = {
|
|
74
|
-
authentication: this._authentication,
|
|
75
|
-
portal: this.sharingApiUrl,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return ro;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Return a `IHubRequestOptions` object
|
|
82
|
-
*/
|
|
83
|
-
get hubRequestOptions() {
|
|
84
|
-
// We may add more logic around what is returned in some corner cases
|
|
85
|
-
return {
|
|
86
|
-
authentication: this.session,
|
|
87
|
-
isPortal: this.isPortal,
|
|
88
|
-
portalSelf: this.portal,
|
|
89
|
-
hubApiUrl: this.hubUrl,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
// ==============================
|
|
93
|
-
// Getters / Computed Properties
|
|
94
|
-
// ==============================
|
|
95
|
-
/**
|
|
96
|
-
* Return the portal url.
|
|
97
|
-
*
|
|
98
|
-
* If authenticated @ ArcGIS Online, it will return
|
|
99
|
-
* the https://org.env.arcgis.com
|
|
100
|
-
*
|
|
101
|
-
* If authenticated @ ArcGIS Enterprise, it will return
|
|
102
|
-
* https://portalHostname, which includes the web adaptor
|
|
103
|
-
*/
|
|
104
|
-
get portalUrl() {
|
|
105
|
-
if (this.isAuthenticated) {
|
|
106
|
-
if (this.isPortal) {
|
|
107
|
-
return `https://${this._portalSelf.portalHostname}`;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
return `https://${this._portalSelf.urlKey}.${this._portalSelf.customBaseUrl}`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return this._portalUrl;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Returns the url to the sharing api
|
|
119
|
-
* i.e. https://myorg.maps.arcgis.com/sharing/rest
|
|
120
|
-
*/
|
|
121
|
-
get sharingApiUrl() {
|
|
122
|
-
return `${this.portalUrl}/sharing/rest`;
|
|
123
|
-
}
|
|
124
|
-
get hubUrl() {
|
|
125
|
-
return this._hubUrl;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns boolean indicating if the backing system
|
|
129
|
-
* is ArcGIS Enterprise (formerly ArcGIS Portal) or not
|
|
130
|
-
*/
|
|
131
|
-
get isPortal() {
|
|
132
|
-
return this._portalSelf
|
|
133
|
-
? this._portalSelf.isPortal
|
|
134
|
-
: this._portalUrl.indexOf("arcgis.com") === -1;
|
|
135
|
-
}
|
|
136
|
-
// Hub APIs
|
|
137
|
-
// ----------
|
|
138
|
-
// Discussions
|
|
139
|
-
get discussionsServiceUrl() {
|
|
140
|
-
if (this._hubUrl) {
|
|
141
|
-
return `${this._hubUrl}${hubApiEndpoints.discussions}`;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// Hub Search
|
|
145
|
-
get hubSearchServiceUrl() {
|
|
146
|
-
if (this._hubUrl) {
|
|
147
|
-
return `${this._hubUrl}${hubApiEndpoints.search}`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// Domain
|
|
151
|
-
get domainServiceUrl() {
|
|
152
|
-
if (this._hubUrl) {
|
|
153
|
-
return `${this._hubUrl}${hubApiEndpoints.domains}`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// Events
|
|
157
|
-
// returns `{serviceId: '3ef..', publicViewId: 'bc3...'}
|
|
158
|
-
get eventsConfig() {
|
|
159
|
-
if (this._portalSelf) {
|
|
160
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.events");
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Returns boolean indicating if the current user
|
|
165
|
-
* belongs to an organization that has licensed
|
|
166
|
-
* ArcGIS Hub
|
|
167
|
-
*/
|
|
168
|
-
get hubEnabled() {
|
|
169
|
-
return getWithDefault(this._portalSelf, "portalProperties.hub.enabled", false);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Return Hub Community Org Id, if defined
|
|
173
|
-
*/
|
|
174
|
-
get communityOrgId() {
|
|
175
|
-
if (this._portalSelf) {
|
|
176
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.orgId");
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
get communityOrgHostname() {
|
|
180
|
-
if (this._portalSelf) {
|
|
181
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
get communityOrgUrl() {
|
|
185
|
-
if (this.communityOrgHostname) {
|
|
186
|
-
return `https://${this.communityOrgHostname}`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Platform API service urls are all in helperServices
|
|
190
|
-
// and not consistent to expose as urls
|
|
191
|
-
get helperServices() {
|
|
192
|
-
if (this._portalSelf) {
|
|
193
|
-
return this._portalSelf.helperServices;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
get currentUser() {
|
|
197
|
-
return this._currentUser;
|
|
198
|
-
}
|
|
199
|
-
get portal() {
|
|
200
|
-
return this._portalSelf;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=ArcGISContextState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArcGISContextState.js","sourceRoot":"","sources":["../../src/ArcGISContextState.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAsB,MAAM,GAAG,CAAC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AO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { getProp, getWithDefault } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* Hash of Hub API end points so updates
|
|
4
|
-
* are centralized
|
|
5
|
-
*/
|
|
6
|
-
var hubApiEndpoints = {
|
|
7
|
-
domains: "/api/v3/domains",
|
|
8
|
-
search: "/api/v3/datasets",
|
|
9
|
-
discussions: "/api/discussions/v1",
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
* Thin class just used to enable getters
|
|
14
|
-
*
|
|
15
|
-
* This class should not be used by anything other than
|
|
16
|
-
* the ArcGISContext class
|
|
17
|
-
*/
|
|
18
|
-
var ArcGISContextState = /** @class */ (function () {
|
|
19
|
-
function ArcGISContextState(opts) {
|
|
20
|
-
this._portalUrl = "https://www.arcgis.com";
|
|
21
|
-
this.id = opts.id;
|
|
22
|
-
this._portalUrl = opts.portalUrl;
|
|
23
|
-
this._hubUrl = opts.hubUrl;
|
|
24
|
-
if (opts.authentication) {
|
|
25
|
-
this._authentication = opts.authentication;
|
|
26
|
-
}
|
|
27
|
-
if (opts.portalSelf) {
|
|
28
|
-
this._portalSelf = opts.portalSelf;
|
|
29
|
-
}
|
|
30
|
-
if (opts.currentUser) {
|
|
31
|
-
this._currentUser = opts.currentUser;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(ArcGISContextState.prototype, "session", {
|
|
35
|
-
/**
|
|
36
|
-
* Return the UserSession if authenticated
|
|
37
|
-
*/
|
|
38
|
-
get: function () {
|
|
39
|
-
return this._authentication;
|
|
40
|
-
},
|
|
41
|
-
enumerable: false,
|
|
42
|
-
configurable: true
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(ArcGISContextState.prototype, "isAuthenticated", {
|
|
45
|
-
/**
|
|
46
|
-
* Return boolean indicating if authenticatio is present
|
|
47
|
-
*/
|
|
48
|
-
get: function () {
|
|
49
|
-
return !!this._authentication;
|
|
50
|
-
},
|
|
51
|
-
enumerable: false,
|
|
52
|
-
configurable: true
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(ArcGISContextState.prototype, "userRequestOptions", {
|
|
55
|
-
/**
|
|
56
|
-
* Return `IUserRequestOptions`, which is used for REST-JS
|
|
57
|
-
* functions which require authentication information.
|
|
58
|
-
*
|
|
59
|
-
* If context is not authenticated, this function will throw
|
|
60
|
-
*/
|
|
61
|
-
get: function () {
|
|
62
|
-
if (this.isAuthenticated) {
|
|
63
|
-
return {
|
|
64
|
-
authentication: this._authentication,
|
|
65
|
-
portal: this.sharingApiUrl,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
enumerable: false,
|
|
70
|
-
configurable: true
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(ArcGISContextState.prototype, "requestOptions", {
|
|
73
|
-
/**
|
|
74
|
-
* Return `IRequestOptions`, which is used by REST-JS functions
|
|
75
|
-
* which *may* use authentication information if provided.
|
|
76
|
-
*
|
|
77
|
-
* If context is not authenticated, this function just returns
|
|
78
|
-
* the `portal` property, which informs REST-JS what Sharing API
|
|
79
|
-
* instance to use (i.e. AGO, Enterprise etc)
|
|
80
|
-
*/
|
|
81
|
-
get: function () {
|
|
82
|
-
var ro = {
|
|
83
|
-
portal: this.sharingApiUrl,
|
|
84
|
-
};
|
|
85
|
-
if (this.isAuthenticated) {
|
|
86
|
-
ro = {
|
|
87
|
-
authentication: this._authentication,
|
|
88
|
-
portal: this.sharingApiUrl,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return ro;
|
|
92
|
-
},
|
|
93
|
-
enumerable: false,
|
|
94
|
-
configurable: true
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(ArcGISContextState.prototype, "hubRequestOptions", {
|
|
97
|
-
/**
|
|
98
|
-
* Return a `IHubRequestOptions` object
|
|
99
|
-
*/
|
|
100
|
-
get: function () {
|
|
101
|
-
// We may add more logic around what is returned in some corner cases
|
|
102
|
-
return {
|
|
103
|
-
authentication: this.session,
|
|
104
|
-
isPortal: this.isPortal,
|
|
105
|
-
portalSelf: this.portal,
|
|
106
|
-
hubApiUrl: this.hubUrl,
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
enumerable: false,
|
|
110
|
-
configurable: true
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(ArcGISContextState.prototype, "portalUrl", {
|
|
113
|
-
// ==============================
|
|
114
|
-
// Getters / Computed Properties
|
|
115
|
-
// ==============================
|
|
116
|
-
/**
|
|
117
|
-
* Return the portal url.
|
|
118
|
-
*
|
|
119
|
-
* If authenticated @ ArcGIS Online, it will return
|
|
120
|
-
* the https://org.env.arcgis.com
|
|
121
|
-
*
|
|
122
|
-
* If authenticated @ ArcGIS Enterprise, it will return
|
|
123
|
-
* https://portalHostname, which includes the web adaptor
|
|
124
|
-
*/
|
|
125
|
-
get: function () {
|
|
126
|
-
if (this.isAuthenticated) {
|
|
127
|
-
if (this.isPortal) {
|
|
128
|
-
return "https://" + this._portalSelf.portalHostname;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return "https://" + this._portalSelf.urlKey + "." + this._portalSelf.customBaseUrl;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return this._portalUrl;
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
enumerable: false,
|
|
139
|
-
configurable: true
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(ArcGISContextState.prototype, "sharingApiUrl", {
|
|
142
|
-
/**
|
|
143
|
-
* Returns the url to the sharing api
|
|
144
|
-
* i.e. https://myorg.maps.arcgis.com/sharing/rest
|
|
145
|
-
*/
|
|
146
|
-
get: function () {
|
|
147
|
-
return this.portalUrl + "/sharing/rest";
|
|
148
|
-
},
|
|
149
|
-
enumerable: false,
|
|
150
|
-
configurable: true
|
|
151
|
-
});
|
|
152
|
-
Object.defineProperty(ArcGISContextState.prototype, "hubUrl", {
|
|
153
|
-
get: function () {
|
|
154
|
-
return this._hubUrl;
|
|
155
|
-
},
|
|
156
|
-
enumerable: false,
|
|
157
|
-
configurable: true
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(ArcGISContextState.prototype, "isPortal", {
|
|
160
|
-
/**
|
|
161
|
-
* Returns boolean indicating if the backing system
|
|
162
|
-
* is ArcGIS Enterprise (formerly ArcGIS Portal) or not
|
|
163
|
-
*/
|
|
164
|
-
get: function () {
|
|
165
|
-
return this._portalSelf
|
|
166
|
-
? this._portalSelf.isPortal
|
|
167
|
-
: this._portalUrl.indexOf("arcgis.com") === -1;
|
|
168
|
-
},
|
|
169
|
-
enumerable: false,
|
|
170
|
-
configurable: true
|
|
171
|
-
});
|
|
172
|
-
Object.defineProperty(ArcGISContextState.prototype, "discussionsServiceUrl", {
|
|
173
|
-
// Hub APIs
|
|
174
|
-
// ----------
|
|
175
|
-
// Discussions
|
|
176
|
-
get: function () {
|
|
177
|
-
if (this._hubUrl) {
|
|
178
|
-
return "" + this._hubUrl + hubApiEndpoints.discussions;
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
enumerable: false,
|
|
182
|
-
configurable: true
|
|
183
|
-
});
|
|
184
|
-
Object.defineProperty(ArcGISContextState.prototype, "hubSearchServiceUrl", {
|
|
185
|
-
// Hub Search
|
|
186
|
-
get: function () {
|
|
187
|
-
if (this._hubUrl) {
|
|
188
|
-
return "" + this._hubUrl + hubApiEndpoints.search;
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
enumerable: false,
|
|
192
|
-
configurable: true
|
|
193
|
-
});
|
|
194
|
-
Object.defineProperty(ArcGISContextState.prototype, "domainServiceUrl", {
|
|
195
|
-
// Domain
|
|
196
|
-
get: function () {
|
|
197
|
-
if (this._hubUrl) {
|
|
198
|
-
return "" + this._hubUrl + hubApiEndpoints.domains;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
enumerable: false,
|
|
202
|
-
configurable: true
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(ArcGISContextState.prototype, "eventsConfig", {
|
|
205
|
-
// Events
|
|
206
|
-
// returns `{serviceId: '3ef..', publicViewId: 'bc3...'}
|
|
207
|
-
get: function () {
|
|
208
|
-
if (this._portalSelf) {
|
|
209
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.events");
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
enumerable: false,
|
|
213
|
-
configurable: true
|
|
214
|
-
});
|
|
215
|
-
Object.defineProperty(ArcGISContextState.prototype, "hubEnabled", {
|
|
216
|
-
/**
|
|
217
|
-
* Returns boolean indicating if the current user
|
|
218
|
-
* belongs to an organization that has licensed
|
|
219
|
-
* ArcGIS Hub
|
|
220
|
-
*/
|
|
221
|
-
get: function () {
|
|
222
|
-
return getWithDefault(this._portalSelf, "portalProperties.hub.enabled", false);
|
|
223
|
-
},
|
|
224
|
-
enumerable: false,
|
|
225
|
-
configurable: true
|
|
226
|
-
});
|
|
227
|
-
Object.defineProperty(ArcGISContextState.prototype, "communityOrgId", {
|
|
228
|
-
/**
|
|
229
|
-
* Return Hub Community Org Id, if defined
|
|
230
|
-
*/
|
|
231
|
-
get: function () {
|
|
232
|
-
if (this._portalSelf) {
|
|
233
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.orgId");
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
enumerable: false,
|
|
237
|
-
configurable: true
|
|
238
|
-
});
|
|
239
|
-
Object.defineProperty(ArcGISContextState.prototype, "communityOrgHostname", {
|
|
240
|
-
get: function () {
|
|
241
|
-
if (this._portalSelf) {
|
|
242
|
-
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
enumerable: false,
|
|
246
|
-
configurable: true
|
|
247
|
-
});
|
|
248
|
-
Object.defineProperty(ArcGISContextState.prototype, "communityOrgUrl", {
|
|
249
|
-
get: function () {
|
|
250
|
-
if (this.communityOrgHostname) {
|
|
251
|
-
return "https://" + this.communityOrgHostname;
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
enumerable: false,
|
|
255
|
-
configurable: true
|
|
256
|
-
});
|
|
257
|
-
Object.defineProperty(ArcGISContextState.prototype, "helperServices", {
|
|
258
|
-
// Platform API service urls are all in helperServices
|
|
259
|
-
// and not consistent to expose as urls
|
|
260
|
-
get: function () {
|
|
261
|
-
if (this._portalSelf) {
|
|
262
|
-
return this._portalSelf.helperServices;
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
enumerable: false,
|
|
266
|
-
configurable: true
|
|
267
|
-
});
|
|
268
|
-
Object.defineProperty(ArcGISContextState.prototype, "currentUser", {
|
|
269
|
-
get: function () {
|
|
270
|
-
return this._currentUser;
|
|
271
|
-
},
|
|
272
|
-
enumerable: false,
|
|
273
|
-
configurable: true
|
|
274
|
-
});
|
|
275
|
-
Object.defineProperty(ArcGISContextState.prototype, "portal", {
|
|
276
|
-
get: function () {
|
|
277
|
-
return this._portalSelf;
|
|
278
|
-
},
|
|
279
|
-
enumerable: false,
|
|
280
|
-
configurable: true
|
|
281
|
-
});
|
|
282
|
-
return ArcGISContextState;
|
|
283
|
-
}());
|
|
284
|
-
export { ArcGISContextState };
|
|
285
|
-
//# sourceMappingURL=ArcGISContextState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArcGISContextState.js","sourceRoot":"","sources":["../../src/ArcGISContextState.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAsB,MAAM,GAAG,CAAC;AAEhE;;;GAGG;AACH,IAAM,eAAe,GAAG;IACtB,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,kBAAkB;IAC1B,WAAW,EAAE,qBAAqB;CACnC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