@esri/hub-common 9.13.0 → 9.14.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/ArcGISContext.js +66 -106
- package/dist/es2017/ArcGISContext.js.map +1 -1
- package/dist/es2017/ArcGISContextManager.js +163 -0
- package/dist/es2017/ArcGISContextManager.js.map +1 -0
- package/dist/es2017/content/index.js +12 -3
- package/dist/es2017/content/index.js.map +1 -1
- 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 +66 -139
- package/dist/esm/ArcGISContext.js.map +1 -1
- package/dist/esm/ArcGISContextManager.js +207 -0
- package/dist/esm/ArcGISContextManager.js.map +1 -0
- package/dist/esm/content/index.js +12 -3
- package/dist/esm/content/index.js.map +1 -1
- 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 +66 -106
- package/dist/node/ArcGISContext.js.map +1 -1
- package/dist/node/ArcGISContextManager.js +167 -0
- package/dist/node/ArcGISContextManager.js.map +1 -0
- package/dist/node/content/index.js +12 -3
- package/dist/node/content/index.js.map +1 -1
- 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 +211 -54
- package/dist/types/ArcGISContextManager.d.ts +116 -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 +344 -153
- 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/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.
|
|
2
|
+
* @esri/hub-common - v9.14.0 - Mon Feb 07 2022 19:02:27 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -4976,6 +4976,52 @@
|
|
|
4976
4976
|
return content.replace("(", "<br/>(");
|
|
4977
4977
|
}
|
|
4978
4978
|
|
|
4979
|
+
/**
|
|
4980
|
+
* Cross-walk from a portalUrl to the corresponding Hub API Url
|
|
4981
|
+
*
|
|
4982
|
+
* If the passed url is not recognized, then this will return `undefined`
|
|
4983
|
+
* @param portalUrl
|
|
4984
|
+
* @returns
|
|
4985
|
+
*/
|
|
4986
|
+
function getHubApiFromPortalUrl(portalUrl) {
|
|
4987
|
+
var result;
|
|
4988
|
+
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
4989
|
+
result = "https://hubqa.arcgis.com";
|
|
4990
|
+
}
|
|
4991
|
+
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
4992
|
+
result = "https://hubdev.arcgis.com";
|
|
4993
|
+
}
|
|
4994
|
+
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
4995
|
+
result = "https://hub.arcgis.com";
|
|
4996
|
+
}
|
|
4997
|
+
return result;
|
|
4998
|
+
}
|
|
4999
|
+
|
|
5000
|
+
/**
|
|
5001
|
+
* Given an org url, get the portal base url
|
|
5002
|
+
*
|
|
5003
|
+
* i.e. https://myorg.maps.arcgis.com will return https://www.arcgis.com
|
|
5004
|
+
*
|
|
5005
|
+
* @param orgUrl
|
|
5006
|
+
* @returns
|
|
5007
|
+
*/
|
|
5008
|
+
function getPortalBaseFromOrgUrl(orgUrl) {
|
|
5009
|
+
var result = orgUrl;
|
|
5010
|
+
if (orgUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
5011
|
+
result = "https://qaext.arcgis.com";
|
|
5012
|
+
}
|
|
5013
|
+
else if (orgUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
5014
|
+
result = "https://devext.arcgis.com";
|
|
5015
|
+
}
|
|
5016
|
+
else {
|
|
5017
|
+
/* istanbul ignore else */
|
|
5018
|
+
if (orgUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
5019
|
+
result = "https://www.arcgis.com";
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
return result;
|
|
5023
|
+
}
|
|
5024
|
+
|
|
4979
5025
|
var MAP_OR_FEATURE_SERVER_URL_REGEX = /\/(map|feature)server/i;
|
|
4980
5026
|
/**
|
|
4981
5027
|
*
|
|
@@ -6384,12 +6430,15 @@
|
|
|
6384
6430
|
appbuilderExtension: "file",
|
|
6385
6431
|
appbuilderWidgetPackage: "widgets-source",
|
|
6386
6432
|
application: "web",
|
|
6433
|
+
applicationConfiguration: "app-gear",
|
|
6387
6434
|
arcgisProMap: "desktop",
|
|
6388
6435
|
cadDrawing: "file-cad",
|
|
6389
6436
|
cityEngineWebScene: "urban-model",
|
|
6390
6437
|
codeAttachment: "file-code",
|
|
6438
|
+
codeSample: "file-code",
|
|
6391
6439
|
colorSet: "palette",
|
|
6392
6440
|
contentCategorySet: "label",
|
|
6441
|
+
csv: "file-csv",
|
|
6393
6442
|
cSV: "file-csv",
|
|
6394
6443
|
cSVCollection: "file-csv",
|
|
6395
6444
|
dashboard: "dashboard",
|
|
@@ -6411,8 +6460,8 @@
|
|
|
6411
6460
|
geoprocessingService: "file",
|
|
6412
6461
|
globeLayer: "layers",
|
|
6413
6462
|
globeService: "file",
|
|
6414
|
-
hubInitiative: "
|
|
6415
|
-
hubInitiativeTemplate: "initiative-template
|
|
6463
|
+
hubInitiative: "initiative",
|
|
6464
|
+
hubInitiativeTemplate: "initiative-template",
|
|
6416
6465
|
hubPage: "browser",
|
|
6417
6466
|
hubSiteApplication: "web",
|
|
6418
6467
|
image: "file-image",
|
|
@@ -6428,6 +6477,7 @@
|
|
|
6428
6477
|
kMLCollection: "data",
|
|
6429
6478
|
layer: "layers",
|
|
6430
6479
|
layerPackage: "layers",
|
|
6480
|
+
layerTemplate: "file",
|
|
6431
6481
|
locatorPackage: "file",
|
|
6432
6482
|
mapArea: "file",
|
|
6433
6483
|
mapDocument: "map-contents",
|
|
@@ -6450,6 +6500,7 @@
|
|
|
6450
6500
|
orthoMappingTemplate: "file",
|
|
6451
6501
|
pDF: "file-pdf",
|
|
6452
6502
|
quickCaptureProject: "mobile",
|
|
6503
|
+
rasterFunctionTemplate: "file",
|
|
6453
6504
|
rasterLayer: "map",
|
|
6454
6505
|
realTimeAnalytic: "file",
|
|
6455
6506
|
relationalDatabaseConnection: "file",
|
|
@@ -6458,19 +6509,23 @@
|
|
|
6458
6509
|
sceneService: "urban-model",
|
|
6459
6510
|
serviceDefinition: "file",
|
|
6460
6511
|
shapefile: "data",
|
|
6461
|
-
solution: "
|
|
6512
|
+
solution: "puzzle-piece",
|
|
6462
6513
|
sqliteGeodatabase: "file",
|
|
6463
6514
|
statisticalDataCollection: "file",
|
|
6515
|
+
storymap: "tour",
|
|
6464
6516
|
storyMap: "tour",
|
|
6517
|
+
storymapTheme: "palette",
|
|
6465
6518
|
symbolSet: "file",
|
|
6466
6519
|
table: "table",
|
|
6467
6520
|
urbanModel: "urban-model",
|
|
6521
|
+
vectorTilePackage: "file-shape",
|
|
6468
6522
|
vectorTileService: "map",
|
|
6469
6523
|
visioDocument: "conditional-rules",
|
|
6470
6524
|
webExperience: "apps",
|
|
6471
6525
|
webMap: "map",
|
|
6472
6526
|
webMappingApplication: "apps",
|
|
6473
6527
|
webScene: "urban-model",
|
|
6528
|
+
wfs: "map",
|
|
6474
6529
|
wFS: "map",
|
|
6475
6530
|
wMS: "map",
|
|
6476
6531
|
wMTS: "map",
|
|
@@ -8793,7 +8848,7 @@
|
|
|
8793
8848
|
* Construct a the full url to a group thumbnail
|
|
8794
8849
|
*
|
|
8795
8850
|
* - If the group has a thumbnail, construct the full url
|
|
8796
|
-
* - If the group is not public, append on the token
|
|
8851
|
+
* - If the group is not public, append on the token (if passed in)
|
|
8797
8852
|
* @param portalUrl
|
|
8798
8853
|
* @param group
|
|
8799
8854
|
* @param token
|
|
@@ -9524,12 +9579,11 @@
|
|
|
9524
9579
|
return __generator(this, function (_b) {
|
|
9525
9580
|
expanded = expandContentFilter(filter);
|
|
9526
9581
|
api = expandApi(options.api || "arcgis");
|
|
9527
|
-
// map over the apis, depending on the type we issue the queries
|
|
9528
|
-
// const searchPromises = apis.map((api) => {
|
|
9529
9582
|
// Portal Search
|
|
9530
9583
|
if (api.type === "arcgis") {
|
|
9531
9584
|
so = serializeContentFilterForPortal(expanded);
|
|
9532
|
-
//
|
|
9585
|
+
// if we have auth, pass it forward
|
|
9586
|
+
// otherwise set the portal property
|
|
9533
9587
|
if (options.authentication) {
|
|
9534
9588
|
so.authentication = options.authentication;
|
|
9535
9589
|
}
|
|
@@ -9542,7 +9596,6 @@
|
|
|
9542
9596
|
so.countSize = 200;
|
|
9543
9597
|
}
|
|
9544
9598
|
// copy over various options
|
|
9545
|
-
// TODO: Dry this up - typscript makes this... inconvenient
|
|
9546
9599
|
if (options.num) {
|
|
9547
9600
|
so.num = options.num;
|
|
9548
9601
|
}
|
|
@@ -9569,8 +9622,6 @@
|
|
|
9569
9622
|
},
|
|
9570
9623
|
});
|
|
9571
9624
|
}
|
|
9572
|
-
// });
|
|
9573
|
-
// return for results
|
|
9574
9625
|
return [2 /*return*/, searchPromise];
|
|
9575
9626
|
});
|
|
9576
9627
|
});
|
|
@@ -9584,14 +9635,29 @@
|
|
|
9584
9635
|
* @returns
|
|
9585
9636
|
*/
|
|
9586
9637
|
function searchPortal(searchOptions) {
|
|
9638
|
+
var _a;
|
|
9639
|
+
var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
|
|
9640
|
+
var token;
|
|
9641
|
+
if (searchOptions.authentication) {
|
|
9642
|
+
var us = searchOptions.authentication;
|
|
9643
|
+
token = us.token;
|
|
9644
|
+
}
|
|
9645
|
+
var thumbnailify = function (content) {
|
|
9646
|
+
content.thumbnailUrl = getItemThumbnailUrl(content, portalUrl, token);
|
|
9647
|
+
return content;
|
|
9648
|
+
};
|
|
9587
9649
|
return searchItems(searchOptions).then(function (resp) {
|
|
9588
9650
|
var hasNext = resp.nextStart > -1;
|
|
9651
|
+
// convert items to IHubContent's
|
|
9589
9652
|
var content = resp.results.map(itemToContent);
|
|
9653
|
+
// if we have a site, add those urls
|
|
9590
9654
|
if (searchOptions.site) {
|
|
9591
9655
|
content = content.map(function (entry) {
|
|
9592
9656
|
return setContentSiteUrls(entry, searchOptions.site);
|
|
9593
9657
|
});
|
|
9594
9658
|
}
|
|
9659
|
+
// add thumbnailUrl
|
|
9660
|
+
content = content.map(thumbnailify);
|
|
9595
9661
|
// convert aggregations into facets
|
|
9596
9662
|
var facets = convertPortalResponseToFacets(resp);
|
|
9597
9663
|
return {
|
|
@@ -9613,10 +9679,9 @@
|
|
|
9613
9679
|
* @returns
|
|
9614
9680
|
*/
|
|
9615
9681
|
function _searchGroups(filter, options) {
|
|
9616
|
-
var _a;
|
|
9617
9682
|
return __awaiter(this, void 0, void 0, function () {
|
|
9618
9683
|
var expanded, api, so;
|
|
9619
|
-
return __generator(this, function (
|
|
9684
|
+
return __generator(this, function (_a) {
|
|
9620
9685
|
expanded = expandGroupFilter(filter);
|
|
9621
9686
|
api = expandApi(options.api || "arcgis");
|
|
9622
9687
|
if (api.type === "arcgis") {
|
|
@@ -9629,7 +9694,6 @@
|
|
|
9629
9694
|
else {
|
|
9630
9695
|
so.portal = api.url + "/sharing/rest";
|
|
9631
9696
|
}
|
|
9632
|
-
// TODO: Dry this up - typscript makes this... inconvenient
|
|
9633
9697
|
if (options.num) {
|
|
9634
9698
|
so.num = options.num;
|
|
9635
9699
|
}
|
|
@@ -9639,10 +9703,6 @@
|
|
|
9639
9703
|
if (options.sortOrder) {
|
|
9640
9704
|
so.sortOrder = options.sortOrder;
|
|
9641
9705
|
}
|
|
9642
|
-
api.url + "/sharing/rest";
|
|
9643
|
-
if ((_a = so.authentication) === null || _a === void 0 ? void 0 : _a.portal) {
|
|
9644
|
-
so.authentication.portal;
|
|
9645
|
-
}
|
|
9646
9706
|
if (options.site) {
|
|
9647
9707
|
so.site = cloneObject$1(options.site);
|
|
9648
9708
|
}
|
|
@@ -9665,8 +9725,7 @@
|
|
|
9665
9725
|
group.siteTeamUrl = searchOptions.site.item.url + "/teams/" + group.id + "/about";
|
|
9666
9726
|
return group;
|
|
9667
9727
|
};
|
|
9668
|
-
var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) ||
|
|
9669
|
-
"https://www.arcgis.com/sharing/rest";
|
|
9728
|
+
var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
|
|
9670
9729
|
var token;
|
|
9671
9730
|
if (searchOptions.authentication) {
|
|
9672
9731
|
var us = searchOptions.authentication;
|
|
@@ -10733,116 +10792,37 @@
|
|
|
10733
10792
|
discussions: "/api/discussions/v1",
|
|
10734
10793
|
};
|
|
10735
10794
|
/**
|
|
10736
|
-
*
|
|
10737
|
-
*
|
|
10738
|
-
*
|
|
10739
|
-
*
|
|
10740
|
-
* provide a central lookup of platform information.
|
|
10795
|
+
* Abstraction that holds a `UserSession`, along with
|
|
10796
|
+
* getters to streamline access to various platform
|
|
10797
|
+
* urls, and common constructs like `IRequestOptions`,
|
|
10798
|
+
* `IUserRequestOptions` etc.
|
|
10741
10799
|
*
|
|
10742
|
-
*
|
|
10800
|
+
* Instances are intended to be immutable, but this is not directly enforced.
|
|
10743
10801
|
*
|
|
10744
|
-
*
|
|
10745
|
-
*
|
|
10802
|
+
* In most circumstances, this class should be created by
|
|
10803
|
+
* the ArcGISContextManager class.
|
|
10746
10804
|
*/
|
|
10747
10805
|
var ArcGISContext = /** @class */ (function () {
|
|
10748
10806
|
/**
|
|
10749
|
-
*
|
|
10750
|
-
*
|
|
10807
|
+
* Create a new instance of `ArcGISContext`.
|
|
10808
|
+
*
|
|
10751
10809
|
* @param opts
|
|
10752
10810
|
*/
|
|
10753
10811
|
function ArcGISContext(opts) {
|
|
10754
10812
|
this._portalUrl = "https://www.arcgis.com";
|
|
10755
|
-
this.
|
|
10756
|
-
|
|
10757
|
-
this.
|
|
10758
|
-
if (opts.debug) {
|
|
10759
|
-
this._debug = opts.debug;
|
|
10760
|
-
}
|
|
10761
|
-
this.log("ArcGISContext:ctor: Creating " + this.id);
|
|
10813
|
+
this.id = opts.id;
|
|
10814
|
+
this._portalUrl = opts.portalUrl;
|
|
10815
|
+
this._hubUrl = opts.hubUrl;
|
|
10762
10816
|
if (opts.authentication) {
|
|
10763
10817
|
this._authentication = opts.authentication;
|
|
10764
|
-
this._portalUrl = this._authentication.portal.replace("/sharing/rest", "");
|
|
10765
|
-
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
10766
10818
|
}
|
|
10767
|
-
|
|
10768
|
-
this.
|
|
10769
|
-
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
10819
|
+
if (opts.portalSelf) {
|
|
10820
|
+
this._portalSelf = opts.portalSelf;
|
|
10770
10821
|
}
|
|
10771
|
-
|
|
10772
|
-
this.
|
|
10822
|
+
if (opts.currentUser) {
|
|
10823
|
+
this._currentUser = opts.currentUser;
|
|
10773
10824
|
}
|
|
10774
10825
|
}
|
|
10775
|
-
/**
|
|
10776
|
-
* Static async Factory
|
|
10777
|
-
* @param opts
|
|
10778
|
-
* @returns
|
|
10779
|
-
*/
|
|
10780
|
-
ArcGISContext.create = function (opts) {
|
|
10781
|
-
if (opts === void 0) { opts = {}; }
|
|
10782
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
10783
|
-
var ctx;
|
|
10784
|
-
return __generator(this, function (_a) {
|
|
10785
|
-
switch (_a.label) {
|
|
10786
|
-
case 0:
|
|
10787
|
-
ctx = new ArcGISContext(opts);
|
|
10788
|
-
return [4 /*yield*/, ctx.initialize()];
|
|
10789
|
-
case 1:
|
|
10790
|
-
_a.sent();
|
|
10791
|
-
return [2 /*return*/, ctx];
|
|
10792
|
-
}
|
|
10793
|
-
});
|
|
10794
|
-
});
|
|
10795
|
-
};
|
|
10796
|
-
/**
|
|
10797
|
-
* If we have a UserSession, fetch portal/self and
|
|
10798
|
-
* store that along with current user
|
|
10799
|
-
*/
|
|
10800
|
-
ArcGISContext.prototype.initialize = function () {
|
|
10801
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
10802
|
-
var ps;
|
|
10803
|
-
return __generator(this, function (_a) {
|
|
10804
|
-
switch (_a.label) {
|
|
10805
|
-
case 0:
|
|
10806
|
-
if (!this._authentication) return [3 /*break*/, 2];
|
|
10807
|
-
this.log("ArcGISContext-" + this.id + ": Initializing");
|
|
10808
|
-
return [4 /*yield*/, getSelf({ authentication: this._authentication })];
|
|
10809
|
-
case 1:
|
|
10810
|
-
ps = _a.sent();
|
|
10811
|
-
this._portalSelf = ps;
|
|
10812
|
-
this._currentUser = ps.user;
|
|
10813
|
-
_a.label = 2;
|
|
10814
|
-
case 2: return [2 /*return*/];
|
|
10815
|
-
}
|
|
10816
|
-
});
|
|
10817
|
-
});
|
|
10818
|
-
};
|
|
10819
|
-
// Set authentication after the instance is up and running
|
|
10820
|
-
ArcGISContext.prototype.setAuthentication = function (auth) {
|
|
10821
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
10822
|
-
return __generator(this, function (_a) {
|
|
10823
|
-
switch (_a.label) {
|
|
10824
|
-
case 0:
|
|
10825
|
-
this._authentication = auth;
|
|
10826
|
-
this._portalUrl = auth.portal.replace("/sharing/rest", "");
|
|
10827
|
-
return [4 /*yield*/, this.initialize()];
|
|
10828
|
-
case 1:
|
|
10829
|
-
_a.sent();
|
|
10830
|
-
return [2 /*return*/];
|
|
10831
|
-
}
|
|
10832
|
-
});
|
|
10833
|
-
});
|
|
10834
|
-
};
|
|
10835
|
-
/**
|
|
10836
|
-
* @internal
|
|
10837
|
-
* Log debugging messages to the console
|
|
10838
|
-
* @param message
|
|
10839
|
-
*/
|
|
10840
|
-
ArcGISContext.prototype.log = function (message) {
|
|
10841
|
-
if (this._debug) {
|
|
10842
|
-
// tslint:disable-next-line:no-console
|
|
10843
|
-
console.info(message);
|
|
10844
|
-
}
|
|
10845
|
-
};
|
|
10846
10826
|
Object.defineProperty(ArcGISContext.prototype, "session", {
|
|
10847
10827
|
/**
|
|
10848
10828
|
* Return the UserSession if authenticated
|
|
@@ -10911,28 +10891,27 @@
|
|
|
10911
10891
|
*/
|
|
10912
10892
|
get: function () {
|
|
10913
10893
|
// We may add more logic around what is returned in some corner cases
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10894
|
+
if (this.isAuthenticated) {
|
|
10895
|
+
return {
|
|
10896
|
+
authentication: this.session,
|
|
10897
|
+
isPortal: this.isPortal,
|
|
10898
|
+
portalSelf: this.portal,
|
|
10899
|
+
hubApiUrl: this.hubUrl,
|
|
10900
|
+
};
|
|
10901
|
+
}
|
|
10920
10902
|
},
|
|
10921
10903
|
enumerable: false,
|
|
10922
10904
|
configurable: true
|
|
10923
10905
|
});
|
|
10924
10906
|
Object.defineProperty(ArcGISContext.prototype, "portalUrl", {
|
|
10925
|
-
// ==============================
|
|
10926
|
-
// Getters / Computed Properties
|
|
10927
|
-
// ==============================
|
|
10928
10907
|
/**
|
|
10929
|
-
* Return the portal url.
|
|
10908
|
+
* Return the portal url i.e. https://www.arcgis.com
|
|
10930
10909
|
*
|
|
10931
10910
|
* If authenticated @ ArcGIS Online, it will return
|
|
10932
10911
|
* the https://org.env.arcgis.com
|
|
10933
10912
|
*
|
|
10934
10913
|
* If authenticated @ ArcGIS Enterprise, it will return
|
|
10935
|
-
* https://portalHostname
|
|
10914
|
+
* https://{portalHostname}/{webadaptor}
|
|
10936
10915
|
*/
|
|
10937
10916
|
get: function () {
|
|
10938
10917
|
if (this.isAuthenticated) {
|
|
@@ -10952,7 +10931,7 @@
|
|
|
10952
10931
|
});
|
|
10953
10932
|
Object.defineProperty(ArcGISContext.prototype, "sharingApiUrl", {
|
|
10954
10933
|
/**
|
|
10955
|
-
* Returns the url to the sharing api
|
|
10934
|
+
* Returns the url to the sharing api composed from portalUrl
|
|
10956
10935
|
* i.e. https://myorg.maps.arcgis.com/sharing/rest
|
|
10957
10936
|
*/
|
|
10958
10937
|
get: function () {
|
|
@@ -10962,6 +10941,11 @@
|
|
|
10962
10941
|
configurable: true
|
|
10963
10942
|
});
|
|
10964
10943
|
Object.defineProperty(ArcGISContext.prototype, "hubUrl", {
|
|
10944
|
+
/**
|
|
10945
|
+
* Returns the Hub url, based on the portalUrl
|
|
10946
|
+
*
|
|
10947
|
+
* For ArcGIS Enterprise this will return `undefined`
|
|
10948
|
+
*/
|
|
10965
10949
|
get: function () {
|
|
10966
10950
|
return this._hubUrl;
|
|
10967
10951
|
},
|
|
@@ -10982,9 +10966,9 @@
|
|
|
10982
10966
|
configurable: true
|
|
10983
10967
|
});
|
|
10984
10968
|
Object.defineProperty(ArcGISContext.prototype, "discussionsServiceUrl", {
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10969
|
+
/**
|
|
10970
|
+
* Returns the discussions API URL
|
|
10971
|
+
*/
|
|
10988
10972
|
get: function () {
|
|
10989
10973
|
if (this._hubUrl) {
|
|
10990
10974
|
return "" + this._hubUrl + hubApiEndpoints.discussions;
|
|
@@ -10994,7 +10978,9 @@
|
|
|
10994
10978
|
configurable: true
|
|
10995
10979
|
});
|
|
10996
10980
|
Object.defineProperty(ArcGISContext.prototype, "hubSearchServiceUrl", {
|
|
10997
|
-
|
|
10981
|
+
/**
|
|
10982
|
+
* Returns the Hub Search API URL
|
|
10983
|
+
*/
|
|
10998
10984
|
get: function () {
|
|
10999
10985
|
if (this._hubUrl) {
|
|
11000
10986
|
return "" + this._hubUrl + hubApiEndpoints.search;
|
|
@@ -11004,7 +10990,9 @@
|
|
|
11004
10990
|
configurable: true
|
|
11005
10991
|
});
|
|
11006
10992
|
Object.defineProperty(ArcGISContext.prototype, "domainServiceUrl", {
|
|
11007
|
-
|
|
10993
|
+
/**
|
|
10994
|
+
* Returns Hub Domain Service URL
|
|
10995
|
+
*/
|
|
11008
10996
|
get: function () {
|
|
11009
10997
|
if (this._hubUrl) {
|
|
11010
10998
|
return "" + this._hubUrl + hubApiEndpoints.domains;
|
|
@@ -11014,8 +11002,11 @@
|
|
|
11014
11002
|
configurable: true
|
|
11015
11003
|
});
|
|
11016
11004
|
Object.defineProperty(ArcGISContext.prototype, "eventsConfig", {
|
|
11017
|
-
|
|
11018
|
-
|
|
11005
|
+
/**
|
|
11006
|
+
* Returns the Events configuration object from portal/self
|
|
11007
|
+
*
|
|
11008
|
+
* `{serviceId: '3ef..', publicViewId: 'bc3...'}`
|
|
11009
|
+
*/
|
|
11019
11010
|
get: function () {
|
|
11020
11011
|
if (this._portalSelf) {
|
|
11021
11012
|
return getProp(this._portalSelf, "portalProperties.hub.settings.events");
|
|
@@ -11038,7 +11029,7 @@
|
|
|
11038
11029
|
});
|
|
11039
11030
|
Object.defineProperty(ArcGISContext.prototype, "communityOrgId", {
|
|
11040
11031
|
/**
|
|
11041
|
-
* Return Hub Community Org Id, if defined
|
|
11032
|
+
* Return the Hub Community Org Id, if defined
|
|
11042
11033
|
*/
|
|
11043
11034
|
get: function () {
|
|
11044
11035
|
if (this._portalSelf) {
|
|
@@ -11049,6 +11040,11 @@
|
|
|
11049
11040
|
configurable: true
|
|
11050
11041
|
});
|
|
11051
11042
|
Object.defineProperty(ArcGISContext.prototype, "communityOrgHostname", {
|
|
11043
|
+
/**
|
|
11044
|
+
* Returns the Hub Community Org Hostname, if defined
|
|
11045
|
+
*
|
|
11046
|
+
* i.e. c-org.maps.arcgis.com
|
|
11047
|
+
*/
|
|
11052
11048
|
get: function () {
|
|
11053
11049
|
if (this._portalSelf) {
|
|
11054
11050
|
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
|
|
@@ -11058,6 +11054,11 @@
|
|
|
11058
11054
|
configurable: true
|
|
11059
11055
|
});
|
|
11060
11056
|
Object.defineProperty(ArcGISContext.prototype, "communityOrgUrl", {
|
|
11057
|
+
/**
|
|
11058
|
+
* Returns the Hub Community Org url
|
|
11059
|
+
*
|
|
11060
|
+
* i.e. https://c-org.maps.arcgis.com
|
|
11061
|
+
*/
|
|
11061
11062
|
get: function () {
|
|
11062
11063
|
if (this.communityOrgHostname) {
|
|
11063
11064
|
return "https://" + this.communityOrgHostname;
|
|
@@ -11067,8 +11068,9 @@
|
|
|
11067
11068
|
configurable: true
|
|
11068
11069
|
});
|
|
11069
11070
|
Object.defineProperty(ArcGISContext.prototype, "helperServices", {
|
|
11070
|
-
|
|
11071
|
-
|
|
11071
|
+
/**
|
|
11072
|
+
* Returns the hash of helper services from portal self
|
|
11073
|
+
*/
|
|
11072
11074
|
get: function () {
|
|
11073
11075
|
if (this._portalSelf) {
|
|
11074
11076
|
return this._portalSelf.helperServices;
|
|
@@ -11078,6 +11080,9 @@
|
|
|
11078
11080
|
configurable: true
|
|
11079
11081
|
});
|
|
11080
11082
|
Object.defineProperty(ArcGISContext.prototype, "currentUser", {
|
|
11083
|
+
/**
|
|
11084
|
+
* Returns the current user as IUser
|
|
11085
|
+
*/
|
|
11081
11086
|
get: function () {
|
|
11082
11087
|
return this._currentUser;
|
|
11083
11088
|
},
|
|
@@ -11085,6 +11090,9 @@
|
|
|
11085
11090
|
configurable: true
|
|
11086
11091
|
});
|
|
11087
11092
|
Object.defineProperty(ArcGISContext.prototype, "portal", {
|
|
11093
|
+
/**
|
|
11094
|
+
* Returns the portal object as IPortal
|
|
11095
|
+
*/
|
|
11088
11096
|
get: function () {
|
|
11089
11097
|
return this._portalSelf;
|
|
11090
11098
|
},
|
|
@@ -11093,26 +11101,206 @@
|
|
|
11093
11101
|
});
|
|
11094
11102
|
return ArcGISContext;
|
|
11095
11103
|
}());
|
|
11104
|
+
|
|
11096
11105
|
/**
|
|
11097
|
-
*
|
|
11106
|
+
* The manager exposes context (`IArcGISContext`), which combines a `UserSession` with
|
|
11107
|
+
* the `portal/self` and `user/self` responses to provide a central lookup for platform
|
|
11108
|
+
* information, api urls, and other useful properties for developers such as IRequestOptions
|
|
11109
|
+
* IUserRequestOptions, IHubRequestOptions etc.
|
|
11110
|
+
*
|
|
11111
|
+
* The context is exposed on gthe `.context` property, and as the authentication changes
|
|
11112
|
+
* the `.context` is re-created. This is done to allow web frameworks to watch for
|
|
11113
|
+
* changes on that single property, instead of having to leverage observers or events
|
|
11114
|
+
* for change detection.
|
|
11115
|
+
*
|
|
11116
|
+
* Please see the [ArcGISContext Guide](/hub.js/guides/context) for additional information.
|
|
11098
11117
|
*
|
|
11099
|
-
* If the passed url is not recognized, then this will return `undefined`
|
|
11100
|
-
* @param portalUrl
|
|
11101
|
-
* @returns
|
|
11102
11118
|
*/
|
|
11103
|
-
function
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11119
|
+
var ArcGISContextManager = /** @class */ (function () {
|
|
11120
|
+
/**
|
|
11121
|
+
* Private constructor. Use `ArcGISContextManager.create(...)` to
|
|
11122
|
+
* instantiate an instance
|
|
11123
|
+
* @param opts
|
|
11124
|
+
*/
|
|
11125
|
+
function ArcGISContextManager(opts) {
|
|
11126
|
+
this._portalUrl = "https://www.arcgis.com";
|
|
11127
|
+
this._logLevel = exports.Level.error;
|
|
11128
|
+
// Having a unique id makes debugging easier
|
|
11129
|
+
this.id = new Date().getTime();
|
|
11130
|
+
if (opts.logLevel) {
|
|
11131
|
+
this._logLevel = opts.logLevel;
|
|
11132
|
+
}
|
|
11133
|
+
Logger.setLogLevel(this._logLevel);
|
|
11134
|
+
Logger.debug("ArcGISContextManager:ctor: Creating " + this.id);
|
|
11135
|
+
if (opts.authentication) {
|
|
11136
|
+
this._authentication = opts.authentication;
|
|
11137
|
+
this._portalUrl = this._authentication.portal.replace("/sharing/rest", "");
|
|
11138
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
11139
|
+
}
|
|
11140
|
+
else if (opts.portalUrl) {
|
|
11141
|
+
this._portalUrl = opts.portalUrl;
|
|
11142
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
11143
|
+
}
|
|
11144
|
+
else {
|
|
11145
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
11146
|
+
}
|
|
11147
|
+
if (opts.portal) {
|
|
11148
|
+
this._portalSelf = cloneObject$1(opts.portal);
|
|
11149
|
+
}
|
|
11150
|
+
if (opts.currentUser) {
|
|
11151
|
+
this._currentUser = cloneObject$1(opts.currentUser);
|
|
11152
|
+
}
|
|
11113
11153
|
}
|
|
11114
|
-
|
|
11115
|
-
|
|
11154
|
+
/**
|
|
11155
|
+
* Used to create a new instance of the ArcGISContext class.
|
|
11156
|
+
*
|
|
11157
|
+
* ```js
|
|
11158
|
+
* const ctxMgr = await ArcGISContextManager.create();
|
|
11159
|
+
* ```
|
|
11160
|
+
*
|
|
11161
|
+
* @param opts
|
|
11162
|
+
* @returns
|
|
11163
|
+
*/
|
|
11164
|
+
ArcGISContextManager.create = function (opts) {
|
|
11165
|
+
if (opts === void 0) { opts = {}; }
|
|
11166
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11167
|
+
var ctx;
|
|
11168
|
+
return __generator(this, function (_a) {
|
|
11169
|
+
switch (_a.label) {
|
|
11170
|
+
case 0:
|
|
11171
|
+
ctx = new ArcGISContextManager(opts);
|
|
11172
|
+
return [4 /*yield*/, ctx.initialize()];
|
|
11173
|
+
case 1:
|
|
11174
|
+
_a.sent();
|
|
11175
|
+
return [2 /*return*/, ctx];
|
|
11176
|
+
}
|
|
11177
|
+
});
|
|
11178
|
+
});
|
|
11179
|
+
};
|
|
11180
|
+
/**
|
|
11181
|
+
* Set the Authentication (UserSession) for the context.
|
|
11182
|
+
* This should be called when a user signs into a running
|
|
11183
|
+
* application.
|
|
11184
|
+
* @param auth
|
|
11185
|
+
*/
|
|
11186
|
+
ArcGISContextManager.prototype.setAuthentication = function (auth) {
|
|
11187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11188
|
+
return __generator(this, function (_a) {
|
|
11189
|
+
switch (_a.label) {
|
|
11190
|
+
case 0:
|
|
11191
|
+
this._authentication = auth;
|
|
11192
|
+
this._portalUrl = auth.portal.replace("/sharing/rest", "");
|
|
11193
|
+
return [4 /*yield*/, this.initialize()];
|
|
11194
|
+
case 1:
|
|
11195
|
+
_a.sent();
|
|
11196
|
+
return [2 /*return*/];
|
|
11197
|
+
}
|
|
11198
|
+
});
|
|
11199
|
+
});
|
|
11200
|
+
};
|
|
11201
|
+
/**
|
|
11202
|
+
* Clear the Authentication (UserSession). This should be
|
|
11203
|
+
* called when a user signs out of an application, but
|
|
11204
|
+
* the application continues running
|
|
11205
|
+
*/
|
|
11206
|
+
ArcGISContextManager.prototype.clearAuthentication = function () {
|
|
11207
|
+
// Reset the portalUrl from the org url to the base url
|
|
11208
|
+
// for ArcGIS Enterprise, we just leave the _portalUrl as-is
|
|
11209
|
+
if (!this._context.isPortal) {
|
|
11210
|
+
this._portalUrl = getPortalBaseFromOrgUrl(this._portalUrl);
|
|
11211
|
+
}
|
|
11212
|
+
// Clear the auth, portalSelf and currentUser props
|
|
11213
|
+
this._authentication = null;
|
|
11214
|
+
this._portalSelf = null;
|
|
11215
|
+
this._currentUser = null;
|
|
11216
|
+
this._context = new ArcGISContext({
|
|
11217
|
+
id: this.id,
|
|
11218
|
+
portalUrl: this._portalUrl,
|
|
11219
|
+
hubUrl: this._hubUrl,
|
|
11220
|
+
});
|
|
11221
|
+
};
|
|
11222
|
+
Object.defineProperty(ArcGISContextManager.prototype, "context", {
|
|
11223
|
+
/**
|
|
11224
|
+
* Return a reference to the current state.
|
|
11225
|
+
* When `.setAuthentication()` or `.clearAuthenentication()` are
|
|
11226
|
+
* called, the state will be re-created. This is done so frameworks
|
|
11227
|
+
* like React or Ember can detect changes.
|
|
11228
|
+
*/
|
|
11229
|
+
get: function () {
|
|
11230
|
+
return this._context;
|
|
11231
|
+
},
|
|
11232
|
+
enumerable: false,
|
|
11233
|
+
configurable: true
|
|
11234
|
+
});
|
|
11235
|
+
/**
|
|
11236
|
+
* If we have a UserSession, fetch portal/self and
|
|
11237
|
+
* store that along with current user
|
|
11238
|
+
*/
|
|
11239
|
+
ArcGISContextManager.prototype.initialize = function () {
|
|
11240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11241
|
+
var username, requests, _a, portal, user, ex_1, msg;
|
|
11242
|
+
return __generator(this, function (_b) {
|
|
11243
|
+
switch (_b.label) {
|
|
11244
|
+
case 0:
|
|
11245
|
+
if (!(this._authentication && (!this._portalSelf || !this._currentUser))) return [3 /*break*/, 4];
|
|
11246
|
+
Logger.debug("ArcGISContextManager-" + this.id + ": Initializing");
|
|
11247
|
+
username = this._authentication.username;
|
|
11248
|
+
requests = [
|
|
11249
|
+
getSelf({ authentication: this._authentication }),
|
|
11250
|
+
getUser({ username: username, authentication: this._authentication }),
|
|
11251
|
+
];
|
|
11252
|
+
_b.label = 1;
|
|
11253
|
+
case 1:
|
|
11254
|
+
_b.trys.push([1, 3, , 4]);
|
|
11255
|
+
return [4 /*yield*/, Promise.all(requests)];
|
|
11256
|
+
case 2:
|
|
11257
|
+
_a = _b.sent(), portal = _a[0], user = _a[1];
|
|
11258
|
+
this._portalSelf = portal;
|
|
11259
|
+
this._currentUser = user;
|
|
11260
|
+
Logger.debug("ArcGISContextManager-" + this.id + ": received portalSelf and currentUser");
|
|
11261
|
+
return [3 /*break*/, 4];
|
|
11262
|
+
case 3:
|
|
11263
|
+
ex_1 = _b.sent();
|
|
11264
|
+
msg = "ArcGISContextManager could not fetch portal & user for \"" + this._authentication.username + "\" using " + this._authentication.portal + ".";
|
|
11265
|
+
Logger.error(msg);
|
|
11266
|
+
// tslint:disable-next-line:no-console
|
|
11267
|
+
console.error(msg);
|
|
11268
|
+
throw ex_1;
|
|
11269
|
+
case 4:
|
|
11270
|
+
Logger.debug("ArcGISContextManager-" + this.id + ": updating context");
|
|
11271
|
+
// update the context
|
|
11272
|
+
this._context = new ArcGISContext(this.contextOpts);
|
|
11273
|
+
return [2 /*return*/];
|
|
11274
|
+
}
|
|
11275
|
+
});
|
|
11276
|
+
});
|
|
11277
|
+
};
|
|
11278
|
+
Object.defineProperty(ArcGISContextManager.prototype, "contextOpts", {
|
|
11279
|
+
/**
|
|
11280
|
+
* Getter to streamline the creation of updated Context instances
|
|
11281
|
+
*/
|
|
11282
|
+
get: function () {
|
|
11283
|
+
var contextOpts = {
|
|
11284
|
+
id: this.id,
|
|
11285
|
+
portalUrl: this._portalUrl,
|
|
11286
|
+
hubUrl: this._hubUrl,
|
|
11287
|
+
};
|
|
11288
|
+
if (this._authentication) {
|
|
11289
|
+
contextOpts.authentication = this._authentication;
|
|
11290
|
+
}
|
|
11291
|
+
if (this._portalSelf) {
|
|
11292
|
+
contextOpts.portalSelf = this._portalSelf;
|
|
11293
|
+
}
|
|
11294
|
+
if (this._currentUser) {
|
|
11295
|
+
contextOpts.currentUser = this._currentUser;
|
|
11296
|
+
}
|
|
11297
|
+
return contextOpts;
|
|
11298
|
+
},
|
|
11299
|
+
enumerable: false,
|
|
11300
|
+
configurable: true
|
|
11301
|
+
});
|
|
11302
|
+
return ArcGISContextManager;
|
|
11303
|
+
}());
|
|
11116
11304
|
|
|
11117
11305
|
/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.
|
|
11118
11306
|
* Apache-2.0 */
|
|
@@ -11374,6 +11562,7 @@
|
|
|
11374
11562
|
}
|
|
11375
11563
|
|
|
11376
11564
|
exports.ArcGISContext = ArcGISContext;
|
|
11565
|
+
exports.ArcGISContextManager = ArcGISContextManager;
|
|
11377
11566
|
exports.GLOBAL_EXTENT = GLOBAL_EXTENT;
|
|
11378
11567
|
exports.HUB_CDN_URLMAP = HUB_CDN_URLMAP;
|
|
11379
11568
|
exports.HUB_LOCALES = HUB_LOCALES;
|
|
@@ -11502,6 +11691,7 @@
|
|
|
11502
11691
|
exports.getFamily = getFamily;
|
|
11503
11692
|
exports.getGeographicOrgExtent = getGeographicOrgExtent;
|
|
11504
11693
|
exports.getGroupThumbnailUrl = getGroupThumbnailUrl;
|
|
11694
|
+
exports.getHubApiFromPortalUrl = getHubApiFromPortalUrl;
|
|
11505
11695
|
exports.getHubApiUrl = getHubApiUrl;
|
|
11506
11696
|
exports.getHubApiUrlFromPortal = getHubApiUrlFromPortal;
|
|
11507
11697
|
exports.getHubLocaleAssetUrl = getHubLocaleAssetUrl;
|
|
@@ -11522,6 +11712,7 @@
|
|
|
11522
11712
|
exports.getNextFunction = getNextFunction;
|
|
11523
11713
|
exports.getOrgExtentAsBBox = getOrgExtentAsBBox;
|
|
11524
11714
|
exports.getPortalApiUrl = getPortalApiUrl;
|
|
11715
|
+
exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
|
|
11525
11716
|
exports.getPortalUrl = getPortalUrl;
|
|
11526
11717
|
exports.getProp = getProp;
|
|
11527
11718
|
exports.getProps = getProps;
|