@esri/hub-common 9.25.0 → 9.25.3
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/_fetch.js +16 -3
- package/dist/es2017/content/_fetch.js.map +1 -1
- package/dist/es2017/content/_internal.js +7 -17
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +11 -15
- package/dist/es2017/content/compose.js.map +1 -1
- package/dist/es2017/content/fetch.js +27 -23
- package/dist/es2017/content/fetch.js.map +1 -1
- package/dist/es2017/items/_enrichments.js +29 -14
- package/dist/es2017/items/_enrichments.js.map +1 -1
- package/dist/es2017/search/utils.js +3 -0
- package/dist/es2017/search/utils.js.map +1 -1
- package/dist/es2017/utils/_array.js +13 -0
- package/dist/es2017/utils/_array.js.map +1 -0
- package/dist/esm/content/_fetch.js +14 -3
- package/dist/esm/content/_fetch.js.map +1 -1
- package/dist/esm/content/_internal.js +7 -17
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +12 -14
- package/dist/esm/content/compose.js.map +1 -1
- package/dist/esm/content/fetch.js +40 -31
- package/dist/esm/content/fetch.js.map +1 -1
- package/dist/esm/items/_enrichments.js +29 -14
- package/dist/esm/items/_enrichments.js.map +1 -1
- package/dist/esm/search/utils.js +3 -0
- package/dist/esm/search/utils.js.map +1 -1
- package/dist/esm/utils/_array.js +13 -0
- package/dist/esm/utils/_array.js.map +1 -0
- package/dist/node/content/_fetch.js +16 -3
- package/dist/node/content/_fetch.js.map +1 -1
- package/dist/node/content/_internal.js +8 -18
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +10 -14
- package/dist/node/content/compose.js.map +1 -1
- package/dist/node/content/fetch.js +27 -23
- package/dist/node/content/fetch.js.map +1 -1
- package/dist/node/items/_enrichments.js +30 -15
- package/dist/node/items/_enrichments.js.map +1 -1
- package/dist/node/search/utils.js +3 -0
- package/dist/node/search/utils.js.map +1 -1
- package/dist/node/utils/_array.js +16 -0
- package/dist/node/utils/_array.js.map +1 -0
- package/dist/types/content/_fetch.d.ts +9 -4
- package/dist/types/content/_internal.d.ts +0 -8
- package/dist/types/items/_enrichments.d.ts +10 -1
- package/dist/types/utils/_array.d.ts +9 -0
- package/dist/umd/common.umd.js +116 -79
- 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.25.2 - Wed Mar 30 2022 22:05:13 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -6588,23 +6588,12 @@
|
|
|
6588
6588
|
}
|
|
6589
6589
|
return date && precision && { date: date, precision: precision };
|
|
6590
6590
|
}
|
|
6591
|
-
/**
|
|
6592
|
-
* Get the spatial reference from layer or server info
|
|
6593
|
-
* @param server
|
|
6594
|
-
* @param layer
|
|
6595
|
-
* @returns
|
|
6596
|
-
* @private
|
|
6597
|
-
*/
|
|
6598
|
-
var getServerSpatialReference = function (server, layer) {
|
|
6599
|
-
var _a;
|
|
6600
|
-
var layerSpatialReference = (_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference;
|
|
6601
|
-
return layerSpatialReference || (server === null || server === void 0 ? void 0 : server.spatialReference);
|
|
6602
|
-
};
|
|
6603
6591
|
// NOTE: IItem has spatialRefernce: ISpatialReference, but
|
|
6604
6592
|
// the portal REST API returns spatialReference as as string
|
|
6605
|
-
// that is always either WKID like "102100" or
|
|
6606
|
-
// WKT like "NAD_1983_HARN_StatePlane_Hawaii_3_FIPS_5103_Feet"
|
|
6607
|
-
//
|
|
6593
|
+
// that is always either WKID like "102100" or the name of a
|
|
6594
|
+
// WKT like "NAD_1983_HARN_StatePlane_Hawaii_3_FIPS_5103_Feet".
|
|
6595
|
+
// We only coerce WKIDs into a ISpatialReference objects since we
|
|
6596
|
+
// can't easily lookup a complete WKT.
|
|
6608
6597
|
/**
|
|
6609
6598
|
* Get the spatial reference as an object for an item
|
|
6610
6599
|
* @param item
|
|
@@ -6622,8 +6611,9 @@
|
|
|
6622
6611
|
var spatialReferenceString = spatialReference + "";
|
|
6623
6612
|
var wkid = parseInt(spatialReferenceString, 10);
|
|
6624
6613
|
return isNaN(wkid)
|
|
6625
|
-
? //
|
|
6626
|
-
|
|
6614
|
+
? // It looks like the portal api returns the name of a WKT, but we'd
|
|
6615
|
+
// need to perform a lookup to get the full WKT. Return null for now.
|
|
6616
|
+
null
|
|
6627
6617
|
: //
|
|
6628
6618
|
{ wkid: wkid };
|
|
6629
6619
|
};
|
|
@@ -7487,7 +7477,7 @@
|
|
|
7487
7477
|
return name;
|
|
7488
7478
|
},
|
|
7489
7479
|
get description() {
|
|
7490
|
-
return
|
|
7480
|
+
return _layerDescription || item.description;
|
|
7491
7481
|
}, type: type, get family() {
|
|
7492
7482
|
return getFamily(type);
|
|
7493
7483
|
}, get url() {
|
|
@@ -7534,12 +7524,11 @@
|
|
|
7534
7524
|
return boundary || getContentBoundary(item);
|
|
7535
7525
|
},
|
|
7536
7526
|
get summary() {
|
|
7537
|
-
return
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
item.snippet || item.description;
|
|
7527
|
+
return (searchDescription ||
|
|
7528
|
+
// TODO: this should use the logic for the Hub API's searchDescription
|
|
7529
|
+
// see: https://github.com/ArcGIS/hub-indexer/blob/b352cfded8221a967ac80447879d493db6476d7a/packages/duke/compose/dataset.js#L238-L250
|
|
7530
|
+
item.snippet ||
|
|
7531
|
+
item.description);
|
|
7543
7532
|
}, urls: urls, get portalHomeUrl() {
|
|
7544
7533
|
return urls.portalHome;
|
|
7545
7534
|
},
|
|
@@ -7602,14 +7591,13 @@
|
|
|
7602
7591
|
// TODO: is metrics in use?
|
|
7603
7592
|
get metrics() {
|
|
7604
7593
|
return item.properties && item.properties.metrics;
|
|
7605
|
-
},
|
|
7606
|
-
|
|
7594
|
+
}, get spatialReference() {
|
|
7595
|
+
var _a;
|
|
7607
7596
|
// NOTE: I had to add || null just so packages/content/test/portal.test.ts would pass
|
|
7608
7597
|
// we can remove that when that package is deprecated
|
|
7609
|
-
return (getItemSpatialReference(item) ||
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
}, get viewDefinition() {
|
|
7598
|
+
return (((_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference) || getItemSpatialReference(item) || null);
|
|
7599
|
+
},
|
|
7600
|
+
get viewDefinition() {
|
|
7613
7601
|
// if this is a layer view and we have the item data
|
|
7614
7602
|
// find the definition that corresponds to the current layer
|
|
7615
7603
|
var dataLayer = layer &&
|
|
@@ -8755,29 +8743,44 @@
|
|
|
8755
8743
|
var handleEnrichmentError = function (error, input, opId) {
|
|
8756
8744
|
var data = input.data, stack = input.stack, requestOptions = input.requestOptions;
|
|
8757
8745
|
stack.finish(opId, { error: error });
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
:
|
|
8762
|
-
|
|
8763
|
-
errors.push({
|
|
8764
|
-
// NOTE: for now we just return the message and type "Other"
|
|
8765
|
-
// but we could later introspect for HTTP or AGO errors
|
|
8766
|
-
// and/or return the status code if available
|
|
8767
|
-
type: "Other",
|
|
8768
|
-
message: message,
|
|
8769
|
-
});
|
|
8770
|
-
return { data: __assign(__assign({}, data), { errors: errors }), stack: stack, requestOptions: requestOptions };
|
|
8746
|
+
return {
|
|
8747
|
+
data: __assign(__assign({}, data), { errors: getEnrichmentErrors(error, data.errors) }),
|
|
8748
|
+
stack: stack,
|
|
8749
|
+
requestOptions: requestOptions,
|
|
8750
|
+
};
|
|
8771
8751
|
};
|
|
8772
8752
|
var enrichmentOperations = {
|
|
8773
8753
|
groupIds: enrichGroupIds,
|
|
8774
8754
|
metadata: enrichMetadata,
|
|
8775
8755
|
ownerUser: enrichOwnerUser,
|
|
8776
|
-
// TOOD: org
|
|
8777
8756
|
data: enrichData,
|
|
8778
8757
|
server: enrichServer,
|
|
8779
8758
|
layers: enrichLayers,
|
|
8780
8759
|
};
|
|
8760
|
+
/**
|
|
8761
|
+
* convert an error to an enrichment error info format
|
|
8762
|
+
* and optionally append it to an existing array of those
|
|
8763
|
+
* @param error
|
|
8764
|
+
* @param errors an array of existing enrichment error info
|
|
8765
|
+
* @returns a new array of enrichment error info
|
|
8766
|
+
* @private
|
|
8767
|
+
*/
|
|
8768
|
+
var getEnrichmentErrors = function (error, errors) {
|
|
8769
|
+
if (errors === void 0) { errors = []; }
|
|
8770
|
+
var message = typeof error === "string"
|
|
8771
|
+
? /* istanbul ignore next our tests only throw Error objects */
|
|
8772
|
+
error
|
|
8773
|
+
: error.message;
|
|
8774
|
+
return __spreadArrays(errors, [
|
|
8775
|
+
{
|
|
8776
|
+
// NOTE: for now we just return the message and type "Other"
|
|
8777
|
+
// but we could later introspect for HTTP or AGO errors
|
|
8778
|
+
// and/or return the status code if available
|
|
8779
|
+
type: "Other",
|
|
8780
|
+
message: message,
|
|
8781
|
+
},
|
|
8782
|
+
]);
|
|
8783
|
+
};
|
|
8781
8784
|
/**
|
|
8782
8785
|
* Fetch enrichments for an item
|
|
8783
8786
|
* @param item
|
|
@@ -8803,6 +8806,19 @@
|
|
|
8803
8806
|
}).then(function (output) { return output.data; });
|
|
8804
8807
|
};
|
|
8805
8808
|
|
|
8809
|
+
/**
|
|
8810
|
+
* concat an array of arrays
|
|
8811
|
+
* excluding any elements of the top level array
|
|
8812
|
+
* that are not actually arrays
|
|
8813
|
+
* @param arrays An array of arrays
|
|
8814
|
+
* @returns concatenated array
|
|
8815
|
+
* @private
|
|
8816
|
+
*/
|
|
8817
|
+
var maybeConcat = function (arrays) {
|
|
8818
|
+
var result = [].concat.apply([], arrays.filter(Array.isArray));
|
|
8819
|
+
return result.length ? result : undefined;
|
|
8820
|
+
};
|
|
8821
|
+
|
|
8806
8822
|
/**
|
|
8807
8823
|
* remote server error
|
|
8808
8824
|
*/
|
|
@@ -8906,7 +8922,9 @@
|
|
|
8906
8922
|
// that we fetch from the Hub API, and to optionally filter by slug
|
|
8907
8923
|
var getHubEnrichmentsOptions = function (requestOptions, slug) {
|
|
8908
8924
|
var opts = cloneObject$1(requestOptions);
|
|
8909
|
-
opts.params = __assign(__assign({}, opts.params), {
|
|
8925
|
+
opts.params = __assign(__assign({}, opts.params), {
|
|
8926
|
+
// TODO: we should fetch errors too
|
|
8927
|
+
"fields[datasets]": "slug,boundary,extent,searchDescription,statistics" });
|
|
8910
8928
|
if (slug) {
|
|
8911
8929
|
opts.params["filter[slug]"] = slug;
|
|
8912
8930
|
}
|
|
@@ -8953,13 +8971,21 @@
|
|
|
8953
8971
|
* @private
|
|
8954
8972
|
*/
|
|
8955
8973
|
var fetchHubEnrichmentsById = function (hubId, requestOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8956
|
-
var response;
|
|
8974
|
+
var response, e_1;
|
|
8957
8975
|
return __generator(this, function (_a) {
|
|
8958
8976
|
switch (_a.label) {
|
|
8959
|
-
case 0:
|
|
8977
|
+
case 0:
|
|
8978
|
+
_a.trys.push([0, 2, , 3]);
|
|
8979
|
+
return [4 /*yield*/, hubApiRequest("/datasets/" + hubId, getHubEnrichmentsOptions(requestOptions))];
|
|
8960
8980
|
case 1:
|
|
8961
8981
|
response = _a.sent();
|
|
8962
8982
|
return [2 /*return*/, getDatasetEnrichments(response.data)];
|
|
8983
|
+
case 2:
|
|
8984
|
+
e_1 = _a.sent();
|
|
8985
|
+
// dataset record not found, just log the error
|
|
8986
|
+
// b/c we can still look up the item and enrichments by id
|
|
8987
|
+
return [2 /*return*/, { errors: getEnrichmentErrors(e_1) }];
|
|
8988
|
+
case 3: return [2 /*return*/];
|
|
8963
8989
|
}
|
|
8964
8990
|
});
|
|
8965
8991
|
}); };
|
|
@@ -8990,8 +9016,9 @@
|
|
|
8990
9016
|
_b.label = 3;
|
|
8991
9017
|
case 3:
|
|
8992
9018
|
layerEnrichments = _a;
|
|
8993
|
-
|
|
8994
|
-
|
|
9019
|
+
return [2 /*return*/, __assign(__assign(__assign({}, itemAndEnrichments), layerEnrichments), {
|
|
9020
|
+
// merge error arrays
|
|
9021
|
+
errors: maybeConcat([itemAndEnrichments.errors, layerEnrichments === null || layerEnrichments === void 0 ? void 0 : layerEnrichments.errors]) })];
|
|
8995
9022
|
}
|
|
8996
9023
|
});
|
|
8997
9024
|
}); };
|
|
@@ -9011,62 +9038,69 @@
|
|
|
9011
9038
|
});
|
|
9012
9039
|
}); };
|
|
9013
9040
|
var fetchContentById = function (hubId, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9014
|
-
var itemId, _a, item, itemEnrichments, specifiedLayerId,
|
|
9015
|
-
return __generator(this, function (
|
|
9016
|
-
switch (
|
|
9041
|
+
var itemId, _a, item, itemEnrichments, specifiedLayerId, hubEnrichments, _b, layerId;
|
|
9042
|
+
return __generator(this, function (_c) {
|
|
9043
|
+
switch (_c.label) {
|
|
9017
9044
|
case 0:
|
|
9018
9045
|
itemId = parseDatasetId(hubId).itemId;
|
|
9019
9046
|
return [4 /*yield*/, fetchItemAndEnrichments(itemId, options)];
|
|
9020
9047
|
case 1:
|
|
9021
|
-
_a =
|
|
9048
|
+
_a = _c.sent(), item = _a.item, itemEnrichments = __rest(_a, ["item"]);
|
|
9022
9049
|
specifiedLayerId = options && options.layerId;
|
|
9023
9050
|
if (!canUseHubApiForItem(item, options)) return [3 /*break*/, 3];
|
|
9024
9051
|
return [4 /*yield*/, fetchHubEnrichmentsById(hubId, options)];
|
|
9025
9052
|
case 2:
|
|
9026
|
-
|
|
9053
|
+
_b = _c.sent();
|
|
9027
9054
|
return [3 /*break*/, 4];
|
|
9028
9055
|
case 3:
|
|
9029
|
-
|
|
9030
|
-
|
|
9056
|
+
_b = {};
|
|
9057
|
+
_c.label = 4;
|
|
9031
9058
|
case 4:
|
|
9032
|
-
|
|
9059
|
+
hubEnrichments = _b;
|
|
9060
|
+
layerId = hubEnrichments.layerId;
|
|
9033
9061
|
// return a new content object composed from the item and enrichments we fetched
|
|
9034
|
-
return [2 /*return*/, composeContent(item, __assign(__assign({ requestOptions: options }, itemEnrichments),
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9062
|
+
return [2 /*return*/, composeContent(item, __assign(__assign(__assign({ requestOptions: options }, itemEnrichments), hubEnrichments), {
|
|
9063
|
+
// prefer specified layer id if any
|
|
9064
|
+
layerId: isNil(specifiedLayerId) ? layerId : specifiedLayerId,
|
|
9065
|
+
// merge error arrays
|
|
9066
|
+
errors: maybeConcat([itemEnrichments.errors, hubEnrichments.errors]) }))];
|
|
9038
9067
|
}
|
|
9039
9068
|
});
|
|
9040
9069
|
}); };
|
|
9041
9070
|
var fetchContentBySlug = function (fullyQualifiedSlug, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9042
|
-
var hubEnrichments, itemId, layerId, _a, item, itemEnrichments, specifiedLayerId,
|
|
9043
|
-
return __generator(this, function (
|
|
9044
|
-
switch (
|
|
9071
|
+
var hubEnrichments, itemId, layerId, _a, item, itemEnrichments, specifiedLayerId, _b;
|
|
9072
|
+
return __generator(this, function (_c) {
|
|
9073
|
+
switch (_c.label) {
|
|
9045
9074
|
case 0: return [4 /*yield*/, fetchHubEnrichmentsBySlug(fullyQualifiedSlug, options)];
|
|
9046
9075
|
case 1:
|
|
9047
|
-
hubEnrichments =
|
|
9076
|
+
hubEnrichments = _c.sent();
|
|
9048
9077
|
itemId = hubEnrichments.itemId;
|
|
9049
9078
|
layerId = hubEnrichments.layerId;
|
|
9050
9079
|
return [4 /*yield*/, fetchItemAndEnrichments(itemId, options)];
|
|
9051
9080
|
case 2:
|
|
9052
|
-
_a =
|
|
9081
|
+
_a = _c.sent(), item = _a.item, itemEnrichments = __rest(_a, ["item"]);
|
|
9053
9082
|
specifiedLayerId = options && options.layerId;
|
|
9054
9083
|
if (!(!isNil(specifiedLayerId) && specifiedLayerId !== layerId)) return [3 /*break*/, 4];
|
|
9055
|
-
// we fetched Hub enrichments by slug for another
|
|
9056
|
-
// most likely for the parent service of this layer,
|
|
9057
|
-
// we need to fetch them for the specified layer instead
|
|
9084
|
+
// we fetched Hub enrichments by slug for another record,
|
|
9085
|
+
// most likely the record for the parent service of this layer,
|
|
9086
|
+
// so we need to fetch them for the specified layer instead
|
|
9058
9087
|
layerId = specifiedLayerId;
|
|
9088
|
+
_b = [__assign({}, hubEnrichments)];
|
|
9059
9089
|
return [4 /*yield*/, fetchHubEnrichmentsById(itemId + "_" + layerId, options)];
|
|
9060
9090
|
case 3:
|
|
9061
|
-
hubEnrichments = _b.sent();
|
|
9062
|
-
|
|
9063
|
-
case 4:
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9091
|
+
hubEnrichments = __assign.apply(void 0, _b.concat([(_c.sent())]));
|
|
9092
|
+
_c.label = 4;
|
|
9093
|
+
case 4: return [2 /*return*/, composeContent(item, __assign(__assign(__assign({ requestOptions: options }, itemEnrichments), hubEnrichments), { layerId: layerId,
|
|
9094
|
+
// Note that we are not extracting the slug for the specified layer.
|
|
9095
|
+
// It seems that the old client composer code always populated the slug
|
|
9096
|
+
// field with the slug that was passed into the function (typically the
|
|
9097
|
+
// slug of the parent service). To maintain parity, we do the same here.
|
|
9098
|
+
//
|
|
9099
|
+
// TODO: should we prefer the slug of the fetched layer instead?
|
|
9100
|
+
// return a new content object composed from the item and enrichments we fetched
|
|
9101
|
+
slug: fullyQualifiedSlug,
|
|
9102
|
+
// merge error arrays
|
|
9103
|
+
errors: maybeConcat([itemEnrichments.errors, hubEnrichments.errors]) }))];
|
|
9070
9104
|
}
|
|
9071
9105
|
});
|
|
9072
9106
|
}); };
|
|
@@ -11638,6 +11672,9 @@
|
|
|
11638
11672
|
break;
|
|
11639
11673
|
case "months":
|
|
11640
11674
|
// get the current month and subtract num
|
|
11675
|
+
// NOTE: when the previous month has fewer days than this month
|
|
11676
|
+
// setMonth() will return a date w/in the current month
|
|
11677
|
+
// example: 3/30 -> 3/2 b/c there is no 2/28
|
|
11641
11678
|
now.setMonth(now.getMonth() - relative.num);
|
|
11642
11679
|
result.from = now.getTime();
|
|
11643
11680
|
break;
|